spacemap 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +153 -5
- package/dist/spacemap.iife.js +58 -58
- package/dist/spacemap.js +58 -58
- package/index.d.ts +193 -3
- package/index.js +1799 -99
- package/package.json +1 -1
package/dist/spacemap.iife.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! spacemap SDK — https://spacemap.co — Mozilla Public License 2.0. Bundles MIT and ISC libraries: THIRD_PARTY_NOTICES.txt in the spacemap npm package. */
|
|
2
|
-
var spacemap=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=[`open`,`non-commercial`,`site-only`],n={dataUrl:`https://static.spacemap.co`,imagesUrl:`https://images.spacemap.co`,liveUrl:`https://live.spacemap.co`,locale:()=>`en`,messages:{body_note_no_model:()=>`no model available`,body_note_no_radius:()=>`no size data available`,carried_by_scene_label:({carrier:e})=>`Carried by ${e}`,scene_canvas_label:()=>`Interactive 3D map of the Solar System`,attribution_orbits:()=>`Orbits`,attribution_imagery:()=>`Imagery`,credits_see_all:()=>`See full credits`,layer_surface:()=>`Surface`,layer_clouds:()=>`Clouds`,layer_night:()=>`Night lights`,layer_graticule:()=>`Grid`,layer_nomenclature:()=>`Named features`,cooperative_wheel:()=>`Use ctrl + scroll to zoom the map`,cooperative_wheel_mac:()=>`Use ⌘ + scroll to zoom the map`,cooperative_touch:()=>`Use two fingers to move the map`},bodyHref:()=>``,textures:`open`},r=n;function i(e){let{messages:t,...i}=e;r={...n,...i},t&&(r.messages={...n.messages,...t}),r.dataUrl=r.dataUrl.replace(/\/$/,``),r.imagesUrl=r.imagesUrl.replace(/\/$/,``),r.liveUrl=r.liveUrl.replace(/\/$/,``)}function a(){return r}function o(e){if(e===void 0)return!0;let n=t.indexOf(e);return n<0?!1:n<=t.indexOf(r.textures)}function s(e){for(let t of e)if(t&&o(t.distribution))return t}function c(){return r.locale()}var l=Symbol(`uninitialized`),u=Array.isArray,d=Array.prototype.indexOf,f=Array.prototype.includes;Array.from;var p=Object.getOwnPropertyDescriptor,m=Object.prototype,h=Array.prototype,g=Object.getPrototypeOf,_=()=>{};function v(e){for(var t=0;t<e.length;t++)e[t]()}function y(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}var b=1024,x=2048,S=4096,C=8192,w=16384,T=32768,E=1<<25,D=65536,O=1<<19,k=1<<20,A=65536,j=1<<21,M=1<<23,ee=Symbol(`$state`),N=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"};globalThis.document?.contentType;function te(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function ne(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function re(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function P(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function ie(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function ae(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function F(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function I(){console.warn(`https://svelte.dev/e/derived_inert`)}function oe(e){return e===this.v}var se=!1,ce=!1,le=null;function ue(e){le=e}function de(){return!ce||le!==null&&le.l===null}var fe=[];function pe(){var e=fe;fe=[],v(e)}function me(e){if(fe.length===0&&!we){var t=fe;queueMicrotask(()=>{t===fe&&pe()})}fe.push(e)}function he(e){var t=wt;if(t===null)return xt.f|=M,e;if(!(t.f&32768)&&!(t.f&4))throw e;L(e,t)}function L(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 ge=~(x|S|b);function R(e,t){e.f=e.f&ge|t}function _e(e){e.f&512||e.deps===null?R(e,b):R(e,S)}function z(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=A,z(t.deps))}function ve(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),z(e.deps),R(e,b)}var B=!1,V=null,ye=null,be=null,xe=null,Se=null,Ce=null,we=!1,Te=!1,H=null,Ee=null,De=0,Oe=1,ke=class e{id=Oe++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;#r=new Set;#i=new Set;#a=0;#o=new Map;#s=null;#c=[];#l=[];#u=new Set;#d=new Set;#f=new Map;#p=new Set;is_fork=!1;#m=!1;constructor(){ye===null?V=ye=this:(ye.#n=this,this.#t=ye),ye=this}#h(){if(this.is_fork)return!0;for(let n of this.#o.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#f.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#f.has(e)||this.#f.set(e,{d:[],m:[]}),this.#p.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#f.get(e);if(n){this.#f.delete(e);for(var r of n.d)R(r,x),t(r);for(r of n.m)R(r,S),t(r)}this.#p.add(e)}#g(){this.#e=!0,De++>1e3&&(this.#S(),Ae());for(let e of this.#u)this.#d.delete(e),R(e,x),this.schedule(e);for(let e of this.#d)R(e,S),this.schedule(e);let t=this.#c;this.#c=[],this.apply();var n=H=[],r=[],i=Ee=[];for(let e of t)try{this.#_(e,n,r)}catch(t){throw Le(e),this.#h()||this.discard(),t}if(be=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(H=null,Ee=null,this.#h()){this.#b(r),this.#b(n);for(let[e,t]of this.#f)Ie(e,t);i.length>0&&be.#g();return}let o=this.#v();if(o){this.#b(r),this.#b(n),o.#y(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),xe=this,Me(r),Me(n),xe=null,this.#s?.resolve();var s=be;if(this.#a===0&&(this.#c.length===0||s!==null)&&(this.#S(),se&&(this.#x(),be=s)),this.#c.length>0)if(s!==null){let e=s;e.#c.push(...this.#c.filter(t=>!e.#c.includes(t)))}else s=this;s!==null&&s.#g()}#_(e,t,n){e.f^=b;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=b:i&4?t.push(r):se&&i&16777224?n.push(r):Lt(r)&&(i&16&&this.#d.add(r),Ht(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#v(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#y(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}this.transfer_effects(e.#u,e.#d);let t=e=>{var n=e.reactions;if(n!==null)for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#d.delete(i),R(i,x),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),be=this,this.#g()}#b(e){for(var t=0;t<e.length;t+=1)ve(e[t],this.#u,this.#d)}capture(e,t,n=!1){e.v!==l&&!this.previous.has(e)&&this.previous.set(e,e.v),e.f&8388608||(this.current.set(e,[t,n]),Se?.set(e,t)),this.is_fork||(e.v=t)}activate(){be=this}deactivate(){be=null,Se=null}flush(){try{Te=!0,be=this,this.#g()}finally{De=0,Ce=null,H=null,Ee=null,Te=!1,be=null,Se=null,We.clear()}}discard(){for(let e of this.#i)e(this);this.#i.clear(),this.#S(),this.#s?.resolve()}register_created_effect(e){this.#l.push(e)}#x(){for(let l=V;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).catch(n.reject)}if(l.#e){var r=[...l.current.keys()].filter(e=>!l.current.get(e)[1]&&!this.current.has(e));if(r.length===0)e&&l.discard();else if(t.length>0){if(e)for(let e of this.#p)l.unskip_effect(e,e=>{e.f&4194320?l.schedule(e):l.#b([e])});l.activate();var i=new Set,a=new Map;for(var o of t)Ne(o,r,i,a);a=new Map;var s=[...l.current].filter(([e,t])=>{let n=this.current.get(e);return n?n[0]!==t[0]||n[1]!==t[1]:!0}).map(([e])=>e);if(s.length>0)for(let e of this.#l)!(e.f&155648)&&Pe(e,s,a)&&(e.f&4194320?(R(e,x),l.schedule(e)):l.#u.add(e));if(l.#c.length>0&&!l.#m){l.apply();for(var c of l.#c)l.#_(c,[],[]);l.#c=[]}l.deactivate()}}}}increment(e,t){if(this.#a+=1,e){let e=this.#o.get(t)??0;this.#o.set(t,e+1)}}decrement(e,t){if(--this.#a,e){let e=this.#o.get(t)??0;e===1?this.#o.delete(t):this.#o.set(t,e-1)}this.#m||(this.#m=!0,me(()=>{this.#m=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#u.add(t);for(let e of t)this.#d.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}settled(){return(this.#s??=y()).promise}static ensure(){if(be===null){let t=be=new e;!Te&&!we&&me(()=>{t.#e||t.flush()})}return be}apply(){if(!se||!this.is_fork&&this.#t===null&&this.#n===null){Se=null;return}Se=new Map;for(let[e,[t]]of this.current)Se.set(e,t);for(let t=V;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)Se.has(e)||Se.set(e,n)}}schedule(e){if(Ce=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(H!==null&&t===wt&&(se||(xt===null||!(xt.f&2))&&!B))return;if(n&96){if(!(n&1024))return;t.f^=b}}this.#c.push(t)}#S(){if(this.linked){var e=this.#t,t=this.#n;e===null?V=t:e.#n=t,t===null?ye=e:t.#t=e,this.linked=!1}}};function Ae(){try{P()}catch(e){L(e,Ce)}}var je=null;function Me(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if(!(r.f&24576)&&Lt(r)&&(je=new Set,Ht(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&ht(r),je?.size>0)){We.clear();for(let e of je){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)je.has(n)&&(je.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Ht(n)}}je.clear()}}je=null}}function Ne(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?Ne(i,t,n,r):e&4194320&&!(e&2048)&&Pe(i,t,r)&&(R(i,x),Fe(i))}}function Pe(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(f.call(t,r))return!0;if(r.f&2&&Pe(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function Fe(e){be.schedule(e)}function Ie(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),R(e,b);for(var n=e.first;n!==null;)Ie(n,t),n=n.next}}function Le(e){R(e,b);for(var t=e.first;t!==null;)Le(t),t=t.next}D|O;function Re(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)pt(t[n])}}function ze(e){var t,n=wt,r=e.parent;if(!yt&&r!==null&&e.v!==l&&r.f&24576)return I(),e.v;Tt(r);try{e.f&=~A,Re(e),t=zt(e)}finally{Tt(n)}return t}function Be(e){var t=ze(e);if(!e.equals(t)&&(e.wv=It(),(!be?.is_fork||e.deps===null)&&(be===null?e.v=t:(be.capture(e,t,!0),xe?.capture(e,t,!0)),e.deps===null))){R(e,b);return}yt||(Se===null?_e(e):(ot()||be?.is_fork)&&Se.set(e,t))}function Ve(e){if(e.effects!==null)for(let t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),t.ac?.abort(N),t.fn!==null&&(t.teardown=_),t.ac=null,Vt(t,0),dt(t))}function He(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&Ht(t)}var Ue=new Set,We=new Map,Ge=!1;function Ke(e,t){return{f:0,v:e,reactions:null,equals:oe,rv:0,wv:0}}function qe(e,t){let n=Ke(e,t);return Dt(n),n}function Je(e,t,n=!1){return xt!==null&&(!St||xt.f&131072)&&de()&&xt.f&4325394&&(Et===null||!Et.has(e))&&F(),Ye(e,n?$e(t):t,Ee)}function Ye(e,t,n=null){if(!e.equals(t)){We.set(e,yt?t:e.v);var r=ke.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&ze(t),Se===null&&_e(t)}e.wv=It(),Qe(e,x,n),de()&&wt!==null&&wt.f&1024&&!(wt.f&96)&&(At===null?jt([e]):At.push(e)),!r.is_fork&&Ue.size>0&&!Ge&&Xe()}return t}function Xe(){Ge=!1;for(let e of Ue){e.f&1024&&R(e,S);let t;try{t=Lt(e)}catch{t=!0}t&&Ht(e)}Ue.clear()}function Ze(e){Je(e,e.v+1)}function Qe(e,t,n){var r=e.reactions;if(r!==null)for(var i=de(),a=r.length,o=0;o<a;o++){var s=r[o],c=s.f;if(!(!i&&s===wt)){var l=(c&x)===0;if(l&&R(s,t),c&131072)Ue.add(s);else if(c&2){var u=s;Se?.delete(u),c&65536||(c&512&&(wt===null||!(wt.f&2097152))&&(s.f|=A),Qe(u,S,n))}else if(l){var d=s;c&16&&je!==null&&je.add(d),n===null?Fe(d):n.push(d)}}}}function $e(e){if(typeof e!=`object`||!e||ee in e)return e;let t=g(e);if(t!==m&&t!==h)return e;var n=new Map,r=u(e),i=qe(0),a=null,o=Pt,s=e=>{if(Pt===o)return e();var t=xt,n=Pt;Ct(null),Ft(o);var r=e();return Ct(t),Ft(n),r};return r&&n.set(`length`,qe(e.length,a)),new Proxy(e,{defineProperty(e,t,r){(!(`value`in r)||r.configurable===!1||r.enumerable===!1||r.writable===!1)&&ie();var i=n.get(t);return i===void 0?s(()=>{var e=qe(r.value,a);return n.set(t,e),e}):Je(i,r.value,!0),!0},deleteProperty(e,t){var r=n.get(t);if(r===void 0){if(t in e){let e=s(()=>qe(l,a));n.set(t,e),Ze(i)}}else Je(r,l),Ze(i);return!0},get(t,r,i){if(r===ee)return e;var o=n.get(r),c=r in t;if(o===void 0&&(!c||p(t,r)?.writable)&&(o=s(()=>qe($e(c?t[r]:l),a)),n.set(r,o)),o!==void 0){var u=Ut(o);return u===l?void 0:u}return Reflect.get(t,r,i)},getOwnPropertyDescriptor(e,t){var r=Reflect.getOwnPropertyDescriptor(e,t);if(r&&`value`in r){var i=n.get(t);i&&(r.value=Ut(i))}else if(r===void 0){var a=n.get(t),o=a?.v;if(a!==void 0&&o!==l)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return r},has(e,t){if(t===ee)return!0;var r=n.get(t),i=r!==void 0&&r.v!==l||Reflect.has(e,t);return(r!==void 0||wt!==null&&(!i||p(e,t)?.writable))&&(r===void 0&&(r=s(()=>qe(i?$e(e[t]):l,a)),n.set(t,r)),Ut(r)===l)?!1:i},set(e,t,o,c){var u=n.get(t),d=t in e;if(r&&t===`length`)for(var f=o;f<u.v;f+=1){var m=n.get(f+``);m===void 0?f in e&&(m=s(()=>qe(l,a)),n.set(f+``,m)):Je(m,l)}if(u===void 0)(!d||p(e,t)?.writable)&&(u=s(()=>qe(void 0,a)),Je(u,$e(o)),n.set(t,u));else{d=u.v!==l;var h=s(()=>$e(o));Je(u,h)}var g=Reflect.getOwnPropertyDescriptor(e,t);if(g?.set&&g.set.call(c,o),!d){if(r&&typeof t==`string`){var _=n.get(`length`),v=Number(t);Number.isInteger(v)&&v>=_.v&&Je(_,v+1)}Ze(i)}return!0},ownKeys(e){Ut(i);var t=Reflect.ownKeys(e).filter(e=>{var t=n.get(e);return t===void 0||t.v!==l});for(var[r,a]of n)a.v!==l&&!(r in e)&&t.push(r);return t},setPrototypeOf(){ae()}})}var et;function tt(e){return et.call(e)}function nt(e){var t=xt,n=wt;Ct(null),Tt(null);try{return e()}finally{Ct(t),Tt(n)}}function rt(e){wt===null&&(xt===null&&re(e),ne()),yt&&te(e)}function it(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function at(e,t){var n=wt;n!==null&&n.f&8192&&(e|=C);var r={ctx:le,deps:null,nodes:null,f:e|x|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};be?.register_created_effect(r);var i=r;if(e&4)H===null?ke.ensure().schedule(r):H.push(r);else if(t!==null){try{Ht(r)}catch(e){throw pt(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&&it(i,n),xt!==null&&xt.f&2&&!(e&64))){var a=xt;(a.effects??=[]).push(i)}return r}function ot(){return xt!==null&&!St}function st(e){rt(`$effect`);var t=wt.f;if(!xt&&t&32&&le!==null&&!le.i){var n=le;(n.e??=[]).push(e)}else return ct(e)}function ct(e){return at(4|k,e)}function lt(e){ke.ensure();let t=at(64|O,e);return()=>{pt(t)}}function ut(e){var t=e.teardown;if(t!==null){let e=yt,n=xt;bt(!0),Ct(null);try{t.call(null)}finally{bt(e),Ct(n)}}}function dt(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&nt(()=>{e.abort(N)});var r=n.next;n.f&64?n.parent=null:pt(n,t),n=r}}function ft(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||pt(t),t=n}}function pt(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(mt(e.nodes.start,e.nodes.end),n=!0),e.f|=E,dt(e,t&&!n),Vt(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();ut(e),e.f^=E,e.f|=w;var i=e.parent;i!==null&&i.first!==null&&ht(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function mt(e,t){for(;e!==null;){var n=e===t?null:tt(e);e.remove(),e=n}}function ht(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 gt(e,t,n){if(!(e.f&8192)){e.f^=C;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;gt(i,t,o?n:!1)}i=a}}}var _t=null,vt=!1,yt=!1;function bt(e){yt=e}var xt=null,St=!1;function Ct(e){xt=e}var wt=null;function Tt(e){wt=e}var Et=null;function Dt(e){xt!==null&&(!se||xt.f&2)&&(Et??=new Set).add(e)}var Ot=null,kt=0,At=null;function jt(e){At=e}var Mt=1,Nt=0,Pt=Nt;function Ft(e){Pt=e}function It(){return++Mt}function Lt(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~A),t&4096){for(var n=e.deps,r=n.length,i=0;i<r;i++){var a=n[i];if(Lt(a)&&Be(a),a.wv>e.wv)return!0}t&512&&Se===null&&R(e,b)}return!1}function Rt(e,t,n=!0){var r=e.reactions;if(r!==null&&!(!se&&Et!==null&&Et.has(e)))for(var i=0;i<r.length;i++){var a=r[i];a.f&2?Rt(a,t,!1):t===a&&(n?R(a,x):a.f&1024&&R(a,S),Fe(a))}}function zt(e){var t=Ot,n=kt,r=At,i=xt,a=Et,o=le,s=St,c=Pt,l=e.f;Ot=null,kt=0,At=null,xt=l&96?null:e,Et=null,ue(e.ctx),St=!1,Pt=++Nt,e.ac!==null&&(nt(()=>{e.ac.abort(N)}),e.ac=null);try{e.f|=j;var u=e.fn,d=u();e.f|=T;var f=e.deps,p=be?.is_fork;if(Ot!==null){var m;if(p||Vt(e,kt),f!==null&&kt>0)for(f.length=kt+Ot.length,m=0;m<Ot.length;m++)f[kt+m]=Ot[m];else e.deps=f=Ot;if(ot()&&e.f&512)for(m=kt;m<f.length;m++)(f[m].reactions??=[]).push(e)}else !p&&f!==null&&kt<f.length&&(Vt(e,kt),f.length=kt);if(de()&&At!==null&&!St&&f!==null&&!(e.f&6146))for(m=0;m<At.length;m++)Rt(At[m],e);if(i!==null&&i!==e){if(Nt++,i.deps!==null)for(let e=0;e<n;e+=1)i.deps[e].rv=Nt;if(t!==null)for(let e of t)e.rv=Nt;At!==null&&(r===null?r=At:r.push(...At))}return e.f&8388608&&(e.f^=M),d}catch(e){return he(e)}finally{e.f^=j,Ot=t,kt=n,At=r,xt=i,Et=a,ue(o),St=s,Pt=c}}function Bt(e,t){let n=t.reactions;if(n!==null){var r=d.call(n,e);if(r!==-1){var i=n.length-1;i===0?n=t.reactions=null:(n[r]=n[i],n.pop())}}if(n===null&&t.f&2&&(Ot===null||!f.call(Ot,t))){var a=t;a.f&512&&(a.f^=512,a.f&=~A),a.v!==l&&_e(a),Ve(a),Vt(a,0)}}function Vt(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)Bt(e,n[r])}function Ht(e){var t=e.f;if(!(t&16384)){R(e,b);var n=wt,r=vt;wt=e,vt=!0;try{t&16777232?ft(e):dt(e),ut(e);var i=zt(e);e.teardown=typeof i==`function`?i:null,e.wv=Mt}finally{vt=r,wt=n}}}function Ut(e){var t=(e.f&2)!=0;if(_t?.add(e),xt!==null&&!St&&!(wt!==null&&wt.f&16384)&&(Et===null||!Et.has(e))){var n=xt.deps;if(xt.f&2097152)e.rv<Nt&&(e.rv=Nt,Ot===null&&n!==null&&n[kt]===e?kt++:Ot===null?Ot=[e]:Ot.push(e));else{xt.deps??=[],f.call(xt.deps,e)||xt.deps.push(e);var r=e.reactions;r===null?e.reactions=[xt]:f.call(r,xt)||r.push(xt)}}if(yt&&We.has(e))return We.get(e);if(t){var i=e;if(yt){var a=i.v;return(!(i.f&1024)&&i.reactions!==null||Gt(i))&&(a=ze(i)),We.set(i,a),a}var o=(i.f&512)==0&&!St&&xt!==null&&(vt||(xt.f&512)!=0),s=(i.f&T)===0;Lt(i)&&(o&&(i.f|=512),Be(i)),o&&!s&&(He(i),Wt(i))}if(Se?.has(e))return Se.get(e);if(e.f&8388608)throw e.v;return e.v}function Wt(e){if(e.f|=512,e.deps!==null)for(let t of e.deps)(t.reactions??=[]).push(e),t.f&2&&!(t.f&512)&&(He(t),Wt(t))}function Gt(e){if(e.v===l)return!0;if(e.deps===null)return!1;for(let t of e.deps)if(We.has(t)||t.f&2&&Gt(t))return!0;return!1}globalThis?.window?.trustedTypes,[...`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(`.`)];function Kt(){return a().dataUrl}var qt={};function Jt(e){qt=e??{}}function Yt(e,t){return Xt(Kt(),e,t)}function Xt(e,t,n){let r=qt[n];return r?`${e}${t}?v=${r}`:(console.error(`versionedUrl: missing '${n}' token for ${t}`),`${e}${t}`)}var Zt=32,Qt=e=>`${Kt()}/v1/labels/${e}.gz`;function $t(e){return e===null?``:`${e}/`}function en(e,t,n){return Yt(`/v1/position/${e}/${$t(t)}${n}.bin.gz`,`position`)}function tn(e,t,n,r){return Yt(`/v1/position/${e}/${$t(t)}${n}/${r}.bin.gz`,`position`)}function nn(e,t,n){return Yt(`/v1/position/${e}/${$t(t)}${n}.bin.gz`,`position`)}var rn=function(e){return e[e.PLANET=0]=`PLANET`,e[e.SYSTEM=1]=`SYSTEM`,e}({}),U=function(e){return e[e.HORIZONS=0]=`HORIZONS`,e[e.SBDB=1]=`SBDB`,e[e.CELESTRAK=2]=`CELESTRAK`,e[e.SPICE=3]=`SPICE`,e[e.SBDB_MOON=4]=`SBDB_MOON`,e[e.SPICE_PROBE=5]=`SPICE_PROBE`,e[e.SPACETRACK=6]=`SPACETRACK`,e[e.ASTERSAT=7]=`ASTERSAT`,e[e.UNKNOWN=255]=`UNKNOWN`,e}({}),an=function(e){return e[e.NAIF=0]=`NAIF`,e[e.SPKID=1]=`SPKID`,e[e.NORAD_SATCAT=2]=`NORAD_SATCAT`,e[e.PROBE=4]=`PROBE`,e[e.UNKNOWN=255]=`UNKNOWN`,e}({}),on={[an.NAIF]:`naif`,[an.SPKID]:`spkid`,[an.NORAD_SATCAT]:`norad_satcat`,[an.PROBE]:`probe`},sn=new Map(Object.entries(on).map(([e,t])=>[t,Number(e)]));function cn(e){return sn.get(e)}function ln(e,t){let n=on[e];return n?`${n}-${t}`:null}function un(e){return e.data.objectType===W.SURFACE_FEATURE}var W=function(e){return e[e.BARYCENTER=0]=`BARYCENTER`,e[e.LAGRANGE_POINT=1]=`LAGRANGE_POINT`,e[e.STAR=2]=`STAR`,e[e.PLANET=3]=`PLANET`,e[e.DWARF_PLANET=4]=`DWARF_PLANET`,e[e.MOON=5]=`MOON`,e[e.ASTEROID=6]=`ASTEROID`,e[e.ASTEROID_INNER=7]=`ASTEROID_INNER`,e[e.ASTEROID_MAIN_BELT=8]=`ASTEROID_MAIN_BELT`,e[e.ASTEROID_TROJAN=9]=`ASTEROID_TROJAN`,e[e.ASTEROID_CENTAUR=10]=`ASTEROID_CENTAUR`,e[e.ASTEROID_TNO=11]=`ASTEROID_TNO`,e[e.COMET=12]=`COMET`,e[e.SPACECRAFT=13]=`SPACECRAFT`,e[e.DEBRIS=14]=`DEBRIS`,e[e.UNDOCUMENTED=15]=`UNDOCUMENTED`,e[e.SURFACE_FEATURE=16]=`SURFACE_FEATURE`,e}({}),dn={IEO:{minA:0,maxA:.983},ATE:{minA:.5,maxA:1},APO:{minA:1,maxA:3.2},AMO:{minA:1,maxA:3.2},MCA:{minA:1.3,maxA:3.2},IMB:{minA:1.666,maxA:2},MBA:{minA:2,maxA:3.2},OMB:{minA:3.2,maxA:4.6},ETc:{minA:0,maxA:5.5},JFC:{minA:0,maxA:15},TJN:{minA:4.6,maxA:5.5},CEN:{minA:5.5,maxA:30.1},TNO:{minA:30.1,maxA:1/0},earth:{minA:0,maxA:3e-4}};function fn(e,t){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t))return null;let n=e*(1-t);return e*(1+t)<.983?`IEO`:e<1?`ATE`:n<1.017?`APO`:n<1.3?`AMO`:n<1.666&&e<3.2?`MCA`:e<2?`IMB`:e<3.2?`MBA`:e<4.6?`OMB`:e<5.5&&t<.3?`TJN`:e<30.1?`CEN`:`TNO`}var pn={[U.SPICE_PROBE]:.005,[U.SBDB_MOON]:.01,[U.ASTERSAT]:.01},mn={[W.SPACECRAFT]:.005,[W.DEBRIS]:.005,[W.SURFACE_FEATURE]:.001},hn=.1;function gn(e){return Number.isFinite(e.radiusKm)&&e.radiusKm>0?e.radiusKm:pn[e.orbitalSource]??mn[e.objectType]??hn}function _n(e){return e>=W.ASTEROID&&e<=W.ASTEROID_TNO}function vn(e){return e===W.STAR||e===W.PLANET||e===W.DWARF_PLANET||e===W.MOON}function yn(e){return vn(e)||_n(e)||e===W.COMET}var bn={[U.HORIZONS]:{archive:`horizons`,label:`NASA`},[U.SBDB]:{archive:`sbdb`,label:`NASA`},[U.SPICE]:{archive:`naif`,label:`NASA`},[U.SBDB_MOON]:{archive:`sbdb`,label:`NASA`,scoped:!0},[U.ASTERSAT]:{archive:`nsdb`,label:`Natural Satellites Data Base`,scoped:!0},[U.SPICE_PROBE]:{archive:`naif`,label:`NASA`},[U.CELESTRAK]:{archive:`celestrak`,label:`CelesTrak`,scoped:!0},[U.SPACETRACK]:{archive:`spacetrack`,label:`Space-Track.org`,scoped:!0}},xn=[U.HORIZONS,U.SBDB,U.SPICE,U.SBDB_MOON,U.ASTERSAT,U.SPICE_PROBE,U.CELESTRAK,U.SPACETRACK];function Sn(e){return bn[e]}var Cn=class{imagery=new Map;#e=qe(0);get imageryVersion(){return Ut(this.#e)}set imageryVersion(e){Je(this.#e,e,!0)}model=new Map;#t=qe(0);get modelVersion(){return Ut(this.#t)}set modelVersion(e){Je(this.#t,e,!0)}orientation=new Map;#n=qe(0);get orientationVersion(){return Ut(this.#n)}set orientationVersion(e){Je(this.#n,e,!0)}#r=qe(null);get skybox(){return Ut(this.#r)}set skybox(e){Je(this.#r,e,!0)}#i=qe($e(new Set));get orbitSources(){return Ut(this.#i)}set orbitSources(e){Je(this.#i,e,!0)}#a=qe($e(new Map));get orbitSourceParents(){return Ut(this.#a)}set orbitSourceParents(e){Je(this.#a,e,!0)}registerImagery(e,t,n,r){let i=e===`rings`?`${e}${t}${r.source}`:`${e}${t}`;if(this.imagery.has(i))return;let{source:a,organisation:o,license:s,attribution:c,description:l}=r;this.imagery.set(i,{layer:e,bodyId:t,systemId:n,source:a,organisation:o,license:s,attribution:c,description:l}),this.imageryVersion++}imageryOf(e){return[...this.imagery.values()].filter(t=>t.layer===e)}registerOrientation(e){this.orientation.has(e.bodyId)||(this.orientation.set(e.bodyId,e),this.orientationVersion++)}registerModel(e){this.model.has(e.bodyId)||(this.model.set(e.bodyId,e),this.modelVersion++)}recordOrbitSources(e){let t=!1,n=!1;for(let r of e){let e=r.data.orbitalSource;if(e===U.UNKNOWN||(this.orbitSources.has(e)||(this.orbitSources.add(e),t=!0),!Sn(e)?.scoped))continue;let i=this.orbitSourceParents.get(e);i||(i=new Set,this.orbitSourceParents.set(e,i)),!i.has(r.data.parentId)&&(i.add(r.data.parentId),n=!0)}t&&(this.orbitSources=new Set(this.orbitSources)),n&&(this.orbitSourceParents=new Map(this.orbitSourceParents))}recordOrbitSource(e){e===U.UNKNOWN||this.orbitSources.has(e)||(this.orbitSources.add(e),this.orbitSources=new Set(this.orbitSources))}},wn={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Tn={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},En=`attached`,Dn=1e3,On=1001,kn=1002,An=1003,jn=1004,Mn=1005,Nn=1006,Pn=1007,Fn=1008,In=1009,Ln=1010,Rn=1011,zn=1012,Bn=1013,Vn=1014,Hn=1015,Un=1016,Wn=1017,Gn=1018,Kn=1020,qn=35902,Jn=35899,Yn=1021,Xn=1022,Zn=1023,Qn=1026,$n=1027,er=1028,tr=1029,nr=1030,rr=1031,ir=1033,ar=33776,or=33777,sr=33778,cr=33779,lr=35840,ur=35841,dr=35842,fr=35843,pr=36196,mr=37492,hr=37496,gr=37488,_r=37489,vr=37490,yr=37491,br=37808,xr=37809,Sr=37810,Cr=37811,wr=37812,Tr=37813,Er=37814,Dr=37815,Or=37816,kr=37817,Ar=37818,jr=37819,Mr=37820,Nr=37821,Pr=36492,Fr=36494,Ir=36495,Lr=36283,Rr=36284,zr=36285,Br=36286,Vr=2300,Hr=2301,Ur=2302,Wr=2303,Gr=2400,Kr=2401,qr=2402,Jr=2500,Yr=3200,Xr=`srgb`,Zr=`srgb-linear`,Qr=`linear`,$r=`srgb`,ei=7680,ti=35044,ni=2e3;function ri(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function ii(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ai(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function oi(){let e=ai(`canvas`);return e.style.display=`block`,e}var si={},ci=null;function li(...e){let t=`THREE.`+e.shift();ci?ci(`log`,t,...e):console.log(t,...e)}function ui(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function G(...e){e=ui(e);let t=`THREE.`+e.shift();if(ci)ci(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function K(...e){e=ui(e);let t=`THREE.`+e.shift();if(ci)ci(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function di(...e){let t=e.join(` `);t in si||(si[t]=!0,G(...e))}function fi(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}var pi={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},mi=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}},hi=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`),gi=1234567,_i=Math.PI/180,vi=180/Math.PI;function yi(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(hi[e&255]+hi[e>>8&255]+hi[e>>16&255]+hi[e>>24&255]+`-`+hi[t&255]+hi[t>>8&255]+`-`+hi[t>>16&15|64]+hi[t>>24&255]+`-`+hi[n&63|128]+hi[n>>8&255]+`-`+hi[n>>16&255]+hi[n>>24&255]+hi[r&255]+hi[r>>8&255]+hi[r>>16&255]+hi[r>>24&255]).toLowerCase()}function bi(e,t,n){return Math.max(t,Math.min(n,e))}function xi(e,t){return(e%t+t)%t}function Si(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function Ci(e,t,n){return e===t?0:(n-e)/(t-e)}function wi(e,t,n){return(1-n)*e+n*t}function Ti(e,t,n,r){return wi(e,t,1-Math.exp(-n*r))}function Ei(e,t=1){return t-Math.abs(xi(e,t*2)-t)}function Di(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function Oi(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function ki(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Ai(e,t){return e+Math.random()*(t-e)}function ji(e){return e*(.5-Math.random())}function Mi(e){e!==void 0&&(gi=e);let t=gi+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Ni(e){return e*_i}function Pi(e){return e*vi}function Fi(e){return(e&e-1)==0&&e!==0}function Ii(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function Li(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function Ri(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:G(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function zi(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function Bi(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}var Vi={DEG2RAD:_i,RAD2DEG:vi,generateUUID:yi,clamp:bi,euclideanModulo:xi,mapLinear:Si,inverseLerp:Ci,lerp:wi,damp:Ti,pingpong:Ei,smoothstep:Di,smootherstep:Oi,randInt:ki,randFloat:Ai,randFloatSpread:ji,seededRandom:Mi,degToRad:Ni,radToDeg:Pi,isPowerOfTwo:Fi,ceilPowerOfTwo:Ii,floorPowerOfTwo:Li,setQuaternionFromProperEuler:Ri,normalize:Bi,denormalize:zi},q=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=bi(this.x,e.x,t.x),this.y=bi(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=bi(this.x,e,t),this.y=bi(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(bi(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(bi(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Hi=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:G(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(bi(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},J=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Wi.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Wi.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=bi(this.x,e.x,t.x),this.y=bi(this.y,e.y,t.y),this.z=bi(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=bi(this.x,e,t),this.y=bi(this.y,e,t),this.z=bi(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(bi(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Ui.copy(this).projectOnVector(e),this.sub(Ui)}reflect(e){return this.sub(Ui.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(bi(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Ui=new J,Wi=new Hi,Gi=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,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];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,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=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Ki.makeScale(e,t)),this}rotate(e){return this.premultiply(Ki.makeRotation(-e)),this}translate(e,t){return this.premultiply(Ki.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Ki=new Gi,qi=new Gi().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ji=new Gi().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Yi(){let e={enabled:!0,workingColorSpace:Zr,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=Zi(e.r),e.g=Zi(e.g),e.b=Zi(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=Qi(e.r),e.g=Qi(e.g),e.b=Qi(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?Qr:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return di(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return di(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[Zr]:{primaries:t,whitePoint:r,transfer:Qr,toXYZ:qi,fromXYZ:Ji,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Xr},outputColorSpaceConfig:{drawingBufferColorSpace:Xr}},[Xr]:{primaries:t,whitePoint:r,transfer:$r,toXYZ:qi,fromXYZ:Ji,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Xr}}}),e}var Xi=Yi();function Zi(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Qi(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var $i,ea=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{$i===void 0&&($i=ai(`canvas`)),$i.width=e.width,$i.height=e.height;let t=$i.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=$i}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=ai(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=Zi(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(Zi(t[e]/255)*255):t[e]=Zi(t[e]);return{data:t,width:e.width,height:e.height}}else return G(`ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}},ta=0,na=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,`id`,{value:ta++}),this.uuid=yi(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<`u`&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(ra(r[t].image)):e.push(ra(r[t]))}else e=ra(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function ra(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?ea.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(G(`Texture: Unable to serialize Texture.`),{})}var ia=0,aa=new J,oa=class e extends mi{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=On,i=On,a=Nn,o=Fn,s=Zn,c=In,l=e.DEFAULT_ANISOTROPY,u=``){super(),this.isTexture=!0,Object.defineProperty(this,`id`,{value:ia++}),this.uuid=yi(),this.name=``,this.source=new na(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new q(0,0),this.repeat=new q(1,1),this.center=new q(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Gi,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(aa).x}get height(){return this.source.getSize(aa).y}get depth(){return this.source.getSize(aa).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){G(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){G(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Dn:e.x-=Math.floor(e.x);break;case On:e.x=e.x<0?0:1;break;case kn:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Dn:e.y-=Math.floor(e.y);break;case On:e.y=e.y<0?0:1;break;case kn:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};oa.DEFAULT_IMAGE=null,oa.DEFAULT_MAPPING=300,oa.DEFAULT_ANISOTROPY=1;var sa=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=bi(this.x,e.x,t.x),this.y=bi(this.y,e.y,t.y),this.z=bi(this.z,e.z,t.z),this.w=bi(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=bi(this.x,e,t),this.y=bi(this.y,e,t),this.z=bi(this.z,e,t),this.w=bi(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(bi(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},ca=class extends mi{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Nn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new sa(0,0,e,t),this.scissorTest=!1,this.viewport=new sa(0,0,e,t),this.textures=[];let r=new oa({width:e,height:t,depth:n.depth}),i=n.count;for(let e=0;e<i;e++)this.textures[e]=r.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:Nn,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new na(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:`dispose`})}},la=class extends ca{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},ua=class extends oa{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=An,this.minFilter=An,this.wrapR=On,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},da=class extends oa{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=An,this.minFilter=An,this.wrapR=On,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Y=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();let t=this.elements,n=e.elements,r=1/fa.setFromMatrixColumn(e,0).length(),i=1/fa.setFromMatrixColumn(e,1).length(),a=1/fa.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(ma,e,ha)}lookAt(e,t,n){let r=this.elements;return va.subVectors(e,t),va.lengthSq()===0&&(va.z=1),va.normalize(),ga.crossVectors(n,va),ga.lengthSq()===0&&(Math.abs(n.z)===1?va.x+=1e-4:va.z+=1e-4,va.normalize(),ga.crossVectors(n,va)),ga.normalize(),_a.crossVectors(va,ga),r[0]=ga.x,r[4]=_a.x,r[8]=va.x,r[1]=ga.y,r[5]=_a.y,r[9]=va.y,r[2]=ga.z,r[6]=_a.z,r[10]=va.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],A=r[6],j=r[10],M=r[14],ee=r[3],N=r[7],te=r[11],ne=r[15];return i[0]=a*x+o*T+s*k+c*ee,i[4]=a*S+o*E+s*A+c*N,i[8]=a*C+o*D+s*j+c*te,i[12]=a*w+o*O+s*M+c*ne,i[1]=l*x+u*T+d*k+f*ee,i[5]=l*S+u*E+d*A+f*N,i[9]=l*C+u*D+d*j+f*te,i[13]=l*w+u*O+d*M+f*ne,i[2]=p*x+m*T+h*k+g*ee,i[6]=p*S+m*E+h*A+g*N,i[10]=p*C+m*D+h*j+g*te,i[14]=p*w+m*O+h*M+g*ne,i[3]=_*x+v*T+y*k+b*ee,i[7]=_*S+v*E+y*A+b*N,i[11]=_*C+v*D+y*j+b*te,i[15]=_*w+v*O+y*M+b*ne,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15],_=s*f-c*d,v=o*f-c*u,y=o*d-s*u,b=a*f-c*l,x=a*d-s*l,S=a*u-o*l;return t*(m*_-h*v+g*y)-n*(p*_-h*b+g*x)+r*(p*v-m*b+g*S)-i*(p*y-m*x+h*S)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,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=t*c-i*a,b=n*s-r*o,x=n*c-i*o,S=r*c-i*s,C=l*m-u*p,w=l*h-d*p,T=l*g-f*p,E=u*h-d*m,D=u*g-f*m,O=d*g-f*h,k=_*O-v*D+y*E+b*T-x*w+S*C;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/k;return e[0]=(o*O-s*D+c*E)*A,e[1]=(r*D-n*O-i*E)*A,e[2]=(m*S-h*x+g*b)*A,e[3]=(d*x-u*S-f*b)*A,e[4]=(s*T-a*O-c*w)*A,e[5]=(t*O-r*T+i*w)*A,e[6]=(h*y-p*S-g*v)*A,e[7]=(l*S-d*y+f*v)*A,e[8]=(a*D-o*T+c*C)*A,e[9]=(n*T-t*D-i*C)*A,e[10]=(p*x-m*y+g*_)*A,e[11]=(u*y-l*x-f*_)*A,e[12]=(o*w-a*E-s*C)*A,e[13]=(t*E-n*w+r*C)*A,e[14]=(m*v-p*b-h*_)*A,e[15]=(l*b-u*v+d*_)*A,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinant();if(i===0)return n.set(1,1,1),t.identity(),this;let a=fa.set(r[0],r[1],r[2]).length(),o=fa.set(r[4],r[5],r[6]).length(),s=fa.set(r[8],r[9],r[10]).length();i<0&&(a=-a),pa.copy(this);let c=1/a,l=1/o,u=1/s;return pa.elements[0]*=c,pa.elements[1]*=c,pa.elements[2]*=c,pa.elements[4]*=l,pa.elements[5]*=l,pa.elements[6]*=l,pa.elements[8]*=u,pa.elements[9]*=u,pa.elements[10]*=u,t.setFromRotationMatrix(pa),n.x=a,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,a,o=ni,s=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),p,m;if(s)p=i/(a-i),m=a*i/(a-i);else if(o===2e3)p=-(a+i)/(a-i),m=-2*a*i/(a-i);else if(o===2001)p=-a/(a-i),m=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=ni,s=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),p,m;if(s)p=1/(a-i),m=a/(a-i);else if(o===2e3)p=-2/(a-i),m=-(a+i)/(a-i);else if(o===2001)p=-1/(a-i),m=-i/(a-i);else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},fa=new J,pa=new Y,ma=new J(0,0,0),ha=new J(1,1,1),ga=new J,_a=new J,va=new J,ya=new Y,ba=new Hi,xa=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(bi(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-bi(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(bi(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-bi(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(bi(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-bi(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:G(`Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return ya.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ya,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ba.setFromEuler(this),this.setFromQuaternion(ba,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};xa.DEFAULT_ORDER=`XYZ`;var Sa=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!=0}},Ca=0,wa=new J,Ta=new Hi,Ea=new Y,Da=new J,Oa=new J,ka=new J,Aa=new Hi,ja=new J(1,0,0),Ma=new J(0,1,0),Na=new J(0,0,1),Pa={type:`added`},Fa={type:`removed`},Ia={type:`childadded`,child:null},La={type:`childremoved`,child:null},Ra=class e extends mi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,`id`,{value:Ca++}),this.uuid=yi(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new J,n=new xa,r=new Hi,i=new J(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Y},normalMatrix:{value:new Gi}}),this.matrix=new Y,this.matrixWorld=new Y,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Sa,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Ta.setFromAxisAngle(e,t),this.quaternion.multiply(Ta),this}rotateOnWorldAxis(e,t){return Ta.setFromAxisAngle(e,t),this.quaternion.premultiply(Ta),this}rotateX(e){return this.rotateOnAxis(ja,e)}rotateY(e){return this.rotateOnAxis(Ma,e)}rotateZ(e){return this.rotateOnAxis(Na,e)}translateOnAxis(e,t){return wa.copy(e).applyQuaternion(this.quaternion),this.position.add(wa.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(ja,e)}translateY(e){return this.translateOnAxis(Ma,e)}translateZ(e){return this.translateOnAxis(Na,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ea.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Da.copy(e):Da.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),Oa.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ea.lookAt(Oa,Da,this.up):Ea.lookAt(Da,Oa,this.up),this.quaternion.setFromRotationMatrix(Ea),r&&(Ea.extractRotation(r.matrixWorld),Ta.setFromRotationMatrix(Ea),this.quaternion.premultiply(Ta.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(K(`Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Pa),Ia.child=e,this.dispatchEvent(Ia),Ia.child=null):K(`Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Fa),La.child=e,this.dispatchEvent(La),La.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Ea.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ea.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ea),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Pa),Ia.child=e,this.dispatchEvent(Ia),Ia.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oa,e,ka),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oa,Aa,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++)e[t].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};Ra.DEFAULT_UP=new J(0,1,0),Ra.DEFAULT_MATRIX_AUTO_UPDATE=!0,Ra.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var za=class extends Ra{constructor(){super(),this.isGroup=!0,this.type=`Group`}},Ba={type:`move`},Va=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new za,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new za,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new J,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new J),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new za,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new J,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new J),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:`connected`,data:e}),this}disconnect(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position),s=.02,l=.005;c.inputState.pinching&&o>s+l?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=s-l&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Ba)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new za;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Ha={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ua={h:0,s:0,l:0},Wa={h:0,s:0,l:0};function Ga(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var X=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Xr){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Xi.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Xi.workingColorSpace){return this.r=e,this.g=t,this.b=n,Xi.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Xi.workingColorSpace){if(e=xi(e,1),t=bi(t,0,1),n=bi(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=Ga(i,r,e+1/3),this.g=Ga(i,r,e),this.b=Ga(i,r,e-1/3)}return Xi.colorSpaceToWorking(this,r),this}setStyle(e,t=Xr){function n(t){t!==void 0&&parseFloat(t)<1&&G(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:G(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);G(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Xr){let n=Ha[e.toLowerCase()];return n===void 0?G(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Zi(e.r),this.g=Zi(e.g),this.b=Zi(e.b),this}copyLinearToSRGB(e){return this.r=Qi(e.r),this.g=Qi(e.g),this.b=Qi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Xr){return Xi.workingToColorSpace(Ka.copy(this),e),Math.round(bi(Ka.r*255,0,255))*65536+Math.round(bi(Ka.g*255,0,255))*256+Math.round(bi(Ka.b*255,0,255))}getHexString(e=Xr){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Xi.workingColorSpace){Xi.workingToColorSpace(Ka.copy(this),t);let n=Ka.r,r=Ka.g,i=Ka.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=Xi.workingColorSpace){return Xi.workingToColorSpace(Ka.copy(this),t),e.r=Ka.r,e.g=Ka.g,e.b=Ka.b,e}getStyle(e=Xr){Xi.workingToColorSpace(Ka.copy(this),e);let t=Ka.r,n=Ka.g,r=Ka.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(Ua),this.setHSL(Ua.h+e,Ua.s+t,Ua.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Ua),e.getHSL(Wa);let n=wi(Ua.h,Wa.h,t),r=wi(Ua.s,Wa.s,t),i=wi(Ua.l,Wa.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Ka=new X;X.NAMES=Ha;var qa=class extends Ra{constructor(){super(),this.isScene=!0,this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new xa,this.environmentIntensity=1,this.environmentRotation=new xa,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},Ja=new J,Ya=new J,Xa=new J,Za=new J,Qa=new J,$a=new J,eo=new J,to=new J,no=new J,ro=new J,io=new sa,ao=new sa,oo=new sa,so=class e{constructor(e=new J,t=new J,n=new J){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Ja.subVectors(e,t),r.cross(Ja);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){Ja.subVectors(r,t),Ya.subVectors(n,t),Xa.subVectors(e,t);let a=Ja.dot(Ja),o=Ja.dot(Ya),s=Ja.dot(Xa),c=Ya.dot(Ya),l=Ya.dot(Xa),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Za)===null?!1:Za.x>=0&&Za.y>=0&&Za.x+Za.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Za)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,Za.x),s.addScaledVector(a,Za.y),s.addScaledVector(o,Za.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return io.setScalar(0),ao.setScalar(0),oo.setScalar(0),io.fromBufferAttribute(e,t),ao.fromBufferAttribute(e,n),oo.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(io,i.x),a.addScaledVector(ao,i.y),a.addScaledVector(oo,i.z),a}static isFrontFacing(e,t,n,r){return Ja.subVectors(n,t),Ya.subVectors(e,t),Ja.cross(Ya).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ja.subVectors(this.c,this.b),Ya.subVectors(this.a,this.b),Ja.cross(Ya).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;Qa.subVectors(r,n),$a.subVectors(i,n),to.subVectors(e,n);let s=Qa.dot(to),c=$a.dot(to);if(s<=0&&c<=0)return t.copy(n);no.subVectors(e,r);let l=Qa.dot(no),u=$a.dot(no);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(Qa,a);ro.subVectors(e,i);let f=Qa.dot(ro),p=$a.dot(ro);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector($a,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return eo.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(eo,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Qa,a).addScaledVector($a,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},co=class{constructor(e=new J(1/0,1/0,1/0),t=new J(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(uo.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(uo.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=uo.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,uo):uo.fromBufferAttribute(r,t),uo.applyMatrix4(e.matrixWorld),this.expandByPoint(uo);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),fo.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),fo.copy(e.boundingBox)),fo.applyMatrix4(e.matrixWorld),this.union(fo)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,uo),uo.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(yo),bo.subVectors(this.max,yo),po.subVectors(e.a,yo),mo.subVectors(e.b,yo),ho.subVectors(e.c,yo),go.subVectors(mo,po),_o.subVectors(ho,mo),vo.subVectors(po,ho);let t=[0,-go.z,go.y,0,-_o.z,_o.y,0,-vo.z,vo.y,go.z,0,-go.x,_o.z,0,-_o.x,vo.z,0,-vo.x,-go.y,go.x,0,-_o.y,_o.x,0,-vo.y,vo.x,0];return!Co(t,po,mo,ho,bo)||(t=[1,0,0,0,1,0,0,0,1],!Co(t,po,mo,ho,bo))?!1:(xo.crossVectors(go,_o),t=[xo.x,xo.y,xo.z],Co(t,po,mo,ho,bo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,uo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(uo).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(lo[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),lo[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),lo[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),lo[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),lo[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),lo[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),lo[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),lo[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(lo),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},lo=[new J,new J,new J,new J,new J,new J,new J,new J],uo=new J,fo=new co,po=new J,mo=new J,ho=new J,go=new J,_o=new J,vo=new J,yo=new J,bo=new J,xo=new J,So=new J;function Co(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){So.fromArray(e,a);let o=i.x*Math.abs(So.x)+i.y*Math.abs(So.y)+i.z*Math.abs(So.z),s=t.dot(So),c=n.dot(So),l=r.dot(So);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var wo=new J,To=new q,Eo=0,Do=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:Eo++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=ti,this.updateRanges=[],this.gpuType=Hn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)To.fromBufferAttribute(this,t),To.applyMatrix3(e),this.setXY(t,To.x,To.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)wo.fromBufferAttribute(this,t),wo.applyMatrix3(e),this.setXYZ(t,wo.x,wo.y,wo.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)wo.fromBufferAttribute(this,t),wo.applyMatrix4(e),this.setXYZ(t,wo.x,wo.y,wo.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)wo.fromBufferAttribute(this,t),wo.applyNormalMatrix(e),this.setXYZ(t,wo.x,wo.y,wo.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)wo.fromBufferAttribute(this,t),wo.transformDirection(e),this.setXYZ(t,wo.x,wo.y,wo.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=zi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Bi(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=zi(t,this.array)),t}setX(e,t){return this.normalized&&(t=Bi(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=zi(t,this.array)),t}setY(e,t){return this.normalized&&(t=Bi(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=zi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Bi(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=zi(t,this.array)),t}setW(e,t){return this.normalized&&(t=Bi(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Bi(t,this.array),n=Bi(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Bi(t,this.array),n=Bi(n,this.array),r=Bi(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=Bi(t,this.array),n=Bi(n,this.array),r=Bi(r,this.array),i=Bi(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==35044&&(e.usage=this.usage),e}},Oo=class extends Do{constructor(e,t,n){super(new Uint16Array(e),t,n)}},ko=class extends Do{constructor(e,t,n){super(new Uint32Array(e),t,n)}},Ao=class extends Do{constructor(e,t,n){super(new Float32Array(e),t,n)}},jo=new co,Mo=new J,No=new J,Po=class{constructor(e=new J,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?jo.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Mo.subVectors(e,this.center);let t=Mo.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(Mo,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(No.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Mo.copy(e.center).add(No)),this.expandByPoint(Mo.copy(e.center).sub(No))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Fo=0,Io=new Y,Lo=new Ra,Ro=new J,zo=new co,Bo=new co,Vo=new J,Ho=class e extends mi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,`id`,{value:Fo++}),this.uuid=yi(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(ri(e)?ko:Oo)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new Gi().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Io.makeRotationFromQuaternion(e),this.applyMatrix4(Io),this}rotateX(e){return Io.makeRotationX(e),this.applyMatrix4(Io),this}rotateY(e){return Io.makeRotationY(e),this.applyMatrix4(Io),this}rotateZ(e){return Io.makeRotationZ(e),this.applyMatrix4(Io),this}translate(e,t,n){return Io.makeTranslation(e,t,n),this.applyMatrix4(Io),this}scale(e,t,n){return Io.makeScale(e,t,n),this.applyMatrix4(Io),this}lookAt(e){return Lo.lookAt(e),Lo.updateMatrix(),this.applyMatrix4(Lo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ro).negate(),this.translate(Ro.x,Ro.y,Ro.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new Ao(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&G(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new co);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){K(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new J(-1/0,-1/0,-1/0),new J(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];zo.setFromBufferAttribute(n),this.morphTargetsRelative?(Vo.addVectors(this.boundingBox.min,zo.min),this.boundingBox.expandByPoint(Vo),Vo.addVectors(this.boundingBox.max,zo.max),this.boundingBox.expandByPoint(Vo)):(this.boundingBox.expandByPoint(zo.min),this.boundingBox.expandByPoint(zo.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&K(`BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Po);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){K(`BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new J,1/0);return}if(e){let n=this.boundingSphere.center;if(zo.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Bo.setFromBufferAttribute(n),this.morphTargetsRelative?(Vo.addVectors(zo.min,Bo.min),zo.expandByPoint(Vo),Vo.addVectors(zo.max,Bo.max),zo.expandByPoint(Vo)):(zo.expandByPoint(Bo.min),zo.expandByPoint(Bo.max))}zo.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)Vo.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(Vo));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)Vo.fromBufferAttribute(a,t),o&&(Ro.fromBufferAttribute(e,t),Vo.add(Ro)),r=Math.max(r,n.distanceToSquared(Vo))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&K(`BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){K(`BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new Do(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new J,s[e]=new J;let c=new J,l=new J,u=new J,d=new q,f=new q,p=new q,m=new J,h=new J;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new J,y=new J,b=new J,x=new J;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e])<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,n)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new Do(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new J,i=new J,a=new J,o=new J,s=new J,c=new J,l=new J,u=new J;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Vo.fromBufferAttribute(e,t),Vo.normalize(),e.setXYZ(t,Vo.x,Vo.y,Vo.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new Do(a,r,i)}if(this.index===null)return G(`BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}},Uo=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=ti,this.updateRanges=[],this.version=0,this.uuid=yi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=yi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=yi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Wo=new J,Go=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Wo.fromBufferAttribute(this,t),Wo.applyMatrix4(e),this.setXYZ(t,Wo.x,Wo.y,Wo.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Wo.fromBufferAttribute(this,t),Wo.applyNormalMatrix(e),this.setXYZ(t,Wo.x,Wo.y,Wo.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Wo.fromBufferAttribute(this,t),Wo.transformDirection(e),this.setXYZ(t,Wo.x,Wo.y,Wo.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=zi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Bi(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=zi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=zi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=zi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=zi(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Bi(t,this.array),n=Bi(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Bi(t,this.array),n=Bi(n,this.array),r=Bi(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Bi(t,this.array),n=Bi(n,this.array),r=Bi(r,this.array),i=Bi(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){li(`InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new Do(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){li(`InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Ko=0,qo=class extends mi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,`id`,{value:Ko++}),this.uuid=yi(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new X(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ei,this.stencilZFail=ei,this.stencilZPass=ei,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){G(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){G(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},Jo=class extends qo{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new X(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Yo,Xo=new J,Zo=new J,Qo=new J,$o=new q,es=new q,ts=new Y,ns=new J,rs=new J,is=new J,as=new q,os=new q,ss=new q,cs=class extends Ra{constructor(e=new Jo){if(super(),this.isSprite=!0,this.type=`Sprite`,Yo===void 0){Yo=new Ho;let e=new Uo(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);Yo.setIndex([0,1,2,0,2,3]),Yo.setAttribute(`position`,new Go(e,3,0,!1)),Yo.setAttribute(`uv`,new Go(e,2,3,!1))}this.geometry=Yo,this.material=e,this.center=new q(.5,.5),this.count=1}raycast(e,t){e.camera===null&&K(`Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.`),Zo.setFromMatrixScale(this.matrixWorld),ts.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Qo.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Zo.multiplyScalar(-Qo.z);let n=this.material.rotation,r,i;n!==0&&(i=Math.cos(n),r=Math.sin(n));let a=this.center;ls(ns.set(-.5,-.5,0),Qo,a,Zo,r,i),ls(rs.set(.5,-.5,0),Qo,a,Zo,r,i),ls(is.set(.5,.5,0),Qo,a,Zo,r,i),as.set(0,0),os.set(1,0),ss.set(1,1);let o=e.ray.intersectTriangle(ns,rs,is,!1,Xo);if(o===null&&(ls(rs.set(-.5,.5,0),Qo,a,Zo,r,i),os.set(0,1),o=e.ray.intersectTriangle(ns,is,rs,!1,Xo),o===null))return;let s=e.ray.origin.distanceTo(Xo);s<e.near||s>e.far||t.push({distance:s,point:Xo.clone(),uv:so.getInterpolation(Xo,ns,rs,is,as,os,ss,new q),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};function ls(e,t,n,r,i,a){$o.subVectors(e,n).addScalar(.5).multiply(r),i===void 0?es.copy($o):(es.x=a*$o.x-i*$o.y,es.y=i*$o.x+a*$o.y),e.copy(t),e.x+=es.x,e.y+=es.y,e.applyMatrix4(ts)}var us=new J,ds=new J,fs=new J,ps=new J,ms=new J,hs=new J,gs=new J,_s=class{constructor(e=new J,t=new J(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,us)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=us.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(us.copy(this.origin).addScaledVector(this.direction,t),us.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){ds.copy(e).add(t).multiplyScalar(.5),fs.copy(t).sub(e).normalize(),ps.copy(this.origin).sub(ds);let i=e.distanceTo(t)*.5,a=-this.direction.dot(fs),o=ps.dot(this.direction),s=-ps.dot(fs),c=ps.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(ds).addScaledVector(fs,d),f}intersectSphere(e,t){us.subVectors(e.center,this.origin);let n=us.dot(this.direction),r=us.dot(us)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,us)!==null}intersectTriangle(e,t,n,r,i){ms.subVectors(t,e),hs.subVectors(n,e),gs.crossVectors(ms,hs);let a=this.direction.dot(gs),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;ps.subVectors(this.origin,e);let s=o*this.direction.dot(hs.crossVectors(ps,hs));if(s<0)return null;let c=o*this.direction.dot(ms.cross(ps));if(c<0||s+c>a)return null;let l=-o*ps.dot(gs);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},vs=class extends qo{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new X(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xa,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},ys=new Y,bs=new _s,xs=new Po,Ss=new J,Cs=new J,ws=new J,Ts=new J,Es=new J,Ds=new J,Os=new J,ks=new J,As=class extends Ra{constructor(e=new Ho,t=new vs){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){Ds.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(Es.fromBufferAttribute(s,e),a?Ds.addScaledVector(Es,r):Ds.addScaledVector(Es.sub(t),r))}t.add(Ds)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),xs.copy(n.boundingSphere),xs.applyMatrix4(i),bs.copy(e.ray).recast(e.near),!(xs.containsPoint(bs.origin)===!1&&(bs.intersectSphere(xs,Ss)===null||bs.origin.distanceToSquared(Ss)>(e.far-e.near)**2))&&(ys.copy(i).invert(),bs.copy(e.ray).applyMatrix4(ys),!(n.boundingBox!==null&&bs.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,bs)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=Ms(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=Ms(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=Ms(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=Ms(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function js(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===0,s),c===null)return null;ks.copy(s),ks.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(ks);return l<n.near||l>n.far?null:{distance:l,point:ks.clone(),object:e}}function Ms(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,Cs),e.getVertexPosition(c,ws),e.getVertexPosition(l,Ts);let u=js(e,t,n,r,Cs,ws,Ts,Os);if(u){let e=new J;so.getBarycoord(Os,Cs,ws,Ts,e),i&&(u.uv=so.getInterpolatedAttribute(i,s,c,l,e,new q)),a&&(u.uv1=so.getInterpolatedAttribute(a,s,c,l,e,new q)),o&&(u.normal=so.getInterpolatedAttribute(o,s,c,l,e,new J),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new J,materialIndex:0};so.getNormal(Cs,ws,Ts,t.normal),u.face=t,u.barycoord=e}return u}var Ns=new J,Ps=new sa,Fs=new sa,Is=new J,Ls=new Y,Rs=new J,zs=new Po,Bs=new Y,Vs=new _s,Hs=class extends As{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type=`SkinnedMesh`,this.bindMode=En,this.bindMatrix=new Y,this.bindMatrixInverse=new Y,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new co),this.boundingBox.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e<t.count;e++)this.getVertexPosition(e,Rs),this.boundingBox.expandByPoint(Rs)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Po),this.boundingSphere.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e<t.count;e++)this.getVertexPosition(e,Rs),this.boundingSphere.expandByPoint(Rs)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),zs.copy(this.boundingSphere),zs.applyMatrix4(r),e.ray.intersectsSphere(zs)!==!1&&(Bs.copy(r).invert(),Vs.copy(e.ray).applyMatrix4(Bs),!(this.boundingBox!==null&&Vs.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Vs)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new sa,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();r===1/0?e.set(1,0,0,0):e.multiplyScalar(r),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===`attached`?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===`detached`?this.bindMatrixInverse.copy(this.bindMatrix).invert():G(`SkinnedMesh: Unrecognized bindMode: `+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,r=this.geometry;Ps.fromBufferAttribute(r.attributes.skinIndex,e),Fs.fromBufferAttribute(r.attributes.skinWeight,e),Ns.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){let r=Fs.getComponent(e);if(r!==0){let i=Ps.getComponent(e);Ls.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),t.addScaledVector(Is.copy(Ns).applyMatrix4(Ls),r)}}return t.applyMatrix4(this.bindMatrixInverse)}},Us=class extends Ra{constructor(){super(),this.isBone=!0,this.type=`Bone`}},Ws=class extends oa{constructor(e=null,t=1,n=1,r,i,a,o,s,c=An,l=An,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Gs=new Y,Ks=new Y,qs=class e{constructor(e=[],t=[]){this.uuid=yi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){G(`Skeleton: Number of inverse bone matrices does not match amount of bones.`),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new Y)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let t=new Y;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let r=0,i=e.length;r<i;r++){let i=e[r]?e[r].matrixWorld:Ks;Gs.multiplyMatrices(i,t[r]),Gs.toArray(n,r*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new e(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new Ws(t,e,e,Zn,Hn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){let r=e.bones[n],i=t[r];i===void 0&&(G(`Skeleton: No bone found with UUID:`,r),i=new Us),this.bones.push(i),this.boneInverses.push(new Y().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:`Skeleton`,generator:`Skeleton.toJSON`},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let r=0,i=t.length;r<i;r++){let i=t[r];e.bones.push(i.uuid);let a=n[r];e.boneInverses.push(a.toArray())}return e}},Js=class extends Do{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Ys=new Y,Xs=new Y,Zs=[],Qs=new co,$s=new Y,ec=new As,tc=new Po,nc=class extends As{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Js(new Float32Array(n*16),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<n;e++)this.setMatrixAt(e,$s)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new co),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Ys),Qs.copy(e.boundingBox).applyMatrix4(Ys),this.boundingBox.union(Qs)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Po),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Ys),tc.copy(e.boundingSphere).applyMatrix4(Ys),this.boundingSphere.union(tc)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.previousInstanceMatrix!==null&&(this.previousInstanceMatrix=e.previousInstanceMatrix.clone()),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,i=e*(n.length+1)+1;for(let e=0;e<n.length;e++)n[e]=r[i+e]}raycast(e,t){let n=this.matrixWorld,r=this.count;if(ec.geometry=this.geometry,ec.material=this.material,ec.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),tc.copy(this.boundingSphere),tc.applyMatrix4(n),e.ray.intersectsSphere(tc)!==!1))for(let i=0;i<r;i++){this.getMatrixAt(i,Ys),Xs.multiplyMatrices(n,Ys),ec.matrixWorld=Xs,ec.raycast(e,Zs);for(let e=0,n=Zs.length;e<n;e++){let n=Zs[e];n.instanceId=i,n.object=this,t.push(n)}Zs.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Js(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){let n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new Ws(new Float32Array(r*this.count),r,this.count,er,Hn));let i=this.morphTexture.source.data.data,a=0;for(let e=0;e<n.length;e++)a+=n[e];let o=this.geometry.morphTargetsRelative?1:1-a,s=r*e;i[s]=o,i.set(n,s+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:`dispose`}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},rc=new J,ic=new J,ac=new Gi,oc=class{constructor(e=new J(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=rc.subVectors(n,t).cross(ic.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(rc),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||ac.getNormalMatrix(e),r=this.coplanarPoint(rc).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},sc=new Po,cc=new q(.5,.5),lc=new J,uc=class{constructor(e=new oc,t=new oc,n=new oc,r=new oc,i=new oc,a=new oc){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=ni,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),sc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),sc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(sc)}intersectsSprite(e){return sc.center.set(0,0,0),sc.radius=.7071067811865476+cc.distanceTo(e.center),sc.applyMatrix4(e.matrixWorld),this.intersectsSphere(sc)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(lc.x=r.normal.x>0?e.max.x:e.min.x,lc.y=r.normal.y>0?e.max.y:e.min.y,lc.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(lc)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},dc=class extends qo{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new X(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},fc=new J,pc=new J,mc=new Y,hc=new _s,gc=new Po,_c=new J,vc=new J,yc=class extends Ra{constructor(e=new Ho,t=new dc){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)fc.fromBufferAttribute(t,e-1),pc.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=fc.distanceTo(pc);e.setAttribute(`lineDistance`,new Ao(n,1))}else G(`Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),gc.copy(n.boundingSphere),gc.applyMatrix4(r),gc.radius+=i,e.ray.intersectsSphere(gc)===!1)return;mc.copy(r).invert(),hc.copy(e.ray).applyMatrix4(mc);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=this.isLineSegments?2:1,l=n.index,u=n.attributes.position;if(l!==null){let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=l.getX(i),r=l.getX(i+1),a=bc(this,e,hc,s,n,r,i);a&&t.push(a)}if(this.isLineLoop){let i=l.getX(r-1),a=l.getX(n),o=bc(this,e,hc,s,i,a,r-1);o&&t.push(o)}}else{let n=Math.max(0,a.start),r=Math.min(u.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=bc(this,e,hc,s,i,i+1,i);n&&t.push(n)}if(this.isLineLoop){let i=bc(this,e,hc,s,r-1,n,r-1);i&&t.push(i)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function bc(e,t,n,r,i,a,o){let s=e.geometry.attributes.position;if(fc.fromBufferAttribute(s,i),pc.fromBufferAttribute(s,a),n.distanceSqToSegment(fc,pc,_c,vc)>r)return;_c.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(_c);if(!(c<t.near||c>t.far))return{distance:c,point:vc.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var xc=new J,Sc=new J,Cc=class extends yc{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type=`LineSegments`}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e<r;e+=2)xc.fromBufferAttribute(t,e),Sc.fromBufferAttribute(t,e+1),n[e]=e===0?0:n[e-1],n[e+1]=n[e]+xc.distanceTo(Sc);e.setAttribute(`lineDistance`,new Ao(n,1))}else G(`LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}},wc=class extends yc{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type=`LineLoop`}},Tc=class extends qo{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new X(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Ec=new Y,Dc=new _s,Oc=new Po,kc=new J,Ac=class extends Ra{constructor(e=new Ho,t=new Tc){super(),this.isPoints=!0,this.type=`Points`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Oc.copy(n.boundingSphere),Oc.applyMatrix4(r),Oc.radius+=i,e.ray.intersectsSphere(Oc)===!1)return;Ec.copy(r).invert(),Dc.copy(e.ray).applyMatrix4(Ec);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=n.index,l=n.attributes.position;if(c!==null){let n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let a=n,o=i;a<o;a++){let n=c.getX(a);kc.fromBufferAttribute(l,n),jc(kc,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(l.count,a.start+a.count);for(let a=n,o=i;a<o;a++)kc.fromBufferAttribute(l,a),jc(kc,a,s,r,e,t,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function jc(e,t,n,r,i,a,o){let s=Dc.distanceSqToPoint(e);if(s<n){let n=new J;Dc.closestPointToPoint(e,n),n.applyMatrix4(r);let c=i.ray.origin.distanceTo(n);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var Mc=class extends oa{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Nc=class extends oa{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},Pc=class extends oa{constructor(e,t,n=Vn,r,i,a,o=An,s=An,c,l=Qn,u=1){if(l!==1026&&l!==1027)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new na(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},Fc=class extends Pc{constructor(e,t=Vn,n=301,r,i,a=An,o=An,s,c=Qn){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},Ic=class extends oa{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Lc=class e extends Ho{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new Ao(c,3)),this.setAttribute(`normal`,new Ao(l,3)),this.setAttribute(`uv`,new Ao(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new J;for(let a=0;a<w;a++){let o=a*y-x;for(let s=0;s<C;s++)D[e]=(s*v-b)*r,D[t]=o*i,D[n]=S,c.push(D.x,D.y,D.z),D[e]=0,D[t]=0,D[n]=m>0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),a=d+(t+1)+C*e;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(f,E,_),f+=E,d+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},Rc=class e extends Ho{constructor(e=1,t=1,n=1,r=32,i=1,a=!1,o=0,s=Math.PI*2){super(),this.type=`CylinderGeometry`,this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s};let c=this;r=Math.floor(r),i=Math.floor(i);let l=[],u=[],d=[],f=[],p=0,m=[],h=n/2,g=0;_(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new Ao(u,3)),this.setAttribute(`normal`,new Ao(d,3)),this.setAttribute(`uv`,new Ao(f,2));function _(){let a=new J,_=new J,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n<r;n++)for(let r=0;r<i;r++){let a=m[r][n],o=m[r+1][n],s=m[r+1][n+1],c=m[r][n+1];(e>0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new q,m=new J,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e<r;e++){let t=i+e,r=b+e;n===!0?l.push(r,r+1,t):l.push(r+1,r,t),_+=3}c.addGroup(g,_,n===!0?1:2),g+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},zc=class e extends Rc{constructor(e=1,t=1,n=32,r=1,i=!1,a=0,o=Math.PI*2){super(0,e,t,n,r,i,a,o),this.type=`ConeGeometry`,this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}static fromJSON(t){return new e(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Bc=class{constructor(){this.type=`Curve`,this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){G(`Curve: .getPoint() not implemented.`)}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,r=this.getPoint(0),i=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let n=this.getLengths(),r=0,i=n.length,a;a=t||e*n[i-1];let o=0,s=i-1,c;for(;o<=s;)if(r=Math.floor(o+(s-o)/2),c=n[r]-a,c<0)o=r+1;else if(c>0)s=r-1;else{s=r;break}if(r=s,n[r]===a)return r/(i-1);let l=n[r],u=n[r+1]-l,d=(a-l)/u;return(r+d)/(i-1)}getTangent(e,t){let n=1e-4,r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);let a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new q:new J);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new J,r=[],i=[],a=[],o=new J,s=new Y;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new J)}i[0]=new J,a[0]=new J;let c=Number.MAX_VALUE,l=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>2**-52){o.normalize();let e=Math.acos(bi(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(t===!0){let t=Math.acos(bi(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:`Curve`,generator:`Curve.toJSON`}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Vc=class extends Bc{constructor(e=0,t=0,n=1,r=1,i=0,a=Math.PI*2,o=!1,s=0){super(),this.isEllipseCurve=!0,this.type=`EllipseCurve`,this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t=new q){let n=t,r=Math.PI*2,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)<2**-52;for(;i<0;)i+=r;for(;i>r;)i-=r;i<2**-52&&(i=a?0:r),this.aClockwise===!0&&!a&&(i===r?i=-r:i-=r);let o=this.aStartAngle+e*i,s=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=c-this.aY;s=n*e-r*t+this.aX,c=n*t+r*e+this.aY}return n.set(s,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},Hc=class extends Vc{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.isArcCurve=!0,this.type=`ArcCurve`}};function Uc(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let c=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;c*=o,l*=o,i(t,n,c,l)},calc:function(i){let a=i*i,o=a*i;return e+t*i+n*a+r*o}}}var Wc=new J,Gc=new Uc,Kc=new Uc,qc=new Uc,Jc=class extends Bc{constructor(e=[],t=!1,n=`centripetal`,r=.5){super(),this.isCatmullRomCurve3=!0,this.type=`CatmullRomCurve3`,this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new J){let n=t,r=this.points,i=r.length,a=(i-+!this.closed)*e,o=Math.floor(a),s=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:s===0&&o===i-1&&(o=i-2,s=1);let c,l;this.closed||o>0?c=r[(o-1)%i]:(Wc.subVectors(r[0],r[1]).add(r[0]),c=Wc);let u=r[o%i],d=r[(o+1)%i];if(this.closed||o+2<i?l=r[(o+2)%i]:(Wc.subVectors(r[i-1],r[i-2]).add(r[i-1]),l=Wc),this.curveType===`centripetal`||this.curveType===`chordal`){let e=this.curveType===`chordal`?.5:.25,t=c.distanceToSquared(u)**+e,n=u.distanceToSquared(d)**+e,r=d.distanceToSquared(l)**+e;n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),Gc.initNonuniformCatmullRom(c.x,u.x,d.x,l.x,t,n,r),Kc.initNonuniformCatmullRom(c.y,u.y,d.y,l.y,t,n,r),qc.initNonuniformCatmullRom(c.z,u.z,d.z,l.z,t,n,r)}else this.curveType===`catmullrom`&&(Gc.initCatmullRom(c.x,u.x,d.x,l.x,this.tension),Kc.initCatmullRom(c.y,u.y,d.y,l.y,this.tension),qc.initCatmullRom(c.z,u.z,d.z,l.z,this.tension));return n.set(Gc.calc(s),Kc.calc(s),qc.calc(s)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new J().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function Yc(e,t,n,r,i){let a=(r-t)*.5,o=(i-n)*.5,s=e*e,c=e*s;return(2*n-2*r+a+o)*c+(-3*n+3*r-2*a-o)*s+a*e+n}function Xc(e,t){let n=1-e;return n*n*t}function Zc(e,t){return 2*(1-e)*e*t}function Qc(e,t){return e*e*t}function $c(e,t,n,r){return Xc(e,t)+Zc(e,n)+Qc(e,r)}function el(e,t){let n=1-e;return n*n*n*t}function tl(e,t){let n=1-e;return 3*n*n*e*t}function nl(e,t){return 3*(1-e)*e*e*t}function rl(e,t){return e*e*e*t}function il(e,t,n,r,i){return el(e,t)+tl(e,n)+nl(e,r)+rl(e,i)}var al=class extends Bc{constructor(e=new q,t=new q,n=new q,r=new q){super(),this.isCubicBezierCurve=!0,this.type=`CubicBezierCurve`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new q){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(il(e,r.x,i.x,a.x,o.x),il(e,r.y,i.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ol=class extends Bc{constructor(e=new J,t=new J,n=new J,r=new J){super(),this.isCubicBezierCurve3=!0,this.type=`CubicBezierCurve3`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new J){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(il(e,r.x,i.x,a.x,o.x),il(e,r.y,i.y,a.y,o.y),il(e,r.z,i.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},sl=class extends Bc{constructor(e=new q,t=new q){super(),this.isLineCurve=!0,this.type=`LineCurve`,this.v1=e,this.v2=t}getPoint(e,t=new q){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new q){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},cl=class extends Bc{constructor(e=new J,t=new J){super(),this.isLineCurve3=!0,this.type=`LineCurve3`,this.v1=e,this.v2=t}getPoint(e,t=new J){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new J){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ll=class extends Bc{constructor(e=new q,t=new q,n=new q){super(),this.isQuadraticBezierCurve=!0,this.type=`QuadraticBezierCurve`,this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new q){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set($c(e,r.x,i.x,a.x),$c(e,r.y,i.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ul=class extends Bc{constructor(e=new J,t=new J,n=new J){super(),this.isQuadraticBezierCurve3=!0,this.type=`QuadraticBezierCurve3`,this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new J){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set($c(e,r.x,i.x,a.x),$c(e,r.y,i.y,a.y),$c(e,r.z,i.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},dl=class extends Bc{constructor(e=[]){super(),this.isSplineCurve=!0,this.type=`SplineCurve`,this.points=e}getPoint(e,t=new q){let n=t,r=this.points,i=(r.length-1)*e,a=Math.floor(i),o=i-a,s=r[a===0?a:a-1],c=r[a],l=r[a>r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(Yc(o,s.x,c.x,l.x,u.x),Yc(o,s.y,c.y,l.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new q().fromArray(n))}return this}},fl=Object.freeze({__proto__:null,ArcCurve:Hc,CatmullRomCurve3:Jc,CubicBezierCurve:al,CubicBezierCurve3:ol,EllipseCurve:Vc,LineCurve:sl,LineCurve3:cl,QuadraticBezierCurve:ll,QuadraticBezierCurve3:ul,SplineCurve:dl}),pl=class extends Bc{constructor(){super(),this.type=`CurvePath`,this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let n=e.isVector2===!0?`LineCurve`:`LineCurve3`;this.curves.push(new fl[n](t,e))}return this}getPoint(e,t){let n=e*this.getLength(),r=this.getCurveLengths(),i=0;for(;i<r.length;){if(r[i]>=n){let e=r[i]-n,a=this.curves[i],o=a.getLength(),s=o===0?0:1-e/o;return a.getPointAt(s,t)}i++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let r=0,i=this.curves;r<i.length;r++){let a=i[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,s=a.getPoints(o);for(let e=0;e<s.length;e++){let r=s[e];n&&n.equals(r)||(t.push(r),n=r)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(new fl[n.type]().fromJSON(n))}return this}},ml=class extends pl{constructor(e){super(),this.type=`Path`,this.currentPoint=new q,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let n=new sl(this.currentPoint.clone(),new q(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){let i=new ll(this.currentPoint.clone(),new q(e,t),new q(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,i,a){let o=new al(this.currentPoint.clone(),new q(e,t),new q(n,r),new q(i,a));return this.curves.push(o),this.currentPoint.set(i,a),this}splineThru(e){let t=new dl([this.currentPoint.clone()].concat(e));return this.curves.push(t),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,i,a){let o=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+o,t+s,n,r,i,a),this}absarc(e,t,n,r,i,a){return this.absellipse(e,t,n,n,r,i,a),this}ellipse(e,t,n,r,i,a,o,s){let c=this.currentPoint.x,l=this.currentPoint.y;return this.absellipse(e+c,t+l,n,r,i,a,o,s),this}absellipse(e,t,n,r,i,a,o,s){let c=new Vc(e,t,n,r,i,a,o,s);if(this.curves.length>0){let e=c.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(c);let l=c.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},hl=class extends ml{constructor(e){super(e),this.uuid=yi(),this.type=`Shape`,this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(new ml().fromJSON(n))}return this}};function gl(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length,a=_l(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s,c,l;if(r&&(a=wl(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;a<i;a+=n){let n=e[a],i=e[a+1];n<s&&(s=n),i<c&&(c=i),n>t&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return yl(a,o,n,s,c,l,0),o}function _l(e,t,n,r,i){let a;if(i===Jl(e,t,n,r)>0)for(let i=t;i<n;i+=r)a=Gl(i/r|0,e[i],e[i+1],a);else for(let i=n-r;i>=t;i-=r)a=Gl(i/r|0,e[i],e[i+1],a);return a&&Ll(a,a.next)&&(Kl(a),a=a.next),a}function vl(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(Ll(n,n.next)||Il(n.prev,n,n.next)===0)){if(Kl(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function yl(e,t,n,r,i,a,o){if(!e)return;!o&&a&&kl(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?xl(e,r,i,a):bl(e)){t.push(c.i,e.i,l.i),Kl(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=Sl(vl(e),t),yl(e,t,n,r,i,a,2)):o===2&&Cl(e,t,n,r,i,a):yl(vl(e),t,n,r,i,a,1);break}}}function bl(e){let t=e.prev,n=e,r=e.next;if(Il(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&Pl(i,s,a,c,o,l,m.x,m.y)&&Il(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function xl(e,t,n,r){let i=e.prev,a=e,o=e.next;if(Il(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=jl(p,m,t,n,r),v=jl(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Pl(s,u,c,d,l,f,y.x,y.y)&&Il(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Pl(s,u,c,d,l,f,b.x,b.y)&&Il(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Pl(s,u,c,d,l,f,y.x,y.y)&&Il(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Pl(s,u,c,d,l,f,b.x,b.y)&&Il(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Sl(e,t){let n=e;do{let r=n.prev,i=n.next.next;!Ll(r,i)&&Rl(r,n,n.next,i)&&Hl(r,i)&&Hl(i,r)&&(t.push(r.i,n.i,i.i),Kl(n),Kl(n.next),n=e=i),n=n.next}while(n!==e);return vl(n)}function Cl(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&Fl(o,e)){let s=Wl(o,e);o=vl(o,o.next),s=vl(s,s.next),yl(o,t,n,r,i,a,0),yl(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function wl(e,t,n,r){let i=[];for(let n=0,a=t.length;n<a;n++){let o=_l(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&(o.steiner=!0),i.push(Ml(o))}i.sort(Tl);for(let e=0;e<i.length;e++)n=El(i[e],n);return n}function Tl(e,t){let n=e.x-t.x;return n===0&&(n=e.y-t.y,n===0&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x))),n}function El(e,t){let n=Dl(e,t);if(!n)return t;let r=Wl(n,e);return vl(r,r.next),vl(n,n.next)}function Dl(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(Ll(e,n))return n;do{if(Ll(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.x<n.next.x?n:n.next,e===r))return o}n=n.next}while(n!==t);if(!o)return null;let s=o,c=o.x,l=o.y,u=1/0;n=o;do{if(r>=n.x&&n.x>=c&&r!==n.x&&Nl(i<l?r:a,i,c,l,i<l?a:r,i,n.x,n.y)){let t=Math.abs(i-n.y)/(r-n.x);Hl(n,e)&&(t<u||t===u&&(n.x>o.x||n.x===o.x&&Ol(o,n)))&&(o=n,u=t)}n=n.next}while(n!==s);return o}function Ol(e,t){return Il(e.prev,e,t.prev)<0&&Il(t.next,e,e.next)<0}function kl(e,t,n,r){let i=e;do i.z===0&&(i.z=jl(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,Al(i)}function Al(e){let t,n=1;do{let r=e,i;e=null;let a=null;for(t=0;r;){t++;let o=r,s=0;for(let e=0;e<n&&(s++,o=o.nextZ,o);e++);let c=n;for(;s>0||c>0&&o;)s!==0&&(c===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,s--):(i=o,o=o.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=o}a.nextZ=null,n*=2}while(t>1);return e}function jl(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function Ml(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function Nl(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function Pl(e,t,n,r,i,a,o,s){return!(e===o&&t===s)&&Nl(e,t,n,r,i,a,o,s)}function Fl(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Vl(e,t)&&(Hl(e,t)&&Hl(t,e)&&Ul(e,t)&&(Il(e.prev,e,t.prev)||Il(e,t.prev,t))||Ll(e,t)&&Il(e.prev,e,e.next)>0&&Il(t.prev,t,t.next)>0)}function Il(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Ll(e,t){return e.x===t.x&&e.y===t.y}function Rl(e,t,n,r){let i=Bl(Il(e,t,n)),a=Bl(Il(e,t,r)),o=Bl(Il(n,r,e)),s=Bl(Il(n,r,t));return!!(i!==a&&o!==s||i===0&&zl(e,n,t)||a===0&&zl(e,r,t)||o===0&&zl(n,e,r)||s===0&&zl(n,t,r))}function zl(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Bl(e){return e>0?1:e<0?-1:0}function Vl(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Rl(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Hl(e,t){return Il(e.prev,e,e.next)<0?Il(e,t,e.next)>=0&&Il(e,e.prev,t)>=0:Il(e,t,e.prev)<0||Il(e,e.next,t)<0}function Ul(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function Wl(e,t){let n=ql(e.i,e.x,e.y),r=ql(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function Gl(e,t,n,r){let i=ql(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Kl(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function ql(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Jl(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}var Yl=class{static triangulate(e,t,n=2){return gl(e,t,n)}},Xl=class e{static area(e){let t=e.length,n=0;for(let r=t-1,i=0;i<t;r=i++)n+=e[r].x*e[i].y-e[i].x*e[r].y;return n*.5}static isClockWise(t){return e.area(t)<0}static triangulateShape(e,t){let n=[],r=[],i=[];Zl(e),Ql(n,e);let a=e.length;t.forEach(Zl);for(let e=0;e<t.length;e++)r.push(a),a+=t[e].length,Ql(n,t[e]);let o=Yl.triangulate(n,r);for(let e=0;e<o.length;e+=3)i.push(o.slice(e,e+3));return i}};function Zl(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Ql(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}var $l=class e extends Ho{constructor(e=1,t=1,n=1,r=1){super(),this.type=`PlaneGeometry`,this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),c=o+1,l=s+1,u=e/o,d=t/s,f=[],p=[],m=[],h=[];for(let e=0;e<l;e++){let t=e*d-a;for(let n=0;n<c;n++){let r=n*u-i;p.push(r,-t,0),m.push(0,0,1),h.push(n/o),h.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){let n=t+c*e,r=t+c*(e+1),i=t+1+c*(e+1),a=t+1+c*e;f.push(n,r,a),f.push(r,i,a)}this.setIndex(f),this.setAttribute(`position`,new Ao(p,3)),this.setAttribute(`normal`,new Ao(m,3)),this.setAttribute(`uv`,new Ao(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.widthSegments,t.heightSegments)}},eu=class e extends Ho{constructor(e=.5,t=1,n=32,r=1,i=0,a=Math.PI*2){super(),this.type=`RingGeometry`,this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:i,thetaLength:a},n=Math.max(3,n),r=Math.max(1,r);let o=[],s=[],c=[],l=[],u=e,d=(t-e)/r,f=new J,p=new q;for(let e=0;e<=r;e++){for(let e=0;e<=n;e++){let r=i+e/n*a;f.x=u*Math.cos(r),f.y=u*Math.sin(r),s.push(f.x,f.y,f.z),c.push(0,0,1),p.x=(f.x/t+1)/2,p.y=(f.y/t+1)/2,l.push(p.x,p.y)}u+=d}for(let e=0;e<r;e++){let t=e*(n+1);for(let e=0;e<n;e++){let r=e+t,i=r,a=r+n+1,s=r+n+2,c=r+1;o.push(i,a,c),o.push(a,s,c)}}this.setIndex(o),this.setAttribute(`position`,new Ao(s,3)),this.setAttribute(`normal`,new Ao(c,3)),this.setAttribute(`uv`,new Ao(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}},tu=class e extends Ho{constructor(e=new hl([new q(0,.5),new q(-.5,-.5),new q(.5,-.5)]),t=12){super(),this.type=`ShapeGeometry`,this.parameters={shapes:e,curveSegments:t};let n=[],r=[],i=[],a=[],o=0,s=0;if(Array.isArray(e)===!1)c(e);else for(let t=0;t<e.length;t++)c(e[t]),this.addGroup(o,s,t),o+=s,s=0;this.setIndex(n),this.setAttribute(`position`,new Ao(r,3)),this.setAttribute(`normal`,new Ao(i,3)),this.setAttribute(`uv`,new Ao(a,2));function c(e){let o=r.length/3,c=e.extractPoints(t),l=c.shape,u=c.holes;Xl.isClockWise(l)===!1&&(l=l.reverse());for(let e=0,t=u.length;e<t;e++){let t=u[e];Xl.isClockWise(t)===!0&&(u[e]=t.reverse())}let d=Xl.triangulateShape(l,u);for(let e=0,t=u.length;e<t;e++){let t=u[e];l=l.concat(t)}for(let e=0,t=l.length;e<t;e++){let t=l[e];r.push(t.x,t.y,0),i.push(0,0,1),a.push(t.x,t.y)}for(let e=0,t=d.length;e<t;e++){let t=d[e],r=t[0]+o,i=t[1]+o,a=t[2]+o;n.push(r,i,a),s+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return nu(t,e)}static fromJSON(t,n){let r=[];for(let e=0,i=t.shapes.length;e<i;e++){let i=n[t.shapes[e]];r.push(i)}return new e(r,t.curveSegments)}};function nu(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=e[n];t.shapes.push(r.uuid)}else t.shapes.push(e.uuid);return t}var ru=class e extends Ho{constructor(e=1,t=32,n=16,r=0,i=Math.PI*2,a=0,o=Math.PI){super(),this.type=`SphereGeometry`,this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let s=Math.min(a+o,Math.PI),c=0,l=[],u=new J,d=new J,f=[],p=[],m=[],h=[];for(let f=0;f<=n;f++){let g=[],_=f/n,v=0;f===0&&a===0?v=.5/t:f===n&&s===Math.PI&&(v=-.5/t);for(let n=0;n<=t;n++){let s=n/t;u.x=-e*Math.cos(r+s*i)*Math.sin(a+_*o),u.y=e*Math.cos(a+_*o),u.z=e*Math.sin(r+s*i)*Math.sin(a+_*o),p.push(u.x,u.y,u.z),d.copy(u).normalize(),m.push(d.x,d.y,d.z),h.push(s+v,1-_),g.push(c++)}l.push(g)}for(let e=0;e<n;e++)for(let r=0;r<t;r++){let t=l[e][r+1],i=l[e][r],o=l[e+1][r],c=l[e+1][r+1];(e!==0||a>0)&&f.push(t,i,c),(e!==n-1||s<Math.PI)&&f.push(i,o,c)}this.setIndex(f),this.setAttribute(`position`,new Ao(p,3)),this.setAttribute(`normal`,new Ao(m,3)),this.setAttribute(`uv`,new Ao(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}},iu=class extends qo{constructor(e){super(),this.isShadowMaterial=!0,this.type=`ShadowMaterial`,this.color=new X(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}};function au(e){let t={};for(let n in e){t[n]={};for(let r in e[n]){let i=e[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(G(`UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().`),t[n][r]=null):t[n][r]=i.clone():Array.isArray(i)?t[n][r]=i.slice():t[n][r]=i}}return t}function ou(e){let t={};for(let n=0;n<e.length;n++){let r=au(e[n]);for(let e in r)t[e]=r[e]}return t}function su(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function cu(e){let t=e.getRenderTarget();return t===null?e.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Xi.workingColorSpace}var lu={clone:au,merge:ou},uu=`void main() {
|
|
2
|
+
var spacemap=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=[`open`,`non-commercial`,`site-only`],n={dataUrl:`https://static.spacemap.co`,imagesUrl:`https://images.spacemap.co`,liveUrl:`https://live.spacemap.co`,locale:()=>`en`,messages:{body_note_no_model:()=>`no model available`,body_note_no_radius:()=>`no size data available`,body_note_crash_site:()=>`crash site, no wreckage model`,carried_by_scene_label:({carrier:e})=>`Carried by ${e}`,scene_canvas_label:()=>`Interactive 3D map of the Solar System`,attribution_orbits:()=>`Orbits`,attribution_imagery:()=>`Imagery`,credits_see_all:()=>`See full credits`,layer_surface:()=>`Surface`,layer_clouds:()=>`Clouds`,layer_night:()=>`Night lights`,layer_graticule:()=>`Grid`,layer_nomenclature:()=>`Named features`,cooperative_wheel:()=>`Use ctrl + scroll to zoom the map`,cooperative_wheel_mac:()=>`Use ⌘ + scroll to zoom the map`,cooperative_touch:()=>`Use two fingers to move the map`,planetary_system_primary:()=>`primary`,planetary_system_retrograde:()=>`retrograde`,planetary_system_axis_unit:()=>`primary radii · log`,tab_rings:()=>`Rings`,system_map_solar_system:()=>`Solar System`,system_map_moons:({count:e})=>e===1?`1 moon`:`${e} moons`,system_map_zone_inner:()=>`Inner asteroids & comets`,system_map_zone_outer:()=>`Outer asteroids & comets`,unit_symbol_astronomical_unit:()=>`AU`,system_map_axis_au:()=>`AU · log`},bodyHref:()=>``,textures:`open`},r=n;function i(e){let{messages:t,...i}=e;r={...n,...i},t&&(r.messages={...n.messages,...t}),r.dataUrl=r.dataUrl.replace(/\/$/,``),r.imagesUrl=r.imagesUrl.replace(/\/$/,``),r.liveUrl=r.liveUrl.replace(/\/$/,``)}function a(){return r}function o(e){if(e===void 0)return!0;let n=t.indexOf(e);return n<0?!1:n<=t.indexOf(r.textures)}function s(e){for(let t of e)if(t&&o(t.distribution))return t}function c(){return r.locale()}var l=Symbol(`uninitialized`),u=Array.isArray,d=Array.prototype.indexOf,f=Array.prototype.includes;Array.from;var p=Object.getOwnPropertyDescriptor,m=Object.prototype,h=Array.prototype,g=Object.getPrototypeOf,_=()=>{};function v(e){for(var t=0;t<e.length;t++)e[t]()}function y(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}var b=1024,x=2048,S=4096,C=8192,w=16384,T=32768,E=1<<25,D=65536,O=1<<19,k=1<<20,A=65536,j=1<<21,M=1<<23,ee=Symbol(`$state`),N=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"};globalThis.document?.contentType;function te(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function ne(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function re(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function P(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function ie(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function ae(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function F(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function I(){console.warn(`https://svelte.dev/e/derived_inert`)}function oe(e){return e===this.v}var se=!1,ce=!1,le=null;function ue(e){le=e}function de(){return!ce||le!==null&&le.l===null}var fe=[];function pe(){var e=fe;fe=[],v(e)}function me(e){if(fe.length===0&&!we){var t=fe;queueMicrotask(()=>{t===fe&&pe()})}fe.push(e)}function he(e){var t=wt;if(t===null)return xt.f|=M,e;if(!(t.f&32768)&&!(t.f&4))throw e;L(e,t)}function L(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 ge=~(x|S|b);function R(e,t){e.f=e.f&ge|t}function _e(e){e.f&512||e.deps===null?R(e,b):R(e,S)}function z(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=A,z(t.deps))}function ve(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),z(e.deps),R(e,b)}var B=!1,V=null,ye=null,be=null,xe=null,Se=null,Ce=null,we=!1,Te=!1,H=null,Ee=null,De=0,Oe=1,ke=class e{id=Oe++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;#r=new Set;#i=new Set;#a=0;#o=new Map;#s=null;#c=[];#l=[];#u=new Set;#d=new Set;#f=new Map;#p=new Set;is_fork=!1;#m=!1;constructor(){ye===null?V=ye=this:(ye.#n=this,this.#t=ye),ye=this}#h(){if(this.is_fork)return!0;for(let n of this.#o.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#f.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#f.has(e)||this.#f.set(e,{d:[],m:[]}),this.#p.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#f.get(e);if(n){this.#f.delete(e);for(var r of n.d)R(r,x),t(r);for(r of n.m)R(r,S),t(r)}this.#p.add(e)}#g(){this.#e=!0,De++>1e3&&(this.#S(),Ae());for(let e of this.#u)this.#d.delete(e),R(e,x),this.schedule(e);for(let e of this.#d)R(e,S),this.schedule(e);let t=this.#c;this.#c=[],this.apply();var n=H=[],r=[],i=Ee=[];for(let e of t)try{this.#_(e,n,r)}catch(t){throw Le(e),this.#h()||this.discard(),t}if(be=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(H=null,Ee=null,this.#h()){this.#b(r),this.#b(n);for(let[e,t]of this.#f)Ie(e,t);i.length>0&&be.#g();return}let o=this.#v();if(o){this.#b(r),this.#b(n),o.#y(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),xe=this,Me(r),Me(n),xe=null,this.#s?.resolve();var s=be;if(this.#a===0&&(this.#c.length===0||s!==null)&&(this.#S(),se&&(this.#x(),be=s)),this.#c.length>0)if(s!==null){let e=s;e.#c.push(...this.#c.filter(t=>!e.#c.includes(t)))}else s=this;s!==null&&s.#g()}#_(e,t,n){e.f^=b;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=b:i&4?t.push(r):se&&i&16777224?n.push(r):Lt(r)&&(i&16&&this.#d.add(r),Ht(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#v(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#y(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}this.transfer_effects(e.#u,e.#d);let t=e=>{var n=e.reactions;if(n!==null)for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#d.delete(i),R(i,x),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),be=this,this.#g()}#b(e){for(var t=0;t<e.length;t+=1)ve(e[t],this.#u,this.#d)}capture(e,t,n=!1){e.v!==l&&!this.previous.has(e)&&this.previous.set(e,e.v),e.f&8388608||(this.current.set(e,[t,n]),Se?.set(e,t)),this.is_fork||(e.v=t)}activate(){be=this}deactivate(){be=null,Se=null}flush(){try{Te=!0,be=this,this.#g()}finally{De=0,Ce=null,H=null,Ee=null,Te=!1,be=null,Se=null,We.clear()}}discard(){for(let e of this.#i)e(this);this.#i.clear(),this.#S(),this.#s?.resolve()}register_created_effect(e){this.#l.push(e)}#x(){for(let l=V;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).catch(n.reject)}if(l.#e){var r=[...l.current.keys()].filter(e=>!l.current.get(e)[1]&&!this.current.has(e));if(r.length===0)e&&l.discard();else if(t.length>0){if(e)for(let e of this.#p)l.unskip_effect(e,e=>{e.f&4194320?l.schedule(e):l.#b([e])});l.activate();var i=new Set,a=new Map;for(var o of t)Ne(o,r,i,a);a=new Map;var s=[...l.current].filter(([e,t])=>{let n=this.current.get(e);return n?n[0]!==t[0]||n[1]!==t[1]:!0}).map(([e])=>e);if(s.length>0)for(let e of this.#l)!(e.f&155648)&&Pe(e,s,a)&&(e.f&4194320?(R(e,x),l.schedule(e)):l.#u.add(e));if(l.#c.length>0&&!l.#m){l.apply();for(var c of l.#c)l.#_(c,[],[]);l.#c=[]}l.deactivate()}}}}increment(e,t){if(this.#a+=1,e){let e=this.#o.get(t)??0;this.#o.set(t,e+1)}}decrement(e,t){if(--this.#a,e){let e=this.#o.get(t)??0;e===1?this.#o.delete(t):this.#o.set(t,e-1)}this.#m||(this.#m=!0,me(()=>{this.#m=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#u.add(t);for(let e of t)this.#d.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}settled(){return(this.#s??=y()).promise}static ensure(){if(be===null){let t=be=new e;!Te&&!we&&me(()=>{t.#e||t.flush()})}return be}apply(){if(!se||!this.is_fork&&this.#t===null&&this.#n===null){Se=null;return}Se=new Map;for(let[e,[t]]of this.current)Se.set(e,t);for(let t=V;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)Se.has(e)||Se.set(e,n)}}schedule(e){if(Ce=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(H!==null&&t===wt&&(se||(xt===null||!(xt.f&2))&&!B))return;if(n&96){if(!(n&1024))return;t.f^=b}}this.#c.push(t)}#S(){if(this.linked){var e=this.#t,t=this.#n;e===null?V=t:e.#n=t,t===null?ye=e:t.#t=e,this.linked=!1}}};function Ae(){try{P()}catch(e){L(e,Ce)}}var je=null;function Me(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if(!(r.f&24576)&&Lt(r)&&(je=new Set,Ht(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&ht(r),je?.size>0)){We.clear();for(let e of je){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)je.has(n)&&(je.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Ht(n)}}je.clear()}}je=null}}function Ne(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?Ne(i,t,n,r):e&4194320&&!(e&2048)&&Pe(i,t,r)&&(R(i,x),Fe(i))}}function Pe(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(f.call(t,r))return!0;if(r.f&2&&Pe(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function Fe(e){be.schedule(e)}function Ie(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),R(e,b);for(var n=e.first;n!==null;)Ie(n,t),n=n.next}}function Le(e){R(e,b);for(var t=e.first;t!==null;)Le(t),t=t.next}D|O;function Re(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)pt(t[n])}}function ze(e){var t,n=wt,r=e.parent;if(!yt&&r!==null&&e.v!==l&&r.f&24576)return I(),e.v;Tt(r);try{e.f&=~A,Re(e),t=zt(e)}finally{Tt(n)}return t}function Be(e){var t=ze(e);if(!e.equals(t)&&(e.wv=It(),(!be?.is_fork||e.deps===null)&&(be===null?e.v=t:(be.capture(e,t,!0),xe?.capture(e,t,!0)),e.deps===null))){R(e,b);return}yt||(Se===null?_e(e):(ot()||be?.is_fork)&&Se.set(e,t))}function Ve(e){if(e.effects!==null)for(let t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),t.ac?.abort(N),t.fn!==null&&(t.teardown=_),t.ac=null,Vt(t,0),dt(t))}function He(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&Ht(t)}var Ue=new Set,We=new Map,Ge=!1;function Ke(e,t){return{f:0,v:e,reactions:null,equals:oe,rv:0,wv:0}}function qe(e,t){let n=Ke(e,t);return Dt(n),n}function Je(e,t,n=!1){return xt!==null&&(!St||xt.f&131072)&&de()&&xt.f&4325394&&(Et===null||!Et.has(e))&&F(),Ye(e,n?$e(t):t,Ee)}function Ye(e,t,n=null){if(!e.equals(t)){We.set(e,yt?t:e.v);var r=ke.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&ze(t),Se===null&&_e(t)}e.wv=It(),Qe(e,x,n),de()&&wt!==null&&wt.f&1024&&!(wt.f&96)&&(At===null?jt([e]):At.push(e)),!r.is_fork&&Ue.size>0&&!Ge&&Xe()}return t}function Xe(){Ge=!1;for(let e of Ue){e.f&1024&&R(e,S);let t;try{t=Lt(e)}catch{t=!0}t&&Ht(e)}Ue.clear()}function Ze(e){Je(e,e.v+1)}function Qe(e,t,n){var r=e.reactions;if(r!==null)for(var i=de(),a=r.length,o=0;o<a;o++){var s=r[o],c=s.f;if(!(!i&&s===wt)){var l=(c&x)===0;if(l&&R(s,t),c&131072)Ue.add(s);else if(c&2){var u=s;Se?.delete(u),c&65536||(c&512&&(wt===null||!(wt.f&2097152))&&(s.f|=A),Qe(u,S,n))}else if(l){var d=s;c&16&&je!==null&&je.add(d),n===null?Fe(d):n.push(d)}}}}function $e(e){if(typeof e!=`object`||!e||ee in e)return e;let t=g(e);if(t!==m&&t!==h)return e;var n=new Map,r=u(e),i=qe(0),a=null,o=Pt,s=e=>{if(Pt===o)return e();var t=xt,n=Pt;Ct(null),Ft(o);var r=e();return Ct(t),Ft(n),r};return r&&n.set(`length`,qe(e.length,a)),new Proxy(e,{defineProperty(e,t,r){(!(`value`in r)||r.configurable===!1||r.enumerable===!1||r.writable===!1)&&ie();var i=n.get(t);return i===void 0?s(()=>{var e=qe(r.value,a);return n.set(t,e),e}):Je(i,r.value,!0),!0},deleteProperty(e,t){var r=n.get(t);if(r===void 0){if(t in e){let e=s(()=>qe(l,a));n.set(t,e),Ze(i)}}else Je(r,l),Ze(i);return!0},get(t,r,i){if(r===ee)return e;var o=n.get(r),c=r in t;if(o===void 0&&(!c||p(t,r)?.writable)&&(o=s(()=>qe($e(c?t[r]:l),a)),n.set(r,o)),o!==void 0){var u=Ut(o);return u===l?void 0:u}return Reflect.get(t,r,i)},getOwnPropertyDescriptor(e,t){var r=Reflect.getOwnPropertyDescriptor(e,t);if(r&&`value`in r){var i=n.get(t);i&&(r.value=Ut(i))}else if(r===void 0){var a=n.get(t),o=a?.v;if(a!==void 0&&o!==l)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return r},has(e,t){if(t===ee)return!0;var r=n.get(t),i=r!==void 0&&r.v!==l||Reflect.has(e,t);return(r!==void 0||wt!==null&&(!i||p(e,t)?.writable))&&(r===void 0&&(r=s(()=>qe(i?$e(e[t]):l,a)),n.set(t,r)),Ut(r)===l)?!1:i},set(e,t,o,c){var u=n.get(t),d=t in e;if(r&&t===`length`)for(var f=o;f<u.v;f+=1){var m=n.get(f+``);m===void 0?f in e&&(m=s(()=>qe(l,a)),n.set(f+``,m)):Je(m,l)}if(u===void 0)(!d||p(e,t)?.writable)&&(u=s(()=>qe(void 0,a)),Je(u,$e(o)),n.set(t,u));else{d=u.v!==l;var h=s(()=>$e(o));Je(u,h)}var g=Reflect.getOwnPropertyDescriptor(e,t);if(g?.set&&g.set.call(c,o),!d){if(r&&typeof t==`string`){var _=n.get(`length`),v=Number(t);Number.isInteger(v)&&v>=_.v&&Je(_,v+1)}Ze(i)}return!0},ownKeys(e){Ut(i);var t=Reflect.ownKeys(e).filter(e=>{var t=n.get(e);return t===void 0||t.v!==l});for(var[r,a]of n)a.v!==l&&!(r in e)&&t.push(r);return t},setPrototypeOf(){ae()}})}var et;function tt(e){return et.call(e)}function nt(e){var t=xt,n=wt;Ct(null),Tt(null);try{return e()}finally{Ct(t),Tt(n)}}function rt(e){wt===null&&(xt===null&&re(e),ne()),yt&&te(e)}function it(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function at(e,t){var n=wt;n!==null&&n.f&8192&&(e|=C);var r={ctx:le,deps:null,nodes:null,f:e|x|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};be?.register_created_effect(r);var i=r;if(e&4)H===null?ke.ensure().schedule(r):H.push(r);else if(t!==null){try{Ht(r)}catch(e){throw pt(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&&it(i,n),xt!==null&&xt.f&2&&!(e&64))){var a=xt;(a.effects??=[]).push(i)}return r}function ot(){return xt!==null&&!St}function st(e){rt(`$effect`);var t=wt.f;if(!xt&&t&32&&le!==null&&!le.i){var n=le;(n.e??=[]).push(e)}else return ct(e)}function ct(e){return at(4|k,e)}function lt(e){ke.ensure();let t=at(64|O,e);return()=>{pt(t)}}function ut(e){var t=e.teardown;if(t!==null){let e=yt,n=xt;bt(!0),Ct(null);try{t.call(null)}finally{bt(e),Ct(n)}}}function dt(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&nt(()=>{e.abort(N)});var r=n.next;n.f&64?n.parent=null:pt(n,t),n=r}}function ft(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||pt(t),t=n}}function pt(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(mt(e.nodes.start,e.nodes.end),n=!0),e.f|=E,dt(e,t&&!n),Vt(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();ut(e),e.f^=E,e.f|=w;var i=e.parent;i!==null&&i.first!==null&&ht(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function mt(e,t){for(;e!==null;){var n=e===t?null:tt(e);e.remove(),e=n}}function ht(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 gt(e,t,n){if(!(e.f&8192)){e.f^=C;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;gt(i,t,o?n:!1)}i=a}}}var _t=null,vt=!1,yt=!1;function bt(e){yt=e}var xt=null,St=!1;function Ct(e){xt=e}var wt=null;function Tt(e){wt=e}var Et=null;function Dt(e){xt!==null&&(!se||xt.f&2)&&(Et??=new Set).add(e)}var Ot=null,kt=0,At=null;function jt(e){At=e}var Mt=1,Nt=0,Pt=Nt;function Ft(e){Pt=e}function It(){return++Mt}function Lt(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~A),t&4096){for(var n=e.deps,r=n.length,i=0;i<r;i++){var a=n[i];if(Lt(a)&&Be(a),a.wv>e.wv)return!0}t&512&&Se===null&&R(e,b)}return!1}function Rt(e,t,n=!0){var r=e.reactions;if(r!==null&&!(!se&&Et!==null&&Et.has(e)))for(var i=0;i<r.length;i++){var a=r[i];a.f&2?Rt(a,t,!1):t===a&&(n?R(a,x):a.f&1024&&R(a,S),Fe(a))}}function zt(e){var t=Ot,n=kt,r=At,i=xt,a=Et,o=le,s=St,c=Pt,l=e.f;Ot=null,kt=0,At=null,xt=l&96?null:e,Et=null,ue(e.ctx),St=!1,Pt=++Nt,e.ac!==null&&(nt(()=>{e.ac.abort(N)}),e.ac=null);try{e.f|=j;var u=e.fn,d=u();e.f|=T;var f=e.deps,p=be?.is_fork;if(Ot!==null){var m;if(p||Vt(e,kt),f!==null&&kt>0)for(f.length=kt+Ot.length,m=0;m<Ot.length;m++)f[kt+m]=Ot[m];else e.deps=f=Ot;if(ot()&&e.f&512)for(m=kt;m<f.length;m++)(f[m].reactions??=[]).push(e)}else !p&&f!==null&&kt<f.length&&(Vt(e,kt),f.length=kt);if(de()&&At!==null&&!St&&f!==null&&!(e.f&6146))for(m=0;m<At.length;m++)Rt(At[m],e);if(i!==null&&i!==e){if(Nt++,i.deps!==null)for(let e=0;e<n;e+=1)i.deps[e].rv=Nt;if(t!==null)for(let e of t)e.rv=Nt;At!==null&&(r===null?r=At:r.push(...At))}return e.f&8388608&&(e.f^=M),d}catch(e){return he(e)}finally{e.f^=j,Ot=t,kt=n,At=r,xt=i,Et=a,ue(o),St=s,Pt=c}}function Bt(e,t){let n=t.reactions;if(n!==null){var r=d.call(n,e);if(r!==-1){var i=n.length-1;i===0?n=t.reactions=null:(n[r]=n[i],n.pop())}}if(n===null&&t.f&2&&(Ot===null||!f.call(Ot,t))){var a=t;a.f&512&&(a.f^=512,a.f&=~A),a.v!==l&&_e(a),Ve(a),Vt(a,0)}}function Vt(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)Bt(e,n[r])}function Ht(e){var t=e.f;if(!(t&16384)){R(e,b);var n=wt,r=vt;wt=e,vt=!0;try{t&16777232?ft(e):dt(e),ut(e);var i=zt(e);e.teardown=typeof i==`function`?i:null,e.wv=Mt}finally{vt=r,wt=n}}}function Ut(e){var t=(e.f&2)!=0;if(_t?.add(e),xt!==null&&!St&&!(wt!==null&&wt.f&16384)&&(Et===null||!Et.has(e))){var n=xt.deps;if(xt.f&2097152)e.rv<Nt&&(e.rv=Nt,Ot===null&&n!==null&&n[kt]===e?kt++:Ot===null?Ot=[e]:Ot.push(e));else{xt.deps??=[],f.call(xt.deps,e)||xt.deps.push(e);var r=e.reactions;r===null?e.reactions=[xt]:f.call(r,xt)||r.push(xt)}}if(yt&&We.has(e))return We.get(e);if(t){var i=e;if(yt){var a=i.v;return(!(i.f&1024)&&i.reactions!==null||Gt(i))&&(a=ze(i)),We.set(i,a),a}var o=(i.f&512)==0&&!St&&xt!==null&&(vt||(xt.f&512)!=0),s=(i.f&T)===0;Lt(i)&&(o&&(i.f|=512),Be(i)),o&&!s&&(He(i),Wt(i))}if(Se?.has(e))return Se.get(e);if(e.f&8388608)throw e.v;return e.v}function Wt(e){if(e.f|=512,e.deps!==null)for(let t of e.deps)(t.reactions??=[]).push(e),t.f&2&&!(t.f&512)&&(He(t),Wt(t))}function Gt(e){if(e.v===l)return!0;if(e.deps===null)return!1;for(let t of e.deps)if(We.has(t)||t.f&2&&Gt(t))return!0;return!1}globalThis?.window?.trustedTypes,[...`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(`.`)];function Kt(){return a().dataUrl}var qt={};function Jt(e){qt=e??{}}function Yt(e,t){return Xt(Kt(),e,t)}function Xt(e,t,n){let r=qt[n];return r?`${e}${t}?v=${r}`:(console.error(`versionedUrl: missing '${n}' token for ${t}`),`${e}${t}`)}var Zt=32,Qt=e=>`${Kt()}/v1/labels/${e}.gz`;function $t(e){return e===null?``:`${e}/`}function en(e,t,n){return Yt(`/v1/position/${e}/${$t(t)}${n}.bin.gz`,`position`)}function tn(e,t,n,r){return Yt(`/v1/position/${e}/${$t(t)}${n}/${r}.bin.gz`,`position`)}function nn(e,t,n){return Yt(`/v1/position/${e}/${$t(t)}${n}.bin.gz`,`position`)}var rn=function(e){return e[e.PLANET=0]=`PLANET`,e[e.SYSTEM=1]=`SYSTEM`,e}({}),U=function(e){return e[e.HORIZONS=0]=`HORIZONS`,e[e.SBDB=1]=`SBDB`,e[e.CELESTRAK=2]=`CELESTRAK`,e[e.SPICE=3]=`SPICE`,e[e.SBDB_MOON=4]=`SBDB_MOON`,e[e.SPICE_PROBE=5]=`SPICE_PROBE`,e[e.SPACETRACK=6]=`SPACETRACK`,e[e.ASTERSAT=7]=`ASTERSAT`,e[e.UNKNOWN=255]=`UNKNOWN`,e}({}),an=function(e){return e[e.NAIF=0]=`NAIF`,e[e.SPKID=1]=`SPKID`,e[e.NORAD_SATCAT=2]=`NORAD_SATCAT`,e[e.PROBE=4]=`PROBE`,e[e.UNKNOWN=255]=`UNKNOWN`,e}({}),on={[an.NAIF]:`naif`,[an.SPKID]:`spkid`,[an.NORAD_SATCAT]:`norad_satcat`,[an.PROBE]:`probe`},sn=new Map(Object.entries(on).map(([e,t])=>[t,Number(e)]));function cn(e){return sn.get(e)}function ln(e,t){let n=on[e];return n?`${n}-${t}`:null}function un(e){return e.data.objectType===W.SURFACE_FEATURE}var W=function(e){return e[e.BARYCENTER=0]=`BARYCENTER`,e[e.LAGRANGE_POINT=1]=`LAGRANGE_POINT`,e[e.STAR=2]=`STAR`,e[e.PLANET=3]=`PLANET`,e[e.DWARF_PLANET=4]=`DWARF_PLANET`,e[e.MOON=5]=`MOON`,e[e.ASTEROID=6]=`ASTEROID`,e[e.ASTEROID_INNER=7]=`ASTEROID_INNER`,e[e.ASTEROID_MAIN_BELT=8]=`ASTEROID_MAIN_BELT`,e[e.ASTEROID_TROJAN=9]=`ASTEROID_TROJAN`,e[e.ASTEROID_CENTAUR=10]=`ASTEROID_CENTAUR`,e[e.ASTEROID_TNO=11]=`ASTEROID_TNO`,e[e.COMET=12]=`COMET`,e[e.SPACECRAFT=13]=`SPACECRAFT`,e[e.DEBRIS=14]=`DEBRIS`,e[e.UNDOCUMENTED=15]=`UNDOCUMENTED`,e[e.SURFACE_FEATURE=16]=`SURFACE_FEATURE`,e}({}),dn={IEO:{minA:0,maxA:.983},ATE:{minA:.5,maxA:1},APO:{minA:1,maxA:3.2},AMO:{minA:1,maxA:3.2},MCA:{minA:1.3,maxA:3.2},IMB:{minA:1.666,maxA:2},MBA:{minA:2,maxA:3.2},OMB:{minA:3.2,maxA:4.6},ETc:{minA:0,maxA:5.5},JFC:{minA:0,maxA:15},TJN:{minA:4.6,maxA:5.5},CEN:{minA:5.5,maxA:30.1},TNO:{minA:30.1,maxA:1/0},earth:{minA:0,maxA:3e-4}};function fn(e,t){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t))return null;let n=e*(1-t);return e*(1+t)<.983?`IEO`:e<1?`ATE`:n<1.017?`APO`:n<1.3?`AMO`:n<1.666&&e<3.2?`MCA`:e<2?`IMB`:e<3.2?`MBA`:e<4.6?`OMB`:e<5.5&&t<.3?`TJN`:e<30.1?`CEN`:`TNO`}var pn={[U.SPICE_PROBE]:.005,[U.SBDB_MOON]:.01,[U.ASTERSAT]:.01},mn={[W.SPACECRAFT]:.005,[W.DEBRIS]:.005,[W.SURFACE_FEATURE]:.001},hn=.1;function gn(e){return Number.isFinite(e.radiusKm)&&e.radiusKm>0?e.radiusKm:pn[e.orbitalSource]??mn[e.objectType]??hn}function _n(e){return e>=W.ASTEROID&&e<=W.ASTEROID_TNO}function vn(e){return e===W.STAR||e===W.PLANET||e===W.DWARF_PLANET||e===W.MOON}function yn(e){return vn(e)||_n(e)||e===W.COMET}var bn={[U.HORIZONS]:{archive:`horizons`,label:`NASA`},[U.SBDB]:{archive:`sbdb`,label:`NASA`},[U.SPICE]:{archive:`naif`,label:`NASA`},[U.SBDB_MOON]:{archive:`sbdb`,label:`NASA`,scoped:!0},[U.ASTERSAT]:{archive:`nsdb`,label:`Natural Satellites Data Base`,scoped:!0},[U.SPICE_PROBE]:{archive:`naif`,label:`NASA`},[U.CELESTRAK]:{archive:`celestrak`,label:`CelesTrak`,scoped:!0},[U.SPACETRACK]:{archive:`spacetrack`,label:`Space-Track.org`,scoped:!0}},xn=[U.HORIZONS,U.SBDB,U.SPICE,U.SBDB_MOON,U.ASTERSAT,U.SPICE_PROBE,U.CELESTRAK,U.SPACETRACK];function Sn(e){return bn[e]}var Cn=class{imagery=new Map;#e=qe(0);get imageryVersion(){return Ut(this.#e)}set imageryVersion(e){Je(this.#e,e,!0)}model=new Map;#t=qe(0);get modelVersion(){return Ut(this.#t)}set modelVersion(e){Je(this.#t,e,!0)}orientation=new Map;#n=qe(0);get orientationVersion(){return Ut(this.#n)}set orientationVersion(e){Je(this.#n,e,!0)}#r=qe(null);get skybox(){return Ut(this.#r)}set skybox(e){Je(this.#r,e,!0)}#i=qe($e(new Set));get orbitSources(){return Ut(this.#i)}set orbitSources(e){Je(this.#i,e,!0)}#a=qe($e(new Map));get orbitSourceParents(){return Ut(this.#a)}set orbitSourceParents(e){Je(this.#a,e,!0)}registerImagery(e,t,n,r){let i=e===`rings`?`${e}${t}${r.source}`:`${e}${t}`;if(this.imagery.has(i))return;let{source:a,organisation:o,license:s,attribution:c,description:l}=r;this.imagery.set(i,{layer:e,bodyId:t,systemId:n,source:a,organisation:o,license:s,attribution:c,description:l}),this.imageryVersion++}imageryOf(e){return[...this.imagery.values()].filter(t=>t.layer===e)}registerOrientation(e){this.orientation.has(e.bodyId)||(this.orientation.set(e.bodyId,e),this.orientationVersion++)}registerModel(e){this.model.has(e.bodyId)||(this.model.set(e.bodyId,e),this.modelVersion++)}recordOrbitSources(e){let t=!1,n=!1;for(let r of e){let e=r.data.orbitalSource;if(e===U.UNKNOWN||(this.orbitSources.has(e)||(this.orbitSources.add(e),t=!0),!Sn(e)?.scoped))continue;let i=this.orbitSourceParents.get(e);i||(i=new Set,this.orbitSourceParents.set(e,i)),!i.has(r.data.parentId)&&(i.add(r.data.parentId),n=!0)}t&&(this.orbitSources=new Set(this.orbitSources)),n&&(this.orbitSourceParents=new Map(this.orbitSourceParents))}recordOrbitSource(e){e===U.UNKNOWN||this.orbitSources.has(e)||(this.orbitSources.add(e),this.orbitSources=new Set(this.orbitSources))}},wn={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Tn={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},En=`attached`,Dn=1e3,On=1001,kn=1002,An=1003,jn=1004,Mn=1005,Nn=1006,Pn=1007,Fn=1008,In=1009,Ln=1010,Rn=1011,zn=1012,Bn=1013,Vn=1014,Hn=1015,Un=1016,Wn=1017,Gn=1018,Kn=1020,qn=35902,Jn=35899,Yn=1021,Xn=1022,Zn=1023,Qn=1026,$n=1027,er=1028,tr=1029,nr=1030,rr=1031,ir=1033,ar=33776,or=33777,sr=33778,cr=33779,lr=35840,ur=35841,dr=35842,fr=35843,pr=36196,mr=37492,hr=37496,gr=37488,_r=37489,vr=37490,yr=37491,br=37808,xr=37809,Sr=37810,Cr=37811,wr=37812,Tr=37813,Er=37814,Dr=37815,Or=37816,kr=37817,Ar=37818,jr=37819,Mr=37820,Nr=37821,Pr=36492,Fr=36494,Ir=36495,Lr=36283,Rr=36284,zr=36285,Br=36286,Vr=2300,Hr=2301,Ur=2302,Wr=2303,Gr=2400,Kr=2401,qr=2402,Jr=2500,Yr=3200,Xr=`srgb`,Zr=`srgb-linear`,Qr=`linear`,$r=`srgb`,ei=7680,ti=35044,ni=2e3;function ri(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function ii(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ai(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function oi(){let e=ai(`canvas`);return e.style.display=`block`,e}var si={},ci=null;function li(...e){let t=`THREE.`+e.shift();ci?ci(`log`,t,...e):console.log(t,...e)}function ui(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function G(...e){e=ui(e);let t=`THREE.`+e.shift();if(ci)ci(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function K(...e){e=ui(e);let t=`THREE.`+e.shift();if(ci)ci(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function di(...e){let t=e.join(` `);t in si||(si[t]=!0,G(...e))}function fi(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}var pi={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},mi=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}},hi=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`),gi=1234567,_i=Math.PI/180,vi=180/Math.PI;function yi(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(hi[e&255]+hi[e>>8&255]+hi[e>>16&255]+hi[e>>24&255]+`-`+hi[t&255]+hi[t>>8&255]+`-`+hi[t>>16&15|64]+hi[t>>24&255]+`-`+hi[n&63|128]+hi[n>>8&255]+`-`+hi[n>>16&255]+hi[n>>24&255]+hi[r&255]+hi[r>>8&255]+hi[r>>16&255]+hi[r>>24&255]).toLowerCase()}function bi(e,t,n){return Math.max(t,Math.min(n,e))}function xi(e,t){return(e%t+t)%t}function Si(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function Ci(e,t,n){return e===t?0:(n-e)/(t-e)}function wi(e,t,n){return(1-n)*e+n*t}function Ti(e,t,n,r){return wi(e,t,1-Math.exp(-n*r))}function Ei(e,t=1){return t-Math.abs(xi(e,t*2)-t)}function Di(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function Oi(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function ki(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Ai(e,t){return e+Math.random()*(t-e)}function ji(e){return e*(.5-Math.random())}function Mi(e){e!==void 0&&(gi=e);let t=gi+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Ni(e){return e*_i}function Pi(e){return e*vi}function Fi(e){return(e&e-1)==0&&e!==0}function Ii(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function Li(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function Ri(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:G(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function zi(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function Bi(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}var Vi={DEG2RAD:_i,RAD2DEG:vi,generateUUID:yi,clamp:bi,euclideanModulo:xi,mapLinear:Si,inverseLerp:Ci,lerp:wi,damp:Ti,pingpong:Ei,smoothstep:Di,smootherstep:Oi,randInt:ki,randFloat:Ai,randFloatSpread:ji,seededRandom:Mi,degToRad:Ni,radToDeg:Pi,isPowerOfTwo:Fi,ceilPowerOfTwo:Ii,floorPowerOfTwo:Li,setQuaternionFromProperEuler:Ri,normalize:Bi,denormalize:zi},q=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=bi(this.x,e.x,t.x),this.y=bi(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=bi(this.x,e,t),this.y=bi(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(bi(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(bi(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Hi=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:G(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(bi(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},J=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Wi.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Wi.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=bi(this.x,e.x,t.x),this.y=bi(this.y,e.y,t.y),this.z=bi(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=bi(this.x,e,t),this.y=bi(this.y,e,t),this.z=bi(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(bi(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Ui.copy(this).projectOnVector(e),this.sub(Ui)}reflect(e){return this.sub(Ui.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(bi(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Ui=new J,Wi=new Hi,Gi=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,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];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,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=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Ki.makeScale(e,t)),this}rotate(e){return this.premultiply(Ki.makeRotation(-e)),this}translate(e,t){return this.premultiply(Ki.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Ki=new Gi,qi=new Gi().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ji=new Gi().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Yi(){let e={enabled:!0,workingColorSpace:Zr,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=Zi(e.r),e.g=Zi(e.g),e.b=Zi(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=Qi(e.r),e.g=Qi(e.g),e.b=Qi(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?Qr:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return di(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return di(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[Zr]:{primaries:t,whitePoint:r,transfer:Qr,toXYZ:qi,fromXYZ:Ji,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Xr},outputColorSpaceConfig:{drawingBufferColorSpace:Xr}},[Xr]:{primaries:t,whitePoint:r,transfer:$r,toXYZ:qi,fromXYZ:Ji,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Xr}}}),e}var Xi=Yi();function Zi(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Qi(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var $i,ea=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{$i===void 0&&($i=ai(`canvas`)),$i.width=e.width,$i.height=e.height;let t=$i.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=$i}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=ai(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=Zi(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(Zi(t[e]/255)*255):t[e]=Zi(t[e]);return{data:t,width:e.width,height:e.height}}else return G(`ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}},ta=0,na=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,`id`,{value:ta++}),this.uuid=yi(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<`u`&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(ra(r[t].image)):e.push(ra(r[t]))}else e=ra(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function ra(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?ea.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(G(`Texture: Unable to serialize Texture.`),{})}var ia=0,aa=new J,oa=class e extends mi{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=On,i=On,a=Nn,o=Fn,s=Zn,c=In,l=e.DEFAULT_ANISOTROPY,u=``){super(),this.isTexture=!0,Object.defineProperty(this,`id`,{value:ia++}),this.uuid=yi(),this.name=``,this.source=new na(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new q(0,0),this.repeat=new q(1,1),this.center=new q(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Gi,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(aa).x}get height(){return this.source.getSize(aa).y}get depth(){return this.source.getSize(aa).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){G(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){G(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Dn:e.x-=Math.floor(e.x);break;case On:e.x=e.x<0?0:1;break;case kn:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Dn:e.y-=Math.floor(e.y);break;case On:e.y=e.y<0?0:1;break;case kn:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};oa.DEFAULT_IMAGE=null,oa.DEFAULT_MAPPING=300,oa.DEFAULT_ANISOTROPY=1;var sa=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=bi(this.x,e.x,t.x),this.y=bi(this.y,e.y,t.y),this.z=bi(this.z,e.z,t.z),this.w=bi(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=bi(this.x,e,t),this.y=bi(this.y,e,t),this.z=bi(this.z,e,t),this.w=bi(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(bi(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},ca=class extends mi{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Nn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new sa(0,0,e,t),this.scissorTest=!1,this.viewport=new sa(0,0,e,t),this.textures=[];let r=new oa({width:e,height:t,depth:n.depth}),i=n.count;for(let e=0;e<i;e++)this.textures[e]=r.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:Nn,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new na(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:`dispose`})}},la=class extends ca{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},ua=class extends oa{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=An,this.minFilter=An,this.wrapR=On,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},da=class extends oa{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=An,this.minFilter=An,this.wrapR=On,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Y=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();let t=this.elements,n=e.elements,r=1/fa.setFromMatrixColumn(e,0).length(),i=1/fa.setFromMatrixColumn(e,1).length(),a=1/fa.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(ma,e,ha)}lookAt(e,t,n){let r=this.elements;return va.subVectors(e,t),va.lengthSq()===0&&(va.z=1),va.normalize(),ga.crossVectors(n,va),ga.lengthSq()===0&&(Math.abs(n.z)===1?va.x+=1e-4:va.z+=1e-4,va.normalize(),ga.crossVectors(n,va)),ga.normalize(),_a.crossVectors(va,ga),r[0]=ga.x,r[4]=_a.x,r[8]=va.x,r[1]=ga.y,r[5]=_a.y,r[9]=va.y,r[2]=ga.z,r[6]=_a.z,r[10]=va.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],A=r[6],j=r[10],M=r[14],ee=r[3],N=r[7],te=r[11],ne=r[15];return i[0]=a*x+o*T+s*k+c*ee,i[4]=a*S+o*E+s*A+c*N,i[8]=a*C+o*D+s*j+c*te,i[12]=a*w+o*O+s*M+c*ne,i[1]=l*x+u*T+d*k+f*ee,i[5]=l*S+u*E+d*A+f*N,i[9]=l*C+u*D+d*j+f*te,i[13]=l*w+u*O+d*M+f*ne,i[2]=p*x+m*T+h*k+g*ee,i[6]=p*S+m*E+h*A+g*N,i[10]=p*C+m*D+h*j+g*te,i[14]=p*w+m*O+h*M+g*ne,i[3]=_*x+v*T+y*k+b*ee,i[7]=_*S+v*E+y*A+b*N,i[11]=_*C+v*D+y*j+b*te,i[15]=_*w+v*O+y*M+b*ne,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15],_=s*f-c*d,v=o*f-c*u,y=o*d-s*u,b=a*f-c*l,x=a*d-s*l,S=a*u-o*l;return t*(m*_-h*v+g*y)-n*(p*_-h*b+g*x)+r*(p*v-m*b+g*S)-i*(p*y-m*x+h*S)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,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=t*c-i*a,b=n*s-r*o,x=n*c-i*o,S=r*c-i*s,C=l*m-u*p,w=l*h-d*p,T=l*g-f*p,E=u*h-d*m,D=u*g-f*m,O=d*g-f*h,k=_*O-v*D+y*E+b*T-x*w+S*C;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/k;return e[0]=(o*O-s*D+c*E)*A,e[1]=(r*D-n*O-i*E)*A,e[2]=(m*S-h*x+g*b)*A,e[3]=(d*x-u*S-f*b)*A,e[4]=(s*T-a*O-c*w)*A,e[5]=(t*O-r*T+i*w)*A,e[6]=(h*y-p*S-g*v)*A,e[7]=(l*S-d*y+f*v)*A,e[8]=(a*D-o*T+c*C)*A,e[9]=(n*T-t*D-i*C)*A,e[10]=(p*x-m*y+g*_)*A,e[11]=(u*y-l*x-f*_)*A,e[12]=(o*w-a*E-s*C)*A,e[13]=(t*E-n*w+r*C)*A,e[14]=(m*v-p*b-h*_)*A,e[15]=(l*b-u*v+d*_)*A,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinant();if(i===0)return n.set(1,1,1),t.identity(),this;let a=fa.set(r[0],r[1],r[2]).length(),o=fa.set(r[4],r[5],r[6]).length(),s=fa.set(r[8],r[9],r[10]).length();i<0&&(a=-a),pa.copy(this);let c=1/a,l=1/o,u=1/s;return pa.elements[0]*=c,pa.elements[1]*=c,pa.elements[2]*=c,pa.elements[4]*=l,pa.elements[5]*=l,pa.elements[6]*=l,pa.elements[8]*=u,pa.elements[9]*=u,pa.elements[10]*=u,t.setFromRotationMatrix(pa),n.x=a,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,a,o=ni,s=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),p,m;if(s)p=i/(a-i),m=a*i/(a-i);else if(o===2e3)p=-(a+i)/(a-i),m=-2*a*i/(a-i);else if(o===2001)p=-a/(a-i),m=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=ni,s=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),p,m;if(s)p=1/(a-i),m=a/(a-i);else if(o===2e3)p=-2/(a-i),m=-(a+i)/(a-i);else if(o===2001)p=-1/(a-i),m=-i/(a-i);else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},fa=new J,pa=new Y,ma=new J(0,0,0),ha=new J(1,1,1),ga=new J,_a=new J,va=new J,ya=new Y,ba=new Hi,xa=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(bi(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-bi(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(bi(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-bi(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(bi(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-bi(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:G(`Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return ya.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ya,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ba.setFromEuler(this),this.setFromQuaternion(ba,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};xa.DEFAULT_ORDER=`XYZ`;var Sa=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!=0}},Ca=0,wa=new J,Ta=new Hi,Ea=new Y,Da=new J,Oa=new J,ka=new J,Aa=new Hi,ja=new J(1,0,0),Ma=new J(0,1,0),Na=new J(0,0,1),Pa={type:`added`},Fa={type:`removed`},Ia={type:`childadded`,child:null},La={type:`childremoved`,child:null},Ra=class e extends mi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,`id`,{value:Ca++}),this.uuid=yi(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new J,n=new xa,r=new Hi,i=new J(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Y},normalMatrix:{value:new Gi}}),this.matrix=new Y,this.matrixWorld=new Y,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Sa,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Ta.setFromAxisAngle(e,t),this.quaternion.multiply(Ta),this}rotateOnWorldAxis(e,t){return Ta.setFromAxisAngle(e,t),this.quaternion.premultiply(Ta),this}rotateX(e){return this.rotateOnAxis(ja,e)}rotateY(e){return this.rotateOnAxis(Ma,e)}rotateZ(e){return this.rotateOnAxis(Na,e)}translateOnAxis(e,t){return wa.copy(e).applyQuaternion(this.quaternion),this.position.add(wa.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(ja,e)}translateY(e){return this.translateOnAxis(Ma,e)}translateZ(e){return this.translateOnAxis(Na,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ea.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Da.copy(e):Da.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),Oa.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ea.lookAt(Oa,Da,this.up):Ea.lookAt(Da,Oa,this.up),this.quaternion.setFromRotationMatrix(Ea),r&&(Ea.extractRotation(r.matrixWorld),Ta.setFromRotationMatrix(Ea),this.quaternion.premultiply(Ta.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(K(`Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Pa),Ia.child=e,this.dispatchEvent(Ia),Ia.child=null):K(`Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Fa),La.child=e,this.dispatchEvent(La),La.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Ea.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ea.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ea),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Pa),Ia.child=e,this.dispatchEvent(Ia),Ia.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oa,e,ka),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oa,Aa,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++)e[t].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};Ra.DEFAULT_UP=new J(0,1,0),Ra.DEFAULT_MATRIX_AUTO_UPDATE=!0,Ra.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var za=class extends Ra{constructor(){super(),this.isGroup=!0,this.type=`Group`}},Ba={type:`move`},Va=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new za,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new za,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new J,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new J),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new za,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new J,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new J),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:`connected`,data:e}),this}disconnect(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position),s=.02,l=.005;c.inputState.pinching&&o>s+l?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=s-l&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Ba)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new za;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Ha={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ua={h:0,s:0,l:0},Wa={h:0,s:0,l:0};function Ga(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var X=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Xr){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Xi.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Xi.workingColorSpace){return this.r=e,this.g=t,this.b=n,Xi.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Xi.workingColorSpace){if(e=xi(e,1),t=bi(t,0,1),n=bi(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=Ga(i,r,e+1/3),this.g=Ga(i,r,e),this.b=Ga(i,r,e-1/3)}return Xi.colorSpaceToWorking(this,r),this}setStyle(e,t=Xr){function n(t){t!==void 0&&parseFloat(t)<1&&G(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:G(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);G(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Xr){let n=Ha[e.toLowerCase()];return n===void 0?G(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Zi(e.r),this.g=Zi(e.g),this.b=Zi(e.b),this}copyLinearToSRGB(e){return this.r=Qi(e.r),this.g=Qi(e.g),this.b=Qi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Xr){return Xi.workingToColorSpace(Ka.copy(this),e),Math.round(bi(Ka.r*255,0,255))*65536+Math.round(bi(Ka.g*255,0,255))*256+Math.round(bi(Ka.b*255,0,255))}getHexString(e=Xr){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Xi.workingColorSpace){Xi.workingToColorSpace(Ka.copy(this),t);let n=Ka.r,r=Ka.g,i=Ka.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=Xi.workingColorSpace){return Xi.workingToColorSpace(Ka.copy(this),t),e.r=Ka.r,e.g=Ka.g,e.b=Ka.b,e}getStyle(e=Xr){Xi.workingToColorSpace(Ka.copy(this),e);let t=Ka.r,n=Ka.g,r=Ka.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(Ua),this.setHSL(Ua.h+e,Ua.s+t,Ua.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Ua),e.getHSL(Wa);let n=wi(Ua.h,Wa.h,t),r=wi(Ua.s,Wa.s,t),i=wi(Ua.l,Wa.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Ka=new X;X.NAMES=Ha;var qa=class extends Ra{constructor(){super(),this.isScene=!0,this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new xa,this.environmentIntensity=1,this.environmentRotation=new xa,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},Ja=new J,Ya=new J,Xa=new J,Za=new J,Qa=new J,$a=new J,eo=new J,to=new J,no=new J,ro=new J,io=new sa,ao=new sa,oo=new sa,so=class e{constructor(e=new J,t=new J,n=new J){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Ja.subVectors(e,t),r.cross(Ja);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){Ja.subVectors(r,t),Ya.subVectors(n,t),Xa.subVectors(e,t);let a=Ja.dot(Ja),o=Ja.dot(Ya),s=Ja.dot(Xa),c=Ya.dot(Ya),l=Ya.dot(Xa),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Za)===null?!1:Za.x>=0&&Za.y>=0&&Za.x+Za.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Za)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,Za.x),s.addScaledVector(a,Za.y),s.addScaledVector(o,Za.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return io.setScalar(0),ao.setScalar(0),oo.setScalar(0),io.fromBufferAttribute(e,t),ao.fromBufferAttribute(e,n),oo.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(io,i.x),a.addScaledVector(ao,i.y),a.addScaledVector(oo,i.z),a}static isFrontFacing(e,t,n,r){return Ja.subVectors(n,t),Ya.subVectors(e,t),Ja.cross(Ya).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ja.subVectors(this.c,this.b),Ya.subVectors(this.a,this.b),Ja.cross(Ya).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;Qa.subVectors(r,n),$a.subVectors(i,n),to.subVectors(e,n);let s=Qa.dot(to),c=$a.dot(to);if(s<=0&&c<=0)return t.copy(n);no.subVectors(e,r);let l=Qa.dot(no),u=$a.dot(no);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(Qa,a);ro.subVectors(e,i);let f=Qa.dot(ro),p=$a.dot(ro);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector($a,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return eo.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(eo,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Qa,a).addScaledVector($a,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},co=class{constructor(e=new J(1/0,1/0,1/0),t=new J(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(uo.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(uo.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=uo.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,uo):uo.fromBufferAttribute(r,t),uo.applyMatrix4(e.matrixWorld),this.expandByPoint(uo);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),fo.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),fo.copy(e.boundingBox)),fo.applyMatrix4(e.matrixWorld),this.union(fo)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,uo),uo.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(yo),bo.subVectors(this.max,yo),po.subVectors(e.a,yo),mo.subVectors(e.b,yo),ho.subVectors(e.c,yo),go.subVectors(mo,po),_o.subVectors(ho,mo),vo.subVectors(po,ho);let t=[0,-go.z,go.y,0,-_o.z,_o.y,0,-vo.z,vo.y,go.z,0,-go.x,_o.z,0,-_o.x,vo.z,0,-vo.x,-go.y,go.x,0,-_o.y,_o.x,0,-vo.y,vo.x,0];return!Co(t,po,mo,ho,bo)||(t=[1,0,0,0,1,0,0,0,1],!Co(t,po,mo,ho,bo))?!1:(xo.crossVectors(go,_o),t=[xo.x,xo.y,xo.z],Co(t,po,mo,ho,bo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,uo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(uo).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(lo[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),lo[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),lo[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),lo[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),lo[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),lo[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),lo[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),lo[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(lo),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},lo=[new J,new J,new J,new J,new J,new J,new J,new J],uo=new J,fo=new co,po=new J,mo=new J,ho=new J,go=new J,_o=new J,vo=new J,yo=new J,bo=new J,xo=new J,So=new J;function Co(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){So.fromArray(e,a);let o=i.x*Math.abs(So.x)+i.y*Math.abs(So.y)+i.z*Math.abs(So.z),s=t.dot(So),c=n.dot(So),l=r.dot(So);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var wo=new J,To=new q,Eo=0,Do=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:Eo++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=ti,this.updateRanges=[],this.gpuType=Hn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)To.fromBufferAttribute(this,t),To.applyMatrix3(e),this.setXY(t,To.x,To.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)wo.fromBufferAttribute(this,t),wo.applyMatrix3(e),this.setXYZ(t,wo.x,wo.y,wo.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)wo.fromBufferAttribute(this,t),wo.applyMatrix4(e),this.setXYZ(t,wo.x,wo.y,wo.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)wo.fromBufferAttribute(this,t),wo.applyNormalMatrix(e),this.setXYZ(t,wo.x,wo.y,wo.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)wo.fromBufferAttribute(this,t),wo.transformDirection(e),this.setXYZ(t,wo.x,wo.y,wo.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=zi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Bi(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=zi(t,this.array)),t}setX(e,t){return this.normalized&&(t=Bi(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=zi(t,this.array)),t}setY(e,t){return this.normalized&&(t=Bi(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=zi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Bi(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=zi(t,this.array)),t}setW(e,t){return this.normalized&&(t=Bi(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Bi(t,this.array),n=Bi(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Bi(t,this.array),n=Bi(n,this.array),r=Bi(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=Bi(t,this.array),n=Bi(n,this.array),r=Bi(r,this.array),i=Bi(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==35044&&(e.usage=this.usage),e}},Oo=class extends Do{constructor(e,t,n){super(new Uint16Array(e),t,n)}},ko=class extends Do{constructor(e,t,n){super(new Uint32Array(e),t,n)}},Ao=class extends Do{constructor(e,t,n){super(new Float32Array(e),t,n)}},jo=new co,Mo=new J,No=new J,Po=class{constructor(e=new J,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?jo.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Mo.subVectors(e,this.center);let t=Mo.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(Mo,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(No.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Mo.copy(e.center).add(No)),this.expandByPoint(Mo.copy(e.center).sub(No))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Fo=0,Io=new Y,Lo=new Ra,Ro=new J,zo=new co,Bo=new co,Vo=new J,Ho=class e extends mi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,`id`,{value:Fo++}),this.uuid=yi(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(ri(e)?ko:Oo)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new Gi().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Io.makeRotationFromQuaternion(e),this.applyMatrix4(Io),this}rotateX(e){return Io.makeRotationX(e),this.applyMatrix4(Io),this}rotateY(e){return Io.makeRotationY(e),this.applyMatrix4(Io),this}rotateZ(e){return Io.makeRotationZ(e),this.applyMatrix4(Io),this}translate(e,t,n){return Io.makeTranslation(e,t,n),this.applyMatrix4(Io),this}scale(e,t,n){return Io.makeScale(e,t,n),this.applyMatrix4(Io),this}lookAt(e){return Lo.lookAt(e),Lo.updateMatrix(),this.applyMatrix4(Lo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ro).negate(),this.translate(Ro.x,Ro.y,Ro.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new Ao(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&G(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new co);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){K(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new J(-1/0,-1/0,-1/0),new J(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];zo.setFromBufferAttribute(n),this.morphTargetsRelative?(Vo.addVectors(this.boundingBox.min,zo.min),this.boundingBox.expandByPoint(Vo),Vo.addVectors(this.boundingBox.max,zo.max),this.boundingBox.expandByPoint(Vo)):(this.boundingBox.expandByPoint(zo.min),this.boundingBox.expandByPoint(zo.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&K(`BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Po);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){K(`BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new J,1/0);return}if(e){let n=this.boundingSphere.center;if(zo.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Bo.setFromBufferAttribute(n),this.morphTargetsRelative?(Vo.addVectors(zo.min,Bo.min),zo.expandByPoint(Vo),Vo.addVectors(zo.max,Bo.max),zo.expandByPoint(Vo)):(zo.expandByPoint(Bo.min),zo.expandByPoint(Bo.max))}zo.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)Vo.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(Vo));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)Vo.fromBufferAttribute(a,t),o&&(Ro.fromBufferAttribute(e,t),Vo.add(Ro)),r=Math.max(r,n.distanceToSquared(Vo))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&K(`BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){K(`BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new Do(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new J,s[e]=new J;let c=new J,l=new J,u=new J,d=new q,f=new q,p=new q,m=new J,h=new J;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new J,y=new J,b=new J,x=new J;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e])<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,n)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new Do(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new J,i=new J,a=new J,o=new J,s=new J,c=new J,l=new J,u=new J;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Vo.fromBufferAttribute(e,t),Vo.normalize(),e.setXYZ(t,Vo.x,Vo.y,Vo.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new Do(a,r,i)}if(this.index===null)return G(`BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}},Uo=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=ti,this.updateRanges=[],this.version=0,this.uuid=yi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=yi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=yi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Wo=new J,Go=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Wo.fromBufferAttribute(this,t),Wo.applyMatrix4(e),this.setXYZ(t,Wo.x,Wo.y,Wo.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Wo.fromBufferAttribute(this,t),Wo.applyNormalMatrix(e),this.setXYZ(t,Wo.x,Wo.y,Wo.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Wo.fromBufferAttribute(this,t),Wo.transformDirection(e),this.setXYZ(t,Wo.x,Wo.y,Wo.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=zi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Bi(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=zi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=zi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=zi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=zi(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Bi(t,this.array),n=Bi(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Bi(t,this.array),n=Bi(n,this.array),r=Bi(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Bi(t,this.array),n=Bi(n,this.array),r=Bi(r,this.array),i=Bi(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){li(`InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new Do(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){li(`InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Ko=0,qo=class extends mi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,`id`,{value:Ko++}),this.uuid=yi(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new X(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ei,this.stencilZFail=ei,this.stencilZPass=ei,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){G(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){G(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},Jo=class extends qo{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new X(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Yo,Xo=new J,Zo=new J,Qo=new J,$o=new q,es=new q,ts=new Y,ns=new J,rs=new J,is=new J,as=new q,os=new q,ss=new q,cs=class extends Ra{constructor(e=new Jo){if(super(),this.isSprite=!0,this.type=`Sprite`,Yo===void 0){Yo=new Ho;let e=new Uo(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);Yo.setIndex([0,1,2,0,2,3]),Yo.setAttribute(`position`,new Go(e,3,0,!1)),Yo.setAttribute(`uv`,new Go(e,2,3,!1))}this.geometry=Yo,this.material=e,this.center=new q(.5,.5),this.count=1}raycast(e,t){e.camera===null&&K(`Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.`),Zo.setFromMatrixScale(this.matrixWorld),ts.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Qo.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Zo.multiplyScalar(-Qo.z);let n=this.material.rotation,r,i;n!==0&&(i=Math.cos(n),r=Math.sin(n));let a=this.center;ls(ns.set(-.5,-.5,0),Qo,a,Zo,r,i),ls(rs.set(.5,-.5,0),Qo,a,Zo,r,i),ls(is.set(.5,.5,0),Qo,a,Zo,r,i),as.set(0,0),os.set(1,0),ss.set(1,1);let o=e.ray.intersectTriangle(ns,rs,is,!1,Xo);if(o===null&&(ls(rs.set(-.5,.5,0),Qo,a,Zo,r,i),os.set(0,1),o=e.ray.intersectTriangle(ns,is,rs,!1,Xo),o===null))return;let s=e.ray.origin.distanceTo(Xo);s<e.near||s>e.far||t.push({distance:s,point:Xo.clone(),uv:so.getInterpolation(Xo,ns,rs,is,as,os,ss,new q),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};function ls(e,t,n,r,i,a){$o.subVectors(e,n).addScalar(.5).multiply(r),i===void 0?es.copy($o):(es.x=a*$o.x-i*$o.y,es.y=i*$o.x+a*$o.y),e.copy(t),e.x+=es.x,e.y+=es.y,e.applyMatrix4(ts)}var us=new J,ds=new J,fs=new J,ps=new J,ms=new J,hs=new J,gs=new J,_s=class{constructor(e=new J,t=new J(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,us)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=us.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(us.copy(this.origin).addScaledVector(this.direction,t),us.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){ds.copy(e).add(t).multiplyScalar(.5),fs.copy(t).sub(e).normalize(),ps.copy(this.origin).sub(ds);let i=e.distanceTo(t)*.5,a=-this.direction.dot(fs),o=ps.dot(this.direction),s=-ps.dot(fs),c=ps.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(ds).addScaledVector(fs,d),f}intersectSphere(e,t){us.subVectors(e.center,this.origin);let n=us.dot(this.direction),r=us.dot(us)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,us)!==null}intersectTriangle(e,t,n,r,i){ms.subVectors(t,e),hs.subVectors(n,e),gs.crossVectors(ms,hs);let a=this.direction.dot(gs),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;ps.subVectors(this.origin,e);let s=o*this.direction.dot(hs.crossVectors(ps,hs));if(s<0)return null;let c=o*this.direction.dot(ms.cross(ps));if(c<0||s+c>a)return null;let l=-o*ps.dot(gs);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},vs=class extends qo{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new X(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xa,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},ys=new Y,bs=new _s,xs=new Po,Ss=new J,Cs=new J,ws=new J,Ts=new J,Es=new J,Ds=new J,Os=new J,ks=new J,As=class extends Ra{constructor(e=new Ho,t=new vs){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){Ds.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(Es.fromBufferAttribute(s,e),a?Ds.addScaledVector(Es,r):Ds.addScaledVector(Es.sub(t),r))}t.add(Ds)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),xs.copy(n.boundingSphere),xs.applyMatrix4(i),bs.copy(e.ray).recast(e.near),!(xs.containsPoint(bs.origin)===!1&&(bs.intersectSphere(xs,Ss)===null||bs.origin.distanceToSquared(Ss)>(e.far-e.near)**2))&&(ys.copy(i).invert(),bs.copy(e.ray).applyMatrix4(ys),!(n.boundingBox!==null&&bs.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,bs)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=Ms(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=Ms(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=Ms(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=Ms(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function js(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===0,s),c===null)return null;ks.copy(s),ks.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(ks);return l<n.near||l>n.far?null:{distance:l,point:ks.clone(),object:e}}function Ms(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,Cs),e.getVertexPosition(c,ws),e.getVertexPosition(l,Ts);let u=js(e,t,n,r,Cs,ws,Ts,Os);if(u){let e=new J;so.getBarycoord(Os,Cs,ws,Ts,e),i&&(u.uv=so.getInterpolatedAttribute(i,s,c,l,e,new q)),a&&(u.uv1=so.getInterpolatedAttribute(a,s,c,l,e,new q)),o&&(u.normal=so.getInterpolatedAttribute(o,s,c,l,e,new J),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new J,materialIndex:0};so.getNormal(Cs,ws,Ts,t.normal),u.face=t,u.barycoord=e}return u}var Ns=new J,Ps=new sa,Fs=new sa,Is=new J,Ls=new Y,Rs=new J,zs=new Po,Bs=new Y,Vs=new _s,Hs=class extends As{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type=`SkinnedMesh`,this.bindMode=En,this.bindMatrix=new Y,this.bindMatrixInverse=new Y,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new co),this.boundingBox.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e<t.count;e++)this.getVertexPosition(e,Rs),this.boundingBox.expandByPoint(Rs)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Po),this.boundingSphere.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e<t.count;e++)this.getVertexPosition(e,Rs),this.boundingSphere.expandByPoint(Rs)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),zs.copy(this.boundingSphere),zs.applyMatrix4(r),e.ray.intersectsSphere(zs)!==!1&&(Bs.copy(r).invert(),Vs.copy(e.ray).applyMatrix4(Bs),!(this.boundingBox!==null&&Vs.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Vs)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new sa,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();r===1/0?e.set(1,0,0,0):e.multiplyScalar(r),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===`attached`?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===`detached`?this.bindMatrixInverse.copy(this.bindMatrix).invert():G(`SkinnedMesh: Unrecognized bindMode: `+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,r=this.geometry;Ps.fromBufferAttribute(r.attributes.skinIndex,e),Fs.fromBufferAttribute(r.attributes.skinWeight,e),Ns.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){let r=Fs.getComponent(e);if(r!==0){let i=Ps.getComponent(e);Ls.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),t.addScaledVector(Is.copy(Ns).applyMatrix4(Ls),r)}}return t.applyMatrix4(this.bindMatrixInverse)}},Us=class extends Ra{constructor(){super(),this.isBone=!0,this.type=`Bone`}},Ws=class extends oa{constructor(e=null,t=1,n=1,r,i,a,o,s,c=An,l=An,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Gs=new Y,Ks=new Y,qs=class e{constructor(e=[],t=[]){this.uuid=yi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){G(`Skeleton: Number of inverse bone matrices does not match amount of bones.`),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new Y)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let t=new Y;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let r=0,i=e.length;r<i;r++){let i=e[r]?e[r].matrixWorld:Ks;Gs.multiplyMatrices(i,t[r]),Gs.toArray(n,r*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new e(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new Ws(t,e,e,Zn,Hn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){let r=e.bones[n],i=t[r];i===void 0&&(G(`Skeleton: No bone found with UUID:`,r),i=new Us),this.bones.push(i),this.boneInverses.push(new Y().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:`Skeleton`,generator:`Skeleton.toJSON`},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let r=0,i=t.length;r<i;r++){let i=t[r];e.bones.push(i.uuid);let a=n[r];e.boneInverses.push(a.toArray())}return e}},Js=class extends Do{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Ys=new Y,Xs=new Y,Zs=[],Qs=new co,$s=new Y,ec=new As,tc=new Po,nc=class extends As{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Js(new Float32Array(n*16),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<n;e++)this.setMatrixAt(e,$s)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new co),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Ys),Qs.copy(e.boundingBox).applyMatrix4(Ys),this.boundingBox.union(Qs)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Po),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Ys),tc.copy(e.boundingSphere).applyMatrix4(Ys),this.boundingSphere.union(tc)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.previousInstanceMatrix!==null&&(this.previousInstanceMatrix=e.previousInstanceMatrix.clone()),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,i=e*(n.length+1)+1;for(let e=0;e<n.length;e++)n[e]=r[i+e]}raycast(e,t){let n=this.matrixWorld,r=this.count;if(ec.geometry=this.geometry,ec.material=this.material,ec.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),tc.copy(this.boundingSphere),tc.applyMatrix4(n),e.ray.intersectsSphere(tc)!==!1))for(let i=0;i<r;i++){this.getMatrixAt(i,Ys),Xs.multiplyMatrices(n,Ys),ec.matrixWorld=Xs,ec.raycast(e,Zs);for(let e=0,n=Zs.length;e<n;e++){let n=Zs[e];n.instanceId=i,n.object=this,t.push(n)}Zs.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Js(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){let n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new Ws(new Float32Array(r*this.count),r,this.count,er,Hn));let i=this.morphTexture.source.data.data,a=0;for(let e=0;e<n.length;e++)a+=n[e];let o=this.geometry.morphTargetsRelative?1:1-a,s=r*e;i[s]=o,i.set(n,s+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:`dispose`}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},rc=new J,ic=new J,ac=new Gi,oc=class{constructor(e=new J(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=rc.subVectors(n,t).cross(ic.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(rc),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||ac.getNormalMatrix(e),r=this.coplanarPoint(rc).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},sc=new Po,cc=new q(.5,.5),lc=new J,uc=class{constructor(e=new oc,t=new oc,n=new oc,r=new oc,i=new oc,a=new oc){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=ni,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),sc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),sc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(sc)}intersectsSprite(e){return sc.center.set(0,0,0),sc.radius=.7071067811865476+cc.distanceTo(e.center),sc.applyMatrix4(e.matrixWorld),this.intersectsSphere(sc)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(lc.x=r.normal.x>0?e.max.x:e.min.x,lc.y=r.normal.y>0?e.max.y:e.min.y,lc.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(lc)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},dc=class extends qo{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new X(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},fc=new J,pc=new J,mc=new Y,hc=new _s,gc=new Po,_c=new J,vc=new J,yc=class extends Ra{constructor(e=new Ho,t=new dc){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)fc.fromBufferAttribute(t,e-1),pc.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=fc.distanceTo(pc);e.setAttribute(`lineDistance`,new Ao(n,1))}else G(`Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),gc.copy(n.boundingSphere),gc.applyMatrix4(r),gc.radius+=i,e.ray.intersectsSphere(gc)===!1)return;mc.copy(r).invert(),hc.copy(e.ray).applyMatrix4(mc);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=this.isLineSegments?2:1,l=n.index,u=n.attributes.position;if(l!==null){let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=l.getX(i),r=l.getX(i+1),a=bc(this,e,hc,s,n,r,i);a&&t.push(a)}if(this.isLineLoop){let i=l.getX(r-1),a=l.getX(n),o=bc(this,e,hc,s,i,a,r-1);o&&t.push(o)}}else{let n=Math.max(0,a.start),r=Math.min(u.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=bc(this,e,hc,s,i,i+1,i);n&&t.push(n)}if(this.isLineLoop){let i=bc(this,e,hc,s,r-1,n,r-1);i&&t.push(i)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function bc(e,t,n,r,i,a,o){let s=e.geometry.attributes.position;if(fc.fromBufferAttribute(s,i),pc.fromBufferAttribute(s,a),n.distanceSqToSegment(fc,pc,_c,vc)>r)return;_c.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(_c);if(!(c<t.near||c>t.far))return{distance:c,point:vc.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var xc=new J,Sc=new J,Cc=class extends yc{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type=`LineSegments`}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e<r;e+=2)xc.fromBufferAttribute(t,e),Sc.fromBufferAttribute(t,e+1),n[e]=e===0?0:n[e-1],n[e+1]=n[e]+xc.distanceTo(Sc);e.setAttribute(`lineDistance`,new Ao(n,1))}else G(`LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}},wc=class extends yc{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type=`LineLoop`}},Tc=class extends qo{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new X(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Ec=new Y,Dc=new _s,Oc=new Po,kc=new J,Ac=class extends Ra{constructor(e=new Ho,t=new Tc){super(),this.isPoints=!0,this.type=`Points`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Oc.copy(n.boundingSphere),Oc.applyMatrix4(r),Oc.radius+=i,e.ray.intersectsSphere(Oc)===!1)return;Ec.copy(r).invert(),Dc.copy(e.ray).applyMatrix4(Ec);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=n.index,l=n.attributes.position;if(c!==null){let n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let a=n,o=i;a<o;a++){let n=c.getX(a);kc.fromBufferAttribute(l,n),jc(kc,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(l.count,a.start+a.count);for(let a=n,o=i;a<o;a++)kc.fromBufferAttribute(l,a),jc(kc,a,s,r,e,t,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function jc(e,t,n,r,i,a,o){let s=Dc.distanceSqToPoint(e);if(s<n){let n=new J;Dc.closestPointToPoint(e,n),n.applyMatrix4(r);let c=i.ray.origin.distanceTo(n);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var Mc=class extends oa{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Nc=class extends oa{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},Pc=class extends oa{constructor(e,t,n=Vn,r,i,a,o=An,s=An,c,l=Qn,u=1){if(l!==1026&&l!==1027)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new na(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},Fc=class extends Pc{constructor(e,t=Vn,n=301,r,i,a=An,o=An,s,c=Qn){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},Ic=class extends oa{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Lc=class e extends Ho{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new Ao(c,3)),this.setAttribute(`normal`,new Ao(l,3)),this.setAttribute(`uv`,new Ao(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new J;for(let a=0;a<w;a++){let o=a*y-x;for(let s=0;s<C;s++)D[e]=(s*v-b)*r,D[t]=o*i,D[n]=S,c.push(D.x,D.y,D.z),D[e]=0,D[t]=0,D[n]=m>0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),a=d+(t+1)+C*e;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(f,E,_),f+=E,d+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},Rc=class e extends Ho{constructor(e=1,t=1,n=1,r=32,i=1,a=!1,o=0,s=Math.PI*2){super(),this.type=`CylinderGeometry`,this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s};let c=this;r=Math.floor(r),i=Math.floor(i);let l=[],u=[],d=[],f=[],p=0,m=[],h=n/2,g=0;_(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new Ao(u,3)),this.setAttribute(`normal`,new Ao(d,3)),this.setAttribute(`uv`,new Ao(f,2));function _(){let a=new J,_=new J,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n<r;n++)for(let r=0;r<i;r++){let a=m[r][n],o=m[r+1][n],s=m[r+1][n+1],c=m[r][n+1];(e>0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new q,m=new J,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e<r;e++){let t=i+e,r=b+e;n===!0?l.push(r,r+1,t):l.push(r+1,r,t),_+=3}c.addGroup(g,_,n===!0?1:2),g+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},zc=class e extends Rc{constructor(e=1,t=1,n=32,r=1,i=!1,a=0,o=Math.PI*2){super(0,e,t,n,r,i,a,o),this.type=`ConeGeometry`,this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}static fromJSON(t){return new e(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Bc=class{constructor(){this.type=`Curve`,this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){G(`Curve: .getPoint() not implemented.`)}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,r=this.getPoint(0),i=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let n=this.getLengths(),r=0,i=n.length,a;a=t||e*n[i-1];let o=0,s=i-1,c;for(;o<=s;)if(r=Math.floor(o+(s-o)/2),c=n[r]-a,c<0)o=r+1;else if(c>0)s=r-1;else{s=r;break}if(r=s,n[r]===a)return r/(i-1);let l=n[r],u=n[r+1]-l,d=(a-l)/u;return(r+d)/(i-1)}getTangent(e,t){let n=1e-4,r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);let a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new q:new J);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new J,r=[],i=[],a=[],o=new J,s=new Y;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new J)}i[0]=new J,a[0]=new J;let c=Number.MAX_VALUE,l=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>2**-52){o.normalize();let e=Math.acos(bi(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(t===!0){let t=Math.acos(bi(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:`Curve`,generator:`Curve.toJSON`}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Vc=class extends Bc{constructor(e=0,t=0,n=1,r=1,i=0,a=Math.PI*2,o=!1,s=0){super(),this.isEllipseCurve=!0,this.type=`EllipseCurve`,this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t=new q){let n=t,r=Math.PI*2,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)<2**-52;for(;i<0;)i+=r;for(;i>r;)i-=r;i<2**-52&&(i=a?0:r),this.aClockwise===!0&&!a&&(i===r?i=-r:i-=r);let o=this.aStartAngle+e*i,s=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=c-this.aY;s=n*e-r*t+this.aX,c=n*t+r*e+this.aY}return n.set(s,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},Hc=class extends Vc{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.isArcCurve=!0,this.type=`ArcCurve`}};function Uc(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let c=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;c*=o,l*=o,i(t,n,c,l)},calc:function(i){let a=i*i,o=a*i;return e+t*i+n*a+r*o}}}var Wc=new J,Gc=new Uc,Kc=new Uc,qc=new Uc,Jc=class extends Bc{constructor(e=[],t=!1,n=`centripetal`,r=.5){super(),this.isCatmullRomCurve3=!0,this.type=`CatmullRomCurve3`,this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new J){let n=t,r=this.points,i=r.length,a=(i-+!this.closed)*e,o=Math.floor(a),s=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:s===0&&o===i-1&&(o=i-2,s=1);let c,l;this.closed||o>0?c=r[(o-1)%i]:(Wc.subVectors(r[0],r[1]).add(r[0]),c=Wc);let u=r[o%i],d=r[(o+1)%i];if(this.closed||o+2<i?l=r[(o+2)%i]:(Wc.subVectors(r[i-1],r[i-2]).add(r[i-1]),l=Wc),this.curveType===`centripetal`||this.curveType===`chordal`){let e=this.curveType===`chordal`?.5:.25,t=c.distanceToSquared(u)**+e,n=u.distanceToSquared(d)**+e,r=d.distanceToSquared(l)**+e;n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),Gc.initNonuniformCatmullRom(c.x,u.x,d.x,l.x,t,n,r),Kc.initNonuniformCatmullRom(c.y,u.y,d.y,l.y,t,n,r),qc.initNonuniformCatmullRom(c.z,u.z,d.z,l.z,t,n,r)}else this.curveType===`catmullrom`&&(Gc.initCatmullRom(c.x,u.x,d.x,l.x,this.tension),Kc.initCatmullRom(c.y,u.y,d.y,l.y,this.tension),qc.initCatmullRom(c.z,u.z,d.z,l.z,this.tension));return n.set(Gc.calc(s),Kc.calc(s),qc.calc(s)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new J().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function Yc(e,t,n,r,i){let a=(r-t)*.5,o=(i-n)*.5,s=e*e,c=e*s;return(2*n-2*r+a+o)*c+(-3*n+3*r-2*a-o)*s+a*e+n}function Xc(e,t){let n=1-e;return n*n*t}function Zc(e,t){return 2*(1-e)*e*t}function Qc(e,t){return e*e*t}function $c(e,t,n,r){return Xc(e,t)+Zc(e,n)+Qc(e,r)}function el(e,t){let n=1-e;return n*n*n*t}function tl(e,t){let n=1-e;return 3*n*n*e*t}function nl(e,t){return 3*(1-e)*e*e*t}function rl(e,t){return e*e*e*t}function il(e,t,n,r,i){return el(e,t)+tl(e,n)+nl(e,r)+rl(e,i)}var al=class extends Bc{constructor(e=new q,t=new q,n=new q,r=new q){super(),this.isCubicBezierCurve=!0,this.type=`CubicBezierCurve`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new q){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(il(e,r.x,i.x,a.x,o.x),il(e,r.y,i.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ol=class extends Bc{constructor(e=new J,t=new J,n=new J,r=new J){super(),this.isCubicBezierCurve3=!0,this.type=`CubicBezierCurve3`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new J){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(il(e,r.x,i.x,a.x,o.x),il(e,r.y,i.y,a.y,o.y),il(e,r.z,i.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},sl=class extends Bc{constructor(e=new q,t=new q){super(),this.isLineCurve=!0,this.type=`LineCurve`,this.v1=e,this.v2=t}getPoint(e,t=new q){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new q){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},cl=class extends Bc{constructor(e=new J,t=new J){super(),this.isLineCurve3=!0,this.type=`LineCurve3`,this.v1=e,this.v2=t}getPoint(e,t=new J){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new J){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ll=class extends Bc{constructor(e=new q,t=new q,n=new q){super(),this.isQuadraticBezierCurve=!0,this.type=`QuadraticBezierCurve`,this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new q){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set($c(e,r.x,i.x,a.x),$c(e,r.y,i.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ul=class extends Bc{constructor(e=new J,t=new J,n=new J){super(),this.isQuadraticBezierCurve3=!0,this.type=`QuadraticBezierCurve3`,this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new J){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set($c(e,r.x,i.x,a.x),$c(e,r.y,i.y,a.y),$c(e,r.z,i.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},dl=class extends Bc{constructor(e=[]){super(),this.isSplineCurve=!0,this.type=`SplineCurve`,this.points=e}getPoint(e,t=new q){let n=t,r=this.points,i=(r.length-1)*e,a=Math.floor(i),o=i-a,s=r[a===0?a:a-1],c=r[a],l=r[a>r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(Yc(o,s.x,c.x,l.x,u.x),Yc(o,s.y,c.y,l.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new q().fromArray(n))}return this}},fl=Object.freeze({__proto__:null,ArcCurve:Hc,CatmullRomCurve3:Jc,CubicBezierCurve:al,CubicBezierCurve3:ol,EllipseCurve:Vc,LineCurve:sl,LineCurve3:cl,QuadraticBezierCurve:ll,QuadraticBezierCurve3:ul,SplineCurve:dl}),pl=class extends Bc{constructor(){super(),this.type=`CurvePath`,this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let n=e.isVector2===!0?`LineCurve`:`LineCurve3`;this.curves.push(new fl[n](t,e))}return this}getPoint(e,t){let n=e*this.getLength(),r=this.getCurveLengths(),i=0;for(;i<r.length;){if(r[i]>=n){let e=r[i]-n,a=this.curves[i],o=a.getLength(),s=o===0?0:1-e/o;return a.getPointAt(s,t)}i++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let r=0,i=this.curves;r<i.length;r++){let a=i[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,s=a.getPoints(o);for(let e=0;e<s.length;e++){let r=s[e];n&&n.equals(r)||(t.push(r),n=r)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(new fl[n.type]().fromJSON(n))}return this}},ml=class extends pl{constructor(e){super(),this.type=`Path`,this.currentPoint=new q,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let n=new sl(this.currentPoint.clone(),new q(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){let i=new ll(this.currentPoint.clone(),new q(e,t),new q(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,i,a){let o=new al(this.currentPoint.clone(),new q(e,t),new q(n,r),new q(i,a));return this.curves.push(o),this.currentPoint.set(i,a),this}splineThru(e){let t=new dl([this.currentPoint.clone()].concat(e));return this.curves.push(t),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,i,a){let o=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+o,t+s,n,r,i,a),this}absarc(e,t,n,r,i,a){return this.absellipse(e,t,n,n,r,i,a),this}ellipse(e,t,n,r,i,a,o,s){let c=this.currentPoint.x,l=this.currentPoint.y;return this.absellipse(e+c,t+l,n,r,i,a,o,s),this}absellipse(e,t,n,r,i,a,o,s){let c=new Vc(e,t,n,r,i,a,o,s);if(this.curves.length>0){let e=c.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(c);let l=c.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},hl=class extends ml{constructor(e){super(e),this.uuid=yi(),this.type=`Shape`,this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(new ml().fromJSON(n))}return this}};function gl(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length,a=_l(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s,c,l;if(r&&(a=wl(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;a<i;a+=n){let n=e[a],i=e[a+1];n<s&&(s=n),i<c&&(c=i),n>t&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return yl(a,o,n,s,c,l,0),o}function _l(e,t,n,r,i){let a;if(i===Jl(e,t,n,r)>0)for(let i=t;i<n;i+=r)a=Gl(i/r|0,e[i],e[i+1],a);else for(let i=n-r;i>=t;i-=r)a=Gl(i/r|0,e[i],e[i+1],a);return a&&Ll(a,a.next)&&(Kl(a),a=a.next),a}function vl(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(Ll(n,n.next)||Il(n.prev,n,n.next)===0)){if(Kl(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function yl(e,t,n,r,i,a,o){if(!e)return;!o&&a&&kl(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?xl(e,r,i,a):bl(e)){t.push(c.i,e.i,l.i),Kl(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=Sl(vl(e),t),yl(e,t,n,r,i,a,2)):o===2&&Cl(e,t,n,r,i,a):yl(vl(e),t,n,r,i,a,1);break}}}function bl(e){let t=e.prev,n=e,r=e.next;if(Il(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&Pl(i,s,a,c,o,l,m.x,m.y)&&Il(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function xl(e,t,n,r){let i=e.prev,a=e,o=e.next;if(Il(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=jl(p,m,t,n,r),v=jl(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Pl(s,u,c,d,l,f,y.x,y.y)&&Il(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Pl(s,u,c,d,l,f,b.x,b.y)&&Il(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Pl(s,u,c,d,l,f,y.x,y.y)&&Il(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Pl(s,u,c,d,l,f,b.x,b.y)&&Il(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Sl(e,t){let n=e;do{let r=n.prev,i=n.next.next;!Ll(r,i)&&Rl(r,n,n.next,i)&&Hl(r,i)&&Hl(i,r)&&(t.push(r.i,n.i,i.i),Kl(n),Kl(n.next),n=e=i),n=n.next}while(n!==e);return vl(n)}function Cl(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&Fl(o,e)){let s=Wl(o,e);o=vl(o,o.next),s=vl(s,s.next),yl(o,t,n,r,i,a,0),yl(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function wl(e,t,n,r){let i=[];for(let n=0,a=t.length;n<a;n++){let o=_l(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&(o.steiner=!0),i.push(Ml(o))}i.sort(Tl);for(let e=0;e<i.length;e++)n=El(i[e],n);return n}function Tl(e,t){let n=e.x-t.x;return n===0&&(n=e.y-t.y,n===0&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x))),n}function El(e,t){let n=Dl(e,t);if(!n)return t;let r=Wl(n,e);return vl(r,r.next),vl(n,n.next)}function Dl(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(Ll(e,n))return n;do{if(Ll(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.x<n.next.x?n:n.next,e===r))return o}n=n.next}while(n!==t);if(!o)return null;let s=o,c=o.x,l=o.y,u=1/0;n=o;do{if(r>=n.x&&n.x>=c&&r!==n.x&&Nl(i<l?r:a,i,c,l,i<l?a:r,i,n.x,n.y)){let t=Math.abs(i-n.y)/(r-n.x);Hl(n,e)&&(t<u||t===u&&(n.x>o.x||n.x===o.x&&Ol(o,n)))&&(o=n,u=t)}n=n.next}while(n!==s);return o}function Ol(e,t){return Il(e.prev,e,t.prev)<0&&Il(t.next,e,e.next)<0}function kl(e,t,n,r){let i=e;do i.z===0&&(i.z=jl(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,Al(i)}function Al(e){let t,n=1;do{let r=e,i;e=null;let a=null;for(t=0;r;){t++;let o=r,s=0;for(let e=0;e<n&&(s++,o=o.nextZ,o);e++);let c=n;for(;s>0||c>0&&o;)s!==0&&(c===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,s--):(i=o,o=o.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=o}a.nextZ=null,n*=2}while(t>1);return e}function jl(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function Ml(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function Nl(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function Pl(e,t,n,r,i,a,o,s){return!(e===o&&t===s)&&Nl(e,t,n,r,i,a,o,s)}function Fl(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Vl(e,t)&&(Hl(e,t)&&Hl(t,e)&&Ul(e,t)&&(Il(e.prev,e,t.prev)||Il(e,t.prev,t))||Ll(e,t)&&Il(e.prev,e,e.next)>0&&Il(t.prev,t,t.next)>0)}function Il(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Ll(e,t){return e.x===t.x&&e.y===t.y}function Rl(e,t,n,r){let i=Bl(Il(e,t,n)),a=Bl(Il(e,t,r)),o=Bl(Il(n,r,e)),s=Bl(Il(n,r,t));return!!(i!==a&&o!==s||i===0&&zl(e,n,t)||a===0&&zl(e,r,t)||o===0&&zl(n,e,r)||s===0&&zl(n,t,r))}function zl(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Bl(e){return e>0?1:e<0?-1:0}function Vl(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Rl(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Hl(e,t){return Il(e.prev,e,e.next)<0?Il(e,t,e.next)>=0&&Il(e,e.prev,t)>=0:Il(e,t,e.prev)<0||Il(e,e.next,t)<0}function Ul(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function Wl(e,t){let n=ql(e.i,e.x,e.y),r=ql(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function Gl(e,t,n,r){let i=ql(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Kl(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function ql(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Jl(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}var Yl=class{static triangulate(e,t,n=2){return gl(e,t,n)}},Xl=class e{static area(e){let t=e.length,n=0;for(let r=t-1,i=0;i<t;r=i++)n+=e[r].x*e[i].y-e[i].x*e[r].y;return n*.5}static isClockWise(t){return e.area(t)<0}static triangulateShape(e,t){let n=[],r=[],i=[];Zl(e),Ql(n,e);let a=e.length;t.forEach(Zl);for(let e=0;e<t.length;e++)r.push(a),a+=t[e].length,Ql(n,t[e]);let o=Yl.triangulate(n,r);for(let e=0;e<o.length;e+=3)i.push(o.slice(e,e+3));return i}};function Zl(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Ql(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}var $l=class e extends Ho{constructor(e=1,t=1,n=1,r=1){super(),this.type=`PlaneGeometry`,this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),c=o+1,l=s+1,u=e/o,d=t/s,f=[],p=[],m=[],h=[];for(let e=0;e<l;e++){let t=e*d-a;for(let n=0;n<c;n++){let r=n*u-i;p.push(r,-t,0),m.push(0,0,1),h.push(n/o),h.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){let n=t+c*e,r=t+c*(e+1),i=t+1+c*(e+1),a=t+1+c*e;f.push(n,r,a),f.push(r,i,a)}this.setIndex(f),this.setAttribute(`position`,new Ao(p,3)),this.setAttribute(`normal`,new Ao(m,3)),this.setAttribute(`uv`,new Ao(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.widthSegments,t.heightSegments)}},eu=class e extends Ho{constructor(e=.5,t=1,n=32,r=1,i=0,a=Math.PI*2){super(),this.type=`RingGeometry`,this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:i,thetaLength:a},n=Math.max(3,n),r=Math.max(1,r);let o=[],s=[],c=[],l=[],u=e,d=(t-e)/r,f=new J,p=new q;for(let e=0;e<=r;e++){for(let e=0;e<=n;e++){let r=i+e/n*a;f.x=u*Math.cos(r),f.y=u*Math.sin(r),s.push(f.x,f.y,f.z),c.push(0,0,1),p.x=(f.x/t+1)/2,p.y=(f.y/t+1)/2,l.push(p.x,p.y)}u+=d}for(let e=0;e<r;e++){let t=e*(n+1);for(let e=0;e<n;e++){let r=e+t,i=r,a=r+n+1,s=r+n+2,c=r+1;o.push(i,a,c),o.push(a,s,c)}}this.setIndex(o),this.setAttribute(`position`,new Ao(s,3)),this.setAttribute(`normal`,new Ao(c,3)),this.setAttribute(`uv`,new Ao(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}},tu=class e extends Ho{constructor(e=new hl([new q(0,.5),new q(-.5,-.5),new q(.5,-.5)]),t=12){super(),this.type=`ShapeGeometry`,this.parameters={shapes:e,curveSegments:t};let n=[],r=[],i=[],a=[],o=0,s=0;if(Array.isArray(e)===!1)c(e);else for(let t=0;t<e.length;t++)c(e[t]),this.addGroup(o,s,t),o+=s,s=0;this.setIndex(n),this.setAttribute(`position`,new Ao(r,3)),this.setAttribute(`normal`,new Ao(i,3)),this.setAttribute(`uv`,new Ao(a,2));function c(e){let o=r.length/3,c=e.extractPoints(t),l=c.shape,u=c.holes;Xl.isClockWise(l)===!1&&(l=l.reverse());for(let e=0,t=u.length;e<t;e++){let t=u[e];Xl.isClockWise(t)===!0&&(u[e]=t.reverse())}let d=Xl.triangulateShape(l,u);for(let e=0,t=u.length;e<t;e++){let t=u[e];l=l.concat(t)}for(let e=0,t=l.length;e<t;e++){let t=l[e];r.push(t.x,t.y,0),i.push(0,0,1),a.push(t.x,t.y)}for(let e=0,t=d.length;e<t;e++){let t=d[e],r=t[0]+o,i=t[1]+o,a=t[2]+o;n.push(r,i,a),s+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return nu(t,e)}static fromJSON(t,n){let r=[];for(let e=0,i=t.shapes.length;e<i;e++){let i=n[t.shapes[e]];r.push(i)}return new e(r,t.curveSegments)}};function nu(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=e[n];t.shapes.push(r.uuid)}else t.shapes.push(e.uuid);return t}var ru=class e extends Ho{constructor(e=1,t=32,n=16,r=0,i=Math.PI*2,a=0,o=Math.PI){super(),this.type=`SphereGeometry`,this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let s=Math.min(a+o,Math.PI),c=0,l=[],u=new J,d=new J,f=[],p=[],m=[],h=[];for(let f=0;f<=n;f++){let g=[],_=f/n,v=0;f===0&&a===0?v=.5/t:f===n&&s===Math.PI&&(v=-.5/t);for(let n=0;n<=t;n++){let s=n/t;u.x=-e*Math.cos(r+s*i)*Math.sin(a+_*o),u.y=e*Math.cos(a+_*o),u.z=e*Math.sin(r+s*i)*Math.sin(a+_*o),p.push(u.x,u.y,u.z),d.copy(u).normalize(),m.push(d.x,d.y,d.z),h.push(s+v,1-_),g.push(c++)}l.push(g)}for(let e=0;e<n;e++)for(let r=0;r<t;r++){let t=l[e][r+1],i=l[e][r],o=l[e+1][r],c=l[e+1][r+1];(e!==0||a>0)&&f.push(t,i,c),(e!==n-1||s<Math.PI)&&f.push(i,o,c)}this.setIndex(f),this.setAttribute(`position`,new Ao(p,3)),this.setAttribute(`normal`,new Ao(m,3)),this.setAttribute(`uv`,new Ao(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}},iu=class extends qo{constructor(e){super(),this.isShadowMaterial=!0,this.type=`ShadowMaterial`,this.color=new X(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}};function au(e){let t={};for(let n in e){t[n]={};for(let r in e[n]){let i=e[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(G(`UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().`),t[n][r]=null):t[n][r]=i.clone():Array.isArray(i)?t[n][r]=i.slice():t[n][r]=i}}return t}function ou(e){let t={};for(let n=0;n<e.length;n++){let r=au(e[n]);for(let e in r)t[e]=r[e]}return t}function su(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function cu(e){let t=e.getRenderTarget();return t===null?e.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Xi.workingColorSpace}var lu={clone:au,merge:ou},uu=`void main() {
|
|
3
3
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
4
4
|
}`,du=`void main() {
|
|
5
5
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
@@ -4047,9 +4047,9 @@ void main() {
|
|
|
4047
4047
|
|
|
4048
4048
|
}
|
|
4049
4049
|
|
|
4050
|
-
}`,nh=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Ic(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new fu({vertexShader:eh,fragmentShader:th,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new As(new $l(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},rh=class extends mi{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=typeof XRWebGLBinding<`u`,h=new nh,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new q,C=null,w=new sd;w.viewport=new sa;let T=new sd;T.viewport=new sa;let E=[w,T],D=new Sd,O=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return t===void 0&&(t=new Va,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new Va,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new Va,b[e]=t),t.getHandSpace()};function A(e){let t=x.indexOf(e.inputSource);if(t===-1)return;let n=b[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function j(){r.removeEventListener(`select`,A),r.removeEventListener(`selectstart`,A),r.removeEventListener(`selectend`,A),r.removeEventListener(`squeeze`,A),r.removeEventListener(`squeezestart`,A),r.removeEventListener(`squeezeend`,A),r.removeEventListener(`end`,j),r.removeEventListener(`inputsourceschange`,M);for(let e=0;e<b.length;e++){let t=x[e];t!==null&&(x[e]=null,b[e].disconnect(t))}O=null,k=null,h.reset();for(let e in g)delete g[e];e.setRenderTarget(v),f=null,d=null,u=null,r=null,y=null,ae.stop(),n.isPresenting=!1,e.setPixelRatio(C),e.setSize(S.width,S.height,!1),n.dispatchEvent({type:`sessionend`})}this.setFramebufferScaleFactor=function(e){i=e,n.isPresenting===!0&&G(`WebXRManager: Cannot change framebuffer scale while presenting.`)},this.setReferenceSpaceType=function(e){o=e,n.isPresenting===!0&&G(`WebXRManager: Cannot change reference space type while presenting.`)},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(e){c=e},this.getBaseLayer=function(){return d===null?f:d},this.getBinding=function(){return u===null&&m&&(u=new XRWebGLBinding(r,t)),u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(l){if(r=l,r!==null){if(v=e.getRenderTarget(),r.addEventListener(`select`,A),r.addEventListener(`selectstart`,A),r.addEventListener(`selectend`,A),r.addEventListener(`squeeze`,A),r.addEventListener(`squeezestart`,A),r.addEventListener(`squeezeend`,A),r.addEventListener(`end`,j),r.addEventListener(`inputsourceschange`,M),_.xrCompatible!==!0&&await t.makeXRCompatible(),C=e.getPixelRatio(),e.getSize(S),m&&`createProjectionLayer`in XRWebGLBinding.prototype){let n=null,a=null,o=null;_.depth&&(o=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=_.stencil?$n:Qn,a=_.stencil?Kn:Vn);let s={colorFormat:t.RGBA8,depthFormat:o,scaleFactor:i};u=this.getBinding(),d=u.createProjectionLayer(s),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),y=new la(d.textureWidth,d.textureHeight,{format:Zn,type:In,depthTexture:new Pc(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{let n={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:i};f=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new la(f.framebufferWidth,f.framebufferHeight,{format:Zn,type:In,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(s),c=null,a=await r.requestReferenceSpace(o),ae.setContext(r),ae.start(),n.isPresenting=!0,n.dispatchEvent({type:`sessionstart`})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return h.getDepthTexture()};function M(e){for(let t=0;t<e.removed.length;t++){let n=e.removed[t],r=x.indexOf(n);r>=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t<e.added.length;t++){let n=e.added[t],r=x.indexOf(n);if(r===-1){for(let e=0;e<b.length;e++)if(e>=x.length){x.push(n),r=e;break}else if(x[e]===null){x[e]=n,r=e;break}if(r===-1)break}let i=b[r];i&&i.connect(n)}}let ee=new J,N=new J;function te(e,t,n){ee.setFromMatrixPosition(t.matrixWorld),N.setFromMatrixPosition(n.matrixWorld);let r=ee.distanceTo(N),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function ne(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;h.texture!==null&&(h.depthNear>0&&(t=h.depthNear),h.depthFar>0&&(n=h.depthFar)),D.near=T.near=w.near=t,D.far=T.far=w.far=n,(O!==D.near||k!==D.far)&&(r.updateRenderState({depthNear:D.near,depthFar:D.far}),O=D.near,k=D.far),D.layers.mask=e.layers.mask|6,w.layers.mask=D.layers.mask&-5,T.layers.mask=D.layers.mask&-3;let i=e.parent,a=D.cameras;ne(D,i);for(let e=0;e<a.length;e++)ne(a[e],i);a.length===2?te(D,w,T):D.projectionMatrix.copy(w.projectionMatrix),re(e,D,i)};function re(e,t,n){n===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=vi*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}this.getCamera=function(){return D},this.getFoveation=function(){if(!(d===null&&f===null))return s},this.setFoveation=function(e){s=e,d!==null&&(d.fixedFoveation=e),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=e)},this.hasDepthSensing=function(){return h.texture!==null},this.getDepthSensingMesh=function(){return h.getMesh(D)},this.getCameraTexture=function(e){return g[e]};let P=null;function ie(t,i){if(l=i.getViewerPose(c||a),p=i,l!==null){let t=l.views;f!==null&&(e.setRenderTargetFramebuffer(y,f.framebuffer),e.setRenderTarget(y));let i=!1;t.length!==D.cameras.length&&(D.cameras.length=0,i=!0);for(let n=0;n<t.length;n++){let r=t[n],a=null;if(f!==null)a=f.getViewport(r);else{let t=u.getViewSubImage(d,r);a=t.viewport,n===0&&(e.setRenderTargetTextures(y,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(y))}let o=E[n];o===void 0&&(o=new sd,o.layers.enable(n),o.viewport=new sa,E[n]=o),o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.projectionMatrix.fromArray(r.projectionMatrix),o.projectionMatrixInverse.copy(o.projectionMatrix).invert(),o.viewport.set(a.x,a.y,a.width,a.height),n===0&&(D.matrix.copy(o.matrix),D.matrix.decompose(D.position,D.quaternion,D.scale)),i===!0&&D.cameras.push(o)}let a=r.enabledFeatures;if(a&&a.includes(`depth-sensing`)&&r.depthUsage==`gpu-optimized`&&m){u=n.getBinding();let e=u.getDepthInformation(t[0]);e&&e.isValid&&e.texture&&h.init(e,r.renderState)}if(a&&a.includes(`camera-access`)&&m){e.state.unbindTexture(),u=n.getBinding();for(let e=0;e<t.length;e++){let n=t[e].camera;if(n){let e=g[n];e||(e=new Ic,g[n]=e);let t=u.getCameraImage(n);e.sourceTexture=t}}}}for(let e=0;e<b.length;e++){let t=x[e],n=b[e];t!==null&&n!==void 0&&n.update(t,i,c||a)}P&&P(t,i),i.detectedPlanes&&n.dispatchEvent({type:`planesdetected`,data:i}),p=null}let ae=new Yd;ae.setAnimationLoop(ie),this.setAnimationLoop=function(e){P=e},this.dispose=function(){}}},ih=new xa,ah=new Y;function oh(e,t){function n(e,t){e.matrixAutoUpdate===!0&&e.updateMatrix(),t.value.copy(e.matrix)}function r(t,n){n.color.getRGB(t.fogColor.value,cu(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)}function i(e,t,n,r,i){t.isMeshBasicMaterial?a(e,t):t.isMeshLambertMaterial?(a(e,t),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)):t.isMeshToonMaterial?(a(e,t),d(e,t)):t.isMeshPhongMaterial?(a(e,t),u(e,t),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)):t.isMeshStandardMaterial?(a(e,t),f(e,t),t.isMeshPhysicalMaterial&&p(e,t,i)):t.isMeshMatcapMaterial?(a(e,t),m(e,t)):t.isMeshDepthMaterial?a(e,t):t.isMeshDistanceMaterial?(a(e,t),h(e,t)):t.isMeshNormalMaterial?a(e,t):t.isLineBasicMaterial?(o(e,t),t.isLineDashedMaterial&&s(e,t)):t.isPointsMaterial?c(e,t,n,r):t.isSpriteMaterial?l(e,t):t.isShadowMaterial?(e.color.value.copy(t.color),e.opacity.value=t.opacity):t.isShaderMaterial&&(t.uniformsNeedUpdate=!1)}function a(e,r){e.opacity.value=r.opacity,r.color&&e.diffuse.value.copy(r.color),r.emissive&&e.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(e.map.value=r.map,n(r.map,e.mapTransform)),r.alphaMap&&(e.alphaMap.value=r.alphaMap,n(r.alphaMap,e.alphaMapTransform)),r.bumpMap&&(e.bumpMap.value=r.bumpMap,n(r.bumpMap,e.bumpMapTransform),e.bumpScale.value=r.bumpScale,r.side===1&&(e.bumpScale.value*=-1)),r.normalMap&&(e.normalMap.value=r.normalMap,n(r.normalMap,e.normalMapTransform),e.normalScale.value.copy(r.normalScale),r.side===1&&e.normalScale.value.negate()),r.displacementMap&&(e.displacementMap.value=r.displacementMap,n(r.displacementMap,e.displacementMapTransform),e.displacementScale.value=r.displacementScale,e.displacementBias.value=r.displacementBias),r.emissiveMap&&(e.emissiveMap.value=r.emissiveMap,n(r.emissiveMap,e.emissiveMapTransform)),r.specularMap&&(e.specularMap.value=r.specularMap,n(r.specularMap,e.specularMapTransform)),r.alphaTest>0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,ih.copy(o),ih.x*=-1,ih.y*=-1,ih.z*=-1,a.isCubeTexture&&a.isRenderTargetTexture===!1&&(ih.y*=-1,ih.z*=-1),e.envMapRotation.value.setFromMatrix4(ah.makeRotationFromEuler(ih)),e.flipEnvMap.value=a.isCubeTexture&&a.isRenderTargetTexture===!1?-1:1,e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function sh(e,t,n,r){let i={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(m(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e<s;e++)if(o.indexOf(e)===-1)return o.push(e),e;return K(`WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached.`),0}function f(t){let n=i[t.id],r=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let t=0,n=r.length;t<n;t++){let n=Array.isArray(r[t])?r[t]:[r[t]];for(let r=0,i=n.length;r<i;r++){let i=n[r];if(p(i,t,r,a)===!0){let t=i.__offset,n=Array.isArray(i.value)?i.value:[i.value],r=0;for(let a=0;a<n.length;a++){let o=n[a],s=h(o);typeof o==`number`||typeof o==`boolean`?(i.__data[0]=o,e.bufferSubData(e.UNIFORM_BUFFER,t+r,i.__data)):o.isMatrix3?(i.__data[0]=o.elements[0],i.__data[1]=o.elements[1],i.__data[2]=o.elements[2],i.__data[3]=0,i.__data[4]=o.elements[3],i.__data[5]=o.elements[4],i.__data[6]=o.elements[5],i.__data[7]=0,i.__data[8]=o.elements[6],i.__data[9]=o.elements[7],i.__data[10]=o.elements[8],i.__data[11]=0):(o.toArray(i.__data,r),r+=s.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,i.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}function p(e,t,n,r){let i=e.value,a=t+`_`+n;if(r[a]===void 0)return typeof i==`number`||typeof i==`boolean`?r[a]=i:r[a]=i.clone(),!0;{let e=r[a];if(typeof i==`number`||typeof i==`boolean`){if(e!==i)return r[a]=i,!0}else if(e.equals(i)===!1)return e.copy(i),!0}return!1}function m(e){let t=e.uniforms,n=0;for(let e=0,r=t.length;e<r;e++){let r=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0,t=r.length;e<t;e++){let t=r[e],i=Array.isArray(t.value)?t.value:[t.value];for(let e=0,r=i.length;e<r;e++){let r=i[e],a=h(r),o=n%16,s=o%a.boundary,c=o+s;n+=s,c!==0&&16-c<a.storage&&(n+=16-c),t.__data=new Float32Array(a.storage/Float32Array.BYTES_PER_ELEMENT),t.__offset=n,n+=a.storage}}}let r=n%16;return r>0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e){let t={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?G(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):G(`WebGLRenderer: Unsupported uniform value type.`,e),t}function g(t){let n=t.target;n.removeEventListener(`dispose`,g);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:_}}var ch=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),lh=null;function uh(){return lh===null&&(lh=new Ws(ch,16,16,nr,Un),lh.name=`DFG_LUT`,lh.minFilter=Nn,lh.magFilter=Nn,lh.wrapS=On,lh.wrapT=On,lh.generateMipmaps=!1,lh.needsUpdate=!0),lh}var dh=class{constructor(e={}){let{canvas:t=oi(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:c=!1,powerPreference:l=`default`,failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=In}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<`u`&&n instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);p=n.getContextAttributes().alpha}else p=a;let m=f,h=new Set([ir,rr,tr]),g=new Set([In,Vn,zn,Kn,Wn,Gn]),_=new Uint32Array(4),v=new Int32Array(4),y=null,b=null,x=[],S=[],C=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let w=this,T=!1;this._outputColorSpace=Xr;let E=0,D=0,O=null,k=-1,A=null,j=new sa,M=new sa,ee=null,N=new X(0),te=0,ne=t.width,re=t.height,P=1,ie=null,ae=null,F=new sa(0,0,ne,re),I=new sa(0,0,ne,re),oe=!1,se=new uc,ce=!1,le=!1,ue=new Y,de=new J,fe=new sa,pe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},me=!1;function he(){return O===null?P:1}let L=n;function ge(e,n){return t.getContext(e,n)}try{let e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r183`),t.addEventListener(`webglcontextlost`,Le,!1),t.addEventListener(`webglcontextrestored`,Re,!1),t.addEventListener(`webglcontextcreationerror`,ze,!1),L===null){let t=`webgl2`;if(L=ge(t,e),L===null)throw ge(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}}catch(e){throw K(`WebGLRenderer: `+e.message),e}let R,_e,z,ve,B,V,ye,be,xe,Se,Ce,we,Te,H,Ee,De,Oe,ke,Ae,je,Me,Ne,Pe;function Fe(){R=new Af(L),R.init(),Me=new $m(L,R),_e=new of(L,R,e,Me),z=new Zm(L,R),_e.reversedDepthBuffer&&d&&z.buffers.depth.setReversed(!0),ve=new Nf(L),B=new jm,V=new Qm(L,R,z,B,_e,Me,ve),ye=new kf(w),be=new Xd(L),Ne=new rf(L,be),xe=new jf(L,be,ve,Ne),Se=new Ff(L,xe,be,Ne,ve),ke=new Pf(L,_e,V),Ee=new sf(B),Ce=new Am(w,ye,R,_e,Ne,Ee),we=new oh(w,B),Te=new Fm,H=new Hm(R),Oe=new nf(w,ye,z,Se,p,s),De=new Xm(w,Se,_e),Pe=new sh(L,ve,_e,z),Ae=new af(L,R,ve),je=new Mf(L,R,ve),ve.programs=Ce.programs,w.capabilities=_e,w.extensions=R,w.properties=B,w.renderLists=Te,w.shadowMap=De,w.state=z,w.info=ve}Fe(),m!==1009&&(C=new Lf(m,t.width,t.height,r,i));let Ie=new rh(w,L);this.xr=Ie,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let e=R.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=R.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return P},this.setPixelRatio=function(e){e!==void 0&&(P=e,this.setSize(ne,re,!1))},this.getSize=function(e){return e.set(ne,re)},this.setSize=function(e,n,r=!0){if(Ie.isPresenting){G(`WebGLRenderer: Can't change size while VR device is presenting.`);return}ne=e,re=n,t.width=Math.floor(e*P),t.height=Math.floor(n*P),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),C!==null&&C.setSize(t.width,t.height),this.setViewport(0,0,e,n)},this.getDrawingBufferSize=function(e){return e.set(ne*P,re*P).floor()},this.setDrawingBufferSize=function(e,n,r){ne=e,re=n,P=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(m===1009){console.error(`THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);return}if(e){for(let t=0;t<e.length;t++)if(e[t].isOutputPass===!0){console.warn(`THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.`);break}}C.setEffects(e||[])},this.getCurrentViewport=function(e){return e.copy(j)},this.getViewport=function(e){return e.copy(F)},this.setViewport=function(e,t,n,r){e.isVector4?F.set(e.x,e.y,e.z,e.w):F.set(e,t,n,r),z.viewport(j.copy(F).multiplyScalar(P).round())},this.getScissor=function(e){return e.copy(I)},this.setScissor=function(e,t,n,r){e.isVector4?I.set(e.x,e.y,e.z,e.w):I.set(e,t,n,r),z.scissor(M.copy(I).multiplyScalar(P).round())},this.getScissorTest=function(){return oe},this.setScissorTest=function(e){z.setScissorTest(oe=e)},this.setOpaqueSort=function(e){ie=e},this.setTransparentSort=function(e){ae=e},this.getClearColor=function(e){return e.copy(Oe.getClearColor())},this.setClearColor=function(){Oe.setClearColor(...arguments)},this.getClearAlpha=function(){return Oe.getClearAlpha()},this.setClearAlpha=function(){Oe.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let r=0;if(e){let e=!1;if(O!==null){let t=O.texture.format;e=h.has(t)}if(e){let e=O.texture.type,t=g.has(e),n=Oe.getClearColor(),r=Oe.getClearAlpha(),i=n.r,a=n.g,o=n.b;t?(_[0]=i,_[1]=a,_[2]=o,_[3]=r,L.clearBufferuiv(L.COLOR,0,_)):(v[0]=i,v[1]=a,v[2]=o,v[3]=r,L.clearBufferiv(L.COLOR,0,v))}else r|=L.COLOR_BUFFER_BIT}t&&(r|=L.DEPTH_BUFFER_BIT),n&&(r|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),r!==0&&L.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener(`webglcontextlost`,Le,!1),t.removeEventListener(`webglcontextrestored`,Re,!1),t.removeEventListener(`webglcontextcreationerror`,ze,!1),Oe.dispose(),Te.dispose(),H.dispose(),B.dispose(),ye.dispose(),Se.dispose(),Ne.dispose(),Pe.dispose(),Ce.dispose(),Ie.dispose(),Ie.removeEventListener(`sessionstart`,Ke),Ie.removeEventListener(`sessionend`,qe),Je.stop()};function Le(e){e.preventDefault(),li(`WebGLRenderer: Context Lost.`),T=!0}function Re(){li(`WebGLRenderer: Context Restored.`),T=!1;let e=ve.autoReset,t=De.enabled,n=De.autoUpdate,r=De.needsUpdate,i=De.type;Fe(),ve.autoReset=e,De.enabled=t,De.autoUpdate=n,De.needsUpdate=r,De.type=i}function ze(e){K(`WebGLRenderer: A WebGL context could not be created. Reason: `,e.statusMessage)}function Be(e){let t=e.target;t.removeEventListener(`dispose`,Be),Ve(t)}function Ve(e){He(e),B.remove(e)}function He(e){let t=B.get(e).programs;t!==void 0&&(t.forEach(function(e){Ce.releaseProgram(e)}),e.isShaderMaterial&&Ce.releaseShaderCache(e))}this.renderBufferDirect=function(e,t,n,r,i,a){t===null&&(t=pe);let o=i.isMesh&&i.matrixWorld.determinant()<0,s=rt(e,t,n,r,i);z.setMaterial(r,o);let c=n.index,l=1;if(r.wireframe===!0){if(c=xe.getWireframeAttribute(n),c===void 0)return;l=2}let u=n.drawRange,d=n.attributes.position,f=u.start*l,p=(u.start+u.count)*l;a!==null&&(f=Math.max(f,a.start*l),p=Math.min(p,(a.start+a.count)*l)),c===null?d!=null&&(f=Math.max(f,0),p=Math.min(p,d.count)):(f=Math.max(f,0),p=Math.min(p,c.count));let m=p-f;if(m<0||m===1/0)return;Ne.setup(i,r,s,n,c);let h,g=Ae;if(c!==null&&(h=be.get(c),g=je,g.setIndex(h)),i.isMesh)r.wireframe===!0?(z.setLineWidth(r.wireframeLinewidth*he()),g.setMode(L.LINES)):g.setMode(L.TRIANGLES);else if(i.isLine){let e=r.linewidth;e===void 0&&(e=1),z.setLineWidth(e*he()),i.isLineSegments?g.setMode(L.LINES):i.isLineLoop?g.setMode(L.LINE_LOOP):g.setMode(L.LINE_STRIP)}else i.isPoints?g.setMode(L.POINTS):i.isSprite&&g.setMode(L.TRIANGLES);if(i.isBatchedMesh)if(i._multiDrawInstances!==null)di(`WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.`),g.renderMultiDrawInstances(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount,i._multiDrawInstances);else if(R.get(`WEBGL_multi_draw`))g.renderMultiDraw(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount);else{let e=i._multiDrawStarts,t=i._multiDrawCounts,n=i._multiDrawCount,a=c?be.get(c).bytesPerElement:1,o=B.get(r).currentProgram.getUniforms();for(let r=0;r<n;r++)o.setValue(L,`_gl_DrawID`,r),g.render(e[r]/a,t[r])}else if(i.isInstancedMesh)g.renderInstances(f,m,i.count);else if(n.isInstancedBufferGeometry){let e=n._maxInstanceCount===void 0?1/0:n._maxInstanceCount,t=Math.min(n.instanceCount,e);g.renderInstances(f,m,t)}else g.render(f,m)};function Ue(e,t,n){e.transparent===!0&&e.side===2&&e.forceSinglePass===!1?(e.side=1,e.needsUpdate=!0,et(e,t,n),e.side=0,e.needsUpdate=!0,et(e,t,n),e.side=2):et(e,t,n)}this.compile=function(e,t,n=null){n===null&&(n=e),b=H.get(n),b.init(t),S.push(b),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(b.pushLight(e),e.castShadow&&b.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(b.pushLight(e),e.castShadow&&b.pushShadow(e))}),b.setupLights();let r=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;let t=e.material;if(t)if(Array.isArray(t))for(let i=0;i<t.length;i++){let a=t[i];Ue(a,n,e),r.add(a)}else Ue(t,n,e),r.add(t)}),b=S.pop(),r},this.compileAsync=function(e,t,n=null){let r=this.compile(e,t,n);return new Promise(t=>{function n(){if(r.forEach(function(e){B.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}R.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let We=null;function Ge(e){We&&We(e)}function Ke(){Je.stop()}function qe(){Je.start()}let Je=new Yd;Je.setAnimationLoop(Ge),typeof self<`u`&&Je.setContext(self),this.setAnimationLoop=function(e){We=e,Ie.setAnimationLoop(e),e===null?Je.stop():Je.start()},Ie.addEventListener(`sessionstart`,Ke),Ie.addEventListener(`sessionend`,qe),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){K(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(T===!0)return;let n=Ie.enabled===!0&&Ie.isPresenting===!0,r=C!==null&&(O===null||n)&&C.begin(w,O);if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),Ie.enabled===!0&&Ie.isPresenting===!0&&(C===null||C.isCompositing()===!1)&&(Ie.cameraAutoUpdate===!0&&Ie.updateCamera(t),t=Ie.getCamera()),e.isScene===!0&&e.onBeforeRender(w,e,t,O),b=H.get(e,S.length),b.init(t),S.push(b),ue.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),se.setFromProjectionMatrix(ue,ni,t.reversedDepth),le=this.localClippingEnabled,ce=Ee.init(this.clippingPlanes,le),y=Te.get(e,x.length),y.init(),x.push(y),Ie.enabled===!0&&Ie.isPresenting===!0){let e=w.xr.getDepthSensingMesh();e!==null&&Ye(e,t,-1/0,w.sortObjects)}Ye(e,t,0,w.sortObjects),y.finish(),w.sortObjects===!0&&y.sort(ie,ae),me=Ie.enabled===!1||Ie.isPresenting===!1||Ie.hasDepthSensing()===!1,me&&Oe.addToRenderList(y,e),this.info.render.frame++,ce===!0&&Ee.beginShadows();let i=b.state.shadowsArray;if(De.render(i,e,t),ce===!0&&Ee.endShadows(),this.info.autoReset===!0&&this.info.reset(),(r&&C.hasRenderPass())===!1){let n=y.opaque,r=y.transmissive;if(b.setupLights(),t.isArrayCamera){let i=t.cameras;if(r.length>0)for(let t=0,a=i.length;t<a;t++){let a=i[t];Ze(n,r,e,a)}me&&Oe.render(e);for(let t=0,n=i.length;t<n;t++){let n=i[t];Xe(y,e,n,n.viewport)}}else r.length>0&&Ze(n,r,e,t),me&&Oe.render(e),Xe(y,e,t)}O!==null&&D===0&&(V.updateMultisampleRenderTarget(O),V.updateRenderTargetMipmap(O)),r&&C.end(w),e.isScene===!0&&e.onAfterRender(w,e,t),Ne.resetDefaultState(),k=-1,A=null,S.pop(),S.length>0?(b=S[S.length-1],ce===!0&&Ee.setGlobalState(w.clippingPlanes,b.state.camera)):b=null,x.pop(),y=x.length>0?x[x.length-1]:null};function Ye(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)b.pushLight(e),e.castShadow&&b.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||se.intersectsSprite(e)){r&&fe.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ue);let t=Se.update(e),i=e.material;i.visible&&y.push(e,t,i,n,fe.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||se.intersectsObject(e))){let t=Se.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),fe.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),fe.copy(e.boundingSphere.center)),fe.applyMatrix4(e.matrixWorld).applyMatrix4(ue)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a<o;a++){let o=r[a],s=i[o.materialIndex];s&&s.visible&&y.push(e,t,s,n,fe.z,o)}}else i.visible&&y.push(e,t,i,n,fe.z,null)}}let i=e.children;for(let e=0,a=i.length;e<a;e++)Ye(i[e],t,n,r)}function Xe(e,t,n,r){let{opaque:i,transmissive:a,transparent:o}=e;b.setupLightsView(n),ce===!0&&Ee.setGlobalState(w.clippingPlanes,n),r&&z.viewport(j.copy(r)),i.length>0&&Qe(i,t,n),a.length>0&&Qe(a,t,n),o.length>0&&Qe(o,t,n),z.buffers.depth.setTest(!0),z.buffers.depth.setMask(!0),z.buffers.color.setMask(!0),z.setPolygonOffset(!1)}function Ze(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[r.id]===void 0){let e=R.has(`EXT_color_buffer_half_float`)||R.has(`EXT_color_buffer_float`);b.state.transmissionRenderTarget[r.id]=new la(1,1,{generateMipmaps:!0,type:e?Un:In,minFilter:Fn,samples:Math.max(4,_e.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Xi.workingColorSpace})}let a=b.state.transmissionRenderTarget[r.id],o=r.viewport||j;a.setSize(o.z*w.transmissionResolutionScale,o.w*w.transmissionResolutionScale);let s=w.getRenderTarget(),c=w.getActiveCubeFace(),l=w.getActiveMipmapLevel();w.setRenderTarget(a),w.getClearColor(N),te=w.getClearAlpha(),te<1&&w.setClearColor(16777215,.5),w.clear(),me&&Oe.render(n);let u=w.toneMapping;w.toneMapping=0;let d=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),b.setupLightsView(r),ce===!0&&Ee.setGlobalState(w.clippingPlanes,r),Qe(e,n,r),V.updateMultisampleRenderTarget(a),V.updateRenderTargetMipmap(a),R.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i<a;i++){let{object:a,geometry:o,material:s,group:c}=t[i];if(s.side===2&&a.layers.test(r.layers)){let t=s.side;s.side=1,s.needsUpdate=!0,$e(a,n,r,o,s,c),s.side=t,s.needsUpdate=!0,e=!0}}e===!0&&(V.updateMultisampleRenderTarget(a),V.updateRenderTargetMipmap(a))}w.setRenderTarget(s,c,l),w.setClearColor(N,te),d!==void 0&&(r.viewport=d),w.toneMapping=u}function Qe(e,t,n){let r=t.isScene===!0?t.overrideMaterial:null;for(let i=0,a=e.length;i<a;i++){let a=e[i],{object:o,geometry:s,group:c}=a,l=a.material;l.allowOverride===!0&&r!==null&&(l=r),o.layers.test(n.layers)&&$e(o,t,n,s,l,c)}}function $e(e,t,n,r,i,a){e.onBeforeRender(w,t,n,r,i,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),i.onBeforeRender(w,t,n,r,e,a),i.transparent===!0&&i.side===2&&i.forceSinglePass===!1?(i.side=1,i.needsUpdate=!0,w.renderBufferDirect(n,t,r,i,e,a),i.side=0,i.needsUpdate=!0,w.renderBufferDirect(n,t,r,i,e,a),i.side=2):w.renderBufferDirect(n,t,r,i,e,a),e.onAfterRender(w,t,n,r,i,a)}function et(e,t,n){t.isScene!==!0&&(t=pe);let r=B.get(e),i=b.state.lights,a=b.state.shadowsArray,o=i.state.version,s=Ce.getParameters(e,i.state,a,t,n),c=Ce.getProgramCacheKey(s),l=r.programs;r.environment=e.isMeshStandardMaterial||e.isMeshLambertMaterial||e.isMeshPhongMaterial?t.environment:null,r.fog=t.fog;let u=e.isMeshStandardMaterial||e.isMeshLambertMaterial&&!e.envMap||e.isMeshPhongMaterial&&!e.envMap;r.envMap=ye.get(e.envMap||r.environment,u),r.envMapRotation=r.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation,l===void 0&&(e.addEventListener(`dispose`,Be),l=new Map,r.programs=l);let d=l.get(c);if(d!==void 0){if(r.currentProgram===d&&r.lightsStateVersion===o)return nt(e,s),d}else s.uniforms=Ce.getUniforms(e),e.onBeforeCompile(s,w),d=Ce.acquireProgram(s,c),l.set(c,d),r.uniforms=s.uniforms;let f=r.uniforms;return(!e.isShaderMaterial&&!e.isRawShaderMaterial||e.clipping===!0)&&(f.clippingPlanes=Ee.uniform),nt(e,s),r.needsLights=at(e),r.lightsStateVersion=o,r.needsLights&&(f.ambientLightColor.value=i.state.ambient,f.lightProbe.value=i.state.probe,f.directionalLights.value=i.state.directional,f.directionalLightShadows.value=i.state.directionalShadow,f.spotLights.value=i.state.spot,f.spotLightShadows.value=i.state.spotShadow,f.rectAreaLights.value=i.state.rectArea,f.ltc_1.value=i.state.rectAreaLTC1,f.ltc_2.value=i.state.rectAreaLTC2,f.pointLights.value=i.state.point,f.pointLightShadows.value=i.state.pointShadow,f.hemisphereLights.value=i.state.hemi,f.directionalShadowMatrix.value=i.state.directionalShadowMatrix,f.spotLightMatrix.value=i.state.spotLightMatrix,f.spotLightMap.value=i.state.spotLightMap,f.pointShadowMatrix.value=i.state.pointShadowMatrix),r.currentProgram=d,r.uniformsList=null,d}function tt(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=Wp.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function nt(e,t){let n=B.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}function rt(e,t,n,r,i){t.isScene!==!0&&(t=pe),V.resetTextureUnits();let a=t.fog,o=r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial?t.environment:null,s=O===null?w.outputColorSpace:O.isXRRenderTarget===!0?O.texture.colorSpace:Zr,c=r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap,l=ye.get(r.envMap||o,c),u=r.vertexColors===!0&&!!n.attributes.color&&n.attributes.color.itemSize===4,d=!!n.attributes.tangent&&(!!r.normalMap||r.anisotropy>0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,h=0;r.toneMapped&&(O===null||O.isXRRenderTarget===!0)&&(h=w.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,v=B.get(r),y=b.state.lights;if(ce===!0&&(le===!0||e!==A)){let t=e===A&&r.id===k;Ee.setState(r,e,t)}let x=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version?x=!0:v.outputColorSpace===s?i.isBatchedMesh&&v.batching===!1||!i.isBatchedMesh&&v.batching===!0||i.isBatchedMesh&&v.batchingColor===!0&&i.colorTexture===null||i.isBatchedMesh&&v.batchingColor===!1&&i.colorTexture!==null||i.isInstancedMesh&&v.instancing===!1||!i.isInstancedMesh&&v.instancing===!0||i.isSkinnedMesh&&v.skinning===!1||!i.isSkinnedMesh&&v.skinning===!0||i.isInstancedMesh&&v.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&v.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&v.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&v.instancingMorph===!1&&i.morphTexture!==null?x=!0:v.envMap===l?r.fog===!0&&v.fog!==a||v.numClippingPlanes!==void 0&&(v.numClippingPlanes!==Ee.numPlanes||v.numIntersection!==Ee.numIntersection)?x=!0:v.vertexAlphas===u&&v.vertexTangents===d&&v.morphTargets===f&&v.morphNormals===p&&v.morphColors===m&&v.toneMapping===h?v.morphTargetsCount!==_&&(x=!0):x=!0:x=!0:x=!0:(x=!0,v.__version=r.version);let S=v.currentProgram;x===!0&&(S=et(r,t,i));let C=!1,T=!1,E=!1,D=S.getUniforms(),j=v.uniforms;if(z.useProgram(S.program)&&(C=!0,T=!0,E=!0),r.id!==k&&(k=r.id,T=!0),C||A!==e){z.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),D.setValue(L,`projectionMatrix`,e.projectionMatrix),D.setValue(L,`viewMatrix`,e.matrixWorldInverse);let t=D.map.cameraPosition;t!==void 0&&t.setValue(L,de.setFromMatrixPosition(e.matrixWorld)),_e.logarithmicDepthBuffer&&D.setValue(L,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&D.setValue(L,`isOrthographic`,e.isOrthographicCamera===!0),A!==e&&(A=e,T=!0,E=!0)}if(v.needsLights&&(y.state.directionalShadowMap.length>0&&D.setValue(L,`directionalShadowMap`,y.state.directionalShadowMap,V),y.state.spotShadowMap.length>0&&D.setValue(L,`spotShadowMap`,y.state.spotShadowMap,V),y.state.pointShadowMap.length>0&&D.setValue(L,`pointShadowMap`,y.state.pointShadowMap,V)),i.isSkinnedMesh){D.setOptional(L,i,`bindMatrix`),D.setOptional(L,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),D.setValue(L,`boneTexture`,e.boneTexture,V))}i.isBatchedMesh&&(D.setOptional(L,i,`batchingTexture`),D.setValue(L,`batchingTexture`,i._matricesTexture,V),D.setOptional(L,i,`batchingIdTexture`),D.setValue(L,`batchingIdTexture`,i._indirectTexture,V),D.setOptional(L,i,`batchingColorTexture`),i._colorsTexture!==null&&D.setValue(L,`batchingColorTexture`,i._colorsTexture,V));let M=n.morphAttributes;if((M.position!==void 0||M.normal!==void 0||M.color!==void 0)&&ke.update(i,n,S),(T||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,D.setValue(L,`receiveShadow`,i.receiveShadow)),(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial)&&r.envMap===null&&t.environment!==null&&(j.envMapIntensity.value=t.environmentIntensity),j.dfgLUT!==void 0&&(j.dfgLUT.value=uh()),T&&(D.setValue(L,`toneMappingExposure`,w.toneMappingExposure),v.needsLights&&it(j,E),a&&r.fog===!0&&we.refreshFogUniforms(j,a),we.refreshMaterialUniforms(j,r,P,re,b.state.transmissionRenderTarget[e.id]),Wp.upload(L,tt(v),j,V)),r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(Wp.upload(L,tt(v),j,V),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&D.setValue(L,`center`,i.center),D.setValue(L,`modelViewMatrix`,i.modelViewMatrix),D.setValue(L,`normalMatrix`,i.normalMatrix),D.setValue(L,`modelMatrix`,i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){let e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++){let n=e[t];Pe.update(n,S),Pe.bind(n,S)}}return S}function it(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function at(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&e.lights===!0}this.getActiveCubeFace=function(){return E},this.getActiveMipmapLevel=function(){return D},this.getRenderTarget=function(){return O},this.setRenderTargetTextures=function(e,t,n){let r=B.get(e);r.__autoAllocateDepthBuffer=e.resolveDepthBuffer===!1,r.__autoAllocateDepthBuffer===!1&&(r.__useRenderToTexture=!1),B.get(e.texture).__webglTexture=t,B.get(e.depthTexture).__webglTexture=r.__autoAllocateDepthBuffer?void 0:n,r.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){let n=B.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=t===void 0};let ot=L.createFramebuffer();this.setRenderTarget=function(e,t=0,n=0){O=e,E=t,D=n;let r=null,i=!1,a=!1;if(e){let o=B.get(e);if(o.__useDefaultFramebuffer!==void 0){z.bindFramebuffer(L.FRAMEBUFFER,o.__webglFramebuffer),j.copy(e.viewport),M.copy(e.scissor),ee=e.scissorTest,z.viewport(j),z.scissor(M),z.setScissorTest(ee),k=-1;return}else if(o.__webglFramebuffer===void 0)V.setupRenderTarget(e);else if(o.__hasExternalTextures)V.rebindTextures(e,B.get(e.texture).__webglTexture,B.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let t=e.depthTexture;if(o.__boundDepthTexture!==t){if(t!==null&&B.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw Error(`WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.`);V.setupDepthRenderbuffer(e)}}let s=e.texture;(s.isData3DTexture||s.isDataArrayTexture||s.isCompressedArrayTexture)&&(a=!0);let c=B.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],i=!0):r=e.samples>0&&V.useMultisampledRTT(e)===!1?B.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,j.copy(e.viewport),M.copy(e.scissor),ee=e.scissorTest}else j.copy(F).multiplyScalar(P).floor(),M.copy(I).multiplyScalar(P).floor(),ee=oe;if(n!==0&&(r=ot),z.bindFramebuffer(L.FRAMEBUFFER,r)&&z.drawBuffers(e,r),z.viewport(j),z.scissor(M),z.setScissorTest(ee),i){let r=B.get(e.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t<e.textures.length;t++){let i=B.get(e.textures[t]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+t,i.__webglTexture,n,r)}}else if(e!==null&&n!==0){let t=B.get(e.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,t.__webglTexture,n)}k=-1},this.readRenderTargetPixels=function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget)){K(`WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);return}let c=B.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c){z.bindFramebuffer(L.FRAMEBUFFER,c);try{let o=e.textures[s],c=o.format,l=o.type;if(e.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+s),!_e.textureFormatReadable(c)){K(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!_e.textureTypeReadable(l)){K(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&L.readPixels(t,n,r,i,Me.convert(c),Me.convert(l),a)}finally{let e=O===null?null:B.get(O).__webglFramebuffer;z.bindFramebuffer(L.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=B.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c)if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){z.bindFramebuffer(L.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(e.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+s),!_e.textureFormatReadable(l))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(!_e.textureTypeReadable(u))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let d=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,d),L.bufferData(L.PIXEL_PACK_BUFFER,a.byteLength,L.STREAM_READ),L.readPixels(t,n,r,i,Me.convert(l),Me.convert(u),0);let f=O===null?null:B.get(O).__webglFramebuffer;z.bindFramebuffer(L.FRAMEBUFFER,f);let p=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await fi(L,p,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,d),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,a),L.deleteBuffer(d),L.deleteSync(p),a}else throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;V.setTexture2D(e,0),L.copyTexSubImage2D(L.TEXTURE_2D,n,0,0,o,s,i,a),z.unbindTexture()};let st=L.createFramebuffer(),ct=L.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=0){let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=Me.convert(t.format),_=Me.convert(t.type),v;t.isData3DTexture?(V.setTexture3D(t,0),v=L.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(V.setTexture2DArray(t,0),v=L.TEXTURE_2D_ARRAY):(V.setTexture2D(t,0),v=L.TEXTURE_2D),L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,t.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,t.unpackAlignment);let y=L.getParameter(L.UNPACK_ROW_LENGTH),b=L.getParameter(L.UNPACK_IMAGE_HEIGHT),x=L.getParameter(L.UNPACK_SKIP_PIXELS),S=L.getParameter(L.UNPACK_SKIP_ROWS),C=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,h.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,h.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,l),L.pixelStorei(L.UNPACK_SKIP_ROWS,u),L.pixelStorei(L.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=B.get(e),r=B.get(t),h=B.get(n.__renderTarget),g=B.get(r.__renderTarget);z.bindFramebuffer(L.READ_FRAMEBUFFER,h.__webglFramebuffer),z.bindFramebuffer(L.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<c;n++)w&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,B.get(e).__webglTexture,i,d+n),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,B.get(t).__webglTexture,a,m+n)),L.blitFramebuffer(l,u,o,s,f,p,o,s,L.DEPTH_BUFFER_BIT,L.NEAREST);z.bindFramebuffer(L.READ_FRAMEBUFFER,null),z.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(i!==0||e.isRenderTargetTexture||B.has(e)){let n=B.get(e),r=B.get(t);z.bindFramebuffer(L.READ_FRAMEBUFFER,st),z.bindFramebuffer(L.DRAW_FRAMEBUFFER,ct);for(let e=0;e<c;e++)w?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,n.__webglTexture,i,d+e):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,n.__webglTexture,i),T?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,r.__webglTexture,a,m+e):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,r.__webglTexture,a),i===0?T?L.copyTexSubImage3D(v,a,f,p,m+e,l,u,o,s):L.copyTexSubImage2D(v,a,f,p,l,u,o,s):L.blitFramebuffer(l,u,o,s,f,p,o,s,L.COLOR_BUFFER_BIT,L.NEAREST);z.bindFramebuffer(L.READ_FRAMEBUFFER,null),z.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else T?e.isDataTexture||e.isData3DTexture?L.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h.data):t.isCompressedArrayTexture?L.compressedTexSubImage3D(v,a,f,p,m,o,s,c,g,h.data):L.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h):e.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,a,f,p,o,s,g,_,h.data):e.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,a,f,p,h.width,h.height,g,h.data):L.texSubImage2D(L.TEXTURE_2D,a,f,p,o,s,g,_,h);L.pixelStorei(L.UNPACK_ROW_LENGTH,y),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,b),L.pixelStorei(L.UNPACK_SKIP_PIXELS,x),L.pixelStorei(L.UNPACK_SKIP_ROWS,S),L.pixelStorei(L.UNPACK_SKIP_IMAGES,C),a===0&&t.generateMipmaps&&L.generateMipmap(v),z.unbindTexture()},this.initRenderTarget=function(e){B.get(e).__webglFramebuffer===void 0&&V.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?V.setTextureCube(e,0):e.isData3DTexture?V.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?V.setTexture2DArray(e,0):V.setTexture2D(e,0),z.unbindTexture()},this.resetState=function(){E=0,D=0,O=null,z.reset(),Ne.reset()},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}get coordinateSystem(){return ni}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Xi._getDrawingBufferColorSpace(e),t.unpackColorSpace=Xi._getUnpackColorSpace()}},fh=-(2**40),ph=8;function mh(e,t){return e<0||e>=ph?fh:t*ph+e}function hh(e){return(e%ph+ph)%ph}function gh(e){return(e-hh(e))/ph}function _h(e){return e===fh?null:ln(hh(e),gh(e))}function vh(e){let t=e.indexOf(`-`);if(t<=0)return null;let n=cn(e.slice(0,t));if(n===void 0)return null;let r=Number(e.slice(t+1));if(!Number.isInteger(r)||r>2147483647||r<-2147483648)return null;let i=mh(n,r);return i===fh?null:i}function yh(e){let t=new Set;for(let n of e){let e=vh(n);e!==null&&t.add(e)}return t}function bh(e){return e+7&-8}function xh(e){return{subFormat:e.getUint16(24,!0),source:e.getUint8(26),idType:e.getUint8(27),rowCount:e.getUint32(28,!0)}}function Sh(e,t){return ln(e.idType,e.id[t])}function Ch(e,t){return mh(e.idType,e.id[t])}function wh(e,t){let n=Zt,r=new Int32Array(e,n,t);n+=bh(t*4);let i=new Uint8Array(e,n,t);n+=bh(t);let a=new Int32Array(e,n,t);n+=bh(t*4);let o=new Uint8Array(e,n,t);return n+=bh(t),{id:r,objectType:i,parentId:a,scale:o,offset:n}}function Th(e,t,n){let r=n,i=new Float64Array(e,r,t);r+=t*8;let a=new Float32Array(e,r,t);r+=bh(t*4);let o=new Float32Array(e,r,t);r+=bh(t*4);let s=new Float32Array(e,r,t);r+=bh(t*4);let c=new Float32Array(e,r,t);r+=bh(t*4);let l=new Float32Array(e,r,t);r+=bh(t*4);let u=new Float32Array(e,r,t);r+=bh(t*4);let d=new Float32Array(e,r,t);r+=bh(t*4);let f=new Float32Array(e,r,t);return r+=bh(t*4),{epochJd:i,a,e:o,i:s,om:c,w:l,ma:u,n:d,radiusKm:f,offset:r}}function Eh(e,t,n){let{subFormat:r,rowCount:i,source:a,idType:o}=xh(new DataView(e));if(o===an.UNKNOWN&&i>0&&console.warn(`elements payload has unknown id-type — ${i} row(s) will lack reconstructed IDs`),r===1)return Oh(e,i,t,n,a,o);if(r===2)return Dh(e,i,t,n,a,o);if(r!==0)throw Error(`Unknown elements sub-format: ${r}`);let{id:s,objectType:c,parentId:l,scale:u,offset:d}=wh(e,i),f=Th(e,i,d),p=f.offset,m=new Float32Array(e,p,i);p+=bh(i*4);let h=new Float32Array(e,p,i);p+=bh(i*4);let g=new Uint8Array(e,p,i);p+=bh(i);let _=new Uint8Array(e,p,i);p+=bh(i);let v=new Float32Array(e,p,i),y={validityStart:t,validityEnd:n,source:a,idType:o};return{kind:`keplerian`,id:s,objectType:c,parentId:l,scale:u,epochJd:f.epochJd,a:f.a,e:f.e,i:f.i,om:f.om,w:f.w,ma:f.ma,n:f.n,radiusKm:f.radiusKm,omDot:m,wDot:h,hasLocalized:g,flags:_,visibleFromDays:v,rowCount:i,...y}}function Dh(e,t,n,r,i,a){let{id:o,objectType:s,parentId:c,scale:l,offset:u}=wh(e,t),d=Th(e,t,u),f=d.offset,p={validityStart:n,validityEnd:r,source:i,idType:a},m=new Float32Array(e,f,t);f+=bh(t*4);let h=new Float32Array(e,f,t);f+=bh(t*4);let g=new Float32Array(e,f,t);f+=bh(t*4);let _=new Int32Array(e,f,t);f+=bh(t*4);let v=new Int32Array(e,f,t);f+=bh(t*4);let y=new Uint8Array(e,f,t);f+=bh(t);let b=new Uint8Array(e,f,t);f+=bh(t);let x=new Float32Array(e,f,t);return{kind:`sgp4`,id:o,objectType:s,parentId:c,scale:l,epochJd:d.epochJd,a:d.a,e:d.e,i:d.i,om:d.om,w:d.w,ma:d.ma,n:d.n,radiusKm:d.radiusKm,bstar:m,meanMotionDot:h,meanMotionDdot:g,elementSetNo:_,revAtEpoch:v,hasLocalized:y,flags:b,visibleFromDays:x,rowCount:t,...p}}function Oh(e,t,n,r,i,a){let{id:o,objectType:s,parentId:c,scale:l,offset:u}=wh(e,t),d=u,f={validityStart:n,validityEnd:r,source:i,idType:a},p=new Float64Array(e,d,t);d+=t*8;let m=new Float32Array(e,d,t);d+=bh(t*4);let h=new Float32Array(e,d,t);d+=bh(t*4);let g=new Float32Array(e,d,t);d+=bh(t*4);let _=new Float32Array(e,d,t);d+=bh(t*4);let v=new Float32Array(e,d,t);d+=bh(t*4);let y=new Float64Array(e,d,t);d+=t*8;let b=new Float32Array(e,d,t);d+=bh(t*4);let x=new Uint8Array(e,d,t);d+=bh(t);let S=new Uint8Array(e,d,t);return d+=bh(t),{kind:`parabolic`,id:o,objectType:s,parentId:c,scale:l,epochJd:p,q:m,e:h,i:g,om:_,w:v,tp:y,radiusKm:b,hasLocalized:x,flags:S,visibleFromDays:new Float32Array(e,d,t),rowCount:t,...f}}var kh=Math.PI,Ah=kh*2,jh=kh/180;180/kh;var Mh=398600.8,Nh=6378.135,Ph=60/Math.sqrt(Nh*Nh*Nh/Mh),Fh=Nh*Ph/60,Ih=1/Ph,Lh=.001082616,Rh=-253881e-11,zh=-165597e-11,Bh=Rh/Lh,Vh=2/3,Hh=1440/(2*kh);function Uh(e,t){let n=[31,e%4==0?29:28,31,30,31,30,31,31,30,31,30,31],r=Math.floor(t),i=1,a=0;for(;r>a+n[i-1]&&i<12;)a+=n[i-1],i+=1;let o=i,s=r-a,c=(t-r)*24,l=Math.floor(c);c=(c-l)*60;let u=Math.floor(c);return{mon:o,day:s,hr:l,minute:u,sec:(c-u)*60}}function Wh(e,t,n,r,i,a,o=0){return 367*e-Math.floor(7*(e+Math.floor((t+9)/12))*.25)+Math.floor(275*t/9)+n+1721013.5+((o/6e4+a/60+i)/60+r)/24}function Gh(e,t,n,r,i,a,o=0){if(e instanceof Date){let t=e;return Wh(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())}return Wh(e,t,n,r,i,a,o)}function Kh(e,t){let{e3:n,ee2:r,peo:i,pgho:a,pho:o,pinco:s,plo:c,se2:l,se3:u,sgh2:d,sgh3:f,sgh4:p,sh2:m,sh3:h,si2:g,si3:_,sl2:v,sl3:y,sl4:b,t:x,xgh2:S,xgh3:C,xgh4:w,xh2:T,xh3:E,xi2:D,xi3:O,xl2:k,xl3:A,xl4:j,zmol:M,zmos:ee}=e,{init:N,opsmode:te}=t,{ep:ne,inclp:re,nodep:P,argpp:ie,mp:ae}=t,F,I,oe,se,ce,le,ue,de,fe,pe,me,he,L,ge,R,_e,z,ve,B,V,ye;ye=ee+119459e-10*x,N===`y`&&(ye=ee),V=ye+2*.01675*Math.sin(ye),z=Math.sin(V),pe=.5*z*z-.25,me=-.5*z*Math.cos(V);let be=l*pe+u*me,xe=g*pe+_*me,Se=v*pe+y*me+b*z,Ce=d*pe+f*me+p*z,we=m*pe+h*me;ye=M+.00015835218*x,N===`y`&&(ye=M),V=ye+2*.0549*Math.sin(ye),z=Math.sin(V),pe=.5*z*z-.25,me=-.5*z*Math.cos(V);let Te=r*pe+n*me,H=D*pe+O*me,Ee=k*pe+A*me+j*z,De=S*pe+C*me+w*z,Oe=T*pe+E*me;return he=be+Te,R=xe+H,_e=Se+Ee,L=Ce+De,ge=we+Oe,N===`n`&&(he-=i,R-=s,_e-=c,L-=a,ge-=o,re+=R,ne+=he,se=Math.sin(re),oe=Math.cos(re),re>=.2?(ge/=se,L-=oe*ge,ie+=L,P+=ge,ae+=_e):(le=Math.sin(P),ce=Math.cos(P),F=se*le,I=se*ce,ue=ge*ce+R*oe*le,de=-ge*le+R*oe*ce,F+=ue,I+=de,P%=Ah,P<0&&te===`a`&&(P+=Ah),ve=ae+ie+oe*P,fe=_e+L-R*P*se,ve+=fe,B=P,P=Math.atan2(F,I),P<0&&te===`a`&&(P+=Ah),Math.abs(B-P)>kh&&(P<B?P+=Ah:P-=Ah),ae+=_e,ie=ve-ae-oe*P)),{ep:ne,inclp:re,nodep:P,argpp:ie,mp:ae}}function qh(e){let{epoch:t,ep:n,argpp:r,tc:i,inclp:a,nodep:o,np:s}=e,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,ee,N,te,ne,re,P,ie,ae,F,I,oe,se,ce,le,ue,de,fe,pe,me,he,L,ge,R,_e,z,ve,B,V,ye,be,xe,Se,Ce,we,Te,H,Ee,De,Oe=.01675,ke=.0549,Ae=s,je=n,Me=Math.sin(o),Ne=Math.cos(o),Pe=Math.sin(r),Fe=Math.cos(r),Ie=Math.sin(a),Le=Math.cos(a),Re=je*je,ze=1-Re,Be=Math.sqrt(ze),Ve=t+18261.5+i/1440,He=(4.523602-.00092422029*Ve)%Ah,Ue=Math.sin(He),We=Math.cos(He),Ge=.91375164-.03568096*We,Ke=Math.sqrt(1-Ge*Ge),qe=.089683511*Ue/Ke,Je=Math.sqrt(1-qe*qe),Ye=5.8351514+.001944368*Ve,Xe=.39785416*Ue/Ke,Ze=Je*We+.91744867*qe*Ue;Xe=Math.atan2(Xe,Ze),Xe+=Ye-He;let Qe=Math.cos(Xe),$e=Math.sin(Xe);D=.1945905,O=-.98088458,j=.91744867,M=.39785416,k=Ne,A=Me,v=29864797e-13;let et=1/Ae,tt=0;for(;tt<2;)tt+=1,c=D*k+O*j*A,u=-O*k+D*j*A,m=-D*A+O*j*k,h=O*M,g=O*A+D*j*k,_=D*M,l=Le*m+Ie*h,d=Le*g+Ie*_,f=-Ie*m+Le*h,p=-Ie*g+Le*_,y=c*Fe+l*Pe,b=u*Fe+d*Pe,x=-c*Pe+l*Fe,S=-u*Pe+d*Fe,C=f*Pe,w=p*Pe,T=f*Fe,E=p*Fe,H=12*y*y-3*x*x,Ee=24*y*b-6*x*S,De=12*b*b-3*S*S,B=3*(c*c+l*l)+H*Re,V=6*(c*u+l*d)+Ee*Re,ye=3*(u*u+d*d)+De*Re,be=-6*c*f+Re*(-24*y*T-6*x*C),xe=-6*(c*p+u*f)+Re*(-24*(b*T+y*E)+-6*(x*w+S*C)),Se=-6*u*p+Re*(-24*b*E-6*S*w),Ce=6*l*f+Re*(24*y*C-6*x*T),we=6*(d*f+l*p)+Re*(24*(b*C+y*w)-6*(S*T+x*E)),Te=6*d*p+Re*(24*b*w-6*S*E),B=B+B+ze*H,V=V+V+ze*Ee,ye=ye+ye+ze*De,ge=v*et,L=-.5*ge/Be,R=ge*Be,he=-15*je*R,_e=y*x+b*S,z=b*x+y*S,ve=b*S-y*x,tt===1&&(ee=he,N=L,te=ge,ne=R,re=_e,P=z,ie=ve,ae=B,F=V,I=ye,oe=be,se=xe,ce=Se,le=Ce,ue=we,de=Te,fe=H,pe=Ee,me=De,D=Qe,O=$e,j=Ge,M=Ke,k=Je*Ne+qe*Me,A=Me*Je-Ne*qe,v=4.7968065e-7);let nt=(4.7199672+(.2299715*Ve-Ye))%Ah,rt=(6.2565837+.017201977*Ve)%Ah,it=2*ee*P,at=2*ee*ie,ot=2*N*se,st=2*N*(ce-oe),ct=-2*te*F,lt=-2*te*(I-ae),ut=-2*te*(-21-9*Re)*Oe,dt=2*ne*pe,ft=2*ne*(me-fe),pt=-18*ne*Oe,mt=-2*N*ue,ht=-2*N*(de-le),gt=2*he*z,_t=2*he*ve,vt=2*L*xe,yt=2*L*(Se-be),bt=-2*ge*V,xt=-2*ge*(ye-B),St=-2*ge*(-21-9*Re)*ke,Ct=2*R*Ee,wt=2*R*(De-H),Tt=-18*R*ke,Et=-2*L*we,Dt=-2*L*(Te-Ce);return{snodm:Me,cnodm:Ne,sinim:Ie,cosim:Le,sinomm:Pe,cosomm:Fe,day:Ve,e3:_t,ee2:gt,em:je,emsq:Re,gam:Ye,peo:0,pgho:0,pho:0,pinco:0,plo:0,rtemsq:Be,se2:it,se3:at,sgh2:dt,sgh3:ft,sgh4:pt,sh2:mt,sh3:ht,si2:ot,si3:st,sl2:ct,sl3:lt,sl4:ut,s1:he,s2:L,s3:ge,s4:R,s5:_e,s6:z,s7:ve,ss1:ee,ss2:N,ss3:te,ss4:ne,ss5:re,ss6:P,ss7:ie,sz1:ae,sz2:F,sz3:I,sz11:oe,sz12:se,sz13:ce,sz21:le,sz22:ue,sz23:de,sz31:fe,sz32:pe,sz33:me,xgh2:Ct,xgh3:wt,xgh4:Tt,xh2:Et,xh3:Dt,xi2:vt,xi3:yt,xl2:bt,xl3:xt,xl4:St,nm:Ae,z1:B,z2:V,z3:ye,z11:be,z12:xe,z13:Se,z21:Ce,z22:we,z23:Te,z31:H,z32:Ee,z33:De,zmol:nt,zmos:rt}}function Jh(e){let{cosim:t,argpo:n,s1:r,s2:i,s3:a,s4:o,s5:s,sinim:c,ss1:l,ss2:u,ss3:d,ss4:f,ss5:p,sz1:m,sz3:h,sz11:g,sz13:_,sz21:v,sz23:y,sz31:b,sz33:x,t:S,tc:C,gsto:w,mo:T,mdot:E,no:D,nodeo:O,nodedot:k,xpidot:A,z1:j,z3:M,z11:ee,z13:N,z21:te,z23:ne,z31:re,z33:P,ecco:ie,eccsq:ae}=e,{emsq:F,em:I,argpm:oe,inclm:se,mm:ce,nm:le,nodem:ue,irez:de,atime:fe,d2201:pe,d2211:me,d3210:he,d3222:L,d4410:ge,d4422:R,d5220:_e,d5232:z,d5421:ve,d5433:B,dedt:V,didt:ye,dmdt:be,dnodt:xe,domdt:Se,del1:Ce,del2:we,del3:Te,xfact:H,xlamo:Ee,xli:De,xni:Oe}=e,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,et,tt,nt,rt,it,at,ot,st=.0043752690880113,ct=.00015835218,lt=119459e-10;de=0,le<.0052359877&&le>.0034906585&&(de=1),le>=.00826&&le<=.00924&&I>=.5&&(de=2);let ut=l*lt*p,dt=u*lt*(g+_),ft=-lt*d*(m+h-14-6*F),pt=f*lt*(b+x-6),mt=-lt*u*(v+y);(se<.052359877||se>kh-.052359877)&&(mt=0),c!==0&&(mt/=c);let ht=pt-t*mt;V=ut+r*ct*s,ye=dt+i*ct*(ee+N),be=ft-ct*a*(j+M-14-6*F);let gt=o*ct*(re+P-6),_t=-ct*i*(te+ne);(se<.052359877||se>kh-.052359877)&&(_t=0),Se=ht+gt,xe=mt,c!==0&&(Se-=t/c*_t,xe+=_t/c);let vt=(w+C*st)%Ah;if(I+=V*S,se+=ye*S,oe+=Se*S,ue+=xe*S,ce+=be*S,de!==0){if(it=(le/Ph)**Vh,de===2){at=t*t;let e=I;I=ie;let n=F;F=ae,ot=I*F,He=-.306-(I-.64)*.44,I<=.65?(Ue=3.616-13.247*I+16.29*F,Ge=-19.302+117.39*I-228.419*F+156.591*ot,Ke=-18.9068+109.7927*I-214.6334*F+146.5816*ot,qe=-41.122+242.694*I-471.094*F+313.953*ot,Je=-146.407+841.88*I-1629.014*F+1083.435*ot,Ye=-532.114+3017.977*I-5740.032*F+3708.276*ot):(Ue=-72.099+331.819*I-508.738*F+266.724*ot,Ge=-346.844+1582.851*I-2415.925*F+1246.113*ot,Ke=-342.585+1554.908*I-2366.899*F+1215.972*ot,qe=-1052.797+4758.686*I-7193.992*F+3651.957*ot,Je=-3581.69+16178.11*I-24462.77*F+12422.52*ot,Ye=I>.715?-5149.66+29936.92*I-54087.36*F+31324.56*ot:1464.74-4664.75*I+3763.64*F),I<.7?(Qe=-919.2277+4988.61*I-9064.77*F+5542.21*ot,Xe=-822.71072+4568.6173*I-8491.4146*F+5337.524*ot,Ze=-853.666+4690.25*I-8624.77*F+5341.4*ot):(Qe=-37995.78+161616.52*I-229838.2*F+109377.94*ot,Xe=-51752.104+218913.95*I-309468.16*F+146349.42*ot,Ze=-40023.88+170470.89*I-242699.48*F+115605.82*ot),$e=c*c,ke=.75*(1+2*t+at),Ae=1.5*$e,Me=1.875*c*(1-2*t-3*at),Ne=-1.875*c*(1+2*t-3*at),Fe=35*$e*ke,Ie=39.375*$e*$e,Le=9.84375*c*($e*(1-2*t-5*at)+.33333333*(-2+4*t+6*at)),Re=c*(4.92187512*$e*(-2-4*t+10*at)+6.56250012*(1+2*t-3*at)),ze=29.53125*c*(2-8*t+at*(-12+8*t+10*at)),Be=29.53125*c*(-2-8*t+at*(12+8*t-10*at)),nt=le*le,rt=it*it,tt=3*nt*rt,et=tt*17891679e-13,pe=et*ke*He,me=et*Ae*Ue,tt*=it,et=tt*3.7393792e-7,he=et*Me*Ge,L=et*Ne*Ke,tt*=it,et=2*tt*7.3636953e-9,ge=et*Fe*qe,R=et*Ie*Je,tt*=it,et=tt*1.1428639e-7,_e=et*Le*Ye,z=et*Re*Ze,et=2*tt*2.1765803e-9,ve=et*ze*Xe,B=et*Be*Qe,Ee=(T+O+O-(vt+vt))%Ah,H=E+be+2*(k+xe-st)-D,I=e,F=n}de===1&&(Ve=1+F*(-2.5+.8125*F),Ge=1+2*F,We=1+F*(-6+6.60937*F),ke=.75*(1+t)*(1+t),je=.9375*c*c*(1+3*t)-.75*(1+t),Pe=1+t,Pe*=1.875*Pe*Pe,Ce=3*le*le*it*it,we=2*Ce*ke*Ve*17891679e-13,Te=3*Ce*Pe*We*2.2123015e-7*it,Ce=Ce*je*Ge*21460748e-13*it,Ee=(T+O+n-vt)%Ah,H=E+A+be+Se+xe-(D+st)),De=Ee,Oe=D,fe=0,le=D+0}return{em:I,argpm:oe,inclm:se,mm:ce,nm:le,nodem:ue,irez:de,atime:fe,d2201:pe,d2211:me,d3210:he,d3222:L,d4410:ge,d4422:R,d5220:_e,d5232:z,d5421:ve,d5433:B,dedt:V,didt:ye,dmdt:be,dndt:0,dnodt:xe,domdt:Se,del1:Ce,del2:we,del3:Te,xfact:H,xlamo:Ee,xli:De,xni:Oe}}function Yh(e){let t=(e-2451545)/36525,n=-62e-7*t*t*t+.093104*t*t+3164400184.812866*t+67310.54841;return n=n*jh/240%Ah,n<0&&(n+=Ah),n}function Xh(e,t,n,r,i,a,o){return e instanceof Date?Yh(Gh(e)):Yh(t===void 0?e:Gh(e,t,n,r,i,a,o))}function Zh(e){let{ecco:t,epoch:n,inclo:r,opsmode:i}=e,{no:a}=e,o=t*t,s=1-o,c=Math.sqrt(s),l=Math.cos(r),u=l*l,d=(Ph/a)**Vh,f=.75*Lh*(3*u-1)/(c*s),p=f/(d*d),m=d*(1-p*p-p*(1/3+134*p*p/81));p=f/(m*m),a/=1+p;let h=(Ph/a)**Vh,g=Math.sin(r),_=h*s,v=1-5*u,y=-v-u-u,b=1/h,x=_*_,S=h*(1-t),C;if(i===`a`){let e=n-7305,t=Math.floor(e+1e-8),r=e-t,i=.017202791694070362,a=i+Ah;C=(1.7321343856509375+i*t+a*r+e*e*5075514194322695e-30)%Ah,C<0&&(C+=Ah)}else C=Xh(n+2433281.5);return{no:a,method:`n`,ainv:b,ao:h,con41:y,con42:v,cosio:l,cosio2:u,eccsq:o,omeosq:s,posq:x,rp:S,rteosq:c,sinio:g,gsto:C}}function Qh(e){let{irez:t,d2201:n,d2211:r,d3210:i,d3222:a,d4410:o,d4422:s,d5220:c,d5232:l,d5421:u,d5433:d,dedt:f,del1:p,del2:m,del3:h,didt:g,dmdt:_,dnodt:v,domdt:y,argpo:b,argpdot:x,t:S,tc:C,gsto:w,xfact:T,xlamo:E,no:D}=e,{atime:O,em:k,argpm:A,inclm:j,xli:M,mm:ee,xni:N,nodem:te,nm:ne}=e,re=.13130908,P=2.8843198,ie=.37448087,ae=5.7686396,F=.95240898,I=1.8014998,oe=1.050833,se=4.4108898,ce=259200,le,ue,de,fe,pe,me,he,L,ge=0,R=0,_e=(w+C*.0043752690880113)%Ah;if(k+=f*S,j+=g*S,A+=y*S,te+=v*S,ee+=_*S,t!==0){(O===0||S*O<=0||Math.abs(S)<Math.abs(O))&&(O=0,N=D,M=E),le=S>0?720:-720;let e=381;for(;e===381;)t===2?(L=b+x*O,de=L+L,ue=M+M,he=n*Math.sin(de+M-ae)+r*Math.sin(M-ae)+i*Math.sin(L+M-F)+a*Math.sin(-L+M-F)+o*Math.sin(de+ue-I)+s*Math.sin(ue-I)+c*Math.sin(L+M-oe)+l*Math.sin(-L+M-oe)+u*Math.sin(L+ue-se)+d*Math.sin(-L+ue-se),pe=N+T,me=n*Math.cos(de+M-ae)+r*Math.cos(M-ae)+i*Math.cos(L+M-F)+a*Math.cos(-L+M-F)+c*Math.cos(L+M-oe)+l*Math.cos(-L+M-oe)+2*(o*Math.cos(de+ue-I)+s*Math.cos(ue-I)+u*Math.cos(L+ue-se)+d*Math.cos(-L+ue-se)),me*=pe):(he=p*Math.sin(M-re)+m*Math.sin(2*(M-P))+h*Math.sin(3*(M-ie)),pe=N+T,me=p*Math.cos(M-re)+2*m*Math.cos(2*(M-P))+3*h*Math.cos(3*(M-ie)),me*=pe),Math.abs(S-O)>=720?e=381:(R=S-O,e=0),e===381&&(M+=pe*le+he*ce,N+=he*le+me*ce,O+=le);ne=N+he*R+me*R*R*.5,fe=M+pe*R+he*R*R*.5,t===1?(ee=fe-te-A+_e,ge=ne-D):(ee=fe-2*te+2*_e,ge=ne-D),ne=D+ge}return{atime:O,em:k,argpm:A,inclm:j,xli:M,mm:ee,xni:N,nodem:te,dndt:ge,nm:ne}}var $h;(function(e){e[e.None=0]=`None`,e[e.MeanEccentricityOutOfRange=1]=`MeanEccentricityOutOfRange`,e[e.MeanMotionBelowZero=2]=`MeanMotionBelowZero`,e[e.PerturbedEccentricityOutOfRange=3]=`PerturbedEccentricityOutOfRange`,e[e.SemiLatusRectumBelowZero=4]=`SemiLatusRectumBelowZero`,e[e.Decayed=6]=`Decayed`})($h||={});function eg(e,t){let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O;e.t=t,e.error=$h.None;let k=e.mo+e.mdot*e.t,A=e.argpo+e.argpdot*e.t,j=e.nodeo+e.nodedot*e.t;u=A,S=k;let M=e.t*e.t;if(w=j+e.nodecf*M,v=1-e.cc1*e.t,y=e.bstar*e.cc4*e.t,b=e.t2cof*M,e.isimp!==1){c=e.omgcof*e.t;let t=1+e.eta*Math.cos(k);s=e.xmcof*(t*t*t-e.delmo),_=c+s,S=k+_,u=A-_,p=M*e.t,m=p*e.t,v=v-e.d2*M-e.d3*p-e.d4*m,y+=e.bstar*e.cc5*(Math.sin(S)-e.sinmao),b=b+e.t3cof*p+m*(e.t4cof+e.t*e.t5cof)}C=e.no;let ee=e.ecco;if(x=e.inclo,e.method===`d`){h=e.t;let t=Qh({irez:e.irez,d2201:e.d2201,d2211:e.d2211,d3210:e.d3210,d3222:e.d3222,d4410:e.d4410,d4422:e.d4422,d5220:e.d5220,d5232:e.d5232,d5421:e.d5421,d5433:e.d5433,dedt:e.dedt,del1:e.del1,del2:e.del2,del3:e.del3,didt:e.didt,dmdt:e.dmdt,dnodt:e.dnodt,domdt:e.domdt,argpo:e.argpo,argpdot:e.argpdot,t:e.t,tc:h,gsto:e.gsto,xfact:e.xfact,xlamo:e.xlamo,no:e.no,atime:e.atime,em:ee,argpm:u,inclm:x,xli:e.xli,mm:S,xni:e.xni,nodem:w,nm:C});({em:ee,argpm:u,inclm:x,mm:S,nodem:w,nm:C}=t)}if(C<=0)return e.error=$h.MeanMotionBelowZero,null;let N=(Ph/C)**Vh*v*v;if(C=Ph/N**1.5,ee-=y,ee>=1||ee<-.001)return e.error=$h.MeanEccentricityOutOfRange,null;ee<1e-6&&(ee=1e-6),S+=e.no*b,E=S+u+w,w%=Ah,u%=Ah,E%=Ah,S=(E-u-w)%Ah;let te={am:N,em:ee,im:x,Om:w,om:u,mm:S,nm:C},ne=Math.sin(x),re=Math.cos(x),P=ee;if(T=x,d=u,O=w,D=S,a=ne,i=re,e.method===`d`){let t=Kh(e,{inclo:e.inclo,init:`n`,ep:P,inclp:T,nodep:O,argpp:d,mp:D,opsmode:e.operationmode});if({ep:P,nodep:O,argpp:d,mp:D}=t,T=t.inclp,T<0&&(T=-T,O+=kh,d-=kh),P<0||P>1)return e.error=$h.PerturbedEccentricityOutOfRange,null}e.method===`d`&&(a=Math.sin(T),i=Math.cos(T),e.aycof=-.5*Bh*a,Math.abs(i+1)>15e-13?e.xlcof=-.25*Bh*a*(3+5*i)/(1+i):e.xlcof=-.25*Bh*a*(3+5*i)/15e-13);let ie=P*Math.cos(d);_=1/(N*(1-P*P));let ae=P*Math.sin(d)+_*e.aycof,F=(D+d+O+_*e.xlcof*ie-O)%Ah;l=F,g=9999.9;let I=1;for(;Math.abs(g)>=1e-12&&I<=10;)r=Math.sin(l),n=Math.cos(l),g=1-n*ie-r*ae,g=(F-ae*n+ie*r-l)/g,Math.abs(g)>=.95&&(g=g>0?.95:-.95),l+=g,I+=1;let oe=ie*n+ae*r,se=ie*r-ae*n,ce=ie*ie+ae*ae,le=N*(1-ce);if(le<0)return e.error=$h.SemiLatusRectumBelowZero,null;let ue=N*(1-oe),de=Math.sqrt(N)*se/ue,fe=Math.sqrt(le)/ue,pe=Math.sqrt(1-ce);_=se/(1+pe);let me=N/ue*(r-ae-ie*_),he=N/ue*(n-ie+ae*_);f=Math.atan2(me,he);let L=(he+he)*me,ge=1-2*me*me;_=1/le;let R=.5*Lh*_,_e=R*_;e.method===`d`&&(o=i*i,e.con41=3*o-1,e.x1mth2=1-o,e.x7thm1=7*o-1);let z=ue*(1-1.5*_e*pe*e.con41)+.5*R*e.x1mth2*ge;if(z<1)return e.error=$h.Decayed,null;f-=.25*_e*e.x7thm1*L;let ve=O+1.5*_e*i*L,B=T+1.5*_e*i*a*ge,V=de-C*R*e.x1mth2*L/Ph,ye=fe+C*R*(e.x1mth2*ge+1.5*e.con41)/Ph,be=Math.sin(f),xe=Math.cos(f),Se=Math.sin(ve),Ce=Math.cos(ve),we=Math.sin(B),Te=Math.cos(B),H=-Se*Te,Ee=Ce*Te,De=H*be+Ce*xe,Oe=Ee*be+Se*xe,ke=we*be,Ae=H*xe-Ce*be,je=Ee*xe-Se*be,Me=we*xe;return{position:{x:z*De*Nh,y:z*Oe*Nh,z:z*ke*Nh},velocity:{x:(V*De+ye*Ae)*Fh,y:(V*Oe+ye*je)*Fh,z:(V*ke+ye*Me)*Fh},meanElements:te}}function tg(e,t){let{opsmode:n,satn:r,epoch:i,xbstar:a,xecco:o,xargpo:s,xinclo:c,xmo:l,xno:u,xnodeo:d}=t,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,ee,N,te,ne,re,P,ie,ae,F,I,oe,se,ce,le,ue,de,fe,pe,me,he,L,ge,R,_e,z,ve,B,V,ye,be,xe,Se,Ce,we,Te,H=e;H.isimp=0,H.method=`n`,H.aycof=0,H.con41=0,H.cc1=0,H.cc4=0,H.cc5=0,H.d2=0,H.d3=0,H.d4=0,H.delmo=0,H.eta=0,H.argpdot=0,H.omgcof=0,H.sinmao=0,H.t=0,H.t2cof=0,H.t3cof=0,H.t4cof=0,H.t5cof=0,H.x1mth2=0,H.x7thm1=0,H.mdot=0,H.nodedot=0,H.xlcof=0,H.xmcof=0,H.nodecf=0,H.irez=0,H.d2201=0,H.d2211=0,H.d3210=0,H.d3222=0,H.d4410=0,H.d4422=0,H.d5220=0,H.d5232=0,H.d5421=0,H.d5433=0,H.dedt=0,H.del1=0,H.del2=0,H.del3=0,H.didt=0,H.dmdt=0,H.dnodt=0,H.domdt=0,H.e3=0,H.ee2=0,H.peo=0,H.pgho=0,H.pho=0,H.pinco=0,H.plo=0,H.se2=0,H.se3=0,H.sgh2=0,H.sgh3=0,H.sgh4=0,H.sh2=0,H.sh3=0,H.si2=0,H.si3=0,H.sl2=0,H.sl3=0,H.sl4=0,H.gsto=0,H.xfact=0,H.xgh2=0,H.xgh3=0,H.xgh4=0,H.xh2=0,H.xh3=0,H.xi2=0,H.xi3=0,H.xl2=0,H.xl3=0,H.xl4=0,H.xlamo=0,H.zmol=0,H.zmos=0,H.atime=0,H.xli=0,H.xni=0,H.bstar=a,H.ecco=o,H.argpo=s,H.inclo=c,H.mo=l,H.no=u,H.nodeo=d,H.operationmode=n;let Ee=78/Nh+1,De=42/Nh,Oe=De*De*De*De;H.init=`y`,H.t=0;let ke=Zh({satn:r,ecco:H.ecco,epoch:i,inclo:H.inclo,no:H.no,method:H.method,opsmode:H.operationmode}),{ao:Ae,con42:je,cosio:Me,cosio2:Ne,eccsq:Pe,omeosq:Fe,posq:Ie,rp:Le,rteosq:Re,sinio:ze}=ke;if(H.no=ke.no,H.con41=ke.con41,H.gsto=ke.gsto,H.a=(H.no*Ih)**(-2/3),H.alta=H.a*(1+H.ecco)-1,H.altp=H.a*(1-H.ecco)-1,H.error=0,Fe>=0||H.no>=0){if(H.isimp=0,Le<1.034492841559484&&(H.isimp=1),P=Ee,M=Oe,k=(Le-1)*Nh,k<156){P=k-78,k<98&&(P=20);let e=(120-P)/Nh;M=e*e*e*e,P=P/Nh+1}A=1/Ie,z=1/(Ae-P),H.eta=Ae*H.ecco*z,C=H.eta*H.eta,S=H.ecco*H.eta,j=Math.abs(1-C),_=M*z**4,v=_/j**3.5,h=v*H.no*(Ae*(1+1.5*C+S*(4+C))+.375*Lh*z/j*H.con41*(8+3*C*(8+C))),H.cc1=H.bstar*h,g=0,H.ecco>1e-4&&(g=-2*_*z*Bh*H.no*ze/H.ecco),H.x1mth2=1-Ne,H.cc4=2*H.no*v*Ae*Fe*(H.eta*(2+.5*C)+H.ecco*(.5+2*C)-Lh*z/(Ae*j)*(-3*H.con41*(1-2*S+C*(1.5-.5*S))+.75*H.x1mth2*(2*C-S*(1+C))*Math.cos(2*H.argpo))),H.cc5=2*v*Ae*Fe*(1+2.75*(C+S)+S*C),y=Ne*Ne,ge=1.5*Lh*A*H.no,R=.5*ge*Lh*A,_e=-.46875*zh*A*A*H.no,H.mdot=H.no+.5*ge*Re*H.con41+.0625*R*Re*(13-78*Ne+137*y),H.argpdot=-.5*ge*je+.0625*R*(7-114*Ne+395*y)+_e*(3-36*Ne+49*y),B=-ge*Me,H.nodedot=B+(.5*R*(4-19*Ne)+2*_e*(3-7*Ne))*Me,ve=H.argpdot+H.nodedot,H.omgcof=H.bstar*g*Math.cos(H.argpo),H.xmcof=0,H.ecco>1e-4&&(H.xmcof=-Vh*_*H.bstar/S),H.nodecf=3.5*Fe*B*H.cc1,H.t2cof=1.5*H.cc1,Math.abs(Me+1)>15e-13?H.xlcof=-.25*Bh*ze*(3+5*Me)/(1+Me):H.xlcof=-.25*Bh*ze*(3+5*Me)/15e-13,H.aycof=-.5*Bh*ze;let e=1+H.eta*Math.cos(H.mo);if(H.delmo=e*e*e,H.sinmao=Math.sin(H.mo),H.x7thm1=7*Ne-1,2*kh/H.no>=225){H.method=`d`,H.isimp=1,he=0,E=H.inclo;let e=qh({epoch:i,ep:H.ecco,argpp:H.argpo,tc:he,inclp:H.inclo,nodep:H.nodeo,np:H.no,e3:H.e3,ee2:H.ee2,peo:H.peo,pgho:H.pgho,pho:H.pho,pinco:H.pinco,plo:H.plo,se2:H.se2,se3:H.se3,sgh2:H.sgh2,sgh3:H.sgh3,sgh4:H.sgh4,sh2:H.sh2,sh3:H.sh3,si2:H.si2,si3:H.si3,sl2:H.sl2,sl3:H.sl3,sl4:H.sl4,xgh2:H.xgh2,xgh3:H.xgh3,xgh4:H.xgh4,xh2:H.xh2,xh3:H.xh3,xi2:H.xi2,xi3:H.xi3,xl2:H.xl2,xl3:H.xl3,xl4:H.xl4,zmol:H.zmol,zmos:H.zmos});H.e3=e.e3,H.ee2=e.ee2,H.peo=e.peo,H.pgho=e.pgho,H.pho=e.pho,H.pinco=e.pinco,H.plo=e.plo,H.se2=e.se2,H.se3=e.se3,H.sgh2=e.sgh2,H.sgh3=e.sgh3,H.sgh4=e.sgh4,H.sh2=e.sh2,H.sh3=e.sh3,H.si2=e.si2,H.si3=e.si3,H.sl2=e.sl2,H.sl3=e.sl3,H.sl4=e.sl4,{sinim:p,cosim:f,em:b,emsq:x,s1:ee,s2:N,s3:te,s4:ne,s5:re,ss1:ie,ss2:ae,ss3:F,ss4:I,ss5:oe,sz1:se,sz3:ce,sz11:le,sz13:ue,sz21:de,sz23:fe,sz31:pe,sz33:me}=e,H.xgh2=e.xgh2,H.xgh3=e.xgh3,H.xgh4=e.xgh4,H.xh2=e.xh2,H.xh3=e.xh3,H.xi2=e.xi2,H.xi3=e.xi3,H.xl2=e.xl2,H.xl3=e.xl3,H.xl4=e.xl4,H.zmol=e.zmol,H.zmos=e.zmos,{nm:O,z1:V,z3:ye,z11:be,z13:xe,z21:Se,z23:Ce,z31:we,z33:Te}=e;let t=Kh(H,{inclo:E,init:H.init,ep:H.ecco,inclp:H.inclo,nodep:H.nodeo,argpp:H.argpo,mp:H.mo,opsmode:H.operationmode});H.ecco=t.ep,H.inclo=t.inclp,H.nodeo=t.nodep,H.argpo=t.argpp,H.mo=t.mp,w=0,T=0,D=0;let n=Jh({cosim:f,emsq:x,argpo:H.argpo,s1:ee,s2:N,s3:te,s4:ne,s5:re,sinim:p,ss1:ie,ss2:ae,ss3:F,ss4:I,ss5:oe,sz1:se,sz3:ce,sz11:le,sz13:ue,sz21:de,sz23:fe,sz31:pe,sz33:me,t:H.t,tc:he,gsto:H.gsto,mo:H.mo,mdot:H.mdot,no:H.no,nodeo:H.nodeo,nodedot:H.nodedot,xpidot:ve,z1:V,z3:ye,z11:be,z13:xe,z21:Se,z23:Ce,z31:we,z33:Te,ecco:H.ecco,eccsq:Pe,em:b,argpm:w,inclm:E,mm:D,nm:O,nodem:T,irez:H.irez,atime:H.atime,d2201:H.d2201,d2211:H.d2211,d3210:H.d3210,d3222:H.d3222,d4410:H.d4410,d4422:H.d4422,d5220:H.d5220,d5232:H.d5232,d5421:H.d5421,d5433:H.d5433,dedt:H.dedt,didt:H.didt,dmdt:H.dmdt,dnodt:H.dnodt,domdt:H.domdt,del1:H.del1,del2:H.del2,del3:H.del3,xfact:H.xfact,xlamo:H.xlamo,xli:H.xli,xni:H.xni});H.irez=n.irez,H.atime=n.atime,H.d2201=n.d2201,H.d2211=n.d2211,H.d3210=n.d3210,H.d3222=n.d3222,H.d4410=n.d4410,H.d4422=n.d4422,H.d5220=n.d5220,H.d5232=n.d5232,H.d5421=n.d5421,H.d5433=n.d5433,H.dedt=n.dedt,H.didt=n.didt,H.dmdt=n.dmdt,H.dnodt=n.dnodt,H.domdt=n.domdt,H.del1=n.del1,H.del2=n.del2,H.del3=n.del3,H.xfact=n.xfact,H.xlamo=n.xlamo,H.xli=n.xli,H.xni=n.xni}H.isimp!==1&&(m=H.cc1*H.cc1,H.d2=4*Ae*z*m,L=H.d2*z*H.cc1/3,H.d3=(17*Ae+P)*L,H.d4=.5*L*Ae*z*(221*Ae+31*P)*H.cc1,H.t3cof=H.d2+2*m,H.t4cof=.25*(3*H.d3+H.cc1*(12*H.d2+10*m)),H.t5cof=.2*(3*H.d4+12*H.cc1*H.d3+6*H.d2*H.d2+15*m*(2*H.d2+m)))}eg(H,0),H.init=`n`}function ng(e,t){let n=e.substring(2,7),r=parseInt(e.substring(18,20),10),i=parseFloat(e.substring(20,32)),a=parseFloat(e.substring(33,43)),o=parseFloat(`${e.substring(44,45)}.${e.substring(45,50)}E${e.substring(50,52)}`),s=parseFloat(`${e.substring(53,54)}.${e.substring(54,59)}E${e.substring(59,61)}`),c=parseFloat(t.substring(8,16))*jh,l=parseFloat(t.substring(17,25))*jh,u=parseFloat(`.${t.substring(26,33).replace(/\s/g,`0`)}`),d=parseFloat(t.substring(34,42))*jh,f=parseFloat(t.substring(43,51))*jh,p=parseFloat(t.substring(52,63))/Hh;a/=Hh*1440,o/=Hh*1440*1440;let m=r<57?r+2e3:r+1900,{mon:h,day:g,hr:_,minute:v,sec:y}=Uh(m,i),b=Gh(m,h,g,_,v,y),x={error:0,satnum:n,epochyr:r,epochdays:i,ndot:a,nddot:o,bstar:s,inclo:c,nodeo:l,ecco:u,argpo:d,mo:f,no:p,jdsatepoch:b};return tg(x,{opsmode:`i`,satn:x.satnum,epoch:x.jdsatepoch-2433281.5,xbstar:x.bstar,xecco:x.ecco,xargpo:x.argpo,xinclo:x.inclo,xmo:x.mo,xno:x.no,xnodeo:x.nodeo}),x}function rg(e,t=`i`){let n=e.NORAD_CAT_ID.toString(),r=new Date(e.EPOCH.endsWith(`Z`)?e.EPOCH:`${e.EPOCH}Z`),i=r.getUTCFullYear(),a=Number(i.toString().slice(-2)),o=(r.valueOf()-new Date(Date.UTC(i,0,1,0,0,0)).valueOf())/(86400*1e3)+1,s=Number(e.MEAN_MOTION_DOT),c=Number(e.MEAN_MOTION_DDOT);s/=Hh*1440,c/=Hh*1440*1440;let l=Number(e.BSTAR),u=Number(e.INCLINATION)*jh,d=Number(e.RA_OF_ASC_NODE)*jh,f=Number(e.ECCENTRICITY),p=Number(e.ARG_OF_PERICENTER)*jh,m=Number(e.MEAN_ANOMALY)*jh,h=Number(e.MEAN_MOTION)/Hh,{mon:g,day:_,hr:v,minute:y,sec:b}=Uh(i,o),x=Gh(i,g,_,v,y,b),S={error:0,satnum:n,epochyr:a,epochdays:o,ndot:s,nddot:c,bstar:l,inclo:u,nodeo:d,ecco:f,argpo:p,mo:m,no:h,jdsatepoch:x};return tg(S,{opsmode:t,satn:S.satnum,epoch:S.jdsatepoch-2433281.5,xbstar:S.bstar,xecco:S.ecco,xargpo:S.argpo,xinclo:S.inclo,xmo:S.mo,xno:S.no,xnodeo:S.nodeo}),S}3*Float64Array.BYTES_PER_ELEMENT;var ig=149597870.7,ag=23.4392911,og=86400**2/ig**3,sg=1/ig;function Q(e){return e/ig*10}function cg(e){return e/10*ig}var lg=Math.cos(Math.PI/180*ag),ug=Math.sin(Math.PI/180*ag);function dg(e,t,n,r){let i=r??{x:0,y:0,z:0};return i.x=e,i.y=-t*ug+n*lg,i.z=-(t*lg+n*ug),i}var fg=Math.PI/180,pg=Math.cos(ag*fg),mg=Math.sin(ag*fg),hg=2440587.5;function gg(e){return new Date((e-hg)*864e5).toISOString()}function _g(e,t){let n=rg({OBJECT_NAME:t??String(e.noradCatId),OBJECT_ID:String(e.noradCatId),EPOCH:gg(e.epochJd),MEAN_MOTION:e.meanMotion,ECCENTRICITY:e.eccentricity,INCLINATION:e.inclination,RA_OF_ASC_NODE:e.raOfAscNode,ARG_OF_PERICENTER:e.argOfPericenter,MEAN_ANOMALY:e.meanAnomaly,EPHEMERIS_TYPE:0,CLASSIFICATION_TYPE:`U`,NORAD_CAT_ID:e.noradCatId,ELEMENT_SET_NO:e.elementSetNo,REV_AT_EPOCH:e.revAtEpoch,BSTAR:e.bstar,MEAN_MOTION_DOT:e.meanMotionDot,MEAN_MOTION_DDOT:e.meanMotionDdot});return n.error===$h.None?n:(console.warn(`buildSatrec: SGP4 init failed for NORAD ${e.noradCatId} (error=${n.error})`),null)}function vg(e,t){let n=eg(e,(t-e.jdsatepoch)*1440);if(!n||e.error!==$h.None)return null;let{x:r,y:i,z:a}=n.position;return[r,i,a]}function yg(e,t,n){let r=10/ig,i=e*r,a=t*r,o=n*r,s=a*pg+o*mg,c=-a*mg+o*pg;return a=s,o=c,[i,o,-a]}function bg(e,t){let n=vg(e,t);return n?yg(n[0],n[1],n[2]):null}function xg(e,t,n=1e-10,r=50){let i=e;for(let a=0;a<r;a++){let r=(i-t*Math.sin(i)-e)/(1-t*Math.cos(i));if(i-=Math.max(-1,Math.min(1,r)),Math.abs(r)<n)break}return i}var Sg=700;function Cg(e,t,n=1e-10,r=50){if(e===0)return 0;let i=e<0?-1:1,a=Math.abs(e),o=0,s=1;for(;t*Math.sinh(s)-s<a;)if(s*=2,s>Sg)return NaN;let c=.5*(o+s);for(let e=0;e<r;e++){let e=t*Math.sinh(c)-c-a;e>0?s=c:o=c;let r=c-e/(t*Math.cosh(c)-1);r>o&&r<s||(r=.5*(o+s));let i=Math.abs(r-c);if(c=r,i<n)break}return i*c}function wg(e,t,n){let r=.01720209895*(n-t)/(Math.sqrt(2)*e**1.5),i=Math.cbrt(3*r+Math.sqrt(1+9*r*r)),a=i-1/i,o=2*Math.atan(a),s=e*(1+a*a);return!isFinite(o)||!isFinite(s)||s<=0?null:{nu:o,r:s}}var Tg=null,Eg=null;function Dg(){if(!Eg){Tg=[];let e=new MessageChannel;e.port1.onmessage=()=>Tg.shift()?.(),Eg=e.port2}return new Promise(e=>{Tg.push(e),Eg.postMessage(null)})}var Og=2451545,kg=86400,Ag=2440587.5,jg=864e5;function Mg(e){return e/jg+Ag}function Ng(e){return Mg(e.getTime())}function Pg(e){return new Date((e-Ag)*jg)}function Fg(e){return(e-Og)*kg}function Ig(e){return Og+e/kg}var Lg=Math.PI/180;Math.cos(ag*Lg),Math.sin(ag*Lg),10/ig;function Rg(e,t,n,r,i,a,o,s,c,l,u,d){e.a[t]=n,e.e[t]=r,e.i[t]=i,e.om[t]=a,e.w[t]=o,e.ma[t]=s,e.n[t]=c,e.epoch[t]=l,e.equatorial[t]=+!!u,e.flags[t]=d}function zg(e,t,n,r){let i=n.data;if(r?.has(i.id))return e.kind[t]=0,!1;if(i.omm)e.kind[t]=3,e.satnum[t]=i.omm.noradCatId,e.bstar[t]=i.omm.bstar,e.ndot[t]=i.omm.meanMotionDot,e.nddot[t]=i.omm.meanMotionDdot;else if(i.satrec)e.kind[t]=3,e.satrec[t]=i.satrec;else if(i.q!=null&&i.tp!=null&&isFinite(i.q)&&isFinite(i.tp))e.kind[t]=2,e.q[t]=i.q,e.tp[t]=i.tp;else if(i.a!==0&&isFinite(i.a))e.kind[t]=1;else return e.kind[t]=0,!1;return Rg(e,t,i.a,i.e,i.i,i.om,i.w,i.ma,i.n,i.epoch,i.equatorial,i.flags??0),!0}async function Bg(e,t,n=!1){let r=e.length,i=Ug(r);i.applyFlagFilter=n;let a=1/0,o=-1/0,s=performance.now();for(let n=0;n<r;n++){if((n&4095)==4095&&performance.now()-s>6&&(await Dg(),s=performance.now()),!zg(i,n,e[n],t))continue;let r=e[n].data;r.validityStart<a&&(a=r.validityStart),r.validityEnd>o&&(o=r.validityEnd)}return i.validityStart=a===1/0?-1/0:a,i.validityEnd=o===-1/0?1/0:o,i}var Vg=[{name:`kind`,make:e=>new Uint8Array(e)},{name:`equatorial`,make:e=>new Uint8Array(e)},{name:`a`,make:e=>new Float64Array(e)},{name:`e`,make:e=>new Float64Array(e)},{name:`i`,make:e=>new Float64Array(e)},{name:`om`,make:e=>new Float64Array(e)},{name:`w`,make:e=>new Float64Array(e)},{name:`ma`,make:e=>new Float64Array(e)},{name:`n`,make:e=>new Float64Array(e)},{name:`epoch`,make:e=>new Float64Array(e)},{name:`q`,make:e=>new Float64Array(e)},{name:`tp`,make:e=>new Float64Array(e)},{name:`flags`,make:e=>new Uint8Array(e)},{name:`visibleFromDays`,make:e=>new Float32Array(e).fill(NaN)},{name:`satnum`,make:e=>new Int32Array(e)},{name:`bstar`,make:e=>new Float64Array(e)},{name:`ndot`,make:e=>new Float64Array(e)},{name:`nddot`,make:e=>new Float64Array(e)},{name:`satrec`,make:e=>Array(e).fill(null),transferable:!1}];function Hg(e){let t=[];for(let n of Vg)n.transferable!==!1&&t.push(e[n.name].buffer);return t}function Ug(e){let t={count:e,applyFlagFilter:!1,validityStart:-1/0,validityEnd:1/0,pickBase:0};for(let n of Vg)t[n.name]=n.make(e);return t}function Wg(e,t){return e.get(t)?.name||null}function Gg(e,t){return e.get(t)?.isMinor??!1}function Kg(e,t){let n=e.get(t);return{name:n?.name||null,isMinor:n?.isMinor??!1}}function qg(e,t,n,r){let i=e.scale[t]===rn.PLANET,a=e.omDot[t],o=e.wDot[t],s=Sh(e,t);if(s===null)return null;let{name:c,isMinor:l}=Kg(n,s);return{id:s,name:c,isMinor:l,hasLocalized:e.hasLocalized[t]===1,flags:e.flags[t],objectType:e.objectType[t],parentId:`${r}-${e.parentId[t]}`,radiusKm:e.radiusKm[t],a:i?e.a[t]/ig:e.a[t],e:e.e[t],i:e.i[t],om:e.om[t],w:e.w[t],ma:e.ma[t],n:i?e.n[t]*360:e.n[t],epoch:e.epochJd[t],omDot:a===0?void 0:a,wDot:o===0?void 0:o,equatorial:i,validityStart:e.validityStart,validityEnd:e.validityEnd,orbitalSource:e.source,visibleFromDays:e.visibleFromDays[t]}}function Jg(e,t,n,r){let i=Sh(e,t);if(i===null)return null;let{name:a,isMinor:o}=Kg(n,i);return{id:i,name:a,isMinor:o,hasLocalized:e.hasLocalized[t]===1,flags:e.flags[t],objectType:e.objectType[t],parentId:`${r}-${e.parentId[t]}`,radiusKm:e.radiusKm[t],a:0,e:e.e[t],i:e.i[t],om:e.om[t],w:e.w[t],ma:0,n:0,epoch:e.epochJd[t],q:e.q[t],tp:e.tp[t],validityStart:e.validityStart,validityEnd:e.validityEnd,orbitalSource:e.source,visibleFromDays:e.visibleFromDays[t]}}var Yg=new WeakMap,Xg=new WeakMap;function Zg(e,t){return{noradCatId:e.id[t],epochJd:e.epochJd[t],meanMotion:e.n[t],eccentricity:e.e[t],inclination:e.i[t],raOfAscNode:e.om[t],argOfPericenter:e.w[t],meanAnomaly:e.ma[t],bstar:e.bstar[t],meanMotionDot:e.meanMotionDot[t],meanMotionDdot:e.meanMotionDdot[t],elementSetNo:e.elementSetNo[t],revAtEpoch:e.revAtEpoch[t]}}var Qg={get omm(){let e=Xg.get(this);return e&&Zg(e[0],e[1])},get satrec(){let e=this,t=Yg.get(e);return t===void 0&&(t=_g(e.omm,e.name??void 0),Yg.set(e,t),t||(e.unplaceable=!0)),t??void 0}};function $g(e,t,n,r){let i=Sh(e,t);if(i===null)return null;let{name:a,isMinor:o}=Kg(n,i),s=Object.assign(Object.create(Qg),{id:i,name:a,isMinor:o,hasLocalized:e.hasLocalized[t]===1,flags:e.flags[t],objectType:e.objectType[t],parentId:`${r}-${e.parentId[t]}`,radiusKm:e.radiusKm[t],a:e.a[t]/ig,e:e.e[t],i:e.i[t],om:e.om[t],w:e.w[t],ma:e.ma[t],n:e.n[t]*360,epoch:e.epochJd[t],equatorial:!0,validityStart:e.validityStart,validityEnd:e.validityEnd,orbitalSource:e.source,visibleFromDays:e.visibleFromDays[t]});return Xg.set(s,[e,t]),s}function e_(e,t,n,r){return e.kind===`parabolic`?Jg(e,t,n,r):e.kind===`sgp4`?$g(e,t,n,r):qg(e,t,n,r)}function t_(e,t,n,r,i,a){if(a&&i!==void 0&&a.has(i))return n.kind[r]=0,!1;if(e.kind===`parabolic`){let i=e.q[t],a=e.tp[t];return isFinite(i)&&isFinite(a)?(n.kind[r]=2,n.q[r]=i,n.tp[r]=a,Rg(n,r,0,e.e[t],e.i[t],e.om[t],e.w[t],0,0,e.epochJd[t],!1,e.flags[t]),n.visibleFromDays[r]=e.visibleFromDays[t],!0):(n.kind[r]=0,!1)}if(e.kind===`sgp4`)return n.kind[r]=3,n.satrec[r]=null,n.satnum[r]=e.id[t],n.bstar[r]=e.bstar[t],n.ndot[r]=e.meanMotionDot[t],n.nddot[r]=e.meanMotionDdot[t],Rg(n,r,e.a[t]/ig,e.e[t],e.i[t],e.om[t],e.w[t],e.ma[t],e.n[t]*360,e.epochJd[t],!0,e.flags[t]),n.visibleFromDays[r]=e.visibleFromDays[t],!0;let o=e.scale[t]===rn.PLANET,s=o?e.a[t]/ig:e.a[t];return s!==0&&isFinite(s)?(n.kind[r]=1,Rg(n,r,s,e.e[t],e.i[t],e.om[t],e.w[t],e.ma[t],o?e.n[t]*360:e.n[t],e.epochJd[t],o,e.flags[t]),n.visibleFromDays[r]=e.visibleFromDays[t],!0):(n.kind[r]=0,!1)}var n_={"naif-10":`#ffdd44`,"naif-199":`#b5b5b5`,"naif-299":`#e8cda0`,"naif-399":`#4da6ff`,"naif-301":`#888888`,"naif-499":`#c1440e`,"naif-401":`#aa9988`,"naif-402":`#aa9988`,"naif-599":`#d4a66a`,"naif-501":`#8a762e`,"naif-502":`#7c7f6c`,"naif-503":`#7e6c5e`,"naif-504":`#6c6453`,"naif-699":`#e8d8a0`,"naif-601":`#aba890`,"naif-602":`#71a29f`,"naif-603":`#6c6645`,"naif-604":`#494a2a`,"naif-605":`#5c5a3c`,"naif-606":`#835422`,"naif-608":`#776b60`,"naif-799":`#87ceeb`,"naif-701":`#b0b0b0`,"naif-702":`#a8a8a8`,"naif-703":`#62534c`,"naif-704":`#626a62`,"naif-705":`#625252`,"naif-899":`#3f54ba`,"naif-801":`#7c757c`,"naif-999":`#b48977`,"naif-2000001":`#9b9087`},r_=`#cccccc`,i_=`#fcb493`,a_=`#c7ccda`,o_=`#ffe89e`,s_=`#ccb49a`,c_=`#d8ffe8`,l_=`#e8a85c`,u_=`#bed4ec`,d_=`#d5cfe7`,f_=`naif-10`,p_=`naif-399`,m_=new Set(`naif-0.naif-9.spkid-20000002.spkid-20000003.spkid-20000007.spkid-20000010.spkid-20000015.spkid-20000031.spkid-20000052.spkid-20000065.spkid-20000088.spkid-20000107.spkid-20000130.spkid-20000511.spkid-20000588.spkid-20000704.spkid-20001862.spkid-1000592.spkid-1000616.spkid-1000630.spkid-1000639.spkid-1000648.spkid-1000651.spkid-1000669.spkid-1000690.spkid-1000738.spkid-1000742.spkid-1000749.spkid-1000755.spkid-1000778.spkid-1000845.spkid-1000872.spkid-1000882.spkid-1000899.spkid-1000945.spkid-1000967.spkid-1001121`.split(`.`));function h_(e){if(n_[e.id])return n_[e.id];let{objectType:t,parentId:n}=e;if(t===W.BARYCENTER){if(e.id===`naif-0`)return n_[`naif-10`];if(e.id===`naif-9`)return n_[`naif-999`];let t=`naif-${e.id.replace(`naif-`,``)}99`;if(n_[t])return n_[t]}if(t===W.STAR)return o_;if(t===W.PLANET||t===W.DWARF_PLANET)return i_;if(t===W.MOON)return a_;if(_n(t))return s_;if(t===W.COMET)return c_;if(t===W.DEBRIS)return l_;if(t===W.SPACECRAFT){if(n===`naif-399`)return u_;if(n===`naif-0`||n===`naif-10`)return d_}return r_}var g_=`#6b6b6b`;function __(e){return e.color??g_}function v_(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t>>>0}function y_(e,t){let n=Array.from({length:t},()=>[]);for(let r of e)n[v_(r.data.id)%t].push(r);return n}function b_(e,t,n){return{buckets:y_(t,t.length>=n*600?n:1),baseWorker:v_(e)%n}}async function x_(e,t,n){let r=t.length>=n*600?n:1,i=Array.from({length:r},()=>[]),a=performance.now();for(let e=0;e<t.length;e++){(e&16383)==16383&&performance.now()-a>6&&(await Dg(),a=performance.now());let n=t[e];i[v_(n.data.id)%r].push(n)}return{buckets:i,baseWorker:v_(e)%n}}function S_(e){let t=e.indexOf(`#`);return t<0?e:e.substring(0,t)}var C_=4096,w_=.75;function T_(e){let t=(e^Math.floor(e/4294967296))>>>0;return t=Math.imul(t^t>>>16,73244475),t=Math.imul(t^t>>>16,73244475),(t^t>>>16)>>>0}var E_=class{table=new Uint32Array(C_);mask=C_-1;count=0;constructor(e){this.keyOfRef=e}get size(){return this.count}slot(e){let t=T_(e)&this.mask;for(;;){let n=this.table[t];if(n===0||this.keyOfRef(n-1)===e)return t;t=t+1&this.mask}}get(e){let t=this.table[this.slot(e)];return t===0?void 0:t-1}has(e){return this.table[this.slot(e)]!==0}set(e,t,n=()=>!0){let r=this.slot(e),i=this.table[r];return i===0?(this.count++,this.count>this.table.length*w_&&(this.grow(),r=this.slot(e)),this.table[r]=t+1,!0):(n(i-1)&&(this.table[r]=t+1),!1)}grow(){let e=this.table;this.table=new Uint32Array(e.length*2),this.mask=this.table.length-1;for(let t of e){if(t===0)continue;let e=T_(this.keyOfRef(t-1))&this.mask;for(;this.table[e]!==0;)e=e+1&this.mask;this.table[e]=t}}*values(){for(let e of this.table)e!==0&&(yield e-1)}*keys(){for(let e of this.values())yield this.keyOfRef(e)}},D_=2**20,O_=4096,k_=6;function A_(e){let t=e>>>0;return t=Math.imul(t^t>>>16,73244475),t=Math.imul(t^t>>>16,73244475),(t^t>>>16)>>>0}var j_=class{chunks=[];rowOf=new E_(e=>this.keyOfRef(e));cache=new Map;placeholders=new Map;parentIdType=`naif`;constructor(e){this.labels=e}async addChunk(e,t,n){if(this.parentIdType=t,e.rowCount>=D_)throw Error(`MinorBucket: chunk too large (${e.rowCount} rows)`);let r=this.chunks.length;this.chunks.push(e);let i=0,a=this.placeholders.size>0,o=performance.now();for(let t=0;t<e.rowCount;t++){t%O_===O_-1&&performance.now()-o>k_&&(await Dg(),o=performance.now());let s=Ch(e,t);if(!(s===fh||n&&!n.has(s))&&(this.rowOf.set(s,r*D_+t,e=>Math.floor(e/D_)<=r)&&i++,a)){let n=Sh(e,t),r=n===null?void 0:this.placeholders.get(n);if(r){let n=e_(e,t,this.labels,this.parentIdType);n&&Object.assign(r.data,n)}}}return i}addPlaceholder(e){this.placeholders.set(e.data.id,e),this.cache.set(e.data.id,e)}keyOfRef(e){let t=Math.floor(e/D_);return Ch(this.chunks[t],e-t*D_)}get size(){let e=0;for(let t of this.placeholders.keys())this.hasRow(t)||e++;return this.rowOf.size+e}hasRow(e){let t=vh(e);return t!==null&&this.rowOf.has(t)}has(e){return this.hasRow(e)||this.placeholders.has(e)}hasKey(e){if(this.rowOf.has(e))return!0;if(this.placeholders.size===0)return!1;let t=_h(e);return t!==null&&this.placeholders.has(t)}*ids(){for(let e of this.rowOf.keys()){let t=_h(e);t!==null&&(yield t)}for(let e of this.placeholders.keys())this.hasRow(e)||(yield e)}*keys(){yield*this.rowOf.keys();for(let e of this.placeholders.keys()){let t=vh(e);t!==null&&!this.rowOf.has(t)&&(yield t)}}get(e){let t=this.cache.get(e);if(t)return t;let n=vh(e),r=n===null?void 0:this.rowOf.get(n);if(r===void 0)return;let i=Math.floor(r/D_),a=e_(this.chunks[i],r-i*D_,this.labels,this.parentIdType);if(!a)return;let o={data:a,position:[0,0,0],positionUnknown:!0};return this.cache.set(e,o),o}getKey(e){let t=_h(e);return t===null?void 0:this.get(t)}*values(){for(let e of this.ids()){let t=this.get(e);t&&(yield t)}}cloudColor(){let e=this.chunks.find(e=>e.rowCount>0);if(!e)return`#888888`;let t=e_(e,0,this.labels,this.parentIdType);return t?h_(t):`#888888`}async buildWorkerGroups(e,t,n,r){let i=this.rowOf.size,a=i>=t*600?t:1,o=new Float64Array(i),s=new Uint8Array(i),c=Array(a).fill(0),l=0,u=performance.now();for(let e of this.rowOf.values()){if(l===i)break;l%16384==0&&performance.now()-u>6&&(await Dg(),u=performance.now());let t=Math.floor(e/D_),n=a===1?0:A_(this.chunks[t].id[e-t*D_])%a;o[l]=e,s[l]=n,c[n]++,l++}let d=[];for(let e=0;e<a;e++){let t=Ug(c[e]);t.applyFlagFilter=!1,d.push({cols:t,colors:r?new Float32Array(c[e]*3):null,keys:new Float64Array(c[e]).fill(fh)})}let f=Array(a).fill(1/0),p=Array(a).fill(-1/0),m=Array(a).fill(0),h=r?new X:null;u=performance.now();for(let e=0;e<l;e++){(e&16383)==16383&&performance.now()-u>6&&(await Dg(),u=performance.now());let t=o[e],r=Math.floor(t/D_),i=t-r*D_,a=this.chunks[r],c=s[e],l=d[c],g=m[c]++,_=Ch(a,i);if(l.keys[g]=_,t_(a,i,l.cols,g,_,n)&&(a.validityStart<f[c]&&(f[c]=a.validityStart),a.validityEnd>p[c]&&(p[c]=a.validityEnd)),l.colors&&h){let e=e_(a,i,this.labels,this.parentIdType);h.set(e?h_(e):`#ffffff`),l.colors[g*3]=h.r,l.colors[g*3+1]=h.g,l.colors[g*3+2]=h.b}}for(let e=0;e<a;e++)d[e].cols.validityStart=f[e]===1/0?-1/0:f[e],d[e].cols.validityEnd=p[e]===-1/0?1/0:p[e];return{groups:d,baseWorker:v_(e)%t}}};function M_(e){return e===`naif-0`||e===`naif-10`}function N_(e){let t=/^naif-([1-9])$/.exec(e);return t?`naif-${t[1]}99`:null}function P_(e){return e===`naif-0`?f_:N_(e)}function F_(e){if(!M_(e))return N_(e)??e}var I_=class{bodiesById=new Map;majorBodies=[];asteroidBodiesByZone=new Map;spacecraftByParent=new Map;focusFeature=null;dirtyAsteroidZones=new Set;dirtySpacecraftGroups=new Set;minorStreaming=!1;#e=qe(0);get minorBodyVersion(){return Ut(this.#e)}set minorBodyVersion(e){Je(this.#e,e,!0)}#t=qe(0);get orientationVersion(){return Ut(this.#t)}set orientationVersion(e){Je(this.#t,e,!0)}childrenByParent=new Map;moonMaxAByParent=new Map;addListeners=new Set;onBodiesAdded(e){return this.addListeners.add(e),()=>this.addListeners.delete(e)}notifyBodiesAdded(){for(let e of this.addListeners)e()}getBody(e,t){let n=this.bodiesById.get(e);if(n)return n;if(this.focusFeature?.data.id===e)return this.focusFeature;if(t!==void 0)return this.spacecraftByParent.get(t)?.get(e)??this.asteroidBodiesByZone.get(t)?.get(e);for(let t of this.spacecraftByParent.values()){let n=t.get(e);if(n)return n}for(let t of this.asteroidBodiesByZone.values()){let n=t.get(e);if(n)return n}}addBodies(e){let t=!1;for(let n of e){this.bodiesById.has(n.data.id)||(t=!0),this.bodiesById.set(n.data.id,n);let e=this.childrenByParent.get(n.data.parentId)??new Set;if(e.add(n.data.id),this.childrenByParent.set(n.data.parentId,e),n.data.objectType===W.MOON){let e=this.moonMaxAByParent.get(n.data.parentId)??0;n.data.a>e&&this.moonMaxAByParent.set(n.data.parentId,n.data.a)}}t&&this.notifyBodiesAdded()}asteroidBucket(e,t){let n=this.asteroidBodiesByZone.get(e);return n||this.asteroidBodiesByZone.set(e,n=new j_(t)),n}spacecraftBucket(e){let t=this.spacecraftByParent.get(e);return t||this.spacecraftByParent.set(e,t=new Map),t}flushMinor(e){this.asteroidBodiesByZone=new Map(this.asteroidBodiesByZone),this.spacecraftByParent=new Map(this.spacecraftByParent),this.minorBodyVersion++,e&&this.notifyBodiesAdded()}getChildren(e){return this.childrenByParent.get(e)}findAsteroidZone(e){for(let[t,n]of this.asteroidBodiesByZone)if(n.has(e))return t}maxMoonA(e){return this.moonMaxAByParent.get(e)}getSystemExtent(e){return this.moonMaxAByParent.get(e)??.01}isSystemBody(e){return M_(e.data.parentId)?!1:this.bodiesById.get(e.data.parentId)?.data.objectType!==W.BARYCENTER}isInSystem(e,t){return t?e===t?!0:this.childrenByParent.get(t)?.has(e)??!1:!1}getObjectCounts(){let e=0,t=0,n=0;for(let r of this.bodiesById.values()){let i=r.data.objectType;i===W.PLANET||i===W.DWARF_PLANET?e++:i===W.MOON?t++:i===W.SPACECRAFT&&n++}let r=this.spacecraftByParent.get(`naif-399`)?.size??0;r+=this.asteroidBodiesByZone.get(`earth`)?.size??0;for(let[e,t]of this.spacecraftByParent)e!==`naif-399`&&(n+=t.size);let i=0;for(let[e,t]of this.asteroidBodiesByZone)e!==`earth`&&(i+=t.size);for(let e of this.bodiesById.values())(_n(e.data.objectType)||e.data.objectType===W.COMET)&&i++;return{planets:e,moons:t,probes:n,earthSatellites:r,smallBodies:i}}};function L_(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function R_(e,t){let n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(n*n+r*r+i*i)}function z_(e,t,n,r){let i=e[0]-n[0],a=e[1]-n[1],o=e[2]-n[2],s=t[0]-n[0],c=t[1]-n[1],l=t[2]-n[2],u=Math.sqrt(i*i+a*a+o*o),d=Math.sqrt(s*s+c*c+l*l);if(u<1e-9||d<1e-9)return L_(e,t,r);let f=i/u,p=a/u,m=o/u,h=s/d,g=c/d,_=l/d,v=Math.max(-1,Math.min(1,f*h+p*g+m*_)),y=Math.acos(v),b=u+(d-u)*r;if(y<1e-4||Math.PI-y<1e-4)return L_(e,t,r);let x=Math.sin(y),S=Math.sin((1-r)*y)/x,C=Math.sin(r*y)/x,w=S*f+C*h,T=S*p+C*g,E=S*m+C*_;return[n[0]+w*b,n[1]+T*b,n[2]+E*b]}var B_={metadata:.12,ephemeris:.55,majors:.8,labels:.92,done:1},V_=[`metadata`,`ephemeris`,`majors`,`labels`,`done`],H_=.9,U_=new class{#e=0;#t=B_.metadata;#n=0;#r=0;#i=!1;#a=qe(0);get value(){return Ut(this.#a)}set value(e){Je(this.#a,e,!0)}get active(){return this.#i}#o(){let e=this.#t-this.#e,t=this.#r>0?Math.min(this.#n/this.#r,1):0,n=this.#e+e*t*H_;n>this.value&&(this.value=n)}reset(){this.#e=0,this.#t=B_.metadata,this.#n=0,this.#r=0,this.#i=!0,this.value=0}reach(e){if(!this.#i)return;let t=B_[e];if(t<=this.#e)return;this.#e=t,this.value<t&&(this.value=t);let n=V_[V_.indexOf(e)+1];this.#t=n?B_[n]:t,this.#n=0,this.#r=0,e===`done`&&(this.value=1,this.#i=!1)}announce(e){!this.#i||e<=0||(this.#r+=e,this.#o())}addBytes(e){this.#i&&(this.#n+=e,this.#o())}},W_=3e4;function G_(e){if(!U_.active||!e.body)return e;let t=Number(e.headers.get(`content-length`));if(!Number.isFinite(t)||t<=0)return e;U_.announce(t);let n=new TransformStream({transform(e,t){U_.addBytes(e.byteLength),t.enqueue(e)}});return new Response(e.body.pipeThrough(n),{status:e.status,statusText:e.statusText,headers:e.headers})}async function K_(e,t={},n=W_){let r=new AbortController,i=setTimeout(()=>r.abort(),n),a=()=>r.abort();t.signal?.addEventListener(`abort`,a,{once:!0});try{return G_(await fetch(e,{...t,signal:r.signal}))}catch(i){throw r.signal.aborted&&!t.signal?.aborted?Error(`Request timed out after ${n} ms: ${e}`,{cause:i}):i}finally{clearTimeout(i),t.signal?.removeEventListener(`abort`,a)}}var q_=new Map,J_=new Map,Y_=null;function X_(){if(Y_)return Y_;let e=(async()=>{let e=await K_(`${Kt()}/v1/systems/global.json`);if(!e.ok)return;let t=await e.json();if(t.gm)for(let[e,n]of Object.entries(t.gm))J_.set(parseInt(e,10),n);if(t.nut_prec_angles)for(let[e,n]of Object.entries(t.nut_prec_angles))q_.set(parseInt(e,10),n)})();return e.catch(()=>{Y_===e&&(Y_=null)}),Y_=e,e}function Z_(e){return e>=100?Math.trunc(e/100):e}function Q_(e){return q_.get(e)}function $_(e){return J_.get(e)}var ev=132712440018,tv=86400;function nv(e){if(!M_(e.parentId))return;let t=Number(e.id.replace(/^naif-/,``));if(!Number.isFinite(t))return;let n=$_(t>=1&&t<=9?t*100+99:t),r=e.a*ig;if(!(!n||!(n>0)||!(r>0)))return r*(1-(Number.isFinite(e.e)?Math.min(Math.max(e.e,0),.99):0))*Math.cbrt(n/(3*ev))/ig}var rv=`class-`,iv=`flag-`,av=`cat-`;`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`;var ov=`${av}asteroids`,sv=`${av}comets`,cv=`${av}satellites`,lv=`${av}debris`;`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`;var uv={neo:1,pha:2},dv=new Set([`ETc`,`JFc`,`JFC`,`CTc`,`HTC`,`PAR`,`HYP`,`COM`]);function fv(e){return dv.has(e)?`comet`:`asteroid`}function pv(e,t){return e===t?!0:e===null||t===null||e.kind!==t.kind?!1:e.kind===`class`&&t.kind===`class`?e.className===t.className:e.kind===`category`&&t.kind===`category`?e.category===t.category:e.kind===`flag`&&t.kind===`flag`?e.flag===t.flag:!1}var mv=null;function hv(){if(mv)return mv;let e=K_(`${Kt()}/v1/groups/__index__.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch group index: ${e.status}`);return e.json()});return mv=e,e.catch(()=>{mv===e&&(mv=null)}),mv}var gv=[`planets`,`dwarfPlanets`,`moons`,`asteroids`,`comets`,`spacecraft`,`satellites`,`debris`,`orbits`,`labels`,`nomenclature`,`stars`],_v=new Set(gv),vv={[W.PLANET]:`planets`,[W.DWARF_PLANET]:`dwarfPlanets`,[W.MOON]:`moons`,[W.ASTEROID]:`asteroids`,[W.ASTEROID_INNER]:`asteroids`,[W.ASTEROID_MAIN_BELT]:`asteroids`,[W.ASTEROID_TROJAN]:`asteroids`,[W.ASTEROID_CENTAUR]:`asteroids`,[W.ASTEROID_TNO]:`asteroids`,[W.COMET]:`comets`,[W.DEBRIS]:`debris`},yv=`small_bodies/`,bv=new Set([`COM`,`PAR`,`HYP`,`HYA`,`JFC`,`JFc`,`HTC`,`CTc`]);function xv(e){return e===`moons`||e.startsWith(`moons/`)||e===`small_body_moons`?`moons`:e.startsWith(`probes/`)?`spacecraft`:e.startsWith(yv)?bv.has(e.slice(13))?`comets`:`asteroids`:null}function Sv(e,t){return e===W.SPACECRAFT?t===`naif-399`?`satellites`:`spacecraft`:vv[e]??null}var Cv=class{skipped;hiddenIds;onChange=null;constructor(e={}){let t=new Set;for(let n of gv)e[n]===!1&&t.add(n);this.skipped=t,this.hiddenIds=new Set(t)}isVisible(e){return!this.hiddenIds.has(e)}setVisible(e,t){t!==this.isVisible(e)&&(t?this.hiddenIds.delete(e):this.hiddenIds.add(e),this.onChange?.())}static has(e){return _v.has(e)}skipsZone(e){if(e===`earth`)return this.skipped.has(`satellites`)&&this.skipped.has(`debris`);let t=xv(e);return t!==null&&this.skipped.has(t)}hidesZone(e){let t=xv(e);return t!==null&&!this.isVisible(t)}hidesBody(e,t){let n=Sv(e,t);return n!==null&&!this.isVisible(n)}hidesSpacecraftGroup(e){return e===`naif-399`?!this.isVisible(`satellites`)&&!this.isVisible(`debris`):!this.isVisible(`spacecraft`)}};function wv(e,t,n){return t!==`naif-399`||e.isVisible(`satellites`)===e.isVisible(`debris`)?n:n.filter(t=>!e.hidesBody(t.data.objectType,t.data.parentId))}var Tv=`small_bodies/`;function Ev(e,t){let n=e.findAsteroidZone(t);if(n&&n.startsWith(`small_bodies/`))return n.slice(13);let r=e.bodiesById.get(t);if(r?.data.objectType!==W.DWARF_PLANET)return null;let i=r.data.a,a=r.data.e;if(!M_(r.data.parentId)){let t=e.bodiesById.get(r.data.parentId);t?.data.a&&(i=t.data.a,a=t.data.e)}return fn(i,a)}function Dv(e,t,n){if(n.kind===`class`||n.kind===`category`){let r=Ev(e,t);return r===null?!1:n.kind===`class`?r===n.className:fv(r)===n.category}let r=e.getBody(t);return r===void 0?!1:((r.data.flags??0)&n.mask)===n.mask}var $=function(e){return e[e.CLOSE=1]=`CLOSE`,e[e.FULL=2]=`FULL`,e[e.CAPPED=3]=`CAPPED`,e[e.FAR=4]=`FAR`,e[e.HIDE=5]=`HIDE`,e}({}),Ov=1503,kv={[$.CLOSE]:.3,[$.FULL]:20,[$.FAR]:100,[$.HIDE]:1/0},Av={[$.CLOSE]:.01,[$.FULL]:20,[$.FAR]:100,[$.HIDE]:1/0},jv=1/3;function Mv(e,t,n,r){return e<=t[$.CLOSE]?$.CLOSE:e<=t[$.FULL]*(r?n:1)?$.FULL:e<=t[$.FAR]?$.FAR:$.HIDE}var Nv=new Cv,Pv=3,Fv=4e6/ig;function Iv(e){return _n(e)||e===W.COMET||e===W.DWARF_PLANET}var Lv=class{#e=qe($e(f_));get focusedBodyId(){return Ut(this.#e)}set focusedBodyId(e){Je(this.#e,e,!0)}#t=qe(null);get focusedSystemId(){return Ut(this.#t)}set focusedSystemId(e){Je(this.#t,e,!0)}activeSystemId=null;isZoomedIn=!1;focusedBodyIdPlain=f_;focusedSystemIdPlain=null;travelSystemActive=!1;cameraDistThreeJS=0;lastRecomputeDist=-1;currentJd=0;hideThresholdAU=0;scaledPlanetary=kv;scaledSystem=Av;fullMoonIds=new Set;moonVisibilityCache=new Map;constructor(e,t=()=>null,n=()=>null,r=()=>null,i=()=>Nv){this.bodies=e,this.getProbeStore=t,this.getEarthSatGroupFilter=n,this.getSmallBodyFilter=r,this.getLayers=i}getRequiredFlags(){let e=this.getSmallBodyFilter();return e?.kind===`flag`?e.mask:0}updateViewport(e){let t=(e/Ov)**1.5,n=e=>({...e,[$.FULL]:e[$.FULL]*t,[$.FAR]:e[$.FAR]*t});this.scaledPlanetary=n(kv),this.scaledSystem=n(Av)}updateCamera(e,t){this.cameraDistThreeJS=e,this.currentJd=t,this.moonVisibilityCache.clear(),this.travelSystemActive||this.refreshProbeFocusedSystem(),this.hideThresholdAU=this.computeHideThreshold(),this.isZoomedIn=e/10<this.hideThresholdAU,this.activeSystemId=this.isZoomedIn?this.focusedSystemIdPlain:null,Math.abs(e-this.lastRecomputeDist)>this.lastRecomputeDist*.005+.001&&(this.lastRecomputeDist=e,this.recomputeFullMoons())}refreshProbeFocusedSystem(){let e=this.getProbeStore();if(!e)return;let t=this.bodies.bodiesById.get(this.focusedBodyIdPlain);if(!t||t.data.orbitalSource!==U.SPICE_PROBE)return;let n=e.containingSystemAt(t.data.id,this.currentJd),r=n===null?e.stampedFitCenterAt(t.data.id,this.currentJd):`naif-${n}`;r!==this.focusedSystemIdPlain&&(this.focusedSystemId=r,this.focusedSystemIdPlain=r,this.lastRecomputeDist=-1)}resolveSystemId(e){let t=e.data.objectType===W.BARYCENTER&&M_(e.data.parentId)&&!M_(e.data.id),n=e.data.objectType===W.STAR||!t&&M_(e.data.parentId);if(t)return e.data.id;if(n)return Iv(e.data.objectType)?e.data.id:null;let r=this.bodies.bodiesById.get(e.data.parentId);return r&&!M_(r.data.parentId)?r.data.parentId:e.data.parentId}setTravelSystem(e){this.travelSystemActive=!0,e!==this.focusedSystemIdPlain&&(this.focusedSystemId=e,this.focusedSystemIdPlain=e,this.lastRecomputeDist=-1)}clearTravelSystem(){this.travelSystemActive=!1}setFocused(e){if(this.travelSystemActive=!1,e.data.id===this.focusedBodyIdPlain)return;this.focusedBodyId=e.data.id,this.focusedBodyIdPlain=e.data.id;let t=this.resolveSystemId(e);this.focusedSystemId=t,this.focusedSystemIdPlain=t,this.hideThresholdAU=this.computeHideThreshold(),this.isZoomedIn=this.cameraDistThreeJS/10<this.hideThresholdAU,this.activeSystemId=this.isZoomedIn?t:null,this.lastRecomputeDist=-1,this.recomputeFullMoons()}getMoonVisibility(e){if(this.getLayers().hidesBody(e.data.objectType,e.data.parentId))return $.HIDE;let t=this.moonVisibilityCache.get(e.data.id);if(t!==void 0)return t;let n,r=this.bodies.getBody(e.data.parentId),i=r!==void 0&&_n(r.data.objectType);if(!this.isInFocusedSystem(e.data.parentId))n=$.HIDE;else if(i&&!this.matchesSmallBodyClass(e.data.parentId))n=$.HIDE;else{let t=this.cameraDistThreeJS/10/e.data.a,r=e.data.id===this.focusedBodyIdPlain;n=Mv(t,this.scaledPlanetary,5,r),!i&&n===$.FULL&&!this.fullMoonIds.has(e.data.id)&&!r&&(n=$.CAPPED)}return this.moonVisibilityCache.set(e.data.id,n),n}getPlanetVisibility(e,t){if(this.getLayers().hidesBody(e.data.objectType,e.data.parentId))return $.HIDE;if(e.data.orbitalSource===U.SPICE_PROBE)return this.getProbeVisibility(e);let n=this.getEarthSatGroupFilter();if(n&&e.data.parentId===`naif-399`&&!n.has(e.data.id))return $.HIDE;let r=e.data.objectType;if((_n(r)||r===W.COMET||r===W.DWARF_PLANET)&&!this.matchesSmallBodyClass(e.data.id))return $.HIDE;if(this.bodies.isSystemBody(e)){if(!this.isInFocusedSystem(e.data.parentId))return $.HIDE;let n=e.data.a;if(!n||n<=0)return $.FULL;let r=e.data.id===this.focusedBodyIdPlain;return Mv(t/10/n,this.scaledPlanetary,5,r)}let i=e.data.a;if(!M_(e.data.parentId)){let t=this.bodies.bodiesById.get(e.data.parentId);t?.data.a&&(i=t.data.a)}if(!i||i<0)return i===0&&e.data.e<.9&&console.warn(`No semi-major axis available for body ${e.data.id} (${e.data.name}), falling back to FULL visibility`),$.FULL;let a=e.data.id===this.focusedBodyIdPlain,o=Mv(t/10/i,this.scaledSystem,50,a);return o===$.CLOSE?$.FULL:o}getProbeVisibility(e){let t=this.getProbeStore();if((t?t.containingSystemAt(e.data.id,this.currentJd):null)===Pv&&this.getEarthSatGroupFilter())return $.HIDE;let n=e.data.id===this.focusedBodyIdPlain;if(!(t&&!t.hasHeliocentricFit(e.data.id,this.currentJd))){let t=this.bodies.bodiesById.get(f_),r=t?R_(e.position,t.position)/10:0;if(r===0)return $.FULL;let i=Mv(this.cameraDistThreeJS/10/r,this.scaledSystem,50,n);return i===$.CLOSE?$.FULL:i}if(!this.isProbeInFocusedSystem(e))return $.HIDE;let r=this.bodies.bodiesById.get(e.data.parentId);if(!r)return $.FULL;let i=R_(e.position,r.position)/10;return i===0||this.cameraDistThreeJS/10/i<=this.scaledPlanetary[$.FULL]*(n?5:1)?$.FULL:$.HIDE}isProbeInFocusedSystem(e){let t=e.data.parentId;if(!M_(t)&&this.isInFocusedSystem(t))return!0;let n=this.getProbeStore();if(!n)return!1;let r=n.containingSystemAt(e.data.id,this.currentJd);return r!==null&&this.isInFocusedSystem(`naif-${r}`)}hasFullRendering(e){if(!this.activeSystemId||this.isInActiveSystem(M_(e.data.parentId)?e.data.id:e.data.parentId))return!0;if(e.data.orbitalSource!==U.SPICE_PROBE)return!1;let t=this.getProbeStore();if(!t)return!1;let n=t.containingSystemAt(e.data.id,this.currentJd);return n!==null&&this.isInActiveSystem(`naif-${n}`)}isMoonGroupVisible(e){if(!this.getLayers().isVisible(`moons`)||!this.isInFocusedSystem(e))return!1;let t=this.bodies.maxMoonA(e);return t?this.cameraDistThreeJS/10/t<=this.scaledPlanetary[$.FAR]:!1}isSpacecraftGroupVisible(e){if(this.getLayers().hidesSpacecraftGroup(e))return!1;let t=this.activeSystemId;return M_(e)||this.bodies.bodiesById.get(e)?.data.objectType===W.STAR?!t:t?e===t?!0:this.bodies.getChildren(t)?.has(e)??!1:!1}isAsteroidGroupVisible(e){if(this.getLayers().hidesZone(e)||this.activeSystemId)return!1;let t=this.getSmallBodyFilter();if(t&&e.startsWith(`small_bodies/`)){let n=e.slice(Tv.length);if(t.kind===`class`&&n!==t.className||t.kind===`category`&&fv(n)!==t.category)return!1}let n=dn[e];return n?this.cameraDistThreeJS/10/n.maxA<=this.scaledSystem[$.FAR]/3:!0}isInActiveSystem(e){return this.bodies.isInSystem(e,this.activeSystemId)}debugBody(e){let t=this.bodies.getBody(e);if(!t)return{id:e,found:!1};let n=t.data.objectType,r=n===W.MOON,i=this.getProbeStore(),a=r?this.getMoonVisibility(t):this.getPlanetVisibility(t,this.cameraDistThreeJS);return{id:e,name:t.data.name,objectType:W[n],orbitalSource:t.data.orbitalSource,parentId:t.data.parentId,a:t.data.a,jd:this.currentJd,isMoon:r,isSystemBody:this.bodies.isSystemBody(t),isInFocusedSystem_parent:this.isInFocusedSystem(t.data.parentId),focusedBodyId:this.focusedBodyIdPlain,focusedSystemId:this.focusedSystemIdPlain,activeSystemId:this.activeSystemId,isZoomedIn:this.isZoomedIn,hideThresholdAU:this.hideThresholdAU,containingSystemAt:i?i.containingSystemAt(t.data.id,this.currentJd):null,camDistAU:this.cameraDistThreeJS/10,visibility:$[a],hasFullRendering:this.hasFullRendering(t)}}isBodyInSystem(e,t){return e.data.id===t||this.bodies.isInSystem(e.data.parentId,t)}isInFocusedSystem(e){return this.bodies.isInSystem(e,this.focusedSystemIdPlain)}matchesSmallBodyClass(e){let t=this.getSmallBodyFilter();return t===null?!0:Dv(this.bodies,e,t)}recomputeFullMoons(){this.fullMoonIds.clear();let e=this.focusedSystemIdPlain;if(!e)return;let t=this.cameraDistThreeJS/10,n=[];for(let r of this.bodies.getChildren(e)??[]){let e=this.bodies.bodiesById.get(r);e&&e.data.objectType===W.MOON&&t/e.data.a<=this.scaledPlanetary[$.FULL]&&n.push(e)}n.sort((e,t)=>e.data.a-t.data.a).slice(0,40).forEach(e=>this.fullMoonIds.add(e.data.id))}computeHideThreshold(){let e=this.focusedSystemIdPlain;return e?this.systemReachAU(e):1/0}systemReachAU(e){let t=this.bodies.maxMoonA(e);if(t)return 2*t;let n=this.bodies.getBody(e);if(!n)return 0;if(Iv(n.data.objectType))return Fv;let r=nv(n.data);return r?r*jv:0}},Rv=``;function zv(e){let t=new Map;if(!e)return t;for(let n of e.split(`
|
|
4051
|
-
`)){let e=n.indexOf(Rv);if(e===-1)continue;let r=n.slice(0,e),i=n.slice(e+1),a=i.indexOf(Rv),o=a===-1?i:i.slice(0,a),s=a===-1?``:i.slice(a+1);t.set(r,{name:o,isMinor:s.includes(`m`)})}return t}var Bv=new Map;async function Vv(e=c()){let t=Bv.get(e);return t||(t=(async()=>{let t=Qt(e),n=await K_(t,{priority:`high`});if(!n.ok)throw Error(`Failed to fetch ${t}: ${n.status}`);let r=new DecompressionStream(`gzip`);return zv(await new Response(n.body.pipeThrough(r)).text())})(),Bv.set(e,t),t.catch(()=>{Bv.get(e)===t&&Bv.delete(e)})),t}var Hv=Math.PI/180,Uv=Math.cos(ag*Hv),Wv=Math.sin(ag*Hv);function Gv(e,t,n,r,i,a=!1){let o=Math.cos(n*Hv),s=Math.sin(n*Hv),c=Math.cos(r*Hv),l=Math.sin(r*Hv),u=Math.cos(i*Hv),d=Math.sin(i*Hv),f=(u*o-d*s*c)*e+(-u*s-d*o*c)*t,p=(d*o+u*s*c)*e+(-d*s+u*o*c)*t,m=s*l*e+o*l*t;if(a){let e=p*Uv+m*Wv,t=-p*Wv+m*Uv;p=e,m=t}return[f*10,m*10,-p*10]}function Kv(e,t){let{omDot:n,wDot:r,om:i,w:a,epoch:o}=e;if(!n&&!r)return e;let s=t-o;return{...e,om:n?i+n*s:i,w:r?a+r*s:a}}function qv(e,t=new Date){return Jv(e,Ng(t))}function Jv(e,t){let{a:n,e:r,i,ma:a,n:o,epoch:s}=e;if(!isFinite(n)||!isFinite(r)||!isFinite(a)||!isFinite(o))return console.warn(`NaN in orbital elements: a=${n} e=${r} ma=${a} n=${o}`),null;let c=(a+o*(t-s))*Hv,{om:l,w:u}=Kv(e,t),d,f;if(r<1||n>0){let e=Math.min(r,.9999999),t=xg(c,e),i=Math.sqrt(1-e*e)*Math.sin(t)/(1-e*Math.cos(t)),a=(Math.cos(t)-e)/(1-e*Math.cos(t));d=Math.atan2(i,a),f=n*(1-e*Math.cos(t))}else{let e=Cg(c,r);if(!isFinite(e))return console.warn(`solveKeplerHyperbolic overflow: M=${c} e=${r}`),null;let t=r*Math.cosh(e)-1;if(Math.abs(t)<1e-15)return console.warn(`Hyperbolic denom near zero: H=${e} e=${r} denom=${t}`),null;let i=Math.sqrt(r*r-1)*Math.sinh(e)/t,a=(r-Math.cosh(e))/t;d=Math.atan2(i,a),f=n*(1-r*Math.cosh(e))}let p=f*Math.cos(d),m=f*Math.sin(d);return!isFinite(p)||!isFinite(m)?(console.warn(`Non-finite orbital position: r=${f} nu=${d} xOrb=${p} yOrb=${m} a=${n} e=${r}`),null):Gv(p,m,u,i,l,e.equatorial)}function Yv(e,t=new Date){return Xv(e,Ng(t))}function Xv(e,t){let{q:n,tp:r,i,om:a,w:o}=e;if(n==null||r==null||!isFinite(n)||!isFinite(r))return null;let s=wg(n,r,t);if(!s)return null;let c=s.r*Math.cos(s.nu),l=s.r*Math.sin(s.nu);return!isFinite(c)||!isFinite(l)?null:Gv(c,l,o,i,a,e.equatorial)}var Zv=class{map=new Map;constructor(e){this.capacity=e}getOrCompute(e,t){let n=this.map.get(e);if(n)return this.map.delete(e),this.map.set(e,n),n;let r=t();if(this.map.set(e,r),this.map.size>this.capacity){let e=this.map.keys().next().value;e!==void 0&&this.map.delete(e)}return r.catch(()=>{this.map.get(e)===r&&this.map.delete(e)}),r}};function Qv(e,t,n){let r=new DataView(e),i=r.getUint32(24,!0),a=(r.getUint8(28)&1)!=0,o=a?8:4,s=[],c=Zt;for(let t=0;t<i;t++){let n=r.getInt32(c,!0),i=r.getInt32(c+4,!0),l=r.getInt32(c+8,!0),u=r.getFloat32(c+12,!0),d=r.getUint16(c+16,!0),f=r.getUint8(c+18),p=r.getUint8(c+19)===1,m=r.getUint8(c+20),h=r.getUint16(c+22,!0),g=r.getFloat32(c+24,!0);c+=32;let _=ln(f,l)??``;_||console.warn(`chebyshev body[${t}] (naifId=${n}) has unknown id-type ${f}; routing keyed lookups will skip it`);let v=new Float64Array(h),y=new Float64Array(h),b=3*d,x=a?new Float64Array(b*h):new Float32Array(b*h),S=b*o;for(let t=0;t<h;t++){if(v[t]=r.getFloat64(c,!0),y[t]=r.getFloat64(c+8,!0),c+=16,a){let n=new Float64Array(e,c,b);x.set(n,t*b)}else{let n=new Float32Array(e,c,b);x.set(n,t*b)}c+=S}s.push({id:_,naifId:n,parentId:i,hasLocalized:p,objectType:m,radiusKm:u,visibleFromDays:g,coeffsPerAxis:d,startJds:v,endJds:y,coeffs:x})}return{startJd:t,endJd:n,bodies:s}}function $v(e,t,n,r){let i=n*(r?8:4),a=new(r?Float64Array:Float32Array)(n);if(r&&t%8==0)return a.set(new Float64Array(e,t,n)),a;if(!r&&t%4==0)return a.set(new Float32Array(e,t,n)),a;let o=new DataView(e,t,i);if(r)for(let e=0;e<n;e++)a[e]=o.getFloat64(e*8,!0);else for(let e=0;e<n;e++)a[e]=o.getFloat32(e*4,!0);return a}function ey(e,t,n,r){let i=$v(e,t,n===1?7:10,r);return n===1?{method:n,aKm:i[0],e:i[1],iRad:i[2],om0:i[3],w0:i[4],m0:i[5],tAnchorOffsetS:i[6]}:{method:n,aKm:i[0],e:i[1],iRad:i[2],om0:i[3],w0:i[4],m0:i[5],omDot:i[6],wDot:i[7],nMeanRadS:i[8],tAnchorOffsetS:i[9]}}var ty=1e-7,ny=.001,ry=1,iy=16,ay=32;function oy(e,t,n){let r=new DataView(e,t,ay),i=r.getInt32(0,!0),a=r.getUint8(4),o=r.getUint32(8,!0),s=r.getUint32(12,!0),c=r.getInt32(16,!0)*ty,l=r.getInt32(20,!0)*ty,u=r.getInt32(24,!0)*ny,d=r.getUint32(28,!0),f=new Float64Array(d),p=new Float32Array(d),m=new Float32Array(d),h=new Float32Array(d);if(d>0){let r=new DataView(e,t+ay,d*iy);for(let e=0;e<d;e++){let t=e*iy;f[e]=n+r.getUint32(t,!0),p[e]=r.getInt32(t+4,!0)*ty,m[e]=r.getInt32(t+8,!0)*ty,h[e]=r.getInt32(t+12,!0)*ny}}return{bodyNaifId:i,isStatic:(a&ry)!==0,startEt:n+o,endEt:n+s,latRefDeg:c,lngRefDeg:l,altRefM:u,sampleEt:f,sampleLatDeg:p,sampleLngDeg:m,sampleAltM:h}}function sy(e,t,n,r){let i=n/(36*(r?8:4));return{method:3,coeffsPerAxis:12,nSeg:i,coeffs:$v(e,t,i*3*12,r)}}function cy(e,t,n,r){let i=new DataView(e),a=i.getUint32(24,!0),o=i.getFloat32(28,!0),s=o*kg,c=Fg(t),l=[],u=Zt;for(let t=0;t<a;t++){let n=i.getInt32(u,!0),a=i.getUint8(u+4),o=i.getUint8(u+5),d=i.getUint8(u+6)===1,f=(i.getUint8(u+7)&1)!=0,p=i.getUint16(u+8,!0),m=i.getUint16(u+10,!0),h=i.getInt32(u+12,!0),g=i.getUint8(u+16),_=i.getUint8(u+17);u+=20;let v=ln(a,n)??``;v||console.warn(`probes payload: probe[${t}] (value=${n}) has unknown id-type ${a}; skipping`);let y=null;if(h!==-1&&g!==255){let e=ln(g,h);e?y={id:e,idType:g,idValue:h}:console.warn(`probes payload: probe[${t}] has unknown fit-center id-type ${g}; falling back to zone default`)}let b=Array(p),x=Array(p),S=Array(p);for(let n=0;n<p;n++){let a=i.getUint8(u),o=i.getUint32(u+4,!0),l=u+8,d=c+(m+n)*s;if(b[n]=d,x[n]=d+s,a===0)S[n]={method:0};else if(a===1||a===2)S[n]=ey(e,l,a,r);else if(a===3)S[n]=sy(e,l,o,r);else throw Error(`Unknown probe sub-chunk method ${a} at probe ${t} sub ${n}`);u=l+o}let C;if(f){let n=i.getUint8(u);if(n!==4)throw Error(`probe ${t}: PROBE_FLAG_HAS_LANDED_RECORD set but trailing record method = ${n}, expected 4`);let r=i.getUint32(u+4,!0),a=u+8;C=oy(e,a,c),u=a+r}let w=Array(_);for(let e=0;e<_;e++)w[e]={startEt:i.getFloat64(u,!0),endEt:i.getFloat64(u+8,!0),systemNaifId:i.getUint8(u+16)},u+=17;l.push({id:v,probeId:n,hasLocalized:d,objectType:o,fitCenter:y,subStartEt:b,subEndEt:x,subChunks:S,landed:C,systemIntervals:w})}return{startJd:t,endJd:n,subchunkDays:o,probes:l}}function ly(e,t={}){let n=new DataView(e),r=n.getUint32(0,!0);if(r!==1346456915)throw Error(`Invalid position file: bad magic 0x${r.toString(16)}`);let i=n.getUint16(4,!0);if(i!==13)throw Error(`Unsupported position file version: ${i}`);let a=n.getUint8(6),o=n.getFloat64(8,!0),s=n.getFloat64(16,!0);if(a===0)return{kind:`elements`,columns:Eh(e,o,s)};if(a===1)return{kind:`chebyshev`,chunk:Qv(e,o,s)};if(a===2)return{kind:`probes`,chunk:cy(e,o,s,t.probesFloat64??!1)};throw Error(`Unknown position-file format: ${a}`)}function uy(e,t,n){let r=e.length;if(r===0||n<e[0]||n>=t[r-1])return-1;let i=0,a=r-1;for(;i<a;){let t=i+a+1>>>1;e[t]<=n?i=t:a=t-1}return n<t[i]?i:-1}function dy(e,t){let n=uy(e.startJds,e.endJds,t);if(n<0)return null;let r=e.startJds[n],i=e.endJds[n],a=2*(t-r)/(i-r)-1,o=e.coeffsPerAxis,s=e.coeffs,c=n*3*o,l=[0,0,0],u=2*a;for(let e=0;e<3;e++){let t=c+e*o;if(o===1){l[e]=s[t];continue}let n=0,r=0;for(let e=o-1;e>=1;e--){let i=s[t+e]+u*n-r;r=n,n=i}l[e]=s[t]+a*n-r}return l}function fy(e,t){let n=dy(e,t);return n===null?null:[Q(n[0]),Q(n[2]),-Q(n[1])]}function py(e,t){let n=uy(e.startJds,e.endJds,t);if(n<0)return null;let r=e.startJds[n],i=e.endJds[n],a=2*(t-r)/(i-r)-1,o=2/(i-r),s=e.coeffsPerAxis,c=e.coeffs,l=n*3*s,u=[0,0,0],d=[0,0,0],f=2*a;for(let e=0;e<3;e++){let t=l+e*s;if(s===1){u[e]=c[t],d[e]=0;continue}let n=0,r=0;for(let e=s-1;e>=1;e--){let i=c[t+e]+f*n-r;r=n,n=i}u[e]=c[t]+a*n-r;let i=0,p=0;for(let e=s-2;e>=0;e--){let n=c[t+e+1]*(e+1)+f*i-p;p=i,i=n}d[e]=i*o}return{position:u,velocity:d}}function my(e,t){let n=e.subStartEt,r=e.subEndEt,i=n.length;if(i===0||t<n[0]||t>=r[i-1])return-1;let a=0,o=i-1;for(;a<o;){let e=a+o+1>>>1;n[e]<=t?a=e:o=e-1}return t<r[a]?a:-1}function hy(e,t,n,r,i){let a=Math.cos(i),o=Math.sin(i),s=Math.cos(r),c=Math.sin(r),l=Math.cos(n),u=Math.sin(n);return[(l*a-u*o*s)*e+(-l*o-u*a*s)*t,(u*a+l*o*s)*e+(-u*o+l*a*s)*t,o*c*e+a*c*t]}function gy(e,t,n,r,i,a){if(t>=1)return null;let o=xg(a,t),s=Math.sin(o),c=Math.cos(o),l=Math.sqrt(1-t*t)*s/(1-t*c),u=(c-t)/(1-t*c),d=e*(1-t*c),f=d*u,p=d*l;return!isFinite(f)||!isFinite(p)?null:hy(f,p,r,n,i)}function _y(e,t,n,r){let i=n-(t+e.tAnchorOffsetS),a=Math.sqrt(r/(e.aKm*e.aKm*e.aKm)),o=e.m0+a*i;return gy(e.aKm,e.e,e.iRad,e.om0,e.w0,o)}function vy(e,t,n){let r=n-(t+e.tAnchorOffsetS),i=e.om0+e.omDot*r,a=e.w0+e.wDot*r,o=e.m0+e.nMeanRadS*r;return gy(e.aKm,e.e,e.iRad,i,a,o)}function yy(e,t,n,r){let{coeffs:i,coeffsPerAxis:a,nSeg:o}=e,s=(n-t)/o,c=Math.floor((r-t)/s);c<0?c=0:c>=o&&(c=o-1);let l=2*(r-(t+c*s))/s-1,u=2*l,d=c*3*a,f=[0,0,0];for(let e=0;e<3;e++){let t=d+e*a;if(a===1){f[e]=i[t];continue}let n=0,r=0;for(let e=a-1;e>=1;e--){let a=i[t+e]+u*n-r;r=n,n=a}f[e]=i[t]+l*n-r}return!isFinite(f[0])||!isFinite(f[1])||!isFinite(f[2])?null:f}function by(e,t,n,r,i){switch(e.method){case 0:return null;case 1:return _y(e,t,r,i);case 2:return vy(e,t,r);case 3:return yy(e,t,n,r)}}function xy(e,t,n){let r=Fg(t),i=my(e,r);return i<0?null:by(e.subChunks[i],e.subStartEt[i],e.subEndEt[i],r,n)}function Sy(e,t,n){let r=xy(e,t,n);return r===null?null:[Q(r[0]),Q(r[2]),-Q(r[1])]}function Cy(e){if(!e.landed)return!1;let t=e.subEndEt.length;return t===0||e.subEndEt[t-1]<=e.landed.endEt}function wy(e,t){if(!e.landed)return!1;let n=Fg(t);return n>=e.landed.startEt&&(n<e.landed.endEt||Cy(e))}function Ty(e,t,n=!1){let r=Fg(t);if(r<e.startEt||!n&&r>=e.endEt)return null;let i=e.sampleEt.length;if(i===0||r<e.sampleEt[0])return{latDeg:e.latRefDeg,lngDeg:e.lngRefDeg,altM:e.altRefM};let a=0,o=i-1;for(;a<o;){let t=a+o+1>>>1;e.sampleEt[t]<=r?a=t:o=t-1}return{latDeg:e.sampleLatDeg[a],lngDeg:e.sampleLngDeg[a],altM:e.sampleAltM[a]}}var Ey=30/kg;function Dy(e,t,n){let r=xy(e,t,n);if(r===null)return null;let i=Ey,a=xy(e,t+i,n),o=xy(e,t-i,n),s,c,l;if(a!==null&&o!==null)s=a,c=o,l=1/(2*i);else if(a!==null)s=a,c=r,l=1/i;else if(o!==null)s=r,c=o,l=1/i;else return null;return{position:r,velocity:[(s[0]-c[0])*l,(s[1]-c[1])*l,(s[2]-c[2])*l]}}Math.PI/180;var Oy=180/Math.PI;ig/86400;var ky=1e-9,Ay=1e-9;function jy(e,t,n){return e<t?t:e>n?n:e}function My(e,t,n,r){let[i,a,o]=e,[s,c,l]=t,u=Math.hypot(i,a,o),d=s*s+c*c+l*l;if(u===0||n<=0||!isFinite(u)||!isFinite(d))return null;let f=a*l-o*c,p=o*s-i*l,m=i*c-a*s,h=Math.hypot(f,p,m);if(h===0)return null;let g=Math.acos(jy(m/h,-1,1)),_=Math.sin(g),v=(c*m-l*p)/n-i/u,y=(l*f-s*m)/n-a/u,b=(s*p-c*f)/n-o/u,x=Math.hypot(v,y,b),S=2/u-d/n;if(Math.abs(S)<1e-12)return null;let C=1/S,w=-p,T=f,E=Math.hypot(w,T),D;_<Ay||E===0?D=0:(D=Math.acos(jy(w/E,-1,1)),T<0&&(D=2*Math.PI-D));let O;if(x<ky)O=0;else if(_<Ay||E===0)O=Math.atan2(y,v),m<0&&(O=-O),O<0&&(O+=2*Math.PI);else{let e=(w*v+T*y)/(E*x);O=Math.acos(jy(e,-1,1)),b<0&&(O=2*Math.PI-O)}let k,A=i*s+a*c+o*l;if(x<ky&&(_<Ay||E===0))k=Math.atan2(a,i),m<0&&(k=-k),k<0&&(k+=2*Math.PI);else if(x<ky){let e=(w*i+T*a)/(E*u);k=Math.acos(jy(e,-1,1)),o<0&&(k=2*Math.PI-k)}else{let e=(v*i+y*a+b*o)/(x*u);k=Math.acos(jy(e,-1,1)),A<0&&(k=2*Math.PI-k)}let j;if(x<1){let e=2*Math.atan2(Math.sqrt(1-x)*Math.sin(k/2),Math.sqrt(1+x)*Math.cos(k/2));j=e-x*Math.sin(e)}else if(x>1){let e=2*Math.atanh(Math.sqrt((x-1)/(x+1))*Math.tan(k/2));if(!isFinite(e))return null;j=x*Math.sinh(e)-e}else return null;let M=Math.abs(C),ee=Math.sqrt(n/(M*M*M))*Oy;return{a:C,e:x,i:g*Oy,om:D*Oy,w:O*Oy,ma:j*Oy,n:ee,epoch:r,equatorial:!1}}var Ny=180/Math.PI;function Py(e,t,n){if(n<=0)return null;let r=Math.sqrt(n/(e.aKm*e.aKm*e.aKm)),i=Ig(t+e.tAnchorOffsetS);return{a:e.aKm/ig,e:e.e,i:e.iRad*Ny,om:e.om0*Ny,w:e.w0*Ny,ma:e.m0*Ny,n:r*Ny*kg,epoch:i,equatorial:!1}}function Fy(e,t){let n=Ig(t+e.tAnchorOffsetS);return{a:e.aKm/ig,e:e.e,i:e.iRad*Ny,om:e.om0*Ny,w:e.w0*Ny,ma:e.m0*Ny,n:e.nMeanRadS*Ny*kg,omDot:e.omDot*Ny*kg,wDot:e.wDot*Ny*kg,epoch:n,equatorial:!1}}function Iy(e,t,n){if(n<=0)return null;let r=Dy(e,t,n);if(!r)return null;let i=n*og;return My([r.position[0]/ig,r.position[1]/ig,r.position[2]/ig],[r.velocity[0]*sg,r.velocity[1]*sg,r.velocity[2]*sg],i,t)}function Ly(e,t,n){let r=my(e,Fg(t));if(r<0)return null;let i=e.subChunks[r];switch(i.method){case 0:return null;case 1:return Py(i,e.subStartEt[r],n);case 2:return Fy(i,e.subStartEt[r]);case 3:return Iy(e,t,n)}}function Ry(e,t,n,r){let i=e.fitCenter;if(!i||i.id===n||!r)return null;let a=r.body(i.id,t),o=r.body(n,t);if(!a||!o)return null;if(a.parentId!==o.parentId)return console.warn(`fit-center override: ${i.id} (parent ${a.parentId}) and zone center ${n} (parent ${o.parentId}) don't share a chebyshev parent; treating the record as unplaceable`),null;let s=py(a,t),c=py(o,t);return!s||!c?null:{id:i.id,naifId:a.naifId,positionKm:[s.position[0]-c.position[0],s.position[1]-c.position[1],s.position[2]-c.position[2]],velocityKmDay:[s.velocity[0]-c.velocity[0],s.velocity[1]-c.velocity[1],s.velocity[2]-c.velocity[2]]}}function zy(e){let t=e-18e6;if(t>=2e6&&t<=2999999){let e=$_(t);if(e!==void 0)return{naifId:t,muKm3S2:e}}return{naifId:e,muKm3S2:$_(e)??0}}function By(e,t,n,r,i){let a=`naif-${n}`,o=e.fitCenter;if(o&&o.id!==a){let n=Ry(e,t,a,r);return n?{id:n.id,naifId:n.naifId,muKm3S2:$_(n.naifId)??0}:i?.(o.id)?o.idType===an.SPKID?{id:o.id,...zy(o.idValue)}:{id:o.id,naifId:o.idValue,muKm3S2:$_(o.idValue)??0}:null}return{id:a,naifId:n,muKm3S2:$_(n)??0}}var Vy=1/256,Hy=class{capacity;stepDays;epsilonScene;spanDays;needsPopulate=!1;positions;jds;head=0;_count=0;constructor(e,t,n=1/0,r){this.capacity=e,this.stepDays=t,this.epsilonScene=n,this.spanDays=r??t*e,this.positions=new Float32Array(e*3),this.jds=new Float64Array(e)}get count(){return this._count}reconfigure(e,t,n){Number.isFinite(e)&&e>0&&(this.stepDays=e),this.epsilonScene=t,this.spanDays=n??this.stepDays*this.capacity}get newestJd(){if(this._count===0)return NaN;let e=(this.head-1+this.capacity)%this.capacity;return this.jds[e]}readNewestPos(e){if(this._count===0)return!1;let t=(this.head-1+this.capacity)%this.capacity*3;return e[0]=this.positions[t],e[1]=this.positions[t+1],e[2]=this.positions[t+2],!0}append(e,t,n,r){let i=this.head;this.jds[i]=e,this.positions[i*3]=t,this.positions[i*3+1]=n,this.positions[i*3+2]=r,this.head=(i+1)%this.capacity,this._count<this.capacity&&this._count++}clear(){this.head=0,this._count=0}writeVertices(e,t,n,r,i){let a=Math.min(this._count,e.length/3|0),o=i?new Float64Array(3):null;for(let s=0;s<a;s++){let a=(this.head-1-s+this.capacity)%this.capacity,c=a*3,l=s*3;if(i&&o){o[0]=this.positions[c],o[1]=this.positions[c+1],o[2]=this.positions[c+2],i(this.jds[a],o),e[l]=o[0]+t,e[l+1]=o[1]+n,e[l+2]=o[2]+r;continue}e[l]=this.positions[c]+t,e[l+1]=this.positions[c+1]+n,e[l+2]=this.positions[c+2]+r}return a}},Uy=200;function Wy(e,t,n,r=!1){if(r)return{stepDays:Uy/n,epsilonScene:1/0,spanDays:Uy};let i=e!==null&&e.n>0,a=i?360/e.n:t,o=a>0?a/n:1,s=e?e.a*(1-e.e):0,c=s>0?s*10*1e-4:1/0;return{stepDays:o,epsilonScene:c,spanDays:!i&&isFinite(c)?1/0:o*n}}function Gy(e){let t=Number(e.slice(5));return e=>e===t}function Ky(e,t,n,r){let i=Gy(r);return a=>{let o=e.probeWithCenter(n,a,i);if(!o)return null;let s=By(o.probe,a,o.fitCenterNaifId,t,e=>e===r);return!s||s.id!==r?null:Sy(o.probe,a,s.muKm3S2)}}function qy(e,t,n,r,i){let a=e((t+r)/2);if(!a)return null;let o=a[0]-(n[0]+i[0])/2,s=a[1]-(n[1]+i[1])/2,c=a[2]-(n[2]+i[2])/2;return Math.sqrt(o*o+s*s+c*c)}var Jy=.005;function Yy(e,t,n,r,i,a,o){let s=(e,t)=>{if(e===null)return!1;let i=Math.hypot(t[0]-n[0],t[1]-n[1],t[2]-n[2]);return e<=Math.max(r,Jy*i)},c=t+o*a,l=e(c);if(l!==null&&s(qy(e,t,n,c,l),l))return{jd:c,pos:l};let u=i,d=a,f=null,p=i*.25;for(let r=0;r<16;r++){let r=(u+d)/2,i=t+o*r,a=e(i);if(a===null){d=r;continue}if(s(qy(e,t,n,i,a),a)?(u=r,f={jd:i,pos:a}):d=r,d-u<p)break}if(f)return f;let m=t+o*i,h=e(m);return h?{jd:m,pos:h}:null}function Xy(e,t,n,r,i,a){Zy(e,Ky(t,n,r,i),a)}function Zy(e,t,n){let r=t(n);if(!r)return;let i=[{jd:n,pos:r}];if(isFinite(e.epsilonScene)){let r=e.stepDays*16,a=e.stepDays*Vy,o=n-e.spanDays;for(;i.length<e.capacity;){let n=i[i.length-1];if(n.jd<=o)break;let s=Yy(t,n.jd,n.pos,e.epsilonScene,a,r,-1);if(!s)break;if(s.jd<o){let e=t(o);e&&i.push({jd:o,pos:e});break}i.push(s)}}else for(let r=1;r<e.capacity;r++){let a=n-r*e.stepDays,o=t(a);o&&i.push({jd:a,pos:o})}for(let t=i.length-1;t>=0;t--){let n=i[t];e.append(n.jd,n.pos[0],n.pos[1],n.pos[2])}}function Qy(e,t,n,r,i){if(!isFinite(e.epsilonScene))return;let a=e.stepDays*16,o=e.stepDays*Vy,s=n,c=r;for(let n=0;n<e.capacity&&!(i-s<=o);n++){let n=Math.min(a,i-s),r=Yy(t,s,c,e.epsilonScene,o,n,1);if(!r||r.jd<=s)break;e.append(r.jd,r.pos[0],r.pos[1],r.pos[2]),s=r.jd,c=r.pos}}function $y(e,t,n,r,i,a){if(t.length===0)return[];let o=e.trailAnchor??e.position,s=[o[0]-r,o[1]-i,o[2]-a],c=0,l=1/0;for(let e=0;e<t.length;e++){let n=(t[e][0]-s[0])**2+(t[e][1]-s[1])**2+(t[e][2]-s[2])**2;n<l&&(l=n,c=e)}let u=Math.max(c-1,0),d=Math.min(c+1,t.length-1),f=(t[u][0]-s[0])**2+(t[u][1]-s[1])**2+(t[u][2]-s[2])**2<(t[d][0]-s[0])**2+(t[d][1]-s[1])**2+(t[d][2]-s[2])**2?u:c,p=[s];if(n)for(let e=0;e<511;e++){let n=Math.max(f-e,0);if(p.push(t[n]),n===0)break}else{for(let e=0;e<511;e++)p.push(t[((f-e)%512+512)%512]);p.push(s)}return p.filter(e=>e.every(Number.isFinite))}function eb(e,t,n,r){let i=.55,a=n?0:i/3,o=e.length-1;for(let t=0;t<e.length;t++)e[t]=i-(o>0?t/o:0)*(i-a);if(r){let e=.35;t.fill(0);for(let n=0;n<Math.min(171,t.length);n++)t[n]=e-n/170*e}else t.set(e)}var tb=new Map,nb=0,rb=10;function ib(e,t,n,r){let i=$_(t);if(!i)return null;let a=py(e,n);if(!a)return null;let o=r?py(r,n):null;if(r&&!o)return null;let s=i*og;return My([(a.position[0]-(o?.position[0]??0))/ig,(a.position[1]-(o?.position[1]??0))/ig,(a.position[2]-(o?.position[2]??0))/ig],[(a.velocity[0]-(o?.velocity[0]??0))*sg,(a.velocity[1]-(o?.velocity[1]??0))*sg,(a.velocity[2]-(o?.velocity[2]??0))*sg],s,n)}function ab(e,t,n){return!n||e.parentId!==nb||e.naifId===rb?null:ib(e,rb,t,n)}function ob(e,t,n,r){return r?tn(e,t,r,n):en(e,t,n)}var sb=new Zv(8);async function cb(e,t,n,r,i){let a=`${e}:${t??``}:${n}:${r??``}`;return sb.getOrCompute(a,async()=>{let a=await K_(ob(e,t,n,r),{priority:i});if(!a.ok)throw Error(`Failed to fetch elements: ${a.status}`);let o=new DecompressionStream(`gzip`),s=ly(await new Response(a.body.pipeThrough(o)).arrayBuffer());if(s.kind!==`elements`)throw Error(`Expected elements payload at ${e}/${t}/${n}, got ${s.kind}`);return s.columns})}var lb=class{static prefetch(e,t,n,r=null){fetch(ob(e,t,n,r))}positions=new Map;barycenters=new Map;neededParentKeys=new Set;probeBuffers=new Map;constructor(e){this.cheb=e,this.positions.set(`naif-0`,[0,0,0])}processChebyshev(e,t){if(!this.cheb)return[];let n=Ng(e),r=this.barycenters.size===0,i=[],a=new Map,o=Array.from(this.cheb.bodiesAt(n));o.sort((e,t)=>{let n=e=>e.objectType===W.BARYCENTER?0:e.objectType===W.STAR?1:e.naifId%100==99?2:3;return n(e.body)-n(t.body)||e.body.naifId-t.body.naifId});let s=this.cheb,c=s.body(`naif-${rb}`,n);for(let{body:e,startJd:l,endJd:u}of o){let o=fy(e,n);if(!o)continue;a.set(e.naifId,e);let d=`naif-${e.parentId}`,f=this.positions.get(d);if(!f){console.warn(`processChebyshev: parent ${d} not in positions for ${e.id} — hiding`);continue}let p=[f[0]+o[0],f[1]+o[1],f[2]+o[2]],m=e.objectType,h=m===W.MOON&&e.parentId>=1&&e.parentId<=9?`naif-${e.parentId*100+99}`:null,g=h?this.positions.get(h):void 0,_=ib(e,e.parentId,n,h?s.body(h,n)??void 0:void 0),v=e.id,y=e=>{let t=s.body(v,e);return t?ib(t,t.parentId,e,h?s.body(h,e)??void 0:void 0):null},b=Math.hypot(o[0],o[1],o[2])/10,x={id:e.id,name:Wg(t,e.id),isMinor:Gg(t,e.id),hasLocalized:e.hasLocalized,objectType:m,parentId:`naif-${e.parentId}`,radiusKm:e.radiusKm,a:_?Math.abs(_.a):b,e:_?.e??0,i:_?.i??0,om:_?.om??0,w:_?.w??0,ma:_?.ma??0,n:_?.n??0,epoch:_?.epoch??0,equatorial:!1,helioElements:ab(e,n,c)??void 0,validityStart:l,validityEnd:u,orbitalSource:U.SPICE,visibleFromDays:e.visibleFromDays};if(r&&this.positions.set(e.id,p),m===W.BARYCENTER||m===W.LAGRANGE_POINT){r&&_&&_.a>0&&_.e<1&&this.barycenters.set(e.id,_),i.push({data:x,position:p,orbitElements:_??void 0,orbitCenter:f,rederiveElements:y});continue}if(vn(m)){let t=m===W.MOON,n=this.barycenters.get(d),r=t?_:n??_,o=!t&&n!==void 0,c=a.get(e.parentId)?.id,l=o&&c?e=>{let t=s.body(c,e);return t?ib(t,t.parentId,e):null}:y;i.push({data:x,position:p,orbitElements:r??void 0,orbitCenter:o?void 0:g??f,trailAnchor:o?[f[0],f[1],f[2]]:void 0,rederiveElements:l})}else i.push({data:x,position:p,orbitElements:_??void 0,orbitCenter:f,rederiveElements:y})}return i}processProbes(e,t,n){let r=Ng(t),i=[],a=new Map,o=new Map,s=new Set,c=new Set;for(let{id:t,probe:l,zoneCenterNaifId:u,startJd:d,endJd:f}of e.probesAt(r)){if(!t)continue;u===void 0&&c.add(t);let p=`naif-${u}`,m=u===void 0?null:By(l,r,u,this.cheb,e=>this.positions.has(e)),h=m?m.id:p,g=m?.muKm3S2??0,_=m===null,v=this.positions.get(h);if(!v){let e=a.get(h);e||a.set(h,e=new Set),e.add(t)}if(g===0){let e=o.get(h);e||o.set(h,e=new Set),e.add(t)}let y=xy(l,r,g);y||s.add(t);let b=v??[0,0,0],x=y?[Q(y[0]),Q(y[2]),-Q(y[1])]:null,S=!x||!v||_,C=x&&!_?[b[0]+x[0],b[1]+x[1],b[2]+x[2]]:[b[0],b[1],b[2]],w={id:t,name:Wg(n,t),isMinor:Gg(n,t),hasLocalized:l.hasLocalized,objectType:l.objectType,parentId:h,loadParentId:h,radiusKm:NaN,a:0,e:0,i:0,om:0,w:0,ma:0,n:0,epoch:0,equatorial:!1,validityStart:d,validityEnd:f,orbitalSource:U.SPICE_PROBE},T=Ly(l,r,g),E=t,D=this.cheb,O=t=>{let n=e.probeWithCenter(E,t);if(!n)return null;let r=By(n.probe,t,n.fitCenterNaifId,D,()=>!0);return r?Ly(n.probe,t,r.muKm3S2):null},k;{let{stepDays:e,epsilonScene:n,spanDays:r}=Wy(T,f-d,512),i=this.probeBuffers.get(t);i&&i.parentKey===h?(k=i.buffer,!isFinite(k.epsilonScene)&&isFinite(n)&&k.reconfigure(e,n,r)):(k=new Hy(512,e,n,r),k.needsPopulate=!0,this.probeBuffers.set(t,{buffer:k,parentKey:h}))}i.push({data:w,position:C,positionUnknown:S,orbitElements:T??void 0,orbitCenter:[b[0],b[1],b[2]],rederiveElements:O,trailBuffer:k})}c.size>0&&console.error(`processProbes: ${c.size} probe(s) have undefined fit_center_naif_id — metadata.json is stale (re-export to pick up fit_center_naif_id field). Affected probe ids: ${Array.from(c).slice(0,10).join(`, `)}`+(c.size>10?` (+${c.size-10} more)`:``));for(let[e,t]of a)console.warn(`processProbes: fit-center ${e} not in positions (unplaceable, kept hidden) — ${t.size} probe(s): ${Array.from(t).slice(0,5).join(`, `)}`+(t.size>5?` (+${t.size-5} more)`:``));for(let[e,t]of o)console.warn(`processProbes: GM unavailable for ${e} — kepler_pure sub-chunks will use mu=0 (static snapshot); affected ${t.size} probe(s): ${Array.from(t).slice(0,5).join(`, `)}`+(t.size>5?` (+${t.size-5} more)`:``));return s.size>0&&console.warn(`processProbes: ${s.size} probe(s) outside sub-chunk windows at load (will stay hidden until jd enters coverage): ${Array.from(s).slice(0,5).join(`, `)}`+(s.size>5?` (+${s.size-5} more)`:``)),i}async seedNeededParents(e,t,n,r,i){let a=await cb(e,t,n,r),o=cn(i);if(o!==void 0)for(let e=0;e<a.rowCount;e++)this.neededParentKeys.add(mh(o,a.parentId[e]))}async fetchMinorColumns(e,t,n,r,i=null,a=`naif`,o){let s=await cb(e,t,n,i,o);return this.neededParentKeys.size>0&&await this.resolveNeededParents(s,r,a),s}async resolveNeededParents(e,t,n){let r=Ng(t),i=e.kind===`parabolic`,a=this.neededParentKeys,o=performance.now();for(let s=0;s<e.rowCount;s++){if((s&4095)==4095&&performance.now()-o>6&&(await Dg(),o=performance.now()),!a.has(Ch(e,s)))continue;let c=Sh(e,s);if(c===null)continue;let l=this.positions.get(`${n}-${e.parentId[s]}`);if(!l)continue;let u=e_(e,s,tb,n);if(!u)continue;let d=r>=u.validityStart&&r<=u.validityEnd?u.satrec?bg(u.satrec,r):u.q==null?u.a===0&&!i?[0,0,0]:qv(u,t):Yv(u,t):[0,0,0];d&&this.positions.set(c,[l[0]+d[0],l[1]+d[1],l[2]+d[2]])}}async process(e,t,n,r,i=null,a=`naif`,o,s){let c=this.barycenters.size===0,l=[],u=new Map,d=[],[f,p]=await Promise.all([cb(e,t,n,i,s),Vv()]),m=f.kind===`parabolic`,h=f.kind===`sgp4`,g=Ng(r),_=performance.now();for(let e=0;e<f.rowCount;e++){(e&255)==255&&performance.now()-_>6&&(await Dg(),_=performance.now());let t=f.objectType[e];if(!m&&f.a[e]===0&&t!==W.BARYCENTER&&t!==W.LAGRANGE_POINT&&!vn(t))continue;let n=`${a}-${f.parentId[e]}`,i=this.positions.get(n);if(!i){u.set(n,(u.get(n)??0)+1);continue}let s=m?Jg(f,e,p,a):h?$g(f,e,p,a):qg(f,e,p,a);if(!s)continue;if(h&&s.name===null&&!o?.has(s.id)){l.push({data:s,position:[i[0],i[1],i[2]],positionUnknown:!0});continue}if(h&&!s.satrec)continue;let v=g>=s.validityStart&&g<=s.validityEnd,y=v?s.satrec?bg(s.satrec,g):s.a===0&&!m?[0,0,0]:s.q==null?qv(s,r):Yv(s,r):[0,0,0];if(!y){d.push(s.id);continue}let b=[i[0]+y[0],i[1]+y[1],i[2]+y[2]],x=vh(s.id);if(x!==null&&this.neededParentKeys.has(x)&&this.positions.set(s.id,b),t===W.BARYCENTER||t===W.LAGRANGE_POINT){c&&(s.a>0&&s.e<1&&this.barycenters.set(s.id,s),this.positions.set(s.id,b)),l.push({data:s,position:b,positionUnknown:!v,orbitElements:s.a>0?s:void 0,orbitCenter:i});continue}if(c&&vn(t)&&this.positions.set(s.id,b),vn(t)){let e=t===W.MOON,r=this.barycenters.has(n);l.push({data:s,position:b,positionUnknown:!v,orbitElements:e?s:this.barycenters.get(n)??s,orbitCenter:e||!r?i:void 0})}else l.push({data:s,position:b,positionUnknown:!v})}if(d.length>0&&console.warn(`process(${e}/${t}/${n}): positioned ${l.length} body(ies), dropped ${d.length} the propagator refused — ${d.slice(0,5).join(`, `)}`+(d.length>5?` (+${d.length-5} more)`:``)),u.size>0){let r=Array.from(u.values()).reduce((e,t)=>e+t,0),i=Array.from(u.entries()).map(([e,t])=>`${e}×${t}`).join(`, `);console.warn(`process(${e}/${t}/${n}): hid ${r} body(ies) with unresolved parent — ${i}`)}return l}},ub=new Map,db=null,fb=null;function pb(e){if(!e)return;let t=e.ls_deg.length;if(t<2||e.dust_tau_factor.length!==t||e.dust_scale_height_km.length!==t||e.pressure_factor.length!==t){console.warn(`atmospheres: malformed seasonal table — ignored`);return}return{lsDeg:e.ls_deg,dustTauFactor:e.dust_tau_factor,dustScaleHeightKm:e.dust_scale_height_km,pressureFactor:e.pressure_factor}}function mb(e,t,n){if(t){if(!n||n<2||!(t.top_km>0)||t.flux_down.length!==3*n||t.flux_up_ratio.length!==3*n||t.extinction_per_km.length!==3*n){console.warn(`atmospheres: ${e} has a malformed deep column — ignored`);return}return{n,topKm:t.top_km,fluxDown:t.flux_down,fluxUpRatio:t.flux_up_ratio,extinctionPerKm:t.extinction_per_km}}}function hb(){if(fb)return fb;let e=(async()=>{let e=await K_(`${Kt()}/v1/atmospheres.json`);if(!e.ok){console.warn(`atmospheres: fetch failed (${e.status}) — rendering without shells`);return}let t=await e.json();db=t.sun?.limb_darkening_alpha??null;for(let[e,n]of Object.entries(t.bodies)){let r=t.phases[n.phase];if(!r||r.length!==3*t.phase_n){console.warn(`atmospheres: ${e} has bad phase table "${n.phase}" — skipped`);continue}let i=n.mie_profile;i&&i.length!==t.profile_n&&(console.warn(`atmospheres: ${e} has a bad mie profile — falling back to exponential`),i=void 0),ub.set(e,{topAltitudeKm:n.top_altitude_km,rayleighScatterPerKm:n.rayleigh_scatter_per_km,rayleighScaleHeightKm:n.rayleigh_scale_height_km,mieScatterPerKm:n.mie_scatter_per_km,mieAbsorptionPerKm:n.mie_absorption_per_km,mieScaleHeightKm:n.mie_scale_height_km,miePhase:r,absorptionPerKm:n.absorption_per_km,absorptionCenterKm:n.absorption_center_km,absorptionWidthKm:n.absorption_width_km,bakedCompensation:n.baked_compensation,multiScatterGain:n.multi_scatter_gain,sunIntensity:n.sun_intensity,sunColor:[1,1,1],realisticSunAlways:n.realistic_sun_always,refractivity:n.refractivity,groundAlbedo:n.ground_albedo,mieProfile:i,seasonal:pb(n.seasonal),referenceAltitudeKm:n.reference_altitude_km,deepColumn:mb(e,n.deep_column,t.deep_n)})}})();return e.catch(()=>{fb===e&&(fb=null)}),fb=e,e}function gb(e){return ub.get(e)}function _b(){return db}var vb=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function yb(e,t){return e>>>t|e<<32-t}function bb(e){let t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),n=Math.ceil((e.length+9)/64),r=new Uint8Array(n*64);r.set(e),r[e.length]=128,new DataView(r.buffer).setUint32(r.length-4,e.length*8,!1);let i=new Uint32Array(64),a=new DataView(r.buffer);for(let e=0;e<n;e++){for(let t=0;t<16;t++)i[t]=a.getUint32(e*64+t*4,!1);for(let e=16;e<64;e++){let t=yb(i[e-15],7)^yb(i[e-15],18)^i[e-15]>>>3,n=yb(i[e-2],17)^yb(i[e-2],19)^i[e-2]>>>10;i[e]=i[e-16]+t+i[e-7]+n|0}let[n,r,o,s,c,l,u,d]=t;for(let e=0;e<64;e++){let t=yb(c,6)^yb(c,11)^yb(c,25),a=c&l^~c&u,f=d+t+a+vb[e]+i[e]|0,p=(yb(n,2)^yb(n,13)^yb(n,22))+(n&r^n&o^r&o)|0;d=u,u=l,l=c,c=s+f|0,s=o,o=r,r=n,n=f+p|0}t[0]=t[0]+n|0,t[1]=t[1]+r|0,t[2]=t[2]+o|0,t[3]=t[3]+s|0,t[4]=t[4]+c|0,t[5]=t[5]+l|0,t[6]=t[6]+u|0,t[7]=t[7]+d|0}let o=new Uint8Array(32),s=new DataView(o.buffer);for(let e=0;e<8;e++)s.setUint32(e*4,t[e],!1);return o}function xb(e){return e.shape===`parted`}function Sb(e){return e.shape===`chunked-parted`&&e.label===`date`}function Cb(e){return e.shape===`chunked-parted`&&e.label===`index`}function wb(e){return e.shape===`chunked`}function Tb(e,t){let n=Math.floor((t-e.start_jd)/e.chunk_days);return Math.max(0,Math.min(e.chunks-1,n))}function Eb(e){return`shape`in e&&e.shape===`probes`}function Db(e){return`zooms`in e}function Ob(e){return Eb(e)?[]:Db(e)?Object.entries(e.zooms).map(([e,t])=>({zoom:Number(e),data:t})):[{zoom:null,data:e}]}function kb(e){return!Db(e)&&!Eb(e)?e:void 0}var Ab=new WeakMap;function jb(e){let t=Ab.get(e);return t||(t=Object.keys(e.parts_by_date).map(e=>Date.parse(`${e}T00:00:00Z`)).sort((e,t)=>e-t),Ab.set(e,t)),t}function Mb(e,t){let n=jb(e),r=t.getTime(),i=e=>new Date(e).toISOString().slice(0,10);if(r<=n[0])return i(n[0]);if(r>=n[n.length-1])return i(n[n.length-1]);let a=0,o=n.length-1;for(;a<o;){let e=a+o>>1;n[e]<r?a=e+1:o=e}let s=n[a-1],c=n[a];return i(r-s<=c-r?s:c)}var Nb=14;function Pb(e,t){let n=jb(e),r=t.getTime(),i=Nb*864e5,a=n[0],o=n[n.length-1];if(r<a)return{kind:`covered`};if(r>o+i)return{kind:`after`,lastMs:o+i};if(r>=o)return{kind:`covered`};let s=0,c=n.length-1;for(;s<c;){let e=s+c>>1;n[e]<r?s=e+1:c=e}let l=n[s],u=s>0?n[s-1]:l;return Math.min(r-u,l-r)>i?{kind:`gap`}:{kind:`covered`}}function Fb(e,t,n=0){let r=e.parts_by_date[t]??e.parts;return n>0?Math.min(r,n):r}var Ib=null;function Lb(){if(Ib)return Ib;let e=K_(`${Kt()}/v1/metadata.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch metadata: ${e.status}`);return e.json()}).then(e=>(Jt(e.versions),e));return Ib=e,e.catch(()=>{Ib===e&&(Ib=null)}),Ib}function Rb(e){let t=new Map;for(let[n,r]of Object.entries(e.position.zones)){if(Eb(r))continue;let e=Db(r)?0:null,i=e===0?r.zooms[0]:r;!i||!wb(i)||t.set(n,{zoom:e,chunks:i.chunks,chunk_days:i.chunk_days,start_jd:i.start_jd,end_jd:i.end_jd})}return t}function zb(e){let t=new Map,n=Object.entries(e.position.zones).filter(([,e])=>Eb(e)).sort(([e],[t])=>(e===`probes/interplanetary`)-+(t===`probes/interplanetary`)||e.localeCompare(t));for(let[e,r]of n)Eb(r)&&t.set(e,{chunks:r.chunks,chunk_days:r.chunk_days,start_jd:r.start_jd,end_jd:r.end_jd,float64_coeffs:r.float64_coeffs,fit_center_naif_id:r.fit_center_naif_id,present:r.present});return t}async function Bb(e,t){let n=new TextEncoder().encode(e),r=crypto.subtle?await crypto.subtle.digest(`SHA-256`,n):bb(n).buffer;return new DataView(r).getUint32(0,!1)%t}async function Vb(e,t){let n=await K_(e,{priority:t});if(!n.ok)throw Error(`Failed to fetch ${e}: ${n.status}`);let r=new DecompressionStream(`gzip`);return new Response(n.body.pipeThrough(r)).arrayBuffer()}async function Hb(e,t,n,r){let i=ly(await Vb(nn(e,t,n),r));if(i.kind!==`chebyshev`)throw Error(`Expected chebyshev payload at ${e}/${n}, got ${i.kind}`);let a=new Map;for(let e of i.chunk.bodies)e.id&&a.set(e.id,e);return{...i.chunk,byId:a}}var Ub=1,Wb=Promise.resolve();function Gb(e,t){return`${e}:${t}`}var Kb=class{chunks=new Map;inflight=new Map;lastEnsuredJd=NaN;constructor(e){this.zoneParams=e}zones(){return Array.from(this.zoneParams.keys())}ensure(e){if(e===this.lastEnsuredJd)return{ready:this.allCurrentChunksLoaded(e),done:this.pendingCurrent(e)};this.lastEnsuredJd=e;let t=[],n=[],r=!0;for(let[i,a]of this.zoneParams){let o=Tb(a,e);if(this.isLoadable(a,o)&&!this.isResident(i,o)){r=!1;let e=this.loadChunk(i,a,o,`high`);e&&t.push(e)}for(let e=-Ub;e<=Ub;e++){let t=o+e;e===0||t<0||t>=a.chunks||this.isLoadable(a,t)&&n.push([i,a,t])}this.evictOutsideWindow(i,o)}let i=t.length>0?Promise.all(t).then(()=>void 0):Wb;return i.catch(()=>{}).then(()=>{for(let[e,t,r]of n)this.loadChunk(e,t,r,`low`)?.catch(()=>{})}),{ready:r,done:i}}pendingCurrent(e){if(this.inflight.size===0)return Wb;let t=null;for(let[n,r]of this.zoneParams){let i=this.inflight.get(Gb(n,Tb(r,e)));i&&(t??=[]).push(i)}return t?Promise.all(t).then(()=>void 0):Wb}allCurrentChunksLoaded(e){for(let[t,n]of this.zoneParams){let r=Tb(n,e);if(this.isLoadable(n,r)&&!this.isResident(t,r))return!1}return!0}isResident(e,t){return this.chunks.get(e)?.has(t)??!1}evictOutsideWindow(e,t){let n=this.chunks.get(e);if(n)for(let e of n.keys())(e<t-Ub||e>t+Ub)&&n.delete(e)}loadChunk(e,t,n,r){if(this.isResident(e,n))return null;let i=Gb(e,n),a=this.inflight.get(i);if(a)return a;let o=this.fetchAndStore(e,t,n,r);return this.inflight.set(i,o),o.finally(()=>this.inflight.delete(i)),o}async fetchAndStore(e,t,n,r){let i=await this.fetchChunk(e,t,n,r),a=this.chunks.get(e);a||this.chunks.set(e,a=new Map),a.set(n,i),this.afterStore(e,i)}},qb=class extends Kb{idToZone=new Map;isLoadable(){return!0}fetchChunk(e,t,n,r){return Hb(e,t.zoom,n,r)}afterStore(e,t){for(let n of t.byId.keys())this.idToZone.has(n)||this.idToZone.set(n,e)}has(e){return this.idToZone.has(e)}zoneCoverage(e){let t=this.idToZone.get(e);if(t===void 0)return null;let n=this.zoneParams.get(t);return n?{start:n.start_jd,end:n.end_jd}:null}resolve(e,t){let n=this.idToZone.get(e);if(n===void 0)return null;let r=this.zoneParams.get(n);if(!r)return null;let i=Tb(r,t),a=this.chunks.get(n)?.get(i);if(!a)return null;let o=a.byId.get(e);return o?{zone:n,chunkIdx:i,body:o}:null}body(e,t){return this.resolve(e,t)?.body??null}*bodiesAt(e){for(let[t,n]of this.zoneParams){let r=Tb(n,e),i=this.chunks.get(t)?.get(r);if(i)for(let e of i.bodies)yield{zone:t,body:e,startJd:i.startJd,endJd:i.endJd}}}positionScene(e,t){let n=this.resolve(e,t);return n?fy(n.body,t):null}};async function Jb(e,t,n,r){let i=nn(e,null,t),a=await K_(i,{priority:r});if(!a.ok)throw Error(`Failed to fetch ${i}: ${a.status}`);let o=new DecompressionStream(`gzip`),s=ly(await new Response(a.body.pipeThrough(o)).arrayBuffer(),{probesFloat64:n});if(s.kind!==`probes`)throw Error(`Expected probes payload at ${e}/${t}, got ${s.kind}`);return{...s.chunk,ids:s.chunk.probes.map(e=>e.id)}}var Yb=24;function Xb(e,t){for(let[n,r]of e){if(t<n)return!1;if(t<=r)return!0}return!1}var Zb=7,Qb=class extends Kb{fitCenterUsable=null;warmed=new Map;carried=new Map;_version=0;get version(){return this._version}zoneCenter(e){return this.zoneParams.get(e)?.fit_center_naif_id}isLoadable(e,t){return Xb(e.present,t)}fetchChunk(e,t,n,r){return Jb(e,n,t.float64_coeffs,r)}afterStore(){this._version++}async warmAt(e){let t=[];for(let[n,r]of this.zoneParams){let i=Tb(r,e);if(i<0||i>=r.chunks||!Xb(r.present,i)||this.isResident(n,i))continue;let a=Gb(n,i);if(this.warmed.has(a))continue;let o=this.inflight.get(a);if(o){t.push(o);continue}let s=this.fetchAndWarm(a,n,i,r);this.inflight.set(a,s),s.finally(()=>this.inflight.delete(a)),t.push(s)}await Promise.all(t)}async fetchAndWarm(e,t,n,r){let i=await Jb(t,n,r.float64_coeffs,`low`);for(this.warmed.set(e,i);this.warmed.size>Yb;){let e=this.warmed.keys().next().value;if(e===void 0)break;this.warmed.delete(e)}}fitCenterCovered(e){let t=e.fitCenter;return!t||!this.fitCenterUsable?!0:this.fitCenterUsable(t.id)}*probesAt(e,t){let n=new Map,r=new Set;for(let[i,a]of this.zoneParams){let o=Tb(a,e),s=this.chunks.get(i)?.get(o)??this.warmed.get(Gb(i,o));if(!s)continue;let c=t?.(a.fit_center_naif_id)??!1;for(let e=0;e<s.probes.length;e++){let t=s.probes[e],o=t.id;if(!o||r.has(o)||!this.fitCenterCovered(t))continue;let l={zone:i,zoneCenterNaifId:a.fit_center_naif_id,id:o,probe:t,startJd:s.startJd,endJd:s.endJd};c?(n.set(o,l),r.add(o)):n.has(o)||n.set(o,l)}}yield*this.withPassengers(n,e).values()}withPassengers(e,t){if(this.carried.size===0)return e;let n=[];for(let[r,{carriedFrom:i}]of this.carried){if(t<i.start_jd||t>=i.end_jd||e.has(r))continue;let a=e.get(i.object_id);a&&n.push([r,a])}for(let[t,r]of n)e.set(t,{...r,id:t});return e}registerCarried(e){this.carried.set(e.id,e)}carrierAt(e,t){if(this.carried.size===0)return null;let n=this.carried.get(e)?.carriedFrom;return!n||t<n.start_jd||t>=n.end_jd+Zb?null:n.object_id}ridesAt(e){let t=[];for(let[n,r]of this.carried){let i=r.carriedFrom;if(e<i.start_jd||e>=i.end_jd+Zb)continue;let a=e<i.end_jd;!a&&this.resolveOwn(n,e)||t.push({passengerId:n,carrierId:i.object_id,carrierName:r.carrierName,attached:a})}return t}resolve(e,t,n){let r=this.resolveOwn(e,t,n);if(r)return r;let i=this.carrierAt(e,t);return i?this.resolveOwn(i,t,n):null}resolveOwn(e,t,n){let r=Fg(t),i=null;for(let[a,o]of this.zoneParams){let s=Tb(o,t),c=this.chunks.get(a)?.get(s)??this.warmed.get(Gb(a,s));if(c)for(let t of nx(c,e)){let e=c.probes[t];if(!this.fitCenterCovered(e))break;let s=my(e,r)>=0,l=e.landed,u=l!==void 0&&r>=l.startEt&&r<l.endEt;if(!s&&!u)continue;let d={zone:a,probe:e,params:o};if(n?.(o.fit_center_naif_id))return d;i??=d;break}}return i}stampedFitCenterAt(e,t){let n=this.stampedFitCenterAtOwn(e,t);if(n!==null)return n;let r=this.carrierAt(e,t);return r?this.stampedFitCenterAtOwn(r,t):null}stampedFitCenterAtOwn(e,t){let n=Fg(t);for(let[r,i]of this.zoneParams){let a=Tb(i,t),o=this.chunks.get(r)?.get(a)??this.warmed.get(Gb(r,a));if(o)for(let t of nx(o,e)){let e=o.probes[t];if(my(e,n)<0)break;return e.fitCenter?.id??null}}return null}probe(e,t,n){return this.resolve(e,t,n)?.probe??null}probeWithCenter(e,t,n){let r=this.resolve(e,t,n);return r?{probe:r.probe,fitCenterNaifId:r.params.fit_center_naif_id}:null}positionKm(e,t,n,r){let i=this.resolve(e,t,r);return i?xy(i.probe,t,n):null}positionScene(e,t,n,r){let i=this.resolve(e,t,r);return i?Sy(i.probe,t,n):null}containingSystemAt(e,t){let n=this.containingSystemAtOwn(e,t);if(n!==null)return n;let r=this.carrierAt(e,t);return r?this.containingSystemAtOwn(r,t):null}containingSystemAtOwn(e,t){let n=Fg(t),r=this.zoneParams.get($b);if(r){let i=Tb(r,t),a=this.chunks.get($b)?.get(i);if(a)for(let t of nx(a,e)){let e=a.probes[t];for(let t of e.systemIntervals)if(n>=t.startEt&&n<t.endEt)return t.systemNaifId;return null}}for(let[n,r]of this.zoneParams){if(n===$b||r.fit_center_naif_id===10)continue;let i=Tb(r,t),a=this.chunks.get(n)?.get(i);if(a)for(let t of nx(a,e))return Math.floor(r.fit_center_naif_id/100)}return null}hasHeliocentricFit(e,t){if(this.hasHeliocentricFitOwn(e,t))return!0;let n=this.carrierAt(e,t);return n!==null&&this.hasHeliocentricFitOwn(n,t)}hasHeliocentricFitOwn(e,t){let n=this.zoneParams.get($b);if(!n)return!1;let r=Tb(n,t),i=this.chunks.get($b)?.get(r);if(!i)return!1;let a=Fg(t);for(let t of nx(i,e))if(my(i.probes[t],a)>=0)return!0;return!1}},$b=`probes/interplanetary`,ex=[],tx=new WeakMap;function nx(e,t){let n=tx.get(e);if(!n){n=new Map;for(let t=0;t<e.ids.length;t++){let r=n.get(e.ids[t]);r?r.push(t):n.set(e.ids[t],[t])}tx.set(e,n)}return n.get(t)??ex}async function rx(e){let t=new DecompressionStream(`gzip`);return await new Response(e.body.pipeThrough(t)).json()}function ix(e,t={}){let{onMissing:n,fetcher:r=e=>fetch(e),error:i=(e,t)=>`memoizedGzJson: ${t} returned ${e.status} ${e.statusText}`}=t,a=null;return()=>{if(a)return a;let t=(async()=>{let t=await e(),a=await r(t);if(!a.ok){if(a.status===404&&n)return n();throw Error(i(a,t))}return rx(a)})();return a=t,t.catch(()=>{a===t&&(a=null)}),t}}var ax=24,ox=new Map;function sx(e){let t=ox.get(e);if(t&&(ox.delete(e),ox.set(e,t)),!t){t=(async()=>{let t=await K_(e);if(!t.ok){if(t.status===404)return{};throw Error(`fetchGzipBundle: ${e} returned ${t.status} ${t.statusText}`)}return rx(t)})(),ox.set(e,t),t.catch(()=>{ox.get(e)===t&&ox.delete(e)});for(let e of ox.keys()){if(ox.size<=ax)break;ox.delete(e)}}return t}var cx={counts:`object_bundles`,globalPath:e=>`/v1/objects/__global__/${e}.json.gz`,localizedPath:(e,t)=>`/v1/objects/${e}/${t}.json.gz`,versionClass:`objects`},lx={counts:`group_bundles`,globalPath:e=>`/v1/groups/__global__/${e}.json.gz`,localizedPath:(e,t)=>`/v1/groups/${e}/${t}.json.gz`},ux=(e,t)=>sx(t?Yt(e,t):`${Kt()}${e}`);async function dx(e,t,{meta:n,lang:r,fetchBundle:i,localized:a=!0}){let o=n[e.counts],s=o?.global??0,c=a?o?.[r]??0:0,[l,u]=await Promise.all([s?Bb(t,s):-1,c?Bb(t,c):-1]),[d,f]=await Promise.all([l>=0?i(e.globalPath(l),e.versionClass):null,u>=0?i(e.localizedPath(r,u),e.versionClass):null]);return{global:d?.[t]??null,localized:f?.[t]??null}}async function fx(e,t,n,r=!0){return dx(e,t,{meta:await Lb(),lang:n,localized:r,fetchBundle:ux})}function px(e){return e.imagery!==`withheld`&&o(e.distribution)}function mx(e,t=!0,n=c()){return fx(cx,e,n,t)}async function hx(e){if(e?.startsWith(`probe-`))try{let t=(await mx(e,!1)).global,n=t?.coverage?.position_from;return n?{id:e,carriedFrom:n,carrierName:t?.carried_by?.name}:void 0}catch{return}}function gx(e,t,n){let r=new Set,i=new Map;for(let a of e){let e=t===a.passengerId;if(r.add(e?a.carrierId:a.passengerId),!e||!a.attached)continue;let o=n(a.carrierId)??a.carrierName;o&&i.set(a.passengerId,o)}return{hidden:r,credits:i}}function _x(e){return W[e.toUpperCase()]??W.UNDOCUMENTED}var vx={horizons:U.HORIZONS,sbdb:U.SBDB,celestrak:U.CELESTRAK,spacetrack:U.SPACETRACK,spice:U.SPICE,sbdb_moons:U.SBDB_MOON,astersat:U.ASTERSAT};function yx(e){return e?vx[e]??U.UNKNOWN:U.UNKNOWN}var bx=14;function xx(e,t){let n=t.global;if(!n?.orbit)return null;let r=n.orbit,i=r.scale===`planet`,a=r.q!=null,o=n.cross_refs?.norad_cat_id,s=r.bstar!=null&&r.mean_motion_dot!=null&&r.mean_motion_ddot!=null&&r.n!=null&&o!=null,c=i&&s?_g({noradCatId:o,epochJd:r.epoch_jd,meanMotion:r.n,eccentricity:r.e,inclination:r.i,raOfAscNode:r.om,argOfPericenter:r.w,meanAnomaly:r.ma??0,bstar:r.bstar,meanMotionDot:r.mean_motion_dot,meanMotionDdot:r.mean_motion_ddot,elementSetNo:r.element_set_no??0,revAtEpoch:r.rev_at_epoch??0},n.name??void 0)??void 0:void 0;return{id:e,name:t.localized?.name??n.name??n.sbdb_primary_designation??n.provisional_designation??null,objectType:_x(n.type),parentId:r.parent_id,radiusKm:n.sbdb?.diameter?n.sbdb.diameter/2:NaN,hasLocalized:t.localized!=null,a:i?(r.a??0)/ig:r.a??0,e:r.e,i:r.i,om:r.om,w:r.w,ma:r.ma??0,n:i?(r.n??0)*360:r.n??0,epoch:r.epoch_jd,equatorial:i,validityStart:c?r.epoch_jd-bx:-1/0,validityEnd:c?r.epoch_jd+bx:1/0,orbitalSource:yx(r.source),...a?{q:r.q,tp:r.tp}:{},...c?{satrec:c}:{}}}function Sx(e,t){let n=t.global;return n?{id:e,name:t.localized?.name??n.name??n.sbdb_primary_designation??n.provisional_designation??null,objectType:_x(n.type),parentId:``,radiusKm:n.sbdb?.diameter?n.sbdb.diameter/2:NaN,hasLocalized:t.localized!=null,unplaceable:!0,a:NaN,e:NaN,i:NaN,om:NaN,w:NaN,ma:NaN,n:NaN,epoch:NaN,validityStart:-1/0,validityEnd:1/0,orbitalSource:U.UNKNOWN}:null}async function Cx(e,t,n,r=new Set){if(r.has(e))return console.warn(`createPlaceholderBody: cycle detected at ${e} — hiding`),[];r.add(e);let i;try{i=await mx(e)}catch{return console.warn(`createPlaceholderBody: failed to fetch global data for ${e} — hiding`),[]}let a=i.global;if(!a)return console.warn(`createPlaceholderBody: no catalogue record for ${e} — hiding`),[];let o=a.sbdb?.class??null,s=t=>{let n=t?{...t,unplaceable:!0}:Sx(e,i);return n?[{body:{data:n,position:[0,0,0],positionUnknown:!0},zone:o}]:[]},c=xx(e,i);if(!c)return s();let l=c.satrec,u=c.q!=null,d=[],f=n.positions.get(c.parentId);if(!f){let e=await Cx(c.parentId,t,n,r),i=e[e.length-1];if(!i||i.body.positionUnknown)return[...e,...s(c)];f=i.body.position,n.positions.set(c.parentId,f),d.push(...e)}let p=l?bg(l,Ng(t)):u?Yv(c,t):qv(c,t);if(!p)return console.warn(`Failed to compute position for ${e} (e=${c.e})`),[...d,...s(c)];let m=[f[0]+p[0],f[1]+p[1],f[2]+p[2]];return d.push({body:{data:c,position:m,orbitElements:c,orbitCenter:f},zone:o}),d}function wx(e,t,n,r){let i=0;for(let a=0;a<t.length;a++){let{body:o,zone:s}=t[a];if(e.getBody(o.data.id))continue;let c=o.data.objectType;if(o.data.unplaceable)e.bodies.addBodies([o]),i++;else{let l=a>0?t[a-1]:null,u=c===W.MOON&&l&&_n(l.body.data.objectType)?`small_body_moons`:s;if(c===W.SPACECRAFT||c===W.DEBRIS){let t=o.data.parentId;e.bodies.spacecraftBucket(t).set(o.data.id,o),r?.onPlaceholder?.(o),e.bodies.dirtySpacecraftGroups.add(t),i++}else u?(e.bodies.asteroidBucket(u,n).addPlaceholder(o),e.bodies.dirtyAsteroidZones.add(u),i++):e.bodies.addBodies([o])}e.credits.recordOrbitSources([o])}return i}async function Tx(e,t,n,r){if(e.getBody(t))return;let i=await Cx(t,n,r);if(i.length===0)return;let a=wx(e,i,await Vv());e.bodies.flushMinor(a>0)}var Ex=`spacemap.atmosphere-calibration`;function Dx(){try{let e=localStorage.getItem(Ex);return e?JSON.parse(e):null}catch{return null}}function Ox(e){try{e?localStorage.setItem(Ex,JSON.stringify(e)):localStorage.removeItem(Ex)}catch{}}function kx(){return $e({resolvedReducedMotion:typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,viewMode:`map`,showClouds:!0,showAtmospheres:!0,atmosphereQuality:`auto`,atmosphereAutoTier:null,atmosphereCalibration:Dx(),atmoQualityOverrides:{},highAmbient:!1,realisticLighting:!1,overexposeRings:!1,showShapeMesh:!0,showSurfaceTexture:!0,showDisplacement:!0,showSelfShadow:!0,showHaloDebug:!1,maxPartsPerZone:0,setAtmosphereCalibration(e){this.atmosphereCalibration=e,Ox(e)},setAtmosphereAutoTier(e){this.atmosphereAutoTier=e}})}var Ax=null;function jx(){return Ax??=kx()}function Mx(e){Ax=e}var Nx=2e3,Px=3,Fx=class{zones=[];latestDate;failureStreak=0;staleNotified=!1;constructor(e,t,n,r){this.ctx=e,this.loader=n,this.latestDate=r;let i=Ng(r),a=jx().maxPartsPerZone;for(let[n,o]of Object.entries(t.position.zones)){if(e.layers.skipsZone(n))continue;let t=o.parent_id_type??`naif`;for(let{zoom:e,data:s}of Ob(o)){if(s.shape===`chunked`||s.shape===`parted`)continue;let o=a>0?Math.min(s.parts,a):s.parts;if(Sb(s)){let i={kind:`time`,zone:n,zoom:e,parts:o,parentIdType:t,zoomData:s,currentTime:Mb(s,r),inFlight:null,lastLoadStartMs:-1/0,cap:a};this.zones.push(i),this.prefetchTimeNeighbors(i,r)}else if(Cb(s)){let a={kind:`chunk`,zone:n,zoom:e,parts:o,parentIdType:t,zoomData:s,currentIdx:Tb(s,i),inFlight:null,preloads:new Map};this.zones.push(a),this.preloadChunkNeighbors(a,r)}}}}recordSuccess(){this.failureStreak=0}recordFailure(){this.failureStreak++,this.failureStreak>=Px&&!this.staleNotified&&(this.staleNotified=!0,this.ctx.onDataStale?.())}invalidateZone(e){for(let t of this.zones)t.zone!==e||t.kind!==`time`||(t.currentTime=``,t.lastLoadStartMs=-1/0);this.tick(this.latestDate)}satelliteCoverage(e){let t=this.zones.find(e=>e.kind===`time`&&e.zone===`earth`);return t?Pb(t.zoomData,Pg(e)):{kind:`covered`}}tick(e){this.latestDate=e;let t=Ng(e);for(let n of this.zones)if(n.kind===`time`){if(n.inFlight)continue;let t=Mb(n.zoomData,e);if(t===n.currentTime)continue;let r=performance.now();if(r-n.lastLoadStartMs<Nx)continue;n.lastLoadStartMs=r,n.inFlight=this.loadTime(n,t,e).finally(()=>{n.inFlight=null})}else{for(;;){let r=Tb(n.zoomData,t);if(r===n.currentIdx)break;let i=n.preloads.get(r);if(i?.kind!==`ready`)break;let a=n.currentIdx;n.currentIdx=r,this.applyChunkSwap(n,a,r,i.bodies),this.preloadChunkNeighbors(n,e)}if(n.inFlight)continue;let r=Tb(n.zoomData,t);if(r===n.currentIdx)continue;n.inFlight=this.loadChunk(n,r,e).finally(()=>{n.inFlight=null})}}async ensureBody(e,t){if(!this.ctx.getBody(e)){if(e.startsWith(`probe-`)){let n=this.ctx.probeStore;if(!n)return;let r=Ng(t),i=hx(e);await n.ensure(r).done;let a=await i;a&&n.registerCarried(a);let o=n.stampedFitCenterAt(e,r);if(o){this.ctx.getBody(o)||await Tx(this.ctx,o,t,this.loader);let e=this.ctx.getBody(o);e&&!e.positionUnknown&&!this.loader.positions.has(o)&&this.loader.positions.set(o,e.position)}let s=await Vv(),c=this.loader.processProbes(n,t,s).find(t=>t.data.id===e);if(!c){await Tx(this.ctx,e,t,this.loader);return}this.ctx.bodies.addBodies([c]),this.ctx.credits.recordOrbitSources([c]),this.ctx.bodies.notifyBodiesAdded();return}await Tx(this.ctx,e,t,this.loader)}}async loadTime(e,t,n){let r=e.currentTime;try{let i=Fb(e.zoomData,t,e.cap),a=await Promise.all(Array.from({length:i},(r,i)=>this.loader.process(e.zone,e.zoom,i,n,t,e.parentIdType))),o=e.zone===`earth`,s=o?this.ctx.earthSatFilter:null,c=o?this.ctx.earthTypeFilter:null,l=0,u=new Map;for(let t of a){this.ctx.credits.recordOrbitSources(t);for(let n of t){let t=n.data.objectType;if(t!==W.SPACECRAFT&&t!==W.DEBRIS){console.warn(`zone-refresher: unexpected non-spacecraft body in ${e.zone}: ${n.data.id} (type=${t})`);continue}if(s&&!s.has(n.data.id)){l++;continue}if(c&&!c.has(t)){l++;continue}let r=n.data.parentId,i=u.get(r);i||u.set(r,i=new Map),i.set(n.data.id,n)}}l>0&&console.log(`zone-refresher: ${e.zone}@${t}: filtered out ${l} non-member bodies`);let d=0,f=0,p=0;for(let[e,t]of u){let n=this.ctx.bodies.spacecraftBucket(e);for(let e of n.keys())t.has(e)||this.ctx.hasMeshBody?.(e)||(n.delete(e),p++);for(let[e,r]of t){let t=n.get(e);t?(t.data=r.data,t.position=r.position,r.orbitElements!==void 0&&(t.orbitElements=r.orbitElements),r.orbitCenter!==void 0&&(t.orbitCenter=r.orbitCenter),f++):(n.set(e,r),d++)}this.ctx.bodies.dirtySpacecraftGroups.add(e)}e.currentTime=t,this.ctx.bodies.minorBodyVersion++,d>0&&this.ctx.bodies.notifyBodiesAdded(),e.zone===`earth`&&this.ctx.notifyEarthSatRollover(),console.log(`zone-refresher: ${e.zone}@${r} → ${t} (+${d} ~${f} -${p})`),this.prefetchTimeNeighbors(e,n),this.recordSuccess()}catch(n){console.warn(`zone-refresher: failed to refresh ${e.zone}@${t}:`,n),this.recordFailure()}}async loadChunk(e,t,n){let r=e.currentIdx;e.currentIdx=t;try{let i=e.preloads.get(t),a;a=i?.kind===`pending`?await i.promise:await Promise.all(Array.from({length:e.parts},(r,i)=>this.loader.process(e.zone,e.zoom,i,n,String(t),e.parentIdType))),this.applyChunkSwap(e,r,t,a),this.preloadChunkNeighbors(e,n),this.recordSuccess()}catch(n){console.warn(`zone-refresher: ${e.zone} chunk reload failed (${r} → ${t}):`,n),e.currentIdx=r,this.recordFailure()}}applyChunkSwap(e,t,n,r){let i=0,a=0;for(let e of r){this.ctx.credits.recordOrbitSources(e);for(let t of e){let e=this.ctx.bodies.bodiesById.get(t.data.id);if(!e){this.ctx.bodies.addBodies([t]),this.ctx.bodies.majorBodies.push(t),a++;continue}e.data=t.data,e.position=t.position,t.orbitElements!==void 0&&(e.orbitElements=t.orbitElements),t.orbitCenter!==void 0&&(e.orbitCenter=t.orbitCenter),i++}}this.ctx.bodies.minorBodyVersion++,console.log(`zone-refresher: ${e.zone} chunk ${t} → ${n} (+${a} ~${i})`)}preloadChunkNeighbors(e,t){let n=Math.max(0,e.currentIdx-1),r=Math.min(e.zoomData.chunks-1,e.currentIdx+1);for(let i=n;i<=r;i++){if(e.preloads.has(i))continue;let n=String(i),r=Promise.all(Array.from({length:e.parts},(r,i)=>this.loader.process(e.zone,e.zoom,i,t,n,e.parentIdType)));e.preloads.set(i,{kind:`pending`,promise:r}),r.then(t=>{e.preloads.get(i)?.kind===`pending`&&e.preloads.set(i,{kind:`ready`,bodies:t})},t=>{console.warn(`zone-refresher: ${e.zone} chunk ${i} preload failed:`,t),e.preloads.get(i)?.kind===`pending`&&e.preloads.delete(i)})}for(let t of e.preloads.keys())(t<n||t>r)&&e.preloads.delete(t)}prefetchTimeNeighbors(e,t){let n=864e5,r=Mb(e.zoomData,new Date(t.getTime()-n)),i=Mb(e.zoomData,new Date(t.getTime()+n));for(let t of new Set([r,i])){if(t===e.currentTime)continue;let n=Fb(e.zoomData,t,e.cap);for(let r=0;r<n;r++)lb.prefetch(e.zone,e.zoom,r,t)}}},Ix,Lx=new Promise(e=>{Ix=e});function Rx(){Ix()}var zx=4;function Bx(){return typeof navigator>`u`?!1:navigator.connection?.saveData===!0}function Vx(){if(typeof navigator>`u`)return!1;if(Bx())return!0;let e=navigator.deviceMemory;return typeof e==`number`&&e>0&&e<=zx}var Hx;function Ux(){return Hx===void 0&&(Hx=typeof window<`u`&&!!window.matchMedia?.(`(pointer: coarse)`).matches),Hx}function Wx(){return typeof window>`u`?1:Math.min(window.devicePixelRatio,2)}var Gx={low:{maxPixelRatio:1.25,shadowMapSize:1024,softShadows:!1,bloomScale:.5,pointBudget:4e5,maxTextureTier:`medium`,maxSkyboxFace:2048},medium:{maxPixelRatio:1.5,shadowMapSize:2048,softShadows:!0,bloomScale:.75,pointBudget:9e5,maxTextureTier:`medium`,maxSkyboxFace:2048},high:{maxPixelRatio:2,shadowMapSize:4096,softShadows:!0,bloomScale:1,pointBudget:1/0,maxTextureTier:`high`,maxSkyboxFace:1/0}};function Kx(){return Vx()?`low`:Jx().maxTextureTier}function qx(){let e=jx().atmosphereCalibration?.tier;return e===`low`||e===`medium`?e:e===`high`||e===`ultra`?`high`:Ux()?Vx()?`low`:`medium`:Vx()?`medium`:`high`}function Jx(){return Gx[qx()]}function Yx(){return typeof window>`u`?1:Math.min(window.devicePixelRatio,Jx().maxPixelRatio)}var Xx=Math.PI/180*ag,Zx=new Hi().setFromAxisAngle(new J(0,0,1),-Math.PI/2).premultiply(new Hi().setFromAxisAngle(new J(0,1,0),Math.PI/2-Xx)).premultiply(new Hi().setFromAxisAngle(new J(1,0,0),-Math.PI/2)),Qx=[`px`,`nx`,`py`,`ny`,`pz`,`nz`];function $x(e,t){if(e.tiers.length===0)return null;let n=[...e.tiers].sort((t,n)=>(e.tier_face_size[n]??0)-(e.tier_face_size[t]??0));for(let r of n)if((e.tier_face_size[r]??1/0)<=t)return r;return n[n.length-1]}function eS(e,t,n){return Yt(`/v1/textures/${e}/${t}_${n}.webp`,`textures`)}async function tS(e,t,n){return Promise.all(Qx.map(async r=>{let i=await fetch(eS(e,t,r),{priority:n});if(!i.ok)throw Error(`Skybox face fetch failed (${i.status}): ${t}_${r}`);let a=await i.blob();return createImageBitmap(a,{imageOrientation:`none`,premultiplyAlpha:`none`})}))}var nS=new Map;function rS(e,t){return`${e}:${t}`}function iS(e,t,n){let r=rS(e,t),i=nS.get(r);return i||(i=tS(e,t,n),nS.set(r,i)),i}function aS(e,t,n){nS.delete(rS(e,t));for(let e of n)e.close()}function oS(e){let t=new Mc(e);return t.colorSpace=Xr,t.needsUpdate=!0,t}function sS(e){return e.tiers.length===0?null:[...e.tiers].sort((t,n)=>(e.tier_face_size[t]??0)-(e.tier_face_size[n]??0))[0]}function cS(e){let t=sS(e);t&&iS(e.id,t).catch(()=>nS.delete(rS(e.id,t)))}var lS=12e3;async function uS(e,t,n){let r=$x(n,Math.min(t.capabilities.maxTextureSize,Jx().maxSkyboxFace));if(!r){console.warn(`Skybox ${n.id}: no tiers declared`);return}let i=sS(n),a={cube:null,bitmaps:null},o=!1;i&&i!==r&&iS(n.id,i).then(t=>{if(o){aS(n.id,i,t);return}a.cube=oS(t),a.bitmaps=t,e.background=a.cube,performance.mark(`sm-skybox-low`)}).catch(()=>{}),r!==i&&await Promise.race([Lx,new Promise(e=>setTimeout(e,lS))]);let s=await iS(n.id,r,r===i?void 0:`low`),c=oS(s);await new Promise(e=>`requestIdleCallback`in window?requestIdleCallback(()=>e(),{timeout:2e3}):setTimeout(e,500)),t.initTexture(c),o=!0;let l=e.background;e.background=c,performance.mark(`sm-skybox-high`),a.cube?.dispose(),l&&l!==a.cube&&l instanceof Mc&&l.dispose(),aS(n.id,r,s),i&&i!==r&&a.bitmaps&&aS(n.id,i,a.bitmaps)}async function dS(e,t,n){if(!n?.layers.skipped.has(`stars`))try{let r=await Lb();if(!r.skybox)return;n&&(n.credits.skybox={source:r.skybox.source,organisation:r.skybox.organisation,license:r.skybox.license,attribution:r.skybox.attribution,description:r.skybox.description}),await uS(e,t,r.skybox)}catch(e){console.warn(`Failed to load skybox:`,e)}}var fS=13;function pS(e,t,n){let r=jx().maxPartsPerZone,i=[],a=[];for(let[o,s]of Object.entries(e.position.zones)){if(o===`major`||o===`moons`||o===`spacecraft`||Eb(s)||n.skipsZone(o))continue;let e=s.parent_id_type??`naif`;for(let{zoom:n,data:c}of Ob(s)){if(c.shape===`chunked`)continue;let s=Sb(c)?Mb(c,t):null,l=Sb(c)&&s!==null?Fb(c,s,r):r>0?Math.min(c.parts,r):c.parts;for(let t=0;t<l;t++){let r={zone:o,zoom:n,part:t,time:s,parentIdType:e};n!==null&&n>=1&&t>=fS?a.push(r):i.push(r)}}}return{eager:i,deferred:a}}async function mS(e,t,n){let r=zb(e);for(let e of r.keys())n.skipsZone(e)&&r.delete(e);if(r.size===0)return null;console.log(`ProbeStore: ${r.size} zone(s) from metadata:\n`+Array.from(r).map(([e,t])=>` ${e}: chunks=${t.chunks} chunk_days=${t.chunk_days} fit_center=naif-${t.fit_center_naif_id} float64=${t.float64_coeffs}`).join(`
|
|
4052
|
-
`));let i=Array.from(r).filter(([,e])=>e.fit_center_naif_id===void 0);i.length>0&&console.warn(`ProbeStore: ${i.length} zone(s) missing fit_center_naif_id in metadata — re-export to refresh: ${i.map(([e])=>e).join(`, `)}`);let a=new Qb(r);return await a.ensure(t).done,a}async function hS(e,t,n,r,i,a){let o=[],s=null;e.chebStore&&(s=await Vv(),o.push(...t.processChebyshev(r,s))),e.probeStore&&(s??=await Vv(),a&&e.probeStore.registerCarried(a),o.push(...t.processProbes(e.probeStore,r,s)));let c=n.position.zones.major;if(c&&Db(c))for(let e of[1,2]){let n=c.zooms[String(e)];if(n&&xb(n))for(let i=0;i<n.parts;i++)o.push(...await t.process(`major`,e,i,r))}let l=e.layers.skipsZone(`moons`)?void 0:n.position.zones.moons,u=l?kb(l):void 0,d=u&&Cb(u)?String(Tb(u,i)):null;return u&&o.push(...await t.process(`moons`,null,0,r,d)),gS(o)}function gS(e){let t=new Map,n=[];for(let r of e){let e=r.data.id;t.has(e)?n.push(e):t.set(e,r)}return n.length>0&&console.warn(`majors: ${n.length} duplicate id(s) in phase 1, kept first:`,n),[...t.values()]}async function _S(e,t,n){performance.mark(`sm-load-start`),U_.reset(),X_().catch(e=>console.warn(`scene-load: systems-global (GMs/nutation) failed to load:`,e));let r=hb().catch(e=>console.warn(`scene-load: atmospheres failed to load — rendering without shells:`,e)),i=Ng(t),a=Lb();Vv().catch(()=>{}),a.then(t=>{let n=t.position.zones.moons;if(!n||e.layers.skipsZone(`moons`))return;let r=kb(n);r&&xb(r)&&lb.prefetch(`moons`,null,0,null)}),a.then(t=>{t.skybox&&!e.layers.skipped.has(`stars`)&&cS(t.skybox)});let o=a.then(n=>pS(n,t,e.layers)),s=a.then(async t=>{let n=Rb(t);for(let t of n.keys())e.layers.skipsZone(t)&&n.delete(t);if(n.size===0)return null;let r=new qb(n);return await r.ensure(i).done,r}),c=a.then(t=>mS(t,i,e.layers)),l=hx(n),u=await a;U_.reach(`metadata`),e.chebStore=await s,e.probeStore=await c,U_.reach(`ephemeris`);let d=new lb(e.chebStore);e.probeStore&&(e.probeStore.fitCenterUsable=t=>(e.chebStore?.has(t)??!1)||(e.hasMeshBody?.(t)??!1)||d.positions.has(t));let f=await hS(e,d,u,t,i,await l);U_.reach(`majors`),await r,e.bodies.addBodies(f),e.credits.recordOrbitSources(f);let p=await Vv();U_.reach(`labels`);let m=new Map,h=!1,g=()=>{h=!0},_=()=>{let t=h;h=!1,e.bodies.flushMinor(t)};if(n&&!e.getBody(n)){let r=await Cx(n,t,d);wx(e,r,p,{onPlaceholder:e=>m.set(e.data.id,e)})>0&&g(),r.length>0&&_()}e.bodies.majorBodies=f.filter(e=>e.data.objectType!==W.BARYCENTER&&e.data.objectType!==W.LAGRANGE_POINT&&e.data.orbitalSource!==U.SPICE_PROBE),U_.reach(`done`),e.loading=!1,performance.mark(`sm-majors-done`);let{eager:v,deferred:y}=await o,b=v.filter(e=>e.zone===`small_body_moons`),x=v.filter(e=>e.zone!==`small_body_moons`);for(let e of b)try{await d.seedNeededParents(e.zone,e.zoom,e.part,e.time,e.parentIdType)}catch(t){console.warn(`scene-load: seedNeededParents failed for ${e.zone} part ${e.part}:`,t)}e.bodies.minorStreaming=!0;let S=setInterval(_,500),C=async(t,n,r)=>{e.credits.recordOrbitSource(n.source),n.rowCount!==0&&(await e.bodies.asteroidBucket(t,p).addChunk(n,r)>0&&g(),e.bodies.dirtyAsteroidZones.add(t))},w=(t,n)=>{e.credits.recordOrbitSources(n);let r=t===`earth`,i=r?e.earthSatFilter:null,a=r?e.earthTypeFilter:null;for(let t of n){if(i&&!i.has(t.data.id)||a&&!a.has(t.data.objectType))continue;let n=m.get(t.data.id);if(n){n.data=t.data,n.position=t.position,t.orbitElements!==void 0&&(n.orbitElements=t.orbitElements),t.orbitCenter!==void 0&&(n.orbitCenter=t.orbitCenter),m.delete(t.data.id),e.bodies.dirtySpacecraftGroups.add(t.data.parentId);continue}let r=t.data.parentId,o=e.bodies.spacecraftBucket(r);o.has(t.data.id)||g(),o.set(t.data.id,t),e.bodies.dirtySpacecraftGroups.add(r)}},T=(t,n)=>{e.credits.recordOrbitSources(n);let r=e.bodies.asteroidBucket(t,p);for(let e of n)r.addPlaceholder(e),g();e.bodies.dirtyAsteroidZones.add(t)},E=x.filter(e=>e.zone.startsWith(`small_bodies/`)),D=x.filter(e=>!e.zone.startsWith(`small_bodies/`)),O=new Set,k=(e,t)=>n=>{O.add(e),console.warn(`scene-load: ${e} part ${t} failed (skipped):`,n)};try{await Promise.all([...E.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.fetchMinorColumns(e,n,r,t,i,a).then(t=>C(e,t,a)).catch(k(e,r))),...D.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.process(e,n,r,t,i,a,new Set(m.keys()),`high`).then(t=>w(e,t)).catch(k(e,r)))]),await Promise.all(b.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.process(e,n,r,t,i,a).then(t=>T(e,t)).catch(k(e,r))))}finally{clearInterval(S),e.bodies.minorStreaming=!1,_(),performance.mark(`sm-minors-done`),Rx()}if(y.length>0&&Vx())console.info(`Low-end device: skipping ${y.length} deferred minor-belt parts to conserve memory`);else if(y.length>0){e.bodies.minorStreaming=!0;let n=setInterval(_,1e3);try{await Promise.all(y.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.fetchMinorColumns(e,n,r,t,i,a,`low`).then(t=>C(e,t,a)).catch(k(e,r))))}finally{clearInterval(n),e.bodies.minorStreaming=!1,_(),performance.mark(`sm-deferred-done`)}}try{e.refresher=new Fx(e,await a,d,t);for(let t of O)e.refresher.invalidateZone(t)}catch(e){console.error(`scene-load: ZoneRefresher init failed; hot-reload disabled:`,e)}}var vS=ix(async()=>(await Lb(),Yt(`/v1/membership/earth.json.gz`,`membership`)),{onMissing:()=>({}),error:e=>`fetchEarthMembership: ${e.status} ${e.statusText}`});async function yS(e){let t=await vS();return new Set(t[e]??[])}function bS(e,t=c()){return fx(lx,e,t)}var xS={[cv]:new Set([W.SPACECRAFT]),[lv]:new Set([W.DEBRIS])},SS=class{bodies=new I_;credits=new Cn;layers=new Cv;visibility=new Lv(this.bodies,()=>this.probeStore,()=>this.earthSatFilter,()=>this.smallBodyFilter,()=>this.layers);#e=qe(!0);get loading(){return Ut(this.#e)}set loading(e){Je(this.#e,e,!0)}#t=qe(null);get error(){return Ut(this.#t)}set error(e){Je(this.#t,e,!0)}onDataStale=null;constructor(){}chebStore=null;probeStore=null;refresher=null;hasMeshBody=null;earthSatFilter=null;earthSatFilterSlug=null;earthTypeFilter=null;smallBodyFilter=null;missionMemberIds=null;currentGroupSlug=null;groupFilterListeners=new Set;smallBodyFilterListeners=new Set;earthSatRolloverListeners=new Set;onGroupFilterChange(e){return this.groupFilterListeners.add(e),()=>this.groupFilterListeners.delete(e)}onSmallBodyFilterChange(e){return this.smallBodyFilterListeners.add(e),()=>this.smallBodyFilterListeners.delete(e)}onEarthSatRollover(e){return this.earthSatRolloverListeners.add(e),()=>this.earthSatRolloverListeners.delete(e)}notifyEarthSatRollover(){for(let e of this.earthSatRolloverListeners)e()}getBody(e,t){return this.bodies.getBody(e,t)}isMemberOfActiveGroup(e){if(this.missionMemberIds?.has(e)===!0||this.earthSatFilter?.has(e)===!0)return!0;let t=this.earthTypeFilter;if(t){let n=this.bodies.getBody(e)?.data.objectType;if(n!==void 0&&t.has(n))return!0}let n=this.smallBodyFilter;return n===null?!1:Dv(this.bodies,e,n)}async load(e,t){try{await _S(this,e,t)}catch(e){throw this.loading=!1,this.error=e instanceof Error?e.message:String(e),console.error(`[scene-load]`,e),e}}refreshTick(e){this.refresher?.tick(e)}async ensureBody(e,t){await this.refresher?.ensureBody(e,t)}async applyGroupFilter(e){if(e===this.currentGroupSlug)return;if(this.currentGroupSlug=e,e?.startsWith(`mission-`)){let t=await bS(e);if(e!==this.currentGroupSlug)return;this.missionMemberIds=new Set((t.global?.notable_members??[]).map(e=>e.id).filter(e=>!!e))}else this.missionMemberIds=null;let t=e?await this.resolveIndexEntry(e):null;if(e!==this.currentGroupSlug)return;let n=this.resolveSmallBodyFilter(e,t?.applies_to,t?.n),r=t?.applies_to===`earth_sat`?e:null,i=xS[e??``]??null;if(!pv(this.smallBodyFilter,n)){this.smallBodyFilter=n;for(let e of this.smallBodyFilterListeners)e(n)}if(r===this.earthSatFilterSlug&&i===this.earthTypeFilter)return;let a=r?await yS(r):null;if(e===this.currentGroupSlug){this.earthSatFilter=a,this.earthSatFilterSlug=r,this.earthTypeFilter=i;for(let e of this.groupFilterListeners)e(a);this.loading||(this.bodies.spacecraftByParent.delete(p_),this.bodies.dirtySpacecraftGroups.add(p_),this.bodies.minorBodyVersion++,this.refresher?.invalidateZone(`earth`))}}resolveSmallBodyFilter(e,t,n){if(e===ov)return{kind:`category`,category:`asteroid`};if(e===sv)return{kind:`category`,category:`comet`};if(e===null||t!==`small_body`)return null;if(e.startsWith(`class-`))return{kind:`class`,className:e.slice(rv.length)};if(e.startsWith(`flag-`)){let t=e.slice(iv.length),r=uv[t];return r===void 0?null:{kind:`flag`,flag:t,mask:r,n:n??0}}return null}async resolveIndexEntry(e){try{return(await hv())[e]??null}catch{return null}}},CS=400,wS=class{#e=qe(0);get jd(){return Ut(this.#e)}set jd(e){Je(this.#e,e,!0)}#t=qe(1);get timeScale(){return Ut(this.#t)}set timeScale(e){Je(this.#t,e,!0)}#n=qe(1);get direction(){return Ut(this.#n)}set direction(e){Je(this.#n,e,!0)}seeked=!1;#r=qe(0);get jumps(){return Ut(this.#r)}set jumps(e){Je(this.#r,e,!0)}#i=qe(0);get settledJd(){return Ut(this.#i)}set settledJd(e){Je(this.#i,e,!0)}#a=qe(!1);get live(){return Ut(this.#a)}set live(e){Je(this.#a,e,!0)}lastRealMs=0;prevScale=1;stops=null;settleTimer=null;constructor(e,t=!1){this.jd=e,this.settledJd=e,this.live=t,this.lastRealMs=performance.now()}tick(e){let t=e-this.lastRealMs;if(this.lastRealMs=e,this.timeScale===0)return;let n=this.jd+t/jg*this.timeScale,r=this.stops;if(r!==null){if(this.timeScale>0&&r.forwardJd!==null&&n>=r.forwardJd&&this.jd<r.forwardJd){this.jd=r.forwardJd,this.pause(),r.onHit(r.forwardJd);return}if(this.timeScale<0&&r.backwardJd!==null&&n<=r.backwardJd&&this.jd>r.backwardJd){this.jd=r.backwardJd,this.pause(),r.onHit(r.backwardJd);return}}this.jd=n}setBoundaryStops(e){this.stops=e}setTimeScale(e){let t=e*this.direction;t!==0&&(this.prevScale=t),this.timeScale=t,t!==1&&(this.live=!1),this.lastRealMs=performance.now()}toggleDirection(){this.direction=this.direction===1?-1:1,this.timeScale=-this.timeScale,this.prevScale=-this.prevScale,this.live=!1,this.lastRealMs=performance.now()}setJD(e){this.jd=e,this.seeked=!0,this.live=!1,this.lastRealMs=performance.now(),this.settleAfterPause()}jumpTo(e){this.setJD(e),this.jumps++,this.settle()}settle(){this.settleTimer!==null&&clearTimeout(this.settleTimer),this.settleTimer=null,this.settledJd=this.jd}settleAfterPause(){this.settleTimer!==null&&clearTimeout(this.settleTimer),this.settleTimer=null,!this.playing&&(this.settleTimer=setTimeout(()=>this.settle(),CS))}sweepTo(e){this.jd=e,this.live=!1,this.lastRealMs=performance.now()}pause(){this.timeScale!==0&&(this.prevScale=this.timeScale),this.timeScale=0,this.live=!1,this.settle()}play(){this.timeScale===0&&(this.timeScale=this.prevScale||1,this.lastRealMs=performance.now())}now(){this.jumpTo(Ng(new Date)),this.live=this.timeScale===1}get playing(){return this.timeScale!==0}get date(){return Pg(this.jd)}setDate(e){this.jumpTo(Ng(e))}},TS={type:`change`},ES={type:`start`},DS={type:`end`},OS=new _s,kS=new oc,AS=Math.cos(70*Vi.DEG2RAD),jS=new J,MS=2*Math.PI,NS={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},PS=1e-6,FS=class extends Kd{constructor(e,t=null){super(e,t),this.state=NS.NONE,this.target=new J,this.cursor=new J,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:`ArrowLeft`,UP:`ArrowUp`,RIGHT:`ArrowRight`,BOTTOM:`ArrowDown`},this.mouseButtons={LEFT:wn.ROTATE,MIDDLE:wn.DOLLY,RIGHT:wn.PAN},this.touches={ONE:Tn.ROTATE,TWO:Tn.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle=`auto`,this._domElementKeyEvents=null,this._lastPosition=new J,this._lastQuaternion=new Hi,this._lastTargetPosition=new J,this._quat=new Hi().setFromUnitVectors(e.up,new J(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Vd,this._sphericalDelta=new Vd,this._scale=1,this._panOffset=new J,this._rotateStart=new q,this._rotateEnd=new q,this._rotateDelta=new q,this._panStart=new q,this._panEnd=new q,this._panDelta=new q,this._dollyStart=new q,this._dollyEnd=new q,this._dollyDelta=new q,this._dollyDirection=new J,this._mouse=new q,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=LS.bind(this),this._onPointerDown=IS.bind(this),this._onPointerUp=RS.bind(this),this._onContextMenu=GS.bind(this),this._onMouseWheel=VS.bind(this),this._onKeyDown=HS.bind(this),this._onTouchStart=US.bind(this),this._onTouchMove=WS.bind(this),this._onMouseDown=zS.bind(this),this._onMouseMove=BS.bind(this),this._interceptControlDown=KS.bind(this),this._interceptControlUp=qS.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e===`grab`?this.domElement.style.cursor=`grab`:this.domElement.style.cursor=`auto`}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointercancel`,this._onPointerUp),this.domElement.addEventListener(`contextmenu`,this._onContextMenu),this.domElement.addEventListener(`wheel`,this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener(`keydown`,this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction=`none`}disconnect(){this.domElement.removeEventListener(`pointerdown`,this._onPointerDown),this.domElement.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.removeEventListener(`pointerup`,this._onPointerUp),this.domElement.removeEventListener(`pointercancel`,this._onPointerUp),this.domElement.removeEventListener(`wheel`,this._onMouseWheel),this.domElement.removeEventListener(`contextmenu`,this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener(`keydown`,this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=`auto`}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener(`keydown`,this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener(`keydown`,this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(TS),this.update(),this.state=NS.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;jS.copy(t).sub(this.target),jS.applyQuaternion(this._quat),this._spherical.setFromVector3(jS),this.autoRotate&&this.state===NS.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=MS:n>Math.PI&&(n-=MS),r<-Math.PI?r+=MS:r>Math.PI&&(r-=MS),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let e=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=e!=this._spherical.radius}if(jS.setFromSpherical(this._spherical),jS.applyQuaternion(this._quatInverse),t.copy(this.target).add(jS),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let e=null;if(this.object.isPerspectiveCamera){let t=jS.length();e=this._clampDistance(t*this._scale);let n=t-e;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),i=!!n}else if(this.object.isOrthographicCamera){let t=new J(this._mouse.x,this._mouse.y,0);t.unproject(this.object);let n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=n!==this.object.zoom;let r=new J(this._mouse.x,this._mouse.y,0);r.unproject(this.object),this.object.position.sub(r).add(t),this.object.updateMatrixWorld(),e=jS.length()}else console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.`),this.zoomToCursor=!1;e!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(OS.origin.copy(this.object.position),OS.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(OS.direction))<AS?this.object.lookAt(this.target):(kS.setFromNormalAndCoplanarPoint(this.object.up,this.target),OS.intersectPlane(kS,this.target))))}else if(this.object.isOrthographicCamera){let e=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),e!==this.object.zoom&&(this.object.updateProjectionMatrix(),i=!0)}return this._scale=1,this._performCursorZoom=!1,i||this._lastPosition.distanceToSquared(this.object.position)>PS||8*(1-this._lastQuaternion.dot(this.object.quaternion))>PS||this._lastTargetPosition.distanceToSquared(this.target)>PS?(this.dispatchEvent(TS),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e===null?MS/60/60*this.autoRotateSpeed:MS/60*this.autoRotateSpeed*e}_getZoomScale(e){let t=Math.abs(e*.01);return .95**(this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){jS.setFromMatrixColumn(t,0),jS.multiplyScalar(-e),this._panOffset.add(jS)}_panUp(e,t){this.screenSpacePanning===!0?jS.setFromMatrixColumn(t,1):(jS.setFromMatrixColumn(t,0),jS.crossVectors(this.object.up,jS)),jS.multiplyScalar(e),this._panOffset.add(jS)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;jS.copy(r).sub(this.target);let i=jS.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/n.clientHeight,this.object.matrix),this._panUp(2*t*i/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),r=e-n.left,i=t-n.top,a=n.width,o=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(i/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(MS*this._rotateDelta.x/t.clientHeight),this._rotateUp(MS*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(MS*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-MS*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(MS*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-MS*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(MS*this._rotateDelta.x/t.clientHeight),this._rotateUp(MS*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,i),this._dollyDelta.set(0,(this._dollyEnd.y/this._dollyStart.y)**+this.zoomSpeed),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new q,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function IS(e){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.addEventListener(`pointerup`,this._onPointerUp)),!this._isTrackingPointer(e)&&(this._addPointer(e),e.pointerType===`touch`?this._onTouchStart(e):this._onMouseDown(e),this._cursorStyle===`grab`&&(this.domElement.style.cursor=`grabbing`)))}function LS(e){this.enabled!==!1&&(e.pointerType===`touch`?this._onTouchMove(e):this._onMouseMove(e))}function RS(e){switch(this._removePointer(e),this._pointers.length){case 0:this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.removeEventListener(`pointerup`,this._onPointerUp),this.dispatchEvent(DS),this.state=NS.NONE,this._cursorStyle===`grab`&&(this.domElement.style.cursor=`grab`);break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function zS(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case wn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=NS.DOLLY;break;case wn.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=NS.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=NS.ROTATE}break;case wn.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=NS.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=NS.PAN}break;default:this.state=NS.NONE}this.state!==NS.NONE&&this.dispatchEvent(ES)}function BS(e){switch(this.state){case NS.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case NS.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case NS.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function VS(e){this.enabled===!1||this.enableZoom===!1||this.state!==NS.NONE||(e.preventDefault(),this.dispatchEvent(ES),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(DS))}function HS(e){this.enabled!==!1&&this._handleKeyDown(e)}function US(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Tn.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=NS.TOUCH_ROTATE;break;case Tn.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=NS.TOUCH_PAN;break;default:this.state=NS.NONE}break;case 2:switch(this.touches.TWO){case Tn.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=NS.TOUCH_DOLLY_PAN;break;case Tn.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=NS.TOUCH_DOLLY_ROTATE;break;default:this.state=NS.NONE}break;default:this.state=NS.NONE}this.state!==NS.NONE&&this.dispatchEvent(ES)}function WS(e){switch(this._trackPointer(e),this.state){case NS.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case NS.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case NS.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case NS.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=NS.NONE}}function GS(e){this.enabled!==!1&&e.preventDefault()}function KS(e){e.key===`Control`&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}function qS(e){e.key===`Control`&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}var{PI:JS,sin:YS,cos:XS,asin:ZS,atan2:QS,sqrt:$S}=Math,eC=180/JS,tC=JS/180;function nC(e,t,n){let[r,i,a]=e,[o,s,c,l]=n?[-t[0],-t[1],-t[2],t[3]]:t,u=l*r+s*a-c*i,d=l*i+c*r-o*a,f=l*a+o*i-s*r,p=-o*r-s*i-c*a;return[u*l+p*-o+d*-c-f*-s,d*l+p*-s+f*-o-u*-c,f*l+p*-c+u*-s-d*-o]}function rC(e,t,n){let r=e[0]-t[0],i=e[1]-t[1],a=e[2]-t[2],o=$S(r*r+i*i+a*a);return n&&([r,i,a]=nC([r,i,a],n,!0)),{latitude:ZS(i/o)*eC,longitude:n?QS(-a,r)*eC:QS(r,a)*eC,distance:o}}function iC(e,t,n,r,i){let a=t*tC,o=n*tC,s,c,l;if(i){let e=[r*XS(a)*XS(o),r*YS(a),-r*XS(a)*YS(o)];[s,c,l]=nC(e,i,!1)}else s=r*XS(a)*YS(o),c=r*YS(a),l=r*XS(a)*XS(o);return[e[0]+s,e[1]+c,e[2]+l]}function aC(e,t,n,r){let i=e[0]-t[0],a=e[2]-t[2],o=$S(i*i+a*a);o>0?(i/=o,a/=o):(i=0,a=1);let s=n*tC,c=XS(s);return[r*c*i,r*YS(s),r*c*a]}function oC(e){let t=(e+180)%360-180;return t<=-180?t+360:t}function sC(e,t,n){if(t===void 0&&n===void 0)return e;let r=t===void 0?-180:oC(t),i=r===180?-180:r,a=n===void 0?180:oC(n);if(i<=a?e>=i&&e<=a:e>=i||e<=a)return e;let o=(e,t)=>Math.abs(oC(e-t));return o(e,i)<=o(e,a)?i:a}var cC=p_,lC=Math.PI/180,uC=2451545,dC=36525;function fC(e,t,n){let r=t-uC,i=r/dC,a=e.pole_ra_0+e.pole_ra_1*i,o=e.pole_dec_0+e.pole_dec_1*i,s=e.w0+e.w1*r+e.w2*r*r;if(n){let{ra:e,dec:t,pm:r,angles:c}=n,l=Math.min(c.length>>1,Math.max(e.length,t.length,r.length));for(let n=0;n<l;n++){let l=(c[2*n]+c[2*n+1]*i)*lC,u=Math.sin(l);n<e.length&&(a+=e[n]*u),n<t.length&&(o+=t[n]*Math.cos(l)),n<r.length&&(s+=r[n]*u)}}let c=a*lC,l=o*lC,u=Math.cos(l),d=dg(u*Math.cos(c),u*Math.sin(c),Math.sin(l),new J).normalize(),f=dg(-Math.sin(c),Math.cos(c),0,new J).normalize(),p=new J().crossVectors(f,d).normalize(),m=new Hi().setFromRotationMatrix(new Y().makeBasis(f,d,p));return new Hi().setFromAxisAngle(d,s*lC).multiply(m)}function pC(e,t,n,r){e.quaternion.copy(fC(t,n,r))}var mC=new J(0,1,0),hC=new J;function gC(e,t,n){hC.set(t[0]-n[0],t[1]-n[1],t[2]-n[2]),!(hC.lengthSq()<1e-20)&&(hC.normalize(),e.quaternion.setFromUnitVectors(mC,hC))}function _C(e,t){e.quaternion.setFromUnitVectors(mC,t)}var vC={"+x":new J(1,0,0),"-x":new J(-1,0,0),"+y":new J(0,1,0),"-y":new J(0,-1,0),"+z":new J(0,0,1),"-z":new J(0,0,-1)};function yC(e){let t=[];for(let[n,r]of Object.entries(e)){let e=vC[n],i=vC[r];if(!e||!i)return console.warn(`frame_map: invalid axis pair ${n}→${r}; ignoring map`),null;t.push([e,i])}if(t.length<1||t.length>2)return console.warn(`frame_map: expected 1–2 axis pairs, got ${t.length}; ignoring map`),null;if(t.length===1)return new Hi().setFromUnitVectors(t[0][0],t[0][1]);let[[n,r],[i,a]]=t;if(n.dot(i)!==0||r.dot(a)!==0)return console.warn(`frame_map: the two pairs must use perpendicular axes; ignoring map`),null;let o=new J().crossVectors(n,i),s=new J().crossVectors(r,a),c=new Y().makeBasis(r,a,s),l=new Y().makeBasis(n,i,o).transpose();return new Hi().setFromRotationMatrix(c.multiply(l))}var bC=new J,xC=new J,SC=new J,CC=new J,wC=new J,TC=new J,EC=new J,DC=new J,OC=new Y,kC=new Y;function AC(e,t,n){if(e===`parent`)n.set(t.parentPos[0]-t.bodyPos[0],t.parentPos[1]-t.bodyPos[1],t.parentPos[2]-t.bodyPos[2]);else if(e===`sun`){if(!t.sunPos)return!1;n.set(t.sunPos[0]-t.bodyPos[0],t.sunPos[1]-t.bodyPos[1],t.sunPos[2]-t.bodyPos[2])}else{if(!t.velocity)return!1;n.set(t.velocity[0],t.velocity[1],t.velocity[2])}return n.lengthSq()<1e-20?!1:(n.normalize(),!0)}function jC(e,t,n){if(!AC(t.primary.target,n,bC))return;let r=vC[t.primary.axis],i=t.secondary;if(!i||!AC(i.target,n,xC)){e.quaternion.setFromUnitVectors(r,bC);return}if(wC.crossVectors(r,vC[i.axis]),DC.crossVectors(bC,xC),wC.lengthSq()<1e-20||DC.lengthSq()<1e-20){e.quaternion.setFromUnitVectors(r,bC);return}wC.normalize(),DC.normalize(),SC.copy(r),TC.copy(bC),CC.crossVectors(wC,SC),EC.crossVectors(DC,TC),OC.makeBasis(TC,EC,DC),kC.makeBasis(SC,CC,wC).transpose(),OC.multiply(kC),e.quaternion.setFromRotationMatrix(OC)}function MC(e,t){let n=e,r=n.userData.shaderMods??=[];r.includes(t)||(r.push(t),e.customProgramCacheKey=()=>r.join(`|`))}function NC(e,t,n){let r=e.onBeforeCompile;e.onBeforeCompile=(e,t)=>{r?.(e,t),n(e,t)},MC(e,t),e.needsUpdate=!0}var PC={uSunDir:{value:new J(1,0,0)},uSunAngularRadius:{value:0},uOccluderCount:{value:0},uOccluders:{value:Array.from({length:32},()=>new sa)}},FC=`
|
|
4050
|
+
}`,nh=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Ic(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new fu({vertexShader:eh,fragmentShader:th,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new As(new $l(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},rh=class extends mi{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=typeof XRWebGLBinding<`u`,h=new nh,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new q,C=null,w=new sd;w.viewport=new sa;let T=new sd;T.viewport=new sa;let E=[w,T],D=new Sd,O=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return t===void 0&&(t=new Va,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new Va,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new Va,b[e]=t),t.getHandSpace()};function A(e){let t=x.indexOf(e.inputSource);if(t===-1)return;let n=b[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function j(){r.removeEventListener(`select`,A),r.removeEventListener(`selectstart`,A),r.removeEventListener(`selectend`,A),r.removeEventListener(`squeeze`,A),r.removeEventListener(`squeezestart`,A),r.removeEventListener(`squeezeend`,A),r.removeEventListener(`end`,j),r.removeEventListener(`inputsourceschange`,M);for(let e=0;e<b.length;e++){let t=x[e];t!==null&&(x[e]=null,b[e].disconnect(t))}O=null,k=null,h.reset();for(let e in g)delete g[e];e.setRenderTarget(v),f=null,d=null,u=null,r=null,y=null,ae.stop(),n.isPresenting=!1,e.setPixelRatio(C),e.setSize(S.width,S.height,!1),n.dispatchEvent({type:`sessionend`})}this.setFramebufferScaleFactor=function(e){i=e,n.isPresenting===!0&&G(`WebXRManager: Cannot change framebuffer scale while presenting.`)},this.setReferenceSpaceType=function(e){o=e,n.isPresenting===!0&&G(`WebXRManager: Cannot change reference space type while presenting.`)},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(e){c=e},this.getBaseLayer=function(){return d===null?f:d},this.getBinding=function(){return u===null&&m&&(u=new XRWebGLBinding(r,t)),u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(l){if(r=l,r!==null){if(v=e.getRenderTarget(),r.addEventListener(`select`,A),r.addEventListener(`selectstart`,A),r.addEventListener(`selectend`,A),r.addEventListener(`squeeze`,A),r.addEventListener(`squeezestart`,A),r.addEventListener(`squeezeend`,A),r.addEventListener(`end`,j),r.addEventListener(`inputsourceschange`,M),_.xrCompatible!==!0&&await t.makeXRCompatible(),C=e.getPixelRatio(),e.getSize(S),m&&`createProjectionLayer`in XRWebGLBinding.prototype){let n=null,a=null,o=null;_.depth&&(o=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=_.stencil?$n:Qn,a=_.stencil?Kn:Vn);let s={colorFormat:t.RGBA8,depthFormat:o,scaleFactor:i};u=this.getBinding(),d=u.createProjectionLayer(s),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),y=new la(d.textureWidth,d.textureHeight,{format:Zn,type:In,depthTexture:new Pc(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{let n={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:i};f=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new la(f.framebufferWidth,f.framebufferHeight,{format:Zn,type:In,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(s),c=null,a=await r.requestReferenceSpace(o),ae.setContext(r),ae.start(),n.isPresenting=!0,n.dispatchEvent({type:`sessionstart`})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return h.getDepthTexture()};function M(e){for(let t=0;t<e.removed.length;t++){let n=e.removed[t],r=x.indexOf(n);r>=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t<e.added.length;t++){let n=e.added[t],r=x.indexOf(n);if(r===-1){for(let e=0;e<b.length;e++)if(e>=x.length){x.push(n),r=e;break}else if(x[e]===null){x[e]=n,r=e;break}if(r===-1)break}let i=b[r];i&&i.connect(n)}}let ee=new J,N=new J;function te(e,t,n){ee.setFromMatrixPosition(t.matrixWorld),N.setFromMatrixPosition(n.matrixWorld);let r=ee.distanceTo(N),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function ne(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;h.texture!==null&&(h.depthNear>0&&(t=h.depthNear),h.depthFar>0&&(n=h.depthFar)),D.near=T.near=w.near=t,D.far=T.far=w.far=n,(O!==D.near||k!==D.far)&&(r.updateRenderState({depthNear:D.near,depthFar:D.far}),O=D.near,k=D.far),D.layers.mask=e.layers.mask|6,w.layers.mask=D.layers.mask&-5,T.layers.mask=D.layers.mask&-3;let i=e.parent,a=D.cameras;ne(D,i);for(let e=0;e<a.length;e++)ne(a[e],i);a.length===2?te(D,w,T):D.projectionMatrix.copy(w.projectionMatrix),re(e,D,i)};function re(e,t,n){n===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=vi*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}this.getCamera=function(){return D},this.getFoveation=function(){if(!(d===null&&f===null))return s},this.setFoveation=function(e){s=e,d!==null&&(d.fixedFoveation=e),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=e)},this.hasDepthSensing=function(){return h.texture!==null},this.getDepthSensingMesh=function(){return h.getMesh(D)},this.getCameraTexture=function(e){return g[e]};let P=null;function ie(t,i){if(l=i.getViewerPose(c||a),p=i,l!==null){let t=l.views;f!==null&&(e.setRenderTargetFramebuffer(y,f.framebuffer),e.setRenderTarget(y));let i=!1;t.length!==D.cameras.length&&(D.cameras.length=0,i=!0);for(let n=0;n<t.length;n++){let r=t[n],a=null;if(f!==null)a=f.getViewport(r);else{let t=u.getViewSubImage(d,r);a=t.viewport,n===0&&(e.setRenderTargetTextures(y,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(y))}let o=E[n];o===void 0&&(o=new sd,o.layers.enable(n),o.viewport=new sa,E[n]=o),o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.projectionMatrix.fromArray(r.projectionMatrix),o.projectionMatrixInverse.copy(o.projectionMatrix).invert(),o.viewport.set(a.x,a.y,a.width,a.height),n===0&&(D.matrix.copy(o.matrix),D.matrix.decompose(D.position,D.quaternion,D.scale)),i===!0&&D.cameras.push(o)}let a=r.enabledFeatures;if(a&&a.includes(`depth-sensing`)&&r.depthUsage==`gpu-optimized`&&m){u=n.getBinding();let e=u.getDepthInformation(t[0]);e&&e.isValid&&e.texture&&h.init(e,r.renderState)}if(a&&a.includes(`camera-access`)&&m){e.state.unbindTexture(),u=n.getBinding();for(let e=0;e<t.length;e++){let n=t[e].camera;if(n){let e=g[n];e||(e=new Ic,g[n]=e);let t=u.getCameraImage(n);e.sourceTexture=t}}}}for(let e=0;e<b.length;e++){let t=x[e],n=b[e];t!==null&&n!==void 0&&n.update(t,i,c||a)}P&&P(t,i),i.detectedPlanes&&n.dispatchEvent({type:`planesdetected`,data:i}),p=null}let ae=new Yd;ae.setAnimationLoop(ie),this.setAnimationLoop=function(e){P=e},this.dispose=function(){}}},ih=new xa,ah=new Y;function oh(e,t){function n(e,t){e.matrixAutoUpdate===!0&&e.updateMatrix(),t.value.copy(e.matrix)}function r(t,n){n.color.getRGB(t.fogColor.value,cu(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)}function i(e,t,n,r,i){t.isMeshBasicMaterial?a(e,t):t.isMeshLambertMaterial?(a(e,t),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)):t.isMeshToonMaterial?(a(e,t),d(e,t)):t.isMeshPhongMaterial?(a(e,t),u(e,t),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)):t.isMeshStandardMaterial?(a(e,t),f(e,t),t.isMeshPhysicalMaterial&&p(e,t,i)):t.isMeshMatcapMaterial?(a(e,t),m(e,t)):t.isMeshDepthMaterial?a(e,t):t.isMeshDistanceMaterial?(a(e,t),h(e,t)):t.isMeshNormalMaterial?a(e,t):t.isLineBasicMaterial?(o(e,t),t.isLineDashedMaterial&&s(e,t)):t.isPointsMaterial?c(e,t,n,r):t.isSpriteMaterial?l(e,t):t.isShadowMaterial?(e.color.value.copy(t.color),e.opacity.value=t.opacity):t.isShaderMaterial&&(t.uniformsNeedUpdate=!1)}function a(e,r){e.opacity.value=r.opacity,r.color&&e.diffuse.value.copy(r.color),r.emissive&&e.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(e.map.value=r.map,n(r.map,e.mapTransform)),r.alphaMap&&(e.alphaMap.value=r.alphaMap,n(r.alphaMap,e.alphaMapTransform)),r.bumpMap&&(e.bumpMap.value=r.bumpMap,n(r.bumpMap,e.bumpMapTransform),e.bumpScale.value=r.bumpScale,r.side===1&&(e.bumpScale.value*=-1)),r.normalMap&&(e.normalMap.value=r.normalMap,n(r.normalMap,e.normalMapTransform),e.normalScale.value.copy(r.normalScale),r.side===1&&e.normalScale.value.negate()),r.displacementMap&&(e.displacementMap.value=r.displacementMap,n(r.displacementMap,e.displacementMapTransform),e.displacementScale.value=r.displacementScale,e.displacementBias.value=r.displacementBias),r.emissiveMap&&(e.emissiveMap.value=r.emissiveMap,n(r.emissiveMap,e.emissiveMapTransform)),r.specularMap&&(e.specularMap.value=r.specularMap,n(r.specularMap,e.specularMapTransform)),r.alphaTest>0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,ih.copy(o),ih.x*=-1,ih.y*=-1,ih.z*=-1,a.isCubeTexture&&a.isRenderTargetTexture===!1&&(ih.y*=-1,ih.z*=-1),e.envMapRotation.value.setFromMatrix4(ah.makeRotationFromEuler(ih)),e.flipEnvMap.value=a.isCubeTexture&&a.isRenderTargetTexture===!1?-1:1,e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function sh(e,t,n,r){let i={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(m(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e<s;e++)if(o.indexOf(e)===-1)return o.push(e),e;return K(`WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached.`),0}function f(t){let n=i[t.id],r=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let t=0,n=r.length;t<n;t++){let n=Array.isArray(r[t])?r[t]:[r[t]];for(let r=0,i=n.length;r<i;r++){let i=n[r];if(p(i,t,r,a)===!0){let t=i.__offset,n=Array.isArray(i.value)?i.value:[i.value],r=0;for(let a=0;a<n.length;a++){let o=n[a],s=h(o);typeof o==`number`||typeof o==`boolean`?(i.__data[0]=o,e.bufferSubData(e.UNIFORM_BUFFER,t+r,i.__data)):o.isMatrix3?(i.__data[0]=o.elements[0],i.__data[1]=o.elements[1],i.__data[2]=o.elements[2],i.__data[3]=0,i.__data[4]=o.elements[3],i.__data[5]=o.elements[4],i.__data[6]=o.elements[5],i.__data[7]=0,i.__data[8]=o.elements[6],i.__data[9]=o.elements[7],i.__data[10]=o.elements[8],i.__data[11]=0):(o.toArray(i.__data,r),r+=s.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,i.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}function p(e,t,n,r){let i=e.value,a=t+`_`+n;if(r[a]===void 0)return typeof i==`number`||typeof i==`boolean`?r[a]=i:r[a]=i.clone(),!0;{let e=r[a];if(typeof i==`number`||typeof i==`boolean`){if(e!==i)return r[a]=i,!0}else if(e.equals(i)===!1)return e.copy(i),!0}return!1}function m(e){let t=e.uniforms,n=0;for(let e=0,r=t.length;e<r;e++){let r=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0,t=r.length;e<t;e++){let t=r[e],i=Array.isArray(t.value)?t.value:[t.value];for(let e=0,r=i.length;e<r;e++){let r=i[e],a=h(r),o=n%16,s=o%a.boundary,c=o+s;n+=s,c!==0&&16-c<a.storage&&(n+=16-c),t.__data=new Float32Array(a.storage/Float32Array.BYTES_PER_ELEMENT),t.__offset=n,n+=a.storage}}}let r=n%16;return r>0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e){let t={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?G(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):G(`WebGLRenderer: Unsupported uniform value type.`,e),t}function g(t){let n=t.target;n.removeEventListener(`dispose`,g);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:_}}var ch=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),lh=null;function uh(){return lh===null&&(lh=new Ws(ch,16,16,nr,Un),lh.name=`DFG_LUT`,lh.minFilter=Nn,lh.magFilter=Nn,lh.wrapS=On,lh.wrapT=On,lh.generateMipmaps=!1,lh.needsUpdate=!0),lh}var dh=class{constructor(e={}){let{canvas:t=oi(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:c=!1,powerPreference:l=`default`,failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=In}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<`u`&&n instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);p=n.getContextAttributes().alpha}else p=a;let m=f,h=new Set([ir,rr,tr]),g=new Set([In,Vn,zn,Kn,Wn,Gn]),_=new Uint32Array(4),v=new Int32Array(4),y=null,b=null,x=[],S=[],C=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let w=this,T=!1;this._outputColorSpace=Xr;let E=0,D=0,O=null,k=-1,A=null,j=new sa,M=new sa,ee=null,N=new X(0),te=0,ne=t.width,re=t.height,P=1,ie=null,ae=null,F=new sa(0,0,ne,re),I=new sa(0,0,ne,re),oe=!1,se=new uc,ce=!1,le=!1,ue=new Y,de=new J,fe=new sa,pe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},me=!1;function he(){return O===null?P:1}let L=n;function ge(e,n){return t.getContext(e,n)}try{let e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r183`),t.addEventListener(`webglcontextlost`,Le,!1),t.addEventListener(`webglcontextrestored`,Re,!1),t.addEventListener(`webglcontextcreationerror`,ze,!1),L===null){let t=`webgl2`;if(L=ge(t,e),L===null)throw ge(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}}catch(e){throw K(`WebGLRenderer: `+e.message),e}let R,_e,z,ve,B,V,ye,be,xe,Se,Ce,we,Te,H,Ee,De,Oe,ke,Ae,je,Me,Ne,Pe;function Fe(){R=new Af(L),R.init(),Me=new $m(L,R),_e=new of(L,R,e,Me),z=new Zm(L,R),_e.reversedDepthBuffer&&d&&z.buffers.depth.setReversed(!0),ve=new Nf(L),B=new jm,V=new Qm(L,R,z,B,_e,Me,ve),ye=new kf(w),be=new Xd(L),Ne=new rf(L,be),xe=new jf(L,be,ve,Ne),Se=new Ff(L,xe,be,Ne,ve),ke=new Pf(L,_e,V),Ee=new sf(B),Ce=new Am(w,ye,R,_e,Ne,Ee),we=new oh(w,B),Te=new Fm,H=new Hm(R),Oe=new nf(w,ye,z,Se,p,s),De=new Xm(w,Se,_e),Pe=new sh(L,ve,_e,z),Ae=new af(L,R,ve),je=new Mf(L,R,ve),ve.programs=Ce.programs,w.capabilities=_e,w.extensions=R,w.properties=B,w.renderLists=Te,w.shadowMap=De,w.state=z,w.info=ve}Fe(),m!==1009&&(C=new Lf(m,t.width,t.height,r,i));let Ie=new rh(w,L);this.xr=Ie,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let e=R.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=R.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return P},this.setPixelRatio=function(e){e!==void 0&&(P=e,this.setSize(ne,re,!1))},this.getSize=function(e){return e.set(ne,re)},this.setSize=function(e,n,r=!0){if(Ie.isPresenting){G(`WebGLRenderer: Can't change size while VR device is presenting.`);return}ne=e,re=n,t.width=Math.floor(e*P),t.height=Math.floor(n*P),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),C!==null&&C.setSize(t.width,t.height),this.setViewport(0,0,e,n)},this.getDrawingBufferSize=function(e){return e.set(ne*P,re*P).floor()},this.setDrawingBufferSize=function(e,n,r){ne=e,re=n,P=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(m===1009){console.error(`THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);return}if(e){for(let t=0;t<e.length;t++)if(e[t].isOutputPass===!0){console.warn(`THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.`);break}}C.setEffects(e||[])},this.getCurrentViewport=function(e){return e.copy(j)},this.getViewport=function(e){return e.copy(F)},this.setViewport=function(e,t,n,r){e.isVector4?F.set(e.x,e.y,e.z,e.w):F.set(e,t,n,r),z.viewport(j.copy(F).multiplyScalar(P).round())},this.getScissor=function(e){return e.copy(I)},this.setScissor=function(e,t,n,r){e.isVector4?I.set(e.x,e.y,e.z,e.w):I.set(e,t,n,r),z.scissor(M.copy(I).multiplyScalar(P).round())},this.getScissorTest=function(){return oe},this.setScissorTest=function(e){z.setScissorTest(oe=e)},this.setOpaqueSort=function(e){ie=e},this.setTransparentSort=function(e){ae=e},this.getClearColor=function(e){return e.copy(Oe.getClearColor())},this.setClearColor=function(){Oe.setClearColor(...arguments)},this.getClearAlpha=function(){return Oe.getClearAlpha()},this.setClearAlpha=function(){Oe.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let r=0;if(e){let e=!1;if(O!==null){let t=O.texture.format;e=h.has(t)}if(e){let e=O.texture.type,t=g.has(e),n=Oe.getClearColor(),r=Oe.getClearAlpha(),i=n.r,a=n.g,o=n.b;t?(_[0]=i,_[1]=a,_[2]=o,_[3]=r,L.clearBufferuiv(L.COLOR,0,_)):(v[0]=i,v[1]=a,v[2]=o,v[3]=r,L.clearBufferiv(L.COLOR,0,v))}else r|=L.COLOR_BUFFER_BIT}t&&(r|=L.DEPTH_BUFFER_BIT),n&&(r|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),r!==0&&L.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener(`webglcontextlost`,Le,!1),t.removeEventListener(`webglcontextrestored`,Re,!1),t.removeEventListener(`webglcontextcreationerror`,ze,!1),Oe.dispose(),Te.dispose(),H.dispose(),B.dispose(),ye.dispose(),Se.dispose(),Ne.dispose(),Pe.dispose(),Ce.dispose(),Ie.dispose(),Ie.removeEventListener(`sessionstart`,Ke),Ie.removeEventListener(`sessionend`,qe),Je.stop()};function Le(e){e.preventDefault(),li(`WebGLRenderer: Context Lost.`),T=!0}function Re(){li(`WebGLRenderer: Context Restored.`),T=!1;let e=ve.autoReset,t=De.enabled,n=De.autoUpdate,r=De.needsUpdate,i=De.type;Fe(),ve.autoReset=e,De.enabled=t,De.autoUpdate=n,De.needsUpdate=r,De.type=i}function ze(e){K(`WebGLRenderer: A WebGL context could not be created. Reason: `,e.statusMessage)}function Be(e){let t=e.target;t.removeEventListener(`dispose`,Be),Ve(t)}function Ve(e){He(e),B.remove(e)}function He(e){let t=B.get(e).programs;t!==void 0&&(t.forEach(function(e){Ce.releaseProgram(e)}),e.isShaderMaterial&&Ce.releaseShaderCache(e))}this.renderBufferDirect=function(e,t,n,r,i,a){t===null&&(t=pe);let o=i.isMesh&&i.matrixWorld.determinant()<0,s=rt(e,t,n,r,i);z.setMaterial(r,o);let c=n.index,l=1;if(r.wireframe===!0){if(c=xe.getWireframeAttribute(n),c===void 0)return;l=2}let u=n.drawRange,d=n.attributes.position,f=u.start*l,p=(u.start+u.count)*l;a!==null&&(f=Math.max(f,a.start*l),p=Math.min(p,(a.start+a.count)*l)),c===null?d!=null&&(f=Math.max(f,0),p=Math.min(p,d.count)):(f=Math.max(f,0),p=Math.min(p,c.count));let m=p-f;if(m<0||m===1/0)return;Ne.setup(i,r,s,n,c);let h,g=Ae;if(c!==null&&(h=be.get(c),g=je,g.setIndex(h)),i.isMesh)r.wireframe===!0?(z.setLineWidth(r.wireframeLinewidth*he()),g.setMode(L.LINES)):g.setMode(L.TRIANGLES);else if(i.isLine){let e=r.linewidth;e===void 0&&(e=1),z.setLineWidth(e*he()),i.isLineSegments?g.setMode(L.LINES):i.isLineLoop?g.setMode(L.LINE_LOOP):g.setMode(L.LINE_STRIP)}else i.isPoints?g.setMode(L.POINTS):i.isSprite&&g.setMode(L.TRIANGLES);if(i.isBatchedMesh)if(i._multiDrawInstances!==null)di(`WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.`),g.renderMultiDrawInstances(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount,i._multiDrawInstances);else if(R.get(`WEBGL_multi_draw`))g.renderMultiDraw(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount);else{let e=i._multiDrawStarts,t=i._multiDrawCounts,n=i._multiDrawCount,a=c?be.get(c).bytesPerElement:1,o=B.get(r).currentProgram.getUniforms();for(let r=0;r<n;r++)o.setValue(L,`_gl_DrawID`,r),g.render(e[r]/a,t[r])}else if(i.isInstancedMesh)g.renderInstances(f,m,i.count);else if(n.isInstancedBufferGeometry){let e=n._maxInstanceCount===void 0?1/0:n._maxInstanceCount,t=Math.min(n.instanceCount,e);g.renderInstances(f,m,t)}else g.render(f,m)};function Ue(e,t,n){e.transparent===!0&&e.side===2&&e.forceSinglePass===!1?(e.side=1,e.needsUpdate=!0,et(e,t,n),e.side=0,e.needsUpdate=!0,et(e,t,n),e.side=2):et(e,t,n)}this.compile=function(e,t,n=null){n===null&&(n=e),b=H.get(n),b.init(t),S.push(b),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(b.pushLight(e),e.castShadow&&b.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(b.pushLight(e),e.castShadow&&b.pushShadow(e))}),b.setupLights();let r=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;let t=e.material;if(t)if(Array.isArray(t))for(let i=0;i<t.length;i++){let a=t[i];Ue(a,n,e),r.add(a)}else Ue(t,n,e),r.add(t)}),b=S.pop(),r},this.compileAsync=function(e,t,n=null){let r=this.compile(e,t,n);return new Promise(t=>{function n(){if(r.forEach(function(e){B.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}R.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let We=null;function Ge(e){We&&We(e)}function Ke(){Je.stop()}function qe(){Je.start()}let Je=new Yd;Je.setAnimationLoop(Ge),typeof self<`u`&&Je.setContext(self),this.setAnimationLoop=function(e){We=e,Ie.setAnimationLoop(e),e===null?Je.stop():Je.start()},Ie.addEventListener(`sessionstart`,Ke),Ie.addEventListener(`sessionend`,qe),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){K(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(T===!0)return;let n=Ie.enabled===!0&&Ie.isPresenting===!0,r=C!==null&&(O===null||n)&&C.begin(w,O);if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),Ie.enabled===!0&&Ie.isPresenting===!0&&(C===null||C.isCompositing()===!1)&&(Ie.cameraAutoUpdate===!0&&Ie.updateCamera(t),t=Ie.getCamera()),e.isScene===!0&&e.onBeforeRender(w,e,t,O),b=H.get(e,S.length),b.init(t),S.push(b),ue.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),se.setFromProjectionMatrix(ue,ni,t.reversedDepth),le=this.localClippingEnabled,ce=Ee.init(this.clippingPlanes,le),y=Te.get(e,x.length),y.init(),x.push(y),Ie.enabled===!0&&Ie.isPresenting===!0){let e=w.xr.getDepthSensingMesh();e!==null&&Ye(e,t,-1/0,w.sortObjects)}Ye(e,t,0,w.sortObjects),y.finish(),w.sortObjects===!0&&y.sort(ie,ae),me=Ie.enabled===!1||Ie.isPresenting===!1||Ie.hasDepthSensing()===!1,me&&Oe.addToRenderList(y,e),this.info.render.frame++,ce===!0&&Ee.beginShadows();let i=b.state.shadowsArray;if(De.render(i,e,t),ce===!0&&Ee.endShadows(),this.info.autoReset===!0&&this.info.reset(),(r&&C.hasRenderPass())===!1){let n=y.opaque,r=y.transmissive;if(b.setupLights(),t.isArrayCamera){let i=t.cameras;if(r.length>0)for(let t=0,a=i.length;t<a;t++){let a=i[t];Ze(n,r,e,a)}me&&Oe.render(e);for(let t=0,n=i.length;t<n;t++){let n=i[t];Xe(y,e,n,n.viewport)}}else r.length>0&&Ze(n,r,e,t),me&&Oe.render(e),Xe(y,e,t)}O!==null&&D===0&&(V.updateMultisampleRenderTarget(O),V.updateRenderTargetMipmap(O)),r&&C.end(w),e.isScene===!0&&e.onAfterRender(w,e,t),Ne.resetDefaultState(),k=-1,A=null,S.pop(),S.length>0?(b=S[S.length-1],ce===!0&&Ee.setGlobalState(w.clippingPlanes,b.state.camera)):b=null,x.pop(),y=x.length>0?x[x.length-1]:null};function Ye(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)b.pushLight(e),e.castShadow&&b.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||se.intersectsSprite(e)){r&&fe.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ue);let t=Se.update(e),i=e.material;i.visible&&y.push(e,t,i,n,fe.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||se.intersectsObject(e))){let t=Se.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),fe.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),fe.copy(e.boundingSphere.center)),fe.applyMatrix4(e.matrixWorld).applyMatrix4(ue)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a<o;a++){let o=r[a],s=i[o.materialIndex];s&&s.visible&&y.push(e,t,s,n,fe.z,o)}}else i.visible&&y.push(e,t,i,n,fe.z,null)}}let i=e.children;for(let e=0,a=i.length;e<a;e++)Ye(i[e],t,n,r)}function Xe(e,t,n,r){let{opaque:i,transmissive:a,transparent:o}=e;b.setupLightsView(n),ce===!0&&Ee.setGlobalState(w.clippingPlanes,n),r&&z.viewport(j.copy(r)),i.length>0&&Qe(i,t,n),a.length>0&&Qe(a,t,n),o.length>0&&Qe(o,t,n),z.buffers.depth.setTest(!0),z.buffers.depth.setMask(!0),z.buffers.color.setMask(!0),z.setPolygonOffset(!1)}function Ze(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[r.id]===void 0){let e=R.has(`EXT_color_buffer_half_float`)||R.has(`EXT_color_buffer_float`);b.state.transmissionRenderTarget[r.id]=new la(1,1,{generateMipmaps:!0,type:e?Un:In,minFilter:Fn,samples:Math.max(4,_e.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Xi.workingColorSpace})}let a=b.state.transmissionRenderTarget[r.id],o=r.viewport||j;a.setSize(o.z*w.transmissionResolutionScale,o.w*w.transmissionResolutionScale);let s=w.getRenderTarget(),c=w.getActiveCubeFace(),l=w.getActiveMipmapLevel();w.setRenderTarget(a),w.getClearColor(N),te=w.getClearAlpha(),te<1&&w.setClearColor(16777215,.5),w.clear(),me&&Oe.render(n);let u=w.toneMapping;w.toneMapping=0;let d=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),b.setupLightsView(r),ce===!0&&Ee.setGlobalState(w.clippingPlanes,r),Qe(e,n,r),V.updateMultisampleRenderTarget(a),V.updateRenderTargetMipmap(a),R.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i<a;i++){let{object:a,geometry:o,material:s,group:c}=t[i];if(s.side===2&&a.layers.test(r.layers)){let t=s.side;s.side=1,s.needsUpdate=!0,$e(a,n,r,o,s,c),s.side=t,s.needsUpdate=!0,e=!0}}e===!0&&(V.updateMultisampleRenderTarget(a),V.updateRenderTargetMipmap(a))}w.setRenderTarget(s,c,l),w.setClearColor(N,te),d!==void 0&&(r.viewport=d),w.toneMapping=u}function Qe(e,t,n){let r=t.isScene===!0?t.overrideMaterial:null;for(let i=0,a=e.length;i<a;i++){let a=e[i],{object:o,geometry:s,group:c}=a,l=a.material;l.allowOverride===!0&&r!==null&&(l=r),o.layers.test(n.layers)&&$e(o,t,n,s,l,c)}}function $e(e,t,n,r,i,a){e.onBeforeRender(w,t,n,r,i,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),i.onBeforeRender(w,t,n,r,e,a),i.transparent===!0&&i.side===2&&i.forceSinglePass===!1?(i.side=1,i.needsUpdate=!0,w.renderBufferDirect(n,t,r,i,e,a),i.side=0,i.needsUpdate=!0,w.renderBufferDirect(n,t,r,i,e,a),i.side=2):w.renderBufferDirect(n,t,r,i,e,a),e.onAfterRender(w,t,n,r,i,a)}function et(e,t,n){t.isScene!==!0&&(t=pe);let r=B.get(e),i=b.state.lights,a=b.state.shadowsArray,o=i.state.version,s=Ce.getParameters(e,i.state,a,t,n),c=Ce.getProgramCacheKey(s),l=r.programs;r.environment=e.isMeshStandardMaterial||e.isMeshLambertMaterial||e.isMeshPhongMaterial?t.environment:null,r.fog=t.fog;let u=e.isMeshStandardMaterial||e.isMeshLambertMaterial&&!e.envMap||e.isMeshPhongMaterial&&!e.envMap;r.envMap=ye.get(e.envMap||r.environment,u),r.envMapRotation=r.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation,l===void 0&&(e.addEventListener(`dispose`,Be),l=new Map,r.programs=l);let d=l.get(c);if(d!==void 0){if(r.currentProgram===d&&r.lightsStateVersion===o)return nt(e,s),d}else s.uniforms=Ce.getUniforms(e),e.onBeforeCompile(s,w),d=Ce.acquireProgram(s,c),l.set(c,d),r.uniforms=s.uniforms;let f=r.uniforms;return(!e.isShaderMaterial&&!e.isRawShaderMaterial||e.clipping===!0)&&(f.clippingPlanes=Ee.uniform),nt(e,s),r.needsLights=at(e),r.lightsStateVersion=o,r.needsLights&&(f.ambientLightColor.value=i.state.ambient,f.lightProbe.value=i.state.probe,f.directionalLights.value=i.state.directional,f.directionalLightShadows.value=i.state.directionalShadow,f.spotLights.value=i.state.spot,f.spotLightShadows.value=i.state.spotShadow,f.rectAreaLights.value=i.state.rectArea,f.ltc_1.value=i.state.rectAreaLTC1,f.ltc_2.value=i.state.rectAreaLTC2,f.pointLights.value=i.state.point,f.pointLightShadows.value=i.state.pointShadow,f.hemisphereLights.value=i.state.hemi,f.directionalShadowMatrix.value=i.state.directionalShadowMatrix,f.spotLightMatrix.value=i.state.spotLightMatrix,f.spotLightMap.value=i.state.spotLightMap,f.pointShadowMatrix.value=i.state.pointShadowMatrix),r.currentProgram=d,r.uniformsList=null,d}function tt(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=Wp.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function nt(e,t){let n=B.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}function rt(e,t,n,r,i){t.isScene!==!0&&(t=pe),V.resetTextureUnits();let a=t.fog,o=r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial?t.environment:null,s=O===null?w.outputColorSpace:O.isXRRenderTarget===!0?O.texture.colorSpace:Zr,c=r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap,l=ye.get(r.envMap||o,c),u=r.vertexColors===!0&&!!n.attributes.color&&n.attributes.color.itemSize===4,d=!!n.attributes.tangent&&(!!r.normalMap||r.anisotropy>0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,h=0;r.toneMapped&&(O===null||O.isXRRenderTarget===!0)&&(h=w.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,v=B.get(r),y=b.state.lights;if(ce===!0&&(le===!0||e!==A)){let t=e===A&&r.id===k;Ee.setState(r,e,t)}let x=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version?x=!0:v.outputColorSpace===s?i.isBatchedMesh&&v.batching===!1||!i.isBatchedMesh&&v.batching===!0||i.isBatchedMesh&&v.batchingColor===!0&&i.colorTexture===null||i.isBatchedMesh&&v.batchingColor===!1&&i.colorTexture!==null||i.isInstancedMesh&&v.instancing===!1||!i.isInstancedMesh&&v.instancing===!0||i.isSkinnedMesh&&v.skinning===!1||!i.isSkinnedMesh&&v.skinning===!0||i.isInstancedMesh&&v.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&v.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&v.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&v.instancingMorph===!1&&i.morphTexture!==null?x=!0:v.envMap===l?r.fog===!0&&v.fog!==a||v.numClippingPlanes!==void 0&&(v.numClippingPlanes!==Ee.numPlanes||v.numIntersection!==Ee.numIntersection)?x=!0:v.vertexAlphas===u&&v.vertexTangents===d&&v.morphTargets===f&&v.morphNormals===p&&v.morphColors===m&&v.toneMapping===h?v.morphTargetsCount!==_&&(x=!0):x=!0:x=!0:x=!0:(x=!0,v.__version=r.version);let S=v.currentProgram;x===!0&&(S=et(r,t,i));let C=!1,T=!1,E=!1,D=S.getUniforms(),j=v.uniforms;if(z.useProgram(S.program)&&(C=!0,T=!0,E=!0),r.id!==k&&(k=r.id,T=!0),C||A!==e){z.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),D.setValue(L,`projectionMatrix`,e.projectionMatrix),D.setValue(L,`viewMatrix`,e.matrixWorldInverse);let t=D.map.cameraPosition;t!==void 0&&t.setValue(L,de.setFromMatrixPosition(e.matrixWorld)),_e.logarithmicDepthBuffer&&D.setValue(L,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&D.setValue(L,`isOrthographic`,e.isOrthographicCamera===!0),A!==e&&(A=e,T=!0,E=!0)}if(v.needsLights&&(y.state.directionalShadowMap.length>0&&D.setValue(L,`directionalShadowMap`,y.state.directionalShadowMap,V),y.state.spotShadowMap.length>0&&D.setValue(L,`spotShadowMap`,y.state.spotShadowMap,V),y.state.pointShadowMap.length>0&&D.setValue(L,`pointShadowMap`,y.state.pointShadowMap,V)),i.isSkinnedMesh){D.setOptional(L,i,`bindMatrix`),D.setOptional(L,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),D.setValue(L,`boneTexture`,e.boneTexture,V))}i.isBatchedMesh&&(D.setOptional(L,i,`batchingTexture`),D.setValue(L,`batchingTexture`,i._matricesTexture,V),D.setOptional(L,i,`batchingIdTexture`),D.setValue(L,`batchingIdTexture`,i._indirectTexture,V),D.setOptional(L,i,`batchingColorTexture`),i._colorsTexture!==null&&D.setValue(L,`batchingColorTexture`,i._colorsTexture,V));let M=n.morphAttributes;if((M.position!==void 0||M.normal!==void 0||M.color!==void 0)&&ke.update(i,n,S),(T||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,D.setValue(L,`receiveShadow`,i.receiveShadow)),(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial)&&r.envMap===null&&t.environment!==null&&(j.envMapIntensity.value=t.environmentIntensity),j.dfgLUT!==void 0&&(j.dfgLUT.value=uh()),T&&(D.setValue(L,`toneMappingExposure`,w.toneMappingExposure),v.needsLights&&it(j,E),a&&r.fog===!0&&we.refreshFogUniforms(j,a),we.refreshMaterialUniforms(j,r,P,re,b.state.transmissionRenderTarget[e.id]),Wp.upload(L,tt(v),j,V)),r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(Wp.upload(L,tt(v),j,V),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&D.setValue(L,`center`,i.center),D.setValue(L,`modelViewMatrix`,i.modelViewMatrix),D.setValue(L,`normalMatrix`,i.normalMatrix),D.setValue(L,`modelMatrix`,i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){let e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++){let n=e[t];Pe.update(n,S),Pe.bind(n,S)}}return S}function it(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function at(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&e.lights===!0}this.getActiveCubeFace=function(){return E},this.getActiveMipmapLevel=function(){return D},this.getRenderTarget=function(){return O},this.setRenderTargetTextures=function(e,t,n){let r=B.get(e);r.__autoAllocateDepthBuffer=e.resolveDepthBuffer===!1,r.__autoAllocateDepthBuffer===!1&&(r.__useRenderToTexture=!1),B.get(e.texture).__webglTexture=t,B.get(e.depthTexture).__webglTexture=r.__autoAllocateDepthBuffer?void 0:n,r.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){let n=B.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=t===void 0};let ot=L.createFramebuffer();this.setRenderTarget=function(e,t=0,n=0){O=e,E=t,D=n;let r=null,i=!1,a=!1;if(e){let o=B.get(e);if(o.__useDefaultFramebuffer!==void 0){z.bindFramebuffer(L.FRAMEBUFFER,o.__webglFramebuffer),j.copy(e.viewport),M.copy(e.scissor),ee=e.scissorTest,z.viewport(j),z.scissor(M),z.setScissorTest(ee),k=-1;return}else if(o.__webglFramebuffer===void 0)V.setupRenderTarget(e);else if(o.__hasExternalTextures)V.rebindTextures(e,B.get(e.texture).__webglTexture,B.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let t=e.depthTexture;if(o.__boundDepthTexture!==t){if(t!==null&&B.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw Error(`WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.`);V.setupDepthRenderbuffer(e)}}let s=e.texture;(s.isData3DTexture||s.isDataArrayTexture||s.isCompressedArrayTexture)&&(a=!0);let c=B.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],i=!0):r=e.samples>0&&V.useMultisampledRTT(e)===!1?B.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,j.copy(e.viewport),M.copy(e.scissor),ee=e.scissorTest}else j.copy(F).multiplyScalar(P).floor(),M.copy(I).multiplyScalar(P).floor(),ee=oe;if(n!==0&&(r=ot),z.bindFramebuffer(L.FRAMEBUFFER,r)&&z.drawBuffers(e,r),z.viewport(j),z.scissor(M),z.setScissorTest(ee),i){let r=B.get(e.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t<e.textures.length;t++){let i=B.get(e.textures[t]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+t,i.__webglTexture,n,r)}}else if(e!==null&&n!==0){let t=B.get(e.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,t.__webglTexture,n)}k=-1},this.readRenderTargetPixels=function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget)){K(`WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);return}let c=B.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c){z.bindFramebuffer(L.FRAMEBUFFER,c);try{let o=e.textures[s],c=o.format,l=o.type;if(e.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+s),!_e.textureFormatReadable(c)){K(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!_e.textureTypeReadable(l)){K(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&L.readPixels(t,n,r,i,Me.convert(c),Me.convert(l),a)}finally{let e=O===null?null:B.get(O).__webglFramebuffer;z.bindFramebuffer(L.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=B.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c)if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){z.bindFramebuffer(L.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(e.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+s),!_e.textureFormatReadable(l))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(!_e.textureTypeReadable(u))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let d=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,d),L.bufferData(L.PIXEL_PACK_BUFFER,a.byteLength,L.STREAM_READ),L.readPixels(t,n,r,i,Me.convert(l),Me.convert(u),0);let f=O===null?null:B.get(O).__webglFramebuffer;z.bindFramebuffer(L.FRAMEBUFFER,f);let p=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await fi(L,p,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,d),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,a),L.deleteBuffer(d),L.deleteSync(p),a}else throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;V.setTexture2D(e,0),L.copyTexSubImage2D(L.TEXTURE_2D,n,0,0,o,s,i,a),z.unbindTexture()};let st=L.createFramebuffer(),ct=L.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=0){let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=Me.convert(t.format),_=Me.convert(t.type),v;t.isData3DTexture?(V.setTexture3D(t,0),v=L.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(V.setTexture2DArray(t,0),v=L.TEXTURE_2D_ARRAY):(V.setTexture2D(t,0),v=L.TEXTURE_2D),L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,t.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,t.unpackAlignment);let y=L.getParameter(L.UNPACK_ROW_LENGTH),b=L.getParameter(L.UNPACK_IMAGE_HEIGHT),x=L.getParameter(L.UNPACK_SKIP_PIXELS),S=L.getParameter(L.UNPACK_SKIP_ROWS),C=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,h.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,h.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,l),L.pixelStorei(L.UNPACK_SKIP_ROWS,u),L.pixelStorei(L.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=B.get(e),r=B.get(t),h=B.get(n.__renderTarget),g=B.get(r.__renderTarget);z.bindFramebuffer(L.READ_FRAMEBUFFER,h.__webglFramebuffer),z.bindFramebuffer(L.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<c;n++)w&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,B.get(e).__webglTexture,i,d+n),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,B.get(t).__webglTexture,a,m+n)),L.blitFramebuffer(l,u,o,s,f,p,o,s,L.DEPTH_BUFFER_BIT,L.NEAREST);z.bindFramebuffer(L.READ_FRAMEBUFFER,null),z.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(i!==0||e.isRenderTargetTexture||B.has(e)){let n=B.get(e),r=B.get(t);z.bindFramebuffer(L.READ_FRAMEBUFFER,st),z.bindFramebuffer(L.DRAW_FRAMEBUFFER,ct);for(let e=0;e<c;e++)w?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,n.__webglTexture,i,d+e):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,n.__webglTexture,i),T?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,r.__webglTexture,a,m+e):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,r.__webglTexture,a),i===0?T?L.copyTexSubImage3D(v,a,f,p,m+e,l,u,o,s):L.copyTexSubImage2D(v,a,f,p,l,u,o,s):L.blitFramebuffer(l,u,o,s,f,p,o,s,L.COLOR_BUFFER_BIT,L.NEAREST);z.bindFramebuffer(L.READ_FRAMEBUFFER,null),z.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else T?e.isDataTexture||e.isData3DTexture?L.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h.data):t.isCompressedArrayTexture?L.compressedTexSubImage3D(v,a,f,p,m,o,s,c,g,h.data):L.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h):e.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,a,f,p,o,s,g,_,h.data):e.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,a,f,p,h.width,h.height,g,h.data):L.texSubImage2D(L.TEXTURE_2D,a,f,p,o,s,g,_,h);L.pixelStorei(L.UNPACK_ROW_LENGTH,y),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,b),L.pixelStorei(L.UNPACK_SKIP_PIXELS,x),L.pixelStorei(L.UNPACK_SKIP_ROWS,S),L.pixelStorei(L.UNPACK_SKIP_IMAGES,C),a===0&&t.generateMipmaps&&L.generateMipmap(v),z.unbindTexture()},this.initRenderTarget=function(e){B.get(e).__webglFramebuffer===void 0&&V.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?V.setTextureCube(e,0):e.isData3DTexture?V.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?V.setTexture2DArray(e,0):V.setTexture2D(e,0),z.unbindTexture()},this.resetState=function(){E=0,D=0,O=null,z.reset(),Ne.reset()},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}get coordinateSystem(){return ni}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Xi._getDrawingBufferColorSpace(e),t.unpackColorSpace=Xi._getUnpackColorSpace()}},fh=-(2**40),ph=8;function mh(e,t){return e<0||e>=ph?fh:t*ph+e}function hh(e){return(e%ph+ph)%ph}function gh(e){return(e-hh(e))/ph}function _h(e){return e===fh?null:ln(hh(e),gh(e))}function vh(e){let t=e.indexOf(`-`);if(t<=0)return null;let n=cn(e.slice(0,t));if(n===void 0)return null;let r=Number(e.slice(t+1));if(!Number.isInteger(r)||r>2147483647||r<-2147483648)return null;let i=mh(n,r);return i===fh?null:i}function yh(e){let t=new Set;for(let n of e){let e=vh(n);e!==null&&t.add(e)}return t}function bh(e){return e+7&-8}function xh(e){return{subFormat:e.getUint16(24,!0),source:e.getUint8(26),idType:e.getUint8(27),rowCount:e.getUint32(28,!0)}}function Sh(e,t){return ln(e.idType,e.id[t])}function Ch(e,t){return mh(e.idType,e.id[t])}function wh(e,t){let n=Zt,r=new Int32Array(e,n,t);n+=bh(t*4);let i=new Uint8Array(e,n,t);n+=bh(t);let a=new Int32Array(e,n,t);n+=bh(t*4);let o=new Uint8Array(e,n,t);return n+=bh(t),{id:r,objectType:i,parentId:a,scale:o,offset:n}}function Th(e,t,n){let r=n,i=new Float64Array(e,r,t);r+=t*8;let a=new Float32Array(e,r,t);r+=bh(t*4);let o=new Float32Array(e,r,t);r+=bh(t*4);let s=new Float32Array(e,r,t);r+=bh(t*4);let c=new Float32Array(e,r,t);r+=bh(t*4);let l=new Float32Array(e,r,t);r+=bh(t*4);let u=new Float32Array(e,r,t);r+=bh(t*4);let d=new Float32Array(e,r,t);r+=bh(t*4);let f=new Float32Array(e,r,t);return r+=bh(t*4),{epochJd:i,a,e:o,i:s,om:c,w:l,ma:u,n:d,radiusKm:f,offset:r}}function Eh(e,t,n){let{subFormat:r,rowCount:i,source:a,idType:o}=xh(new DataView(e));if(o===an.UNKNOWN&&i>0&&console.warn(`elements payload has unknown id-type — ${i} row(s) will lack reconstructed IDs`),r===1)return Oh(e,i,t,n,a,o);if(r===2)return Dh(e,i,t,n,a,o);if(r!==0)throw Error(`Unknown elements sub-format: ${r}`);let{id:s,objectType:c,parentId:l,scale:u,offset:d}=wh(e,i),f=Th(e,i,d),p=f.offset,m=new Float32Array(e,p,i);p+=bh(i*4);let h=new Float32Array(e,p,i);p+=bh(i*4);let g=new Uint8Array(e,p,i);p+=bh(i);let _=new Uint8Array(e,p,i);p+=bh(i);let v=new Float32Array(e,p,i),y={validityStart:t,validityEnd:n,source:a,idType:o};return{kind:`keplerian`,id:s,objectType:c,parentId:l,scale:u,epochJd:f.epochJd,a:f.a,e:f.e,i:f.i,om:f.om,w:f.w,ma:f.ma,n:f.n,radiusKm:f.radiusKm,omDot:m,wDot:h,hasLocalized:g,flags:_,visibleFromDays:v,rowCount:i,...y}}function Dh(e,t,n,r,i,a){let{id:o,objectType:s,parentId:c,scale:l,offset:u}=wh(e,t),d=Th(e,t,u),f=d.offset,p={validityStart:n,validityEnd:r,source:i,idType:a},m=new Float32Array(e,f,t);f+=bh(t*4);let h=new Float32Array(e,f,t);f+=bh(t*4);let g=new Float32Array(e,f,t);f+=bh(t*4);let _=new Int32Array(e,f,t);f+=bh(t*4);let v=new Int32Array(e,f,t);f+=bh(t*4);let y=new Uint8Array(e,f,t);f+=bh(t);let b=new Uint8Array(e,f,t);f+=bh(t);let x=new Float32Array(e,f,t);return{kind:`sgp4`,id:o,objectType:s,parentId:c,scale:l,epochJd:d.epochJd,a:d.a,e:d.e,i:d.i,om:d.om,w:d.w,ma:d.ma,n:d.n,radiusKm:d.radiusKm,bstar:m,meanMotionDot:h,meanMotionDdot:g,elementSetNo:_,revAtEpoch:v,hasLocalized:y,flags:b,visibleFromDays:x,rowCount:t,...p}}function Oh(e,t,n,r,i,a){let{id:o,objectType:s,parentId:c,scale:l,offset:u}=wh(e,t),d=u,f={validityStart:n,validityEnd:r,source:i,idType:a},p=new Float64Array(e,d,t);d+=t*8;let m=new Float32Array(e,d,t);d+=bh(t*4);let h=new Float32Array(e,d,t);d+=bh(t*4);let g=new Float32Array(e,d,t);d+=bh(t*4);let _=new Float32Array(e,d,t);d+=bh(t*4);let v=new Float32Array(e,d,t);d+=bh(t*4);let y=new Float64Array(e,d,t);d+=t*8;let b=new Float32Array(e,d,t);d+=bh(t*4);let x=new Uint8Array(e,d,t);d+=bh(t);let S=new Uint8Array(e,d,t);return d+=bh(t),{kind:`parabolic`,id:o,objectType:s,parentId:c,scale:l,epochJd:p,q:m,e:h,i:g,om:_,w:v,tp:y,radiusKm:b,hasLocalized:x,flags:S,visibleFromDays:new Float32Array(e,d,t),rowCount:t,...f}}var kh=Math.PI,Ah=kh*2,jh=kh/180;180/kh;var Mh=398600.8,Nh=6378.135,Ph=60/Math.sqrt(Nh*Nh*Nh/Mh),Fh=Nh*Ph/60,Ih=1/Ph,Lh=.001082616,Rh=-253881e-11,zh=-165597e-11,Bh=Rh/Lh,Vh=2/3,Hh=1440/(2*kh);function Uh(e,t){let n=[31,e%4==0?29:28,31,30,31,30,31,31,30,31,30,31],r=Math.floor(t),i=1,a=0;for(;r>a+n[i-1]&&i<12;)a+=n[i-1],i+=1;let o=i,s=r-a,c=(t-r)*24,l=Math.floor(c);c=(c-l)*60;let u=Math.floor(c);return{mon:o,day:s,hr:l,minute:u,sec:(c-u)*60}}function Wh(e,t,n,r,i,a,o=0){return 367*e-Math.floor(7*(e+Math.floor((t+9)/12))*.25)+Math.floor(275*t/9)+n+1721013.5+((o/6e4+a/60+i)/60+r)/24}function Gh(e,t,n,r,i,a,o=0){if(e instanceof Date){let t=e;return Wh(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())}return Wh(e,t,n,r,i,a,o)}function Kh(e,t){let{e3:n,ee2:r,peo:i,pgho:a,pho:o,pinco:s,plo:c,se2:l,se3:u,sgh2:d,sgh3:f,sgh4:p,sh2:m,sh3:h,si2:g,si3:_,sl2:v,sl3:y,sl4:b,t:x,xgh2:S,xgh3:C,xgh4:w,xh2:T,xh3:E,xi2:D,xi3:O,xl2:k,xl3:A,xl4:j,zmol:M,zmos:ee}=e,{init:N,opsmode:te}=t,{ep:ne,inclp:re,nodep:P,argpp:ie,mp:ae}=t,F,I,oe,se,ce,le,ue,de,fe,pe,me,he,L,ge,R,_e,z,ve,B,V,ye;ye=ee+119459e-10*x,N===`y`&&(ye=ee),V=ye+2*.01675*Math.sin(ye),z=Math.sin(V),pe=.5*z*z-.25,me=-.5*z*Math.cos(V);let be=l*pe+u*me,xe=g*pe+_*me,Se=v*pe+y*me+b*z,Ce=d*pe+f*me+p*z,we=m*pe+h*me;ye=M+.00015835218*x,N===`y`&&(ye=M),V=ye+2*.0549*Math.sin(ye),z=Math.sin(V),pe=.5*z*z-.25,me=-.5*z*Math.cos(V);let Te=r*pe+n*me,H=D*pe+O*me,Ee=k*pe+A*me+j*z,De=S*pe+C*me+w*z,Oe=T*pe+E*me;return he=be+Te,R=xe+H,_e=Se+Ee,L=Ce+De,ge=we+Oe,N===`n`&&(he-=i,R-=s,_e-=c,L-=a,ge-=o,re+=R,ne+=he,se=Math.sin(re),oe=Math.cos(re),re>=.2?(ge/=se,L-=oe*ge,ie+=L,P+=ge,ae+=_e):(le=Math.sin(P),ce=Math.cos(P),F=se*le,I=se*ce,ue=ge*ce+R*oe*le,de=-ge*le+R*oe*ce,F+=ue,I+=de,P%=Ah,P<0&&te===`a`&&(P+=Ah),ve=ae+ie+oe*P,fe=_e+L-R*P*se,ve+=fe,B=P,P=Math.atan2(F,I),P<0&&te===`a`&&(P+=Ah),Math.abs(B-P)>kh&&(P<B?P+=Ah:P-=Ah),ae+=_e,ie=ve-ae-oe*P)),{ep:ne,inclp:re,nodep:P,argpp:ie,mp:ae}}function qh(e){let{epoch:t,ep:n,argpp:r,tc:i,inclp:a,nodep:o,np:s}=e,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,ee,N,te,ne,re,P,ie,ae,F,I,oe,se,ce,le,ue,de,fe,pe,me,he,L,ge,R,_e,z,ve,B,V,ye,be,xe,Se,Ce,we,Te,H,Ee,De,Oe=.01675,ke=.0549,Ae=s,je=n,Me=Math.sin(o),Ne=Math.cos(o),Pe=Math.sin(r),Fe=Math.cos(r),Ie=Math.sin(a),Le=Math.cos(a),Re=je*je,ze=1-Re,Be=Math.sqrt(ze),Ve=t+18261.5+i/1440,He=(4.523602-.00092422029*Ve)%Ah,Ue=Math.sin(He),We=Math.cos(He),Ge=.91375164-.03568096*We,Ke=Math.sqrt(1-Ge*Ge),qe=.089683511*Ue/Ke,Je=Math.sqrt(1-qe*qe),Ye=5.8351514+.001944368*Ve,Xe=.39785416*Ue/Ke,Ze=Je*We+.91744867*qe*Ue;Xe=Math.atan2(Xe,Ze),Xe+=Ye-He;let Qe=Math.cos(Xe),$e=Math.sin(Xe);D=.1945905,O=-.98088458,j=.91744867,M=.39785416,k=Ne,A=Me,v=29864797e-13;let et=1/Ae,tt=0;for(;tt<2;)tt+=1,c=D*k+O*j*A,u=-O*k+D*j*A,m=-D*A+O*j*k,h=O*M,g=O*A+D*j*k,_=D*M,l=Le*m+Ie*h,d=Le*g+Ie*_,f=-Ie*m+Le*h,p=-Ie*g+Le*_,y=c*Fe+l*Pe,b=u*Fe+d*Pe,x=-c*Pe+l*Fe,S=-u*Pe+d*Fe,C=f*Pe,w=p*Pe,T=f*Fe,E=p*Fe,H=12*y*y-3*x*x,Ee=24*y*b-6*x*S,De=12*b*b-3*S*S,B=3*(c*c+l*l)+H*Re,V=6*(c*u+l*d)+Ee*Re,ye=3*(u*u+d*d)+De*Re,be=-6*c*f+Re*(-24*y*T-6*x*C),xe=-6*(c*p+u*f)+Re*(-24*(b*T+y*E)+-6*(x*w+S*C)),Se=-6*u*p+Re*(-24*b*E-6*S*w),Ce=6*l*f+Re*(24*y*C-6*x*T),we=6*(d*f+l*p)+Re*(24*(b*C+y*w)-6*(S*T+x*E)),Te=6*d*p+Re*(24*b*w-6*S*E),B=B+B+ze*H,V=V+V+ze*Ee,ye=ye+ye+ze*De,ge=v*et,L=-.5*ge/Be,R=ge*Be,he=-15*je*R,_e=y*x+b*S,z=b*x+y*S,ve=b*S-y*x,tt===1&&(ee=he,N=L,te=ge,ne=R,re=_e,P=z,ie=ve,ae=B,F=V,I=ye,oe=be,se=xe,ce=Se,le=Ce,ue=we,de=Te,fe=H,pe=Ee,me=De,D=Qe,O=$e,j=Ge,M=Ke,k=Je*Ne+qe*Me,A=Me*Je-Ne*qe,v=4.7968065e-7);let nt=(4.7199672+(.2299715*Ve-Ye))%Ah,rt=(6.2565837+.017201977*Ve)%Ah,it=2*ee*P,at=2*ee*ie,ot=2*N*se,st=2*N*(ce-oe),ct=-2*te*F,lt=-2*te*(I-ae),ut=-2*te*(-21-9*Re)*Oe,dt=2*ne*pe,ft=2*ne*(me-fe),pt=-18*ne*Oe,mt=-2*N*ue,ht=-2*N*(de-le),gt=2*he*z,_t=2*he*ve,vt=2*L*xe,yt=2*L*(Se-be),bt=-2*ge*V,xt=-2*ge*(ye-B),St=-2*ge*(-21-9*Re)*ke,Ct=2*R*Ee,wt=2*R*(De-H),Tt=-18*R*ke,Et=-2*L*we,Dt=-2*L*(Te-Ce);return{snodm:Me,cnodm:Ne,sinim:Ie,cosim:Le,sinomm:Pe,cosomm:Fe,day:Ve,e3:_t,ee2:gt,em:je,emsq:Re,gam:Ye,peo:0,pgho:0,pho:0,pinco:0,plo:0,rtemsq:Be,se2:it,se3:at,sgh2:dt,sgh3:ft,sgh4:pt,sh2:mt,sh3:ht,si2:ot,si3:st,sl2:ct,sl3:lt,sl4:ut,s1:he,s2:L,s3:ge,s4:R,s5:_e,s6:z,s7:ve,ss1:ee,ss2:N,ss3:te,ss4:ne,ss5:re,ss6:P,ss7:ie,sz1:ae,sz2:F,sz3:I,sz11:oe,sz12:se,sz13:ce,sz21:le,sz22:ue,sz23:de,sz31:fe,sz32:pe,sz33:me,xgh2:Ct,xgh3:wt,xgh4:Tt,xh2:Et,xh3:Dt,xi2:vt,xi3:yt,xl2:bt,xl3:xt,xl4:St,nm:Ae,z1:B,z2:V,z3:ye,z11:be,z12:xe,z13:Se,z21:Ce,z22:we,z23:Te,z31:H,z32:Ee,z33:De,zmol:nt,zmos:rt}}function Jh(e){let{cosim:t,argpo:n,s1:r,s2:i,s3:a,s4:o,s5:s,sinim:c,ss1:l,ss2:u,ss3:d,ss4:f,ss5:p,sz1:m,sz3:h,sz11:g,sz13:_,sz21:v,sz23:y,sz31:b,sz33:x,t:S,tc:C,gsto:w,mo:T,mdot:E,no:D,nodeo:O,nodedot:k,xpidot:A,z1:j,z3:M,z11:ee,z13:N,z21:te,z23:ne,z31:re,z33:P,ecco:ie,eccsq:ae}=e,{emsq:F,em:I,argpm:oe,inclm:se,mm:ce,nm:le,nodem:ue,irez:de,atime:fe,d2201:pe,d2211:me,d3210:he,d3222:L,d4410:ge,d4422:R,d5220:_e,d5232:z,d5421:ve,d5433:B,dedt:V,didt:ye,dmdt:be,dnodt:xe,domdt:Se,del1:Ce,del2:we,del3:Te,xfact:H,xlamo:Ee,xli:De,xni:Oe}=e,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,et,tt,nt,rt,it,at,ot,st=.0043752690880113,ct=.00015835218,lt=119459e-10;de=0,le<.0052359877&&le>.0034906585&&(de=1),le>=.00826&&le<=.00924&&I>=.5&&(de=2);let ut=l*lt*p,dt=u*lt*(g+_),ft=-lt*d*(m+h-14-6*F),pt=f*lt*(b+x-6),mt=-lt*u*(v+y);(se<.052359877||se>kh-.052359877)&&(mt=0),c!==0&&(mt/=c);let ht=pt-t*mt;V=ut+r*ct*s,ye=dt+i*ct*(ee+N),be=ft-ct*a*(j+M-14-6*F);let gt=o*ct*(re+P-6),_t=-ct*i*(te+ne);(se<.052359877||se>kh-.052359877)&&(_t=0),Se=ht+gt,xe=mt,c!==0&&(Se-=t/c*_t,xe+=_t/c);let vt=(w+C*st)%Ah;if(I+=V*S,se+=ye*S,oe+=Se*S,ue+=xe*S,ce+=be*S,de!==0){if(it=(le/Ph)**Vh,de===2){at=t*t;let e=I;I=ie;let n=F;F=ae,ot=I*F,He=-.306-(I-.64)*.44,I<=.65?(Ue=3.616-13.247*I+16.29*F,Ge=-19.302+117.39*I-228.419*F+156.591*ot,Ke=-18.9068+109.7927*I-214.6334*F+146.5816*ot,qe=-41.122+242.694*I-471.094*F+313.953*ot,Je=-146.407+841.88*I-1629.014*F+1083.435*ot,Ye=-532.114+3017.977*I-5740.032*F+3708.276*ot):(Ue=-72.099+331.819*I-508.738*F+266.724*ot,Ge=-346.844+1582.851*I-2415.925*F+1246.113*ot,Ke=-342.585+1554.908*I-2366.899*F+1215.972*ot,qe=-1052.797+4758.686*I-7193.992*F+3651.957*ot,Je=-3581.69+16178.11*I-24462.77*F+12422.52*ot,Ye=I>.715?-5149.66+29936.92*I-54087.36*F+31324.56*ot:1464.74-4664.75*I+3763.64*F),I<.7?(Qe=-919.2277+4988.61*I-9064.77*F+5542.21*ot,Xe=-822.71072+4568.6173*I-8491.4146*F+5337.524*ot,Ze=-853.666+4690.25*I-8624.77*F+5341.4*ot):(Qe=-37995.78+161616.52*I-229838.2*F+109377.94*ot,Xe=-51752.104+218913.95*I-309468.16*F+146349.42*ot,Ze=-40023.88+170470.89*I-242699.48*F+115605.82*ot),$e=c*c,ke=.75*(1+2*t+at),Ae=1.5*$e,Me=1.875*c*(1-2*t-3*at),Ne=-1.875*c*(1+2*t-3*at),Fe=35*$e*ke,Ie=39.375*$e*$e,Le=9.84375*c*($e*(1-2*t-5*at)+.33333333*(-2+4*t+6*at)),Re=c*(4.92187512*$e*(-2-4*t+10*at)+6.56250012*(1+2*t-3*at)),ze=29.53125*c*(2-8*t+at*(-12+8*t+10*at)),Be=29.53125*c*(-2-8*t+at*(12+8*t-10*at)),nt=le*le,rt=it*it,tt=3*nt*rt,et=tt*17891679e-13,pe=et*ke*He,me=et*Ae*Ue,tt*=it,et=tt*3.7393792e-7,he=et*Me*Ge,L=et*Ne*Ke,tt*=it,et=2*tt*7.3636953e-9,ge=et*Fe*qe,R=et*Ie*Je,tt*=it,et=tt*1.1428639e-7,_e=et*Le*Ye,z=et*Re*Ze,et=2*tt*2.1765803e-9,ve=et*ze*Xe,B=et*Be*Qe,Ee=(T+O+O-(vt+vt))%Ah,H=E+be+2*(k+xe-st)-D,I=e,F=n}de===1&&(Ve=1+F*(-2.5+.8125*F),Ge=1+2*F,We=1+F*(-6+6.60937*F),ke=.75*(1+t)*(1+t),je=.9375*c*c*(1+3*t)-.75*(1+t),Pe=1+t,Pe*=1.875*Pe*Pe,Ce=3*le*le*it*it,we=2*Ce*ke*Ve*17891679e-13,Te=3*Ce*Pe*We*2.2123015e-7*it,Ce=Ce*je*Ge*21460748e-13*it,Ee=(T+O+n-vt)%Ah,H=E+A+be+Se+xe-(D+st)),De=Ee,Oe=D,fe=0,le=D+0}return{em:I,argpm:oe,inclm:se,mm:ce,nm:le,nodem:ue,irez:de,atime:fe,d2201:pe,d2211:me,d3210:he,d3222:L,d4410:ge,d4422:R,d5220:_e,d5232:z,d5421:ve,d5433:B,dedt:V,didt:ye,dmdt:be,dndt:0,dnodt:xe,domdt:Se,del1:Ce,del2:we,del3:Te,xfact:H,xlamo:Ee,xli:De,xni:Oe}}function Yh(e){let t=(e-2451545)/36525,n=-62e-7*t*t*t+.093104*t*t+3164400184.812866*t+67310.54841;return n=n*jh/240%Ah,n<0&&(n+=Ah),n}function Xh(e,t,n,r,i,a,o){return e instanceof Date?Yh(Gh(e)):Yh(t===void 0?e:Gh(e,t,n,r,i,a,o))}function Zh(e){let{ecco:t,epoch:n,inclo:r,opsmode:i}=e,{no:a}=e,o=t*t,s=1-o,c=Math.sqrt(s),l=Math.cos(r),u=l*l,d=(Ph/a)**Vh,f=.75*Lh*(3*u-1)/(c*s),p=f/(d*d),m=d*(1-p*p-p*(1/3+134*p*p/81));p=f/(m*m),a/=1+p;let h=(Ph/a)**Vh,g=Math.sin(r),_=h*s,v=1-5*u,y=-v-u-u,b=1/h,x=_*_,S=h*(1-t),C;if(i===`a`){let e=n-7305,t=Math.floor(e+1e-8),r=e-t,i=.017202791694070362,a=i+Ah;C=(1.7321343856509375+i*t+a*r+e*e*5075514194322695e-30)%Ah,C<0&&(C+=Ah)}else C=Xh(n+2433281.5);return{no:a,method:`n`,ainv:b,ao:h,con41:y,con42:v,cosio:l,cosio2:u,eccsq:o,omeosq:s,posq:x,rp:S,rteosq:c,sinio:g,gsto:C}}function Qh(e){let{irez:t,d2201:n,d2211:r,d3210:i,d3222:a,d4410:o,d4422:s,d5220:c,d5232:l,d5421:u,d5433:d,dedt:f,del1:p,del2:m,del3:h,didt:g,dmdt:_,dnodt:v,domdt:y,argpo:b,argpdot:x,t:S,tc:C,gsto:w,xfact:T,xlamo:E,no:D}=e,{atime:O,em:k,argpm:A,inclm:j,xli:M,mm:ee,xni:N,nodem:te,nm:ne}=e,re=.13130908,P=2.8843198,ie=.37448087,ae=5.7686396,F=.95240898,I=1.8014998,oe=1.050833,se=4.4108898,ce=259200,le,ue,de,fe,pe,me,he,L,ge=0,R=0,_e=(w+C*.0043752690880113)%Ah;if(k+=f*S,j+=g*S,A+=y*S,te+=v*S,ee+=_*S,t!==0){(O===0||S*O<=0||Math.abs(S)<Math.abs(O))&&(O=0,N=D,M=E),le=S>0?720:-720;let e=381;for(;e===381;)t===2?(L=b+x*O,de=L+L,ue=M+M,he=n*Math.sin(de+M-ae)+r*Math.sin(M-ae)+i*Math.sin(L+M-F)+a*Math.sin(-L+M-F)+o*Math.sin(de+ue-I)+s*Math.sin(ue-I)+c*Math.sin(L+M-oe)+l*Math.sin(-L+M-oe)+u*Math.sin(L+ue-se)+d*Math.sin(-L+ue-se),pe=N+T,me=n*Math.cos(de+M-ae)+r*Math.cos(M-ae)+i*Math.cos(L+M-F)+a*Math.cos(-L+M-F)+c*Math.cos(L+M-oe)+l*Math.cos(-L+M-oe)+2*(o*Math.cos(de+ue-I)+s*Math.cos(ue-I)+u*Math.cos(L+ue-se)+d*Math.cos(-L+ue-se)),me*=pe):(he=p*Math.sin(M-re)+m*Math.sin(2*(M-P))+h*Math.sin(3*(M-ie)),pe=N+T,me=p*Math.cos(M-re)+2*m*Math.cos(2*(M-P))+3*h*Math.cos(3*(M-ie)),me*=pe),Math.abs(S-O)>=720?e=381:(R=S-O,e=0),e===381&&(M+=pe*le+he*ce,N+=he*le+me*ce,O+=le);ne=N+he*R+me*R*R*.5,fe=M+pe*R+he*R*R*.5,t===1?(ee=fe-te-A+_e,ge=ne-D):(ee=fe-2*te+2*_e,ge=ne-D),ne=D+ge}return{atime:O,em:k,argpm:A,inclm:j,xli:M,mm:ee,xni:N,nodem:te,dndt:ge,nm:ne}}var $h;(function(e){e[e.None=0]=`None`,e[e.MeanEccentricityOutOfRange=1]=`MeanEccentricityOutOfRange`,e[e.MeanMotionBelowZero=2]=`MeanMotionBelowZero`,e[e.PerturbedEccentricityOutOfRange=3]=`PerturbedEccentricityOutOfRange`,e[e.SemiLatusRectumBelowZero=4]=`SemiLatusRectumBelowZero`,e[e.Decayed=6]=`Decayed`})($h||={});function eg(e,t){let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O;e.t=t,e.error=$h.None;let k=e.mo+e.mdot*e.t,A=e.argpo+e.argpdot*e.t,j=e.nodeo+e.nodedot*e.t;u=A,S=k;let M=e.t*e.t;if(w=j+e.nodecf*M,v=1-e.cc1*e.t,y=e.bstar*e.cc4*e.t,b=e.t2cof*M,e.isimp!==1){c=e.omgcof*e.t;let t=1+e.eta*Math.cos(k);s=e.xmcof*(t*t*t-e.delmo),_=c+s,S=k+_,u=A-_,p=M*e.t,m=p*e.t,v=v-e.d2*M-e.d3*p-e.d4*m,y+=e.bstar*e.cc5*(Math.sin(S)-e.sinmao),b=b+e.t3cof*p+m*(e.t4cof+e.t*e.t5cof)}C=e.no;let ee=e.ecco;if(x=e.inclo,e.method===`d`){h=e.t;let t=Qh({irez:e.irez,d2201:e.d2201,d2211:e.d2211,d3210:e.d3210,d3222:e.d3222,d4410:e.d4410,d4422:e.d4422,d5220:e.d5220,d5232:e.d5232,d5421:e.d5421,d5433:e.d5433,dedt:e.dedt,del1:e.del1,del2:e.del2,del3:e.del3,didt:e.didt,dmdt:e.dmdt,dnodt:e.dnodt,domdt:e.domdt,argpo:e.argpo,argpdot:e.argpdot,t:e.t,tc:h,gsto:e.gsto,xfact:e.xfact,xlamo:e.xlamo,no:e.no,atime:e.atime,em:ee,argpm:u,inclm:x,xli:e.xli,mm:S,xni:e.xni,nodem:w,nm:C});({em:ee,argpm:u,inclm:x,mm:S,nodem:w,nm:C}=t)}if(C<=0)return e.error=$h.MeanMotionBelowZero,null;let N=(Ph/C)**Vh*v*v;if(C=Ph/N**1.5,ee-=y,ee>=1||ee<-.001)return e.error=$h.MeanEccentricityOutOfRange,null;ee<1e-6&&(ee=1e-6),S+=e.no*b,E=S+u+w,w%=Ah,u%=Ah,E%=Ah,S=(E-u-w)%Ah;let te={am:N,em:ee,im:x,Om:w,om:u,mm:S,nm:C},ne=Math.sin(x),re=Math.cos(x),P=ee;if(T=x,d=u,O=w,D=S,a=ne,i=re,e.method===`d`){let t=Kh(e,{inclo:e.inclo,init:`n`,ep:P,inclp:T,nodep:O,argpp:d,mp:D,opsmode:e.operationmode});if({ep:P,nodep:O,argpp:d,mp:D}=t,T=t.inclp,T<0&&(T=-T,O+=kh,d-=kh),P<0||P>1)return e.error=$h.PerturbedEccentricityOutOfRange,null}e.method===`d`&&(a=Math.sin(T),i=Math.cos(T),e.aycof=-.5*Bh*a,Math.abs(i+1)>15e-13?e.xlcof=-.25*Bh*a*(3+5*i)/(1+i):e.xlcof=-.25*Bh*a*(3+5*i)/15e-13);let ie=P*Math.cos(d);_=1/(N*(1-P*P));let ae=P*Math.sin(d)+_*e.aycof,F=(D+d+O+_*e.xlcof*ie-O)%Ah;l=F,g=9999.9;let I=1;for(;Math.abs(g)>=1e-12&&I<=10;)r=Math.sin(l),n=Math.cos(l),g=1-n*ie-r*ae,g=(F-ae*n+ie*r-l)/g,Math.abs(g)>=.95&&(g=g>0?.95:-.95),l+=g,I+=1;let oe=ie*n+ae*r,se=ie*r-ae*n,ce=ie*ie+ae*ae,le=N*(1-ce);if(le<0)return e.error=$h.SemiLatusRectumBelowZero,null;let ue=N*(1-oe),de=Math.sqrt(N)*se/ue,fe=Math.sqrt(le)/ue,pe=Math.sqrt(1-ce);_=se/(1+pe);let me=N/ue*(r-ae-ie*_),he=N/ue*(n-ie+ae*_);f=Math.atan2(me,he);let L=(he+he)*me,ge=1-2*me*me;_=1/le;let R=.5*Lh*_,_e=R*_;e.method===`d`&&(o=i*i,e.con41=3*o-1,e.x1mth2=1-o,e.x7thm1=7*o-1);let z=ue*(1-1.5*_e*pe*e.con41)+.5*R*e.x1mth2*ge;if(z<1)return e.error=$h.Decayed,null;f-=.25*_e*e.x7thm1*L;let ve=O+1.5*_e*i*L,B=T+1.5*_e*i*a*ge,V=de-C*R*e.x1mth2*L/Ph,ye=fe+C*R*(e.x1mth2*ge+1.5*e.con41)/Ph,be=Math.sin(f),xe=Math.cos(f),Se=Math.sin(ve),Ce=Math.cos(ve),we=Math.sin(B),Te=Math.cos(B),H=-Se*Te,Ee=Ce*Te,De=H*be+Ce*xe,Oe=Ee*be+Se*xe,ke=we*be,Ae=H*xe-Ce*be,je=Ee*xe-Se*be,Me=we*xe;return{position:{x:z*De*Nh,y:z*Oe*Nh,z:z*ke*Nh},velocity:{x:(V*De+ye*Ae)*Fh,y:(V*Oe+ye*je)*Fh,z:(V*ke+ye*Me)*Fh},meanElements:te}}function tg(e,t){let{opsmode:n,satn:r,epoch:i,xbstar:a,xecco:o,xargpo:s,xinclo:c,xmo:l,xno:u,xnodeo:d}=t,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,ee,N,te,ne,re,P,ie,ae,F,I,oe,se,ce,le,ue,de,fe,pe,me,he,L,ge,R,_e,z,ve,B,V,ye,be,xe,Se,Ce,we,Te,H=e;H.isimp=0,H.method=`n`,H.aycof=0,H.con41=0,H.cc1=0,H.cc4=0,H.cc5=0,H.d2=0,H.d3=0,H.d4=0,H.delmo=0,H.eta=0,H.argpdot=0,H.omgcof=0,H.sinmao=0,H.t=0,H.t2cof=0,H.t3cof=0,H.t4cof=0,H.t5cof=0,H.x1mth2=0,H.x7thm1=0,H.mdot=0,H.nodedot=0,H.xlcof=0,H.xmcof=0,H.nodecf=0,H.irez=0,H.d2201=0,H.d2211=0,H.d3210=0,H.d3222=0,H.d4410=0,H.d4422=0,H.d5220=0,H.d5232=0,H.d5421=0,H.d5433=0,H.dedt=0,H.del1=0,H.del2=0,H.del3=0,H.didt=0,H.dmdt=0,H.dnodt=0,H.domdt=0,H.e3=0,H.ee2=0,H.peo=0,H.pgho=0,H.pho=0,H.pinco=0,H.plo=0,H.se2=0,H.se3=0,H.sgh2=0,H.sgh3=0,H.sgh4=0,H.sh2=0,H.sh3=0,H.si2=0,H.si3=0,H.sl2=0,H.sl3=0,H.sl4=0,H.gsto=0,H.xfact=0,H.xgh2=0,H.xgh3=0,H.xgh4=0,H.xh2=0,H.xh3=0,H.xi2=0,H.xi3=0,H.xl2=0,H.xl3=0,H.xl4=0,H.xlamo=0,H.zmol=0,H.zmos=0,H.atime=0,H.xli=0,H.xni=0,H.bstar=a,H.ecco=o,H.argpo=s,H.inclo=c,H.mo=l,H.no=u,H.nodeo=d,H.operationmode=n;let Ee=78/Nh+1,De=42/Nh,Oe=De*De*De*De;H.init=`y`,H.t=0;let ke=Zh({satn:r,ecco:H.ecco,epoch:i,inclo:H.inclo,no:H.no,method:H.method,opsmode:H.operationmode}),{ao:Ae,con42:je,cosio:Me,cosio2:Ne,eccsq:Pe,omeosq:Fe,posq:Ie,rp:Le,rteosq:Re,sinio:ze}=ke;if(H.no=ke.no,H.con41=ke.con41,H.gsto=ke.gsto,H.a=(H.no*Ih)**(-2/3),H.alta=H.a*(1+H.ecco)-1,H.altp=H.a*(1-H.ecco)-1,H.error=0,Fe>=0||H.no>=0){if(H.isimp=0,Le<1.034492841559484&&(H.isimp=1),P=Ee,M=Oe,k=(Le-1)*Nh,k<156){P=k-78,k<98&&(P=20);let e=(120-P)/Nh;M=e*e*e*e,P=P/Nh+1}A=1/Ie,z=1/(Ae-P),H.eta=Ae*H.ecco*z,C=H.eta*H.eta,S=H.ecco*H.eta,j=Math.abs(1-C),_=M*z**4,v=_/j**3.5,h=v*H.no*(Ae*(1+1.5*C+S*(4+C))+.375*Lh*z/j*H.con41*(8+3*C*(8+C))),H.cc1=H.bstar*h,g=0,H.ecco>1e-4&&(g=-2*_*z*Bh*H.no*ze/H.ecco),H.x1mth2=1-Ne,H.cc4=2*H.no*v*Ae*Fe*(H.eta*(2+.5*C)+H.ecco*(.5+2*C)-Lh*z/(Ae*j)*(-3*H.con41*(1-2*S+C*(1.5-.5*S))+.75*H.x1mth2*(2*C-S*(1+C))*Math.cos(2*H.argpo))),H.cc5=2*v*Ae*Fe*(1+2.75*(C+S)+S*C),y=Ne*Ne,ge=1.5*Lh*A*H.no,R=.5*ge*Lh*A,_e=-.46875*zh*A*A*H.no,H.mdot=H.no+.5*ge*Re*H.con41+.0625*R*Re*(13-78*Ne+137*y),H.argpdot=-.5*ge*je+.0625*R*(7-114*Ne+395*y)+_e*(3-36*Ne+49*y),B=-ge*Me,H.nodedot=B+(.5*R*(4-19*Ne)+2*_e*(3-7*Ne))*Me,ve=H.argpdot+H.nodedot,H.omgcof=H.bstar*g*Math.cos(H.argpo),H.xmcof=0,H.ecco>1e-4&&(H.xmcof=-Vh*_*H.bstar/S),H.nodecf=3.5*Fe*B*H.cc1,H.t2cof=1.5*H.cc1,Math.abs(Me+1)>15e-13?H.xlcof=-.25*Bh*ze*(3+5*Me)/(1+Me):H.xlcof=-.25*Bh*ze*(3+5*Me)/15e-13,H.aycof=-.5*Bh*ze;let e=1+H.eta*Math.cos(H.mo);if(H.delmo=e*e*e,H.sinmao=Math.sin(H.mo),H.x7thm1=7*Ne-1,2*kh/H.no>=225){H.method=`d`,H.isimp=1,he=0,E=H.inclo;let e=qh({epoch:i,ep:H.ecco,argpp:H.argpo,tc:he,inclp:H.inclo,nodep:H.nodeo,np:H.no,e3:H.e3,ee2:H.ee2,peo:H.peo,pgho:H.pgho,pho:H.pho,pinco:H.pinco,plo:H.plo,se2:H.se2,se3:H.se3,sgh2:H.sgh2,sgh3:H.sgh3,sgh4:H.sgh4,sh2:H.sh2,sh3:H.sh3,si2:H.si2,si3:H.si3,sl2:H.sl2,sl3:H.sl3,sl4:H.sl4,xgh2:H.xgh2,xgh3:H.xgh3,xgh4:H.xgh4,xh2:H.xh2,xh3:H.xh3,xi2:H.xi2,xi3:H.xi3,xl2:H.xl2,xl3:H.xl3,xl4:H.xl4,zmol:H.zmol,zmos:H.zmos});H.e3=e.e3,H.ee2=e.ee2,H.peo=e.peo,H.pgho=e.pgho,H.pho=e.pho,H.pinco=e.pinco,H.plo=e.plo,H.se2=e.se2,H.se3=e.se3,H.sgh2=e.sgh2,H.sgh3=e.sgh3,H.sgh4=e.sgh4,H.sh2=e.sh2,H.sh3=e.sh3,H.si2=e.si2,H.si3=e.si3,H.sl2=e.sl2,H.sl3=e.sl3,H.sl4=e.sl4,{sinim:p,cosim:f,em:b,emsq:x,s1:ee,s2:N,s3:te,s4:ne,s5:re,ss1:ie,ss2:ae,ss3:F,ss4:I,ss5:oe,sz1:se,sz3:ce,sz11:le,sz13:ue,sz21:de,sz23:fe,sz31:pe,sz33:me}=e,H.xgh2=e.xgh2,H.xgh3=e.xgh3,H.xgh4=e.xgh4,H.xh2=e.xh2,H.xh3=e.xh3,H.xi2=e.xi2,H.xi3=e.xi3,H.xl2=e.xl2,H.xl3=e.xl3,H.xl4=e.xl4,H.zmol=e.zmol,H.zmos=e.zmos,{nm:O,z1:V,z3:ye,z11:be,z13:xe,z21:Se,z23:Ce,z31:we,z33:Te}=e;let t=Kh(H,{inclo:E,init:H.init,ep:H.ecco,inclp:H.inclo,nodep:H.nodeo,argpp:H.argpo,mp:H.mo,opsmode:H.operationmode});H.ecco=t.ep,H.inclo=t.inclp,H.nodeo=t.nodep,H.argpo=t.argpp,H.mo=t.mp,w=0,T=0,D=0;let n=Jh({cosim:f,emsq:x,argpo:H.argpo,s1:ee,s2:N,s3:te,s4:ne,s5:re,sinim:p,ss1:ie,ss2:ae,ss3:F,ss4:I,ss5:oe,sz1:se,sz3:ce,sz11:le,sz13:ue,sz21:de,sz23:fe,sz31:pe,sz33:me,t:H.t,tc:he,gsto:H.gsto,mo:H.mo,mdot:H.mdot,no:H.no,nodeo:H.nodeo,nodedot:H.nodedot,xpidot:ve,z1:V,z3:ye,z11:be,z13:xe,z21:Se,z23:Ce,z31:we,z33:Te,ecco:H.ecco,eccsq:Pe,em:b,argpm:w,inclm:E,mm:D,nm:O,nodem:T,irez:H.irez,atime:H.atime,d2201:H.d2201,d2211:H.d2211,d3210:H.d3210,d3222:H.d3222,d4410:H.d4410,d4422:H.d4422,d5220:H.d5220,d5232:H.d5232,d5421:H.d5421,d5433:H.d5433,dedt:H.dedt,didt:H.didt,dmdt:H.dmdt,dnodt:H.dnodt,domdt:H.domdt,del1:H.del1,del2:H.del2,del3:H.del3,xfact:H.xfact,xlamo:H.xlamo,xli:H.xli,xni:H.xni});H.irez=n.irez,H.atime=n.atime,H.d2201=n.d2201,H.d2211=n.d2211,H.d3210=n.d3210,H.d3222=n.d3222,H.d4410=n.d4410,H.d4422=n.d4422,H.d5220=n.d5220,H.d5232=n.d5232,H.d5421=n.d5421,H.d5433=n.d5433,H.dedt=n.dedt,H.didt=n.didt,H.dmdt=n.dmdt,H.dnodt=n.dnodt,H.domdt=n.domdt,H.del1=n.del1,H.del2=n.del2,H.del3=n.del3,H.xfact=n.xfact,H.xlamo=n.xlamo,H.xli=n.xli,H.xni=n.xni}H.isimp!==1&&(m=H.cc1*H.cc1,H.d2=4*Ae*z*m,L=H.d2*z*H.cc1/3,H.d3=(17*Ae+P)*L,H.d4=.5*L*Ae*z*(221*Ae+31*P)*H.cc1,H.t3cof=H.d2+2*m,H.t4cof=.25*(3*H.d3+H.cc1*(12*H.d2+10*m)),H.t5cof=.2*(3*H.d4+12*H.cc1*H.d3+6*H.d2*H.d2+15*m*(2*H.d2+m)))}eg(H,0),H.init=`n`}function ng(e,t){let n=e.substring(2,7),r=parseInt(e.substring(18,20),10),i=parseFloat(e.substring(20,32)),a=parseFloat(e.substring(33,43)),o=parseFloat(`${e.substring(44,45)}.${e.substring(45,50)}E${e.substring(50,52)}`),s=parseFloat(`${e.substring(53,54)}.${e.substring(54,59)}E${e.substring(59,61)}`),c=parseFloat(t.substring(8,16))*jh,l=parseFloat(t.substring(17,25))*jh,u=parseFloat(`.${t.substring(26,33).replace(/\s/g,`0`)}`),d=parseFloat(t.substring(34,42))*jh,f=parseFloat(t.substring(43,51))*jh,p=parseFloat(t.substring(52,63))/Hh;a/=Hh*1440,o/=Hh*1440*1440;let m=r<57?r+2e3:r+1900,{mon:h,day:g,hr:_,minute:v,sec:y}=Uh(m,i),b=Gh(m,h,g,_,v,y),x={error:0,satnum:n,epochyr:r,epochdays:i,ndot:a,nddot:o,bstar:s,inclo:c,nodeo:l,ecco:u,argpo:d,mo:f,no:p,jdsatepoch:b};return tg(x,{opsmode:`i`,satn:x.satnum,epoch:x.jdsatepoch-2433281.5,xbstar:x.bstar,xecco:x.ecco,xargpo:x.argpo,xinclo:x.inclo,xmo:x.mo,xno:x.no,xnodeo:x.nodeo}),x}function rg(e,t=`i`){let n=e.NORAD_CAT_ID.toString(),r=new Date(e.EPOCH.endsWith(`Z`)?e.EPOCH:`${e.EPOCH}Z`),i=r.getUTCFullYear(),a=Number(i.toString().slice(-2)),o=(r.valueOf()-new Date(Date.UTC(i,0,1,0,0,0)).valueOf())/(86400*1e3)+1,s=Number(e.MEAN_MOTION_DOT),c=Number(e.MEAN_MOTION_DDOT);s/=Hh*1440,c/=Hh*1440*1440;let l=Number(e.BSTAR),u=Number(e.INCLINATION)*jh,d=Number(e.RA_OF_ASC_NODE)*jh,f=Number(e.ECCENTRICITY),p=Number(e.ARG_OF_PERICENTER)*jh,m=Number(e.MEAN_ANOMALY)*jh,h=Number(e.MEAN_MOTION)/Hh,{mon:g,day:_,hr:v,minute:y,sec:b}=Uh(i,o),x=Gh(i,g,_,v,y,b),S={error:0,satnum:n,epochyr:a,epochdays:o,ndot:s,nddot:c,bstar:l,inclo:u,nodeo:d,ecco:f,argpo:p,mo:m,no:h,jdsatepoch:x};return tg(S,{opsmode:t,satn:S.satnum,epoch:S.jdsatepoch-2433281.5,xbstar:S.bstar,xecco:S.ecco,xargpo:S.argpo,xinclo:S.inclo,xmo:S.mo,xno:S.no,xnodeo:S.nodeo}),S}3*Float64Array.BYTES_PER_ELEMENT;var ig=149597870.7,ag=23.4392911,og=86400**2/ig**3,sg=1/ig;function Q(e){return e/ig*10}function cg(e){return e/10*ig}var lg=Math.cos(Math.PI/180*ag),ug=Math.sin(Math.PI/180*ag);function dg(e,t,n,r){let i=r??{x:0,y:0,z:0};return i.x=e,i.y=-t*ug+n*lg,i.z=-(t*lg+n*ug),i}var fg=Math.PI/180,pg=Math.cos(ag*fg),mg=Math.sin(ag*fg),hg=2440587.5;function gg(e){return new Date((e-hg)*864e5).toISOString()}function _g(e,t){let n=rg({OBJECT_NAME:t??String(e.noradCatId),OBJECT_ID:String(e.noradCatId),EPOCH:gg(e.epochJd),MEAN_MOTION:e.meanMotion,ECCENTRICITY:e.eccentricity,INCLINATION:e.inclination,RA_OF_ASC_NODE:e.raOfAscNode,ARG_OF_PERICENTER:e.argOfPericenter,MEAN_ANOMALY:e.meanAnomaly,EPHEMERIS_TYPE:0,CLASSIFICATION_TYPE:`U`,NORAD_CAT_ID:e.noradCatId,ELEMENT_SET_NO:e.elementSetNo,REV_AT_EPOCH:e.revAtEpoch,BSTAR:e.bstar,MEAN_MOTION_DOT:e.meanMotionDot,MEAN_MOTION_DDOT:e.meanMotionDdot});return n.error===$h.None?n:(console.warn(`buildSatrec: SGP4 init failed for NORAD ${e.noradCatId} (error=${n.error})`),null)}function vg(e,t){let n=eg(e,(t-e.jdsatepoch)*1440);if(!n||e.error!==$h.None)return null;let{x:r,y:i,z:a}=n.position;return[r,i,a]}function yg(e,t,n){let r=10/ig,i=e*r,a=t*r,o=n*r,s=a*pg+o*mg,c=-a*mg+o*pg;return a=s,o=c,[i,o,-a]}function bg(e,t){let n=vg(e,t);return n?yg(n[0],n[1],n[2]):null}function xg(e,t,n=1e-10,r=50){let i=e;for(let a=0;a<r;a++){let r=(i-t*Math.sin(i)-e)/(1-t*Math.cos(i));if(i-=Math.max(-1,Math.min(1,r)),Math.abs(r)<n)break}return i}var Sg=700;function Cg(e,t,n=1e-10,r=50){if(e===0)return 0;let i=e<0?-1:1,a=Math.abs(e),o=0,s=1;for(;t*Math.sinh(s)-s<a;)if(s*=2,s>Sg)return NaN;let c=.5*(o+s);for(let e=0;e<r;e++){let e=t*Math.sinh(c)-c-a;e>0?s=c:o=c;let r=c-e/(t*Math.cosh(c)-1);r>o&&r<s||(r=.5*(o+s));let i=Math.abs(r-c);if(c=r,i<n)break}return i*c}function wg(e,t,n){let r=.01720209895*(n-t)/(Math.sqrt(2)*e**1.5),i=Math.cbrt(3*r+Math.sqrt(1+9*r*r)),a=i-1/i,o=2*Math.atan(a),s=e*(1+a*a);return!isFinite(o)||!isFinite(s)||s<=0?null:{nu:o,r:s}}var Tg=null,Eg=null;function Dg(){if(!Eg){Tg=[];let e=new MessageChannel;e.port1.onmessage=()=>Tg.shift()?.(),Eg=e.port2}return new Promise(e=>{Tg.push(e),Eg.postMessage(null)})}var Og=2451545,kg=86400,Ag=2440587.5,jg=864e5;function Mg(e){return e/jg+Ag}function Ng(e){return Mg(e.getTime())}function Pg(e){return new Date((e-Ag)*jg)}function Fg(e){return(e-Og)*kg}function Ig(e){return Og+e/kg}var Lg=Math.PI/180;Math.cos(ag*Lg),Math.sin(ag*Lg),10/ig;function Rg(e,t,n,r,i,a,o,s,c,l,u,d){e.a[t]=n,e.e[t]=r,e.i[t]=i,e.om[t]=a,e.w[t]=o,e.ma[t]=s,e.n[t]=c,e.epoch[t]=l,e.equatorial[t]=+!!u,e.flags[t]=d}function zg(e,t,n,r){let i=n.data;if(r?.has(i.id))return e.kind[t]=0,!1;if(i.omm)e.kind[t]=3,e.satnum[t]=i.omm.noradCatId,e.bstar[t]=i.omm.bstar,e.ndot[t]=i.omm.meanMotionDot,e.nddot[t]=i.omm.meanMotionDdot;else if(i.satrec)e.kind[t]=3,e.satrec[t]=i.satrec;else if(i.q!=null&&i.tp!=null&&isFinite(i.q)&&isFinite(i.tp))e.kind[t]=2,e.q[t]=i.q,e.tp[t]=i.tp;else if(i.a!==0&&isFinite(i.a))e.kind[t]=1;else return e.kind[t]=0,!1;return Rg(e,t,i.a,i.e,i.i,i.om,i.w,i.ma,i.n,i.epoch,i.equatorial,i.flags??0),!0}async function Bg(e,t,n=!1){let r=e.length,i=Ug(r);i.applyFlagFilter=n;let a=1/0,o=-1/0,s=performance.now();for(let n=0;n<r;n++){if((n&4095)==4095&&performance.now()-s>6&&(await Dg(),s=performance.now()),!zg(i,n,e[n],t))continue;let r=e[n].data;r.validityStart<a&&(a=r.validityStart),r.validityEnd>o&&(o=r.validityEnd)}return i.validityStart=a===1/0?-1/0:a,i.validityEnd=o===-1/0?1/0:o,i}var Vg=[{name:`kind`,make:e=>new Uint8Array(e)},{name:`equatorial`,make:e=>new Uint8Array(e)},{name:`a`,make:e=>new Float64Array(e)},{name:`e`,make:e=>new Float64Array(e)},{name:`i`,make:e=>new Float64Array(e)},{name:`om`,make:e=>new Float64Array(e)},{name:`w`,make:e=>new Float64Array(e)},{name:`ma`,make:e=>new Float64Array(e)},{name:`n`,make:e=>new Float64Array(e)},{name:`epoch`,make:e=>new Float64Array(e)},{name:`q`,make:e=>new Float64Array(e)},{name:`tp`,make:e=>new Float64Array(e)},{name:`flags`,make:e=>new Uint8Array(e)},{name:`visibleFromDays`,make:e=>new Float32Array(e).fill(NaN)},{name:`satnum`,make:e=>new Int32Array(e)},{name:`bstar`,make:e=>new Float64Array(e)},{name:`ndot`,make:e=>new Float64Array(e)},{name:`nddot`,make:e=>new Float64Array(e)},{name:`satrec`,make:e=>Array(e).fill(null),transferable:!1}];function Hg(e){let t=[];for(let n of Vg)n.transferable!==!1&&t.push(e[n.name].buffer);return t}function Ug(e){let t={count:e,applyFlagFilter:!1,validityStart:-1/0,validityEnd:1/0,pickBase:0};for(let n of Vg)t[n.name]=n.make(e);return t}function Wg(e,t){return e.get(t)?.name||null}function Gg(e,t){return e.get(t)?.isMinor??!1}function Kg(e,t){let n=e.get(t);return{name:n?.name||null,isMinor:n?.isMinor??!1}}function qg(e,t,n,r){let i=e.scale[t]===rn.PLANET,a=e.omDot[t],o=e.wDot[t],s=Sh(e,t);if(s===null)return null;let{name:c,isMinor:l}=Kg(n,s);return{id:s,name:c,isMinor:l,hasLocalized:e.hasLocalized[t]===1,flags:e.flags[t],objectType:e.objectType[t],parentId:`${r}-${e.parentId[t]}`,radiusKm:e.radiusKm[t],a:i?e.a[t]/ig:e.a[t],e:e.e[t],i:e.i[t],om:e.om[t],w:e.w[t],ma:e.ma[t],n:i?e.n[t]*360:e.n[t],epoch:e.epochJd[t],omDot:a===0?void 0:a,wDot:o===0?void 0:o,equatorial:i,validityStart:e.validityStart,validityEnd:e.validityEnd,orbitalSource:e.source,visibleFromDays:e.visibleFromDays[t]}}function Jg(e,t,n,r){let i=Sh(e,t);if(i===null)return null;let{name:a,isMinor:o}=Kg(n,i);return{id:i,name:a,isMinor:o,hasLocalized:e.hasLocalized[t]===1,flags:e.flags[t],objectType:e.objectType[t],parentId:`${r}-${e.parentId[t]}`,radiusKm:e.radiusKm[t],a:0,e:e.e[t],i:e.i[t],om:e.om[t],w:e.w[t],ma:0,n:0,epoch:e.epochJd[t],q:e.q[t],tp:e.tp[t],validityStart:e.validityStart,validityEnd:e.validityEnd,orbitalSource:e.source,visibleFromDays:e.visibleFromDays[t]}}var Yg=new WeakMap,Xg=new WeakMap;function Zg(e,t){return{noradCatId:e.id[t],epochJd:e.epochJd[t],meanMotion:e.n[t],eccentricity:e.e[t],inclination:e.i[t],raOfAscNode:e.om[t],argOfPericenter:e.w[t],meanAnomaly:e.ma[t],bstar:e.bstar[t],meanMotionDot:e.meanMotionDot[t],meanMotionDdot:e.meanMotionDdot[t],elementSetNo:e.elementSetNo[t],revAtEpoch:e.revAtEpoch[t]}}var Qg={get omm(){let e=Xg.get(this);return e&&Zg(e[0],e[1])},get satrec(){let e=this,t=Yg.get(e);return t===void 0&&(t=_g(e.omm,e.name??void 0),Yg.set(e,t),t||(e.unplaceable=!0)),t??void 0}};function $g(e,t,n,r){let i=Sh(e,t);if(i===null)return null;let{name:a,isMinor:o}=Kg(n,i),s=Object.assign(Object.create(Qg),{id:i,name:a,isMinor:o,hasLocalized:e.hasLocalized[t]===1,flags:e.flags[t],objectType:e.objectType[t],parentId:`${r}-${e.parentId[t]}`,radiusKm:e.radiusKm[t],a:e.a[t]/ig,e:e.e[t],i:e.i[t],om:e.om[t],w:e.w[t],ma:e.ma[t],n:e.n[t]*360,epoch:e.epochJd[t],equatorial:!0,validityStart:e.validityStart,validityEnd:e.validityEnd,orbitalSource:e.source,visibleFromDays:e.visibleFromDays[t]});return Xg.set(s,[e,t]),s}function e_(e,t,n,r){return e.kind===`parabolic`?Jg(e,t,n,r):e.kind===`sgp4`?$g(e,t,n,r):qg(e,t,n,r)}function t_(e,t,n,r,i,a){if(a&&i!==void 0&&a.has(i))return n.kind[r]=0,!1;if(e.kind===`parabolic`){let i=e.q[t],a=e.tp[t];return isFinite(i)&&isFinite(a)?(n.kind[r]=2,n.q[r]=i,n.tp[r]=a,Rg(n,r,0,e.e[t],e.i[t],e.om[t],e.w[t],0,0,e.epochJd[t],!1,e.flags[t]),n.visibleFromDays[r]=e.visibleFromDays[t],!0):(n.kind[r]=0,!1)}if(e.kind===`sgp4`)return n.kind[r]=3,n.satrec[r]=null,n.satnum[r]=e.id[t],n.bstar[r]=e.bstar[t],n.ndot[r]=e.meanMotionDot[t],n.nddot[r]=e.meanMotionDdot[t],Rg(n,r,e.a[t]/ig,e.e[t],e.i[t],e.om[t],e.w[t],e.ma[t],e.n[t]*360,e.epochJd[t],!0,e.flags[t]),n.visibleFromDays[r]=e.visibleFromDays[t],!0;let o=e.scale[t]===rn.PLANET,s=o?e.a[t]/ig:e.a[t];return s!==0&&isFinite(s)?(n.kind[r]=1,Rg(n,r,s,e.e[t],e.i[t],e.om[t],e.w[t],e.ma[t],o?e.n[t]*360:e.n[t],e.epochJd[t],o,e.flags[t]),n.visibleFromDays[r]=e.visibleFromDays[t],!0):(n.kind[r]=0,!1)}var n_={"naif-10":`#ffdd44`,"naif-199":`#b5b5b5`,"naif-299":`#e8cda0`,"naif-399":`#4da6ff`,"naif-301":`#888888`,"naif-499":`#c1440e`,"naif-401":`#aa9988`,"naif-402":`#aa9988`,"naif-599":`#d4a66a`,"naif-501":`#8a762e`,"naif-502":`#7c7f6c`,"naif-503":`#7e6c5e`,"naif-504":`#6c6453`,"naif-699":`#e8d8a0`,"naif-601":`#aba890`,"naif-602":`#71a29f`,"naif-603":`#6c6645`,"naif-604":`#494a2a`,"naif-605":`#5c5a3c`,"naif-606":`#835422`,"naif-608":`#776b60`,"naif-799":`#87ceeb`,"naif-701":`#b0b0b0`,"naif-702":`#a8a8a8`,"naif-703":`#62534c`,"naif-704":`#626a62`,"naif-705":`#625252`,"naif-899":`#3f54ba`,"naif-801":`#7c757c`,"naif-999":`#b48977`,"naif-2000001":`#9b9087`},r_=`#cccccc`,i_=`#fcb493`,a_=`#c7ccda`,o_=`#ffe89e`,s_=`#ccb49a`,c_=`#d8ffe8`,l_=`#e8a85c`,u_=`#bed4ec`,d_=`#d5cfe7`,f_=`naif-10`,p_=`naif-399`,m_=new Set(`naif-0.naif-9.spkid-20000002.spkid-20000003.spkid-20000007.spkid-20000010.spkid-20000015.spkid-20000031.spkid-20000052.spkid-20000065.spkid-20000088.spkid-20000107.spkid-20000130.spkid-20000511.spkid-20000588.spkid-20000704.spkid-20001862.spkid-1000592.spkid-1000616.spkid-1000630.spkid-1000639.spkid-1000648.spkid-1000651.spkid-1000669.spkid-1000690.spkid-1000738.spkid-1000742.spkid-1000749.spkid-1000755.spkid-1000778.spkid-1000845.spkid-1000872.spkid-1000882.spkid-1000899.spkid-1000945.spkid-1000967.spkid-1001121`.split(`.`));function h_(e){if(n_[e.id])return n_[e.id];let{objectType:t,parentId:n}=e;if(t===W.BARYCENTER){if(e.id===`naif-0`)return n_[`naif-10`];if(e.id===`naif-9`)return n_[`naif-999`];let t=`naif-${e.id.replace(`naif-`,``)}99`;if(n_[t])return n_[t]}if(t===W.STAR)return o_;if(t===W.PLANET||t===W.DWARF_PLANET)return i_;if(t===W.MOON)return a_;if(_n(t))return s_;if(t===W.COMET)return c_;if(t===W.DEBRIS)return l_;if(t===W.SPACECRAFT){if(n===`naif-399`)return u_;if(n===`naif-0`||n===`naif-10`)return d_}return r_}var g_=`#6b6b6b`;function __(e){return e.color??g_}function v_(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t>>>0}function y_(e,t){let n=Array.from({length:t},()=>[]);for(let r of e)n[v_(r.data.id)%t].push(r);return n}function b_(e,t,n){return{buckets:y_(t,t.length>=n*600?n:1),baseWorker:v_(e)%n}}async function x_(e,t,n){let r=t.length>=n*600?n:1,i=Array.from({length:r},()=>[]),a=performance.now();for(let e=0;e<t.length;e++){(e&16383)==16383&&performance.now()-a>6&&(await Dg(),a=performance.now());let n=t[e];i[v_(n.data.id)%r].push(n)}return{buckets:i,baseWorker:v_(e)%n}}function S_(e){let t=e.indexOf(`#`);return t<0?e:e.substring(0,t)}var C_=4096,w_=.75;function T_(e){let t=(e^Math.floor(e/4294967296))>>>0;return t=Math.imul(t^t>>>16,73244475),t=Math.imul(t^t>>>16,73244475),(t^t>>>16)>>>0}var E_=class{table=new Uint32Array(C_);mask=C_-1;count=0;constructor(e){this.keyOfRef=e}get size(){return this.count}slot(e){let t=T_(e)&this.mask;for(;;){let n=this.table[t];if(n===0||this.keyOfRef(n-1)===e)return t;t=t+1&this.mask}}get(e){let t=this.table[this.slot(e)];return t===0?void 0:t-1}has(e){return this.table[this.slot(e)]!==0}set(e,t,n=()=>!0){let r=this.slot(e),i=this.table[r];return i===0?(this.count++,this.count>this.table.length*w_&&(this.grow(),r=this.slot(e)),this.table[r]=t+1,!0):(n(i-1)&&(this.table[r]=t+1),!1)}grow(){let e=this.table;this.table=new Uint32Array(e.length*2),this.mask=this.table.length-1;for(let t of e){if(t===0)continue;let e=T_(this.keyOfRef(t-1))&this.mask;for(;this.table[e]!==0;)e=e+1&this.mask;this.table[e]=t}}*values(){for(let e of this.table)e!==0&&(yield e-1)}*keys(){for(let e of this.values())yield this.keyOfRef(e)}},D_=2**20,O_=4096,k_=6;function A_(e){let t=e>>>0;return t=Math.imul(t^t>>>16,73244475),t=Math.imul(t^t>>>16,73244475),(t^t>>>16)>>>0}var j_=class{chunks=[];rowOf=new E_(e=>this.keyOfRef(e));cache=new Map;placeholders=new Map;parentIdType=`naif`;constructor(e){this.labels=e}async addChunk(e,t,n){if(this.parentIdType=t,e.rowCount>=D_)throw Error(`MinorBucket: chunk too large (${e.rowCount} rows)`);let r=this.chunks.length;this.chunks.push(e);let i=0,a=this.placeholders.size>0,o=performance.now();for(let t=0;t<e.rowCount;t++){t%O_===O_-1&&performance.now()-o>k_&&(await Dg(),o=performance.now());let s=Ch(e,t);if(!(s===fh||n&&!n.has(s))&&(this.rowOf.set(s,r*D_+t,e=>Math.floor(e/D_)<=r)&&i++,a)){let n=Sh(e,t),r=n===null?void 0:this.placeholders.get(n);if(r){let n=e_(e,t,this.labels,this.parentIdType);n&&Object.assign(r.data,n)}}}return i}addPlaceholder(e){this.placeholders.set(e.data.id,e),this.cache.set(e.data.id,e)}keyOfRef(e){let t=Math.floor(e/D_);return Ch(this.chunks[t],e-t*D_)}get size(){let e=0;for(let t of this.placeholders.keys())this.hasRow(t)||e++;return this.rowOf.size+e}hasRow(e){let t=vh(e);return t!==null&&this.rowOf.has(t)}has(e){return this.hasRow(e)||this.placeholders.has(e)}hasKey(e){if(this.rowOf.has(e))return!0;if(this.placeholders.size===0)return!1;let t=_h(e);return t!==null&&this.placeholders.has(t)}*ids(){for(let e of this.rowOf.keys()){let t=_h(e);t!==null&&(yield t)}for(let e of this.placeholders.keys())this.hasRow(e)||(yield e)}*keys(){yield*this.rowOf.keys();for(let e of this.placeholders.keys()){let t=vh(e);t!==null&&!this.rowOf.has(t)&&(yield t)}}get(e){let t=this.cache.get(e);if(t)return t;let n=vh(e),r=n===null?void 0:this.rowOf.get(n);if(r===void 0)return;let i=Math.floor(r/D_),a=e_(this.chunks[i],r-i*D_,this.labels,this.parentIdType);if(!a)return;let o={data:a,position:[0,0,0],positionUnknown:!0};return this.cache.set(e,o),o}getKey(e){let t=_h(e);return t===null?void 0:this.get(t)}*values(){for(let e of this.ids()){let t=this.get(e);t&&(yield t)}}cloudColor(){let e=this.chunks.find(e=>e.rowCount>0);if(!e)return`#888888`;let t=e_(e,0,this.labels,this.parentIdType);return t?h_(t):`#888888`}async buildWorkerGroups(e,t,n,r){let i=this.rowOf.size,a=i>=t*600?t:1,o=new Float64Array(i),s=new Uint8Array(i),c=Array(a).fill(0),l=0,u=performance.now();for(let e of this.rowOf.values()){if(l===i)break;l%16384==0&&performance.now()-u>6&&(await Dg(),u=performance.now());let t=Math.floor(e/D_),n=a===1?0:A_(this.chunks[t].id[e-t*D_])%a;o[l]=e,s[l]=n,c[n]++,l++}let d=[];for(let e=0;e<a;e++){let t=Ug(c[e]);t.applyFlagFilter=!1,d.push({cols:t,colors:r?new Float32Array(c[e]*3):null,keys:new Float64Array(c[e]).fill(fh)})}let f=Array(a).fill(1/0),p=Array(a).fill(-1/0),m=Array(a).fill(0),h=r?new X:null;u=performance.now();for(let e=0;e<l;e++){(e&16383)==16383&&performance.now()-u>6&&(await Dg(),u=performance.now());let t=o[e],r=Math.floor(t/D_),i=t-r*D_,a=this.chunks[r],c=s[e],l=d[c],g=m[c]++,_=Ch(a,i);if(l.keys[g]=_,t_(a,i,l.cols,g,_,n)&&(a.validityStart<f[c]&&(f[c]=a.validityStart),a.validityEnd>p[c]&&(p[c]=a.validityEnd)),l.colors&&h){let e=e_(a,i,this.labels,this.parentIdType);h.set(e?h_(e):`#ffffff`),l.colors[g*3]=h.r,l.colors[g*3+1]=h.g,l.colors[g*3+2]=h.b}}for(let e=0;e<a;e++)d[e].cols.validityStart=f[e]===1/0?-1/0:f[e],d[e].cols.validityEnd=p[e]===-1/0?1/0:p[e];return{groups:d,baseWorker:v_(e)%t}}};function M_(e){return e===`naif-0`||e===`naif-10`}function N_(e){let t=/^naif-([1-9])$/.exec(e);return t?`naif-${t[1]}99`:null}function P_(e){return e===`naif-0`?f_:N_(e)}function F_(e){if(!M_(e))return N_(e)??e}var I_=class{bodiesById=new Map;majorBodies=[];asteroidBodiesByZone=new Map;spacecraftByParent=new Map;focusFeature=null;dirtyAsteroidZones=new Set;dirtySpacecraftGroups=new Set;minorStreaming=!1;#e=qe(0);get minorBodyVersion(){return Ut(this.#e)}set minorBodyVersion(e){Je(this.#e,e,!0)}#t=qe(0);get orientationVersion(){return Ut(this.#t)}set orientationVersion(e){Je(this.#t,e,!0)}orientationRead=new Set;hostRead=new Map;hostReadVersion=0;childrenByParent=new Map;moonMaxAByParent=new Map;addListeners=new Set;onBodiesAdded(e){return this.addListeners.add(e),()=>this.addListeners.delete(e)}notifyBodiesAdded(){for(let e of this.addListeners)e()}getBody(e,t){let n=this.bodiesById.get(e);if(n)return n;if(this.focusFeature?.data.id===e)return this.focusFeature;if(t!==void 0)return this.spacecraftByParent.get(t)?.get(e)??this.asteroidBodiesByZone.get(t)?.get(e);for(let t of this.spacecraftByParent.values()){let n=t.get(e);if(n)return n}for(let t of this.asteroidBodiesByZone.values()){let n=t.get(e);if(n)return n}}addBodies(e){let t=!1;for(let n of e){this.bodiesById.has(n.data.id)||(t=!0),this.bodiesById.set(n.data.id,n);let e=this.childrenByParent.get(n.data.parentId)??new Set;if(e.add(n.data.id),this.childrenByParent.set(n.data.parentId,e),n.data.objectType===W.MOON){let e=this.moonMaxAByParent.get(n.data.parentId)??0;n.data.a>e&&this.moonMaxAByParent.set(n.data.parentId,n.data.a)}}t&&this.notifyBodiesAdded()}asteroidBucket(e,t){let n=this.asteroidBodiesByZone.get(e);return n||this.asteroidBodiesByZone.set(e,n=new j_(t)),n}spacecraftBucket(e){let t=this.spacecraftByParent.get(e);return t||this.spacecraftByParent.set(e,t=new Map),t}flushMinor(e){this.asteroidBodiesByZone=new Map(this.asteroidBodiesByZone),this.spacecraftByParent=new Map(this.spacecraftByParent),this.minorBodyVersion++,e&&this.notifyBodiesAdded()}getChildren(e){return this.childrenByParent.get(e)}findAsteroidZone(e){for(let[t,n]of this.asteroidBodiesByZone)if(n.has(e))return t}maxMoonA(e){return this.moonMaxAByParent.get(e)}getSystemExtent(e){return this.moonMaxAByParent.get(e)??.01}isSystemBody(e){return M_(e.data.parentId)?!1:this.bodiesById.get(e.data.parentId)?.data.objectType!==W.BARYCENTER}isInSystem(e,t){return t?e===t?!0:this.childrenByParent.get(t)?.has(e)??!1:!1}getObjectCounts(){let e=0,t=0,n=0;for(let r of this.bodiesById.values()){let i=r.data.objectType;i===W.PLANET||i===W.DWARF_PLANET?e++:i===W.MOON?t++:i===W.SPACECRAFT&&n++}let r=this.spacecraftByParent.get(`naif-399`)?.size??0;r+=this.asteroidBodiesByZone.get(`earth`)?.size??0;for(let[e,t]of this.spacecraftByParent)e!==`naif-399`&&(n+=t.size);let i=0;for(let[e,t]of this.asteroidBodiesByZone)e!==`earth`&&(i+=t.size);for(let e of this.bodiesById.values())(_n(e.data.objectType)||e.data.objectType===W.COMET)&&i++;return{planets:e,moons:t,probes:n,earthSatellites:r,smallBodies:i}}};function L_(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function R_(e,t){let n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(n*n+r*r+i*i)}function z_(e,t,n,r){let i=e[0]-n[0],a=e[1]-n[1],o=e[2]-n[2],s=t[0]-n[0],c=t[1]-n[1],l=t[2]-n[2],u=Math.sqrt(i*i+a*a+o*o),d=Math.sqrt(s*s+c*c+l*l);if(u<1e-9||d<1e-9)return L_(e,t,r);let f=i/u,p=a/u,m=o/u,h=s/d,g=c/d,_=l/d,v=Math.max(-1,Math.min(1,f*h+p*g+m*_)),y=Math.acos(v),b=u+(d-u)*r;if(y<1e-4||Math.PI-y<1e-4)return L_(e,t,r);let x=Math.sin(y),S=Math.sin((1-r)*y)/x,C=Math.sin(r*y)/x,w=S*f+C*h,T=S*p+C*g,E=S*m+C*_;return[n[0]+w*b,n[1]+T*b,n[2]+E*b]}var B_={metadata:.12,ephemeris:.55,majors:.8,labels:.92,done:1},V_=[`metadata`,`ephemeris`,`majors`,`labels`,`done`],H_=.9,U_=new class{#e=0;#t=B_.metadata;#n=0;#r=0;#i=!1;#a=qe(0);get value(){return Ut(this.#a)}set value(e){Je(this.#a,e,!0)}get active(){return this.#i}#o(){let e=this.#t-this.#e,t=this.#r>0?Math.min(this.#n/this.#r,1):0,n=this.#e+e*t*H_;n>this.value&&(this.value=n)}reset(){this.#e=0,this.#t=B_.metadata,this.#n=0,this.#r=0,this.#i=!0,this.value=0}reach(e){if(!this.#i)return;let t=B_[e];if(t<=this.#e)return;this.#e=t,this.value<t&&(this.value=t);let n=V_[V_.indexOf(e)+1];this.#t=n?B_[n]:t,this.#n=0,this.#r=0,e===`done`&&(this.value=1,this.#i=!1)}announce(e){!this.#i||e<=0||(this.#r+=e,this.#o())}addBytes(e){this.#i&&(this.#n+=e,this.#o())}},W_=3e4;function G_(e,t){if(t||!U_.active||!e.body)return e;let n=Number(e.headers.get(`content-length`));if(!Number.isFinite(n)||n<=0)return e;U_.announce(n);let r=new TransformStream({transform(e,t){U_.addBytes(e.byteLength),t.enqueue(e)}});return new Response(e.body.pipeThrough(r),{status:e.status,statusText:e.statusText,headers:e.headers})}async function K_(e,t={},n=W_){let r=new AbortController,i=setTimeout(()=>r.abort(),n),a=()=>r.abort();t.signal?.addEventListener(`abort`,a,{once:!0});try{return G_(await fetch(e,{...t,signal:r.signal}),t.priority===`low`)}catch(i){throw r.signal.aborted&&!t.signal?.aborted?Error(`Request timed out after ${n} ms: ${e}`,{cause:i}):i}finally{clearTimeout(i),t.signal?.removeEventListener(`abort`,a)}}var q_=new Map,J_=new Map,Y_=null;function X_(){if(Y_)return Y_;let e=(async()=>{let e=await K_(`${Kt()}/v1/systems/global.json`);if(!e.ok)return;let t=await e.json();if(t.gm)for(let[e,n]of Object.entries(t.gm))J_.set(parseInt(e,10),n);if(t.nut_prec_angles)for(let[e,n]of Object.entries(t.nut_prec_angles))q_.set(parseInt(e,10),n)})();return e.catch(()=>{Y_===e&&(Y_=null)}),Y_=e,e}function Z_(e){return e>=100?Math.trunc(e/100):e}function Q_(e){return q_.get(e)}function $_(e){return J_.get(e)}var ev=132712440018,tv=86400;function nv(e){if(!M_(e.parentId))return;let t=Number(e.id.replace(/^naif-/,``));if(!Number.isFinite(t))return;let n=$_(t>=1&&t<=9?t*100+99:t),r=e.a*ig;if(!(!n||!(n>0)||!(r>0)))return r*(1-(Number.isFinite(e.e)?Math.min(Math.max(e.e,0),.99):0))*Math.cbrt(n/(3*ev))/ig}var rv=`class-`,iv=`flag-`,av=`cat-`;`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`;var ov=`${av}asteroids`,sv=`${av}comets`,cv=`${av}satellites`,lv=`${av}debris`;`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`;var uv={neo:1,pha:2},dv=new Set([`ETc`,`JFc`,`JFC`,`CTc`,`HTC`,`PAR`,`HYP`,`COM`]);function fv(e){return dv.has(e)?`comet`:`asteroid`}function pv(e,t){return e===t?!0:e===null||t===null||e.kind!==t.kind?!1:e.kind===`class`&&t.kind===`class`?e.className===t.className:e.kind===`category`&&t.kind===`category`?e.category===t.category:e.kind===`flag`&&t.kind===`flag`?e.flag===t.flag:!1}var mv=null;function hv(){if(mv)return mv;let e=K_(`${Kt()}/v1/groups/__index__.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch group index: ${e.status}`);return e.json()});return mv=e,e.catch(()=>{mv===e&&(mv=null)}),mv}var gv=[`planets`,`dwarfPlanets`,`moons`,`asteroids`,`comets`,`spacecraft`,`satellites`,`debris`,`orbits`,`labels`,`nomenclature`,`stars`],_v=new Set(gv),vv={[W.PLANET]:`planets`,[W.DWARF_PLANET]:`dwarfPlanets`,[W.MOON]:`moons`,[W.ASTEROID]:`asteroids`,[W.ASTEROID_INNER]:`asteroids`,[W.ASTEROID_MAIN_BELT]:`asteroids`,[W.ASTEROID_TROJAN]:`asteroids`,[W.ASTEROID_CENTAUR]:`asteroids`,[W.ASTEROID_TNO]:`asteroids`,[W.COMET]:`comets`,[W.DEBRIS]:`debris`},yv=`small_bodies/`,bv=new Set([`COM`,`PAR`,`HYP`,`HYA`,`JFC`,`JFc`,`HTC`,`CTc`]);function xv(e){return e===`moons`||e.startsWith(`moons/`)||e===`small_body_moons`?`moons`:e.startsWith(`probes/`)?`spacecraft`:e.startsWith(yv)?bv.has(e.slice(13))?`comets`:`asteroids`:null}function Sv(e,t){return e===W.SPACECRAFT?t===`naif-399`?`satellites`:`spacecraft`:vv[e]??null}var Cv=class{skipped;hiddenIds;onChange=null;constructor(e={}){let t=new Set;for(let n of gv)e[n]===!1&&t.add(n);this.skipped=t,this.hiddenIds=new Set(t)}isVisible(e){return!this.hiddenIds.has(e)}setVisible(e,t){t!==this.isVisible(e)&&(t?this.hiddenIds.delete(e):this.hiddenIds.add(e),this.onChange?.())}static has(e){return _v.has(e)}skipsZone(e){if(e===`earth`)return this.skipped.has(`satellites`)&&this.skipped.has(`debris`);let t=xv(e);return t!==null&&this.skipped.has(t)}hidesZone(e){let t=xv(e);return t!==null&&!this.isVisible(t)}hidesBody(e,t){let n=Sv(e,t);return n!==null&&!this.isVisible(n)}hidesSpacecraftGroup(e){return e===`naif-399`?!this.isVisible(`satellites`)&&!this.isVisible(`debris`):!this.isVisible(`spacecraft`)}};function wv(e,t,n){return t!==`naif-399`||e.isVisible(`satellites`)===e.isVisible(`debris`)?n:n.filter(t=>!e.hidesBody(t.data.objectType,t.data.parentId))}var Tv=`small_bodies/`;function Ev(e,t){let n=e.findAsteroidZone(t);if(n&&n.startsWith(`small_bodies/`))return n.slice(13);let r=e.bodiesById.get(t);if(r?.data.objectType!==W.DWARF_PLANET)return null;let i=r.data.a,a=r.data.e;if(!M_(r.data.parentId)){let t=e.bodiesById.get(r.data.parentId);t?.data.a&&(i=t.data.a,a=t.data.e)}return fn(i,a)}function Dv(e,t,n){if(n.kind===`class`||n.kind===`category`){let r=Ev(e,t);return r===null?!1:n.kind===`class`?r===n.className:fv(r)===n.category}let r=e.getBody(t);return r===void 0?!1:((r.data.flags??0)&n.mask)===n.mask}var $=function(e){return e[e.CLOSE=1]=`CLOSE`,e[e.FULL=2]=`FULL`,e[e.CAPPED=3]=`CAPPED`,e[e.FAR=4]=`FAR`,e[e.HIDE=5]=`HIDE`,e}({}),Ov=1503,kv={[$.CLOSE]:.3,[$.FULL]:20,[$.FAR]:100,[$.HIDE]:1/0},Av={[$.CLOSE]:.01,[$.FULL]:20,[$.FAR]:100,[$.HIDE]:1/0},jv=1/3;function Mv(e,t,n,r){return e<=t[$.CLOSE]?$.CLOSE:e<=t[$.FULL]*(r?n:1)?$.FULL:e<=t[$.FAR]?$.FAR:$.HIDE}var Nv=new Cv,Pv=3,Fv=4e6/ig;function Iv(e){return _n(e)||e===W.COMET||e===W.DWARF_PLANET}var Lv=class{#e=qe($e(f_));get focusedBodyId(){return Ut(this.#e)}set focusedBodyId(e){Je(this.#e,e,!0)}#t=qe(null);get focusedSystemId(){return Ut(this.#t)}set focusedSystemId(e){Je(this.#t,e,!0)}activeSystemId=null;isZoomedIn=!1;focusedBodyIdPlain=f_;focusedSystemIdPlain=null;travelSystemActive=!1;cameraDistThreeJS=0;lastRecomputeDist=-1;currentJd=0;hideThresholdAU=0;scaledPlanetary=kv;scaledSystem=Av;fullMoonIds=new Set;moonVisibilityCache=new Map;constructor(e,t=()=>null,n=()=>null,r=()=>null,i=()=>Nv){this.bodies=e,this.getProbeStore=t,this.getEarthSatGroupFilter=n,this.getSmallBodyFilter=r,this.getLayers=i}getRequiredFlags(){let e=this.getSmallBodyFilter();return e?.kind===`flag`?e.mask:0}updateViewport(e){let t=(e/Ov)**1.5,n=e=>({...e,[$.FULL]:e[$.FULL]*t,[$.FAR]:e[$.FAR]*t});this.scaledPlanetary=n(kv),this.scaledSystem=n(Av)}updateCamera(e,t){this.cameraDistThreeJS=e,this.currentJd=t,this.moonVisibilityCache.clear(),this.travelSystemActive||this.refreshProbeFocusedSystem(),this.hideThresholdAU=this.computeHideThreshold(),this.isZoomedIn=e/10<this.hideThresholdAU,this.activeSystemId=this.isZoomedIn?this.focusedSystemIdPlain:null,Math.abs(e-this.lastRecomputeDist)>this.lastRecomputeDist*.005+.001&&(this.lastRecomputeDist=e,this.recomputeFullMoons())}refreshProbeFocusedSystem(){let e=this.getProbeStore();if(!e)return;let t=this.bodies.bodiesById.get(this.focusedBodyIdPlain);if(!t||t.data.orbitalSource!==U.SPICE_PROBE)return;let n=e.containingSystemAt(t.data.id,this.currentJd),r=n===null?e.stampedFitCenterAt(t.data.id,this.currentJd):`naif-${n}`;r!==this.focusedSystemIdPlain&&(this.focusedSystemId=r,this.focusedSystemIdPlain=r,this.lastRecomputeDist=-1)}resolveSystemId(e){let t=e.data.objectType===W.BARYCENTER&&M_(e.data.parentId)&&!M_(e.data.id),n=e.data.objectType===W.STAR||!t&&M_(e.data.parentId);if(t)return e.data.id;if(n)return Iv(e.data.objectType)?e.data.id:null;let r=this.bodies.bodiesById.get(e.data.parentId);return r&&!M_(r.data.parentId)?r.data.parentId:e.data.parentId}setTravelSystem(e){this.travelSystemActive=!0,e!==this.focusedSystemIdPlain&&(this.focusedSystemId=e,this.focusedSystemIdPlain=e,this.lastRecomputeDist=-1)}clearTravelSystem(){this.travelSystemActive=!1}setFocused(e){if(this.travelSystemActive=!1,e.data.id===this.focusedBodyIdPlain)return;this.focusedBodyId=e.data.id,this.focusedBodyIdPlain=e.data.id;let t=this.resolveSystemId(e);this.focusedSystemId=t,this.focusedSystemIdPlain=t,this.hideThresholdAU=this.computeHideThreshold(),this.isZoomedIn=this.cameraDistThreeJS/10<this.hideThresholdAU,this.activeSystemId=this.isZoomedIn?t:null,this.lastRecomputeDist=-1,this.recomputeFullMoons()}getMoonVisibility(e){if(this.getLayers().hidesBody(e.data.objectType,e.data.parentId))return $.HIDE;let t=this.moonVisibilityCache.get(e.data.id);if(t!==void 0)return t;let n,r=this.bodies.getBody(e.data.parentId),i=r!==void 0&&_n(r.data.objectType);if(!this.isInFocusedSystem(e.data.parentId))n=$.HIDE;else if(i&&!this.matchesSmallBodyClass(e.data.parentId))n=$.HIDE;else{let t=this.cameraDistThreeJS/10/e.data.a,r=e.data.id===this.focusedBodyIdPlain;n=Mv(t,this.scaledPlanetary,5,r),!i&&n===$.FULL&&!this.fullMoonIds.has(e.data.id)&&!r&&(n=$.CAPPED)}return this.moonVisibilityCache.set(e.data.id,n),n}getPlanetVisibility(e,t){if(this.getLayers().hidesBody(e.data.objectType,e.data.parentId))return $.HIDE;if(e.data.orbitalSource===U.SPICE_PROBE)return this.getProbeVisibility(e);let n=this.getEarthSatGroupFilter();if(n&&e.data.parentId===`naif-399`&&!n.has(e.data.id))return $.HIDE;let r=e.data.objectType;if((_n(r)||r===W.COMET||r===W.DWARF_PLANET)&&!this.matchesSmallBodyClass(e.data.id))return $.HIDE;if(this.bodies.isSystemBody(e)){if(!this.isInFocusedSystem(e.data.parentId))return $.HIDE;let n=e.data.a;if(!n||n<=0)return $.FULL;let r=e.data.id===this.focusedBodyIdPlain;return Mv(t/10/n,this.scaledPlanetary,5,r)}let i=e.data.a;if(!M_(e.data.parentId)){let t=this.bodies.bodiesById.get(e.data.parentId);t?.data.a&&(i=t.data.a)}if(!i||i<0)return i===0&&e.data.e<.9&&console.warn(`No semi-major axis available for body ${e.data.id} (${e.data.name}), falling back to FULL visibility`),$.FULL;let a=e.data.id===this.focusedBodyIdPlain,o=Mv(t/10/i,this.scaledSystem,50,a);return o===$.CLOSE?$.FULL:o}getProbeVisibility(e){let t=this.getProbeStore();if((t?t.containingSystemAt(e.data.id,this.currentJd):null)===Pv&&this.getEarthSatGroupFilter())return $.HIDE;let n=e.data.id===this.focusedBodyIdPlain;if(!(t&&!t.hasHeliocentricFit(e.data.id,this.currentJd))){let t=this.bodies.bodiesById.get(f_),r=t?R_(e.position,t.position)/10:0;if(r===0)return $.FULL;let i=Mv(this.cameraDistThreeJS/10/r,this.scaledSystem,50,n);return i===$.CLOSE?$.FULL:i}if(!this.isProbeInFocusedSystem(e))return $.HIDE;let r=this.bodies.bodiesById.get(e.data.parentId);if(!r)return $.FULL;let i=R_(e.position,r.position)/10;return i===0||this.cameraDistThreeJS/10/i<=this.scaledPlanetary[$.FULL]*(n?5:1)?$.FULL:$.HIDE}isProbeInFocusedSystem(e){let t=e.data.parentId;if(!M_(t)&&this.isInFocusedSystem(t))return!0;let n=this.getProbeStore();if(!n)return!1;let r=n.containingSystemAt(e.data.id,this.currentJd);return r!==null&&this.isInFocusedSystem(`naif-${r}`)}hasFullRendering(e){if(!this.activeSystemId||this.isInActiveSystem(M_(e.data.parentId)?e.data.id:e.data.parentId))return!0;if(e.data.orbitalSource!==U.SPICE_PROBE)return!1;let t=this.getProbeStore();if(!t)return!1;let n=t.containingSystemAt(e.data.id,this.currentJd);return n!==null&&this.isInActiveSystem(`naif-${n}`)}isMoonGroupVisible(e){if(!this.getLayers().isVisible(`moons`)||!this.isInFocusedSystem(e))return!1;let t=this.bodies.maxMoonA(e);return t?this.cameraDistThreeJS/10/t<=this.scaledPlanetary[$.FAR]:!1}isSpacecraftGroupVisible(e){if(this.getLayers().hidesSpacecraftGroup(e))return!1;let t=this.activeSystemId;return M_(e)||this.bodies.bodiesById.get(e)?.data.objectType===W.STAR?!t:t?e===t?!0:this.bodies.getChildren(t)?.has(e)??!1:!1}isAsteroidGroupVisible(e){if(this.getLayers().hidesZone(e)||this.activeSystemId)return!1;let t=this.getSmallBodyFilter();if(t&&e.startsWith(`small_bodies/`)){let n=e.slice(Tv.length);if(t.kind===`class`&&n!==t.className||t.kind===`category`&&fv(n)!==t.category)return!1}let n=dn[e];return n?this.cameraDistThreeJS/10/n.maxA<=this.scaledSystem[$.FAR]/3:!0}isInActiveSystem(e){return this.bodies.isInSystem(e,this.activeSystemId)}debugBody(e){let t=this.bodies.getBody(e);if(!t)return{id:e,found:!1};let n=t.data.objectType,r=n===W.MOON,i=this.getProbeStore(),a=r?this.getMoonVisibility(t):this.getPlanetVisibility(t,this.cameraDistThreeJS);return{id:e,name:t.data.name,objectType:W[n],orbitalSource:t.data.orbitalSource,parentId:t.data.parentId,a:t.data.a,jd:this.currentJd,isMoon:r,isSystemBody:this.bodies.isSystemBody(t),isInFocusedSystem_parent:this.isInFocusedSystem(t.data.parentId),focusedBodyId:this.focusedBodyIdPlain,focusedSystemId:this.focusedSystemIdPlain,activeSystemId:this.activeSystemId,isZoomedIn:this.isZoomedIn,hideThresholdAU:this.hideThresholdAU,containingSystemAt:i?i.containingSystemAt(t.data.id,this.currentJd):null,camDistAU:this.cameraDistThreeJS/10,visibility:$[a],hasFullRendering:this.hasFullRendering(t)}}isBodyInSystem(e,t){return e.data.id===t||this.bodies.isInSystem(e.data.parentId,t)}isInFocusedSystem(e){return this.bodies.isInSystem(e,this.focusedSystemIdPlain)}matchesSmallBodyClass(e){let t=this.getSmallBodyFilter();return t===null?!0:Dv(this.bodies,e,t)}recomputeFullMoons(){this.fullMoonIds.clear();let e=this.focusedSystemIdPlain;if(!e)return;let t=this.cameraDistThreeJS/10,n=[];for(let r of this.bodies.getChildren(e)??[]){let e=this.bodies.bodiesById.get(r);e&&e.data.objectType===W.MOON&&t/e.data.a<=this.scaledPlanetary[$.FULL]&&n.push(e)}n.sort((e,t)=>e.data.a-t.data.a).slice(0,40).forEach(e=>this.fullMoonIds.add(e.data.id))}computeHideThreshold(){let e=this.focusedSystemIdPlain;return e?this.systemReachAU(e):1/0}systemReachAU(e){let t=this.bodies.maxMoonA(e);if(t)return 2*t;let n=this.bodies.getBody(e);if(!n)return 0;if(Iv(n.data.objectType))return Fv;let r=nv(n.data);return r?r*jv:0}},Rv=``;function zv(e){let t=new Map;if(!e)return t;for(let n of e.split(`
|
|
4051
|
+
`)){let e=n.indexOf(Rv);if(e===-1)continue;let r=n.slice(0,e),i=n.slice(e+1),a=i.indexOf(Rv),o=a===-1?i:i.slice(0,a),s=a===-1?``:i.slice(a+1);t.set(r,{name:o,isMinor:s.includes(`m`)})}return t}var Bv=new Map;async function Vv(e=c()){let t=Bv.get(e);return t||(t=(async()=>{let t=Qt(e),n=await K_(t,{priority:`high`});if(!n.ok)throw Error(`Failed to fetch ${t}: ${n.status}`);let r=new DecompressionStream(`gzip`);return zv(await new Response(n.body.pipeThrough(r)).text())})(),Bv.set(e,t),t.catch(()=>{Bv.get(e)===t&&Bv.delete(e)})),t}var Hv=Math.PI/180,Uv=Math.cos(ag*Hv),Wv=Math.sin(ag*Hv);function Gv(e,t,n,r,i,a=!1){let o=Math.cos(n*Hv),s=Math.sin(n*Hv),c=Math.cos(r*Hv),l=Math.sin(r*Hv),u=Math.cos(i*Hv),d=Math.sin(i*Hv),f=(u*o-d*s*c)*e+(-u*s-d*o*c)*t,p=(d*o+u*s*c)*e+(-d*s+u*o*c)*t,m=s*l*e+o*l*t;if(a){let e=p*Uv+m*Wv,t=-p*Wv+m*Uv;p=e,m=t}return[f*10,m*10,-p*10]}function Kv(e,t){let{omDot:n,wDot:r,om:i,w:a,epoch:o}=e;if(!n&&!r)return e;let s=t-o;return{...e,om:n?i+n*s:i,w:r?a+r*s:a}}function qv(e,t=new Date){return Jv(e,Ng(t))}function Jv(e,t){let{a:n,e:r,i,ma:a,n:o,epoch:s}=e;if(!isFinite(n)||!isFinite(r)||!isFinite(a)||!isFinite(o))return console.warn(`NaN in orbital elements: a=${n} e=${r} ma=${a} n=${o}`),null;let c=(a+o*(t-s))*Hv,{om:l,w:u}=Kv(e,t),d,f;if(r<1||n>0){let e=Math.min(r,.9999999),t=xg(c,e),i=Math.sqrt(1-e*e)*Math.sin(t)/(1-e*Math.cos(t)),a=(Math.cos(t)-e)/(1-e*Math.cos(t));d=Math.atan2(i,a),f=n*(1-e*Math.cos(t))}else{let e=Cg(c,r);if(!isFinite(e))return console.warn(`solveKeplerHyperbolic overflow: M=${c} e=${r}`),null;let t=r*Math.cosh(e)-1;if(Math.abs(t)<1e-15)return console.warn(`Hyperbolic denom near zero: H=${e} e=${r} denom=${t}`),null;let i=Math.sqrt(r*r-1)*Math.sinh(e)/t,a=(r-Math.cosh(e))/t;d=Math.atan2(i,a),f=n*(1-r*Math.cosh(e))}let p=f*Math.cos(d),m=f*Math.sin(d);return!isFinite(p)||!isFinite(m)?(console.warn(`Non-finite orbital position: r=${f} nu=${d} xOrb=${p} yOrb=${m} a=${n} e=${r}`),null):Gv(p,m,u,i,l,e.equatorial)}function Yv(e,t=new Date){return Xv(e,Ng(t))}function Xv(e,t){let{q:n,tp:r,i,om:a,w:o}=e;if(n==null||r==null||!isFinite(n)||!isFinite(r))return null;let s=wg(n,r,t);if(!s)return null;let c=s.r*Math.cos(s.nu),l=s.r*Math.sin(s.nu);return!isFinite(c)||!isFinite(l)?null:Gv(c,l,o,i,a,e.equatorial)}var Zv=class{map=new Map;constructor(e){this.capacity=e}getOrCompute(e,t){let n=this.map.get(e);if(n)return this.map.delete(e),this.map.set(e,n),n;let r=t();if(this.map.set(e,r),this.map.size>this.capacity){let e=this.map.keys().next().value;e!==void 0&&this.map.delete(e)}return r.catch(()=>{this.map.get(e)===r&&this.map.delete(e)}),r}};function Qv(e,t,n){let r=new DataView(e),i=r.getUint32(24,!0),a=(r.getUint8(28)&1)!=0,o=a?8:4,s=[],c=Zt;for(let t=0;t<i;t++){let n=r.getInt32(c,!0),i=r.getInt32(c+4,!0),l=r.getInt32(c+8,!0),u=r.getFloat32(c+12,!0),d=r.getUint16(c+16,!0),f=r.getUint8(c+18),p=r.getUint8(c+19)===1,m=r.getUint8(c+20),h=r.getUint16(c+22,!0),g=r.getFloat32(c+24,!0);c+=32;let _=ln(f,l)??``;_||console.warn(`chebyshev body[${t}] (naifId=${n}) has unknown id-type ${f}; routing keyed lookups will skip it`);let v=new Float64Array(h),y=new Float64Array(h),b=3*d,x=a?new Float64Array(b*h):new Float32Array(b*h),S=b*o;for(let t=0;t<h;t++){if(v[t]=r.getFloat64(c,!0),y[t]=r.getFloat64(c+8,!0),c+=16,a){let n=new Float64Array(e,c,b);x.set(n,t*b)}else{let n=new Float32Array(e,c,b);x.set(n,t*b)}c+=S}s.push({id:_,naifId:n,parentId:i,hasLocalized:p,objectType:m,radiusKm:u,visibleFromDays:g,coeffsPerAxis:d,startJds:v,endJds:y,coeffs:x})}return{startJd:t,endJd:n,bodies:s}}function $v(e,t,n,r){let i=n*(r?8:4),a=new(r?Float64Array:Float32Array)(n);if(r&&t%8==0)return a.set(new Float64Array(e,t,n)),a;if(!r&&t%4==0)return a.set(new Float32Array(e,t,n)),a;let o=new DataView(e,t,i);if(r)for(let e=0;e<n;e++)a[e]=o.getFloat64(e*8,!0);else for(let e=0;e<n;e++)a[e]=o.getFloat32(e*4,!0);return a}function ey(e,t,n,r){let i=$v(e,t,n===1?7:10,r);return n===1?{method:n,aKm:i[0],e:i[1],iRad:i[2],om0:i[3],w0:i[4],m0:i[5],tAnchorOffsetS:i[6]}:{method:n,aKm:i[0],e:i[1],iRad:i[2],om0:i[3],w0:i[4],m0:i[5],omDot:i[6],wDot:i[7],nMeanRadS:i[8],tAnchorOffsetS:i[9]}}var ty=1e-7,ny=.001,ry=1,iy=2,ay=16,oy=32;function sy(e,t,n){let r=new DataView(e,t,oy),i=r.getInt32(0,!0),a=r.getUint8(4),o=r.getUint32(8,!0),s=r.getUint32(12,!0),c=r.getInt32(16,!0)*ty,l=r.getInt32(20,!0)*ty,u=r.getInt32(24,!0)*ny,d=r.getUint32(28,!0),f=new Float64Array(d),p=new Float32Array(d),m=new Float32Array(d),h=new Float32Array(d);if(d>0){let r=new DataView(e,t+oy,d*ay);for(let e=0;e<d;e++){let t=e*ay;f[e]=n+r.getUint32(t,!0),p[e]=r.getInt32(t+4,!0)*ty,m[e]=r.getInt32(t+8,!0)*ty,h[e]=r.getInt32(t+12,!0)*ny}}return{bodyNaifId:i,isStatic:(a&ry)!==0,isDestroyed:(a&iy)!==0,startEt:n+o,endEt:n+s,latRefDeg:c,lngRefDeg:l,altRefM:u,sampleEt:f,sampleLatDeg:p,sampleLngDeg:m,sampleAltM:h}}function cy(e,t,n,r){let i=n/(36*(r?8:4));return{method:3,coeffsPerAxis:12,nSeg:i,coeffs:$v(e,t,i*3*12,r)}}function ly(e,t,n,r){let i=new DataView(e),a=i.getUint32(24,!0),o=i.getFloat32(28,!0),s=o*kg,c=Fg(t),l=[],u=Zt;for(let t=0;t<a;t++){let n=i.getInt32(u,!0),a=i.getUint8(u+4),o=i.getUint8(u+5),d=i.getUint8(u+6)===1,f=(i.getUint8(u+7)&1)!=0,p=i.getUint16(u+8,!0),m=i.getUint16(u+10,!0),h=i.getInt32(u+12,!0),g=i.getUint8(u+16),_=i.getUint8(u+17);u+=20;let v=ln(a,n)??``;v||console.warn(`probes payload: probe[${t}] (value=${n}) has unknown id-type ${a}; skipping`);let y=null;if(h!==-1&&g!==255){let e=ln(g,h);e?y={id:e,idType:g,idValue:h}:console.warn(`probes payload: probe[${t}] has unknown fit-center id-type ${g}; falling back to zone default`)}let b=Array(p),x=Array(p),S=Array(p);for(let n=0;n<p;n++){let a=i.getUint8(u),o=i.getUint32(u+4,!0),l=u+8,d=c+(m+n)*s;if(b[n]=d,x[n]=d+s,a===0)S[n]={method:0};else if(a===1||a===2)S[n]=ey(e,l,a,r);else if(a===3)S[n]=cy(e,l,o,r);else throw Error(`Unknown probe sub-chunk method ${a} at probe ${t} sub ${n}`);u=l+o}let C;if(f){let n=i.getUint8(u);if(n!==4)throw Error(`probe ${t}: PROBE_FLAG_HAS_LANDED_RECORD set but trailing record method = ${n}, expected 4`);let r=i.getUint32(u+4,!0),a=u+8;C=sy(e,a,c),u=a+r}let w=Array(_);for(let e=0;e<_;e++)w[e]={startEt:i.getFloat64(u,!0),endEt:i.getFloat64(u+8,!0),systemNaifId:i.getUint8(u+16)},u+=17;l.push({id:v,probeId:n,hasLocalized:d,objectType:o,fitCenter:y,subStartEt:b,subEndEt:x,subChunks:S,landed:C,systemIntervals:w})}return{startJd:t,endJd:n,subchunkDays:o,probes:l}}function uy(e,t={}){let n=new DataView(e),r=n.getUint32(0,!0);if(r!==1346456915)throw Error(`Invalid position file: bad magic 0x${r.toString(16)}`);let i=n.getUint16(4,!0);if(i!==13)throw Error(`Unsupported position file version: ${i}`);let a=n.getUint8(6),o=n.getFloat64(8,!0),s=n.getFloat64(16,!0);if(a===0)return{kind:`elements`,columns:Eh(e,o,s)};if(a===1)return{kind:`chebyshev`,chunk:Qv(e,o,s)};if(a===2)return{kind:`probes`,chunk:ly(e,o,s,t.probesFloat64??!1)};throw Error(`Unknown position-file format: ${a}`)}function dy(e,t,n){let r=e.length;if(r===0||n<e[0]||n>=t[r-1])return-1;let i=0,a=r-1;for(;i<a;){let t=i+a+1>>>1;e[t]<=n?i=t:a=t-1}return n<t[i]?i:-1}function fy(e,t){let n=dy(e.startJds,e.endJds,t);if(n<0)return null;let r=e.startJds[n],i=e.endJds[n],a=2*(t-r)/(i-r)-1,o=e.coeffsPerAxis,s=e.coeffs,c=n*3*o,l=[0,0,0],u=2*a;for(let e=0;e<3;e++){let t=c+e*o;if(o===1){l[e]=s[t];continue}let n=0,r=0;for(let e=o-1;e>=1;e--){let i=s[t+e]+u*n-r;r=n,n=i}l[e]=s[t]+a*n-r}return l}function py(e,t){let n=fy(e,t);return n===null?null:[Q(n[0]),Q(n[2]),-Q(n[1])]}function my(e,t){let n=dy(e.startJds,e.endJds,t);if(n<0)return null;let r=e.startJds[n],i=e.endJds[n],a=2*(t-r)/(i-r)-1,o=2/(i-r),s=e.coeffsPerAxis,c=e.coeffs,l=n*3*s,u=[0,0,0],d=[0,0,0],f=2*a;for(let e=0;e<3;e++){let t=l+e*s;if(s===1){u[e]=c[t],d[e]=0;continue}let n=0,r=0;for(let e=s-1;e>=1;e--){let i=c[t+e]+f*n-r;r=n,n=i}u[e]=c[t]+a*n-r;let i=0,p=0;for(let e=s-2;e>=0;e--){let n=c[t+e+1]*(e+1)+f*i-p;p=i,i=n}d[e]=i*o}return{position:u,velocity:d}}function hy(e,t){let n=e.subStartEt,r=e.subEndEt,i=n.length;if(i===0||t<n[0]||t>=r[i-1])return-1;let a=0,o=i-1;for(;a<o;){let e=a+o+1>>>1;n[e]<=t?a=e:o=e-1}return t<r[a]?a:-1}function gy(e,t,n,r,i){let a=Math.cos(i),o=Math.sin(i),s=Math.cos(r),c=Math.sin(r),l=Math.cos(n),u=Math.sin(n);return[(l*a-u*o*s)*e+(-l*o-u*a*s)*t,(u*a+l*o*s)*e+(-u*o+l*a*s)*t,o*c*e+a*c*t]}function _y(e,t,n,r,i,a){if(t>=1)return null;let o=xg(a,t),s=Math.sin(o),c=Math.cos(o),l=Math.sqrt(1-t*t)*s/(1-t*c),u=(c-t)/(1-t*c),d=e*(1-t*c),f=d*u,p=d*l;return!isFinite(f)||!isFinite(p)?null:gy(f,p,r,n,i)}function vy(e,t,n,r){let i=n-(t+e.tAnchorOffsetS),a=Math.sqrt(r/(e.aKm*e.aKm*e.aKm)),o=e.m0+a*i;return _y(e.aKm,e.e,e.iRad,e.om0,e.w0,o)}function yy(e,t,n){let r=n-(t+e.tAnchorOffsetS),i=e.om0+e.omDot*r,a=e.w0+e.wDot*r,o=e.m0+e.nMeanRadS*r;return _y(e.aKm,e.e,e.iRad,i,a,o)}function by(e,t,n,r){let{coeffs:i,coeffsPerAxis:a,nSeg:o}=e,s=(n-t)/o,c=Math.floor((r-t)/s);c<0?c=0:c>=o&&(c=o-1);let l=2*(r-(t+c*s))/s-1,u=2*l,d=c*3*a,f=[0,0,0];for(let e=0;e<3;e++){let t=d+e*a;if(a===1){f[e]=i[t];continue}let n=0,r=0;for(let e=a-1;e>=1;e--){let a=i[t+e]+u*n-r;r=n,n=a}f[e]=i[t]+l*n-r}return!isFinite(f[0])||!isFinite(f[1])||!isFinite(f[2])?null:f}function xy(e,t,n,r,i){switch(e.method){case 0:return null;case 1:return vy(e,t,r,i);case 2:return yy(e,t,r);case 3:return by(e,t,n,r)}}function Sy(e,t,n){let r=Fg(t),i=hy(e,r);return i<0?null:xy(e.subChunks[i],e.subStartEt[i],e.subEndEt[i],r,n)}function Cy(e,t,n){let r=Sy(e,t,n);return r===null?null:[Q(r[0]),Q(r[2]),-Q(r[1])]}function wy(e){if(!e.landed)return!1;let t=e.subEndEt.length;return t===0||e.subEndEt[t-1]<=e.landed.endEt}function Ty(e,t){if(!e.landed)return!1;let n=Fg(t);return n>=e.landed.startEt&&(n<e.landed.endEt||wy(e))}function Ey(e,t,n=!1){let r=Fg(t);if(r<e.startEt||!n&&r>=e.endEt)return null;let i=e.sampleEt.length;if(i===0||r<e.sampleEt[0])return{latDeg:e.latRefDeg,lngDeg:e.lngRefDeg,altM:e.altRefM};let a=0,o=i-1;for(;a<o;){let t=a+o+1>>>1;e.sampleEt[t]<=r?a=t:o=t-1}return{latDeg:e.sampleLatDeg[a],lngDeg:e.sampleLngDeg[a],altM:e.sampleAltM[a]}}var Dy=30/kg;function Oy(e,t,n){let r=Sy(e,t,n);if(r===null)return null;let i=Dy,a=Sy(e,t+i,n),o=Sy(e,t-i,n),s,c,l;if(a!==null&&o!==null)s=a,c=o,l=1/(2*i);else if(a!==null)s=a,c=r,l=1/i;else if(o!==null)s=r,c=o,l=1/i;else return null;return{position:r,velocity:[(s[0]-c[0])*l,(s[1]-c[1])*l,(s[2]-c[2])*l]}}Math.PI/180;var ky=180/Math.PI;ig/86400;var Ay=1e-9,jy=1e-9;function My(e,t,n){return e<t?t:e>n?n:e}function Ny(e,t,n,r){let[i,a,o]=e,[s,c,l]=t,u=Math.hypot(i,a,o),d=s*s+c*c+l*l;if(u===0||n<=0||!isFinite(u)||!isFinite(d))return null;let f=a*l-o*c,p=o*s-i*l,m=i*c-a*s,h=Math.hypot(f,p,m);if(h===0)return null;let g=Math.acos(My(m/h,-1,1)),_=Math.sin(g),v=(c*m-l*p)/n-i/u,y=(l*f-s*m)/n-a/u,b=(s*p-c*f)/n-o/u,x=Math.hypot(v,y,b),S=2/u-d/n;if(Math.abs(S)<1e-12)return null;let C=1/S,w=-p,T=f,E=Math.hypot(w,T),D;_<jy||E===0?D=0:(D=Math.acos(My(w/E,-1,1)),T<0&&(D=2*Math.PI-D));let O;if(x<Ay)O=0;else if(_<jy||E===0)O=Math.atan2(y,v),m<0&&(O=-O),O<0&&(O+=2*Math.PI);else{let e=(w*v+T*y)/(E*x);O=Math.acos(My(e,-1,1)),b<0&&(O=2*Math.PI-O)}let k,A=i*s+a*c+o*l;if(x<Ay&&(_<jy||E===0))k=Math.atan2(a,i),m<0&&(k=-k),k<0&&(k+=2*Math.PI);else if(x<Ay){let e=(w*i+T*a)/(E*u);k=Math.acos(My(e,-1,1)),o<0&&(k=2*Math.PI-k)}else{let e=(v*i+y*a+b*o)/(x*u);k=Math.acos(My(e,-1,1)),A<0&&(k=2*Math.PI-k)}let j;if(x<1){let e=2*Math.atan2(Math.sqrt(1-x)*Math.sin(k/2),Math.sqrt(1+x)*Math.cos(k/2));j=e-x*Math.sin(e)}else if(x>1){let e=2*Math.atanh(Math.sqrt((x-1)/(x+1))*Math.tan(k/2));if(!isFinite(e))return null;j=x*Math.sinh(e)-e}else return null;let M=Math.abs(C),ee=Math.sqrt(n/(M*M*M))*ky;return{a:C,e:x,i:g*ky,om:D*ky,w:O*ky,ma:j*ky,n:ee,epoch:r,equatorial:!1}}var Py=180/Math.PI;function Fy(e,t,n){if(n<=0)return null;let r=Math.sqrt(n/(e.aKm*e.aKm*e.aKm)),i=Ig(t+e.tAnchorOffsetS);return{a:e.aKm/ig,e:e.e,i:e.iRad*Py,om:e.om0*Py,w:e.w0*Py,ma:e.m0*Py,n:r*Py*kg,epoch:i,equatorial:!1}}function Iy(e,t){let n=Ig(t+e.tAnchorOffsetS);return{a:e.aKm/ig,e:e.e,i:e.iRad*Py,om:e.om0*Py,w:e.w0*Py,ma:e.m0*Py,n:e.nMeanRadS*Py*kg,omDot:e.omDot*Py*kg,wDot:e.wDot*Py*kg,epoch:n,equatorial:!1}}function Ly(e,t,n){if(n<=0)return null;let r=Oy(e,t,n);if(!r)return null;let i=n*og;return Ny([r.position[0]/ig,r.position[1]/ig,r.position[2]/ig],[r.velocity[0]*sg,r.velocity[1]*sg,r.velocity[2]*sg],i,t)}function Ry(e,t,n){let r=hy(e,Fg(t));if(r<0)return null;let i=e.subChunks[r];switch(i.method){case 0:return null;case 1:return Fy(i,e.subStartEt[r],n);case 2:return Iy(i,e.subStartEt[r]);case 3:return Ly(e,t,n)}}function zy(e,t,n,r){let i=e.fitCenter;if(!i||i.id===n||!r)return null;let a=r.body(i.id,t),o=r.body(n,t);if(!a||!o)return null;if(a.parentId!==o.parentId)return console.warn(`fit-center override: ${i.id} (parent ${a.parentId}) and zone center ${n} (parent ${o.parentId}) don't share a chebyshev parent; treating the record as unplaceable`),null;let s=my(a,t),c=my(o,t);return!s||!c?null:{id:i.id,naifId:a.naifId,positionKm:[s.position[0]-c.position[0],s.position[1]-c.position[1],s.position[2]-c.position[2]],velocityKmDay:[s.velocity[0]-c.velocity[0],s.velocity[1]-c.velocity[1],s.velocity[2]-c.velocity[2]]}}function By(e){let t=e-18e6;if(t>=2e6&&t<=2999999){let e=$_(t);if(e!==void 0)return{naifId:t,muKm3S2:e}}return{naifId:e,muKm3S2:$_(e)??0}}function Vy(e,t,n,r,i){let a=`naif-${n}`,o=e.fitCenter;if(o&&o.id!==a){let n=zy(e,t,a,r);return n?{id:n.id,naifId:n.naifId,muKm3S2:$_(n.naifId)??0}:i?.(o.id)?o.idType===an.SPKID?{id:o.id,...By(o.idValue)}:{id:o.id,naifId:o.idValue,muKm3S2:$_(o.idValue)??0}:null}return{id:a,naifId:n,muKm3S2:$_(n)??0}}var Hy=1/256,Uy=class{capacity;stepDays;epsilonScene;spanDays;needsPopulate=!1;positions;jds;head=0;_count=0;constructor(e,t,n=1/0,r){this.capacity=e,this.stepDays=t,this.epsilonScene=n,this.spanDays=r??t*e,this.positions=new Float32Array(e*3),this.jds=new Float64Array(e)}get count(){return this._count}reconfigure(e,t,n){Number.isFinite(e)&&e>0&&(this.stepDays=e),this.epsilonScene=t,this.spanDays=n??this.stepDays*this.capacity}get newestJd(){if(this._count===0)return NaN;let e=(this.head-1+this.capacity)%this.capacity;return this.jds[e]}readNewestPos(e){if(this._count===0)return!1;let t=(this.head-1+this.capacity)%this.capacity*3;return e[0]=this.positions[t],e[1]=this.positions[t+1],e[2]=this.positions[t+2],!0}append(e,t,n,r){let i=this.head;this.jds[i]=e,this.positions[i*3]=t,this.positions[i*3+1]=n,this.positions[i*3+2]=r,this.head=(i+1)%this.capacity,this._count<this.capacity&&this._count++}clear(){this.head=0,this._count=0}writeVertices(e,t,n,r,i){let a=Math.min(this._count,e.length/3|0),o=i?new Float64Array(3):null;for(let s=0;s<a;s++){let a=(this.head-1-s+this.capacity)%this.capacity,c=a*3,l=s*3;if(i&&o){o[0]=this.positions[c],o[1]=this.positions[c+1],o[2]=this.positions[c+2],i(this.jds[a],o),e[l]=o[0]+t,e[l+1]=o[1]+n,e[l+2]=o[2]+r;continue}e[l]=this.positions[c]+t,e[l+1]=this.positions[c+1]+n,e[l+2]=this.positions[c+2]+r}return a}},Wy=200;function Gy(e,t,n,r=!1){if(r)return{stepDays:Wy/n,epsilonScene:1/0,spanDays:Wy};let i=e!==null&&e.n>0,a=i?360/e.n:t,o=a>0?a/n:1,s=e?e.a*(1-e.e):0,c=s>0?s*10*1e-4:1/0;return{stepDays:o,epsilonScene:c,spanDays:!i&&isFinite(c)?1/0:o*n}}function Ky(e){let t=Number(e.slice(5));return e=>e===t}function qy(e,t,n,r){let i=Ky(r);return a=>{let o=e.probeWithCenter(n,a,i);if(!o)return null;let s=Vy(o.probe,a,o.fitCenterNaifId,t,e=>e===r);return!s||s.id!==r?null:Cy(o.probe,a,s.muKm3S2)}}function Jy(e,t,n,r,i){let a=e((t+r)/2);if(!a)return null;let o=a[0]-(n[0]+i[0])/2,s=a[1]-(n[1]+i[1])/2,c=a[2]-(n[2]+i[2])/2;return Math.sqrt(o*o+s*s+c*c)}var Yy=.005;function Xy(e,t,n,r,i,a,o){let s=(e,t)=>{if(e===null)return!1;let i=Math.hypot(t[0]-n[0],t[1]-n[1],t[2]-n[2]);return e<=Math.max(r,Yy*i)},c=t+o*a,l=e(c);if(l!==null&&s(Jy(e,t,n,c,l),l))return{jd:c,pos:l};let u=i,d=a,f=null,p=i*.25;for(let r=0;r<16;r++){let r=(u+d)/2,i=t+o*r,a=e(i);if(a===null){d=r;continue}if(s(Jy(e,t,n,i,a),a)?(u=r,f={jd:i,pos:a}):d=r,d-u<p)break}if(f)return f;let m=t+o*i,h=e(m);return h?{jd:m,pos:h}:null}function Zy(e,t,n,r,i,a){Qy(e,qy(t,n,r,i),a)}function Qy(e,t,n){let r=t(n);if(!r)return;let i=[{jd:n,pos:r}];if(isFinite(e.epsilonScene)){let r=e.stepDays*16,a=e.stepDays*Hy,o=n-e.spanDays;for(;i.length<e.capacity;){let n=i[i.length-1];if(n.jd<=o)break;let s=Xy(t,n.jd,n.pos,e.epsilonScene,a,r,-1);if(!s)break;if(s.jd<o){let e=t(o);e&&i.push({jd:o,pos:e});break}i.push(s)}}else for(let r=1;r<e.capacity;r++){let a=n-r*e.stepDays,o=t(a);o&&i.push({jd:a,pos:o})}for(let t=i.length-1;t>=0;t--){let n=i[t];e.append(n.jd,n.pos[0],n.pos[1],n.pos[2])}}function $y(e,t,n,r,i){if(!isFinite(e.epsilonScene))return;let a=e.stepDays*16,o=e.stepDays*Hy,s=n,c=r;for(let n=0;n<e.capacity&&!(i-s<=o);n++){let n=Math.min(a,i-s),r=Xy(t,s,c,e.epsilonScene,o,n,1);if(!r||r.jd<=s)break;e.append(r.jd,r.pos[0],r.pos[1],r.pos[2]),s=r.jd,c=r.pos}}function eb(e,t,n,r,i,a){if(t.length===0)return[];let o=e.trailAnchor??e.position,s=[o[0]-r,o[1]-i,o[2]-a],c=0,l=1/0;for(let e=0;e<t.length;e++){let n=(t[e][0]-s[0])**2+(t[e][1]-s[1])**2+(t[e][2]-s[2])**2;n<l&&(l=n,c=e)}let u=Math.max(c-1,0),d=Math.min(c+1,t.length-1),f=(t[u][0]-s[0])**2+(t[u][1]-s[1])**2+(t[u][2]-s[2])**2<(t[d][0]-s[0])**2+(t[d][1]-s[1])**2+(t[d][2]-s[2])**2?u:c,p=[s];if(n)for(let e=0;e<511;e++){let n=Math.max(f-e,0);if(p.push(t[n]),n===0)break}else{for(let e=0;e<511;e++)p.push(t[((f-e)%512+512)%512]);p.push(s)}return p.filter(e=>e.every(Number.isFinite))}function tb(e,t,n,r){let i=.55,a=n?0:i/3,o=e.length-1;for(let t=0;t<e.length;t++)e[t]=i-(o>0?t/o:0)*(i-a);if(r){let e=.35;t.fill(0);for(let n=0;n<Math.min(171,t.length);n++)t[n]=e-n/170*e}else t.set(e)}var nb=new Map,rb=0,ib=10;function ab(e,t,n,r){let i=$_(t);if(!i)return null;let a=my(e,n);if(!a)return null;let o=r?my(r,n):null;if(r&&!o)return null;let s=i*og;return Ny([(a.position[0]-(o?.position[0]??0))/ig,(a.position[1]-(o?.position[1]??0))/ig,(a.position[2]-(o?.position[2]??0))/ig],[(a.velocity[0]-(o?.velocity[0]??0))*sg,(a.velocity[1]-(o?.velocity[1]??0))*sg,(a.velocity[2]-(o?.velocity[2]??0))*sg],s,n)}function ob(e,t,n){return!n||e.parentId!==rb||e.naifId===ib?null:ab(e,ib,t,n)}function sb(e,t,n,r){return r?tn(e,t,r,n):en(e,t,n)}var cb=new Zv(8);async function lb(e,t,n,r,i){let a=`${e}:${t??``}:${n}:${r??``}`;return cb.getOrCompute(a,async()=>{let a=await K_(sb(e,t,n,r),{priority:i});if(!a.ok)throw Error(`Failed to fetch elements: ${a.status}`);let o=new DecompressionStream(`gzip`),s=uy(await new Response(a.body.pipeThrough(o)).arrayBuffer());if(s.kind!==`elements`)throw Error(`Expected elements payload at ${e}/${t}/${n}, got ${s.kind}`);return s.columns})}var ub=class{static prefetch(e,t,n,r=null){fetch(sb(e,t,n,r))}positions=new Map;barycenters=new Map;neededParentKeys=new Set;probeBuffers=new Map;constructor(e){this.cheb=e,this.positions.set(`naif-0`,[0,0,0])}processChebyshev(e,t){if(!this.cheb)return[];let n=Ng(e),r=this.barycenters.size===0,i=[],a=new Map,o=Array.from(this.cheb.bodiesAt(n));o.sort((e,t)=>{let n=e=>e.objectType===W.BARYCENTER?0:e.objectType===W.STAR?1:e.naifId%100==99?2:3;return n(e.body)-n(t.body)||e.body.naifId-t.body.naifId});let s=this.cheb,c=s.body(`naif-${ib}`,n);for(let{body:e,startJd:l,endJd:u}of o){let o=py(e,n);if(!o)continue;a.set(e.naifId,e);let d=`naif-${e.parentId}`,f=this.positions.get(d);if(!f){console.warn(`processChebyshev: parent ${d} not in positions for ${e.id} — hiding`);continue}let p=[f[0]+o[0],f[1]+o[1],f[2]+o[2]],m=e.objectType,h=m===W.MOON&&e.parentId>=1&&e.parentId<=9?`naif-${e.parentId*100+99}`:null,g=h?this.positions.get(h):void 0,_=ab(e,e.parentId,n,h?s.body(h,n)??void 0:void 0),v=e.id,y=e=>{let t=s.body(v,e);return t?ab(t,t.parentId,e,h?s.body(h,e)??void 0:void 0):null},b=Math.hypot(o[0],o[1],o[2])/10,x={id:e.id,name:Wg(t,e.id),isMinor:Gg(t,e.id),hasLocalized:e.hasLocalized,objectType:m,parentId:`naif-${e.parentId}`,radiusKm:e.radiusKm,a:_?Math.abs(_.a):b,e:_?.e??0,i:_?.i??0,om:_?.om??0,w:_?.w??0,ma:_?.ma??0,n:_?.n??0,epoch:_?.epoch??0,equatorial:!1,helioElements:ob(e,n,c)??void 0,validityStart:l,validityEnd:u,orbitalSource:U.SPICE,visibleFromDays:e.visibleFromDays};if(r&&this.positions.set(e.id,p),m===W.BARYCENTER||m===W.LAGRANGE_POINT){r&&_&&_.a>0&&_.e<1&&this.barycenters.set(e.id,_),i.push({data:x,position:p,orbitElements:_??void 0,orbitCenter:f,rederiveElements:y});continue}if(vn(m)){let t=m===W.MOON,n=this.barycenters.get(d),r=t?_:n??_,o=!t&&n!==void 0,c=a.get(e.parentId)?.id,l=o&&c?e=>{let t=s.body(c,e);return t?ab(t,t.parentId,e):null}:y;i.push({data:x,position:p,orbitElements:r??void 0,orbitCenter:o?void 0:g??f,trailAnchor:o?[f[0],f[1],f[2]]:void 0,rederiveElements:l})}else i.push({data:x,position:p,orbitElements:_??void 0,orbitCenter:f,rederiveElements:y})}return i}processProbes(e,t,n){let r=Ng(t),i=[],a=new Map,o=new Map,s=new Set,c=new Set;for(let{id:t,probe:l,zoneCenterNaifId:u,startJd:d,endJd:f}of e.probesAt(r)){if(!t)continue;u===void 0&&c.add(t);let p=`naif-${u}`,m=u===void 0?null:Vy(l,r,u,this.cheb,e=>this.positions.has(e)),h=m?m.id:p,g=m?.muKm3S2??0,_=m===null,v=this.positions.get(h);if(!v){let e=a.get(h);e||a.set(h,e=new Set),e.add(t)}if(g===0){let e=o.get(h);e||o.set(h,e=new Set),e.add(t)}let y=Sy(l,r,g);y||s.add(t);let b=v??[0,0,0],x=y?[Q(y[0]),Q(y[2]),-Q(y[1])]:null,S=!x||!v||_,C=x&&!_?[b[0]+x[0],b[1]+x[1],b[2]+x[2]]:[b[0],b[1],b[2]],w={id:t,name:Wg(n,t),isMinor:Gg(n,t),hasLocalized:l.hasLocalized,objectType:l.objectType,parentId:h,loadParentId:h,radiusKm:NaN,a:0,e:0,i:0,om:0,w:0,ma:0,n:0,epoch:0,equatorial:!1,validityStart:d,validityEnd:f,orbitalSource:U.SPICE_PROBE},T=Ry(l,r,g),E=t,D=this.cheb,O=t=>{let n=e.probeWithCenter(E,t);if(!n)return null;let r=Vy(n.probe,t,n.fitCenterNaifId,D,()=>!0);return r?Ry(n.probe,t,r.muKm3S2):null},k;{let{stepDays:e,epsilonScene:n,spanDays:r}=Gy(T,f-d,512),i=this.probeBuffers.get(t);i&&i.parentKey===h?(k=i.buffer,!isFinite(k.epsilonScene)&&isFinite(n)&&k.reconfigure(e,n,r)):(k=new Uy(512,e,n,r),k.needsPopulate=!0,this.probeBuffers.set(t,{buffer:k,parentKey:h}))}i.push({data:w,position:C,positionUnknown:S,orbitElements:T??void 0,orbitCenter:[b[0],b[1],b[2]],rederiveElements:O,trailBuffer:k})}c.size>0&&console.error(`processProbes: ${c.size} probe(s) have undefined fit_center_naif_id — metadata.json is stale (re-export to pick up fit_center_naif_id field). Affected probe ids: ${Array.from(c).slice(0,10).join(`, `)}`+(c.size>10?` (+${c.size-10} more)`:``));for(let[e,t]of a)console.warn(`processProbes: fit-center ${e} not in positions (unplaceable, kept hidden) — ${t.size} probe(s): ${Array.from(t).slice(0,5).join(`, `)}`+(t.size>5?` (+${t.size-5} more)`:``));for(let[e,t]of o)console.warn(`processProbes: GM unavailable for ${e} — kepler_pure sub-chunks will use mu=0 (static snapshot); affected ${t.size} probe(s): ${Array.from(t).slice(0,5).join(`, `)}`+(t.size>5?` (+${t.size-5} more)`:``));return s.size>0&&console.warn(`processProbes: ${s.size} probe(s) outside sub-chunk windows at load (will stay hidden until jd enters coverage): ${Array.from(s).slice(0,5).join(`, `)}`+(s.size>5?` (+${s.size-5} more)`:``)),i}async seedNeededParents(e,t,n,r,i){let a=await lb(e,t,n,r),o=cn(i);if(o!==void 0)for(let e=0;e<a.rowCount;e++)this.neededParentKeys.add(mh(o,a.parentId[e]))}async fetchMinorColumns(e,t,n,r,i=null,a=`naif`,o){let s=await lb(e,t,n,i,o);return this.neededParentKeys.size>0&&await this.resolveNeededParents(s,r,a),s}async resolveNeededParents(e,t,n){let r=Ng(t),i=e.kind===`parabolic`,a=this.neededParentKeys,o=performance.now();for(let s=0;s<e.rowCount;s++){if((s&4095)==4095&&performance.now()-o>6&&(await Dg(),o=performance.now()),!a.has(Ch(e,s)))continue;let c=Sh(e,s);if(c===null)continue;let l=this.positions.get(`${n}-${e.parentId[s]}`);if(!l)continue;let u=e_(e,s,nb,n);if(!u)continue;let d=r>=u.validityStart&&r<=u.validityEnd?u.satrec?bg(u.satrec,r):u.q==null?u.a===0&&!i?[0,0,0]:qv(u,t):Yv(u,t):[0,0,0];d&&this.positions.set(c,[l[0]+d[0],l[1]+d[1],l[2]+d[2]])}}async process(e,t,n,r,i=null,a=`naif`,o,s){let c=this.barycenters.size===0,l=[],u=new Map,d=[],[f,p]=await Promise.all([lb(e,t,n,i,s),Vv()]),m=f.kind===`parabolic`,h=f.kind===`sgp4`,g=Ng(r),_=performance.now();for(let e=0;e<f.rowCount;e++){(e&255)==255&&performance.now()-_>6&&(await Dg(),_=performance.now());let t=f.objectType[e];if(!m&&f.a[e]===0&&t!==W.BARYCENTER&&t!==W.LAGRANGE_POINT&&!vn(t))continue;let n=`${a}-${f.parentId[e]}`,i=this.positions.get(n);if(!i){u.set(n,(u.get(n)??0)+1);continue}let s=m?Jg(f,e,p,a):h?$g(f,e,p,a):qg(f,e,p,a);if(!s)continue;if(h&&s.name===null&&!o?.has(s.id)){l.push({data:s,position:[i[0],i[1],i[2]],positionUnknown:!0});continue}if(h&&!s.satrec)continue;let v=g>=s.validityStart&&g<=s.validityEnd,y=v?s.satrec?bg(s.satrec,g):s.a===0&&!m?[0,0,0]:s.q==null?qv(s,r):Yv(s,r):[0,0,0];if(!y){d.push(s.id);continue}let b=[i[0]+y[0],i[1]+y[1],i[2]+y[2]],x=vh(s.id);if(x!==null&&this.neededParentKeys.has(x)&&this.positions.set(s.id,b),t===W.BARYCENTER||t===W.LAGRANGE_POINT){c&&(s.a>0&&s.e<1&&this.barycenters.set(s.id,s),this.positions.set(s.id,b)),l.push({data:s,position:b,positionUnknown:!v,orbitElements:s.a>0?s:void 0,orbitCenter:i});continue}if(c&&vn(t)&&this.positions.set(s.id,b),vn(t)){let e=t===W.MOON,r=this.barycenters.has(n);l.push({data:s,position:b,positionUnknown:!v,orbitElements:e?s:this.barycenters.get(n)??s,orbitCenter:e||!r?i:void 0})}else l.push({data:s,position:b,positionUnknown:!v})}if(d.length>0&&console.warn(`process(${e}/${t}/${n}): positioned ${l.length} body(ies), dropped ${d.length} the propagator refused — ${d.slice(0,5).join(`, `)}`+(d.length>5?` (+${d.length-5} more)`:``)),u.size>0){let r=Array.from(u.values()).reduce((e,t)=>e+t,0),i=Array.from(u.entries()).map(([e,t])=>`${e}×${t}`).join(`, `);console.warn(`process(${e}/${t}/${n}): hid ${r} body(ies) with unresolved parent — ${i}`)}return l}},db=new Map,fb=null,pb=null;function mb(e){if(!e)return;let t=e.ls_deg.length;if(t<2||e.dust_tau_factor.length!==t||e.dust_scale_height_km.length!==t||e.pressure_factor.length!==t){console.warn(`atmospheres: malformed seasonal table — ignored`);return}return{lsDeg:e.ls_deg,dustTauFactor:e.dust_tau_factor,dustScaleHeightKm:e.dust_scale_height_km,pressureFactor:e.pressure_factor}}function hb(e,t,n){if(t){if(!n||n<2||!(t.top_km>0)||t.flux_down.length!==3*n||t.flux_up_ratio.length!==3*n||t.extinction_per_km.length!==3*n){console.warn(`atmospheres: ${e} has a malformed deep column — ignored`);return}return{n,topKm:t.top_km,fluxDown:t.flux_down,fluxUpRatio:t.flux_up_ratio,extinctionPerKm:t.extinction_per_km}}}function gb(){if(pb)return pb;let e=(async()=>{let e=await K_(`${Kt()}/v1/atmospheres.json`);if(!e.ok){console.warn(`atmospheres: fetch failed (${e.status}) — rendering without shells`);return}let t=await e.json();fb=t.sun?.limb_darkening_alpha??null;for(let[e,n]of Object.entries(t.bodies)){let r=t.phases[n.phase];if(!r||r.length!==3*t.phase_n){console.warn(`atmospheres: ${e} has bad phase table "${n.phase}" — skipped`);continue}let i=n.mie_profile;i&&i.length!==t.profile_n&&(console.warn(`atmospheres: ${e} has a bad mie profile — falling back to exponential`),i=void 0),db.set(e,{topAltitudeKm:n.top_altitude_km,rayleighScatterPerKm:n.rayleigh_scatter_per_km,rayleighScaleHeightKm:n.rayleigh_scale_height_km,mieScatterPerKm:n.mie_scatter_per_km,mieAbsorptionPerKm:n.mie_absorption_per_km,mieScaleHeightKm:n.mie_scale_height_km,miePhase:r,absorptionPerKm:n.absorption_per_km,absorptionCenterKm:n.absorption_center_km,absorptionWidthKm:n.absorption_width_km,bakedCompensation:n.baked_compensation,multiScatterGain:n.multi_scatter_gain,sunIntensity:n.sun_intensity,sunColor:[1,1,1],realisticSunAlways:n.realistic_sun_always,refractivity:n.refractivity,groundAlbedo:n.ground_albedo,mieProfile:i,seasonal:mb(n.seasonal),referenceAltitudeKm:n.reference_altitude_km,deepColumn:hb(e,n.deep_column,t.deep_n)})}})();return e.catch(()=>{pb===e&&(pb=null)}),pb=e,e}function _b(e){return db.get(e)}function vb(){return fb}var yb=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function bb(e,t){return e>>>t|e<<32-t}function xb(e){let t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),n=Math.ceil((e.length+9)/64),r=new Uint8Array(n*64);r.set(e),r[e.length]=128,new DataView(r.buffer).setUint32(r.length-4,e.length*8,!1);let i=new Uint32Array(64),a=new DataView(r.buffer);for(let e=0;e<n;e++){for(let t=0;t<16;t++)i[t]=a.getUint32(e*64+t*4,!1);for(let e=16;e<64;e++){let t=bb(i[e-15],7)^bb(i[e-15],18)^i[e-15]>>>3,n=bb(i[e-2],17)^bb(i[e-2],19)^i[e-2]>>>10;i[e]=i[e-16]+t+i[e-7]+n|0}let[n,r,o,s,c,l,u,d]=t;for(let e=0;e<64;e++){let t=bb(c,6)^bb(c,11)^bb(c,25),a=c&l^~c&u,f=d+t+a+yb[e]+i[e]|0,p=(bb(n,2)^bb(n,13)^bb(n,22))+(n&r^n&o^r&o)|0;d=u,u=l,l=c,c=s+f|0,s=o,o=r,r=n,n=f+p|0}t[0]=t[0]+n|0,t[1]=t[1]+r|0,t[2]=t[2]+o|0,t[3]=t[3]+s|0,t[4]=t[4]+c|0,t[5]=t[5]+l|0,t[6]=t[6]+u|0,t[7]=t[7]+d|0}let o=new Uint8Array(32),s=new DataView(o.buffer);for(let e=0;e<8;e++)s.setUint32(e*4,t[e],!1);return o}function Sb(e){return e.shape===`parted`}function Cb(e){return e.shape===`chunked-parted`&&e.label===`date`}function wb(e){return e.shape===`chunked-parted`&&e.label===`index`}function Tb(e){return e.shape===`chunked`}function Eb(e,t){let n=Math.floor((t-e.start_jd)/e.chunk_days);return Math.max(0,Math.min(e.chunks-1,n))}function Db(e){return`shape`in e&&e.shape===`probes`}function Ob(e){return`zooms`in e}function kb(e){return Db(e)?[]:Ob(e)?Object.entries(e.zooms).map(([e,t])=>({zoom:Number(e),data:t})):[{zoom:null,data:e}]}function Ab(e){return!Ob(e)&&!Db(e)?e:void 0}var jb=new WeakMap;function Mb(e){let t=jb.get(e);return t||(t=Object.keys(e.parts_by_date).map(e=>Date.parse(`${e}T00:00:00Z`)).sort((e,t)=>e-t),jb.set(e,t)),t}function Nb(e,t){let n=Mb(e),r=t.getTime(),i=e=>new Date(e).toISOString().slice(0,10);if(r<=n[0])return i(n[0]);if(r>=n[n.length-1])return i(n[n.length-1]);let a=0,o=n.length-1;for(;a<o;){let e=a+o>>1;n[e]<r?a=e+1:o=e}let s=n[a-1],c=n[a];return i(r-s<=c-r?s:c)}var Pb=14;function Fb(e,t){let n=Mb(e),r=t.getTime(),i=Pb*864e5,a=n[0],o=n[n.length-1];if(r<a)return{kind:`covered`};if(r>o+i)return{kind:`after`,lastMs:o+i};if(r>=o)return{kind:`covered`};let s=0,c=n.length-1;for(;s<c;){let e=s+c>>1;n[e]<r?s=e+1:c=e}let l=n[s],u=s>0?n[s-1]:l;return Math.min(r-u,l-r)>i?{kind:`gap`}:{kind:`covered`}}function Ib(e,t,n=0){let r=e.parts_by_date[t]??e.parts;return n>0?Math.min(r,n):r}var Lb=null;function Rb(){if(Lb)return Lb;let e=K_(`${Kt()}/v1/metadata.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch metadata: ${e.status}`);return e.json()}).then(e=>(Jt(e.versions),e));return Lb=e,e.catch(()=>{Lb===e&&(Lb=null)}),Lb}function zb(e){let t=new Map;for(let[n,r]of Object.entries(e.position.zones)){if(Db(r))continue;let e=Ob(r)?0:null,i=e===0?r.zooms[0]:r;!i||!Tb(i)||t.set(n,{zoom:e,chunks:i.chunks,chunk_days:i.chunk_days,start_jd:i.start_jd,end_jd:i.end_jd})}return t}function Bb(e){let t=new Map,n=Object.entries(e.position.zones).filter(([,e])=>Db(e)).sort(([e],[t])=>(e===`probes/interplanetary`)-+(t===`probes/interplanetary`)||e.localeCompare(t));for(let[e,r]of n)Db(r)&&t.set(e,{chunks:r.chunks,chunk_days:r.chunk_days,start_jd:r.start_jd,end_jd:r.end_jd,float64_coeffs:r.float64_coeffs,fit_center_naif_id:r.fit_center_naif_id,present:r.present});return t}async function Vb(e,t){let n=new TextEncoder().encode(e),r=crypto.subtle?await crypto.subtle.digest(`SHA-256`,n):xb(n).buffer;return new DataView(r).getUint32(0,!1)%t}async function Hb(e,t){let n=await K_(e,{priority:t});if(!n.ok)throw Error(`Failed to fetch ${e}: ${n.status}`);let r=new DecompressionStream(`gzip`);return new Response(n.body.pipeThrough(r)).arrayBuffer()}async function Ub(e,t,n,r){let i=uy(await Hb(nn(e,t,n),r));if(i.kind!==`chebyshev`)throw Error(`Expected chebyshev payload at ${e}/${n}, got ${i.kind}`);let a=new Map;for(let e of i.chunk.bodies)e.id&&a.set(e.id,e);return{...i.chunk,byId:a}}var Wb=1,Gb=Promise.resolve();function Kb(e,t){return`${e}:${t}`}var qb=class{chunks=new Map;inflight=new Map;lastEnsuredJd=NaN;constructor(e){this.zoneParams=e}zones(){return Array.from(this.zoneParams.keys())}ensure(e){if(e===this.lastEnsuredJd)return{ready:this.allCurrentChunksLoaded(e),done:this.pendingCurrent(e)};this.lastEnsuredJd=e;let t=[],n=[],r=!0;for(let[i,a]of this.zoneParams){let o=Eb(a,e);if(this.isLoadable(a,o)&&!this.isResident(i,o)){r=!1;let e=this.loadChunk(i,a,o,`high`);e&&t.push(e)}for(let e=-Wb;e<=Wb;e++){let t=o+e;e===0||t<0||t>=a.chunks||this.isLoadable(a,t)&&n.push([i,a,t])}this.evictOutsideWindow(i,o)}let i=t.length>0?Promise.all(t).then(()=>void 0):Gb;return i.catch(()=>{}).then(()=>{for(let[e,t,r]of n)this.loadChunk(e,t,r,`low`)?.catch(()=>{})}),{ready:r,done:i}}pendingCurrent(e){if(this.inflight.size===0)return Gb;let t=null;for(let[n,r]of this.zoneParams){let i=this.inflight.get(Kb(n,Eb(r,e)));i&&(t??=[]).push(i)}return t?Promise.all(t).then(()=>void 0):Gb}allCurrentChunksLoaded(e){for(let[t,n]of this.zoneParams){let r=Eb(n,e);if(this.isLoadable(n,r)&&!this.isResident(t,r))return!1}return!0}isResident(e,t){return this.chunks.get(e)?.has(t)??!1}evictOutsideWindow(e,t){let n=this.chunks.get(e);if(n)for(let e of n.keys())(e<t-Wb||e>t+Wb)&&n.delete(e)}loadChunk(e,t,n,r){if(this.isResident(e,n))return null;let i=Kb(e,n),a=this.inflight.get(i);if(a)return a;let o=this.fetchAndStore(e,t,n,r);return this.inflight.set(i,o),o.finally(()=>this.inflight.delete(i)),o}async fetchAndStore(e,t,n,r){let i=await this.fetchChunk(e,t,n,r),a=this.chunks.get(e);a||this.chunks.set(e,a=new Map),a.set(n,i),this.afterStore(e,i)}},Jb=class extends qb{idToZone=new Map;isLoadable(){return!0}fetchChunk(e,t,n,r){return Ub(e,t.zoom,n,r)}afterStore(e,t){for(let n of t.byId.keys())this.idToZone.has(n)||this.idToZone.set(n,e)}has(e){return this.idToZone.has(e)}zoneCoverage(e){let t=this.idToZone.get(e);if(t===void 0)return null;let n=this.zoneParams.get(t);return n?{start:n.start_jd,end:n.end_jd}:null}resolve(e,t){let n=this.idToZone.get(e);if(n===void 0)return null;let r=this.zoneParams.get(n);if(!r)return null;let i=Eb(r,t),a=this.chunks.get(n)?.get(i);if(!a)return null;let o=a.byId.get(e);return o?{zone:n,chunkIdx:i,body:o}:null}body(e,t){return this.resolve(e,t)?.body??null}*bodiesAt(e){for(let[t,n]of this.zoneParams){let r=Eb(n,e),i=this.chunks.get(t)?.get(r);if(i)for(let e of i.bodies)yield{zone:t,body:e,startJd:i.startJd,endJd:i.endJd}}}positionScene(e,t){let n=this.resolve(e,t);return n?py(n.body,t):null}};async function Yb(e,t,n,r){let i=nn(e,null,t),a=await K_(i,{priority:r});if(!a.ok)throw Error(`Failed to fetch ${i}: ${a.status}`);let o=new DecompressionStream(`gzip`),s=uy(await new Response(a.body.pipeThrough(o)).arrayBuffer(),{probesFloat64:n});if(s.kind!==`probes`)throw Error(`Expected probes payload at ${e}/${t}, got ${s.kind}`);return{...s.chunk,ids:s.chunk.probes.map(e=>e.id)}}var Xb=24;function Zb(e,t){for(let[n,r]of e){if(t<n)return!1;if(t<=r)return!0}return!1}var Qb=7,$b=class extends qb{fitCenterUsable=null;warmed=new Map;carried=new Map;_version=0;get version(){return this._version}zoneCenter(e){return this.zoneParams.get(e)?.fit_center_naif_id}isLoadable(e,t){return Zb(e.present,t)}fetchChunk(e,t,n,r){return Yb(e,n,t.float64_coeffs,r)}afterStore(){this._version++}async warmAt(e){let t=[];for(let[n,r]of this.zoneParams){let i=Eb(r,e);if(i<0||i>=r.chunks||!Zb(r.present,i)||this.isResident(n,i))continue;let a=Kb(n,i);if(this.warmed.has(a))continue;let o=this.inflight.get(a);if(o){t.push(o);continue}let s=this.fetchAndWarm(a,n,i,r);this.inflight.set(a,s),s.finally(()=>this.inflight.delete(a)),t.push(s)}await Promise.all(t)}async fetchAndWarm(e,t,n,r){let i=await Yb(t,n,r.float64_coeffs,`low`);for(this.warmed.set(e,i);this.warmed.size>Xb;){let e=this.warmed.keys().next().value;if(e===void 0)break;this.warmed.delete(e)}}fitCenterCovered(e){let t=e.fitCenter;return!t||!this.fitCenterUsable?!0:this.fitCenterUsable(t.id)}*probesAt(e,t){let n=new Map,r=new Set;for(let[i,a]of this.zoneParams){let o=Eb(a,e),s=this.chunks.get(i)?.get(o)??this.warmed.get(Kb(i,o));if(!s)continue;let c=t?.(a.fit_center_naif_id)??!1;for(let e=0;e<s.probes.length;e++){let t=s.probes[e],o=t.id;if(!o||r.has(o)||!this.fitCenterCovered(t))continue;let l={zone:i,zoneCenterNaifId:a.fit_center_naif_id,id:o,probe:t,startJd:s.startJd,endJd:s.endJd};c?(n.set(o,l),r.add(o)):n.has(o)||n.set(o,l)}}yield*this.withPassengers(n,e).values()}withPassengers(e,t){if(this.carried.size===0)return e;let n=[];for(let[r,{carriedFrom:i}]of this.carried){if(t<i.start_jd||t>=i.end_jd||e.has(r))continue;let a=e.get(i.object_id);a&&n.push([r,a])}for(let[t,r]of n)e.set(t,{...r,id:t});return e}registerCarried(e){this.carried.set(e.id,e)}carrierAt(e,t){if(this.carried.size===0)return null;let n=this.carried.get(e)?.carriedFrom;return!n||t<n.start_jd||t>=n.end_jd+Qb?null:n.object_id}ridesAt(e){let t=[];for(let[n,r]of this.carried){let i=r.carriedFrom;if(e<i.start_jd||e>=i.end_jd+Qb)continue;let a=e<i.end_jd;!a&&this.resolveOwn(n,e)||t.push({passengerId:n,carrierId:i.object_id,carrierName:r.carrierName,attached:a})}return t}resolve(e,t,n){let r=this.resolveOwn(e,t,n);if(r)return r;let i=this.carrierAt(e,t);return i?this.resolveOwn(i,t,n):null}resolveOwn(e,t,n){let r=Fg(t),i=null;for(let[a,o]of this.zoneParams){let s=Eb(o,t),c=this.chunks.get(a)?.get(s)??this.warmed.get(Kb(a,s));if(c)for(let t of rx(c,e)){let e=c.probes[t];if(!this.fitCenterCovered(e))break;let s=hy(e,r)>=0,l=e.landed,u=l!==void 0&&r>=l.startEt&&r<l.endEt;if(!s&&!u)continue;let d={zone:a,probe:e,params:o};if(n?.(o.fit_center_naif_id))return d;i??=d;break}}return i}stampedFitCenterAt(e,t){let n=this.stampedFitCenterAtOwn(e,t);if(n!==null)return n;let r=this.carrierAt(e,t);return r?this.stampedFitCenterAtOwn(r,t):null}stampedFitCenterAtOwn(e,t){let n=Fg(t);for(let[r,i]of this.zoneParams){let a=Eb(i,t),o=this.chunks.get(r)?.get(a)??this.warmed.get(Kb(r,a));if(o)for(let t of rx(o,e)){let e=o.probes[t];if(hy(e,n)<0)break;return e.fitCenter?.id??null}}return null}probe(e,t,n){return this.resolve(e,t,n)?.probe??null}probeWithCenter(e,t,n){let r=this.resolve(e,t,n);return r?{probe:r.probe,fitCenterNaifId:r.params.fit_center_naif_id}:null}positionKm(e,t,n,r){let i=this.resolve(e,t,r);return i?Sy(i.probe,t,n):null}positionScene(e,t,n,r){let i=this.resolve(e,t,r);return i?Cy(i.probe,t,n):null}containingSystemAt(e,t){let n=this.containingSystemAtOwn(e,t);if(n!==null)return n;let r=this.carrierAt(e,t);return r?this.containingSystemAtOwn(r,t):null}containingSystemAtOwn(e,t){let n=Fg(t),r=this.zoneParams.get(ex);if(r){let i=Eb(r,t),a=this.chunks.get(ex)?.get(i);if(a)for(let t of rx(a,e)){let e=a.probes[t];for(let t of e.systemIntervals)if(n>=t.startEt&&n<t.endEt)return t.systemNaifId;return null}}for(let[n,r]of this.zoneParams){if(n===ex||r.fit_center_naif_id===10)continue;let i=Eb(r,t),a=this.chunks.get(n)?.get(i);if(a)for(let t of rx(a,e))return Math.floor(r.fit_center_naif_id/100)}return null}hasHeliocentricFit(e,t){if(this.hasHeliocentricFitOwn(e,t))return!0;let n=this.carrierAt(e,t);return n!==null&&this.hasHeliocentricFitOwn(n,t)}hasHeliocentricFitOwn(e,t){let n=this.zoneParams.get(ex);if(!n)return!1;let r=Eb(n,t),i=this.chunks.get(ex)?.get(r);if(!i)return!1;let a=Fg(t);for(let t of rx(i,e))if(hy(i.probes[t],a)>=0)return!0;return!1}},ex=`probes/interplanetary`,tx=[],nx=new WeakMap;function rx(e,t){let n=nx.get(e);if(!n){n=new Map;for(let t=0;t<e.ids.length;t++){let r=n.get(e.ids[t]);r?r.push(t):n.set(e.ids[t],[t])}nx.set(e,n)}return n.get(t)??tx}async function ix(e){let t=new DecompressionStream(`gzip`);return await new Response(e.body.pipeThrough(t)).json()}function ax(e,t={}){let{onMissing:n,fetcher:r=e=>fetch(e),error:i=(e,t)=>`memoizedGzJson: ${t} returned ${e.status} ${e.statusText}`}=t,a=null;return()=>{if(a)return a;let t=(async()=>{let t=await e(),a=await r(t);if(!a.ok){if(a.status===404&&n)return n();throw Error(i(a,t))}return ix(a)})();return a=t,t.catch(()=>{a===t&&(a=null)}),t}}var ox=24,sx=new Map;function cx(e,t){let n=sx.get(e);if(n&&(sx.delete(e),sx.set(e,n)),!n){n=(async()=>{let n=await K_(e,t);if(!n.ok){if(n.status===404)return{};throw Error(`fetchGzipBundle: ${e} returned ${n.status} ${n.statusText}`)}return ix(n)})(),sx.set(e,n),n.catch(()=>{sx.get(e)===n&&sx.delete(e)});for(let e of sx.keys()){if(sx.size<=ox)break;sx.delete(e)}}return n}var lx={counts:`object_bundles`,globalPath:e=>`/v1/objects/__global__/${e}.json.gz`,localizedPath:(e,t)=>`/v1/objects/${e}/${t}.json.gz`,versionClass:`objects`},ux={counts:`group_bundles`,globalPath:e=>`/v1/groups/__global__/${e}.json.gz`,localizedPath:(e,t)=>`/v1/groups/${e}/${t}.json.gz`},dx=(e,t)=>cx(t?Yt(e,t):`${Kt()}${e}`);async function fx(e,t,{meta:n,lang:r,fetchBundle:i,localized:a=!0}){let o=n[e.counts],s=o?.global??0,c=a?o?.[r]??0:0,[l,u]=await Promise.all([s?Vb(t,s):-1,c?Vb(t,c):-1]),[d,f]=await Promise.all([l>=0?i(e.globalPath(l),e.versionClass):null,u>=0?i(e.localizedPath(r,u),e.versionClass):null]);return{global:d?.[t]??null,localized:f?.[t]??null}}async function px(e,t,n,r=!0){return fx(e,t,{meta:await Rb(),lang:n,localized:r,fetchBundle:dx})}function mx(e){return e.imagery!==`withheld`&&o(e.distribution)}function hx(e,t=!0,n=c()){return px(lx,e,n,t)}async function gx(e){if(e?.startsWith(`probe-`))try{let t=(await hx(e,!1)).global,n=t?.coverage?.position_from;return n?{id:e,carriedFrom:n,carrierName:t?.carried_by?.name}:void 0}catch{return}}function _x(e,t,n){let r=new Set,i=new Map;for(let a of e){let e=t===a.passengerId;if(r.add(e?a.carrierId:a.passengerId),!e||!a.attached)continue;let o=n(a.carrierId)??a.carrierName;o&&i.set(a.passengerId,o)}return{hidden:r,credits:i}}function vx(e){return W[e.toUpperCase()]??W.UNDOCUMENTED}var yx={horizons:U.HORIZONS,sbdb:U.SBDB,celestrak:U.CELESTRAK,spacetrack:U.SPACETRACK,spice:U.SPICE,sbdb_moons:U.SBDB_MOON,astersat:U.ASTERSAT};function bx(e){return e?yx[e]??U.UNKNOWN:U.UNKNOWN}var xx=14;function Sx(e,t){let n=t.global;if(!n?.orbit)return null;let r=n.orbit,i=r.scale===`planet`,a=r.q!=null,o=n.cross_refs?.norad_cat_id,s=r.bstar!=null&&r.mean_motion_dot!=null&&r.mean_motion_ddot!=null&&r.n!=null&&o!=null,c=i&&s?_g({noradCatId:o,epochJd:r.epoch_jd,meanMotion:r.n,eccentricity:r.e,inclination:r.i,raOfAscNode:r.om,argOfPericenter:r.w,meanAnomaly:r.ma??0,bstar:r.bstar,meanMotionDot:r.mean_motion_dot,meanMotionDdot:r.mean_motion_ddot,elementSetNo:r.element_set_no??0,revAtEpoch:r.rev_at_epoch??0},n.name??void 0)??void 0:void 0;return{id:e,name:t.localized?.name??n.name??n.sbdb_primary_designation??n.provisional_designation??null,objectType:vx(n.type),parentId:r.parent_id,radiusKm:n.sbdb?.diameter?n.sbdb.diameter/2:NaN,hasLocalized:t.localized!=null,a:i?(r.a??0)/ig:r.a??0,e:r.e,i:r.i,om:r.om,w:r.w,ma:r.ma??0,n:i?(r.n??0)*360:r.n??0,epoch:r.epoch_jd,equatorial:i,validityStart:c?r.epoch_jd-xx:-1/0,validityEnd:c?r.epoch_jd+xx:1/0,orbitalSource:bx(r.source),...a?{q:r.q,tp:r.tp}:{},...c?{satrec:c}:{}}}function Cx(e,t){let n=t.global;return n?{id:e,name:t.localized?.name??n.name??n.sbdb_primary_designation??n.provisional_designation??null,objectType:vx(n.type),parentId:``,radiusKm:n.sbdb?.diameter?n.sbdb.diameter/2:NaN,hasLocalized:t.localized!=null,unplaceable:!0,a:NaN,e:NaN,i:NaN,om:NaN,w:NaN,ma:NaN,n:NaN,epoch:NaN,validityStart:-1/0,validityEnd:1/0,orbitalSource:U.UNKNOWN}:null}async function wx(e,t,n,r=new Set){if(r.has(e))return console.warn(`createPlaceholderBody: cycle detected at ${e} — hiding`),[];r.add(e);let i;try{i=await hx(e)}catch{return console.warn(`createPlaceholderBody: failed to fetch global data for ${e} — hiding`),[]}let a=i.global;if(!a)return console.warn(`createPlaceholderBody: no catalogue record for ${e} — hiding`),[];let o=a.sbdb?.class??null,s=t=>{let n=t?{...t,unplaceable:!0}:Cx(e,i);return n?[{body:{data:n,position:[0,0,0],positionUnknown:!0},zone:o}]:[]},c=Sx(e,i);if(!c)return s();let l=c.satrec,u=c.q!=null,d=[],f=n.positions.get(c.parentId);if(!f){let e=await wx(c.parentId,t,n,r),i=e[e.length-1];if(!i||i.body.positionUnknown)return[...e,...s(c)];f=i.body.position,n.positions.set(c.parentId,f),d.push(...e)}let p=l?bg(l,Ng(t)):u?Yv(c,t):qv(c,t);if(!p)return console.warn(`Failed to compute position for ${e} (e=${c.e})`),[...d,...s(c)];let m=[f[0]+p[0],f[1]+p[1],f[2]+p[2]];return d.push({body:{data:c,position:m,orbitElements:c,orbitCenter:f},zone:o}),d}function Tx(e,t,n,r){let i=0;for(let a=0;a<t.length;a++){let{body:o,zone:s}=t[a];if(e.getBody(o.data.id))continue;let c=o.data.objectType;if(o.data.unplaceable)e.bodies.addBodies([o]),i++;else{let l=a>0?t[a-1]:null,u=c===W.MOON&&l&&_n(l.body.data.objectType)?`small_body_moons`:s;if(c===W.SPACECRAFT||c===W.DEBRIS){let t=o.data.parentId;e.bodies.spacecraftBucket(t).set(o.data.id,o),r?.onPlaceholder?.(o),e.bodies.dirtySpacecraftGroups.add(t),i++}else u?(e.bodies.asteroidBucket(u,n).addPlaceholder(o),e.bodies.dirtyAsteroidZones.add(u),i++):e.bodies.addBodies([o])}e.credits.recordOrbitSources([o])}return i}async function Ex(e,t,n,r){if(e.getBody(t))return;let i=await wx(t,n,r);if(i.length===0)return;let a=Tx(e,i,await Vv());e.bodies.flushMinor(a>0)}var Dx=`spacemap.atmosphere-calibration`;function Ox(){try{let e=localStorage.getItem(Dx);return e?JSON.parse(e):null}catch{return null}}function kx(e){try{e?localStorage.setItem(Dx,JSON.stringify(e)):localStorage.removeItem(Dx)}catch{}}function Ax(){return $e({resolvedReducedMotion:typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,viewMode:`map`,showClouds:!0,showAtmospheres:!0,atmosphereQuality:`auto`,atmosphereAutoTier:null,atmosphereCalibration:Ox(),atmoQualityOverrides:{},highAmbient:!1,realisticLighting:!1,overexposeRings:!1,showShapeMesh:!0,showSurfaceTexture:!0,showDisplacement:!0,showSelfShadow:!0,showHaloDebug:!1,maxPartsPerZone:0,setAtmosphereCalibration(e){this.atmosphereCalibration=e,kx(e)},setAtmosphereAutoTier(e){this.atmosphereAutoTier=e}})}var jx=null;function Mx(){return jx??=Ax()}function Nx(e){jx=e}var Px=2e3,Fx=3,Ix=class{zones=[];latestDate;failureStreak=0;staleNotified=!1;constructor(e,t,n,r){this.ctx=e,this.loader=n,this.latestDate=r;let i=Ng(r),a=Mx().maxPartsPerZone;for(let[n,o]of Object.entries(t.position.zones)){if(e.layers.skipsZone(n))continue;let t=o.parent_id_type??`naif`;for(let{zoom:e,data:s}of kb(o)){if(s.shape===`chunked`||s.shape===`parted`)continue;let o=a>0?Math.min(s.parts,a):s.parts;if(Cb(s)){let i={kind:`time`,zone:n,zoom:e,parts:o,parentIdType:t,zoomData:s,currentTime:Nb(s,r),inFlight:null,lastLoadStartMs:-1/0,cap:a};this.zones.push(i),this.prefetchTimeNeighbors(i,r)}else if(wb(s)){let a={kind:`chunk`,zone:n,zoom:e,parts:o,parentIdType:t,zoomData:s,currentIdx:Eb(s,i),inFlight:null,preloads:new Map};this.zones.push(a),this.preloadChunkNeighbors(a,r)}}}}recordSuccess(){this.failureStreak=0}recordFailure(){this.failureStreak++,this.failureStreak>=Fx&&!this.staleNotified&&(this.staleNotified=!0,this.ctx.onDataStale?.())}invalidateZone(e){for(let t of this.zones)t.zone!==e||t.kind!==`time`||(t.currentTime=``,t.lastLoadStartMs=-1/0);this.tick(this.latestDate)}satelliteCoverage(e){let t=this.zones.find(e=>e.kind===`time`&&e.zone===`earth`);return t?Fb(t.zoomData,Pg(e)):{kind:`covered`}}tick(e){this.latestDate=e;let t=Ng(e);for(let n of this.zones)if(n.kind===`time`){if(n.inFlight)continue;let t=Nb(n.zoomData,e);if(t===n.currentTime)continue;let r=performance.now();if(r-n.lastLoadStartMs<Px)continue;n.lastLoadStartMs=r,n.inFlight=this.loadTime(n,t,e).finally(()=>{n.inFlight=null})}else{for(;;){let r=Eb(n.zoomData,t);if(r===n.currentIdx)break;let i=n.preloads.get(r);if(i?.kind!==`ready`)break;let a=n.currentIdx;n.currentIdx=r,this.applyChunkSwap(n,a,r,i.bodies),this.preloadChunkNeighbors(n,e)}if(n.inFlight)continue;let r=Eb(n.zoomData,t);if(r===n.currentIdx)continue;n.inFlight=this.loadChunk(n,r,e).finally(()=>{n.inFlight=null})}}async ensureBody(e,t){if(!this.ctx.getBody(e)){if(e.startsWith(`probe-`)){let n=this.ctx.probeStore;if(!n)return;let r=Ng(t),i=gx(e);await n.ensure(r).done;let a=await i;a&&n.registerCarried(a);let o=n.stampedFitCenterAt(e,r);if(o){this.ctx.getBody(o)||await Ex(this.ctx,o,t,this.loader);let e=this.ctx.getBody(o);e&&!e.positionUnknown&&!this.loader.positions.has(o)&&this.loader.positions.set(o,e.position)}let s=await Vv(),c=this.loader.processProbes(n,t,s).find(t=>t.data.id===e);if(!c){await Ex(this.ctx,e,t,this.loader);return}this.ctx.bodies.addBodies([c]),this.ctx.credits.recordOrbitSources([c]),this.ctx.bodies.notifyBodiesAdded();return}await Ex(this.ctx,e,t,this.loader)}}async loadTime(e,t,n){let r=e.currentTime;try{let i=Ib(e.zoomData,t,e.cap),a=await Promise.all(Array.from({length:i},(r,i)=>this.loader.process(e.zone,e.zoom,i,n,t,e.parentIdType))),o=e.zone===`earth`,s=o?this.ctx.earthSatFilter:null,c=o?this.ctx.earthTypeFilter:null,l=0,u=new Map;for(let t of a){this.ctx.credits.recordOrbitSources(t);for(let n of t){let t=n.data.objectType;if(t!==W.SPACECRAFT&&t!==W.DEBRIS){console.warn(`zone-refresher: unexpected non-spacecraft body in ${e.zone}: ${n.data.id} (type=${t})`);continue}if(s&&!s.has(n.data.id)){l++;continue}if(c&&!c.has(t)){l++;continue}let r=n.data.parentId,i=u.get(r);i||u.set(r,i=new Map),i.set(n.data.id,n)}}l>0&&console.log(`zone-refresher: ${e.zone}@${t}: filtered out ${l} non-member bodies`);let d=0,f=0,p=0;for(let[e,t]of u){let n=this.ctx.bodies.spacecraftBucket(e);for(let e of n.keys())t.has(e)||this.ctx.hasMeshBody?.(e)||(n.delete(e),p++);for(let[e,r]of t){let t=n.get(e);t?(t.data=r.data,t.position=r.position,r.orbitElements!==void 0&&(t.orbitElements=r.orbitElements),r.orbitCenter!==void 0&&(t.orbitCenter=r.orbitCenter),f++):(n.set(e,r),d++)}this.ctx.bodies.dirtySpacecraftGroups.add(e)}e.currentTime=t,this.ctx.bodies.minorBodyVersion++,d>0&&this.ctx.bodies.notifyBodiesAdded(),e.zone===`earth`&&this.ctx.notifyEarthSatRollover(),console.log(`zone-refresher: ${e.zone}@${r} → ${t} (+${d} ~${f} -${p})`),this.prefetchTimeNeighbors(e,n),this.recordSuccess()}catch(n){console.warn(`zone-refresher: failed to refresh ${e.zone}@${t}:`,n),this.recordFailure()}}async loadChunk(e,t,n){let r=e.currentIdx;e.currentIdx=t;try{let i=e.preloads.get(t),a;a=i?.kind===`pending`?await i.promise:await Promise.all(Array.from({length:e.parts},(r,i)=>this.loader.process(e.zone,e.zoom,i,n,String(t),e.parentIdType))),this.applyChunkSwap(e,r,t,a),this.preloadChunkNeighbors(e,n),this.recordSuccess()}catch(n){console.warn(`zone-refresher: ${e.zone} chunk reload failed (${r} → ${t}):`,n),e.currentIdx=r,this.recordFailure()}}applyChunkSwap(e,t,n,r){let i=0,a=0;for(let e of r){this.ctx.credits.recordOrbitSources(e);for(let t of e){let e=this.ctx.bodies.bodiesById.get(t.data.id);if(!e){this.ctx.bodies.addBodies([t]),this.ctx.bodies.majorBodies.push(t),a++;continue}e.data=t.data,e.position=t.position,t.orbitElements!==void 0&&(e.orbitElements=t.orbitElements),t.orbitCenter!==void 0&&(e.orbitCenter=t.orbitCenter),i++}}this.ctx.bodies.minorBodyVersion++,console.log(`zone-refresher: ${e.zone} chunk ${t} → ${n} (+${a} ~${i})`)}preloadChunkNeighbors(e,t){let n=Math.max(0,e.currentIdx-1),r=Math.min(e.zoomData.chunks-1,e.currentIdx+1);for(let i=n;i<=r;i++){if(e.preloads.has(i))continue;let n=String(i),r=Promise.all(Array.from({length:e.parts},(r,i)=>this.loader.process(e.zone,e.zoom,i,t,n,e.parentIdType)));e.preloads.set(i,{kind:`pending`,promise:r}),r.then(t=>{e.preloads.get(i)?.kind===`pending`&&e.preloads.set(i,{kind:`ready`,bodies:t})},t=>{console.warn(`zone-refresher: ${e.zone} chunk ${i} preload failed:`,t),e.preloads.get(i)?.kind===`pending`&&e.preloads.delete(i)})}for(let t of e.preloads.keys())(t<n||t>r)&&e.preloads.delete(t)}prefetchTimeNeighbors(e,t){let n=864e5,r=Nb(e.zoomData,new Date(t.getTime()-n)),i=Nb(e.zoomData,new Date(t.getTime()+n));for(let t of new Set([r,i])){if(t===e.currentTime)continue;let n=Ib(e.zoomData,t,e.cap);for(let r=0;r<n;r++)ub.prefetch(e.zone,e.zoom,r,t)}}},Lx,Rx=new Promise(e=>{Lx=e});function zx(){Lx()}var Bx=4;function Vx(){return typeof navigator>`u`?!1:navigator.connection?.saveData===!0}function Hx(){if(typeof navigator>`u`)return!1;if(Vx())return!0;let e=navigator.deviceMemory;return typeof e==`number`&&e>0&&e<=Bx}var Ux;function Wx(){return Ux===void 0&&(Ux=typeof window<`u`&&!!window.matchMedia?.(`(pointer: coarse)`).matches),Ux}function Gx(){return typeof window>`u`?1:Math.min(window.devicePixelRatio,2)}var Kx={low:{maxPixelRatio:1.25,shadowMapSize:1024,softShadows:!1,bloomScale:.5,pointBudget:4e5,maxTextureTier:`medium`,maxSkyboxFace:2048},medium:{maxPixelRatio:1.5,shadowMapSize:2048,softShadows:!0,bloomScale:.75,pointBudget:9e5,maxTextureTier:`medium`,maxSkyboxFace:2048},high:{maxPixelRatio:2,shadowMapSize:4096,softShadows:!0,bloomScale:1,pointBudget:1/0,maxTextureTier:`high`,maxSkyboxFace:1/0}};function qx(){return Hx()?`low`:Yx().maxTextureTier}function Jx(){let e=Mx().atmosphereCalibration?.tier;return e===`low`||e===`medium`?e:e===`high`||e===`ultra`?`high`:Wx()?Hx()?`low`:`medium`:Hx()?`medium`:`high`}function Yx(){return Kx[Jx()]}function Xx(){return typeof window>`u`?1:Math.min(window.devicePixelRatio,Yx().maxPixelRatio)}var Zx=Math.PI/180*ag,Qx=new Hi().setFromAxisAngle(new J(0,0,1),-Math.PI/2).premultiply(new Hi().setFromAxisAngle(new J(0,1,0),Math.PI/2-Zx)).premultiply(new Hi().setFromAxisAngle(new J(1,0,0),-Math.PI/2)),$x=[`px`,`nx`,`py`,`ny`,`pz`,`nz`];function eS(e,t){if(e.tiers.length===0)return null;let n=[...e.tiers].sort((t,n)=>(e.tier_face_size[n]??0)-(e.tier_face_size[t]??0));for(let r of n)if((e.tier_face_size[r]??1/0)<=t)return r;return n[n.length-1]}function tS(e,t,n){return Yt(`/v1/textures/${e}/${t}_${n}.webp`,`textures`)}async function nS(e,t,n){return Promise.all($x.map(async r=>{let i=await fetch(tS(e,t,r),{priority:n});if(!i.ok)throw Error(`Skybox face fetch failed (${i.status}): ${t}_${r}`);let a=await i.blob();return createImageBitmap(a,{imageOrientation:`none`,premultiplyAlpha:`none`})}))}var rS=new Map,iS=new Map;function aS(e,t){return`${e}:${t}`}function oS(e,t,n,r=!0){let i=aS(e,t),a=rS.get(i);if(!a){let r=nS(e,t,n);a=r,rS.set(i,a),r.catch(()=>{rS.get(i)===r&&(rS.delete(i),iS.delete(i))})}return r&&iS.set(i,(iS.get(i)??0)+1),a}function sS(e,t,n){let r=aS(e,t),i=(iS.get(r)??1)-1;if(i>0){iS.set(r,i);return}iS.delete(r),rS.delete(r);for(let e of n)e.close()}function cS(e){let t=new Mc(e);return t.colorSpace=Xr,t.needsUpdate=!0,t}function lS(e){return e.tiers.length===0?null:[...e.tiers].sort((t,n)=>(e.tier_face_size[t]??0)-(e.tier_face_size[n]??0))[0]}function uS(e){let t=lS(e);t&&oS(e.id,t,void 0,!1).catch(()=>{})}var dS=12e3;async function fS(e,t,n,r){let i=eS(n,Math.min(t.capabilities.maxTextureSize,Yx().maxSkyboxFace));if(!i){console.warn(`Skybox ${n.id}: no tiers declared`);return}let a=lS(n),o={cube:null,bitmaps:null},s=!1;a&&a!==i&&oS(n.id,a).then(t=>{if(s||r()){sS(n.id,a,t);return}o.cube=cS(t),o.bitmaps=t,e.background=o.cube,performance.mark(`sm-skybox-low`),c&&l()}).catch(()=>{});let c=!1,l=()=>{!a||!o.cube||!o.bitmaps||(t.initTexture(o.cube),sS(n.id,a,o.bitmaps),o.bitmaps=null)};i!==a&&await Promise.race([Rx,new Promise(e=>setTimeout(e,dS))]);let u;try{u=await oS(n.id,i,i===a?void 0:`low`)}catch(e){throw c=!0,r()?a&&o.bitmaps&&(o.cube?.dispose(),sS(n.id,a,o.bitmaps),o.bitmaps=null):l(),e}if(await new Promise(e=>`requestIdleCallback`in window?requestIdleCallback(()=>e(),{timeout:2e3}):setTimeout(e,500)),r()){s=!0,o.cube?.dispose(),sS(n.id,i,u),a&&a!==i&&o.bitmaps&&sS(n.id,a,o.bitmaps);return}let d=cS(u);t.initTexture(d),s=!0;let f=e.background;e.background=d,performance.mark(`sm-skybox-high`),o.cube?.dispose(),f&&f!==o.cube&&f instanceof Mc&&f.dispose(),sS(n.id,i,u),a&&a!==i&&o.bitmaps&&sS(n.id,a,o.bitmaps)}async function pS(e,t,n,r=()=>!1){if(!n?.layers.skipped.has(`stars`))try{let i=await Rb();if(!i.skybox)return;n&&(n.credits.skybox={source:i.skybox.source,organisation:i.skybox.organisation,license:i.skybox.license,attribution:i.skybox.attribution,description:i.skybox.description}),await fS(e,t,i.skybox,r)}catch(e){console.warn(`Failed to load skybox:`,e)}}var mS=13;function hS(e,t,n){let r=Mx().maxPartsPerZone,i=[],a=[];for(let[o,s]of Object.entries(e.position.zones)){if(o===`major`||o===`moons`||o===`spacecraft`||Db(s)||n.skipsZone(o))continue;let e=s.parent_id_type??`naif`;for(let{zoom:n,data:c}of kb(s)){if(c.shape===`chunked`)continue;let s=Cb(c)?Nb(c,t):null,l=Cb(c)&&s!==null?Ib(c,s,r):r>0?Math.min(c.parts,r):c.parts;for(let t=0;t<l;t++){let r={zone:o,zoom:n,part:t,time:s,parentIdType:e};n!==null&&n>=1&&t>=mS?a.push(r):i.push(r)}}}return{eager:i,deferred:a}}async function gS(e,t,n){let r=Bb(e);for(let e of r.keys())n.skipsZone(e)&&r.delete(e);if(r.size===0)return null;console.log(`ProbeStore: ${r.size} zone(s) from metadata:\n`+Array.from(r).map(([e,t])=>` ${e}: chunks=${t.chunks} chunk_days=${t.chunk_days} fit_center=naif-${t.fit_center_naif_id} float64=${t.float64_coeffs}`).join(`
|
|
4052
|
+
`));let i=Array.from(r).filter(([,e])=>e.fit_center_naif_id===void 0);i.length>0&&console.warn(`ProbeStore: ${i.length} zone(s) missing fit_center_naif_id in metadata — re-export to refresh: ${i.map(([e])=>e).join(`, `)}`);let a=new $b(r);return await a.ensure(t).done,a}async function _S(e,t,n,r,i,a){let o=[],s=null;e.chebStore&&(s=await Vv(),o.push(...t.processChebyshev(r,s))),e.probeStore&&(s??=await Vv(),a&&e.probeStore.registerCarried(a),o.push(...t.processProbes(e.probeStore,r,s)));let c=n.position.zones.major;if(c&&Ob(c))for(let e of[1,2]){let n=c.zooms[String(e)];if(n&&Sb(n))for(let i=0;i<n.parts;i++)o.push(...await t.process(`major`,e,i,r))}let l=e.layers.skipsZone(`moons`)?void 0:n.position.zones.moons,u=l?Ab(l):void 0,d=u&&wb(u)?String(Eb(u,i)):null;return u&&o.push(...await t.process(`moons`,null,0,r,d)),vS(o)}function vS(e){let t=new Map,n=[];for(let r of e){let e=r.data.id;t.has(e)?n.push(e):t.set(e,r)}return n.length>0&&console.warn(`majors: ${n.length} duplicate id(s) in phase 1, kept first:`,n),[...t.values()]}async function yS(e,t,n){performance.mark(`sm-load-start`),U_.reset(),X_().catch(e=>console.warn(`scene-load: systems-global (GMs/nutation) failed to load:`,e));let r=gb().catch(e=>console.warn(`scene-load: atmospheres failed to load — rendering without shells:`,e)),i=Ng(t),a=Rb();Vv().catch(()=>{}),a.then(t=>{let n=t.position.zones.moons;if(!n||e.layers.skipsZone(`moons`))return;let r=Ab(n);r&&Sb(r)&&ub.prefetch(`moons`,null,0,null)}),a.then(t=>{t.skybox&&!e.layers.skipped.has(`stars`)&&uS(t.skybox)});let o=a.then(n=>hS(n,t,e.layers)),s=a.then(async t=>{let n=zb(t);for(let t of n.keys())e.layers.skipsZone(t)&&n.delete(t);if(n.size===0)return null;let r=new Jb(n);return await r.ensure(i).done,r}),c=a.then(t=>gS(t,i,e.layers)),l=gx(n),u=await a;U_.reach(`metadata`),e.chebStore=await s,e.probeStore=await c,U_.reach(`ephemeris`);let d=new ub(e.chebStore);e.probeStore&&(e.probeStore.fitCenterUsable=t=>(e.chebStore?.has(t)??!1)||(e.hasMeshBody?.(t)??!1)||d.positions.has(t));let f=await _S(e,d,u,t,i,await l);U_.reach(`majors`),await r,e.bodies.addBodies(f),e.credits.recordOrbitSources(f);let p=await Vv();U_.reach(`labels`);let m=new Map,h=!1,g=()=>{h=!0},_=()=>{let t=h;h=!1,e.bodies.flushMinor(t)};if(n&&!e.getBody(n)){let r=await wx(n,t,d);Tx(e,r,p,{onPlaceholder:e=>m.set(e.data.id,e)})>0&&g(),r.length>0&&_()}e.bodies.majorBodies=f.filter(e=>e.data.objectType!==W.BARYCENTER&&e.data.objectType!==W.LAGRANGE_POINT&&e.data.orbitalSource!==U.SPICE_PROBE),U_.reach(`done`),e.loading=!1,performance.mark(`sm-majors-done`);let{eager:v,deferred:y}=await o,b=v.filter(e=>e.zone===`small_body_moons`),x=v.filter(e=>e.zone!==`small_body_moons`);for(let e of b)try{await d.seedNeededParents(e.zone,e.zoom,e.part,e.time,e.parentIdType)}catch(t){console.warn(`scene-load: seedNeededParents failed for ${e.zone} part ${e.part}:`,t)}e.bodies.minorStreaming=!0;let S=setInterval(_,500),C=async(t,n,r)=>{e.credits.recordOrbitSource(n.source),n.rowCount!==0&&(await e.bodies.asteroidBucket(t,p).addChunk(n,r)>0&&g(),e.bodies.dirtyAsteroidZones.add(t))},w=(t,n)=>{e.credits.recordOrbitSources(n);let r=t===`earth`,i=r?e.earthSatFilter:null,a=r?e.earthTypeFilter:null;for(let t of n){if(i&&!i.has(t.data.id)||a&&!a.has(t.data.objectType))continue;let n=m.get(t.data.id);if(n){n.data=t.data,n.position=t.position,t.orbitElements!==void 0&&(n.orbitElements=t.orbitElements),t.orbitCenter!==void 0&&(n.orbitCenter=t.orbitCenter),m.delete(t.data.id),e.bodies.dirtySpacecraftGroups.add(t.data.parentId);continue}let r=t.data.parentId,o=e.bodies.spacecraftBucket(r);o.has(t.data.id)||g(),o.set(t.data.id,t),e.bodies.dirtySpacecraftGroups.add(r)}},T=(t,n)=>{e.credits.recordOrbitSources(n);let r=e.bodies.asteroidBucket(t,p);for(let e of n)r.addPlaceholder(e),g();e.bodies.dirtyAsteroidZones.add(t)},E=x.filter(e=>e.zone.startsWith(`small_bodies/`)),D=x.filter(e=>!e.zone.startsWith(`small_bodies/`)),O=new Set,k=(e,t)=>n=>{O.add(e),console.warn(`scene-load: ${e} part ${t} failed (skipped):`,n)};try{await Promise.all([...E.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.fetchMinorColumns(e,n,r,t,i,a).then(t=>C(e,t,a)).catch(k(e,r))),...D.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.process(e,n,r,t,i,a,new Set(m.keys()),`high`).then(t=>w(e,t)).catch(k(e,r)))]),await Promise.all(b.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.process(e,n,r,t,i,a).then(t=>T(e,t)).catch(k(e,r))))}finally{clearInterval(S),e.bodies.minorStreaming=!1,_(),performance.mark(`sm-minors-done`),zx()}if(y.length>0&&Hx())console.info(`Low-end device: skipping ${y.length} deferred minor-belt parts to conserve memory`);else if(y.length>0){e.bodies.minorStreaming=!0;let n=setInterval(_,1e3);try{await Promise.all(y.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.fetchMinorColumns(e,n,r,t,i,a,`low`).then(t=>C(e,t,a)).catch(k(e,r))))}finally{clearInterval(n),e.bodies.minorStreaming=!1,_(),performance.mark(`sm-deferred-done`)}}try{e.refresher=new Ix(e,await a,d,t);for(let t of O)e.refresher.invalidateZone(t)}catch(e){console.error(`scene-load: ZoneRefresher init failed; hot-reload disabled:`,e)}}var bS=ax(async()=>(await Rb(),Yt(`/v1/membership/earth.json.gz`,`membership`)),{onMissing:()=>({}),error:e=>`fetchEarthMembership: ${e.status} ${e.statusText}`});async function xS(e){let t=await bS();return new Set(t[e]??[])}function SS(e,t=c()){return px(ux,e,t)}var CS={[cv]:new Set([W.SPACECRAFT]),[lv]:new Set([W.DEBRIS])},wS=class{bodies=new I_;credits=new Cn;layers=new Cv;visibility=new Lv(this.bodies,()=>this.probeStore,()=>this.earthSatFilter,()=>this.smallBodyFilter,()=>this.layers);#e=qe(!0);get loading(){return Ut(this.#e)}set loading(e){Je(this.#e,e,!0)}#t=qe(null);get error(){return Ut(this.#t)}set error(e){Je(this.#t,e,!0)}onDataStale=null;constructor(){}chebStore=null;probeStore=null;refresher=null;hasMeshBody=null;earthSatFilter=null;earthSatFilterSlug=null;earthTypeFilter=null;smallBodyFilter=null;missionMemberIds=null;currentGroupSlug=null;groupFilterListeners=new Set;smallBodyFilterListeners=new Set;earthSatRolloverListeners=new Set;onGroupFilterChange(e){return this.groupFilterListeners.add(e),()=>this.groupFilterListeners.delete(e)}onSmallBodyFilterChange(e){return this.smallBodyFilterListeners.add(e),()=>this.smallBodyFilterListeners.delete(e)}onEarthSatRollover(e){return this.earthSatRolloverListeners.add(e),()=>this.earthSatRolloverListeners.delete(e)}notifyEarthSatRollover(){for(let e of this.earthSatRolloverListeners)e()}getBody(e,t){return this.bodies.getBody(e,t)}isMemberOfActiveGroup(e){if(this.missionMemberIds?.has(e)===!0||this.earthSatFilter?.has(e)===!0)return!0;let t=this.earthTypeFilter;if(t){let n=this.bodies.getBody(e)?.data.objectType;if(n!==void 0&&t.has(n))return!0}let n=this.smallBodyFilter;return n===null?!1:Dv(this.bodies,e,n)}async load(e,t){try{await yS(this,e,t)}catch(e){throw this.loading=!1,this.error=e instanceof Error?e.message:String(e),console.error(`[scene-load]`,e),e}}refreshTick(e){this.refresher?.tick(e)}async ensureBody(e,t){await this.refresher?.ensureBody(e,t)}async applyGroupFilter(e){if(e===this.currentGroupSlug)return;if(this.currentGroupSlug=e,e?.startsWith(`mission-`)){let t=await SS(e);if(e!==this.currentGroupSlug)return;this.missionMemberIds=new Set((t.global?.notable_members??[]).map(e=>e.id).filter(e=>!!e))}else this.missionMemberIds=null;let t=e?await this.resolveIndexEntry(e):null;if(e!==this.currentGroupSlug)return;let n=this.resolveSmallBodyFilter(e,t?.applies_to,t?.n),r=t?.applies_to===`earth_sat`?e:null,i=CS[e??``]??null;if(!pv(this.smallBodyFilter,n)){this.smallBodyFilter=n;for(let e of this.smallBodyFilterListeners)e(n)}if(r===this.earthSatFilterSlug&&i===this.earthTypeFilter)return;let a=r?await xS(r):null;if(e===this.currentGroupSlug){this.earthSatFilter=a,this.earthSatFilterSlug=r,this.earthTypeFilter=i;for(let e of this.groupFilterListeners)e(a);this.loading||(this.bodies.spacecraftByParent.delete(p_),this.bodies.dirtySpacecraftGroups.add(p_),this.bodies.minorBodyVersion++,this.refresher?.invalidateZone(`earth`))}}resolveSmallBodyFilter(e,t,n){if(e===ov)return{kind:`category`,category:`asteroid`};if(e===sv)return{kind:`category`,category:`comet`};if(e===null||t!==`small_body`)return null;if(e.startsWith(`class-`))return{kind:`class`,className:e.slice(rv.length)};if(e.startsWith(`flag-`)){let t=e.slice(iv.length),r=uv[t];return r===void 0?null:{kind:`flag`,flag:t,mask:r,n:n??0}}return null}async resolveIndexEntry(e){try{return(await hv())[e]??null}catch{return null}}},TS=400,ES=class{#e=qe(0);get jd(){return Ut(this.#e)}set jd(e){Je(this.#e,e,!0)}#t=qe(1);get timeScale(){return Ut(this.#t)}set timeScale(e){Je(this.#t,e,!0)}#n=qe(1);get direction(){return Ut(this.#n)}set direction(e){Je(this.#n,e,!0)}seeked=!1;#r=qe(0);get jumps(){return Ut(this.#r)}set jumps(e){Je(this.#r,e,!0)}#i=qe(0);get settledJd(){return Ut(this.#i)}set settledJd(e){Je(this.#i,e,!0)}#a=qe(!1);get live(){return Ut(this.#a)}set live(e){Je(this.#a,e,!0)}lastRealMs=0;prevScale=1;stops=null;settleTimer=null;constructor(e,t=!1){this.jd=e,this.settledJd=e,this.live=t,this.lastRealMs=performance.now()}tick(e){let t=e-this.lastRealMs;if(this.lastRealMs=e,this.timeScale===0)return;let n=this.jd+t/jg*this.timeScale,r=this.stops;if(r!==null){if(this.timeScale>0&&r.forwardJd!==null&&n>=r.forwardJd&&this.jd<r.forwardJd){this.jd=r.forwardJd,this.pause(),r.onHit(r.forwardJd);return}if(this.timeScale<0&&r.backwardJd!==null&&n<=r.backwardJd&&this.jd>r.backwardJd){this.jd=r.backwardJd,this.pause(),r.onHit(r.backwardJd);return}}this.jd=n}setBoundaryStops(e){this.stops=e}setTimeScale(e){let t=e*this.direction;t!==0&&(this.prevScale=t),this.timeScale=t,t!==1&&(this.live=!1),this.lastRealMs=performance.now()}toggleDirection(){this.direction=this.direction===1?-1:1,this.timeScale=-this.timeScale,this.prevScale=-this.prevScale,this.live=!1,this.lastRealMs=performance.now()}setJD(e){this.jd=e,this.seeked=!0,this.live=!1,this.lastRealMs=performance.now(),this.settleAfterPause()}jumpTo(e){this.setJD(e),this.jumps++,this.settle()}settle(){this.settleTimer!==null&&clearTimeout(this.settleTimer),this.settleTimer=null,this.settledJd=this.jd}settleAfterPause(){this.settleTimer!==null&&clearTimeout(this.settleTimer),this.settleTimer=null,!this.playing&&(this.settleTimer=setTimeout(()=>this.settle(),TS))}sweepTo(e){this.jd=e,this.live=!1,this.lastRealMs=performance.now()}pause(){this.timeScale!==0&&(this.prevScale=this.timeScale),this.timeScale=0,this.live=!1,this.settle()}play(){this.timeScale===0&&(this.timeScale=this.prevScale||1,this.lastRealMs=performance.now())}now(){this.jumpTo(Ng(new Date)),this.live=this.timeScale===1}get playing(){return this.timeScale!==0}get date(){return Pg(this.jd)}setDate(e){this.jumpTo(Ng(e))}},DS={type:`change`},OS={type:`start`},kS={type:`end`},AS=new _s,jS=new oc,MS=Math.cos(70*Vi.DEG2RAD),NS=new J,PS=2*Math.PI,FS={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},IS=1e-6,LS=class extends Kd{constructor(e,t=null){super(e,t),this.state=FS.NONE,this.target=new J,this.cursor=new J,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:`ArrowLeft`,UP:`ArrowUp`,RIGHT:`ArrowRight`,BOTTOM:`ArrowDown`},this.mouseButtons={LEFT:wn.ROTATE,MIDDLE:wn.DOLLY,RIGHT:wn.PAN},this.touches={ONE:Tn.ROTATE,TWO:Tn.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle=`auto`,this._domElementKeyEvents=null,this._lastPosition=new J,this._lastQuaternion=new Hi,this._lastTargetPosition=new J,this._quat=new Hi().setFromUnitVectors(e.up,new J(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Vd,this._sphericalDelta=new Vd,this._scale=1,this._panOffset=new J,this._rotateStart=new q,this._rotateEnd=new q,this._rotateDelta=new q,this._panStart=new q,this._panEnd=new q,this._panDelta=new q,this._dollyStart=new q,this._dollyEnd=new q,this._dollyDelta=new q,this._dollyDirection=new J,this._mouse=new q,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=zS.bind(this),this._onPointerDown=RS.bind(this),this._onPointerUp=BS.bind(this),this._onContextMenu=qS.bind(this),this._onMouseWheel=US.bind(this),this._onKeyDown=WS.bind(this),this._onTouchStart=GS.bind(this),this._onTouchMove=KS.bind(this),this._onMouseDown=VS.bind(this),this._onMouseMove=HS.bind(this),this._interceptControlDown=JS.bind(this),this._interceptControlUp=YS.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e===`grab`?this.domElement.style.cursor=`grab`:this.domElement.style.cursor=`auto`}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointercancel`,this._onPointerUp),this.domElement.addEventListener(`contextmenu`,this._onContextMenu),this.domElement.addEventListener(`wheel`,this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener(`keydown`,this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction=`none`}disconnect(){this.domElement.removeEventListener(`pointerdown`,this._onPointerDown),this.domElement.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.removeEventListener(`pointerup`,this._onPointerUp),this.domElement.removeEventListener(`pointercancel`,this._onPointerUp),this.domElement.removeEventListener(`wheel`,this._onMouseWheel),this.domElement.removeEventListener(`contextmenu`,this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener(`keydown`,this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=`auto`}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener(`keydown`,this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener(`keydown`,this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(DS),this.update(),this.state=FS.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;NS.copy(t).sub(this.target),NS.applyQuaternion(this._quat),this._spherical.setFromVector3(NS),this.autoRotate&&this.state===FS.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=PS:n>Math.PI&&(n-=PS),r<-Math.PI?r+=PS:r>Math.PI&&(r-=PS),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let e=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=e!=this._spherical.radius}if(NS.setFromSpherical(this._spherical),NS.applyQuaternion(this._quatInverse),t.copy(this.target).add(NS),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let e=null;if(this.object.isPerspectiveCamera){let t=NS.length();e=this._clampDistance(t*this._scale);let n=t-e;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),i=!!n}else if(this.object.isOrthographicCamera){let t=new J(this._mouse.x,this._mouse.y,0);t.unproject(this.object);let n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=n!==this.object.zoom;let r=new J(this._mouse.x,this._mouse.y,0);r.unproject(this.object),this.object.position.sub(r).add(t),this.object.updateMatrixWorld(),e=NS.length()}else console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.`),this.zoomToCursor=!1;e!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(AS.origin.copy(this.object.position),AS.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(AS.direction))<MS?this.object.lookAt(this.target):(jS.setFromNormalAndCoplanarPoint(this.object.up,this.target),AS.intersectPlane(jS,this.target))))}else if(this.object.isOrthographicCamera){let e=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),e!==this.object.zoom&&(this.object.updateProjectionMatrix(),i=!0)}return this._scale=1,this._performCursorZoom=!1,i||this._lastPosition.distanceToSquared(this.object.position)>IS||8*(1-this._lastQuaternion.dot(this.object.quaternion))>IS||this._lastTargetPosition.distanceToSquared(this.target)>IS?(this.dispatchEvent(DS),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e===null?PS/60/60*this.autoRotateSpeed:PS/60*this.autoRotateSpeed*e}_getZoomScale(e){let t=Math.abs(e*.01);return .95**(this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){NS.setFromMatrixColumn(t,0),NS.multiplyScalar(-e),this._panOffset.add(NS)}_panUp(e,t){this.screenSpacePanning===!0?NS.setFromMatrixColumn(t,1):(NS.setFromMatrixColumn(t,0),NS.crossVectors(this.object.up,NS)),NS.multiplyScalar(e),this._panOffset.add(NS)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;NS.copy(r).sub(this.target);let i=NS.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/n.clientHeight,this.object.matrix),this._panUp(2*t*i/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),r=e-n.left,i=t-n.top,a=n.width,o=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(i/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(PS*this._rotateDelta.x/t.clientHeight),this._rotateUp(PS*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(PS*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-PS*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(PS*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-PS*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(PS*this._rotateDelta.x/t.clientHeight),this._rotateUp(PS*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,i),this._dollyDelta.set(0,(this._dollyEnd.y/this._dollyStart.y)**+this.zoomSpeed),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new q,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function RS(e){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.addEventListener(`pointerup`,this._onPointerUp)),!this._isTrackingPointer(e)&&(this._addPointer(e),e.pointerType===`touch`?this._onTouchStart(e):this._onMouseDown(e),this._cursorStyle===`grab`&&(this.domElement.style.cursor=`grabbing`)))}function zS(e){this.enabled!==!1&&(e.pointerType===`touch`?this._onTouchMove(e):this._onMouseMove(e))}function BS(e){switch(this._removePointer(e),this._pointers.length){case 0:this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.removeEventListener(`pointerup`,this._onPointerUp),this.dispatchEvent(kS),this.state=FS.NONE,this._cursorStyle===`grab`&&(this.domElement.style.cursor=`grab`);break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function VS(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case wn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=FS.DOLLY;break;case wn.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=FS.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=FS.ROTATE}break;case wn.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=FS.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=FS.PAN}break;default:this.state=FS.NONE}this.state!==FS.NONE&&this.dispatchEvent(OS)}function HS(e){switch(this.state){case FS.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case FS.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case FS.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function US(e){this.enabled===!1||this.enableZoom===!1||this.state!==FS.NONE||(e.preventDefault(),this.dispatchEvent(OS),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(kS))}function WS(e){this.enabled!==!1&&this._handleKeyDown(e)}function GS(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Tn.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=FS.TOUCH_ROTATE;break;case Tn.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=FS.TOUCH_PAN;break;default:this.state=FS.NONE}break;case 2:switch(this.touches.TWO){case Tn.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=FS.TOUCH_DOLLY_PAN;break;case Tn.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=FS.TOUCH_DOLLY_ROTATE;break;default:this.state=FS.NONE}break;default:this.state=FS.NONE}this.state!==FS.NONE&&this.dispatchEvent(OS)}function KS(e){switch(this._trackPointer(e),this.state){case FS.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case FS.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case FS.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case FS.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=FS.NONE}}function qS(e){this.enabled!==!1&&e.preventDefault()}function JS(e){e.key===`Control`&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}function YS(e){e.key===`Control`&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}var{PI:XS,sin:ZS,cos:QS,asin:$S,atan2:eC,sqrt:tC}=Math,nC=180/XS,rC=XS/180;function iC(e,t,n){let[r,i,a]=e,[o,s,c,l]=n?[-t[0],-t[1],-t[2],t[3]]:t,u=l*r+s*a-c*i,d=l*i+c*r-o*a,f=l*a+o*i-s*r,p=-o*r-s*i-c*a;return[u*l+p*-o+d*-c-f*-s,d*l+p*-s+f*-o-u*-c,f*l+p*-c+u*-s-d*-o]}function aC(e,t,n){let r=e[0]-t[0],i=e[1]-t[1],a=e[2]-t[2],o=tC(r*r+i*i+a*a);return n&&([r,i,a]=iC([r,i,a],n,!0)),{latitude:$S(i/o)*nC,longitude:n?eC(-a,r)*nC:eC(r,a)*nC,distance:o}}function oC(e,t,n,r,i){let a=t*rC,o=n*rC,s,c,l;if(i){let e=[r*QS(a)*QS(o),r*ZS(a),-r*QS(a)*ZS(o)];[s,c,l]=iC(e,i,!1)}else s=r*QS(a)*ZS(o),c=r*ZS(a),l=r*QS(a)*QS(o);return[e[0]+s,e[1]+c,e[2]+l]}function sC(e,t,n,r){let i=e[0]-t[0],a=e[2]-t[2],o=tC(i*i+a*a);o>0?(i/=o,a/=o):(i=0,a=1);let s=n*rC,c=QS(s);return[r*c*i,r*ZS(s),r*c*a]}function cC(e){let t=(e+180)%360-180;return t<=-180?t+360:t}function lC(e,t,n){if(t===void 0&&n===void 0)return e;let r=t===void 0?-180:cC(t),i=r===180?-180:r,a=n===void 0?180:cC(n);if(i<=a?e>=i&&e<=a:e>=i||e<=a)return e;let o=(e,t)=>Math.abs(cC(e-t));return o(e,i)<=o(e,a)?i:a}var uC=p_,dC=Math.PI/180,fC=2451545,pC=36525;function mC(e,t,n){let r=t-fC,i=r/pC,a=e.pole_ra_0+e.pole_ra_1*i,o=e.pole_dec_0+e.pole_dec_1*i,s=e.w0+e.w1*r+e.w2*r*r;if(n){let{ra:e,dec:t,pm:r,angles:c}=n,l=Math.min(c.length>>1,Math.max(e.length,t.length,r.length));for(let n=0;n<l;n++){let l=(c[2*n]+c[2*n+1]*i)*dC,u=Math.sin(l);n<e.length&&(a+=e[n]*u),n<t.length&&(o+=t[n]*Math.cos(l)),n<r.length&&(s+=r[n]*u)}}let c=a*dC,l=o*dC,u=Math.cos(l),d=dg(u*Math.cos(c),u*Math.sin(c),Math.sin(l),new J).normalize(),f=dg(-Math.sin(c),Math.cos(c),0,new J).normalize(),p=new J().crossVectors(f,d).normalize(),m=new Hi().setFromRotationMatrix(new Y().makeBasis(f,d,p));return new Hi().setFromAxisAngle(d,s*dC).multiply(m)}function hC(e,t,n,r){e.quaternion.copy(mC(t,n,r))}var gC=new J(0,1,0),_C=new J;function vC(e,t,n){_C.set(t[0]-n[0],t[1]-n[1],t[2]-n[2]),!(_C.lengthSq()<1e-20)&&(_C.normalize(),e.quaternion.setFromUnitVectors(gC,_C))}function yC(e,t){e.quaternion.setFromUnitVectors(gC,t)}var bC={"+x":new J(1,0,0),"-x":new J(-1,0,0),"+y":new J(0,1,0),"-y":new J(0,-1,0),"+z":new J(0,0,1),"-z":new J(0,0,-1)};function xC(e){let t=[];for(let[n,r]of Object.entries(e)){let e=bC[n],i=bC[r];if(!e||!i)return console.warn(`frame_map: invalid axis pair ${n}→${r}; ignoring map`),null;t.push([e,i])}if(t.length<1||t.length>2)return console.warn(`frame_map: expected 1–2 axis pairs, got ${t.length}; ignoring map`),null;if(t.length===1)return new Hi().setFromUnitVectors(t[0][0],t[0][1]);let[[n,r],[i,a]]=t;if(n.dot(i)!==0||r.dot(a)!==0)return console.warn(`frame_map: the two pairs must use perpendicular axes; ignoring map`),null;let o=new J().crossVectors(n,i),s=new J().crossVectors(r,a),c=new Y().makeBasis(r,a,s),l=new Y().makeBasis(n,i,o).transpose();return new Hi().setFromRotationMatrix(c.multiply(l))}var SC=new J,CC=new J,wC=new J,TC=new J,EC=new J,DC=new J,OC=new J,kC=new J,AC=new Y,jC=new Y;function MC(e,t,n){if(e===`parent`)n.set(t.parentPos[0]-t.bodyPos[0],t.parentPos[1]-t.bodyPos[1],t.parentPos[2]-t.bodyPos[2]);else if(e===`sun`){if(!t.sunPos)return!1;n.set(t.sunPos[0]-t.bodyPos[0],t.sunPos[1]-t.bodyPos[1],t.sunPos[2]-t.bodyPos[2])}else{if(!t.velocity)return!1;n.set(t.velocity[0],t.velocity[1],t.velocity[2])}return n.lengthSq()<1e-20?!1:(n.normalize(),!0)}function NC(e,t,n){if(!MC(t.primary.target,n,SC))return;let r=bC[t.primary.axis],i=t.secondary;if(!i||!MC(i.target,n,CC)){e.quaternion.setFromUnitVectors(r,SC);return}if(EC.crossVectors(r,bC[i.axis]),kC.crossVectors(SC,CC),EC.lengthSq()<1e-20||kC.lengthSq()<1e-20){e.quaternion.setFromUnitVectors(r,SC);return}EC.normalize(),kC.normalize(),wC.copy(r),DC.copy(SC),TC.crossVectors(EC,wC),OC.crossVectors(kC,DC),AC.makeBasis(DC,OC,kC),jC.makeBasis(wC,TC,EC).transpose(),AC.multiply(jC),e.quaternion.setFromRotationMatrix(AC)}function PC(e,t){let n=e,r=n.userData.shaderMods??=[];r.includes(t)||(r.push(t),e.customProgramCacheKey=()=>r.join(`|`))}function FC(e,t,n){let r=e.onBeforeCompile;e.onBeforeCompile=(e,t)=>{r?.(e,t),n(e,t)},PC(e,t),e.needsUpdate=!0}var IC={uSunDir:{value:new J(1,0,0)},uSunAngularRadius:{value:0},uOccluderCount:{value:0},uOccluders:{value:Array.from({length:32},()=>new sa)}},LC=`
|
|
4053
4053
|
#define ECLIPSE_MAX_OCCLUDERS 32
|
|
4054
4054
|
uniform float uSunAngularRadius;
|
|
4055
4055
|
uniform int uOccluderCount;
|
|
@@ -4101,20 +4101,20 @@ void main() {
|
|
|
4101
4101
|
}
|
|
4102
4102
|
return result;
|
|
4103
4103
|
}
|
|
4104
|
-
`;function
|
|
4104
|
+
`;function RC(){return IC}function zC(){return{uEclipseSelfPos:{value:new J},uOccluders:{value:Array.from({length:32},()=>new sa)},uOccluderCount:{value:0}}}function BC(e,t,n,r){let i=IC.uSunAngularRadius.value,a=IC.uOccluders.value,o=IC.uOccluderCount.value,s=0;for(let c=0;c<o;c++){let o=a[c],l=o.x-t.x,u=o.y-t.y,d=o.z-t.z,f=l*l+u*u+d*d;if(f<o.w*o.w*.25)continue;let p=l*r.x+u*r.y+d*r.z;if(p<-(n+o.w))continue;let m=n+o.w+i*(p+n)*1.5;f-p*p>m*m||e[s++].copy(o)}return s}function VC(e,t){let n=IC.uSunAngularRadius.value;if(n<=0)return 1;let r=IC.uSunDir.value,i=IC.uOccluderCount.value,a=IC.uOccluders.value,o=1;for(let s=0;s<i;s++){let i=a[s],c=i.w;if(c<=0)continue;let l=i.x-t.x,u=i.y-t.y,d=i.z-t.z;if(Math.hypot(l,u,d)<c*.5)continue;let f=i.x-e.x,p=i.y-e.y,m=i.z-e.z,h=Math.hypot(f,p,m);if(h<1e-5)continue;let g=Math.asin(Math.min(c/h,1)),_=Math.max(-1,Math.min(1,(r.x*f+r.y*p+r.z*m)/h)),v=Math.acos(_);if(g>10*n){let e=(g-v)/n;if(e>=1)return 0;if(e<=-1)continue;let t=(Math.acos(-e)+e*Math.sqrt(Math.max(1-e*e,0)))/Math.PI;o*=1-t;continue}if(v>=n+g)continue;if(v+n<=g)return 0;if(v+g<=n){o*=1-g*g/(n*n);continue}let y=n,b=g,x=v,S=(x*x+y*y-b*b)/(2*x),C=Math.sqrt(Math.max(y*y-S*S,0)),w=y*y*Math.acos(Math.max(-1,Math.min(1,S/y)))+b*b*Math.acos(Math.max(-1,Math.min(1,(x-S)/b)))-x*C;o*=1-w/(Math.PI*y*y)}return o}function HC(e,t){let n=t??zC();return FC(e,`eclipse`,e=>{Object.assign(e.uniforms,IC,n),e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
|
|
4105
4105
|
varying vec3 vEclipseWorldPos;`).replace(`#include <begin_vertex>`,`#include <begin_vertex>
|
|
4106
4106
|
vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
|
|
4107
4107
|
uniform vec3 uSunDir;
|
|
4108
4108
|
uniform vec3 uEclipseSelfPos;
|
|
4109
4109
|
varying vec3 vEclipseWorldPos;
|
|
4110
|
-
${
|
|
4110
|
+
${LC}
|
|
4111
4111
|
float eclipseFactor() {
|
|
4112
4112
|
return eclipseFactorAt(vEclipseWorldPos, uEclipseSelfPos, uSunDir);
|
|
4113
4113
|
}
|
|
4114
4114
|
`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>
|
|
4115
4115
|
float eclipseShadow = eclipseFactor();
|
|
4116
4116
|
reflectedLight.directDiffuse *= eclipseShadow;
|
|
4117
|
-
reflectedLight.directSpecular *= eclipseShadow;`)}),n}var
|
|
4117
|
+
reflectedLight.directSpecular *= eclipseShadow;`)}),n}var UC=32,WC=1,GC=2,KC=1.5,qC=4,JC=.04,YC=.02,XC=-.08,ZC=.18;function QC(e,t,n,r){let i=t.image,a=new q(1/(i?.width??4096),1/(i?.height??2048)),o=e.userData.selfShadow;if(o)return o.uSelfHeightMap.value=t,o.uSelfScale.value=n,o.uSelfTexel.value.copy(a),o;let s={uSelfHeightMap:{value:t},uSelfScale:{value:n},uSelfTexel:{value:a}};e.userData.selfShadow=s;let c=r??RC().uSunDir;return FC(e,`selfShadow`,e=>{Object.assign(e.uniforms,s,{uSelfSunDir:c}),e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
|
|
4118
4118
|
varying vec3 vSelfWorldNormal;
|
|
4119
4119
|
varying vec2 vSelfUv;
|
|
4120
4120
|
varying vec3 vSelfEastW;
|
|
@@ -4133,7 +4133,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
|
|
|
4133
4133
|
vSelfNorthW = normalize(mat3(modelMatrix) * cross(nObj, eastObj));
|
|
4134
4134
|
vSelfRadiusW = length(mat3(modelMatrix) * position);
|
|
4135
4135
|
vSelfCosLat = cl;`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
|
|
4136
|
-
#define SELF_STEPS ${
|
|
4136
|
+
#define SELF_STEPS ${UC}
|
|
4137
4137
|
uniform sampler2D uSelfHeightMap;
|
|
4138
4138
|
uniform float uSelfScale;
|
|
4139
4139
|
uniform vec2 uSelfTexel;
|
|
@@ -4167,18 +4167,18 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
|
|
|
4167
4167
|
// Wider-than-one-texel stencil averages out 8-bit terracing, floored
|
|
4168
4168
|
// at the low tier's texel so a higher-res map keeps the same
|
|
4169
4169
|
// physical smoothing width instead of flattening the relief.
|
|
4170
|
-
vec2 d = max(uSelfTexel, vec2(1.0 / 2048.0, 1.0 / 1024.0)) * ${
|
|
4170
|
+
vec2 d = max(uSelfTexel, vec2(1.0 / 2048.0, 1.0 / 1024.0)) * ${GC.toFixed(3)};
|
|
4171
4171
|
float hu = selfHeight(vSelfUv + vec2(d.x, 0.0))
|
|
4172
4172
|
- selfHeight(vSelfUv - vec2(d.x, 0.0));
|
|
4173
4173
|
float hv = selfHeight(vSelfUv + vec2(0.0, d.y))
|
|
4174
4174
|
- selfHeight(vSelfUv - vec2(0.0, d.y));
|
|
4175
4175
|
// Slope = Δheight / Δworld-distance along each axis.
|
|
4176
|
-
float su = ${
|
|
4177
|
-
float sv = ${
|
|
4176
|
+
float su = ${WC.toFixed(3)} * hu / (2.0 * d.x * lenTu);
|
|
4177
|
+
float sv = ${WC.toFixed(3)} * hv / (2.0 * d.y * lenTv);
|
|
4178
4178
|
// |Tu|/|Tv|=2·cos(lat): fade relief at the poles, where |Tu|→0 blows up east-west slope into a starburst.
|
|
4179
4179
|
float poleFade = smoothstep(0.0, 0.12, lenTu / (2.0 * lenTv));
|
|
4180
|
-
su = clamp(su * poleFade, -${
|
|
4181
|
-
sv = clamp(sv * poleFade, -${
|
|
4180
|
+
su = clamp(su * poleFade, -${KC.toFixed(3)}, ${KC.toFixed(3)});
|
|
4181
|
+
sv = clamp(sv * poleFade, -${KC.toFixed(3)}, ${KC.toFixed(3)});
|
|
4182
4182
|
vec3 reliefN = cross(Tu / lenTu + Nw * su, Tv / lenTv + Nw * sv);
|
|
4183
4183
|
float rl = length(reliefN);
|
|
4184
4184
|
if (rl > 1e-12) {
|
|
@@ -4195,7 +4195,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
|
|
|
4195
4195
|
// Gate on the GEOMETRIC normal: the relief normal can tilt sunward
|
|
4196
4196
|
// past the terminator and light the night side. Fading direct light
|
|
4197
4197
|
// by geometric N·L keeps the night dark regardless.
|
|
4198
|
-
float shadow = smoothstep(${
|
|
4198
|
+
float shadow = smoothstep(${XC.toFixed(3)}, ${YC.toFixed(3)}, gN);
|
|
4199
4199
|
vec3 Tu, Tv;
|
|
4200
4200
|
selfTangents(Tu, Tv);
|
|
4201
4201
|
float lenTu = length(Tu);
|
|
@@ -4207,7 +4207,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
|
|
|
4207
4207
|
float lv = dot(L, Tv / lenTv);
|
|
4208
4208
|
float lh = sqrt(lu * lu + lv * lv);
|
|
4209
4209
|
if (lh > 1e-4) {
|
|
4210
|
-
float ds = ${
|
|
4210
|
+
float ds = ${qC.toFixed(3)} * uSelfScale / float(SELF_STEPS);
|
|
4211
4211
|
// World step → uv step via the per-axis metric (|Tu|, |Tv|).
|
|
4212
4212
|
vec2 stepUv = ds * vec2((lu / lh) / lenTu, (lv / lh) / lenTv);
|
|
4213
4213
|
float h0 = selfHeight(vSelfUv);
|
|
@@ -4220,13 +4220,13 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
|
|
|
4220
4220
|
}
|
|
4221
4221
|
// Fade the march out at grazing angles: a near-horizontal ray
|
|
4222
4222
|
// occludes every away-facing slope, banding the terminator.
|
|
4223
|
-
float marchFade = smoothstep(0.0, ${
|
|
4224
|
-
shadow *= 1.0 - marchFade * clamp(block / (${
|
|
4223
|
+
float marchFade = smoothstep(0.0, ${ZC.toFixed(3)}, gN);
|
|
4224
|
+
shadow *= 1.0 - marchFade * clamp(block / (${JC.toFixed(3)} * uSelfScale), 0.0, 1.0);
|
|
4225
4225
|
}
|
|
4226
4226
|
}
|
|
4227
4227
|
reflectedLight.directDiffuse *= shadow;
|
|
4228
4228
|
reflectedLight.directSpecular *= shadow;
|
|
4229
|
-
}`)}),s}function
|
|
4229
|
+
}`)}),s}function $C(e){e&&(e.uSelfHeightMap.value=null,e.uSelfScale.value=0)}async function ew(e,t,n,r,i,a=Q(1)){let o=tw(t,n),s;try{s=await new Promise((e,t)=>{r.load(o,e,void 0,t)})}catch(e){return console.warn(`Failed to load displacement map ${o}:`,e),null}return s.colorSpace=``,e.displacementMap=s,e.displacementScale=t.scale_km*a,e.displacementBias=t.bias_km*a-(t.absolute_radius?i:0),e.needsUpdate=!0,s}function tw(e,t){return Yt(`/v1/textures/${e.id}/${t}.webp`,`textures`)}async function nw(e){try{let t=await fetch(e);if(!t.ok)throw Error(`${t.status} ${t.statusText}`);return await createImageBitmap(await t.blob())}catch(t){return console.warn(`Failed to decode displacement map ${e}:`,t),null}}var rw=4e6;async function iw(e,t,n){let r=e.width,i=Math.max(1,Math.floor(rw/r)),a=document.createElement(`canvas`);a.width=r,a.height=Math.min(i,n-t+1);let o=a.getContext(`2d`,{willReadFrequently:!0});if(!o)return null;let s=new Uint8Array(r*(n-t+1));for(let a=t;a<=n;a+=i){let c=Math.min(i,n-a+1);o.drawImage(e,0,a,r,c,0,0,r,c);let l=o.getImageData(0,0,r,c).data,u=(a-t)*r;for(let e=0;e<r*c;e++)s[u+e]=l[e*4];!document.hidden&&a+i<=n&&await new Promise(e=>setTimeout(e))}return s}async function aw(e,t){let n=e.displacementMeta;if(!(!n||!e.mesh||e.displacementLoading||e.displacementTier===t)){e.displacementLoading=!0;try{let r=await nw(tw(n,t));if(!r)return;let i=r.width,a=r.height,o=await iw(r,0,a-1);if(r.close(),!o||!e.mesh||!e.displacementMap)return;let s=new Uint8Array(i);for(let e=0;e<a>>1;e++){let t=o.subarray(e*i,(e+1)*i),n=o.subarray((a-1-e)*i,(a-e)*i);s.set(t),t.set(n),n.set(s)}let c=new Ws(o,i,a,er,In);c.colorSpace=``,c.magFilter=Nn,c.minFilter=Nn,c.generateMipmaps=!1,c.unpackAlignment=1,c.needsUpdate=!0;let l=e.mesh.material,u=l.displacementMap;l.displacementMap=c,e.displacementMap=c,e.displacementTier=t,e.selfShadow&&QC(l,c,Q(n.scale_km)),u&&u!==c&&u.dispose()}finally{e.displacementLoading=!1}}}function ow(e,t,n,r,i){let a=Math.floor(r),o=Math.floor(i),s=r-a,c=i-o,l=e=>(e%t+t)%t,u=e=>e<0?0:e>n-1?n-1:e,d=l(a),f=l(a+1),p=u(o)*t,m=u(o+1)*t,h=e[p+d]*(1-s)+e[p+f]*s,g=e[m+d]*(1-s)+e[m+f]*s;return(h*(1-c)+g*c)/255}function sw(e){e.displacementMap&&(e.displacementMap.dispose(),e.displacementMap=null,e.displacementScale=1,e.displacementBias=0,e.needsUpdate=!0)}function cw(e,t){let n=0,r=e.length-2;for(;n<r;){let i=n+r+1>>1;e[i]<=t?n=i:r=i-1}return n}function lw(e,t){let n=Math.cos(e);return[n*Math.cos(t),Math.sin(e),-n*Math.sin(t)]}function uw(e,t,n,r,i,a,o){let s=(r+n)/r,[c,l,u]=lw(e,t);return[s*i*c,s*o*l,s*a*u]}function dw(e,t,n){if(e.kind===`uniform`){let r=e.segs,i=(Math.PI/2-t)*r/Math.PI,a=Math.min(Math.max(Math.floor(i),0),r-1),o=Math.min(Math.max(i-a,0),1),s=(n-Math.PI)*r/(2*Math.PI),c=Math.floor(s),l=s-c;return{corners:[[a,c],[a,c+1],[a+1,c],[a+1,c+1]].map(([e,t])=>({latRad:Math.PI/2-Math.min(e,r)*Math.PI/r,lonRad:Math.PI+t*2*Math.PI/r})),tx:l,ty:o}}let{thetas:r,phis:i}=e,a=Math.PI/2-t,o=(n-Math.PI)%(2*Math.PI);o<0&&(o+=2*Math.PI);let s=cw(r,a),c=cw(i,o),l=Math.min(Math.max((a-r[s])/(r[s+1]-r[s]),0),1),u=Math.min(Math.max((o-i[c])/(i[c+1]-i[c]),0),1);return{corners:[[s,c],[s,c+1],[s+1,c],[s+1,c+1]].map(([e,t])=>({latRad:Math.PI/2-r[e],lonRad:i[t]+Math.PI})),tx:u,ty:l}}function fw(e,t,n){let[r,i,a,o]=e,s=[0,0,0];for(let e=0;e<3;e++)s[e]=t>=n?r[e]+(i[e]-r[e])*t+(o[e]-i[e])*n:r[e]+(o[e]-a[e])*t+(a[e]-r[e])*n;return s}function pw(e,t,n){let[r,i,a]=t>=n?[e[0],e[1],e[3]]:[e[0],e[2],e[3]],o=[i[0]-r[0],i[1]-r[1],i[2]-r[2]],s=[a[0]-r[0],a[1]-r[1],a[2]-r[2]];return{p0:r,n:[o[1]*s[2]-o[2]*s[1],o[2]*s[0]-o[0]*s[2],o[0]*s[1]-o[1]*s[0]]}}function mw(e,t,n){let{p0:r,n:i}=pw(e,t,n),a=Math.hypot(i[0],i[1],i[2]);if(a<1e-12){let e=Math.hypot(r[0],r[1],r[2]);return[r[0]/e,r[1]/e,r[2]/e]}let o=i[0]*r[0]+i[1]*r[1]+i[2]*r[2]<0?-1/a:1/a;return[i[0]*o,i[1]*o,i[2]*o]}var hw=new Map,gw=new Map,_w=0;function vw(){return _w}var yw=6;function bw(){let e=0;for(let t of hw.values())t!==`failed`&&e++;for(let[t,n]of hw){if(e<=yw)break;n!==`failed`&&(hw.delete(t),e--)}}function xw(e,t){let n=gw.get(e);return n||(n=(async()=>{let n=await nw(tw(t,`low`)),r=n&&await iw(n,0,n.height-1);if(!n||!r)return n?.close(),hw.set(e,`failed`),null;let i={data:r,width:n.width,height:n.height,bottomUp:!1};return n.close(),hw.set(e,i),bw(),_w++,i})(),n.finally(()=>gw.delete(e)),gw.set(e,n),n)}function Sw(e,t){let n=e.displacementMap?.image;if(!n)return null;if(n.data instanceof Uint8Array&&n.width&&n.height)return{data:n.data,width:n.width,height:n.height,bottomUp:!0};let r=hw.get(t);if(r&&r!==`failed`)return hw.delete(t),hw.set(t,r),r;let i=e.displacementMeta;return!r&&i&&xw(t,i),null}function Cw(e,t,n){let r=.5+n/(2*Math.PI),i=.5+t/Math.PI,a=(r-Math.floor(r))*e.width-.5,o=(e.bottomUp?i:1-i)*e.height-.5;return ow(e.data,e.width,e.height,a,o)}async function ww(e,t,n,r,i){let a=(e&&Sw(e,t))??await xw(t,n);if(!a)return null;let o=n.bias_km-(n.absolute_radius?r:0),s=new Float64Array(i.length);for(let e=0;e<i.length;e++)s[e]=Cw(a,i[e].latRad,i[e].lonRad)*n.scale_km+o;return s}var Tw=new Map,Ew=new Set;function Dw(e,t){return Tw.get(e)||(Ew.has(e)||(Ew.add(e),(async()=>{try{let n=(await hx(e,!1)).global;Tw.set(e,n?.radii??{a:t,b:t,c:t})}catch(n){console.warn(`Failed to load radii for ${e}:`,n),Tw.set(e,{a:t,b:t,c:t})}finally{Ew.delete(e),_w++}})()),null)}function Ow(e){let t=e?.terrainWindow;return t?{kind:`window`,thetas:t.thetas,phis:t.phis}:{kind:`uniform`,segs:e?.currentSegments??128}}function kw(e,t,n,r,i){let a=Dw(t,n);if(!a)return null;let o=null,s=0,c=0,l=e?.displacementMeta;if(l&&e?.displacementMap){if(o=Sw(e,t),!o)return null;s=l.scale_km,c=l.bias_km-(l.absolute_radius?n:0)}let{corners:u,tx:d,ty:f}=dw(Ow(e),r,i);return{pts:u.map(e=>{let t=o?Cw(o,e.latRad,e.lonRad)*s+c:0;return uw(e.latRad,e.lonRad,t,n,a.a,a.b,a.c)}),tx:d,ty:f}}function Aw(e,t,n,r,i){let a=kw(e,t,n,r,i);return a?{pointKm:fw(a.pts,a.tx,a.ty),normal:mw(a.pts,a.tx,a.ty)}:null}function jw(e,t,n,r){let i=Dw(t,n);if(!i)return null;let a=kw(e,t,n,Math.atan2(r[1]/i.c,Math.hypot(r[0]/i.a,r[2]/i.b)),Math.atan2(-r[2]/i.b,r[0]/i.a));if(!a)return null;let{p0:o,n:s}=pw(a.pts,a.tx,a.ty),c=r[0]*s[0]+r[1]*s[1]+r[2]*s[2];if(Math.abs(c)<1e-12)return null;let l=(o[0]*s[0]+o[1]*s[1]+o[2]*s[2])/c;return l>0?l:null}var Mw=Math.PI/180;function Nw(e,t){return`feature:${e}:${t}`}function Pw(e,t){return{data:{id:Nw(e.hostId,e.featureId),name:t,objectType:W.SURFACE_FEATURE,parentId:e.hostId,radiusKm:NaN,hasLocalized:!1,a:0,e:0,i:0,om:0,w:0,ma:0,n:0,epoch:0,validityStart:-1/0,validityEnd:1/0,orbitalSource:U.UNKNOWN},position:[0,0,0],orbitCenter:[0,0,0],featureAnchor:e}}var Fw=120,Iw=Q(.001)**2,Lw=new WeakMap,Rw=new J,zw=new J;function Bw(e,t,n){e.distanceToSquared(t)<=Iw?e.copy(t):e.lerp(t,n)}function Vw(e,t,n,r){let i=e.featureAnchor,a=t.position;e.orbitCenter&&(e.orbitCenter[0]=a[0],e.orbitCenter[1]=a[1],e.orbitCenter[2]=a[2]),zw.set(0,0,0);let o=n?.nomenclatureActiveIndex??-1,s=o>=0?n?.nomenclatureLabels?.[o]??null:null;if(s&&s.element.dataset.featureId===String(i.featureId)){let e=n?.nomenclatureAnchor;e?(Rw.copy(s.position),zw.copy(e.position)):(Rw.copy(s.position),n?.mesh&&Rw.multiply(n.mesh.scale))}else{let e=t.data.radiusKm,r=i.lat*Mw,a=i.lon*Mw,o=t.orientation&&Number.isFinite(e)&&e>0?Aw(n,t.data.id,e,r,a):null;if(o)Rw.set(o.pointKm[0],o.pointKm[1],o.pointKm[2]);else{let t=Number.isFinite(e)&&e>0?e:0,[n,i,o]=lw(r,a);Rw.set(t*n,t*i,t*o)}Rw.multiplyScalar(Q(1))}let c=performance.now(),l=Lw.get(e);if(!l)l={fixed:Rw.clone(),addend:zw.clone(),t:c},Lw.set(e,l);else{let e=1-Math.exp(-(c-l.t)/Fw);l.t=c,Bw(l.fixed,Rw,e),Bw(l.addend,zw,e)}Rw.copy(l.fixed),t.orientation&&Rw.applyQuaternion(mC(t.orientation,r,t.nutPrec)),e.position[0]=a[0]+Rw.x+l.addend.x,e.position[1]=a[1]+Rw.y+l.addend.y,e.position[2]=a[2]+Rw.z+l.addend.z}var Hw={name:`CopyShader`,uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
|
4230
4230
|
|
|
4231
4231
|
varying vec2 vUv;
|
|
4232
4232
|
|
|
@@ -4249,7 +4249,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
|
|
|
4249
4249
|
gl_FragColor = opacity * texel;
|
|
4250
4250
|
|
|
4251
4251
|
|
|
4252
|
-
}`},
|
|
4252
|
+
}`},Uw=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error(`THREE.Pass: .render() must be implemented in derived pass.`)}dispose(){}},Ww=new fd(-1,1,1,-1,0,1),Gw=new class extends Ho{constructor(){super(),this.setAttribute(`position`,new Ao([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new Ao([0,2,0,0,2,0],2))}},Kw=class{constructor(e){this._mesh=new As(Gw,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Ww)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},qw=class extends Uw{constructor(e,t=`tDiffuse`){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof fu?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=lu.clone(e.uniforms),this.material=new fu({name:e.name===void 0?`unspecified`:e.name,defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new Kw(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}},Jw=class extends Uw{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){let r=e.getContext(),i=e.state;i.buffers.color.setMask(!1),i.buffers.depth.setMask(!1),i.buffers.color.setLocked(!0),i.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),i.buffers.stencil.setTest(!0),i.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),i.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),i.buffers.stencil.setClear(o),i.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),i.buffers.color.setLocked(!1),i.buffers.depth.setLocked(!1),i.buffers.color.setMask(!0),i.buffers.depth.setMask(!0),i.buffers.stencil.setLocked(!1),i.buffers.stencil.setFunc(r.EQUAL,1,4294967295),i.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),i.buffers.stencil.setLocked(!0)}},Yw=class extends Uw{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}},Xw=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){let n=e.getSize(new q);this._width=n.width,this._height=n.height,t=new la(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Un}),t.texture.name=`EffectComposer.rt1`}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name=`EffectComposer.rt2`,this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new qw(Hw),this.copyPass.material.blending=0,this.timer=new Cd}swapBuffers(){let e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){let t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){this.timer.update(),e===void 0&&(e=this.timer.getDelta());let t=this.renderer.getRenderTarget(),n=!1;for(let t=0,r=this.passes.length;t<r;t++){let r=this.passes[t];if(r.enabled!==!1){if(r.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(t),r.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),r.needsSwap){if(n){let t=this.renderer.getContext(),n=this.renderer.state.buffers.stencil;n.setFunc(t.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),n.setFunc(t.EQUAL,1,4294967295)}this.swapBuffers()}Jw!==void 0&&(r instanceof Jw?n=!0:r instanceof Yw&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){let t=this.renderer.getSize(new q);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget1.setSize(n,r),this.renderTarget2.setSize(n,r);for(let e=0;e<this.passes.length;e++)this.passes[e].setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}},Zw=class extends Uw{constructor(e,t,n=null,r=null,i=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=i,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new X}render(e,t,n){let r=e.autoClear;e.autoClear=!1;let i,a;this.overrideMaterial!==null&&(a=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(i=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==1&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(i),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),e.autoClear=r}},Qw={name:`LuminosityHighPassShader`,uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new X(0)},defaultOpacity:{value:0}},vertexShader:`
|
|
4253
4253
|
|
|
4254
4254
|
varying vec2 vUv;
|
|
4255
4255
|
|
|
@@ -4281,7 +4281,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
|
|
|
4281
4281
|
|
|
4282
4282
|
gl_FragColor = mix( outputColor, texel, alpha );
|
|
4283
4283
|
|
|
4284
|
-
}`}
|
|
4284
|
+
}`},$w=class e extends Uw{constructor(e,t=1,n,r){super(),this.strength=t,this.radius=n,this.threshold=r,this.resolution=e===void 0?new q(256,256):new q(e.x,e.y),this.clearColor=new X(0,0,0),this.needsSwap=!1,this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let i=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);this.renderTargetBright=new la(i,a,{type:Un}),this.renderTargetBright.texture.name=`UnrealBloomPass.bright`,this.renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e<this.nMips;e++){let t=new la(i,a,{type:Un});t.texture.name=`UnrealBloomPass.h`+e,t.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(t);let n=new la(i,a,{type:Un});n.texture.name=`UnrealBloomPass.v`+e,n.texture.generateMipmaps=!1,this.renderTargetsVertical.push(n),i=Math.round(i/2),a=Math.round(a/2)}let o=Qw;this.highPassUniforms=lu.clone(o.uniforms),this.highPassUniforms.luminosityThreshold.value=r,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new fu({uniforms:this.highPassUniforms,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader}),this.separableBlurMaterials=[];let s=[6,10,14,18,22];i=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);for(let e=0;e<this.nMips;e++)this.separableBlurMaterials.push(this._getSeparableBlurMaterial(s[e])),this.separableBlurMaterials[e].uniforms.invSize.value=new q(1/i,1/a),i=Math.round(i/2),a=Math.round(a/2);this.compositeMaterial=this._getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=t,this.compositeMaterial.uniforms.bloomRadius.value=.1;let c=[1,.8,.6,.4,.2];this.compositeMaterial.uniforms.bloomFactors.value=c,this.bloomTintColors=[new J(1,1,1),new J(1,1,1),new J(1,1,1),new J(1,1,1),new J(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,this.copyUniforms=lu.clone(Hw.uniforms),this.blendMaterial=new fu({uniforms:this.copyUniforms,vertexShader:Hw.vertexShader,fragmentShader:Hw.fragmentShader,premultipliedAlpha:!0,blending:2,depthTest:!1,depthWrite:!1,transparent:!0}),this._oldClearColor=new X,this._oldClearAlpha=1,this._basic=new vs,this._fsQuad=new Kw(null)}dispose(){for(let e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose();for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.compositeMaterial.dispose(),this.blendMaterial.dispose(),this._basic.dispose(),this._fsQuad.dispose()}setSize(e,t){let n=Math.round(e/2),r=Math.round(t/2);this.renderTargetBright.setSize(n,r);for(let e=0;e<this.nMips;e++)this.renderTargetsHorizontal[e].setSize(n,r),this.renderTargetsVertical[e].setSize(n,r),this.separableBlurMaterials[e].uniforms.invSize.value=new q(1/n,1/r),n=Math.round(n/2),r=Math.round(r/2)}render(t,n,r,i,a){t.getClearColor(this._oldClearColor),this._oldClearAlpha=t.getClearAlpha();let o=t.autoClear;t.autoClear=!1,t.setClearColor(this.clearColor,0),a&&t.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this._fsQuad.material=this._basic,this._basic.map=r.texture,t.setRenderTarget(null),t.clear(),this._fsQuad.render(t)),this.highPassUniforms.tDiffuse.value=r.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this._fsQuad.material=this.materialHighPassFilter,t.setRenderTarget(this.renderTargetBright),t.clear(),this._fsQuad.render(t);let s=this.renderTargetBright;for(let n=0;n<this.nMips;n++)this._fsQuad.material=this.separableBlurMaterials[n],this.separableBlurMaterials[n].uniforms.colorTexture.value=s.texture,this.separableBlurMaterials[n].uniforms.direction.value=e.BlurDirectionX,t.setRenderTarget(this.renderTargetsHorizontal[n]),t.clear(),this._fsQuad.render(t),this.separableBlurMaterials[n].uniforms.colorTexture.value=this.renderTargetsHorizontal[n].texture,this.separableBlurMaterials[n].uniforms.direction.value=e.BlurDirectionY,t.setRenderTarget(this.renderTargetsVertical[n]),t.clear(),this._fsQuad.render(t),s=this.renderTargetsVertical[n];this._fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,t.setRenderTarget(this.renderTargetsHorizontal[0]),t.clear(),this._fsQuad.render(t),this._fsQuad.material=this.blendMaterial,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,a&&t.state.buffers.stencil.setTest(!0),this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(r),this._fsQuad.render(t)),t.setClearColor(this._oldClearColor,this._oldClearAlpha),t.autoClear=o}_getSeparableBlurMaterial(e){let t=[],n=e/3;for(let r=0;r<e;r++)t.push(.39894*Math.exp(-.5*r*r/(n*n))/n);return new fu({defines:{KERNEL_RADIUS:e},uniforms:{colorTexture:{value:null},invSize:{value:new q(.5,.5)},direction:{value:new q(.5,.5)},gaussianCoefficients:{value:t}},vertexShader:`
|
|
4285
4285
|
|
|
4286
4286
|
varying vec2 vUv;
|
|
4287
4287
|
|
|
@@ -4363,7 +4363,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
|
|
|
4363
4363
|
float bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) );
|
|
4364
4364
|
gl_FragColor = vec4( bloom, bloomAlpha );
|
|
4365
4365
|
|
|
4366
|
-
}`})}}
|
|
4366
|
+
}`})}};$w.BlurDirectionX=new q(1,0),$w.BlurDirectionY=new q(0,1);var eT={name:`OutputShader`,uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
|
|
4367
4367
|
precision highp float;
|
|
4368
4368
|
|
|
4369
4369
|
uniform mat4 modelViewMatrix;
|
|
@@ -4434,7 +4434,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
|
|
|
4434
4434
|
|
|
4435
4435
|
#endif
|
|
4436
4436
|
|
|
4437
|
-
}`}
|
|
4437
|
+
}`},tT=class extends Uw{constructor(){super(),this.isOutputPass=!0,this.uniforms=lu.clone(eT.uniforms),this.material=new pu({name:eT.name,uniforms:this.uniforms,vertexShader:eT.vertexShader,fragmentShader:eT.fragmentShader}),this._fsQuad=new Kw(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},Xi.getTransfer(this._outputColorSpace)===`srgb`&&(this.material.defines.SRGB_TRANSFER=``),this._toneMapping===1?this.material.defines.LINEAR_TONE_MAPPING=``:this._toneMapping===2?this.material.defines.REINHARD_TONE_MAPPING=``:this._toneMapping===3?this.material.defines.CINEON_TONE_MAPPING=``:this._toneMapping===4?this.material.defines.ACES_FILMIC_TONE_MAPPING=``:this._toneMapping===6?this.material.defines.AGX_TONE_MAPPING=``:this._toneMapping===7?this.material.defines.NEUTRAL_TONE_MAPPING=``:this._toneMapping===5&&(this.material.defines.CUSTOM_TONE_MAPPING=``),this.material.needsUpdate=!0),this.renderToScreen===!0?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}},nT=!1;function rT(e){nT=e}function iT(){return nT}function aT(e){return nT?e>=0&&e<=1:e>=-1&&e<=1}function oT(e){return e.isCSS2DObject===!0}var sT=NaN,cT=class{domElement;sortObjects=!0;_w=0;_h=0;_wHalf=0;_hHalf=0;_viewMatrix=new Y;_viewProjectionMatrix=new Y;_vector=new J;_a=new J;_b=new J;_cache=new WeakMap;_visibleBuf=[];_visibleCount=0;constructor(e={}){this.domElement=e.element??document.createElement(`div`),this.domElement.style.overflow=`hidden`}getSize(){return{width:this._w,height:this._h}}setSize(e,t){this._w=e,this._h=t,this._wHalf=e/2,this._hHalf=t/2,this.domElement.style.width=e+`px`,this.domElement.style.height=t+`px`}render(e,t){e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),this._viewMatrix.copy(t.matrixWorldInverse),this._viewProjectionMatrix.multiplyMatrices(t.projectionMatrix,this._viewMatrix),this._visibleCount=0,this.renderObject(e,t),this.sortObjects&&this.zOrder();for(let e=this._visibleCount;e<this._visibleBuf.length;e++)this._visibleBuf[e]=void 0;this._visibleBuf.length=this._visibleCount}renderObject(e,t){if(e.visible===!1){e.userData.css2dHidden!==!0&&(this.hideObject(e),e.userData.css2dHidden=!0);return}if(e.userData.css2dHidden===!0&&(e.userData.css2dHidden=!1),oT(e)){let n=e.element;this._vector.setFromMatrixPosition(e.matrixWorld),this._vector.applyMatrix4(this._viewProjectionMatrix);let r=this._vector.z,i=aT(r),a=e.layers.test(t.layers),o=i&&a,s=this.cacheFor(n),c=o?``:`none`;if(s.display!==c&&(n.style.display=c,s.display=c),o){let r=Math.round((this._vector.x*this._wHalf+this._wHalf)*2)/2,i=Math.round((-this._vector.y*this._hHalf+this._hHalf)*2)/2,a=e.center.x,o=e.center.y;(s.tx!==r||s.ty!==i||s.cx!==a||s.cy!==o)&&(n.style.transform=`translate(`+-100*a+`%,`+-100*o+`%) translate(`+r+`px,`+i+`px)`,s.tx=r,s.ty=i,s.cx=a,s.cy=o),n.parentNode!==this.domElement&&this.domElement.appendChild(n),s.dist2=this.distanceToCameraSquared(t,e),this._visibleBuf[this._visibleCount++]=e}}let n=e.children;for(let e=0;e<n.length;e++)this.renderObject(n[e],t)}cacheFor(e){let t=this._cache.get(e);return t||(t={tx:sT,ty:sT,cx:sT,cy:sT,display:`__init__`,zIndex:sT,dist2:0},this._cache.set(e,t)),t}hideObject(e){if(oT(e)){let t=e.element,n=this.cacheFor(t);n.display!==`none`&&(t.style.display=`none`,n.display=`none`)}let t=e.children;for(let e=0;e<t.length;e++)this.hideObject(t[e])}distanceToCameraSquared(e,t){return this._a.setFromMatrixPosition(e.matrixWorld),this._b.setFromMatrixPosition(t.matrixWorld),this._a.distanceToSquared(this._b)}zOrder(){let e=this._visibleBuf,t=this._visibleCount;if(t===0)return;e.sort((e,t)=>e.renderOrder===t.renderOrder?this._cache.get(e.element).dist2-this._cache.get(t.element).dist2:t.renderOrder-e.renderOrder);let n=t;for(let r=0;r<t;r++){let t=e[r],i=n-r,a=this._cache.get(t.element);a.zIndex!==i&&(t.element.style.zIndex=String(i),a.zIndex=i)}}},lT=.5;function uT(e,t){return new X(e).multiplyScalar(t)}var dT=new q(1,1);function fT(e,t){dT.set(e,t)}function pT(e,t=lT){return new fu({transparent:!0,depthWrite:!1,uniforms:{uColor:{value:uT(e,t)},uCenterOffset:{value:new J},uAlphaMultiplier:{value:1},uAlphaMin:{value:0},uShowFull:{value:0}},vertexShader:`
|
|
4438
4438
|
#include <common>
|
|
4439
4439
|
#include <logdepthbuf_pars_vertex>
|
|
4440
4440
|
uniform vec3 uCenterOffset;
|
|
@@ -4458,7 +4458,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
|
|
|
4458
4458
|
gl_FragColor = vec4(uColor, clamp(max(vAlpha * uAlphaMultiplier, uAlphaMin), 0.0, 1.0));
|
|
4459
4459
|
#include <logdepthbuf_fragment>
|
|
4460
4460
|
}
|
|
4461
|
-
`})}function
|
|
4461
|
+
`})}function mT(e,t,n=lT){return new fu({transparent:!0,depthWrite:!1,side:2,uniforms:{uColor:{value:uT(e,n)},uCenterOffset:{value:new J},uAlphaMultiplier:{value:1},uAlphaMin:{value:0},uShowFull:{value:0},uLineWidth:{value:t},uResolution:{value:dT}},vertexShader:`
|
|
4462
4462
|
#include <common>
|
|
4463
4463
|
#include <logdepthbuf_pars_vertex>
|
|
4464
4464
|
uniform vec3 uCenterOffset;
|
|
@@ -4498,7 +4498,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
|
|
|
4498
4498
|
gl_FragColor = vec4(uColor, clamp(max(vAlpha * uAlphaMultiplier, uAlphaMin), 0.0, 1.0));
|
|
4499
4499
|
#include <logdepthbuf_fragment>
|
|
4500
4500
|
}
|
|
4501
|
-
`})}var pT=class extends qa{constructor(){super(),this.name=`RoomEnvironment`,this.position.y=-3.5;let e=new Lc;e.deleteAttribute(`uv`);let t=new mu({side:1}),n=new mu,r=new dd(16777215,900,28,2);r.position.set(.418,16.199,.3),this.add(r);let i=new As(e,t);i.position.set(-.757,13.219,.717),i.scale.set(31.713,28.305,28.591),this.add(i);let a=new nc(e,n,6),o=new Ra;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),a.setMatrixAt(0,o.matrix),o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),a.setMatrixAt(1,o.matrix),o.position.set(6.167,.857,7.803),o.rotation.set(0,.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),a.setMatrixAt(2,o.matrix),o.position.set(-2.017,.018,6.124),o.rotation.set(0,.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),a.setMatrixAt(3,o.matrix),o.position.set(2.291,-.756,-2.621),o.rotation.set(0,-.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),a.setMatrixAt(4,o.matrix),o.position.set(-2.193,-.369,-5.547),o.rotation.set(0,.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),a.setMatrixAt(5,o.matrix),this.add(a);let s=new As(e,mT(50));s.position.set(-16.116,14.37,8.208),s.scale.set(.1,2.428,2.739),this.add(s);let c=new As(e,mT(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(.1,2.425,2.751),this.add(c);let l=new As(e,mT(17));l.position.set(14.904,12.198,-1.832),l.scale.set(.15,4.265,6.331),this.add(l);let u=new As(e,mT(43));u.position.set(-.462,8.89,14.52),u.scale.set(4.38,5.441,.088),this.add(u);let d=new As(e,mT(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,.1),this.add(d);let f=new As(e,mT(100));f.position.set(0,20,0),f.scale.set(1,.1,1),this.add(f)}dispose(){let e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(let t of e)t.dispose()}};function mT(e){return new gu({color:0,emissive:16777215,emissiveIntensity:e})}var hT=.01,gT=3.5,_T=.04;function vT(e){let t=Math.max(e/10,.01);return 1/(t*t)}function yT(e,t,n=1){e.decay=t?2:0,e.intensity=(t?gT*10*10:gT)*n}function bT(e){let t=new yf(e),n=t.fromScene(new pT).texture;return t.dispose(),n}var xT=1e5;function ST(){try{return!!document.createElement(`canvas`).getContext(`webgl2`)?.getExtension(`EXT_clip_control`)}catch{return!1}}var CT=class extends Error{constructor(e){super(`WebGL is unavailable on this device.`,{cause:e}),this.name=`WebGLUnavailableError`}};function wT(e,t,n){let r,i=ST();try{r=new dh(i?{canvas:e,reversedDepthBuffer:!0,antialias:!0}:{canvas:e,logarithmicDepthBuffer:!0,antialias:!0})}catch(e){throw new CT(e)}i&&!r.capabilities.reversedDepthBuffer&&console.warn(`EXT_clip_control probe mismatch: reversed depth unavailable on main context`),tT(r.capabilities.reversedDepthBuffer);let a=Jx();r.setPixelRatio(Yx()),r.setSize(e.clientWidth,e.clientHeight,!1),r.shadowMap.enabled=!0,r.shadowMap.type=a.softShadows?2:1,r.toneMapping=4,r.toneMappingExposure=1,uT(e.clientWidth,e.clientHeight);let o=new oT({element:t});o.setSize(e.clientWidth,e.clientHeight),n.visibility.updateViewport(e.clientHeight);let s=new qa,c=new hd(16777215,hT);s.add(c);let l=new md(16777215,0);l.castShadow=!1,l.shadow.mapSize.set(a.shadowMapSize,a.shadowMapSize),l.shadow.bias=-1e-4,s.add(l),s.add(l.target);let u=new sd(60,e.clientWidth/e.clientHeight,Q(.001),xT),d=r.capabilities.reversedDepthBuffer?new la(e.clientWidth,e.clientHeight,{type:Un,depthTexture:new Pc(e.clientWidth,e.clientHeight,Hn)}):void 0,f=new Jw(r,d);f.setPixelRatio(Yx()),f.setSize(e.clientWidth,e.clientHeight),f.addPass(new Yw(s,u));let p=new Zw(new q(e.clientWidth*a.bloomScale,e.clientHeight*a.bloomScale),.3,.5,1);return f.addPass(p),f.addPass(new $w),{renderer:r,labelRenderer:o,scene:s,camera:u,composer:f,bloomPass:p,ambientLight:c,shadowLight:l}}function TT(e,t,n){let r=e.data,i=r.q!=null,a;if(r.parentId===`naif-0`)a=[0,0,0];else{let t=n.getBody(r.parentId)?.position;if(!t){e.positionUnknown=!0;return}a=t}if(t<r.validityStart||t>r.validityEnd){e.positionUnknown=!0;return}let o=r.a===0&&!i&&!r.satrec?[0,0,0]:r.satrec?bg(r.satrec,t):i?Xv(r,t):Jv(r,t);if(!o){e.positionUnknown=!0;return}e.position[0]=a[0]+o[0],e.position[1]=a[1]+o[1],e.position[2]=a[2]+o[2],e.orbitCenter&&(e.orbitCenter[0]=a[0],e.orbitCenter[1]=a[1],e.orbitCenter[2]=a[2]),e.positionUnknown=!1}function ET(e,t){if(t===0)return console.warn(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.`),e;if(t===2||t===1){let n=e.getIndex();if(n===null){let t=[],r=e.getAttribute(`position`);if(r!==void 0){for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}else return console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.`),e}let r=n.count-2,i=[];if(t===2)for(let e=1;e<=r;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==r&&console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.`);let a=e.clone();return a.setIndex(i),a.clearGroups(),a}else return console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:`,t),e}function DT(e){let t=new Map,n=new Map,r=e.clone();return OT(e,r,function(e,r){t.set(r,e),n.set(e,r)}),r.traverse(function(e){if(!e.isSkinnedMesh)return;let r=e,i=t.get(e),a=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=a.map(function(e){return n.get(e)}),r.bind(r.skeleton,r.bindMatrix)}),r}function OT(e,t,n){n(e,t);for(let r=0;r<e.children.length;r++)OT(e.children[r],t.children[r],n)}var kT=class extends Hu{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new IT(e)}),this.register(function(e){return new LT(e)}),this.register(function(e){return new KT(e)}),this.register(function(e){return new qT(e)}),this.register(function(e){return new JT(e)}),this.register(function(e){return new zT(e)}),this.register(function(e){return new BT(e)}),this.register(function(e){return new VT(e)}),this.register(function(e){return new HT(e)}),this.register(function(e){return new FT(e)}),this.register(function(e){return new UT(e)}),this.register(function(e){return new RT(e)}),this.register(function(e){return new GT(e)}),this.register(function(e){return new WT(e)}),this.register(function(e){return new NT(e)}),this.register(function(e){return new YT(e,MT.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new YT(e,MT.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new XT(e)})}load(e,t,n,r){let i=this,a;if(this.resourcePath!==``)a=this.resourcePath;else if(this.path!==``){let t=gd.extractUrlBase(e);a=gd.resolveURL(t,this.path)}else a=gd.extractUrlBase(e);this.manager.itemStart(e);let o=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},s=new Gu(this.manager);s.setPath(this.path),s.setResponseType(`arraybuffer`),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(n){try{i.parse(n,a,function(n){t(n),i.manager.itemEnd(e)},o)}catch(e){o(e)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i,a={},o={},s=new TextDecoder;if(typeof e==`string`)i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(s.decode(new Uint8Array(e,0,4))===ZT){try{a[MT.KHR_BINARY_GLTF]=new eE(e)}catch(e){r&&r(e);return}i=JSON.parse(a[MT.KHR_BINARY_GLTF].content)}else i=JSON.parse(s.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){r&&r(Error(`THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.`));return}let c=new EE(i,{path:t||this.resourcePath||``,crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){let t=this.pluginCallbacks[e](c);t.name||console.error(`THREE.GLTFLoader: Invalid plugin found: missing name`),o[t.name]=t,a[t.name]=!0}if(i.extensionsUsed)for(let e=0;e<i.extensionsUsed.length;++e){let t=i.extensionsUsed[e],n=i.extensionsRequired||[];switch(t){case MT.KHR_MATERIALS_UNLIT:a[t]=new PT;break;case MT.KHR_DRACO_MESH_COMPRESSION:a[t]=new tE(i,this.dracoLoader);break;case MT.KHR_TEXTURE_TRANSFORM:a[t]=new nE;break;case MT.KHR_MESH_QUANTIZATION:a[t]=new rE;break;default:n.indexOf(t)>=0&&o[t]===void 0&&console.warn(`THREE.GLTFLoader: Unknown extension "`+t+`".`)}}c.setExtensions(a),c.setPlugins(o),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}};function AT(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function jT(e,t,n){let r=e.json.materials[t];return r.extensions&&r.extensions[n]?r.extensions[n]:null}var MT={KHR_BINARY_GLTF:`KHR_binary_glTF`,KHR_DRACO_MESH_COMPRESSION:`KHR_draco_mesh_compression`,KHR_LIGHTS_PUNCTUAL:`KHR_lights_punctual`,KHR_MATERIALS_CLEARCOAT:`KHR_materials_clearcoat`,KHR_MATERIALS_DISPERSION:`KHR_materials_dispersion`,KHR_MATERIALS_IOR:`KHR_materials_ior`,KHR_MATERIALS_SHEEN:`KHR_materials_sheen`,KHR_MATERIALS_SPECULAR:`KHR_materials_specular`,KHR_MATERIALS_TRANSMISSION:`KHR_materials_transmission`,KHR_MATERIALS_IRIDESCENCE:`KHR_materials_iridescence`,KHR_MATERIALS_ANISOTROPY:`KHR_materials_anisotropy`,KHR_MATERIALS_UNLIT:`KHR_materials_unlit`,KHR_MATERIALS_VOLUME:`KHR_materials_volume`,KHR_TEXTURE_BASISU:`KHR_texture_basisu`,KHR_TEXTURE_TRANSFORM:`KHR_texture_transform`,KHR_MESH_QUANTIZATION:`KHR_mesh_quantization`,KHR_MATERIALS_EMISSIVE_STRENGTH:`KHR_materials_emissive_strength`,EXT_MATERIALS_BUMP:`EXT_materials_bump`,EXT_TEXTURE_WEBP:`EXT_texture_webp`,EXT_TEXTURE_AVIF:`EXT_texture_avif`,EXT_MESHOPT_COMPRESSION:`EXT_meshopt_compression`,KHR_MESHOPT_COMPRESSION:`KHR_meshopt_compression`,EXT_MESH_GPU_INSTANCING:`EXT_mesh_gpu_instancing`},NT=class{constructor(e){this.parser=e,this.name=MT.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n=`light:`+e,r=t.cache.get(n);if(r)return r;let i=t.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e],o,s=new X(16777215);a.color!==void 0&&s.setRGB(a.color[0],a.color[1],a.color[2],Zr);let c=a.range===void 0?0:a.range;switch(a.type){case`directional`:o=new md(s),o.target.position.set(0,0,-1),o.add(o.target);break;case`point`:o=new dd(s),o.distance=c;break;case`spot`:o=new ld(s),o.distance=c,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle===void 0?0:a.spot.innerConeAngle,a.spot.outerConeAngle=a.spot.outerConeAngle===void 0?Math.PI/4:a.spot.outerConeAngle,o.angle=a.spot.outerConeAngle,o.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw Error(`THREE.GLTFLoader: Unexpected light type: `+a.type)}return o.position.set(0,0,0),vE(o,a),a.intensity!==void 0&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||`light_`+e),r=Promise.resolve(o),t.cache.add(n,r),r}getDependency(e,t){if(e===`light`)return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return i===void 0?null:this._loadLight(i).then(function(e){return n._getNodeRef(t.cache,i,e)})}},PT=class{constructor(){this.name=MT.KHR_MATERIALS_UNLIT}getMaterialType(){return vs}extendParams(e,t,n){let r=[];e.color=new X(1,1,1),e.opacity=1;let i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){let t=i.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],Zr),e.opacity=t[3]}i.baseColorTexture!==void 0&&r.push(n.assignTexture(e,`map`,i.baseColorTexture,Xr))}return Promise.all(r)}},FT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=jT(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},IT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=jT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&r.push(this.parser.assignTexture(t,`clearcoatMap`,n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`clearcoatRoughnessMap`,n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(r.push(this.parser.assignTexture(t,`clearcoatNormalMap`,n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){let e=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new q(e,e)}return Promise.all(r)}},LT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_DISPERSION}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=jT(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion===void 0?0:n.dispersion),Promise.resolve()}},RT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=jT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceMap`,n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceThicknessMap`,n.iridescenceThicknessTexture)),Promise.all(r)}},zT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_SHEEN}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=jT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(t.sheenColor=new X(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let e=n.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],Zr)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenColorMap`,n.sheenColorTexture,Xr)),n.sheenRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenRoughnessMap`,n.sheenRoughnessTexture)),Promise.all(r)}},BT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=jT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&r.push(this.parser.assignTexture(t,`transmissionMap`,n.transmissionTexture)),Promise.all(r)}},VT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_VOLUME}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=jT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.thickness=n.thicknessFactor===void 0?0:n.thicknessFactor,n.thicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`thicknessMap`,n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;let i=n.attenuationColor||[1,1,1];return t.attenuationColor=new X().setRGB(i[0],i[1],i[2],Zr),Promise.all(r)}},HT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_IOR}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=jT(this.parser,e,this.name);return n===null||(t.ior=n.ior===void 0?1.5:n.ior),Promise.resolve()}},UT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_SPECULAR}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=jT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.specularIntensity=n.specularFactor===void 0?1:n.specularFactor,n.specularTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularIntensityMap`,n.specularTexture));let i=n.specularColorFactor||[1,1,1];return t.specularColor=new X().setRGB(i[0],i[1],i[2],Zr),n.specularColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularColorMap`,n.specularColorTexture,Xr)),Promise.all(r)}},WT=class{constructor(e){this.parser=e,this.name=MT.EXT_MATERIALS_BUMP}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=jT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return t.bumpScale=n.bumpFactor===void 0?1:n.bumpFactor,n.bumpTexture!==void 0&&r.push(this.parser.assignTexture(t,`bumpMap`,n.bumpTexture)),Promise.all(r)}},GT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=jT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&r.push(this.parser.assignTexture(t,`anisotropyMap`,n.anisotropyTexture)),Promise.all(r)}},KT=class{constructor(e){this.parser=e,this.name=MT.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let i=r.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures`);return null}return t.loadTextureImage(e,i.source,a)}},qT=class{constructor(e){this.parser=e,this.name=MT.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},JT=class{constructor(e){this.parser=e,this.name=MT.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},YT=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],r=this.parser.getDependency(`buffer`,e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files`);return null}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,a=e.count,o=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,o,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(a*o);return i.decodeGltfBuffer(new Uint8Array(t),a,o,s,e.mode,e.filter),t})})}else return null}},XT=class{constructor(e){this.name=MT.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==sE.TRIANGLES&&e.mode!==sE.TRIANGLE_STRIP&&e.mode!==sE.TRIANGLE_FAN&&e.mode!==void 0)return null;let i=n.extensions[this.name].attributes,a=[],o={};for(let e in i)a.push(this.parser.getDependency(`accessor`,i[e]).then(t=>(o[e]=t,o[e])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new Y,n=new J,a=new Hi,s=new J(1,1,1),c=new nc(e.geometry,e.material,r);for(let e=0;e<r;e++)o.TRANSLATION&&n.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&a.fromBufferAttribute(o.ROTATION,e),o.SCALE&&s.fromBufferAttribute(o.SCALE,e),c.setMatrixAt(e,t.compose(n,a,s));for(let t in o)if(t===`_COLOR_0`){let e=o[t];c.instanceColor=new Js(e.array,e.itemSize,e.normalized)}else t!==`TRANSLATION`&&t!==`ROTATION`&&t!==`SCALE`&&e.geometry.setAttribute(t,o[t]);Ra.prototype.copy.call(c,e),this.parser.assignFinalMaterial(c),i.push(c)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}},ZT=`glTF`,QT=12,$T={JSON:1313821514,BIN:5130562},eE=class{constructor(e){this.name=MT.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,QT),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==ZT)throw Error(`THREE.GLTFLoader: Unsupported glTF-Binary header.`);if(this.header.version<2)throw Error(`THREE.GLTFLoader: Legacy binary file detected.`);let r=this.header.length-QT,i=new DataView(e,QT),a=0;for(;a<r;){let t=i.getUint32(a,!0);a+=4;let r=i.getUint32(a,!0);if(a+=4,r===$T.JSON){let r=new Uint8Array(e,QT+a,t);this.content=n.decode(r)}else if(r===$T.BIN){let n=QT+a;this.body=e.slice(n,n+t)}a+=t}if(this.content===null)throw Error(`THREE.GLTFLoader: JSON content not found.`)}},tE=class{constructor(e,t){if(!t)throw Error(`THREE.GLTFLoader: No DRACOLoader instance provided.`);this.name=MT.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},s={},c={};for(let e in a){let t=fE[e]||e.toLowerCase();o[t]=a[e]}for(let t in e.attributes){let r=fE[t]||t.toLowerCase();if(a[t]!==void 0){let i=n.accessors[e.attributes[t]];c[r]=cE[i.componentType].name,s[r]=i.normalized===!0}}return t.getDependency(`bufferView`,i).then(function(e){return new Promise(function(t,n){r.decodeDracoFile(e,function(e){for(let t in e.attributes){let n=e.attributes[t],r=s[t];r!==void 0&&(n.normalized=r)}t(e)},o,c,Zr,n)})})}},nE=class{constructor(){this.name=MT.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0?e:(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e)}},rE=class{constructor(){this.name=MT.KHR_MESH_QUANTIZATION}},iE=class extends Cu{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[i+e];return t}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=o*2,c=o*3,l=r-t,u=(n-t)/l,d=u*u,f=d*u,p=e*c,m=p-c,h=-2*f+3*d,g=f-d,_=1-h,v=g-d+u;for(let e=0;e!==o;e++){let t=a[m+e+o],n=a[m+e+s]*l,r=a[p+e+o],c=a[p+e]*l;i[e]=_*t+v*n+h*r+g*c}return i}},aE=new Hi,oE=class extends iE{interpolate_(e,t,n,r){let i=super.interpolate_(e,t,n,r);return aE.fromArray(i).normalize().toArray(i),i}},sE={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},cE={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},lE={9728:An,9729:Nn,9984:jn,9985:Pn,9986:Mn,9987:Fn},uE={33071:On,33648:kn,10497:Dn},dE={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},fE={POSITION:`position`,NORMAL:`normal`,TANGENT:`tangent`,TEXCOORD_0:`uv`,TEXCOORD_1:`uv1`,TEXCOORD_2:`uv2`,TEXCOORD_3:`uv3`,COLOR_0:`color`,WEIGHTS_0:`skinWeight`,JOINTS_0:`skinIndex`},pE={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`},mE={CUBICSPLINE:void 0,LINEAR:Hr,STEP:Vr},hE={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`};function gE(e){return e.DefaultMaterial===void 0&&(e.DefaultMaterial=new mu({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function _E(e,t,n){for(let r in n.extensions)e[r]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function vE(e,t){t.extras!==void 0&&(typeof t.extras==`object`?Object.assign(e.userData,t.extras):console.warn(`THREE.GLTFLoader: Ignoring primitive type .extras, `+t.extras))}function yE(e,t,n){let r=!1,i=!1,a=!1;for(let e=0,n=t.length;e<n;e++){let n=t[e];if(n.POSITION!==void 0&&(r=!0),n.NORMAL!==void 0&&(i=!0),n.COLOR_0!==void 0&&(a=!0),r&&i&&a)break}if(!r&&!i&&!a)return Promise.resolve(e);let o=[],s=[],c=[];for(let l=0,u=t.length;l<u;l++){let u=t[l];if(r){let t=u.POSITION===void 0?e.attributes.position:n.getDependency(`accessor`,u.POSITION);o.push(t)}if(i){let t=u.NORMAL===void 0?e.attributes.normal:n.getDependency(`accessor`,u.NORMAL);s.push(t)}if(a){let t=u.COLOR_0===void 0?e.attributes.color:n.getDependency(`accessor`,u.COLOR_0);c.push(t)}}return Promise.all([Promise.all(o),Promise.all(s),Promise.all(c)]).then(function(t){let n=t[0],o=t[1],s=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=o),a&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e})}function bE(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn(`THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.`)}}function xE(e){let t,n=e.extensions&&e.extensions[MT.KHR_DRACO_MESH_COMPRESSION];if(t=n?`draco:`+n.bufferView+`:`+n.indices+`:`+SE(n.attributes):e.indices+`:`+SE(e.attributes)+`:`+e.mode,e.targets!==void 0)for(let n=0,r=e.targets.length;n<r;n++)t+=`:`+SE(e.targets[n]);return t}function SE(e){let t=``,n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+`:`+e[n[r]]+`;`;return t}function CE(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw Error(`THREE.GLTFLoader: Unsupported normalized accessor component type.`)}}function wE(e){return e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0?`image/jpeg`:e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?`image/webp`:e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0?`image/ktx2`:`image/png`}var TE=new Y,EE=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new AT,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,i=!1,a=-1;if(typeof navigator<`u`&&navigator.userAgent!==void 0){let e=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(e)===!0;let t=e.match(/Version\/(\d+)/);r=n&&t?parseInt(t[1],10):-1,i=e.indexOf(`Firefox`)>-1,a=i?e.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>`u`||n&&r<17||i&&a<98?this.textureLoader=new Ju(this.options.manager):this.textureLoader=new vd(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Gu(this.options.manager),this.fileLoader.setResponseType(`arraybuffer`),this.options.crossOrigin===`use-credentials`&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies(`scene`),n.getDependencies(`animation`),n.getDependencies(`camera`)])}).then(function(t){let a={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return _E(i,a,r),vE(a,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(a)})).then(function(){for(let e of a.scenes)e.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){let r=e[t];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let r=n.clone(),i=(e,t)=>{let n=this.associations.get(e);n!=null&&this.associations.set(t,n);for(let[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+=`_instance_`+ e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let r=e(t[n]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let r=0;r<t.length;r++){let i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){let n=e+`:`+t,r=this.cache.get(n);if(!r){switch(e){case`scene`:r=this.loadScene(t);break;case`node`:r=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case`mesh`:r=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case`accessor`:r=this.loadAccessor(t);break;case`bufferView`:r=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case`buffer`:r=this.loadBuffer(t);break;case`material`:r=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case`texture`:r=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case`skin`:r=this.loadSkin(t);break;case`animation`:r=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case`camera`:r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!r)throw Error(`Unknown type: `+e);break}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,r=this.json[e+(e===`mesh`?`es`:`s`)]||[];t=Promise.all(r.map(function(t,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!==`arraybuffer`)throw Error(`THREE.GLTFLoader: `+t.type+` buffer type is not supported.`);if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[MT.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(e,i){n.load(gd.resolveURL(t.uri,r.path),e,void 0,function(){i(Error(`THREE.GLTFLoader: Failed to load buffer "`+t.uri+`".`))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency(`buffer`,t.buffer).then(function(e){let n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)})}loadAccessor(e){let t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){let e=dE[r.type],t=cE[r.componentType],n=r.normalized===!0,i=new t(r.count*e);return Promise.resolve(new Do(i,e,n))}let i=[];return r.bufferView===void 0?i.push(null):i.push(this.getDependency(`bufferView`,r.bufferView)),r.sparse!==void 0&&(i.push(this.getDependency(`bufferView`,r.sparse.indices.bufferView)),i.push(this.getDependency(`bufferView`,r.sparse.values.bufferView))),Promise.all(i).then(function(e){let i=e[0],a=dE[r.type],o=cE[r.componentType],s=o.BYTES_PER_ELEMENT,c=s*a,l=r.byteOffset||0,u=r.bufferView===void 0?void 0:n.bufferViews[r.bufferView].byteStride,d=r.normalized===!0,f,p;if(u&&u!==c){let e=Math.floor(l/u),n=`InterleavedBuffer:`+r.bufferView+`:`+r.componentType+`:`+e+`:`+r.count,c=t.cache.get(n);c||(f=new o(i,e*u,r.count*u/s),c=new Uo(f,u/s),t.cache.add(n,c)),p=new Go(c,a,l%u/s,d)}else f=i===null?new o(r.count*a):new o(i,l,r.count*a),p=new Do(f,a,d);if(r.sparse!==void 0){let t=dE.SCALAR,n=cE[r.sparse.indices.componentType],s=r.sparse.indices.byteOffset||0,c=r.sparse.values.byteOffset||0,l=new n(e[1],s,r.sparse.count*t),u=new o(e[2],c,r.sparse.count*a);i!==null&&(p=new Do(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let e=0,t=l.length;e<t;e++){let t=l[e];if(p.setX(t,u[e*a]),a>=2&&p.setY(t,u[e*a+1]),a>=3&&p.setZ(t,u[e*a+2]),a>=4&&p.setW(t,u[e*a+3]),a>=5)throw Error(`THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.`)}p.normalized=d}return p})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],a=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);e!==null&&(a=e)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let r=this,i=this.json,a=i.textures[e],o=i.images[t],s=(o.uri||o.bufferView)+`:`+a.sampler;if(this.textureCache[s])return this.textureCache[s];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=a.name||o.name||``,t.name===``&&typeof o.uri==`string`&&o.uri.startsWith(`data:image/`)===!1&&(t.name=o.uri);let n=(i.samplers||{})[a.sampler]||{};return t.magFilter=lE[n.magFilter]||1006,t.minFilter=lE[n.minFilter]||1008,t.wrapS=uE[n.wrapS]||1e3,t.wrapT=uE[n.wrapT]||1e3,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==1003&&t.minFilter!==1006,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=c,c}loadImageSource(e,t){let n=this,r=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(e=>e.clone());let a=r.images[e],o=self.URL||self.webkitURL,s=a.uri||``,c=!1;if(a.bufferView!==void 0)s=n.getDependency(`bufferView`,a.bufferView).then(function(e){c=!0;let t=new Blob([e],{type:a.mimeType});return s=o.createObjectURL(t),s});else if(a.uri===void 0)throw Error(`THREE.GLTFLoader: Image `+e+` is missing URI and bufferView`);let l=Promise.resolve(s).then(function(e){return new Promise(function(n,r){let a=n;t.isImageBitmapLoader===!0&&(a=function(e){let t=new oa(e);t.needsUpdate=!0,n(t)}),t.load(gd.resolveURL(e,i.path),a,void 0,r)})}).then(function(e){return c===!0&&o.revokeObjectURL(s),vE(e,a),e.userData.mimeType=a.mimeType||wE(a.uri),e}).catch(function(e){throw console.error(`THREE.GLTFLoader: Couldn't load texture`,s),e});return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){let i=this;return this.getDependency(`texture`,n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),i.extensions[MT.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[MT.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[MT.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let e=`PointsMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new Tc,qo.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e=`LineBasicMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new dc,qo.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||a){let e=`ClonedMaterial:`+n.uuid+`:`;r&&(e+=`derivative-tangents:`),i&&(e+=`vertex-colors:`),a&&(e+=`flat-shading:`);let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return mu}loadMaterial(e){let t=this,n=this.json,r=this.extensions,i=n.materials[e],a,o={},s=i.extensions||{},c=[];if(s[MT.KHR_MATERIALS_UNLIT]){let e=r[MT.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),c.push(e.extendParams(o,i,t))}else{let n=i.pbrMetallicRoughness||{};if(o.color=new X(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],Zr),o.opacity=e[3]}n.baseColorTexture!==void 0&&c.push(t.assignTexture(o,`map`,n.baseColorTexture,Xr)),o.metalness=n.metallicFactor===void 0?1:n.metallicFactor,o.roughness=n.roughnessFactor===void 0?1:n.roughnessFactor,n.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,`metalnessMap`,n.metallicRoughnessTexture)),c.push(t.assignTexture(o,`roughnessMap`,n.metallicRoughnessTexture))),a=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)})))}i.doubleSided===!0&&(o.side=2);let l=i.alphaMode||hE.OPAQUE;if(l===hE.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,l===hE.MASK&&(o.alphaTest=i.alphaCutoff===void 0?.5:i.alphaCutoff)),i.normalTexture!==void 0&&a!==vs&&(c.push(t.assignTexture(o,`normalMap`,i.normalTexture)),o.normalScale=new q(1,1),i.normalTexture.scale!==void 0)){let e=i.normalTexture.scale;o.normalScale.set(e,e)}if(i.occlusionTexture!==void 0&&a!==vs&&(c.push(t.assignTexture(o,`aoMap`,i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&a!==vs){let e=i.emissiveFactor;o.emissive=new X().setRGB(e[0],e[1],e[2],Zr)}return i.emissiveTexture!==void 0&&a!==vs&&c.push(t.assignTexture(o,`emissiveMap`,i.emissiveTexture,Xr)),Promise.all(c).then(function(){let n=new a(o);return i.name&&(n.name=i.name),vE(n,i),t.associations.set(n,{materials:e}),i.extensions&&_E(r,n,i),n})}createUniqueName(e){let t=Id.sanitizeNodeName(e||``);return t in this.nodeNamesUsed?t+`_`+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[MT.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return OE(n,e,t)})}let a=[];for(let n=0,o=e.length;n<o;n++){let o=e[n],s=xE(o),c=r[s];if(c)a.push(c.promise);else{let e;e=o.extensions&&o.extensions[MT.KHR_DRACO_MESH_COMPRESSION]?i(o):OE(new Ho,o,t),r[s]={primitive:o,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){let t=this,n=this.json,r=this.extensions,i=n.meshes[e],a=i.primitives,o=[];for(let e=0,t=a.length;e<t;e++){let t=a[e].material===void 0?gE(this.cache):this.getDependency(`material`,a[e].material);o.push(t)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(n){let o=n.slice(0,n.length-1),s=n[n.length-1],c=[];for(let n=0,l=s.length;n<l;n++){let l=s[n],u=a[n],d,f=o[n];if(u.mode===sE.TRIANGLES||u.mode===sE.TRIANGLE_STRIP||u.mode===sE.TRIANGLE_FAN||u.mode===void 0)d=i.isSkinnedMesh===!0?new Hs(l,f):new As(l,f),d.isSkinnedMesh===!0&&d.normalizeSkinWeights(),u.mode===sE.TRIANGLE_STRIP?d.geometry=ET(d.geometry,1):u.mode===sE.TRIANGLE_FAN&&(d.geometry=ET(d.geometry,2));else if(u.mode===sE.LINES)d=new Cc(l,f);else if(u.mode===sE.LINE_STRIP)d=new yc(l,f);else if(u.mode===sE.LINE_LOOP)d=new wc(l,f);else if(u.mode===sE.POINTS)d=new Ac(l,f);else throw Error(`THREE.GLTFLoader: Primitive mode unsupported: `+u.mode);Object.keys(d.geometry.morphAttributes).length>0&&bE(d,i),d.name=t.createUniqueName(i.name||`mesh_`+e),vE(d,i),u.extensions&&_E(r,d,u),t.assignFinalMaterial(d),c.push(d)}for(let n=0,r=c.length;n<r;n++)t.associations.set(c[n],{meshes:e,primitives:n});if(c.length===1)return i.extensions&&_E(r,c[0],i),c[0];let l=new za;i.extensions&&_E(r,l,i),t.associations.set(l,{meshes:e});for(let e=0,t=c.length;e<t;e++)l.add(c[e]);return l})}loadCamera(e){let t,n=this.json.cameras[e],r=n[n.type];if(!r){console.warn(`THREE.GLTFLoader: Missing camera parameters.`);return}return n.type===`perspective`?t=new sd(Vi.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type===`orthographic`&&(t=new fd(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),vE(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(this._loadNodeShallow(t.joints[e]));return t.inverseBindMatrices===void 0?n.push(null):n.push(this.getDependency(`accessor`,t.inverseBindMatrices)),Promise.all(n).then(function(e){let n=e.pop(),r=e,i=[],a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e];if(o){i.push(o);let t=new Y;n!==null&&t.fromArray(n.array,e*16),a.push(t)}else console.warn(`THREE.GLTFLoader: Joint "%s" could not be found.`,t.joints[e])}return new qs(i,a)})}loadAnimation(e){let t=this.json,n=this,r=t.animations[e],i=r.name?r.name:`animation_`+e,a=[],o=[],s=[],c=[],l=[];for(let e=0,t=r.channels.length;e<t;e++){let t=r.channels[e],n=r.samplers[t.sampler],i=t.target,u=i.node,d=r.parameters===void 0?n.input:r.parameters[n.input],f=r.parameters===void 0?n.output:r.parameters[n.output];i.node!==void 0&&(a.push(this.getDependency(`node`,u)),o.push(this.getDependency(`accessor`,d)),s.push(this.getDependency(`accessor`,f)),c.push(n),l.push(i))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(s),Promise.all(c),Promise.all(l)]).then(function(e){let t=e[0],a=e[1],o=e[2],s=e[3],c=e[4],l=[];for(let e=0,r=t.length;e<r;e++){let r=t[e],i=a[e],u=o[e],d=s[e],f=c[e];if(r===void 0)continue;r.updateMatrix&&r.updateMatrix();let p=n._createAnimationTracks(r,i,u,d,f);if(p)for(let e=0;e<p.length;e++)l.push(p[e])}let u=new Iu(i,void 0,l);return vE(u,r),u})}createNodeMesh(e){let t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency(`mesh`,r.mesh).then(function(e){let t=n._getNodeRef(n.meshCache,r.mesh,e);return r.weights!==void 0&&t.traverse(function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]}),t})}loadNode(e){let t=this.json,n=this,r=t.nodes[e],i=n._loadNodeShallow(e),a=[],o=r.children||[];for(let e=0,t=o.length;e<t;e++)a.push(n.getDependency(`node`,o[e]));let s=r.skin===void 0?Promise.resolve(null):n.getDependency(`skin`,r.skin);return Promise.all([i,Promise.all(a),s]).then(function(e){let t=e[0],n=e[1],r=e[2];r!==null&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(r,TE)});for(let e=0,r=n.length;e<r;e++)t.add(n[e]);if(t.userData.pivot!==void 0&&n.length>0){let e=t.userData.pivot,r=n[0];t.pivot=new J().fromArray(e),t.position.x-=e[0],t.position.y-=e[1],t.position.z-=e[2],r.position.set(0,0,0),delete t.userData.pivot}return t})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let i=t.nodes[e],a=i.name?r.createUniqueName(i.name):``,o=[],s=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return s&&o.push(s),i.camera!==void 0&&o.push(r.getDependency(`camera`,i.camera).then(function(e){return r._getNodeRef(r.cameraCache,i.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){o.push(e)}),this.nodeCache[e]=Promise.all(o).then(function(t){let o;if(o=i.isBone===!0?new Us:t.length>1?new za:t.length===1?t[0]:new Ra,o!==t[0])for(let e=0,n=t.length;e<n;e++)o.add(t[e]);if(i.name&&(o.userData.name=i.name,o.name=a),vE(o,i),i.extensions&&_E(n,o,i),i.matrix!==void 0){let e=new Y;e.fromArray(i.matrix),o.applyMatrix4(e)}else i.translation!==void 0&&o.position.fromArray(i.translation),i.rotation!==void 0&&o.quaternion.fromArray(i.rotation),i.scale!==void 0&&o.scale.fromArray(i.scale);if(!r.associations.has(o))r.associations.set(o,{});else if(i.mesh!==void 0&&r.meshCache.refs[i.mesh]>1){let e=r.associations.get(o);r.associations.set(o,{...e})}return r.associations.get(o).nodes=e,o}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,i=new za;n.name&&(i.name=r.createUniqueName(n.name)),vE(i,n),n.extensions&&_E(t,i,n);let a=n.nodes||[],o=[];for(let e=0,t=a.length;e<t;e++)o.push(r.getDependency(`node`,a[e]));return Promise.all(o).then(function(e){for(let t=0,n=e.length;t<n;t++){let n=e[t];n.parent===null?i.add(n):i.add(DT(n))}return r.associations=(e=>{let t=new Map;for(let[e,n]of r.associations)(e instanceof qo||e instanceof oa)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);n!=null&&t.set(e,n)}),t})(i),i})}_createAnimationTracks(e,t,n,r,i){let a=[],o=e.name?e.name:e.uuid,s=[];pE[i.path]===pE.weights?e.traverse(function(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}):s.push(o);let c;switch(pE[i.path]){case pE.weights:c=ju;break;case pE.rotation:c=Nu;break;case pE.translation:case pE.scale:c=Fu;break;default:switch(n.itemSize){case 1:c=ju;break;default:c=Fu;break}break}let l=r.interpolation===void 0?Hr:mE[r.interpolation],u=this._getArrayFromAccessor(n);for(let e=0,n=s.length;e<n;e++){let n=new c(s[e]+`.`+pE[i.path],t.array,u,l);r.interpolation===`CUBICSPLINE`&&this._createCubicSplineTrackInterpolant(n),a.push(n)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let e=CE(t.constructor),n=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof Nu?oE:iE)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function DE(e,t,n){let r=t.attributes,i=new co;if(r.POSITION!==void 0){let e=n.json.accessors[r.POSITION],t=e.min,a=e.max;if(t!==void 0&&a!==void 0){if(i.set(new J(t[0],t[1],t[2]),new J(a[0],a[1],a[2])),e.normalized){let t=CE(cE[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}else{console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`);return}}else return;let a=t.targets;if(a!==void 0){let e=new J,t=new J;for(let r=0,i=a.length;r<i;r++){let i=a[r];if(i.POSITION!==void 0){let r=n.json.accessors[i.POSITION],a=r.min,o=r.max;if(a!==void 0&&o!==void 0){if(t.setX(Math.max(Math.abs(a[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(a[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(a[2]),Math.abs(o[2]))),r.normalized){let e=CE(cE[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`)}}i.expandByVector(e)}e.boundingBox=i;let o=new Po;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}function OE(e,t,n){let r=t.attributes,i=[];function a(t,r){return n.getDependency(`accessor`,t).then(function(t){e.setAttribute(r,t)})}for(let t in r){let n=fE[t]||t.toLowerCase();n in e.attributes||i.push(a(r[t],n))}if(t.indices!==void 0&&!e.index){let r=n.getDependency(`accessor`,t.indices).then(function(t){e.setIndex(t)});i.push(r)}return Xi.workingColorSpace!==`srgb-linear`&&`COLOR_0`in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Xi.workingColorSpace}" not supported.`),vE(e,t),DE(e,t,n),Promise.all(i).then(function(){return t.targets===void 0?e:yE(e,t.targets,n)})}var kE=(function(){var e=`b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuec:W:Odkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq;lZkdbk;jYi5ud9:du8Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCabaOad2fhXaAcethQaxaDfhiaOaeaoaeao6E9RhLalcl4cifcd4hKazcj;cbfaAfhYcbh8AazcjdfhEaHh3incbhodnawTmbaxa8Acd4fRbbhokaocFeGh5cbh8Eazcj;cbfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcj;cbfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcj;cbfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaK6mva8FaKfhidnaCTmbaPai9RcK6mbaocdtc:q1jjbfcj1jjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bbarcwf9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfag9c8F1:NghcKtc8F91aicdfa8J9c8N1:Nfg8KRbbG86bbarcVfcba8KahcjeGcr4fghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fag9c8F1:NgicKtc8F91aha8J9c8N1:NfghRbbG86bbarc96fcbahaicjeGcr4fgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbb83bbarcwfaicwf8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasa8Acd4fRbbgociGPlbedrbkaATmdaza8Afh8Fazcj;cbfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeaza8Afhaazcj;cbfhhcbhoceh8EaYh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaLaocefgofmbka8FaQfh8FcdhoaacdfhaahaQfhha8EceGhlcbh8EalmbxdkkaATmbcbaocl49Rh8Eaza8AfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaYhainazcj;cbfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E93aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3a8Aclfg8Aad6mbkaXazcjdfaAad2z:jjjjb8AazazcjdfaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaok:XseHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:kjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbaxcefgOavaiaqaDcsGfRbbgscl49RcsGcdtfydbascz6gPEhDavaias9RcsGcdtfydbaOaPfgzascsGgOEhsaOThOdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiaPfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaOfhiazaOfhxxekaxcbalRbbgHEgAaDc;:eSgDfhzaHcsGhCaHcl4hXdndnaHcs0mbazcefhOxekazhOavaiaX9RcsGcdtfydbhzkdndnaCmbaOcefhxxekaOhxavaiaH9RcsGcdtfydbhOkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhAascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaAhDxekaDcefhDkasce4cbasceG9R7amfgmhAkdndnaXcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhzaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkazhsxekascefhskaPce4cbaPceG9R7amfgmhzkdndnaCcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhOaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkaOhlxekalcefhlkaPce4cbaPceG9R7amfgmhOkdndnadcd9hmbabarcetfgDaA87ebaDclfaO87ebaDcdfaz87ebxekabarcdtfgDaABdbaDcwfaOBdbaDclfazBdbkavc;abfaocitfgDazBdbaDaABdlavaicdtfaABdbavc;abfaocefcsGcitfgDaOBdbaDazBdlavaicefgicsGcdtfazBdbavc;abfaocdfcsGcitfgDaABdbaDaOBdlavaiaHcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnaecvfal9nmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk::ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxabaiarcefciGfcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGfgkcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkabaiarcufciGfcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkabakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K1jjbgeabcifc98GfgbBd:K1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;teeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiaeydlBdlaiaeydwBdwaiaeydxBdxaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk:3eedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdxaialBdwaialBdlaialBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk81dbcjwk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:Kwkl8WNbb`,t=`b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuec:q:6dkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:Ctklbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk:183lYud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxavaialfgmar9Rgoad;8qbbcj;abad9Uc;WFbGcjdadca0EhPdndndnadTmbaoadfhscbhzinaeaz9nmdamax9RaD6miabazad2fhHaxaDfhOaPaeaz9RazaPfae6EgAcsfgocl4cifcd4hCavcj;cbfaoc9WGgXcetfhQavcj;cbfaXci2fhLavcj;cbfaXfhKcbhYaoc;ab6h8AincbhodnawTmbaxaYcd4fRbbhokaocFeGhEcbh3avcj;cbfh5indndndndnaEa3cet4ciGgoc9:fPdebdkamaO9RaX6mwavcj;cbfa3aX2faOaX;8qbbaOaAfhOxdkavcj;cbfa3aX2fcbaX;8kbxekamaO9RaC6moaoclVcbawEhraOaCfhocbhidna8Ambamao9Rc;Gb6mbcbhlina5alfhidndndndndndnaOalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaiaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaiczfaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaicafaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngicitc:q1jjbfpbibaic:q:yjjbfRbbgipsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaiaoclffaqc:q:yjjbfRbbfhoxikaic8Wfaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngicitc:q1jjbfpbibaic:q:yjjbfRbbgipsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaiaocwffaqc:q:yjjbfRbbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitc:q1jjbfpbibaic:q:yjjbfRbbgipsaoRbegqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqc:q:yjjbfRbbfhokalc;abfhialcjefaX0meaihlamao9Rc;Fb0mbkkdnaiaX9pmbaici4hlinamao9RcK6mwa5aifhqdndndndndndnaOaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spkbbaaaoclffahc:q:yjjbfRbbfhoxikaqaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spkbbaaaocwffahc:q:yjjbfRbbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpkbbaaaocdffahc:q:yjjbfRbbfhokalcdfhlaiczfgiaX6mbkkaohOaoTmoka5aXfh5a3cefg3cl9hmbkdndndndnawTmbasaYcd4fRbbglciGPlbedwbkaXTmdavcjdfaYfhlavaYfpbdbhgcbhoinalavcj;cbfaofpblbg8JaKaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaQaofpblbg8MaLaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Ecep9Ta8Epxeeeeeeeeeeeeeeeeg8Fp9op9Hp9rg8Eagp9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8LaypmwDKYqk8AExm35Ps8E8Fg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Ug8Fp9Abbbaladfgla8Fa8Ea8Epmlvorlvorlvorlvorp9Ug8Fp9Abbbaladfgla8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9Ug8Fp9Abbbaladfgla8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9AbbbaladfhlaoczfgoaX6mbxikkaXTmeavcjdfaYfhlavaYfpbdbhgcbhoinalavcj;cbfaofpblbg8JaKaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaQaofpblbg8MaLaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Ecep:nea8Epxebebebebebebebebg8Fp9op:bep9rg8Eagp:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8LaypmwDKYqk8AExm35Ps8E8Fg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeg8Fp9Abbbaladfgla8Fa8Ea8Epmlvorlvorlvorlvorp:oeg8Fp9Abbbaladfgla8Fa8Ea8EpmwDqkwDqkwDqkwDqkp:oeg8Fp9Abbbaladfgla8Fa8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9AbbbaladfhlaoczfgoaX6mbxdkkaXTmbcbhocbalcl4gl9Rc8FGhiavcjdfaYfhravaYfpbdbh8Finaravcj;cbfaofpblbggaKaofpblbg8JpmbzeHdOiAlCvXoQrLg8KaQaofpblbg8LaLaofpblbg8MpmbzeHdOiAlCvXoQrLg8NpmbezHdiOAlvCXorQLg8Eaip:Rea8Ealp:Sep9qg8Ea8Fp9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Fa8Ka8NpmwDKYqk8AExm35Ps8E8Fg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Faga8JpmwKDYq8AkEx3m5P8Es8Fgga8La8MpmwKDYq8AkEx3m5P8Es8Fg8JpmbezHdiOAlvCXorQLg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Faga8JpmwDKYqk8AExm35Ps8E8Fg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9AbbbaradfhraoczfgoaX6mbkkaYclfgYad6mbkaHavcjdfaAad2;8qbbavavcjdfaAcufad2fad;8qbbaAazfhzc9:hoaOhxaOmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdaPaeao9RaoaPfae6Eaofgoae6mbkaial9Rhxkcbc99amax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbk:TseHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbaxcefgOavaiaqaDcsGfRbbgscl49RcsGcdtfydbascz6gPEhDavaias9RcsGcdtfydbaOaPfgzascsGgOEhsaOThOdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiaPfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaOfhiazaOfhxxekaxcbalRbbgHEgAaDc;:eSgDfhzaHcsGhCaHcl4hXdndnaHcs0mbazcefhOxekazhOavaiaX9RcsGcdtfydbhzkdndnaCmbaOcefhxxekaOhxavaiaH9RcsGcdtfydbhOkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhAascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaAhDxekaDcefhDkasce4cbasceG9R7amfgmhAkdndnaXcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhzaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkazhsxekascefhskaPce4cbaPceG9R7amfgmhzkdndnaCcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhOaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkaOhlxekalcefhlkaPce4cbaPceG9R7amfgmhOkdndnadcd9hmbabarcetfgDaA87ebaDclfaO87ebaDcdfaz87ebxekabarcdtfgDaABdbaDcwfaOBdbaDclfazBdbkavc;abfaocitfgDazBdbaDaABdlavaicdtfaABdbavc;abfaocefcsGcitfgDaOBdbaDazBdlavaicefgicsGcdtfazBdbavc;abfaocdfcsGcitfgDaABdbaDaOBdlavaiaHcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnaecvfal9nmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:2Pliur97eue978Jjjjjbc8W9Rhiaec98Ghldndnadcl9hmbdnalTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalaeSmeaipxbbbbbbbbbbbbbbbbgqpklbaiabalcdtfgdaeciGglcdtgv;8qbbdnalTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDaqp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkadaiav;8qbbskaipxFubbFubbFubbFubbgxpklbdnalTmbcbhvabhdinadczfgmampbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraipblbaDaopmlvorxmPsCXQL358E8Fp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgPp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;MeawaqawaPp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oaoarpmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgval6mbkkalaeSmbaiczfpxbbbbbbbbbbbbbbbbgopklbaiaopklbaiabalcitfgdaeciGglcitgv;8qbbaiaxpkladnalTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraipblaaDaopmlvorxmPsCXQL358E8Fp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgPp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;MeawaqawaPp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oaoarpmbezHdiOAlvCXorQLp9qpklbkadaiav;8qbbkk:Iwllue97euo978Jjjjjbca9Rhidnaec98GglTmbcbhvabhoinaocKfpx:ji:1S:ji:1S:ji:1S:ji:1SaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkpxibbbibbbibbbibbbp9qgxp;6ep;Negmaxaxp:1ep;7egxaxp;KearaDpmbediwDqkzHOAKY8AEgxczp:Reczp:Sep;6egrarp;Meaxczp:Sep;6egDaDp;Meaqczp:Reczp:Sep;6egqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gxp;KepxFFbbFFbbFFbbFFbbgPp9oamaDp;Meaxp;Keczp:Rep9qgDamarp;Meaxp;KeaPp9oamaqp;Meaxp;Keczp:Rep9qgxpmwDKYqk8AExm35Ps8E8Fgrp5eakclp:RegmpEi:T:j83ibawarp5bampEd:T:j83ibaocwfaDaxpmbezHdiOAlvCXorQLgxp5eampEe:T:j83ibaoaxp5bampEb:T:j83ibaocafhoavclfgval6mbkkdnalaeSmbaiczfpxbbbbbbbbbbbbbbbbgmpklbaiampklbaiabalcitfgoaeciGgvcitgw;8qbbdnavTmbaipx:ji:1S:ji:1S:ji:1S:ji:1SaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkpxibbbibbbibbbibbbp9qgxp;6ep;Negmaxaxp:1ep;7egxaxp;KearaDpmbediwDqkzHOAKY8AEgxczp:Reczp:Sep;6egrarp;Meaxczp:Sep;6egDaDp;Meaqczp:Reczp:Sep;6egqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gxp;KepxFFbbFFbbFFbbFFbbgPp9oamaDp;Meaxp;Keczp:Rep9qgDamarp;Meaxp;KeaPp9oamaqp;Meaxp;Keczp:Rep9qgxpmwDKYqk8AExm35Ps8E8Fgrp5eakclp:RegmpEi:T:j83iKaiarp5bampEd:T:j83izaiaDaxpmbezHdiOAlvCXorQLgxp5eampEe:T:j83iwaiaxp5bampEb:T:j83ibkaoaiaw;8qbbkk;uddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbheabhdinadadpbbbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbadczfhdaeclfgeav6mbkkdnavalSmbaic8WfpxbbbbbbbbbbbbbbbbgopklbaicafaopklbaiczfaopklbaiaopklbaiabavcdtfgdalciGgecdtgv;8qbbdnaeTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepklbkadaiav;8qbbkk:CPvdue97euw97eu8Jjjjjbc8W9Rhiaec98Ghldndnadcl9hmbaipxbbbbbbbbbbbbbbbbgvpklbdnalTmbcbhoabhdinadpbbbhradpxbbuJbbuJbbuJbbuJaipblbarcKp:Tep9qgwcep:Seawp9qgDcdp:SeaDp9qgDclp:SeaDp9qgqp;6ep;NegDarcwp:RecKp:SegkarpxFbbbFbbbFbbbFbbbgxp9ogmp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gPp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oaDamakp:Xearczp:RecKp:Segrp:Uep;6ep;MeaPp;Keaxp9op9qaDamakarp:Uep:Xep;6ep;MeaPp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qaDaqawcep:Rep9oawpxebbbebbbebbbebbbp9op9qp;6ep;MeaPp;KecKp:Rep9qpkbbadczfhdaoclfgoal6mbkkalaeSmeaiavpklaaicafabalcdtfgdaeciGglcdtgo;8qbbaiavpklbdnalTmbaipblahraipxbbuJbbuJbbuJbbuJaipblbarcKp:Tep9qgwcep:Seawp9qgDcdp:SeaDp9qgDclp:SeaDp9qgqp;6ep;NegDarcwp:RecKp:SegkarpxFbbbFbbbFbbbFbbbgxp9ogmp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gPp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oaDamakp:Xearczp:RecKp:Segrp:Uep;6ep;MeaPp;Keaxp9op9qaDamakarp:Uep:Xep;6ep;MeaPp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qaDaqawcep:Rep9oawpxebbbebbbebbbebbbp9op9qp;6ep;MeaPp;KecKp:Rep9qpklakadaicafao;8qbbskaipxbbbbbbbbbbbbbbbbgvpklbdnalTmbcbhoabhdinadczfgspxbFu9hbFu9hbFu9hbFu9hadpbbbgDaspbbbgPpmlvorxmPsCXQL358E8Fgmczp:Teaipblbp9qgrcep:Searp9qgwcdp:Seawp9qgwclp:Seawp9qgwcwp:Seawp9qgqp;6ep;NegwaDaPpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbgPp9ogkaDczp:Segxp:Ueamczp:Reczp:Segmp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gDp;KeaPp9oawakaxamp:Uep:Xep;6ep;MeaDp;Keczp:Rep9qgxawaqarcep:Rep9oarpxebbbebbbebbbebbbp9op9qp;6ep;MeaDp;Keczp:Reawamakp:Uep;6ep;MeaDp;KeaPp9op9qgrpmwDKYqk8AExm35Ps8E8FpkbbadaxarpmbezHdiOAlvCXorQLpkbbadcafhdaoclfgoal6mbkkalaeSmbaiczfpxbbbbbbbbbbbbbbbbgrpklbaiarpklbaiabalcitfgdaeciGglcitgo;8qbbaiavpkladnalTmbaipxbFu9hbFu9hbFu9hbFu9haipblbgDaipblzgPpmlvorxmPsCXQL358E8Fgmczp:Teaipblap9qgrcep:Searp9qgwcdp:Seawp9qgwclp:Seawp9qgwcwp:Seawp9qgqp;6ep;NegwaDaPpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbgPp9ogkaDczp:Segxp:Ueamczp:Reczp:Segmp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gDp;KeaPp9oawakaxamp:Uep:Xep;6ep;MeaDp;Keczp:Rep9qgxawaqarcep:Rep9oarpxebbbebbbebbbebbbp9op9qp;6ep;MeaDp;Keczp:Reawamakp:Uep;6ep;MeaDp;KeaPp9op9qgrpmwDKYqk8AExm35Ps8E8FpklzaiaxarpmbezHdiOAlvCXorQLpklbkadaiao;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz:Dbb`,n=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),r=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=`object`)return{supported:!1};var i=WebAssembly.validate(n)?s(t):s(e),a,o=WebAssembly.instantiate(i,{}).then(function(e){a=e.instance,a.exports.__wasm_call_ctors()});function s(e){for(var t=new Uint8Array(e.length),n=0;n<e.length;++n){var i=e.charCodeAt(n);t[n]=i>96?i-97:i>64?i-39:i+4}for(var a=0,n=0;n<e.length;++n)t[a++]=t[n]<60?r[t[n]]:(t[n]-60)*64+t[++n];return t.buffer.slice(0,a)}function c(e,t,n,r,i,a,o){var s=e.exports.sbrk,c=r+3&-4,l=s(c*i),u=s(a.length),d=new Uint8Array(e.exports.memory.buffer);d.set(a,u);var f=t(l,r,i,u,a.length);if(f==0&&o&&o(l,c,i),n.set(d.subarray(l,l+r*i)),s(l-s(0)),f!=0)throw Error(`Malformed buffer data: `+f)}var l={NONE:``,OCTAHEDRAL:`meshopt_decodeFilterOct`,QUATERNION:`meshopt_decodeFilterQuat`,EXPONENTIAL:`meshopt_decodeFilterExp`,COLOR:`meshopt_decodeFilterColor`},u={ATTRIBUTES:`meshopt_decodeVertexBuffer`,TRIANGLES:`meshopt_decodeIndexBuffer`,INDICES:`meshopt_decodeIndexSequence`},d=[],f=0;function p(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var n=e.data;t.pending-=n.count,t.requests[n.id][n.action](n.value),delete t.requests[n.id]},t}function m(e){for(var t=`self.ready = WebAssembly.instantiate(new Uint8Array([`+new Uint8Array(i)+`]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = `+g.name+`;`+c.toString()+g.toString(),n=new Blob([t],{type:`text/javascript`}),r=URL.createObjectURL(n),a=d.length;a<e;++a)d[a]=p(r);for(var a=e;a<d.length;++a)d[a].object.postMessage({});d.length=e,URL.revokeObjectURL(r)}function h(e,t,n,r,i){for(var a=d[0],o=1;o<d.length;++o)d[o].pending<a.pending&&(a=d[o]);return new Promise(function(o,s){var c=new Uint8Array(n),l=++f;a.pending+=e,a.requests[l]={resolve:o,reject:s},a.object.postMessage({id:l,count:e,size:t,source:c,mode:r,filter:i},[c.buffer])})}function g(e){var t=e.data;if(!t.id)return self.close();self.ready.then(function(e){try{var n=new Uint8Array(t.count*t.size);c(e,e.exports[t.mode],n,t.count,t.size,t.source,e.exports[t.filter]),self.postMessage({id:t.id,count:t.count,action:`resolve`,value:n},[n.buffer])}catch(e){self.postMessage({id:t.id,count:t.count,action:`reject`,value:e})}})}return{ready:o,supported:!0,useWorkers:function(e){m(e)},decodeVertexBuffer:function(e,t,n,r,i){c(a,a.exports.meshopt_decodeVertexBuffer,e,t,n,r,a.exports[l[i]])},decodeIndexBuffer:function(e,t,n,r){c(a,a.exports.meshopt_decodeIndexBuffer,e,t,n,r)},decodeIndexSequence:function(e,t,n,r){c(a,a.exports.meshopt_decodeIndexSequence,e,t,n,r)},decodeGltfBuffer:function(e,t,n,r,i,o){c(a,a.exports[u[i]],e,t,n,r,a.exports[l[o]])},decodeGltfBufferAsync:function(e,t,n,r,i){return d.length>0?h(e,t,n,u[r],l[i]):o.then(function(){var o=new Uint8Array(e*t);return c(a,a.exports[u[r]],o,e,t,n,a.exports[l[i]]),o})}}})(),AE=1230263361,jE=2,ME=16,NE=11,PE=32767,FE=86400;function IE(e){let t=new DataView(e);if(t.getUint32(0,!0)!==AE)throw Error(`attitude: bad file magic (expected ATTI)`);let n=t.getUint16(4,!0);if(n!==jE)throw Error(`attitude: unsupported version ${n}`);let r=t.getFloat64(8,!0),i=Math.floor((e.byteLength-ME)/NE),a=new Float64Array(i),o=new Float32Array(i*4),s=0;for(let e=0;e<i;e++){let n=ME+e*NE;e>0&&(s+=t.getFloat32(n,!0)),a[e]=r+s/FE;let i=t.getUint8(n+4),c=t.getInt16(n+5,!0)/PE,l=t.getInt16(n+7,!0)/PE,u=t.getInt16(n+9,!0)/PE,d=Math.sqrt(Math.max(0,1-c*c-l*l-u*u)),f=e*4,p=0;for(let e=0;e<4;e++)e===i?o[f+e]=d:(o[f+e]=p===0?c:p===1?l:u,p++)}return{times:a,quats:o}}var LE=86400,RE=new Hi().setFromRotationMatrix(new Y().makeBasis(dg(1,0,0,new J),dg(0,1,0,new J),dg(0,0,1,new J))),zE=new Hi,BE=new Hi,VE=new Hi,HE=new J;function UE(e,t,n){let r=t*4;return n.set(e[r+1],e[r+2],e[r+3],e[r])}var WE=class{startJd;endJd;baselines;files;chunks=new Map;inflight=new Set;failed=new Set;constructor(e,t){this.probeId=e,this.startJd=t.files.length?t.files[0].start_jd:0,this.endJd=t.files.length?t.files[t.files.length-1].end_jd:0,this.baselines=t.baselines,this.files=t.files}covers(e){return e>=this.startJd&&e<=this.endJd&&this.files.length>0}orientationAt(e,t){if(!this.covers(e))return!1;let n=this.fileIndexFor(e),r=this.ensure(n);if(!r)return!1;this.ensure(n-1),this.ensure(n+1),this.sampleChunk(e,n,r);let i=this.baselines?.[this.files[n].baseline_index??0];if(i){let{axis:t,rate_rad_s:n,anchor:r,anchor_jd:a}=i,o=(e-a)*LE;HE.set(t[0],t[1],t[2]),VE.setFromAxisAngle(HE,n*o),BE.set(r[1],r[2],r[3],r[0]),VE.multiply(BE),zE.copy(VE.multiply(zE))}return zE.conjugate(),t.copy(RE).multiply(zE),!0}fileIndexFor(e){let t=this.files;if(e<=t[0].start_jd)return 0;let n=0,r=t.length-1;for(;r-n>1;){let i=n+r>>1;t[i].start_jd<=e?n=i:r=i}return t[r].start_jd<=e?r:n}sampleChunk(e,t,n){let{times:r,quats:i}=n,a=r.length;if(e<=r[0]){UE(i,0,zE);return}if(e>=r[a-1]){let n=this.chunks.get(t+1);if(this.files[t+1]?.baseline_index===this.files[t].baseline_index&&n&&n.times.length>0&&n.times[0]>r[a-1]){let t=n.times[0]-r[a-1],o=Math.min(1,(e-r[a-1])/t);UE(i,a-1,zE),UE(n.quats,0,BE),zE.slerpQuaternions(zE,BE,o)}else UE(i,a-1,zE);return}let o=0,s=a-1;for(;s-o>1;){let t=o+s>>1;r[t]<=e?o=t:s=t}let c=r[s]-r[o],l=c>0?(e-r[o])/c:0;UE(i,o,zE),UE(i,s,BE),zE.slerpQuaternions(zE,BE,l)}ensure(e){if(e<0||e>=this.files.length)return;let t=this.chunks.get(e);if(t)return t;this.inflight.has(e)||this.failed.has(e)||(this.inflight.add(e),this.load(e))}async load(e){let t=this.files[e];try{let n=await fetch(`${Kt()}/v1/attitude/${this.probeId}/${t.name}`);if(!n.ok)throw Error(`${n.status}`);let r=new DecompressionStream(`gzip`),i=await new Response(n.body.pipeThrough(r)).arrayBuffer();this.chunks.set(e,IE(i))}catch(n){this.failed.add(e),console.warn(`attitude: chunk ${this.probeId}/${t.name} failed to load:`,n)}finally{this.inflight.delete(e)}}};function GE(e,t){return new WE(e,t)}var KE=[`carrier`,`missing`],qE=`scene-label__annotation--visible`;function JE(e,t,n){let r=e.labelAnnotations?.[t];if(!r){if(!n||!e.label)return;r=document.createElement(`span`),r.className=`scene-label__annotation`,r.dir=`auto`,r.textContent=n,ZE(e,r,t),(e.labelAnnotations??={})[t]=r}else if(n===null){if(!r.classList.contains(qE))return}else if(r.textContent===n&&r.classList.contains(qE))return;else r.textContent=n;r.classList.toggle(qE,n!==null),YE(e)}function YE(e){let t=e.label?.element;if(!t)return;let n=[t.querySelector(`.scene-label__name`)?.textContent||e.body.data.name];for(let t of KE){let r=e.labelAnnotations?.[t];r?.classList.contains(qE)&&n.push(r.textContent)}let r=n.filter(Boolean).join(`, `);r?t.setAttribute(`aria-label`,r):t.removeAttribute(`aria-label`)}function XE(e){if(!e.labelStack){let t=document.createElement(`span`);t.className=`scene-label__annotations`,e.label.element.appendChild(t),e.labelStack=t}return e.labelStack}function ZE(e,t,n){for(let r of KE.slice(KE.indexOf(n)+1)){let n=e.labelAnnotations?.[r];if(n){n.parentElement.insertBefore(t,n);return}}XE(e).appendChild(t)}function QE(e,t){let n=e.userData,r=t??``;if(n.tintBase&&n.tintKey===r)return n.tintBase;let i=rD(e,t);return n.tintBase=i,n.tintKey=r,i}var $E=32,eD=16,tD=.01,nD=.001;function rD(e,t){let n=new X(16777215);if(!t)return n;let r=iD(e);if(r===null||r>tD)return n;let i=new X(t),a=.2126*i.r+.7152*i.g+.0722*i.b;return a<nD?n:new X().setRGB(i.r/a,i.g/a,i.b/a)}function iD(e){let t=e.image;if(!t||!t.width||!t.height)return null;let n=document.createElement(`canvas`);n.width=$E,n.height=eD;let r=n.getContext(`2d`,{willReadFrequently:!0});if(!r)return null;r.drawImage(t,0,0,$E,eD);let i;try{i=r.getImageData(0,0,$E,eD).data}catch{return null}let a=0,o=i.length/4;for(let e=0;e<i.length;e+=4){let t=i[e]/255,n=i[e+1]/255,r=i[e+2]/255;a+=Math.max(t,n,r)-Math.min(t,n,r)}return a/o}var aD=`
|
|
4501
|
+
`})}var hT=class extends qa{constructor(){super(),this.name=`RoomEnvironment`,this.position.y=-3.5;let e=new Lc;e.deleteAttribute(`uv`);let t=new mu({side:1}),n=new mu,r=new dd(16777215,900,28,2);r.position.set(.418,16.199,.3),this.add(r);let i=new As(e,t);i.position.set(-.757,13.219,.717),i.scale.set(31.713,28.305,28.591),this.add(i);let a=new nc(e,n,6),o=new Ra;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),a.setMatrixAt(0,o.matrix),o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),a.setMatrixAt(1,o.matrix),o.position.set(6.167,.857,7.803),o.rotation.set(0,.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),a.setMatrixAt(2,o.matrix),o.position.set(-2.017,.018,6.124),o.rotation.set(0,.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),a.setMatrixAt(3,o.matrix),o.position.set(2.291,-.756,-2.621),o.rotation.set(0,-.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),a.setMatrixAt(4,o.matrix),o.position.set(-2.193,-.369,-5.547),o.rotation.set(0,.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),a.setMatrixAt(5,o.matrix),this.add(a);let s=new As(e,gT(50));s.position.set(-16.116,14.37,8.208),s.scale.set(.1,2.428,2.739),this.add(s);let c=new As(e,gT(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(.1,2.425,2.751),this.add(c);let l=new As(e,gT(17));l.position.set(14.904,12.198,-1.832),l.scale.set(.15,4.265,6.331),this.add(l);let u=new As(e,gT(43));u.position.set(-.462,8.89,14.52),u.scale.set(4.38,5.441,.088),this.add(u);let d=new As(e,gT(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,.1),this.add(d);let f=new As(e,gT(100));f.position.set(0,20,0),f.scale.set(1,.1,1),this.add(f)}dispose(){let e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(let t of e)t.dispose()}};function gT(e){return new gu({color:0,emissive:16777215,emissiveIntensity:e})}var _T=.01,vT=3.5,yT=.04;function bT(e){let t=Math.max(e/10,.01);return 1/(t*t)}function xT(e,t,n=1){e.decay=t?2:0,e.intensity=(t?vT*10*10:vT)*n}function ST(e){let t=new yf(e),n=t.fromScene(new hT).texture;return t.dispose(),n}var CT=1e5;function wT(){try{return!!document.createElement(`canvas`).getContext(`webgl2`)?.getExtension(`EXT_clip_control`)}catch{return!1}}var TT=class extends Error{constructor(e){super(`WebGL is unavailable on this device.`,{cause:e}),this.name=`WebGLUnavailableError`}};function ET(e,t,n){let r,i=wT();try{r=new dh(i?{canvas:e,reversedDepthBuffer:!0,antialias:!0}:{canvas:e,logarithmicDepthBuffer:!0,antialias:!0})}catch(e){throw new TT(e)}i&&!r.capabilities.reversedDepthBuffer&&console.warn(`EXT_clip_control probe mismatch: reversed depth unavailable on main context`),rT(r.capabilities.reversedDepthBuffer);let a=Yx();r.setPixelRatio(Xx()),r.setSize(e.clientWidth,e.clientHeight,!1),r.shadowMap.enabled=!0,r.shadowMap.type=a.softShadows?2:1,r.toneMapping=4,r.toneMappingExposure=1,fT(e.clientWidth,e.clientHeight);let o=new cT({element:t});o.setSize(e.clientWidth,e.clientHeight),n.visibility.updateViewport(e.clientHeight);let s=new qa,c=new hd(16777215,_T);s.add(c);let l=new md(16777215,0);l.castShadow=!1,l.shadow.mapSize.set(a.shadowMapSize,a.shadowMapSize),l.shadow.bias=-1e-4,s.add(l),s.add(l.target);let u=new sd(60,e.clientWidth/e.clientHeight,Q(.001),CT),d=r.capabilities.reversedDepthBuffer?new la(e.clientWidth,e.clientHeight,{type:Un,depthTexture:new Pc(e.clientWidth,e.clientHeight,Hn)}):void 0,f=new Xw(r,d);f.setPixelRatio(Xx()),f.setSize(e.clientWidth,e.clientHeight),f.addPass(new Zw(s,u));let p=new $w(new q(e.clientWidth*a.bloomScale,e.clientHeight*a.bloomScale),.3,.5,1);return f.addPass(p),f.addPass(new tT),{renderer:r,labelRenderer:o,scene:s,camera:u,composer:f,bloomPass:p,ambientLight:c,shadowLight:l}}function DT(e,t,n){let r=e.data;e.placedJd=t;let i=r.q!=null,a;if(r.parentId===`naif-0`)a=[0,0,0];else{let t=n.getBody(r.parentId)?.position;if(!t){e.positionUnknown=!0;return}a=t}if(t<r.validityStart||t>r.validityEnd){e.positionUnknown=!0;return}let o=r.a===0&&!i&&!r.satrec?[0,0,0]:r.satrec?bg(r.satrec,t):i?Xv(r,t):Jv(r,t);if(!o){e.positionUnknown=!0;return}e.position[0]=a[0]+o[0],e.position[1]=a[1]+o[1],e.position[2]=a[2]+o[2],e.orbitCenter&&(e.orbitCenter[0]=a[0],e.orbitCenter[1]=a[1],e.orbitCenter[2]=a[2]),e.positionUnknown=!1}function OT(e,t,n){let r=e.data;if(e.placedJd=t,e.positionUnknown=!0,r.unplaceable||r.visibleFromDays!==void 0&&t-2451545<r.visibleFromDays)return;let i=n.getBody(r.parentId);if(!i||!kT(i,t,n))return;let a=i.position,o=n.chebStore?.has(r.id)?n.chebStore.positionScene(r.id,t):r.a===0?[0,0,0]:Jv(r,t);o&&(e.position[0]=a[0]+o[0],e.position[1]=a[1]+o[1],e.position[2]=a[2]+o[2],e.orbitCenter&&(e.orbitCenter[0]=a[0],e.orbitCenter[1]=a[1],e.orbitCenter[2]=a[2]),e.positionUnknown=!1)}function kT(e,t,n){let r=e.data,i=e.placedJd!==t;if(r.orbitalSource===U.SPICE_PROBE){let{hostRead:t}=n.bodies;if(!i&&!t.has(r.id))return!e.positionUnknown;if(t.has(r.id)||n.bodies.hostReadVersion++,t.set(r.id,performance.now()),i)return!1}else i&&(r.objectType===W.MOON?OT(e,t,n):!n.bodies.bodiesById.has(r.id)&&!un(e)&&DT(e,t,n));return!e.positionUnknown}function AT(e,t){if(t===0)return console.warn(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.`),e;if(t===2||t===1){let n=e.getIndex();if(n===null){let t=[],r=e.getAttribute(`position`);if(r!==void 0){for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}else return console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.`),e}let r=n.count-2,i=[];if(t===2)for(let e=1;e<=r;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==r&&console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.`);let a=e.clone();return a.setIndex(i),a.clearGroups(),a}else return console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:`,t),e}function jT(e){let t=new Map,n=new Map,r=e.clone();return MT(e,r,function(e,r){t.set(r,e),n.set(e,r)}),r.traverse(function(e){if(!e.isSkinnedMesh)return;let r=e,i=t.get(e),a=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=a.map(function(e){return n.get(e)}),r.bind(r.skeleton,r.bindMatrix)}),r}function MT(e,t,n){n(e,t);for(let r=0;r<e.children.length;r++)MT(e.children[r],t.children[r],n)}var NT=class extends Hu{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new BT(e)}),this.register(function(e){return new VT(e)}),this.register(function(e){return new XT(e)}),this.register(function(e){return new ZT(e)}),this.register(function(e){return new QT(e)}),this.register(function(e){return new UT(e)}),this.register(function(e){return new WT(e)}),this.register(function(e){return new GT(e)}),this.register(function(e){return new KT(e)}),this.register(function(e){return new zT(e)}),this.register(function(e){return new qT(e)}),this.register(function(e){return new HT(e)}),this.register(function(e){return new YT(e)}),this.register(function(e){return new JT(e)}),this.register(function(e){return new LT(e)}),this.register(function(e){return new $T(e,IT.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new $T(e,IT.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new eE(e)})}load(e,t,n,r){let i=this,a;if(this.resourcePath!==``)a=this.resourcePath;else if(this.path!==``){let t=gd.extractUrlBase(e);a=gd.resolveURL(t,this.path)}else a=gd.extractUrlBase(e);this.manager.itemStart(e);let o=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},s=new Gu(this.manager);s.setPath(this.path),s.setResponseType(`arraybuffer`),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(n){try{i.parse(n,a,function(n){t(n),i.manager.itemEnd(e)},o)}catch(e){o(e)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i,a={},o={},s=new TextDecoder;if(typeof e==`string`)i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(s.decode(new Uint8Array(e,0,4))===tE){try{a[IT.KHR_BINARY_GLTF]=new iE(e)}catch(e){r&&r(e);return}i=JSON.parse(a[IT.KHR_BINARY_GLTF].content)}else i=JSON.parse(s.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){r&&r(Error(`THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.`));return}let c=new AE(i,{path:t||this.resourcePath||``,crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){let t=this.pluginCallbacks[e](c);t.name||console.error(`THREE.GLTFLoader: Invalid plugin found: missing name`),o[t.name]=t,a[t.name]=!0}if(i.extensionsUsed)for(let e=0;e<i.extensionsUsed.length;++e){let t=i.extensionsUsed[e],n=i.extensionsRequired||[];switch(t){case IT.KHR_MATERIALS_UNLIT:a[t]=new RT;break;case IT.KHR_DRACO_MESH_COMPRESSION:a[t]=new aE(i,this.dracoLoader);break;case IT.KHR_TEXTURE_TRANSFORM:a[t]=new oE;break;case IT.KHR_MESH_QUANTIZATION:a[t]=new sE;break;default:n.indexOf(t)>=0&&o[t]===void 0&&console.warn(`THREE.GLTFLoader: Unknown extension "`+t+`".`)}}c.setExtensions(a),c.setPlugins(o),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}};function PT(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function FT(e,t,n){let r=e.json.materials[t];return r.extensions&&r.extensions[n]?r.extensions[n]:null}var IT={KHR_BINARY_GLTF:`KHR_binary_glTF`,KHR_DRACO_MESH_COMPRESSION:`KHR_draco_mesh_compression`,KHR_LIGHTS_PUNCTUAL:`KHR_lights_punctual`,KHR_MATERIALS_CLEARCOAT:`KHR_materials_clearcoat`,KHR_MATERIALS_DISPERSION:`KHR_materials_dispersion`,KHR_MATERIALS_IOR:`KHR_materials_ior`,KHR_MATERIALS_SHEEN:`KHR_materials_sheen`,KHR_MATERIALS_SPECULAR:`KHR_materials_specular`,KHR_MATERIALS_TRANSMISSION:`KHR_materials_transmission`,KHR_MATERIALS_IRIDESCENCE:`KHR_materials_iridescence`,KHR_MATERIALS_ANISOTROPY:`KHR_materials_anisotropy`,KHR_MATERIALS_UNLIT:`KHR_materials_unlit`,KHR_MATERIALS_VOLUME:`KHR_materials_volume`,KHR_TEXTURE_BASISU:`KHR_texture_basisu`,KHR_TEXTURE_TRANSFORM:`KHR_texture_transform`,KHR_MESH_QUANTIZATION:`KHR_mesh_quantization`,KHR_MATERIALS_EMISSIVE_STRENGTH:`KHR_materials_emissive_strength`,EXT_MATERIALS_BUMP:`EXT_materials_bump`,EXT_TEXTURE_WEBP:`EXT_texture_webp`,EXT_TEXTURE_AVIF:`EXT_texture_avif`,EXT_MESHOPT_COMPRESSION:`EXT_meshopt_compression`,KHR_MESHOPT_COMPRESSION:`KHR_meshopt_compression`,EXT_MESH_GPU_INSTANCING:`EXT_mesh_gpu_instancing`},LT=class{constructor(e){this.parser=e,this.name=IT.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n=`light:`+e,r=t.cache.get(n);if(r)return r;let i=t.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e],o,s=new X(16777215);a.color!==void 0&&s.setRGB(a.color[0],a.color[1],a.color[2],Zr);let c=a.range===void 0?0:a.range;switch(a.type){case`directional`:o=new md(s),o.target.position.set(0,0,-1),o.add(o.target);break;case`point`:o=new dd(s),o.distance=c;break;case`spot`:o=new ld(s),o.distance=c,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle===void 0?0:a.spot.innerConeAngle,a.spot.outerConeAngle=a.spot.outerConeAngle===void 0?Math.PI/4:a.spot.outerConeAngle,o.angle=a.spot.outerConeAngle,o.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw Error(`THREE.GLTFLoader: Unexpected light type: `+a.type)}return o.position.set(0,0,0),SE(o,a),a.intensity!==void 0&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||`light_`+e),r=Promise.resolve(o),t.cache.add(n,r),r}getDependency(e,t){if(e===`light`)return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return i===void 0?null:this._loadLight(i).then(function(e){return n._getNodeRef(t.cache,i,e)})}},RT=class{constructor(){this.name=IT.KHR_MATERIALS_UNLIT}getMaterialType(){return vs}extendParams(e,t,n){let r=[];e.color=new X(1,1,1),e.opacity=1;let i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){let t=i.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],Zr),e.opacity=t[3]}i.baseColorTexture!==void 0&&r.push(n.assignTexture(e,`map`,i.baseColorTexture,Xr))}return Promise.all(r)}},zT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},BT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&r.push(this.parser.assignTexture(t,`clearcoatMap`,n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`clearcoatRoughnessMap`,n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(r.push(this.parser.assignTexture(t,`clearcoatNormalMap`,n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){let e=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new q(e,e)}return Promise.all(r)}},VT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_DISPERSION}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion===void 0?0:n.dispersion),Promise.resolve()}},HT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceMap`,n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceThicknessMap`,n.iridescenceThicknessTexture)),Promise.all(r)}},UT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_SHEEN}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(t.sheenColor=new X(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let e=n.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],Zr)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenColorMap`,n.sheenColorTexture,Xr)),n.sheenRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenRoughnessMap`,n.sheenRoughnessTexture)),Promise.all(r)}},WT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&r.push(this.parser.assignTexture(t,`transmissionMap`,n.transmissionTexture)),Promise.all(r)}},GT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_VOLUME}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.thickness=n.thicknessFactor===void 0?0:n.thicknessFactor,n.thicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`thicknessMap`,n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;let i=n.attenuationColor||[1,1,1];return t.attenuationColor=new X().setRGB(i[0],i[1],i[2],Zr),Promise.all(r)}},KT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_IOR}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);return n===null||(t.ior=n.ior===void 0?1.5:n.ior),Promise.resolve()}},qT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_SPECULAR}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.specularIntensity=n.specularFactor===void 0?1:n.specularFactor,n.specularTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularIntensityMap`,n.specularTexture));let i=n.specularColorFactor||[1,1,1];return t.specularColor=new X().setRGB(i[0],i[1],i[2],Zr),n.specularColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularColorMap`,n.specularColorTexture,Xr)),Promise.all(r)}},JT=class{constructor(e){this.parser=e,this.name=IT.EXT_MATERIALS_BUMP}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return t.bumpScale=n.bumpFactor===void 0?1:n.bumpFactor,n.bumpTexture!==void 0&&r.push(this.parser.assignTexture(t,`bumpMap`,n.bumpTexture)),Promise.all(r)}},YT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&r.push(this.parser.assignTexture(t,`anisotropyMap`,n.anisotropyTexture)),Promise.all(r)}},XT=class{constructor(e){this.parser=e,this.name=IT.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let i=r.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures`);return null}return t.loadTextureImage(e,i.source,a)}},ZT=class{constructor(e){this.parser=e,this.name=IT.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},QT=class{constructor(e){this.parser=e,this.name=IT.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},$T=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],r=this.parser.getDependency(`buffer`,e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files`);return null}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,a=e.count,o=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,o,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(a*o);return i.decodeGltfBuffer(new Uint8Array(t),a,o,s,e.mode,e.filter),t})})}else return null}},eE=class{constructor(e){this.name=IT.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==dE.TRIANGLES&&e.mode!==dE.TRIANGLE_STRIP&&e.mode!==dE.TRIANGLE_FAN&&e.mode!==void 0)return null;let i=n.extensions[this.name].attributes,a=[],o={};for(let e in i)a.push(this.parser.getDependency(`accessor`,i[e]).then(t=>(o[e]=t,o[e])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new Y,n=new J,a=new Hi,s=new J(1,1,1),c=new nc(e.geometry,e.material,r);for(let e=0;e<r;e++)o.TRANSLATION&&n.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&a.fromBufferAttribute(o.ROTATION,e),o.SCALE&&s.fromBufferAttribute(o.SCALE,e),c.setMatrixAt(e,t.compose(n,a,s));for(let t in o)if(t===`_COLOR_0`){let e=o[t];c.instanceColor=new Js(e.array,e.itemSize,e.normalized)}else t!==`TRANSLATION`&&t!==`ROTATION`&&t!==`SCALE`&&e.geometry.setAttribute(t,o[t]);Ra.prototype.copy.call(c,e),this.parser.assignFinalMaterial(c),i.push(c)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}},tE=`glTF`,nE=12,rE={JSON:1313821514,BIN:5130562},iE=class{constructor(e){this.name=IT.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,nE),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==tE)throw Error(`THREE.GLTFLoader: Unsupported glTF-Binary header.`);if(this.header.version<2)throw Error(`THREE.GLTFLoader: Legacy binary file detected.`);let r=this.header.length-nE,i=new DataView(e,nE),a=0;for(;a<r;){let t=i.getUint32(a,!0);a+=4;let r=i.getUint32(a,!0);if(a+=4,r===rE.JSON){let r=new Uint8Array(e,nE+a,t);this.content=n.decode(r)}else if(r===rE.BIN){let n=nE+a;this.body=e.slice(n,n+t)}a+=t}if(this.content===null)throw Error(`THREE.GLTFLoader: JSON content not found.`)}},aE=class{constructor(e,t){if(!t)throw Error(`THREE.GLTFLoader: No DRACOLoader instance provided.`);this.name=IT.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},s={},c={};for(let e in a){let t=gE[e]||e.toLowerCase();o[t]=a[e]}for(let t in e.attributes){let r=gE[t]||t.toLowerCase();if(a[t]!==void 0){let i=n.accessors[e.attributes[t]];c[r]=fE[i.componentType].name,s[r]=i.normalized===!0}}return t.getDependency(`bufferView`,i).then(function(e){return new Promise(function(t,n){r.decodeDracoFile(e,function(e){for(let t in e.attributes){let n=e.attributes[t],r=s[t];r!==void 0&&(n.normalized=r)}t(e)},o,c,Zr,n)})})}},oE=class{constructor(){this.name=IT.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0?e:(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e)}},sE=class{constructor(){this.name=IT.KHR_MESH_QUANTIZATION}},cE=class extends Cu{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[i+e];return t}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=o*2,c=o*3,l=r-t,u=(n-t)/l,d=u*u,f=d*u,p=e*c,m=p-c,h=-2*f+3*d,g=f-d,_=1-h,v=g-d+u;for(let e=0;e!==o;e++){let t=a[m+e+o],n=a[m+e+s]*l,r=a[p+e+o],c=a[p+e]*l;i[e]=_*t+v*n+h*r+g*c}return i}},lE=new Hi,uE=class extends cE{interpolate_(e,t,n,r){let i=super.interpolate_(e,t,n,r);return lE.fromArray(i).normalize().toArray(i),i}},dE={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},fE={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},pE={9728:An,9729:Nn,9984:jn,9985:Pn,9986:Mn,9987:Fn},mE={33071:On,33648:kn,10497:Dn},hE={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},gE={POSITION:`position`,NORMAL:`normal`,TANGENT:`tangent`,TEXCOORD_0:`uv`,TEXCOORD_1:`uv1`,TEXCOORD_2:`uv2`,TEXCOORD_3:`uv3`,COLOR_0:`color`,WEIGHTS_0:`skinWeight`,JOINTS_0:`skinIndex`},_E={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`},vE={CUBICSPLINE:void 0,LINEAR:Hr,STEP:Vr},yE={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`};function bE(e){return e.DefaultMaterial===void 0&&(e.DefaultMaterial=new mu({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function xE(e,t,n){for(let r in n.extensions)e[r]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function SE(e,t){t.extras!==void 0&&(typeof t.extras==`object`?Object.assign(e.userData,t.extras):console.warn(`THREE.GLTFLoader: Ignoring primitive type .extras, `+t.extras))}function CE(e,t,n){let r=!1,i=!1,a=!1;for(let e=0,n=t.length;e<n;e++){let n=t[e];if(n.POSITION!==void 0&&(r=!0),n.NORMAL!==void 0&&(i=!0),n.COLOR_0!==void 0&&(a=!0),r&&i&&a)break}if(!r&&!i&&!a)return Promise.resolve(e);let o=[],s=[],c=[];for(let l=0,u=t.length;l<u;l++){let u=t[l];if(r){let t=u.POSITION===void 0?e.attributes.position:n.getDependency(`accessor`,u.POSITION);o.push(t)}if(i){let t=u.NORMAL===void 0?e.attributes.normal:n.getDependency(`accessor`,u.NORMAL);s.push(t)}if(a){let t=u.COLOR_0===void 0?e.attributes.color:n.getDependency(`accessor`,u.COLOR_0);c.push(t)}}return Promise.all([Promise.all(o),Promise.all(s),Promise.all(c)]).then(function(t){let n=t[0],o=t[1],s=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=o),a&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e})}function wE(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn(`THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.`)}}function TE(e){let t,n=e.extensions&&e.extensions[IT.KHR_DRACO_MESH_COMPRESSION];if(t=n?`draco:`+n.bufferView+`:`+n.indices+`:`+EE(n.attributes):e.indices+`:`+EE(e.attributes)+`:`+e.mode,e.targets!==void 0)for(let n=0,r=e.targets.length;n<r;n++)t+=`:`+EE(e.targets[n]);return t}function EE(e){let t=``,n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+`:`+e[n[r]]+`;`;return t}function DE(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw Error(`THREE.GLTFLoader: Unsupported normalized accessor component type.`)}}function OE(e){return e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0?`image/jpeg`:e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?`image/webp`:e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0?`image/ktx2`:`image/png`}var kE=new Y,AE=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new PT,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,i=!1,a=-1;if(typeof navigator<`u`&&navigator.userAgent!==void 0){let e=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(e)===!0;let t=e.match(/Version\/(\d+)/);r=n&&t?parseInt(t[1],10):-1,i=e.indexOf(`Firefox`)>-1,a=i?e.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>`u`||n&&r<17||i&&a<98?this.textureLoader=new Ju(this.options.manager):this.textureLoader=new vd(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Gu(this.options.manager),this.fileLoader.setResponseType(`arraybuffer`),this.options.crossOrigin===`use-credentials`&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies(`scene`),n.getDependencies(`animation`),n.getDependencies(`camera`)])}).then(function(t){let a={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return xE(i,a,r),SE(a,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(a)})).then(function(){for(let e of a.scenes)e.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){let r=e[t];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let r=n.clone(),i=(e,t)=>{let n=this.associations.get(e);n!=null&&this.associations.set(t,n);for(let[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+=`_instance_`+ e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let r=e(t[n]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let r=0;r<t.length;r++){let i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){let n=e+`:`+t,r=this.cache.get(n);if(!r){switch(e){case`scene`:r=this.loadScene(t);break;case`node`:r=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case`mesh`:r=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case`accessor`:r=this.loadAccessor(t);break;case`bufferView`:r=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case`buffer`:r=this.loadBuffer(t);break;case`material`:r=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case`texture`:r=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case`skin`:r=this.loadSkin(t);break;case`animation`:r=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case`camera`:r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!r)throw Error(`Unknown type: `+e);break}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,r=this.json[e+(e===`mesh`?`es`:`s`)]||[];t=Promise.all(r.map(function(t,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!==`arraybuffer`)throw Error(`THREE.GLTFLoader: `+t.type+` buffer type is not supported.`);if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[IT.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(e,i){n.load(gd.resolveURL(t.uri,r.path),e,void 0,function(){i(Error(`THREE.GLTFLoader: Failed to load buffer "`+t.uri+`".`))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency(`buffer`,t.buffer).then(function(e){let n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)})}loadAccessor(e){let t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){let e=hE[r.type],t=fE[r.componentType],n=r.normalized===!0,i=new t(r.count*e);return Promise.resolve(new Do(i,e,n))}let i=[];return r.bufferView===void 0?i.push(null):i.push(this.getDependency(`bufferView`,r.bufferView)),r.sparse!==void 0&&(i.push(this.getDependency(`bufferView`,r.sparse.indices.bufferView)),i.push(this.getDependency(`bufferView`,r.sparse.values.bufferView))),Promise.all(i).then(function(e){let i=e[0],a=hE[r.type],o=fE[r.componentType],s=o.BYTES_PER_ELEMENT,c=s*a,l=r.byteOffset||0,u=r.bufferView===void 0?void 0:n.bufferViews[r.bufferView].byteStride,d=r.normalized===!0,f,p;if(u&&u!==c){let e=Math.floor(l/u),n=`InterleavedBuffer:`+r.bufferView+`:`+r.componentType+`:`+e+`:`+r.count,c=t.cache.get(n);c||(f=new o(i,e*u,r.count*u/s),c=new Uo(f,u/s),t.cache.add(n,c)),p=new Go(c,a,l%u/s,d)}else f=i===null?new o(r.count*a):new o(i,l,r.count*a),p=new Do(f,a,d);if(r.sparse!==void 0){let t=hE.SCALAR,n=fE[r.sparse.indices.componentType],s=r.sparse.indices.byteOffset||0,c=r.sparse.values.byteOffset||0,l=new n(e[1],s,r.sparse.count*t),u=new o(e[2],c,r.sparse.count*a);i!==null&&(p=new Do(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let e=0,t=l.length;e<t;e++){let t=l[e];if(p.setX(t,u[e*a]),a>=2&&p.setY(t,u[e*a+1]),a>=3&&p.setZ(t,u[e*a+2]),a>=4&&p.setW(t,u[e*a+3]),a>=5)throw Error(`THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.`)}p.normalized=d}return p})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],a=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);e!==null&&(a=e)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let r=this,i=this.json,a=i.textures[e],o=i.images[t],s=(o.uri||o.bufferView)+`:`+a.sampler;if(this.textureCache[s])return this.textureCache[s];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=a.name||o.name||``,t.name===``&&typeof o.uri==`string`&&o.uri.startsWith(`data:image/`)===!1&&(t.name=o.uri);let n=(i.samplers||{})[a.sampler]||{};return t.magFilter=pE[n.magFilter]||1006,t.minFilter=pE[n.minFilter]||1008,t.wrapS=mE[n.wrapS]||1e3,t.wrapT=mE[n.wrapT]||1e3,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==1003&&t.minFilter!==1006,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=c,c}loadImageSource(e,t){let n=this,r=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(e=>e.clone());let a=r.images[e],o=self.URL||self.webkitURL,s=a.uri||``,c=!1;if(a.bufferView!==void 0)s=n.getDependency(`bufferView`,a.bufferView).then(function(e){c=!0;let t=new Blob([e],{type:a.mimeType});return s=o.createObjectURL(t),s});else if(a.uri===void 0)throw Error(`THREE.GLTFLoader: Image `+e+` is missing URI and bufferView`);let l=Promise.resolve(s).then(function(e){return new Promise(function(n,r){let a=n;t.isImageBitmapLoader===!0&&(a=function(e){let t=new oa(e);t.needsUpdate=!0,n(t)}),t.load(gd.resolveURL(e,i.path),a,void 0,r)})}).then(function(e){return c===!0&&o.revokeObjectURL(s),SE(e,a),e.userData.mimeType=a.mimeType||OE(a.uri),e}).catch(function(e){throw console.error(`THREE.GLTFLoader: Couldn't load texture`,s),e});return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){let i=this;return this.getDependency(`texture`,n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),i.extensions[IT.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[IT.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[IT.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let e=`PointsMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new Tc,qo.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e=`LineBasicMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new dc,qo.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||a){let e=`ClonedMaterial:`+n.uuid+`:`;r&&(e+=`derivative-tangents:`),i&&(e+=`vertex-colors:`),a&&(e+=`flat-shading:`);let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return mu}loadMaterial(e){let t=this,n=this.json,r=this.extensions,i=n.materials[e],a,o={},s=i.extensions||{},c=[];if(s[IT.KHR_MATERIALS_UNLIT]){let e=r[IT.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),c.push(e.extendParams(o,i,t))}else{let n=i.pbrMetallicRoughness||{};if(o.color=new X(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],Zr),o.opacity=e[3]}n.baseColorTexture!==void 0&&c.push(t.assignTexture(o,`map`,n.baseColorTexture,Xr)),o.metalness=n.metallicFactor===void 0?1:n.metallicFactor,o.roughness=n.roughnessFactor===void 0?1:n.roughnessFactor,n.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,`metalnessMap`,n.metallicRoughnessTexture)),c.push(t.assignTexture(o,`roughnessMap`,n.metallicRoughnessTexture))),a=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)})))}i.doubleSided===!0&&(o.side=2);let l=i.alphaMode||yE.OPAQUE;if(l===yE.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,l===yE.MASK&&(o.alphaTest=i.alphaCutoff===void 0?.5:i.alphaCutoff)),i.normalTexture!==void 0&&a!==vs&&(c.push(t.assignTexture(o,`normalMap`,i.normalTexture)),o.normalScale=new q(1,1),i.normalTexture.scale!==void 0)){let e=i.normalTexture.scale;o.normalScale.set(e,e)}if(i.occlusionTexture!==void 0&&a!==vs&&(c.push(t.assignTexture(o,`aoMap`,i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&a!==vs){let e=i.emissiveFactor;o.emissive=new X().setRGB(e[0],e[1],e[2],Zr)}return i.emissiveTexture!==void 0&&a!==vs&&c.push(t.assignTexture(o,`emissiveMap`,i.emissiveTexture,Xr)),Promise.all(c).then(function(){let n=new a(o);return i.name&&(n.name=i.name),SE(n,i),t.associations.set(n,{materials:e}),i.extensions&&xE(r,n,i),n})}createUniqueName(e){let t=Id.sanitizeNodeName(e||``);return t in this.nodeNamesUsed?t+`_`+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[IT.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return ME(n,e,t)})}let a=[];for(let n=0,o=e.length;n<o;n++){let o=e[n],s=TE(o),c=r[s];if(c)a.push(c.promise);else{let e;e=o.extensions&&o.extensions[IT.KHR_DRACO_MESH_COMPRESSION]?i(o):ME(new Ho,o,t),r[s]={primitive:o,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){let t=this,n=this.json,r=this.extensions,i=n.meshes[e],a=i.primitives,o=[];for(let e=0,t=a.length;e<t;e++){let t=a[e].material===void 0?bE(this.cache):this.getDependency(`material`,a[e].material);o.push(t)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(n){let o=n.slice(0,n.length-1),s=n[n.length-1],c=[];for(let n=0,l=s.length;n<l;n++){let l=s[n],u=a[n],d,f=o[n];if(u.mode===dE.TRIANGLES||u.mode===dE.TRIANGLE_STRIP||u.mode===dE.TRIANGLE_FAN||u.mode===void 0)d=i.isSkinnedMesh===!0?new Hs(l,f):new As(l,f),d.isSkinnedMesh===!0&&d.normalizeSkinWeights(),u.mode===dE.TRIANGLE_STRIP?d.geometry=AT(d.geometry,1):u.mode===dE.TRIANGLE_FAN&&(d.geometry=AT(d.geometry,2));else if(u.mode===dE.LINES)d=new Cc(l,f);else if(u.mode===dE.LINE_STRIP)d=new yc(l,f);else if(u.mode===dE.LINE_LOOP)d=new wc(l,f);else if(u.mode===dE.POINTS)d=new Ac(l,f);else throw Error(`THREE.GLTFLoader: Primitive mode unsupported: `+u.mode);Object.keys(d.geometry.morphAttributes).length>0&&wE(d,i),d.name=t.createUniqueName(i.name||`mesh_`+e),SE(d,i),u.extensions&&xE(r,d,u),t.assignFinalMaterial(d),c.push(d)}for(let n=0,r=c.length;n<r;n++)t.associations.set(c[n],{meshes:e,primitives:n});if(c.length===1)return i.extensions&&xE(r,c[0],i),c[0];let l=new za;i.extensions&&xE(r,l,i),t.associations.set(l,{meshes:e});for(let e=0,t=c.length;e<t;e++)l.add(c[e]);return l})}loadCamera(e){let t,n=this.json.cameras[e],r=n[n.type];if(!r){console.warn(`THREE.GLTFLoader: Missing camera parameters.`);return}return n.type===`perspective`?t=new sd(Vi.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type===`orthographic`&&(t=new fd(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),SE(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(this._loadNodeShallow(t.joints[e]));return t.inverseBindMatrices===void 0?n.push(null):n.push(this.getDependency(`accessor`,t.inverseBindMatrices)),Promise.all(n).then(function(e){let n=e.pop(),r=e,i=[],a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e];if(o){i.push(o);let t=new Y;n!==null&&t.fromArray(n.array,e*16),a.push(t)}else console.warn(`THREE.GLTFLoader: Joint "%s" could not be found.`,t.joints[e])}return new qs(i,a)})}loadAnimation(e){let t=this.json,n=this,r=t.animations[e],i=r.name?r.name:`animation_`+e,a=[],o=[],s=[],c=[],l=[];for(let e=0,t=r.channels.length;e<t;e++){let t=r.channels[e],n=r.samplers[t.sampler],i=t.target,u=i.node,d=r.parameters===void 0?n.input:r.parameters[n.input],f=r.parameters===void 0?n.output:r.parameters[n.output];i.node!==void 0&&(a.push(this.getDependency(`node`,u)),o.push(this.getDependency(`accessor`,d)),s.push(this.getDependency(`accessor`,f)),c.push(n),l.push(i))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(s),Promise.all(c),Promise.all(l)]).then(function(e){let t=e[0],a=e[1],o=e[2],s=e[3],c=e[4],l=[];for(let e=0,r=t.length;e<r;e++){let r=t[e],i=a[e],u=o[e],d=s[e],f=c[e];if(r===void 0)continue;r.updateMatrix&&r.updateMatrix();let p=n._createAnimationTracks(r,i,u,d,f);if(p)for(let e=0;e<p.length;e++)l.push(p[e])}let u=new Iu(i,void 0,l);return SE(u,r),u})}createNodeMesh(e){let t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency(`mesh`,r.mesh).then(function(e){let t=n._getNodeRef(n.meshCache,r.mesh,e);return r.weights!==void 0&&t.traverse(function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]}),t})}loadNode(e){let t=this.json,n=this,r=t.nodes[e],i=n._loadNodeShallow(e),a=[],o=r.children||[];for(let e=0,t=o.length;e<t;e++)a.push(n.getDependency(`node`,o[e]));let s=r.skin===void 0?Promise.resolve(null):n.getDependency(`skin`,r.skin);return Promise.all([i,Promise.all(a),s]).then(function(e){let t=e[0],n=e[1],r=e[2];r!==null&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(r,kE)});for(let e=0,r=n.length;e<r;e++)t.add(n[e]);if(t.userData.pivot!==void 0&&n.length>0){let e=t.userData.pivot,r=n[0];t.pivot=new J().fromArray(e),t.position.x-=e[0],t.position.y-=e[1],t.position.z-=e[2],r.position.set(0,0,0),delete t.userData.pivot}return t})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let i=t.nodes[e],a=i.name?r.createUniqueName(i.name):``,o=[],s=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return s&&o.push(s),i.camera!==void 0&&o.push(r.getDependency(`camera`,i.camera).then(function(e){return r._getNodeRef(r.cameraCache,i.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){o.push(e)}),this.nodeCache[e]=Promise.all(o).then(function(t){let o;if(o=i.isBone===!0?new Us:t.length>1?new za:t.length===1?t[0]:new Ra,o!==t[0])for(let e=0,n=t.length;e<n;e++)o.add(t[e]);if(i.name&&(o.userData.name=i.name,o.name=a),SE(o,i),i.extensions&&xE(n,o,i),i.matrix!==void 0){let e=new Y;e.fromArray(i.matrix),o.applyMatrix4(e)}else i.translation!==void 0&&o.position.fromArray(i.translation),i.rotation!==void 0&&o.quaternion.fromArray(i.rotation),i.scale!==void 0&&o.scale.fromArray(i.scale);if(!r.associations.has(o))r.associations.set(o,{});else if(i.mesh!==void 0&&r.meshCache.refs[i.mesh]>1){let e=r.associations.get(o);r.associations.set(o,{...e})}return r.associations.get(o).nodes=e,o}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,i=new za;n.name&&(i.name=r.createUniqueName(n.name)),SE(i,n),n.extensions&&xE(t,i,n);let a=n.nodes||[],o=[];for(let e=0,t=a.length;e<t;e++)o.push(r.getDependency(`node`,a[e]));return Promise.all(o).then(function(e){for(let t=0,n=e.length;t<n;t++){let n=e[t];n.parent===null?i.add(n):i.add(jT(n))}return r.associations=(e=>{let t=new Map;for(let[e,n]of r.associations)(e instanceof qo||e instanceof oa)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);n!=null&&t.set(e,n)}),t})(i),i})}_createAnimationTracks(e,t,n,r,i){let a=[],o=e.name?e.name:e.uuid,s=[];_E[i.path]===_E.weights?e.traverse(function(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}):s.push(o);let c;switch(_E[i.path]){case _E.weights:c=ju;break;case _E.rotation:c=Nu;break;case _E.translation:case _E.scale:c=Fu;break;default:switch(n.itemSize){case 1:c=ju;break;default:c=Fu;break}break}let l=r.interpolation===void 0?Hr:vE[r.interpolation],u=this._getArrayFromAccessor(n);for(let e=0,n=s.length;e<n;e++){let n=new c(s[e]+`.`+_E[i.path],t.array,u,l);r.interpolation===`CUBICSPLINE`&&this._createCubicSplineTrackInterpolant(n),a.push(n)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let e=DE(t.constructor),n=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof Nu?uE:cE)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function jE(e,t,n){let r=t.attributes,i=new co;if(r.POSITION!==void 0){let e=n.json.accessors[r.POSITION],t=e.min,a=e.max;if(t!==void 0&&a!==void 0){if(i.set(new J(t[0],t[1],t[2]),new J(a[0],a[1],a[2])),e.normalized){let t=DE(fE[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}else{console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`);return}}else return;let a=t.targets;if(a!==void 0){let e=new J,t=new J;for(let r=0,i=a.length;r<i;r++){let i=a[r];if(i.POSITION!==void 0){let r=n.json.accessors[i.POSITION],a=r.min,o=r.max;if(a!==void 0&&o!==void 0){if(t.setX(Math.max(Math.abs(a[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(a[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(a[2]),Math.abs(o[2]))),r.normalized){let e=DE(fE[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`)}}i.expandByVector(e)}e.boundingBox=i;let o=new Po;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}function ME(e,t,n){let r=t.attributes,i=[];function a(t,r){return n.getDependency(`accessor`,t).then(function(t){e.setAttribute(r,t)})}for(let t in r){let n=gE[t]||t.toLowerCase();n in e.attributes||i.push(a(r[t],n))}if(t.indices!==void 0&&!e.index){let r=n.getDependency(`accessor`,t.indices).then(function(t){e.setIndex(t)});i.push(r)}return Xi.workingColorSpace!==`srgb-linear`&&`COLOR_0`in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Xi.workingColorSpace}" not supported.`),SE(e,t),jE(e,t,n),Promise.all(i).then(function(){return t.targets===void 0?e:CE(e,t.targets,n)})}var NE=(function(){var e=`b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuec:W:Odkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq;lZkdbk;jYi5ud9:du8Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCabaOad2fhXaAcethQaxaDfhiaOaeaoaeao6E9RhLalcl4cifcd4hKazcj;cbfaAfhYcbh8AazcjdfhEaHh3incbhodnawTmbaxa8Acd4fRbbhokaocFeGh5cbh8Eazcj;cbfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcj;cbfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcj;cbfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaK6mva8FaKfhidnaCTmbaPai9RcK6mbaocdtc:q1jjbfcj1jjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bbarcwf9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfag9c8F1:NghcKtc8F91aicdfa8J9c8N1:Nfg8KRbbG86bbarcVfcba8KahcjeGcr4fghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fag9c8F1:NgicKtc8F91aha8J9c8N1:NfghRbbG86bbarc96fcbahaicjeGcr4fgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbb83bbarcwfaicwf8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasa8Acd4fRbbgociGPlbedrbkaATmdaza8Afh8Fazcj;cbfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeaza8Afhaazcj;cbfhhcbhoceh8EaYh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaLaocefgofmbka8FaQfh8FcdhoaacdfhaahaQfhha8EceGhlcbh8EalmbxdkkaATmbcbaocl49Rh8Eaza8AfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaYhainazcj;cbfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E93aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3a8Aclfg8Aad6mbkaXazcjdfaAad2z:jjjjb8AazazcjdfaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaok:XseHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:kjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbaxcefgOavaiaqaDcsGfRbbgscl49RcsGcdtfydbascz6gPEhDavaias9RcsGcdtfydbaOaPfgzascsGgOEhsaOThOdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiaPfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaOfhiazaOfhxxekaxcbalRbbgHEgAaDc;:eSgDfhzaHcsGhCaHcl4hXdndnaHcs0mbazcefhOxekazhOavaiaX9RcsGcdtfydbhzkdndnaCmbaOcefhxxekaOhxavaiaH9RcsGcdtfydbhOkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhAascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaAhDxekaDcefhDkasce4cbasceG9R7amfgmhAkdndnaXcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhzaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkazhsxekascefhskaPce4cbaPceG9R7amfgmhzkdndnaCcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhOaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkaOhlxekalcefhlkaPce4cbaPceG9R7amfgmhOkdndnadcd9hmbabarcetfgDaA87ebaDclfaO87ebaDcdfaz87ebxekabarcdtfgDaABdbaDcwfaOBdbaDclfazBdbkavc;abfaocitfgDazBdbaDaABdlavaicdtfaABdbavc;abfaocefcsGcitfgDaOBdbaDazBdlavaicefgicsGcdtfazBdbavc;abfaocdfcsGcitfgDaABdbaDaOBdlavaiaHcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnaecvfal9nmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk::ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxabaiarcefciGfcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGfgkcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkabaiarcufciGfcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkabakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K1jjbgeabcifc98GfgbBd:K1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;teeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiaeydlBdlaiaeydwBdwaiaeydxBdxaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk:3eedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdxaialBdwaialBdlaialBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk81dbcjwk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:Kwkl8WNbb`,t=`b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuec:q:6dkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:Ctklbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk:183lYud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxavaialfgmar9Rgoad;8qbbcj;abad9Uc;WFbGcjdadca0EhPdndndnadTmbaoadfhscbhzinaeaz9nmdamax9RaD6miabazad2fhHaxaDfhOaPaeaz9RazaPfae6EgAcsfgocl4cifcd4hCavcj;cbfaoc9WGgXcetfhQavcj;cbfaXci2fhLavcj;cbfaXfhKcbhYaoc;ab6h8AincbhodnawTmbaxaYcd4fRbbhokaocFeGhEcbh3avcj;cbfh5indndndndnaEa3cet4ciGgoc9:fPdebdkamaO9RaX6mwavcj;cbfa3aX2faOaX;8qbbaOaAfhOxdkavcj;cbfa3aX2fcbaX;8kbxekamaO9RaC6moaoclVcbawEhraOaCfhocbhidna8Ambamao9Rc;Gb6mbcbhlina5alfhidndndndndndnaOalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaiaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaiczfaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaicafaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngicitc:q1jjbfpbibaic:q:yjjbfRbbgipsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaiaoclffaqc:q:yjjbfRbbfhoxikaic8Wfaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngicitc:q1jjbfpbibaic:q:yjjbfRbbgipsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaiaocwffaqc:q:yjjbfRbbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitc:q1jjbfpbibaic:q:yjjbfRbbgipsaoRbegqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqc:q:yjjbfRbbfhokalc;abfhialcjefaX0meaihlamao9Rc;Fb0mbkkdnaiaX9pmbaici4hlinamao9RcK6mwa5aifhqdndndndndndnaOaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spkbbaaaoclffahc:q:yjjbfRbbfhoxikaqaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spkbbaaaocwffahc:q:yjjbfRbbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpkbbaaaocdffahc:q:yjjbfRbbfhokalcdfhlaiczfgiaX6mbkkaohOaoTmoka5aXfh5a3cefg3cl9hmbkdndndndnawTmbasaYcd4fRbbglciGPlbedwbkaXTmdavcjdfaYfhlavaYfpbdbhgcbhoinalavcj;cbfaofpblbg8JaKaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaQaofpblbg8MaLaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Ecep9Ta8Epxeeeeeeeeeeeeeeeeg8Fp9op9Hp9rg8Eagp9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8LaypmwDKYqk8AExm35Ps8E8Fg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Ug8Fp9Abbbaladfgla8Fa8Ea8Epmlvorlvorlvorlvorp9Ug8Fp9Abbbaladfgla8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9Ug8Fp9Abbbaladfgla8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9AbbbaladfhlaoczfgoaX6mbxikkaXTmeavcjdfaYfhlavaYfpbdbhgcbhoinalavcj;cbfaofpblbg8JaKaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaQaofpblbg8MaLaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Ecep:nea8Epxebebebebebebebebg8Fp9op:bep9rg8Eagp:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8LaypmwDKYqk8AExm35Ps8E8Fg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeg8Fp9Abbbaladfgla8Fa8Ea8Epmlvorlvorlvorlvorp:oeg8Fp9Abbbaladfgla8Fa8Ea8EpmwDqkwDqkwDqkwDqkp:oeg8Fp9Abbbaladfgla8Fa8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9AbbbaladfhlaoczfgoaX6mbxdkkaXTmbcbhocbalcl4gl9Rc8FGhiavcjdfaYfhravaYfpbdbh8Finaravcj;cbfaofpblbggaKaofpblbg8JpmbzeHdOiAlCvXoQrLg8KaQaofpblbg8LaLaofpblbg8MpmbzeHdOiAlCvXoQrLg8NpmbezHdiOAlvCXorQLg8Eaip:Rea8Ealp:Sep9qg8Ea8Fp9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Fa8Ka8NpmwDKYqk8AExm35Ps8E8Fg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Faga8JpmwKDYq8AkEx3m5P8Es8Fgga8La8MpmwKDYq8AkEx3m5P8Es8Fg8JpmbezHdiOAlvCXorQLg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Faga8JpmwDKYqk8AExm35Ps8E8Fg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9AbbbaradfhraoczfgoaX6mbkkaYclfgYad6mbkaHavcjdfaAad2;8qbbavavcjdfaAcufad2fad;8qbbaAazfhzc9:hoaOhxaOmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdaPaeao9RaoaPfae6Eaofgoae6mbkaial9Rhxkcbc99amax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbk:TseHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbaxcefgOavaiaqaDcsGfRbbgscl49RcsGcdtfydbascz6gPEhDavaias9RcsGcdtfydbaOaPfgzascsGgOEhsaOThOdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiaPfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaOfhiazaOfhxxekaxcbalRbbgHEgAaDc;:eSgDfhzaHcsGhCaHcl4hXdndnaHcs0mbazcefhOxekazhOavaiaX9RcsGcdtfydbhzkdndnaCmbaOcefhxxekaOhxavaiaH9RcsGcdtfydbhOkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhAascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaAhDxekaDcefhDkasce4cbasceG9R7amfgmhAkdndnaXcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhzaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkazhsxekascefhskaPce4cbaPceG9R7amfgmhzkdndnaCcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhOaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkaOhlxekalcefhlkaPce4cbaPceG9R7amfgmhOkdndnadcd9hmbabarcetfgDaA87ebaDclfaO87ebaDcdfaz87ebxekabarcdtfgDaABdbaDcwfaOBdbaDclfazBdbkavc;abfaocitfgDazBdbaDaABdlavaicdtfaABdbavc;abfaocefcsGcitfgDaOBdbaDazBdlavaicefgicsGcdtfazBdbavc;abfaocdfcsGcitfgDaABdbaDaOBdlavaiaHcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnaecvfal9nmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:2Pliur97eue978Jjjjjbc8W9Rhiaec98Ghldndnadcl9hmbdnalTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalaeSmeaipxbbbbbbbbbbbbbbbbgqpklbaiabalcdtfgdaeciGglcdtgv;8qbbdnalTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDaqp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkadaiav;8qbbskaipxFubbFubbFubbFubbgxpklbdnalTmbcbhvabhdinadczfgmampbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraipblbaDaopmlvorxmPsCXQL358E8Fp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgPp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;MeawaqawaPp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oaoarpmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgval6mbkkalaeSmbaiczfpxbbbbbbbbbbbbbbbbgopklbaiaopklbaiabalcitfgdaeciGglcitgv;8qbbaiaxpkladnalTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraipblaaDaopmlvorxmPsCXQL358E8Fp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgPp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;MeawaqawaPp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oaoarpmbezHdiOAlvCXorQLp9qpklbkadaiav;8qbbkk:Iwllue97euo978Jjjjjbca9Rhidnaec98GglTmbcbhvabhoinaocKfpx:ji:1S:ji:1S:ji:1S:ji:1SaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkpxibbbibbbibbbibbbp9qgxp;6ep;Negmaxaxp:1ep;7egxaxp;KearaDpmbediwDqkzHOAKY8AEgxczp:Reczp:Sep;6egrarp;Meaxczp:Sep;6egDaDp;Meaqczp:Reczp:Sep;6egqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gxp;KepxFFbbFFbbFFbbFFbbgPp9oamaDp;Meaxp;Keczp:Rep9qgDamarp;Meaxp;KeaPp9oamaqp;Meaxp;Keczp:Rep9qgxpmwDKYqk8AExm35Ps8E8Fgrp5eakclp:RegmpEi:T:j83ibawarp5bampEd:T:j83ibaocwfaDaxpmbezHdiOAlvCXorQLgxp5eampEe:T:j83ibaoaxp5bampEb:T:j83ibaocafhoavclfgval6mbkkdnalaeSmbaiczfpxbbbbbbbbbbbbbbbbgmpklbaiampklbaiabalcitfgoaeciGgvcitgw;8qbbdnavTmbaipx:ji:1S:ji:1S:ji:1S:ji:1SaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkpxibbbibbbibbbibbbp9qgxp;6ep;Negmaxaxp:1ep;7egxaxp;KearaDpmbediwDqkzHOAKY8AEgxczp:Reczp:Sep;6egrarp;Meaxczp:Sep;6egDaDp;Meaqczp:Reczp:Sep;6egqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gxp;KepxFFbbFFbbFFbbFFbbgPp9oamaDp;Meaxp;Keczp:Rep9qgDamarp;Meaxp;KeaPp9oamaqp;Meaxp;Keczp:Rep9qgxpmwDKYqk8AExm35Ps8E8Fgrp5eakclp:RegmpEi:T:j83iKaiarp5bampEd:T:j83izaiaDaxpmbezHdiOAlvCXorQLgxp5eampEe:T:j83iwaiaxp5bampEb:T:j83ibkaoaiaw;8qbbkk;uddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbheabhdinadadpbbbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbadczfhdaeclfgeav6mbkkdnavalSmbaic8WfpxbbbbbbbbbbbbbbbbgopklbaicafaopklbaiczfaopklbaiaopklbaiabavcdtfgdalciGgecdtgv;8qbbdnaeTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepklbkadaiav;8qbbkk:CPvdue97euw97eu8Jjjjjbc8W9Rhiaec98Ghldndnadcl9hmbaipxbbbbbbbbbbbbbbbbgvpklbdnalTmbcbhoabhdinadpbbbhradpxbbuJbbuJbbuJbbuJaipblbarcKp:Tep9qgwcep:Seawp9qgDcdp:SeaDp9qgDclp:SeaDp9qgqp;6ep;NegDarcwp:RecKp:SegkarpxFbbbFbbbFbbbFbbbgxp9ogmp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gPp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oaDamakp:Xearczp:RecKp:Segrp:Uep;6ep;MeaPp;Keaxp9op9qaDamakarp:Uep:Xep;6ep;MeaPp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qaDaqawcep:Rep9oawpxebbbebbbebbbebbbp9op9qp;6ep;MeaPp;KecKp:Rep9qpkbbadczfhdaoclfgoal6mbkkalaeSmeaiavpklaaicafabalcdtfgdaeciGglcdtgo;8qbbaiavpklbdnalTmbaipblahraipxbbuJbbuJbbuJbbuJaipblbarcKp:Tep9qgwcep:Seawp9qgDcdp:SeaDp9qgDclp:SeaDp9qgqp;6ep;NegDarcwp:RecKp:SegkarpxFbbbFbbbFbbbFbbbgxp9ogmp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gPp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oaDamakp:Xearczp:RecKp:Segrp:Uep;6ep;MeaPp;Keaxp9op9qaDamakarp:Uep:Xep;6ep;MeaPp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qaDaqawcep:Rep9oawpxebbbebbbebbbebbbp9op9qp;6ep;MeaPp;KecKp:Rep9qpklakadaicafao;8qbbskaipxbbbbbbbbbbbbbbbbgvpklbdnalTmbcbhoabhdinadczfgspxbFu9hbFu9hbFu9hbFu9hadpbbbgDaspbbbgPpmlvorxmPsCXQL358E8Fgmczp:Teaipblbp9qgrcep:Searp9qgwcdp:Seawp9qgwclp:Seawp9qgwcwp:Seawp9qgqp;6ep;NegwaDaPpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbgPp9ogkaDczp:Segxp:Ueamczp:Reczp:Segmp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gDp;KeaPp9oawakaxamp:Uep:Xep;6ep;MeaDp;Keczp:Rep9qgxawaqarcep:Rep9oarpxebbbebbbebbbebbbp9op9qp;6ep;MeaDp;Keczp:Reawamakp:Uep;6ep;MeaDp;KeaPp9op9qgrpmwDKYqk8AExm35Ps8E8FpkbbadaxarpmbezHdiOAlvCXorQLpkbbadcafhdaoclfgoal6mbkkalaeSmbaiczfpxbbbbbbbbbbbbbbbbgrpklbaiarpklbaiabalcitfgdaeciGglcitgo;8qbbaiavpkladnalTmbaipxbFu9hbFu9hbFu9hbFu9haipblbgDaipblzgPpmlvorxmPsCXQL358E8Fgmczp:Teaipblap9qgrcep:Searp9qgwcdp:Seawp9qgwclp:Seawp9qgwcwp:Seawp9qgqp;6ep;NegwaDaPpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbgPp9ogkaDczp:Segxp:Ueamczp:Reczp:Segmp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gDp;KeaPp9oawakaxamp:Uep:Xep;6ep;MeaDp;Keczp:Rep9qgxawaqarcep:Rep9oarpxebbbebbbebbbebbbp9op9qp;6ep;MeaDp;Keczp:Reawamakp:Uep;6ep;MeaDp;KeaPp9op9qgrpmwDKYqk8AExm35Ps8E8FpklzaiaxarpmbezHdiOAlvCXorQLpklbkadaiao;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz:Dbb`,n=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),r=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=`object`)return{supported:!1};var i=WebAssembly.validate(n)?s(t):s(e),a,o=WebAssembly.instantiate(i,{}).then(function(e){a=e.instance,a.exports.__wasm_call_ctors()});function s(e){for(var t=new Uint8Array(e.length),n=0;n<e.length;++n){var i=e.charCodeAt(n);t[n]=i>96?i-97:i>64?i-39:i+4}for(var a=0,n=0;n<e.length;++n)t[a++]=t[n]<60?r[t[n]]:(t[n]-60)*64+t[++n];return t.buffer.slice(0,a)}function c(e,t,n,r,i,a,o){var s=e.exports.sbrk,c=r+3&-4,l=s(c*i),u=s(a.length),d=new Uint8Array(e.exports.memory.buffer);d.set(a,u);var f=t(l,r,i,u,a.length);if(f==0&&o&&o(l,c,i),n.set(d.subarray(l,l+r*i)),s(l-s(0)),f!=0)throw Error(`Malformed buffer data: `+f)}var l={NONE:``,OCTAHEDRAL:`meshopt_decodeFilterOct`,QUATERNION:`meshopt_decodeFilterQuat`,EXPONENTIAL:`meshopt_decodeFilterExp`,COLOR:`meshopt_decodeFilterColor`},u={ATTRIBUTES:`meshopt_decodeVertexBuffer`,TRIANGLES:`meshopt_decodeIndexBuffer`,INDICES:`meshopt_decodeIndexSequence`},d=[],f=0;function p(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var n=e.data;t.pending-=n.count,t.requests[n.id][n.action](n.value),delete t.requests[n.id]},t}function m(e){for(var t=`self.ready = WebAssembly.instantiate(new Uint8Array([`+new Uint8Array(i)+`]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = `+g.name+`;`+c.toString()+g.toString(),n=new Blob([t],{type:`text/javascript`}),r=URL.createObjectURL(n),a=d.length;a<e;++a)d[a]=p(r);for(var a=e;a<d.length;++a)d[a].object.postMessage({});d.length=e,URL.revokeObjectURL(r)}function h(e,t,n,r,i){for(var a=d[0],o=1;o<d.length;++o)d[o].pending<a.pending&&(a=d[o]);return new Promise(function(o,s){var c=new Uint8Array(n),l=++f;a.pending+=e,a.requests[l]={resolve:o,reject:s},a.object.postMessage({id:l,count:e,size:t,source:c,mode:r,filter:i},[c.buffer])})}function g(e){var t=e.data;if(!t.id)return self.close();self.ready.then(function(e){try{var n=new Uint8Array(t.count*t.size);c(e,e.exports[t.mode],n,t.count,t.size,t.source,e.exports[t.filter]),self.postMessage({id:t.id,count:t.count,action:`resolve`,value:n},[n.buffer])}catch(e){self.postMessage({id:t.id,count:t.count,action:`reject`,value:e})}})}return{ready:o,supported:!0,useWorkers:function(e){m(e)},decodeVertexBuffer:function(e,t,n,r,i){c(a,a.exports.meshopt_decodeVertexBuffer,e,t,n,r,a.exports[l[i]])},decodeIndexBuffer:function(e,t,n,r){c(a,a.exports.meshopt_decodeIndexBuffer,e,t,n,r)},decodeIndexSequence:function(e,t,n,r){c(a,a.exports.meshopt_decodeIndexSequence,e,t,n,r)},decodeGltfBuffer:function(e,t,n,r,i,o){c(a,a.exports[u[i]],e,t,n,r,a.exports[l[o]])},decodeGltfBufferAsync:function(e,t,n,r,i){return d.length>0?h(e,t,n,u[r],l[i]):o.then(function(){var o=new Uint8Array(e*t);return c(a,a.exports[u[r]],o,e,t,n,a.exports[l[i]]),o})}}})(),PE=1230263361,FE=2,IE=16,LE=11,RE=32767,zE=86400;function BE(e){let t=new DataView(e);if(t.getUint32(0,!0)!==PE)throw Error(`attitude: bad file magic (expected ATTI)`);let n=t.getUint16(4,!0);if(n!==FE)throw Error(`attitude: unsupported version ${n}`);let r=t.getFloat64(8,!0),i=Math.floor((e.byteLength-IE)/LE),a=new Float64Array(i),o=new Float32Array(i*4),s=0;for(let e=0;e<i;e++){let n=IE+e*LE;e>0&&(s+=t.getFloat32(n,!0)),a[e]=r+s/zE;let i=t.getUint8(n+4),c=t.getInt16(n+5,!0)/RE,l=t.getInt16(n+7,!0)/RE,u=t.getInt16(n+9,!0)/RE,d=Math.sqrt(Math.max(0,1-c*c-l*l-u*u)),f=e*4,p=0;for(let e=0;e<4;e++)e===i?o[f+e]=d:(o[f+e]=p===0?c:p===1?l:u,p++)}return{times:a,quats:o}}var VE=86400,HE=new Hi().setFromRotationMatrix(new Y().makeBasis(dg(1,0,0,new J),dg(0,1,0,new J),dg(0,0,1,new J))),UE=new Hi,WE=new Hi,GE=new Hi,KE=new J;function qE(e,t,n){let r=t*4;return n.set(e[r+1],e[r+2],e[r+3],e[r])}var JE=class{startJd;endJd;baselines;files;chunks=new Map;inflight=new Set;failed=new Set;constructor(e,t){this.probeId=e,this.startJd=t.files.length?t.files[0].start_jd:0,this.endJd=t.files.length?t.files[t.files.length-1].end_jd:0,this.baselines=t.baselines,this.files=t.files}covers(e){return e>=this.startJd&&e<=this.endJd&&this.files.length>0}orientationAt(e,t){if(!this.covers(e))return!1;let n=this.fileIndexFor(e),r=this.ensure(n);if(!r)return!1;this.ensure(n-1),this.ensure(n+1),this.sampleChunk(e,n,r);let i=this.baselines?.[this.files[n].baseline_index??0];if(i){let{axis:t,rate_rad_s:n,anchor:r,anchor_jd:a}=i,o=(e-a)*VE;KE.set(t[0],t[1],t[2]),GE.setFromAxisAngle(KE,n*o),WE.set(r[1],r[2],r[3],r[0]),GE.multiply(WE),UE.copy(GE.multiply(UE))}return UE.conjugate(),t.copy(HE).multiply(UE),!0}fileIndexFor(e){let t=this.files;if(e<=t[0].start_jd)return 0;let n=0,r=t.length-1;for(;r-n>1;){let i=n+r>>1;t[i].start_jd<=e?n=i:r=i}return t[r].start_jd<=e?r:n}sampleChunk(e,t,n){let{times:r,quats:i}=n,a=r.length;if(e<=r[0]){qE(i,0,UE);return}if(e>=r[a-1]){let n=this.chunks.get(t+1);if(this.files[t+1]?.baseline_index===this.files[t].baseline_index&&n&&n.times.length>0&&n.times[0]>r[a-1]){let t=n.times[0]-r[a-1],o=Math.min(1,(e-r[a-1])/t);qE(i,a-1,UE),qE(n.quats,0,WE),UE.slerpQuaternions(UE,WE,o)}else qE(i,a-1,UE);return}let o=0,s=a-1;for(;s-o>1;){let t=o+s>>1;r[t]<=e?o=t:s=t}let c=r[s]-r[o],l=c>0?(e-r[o])/c:0;qE(i,o,UE),qE(i,s,WE),UE.slerpQuaternions(UE,WE,l)}ensure(e){if(e<0||e>=this.files.length)return;let t=this.chunks.get(e);if(t)return t;this.inflight.has(e)||this.failed.has(e)||(this.inflight.add(e),this.load(e))}async load(e){let t=this.files[e];try{let n=await fetch(`${Kt()}/v1/attitude/${this.probeId}/${t.name}`);if(!n.ok)throw Error(`${n.status}`);let r=new DecompressionStream(`gzip`),i=await new Response(n.body.pipeThrough(r)).arrayBuffer();this.chunks.set(e,BE(i))}catch(n){this.failed.add(e),console.warn(`attitude: chunk ${this.probeId}/${t.name} failed to load:`,n)}finally{this.inflight.delete(e)}}};function YE(e,t){return new JE(e,t)}var XE=[`carrier`,`missing`],ZE=`scene-label__annotation--visible`;function QE(e,t,n){let r=e.labelAnnotations?.[t];if(!r){if(!n||!e.label)return;r=document.createElement(`span`),r.className=`scene-label__annotation`,r.dir=`auto`,r.textContent=n,tD(e,r,t),(e.labelAnnotations??={})[t]=r}else if(n===null){if(!r.classList.contains(ZE))return}else if(r.textContent===n&&r.classList.contains(ZE))return;else r.textContent=n;r.classList.toggle(ZE,n!==null),$E(e)}function $E(e){let t=e.label?.element;if(!t)return;let n=[t.querySelector(`.scene-label__name`)?.textContent||e.body.data.name];for(let t of XE){let r=e.labelAnnotations?.[t];r?.classList.contains(ZE)&&n.push(r.textContent)}let r=n.filter(Boolean).join(`, `);r?t.setAttribute(`aria-label`,r):t.removeAttribute(`aria-label`)}function eD(e){if(!e.labelStack){let t=document.createElement(`span`);t.className=`scene-label__annotations`,e.label.element.appendChild(t),e.labelStack=t}return e.labelStack}function tD(e,t,n){for(let r of XE.slice(XE.indexOf(n)+1)){let n=e.labelAnnotations?.[r];if(n){n.parentElement.insertBefore(t,n);return}}eD(e).appendChild(t)}function nD(e,t){let n=e.userData,r=t??``;if(n.tintBase&&n.tintKey===r)return n.tintBase;let i=sD(e,t);return n.tintBase=i,n.tintKey=r,i}var rD=32,iD=16,aD=.01,oD=.001;function sD(e,t){let n=new X(16777215);if(!t)return n;let r=cD(e);if(r===null||r>aD)return n;let i=new X(t),a=.2126*i.r+.7152*i.g+.0722*i.b;return a<oD?n:new X().setRGB(i.r/a,i.g/a,i.b/a)}function cD(e){let t=e.image;if(!t||!t.width||!t.height)return null;let n=document.createElement(`canvas`);n.width=rD,n.height=iD;let r=n.getContext(`2d`,{willReadFrequently:!0});if(!r)return null;r.drawImage(t,0,0,rD,iD);let i;try{i=r.getImageData(0,0,rD,iD).data}catch{return null}let a=0,o=i.length/4;for(let e=0;e<i.length;e+=4){let t=i[e]/255,n=i[e+1]/255,r=i[e+2]/255;a+=Math.max(t,n,r)-Math.min(t,n,r)}return a/o}var lD=`
|
|
4502
4502
|
#ifdef USE_MAP
|
|
4503
4503
|
vec3 bodyDir = normalize( vBodyDir );
|
|
4504
4504
|
float lon = atan( -bodyDir.z, bodyDir.x );
|
|
@@ -4510,14 +4510,14 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
|
|
|
4510
4510
|
vec4 sampledDiffuseColor = textureGrad( map, euv, seam ? dxB : dxA, seam ? dyB : dyA );
|
|
4511
4511
|
diffuseColor *= sampledDiffuseColor;
|
|
4512
4512
|
#endif
|
|
4513
|
-
`;function
|
|
4513
|
+
`;function uD(e){let t=new mu({color:e,roughness:1,metalness:0});return t.onBeforeCompile=e=>{e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
|
|
4514
4514
|
varying vec3 vBodyDir;`).replace(`#include <begin_vertex>`,`#include <begin_vertex>
|
|
4515
4515
|
vBodyDir = position;`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
|
|
4516
|
-
varying vec3 vBodyDir;`).replace(`#include <map_fragment>`,
|
|
4516
|
+
varying vec3 vBodyDir;`).replace(`#include <map_fragment>`,lD).replace(`#include <envmap_physical_pars_fragment>`,`
|
|
4517
4517
|
#ifdef USE_ENVMAP
|
|
4518
4518
|
vec3 getIBLIrradiance( const in vec3 normal ) { return vec3( 0.0 ); }
|
|
4519
4519
|
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { return vec3( 0.0 ); }
|
|
4520
|
-
#endif`)},MC(t,`shapeModel`),t}function sD(e,t){e.traverse(e=>{if(!(e instanceof As))return;let n=e.material;e.material=t;let r=Array.isArray(n)?n:[n];for(let e of r)e?.dispose()})}function cD(e,t,n,r){e.traverse(e=>{!(e instanceof As)||!(e.material instanceof mu)||(e.material.map=t,t?e.material.color.copy(QE(t,r)):e.material.color.set(n),e.material.needsUpdate=!0)})}function lD(e,t,n){e.map&&e.map!==t&&e.map.dispose(),t.colorSpace=Xr,e.map=t,e.color.copy(QE(t,n)),e.needsUpdate=!0}var uD=new Set([]);function dD(e){return e?.model_name?Vx()&&e.render_quality!==`high`?`low-end-device`:e.displacement&&!uD.has(e.id)?`dem-preferred`:null:`no-bundle`}function fD(e,t,n,r){e.body.orientation=t,n?.credits.registerOrientation({bodyId:e.body.data.id,systemId:r??e.body.data.id,source:t.source,reference:t.reference})}var pD=48,mD=96,hD=pD*mD,gD=1<<24,_D=Math.PI*2;function vD(e){let t=Math.floor((e+1)/2*pD);return Math.min(pD-1,Math.max(0,t))}function yD(e,t){let n=Math.atan2(-t,e);return(Math.floor((n+Math.PI)/_D*mD)%mD+mD)%mD}var bD=new J;function xD(e){let t=e.verts.length/3,n=new Int32Array(t),r=new Float32Array(t*3);for(let i=0;i<t;i++)bD.set(e.verts[i*3],e.verts[i*3+1],e.verts[i*3+2]).normalize(),r[i*3]=bD.x,r[i*3+1]=bD.y,r[i*3+2]=bD.z,n[i]=vD(bD.y)*mD+yD(bD.x,bD.z);return{cells:n,dirs:r}}function SD(e,t){let n=e.geometry.attributes.position,r=new Y().multiplyMatrices(t,e.matrixWorld),i=new Float32Array(n.count*3);for(let e=0;e<n.count;e++)bD.set(n.getX(e),n.getY(e),n.getZ(e)).applyMatrix4(r),i[e*3]=bD.x,i[e*3+1]=bD.y,i[e*3+2]=bD.z;return i}var CD=new J,wD=new J,TD=new J,ED=new J,DD=new J,OD=new J;function kD(e,t,n){return n.set(e[t*3],e[t*3+1],e[t*3+2])}function AD(e,t,n,r){return OD.crossVectors(e,n).dot(r)>=0&&OD.crossVectors(n,t).dot(r)>=0}function jD(e,t,n){ED.crossVectors(e,t);let r=ED.lengthSq();r<1e-18||(DD.set(0,1,0).addScaledVector(ED,-ED.y/r).normalize(),AD(e,t,DD,ED)&&(n.hi=Math.max(n.hi,vD(DD.y))),DD.negate(),AD(e,t,DD,ED)&&(n.lo=Math.min(n.lo,vD(DD.y))))}function MD(e,t,n,r){let i=(e.z*t.x-e.x*t.z)*r,a=(t.z*n.x-t.x*n.z)*r,o=(n.z*e.x-n.x*e.z)*r;return i>0&&a>0&&o>0||i<0&&a<0&&o<0}function ND(e,t){let n={lo:0,hi:0},r=[];for(let i=0;i<e.length;i++){let a=e[i],{cells:o,dirs:s}=t[i],c=new Int32Array(a.faces*4);r.push(c);for(let e=0;e<a.faces;e++){let t=a.idx?a.idx[e*3]:e*3,r=a.idx?a.idx[e*3+1]:e*3+1,i=a.idx?a.idx[e*3+2]:e*3+2,l=o[t],u=o[r],d=o[i],f=l/mD|0,p=u/mD|0,m=d/mD|0,h=l%mD,g=u%mD,_=d%mD,v=Math.min(f,p,m),y=Math.max(f,p,m),b=Math.min(h,g,_),x=Math.max(h,g,_),S=h+g+_-b-x,C=b+mD-x,w=b,T=x;S-b>=x-S&&S-b>C?(w=S,T=b+mD):x-S>C&&(w=x,T=S+mD),(y-v>1||T-w>1)&&(kD(s,t,CD),kD(s,r,wD),kD(s,i,TD),MD(CD,wD,TD,1)?(y=pD-1,w=0,T=mD-1):MD(CD,wD,TD,-1)?(v=0,w=0,T=mD-1):(n.lo=v,n.hi=y,jD(CD,wD,n),jD(wD,TD,n),jD(TD,CD,n),v=n.lo,y=n.hi)),c[e*4]=v,c[e*4+1]=y,c[e*4+2]=w,c[e*4+3]=T}}return r}function PD(e,t){for(let n=0;n<e.length;n++){let r=e[n];for(let e=0;e*4<r.length;e++){let i=n*gD+e;for(let n=r[e*4];n<=r[e*4+1];n++)for(let a=r[e*4+2];a<=r[e*4+3];a++)t(n*mD+a%mD,i)}}}function FD(e){e.updateMatrixWorld(!0);let t=new Y().makeTranslation(-e.position.x,-e.position.y,-e.position.z),n=[];if(e.traverse(e=>{if(!(e instanceof As))return;let r=e.geometry.attributes.position;if(!r)return;let i=e.geometry.index,a=(i?i.count:r.count)/3;a<1||a>=gD||n.push({verts:SD(e,t),idx:i?i.array:null,faces:Math.floor(a)})}),!n.length)return null;let r=ND(n,n.map(xD)),i=new Int32Array(hD+1);PD(r,e=>i[e+1]++);for(let e=0;e<hD;e++)i[e+1]+=i[e];let a=new Int32Array(i[hD]),o=i.slice(0,hD);return PD(r,(e,t)=>{a[o[e]++]=t}),{meshes:n,start:i,slots:a}}var ID=new J,LD=new J,RD=new J,zD=new J,BD=new J,VD=new J,HD=new J;function UD(e,t,n){let r=e.idx?e.idx[t*3]:t*3,i=e.idx?e.idx[t*3+1]:t*3+1,a=e.idx?e.idx[t*3+2]:t*3+2;ID.set(e.verts[r*3],e.verts[r*3+1],e.verts[r*3+2]),LD.set(e.verts[i*3],e.verts[i*3+1],e.verts[i*3+2]),RD.set(e.verts[a*3],e.verts[a*3+1],e.verts[a*3+2]),zD.subVectors(LD,ID),BD.subVectors(RD,ID),VD.crossVectors(n,BD);let o=zD.dot(VD);if(Math.abs(o)<1e-12)return 0;let s=1/o,c=-ID.dot(VD)*s;if(c<0||c>1)return 0;HD.crossVectors(ID,zD).negate();let l=n.dot(HD)*s;if(l<0||c+l>1)return 0;let u=BD.dot(HD)*s;return u>0?u:0}function WD(e,t,n,r){let{start:i,slots:a,meshes:o}=e;for(let e=i[t];e<i[t+1];e++){let t=a[e],i=UD(o[t/gD|0],t%gD,n);i>r&&(r=i)}return r}function GD(e,t){let n=vD(t.y),r=yD(t.x,t.z),i=WD(e,n*mD+r,t,0);if(i>0)return i;for(let a=-1;a<=1;a++){let o=n+a;if(!(o<0||o>=pD))for(let n=-1;n<=1;n++)i=WD(e,o*mD+(r+n+mD)%mD,t,i)}if(i===0&&(n===0||n===pD-1)){let r=n===0?0:pD-2;for(let n=r;n<r+2;n++)for(let r=0;r<mD;r++)i=WD(e,n*mD+r,t,i)}return i>0?i:null}function KD(e){let t=e.data.objectType;return t===W.SPACECRAFT||t===W.DEBRIS||e.data.orbitalSource===U.SPICE_PROBE}var qD=new kT;qD.setMeshoptDecoder(kE);var JD=qD,YD=new Map;function XD(e){let t=YD.get(e);return t||(t=fetch(Yt(`/v1/models/${e}/metadata.json`,`models`)).then(e=>e.json()),YD.set(e,t)),t}function ZD(e){return e.credit??e.exports.high.credit}function QD(e){return e.modelUnitOverride??e.radiusScene}var $D=new Set;function eO(e,t){let n=new za;n.scale.setScalar(QD(e)),n.userData.pickBody=e.body,n.add(t),e.group.add(n),e.modelRoot=n,e.model=t,$D.add(n)}function tO(e,t){let n=new Set;t.traverse(t=>{if(!(t instanceof As))return;let r=Array.isArray(t.material)?t.material:[t.material];for(let t of r)!(t instanceof mu)||n.has(t)||(n.add(t),e.eclipseShadow=BC(t,e.eclipseShadow??void 0))})}function nO(e,t,n){if(e.model)return Promise.resolve();if(e.modelLoadPromise)return e.modelLoadPromise;let r=(KD(e.body)?rO(e,t,n):iO(e,n)).finally(()=>{e.modelLoadPromise===r&&(e.modelLoadPromise=void 0)});return e.modelLoadPromise=r,r}async function rO(e,t,n){let r=e.modelLoadEpoch??0;e.mesh&&(e.mesh.visible=!1);try{let i=await mx(e.body.data.id,!1);e.body.pointing=i.global?.pointing;let a=i.global?.attitude;if(a&&(e.modelLoadEpoch??0)===r){let t=e.body.data.id.replace(/^probe-/,``);e.body.attitudeTrack=GE(t,a)}let o=i.global?.model_name;if(!o){e.noPhysical=`model`;return}if((e.modelLoadEpoch??0)!==r)return;e.mesh&&(e.mesh.visible=!1),oO(e,!0);let s=XD(o),c=await JD.loadAsync(Yt(`/v1/models/${o}/high.glb`,`models`)),l=null;try{l=await s}catch(e){console.warn(`Failed to load model metadata for ${o}:`,e)}if((e.modelLoadEpoch??0)!==r||!e.mesh){OO(c.scene);return}let u=l?.frame_map?yC(l.frame_map):null;e.body.modelBaseFrame=u??void 0;let d=sO(c.scene,u),f=l?.model_anchor?new J(...l.model_anchor):null;if(cO(d,f&&u?f.applyQuaternion(u):f),DO(d),t.add(d),e.model=d,e.modelName=o,oO(e,!1),l){if(l.scale_meters){let t=l.scale_meters/2e3;e.body.data.radiusKm=t*(l.body_span_ratio??1),e.radiusScene=Q(gn(e.body.data)),e.modelUnitOverride=l.body_span_ratio?Q(t):void 0}n?.credits.registerModel({bodyId:e.body.data.id,source:l.exports.high.credit.url,organisation:l.exports.high.credit.name,license:l.exports.high.credit.license})}}finally{e.model||oO(e,!1)}}async function iO(e,t){if(!jx().showShapeMesh)return;let n=e.modelLoadEpoch??0;try{let r=await mx(e.body.data.id,!1),i=r.global?.model_name;if(!i)return;let a=dD(r.global);if(a){console.info(`Skipping ${r.global?.render_quality??`unrated`} shape mesh for ${e.body.data.id}: ${a}`);return}r.global?.orientation&&!e.body.orientation&&fD(e,r.global.orientation,t);let o=XD(i),s=await JD.loadAsync(Yt(`/v1/models/${i}/high.glb`,`models`));if((e.modelLoadEpoch??0)!==n){OO(s.scene);return}let c;try{c=await o}catch(e){OO(s.scene),console.warn(`Failed to load shape-model metadata for ${i}:`,e);return}if(c.kind!==`shape_model`){OO(s.scene);return}let l=s.scene;cO(l),l.userData.radialIndex=FD(l),sD(l,oD(e.body.data.color??__(e.body.data)));let u=e.mesh?e.mesh.material.map:null;u&&cD(l,u,__(e.body.data),e.body.data.color),DO(l),tO(e,l),c.true_scale&&(e.radiusScene=Q(c.true_scale.max_extent_km/2),Number.isFinite(e.body.data.radiusKm)&&e.body.data.radiusKm>0||(e.body.data.radiusKm=c.true_scale.max_extent_km/2),e.noPhysical&&(e.noPhysical=void 0,JE(e,`missing`,null))),eO(e,l),e.modelName=i,e.mesh&&(e.mesh.visible=!1);let d=ZD(c),f=r.global?.model_source;t?.credits.registerModel({bodyId:e.body.data.id,source:d.url,organisation:d.name,license:d.license,provenance:f?.provenance,technique:f?.technique,archive:f?.archive,archiveUrl:f?.archive_url,mission:f?.mission&&{name:f.mission.name,id:f.mission.primary_id}})}finally{!e.model&&e.mesh&&(e.mesh.visible=!0)}}function aO(e){e.modelLoadEpoch=(e.modelLoadEpoch??0)+1,e.modelLoadPromise=void 0,oO(e,!1);let t=!KD(e.body),n=e.model;if(!n){e.mesh&&t&&(e.mesh.visible=!0);return}e.modelRoot&&=($D.delete(e.modelRoot),e.modelRoot.removeFromParent(),null),n.parent?.remove(n),OO(n),e.model=null,e.modelName=void 0,e.body.pointing=void 0,e.body.attitudeTrack=void 0,e.body.modelBaseFrame=void 0,e.mesh&&t&&(e.mesh.visible=!0)}function oO(e,t){if(t){if(e.loadingEl)return;let t=document.createElement(`div`);t.className=`scene-label__loader`,t.style.display=`none`,document.body.appendChild(t),e.loadingEl=t,e.loadingShown=!1}else e.loadingEl&&(e.loadingEl.remove(),e.loadingEl=null,e.loadingShown=void 0)}function sO(e,t){if(!t)return e;let n=new za;return e.quaternion.copy(t),n.add(e),n}function cO(e,t=null){e.updateMatrixWorld(!0);let n=new co().setFromObject(e,!0),r=n.getSize(new J),i=n.getCenter(new J),a=Math.max(r.x,r.y,r.z);if(a<=0)return;let o=2/a;t&&i.addScaledVector(t,a/2),e.scale.multiplyScalar(o),e.userData.fitScale=e.scale.x,e.position.copy(i).multiplyScalar(-o),e.userData.centerOffset=i.clone().multiplyScalar(o),e.userData.feetOffset=new J(i.x,n.min.y,i.z).multiplyScalar(o),e.userData.halfExtents=r.clone().multiplyScalar(o*.5);let s=dO(e,r,o,e.userData.centerOffset);e.userData.occluderSpheres=s.spheres;let c=e.userData.centerOffset.length();e.userData.minRadius=Math.max(0,s.minRadius-c),e.userData.maxRadius=e.userData.halfExtents.length()+c}var lO=8,uO=4096;function dO(e,t,n,r){e.updateMatrixWorld(!0);let i=t.x>=t.y&&t.x>=t.z?0:t.y>=t.z?1:2,a=0;if(e.traverse(e=>{e instanceof As&&(a+=e.geometry.attributes.position?.count??0)}),!a)return{spheres:[],minRadius:0};let o=Math.max(1,Math.floor(a/uO)),s=[],c=new J;e.traverse(t=>{if(!(t instanceof As))return;let n=t.geometry.attributes.position;if(n)for(let r=0;r<n.count;r+=o)c.fromBufferAttribute(n,r).applyMatrix4(t.matrixWorld).sub(e.position),s.push(c.clone())});let l=t.getComponent(i)*n/2+Math.abs(r.getComponent(i)),u=Array.from({length:lO},()=>[]);for(let e of s){let t=(e.getComponent(i)+l)/(2*l);u[Math.min(lO-1,Math.max(0,Math.floor(t*lO)))].push(e)}let d=1/0;for(let e of s)d=Math.min(d,e.length());let f=[];for(let e of u){if(e.length<3)continue;let t=new J;for(let n of e)t.add(n);t.divideScalar(e.length);let n=0;for(let r of e)n=Math.max(n,t.distanceToSquared(r));f.push({center:t,r:Math.sqrt(n)})}return{spheres:f,minRadius:Number.isFinite(d)?d:0}}var fO=4,pO=.05,mO=new J,hO=new J,gO=new J,_O=new J,vO=new Hi,yO=new J,bO=new Rd;function xO(e,t,n,r){let i=e.parent;if(!i)return null;i.updateMatrixWorld(!0);let a=i.getWorldScale(_O).x;if(!(a>0))return null;let o=Math.cos(t);mO.set(o*Math.cos(n),Math.sin(t),-o*Math.sin(n)),hO.copy(mO).applyQuaternion(e.quaternion),gO.copy(e.position).addScaledVector(hO,fO),i.localToWorld(gO),bO.set(gO,hO.negate());let s=bO.intersectObject(e,!0)[0];return s?(r&&s.face&&r.copy(s.face.normal).transformDirection(s.object.matrixWorld).applyQuaternion(vO.copy(e.quaternion).invert()),Math.max(fO-s.distance/a,pO)):null}function SO(e,t){let n=e?.model?.userData.radialIndex;if(!n)return null;let r=GD(n,yO.set(t[0],t[1],t[2]));return r===null?null:cg(r*QD(e))}function CO(e){return!!e?.model?.userData.radialIndex&&e.model.parent===e.modelRoot}function wO(e){if(!CO(e))return;let t=e.model.position,n=QD(e);return[t.x*n,t.y*n,t.z*n]}function TO(e){if(CO(e))return cg(e.model.userData.maxRadius*QD(e))}function EO(e){if(CO(e))return cg(e.model.userData.minRadius*QD(e))}function DO(e){e.traverse(e=>{e instanceof As&&(e.castShadow=!0,e.receiveShadow=!0)})}function OO(e){e.traverse(e=>{if(!(e instanceof As))return;e.geometry?.dispose();let t=e.material,n=Array.isArray(t)?t:[t];for(let e of n)if(e){for(let t of Object.values(e))t instanceof oa&&t.dispose();e.dispose()}})}function kO(e,t,n,r,i,a,o,s,c,l){let u=c===`touch`||c===`pen`?48:24,d=(e.x+1)*.5*i,f=(1-e.y)*.5*a,p=o,[m,h,g]=r,_=t.position,v,y=u,b=1/0,x=e=>{TT(e,s,n),p.set(e.position[0]-m,e.position[1]-h,e.position[2]-g);let r=Math.hypot(p.x-_.x,p.y-_.y,p.z-_.z);if(p.project(t),!rT(p.z))return;let o=(p.x+1)*.5*i,c=(1-p.y)*.5*a,u=Math.hypot(o-d,c-f);(u<y||u===y&&r<b)&&(l&&!l(p.x,p.y,r)||(y=u,b=r,v=e))};for(let e of n.bodies.majorBodies)e.data.objectType===W.MOON&&n.visibility.isMoonGroupVisible(e.data.parentId)&&x(e);return v?{body:v,distance:b,screenDist:y}:null}var AO=9,jO=class{downPos=new q;pointer=new q;_tmpPointer=new q;raycaster=new Rd;_tmpV3=new J;constructor(e,t,n,r,i,a,o,s,c,l,u,d){this.canvas=e,this.camera=t,this.ctx=n,this.clock=r,this.focus=i,this.clickables=a,this.meshToBody=o,this.onPick=s,this.modelPick=c,this.gpuPick=l,this.getClouds=u,this.pickRegistry=d}attach(){this.canvas.addEventListener(`pointerdown`,this.onDown),this.canvas.addEventListener(`pointerup`,this.onUp)}detach(){this.canvas.removeEventListener(`pointerdown`,this.onDown),this.canvas.removeEventListener(`pointerup`,this.onUp)}onDown=e=>{this.downPos.set(e.clientX,e.clientY)};onUp=e=>{let t=e.clientX-this.downPos.x,n=e.clientY-this.downPos.y;if(t*t+n*n>AO)return;let r=this.canvas.getBoundingClientRect();this.pointer.set((e.clientX-r.left)/r.width*2-1,-((e.clientY-r.top)/r.height)*2+1);let i=this.modelPick(this.pointer.x,this.pointer.y);if(i){this.onPick(i);return}this.raycaster.setFromCamera(this.pointer,this.camera);let a=this.resolveMeshHit(this.raycaster.intersectObjects([...this.clickables,...$D]))?.body,o=kO(this.pointer,this.camera,this.ctx,this.focus.focusTruePos,this.canvas.clientWidth,this.canvas.clientHeight,this._tmpV3,this.clock.jd,e.pointerType,this.isDotVisible),s=this.gpuPickCloud(e,r),c=this.nearer(o,s)?.body??a;c&&this.onPick(c)};nearer(e,t){return e?t&&(t.screenDist<e.screenDist||t.screenDist===e.screenDist&&t.distance<e.distance)?t:e:t}gpuPickCloud(e,t){let n=e.pointerType===`touch`||e.pointerType===`pen`?48:24,r=this.clock.jd,i=this.gpuPick.pick(this.getClouds(),this.camera,e.clientX,e.clientY,t,n);for(let e of i){let t=this.pickRegistry.resolve(e.pickId);if(!t)continue;let n=this.ctx.getBody(t);if(!n)continue;TT(n,r,this.ctx);let i=this.worldDistOf(n);if(this.isDotVisible(e.ndcX,e.ndcY,i))return{body:n,distance:i,screenDist:e.pixelDist}}return null}worldDistOf(e){let[t,n,r]=this.focus.focusTruePos,i=this.camera.position;return Math.hypot(e.position[0]-t-i.x,e.position[1]-n-i.y,e.position[2]-r-i.z)}resolveMeshHit(e){for(let t of e){let e=t.object;for(;e;){let n=this.meshToBody.get(e)??e.userData.pickBody;if(n)return{body:n,distance:t.distance};e=e.parent}}}isDotVisible=(e,t,n)=>{if(this.modelPick(e,t))return!1;if(this.clickables.length===0&&$D.size===0)return!0;this._tmpPointer.set(e,t),this.raycaster.setFromCamera(this._tmpPointer,this.camera);let r=this.raycaster.intersectObjects(this.clickables,!1);if($D.size>0&&r.push(...this.raycaster.intersectObjects([...$D],!0)),r.length===0)return!0;let i=1/0;for(let e of r)e.distance<i&&(i=e.distance);return i>=n*.999}},MO=4,NO=16,PO=`
|
|
4520
|
+
#endif`)},PC(t,`shapeModel`),t}function dD(e,t){e.traverse(e=>{if(!(e instanceof As))return;let n=e.material;e.material=t;let r=Array.isArray(n)?n:[n];for(let e of r)e?.dispose()})}function fD(e,t,n,r){e.traverse(e=>{!(e instanceof As)||!(e.material instanceof mu)||(e.material.map=t,t?e.material.color.copy(nD(t,r)):e.material.color.set(n),e.material.needsUpdate=!0)})}function pD(e,t,n){e.map&&e.map!==t&&e.map.dispose(),t.colorSpace=Xr,e.map=t,e.color.copy(nD(t,n)),e.needsUpdate=!0}var mD=new Set([]);function hD(e){return e?.model_name?Hx()&&e.render_quality!==`high`?`low-end-device`:e.displacement&&!mD.has(e.id)?`dem-preferred`:null:`no-bundle`}function gD(e,t,n,r){e.body.orientation=t,n?.credits.registerOrientation({bodyId:e.body.data.id,systemId:r??e.body.data.id,source:t.source,reference:t.reference})}var _D=48,vD=96,yD=_D*vD,bD=1<<24,xD=Math.PI*2;function SD(e){let t=Math.floor((e+1)/2*_D);return Math.min(_D-1,Math.max(0,t))}function CD(e,t){let n=Math.atan2(-t,e);return(Math.floor((n+Math.PI)/xD*vD)%vD+vD)%vD}var wD=new J;function TD(e){let t=e.verts.length/3,n=new Int32Array(t),r=new Float32Array(t*3);for(let i=0;i<t;i++)wD.set(e.verts[i*3],e.verts[i*3+1],e.verts[i*3+2]).normalize(),r[i*3]=wD.x,r[i*3+1]=wD.y,r[i*3+2]=wD.z,n[i]=SD(wD.y)*vD+CD(wD.x,wD.z);return{cells:n,dirs:r}}function ED(e,t){let n=e.geometry.attributes.position,r=new Y().multiplyMatrices(t,e.matrixWorld),i=new Float32Array(n.count*3);for(let e=0;e<n.count;e++)wD.set(n.getX(e),n.getY(e),n.getZ(e)).applyMatrix4(r),i[e*3]=wD.x,i[e*3+1]=wD.y,i[e*3+2]=wD.z;return i}var DD=new J,OD=new J,kD=new J,AD=new J,jD=new J,MD=new J;function ND(e,t,n){return n.set(e[t*3],e[t*3+1],e[t*3+2])}function PD(e,t,n,r){return MD.crossVectors(e,n).dot(r)>=0&&MD.crossVectors(n,t).dot(r)>=0}function FD(e,t,n){AD.crossVectors(e,t);let r=AD.lengthSq();r<1e-18||(jD.set(0,1,0).addScaledVector(AD,-AD.y/r).normalize(),PD(e,t,jD,AD)&&(n.hi=Math.max(n.hi,SD(jD.y))),jD.negate(),PD(e,t,jD,AD)&&(n.lo=Math.min(n.lo,SD(jD.y))))}function ID(e,t,n,r){let i=(e.z*t.x-e.x*t.z)*r,a=(t.z*n.x-t.x*n.z)*r,o=(n.z*e.x-n.x*e.z)*r;return i>0&&a>0&&o>0||i<0&&a<0&&o<0}function LD(e,t){let n={lo:0,hi:0},r=[];for(let i=0;i<e.length;i++){let a=e[i],{cells:o,dirs:s}=t[i],c=new Int32Array(a.faces*4);r.push(c);for(let e=0;e<a.faces;e++){let t=a.idx?a.idx[e*3]:e*3,r=a.idx?a.idx[e*3+1]:e*3+1,i=a.idx?a.idx[e*3+2]:e*3+2,l=o[t],u=o[r],d=o[i],f=l/vD|0,p=u/vD|0,m=d/vD|0,h=l%vD,g=u%vD,_=d%vD,v=Math.min(f,p,m),y=Math.max(f,p,m),b=Math.min(h,g,_),x=Math.max(h,g,_),S=h+g+_-b-x,C=b+vD-x,w=b,T=x;S-b>=x-S&&S-b>C?(w=S,T=b+vD):x-S>C&&(w=x,T=S+vD),(y-v>1||T-w>1)&&(ND(s,t,DD),ND(s,r,OD),ND(s,i,kD),ID(DD,OD,kD,1)?(y=_D-1,w=0,T=vD-1):ID(DD,OD,kD,-1)?(v=0,w=0,T=vD-1):(n.lo=v,n.hi=y,FD(DD,OD,n),FD(OD,kD,n),FD(kD,DD,n),v=n.lo,y=n.hi)),c[e*4]=v,c[e*4+1]=y,c[e*4+2]=w,c[e*4+3]=T}}return r}function RD(e,t){for(let n=0;n<e.length;n++){let r=e[n];for(let e=0;e*4<r.length;e++){let i=n*bD+e;for(let n=r[e*4];n<=r[e*4+1];n++)for(let a=r[e*4+2];a<=r[e*4+3];a++)t(n*vD+a%vD,i)}}}function zD(e){e.updateMatrixWorld(!0);let t=new Y().makeTranslation(-e.position.x,-e.position.y,-e.position.z),n=[];if(e.traverse(e=>{if(!(e instanceof As))return;let r=e.geometry.attributes.position;if(!r)return;let i=e.geometry.index,a=(i?i.count:r.count)/3;a<1||a>=bD||n.push({verts:ED(e,t),idx:i?i.array:null,faces:Math.floor(a)})}),!n.length)return null;let r=LD(n,n.map(TD)),i=new Int32Array(yD+1);RD(r,e=>i[e+1]++);for(let e=0;e<yD;e++)i[e+1]+=i[e];let a=new Int32Array(i[yD]),o=i.slice(0,yD);return RD(r,(e,t)=>{a[o[e]++]=t}),{meshes:n,start:i,slots:a}}var BD=new J,VD=new J,HD=new J,UD=new J,WD=new J,GD=new J,KD=new J;function qD(e,t,n){let r=e.idx?e.idx[t*3]:t*3,i=e.idx?e.idx[t*3+1]:t*3+1,a=e.idx?e.idx[t*3+2]:t*3+2;BD.set(e.verts[r*3],e.verts[r*3+1],e.verts[r*3+2]),VD.set(e.verts[i*3],e.verts[i*3+1],e.verts[i*3+2]),HD.set(e.verts[a*3],e.verts[a*3+1],e.verts[a*3+2]),UD.subVectors(VD,BD),WD.subVectors(HD,BD),GD.crossVectors(n,WD);let o=UD.dot(GD);if(Math.abs(o)<1e-12)return 0;let s=1/o,c=-BD.dot(GD)*s;if(c<0||c>1)return 0;KD.crossVectors(BD,UD).negate();let l=n.dot(KD)*s;if(l<0||c+l>1)return 0;let u=WD.dot(KD)*s;return u>0?u:0}function JD(e,t,n,r){let{start:i,slots:a,meshes:o}=e;for(let e=i[t];e<i[t+1];e++){let t=a[e],i=qD(o[t/bD|0],t%bD,n);i>r&&(r=i)}return r}function YD(e,t){let n=SD(t.y),r=CD(t.x,t.z),i=JD(e,n*vD+r,t,0);if(i>0)return i;for(let a=-1;a<=1;a++){let o=n+a;if(!(o<0||o>=_D))for(let n=-1;n<=1;n++)i=JD(e,o*vD+(r+n+vD)%vD,t,i)}if(i===0&&(n===0||n===_D-1)){let r=n===0?0:_D-2;for(let n=r;n<r+2;n++)for(let r=0;r<vD;r++)i=JD(e,n*vD+r,t,i)}return i>0?i:null}function XD(e){let t=e.data.objectType;return t===W.SPACECRAFT||t===W.DEBRIS||e.data.orbitalSource===U.SPICE_PROBE}var ZD=new NT;ZD.setMeshoptDecoder(NE);var QD=ZD,$D=new Map;function eO(e){let t=$D.get(e);return t||(t=fetch(Yt(`/v1/models/${e}/metadata.json`,`models`)).then(e=>e.json()),$D.set(e,t)),t}function tO(e){return e.credit??e.exports.high.credit}function nO(e){return e.modelUnitOverride??e.radiusScene}var rO=new Set;function iO(e,t){let n=new za;n.scale.setScalar(nO(e)),n.userData.pickBody=e.body,n.add(t),e.group.add(n),e.modelRoot=n,e.model=t,rO.add(n)}function aO(e,t){let n=new Set;t.traverse(t=>{if(!(t instanceof As))return;let r=Array.isArray(t.material)?t.material:[t.material];for(let t of r)!(t instanceof mu)||n.has(t)||(n.add(t),e.eclipseShadow=HC(t,e.eclipseShadow??void 0))})}function oO(e,t,n){if(e.model)return Promise.resolve();if(e.modelLoadPromise)return e.modelLoadPromise;let r=(XD(e.body)?sO(e,t,n):cO(e,n)).finally(()=>{e.modelLoadPromise===r&&(e.modelLoadPromise=void 0)});return e.modelLoadPromise=r,r}async function sO(e,t,n){let r=e.modelLoadEpoch??0;e.mesh&&(e.mesh.visible=!1);try{let i=await hx(e.body.data.id,!1);e.body.pointing=i.global?.pointing;let a=i.global?.attitude;if(a&&(e.modelLoadEpoch??0)===r){let t=e.body.data.id.replace(/^probe-/,``);e.body.attitudeTrack=YE(t,a)}let o=i.global?.model_name;if(!o){e.noPhysical=`model`;return}if((e.modelLoadEpoch??0)!==r)return;e.mesh&&(e.mesh.visible=!1),uO(e,!0);let s=eO(o),c=await QD.loadAsync(Yt(`/v1/models/${o}/high.glb`,`models`)),l=null;try{l=await s}catch(e){console.warn(`Failed to load model metadata for ${o}:`,e)}if((e.modelLoadEpoch??0)!==r||!e.mesh){MO(c.scene);return}let u=l?.frame_map?xC(l.frame_map):null;e.body.modelBaseFrame=u??void 0;let d=dO(c.scene,u),f=l?.model_anchor?new J(...l.model_anchor):null;if(fO(d,f&&u?f.applyQuaternion(u):f),jO(d),t.add(d),d.visible=!e.isCrashed,e.model=d,e.modelName=o,uO(e,!1),l){if(l.scale_meters){let t=l.scale_meters/2e3;e.body.data.radiusKm=t*(l.body_span_ratio??1),e.radiusScene=Q(gn(e.body.data)),e.modelUnitOverride=l.body_span_ratio?Q(t):void 0}n?.credits.registerModel({bodyId:e.body.data.id,source:l.exports.high.credit.url,organisation:l.exports.high.credit.name,license:l.exports.high.credit.license})}}finally{e.model||uO(e,!1)}}async function cO(e,t){if(!Mx().showShapeMesh)return;let n=e.modelLoadEpoch??0;try{let r=await hx(e.body.data.id,!1),i=r.global?.model_name;if(!i)return;let a=hD(r.global);if(a){console.info(`Skipping ${r.global?.render_quality??`unrated`} shape mesh for ${e.body.data.id}: ${a}`);return}r.global?.orientation&&!e.body.orientation&&gD(e,r.global.orientation,t);let o=eO(i),s=await QD.loadAsync(Yt(`/v1/models/${i}/high.glb`,`models`));if((e.modelLoadEpoch??0)!==n){MO(s.scene);return}let c;try{c=await o}catch(e){MO(s.scene),console.warn(`Failed to load shape-model metadata for ${i}:`,e);return}if(c.kind!==`shape_model`){MO(s.scene);return}let l=s.scene;fO(l),l.userData.radialIndex=zD(l),dD(l,uD(e.body.data.color??__(e.body.data)));let u=e.mesh?e.mesh.material.map:null;u&&fD(l,u,__(e.body.data),e.body.data.color),jO(l),aO(e,l),c.true_scale&&(e.radiusScene=Q(c.true_scale.max_extent_km/2),Number.isFinite(e.body.data.radiusKm)&&e.body.data.radiusKm>0||(e.body.data.radiusKm=c.true_scale.max_extent_km/2),e.noPhysical&&(e.noPhysical=void 0,QE(e,`missing`,null))),iO(e,l),e.modelName=i,e.mesh&&(e.mesh.visible=!1);let d=tO(c),f=r.global?.model_source;t?.credits.registerModel({bodyId:e.body.data.id,source:d.url,organisation:d.name,license:d.license,provenance:f?.provenance,technique:f?.technique,archive:f?.archive,archiveUrl:f?.archive_url,mission:f?.mission&&{name:f.mission.name,id:f.mission.primary_id}})}finally{!e.model&&e.mesh&&(e.mesh.visible=!0)}}function lO(e){e.modelLoadEpoch=(e.modelLoadEpoch??0)+1,e.modelLoadPromise=void 0,uO(e,!1);let t=!XD(e.body),n=e.model;if(!n){e.mesh&&t&&(e.mesh.visible=!0);return}e.modelRoot&&=(rO.delete(e.modelRoot),e.modelRoot.removeFromParent(),null),n.parent?.remove(n),MO(n),e.model=null,e.modelName=void 0,e.body.pointing=void 0,e.body.attitudeTrack=void 0,e.body.modelBaseFrame=void 0,e.mesh&&t&&(e.mesh.visible=!0)}function uO(e,t){if(t){if(e.loadingEl)return;let t=document.createElement(`div`);t.className=`scene-label__loader`,t.style.display=`none`,document.body.appendChild(t),e.loadingEl=t,e.loadingShown=!1}else e.loadingEl&&(e.loadingEl.remove(),e.loadingEl=null,e.loadingShown=void 0)}function dO(e,t){if(!t)return e;let n=new za;return e.quaternion.copy(t),n.add(e),n}function fO(e,t=null){e.updateMatrixWorld(!0);let n=new co().setFromObject(e,!0),r=n.getSize(new J),i=n.getCenter(new J),a=Math.max(r.x,r.y,r.z);if(a<=0)return;let o=2/a;t&&i.addScaledVector(t,a/2),e.scale.multiplyScalar(o),e.userData.fitScale=e.scale.x,e.position.copy(i).multiplyScalar(-o),e.userData.centerOffset=i.clone().multiplyScalar(o),e.userData.feetOffset=new J(i.x,n.min.y,i.z).multiplyScalar(o),e.userData.halfExtents=r.clone().multiplyScalar(o*.5);let s=hO(e,r,o,e.userData.centerOffset);e.userData.occluderSpheres=s.spheres;let c=e.userData.centerOffset.length();e.userData.minRadius=Math.max(0,s.minRadius-c),e.userData.maxRadius=e.userData.halfExtents.length()+c}var pO=8,mO=4096;function hO(e,t,n,r){e.updateMatrixWorld(!0);let i=t.x>=t.y&&t.x>=t.z?0:t.y>=t.z?1:2,a=0;if(e.traverse(e=>{e instanceof As&&(a+=e.geometry.attributes.position?.count??0)}),!a)return{spheres:[],minRadius:0};let o=Math.max(1,Math.floor(a/mO)),s=[],c=new J;e.traverse(t=>{if(!(t instanceof As))return;let n=t.geometry.attributes.position;if(n)for(let r=0;r<n.count;r+=o)c.fromBufferAttribute(n,r).applyMatrix4(t.matrixWorld).sub(e.position),s.push(c.clone())});let l=t.getComponent(i)*n/2+Math.abs(r.getComponent(i)),u=Array.from({length:pO},()=>[]);for(let e of s){let t=(e.getComponent(i)+l)/(2*l);u[Math.min(pO-1,Math.max(0,Math.floor(t*pO)))].push(e)}let d=1/0;for(let e of s)d=Math.min(d,e.length());let f=[];for(let e of u){if(e.length<3)continue;let t=new J;for(let n of e)t.add(n);t.divideScalar(e.length);let n=0;for(let r of e)n=Math.max(n,t.distanceToSquared(r));f.push({center:t,r:Math.sqrt(n)})}return{spheres:f,minRadius:Number.isFinite(d)?d:0}}var gO=4,_O=.05,vO=new J,yO=new J,bO=new J,xO=new J,SO=new Hi,CO=new J,wO=new Rd;function TO(e,t,n,r){let i=e.parent;if(!i)return null;i.updateMatrixWorld(!0);let a=i.getWorldScale(xO).x;if(!(a>0))return null;let o=Math.cos(t);vO.set(o*Math.cos(n),Math.sin(t),-o*Math.sin(n)),yO.copy(vO).applyQuaternion(e.quaternion),bO.copy(e.position).addScaledVector(yO,gO),i.localToWorld(bO),wO.set(bO,yO.negate());let s=wO.intersectObject(e,!0)[0];return s?(r&&s.face&&r.copy(s.face.normal).transformDirection(s.object.matrixWorld).applyQuaternion(SO.copy(e.quaternion).invert()),Math.max(gO-s.distance/a,_O)):null}function EO(e,t){let n=e?.model?.userData.radialIndex;if(!n)return null;let r=YD(n,CO.set(t[0],t[1],t[2]));return r===null?null:cg(r*nO(e))}function DO(e){return!!e?.model?.userData.radialIndex&&e.model.parent===e.modelRoot}function OO(e){if(!DO(e))return;let t=e.model.position,n=nO(e);return[t.x*n,t.y*n,t.z*n]}function kO(e){if(DO(e))return cg(e.model.userData.maxRadius*nO(e))}function AO(e){if(DO(e))return cg(e.model.userData.minRadius*nO(e))}function jO(e){e.traverse(e=>{e instanceof As&&(e.castShadow=!0,e.receiveShadow=!0)})}function MO(e){e.traverse(e=>{if(!(e instanceof As))return;e.geometry?.dispose();let t=e.material,n=Array.isArray(t)?t:[t];for(let e of n)if(e){for(let t of Object.values(e))t instanceof oa&&t.dispose();e.dispose()}})}function NO(e,t,n,r,i,a,o,s,c,l){let u=c===`touch`||c===`pen`?48:24,d=(e.x+1)*.5*i,f=(1-e.y)*.5*a,p=o,[m,h,g]=r,_=t.position,v,y=u,b=1/0,x=e=>{DT(e,s,n),p.set(e.position[0]-m,e.position[1]-h,e.position[2]-g);let r=Math.hypot(p.x-_.x,p.y-_.y,p.z-_.z);if(p.project(t),!aT(p.z))return;let o=(p.x+1)*.5*i,c=(1-p.y)*.5*a,u=Math.hypot(o-d,c-f);(u<y||u===y&&r<b)&&(l&&!l(p.x,p.y,r)||(y=u,b=r,v=e))};for(let e of n.bodies.majorBodies)e.data.objectType===W.MOON&&n.visibility.isMoonGroupVisible(e.data.parentId)&&x(e);return v?{body:v,distance:b,screenDist:y}:null}var PO=9,FO=class{downPos=new q;pointer=new q;_tmpPointer=new q;raycaster=new Rd;_tmpV3=new J;constructor(e,t,n,r,i,a,o,s,c,l,u,d){this.canvas=e,this.camera=t,this.ctx=n,this.clock=r,this.focus=i,this.clickables=a,this.meshToBody=o,this.onPick=s,this.modelPick=c,this.gpuPick=l,this.getClouds=u,this.pickRegistry=d}attach(){this.canvas.addEventListener(`pointerdown`,this.onDown),this.canvas.addEventListener(`pointerup`,this.onUp)}detach(){this.canvas.removeEventListener(`pointerdown`,this.onDown),this.canvas.removeEventListener(`pointerup`,this.onUp)}onDown=e=>{this.downPos.set(e.clientX,e.clientY)};onUp=e=>{let t=e.clientX-this.downPos.x,n=e.clientY-this.downPos.y;if(t*t+n*n>PO)return;let r=this.canvas.getBoundingClientRect();this.pointer.set((e.clientX-r.left)/r.width*2-1,-((e.clientY-r.top)/r.height)*2+1);let i=this.modelPick(this.pointer.x,this.pointer.y);if(i){this.onPick(i);return}this.raycaster.setFromCamera(this.pointer,this.camera);let a=this.resolveMeshHit(this.raycaster.intersectObjects([...this.clickables,...rO]))?.body,o=NO(this.pointer,this.camera,this.ctx,this.focus.focusTruePos,this.canvas.clientWidth,this.canvas.clientHeight,this._tmpV3,this.clock.jd,e.pointerType,this.isDotVisible),s=this.gpuPickCloud(e,r),c=this.nearer(o,s)?.body??a;c&&this.onPick(c)};nearer(e,t){return e?t&&(t.screenDist<e.screenDist||t.screenDist===e.screenDist&&t.distance<e.distance)?t:e:t}gpuPickCloud(e,t){let n=e.pointerType===`touch`||e.pointerType===`pen`?48:24,r=this.clock.jd,i=this.gpuPick.pick(this.getClouds(),this.camera,e.clientX,e.clientY,t,n);for(let e of i){let t=this.pickRegistry.resolve(e.pickId);if(!t)continue;let n=this.ctx.getBody(t);if(!n)continue;DT(n,r,this.ctx);let i=this.worldDistOf(n);if(this.isDotVisible(e.ndcX,e.ndcY,i))return{body:n,distance:i,screenDist:e.pixelDist}}return null}worldDistOf(e){let[t,n,r]=this.focus.focusTruePos,i=this.camera.position;return Math.hypot(e.position[0]-t-i.x,e.position[1]-n-i.y,e.position[2]-r-i.z)}resolveMeshHit(e){for(let t of e){let e=t.object;for(;e;){let n=this.meshToBody.get(e)??e.userData.pickBody;if(n)return{body:n,distance:t.distance};e=e.parent}}}isDotVisible=(e,t,n)=>{if(this.modelPick(e,t))return!1;if(this.clickables.length===0&&rO.size===0)return!0;this._tmpPointer.set(e,t),this.raycaster.setFromCamera(this._tmpPointer,this.camera);let r=this.raycaster.intersectObjects(this.clickables,!1);if(rO.size>0&&r.push(...this.raycaster.intersectObjects([...rO],!0)),r.length===0)return!0;let i=1/0;for(let e of r)e.distance<i&&(i=e.distance);return i>=n*.999}},IO=4,LO=16,RO=`
|
|
4521
4521
|
uniform mat4 modelViewMatrix;
|
|
4522
4522
|
uniform mat4 projectionMatrix;
|
|
4523
4523
|
uniform float uPointSize;
|
|
@@ -4529,13 +4529,13 @@ void main() {
|
|
|
4529
4529
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
4530
4530
|
gl_PointSize = uPointSize;
|
|
4531
4531
|
}
|
|
4532
|
-
`,
|
|
4532
|
+
`,zO=`
|
|
4533
4533
|
precision highp float;
|
|
4534
4534
|
varying vec4 vPick;
|
|
4535
4535
|
void main() {
|
|
4536
4536
|
gl_FragColor = vPick;
|
|
4537
4537
|
}
|
|
4538
|
-
`,IO=class{target;material;scene=new qa;pickCamera;size=0;buffer=new Uint8Array;prevClear=new X;proxies=[];constructor(e,t){this.renderer=e,this.target=new la(1,1,{depthBuffer:!0}),this.target.texture.colorSpace=Zr,this.target.texture.generateMipmaps=!1,this.material=new pu({vertexShader:PO,fragmentShader:FO,uniforms:{uPointSize:{value:MO}},blending:0,depthTest:!0,depthWrite:!0}),this.scene.matrixWorldAutoUpdate=!1,this.pickCamera=t.clone()}ensureSize(e){e!==this.size&&(this.size=e,this.target.setSize(e,e),this.buffer=new Uint8Array(e*e*4))}proxyAt(e,t){let n=this.proxies[e];return n?n.geometry=t.geometry:(n=new Ac(t.geometry,this.material),n.frustumCulled=!1,n.matrixAutoUpdate=!1,n.matrixWorldAutoUpdate=!1,this.proxies[e]=n),n.matrixWorld.copy(t.matrixWorld),n}pick(e,t,n,r,i,a){let o=Math.max(1,Math.round(a)),s=o*2+1;this.ensureSize(s);let c=n-i.left,l=r-i.top,u=c-o,d=l-o;this.scene.clear();let f=0;for(let t of e)t.visible&&t.geometry.getAttribute(`pickColor`)&&t.geometry.drawRange.count!==0&&this.scene.add(this.proxyAt(f++,t));if(f===0)return[];this.pickCamera.copy(t),this.pickCamera.setViewOffset(i.width,i.height,u,d,s,s),this.pickCamera.updateProjectionMatrix();let p=this.renderer.getRenderTarget(),m=this.renderer.autoClear;this.renderer.getClearColor(this.prevClear);let h=this.renderer.getClearAlpha();return this.renderer.setRenderTarget(this.target),this.renderer.autoClear=!1,this.renderer.setClearColor(0,0),this.renderer.clear(!0,!0,!1),this.renderer.render(this.scene,this.pickCamera),this.renderer.readRenderTargetPixels(this.target,0,0,s,s,this.buffer),this.renderer.setRenderTarget(p),this.renderer.autoClear=m,this.renderer.setClearColor(this.prevClear,h),this.pickCamera.clearViewOffset(),this.decode(s,o,i,u,d)}decode(e,t,n,r,i){let a=this.buffer,o=new Map;for(let s=0;s<e;s++){let c=e-1-s;for(let l=0;l<e;l++){let u=(s*e+l)*4,d=(a[u]|a[u+1]<<8|a[u+2]<<16|a[u+3]<<24)>>>0;if(d===0)continue;let f=l-t,p=c-t,m=Math.hypot(f,p),h=o.get(d);if(h&&h.pixelDist<=m)continue;let g=r+l+.5,_=i+c+.5;o.set(d,{pickId:d,pixelDist:m,ndcX:g/n.width*2-1,ndcY:-(_/n.height*2-1)})}}return[...o.values()].sort((e,t)=>e.pixelDist-t.pixelDist).slice(0,NO)}dispose(){this.target.dispose(),this.material.dispose(),this.proxies.length=0}};function LO(e,t,n){return Math.min(Math.max(e,t),n)}function RO(e,t){let n=Math.max(e,0);return LO(t.refMs*n/t.refAngleRad,t.minMs,t.maxMs)}function zO(e,t){if(!(e>0))return t.minMs;let n=Math.log10(e/t.refDist);return LO(t.refMs+n*t.msPerDecade,t.minMs,t.maxMs)}var BO={refMs:350,refAngleRad:Math.PI/3,minMs:200,maxMs:700},VO={refMs:400,refAngleRad:Math.PI/2,minMs:200,maxMs:800},HO={refMs:1600,refDist:2,msPerDecade:400,minMs:600,maxMs:2500},UO={refMs:1600,refAngleRad:Math.PI/2,minMs:600,maxMs:2500},WO=new J(0,1,0),GO=(()=>{let e=Math.PI/180,t=192.85948*e,n=27.12825*e,r=Math.cos(n),i=r*Math.cos(t),a=r*Math.sin(t),o=Math.sin(n),s=ag*e,c=Math.cos(s),l=Math.sin(s),u=i,d=a*c+o*l;return new J(u,-a*l+o*c,-d).normalize()})();function KO(e){return(e??new J).copy(GO)}function qO(e,t,n,r=!1){let i=n??new J;if(!e.orientation)return r&&e.orbitCenter&&(i.set(e.position[0]-e.orbitCenter[0],e.position[1]-e.orbitCenter[1],e.position[2]-e.orbitCenter[2]),i.lengthSq()>1e-20)?i.normalize():(i.copy(WO),e.modelBaseFrame&&i.applyQuaternion(e.modelBaseFrame).normalize(),i);let a=fC(e.orientation,t,e.nutPrec);return i.copy(WO).applyQuaternion(a).normalize()}var JO=class{refId=null;startVec=new J(0,1,0);targetVec=new J(0,1,0);currentVec=new J(0,1,0);animStartTime=-1/0;animDurationMs=VO.refMs;needsDurationCalc=!1;_quatA=new Hi;_quatB=new Hi;constructor(e,t,n,r){this.camera=e,this.controls=t,this.ctx=n,this.isLanded=r}setNorthReference(e){e!==this.refId&&(this.refId=e,this.startVec.copy(this.currentVec),this.animStartTime=performance.now(),this.needsDurationCalc=!0)}update(e){if(this.refId===`galactic`)KO(this.targetVec);else{let t=this.refId?this.ctx.getBody(this.refId):void 0;if(t){let n=!!t.featureAnchor||this.isLanded(t.data.id);qO(t,e,this.targetVec,n)}else this.targetVec.copy(WO)}if(this.needsDurationCalc){this.needsDurationCalc=!1;let e=this.startVec.angleTo(this.targetVec);this.animDurationMs=RO(e,VO)}let t=performance.now()-this.animStartTime;if(t>=this.animDurationMs)this.currentVec.copy(this.targetVec);else{let e=Math.max(0,t/this.animDurationMs),n=e*e*(3-2*e);this._quatA.setFromUnitVectors(WO,this.startVec),this._quatB.setFromUnitVectors(WO,this.targetVec),this._quatA.slerp(this._quatB,n),this.currentVec.copy(WO).applyQuaternion(this._quatA)}this.camera.up.copy(this.currentVec);let n=this.controls;n._quat.setFromUnitVectors(this.currentVec,WO),n._quatInverse.copy(n._quat).invert()}},YO=class extends Ra{constructor(e=document.createElement(`div`)){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position=`absolute`,this.element.style.userSelect=`none`,this.element.setAttribute(`draggable`,!1),this.center=new q(.5,.5),this.addEventListener(`removed`,function(){this.traverse(function(e){e.element&&e.element instanceof e.element.ownerDocument.defaultView.Element&&e.element.parentNode!==null&&e.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}};new J,new Y,new Y,new J,new J;function XO(e){return e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey}function ZO(e,t,n){let r=e[t];return r||(r=n(),e[t]=r),r}function QO(e){switch(e){case W.STAR:return 0;case W.PLANET:return 1;case W.DWARF_PLANET:return 2;case W.MOON:return 3;default:return 4}}var $O=new J,ek=22;function tk(){return{cx0:0,cy0:0,f:0,gxx:0,gxy:0,gxz:0,gyx:0,gyy:0,gyz:0,gzx:0,gzy:0,gzz:0,cpx:0,cpy:0,cpz:0,K:0,id:``,dist:0,ccx:0,ccy:0,ccz:0}}var nk=new WeakMap;function rk(e){nk.delete(e)}function ik(e,t,n,r=.3,i=null){if(e){let t=`d${r}${+!!n}`;if(nk.get(e)===t)return;nk.set(e,t),e.style.transform=`scale(${r})`,e.parentElement&&(e.parentElement.style.pointerEvents=n?``:`none`)}t&&(t.style.display=`none`,t.style.fontSize=``),i&&(i.style.display=`none`)}function ak(e,t,n,r,i=null){if(e){let t=`r${+!!n}${+!!r}`;if(nk.get(e)===t)return;nk.set(e,t),n||(e.style.transform=``),e.style.border=e.dataset.origBorder??``,e.parentElement&&(e.parentElement.style.pointerEvents=``)}t&&(t.style.display=``,t.style.fontSize=r?`18px`:``),i&&(i.style.display=``)}function ok(e,t,n,r,i,a){let{label:o,labelHalo:s,radiusScene:c}=e;if(!o)return!1;let l=o.visible,u=!e.noPhysical&&c>0?c/r*i:0,d=e.body.data.id===a,f=u>=16;return!t&&n&&(d||u>=1)&&(t=u<320),f&&e.labelAnchorOffscreen&&(t=!1),e.trail&&f&&(e.trail.visible=!1),o.visible=t,s&&e.haloHidden!==f&&(s.style.visibility=f?`hidden`:``,e.haloHidden=f),e.loadingEl&&e.loadingShown!==f&&(e.loadingEl.style.display=f?``:`none`,e.loadingShown=f),o.center.x=f?1-4/32:.5,t&&!l}function sk(e,t,n,r,i){for(let a of i){if(a.id===r)continue;let i=e-a.cx0,o=a.cy0-t,s=-a.f,c=i*a.gxx+o*a.gxy+s*a.gxz,l=i*a.gyx+o*a.gyy+s*a.gyz,u=i*a.gzx+o*a.gzy+s*a.gzz,d=c*a.cpx+l*a.cpy+u*a.cpz;if(!(d<=0)&&!(d*d<=a.K*(c*c+l*l+u*u))&&i*a.ccx+o*a.ccy+s*a.ccz<=n*Math.hypot(i,o,s))return!0}return!1}function ck(e,t){e.left=t.left,e.right=t.right,e.y=t.y,e.h=t.h}function lk(e,t,n,r,i,a){let o=e.label,[s,c,l]=e.body.position,u=o.position;$O.set(s-n[0]+u.x,c-n[1]+u.y,l-n[2]+u.z),$O.project(t),a.x=($O.x*.5+.5)*r,a.y=(-$O.y*.5+.5)*i;let d=a.x-o.center.x*32;return a.left=d,a.right=d+40+(e.labelTextWidth||50),a.h=ek,rT($O.z)}var uk=[],dk=0,fk=[],pk=0,mk=[],hk=0,gk={rects:fk,get count(){return pk}};function _k(){return{bodyId:``,bo:null,body:null,label:null,labelHalo:null,isCapped:!1,isMinor:!1,isFocused:!1,isSelected:!1,rect:{x:0,left:0,right:0,y:0,h:0},dist:0}}function vk(){return{left:0,right:0,y:0,h:0}}var yk={x:0,left:0,right:0,y:0,h:0};function bk(e,t){for(let n=0;n<t;n++)ck(ZO(mk,n,vk),e[n]);hk=t}function xk(){for(let e=0;e<hk;e++)ck(ZO(fk,e,vk),mk[e]);return hk}function Sk(e,t,n,r,i,a,o,s,c=[0,0,0]){dk=0,pk=xk();for(let s of e.values()){let{body:e,label:l,labelHalo:u}=s;if(!l?.visible)continue;if(!s.labelTextWidth&&u){let e=u.nextElementSibling;e&&e.offsetWidth>0&&(s.labelTextWidth=e.offsetWidth)}if(!lk(s,r,c,t,n,yk))continue;let d=e.data.id===i,f=o.has(e.data.id),p=ZO(uk,dk++,_k);ck(p.rect,yk),p.rect.x=yk.x,p.bodyId=e.data.id,p.bo=s,p.body=e,p.label=l,p.labelHalo=u,p.isCapped=e.data.objectType===W.MOON?a.visibility.getMoonVisibility(e)===$.CAPPED:!1,p.isMinor=s.isMinor,p.isFocused=d,p.isSelected=d||f,p.dist=s.cachedDist}uk.length=dk,uk.sort((e,t)=>{if(e.isSelected!==t.isSelected)return e.isSelected?-1:1;let n=e.isMinor&&!e.isSelected;if(n!==(t.isMinor&&!t.isSelected))return n?1:-1;let r=QO(e.body.data.objectType),i=QO(t.body.data.objectType);return r===i?e.dist-t.dist:r-i});for(let e=0;e<dk;e++){let t=uk[e],n=t.labelHalo,r=n?.nextElementSibling;if(t.isCapped&&!t.isSelected){ik(n,r,!0,.3,t.bo.labelStack),t.bo.labelMaximized=!1;continue}if(!t.isSelected&&sk(t.rect.x,t.rect.y,t.dist,t.bodyId,s)){t.label.visible=!1,t.bo.labelMaximized=!1;continue}if(t.isMinor&&!t.isSelected){let e=!1;for(let n=0;n<pk;n++){let r=fk[n];if(t.rect.x-8<r.right&&t.rect.x+8>r.left&&Math.abs(t.rect.y-r.y)<ek){e=!0;break}}ik(n,r,!e,e?.3:.5,t.bo.labelStack),t.bo.labelMaximized=!1;continue}let i=!1;for(let e=0;e<pk;e++){let n=fk[e];if(t.rect.left<n.right&&t.rect.right>n.left&&Math.abs(t.rect.y-n.y)<ek){i=!0;break}}i?(ik(n,r,!1,.3,t.bo.labelStack),t.bo.labelMaximized=!1):(ck(ZO(fk,pk++,vk),t.rect),ak(n,r,o.has(t.bodyId),t.isFocused,t.bo.labelStack),t.bo.labelMaximized=!0)}for(let e=0;e<dk;e++){let t=uk[e];t.bo=null,t.body=null,t.label=null,t.labelHalo=null}}function Ck(e,t,n,r,i){pk=xk();for(let a of e.values())a.label?.visible&&a.labelMaximized!==!1&&lk(a,r,i,t,n,yk)&&ck(ZO(fk,pk++,vk),yk)}var wk=`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,Tk=`M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z`;function Ek(e,t){if(!e)return;let n=e.querySelector(`path`);n&&n.setAttribute(`d`,t?Tk:wk)}function Dk(e,t,n,r){let i=document.createElement(`span`);i.className=`scene-label__name scene-label__name--${n}${r?` scene-label__name--large`:``}`,i.dir=`auto`,i.textContent=t;let a=e.firstElementChild;return a?a.after(i):e.appendChild(i),i}function Ok(e,t,n,r){if(n===`none`||!t||!e.label)return;let i=e.label.element,a=i.querySelector(`.scene-label__name`);a?a.textContent=t:Dk(i,t,n,r),YE(e)}function kk(e){let t=e.data.objectType;return vn(t)||t===W.STAR||_n(t)||t===W.COMET||t===W.BARYCENTER||t===W.LAGRANGE_POINT?`major`:t===W.SPACECRAFT?`spacecraft`:t===W.DEBRIS?`debris`:`none`}function Ak(e,t,n,r,i,a=!1,o,s=!1){if(n===`none`)return null;let c=document.createElement(`a`);c.className=`scene-label scene-label--${n}`,r&&(c.href=r),c.tabIndex=-1,c.draggable=!1,t&&c.setAttribute(`aria-label`,t);let l;if(n===`major`){let t=document.createElement(`div`);t.className=`scene-label__halo scene-label__halo--major`,t.style.border=`2px solid ${e}`,t.style.background=`${e}22`,l=t}else{let t=`http://www.w3.org/2000/svg`,r=document.createElementNS(t,`svg`);r.setAttribute(`viewBox`,`0 0 24 24`),r.setAttribute(`fill`,`${e}22`),r.setAttribute(`stroke`,e),r.setAttribute(`stroke-width`,`2`),r.setAttribute(`stroke-linejoin`,`round`),r.classList.add(`scene-label__halo`,`scene-label__halo--${n}`);let i=document.createElementNS(t,`path`);i.setAttribute(`d`,n===`debris`?`M3 5 L21 5 L12 21 Z`:wk),r.appendChild(i),l=r}c.appendChild(l);let u=0,d=0;c.addEventListener(`pointerdown`,e=>{u=e.clientX,d=e.clientY});let f=e=>{if(e.stopPropagation(),XO(e))return;e.preventDefault();let t=e.clientX-u,n=e.clientY-d;t*t+n*n<=9&&i()};t&&Dk(c,t,n,a),s&&(l.style.transform=`scale(0.3)`),c.addEventListener(`click`,f),c.addEventListener(`mouseenter`,()=>{l.style.transform=`scale(1.15)`,document.body.style.cursor=`pointer`,o?.(!0)}),c.addEventListener(`mouseleave`,()=>{l.style.transform=s?`scale(0.3)`:``,rk(l),document.body.style.cursor=``,o?.(!1)});let p=new YO(c);return p.visible=!1,p}var jk=3;function Mk(e,t){e.addEventListener(`wheel`,e=>{let n=e;t.dispatchEvent(new WheelEvent(`wheel`,{deltaY:n.deltaY,deltaMode:n.deltaMode,bubbles:!0,cancelable:!0})),n.preventDefault()},{passive:!1}),e.addEventListener(`pointerdown`,e=>{let n=e.clientX,r=e.clientY,i=e,a=e=>{let a=e.clientX-n,o=e.clientY-r;a*a+o*o>jk*jk&&(s(),t.dispatchEvent(new PointerEvent(`pointerdown`,i)),t.dispatchEvent(new PointerEvent(`pointermove`,e)))},o=()=>s(),s=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o)})}var Nk=[`low`,`medium`,`high`,`ultra`],Pk={low:{primarySteps:6,lightSteps:2,eclipseShadows:!0,ringShadows:!0,insideView:!0,sunTint:!1,layeredDensity:!1,groundAlbedo:!0,seasonal:!0,refraction:!0},medium:{primarySteps:12,lightSteps:3,eclipseShadows:!0,ringShadows:!0,insideView:!0,sunTint:!1,layeredDensity:!1,groundAlbedo:!0,seasonal:!0,refraction:!0},high:{primarySteps:16,lightSteps:4,eclipseShadows:!0,ringShadows:!0,insideView:!0,sunTint:!0,layeredDensity:!0,groundAlbedo:!0,seasonal:!0,refraction:!0},ultra:{primarySteps:32,lightSteps:8,eclipseShadows:!0,ringShadows:!0,insideView:!0,sunTint:!0,layeredDensity:!0,groundAlbedo:!0,seasonal:!0,refraction:!0}};function Fk(){return Ux()?Vx()?`low`:`medium`:Vx()?`high`:`ultra`}function Ik(e){if(e!==`auto`)return e;let t=jx();return t.atmosphereAutoTier??t.atmosphereCalibration?.tier??Fk()}function Lk(){let e=jx();return{...Pk[Ik(e.atmosphereQuality)],...e.atmoQualityOverrides}}function Rk(e){return`${e.primarySteps}|${e.lightSteps}|${+e.eclipseShadows}|${+e.ringShadows}|${+e.insideView}|${+e.layeredDensity}`}var zk=30,Bk=45,Vk=3e3,Hk=2500,Uk=250,Wk=60,Gk=0,Kk=Hk,qk=``;function Jk(e,t){let n=jx();if(n.atmosphereQuality!==`auto`||e<=0||e>Uk)return;let r=Rk(Lk());if(r!==qk&&(qk=r,Kk=Hk,Gk=0,Wk=60),Wk+=(1e3/e-Wk)*Math.min(1,e/500),Kk>0){Kk-=e;return}if(!t||Wk>Bk){Gk=Math.max(0,Gk-e);return}if(Wk>=zk||(Gk+=e,Gk<Vk))return;Gk=0;let i=Nk[Nk.indexOf(Ik(`auto`))-1];i&&n.setAtmosphereAutoTier(i)}var Yk=256,Xk=96;async function Zk(e,t,n){let r=await fetch(e);if(!r.ok)throw Error(`Failed to load ${e}: ${r.status} ${r.statusText}`);let i=await r.blob(),a=await createImageBitmap(i),o=Math.min(a.width,n);o<a.width&&console.info(`Ring strip ${e}: downscaling ${a.width}px → ${o}px to fit GL MAX_TEXTURE_SIZE.`);let s=Qk(a,e,n),c={};for(let[n,r]of Object.entries(t)){let t=document.createElement(`canvas`);t.width=o,t.height=2;let i=t.getContext(`2d`);if(!i)throw Error(`Failed to acquire 2D context for ring strip ${e}`);let l=$k(s,a.width,r,o);i.putImageData(l,0,0),i.putImageData(l,0,1);let u=new Nc(t);n===`color`&&(u.colorSpace=Xr),u.minFilter=Fn,u.magFilter=Nn,u.generateMipmaps=!0,u.anisotropy=16,u.needsUpdate=!0,c[n]=u}return a.close(),c}function Qk(e,t,n){let r=new Uint8ClampedArray(e.width*e.height*4),i=document.createElement(`canvas`);i.width=Math.min(e.width,n),i.height=e.height;let a=i.getContext(`2d`,{willReadFrequently:!0});if(!a)throw Error(`Failed to acquire 2D context for ring strip ${t}`);for(let t=0;t<e.width;t+=i.width){let n=Math.min(i.width,e.width-t);a.clearRect(0,0,n,e.height),a.drawImage(e,t,0,n,e.height,0,0,n,e.height);let o=a.getImageData(0,0,n,e.height).data;for(let i=0;i<e.height;i++)r.set(o.subarray(i*n*4,(i+1)*n*4),(i*e.width+t)*4)}return r}function $k(e,t,n,r){let i=new ImageData(r,1);for(let a=0;a<r;a++){let o=Math.floor(a*t/r),s=Math.max(o+1,Math.floor((a+1)*t/r)),c=0,l=0,u=0;for(let r=o;r<s;r++){let i=(n*t+r)*4;c+=e[i],l+=e[i+1],u+=e[i+2]}let d=s-o,f=a*4;i.data[f]=Math.round(c/d),i.data[f+1]=Math.round(l/d),i.data[f+2]=Math.round(u/d),i.data[f+3]=255}return i}var eA=`
|
|
4538
|
+
`,BO=class{target;material;scene=new qa;pickCamera;size=0;buffer=new Uint8Array;prevClear=new X;proxies=[];constructor(e,t){this.renderer=e,this.target=new la(1,1,{depthBuffer:!0}),this.target.texture.colorSpace=Zr,this.target.texture.generateMipmaps=!1,this.material=new pu({vertexShader:RO,fragmentShader:zO,uniforms:{uPointSize:{value:IO}},blending:0,depthTest:!0,depthWrite:!0}),this.scene.matrixWorldAutoUpdate=!1,this.pickCamera=t.clone()}ensureSize(e){e!==this.size&&(this.size=e,this.target.setSize(e,e),this.buffer=new Uint8Array(e*e*4))}proxyAt(e,t){let n=this.proxies[e];return n?n.geometry=t.geometry:(n=new Ac(t.geometry,this.material),n.frustumCulled=!1,n.matrixAutoUpdate=!1,n.matrixWorldAutoUpdate=!1,this.proxies[e]=n),n.matrixWorld.copy(t.matrixWorld),n}pick(e,t,n,r,i,a){let o=Math.max(1,Math.round(a)),s=o*2+1;this.ensureSize(s);let c=n-i.left,l=r-i.top,u=c-o,d=l-o;this.scene.clear();let f=0;for(let t of e)t.visible&&t.geometry.getAttribute(`pickColor`)&&t.geometry.drawRange.count!==0&&this.scene.add(this.proxyAt(f++,t));if(f===0)return[];this.pickCamera.copy(t),this.pickCamera.setViewOffset(i.width,i.height,u,d,s,s),this.pickCamera.updateProjectionMatrix();let p=this.renderer.getRenderTarget(),m=this.renderer.autoClear;this.renderer.getClearColor(this.prevClear);let h=this.renderer.getClearAlpha();return this.renderer.setRenderTarget(this.target),this.renderer.autoClear=!1,this.renderer.setClearColor(0,0),this.renderer.clear(!0,!0,!1),this.renderer.render(this.scene,this.pickCamera),this.renderer.readRenderTargetPixels(this.target,0,0,s,s,this.buffer),this.renderer.setRenderTarget(p),this.renderer.autoClear=m,this.renderer.setClearColor(this.prevClear,h),this.pickCamera.clearViewOffset(),this.decode(s,o,i,u,d)}decode(e,t,n,r,i){let a=this.buffer,o=new Map;for(let s=0;s<e;s++){let c=e-1-s;for(let l=0;l<e;l++){let u=(s*e+l)*4,d=(a[u]|a[u+1]<<8|a[u+2]<<16|a[u+3]<<24)>>>0;if(d===0)continue;let f=l-t,p=c-t,m=Math.hypot(f,p),h=o.get(d);if(h&&h.pixelDist<=m)continue;let g=r+l+.5,_=i+c+.5;o.set(d,{pickId:d,pixelDist:m,ndcX:g/n.width*2-1,ndcY:-(_/n.height*2-1)})}}return[...o.values()].sort((e,t)=>e.pixelDist-t.pixelDist).slice(0,LO)}dispose(){this.target.dispose(),this.material.dispose(),this.proxies.length=0}};function VO(e,t,n){return Math.min(Math.max(e,t),n)}function HO(e,t){let n=Math.max(e,0);return VO(t.refMs*n/t.refAngleRad,t.minMs,t.maxMs)}function UO(e,t){if(!(e>0))return t.minMs;let n=Math.log10(e/t.refDist);return VO(t.refMs+n*t.msPerDecade,t.minMs,t.maxMs)}var WO={refMs:350,refAngleRad:Math.PI/3,minMs:200,maxMs:700},GO={refMs:400,refAngleRad:Math.PI/2,minMs:200,maxMs:800},KO={refMs:1600,refDist:2,msPerDecade:400,minMs:600,maxMs:2500},qO={refMs:1600,refAngleRad:Math.PI/2,minMs:600,maxMs:2500},JO=new J(0,1,0),YO=(()=>{let e=Math.PI/180,t=192.85948*e,n=27.12825*e,r=Math.cos(n),i=r*Math.cos(t),a=r*Math.sin(t),o=Math.sin(n),s=ag*e,c=Math.cos(s),l=Math.sin(s),u=i,d=a*c+o*l;return new J(u,-a*l+o*c,-d).normalize()})();function XO(e){return(e??new J).copy(YO)}function ZO(e,t,n,r=!1){let i=n??new J;if(!e.orientation)return r&&e.orbitCenter&&(i.set(e.position[0]-e.orbitCenter[0],e.position[1]-e.orbitCenter[1],e.position[2]-e.orbitCenter[2]),i.lengthSq()>1e-20)?i.normalize():(i.copy(JO),e.modelBaseFrame&&i.applyQuaternion(e.modelBaseFrame).normalize(),i);let a=mC(e.orientation,t,e.nutPrec);return i.copy(JO).applyQuaternion(a).normalize()}var QO=class{refId=null;startVec=new J(0,1,0);targetVec=new J(0,1,0);currentVec=new J(0,1,0);animStartTime=-1/0;animDurationMs=GO.refMs;needsDurationCalc=!1;_quatA=new Hi;_quatB=new Hi;constructor(e,t,n,r){this.camera=e,this.controls=t,this.ctx=n,this.isLanded=r}setNorthReference(e){e!==this.refId&&(this.refId=e,this.startVec.copy(this.currentVec),this.animStartTime=performance.now(),this.needsDurationCalc=!0)}update(e){if(this.refId===`galactic`)XO(this.targetVec);else{let t=this.refId?this.ctx.getBody(this.refId):void 0;if(t){let n=!!t.featureAnchor||this.isLanded(t.data.id);ZO(t,e,this.targetVec,n)}else this.targetVec.copy(JO)}if(this.needsDurationCalc){this.needsDurationCalc=!1;let e=this.startVec.angleTo(this.targetVec);this.animDurationMs=HO(e,GO)}let t=performance.now()-this.animStartTime;if(t>=this.animDurationMs)this.currentVec.copy(this.targetVec);else{let e=Math.max(0,t/this.animDurationMs),n=e*e*(3-2*e);this._quatA.setFromUnitVectors(JO,this.startVec),this._quatB.setFromUnitVectors(JO,this.targetVec),this._quatA.slerp(this._quatB,n),this.currentVec.copy(JO).applyQuaternion(this._quatA)}this.camera.up.copy(this.currentVec);let n=this.controls;n._quat.setFromUnitVectors(this.currentVec,JO),n._quatInverse.copy(n._quat).invert()}},$O=class extends Ra{constructor(e=document.createElement(`div`)){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position=`absolute`,this.element.style.userSelect=`none`,this.element.setAttribute(`draggable`,!1),this.center=new q(.5,.5),this.addEventListener(`removed`,function(){this.traverse(function(e){e.element&&e.element instanceof e.element.ownerDocument.defaultView.Element&&e.element.parentNode!==null&&e.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}};new J,new Y,new Y,new J,new J;function ek(e){return e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey}function tk(e,t,n){let r=e[t];return r||(r=n(),e[t]=r),r}function nk(e){switch(e){case W.STAR:return 0;case W.PLANET:return 1;case W.DWARF_PLANET:return 2;case W.MOON:return 3;default:return 4}}var rk=new J,ik=22;function ak(){return{cx0:0,cy0:0,f:0,gxx:0,gxy:0,gxz:0,gyx:0,gyy:0,gyz:0,gzx:0,gzy:0,gzz:0,cpx:0,cpy:0,cpz:0,K:0,id:``,dist:0,ccx:0,ccy:0,ccz:0}}var ok=new WeakMap;function sk(e){ok.delete(e)}function ck(e,t,n,r=.3,i=null){if(e){let t=`d${r}${+!!n}`;if(ok.get(e)===t)return;ok.set(e,t),e.style.transform=`scale(${r})`,e.parentElement&&(e.parentElement.style.pointerEvents=n?``:`none`)}t&&(t.style.display=`none`,t.style.fontSize=``),i&&(i.style.display=`none`)}function lk(e,t,n,r,i=null){if(e){let t=`r${+!!n}${+!!r}`;if(ok.get(e)===t)return;ok.set(e,t),n||(e.style.transform=``),e.style.border=e.dataset.origBorder??``,e.parentElement&&(e.parentElement.style.pointerEvents=``)}t&&(t.style.display=``,t.style.fontSize=r?`18px`:``),i&&(i.style.display=``)}function uk(e,t,n,r,i,a){let{label:o,labelHalo:s,radiusScene:c}=e;if(!o)return!1;let l=o.visible,u=!e.noPhysical&&c>0?c/r*i:0,d=e.body.data.id===a,f=u>=16;return!t&&n&&(d||u>=1)&&(t=u<320),f&&e.labelAnchorOffscreen&&(t=!1),e.trail&&f&&(e.trail.visible=!1),o.visible=t,s&&e.haloHidden!==f&&(s.style.visibility=f?`hidden`:``,e.haloHidden=f),e.loadingEl&&e.loadingShown!==f&&(e.loadingEl.style.display=f?``:`none`,e.loadingShown=f),o.center.x=f?1-4/32:.5,t&&!l}function dk(e,t,n,r,i){for(let a of i){if(a.id===r)continue;let i=e-a.cx0,o=a.cy0-t,s=-a.f,c=i*a.gxx+o*a.gxy+s*a.gxz,l=i*a.gyx+o*a.gyy+s*a.gyz,u=i*a.gzx+o*a.gzy+s*a.gzz,d=c*a.cpx+l*a.cpy+u*a.cpz;if(!(d<=0)&&!(d*d<=a.K*(c*c+l*l+u*u))&&i*a.ccx+o*a.ccy+s*a.ccz<=n*Math.hypot(i,o,s))return!0}return!1}function fk(e,t){e.left=t.left,e.right=t.right,e.y=t.y,e.h=t.h}function pk(e,t,n,r,i,a){let o=e.label,[s,c,l]=e.body.position,u=o.position;rk.set(s-n[0]+u.x,c-n[1]+u.y,l-n[2]+u.z),rk.project(t),a.x=(rk.x*.5+.5)*r,a.y=(-rk.y*.5+.5)*i;let d=a.x-o.center.x*32;return a.left=d,a.right=d+40+(e.labelTextWidth||50),a.h=ik,aT(rk.z)}var mk=[],hk=0,gk=[],_k=0,vk=[],yk=0,bk={rects:gk,get count(){return _k}};function xk(){return{bodyId:``,bo:null,body:null,label:null,labelHalo:null,isCapped:!1,isMinor:!1,isFocused:!1,isSelected:!1,rect:{x:0,left:0,right:0,y:0,h:0},dist:0}}function Sk(){return{left:0,right:0,y:0,h:0}}var Ck={x:0,left:0,right:0,y:0,h:0};function wk(e,t){for(let n=0;n<t;n++)fk(tk(vk,n,Sk),e[n]);yk=t}function Tk(){for(let e=0;e<yk;e++)fk(tk(gk,e,Sk),vk[e]);return yk}function Ek(e,t,n,r,i,a,o,s,c=[0,0,0]){hk=0,_k=Tk();for(let s of e.values()){let{body:e,label:l,labelHalo:u}=s;if(!l?.visible)continue;if(!s.labelTextWidth&&u){let e=u.nextElementSibling;e&&e.offsetWidth>0&&(s.labelTextWidth=e.offsetWidth)}if(!pk(s,r,c,t,n,Ck))continue;let d=e.data.id===i,f=o.has(e.data.id),p=tk(mk,hk++,xk);fk(p.rect,Ck),p.rect.x=Ck.x,p.bodyId=e.data.id,p.bo=s,p.body=e,p.label=l,p.labelHalo=u,p.isCapped=e.data.objectType===W.MOON?a.visibility.getMoonVisibility(e)===$.CAPPED:!1,p.isMinor=s.isMinor,p.isFocused=d,p.isSelected=d||f,p.dist=s.cachedDist}mk.length=hk,mk.sort((e,t)=>{if(e.isSelected!==t.isSelected)return e.isSelected?-1:1;let n=e.isMinor&&!e.isSelected;if(n!==(t.isMinor&&!t.isSelected))return n?1:-1;let r=nk(e.body.data.objectType),i=nk(t.body.data.objectType);return r===i?e.dist-t.dist:r-i});for(let e=0;e<hk;e++){let t=mk[e],n=t.labelHalo,r=n?.nextElementSibling;if(t.isCapped&&!t.isSelected){ck(n,r,!0,.3,t.bo.labelStack),t.bo.labelMaximized=!1;continue}if(!t.isSelected&&dk(t.rect.x,t.rect.y,t.dist,t.bodyId,s)){t.label.visible=!1,t.bo.labelMaximized=!1;continue}if(t.isMinor&&!t.isSelected){let e=!1;for(let n=0;n<_k;n++){let r=gk[n];if(t.rect.x-8<r.right&&t.rect.x+8>r.left&&Math.abs(t.rect.y-r.y)<ik){e=!0;break}}ck(n,r,!e,e?.3:.5,t.bo.labelStack),t.bo.labelMaximized=!1;continue}let i=!1;for(let e=0;e<_k;e++){let n=gk[e];if(t.rect.left<n.right&&t.rect.right>n.left&&Math.abs(t.rect.y-n.y)<ik){i=!0;break}}i?(ck(n,r,!1,.3,t.bo.labelStack),t.bo.labelMaximized=!1):(fk(tk(gk,_k++,Sk),t.rect),lk(n,r,o.has(t.bodyId),t.isFocused,t.bo.labelStack),t.bo.labelMaximized=!0)}for(let e=0;e<hk;e++){let t=mk[e];t.bo=null,t.body=null,t.label=null,t.labelHalo=null}}function Dk(e,t,n,r,i){_k=Tk();for(let a of e.values())a.label?.visible&&a.labelMaximized!==!1&&pk(a,r,i,t,n,Ck)&&fk(tk(gk,_k++,Sk),Ck)}var Ok=`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,kk=`M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z`,Ak={flying:Ok,landed:kk,crashed:kk+`M15 9l-6 6M9 9l6 6`};function jk(e,t){if(!e)return;let n=e.querySelector(`path`);n&&n.setAttribute(`d`,Ak[t])}function Mk(e,t,n,r){let i=document.createElement(`span`);i.className=`scene-label__name scene-label__name--${n}${r?` scene-label__name--large`:``}`,i.dir=`auto`,i.textContent=t;let a=e.firstElementChild;return a?a.after(i):e.appendChild(i),i}function Nk(e,t,n,r){if(n===`none`||!t||!e.label)return;let i=e.label.element,a=i.querySelector(`.scene-label__name`);a?a.textContent=t:Mk(i,t,n,r),$E(e)}function Pk(e){let t=e.data.objectType;return vn(t)||t===W.STAR||_n(t)||t===W.COMET||t===W.BARYCENTER||t===W.LAGRANGE_POINT?`major`:t===W.SPACECRAFT?`spacecraft`:t===W.DEBRIS?`debris`:`none`}function Fk(e,t,n,r,i,a=!1,o,s=!1){if(n===`none`)return null;let c=document.createElement(`a`);c.className=`scene-label scene-label--${n}`,r&&(c.href=r),c.tabIndex=-1,c.draggable=!1,t&&c.setAttribute(`aria-label`,t);let l;if(n===`major`){let t=document.createElement(`div`);t.className=`scene-label__halo scene-label__halo--major`,t.style.border=`2px solid ${e}`,t.style.background=`${e}22`,l=t}else{let t=`http://www.w3.org/2000/svg`,r=document.createElementNS(t,`svg`);r.setAttribute(`viewBox`,`0 0 24 24`),r.setAttribute(`fill`,`${e}22`),r.setAttribute(`stroke`,e),r.setAttribute(`stroke-width`,`2`),r.setAttribute(`stroke-linejoin`,`round`),r.classList.add(`scene-label__halo`,`scene-label__halo--${n}`);let i=document.createElementNS(t,`path`);i.setAttribute(`d`,n===`debris`?`M3 5 L21 5 L12 21 Z`:Ok),r.appendChild(i),l=r}c.appendChild(l);let u=0,d=0;c.addEventListener(`pointerdown`,e=>{u=e.clientX,d=e.clientY});let f=e=>{if(e.stopPropagation(),ek(e))return;e.preventDefault();let t=e.clientX-u,n=e.clientY-d;t*t+n*n<=9&&i()};t&&Mk(c,t,n,a),s&&(l.style.transform=`scale(0.3)`),c.addEventListener(`click`,f),c.addEventListener(`mouseenter`,()=>{l.style.transform=`scale(1.15)`,document.body.style.cursor=`pointer`,o?.(!0)}),c.addEventListener(`mouseleave`,()=>{l.style.transform=s?`scale(0.3)`:``,sk(l),document.body.style.cursor=``,o?.(!1)});let p=new $O(c);return p.visible=!1,p}var Ik=3;function Lk(e,t){e.addEventListener(`wheel`,e=>{let n=e;t.dispatchEvent(new WheelEvent(`wheel`,{deltaY:n.deltaY,deltaMode:n.deltaMode,bubbles:!0,cancelable:!0})),n.preventDefault()},{passive:!1}),e.addEventListener(`pointerdown`,e=>{let n=e.clientX,r=e.clientY,i=e,a=e=>{let a=e.clientX-n,o=e.clientY-r;a*a+o*o>Ik*Ik&&(s(),t.dispatchEvent(new PointerEvent(`pointerdown`,i)),t.dispatchEvent(new PointerEvent(`pointermove`,e)))},o=()=>s(),s=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o)})}var Rk=[`low`,`medium`,`high`,`ultra`],zk={low:{primarySteps:6,lightSteps:2,eclipseShadows:!0,ringShadows:!0,insideView:!0,sunTint:!1,layeredDensity:!1,groundAlbedo:!0,seasonal:!0,refraction:!0},medium:{primarySteps:12,lightSteps:3,eclipseShadows:!0,ringShadows:!0,insideView:!0,sunTint:!1,layeredDensity:!1,groundAlbedo:!0,seasonal:!0,refraction:!0},high:{primarySteps:16,lightSteps:4,eclipseShadows:!0,ringShadows:!0,insideView:!0,sunTint:!0,layeredDensity:!0,groundAlbedo:!0,seasonal:!0,refraction:!0},ultra:{primarySteps:32,lightSteps:8,eclipseShadows:!0,ringShadows:!0,insideView:!0,sunTint:!0,layeredDensity:!0,groundAlbedo:!0,seasonal:!0,refraction:!0}};function Bk(){return Wx()?Hx()?`low`:`medium`:Hx()?`high`:`ultra`}function Vk(e){if(e!==`auto`)return e;let t=Mx();return t.atmosphereAutoTier??t.atmosphereCalibration?.tier??Bk()}function Hk(){let e=Mx();return{...zk[Vk(e.atmosphereQuality)],...e.atmoQualityOverrides}}function Uk(e){return`${e.primarySteps}|${e.lightSteps}|${+e.eclipseShadows}|${+e.ringShadows}|${+e.insideView}|${+e.layeredDensity}`}var Wk=30,Gk=45,Kk=3e3,qk=2500,Jk=250,Yk=60,Xk=0,Zk=qk,Qk=``;function $k(e,t){let n=Mx();if(n.atmosphereQuality!==`auto`||e<=0||e>Jk)return;let r=Uk(Hk());if(r!==Qk&&(Qk=r,Zk=qk,Xk=0,Yk=60),Yk+=(1e3/e-Yk)*Math.min(1,e/500),Zk>0){Zk-=e;return}if(!t||Yk>Gk){Xk=Math.max(0,Xk-e);return}if(Yk>=Wk||(Xk+=e,Xk<Kk))return;Xk=0;let i=Rk[Rk.indexOf(Vk(`auto`))-1];i&&n.setAtmosphereAutoTier(i)}var eA=256,tA=96;async function nA(e,t,n){let r=await fetch(e);if(!r.ok)throw Error(`Failed to load ${e}: ${r.status} ${r.statusText}`);let i=await r.blob(),a=await createImageBitmap(i),o=Math.min(a.width,n);o<a.width&&console.info(`Ring strip ${e}: downscaling ${a.width}px → ${o}px to fit GL MAX_TEXTURE_SIZE.`);let s=rA(a,e,n),c={};for(let[n,r]of Object.entries(t)){let t=document.createElement(`canvas`);t.width=o,t.height=2;let i=t.getContext(`2d`);if(!i)throw Error(`Failed to acquire 2D context for ring strip ${e}`);let l=iA(s,a.width,r,o);i.putImageData(l,0,0),i.putImageData(l,0,1);let u=new Nc(t);n===`color`&&(u.colorSpace=Xr),u.minFilter=Fn,u.magFilter=Nn,u.generateMipmaps=!0,u.anisotropy=16,u.needsUpdate=!0,c[n]=u}return a.close(),c}function rA(e,t,n){let r=new Uint8ClampedArray(e.width*e.height*4),i=document.createElement(`canvas`);i.width=Math.min(e.width,n),i.height=e.height;let a=i.getContext(`2d`,{willReadFrequently:!0});if(!a)throw Error(`Failed to acquire 2D context for ring strip ${t}`);for(let t=0;t<e.width;t+=i.width){let n=Math.min(i.width,e.width-t);a.clearRect(0,0,n,e.height),a.drawImage(e,t,0,n,e.height,0,0,n,e.height);let o=a.getImageData(0,0,n,e.height).data;for(let i=0;i<e.height;i++)r.set(o.subarray(i*n*4,(i+1)*n*4),(i*e.width+t)*4)}return r}function iA(e,t,n,r){let i=new ImageData(r,1);for(let a=0;a<r;a++){let o=Math.floor(a*t/r),s=Math.max(o+1,Math.floor((a+1)*t/r)),c=0,l=0,u=0;for(let r=o;r<s;r++){let i=(n*t+r)*4;c+=e[i],l+=e[i+1],u+=e[i+2]}let d=s-o,f=a*4;i.data[f]=Math.round(c/d),i.data[f+1]=Math.round(l/d),i.data[f+2]=Math.round(u/d),i.data[f+3]=255}return i}var aA=`
|
|
4539
4539
|
#include <common>
|
|
4540
4540
|
#include <logdepthbuf_pars_vertex>
|
|
4541
4541
|
|
|
@@ -4570,7 +4570,7 @@ void main() {
|
|
|
4570
4570
|
gl_Position = projectionMatrix * viewMatrix * worldPosition;
|
|
4571
4571
|
#include <logdepthbuf_vertex>
|
|
4572
4572
|
}
|
|
4573
|
-
`,
|
|
4573
|
+
`,oA=`
|
|
4574
4574
|
#include <common>
|
|
4575
4575
|
#include <logdepthbuf_pars_fragment>
|
|
4576
4576
|
|
|
@@ -4686,7 +4686,7 @@ void main() {
|
|
|
4686
4686
|
gl_FragColor = vec4(finalAlbedo * uIntensityScale * shadow * uLightScale, alpha);
|
|
4687
4687
|
#include <logdepthbuf_fragment>
|
|
4688
4688
|
}
|
|
4689
|
-
`,
|
|
4689
|
+
`,sA=`
|
|
4690
4690
|
uniform sampler2D uRingShadowTransparency;
|
|
4691
4691
|
uniform float uRingShadowInnerScene;
|
|
4692
4692
|
uniform float uRingShadowOuterScene; // 0 = no rings
|
|
@@ -4739,14 +4739,14 @@ void main() {
|
|
|
4739
4739
|
// to avoid blow-up near grazing incidence.
|
|
4740
4740
|
return pow(max(trans, 1e-4), 1.0 / max(abs(denom), 0.02));
|
|
4741
4741
|
}
|
|
4742
|
-
`;function
|
|
4742
|
+
`;function cA(e,t,n,r,i){let a=e.userData,o=a.ringShadow;if(o)return o.uRingShadowTransparency.value=r,o.uRingShadowInnerScene.value=t,o.uRingShadowOuterScene.value=n,o.uRingShadowIntensity.value=i,o;let s=e.onBeforeCompile,c={uRingShadowTransparency:{value:r},uRingShadowInnerScene:{value:t},uRingShadowOuterScene:{value:n},uRingShadowIntensity:{value:i},uRingShadowSunAngularRadius:{value:0},uRingShadowSunDir:{value:new J(1,0,0)},uRingShadowPoleDir:{value:new J(0,1,0)},uRingShadowCenter:{value:new J(0,0,0)},disable:()=>{c.uRingShadowIntensity.value=0,c.uRingShadowTransparency.value=null}};return e.onBeforeCompile=(e,t)=>{s?.(e,t),Object.assign(e.uniforms,c),e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
|
|
4743
4743
|
varying vec3 vRingShadowWorldPos;`).replace(`#include <begin_vertex>`,`#include <begin_vertex>
|
|
4744
4744
|
vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
|
|
4745
4745
|
varying vec3 vRingShadowWorldPos;
|
|
4746
|
-
${
|
|
4746
|
+
${sA}`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>
|
|
4747
4747
|
float ringShadow = ringShadowAt(vRingShadowWorldPos);
|
|
4748
4748
|
reflectedLight.directDiffuse *= ringShadow;
|
|
4749
|
-
reflectedLight.directSpecular *= ringShadow;`)},
|
|
4749
|
+
reflectedLight.directSpecular *= ringShadow;`)},PC(e,`ringShadow`),e.needsUpdate=!0,a.ringShadow=c,c}async function lA(e,t,n){let r=Q(t.inner_radius_km),i=Q(t.outer_radius_km),a=t.intensity_scale??1,o;try{o=await nA(Yt(`/v1/rings/${e}/${t.strip}`,`rings`),t.strip_rows,n)}catch(t){return console.warn(`Failed to load ring strip for ${e}:`,t),null}let s=t.thickness_scale_km&&o.thickness?Q(t.thickness_scale_km):0,c=s>0?48:1,l=new fu({uniforms:{uBackscattered:{value:o.backscattered},uForwardscattered:{value:o.forwardscattered},uUnlitside:{value:o.unlitside},uTransparency:{value:o.transparency},uColor:{value:o.color},uThickness:{value:o.thickness??o.transparency},uThicknessScene:{value:s},uLayerCount:{value:1},uLayerAlphaExp:{value:1},uInnerScene:{value:r},uOuterScene:{value:i},uSunDir:{value:new J(1,0,0)},uSunAngularRadius:{value:0},uPlanetCenter:{value:new J},uPlanetPoleDir:{value:new J(0,1,0)},uPlanetEquatorialScene:{value:0},uPlanetPolarScene:{value:0},uLightScale:{value:1},uIntensityScale:{value:a}},vertexShader:aA,fragmentShader:oA,transparent:!0,depthWrite:!1,blending:1,side:2}),u=new eu(r,i*(1/Math.cos(Math.PI/eA)),eA,c>1?tA:1);u.rotateX(-Math.PI/2);let d;if(c>1){u.setAttribute(`aLayerIndex`,new Js(Float32Array.from({length:c},(e,t)=>t),1));let e=new nc(u,l,c);e.count=1,d=e}else d=new As(u,l);d.frustumCulled=!1,d.renderOrder=3,d.userData.isRingMesh=!0;let f={uPlanetCenter:l.uniforms.uPlanetCenter,uPlanetPoleDir:l.uniforms.uPlanetPoleDir,uPlanetEquatorialScene:l.uniforms.uPlanetEquatorialScene,uPlanetPolarScene:l.uniforms.uPlanetPolarScene};return{mesh:d,material:l,layers:d instanceof nc?d:null,thicknessScene:s,transparency:o.transparency,intensityScale:a,innerScene:r,outerScene:i,planetShadow:null,planetShadowOnRing:f}}function uA(e){e.mesh.geometry.dispose();let t=e.material.uniforms;for(let e of[`uBackscattered`,`uForwardscattered`,`uUnlitside`,`uTransparency`,`uColor`,`uThickness`])(t[e]?.value)?.dispose();e.mesh.material.dispose()}var dA=null;function fA(){return dA||(dA=new Ws(new Uint8Array([255,255,255,255]),1,1),dA.needsUpdate=!0),dA}function pA(e){let t=new Float32Array(e.length*4);for(let n=0;n<e.length;n++)t[n*4]=e[n],t[n*4+3]=1;let n=new Ws(t,e.length,1,Zn,Hn);return n.needsUpdate=!0,n}function mA(e,t,n){if(t===n)return;let r=e.uniforms;r.uMieProfileTex.value!==dA&&r.uMieProfileTex.value.dispose(),r.uMieProfileTex.value=n?pA(n):fA(),r.uMieProfileOn.value=+!!n,r.uMieProfileN.value=n?.length??1}function hA(e){let t=new Float32Array(512);for(let n=0;n<128;n++)t[n*4]=e[n],t[n*4+1]=e[n+128],t[n*4+2]=e[n+256],t[n*4+3]=1;let n=new Ws(t,128,1,Zn,Hn);return n.needsUpdate=!0,n}var gA=new WeakMap;function _A(e){let t=gA.get(e);if(t)return t;let n=e.n,r=new Float32Array(n*3*4),i=[e.fluxDown,e.fluxUpRatio,e.extinctionPerKm];for(let e=0;e<3;e++)for(let t=0;t<n;t++){let a=(e*n+t)*4;for(let o=0;o<3;o++)r[a+o]=i[e][o*n+t];r[a+3]=1}return t=new Ws(r,n,3,Zn,Hn),t.needsUpdate=!0,gA.set(e,t),t}function vA(e,t,n){if(t===n)return;let r=e.uniforms;r.uDeepTex.value=n?_A(n):fA(),r.uDeepN.value=n?.n??1}function yA(e,t){return t+(e.referenceAltitudeKm??0)}var bA=`
|
|
4750
4750
|
#include <common>
|
|
4751
4751
|
#include <logdepthbuf_pars_vertex>
|
|
4752
4752
|
|
|
@@ -4763,7 +4763,7 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
4763
4763
|
gl_Position = projectionMatrix * viewMatrix * worldPos;
|
|
4764
4764
|
#include <logdepthbuf_vertex>
|
|
4765
4765
|
}
|
|
4766
|
-
`,
|
|
4766
|
+
`,xA=`
|
|
4767
4767
|
#include <common>
|
|
4768
4768
|
#include <logdepthbuf_pars_fragment>
|
|
4769
4769
|
|
|
@@ -4830,11 +4830,11 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
4830
4830
|
varying vec3 vWorldPos;
|
|
4831
4831
|
varying vec3 vPlanetCenter;
|
|
4832
4832
|
|
|
4833
|
-
${
|
|
4833
|
+
${LC}
|
|
4834
4834
|
|
|
4835
4835
|
// Ring shadow on the air column: the same uniforms the planet surface
|
|
4836
4836
|
// marches, shared by value-ref once rings load.
|
|
4837
|
-
${
|
|
4837
|
+
${sA}
|
|
4838
4838
|
|
|
4839
4839
|
// PRIMARY_STEPS / LIGHT_STEPS and the ATMO_ECLIPSE / ATMO_RING_SHADOW /
|
|
4840
4840
|
// ATMO_INSIDE feature flags come from material.defines — quality tiers
|
|
@@ -5244,7 +5244,7 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5244
5244
|
gl_FragColor = vec4(color, alpha);
|
|
5245
5245
|
#include <logdepthbuf_fragment>
|
|
5246
5246
|
}
|
|
5247
|
-
`;function
|
|
5247
|
+
`;function SA(e,t,n,r){let i=e=>e*r,a=t.rayleighScatterPerKm,o=t.mieScatterPerKm,s=t.mieAbsorptionPerKm,c=t.absorptionPerKm,l=e.uniforms;l.uPlanetRadiusScene.value=n,l.uAtmosphereRatio.value=1+t.topAltitudeKm/r,l.uSurfaceBlockR.value=1,l.uRayleighScatter.value.set(i(a[0]),i(a[1]),i(a[2])),l.uRayleighScaleHeight.value=t.rayleighScaleHeightKm/r,l.uMieScatter.value.set(i(o[0]),i(o[1]),i(o[2])),l.uMieExtinction.value.set(i(o[0]+s[0]),i(o[1]+s[1]),i(o[2]+s[2])),l.uMieScaleHeight.value=t.mieScaleHeightKm/r,l.uAbsorption.value.set(i(c[0]),i(c[1]),i(c[2])),l.uAbsorptionCenter.value=t.absorptionCenterKm/r,l.uAbsorptionWidth.value=t.absorptionWidthKm/r,l.uDeepBaseR.value=1-(t.referenceAltitudeKm??0)/r,l.uDeepSpanR.value=t.deepColumn?t.deepColumn.topKm/r:0,l.uDeepKmPerRadius.value=r}function CA(e,t,n){let r=yA(e,n),i=t*r/n,a=e.sunColor,o=RC(),s=Hk(),c=new fu({defines:kA(s),uniforms:{uSunAngularRadius:o.uSunAngularRadius,uOccluderCount:{value:0},uOccluders:{value:Array.from({length:32},()=>new sa)},uSunDir:{value:new J(1,0,0)},uSpinAxis:{value:new J(0,1,0)},uStretch:{value:1},uPlanetRadiusScene:{value:0},uAtmosphereRatio:{value:0},uSurfaceBlockR:{value:1},uRingShadowTransparency:{value:fA()},uRingShadowInnerScene:{value:0},uRingShadowOuterScene:{value:0},uRingShadowIntensity:{value:1},uRingShadowSunAngularRadius:{value:0},uRingShadowSunDir:{value:new J(1,0,0)},uRingShadowPoleDir:{value:new J(0,1,0)},uRingShadowCenter:{value:new J},uRayleighScatter:{value:new J},uRayleighScaleHeight:{value:0},uMieScatter:{value:new J},uMieExtinction:{value:new J},uMieScaleHeight:{value:0},uMiePhaseTex:{value:hA(e.miePhase)},uMieProfileTex:{value:e.mieProfile?pA(e.mieProfile):fA()},uMieProfileOn:{value:+!!e.mieProfile},uMieProfileN:{value:e.mieProfile?.length??1},uDeepTex:{value:e.deepColumn?_A(e.deepColumn):fA()},uDeepN:{value:e.deepColumn?.n??1},uDeepBaseR:{value:1},uDeepSpanR:{value:0},uDeepKmPerRadius:{value:1},uDeepOn:{value:0},uDeepBlend:{value:0},uDeepIrradiance:{value:0},uGroundAlbedo:{value:e.groundAlbedo??0},uAbsorption:{value:new J},uAbsorptionCenter:{value:0},uAbsorptionWidth:{value:0},uMultiScatter:{value:e.multiScatterGain},uBakedComp:{value:e.bakedCompensation},uSunIntensity:{value:e.sunIntensity},uSunColor:{value:new J(a[0],a[1],a[2])},uSceneDepth:{value:fA()},uUseDepth:{value:0},uReversedDepth:{value:0},uCamForward:{value:new J(0,0,-1)},uCameraNear:{value:.001},uCameraFar:{value:1},uResolution:{value:new q(1,1)}},vertexShader:bA,fragmentShader:xA,transparent:!0,depthWrite:!0,blending:5,blendSrc:201,blendDst:205,side:0});SA(c,e,i,r);let l=i*(1+e.topAltitudeKm/r),u=new As(new ru(l,64,64),c);return u.renderOrder=2,u.userData.isAtmosphereMesh=!0,{mesh:u,material:c,params:e,geometryRadiusScene:l,planetRadiusKm:r,surfaceRadiusKm:n,surfaceRadiusScene:t,qualityKey:Uk(s)}}function wA(e,t,n,r=+!!n){let i=e.material,a=i.uniforms,o=e.planetRadiusKm-e.surfaceRadiusKm;i.side=+!!t,e.mesh.renderOrder=t?10:2,i.depthWrite=!t,i.depthTest=!t;let s=t&&(n||o===0);a.uUseDepth.value=+!!s,a.uSurfaceBlockR.value=s?1-(o+6)/e.planetRadiusKm:1,a.uDeepOn.value=+!!n,a.uDeepBlend.value=r}var TA=2;function EA(e){return(e.deepColumn?.topKm??0)-(e.referenceAltitudeKm??0)}function DA(e,t){return!!e.deepColumn&&t<EA(e)}function OA(e,t){if(!e.deepColumn)return 0;let n=TA*e.mieScaleHeightKm,r=Math.min(1,Math.max(0,(t-EA(e))/n));return 1-r*r*(3-2*r)}function kA(e){let t={PRIMARY_STEPS:e.primarySteps,LIGHT_STEPS:e.lightSteps};return e.eclipseShadows&&(t.ATMO_ECLIPSE=``),e.ringShadows&&(t.ATMO_RING_SHADOW=``),e.insideView&&(t.ATMO_INSIDE=``),e.layeredDensity&&(t.ATMO_LAYERED=``),t}function AA(e,t){let n=Uk(t);n!==e.qualityKey&&(e.qualityKey=n,e.material.defines=kA(t),e.material.needsUpdate=!0)}function jA(e,t){mA(e.material,e.params.mieProfile,t.mieProfile),vA(e.material,e.params.deepColumn,t.deepColumn),e.params=t;let n=e.material.uniforms;n.uGroundAlbedo.value=t.groundAlbedo??0,e.planetRadiusKm=yA(t,e.surfaceRadiusKm);let r=e.surfaceRadiusScene*e.planetRadiusKm/e.surfaceRadiusKm;SA(e.material,t,r,e.planetRadiusKm),n.uMultiScatter.value=t.multiScatterGain,n.uBakedComp.value=t.bakedCompensation;let i=t.sunColor;n.uSunColor.value.set(i[0],i[1],i[2]);let a=r*(1+t.topAltitudeKm/e.planetRadiusKm);e.mesh.scale.setScalar(a/e.geometryRadiusScene)}function MA(e,t,n,r){e.surfaceRadiusKm=t,e.surfaceRadiusScene=r,e.planetRadiusKm=yA(e.params,t);let i=r*e.planetRadiusKm/t;SA(e.material,e.params,i,e.planetRadiusKm),e.material.uniforms.uStretch.value=e.planetRadiusKm/yA(e.params,n);let a=i*(1+e.params.topAltitudeKm/e.planetRadiusKm);e.mesh.scale.setScalar(a/e.geometryRadiusScene)}function NA(e,t,n,r,i){let a=e.material.uniforms;a.uRingShadowTransparency.value=n,a.uRingShadowInnerScene.value=r,a.uRingShadowOuterScene.value=i,a.uRingShadowSunDir=t.uRingShadowSunDir,a.uRingShadowPoleDir=t.uRingShadowPoleDir,a.uRingShadowCenter=t.uRingShadowCenter,a.uRingShadowIntensity=t.uRingShadowIntensity,a.uRingShadowSunAngularRadius=t.uRingShadowSunAngularRadius}function PA(e){e.mesh.geometry.dispose(),e.material.uniforms.uMiePhaseTex.value.dispose();let t=e.material.uniforms.uMieProfileTex.value;t!==dA&&t.dispose(),e.mesh.material.dispose()}var FA=6,IA=16,LA={uAtmoTEnable:{value:1}};function RA(e){LA.uAtmoTEnable.value=+!!e}var zA=`
|
|
5248
5248
|
uniform vec3 uAtmoTBetaR; // Rayleigh β, per planet radius, (R,G,B)
|
|
5249
5249
|
uniform vec3 uAtmoTBetaMExt; // Mie extinction β, per planet radius
|
|
5250
5250
|
uniform vec3 uAtmoTBetaA; // absorber band β, per planet radius
|
|
@@ -5294,11 +5294,11 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5294
5294
|
vec3 atmoTSquash(vec3 v) {
|
|
5295
5295
|
return v + (uAtmoTStretch - 1.0) * dot(v, uAtmoTSpinAxis) * uAtmoTSpinAxis;
|
|
5296
5296
|
}
|
|
5297
|
-
`,
|
|
5297
|
+
`,BA=`
|
|
5298
5298
|
// Eclipse's uSunDir/uEclipseSelfPos are declared after this chunk's
|
|
5299
5299
|
// insertion point — same value refs re-bound under own names.
|
|
5300
5300
|
uniform vec3 uAtmoTSunDir;
|
|
5301
|
-
${
|
|
5301
|
+
${zA}
|
|
5302
5302
|
|
|
5303
5303
|
// Column (∫density above h) of the linear-tent absorber, in radii of
|
|
5304
5304
|
// surface-density-equivalent path — mirrors tentColumnAboveKm.
|
|
@@ -5348,9 +5348,9 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5348
5348
|
float tFar = -b + sqrt(d);
|
|
5349
5349
|
if (tFar <= 0.0) return vec3(1.0);
|
|
5350
5350
|
// Fragment sits inside the shell → the segment starts at the fragment.
|
|
5351
|
-
float dt = tFar / ${
|
|
5351
|
+
float dt = tFar / ${FA.toFixed(1)};
|
|
5352
5352
|
vec3 od = vec3(0.0);
|
|
5353
|
-
for (int i = 0; i < ${
|
|
5353
|
+
for (int i = 0; i < ${FA}; i++) {
|
|
5354
5354
|
float h = max(length(p + sd * (dt * (float(i) + 0.5))) - 1.0, 0.0);
|
|
5355
5355
|
od += vec3(
|
|
5356
5356
|
exp(-h / uAtmoTRayleighH),
|
|
@@ -5390,8 +5390,8 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5390
5390
|
float w = 0.5 + 0.5 * dot(worldNormal, up);
|
|
5391
5391
|
return mix(down * atmoTDeepTap(1.0, zf), down, w) * uAtmoTDeepBlend;
|
|
5392
5392
|
}
|
|
5393
|
-
`,
|
|
5394
|
-
${
|
|
5393
|
+
`,VA=`
|
|
5394
|
+
${zA}
|
|
5395
5395
|
|
|
5396
5396
|
vec3 atmoViewTint(vec3 worldPos) {
|
|
5397
5397
|
if (uAtmoTEnable < 0.5) return vec3(1.0);
|
|
@@ -5409,9 +5409,9 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5409
5409
|
float t1 = -b + s;
|
|
5410
5410
|
if (t1 <= 0.0) return vec3(1.0);
|
|
5411
5411
|
float t0 = max(-b - s, 0.0);
|
|
5412
|
-
float dt = (t1 - t0) / ${
|
|
5412
|
+
float dt = (t1 - t0) / ${FA.toFixed(1)};
|
|
5413
5413
|
vec3 od = vec3(0.0);
|
|
5414
|
-
for (int i = 0; i < ${
|
|
5414
|
+
for (int i = 0; i < ${FA}; i++) {
|
|
5415
5415
|
float h = max(length(p + rd * (t0 + dt * (float(i) + 0.5))) - 1.0, 0.0);
|
|
5416
5416
|
od += vec3(
|
|
5417
5417
|
exp(-h / uAtmoTRayleighH),
|
|
@@ -5424,13 +5424,13 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5424
5424
|
float lum = dot(t, vec3(0.2126, 0.7152, 0.0722));
|
|
5425
5425
|
return t / max(lum, 1e-4);
|
|
5426
5426
|
}
|
|
5427
|
-
`;function
|
|
5427
|
+
`;function HA(e){return{uAtmoTBetaR:{value:new J},uAtmoTBetaMExt:{value:new J},uAtmoTBetaA:{value:new J},uAtmoTRayleighH:{value:0},uAtmoTMieH:{value:0},uAtmoTAbsCenter:{value:0},uAtmoTAbsWidth:{value:0},uAtmoTTopR:{value:0},uAtmoTBlockR:{value:0},uAtmoTBakedComp:{value:0},uAtmoTRadiusScene:{value:0},uAtmoTEnable:e,uAtmoTSpinAxis:{value:new J(0,1,0)},uAtmoTStretch:{value:1},uAtmoTMeshR:{value:1},uAtmoTDeepTex:{value:WA()},uAtmoTDeepN:{value:1},uAtmoTDeepBaseR:{value:1},uAtmoTDeepSpanR:{value:0},uAtmoTDeepKmPerRadius:{value:1},uAtmoTDeepIrradiance:{value:0},uAtmoTDeepBlend:{value:0}}}var UA=null;function WA(){return UA||(UA=new Ws(new Uint8Array([255,255,255,255]),1,1),UA.needsUpdate=!0),UA}function GA(e,t,n,r){let i=r;r=yA(t,i),n=n*r/i;let a=e=>e*r,o=t.rayleighScatterPerKm,s=t.mieScatterPerKm,c=t.mieAbsorptionPerKm,l=t.absorptionPerKm;e.uAtmoTBetaR.value.set(a(o[0]),a(o[1]),a(o[2])),e.uAtmoTBetaMExt.value.set(a(s[0]+c[0]),a(s[1]+c[1]),a(s[2]+c[2])),e.uAtmoTBetaA.value.set(a(l[0]),a(l[1]),a(l[2])),e.uAtmoTRayleighH.value=t.rayleighScaleHeightKm/r,e.uAtmoTMieH.value=t.mieScaleHeightKm/r,e.uAtmoTAbsCenter.value=t.absorptionCenterKm/r,e.uAtmoTAbsWidth.value=t.absorptionWidthKm/r,e.uAtmoTTopR.value=1+t.topAltitudeKm/r,e.uAtmoTBlockR.value=1-6/r-.015,e.uAtmoTBakedComp.value=t.bakedCompensation,e.uAtmoTRadiusScene.value=n;let u=t.deepColumn;e.uAtmoTDeepTex.value=u?_A(u):WA(),e.uAtmoTDeepN.value=u?.n??1,e.uAtmoTDeepBaseR.value=i/r,e.uAtmoTDeepSpanR.value=u?u.topKm/r:0,e.uAtmoTDeepKmPerRadius.value=r}function KA(){return{...HA({value:0}),uAtmoTCenter:{value:new J}}}function qA(e,t,n,r,i,a,o=1){GA(e,t,r,i),e.uAtmoTCenter.value.copy(n),a?e.uAtmoTSpinAxis.value.copy(a):e.uAtmoTSpinAxis.value.set(0,1,0),e.uAtmoTStretch.value=o,e.uAtmoTEnable.value=1}function JA(e,t,n,r,i,a,o=1){let s={...HA(LA.uAtmoTEnable),uAtmoTSunDir:RC().uSunDir,uAtmoTCenter:i.uEclipseSelfPos};return s.uAtmoTMeshR.value=o*r/yA(t,r),a&&(s.uAtmoTSpinAxis=a.material.uniforms.uSpinAxis,s.uAtmoTStretch=a.material.uniforms.uStretch),GA(s,t,n,r),FC(e,`sunTint`,e=>{Object.assign(e.uniforms,s),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>\n${BA}`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>
|
|
5428
5428
|
vec3 atmoTint = atmoSunTint(vEclipseWorldPos);
|
|
5429
5429
|
reflectedLight.directDiffuse *= atmoTint;
|
|
5430
5430
|
reflectedLight.directSpecular *= atmoTint;
|
|
5431
5431
|
reflectedLight.indirectDiffuse +=
|
|
5432
5432
|
atmoDeepSkyLight(vEclipseWorldPos, inverseTransformDirection(normal, viewMatrix)) *
|
|
5433
|
-
BRDF_Lambert(diffuseColor.rgb);`)}),s}var
|
|
5433
|
+
BRDF_Lambert(diffuseColor.rgb);`)}),s}var YA=new J,XA=new J;function ZA(e,t,n){return!t||n===1?e:e.addScaledVector(t,(n-1)*e.dot(t))}function QA(e,t,n,r,i,a,o,s=1){let c=i;i=yA(e,c),r=r*i/c;let l=ZA(YA.copy(t).divideScalar(r),o,s),u=ZA(XA.copy(n),o,s),d=u.length();u.divideScalar(d);let f=1+e.topAltitudeKm/i,p=1-6/i-.015,m=l.dot(u),h=l.lengthSq(),g=m*m-(h-p*p);if(g>0&&-m-Math.sqrt(g)>0||(g=m*m-(h-f*f),g<=0))return!1;let _=Math.sqrt(g),v=-m+_;if(v<=0)return!1;let y=Math.max(-m-_,0),b=(v-y)/IA,x=b*i/d,S=0,C=0,w=0;for(let t=0;t<IA;t++){let n=y+b*(t+.5),r=Math.max((Math.hypot(l.x+u.x*n,l.y+u.y*n,l.z+u.z*n)-1)*i,0);S+=Math.exp(-r/e.rayleighScaleHeightKm)*x,C+=Math.exp(-r/e.mieScaleHeightKm)*x,w+=Math.max(0,1-Math.abs(r-e.absorptionCenterKm)/e.absorptionWidthKm)*x}let T=e.rayleighScatterPerKm,E=e.mieScatterPerKm,D=e.mieAbsorptionPerKm,O=e.absorptionPerKm;return a.set(Math.exp(-(T[0]*S+(E[0]+D[0])*C+O[0]*w)),Math.exp(-(T[1]*S+(E[1]+D[1])*C+O[1]*w)),Math.exp(-(T[2]*S+(E[2]+D[2])*C+O[2]*w))),!0}var $A=6*.8/.3;function ej(e,t=256){let n=document.createElement(`canvas`);n.width=t,n.height=t;let r=n.getContext(`2d`),i=t/2,a=r.createRadialGradient(i,i,0,i,i,i);return a.addColorStop(0,nj(e,1)),a.addColorStop(.15,nj(e,1)),a.addColorStop(.4,nj(e,.3)),a.addColorStop(1,nj(e,0)),r.fillStyle=a,r.fillRect(0,0,t,t),new Nc(n)}function tj(e){return`rgb(${parseInt(e.slice(1,3),16)}, ${parseInt(e.slice(3,5),16)}, ${parseInt(e.slice(5,7),16)})`}function nj(e,t){return e.replace(`)`,`, ${t})`).replace(`rgb(`,`rgba(`)}var rj=`#fff5eb`,ij=`#ffd9a8`;function aj(){let e=new X(rj),t=new X(ij);return new fu({uniforms:{uCentreColor:{value:new J(e.r,e.g,e.b)},uLimbColor:{value:new J(t.r,t.g,t.b)},uLimbAlpha:{value:new J(.5,.5,.5)},...KA()},vertexShader:`
|
|
5434
5434
|
#include <common>
|
|
5435
5435
|
#include <logdepthbuf_pars_vertex>
|
|
5436
5436
|
varying vec3 vNormalView;
|
|
@@ -5453,7 +5453,7 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5453
5453
|
varying vec3 vNormalView;
|
|
5454
5454
|
varying vec3 vViewDir;
|
|
5455
5455
|
varying vec3 vWorldPos;
|
|
5456
|
-
${
|
|
5456
|
+
${VA}
|
|
5457
5457
|
void main() {
|
|
5458
5458
|
#include <logdepthbuf_fragment>
|
|
5459
5459
|
float mu = max(dot(normalize(vNormalView), normalize(vViewDir)), 0.0);
|
|
@@ -5468,7 +5468,7 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5468
5468
|
vec3 hdr = tint * darkening * ${6 .toFixed(1)};
|
|
5469
5469
|
gl_FragColor = vec4(atmoViewTint(vWorldPos) * hdr, 1.0);
|
|
5470
5470
|
}
|
|
5471
|
-
`})}function
|
|
5471
|
+
`})}function oj(e,t){let n=new cs(new Jo({map:ej(t.startsWith(`#`)?tj(t):t),blending:2,transparent:!0,opacity:.6,depthWrite:!1,depthTest:!0})),r=e*6;return n.scale.set(r,r,1),n}function sj(e,t){let n=new Ho;n.setAttribute(`position`,new Ao(new Float32Array(3),3));let r=new X(e),i=new Ac(n,new fu({uniforms:{uColor:{value:new J(r.r,r.g,r.b)},uIntensity:{value:$A},uTint:{value:new J(1,1,1)},uMap:{value:t}},vertexShader:`
|
|
5472
5472
|
#include <common>
|
|
5473
5473
|
#include <logdepthbuf_pars_vertex>
|
|
5474
5474
|
void main() {
|
|
@@ -5489,7 +5489,7 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5489
5489
|
if (texel.a < 0.01) discard;
|
|
5490
5490
|
gl_FragColor = vec4(uTint * uColor * uIntensity, texel.a);
|
|
5491
5491
|
}
|
|
5492
|
-
`,transparent:!0,depthTest:!0,depthWrite:!1}));return i.frustumCulled=!1,i}function
|
|
5492
|
+
`,transparent:!0,depthTest:!0,depthWrite:!1}));return i.frustumCulled=!1,i}function cj(e,t,n,r){let i=new dd(16777215,vT,0,0);e.add(i);let a=oj(t,n);e.add(a);let o=sj(n,r);return e.add(o),{light:i,corona:a,starPoint:o}}function lj(e,t,n){e&&e.material.color.setRGB(n.x,n.y,n.z),t&&t.material.uniforms.uTint.value.copy(n)}function uj(e){let t=e?.uniforms;return t?.uAtmoTEnable?t:null}function dj(e,t){let n=e?.uniforms;t&&n?.uLimbAlpha&&n.uLimbAlpha.value.set(t[0],t[1],t[2])}function fj(e){if(Array.isArray(e))for(let t of e)t.dispose();else e.dispose()}var pj=96,mj=24;function hj(e,t,n,r,i,o,s,c,l,u){for(let d of e){let e=d.data.id,f=u?.has(e)??!1,p=d.data.objectType,m=f||p===W.BARYCENTER||p===W.LAGRANGE_POINT||p===W.COMET||_n(p)||d.data.orbitalSource===U.SPICE_PROBE,h=h_(d.data),g=Q(gn(d.data)),_=p===W.STAR,v=XD(d),y=Number.isFinite(d.data.radiusKm)&&d.data.radiusKm>0,b=!v&&yn(p)&&!y?`radius`:void 0,x=new za;x.position.set(0,0,0);let S=null,C=null,w=null,T=null,E,D=[];if(!m&&!b){_&&(C=cj(t,g,h,o),D.push(C.light,C.corona,C.starPoint));let i=_?pj:mj,a=new ru(g,i,i),s=_?aj():new mu({color:__(d.data)});S=new As(a,s),v&&(S.visible=!1),_||(w=HC(s)),t.add(S),D.push(S),n.push(S),r.set(S,d);let c=_?void 0:_b(e);c&&(T=CA(c,g,gn(d.data)),t.add(T.mesh),D.push(T.mesh),w&&(E=[JA(s,c,g,gn(d.data),w,T)]))}let O=Pk(d),k=_||p===W.PLANET,A=f||m_.has(e)||d.data.isMinor===!0,j=Fk(h,d.data.name??``,O,a().bodyHref(e,d.data.name??``),()=>c(d),k,l?t=>l(e,t):void 0,A);j&&(Lk(j.element,s),x.add(j)),t.add(x);let M=j?j.element.firstElementChild:null;M&&(M.dataset.origBorder=M.style.border),i.set(e,{body:d,group:x,mesh:S,label:j,labelHalo:M,labelStack:null,loadingEl:null,extraObjects:D,corona:C?.corona??null,starPoint:C?.starPoint??null,trail:null,radiusScene:g,cachedDist:0,currentSegments:m||b?void 0:_?pj:mj,isMinor:A,noPhysical:b,rings:[],clouds:null,atmosphere:T,sunTint:E,specularMap:null,emissiveMap:null,displacementMap:null,selfShadow:null,eclipseShadow:w,nomenclatureLabels:null,model:null})}}function gj(e){let t=e.data.objectType;return t===W.COMET||_n(t)||e.data.orbitalSource===U.SPICE_PROBE}function _j(e,t,n,r){if(e.mesh!==null)return;let{body:i,radiusScene:a}=e;e.focusUpgraded=!0;let o=XD(i);if(!o&&!(Number.isFinite(i.data.radiusKm)&&i.data.radiusKm>0)){e.noPhysical=`radius`;return}let s=__(i.data),c=mj,l=new ru(a,c,c),u=new mu({color:s}),d=new As(l,u);o&&(d.visible=!1),t.add(d),e.mesh=d,e.extraObjects.push(d),n.push(d),r.set(d,i),e.eclipseShadow=HC(u),e.currentSegments=c;let f=_b(i.data.id);f&&(e.atmosphere=CA(f,a,gn(i.data)),t.add(e.atmosphere.mesh),e.extraObjects.push(e.atmosphere.mesh),e.sunTint=[JA(u,f,a,gn(i.data),e.eclipseShadow,e.atmosphere)])}function vj(e,t,n,r){e.focusUpgraded=!1,lO(e);let i=e.mesh;if(i){e.displacementMap&&(e.displacementMap.dispose(),e.displacementMap=null,e.displacementTier=void 0,$C(e.selfShadow),e.selfShadow=null),e.terrainWindow=null,t.remove(i),i.geometry.dispose(),fj(i.material);let a=n.indexOf(i);a>=0&&n.splice(a,1),r.delete(i);let o=e.extraObjects.indexOf(i);o>=0&&e.extraObjects.splice(o,1),e.mesh=null,e.currentSegments=void 0,e.eclipseShadow=null,e.sunTint=void 0,e.radiiApplied=!1,e.semiAxesScene=void 0}if(e.atmosphere){let n=e.atmosphere.mesh;t.remove(n);let r=e.extraObjects.indexOf(n);r>=0&&e.extraObjects.splice(r,1),n.geometry.dispose(),fj(n.material),e.atmosphere=null}let a=e.body.data.orbitalSource===U.SPICE_PROBE;e.trail&&!a&&(t.remove(e.trail),e.trail.geometry.dispose(),fj(e.trail.material),e.trail=null)}var yj=class{#e;#t=new J;#n=new q;#r=new WeakMap;#i=[];constructor(e,t){this.#e=bj(e,t)}setSize(e,t){this.#e.dispose(),this.#e.depthTexture?.dispose(),this.#e=bj(e,t)}run(e,t,n,r,i){let a=this.#i;for(let e of r.values())e.atmosphere?.material.side===1&&(e.mesh&&this.#a(e.mesh,i),e.model&&e.model.parent===e.modelRoot&&e.model.traverse(e=>{e.isMesh&&this.#a(e,i)}));let o=e.getRenderTarget(),s=n.layers.mask,c=t.background;n.layers.set(i),t.background=null,e.setRenderTarget(this.#e),e.clear(),e.render(t,n),e.setRenderTarget(o),t.background=c,n.layers.mask=s;for(let{mesh:e,material:t}of a)e.material=t,e.layers.disable(i);a.length=0,n.getWorldDirection(this.#t),e.getDrawingBufferSize(this.#n);for(let e of r.values()){let t=e.atmosphere?.material.uniforms;t&&(t.uSceneDepth.value=this.#e.depthTexture,t.uCamForward.value.copy(this.#t),t.uReversedDepth.value=+!!iT(),t.uCameraNear.value=n.near,t.uCameraFar.value=n.far,t.uResolution.value.copy(this.#n))}}#a(e,t){if(!e.visible)return;let n=e.material;if(Array.isArray(n))return;let r=this.#r.get(n);r||(r=new _u,this.#r.set(n,r));let i=n;(r.displacementMap??null)!==(i.displacementMap??null)&&(r.displacementMap=i.displacementMap??null,r.needsUpdate=!0),r.displacementScale=i.displacementScale??1,r.displacementBias=i.displacementBias??0,r.side=i.side,this.#i.push({mesh:e,material:n}),e.material=r,e.layers.enable(t)}dispose(){this.#e.depthTexture?.dispose(),this.#e.dispose()}};function bj(e,t){let n=new la(e,t);return n.depthTexture=new Pc(e,t,Hn),n}function xj(e,t,n,r,i,a,o,s){if(!n.length||i.rings.length)return[];let c=n.reduce((e,t)=>t.intensity_scale>e.intensity_scale?t:e),l=[];for(let u of n){if(s)for(let n of u.sources)s.credits.registerImagery(`rings`,e,t,{...n,description:u.description});l.push(lA(e,u,o).then(e=>{if(!e)return;if(i.rings.some(e=>e.mesh.userData.ringBundle===u.bundle)){e.mesh.geometry.dispose(),e.mesh.material.dispose();return}e.mesh.userData.ringBundle=u.bundle;let t=i.mesh??i.model;t&&e.mesh.quaternion.copy(t.quaternion),i.rings.push(e),a.add(e.mesh),i.extraObjects.push(e.mesh),i.mesh&&u===c&&(e.planetShadow=cA(i.mesh.material,e.innerScene,e.outerScene,e.transparency,e.intensityScale),i.atmosphere&&NA(i.atmosphere,e.planetShadow,e.transparency,e.innerScene,e.outerScene)),r&&(e.planetShadowOnRing.uPlanetEquatorialScene.value=Q((r.a+r.b)/2),e.planetShadowOnRing.uPlanetPolarScene.value=Q(r.c))}))}return l}var Sj=1.002,Cj=1e3;function wj(e,t,n){return Yt(`/v1/textures/${e}/${t}_${n}.webp`,`textures`)}async function Tj(e,t,n){try{let r=await fetch(wj(e,t,n));if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.blob(),a=new oa(await createImageBitmap(i,{imageOrientation:`flipY`}));return a.flipY=!1,a.colorSpace=Xr,a.needsUpdate=!0,a}catch(r){return console.warn(`Failed to load ${t} cloud texture for ${e} @ ${n}:`,r),null}}function Ej(e){let t=parseInt(e.slice(0,4),10),n=parseInt(e.slice(4,6),10)-1,r=parseInt(e.slice(6,8),10),i=parseInt(e.slice(8,10),10);return Date.UTC(t,n,r,i)}var Dj=10800*1e3;function Oj(e,t,n){return n?n.some(([t,n])=>e>=Ej(t)&&e<Ej(n)+Dj):e>=Ej(t[0])&&e<=Ej(t[t.length-1])}function kj(e,t,n){if(t.length===0)return;let r=Pg(e).getTime(),i=Ej(t[0]);if(Oj(r,t,n)){let e=0,n=t.length;for(;e<n;){let i=e+n>>>1;Ej(t[i])<=r?e=i+1:n=i}return t[Math.max(0,e-1)]}let a=Pg(e).getUTCHours(),o=Math.round(a/3)*3%24,s=String(o).padStart(2,`0`),c=t.filter(e=>e.slice(8,10)===s);return c.length===0?r<i?t[0]:t[t.length-1]:r<i?c[0]:c[c.length-1]}async function Aj(e,t,n,r,i=Sj){let a=await Tj(n.id,`low`,r);if(!a)return null;let o=jj(e,t,a,i);return o.id=n.id,o.availableTiers=n.tiers,o.availableFrames=n.frames,o.availableCoverage=n.coverage,o.textureTier=`low`,o.textureFrame=r,o}function jj(e,t,n,r=Sj){let i=new mu({map:n,transparent:!0,depthWrite:!1}),a=new As(new ru(t,64,64),i);return a.scale.setScalar(r),a.renderOrder=1,e.add(a),{mesh:a,material:i,id:``,availableTiers:[],availableFrames:[]}}async function Mj(e,t,n){if(e.textureLoading||e.textureTier===t&&e.textureFrame===n||!e.availableTiers.includes(t)||!e.availableFrames.includes(n))return;let r=performance.now();if(!(e.lastSwapMs!==void 0&&r-e.lastSwapMs<Cj)){e.lastSwapMs=r,e.textureLoading=!0;try{let r=await Tj(e.id,t,n);r&&(e.material.map?.dispose(),e.material.map=r,e.material.needsUpdate=!0,e.textureTier=t,e.textureFrame=n)}finally{e.textureLoading=!1}}}function Nj(e){e.mesh.geometry.dispose(),e.material.map?.dispose(),e.material.dispose(),e.mesh.parent?.remove(e.mesh)}var Pj=.2,Fj=-.125,Ij=.1,Lj=Symbol(`night-lights-hook`);async function Rj(e,t,n,r){let i=Yt(`/v1/textures/${t.id}/${n}.webp`,`textures`),a;try{a=await new Promise((e,t)=>{r.load(i,e,void 0,t)})}catch(e){return console.warn(`Failed to load night-lights map ${i}:`,e),null}return a.colorSpace=Xr,zj(e,a),a}function zj(e,t){e.emissiveMap=t,e.emissive=new X(16777215);let n=e;if(!n[Lj]){n[Lj]=!0;let t=RC();FC(e,`nightLights`,e=>{e.uniforms.uSunDir=t.uSunDir,e.uniforms.uNightIntensity={value:Pj},e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
|
|
5493
5493
|
varying vec3 vNightOutwardWorld;`).replace(`#include <begin_vertex>`,`#include <begin_vertex>
|
|
5494
5494
|
vNightOutwardWorld = mat3(modelMatrix) * position;`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
|
|
5495
5495
|
uniform float uNightIntensity;
|
|
@@ -5498,9 +5498,9 @@ vNightOutwardWorld = mat3(modelMatrix) * position;`),e.fragmentShader=e.fragment
|
|
|
5498
5498
|
// Modulate by unlit-side factor: 1 night, 0 day.
|
|
5499
5499
|
vec3 nightOutward = normalize(vNightOutwardWorld);
|
|
5500
5500
|
float nightDot = dot(nightOutward, uSunDir);
|
|
5501
|
-
float nightFactor = 1.0 - smoothstep(${
|
|
5501
|
+
float nightFactor = 1.0 - smoothstep(${Fj.toFixed(2)}, ${Ij.toFixed(2)}, nightDot);
|
|
5502
5502
|
totalEmissiveRadiance *= nightFactor * uNightIntensity;
|
|
5503
|
-
#endif`)})}e.needsUpdate=!0}function
|
|
5503
|
+
#endif`)})}e.needsUpdate=!0}function Bj(e){e.emissiveMap&&(e.emissiveMap.dispose(),e.emissiveMap=null,e.emissive.setRGB(0,0,0),e.needsUpdate=!0)}var Vj=.55,Hj=Symbol(`specular-hook`);async function Uj(e,t,n,r){let i=Yt(`/v1/textures/${t.id}/${n}.webp`,`textures`),a;try{a=await new Promise((e,t)=>{r.load(i,e,void 0,t)})}catch(e){return console.warn(`Failed to load specular map ${i}:`,e),null}e.roughnessMap=a;let o=e;return o[Hj]||(o[Hj]=!0,FC(e,`specular`,e=>{e.uniforms.uOceanRoughness={value:Vj},e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
|
|
5504
5504
|
uniform float uOceanRoughness;`).replace(`#include <roughnessmap_fragment>`,`float roughnessFactor = roughness;
|
|
5505
5505
|
#ifdef USE_ROUGHNESSMAP
|
|
5506
5506
|
// Mask carries the fraction of the texel under water, so a
|
|
@@ -5509,14 +5509,14 @@ uniform float uOceanRoughness;`).replace(`#include <roughnessmap_fragment>`,`flo
|
|
|
5509
5509
|
// roughnessmap sample.
|
|
5510
5510
|
vec4 texelRoughness = texture2D(roughnessMap, vRoughnessMapUv);
|
|
5511
5511
|
roughnessFactor = mix(roughness, uOceanRoughness, texelRoughness.g);
|
|
5512
|
-
#endif`)})),e.needsUpdate=!0,a}function
|
|
5513
|
-
`)}function pM(e,t=c()){let n=`${e}:${t}`,r=uM.get(n);return r||(r=(async()=>{let[n,r]=await Promise.all([dM(e),fM(e,t)]);return n.map((e,t)=>({...e,name:r[t]??`Feature ${e.featureId}`}))})(),uM.set(n,r),r.catch(()=>{uM.get(n)===r&&uM.delete(n)})),r}var mM=3;function hM(e,t,n=mM){let r=0,i=0;e.addEventListener(`pointerdown`,e=>{r=e.clientX,i=e.clientY}),e.addEventListener(`click`,e=>{e.stopPropagation();let a=e.clientX-r,o=e.clientY-i;a*a+o*o<=n*n&&t(e)})}function gM(e,t){if(e)return un(e)?e.featureAnchor.hostId:t.get(e.data.id)?.isLanded?e.data.parentId:e.data.id}var _M=Math.PI/180,vM=.9,yM=24,bM=.2,xM=100,SM=16,CM=new Set([`CA`,`CH`,`DO`,`FL`,`FO`,`LI`,`RI`,`RU`,`VA`]);async function wM(e,t,n){if(e.nomenclatureLabels||!e.mesh&&!e.model)return;let r=await mx(e.body.data.id,!1);if(!r.global?.has_nomenclature||e.nomenclatureLabels)return;let i=await pM(e.body.data.id);if(e.nomenclatureLabels)return;let a=i.filter(e=>!CM.has(e.typeCode));a.sort((e,t)=>{let n=e.diameterM>0?e.diameterM:xM;return(t.diameterM>0?t.diameterM:xM)-n});let o=a.length,s=e.model,c=new Float32Array(o),l;if(s){let t=await DM(s,a);if(e.nomenclatureLabels||e.model!==s)return;let n=QD(e);for(let e=0;e<o;e++)c[e]=t.radii[e]*n;e.nomenclatureNormals=t.normals;let r=new za,i=s.userData.centerOffset;i&&r.position.copy(i).multiplyScalar(-n),r.quaternion.copy(s.quaternion),e.group.add(r),e.nomenclatureAnchor=r,l=r}else{let t=e.mesh.geometry.parameters?.radius;if(!t)return;let n=null;if(r.global.displacement&&(n=await Sw(e,e.body.data.id,r.global.displacement,gn(e.body.data),a.map(e=>({latRad:e.lat*_M,lonRad:e.lon*_M}))),e.nomenclatureLabels||!e.mesh))return;for(let e=0;e<o;e++)c[e]=t+(n?Q(n[e]):0);l=e.mesh}let u=Array(o),d=new Float32Array(o),f=new Float32Array(o).fill(-1),p=new Float32Array(o).fill(NaN),m=new Float32Array(o).fill(NaN),h=0;for(let e=0;e<o;e++){let r=a[e],i=r.diameterM>0?r.diameterM:xM;r.diameterM<=0&&h++;let o=document.createElement(`div`);o.className=`scene-feature-label`,o.dir=`auto`,o.textContent=r.name,o.dataset.featureId=String(r.featureId),Mk(o,t),n&&hM(o,()=>n(r.featureId,r.lat,r.lon,i));let[s,f,p]=sw(r.lat*_M,r.lon*_M),m=c[e],g=new YO(o);g.position.set(m*s,m*f,m*p),l.add(g),u[e]=g,d[e]=i}h>0&&console.log(`[nomenclature] ${e.body.data.id}: ${h}/${o} features have no diameter — using ${xM}m fallback`),e.nomenclatureLabels=u,e.nomenclatureDiamsM=d,e.nomenclatureWidths=f,e.nomenclatureSX=p,e.nomenclatureSY=m,e.nomenclatureActiveIndex=-1}var TM=8,EM=new J;async function DM(e,t){let n=t.length,r=new Float32Array(n),i=new Float32Array(n*3),a=e.userData.halfExtents;for(let o=0;o<n;o++){o>0&&o%TM===0&&await new Promise(e=>setTimeout(e));let n=t[o].lat*_M,s=t[o].lon*_M,c=xO(e,n,s,EM);if(c!==null)r[o]=c;else{let[e,t,i]=sw(n,s),c=Math.max(a?.x??1,.001),l=Math.max(a?.y??1,.001),u=Math.max(a?.z??1,.001);r[o]=1/Math.sqrt((e/c)**2+(t/l)**2+(i/u)**2),EM.set(e/(c*c),t/(l*l),i/(u*u)).normalize()}i[o*3]=EM.x,i[o*3+1]=EM.y,i[o*3+2]=EM.z}return{radii:r,normals:i}}function OM(e,t){let n=e.nomenclatureLabels;if(!n)return;let r=t===null?null:String(t),i=-1;for(let e=0;e<n.length;e++){let t=n[e].element,a=t.dataset.featureId===r;t.classList.toggle(`scene-feature-label--active`,a),a&&(i=e)}e.nomenclatureActiveIndex=i}function kM(e){if(e.nomenclatureLabels){for(let t of e.nomenclatureLabels)t.element.remove(),t.parent?.remove(t);e.nomenclatureAnchor&&=(e.nomenclatureAnchor.parent?.remove(e.nomenclatureAnchor),null),e.nomenclatureNormals=void 0,e.nomenclatureLabels=null,e.nomenclatureDiamsM=void 0,e.nomenclatureWidths=void 0,e.nomenclatureSX=void 0,e.nomenclatureSY=void 0,e.nomenclatureActiveIndex=void 0}}var AM=new J,jM=new J,MM=new J,NM=new J,PM=new J,FM=new Hi,IM=new J,LM=.12;function RM(e,t,n,r,i,a){let o=e.nomenclatureLabels;if(!o)return;if(!t||n<128){for(let e of o)e.visible=!1;return}let s=e.nomenclatureDiamsM,c=e.nomenclatureSX,l=e.nomenclatureSY,u=e.nomenclatureActiveIndex??-1,d=o.length,f=!!e.clouds?.mesh.visible,p=n/(gn(e.body.data)*1e3),m=bM*Math.min(i,a);if(u<0&&(d===0||f||s[0]*p<yM)){for(let e of o)e.visible=!1;return}e.group.getWorldPosition(AM),r.getWorldPosition(jM);let h=jM.x-AM.x,g=jM.y-AM.y,_=jM.z-AM.z;NM.copy(AM).project(r);let v=h*h+g*g+_*_,y=e.radiusScene*e.radiusScene,b=(vM*(n/Math.sqrt(Math.max(1-y/v,1e-6))))**2,x=.5*i,S=.5*a,C=e.nomenclatureNormals;C&&e.nomenclatureAnchor&&e.nomenclatureAnchor.getWorldQuaternion(FM);for(let e=0;e<d;e++){let t=o[e],n=e===u,d=s[e]*p;if(f&&!n||!n&&(d<yM||d>m)){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}t.getWorldPosition(MM);let v=MM.x-AM.x,y=MM.y-AM.y,w=MM.z-AM.z;if(v*h+y*g+w*_<=v*v+y*y+w*w){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}if(C){IM.set(C[e*3],C[e*3+1],C[e*3+2]).applyQuaternion(FM);let n=h-v,r=g-y,i=_-w,a=Math.sqrt(n*n+r*r+i*i);if(IM.x*n+IM.y*r+IM.z*i<LM*a){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}}PM.copy(MM).project(r);let T=(PM.x-NM.x)*x,E=(PM.y-NM.y)*S;if(!n&&T*T+E*E>=b){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}t.visible=!0,c[e]=(PM.x*.5+.5)*i,l[e]=(-PM.y*.5+.5)*a}}var zM=[];function BM(e){let t=zM[e];return t||(t={left:0,right:0,y:0,h:0},zM[e]=t),t}function VM(e,t,n,r){let i=e.nomenclatureLabels[t];if(!i.visible)return r;let a=e.nomenclatureSX[t],o=e.nomenclatureSY[t];if(Number.isNaN(a)||Number.isNaN(o))return r;let s=e.nomenclatureWidths,c=s[t];if(c<0){let e=i.element.offsetWidth;e>0?(s[t]=e,c=e):c=60}let l=c*.5,u=a-l,d=a+l;if(!n)for(let e=0;e<r;e++){let t=zM[e],n=(t.h+SM)*.5;if(u<t.right&&d>t.left&&Math.abs(o-t.y)<n)return i.visible=!1,r}let f=BM(r);return f.left=u,f.right=d,f.y=o,f.h=SM,r+1}function HM(e){let t=e.nomenclatureLabels;if(!t)return;let n=e.nomenclatureActiveIndex??-1,r=0,i=gk,a=i.count;for(let e=0;e<a;e++){let t=i.rects[e],n=BM(r++);n.left=t.left,n.right=t.right,n.y=t.y,n.h=t.h}n>=0&&(r=VM(e,n,!0,r));for(let i=0;i<t.length;i++)i!==n&&(r=VM(e,i,!1,r))}var UM=34028235e31,WM=3;function GM(e){return new X(e).multiplyScalar(.5)}function KM(){let e=document.createElement(`canvas`);e.width=32,e.height=32;let t=e.getContext(`2d`);return t.beginPath(),t.arc(32/2,32/2,32/2-2,0,Math.PI*2),t.fillStyle=`#aaaaaa`,t.globalAlpha=.3,t.fill(),new Nc(e)}function qM(){return typeof window>`u`?3:window.matchMedia(`(max-width: 768px)`).matches?2:3}function JM(e,t,n,r=[0,0,0],i=4,a=null){let o=e.filter(e=>{let[t,n,r]=e.position;return isFinite(t)&&Math.abs(t)<=UM&&isFinite(n)&&Math.abs(n)<=UM&&isFinite(r)&&Math.abs(r)<=UM?!0:(console.warn(`Skipping body with non-finite position: id=${e.data.id} name=${e.data.name}`,e.position),!1)}),s=new Float32Array(o.length*3),c=a?new Float32Array(o.length*3):null,l=c?new X:null;for(let e=0;e<o.length;e++){let t=o[e];s[e*3]=t.position[0]-r[0],s[e*3+1]=t.position[1]-r[1],s[e*3+2]=t.position[2]-r[2],c&&l&&a&&(l.set(a(t)),c[e*3]=l.r,c[e*3+1]=l.g,c[e*3+2]=l.b)}let u=new Ho;u.setAttribute(`position`,new Ao(s,3)),c&&u.setAttribute(`color`,new Ao(c,3));let d=new Ac(u,new Tc({map:t,color:c?new X(.5,.5,.5):GM(n),vertexColors:!!c,transparent:!0,size:i,sizeAttenuation:!1,depthTest:!0,depthWrite:!1}));return d.frustumCulled=!1,d.renderOrder=WM,d}function YM(e,t,n,r,i=4,a=null){let o=new Ho;o.setAttribute(`position`,new Do(e,3)),a&&o.setAttribute(`color`,new Do(a,3)),o.setDrawRange(0,t);let s=new Ac(o,new Tc({map:n,color:a?new X(.5,.5,.5):GM(r),vertexColors:!!a,transparent:!0,size:i,sizeAttenuation:!1,depthTest:!0,depthWrite:!1}));return s.frustumCulled=!1,s.renderOrder=WM,s}function XM(e,t=512,n=50){let r=e.q??e.a;if(!isFinite(r)||r<=0)return[];let i=Math.max(2*r/n-1,-.999),a=Math.acos(i),o=[];for(let n=0;n<=t;n++){let i=-a+2*a*n/t,s=2*r/(1+Math.cos(i)),c=s*Math.cos(i),l=s*Math.sin(i);o.push(Gv(c,l,e.w,e.i,e.om,e.equatorial))}return o}function ZM(e,t=128){let{a:n,i:r,om:i,w:a}=e,o=Math.min(e.e,.9999999),s=1+3*o,c=Math.sqrt(1-o*o),l=[];for(let u=0;u<=t;u++){let d=2*u/t-1,f=Math.PI*Math.sign(d)*Math.abs(d)**+s,p=Math.cos(f),m=Math.sin(f),h=1-o*p,g=c*m/h,_=(p-o)/h,v=Math.atan2(g,_),y=n*h,b=y*Math.cos(v),x=y*Math.sin(v);!isFinite(b)||!isFinite(x)||l.push(Gv(b,x,a,r,i,e.equatorial))}return l}function QM(e,t=512,n=50){let r=Math.abs(e.a),i=r>0?(n/r+1)/e.e:100,a=Math.min(Math.acosh(Math.max(i,1)),6),o=[];for(let n=0;n<=t;n++){let r=-a+2*a*n/t,i=e.e*Math.cosh(r)-1;if(Math.abs(i)<1e-15)continue;let s=Math.sqrt(e.e*e.e-1)*Math.sinh(r)/i,c=(e.e-Math.cosh(r))/i,l=Math.atan2(s,c),u=e.a*(1-e.e*Math.cosh(r)),d=u*Math.cos(l),f=u*Math.sin(l);o.push(Gv(d,f,e.w,e.i,e.om,e.equatorial))}return o}function $M(e,t,n,r=128){if(!isFinite(n)||n<=0)return[];let i=1/n,a=[];for(let n=0;n<=r;n++){let o=bg(e,t-i+i*n/r);o&&a.push(o)}return a}function eN(e){return!(isFinite(e.a)&&e.a>0)&&(e.q!=null||e.e>=1)}function tN(e,t=512){let n=isFinite(e.a)&&e.a>0;return!n&&e.q!=null?{points:XM(e,t),isOpen:!0}:!n&&e.e>=1?{points:QM(e,t),isOpen:!0}:{points:ZM(e,t),isOpen:!1}}var nN=3;function rN(e){let t=2*e,n=new Float32Array(t*3),r=new Float32Array(t*3),i=new Float32Array(t),a=new Float32Array(t),o=new Float32Array(t);for(let t=0;t<e;t++)i[2*t]=-1,i[2*t+1]=1;let s=new Uint16Array(Math.max(0,6*(e-1)));for(let t=0;t<e-1;t++){let e=2*t,n=2*t+1,r=2*(t+1),i=2*(t+1)+1,a=t*6;s[a]=e,s[a+1]=n,s[a+2]=r,s[a+3]=r,s[a+4]=n,s[a+5]=i}let c=new Ho;return c.setAttribute(`position`,new Ao(n,3)),c.setAttribute(`nextPosition`,new Ao(r,3)),c.setAttribute(`side`,new Ao(i,1)),c.setAttribute(`trailAlpha`,new Ao(a,1)),c.setAttribute(`fullAlpha`,new Ao(o,1)),c.setIndex(new Oo(s,1)),c}function iN(e,t,n,r,i){let a=e.getAttribute(`position`),o=e.getAttribute(`nextPosition`),s=e.getAttribute(`trailAlpha`),c=e.getAttribute(`fullAlpha`),l=a.array,u=o.array,d=s.array,f=c.array,p=d.length/2,m=Math.min(i,p);for(let e=0;e<m;e++){let i=t[e*3],a=t[e*3+1],o=t[e*3+2],s=e<m-1?e+1:e,c=t[s*3],p=t[s*3+1],h=t[s*3+2],g=2*e*3;l[g]=i,l[g+1]=a,l[g+2]=o,l[g+3]=i,l[g+4]=a,l[g+5]=o,u[g]=c,u[g+1]=p,u[g+2]=h,u[g+3]=c,u[g+4]=p,u[g+5]=h;let _=n[e],v=r[e];d[2*e]=_,d[2*e+1]=_,f[2*e]=v,f[2*e+1]=v}a.needsUpdate=!0,o.needsUpdate=!0,s.needsUpdate=!0,c.needsUpdate=!0,e.setDrawRange(0,Math.max(0,6*(m-1)))}function aN(){let e=new Ho;e.setAttribute(`position`,new Ao(new Float32Array(6),3));let t=new yc(e,new fu({transparent:!0}));return t.matrixAutoUpdate=!1,t.visible=!1,t.renderOrder=nN,t}function oN(e,t,n,r,i){let a=new Ho;a.setAttribute(`position`,new Ao(e,3)),a.setAttribute(`trailAlpha`,new Ao(t,1)),a.setAttribute(`fullAlpha`,new Ao(n,1)),a.setDrawRange(0,r);let o=new yc(a,dT(i));return o.matrixAutoUpdate=!1,o.renderOrder=nN,o}function sN(e,t,n,r,i,a,o,s){let c=rN(e);iN(c,t,n,r,i);let l=new As(c,fT(a,o,s));return l.matrixAutoUpdate=!1,l.renderOrder=nN,l}function cN(e){if(e.userData.isFatLine){let t=e.userData.thinPositions;return{posArr:t,trailArr:e.userData.thinTrailAlphas,fullArr:e.userData.thinFullAlphas,capacity:t.length/3}}let t=e.geometry.getAttribute(`position`);return{posArr:t.array,trailArr:e.geometry.getAttribute(`trailAlpha`).array,fullArr:e.geometry.getAttribute(`fullAlpha`).array,capacity:t.count}}function lN(e,t,n,r,i,a,o){if(i<2){e.geometry.setDrawRange(0,0),e.userData.isFatLine||(e.geometry.getAttribute(`position`).needsUpdate=!0);return}if(eb(r.subarray(0,i),n.subarray(0,i),a,o),e.userData.isFatLine){iN(e.geometry,t,n,r,i);return}e.geometry.setDrawRange(0,i),e.geometry.getAttribute(`position`).needsUpdate=!0,e.geometry.getAttribute(`trailAlpha`).needsUpdate=!0,e.geometry.getAttribute(`fullAlpha`).needsUpdate=!0}function uN(e,t,n,r,i,a,o,s){let c=e.trailAnchor??e.position;n[0]=c[0]-o[0],n[1]=c[1]-o[1],n[2]=c[2]-o[2];let l=r-o[0],u=i-o[1],d=a-o[2];return 1+t.writeVertices(n.subarray(3),l,u,d,s)}function dN(e,t,n,r,i){let{orbitCenter:a,data:o}=e,s=a?.[0]??0,c=a?.[1]??0,l=a?.[2]??0,u=o.objectType===W.SPACECRAFT||o.objectType===W.DWARF_PLANET||o.objectType===W.MOON||o.objectType===W.COMET||_n(o.objectType),d=t.capacity+1,f=new Float32Array(d*3),p=uN(e,t,f,s,c,l,r),m=new Float32Array(d),h=new Float32Array(d);p>0&&eb(m.subarray(0,p),h.subarray(0,p),!0,u);let g=i>1,_=g?sN(d,f,h,m,p,n,i):oN(f,h,m,p,n);return _.frustumCulled=!1,_.visible=!1,_.userData.orbitCenter=new J(s,c,l),_.userData.trailBuffer=t,_.userData.useTrail=u,g&&(_.userData.isFatLine=!0,_.userData.thinPositions=f,_.userData.thinTrailAlphas=h,_.userData.thinFullAlphas=m),_}function fN(e,t,n=[0,0,0],r=Ng(new Date),i=1){if(e.trailBuffer)return dN(e,e.trailBuffer,t,n,i);let{orbitElements:a,orbitCenter:o,data:s}=e,c,l;if(s.satrec)c=$M(s.satrec,r,s.n/360,512),l=!0;else{if(!a)throw Error(`makeTrail called without orbitElements`);c=null,l=eN(a)}let u=o?.[0]??0,d=o?.[1]??0,f=o?.[2]??0,p=l||s.objectType===W.DWARF_PLANET||s.objectType===W.MOON||s.objectType===W.SPACECRAFT||s.objectType===W.COMET||_n(s.objectType),m=c?$y(e,c,l,u,d,f):[];if(c&&m.length<2)return aN();let h=c?Math.max(m.length,c.length):513,g=new Float32Array(h),_=new Float32Array(h);eb(g.subarray(0,m.length),_.subarray(0,m.length),l,p);let v=u-n[0],y=d-n[1],b=f-n[2],x=new Float32Array(h*3);for(let e=0;e<m.length;e++)x[e*3]=m[e][0]+v,x[e*3+1]=m[e][1]+y,x[e*3+2]=m[e][2]+b;let S=i>1,C=S?sN(h,x,_,g,m.length,t,i):oN(x,_,g,m.length,t);return C.frustumCulled=!1,C.visible=!1,C.userData.orbitCenter=new J(u,d,f),C.userData.trailLocalPositions=c?m:void 0,C.userData.sourceCurve=c??void 0,C.userData.curvePending=c===null,C.userData.isOpenCurve=l,C.userData.useTrail=p,C.userData.curveJd=r,C.userData.elementsJd=a?.epoch??r,S&&(C.userData.isFatLine=!0,C.userData.thinPositions=x,C.userData.thinTrailAlphas=_,C.userData.thinFullAlphas=g),C}function pN(e,t){if(!t||t.size===0)return[...e];let n=[];for(let r of e)t.has(r.data.id)||n.push(r);return n}function mN(e){return e.data.objectType===W.PLANET?4:(e.data.objectType===W.MOON||e.data.objectType===W.DWARF_PLANET)&&n_[e.data.id]?3:1}function hN(e,t,n=[0,0,0],r){for(let[,i]of e){if(i.trail!==null)continue;let{body:e}=i;if(e.data.objectType===W.STAR)continue;if(e.data.orbitalSource===U.SPICE_PROBE){if(i.isMinor&&!i.mesh)continue}else if(!i.mesh&&!i.focusUpgraded&&dj(e))continue;if(!e.orbitElements&&e.rederiveElements&&r!==void 0){let t=e.rederiveElements(r);t&&(e.orbitElements=t)}if(!e.orbitElements&&!e.trailBuffer)continue;let a=fN(e,h_(e.data),n,r,mN(e));t.add(a),i.trail=a}}function gN(e,t,n,r=[0,0,0],i,a){let o=new Map,s=new Map,c=new Map,l=qM();for(let[s,c]of e.bodies.asteroidBodiesByZone){let e=pN(c.values(),i);if(e.length===0)continue;let u=h_(e[0].data),{buckets:d}=b_(s,e,a);for(let e=0;e<d.length;e++){let i=d[e];if(i.length===0)continue;let a=JM(i,n,u,r,l);a.userData.groupId=`asteroid:${s}#${e}`,a.userData.parentVec=[0,0,0],o.set(`${s}#${e}`,a),t.add(a)}}for(let[o,c]of e.bodies.spacecraftByParent.entries()){let l=wv(e.layers,o,pN(c.values(),i));if(l.length===0)continue;let{buckets:u}=b_(o,l,a);for(let e=0;e<u.length;e++){let i=u[e];if(i.length===0)continue;let a=JM(i,n,`#ffffff`,r,void 0,e=>h_(e.data));a.userData.groupId=`spacecraft:${o}#${e}`,a.userData.parentBodyId=o,a.userData.parentVec=[0,0,0],s.set(`${o}#${e}`,a),t.add(a)}}let u=new Map;for(let t of e.bodies.majorBodies)if(t.data.objectType===W.MOON){let e=u.get(t.data.parentId)??[];e.push(t),u.set(t.data.parentId,e)}for(let[e,i]of u){let a=JM(i,n,h_(i[0].data),r),o=a.material;o.transparent=!1,o.alphaTest=.5,o.depthTest=!0,o.depthWrite=!0,a.visible=!1,c.set(e,a),t.add(a)}return{asteroidPoints:o,spacecraftPoints:s,moonPoints:c}}async function _N(e,t,n,r,i,a,o){let c;try{let t=await fetch(`${Kt()}/v1/systems/${e}.json`);if(!t.ok)return;c=await t.json()}catch{return}let l=[];for(let[u,d]of Object.entries(c)){let c=s([d.texture&&{...d.texture,id:u,tiers:d.tiers},...d.alternates??[]]);c&&o?.credits.registerImagery(`surface`,u,e,c);let f=t.get(u);if(f?.mesh){if(d.orientation){if(fD(f,d.orientation,o,e),d.nut_prec){let e=u.match(/^naif-(-?\d+)$/),t=e?parseInt(e[1],10):null,n=t===null?void 0:Q_(Z_(t));n&&(f.body.nutPrec={...d.nut_prec,angles:n})}pC(f.mesh,d.orientation,i,f.body.nutPrec)}if(d.radii&&f.radiusScene>0&&!f.radiiApplied&&!d.displacement?.absolute_radius&&Qj(f,d.radii),c?.tiers?.length&&(f.availableTiers=c.tiers,f.availableFrames=c.frames,f.textureBundleId=c.id===u?void 0:c.id,!f.textureTier)){let e=Xj(i,f.availableFrames);l.push(nM(f,`low`,e,r))}l.push(...Uj(u,e,d,f,{textureLoader:r,currentJd:i,ctx:o})),d.rings?.length&&l.push(...gj(u,e,d.rings,d.radii,f,n,a,o))}}await Promise.allSettled(l)}function vN(e,t,n,r){for(let i of t.values())if(r.visibility.isBodyInSystem(i.body,e)){if(tM(i),Gj(i),i.terrainWindow&&i.mesh){i.terrainWindow=null;let e=Q(gn(i.body.data)),t=i.mesh.geometry;i.mesh.geometry=new ru(e,24,24),t.dispose(),i.currentSegments=24}for(let e of i.rings){e.planetShadow?.disable(),n.remove(e.mesh);let t=i.extraObjects.indexOf(e.mesh);t>=0&&i.extraObjects.splice(t,1),aA(e)}i.rings=[],kM(i)}}var yN=class{lastBaryId=null;pendingUnloads=new Set;prefetched=new Set;constructor(e,t,n,r,i,a,o){this.scene=e,this.ctx=t,this.renderer=n,this.textureLoader=r,this.bodyObjects=i,this.clock=a,this.onLoaded=o}syncToFocus(){let e=this.ctx.visibility.focusedSystemId,t=e?this.resolveBaryId(e):null;if(!t){this.lastBaryId&&=(this.pendingUnloads.add(this.lastBaryId),null);return}t!==this.lastBaryId&&(this.lastBaryId&&this.pendingUnloads.add(this.lastBaryId),this.pendingUnloads.delete(t),this.prefetched.delete(t),this.lastBaryId=t,this.load(t))}prefetch(e){let t=this.resolveBaryId(e);!t||t===this.lastBaryId||this.prefetched.has(t)||(this.prefetched.add(t),this.pendingUnloads.delete(t),this.load(t))}discardPrefetch(e){let t=this.resolveBaryId(e);!t||!this.prefetched.delete(t)||t!==this.lastBaryId&&this.pendingUnloads.add(t)}resolveBaryId(e){let t=this.ctx.getBody(e);if(t?.data.objectType===W.BARYCENTER)return e;let n=t?.data.parentId??e;return M_(n)?null:n}load(e){_N(e,this.bodyObjects,this.scene,this.textureLoader,this.clock.jd,this.renderer.capabilities.maxTextureSize,this.ctx).then(()=>{this.onLoaded(),this.ctx.bodies.orientationVersion++})}drainPendingUnloads(){if(this.pendingUnloads.size!==0){for(let e of this.pendingUnloads)vN(e,this.bodyObjects,this.scene,this.ctx);this.pendingUnloads.clear()}}hasPendingUnloads(){return this.pendingUnloads.size>0}},bN=Math.PI/180,xN=class{adjust={rxDeg:0,ryDeg:0,rzDeg:0};_q=new Hi;_adjustQ=new Hi;_tmpQ=new Hi;_axisX=new J(1,0,0);_axisY=new J(0,1,0);_axisZ=new J(0,0,1);constructor(e){this.scene=e}get(){return{...this.adjust}}set(e,t,n){this.adjust.rxDeg=e,this.adjust.ryDeg=t,this.adjust.rzDeg=n,this._adjustQ.setFromAxisAngle(this._axisX,e*bN).premultiply(this._tmpQ.setFromAxisAngle(this._axisY,t*bN)).premultiply(this._tmpQ.setFromAxisAngle(this._axisZ,n*bN)),this._q.copy(Zx).multiply(this._adjustQ),this.scene.backgroundRotation.setFromQuaternion(this._q)}},SN=Math.PI/180,CN=ag*SN,wN=Math.cos(CN),TN=Math.sin(CN),EN=5e3,DN=[{id:`galactic-center`,label:`Galactic Center`,raDeg:266.41683,decDeg:-29.00781,color:`#ff6b35`},{id:`galactic-anticenter`,label:`Galactic Anticenter`,raDeg:86.4,decDeg:28.93785,color:`#ff6b35`},{id:`galactic-np`,label:`Galactic NP`,raDeg:192.85948,decDeg:27.12825,color:`#ffb84d`},{id:`galactic-sp`,label:`Galactic SP`,raDeg:12.85948,decDeg:-27.12825,color:`#ffb84d`},{id:`ncp`,label:`NCP (Polaris ≈)`,raDeg:37.9542,decDeg:89.2641,color:`#4dd0ff`},{id:`scp`,label:`SCP`,raDeg:0,decDeg:-90,color:`#4dd0ff`},{id:`vernal`,label:`Vernal Equinox (γ)`,raDeg:0,decDeg:0,color:`#9d8cff`},{id:`autumnal`,label:`Autumnal Equinox`,raDeg:180,decDeg:0,color:`#9d8cff`},{id:`m31`,label:`M31 (Andromeda)`,raDeg:10.6847,decDeg:41.2692,color:`#ffffff`},{id:`lmc`,label:`LMC (Large Magellanic Cloud)`,raDeg:80.8942,decDeg:-69.7561,color:`#ffffff`},{id:`smc`,label:`SMC (Small Magellanic Cloud)`,raDeg:13.1583,decDeg:-72.8003,color:`#ffffff`},{id:`sirius`,label:`Sirius`,raDeg:101.2872,decDeg:-16.7161,color:`#ffffff`}],ON=192.85948,kN=27.12825,AN=266.40499,jN=-28.93617,MN=256,NN=[{name:`galactic-plane`,zero:PN(AN,jN,new J).normalize(),pole:PN(ON,kN,new J).normalize(),color:16739125},{name:`ecliptic-plane`,zero:new J(1,0,0),pole:new J(0,1,0),color:5099775},{name:`celestial-equator`,zero:PN(0,0,new J).normalize(),pole:PN(0,90,new J).normalize(),color:10325247}];function PN(e,t,n){let r=e*SN,i=t*SN,a=Math.cos(i),o=a*Math.cos(r),s=a*Math.sin(r),c=Math.sin(i),l=o,u=s*wN+c*TN,d=-s*TN+c*wN;return n.set(l,d,-u)}function FN(e){let t=document.createElement(`div`);t.className=`sky-debug-marker`,t.style.cssText=[`display:flex`,`align-items:center`,`gap:4px`,`font:11px/1 monospace`,`text-shadow:0 0 3px #000, 0 0 3px #000`,`pointer-events:none`,`white-space:nowrap`].join(`;`);let n=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);n.setAttribute(`width`,`48`),n.setAttribute(`height`,`48`),n.setAttribute(`viewBox`,`-24 -24 48 48`),n.style.cssText=`flex:0 0 auto;filter:drop-shadow(0 0 2px #000);margin-inline-start:-24px`;let r=e.color;n.innerHTML=`
|
|
5512
|
+
#endif`)})),e.needsUpdate=!0,a}function Wj(e){e.roughnessMap&&(e.roughnessMap.dispose(),e.roughnessMap=null,e.needsUpdate=!0)}var Gj={specular:{meta:e=>e.specular,loaded:e=>e.specularMap!==null,async load(e,t,n,r){let i=await Uj(n.material,t,`low`,r.textureLoader);if(i){if(e.specularMap){i.dispose();return}e.specularMap=i}},unload(e,t){t&&(Wj(t.material),e.specularMap=null)}},night:{meta:e=>e.night,loaded:e=>e.emissiveMap!==null,async load(e,t,n,r){let i=await Rj(n.material,t,`low`,r.textureLoader);if(i){if(e.emissiveMap){i.dispose();return}e.emissiveMap=i}},unload(e,t){t&&(Bj(t.material),e.emissiveMap=null)}},topography:{meta:e=>e.displacement,loaded:e=>e.displacementMap!==null,enabled(e){return Hx()?(console.info(`Low-end device: skipping DEM relief for ${e}`),!1):Mx().showDisplacement},async load(e,t,n,r){let i=n.material,a=await ew(i,t,`low`,r.textureLoader,e.radiusScene);if(a){if(e.displacementMap){a.dispose();return}e.displacementMap=a,e.displacementMeta=t,e.displacementTier=`low`,e.selfShadow=Mx().showSelfShadow?QC(i,a,Q(t.scale_km)):null}},unload(e,t){t&&(sw(t.material),e.displacementMap=null,e.displacementTier=void 0,$C(e.selfShadow),e.selfShadow=null)}},clouds:{meta:e=>e.clouds,loaded:e=>e.clouds!==null,async load(e,t,n,r){let i=kj(r.currentJd,t.frames,t.coverage);if(!i)return;let a=e.atmosphere?e.atmosphere.planetRadiusKm/e.atmosphere.surfaceRadiusKm:1,o=a>1?a:Sj,s=await Aj(n,e.radiusScene,t,i,o);if(s){if(e.clouds){Nj(s);return}e.eclipseShadow&&(HC(s.material,e.eclipseShadow),e.atmosphere&&(e.sunTint??=[]).push(JA(s.material,e.atmosphere.params,e.radiusScene,e.atmosphere.surfaceRadiusKm,e.eclipseShadow,e.atmosphere,Sj*a))),e.clouds=s}},unload(e){e.clouds&&=(Nj(e.clouds),null)}}},Kj=Object.keys(Gj);function qj(e,t,n,r,i,a){let o=Gj[e],s=o.meta(r);return!s||!i.mesh||o.loaded(i)||o.enabled&&!o.enabled(t)?null:(a.ctx?.credits.registerImagery(e,t,n,s),o.load(i,s,i.mesh,a))}function Jj(e,t,n,r,i){let a=[];for(let o of Kj){let s=qj(o,e,t,n,r,i);s&&a.push(s)}return a}function Yj(e,t){let n=Gj[e];n.loaded(t)&&n.unload(t,t.mesh)}function Xj(e){for(let t of Kj)Yj(t,e)}var Zj=[`low`,`medium`,`high`];function Qj(e){return e===void 0?-1:Zj.indexOf(e)}function $j(e,t){for(let n=e;n>=0;n--){let e=Zj[n];if(t.includes(e))return e}}function eM(e,t,n){return Yt(n===void 0?`/v1/textures/${e}/${t}.webp`:`/v1/textures/${e}/${t}_${String(n).padStart(2,`0`)}.webp`,`textures`)}function tM(e,t){if(!(!t||t<2))return t===12?Pg(e).getUTCMonth()+1:1}async function nM(e,t,n,r){if(!e.mesh||e.appearance?.surfaceOwned)return;let i=e.textureBundleId??e.body.data.id,a=e.textureLoadGen??=0;e.textureLoading=!0;try{let o=await new Promise((e,a)=>{r.load(eM(i,t,n),e,void 0,a)});if(!e.mesh||e.textureLoadGen!==a){o.dispose();return}let s=e.mesh.material;pD(s,o,e.body.data.color),e.model&&fD(e.model,o,__(e.body.data),e.body.data.color),e.textureTier=t,e.textureFrame=n}catch(e){console.warn(`Failed to load ${t} texture for ${i}:`,e)}finally{e.textureLoading=!1}}function rM(e,t){if(!e.mesh)return;let{a:n,b:r,c:i}=t,a=Q(1)/e.radiusScene;if(e.mesh.scale.set(n*a,i*a,r*a),e.radiusScene=Q(Math.max(n,r,i)),e.semiAxesScene=[Q(n),Q(i),Q(r)],e.atmosphere){let t=Math.max(n,r);MA(e.atmosphere,t,i,Q(t));for(let n of e.sunTint??[])GA(n,e.atmosphere.params,Q(t),t)}e.radiiApplied=!0}async function iM(e,t,n,r,i,a){if(e.textureTier||e.textureLoading)return;let o=await hx(e.body.data.id,!1);if(a?.bodies.orientationRead.add(e.body.data.id),!o.global)return;o.global.orientation&&!e.body.orientation&&gD(e,o.global.orientation,a),o.global.radii&&e.radiusScene>0&&!e.radiiApplied&&!o.global.displacement?.absolute_radius&&rM(e,o.global.radii),o.global.rings?.length&&await Promise.allSettled(xj(e.body.data.id,e.body.data.id,o.global.rings,o.global.radii,e,r,i,a));let c=o.global.sbdb?.color??o.global.color;if(c&&(e.body.data.color=c,e.mesh&&!e.textureTier&&e.mesh.material.color.set(c)),!o.global.map_texture_available)return;let l=e.body.data.id,u=s([o.global.texture&&{...o.global.texture,id:l,tiers:void 0},...o.global.alternates??[]]);a&&u&&a.credits.registerImagery(`surface`,l,l,u),await qj(`topography`,l,l,o.global,e,{textureLoader:t,currentJd:n,ctx:a}),!(e.textureTier||e.textureLoading)&&Mx().showSurfaceTexture&&u&&(e.textureBundleId=u.id===l?void 0:u.id,e.availableTiers??=u.tiers??[...Zj],e.availableFrames=u.frames,await nM(e,`low`,tM(n,e.availableFrames),t))}async function aM(e){if(!e.label)return;let t=e.body.data;if(t.name)return;let n=await hx(t.id,t.hasLocalized),r=n.localized?.name??n.global?.name;r&&(t.name??=r,Nk(e,r,Pk(e.body),t.objectType===W.STAR||t.objectType===W.PLANET))}function oM(e){if(!e.mesh)return;e.textureLoadGen=(e.textureLoadGen??0)+1;let t=e.mesh.material;Yj(`topography`,e),t.map&&(t.map.dispose(),t.map=null,t.color.set(__(e.body.data)),t.needsUpdate=!0,e.model&&fD(e.model,null,__(e.body.data)),e.textureTier=void 0)}async function sM(e,t,n,r){e.textureLoading||e.availableTiers?.includes(t)&&(e.textureTier===t&&e.textureFrame===n||await nM(e,t,n,r))}var cM=class{wanted=new Map;reverting=new Set;set(e,t){let n={...t};n.surface===void 0&&n.night===void 0&&n.clouds===void 0?this.wanted.delete(e):this.wanted.set(e,n),this.reverting.add(e)}get(e){let t=this.wanted.get(e);return t&&{...t}}ownsSurface(e){return this.wanted.get(e)?.surface!==void 0}apply(e,t){if(!(this.wanted.size===0&&this.reverting.size===0)){for(let t of this.reverting){let n=e.get(t);n&&lM(n,this.wanted.get(t))}this.reverting.clear();for(let[n,r]of this.wanted){let i=e.get(n);i?.mesh&&(r.surface!==void 0&&((i.appearance??={}).surfaceOwned=!0),uM(i,r,t,()=>this.wanted.get(n)))}}}};function lM(e,t){let n=e.appearance;if(!n||!e.mesh)return;let r=e.mesh.material;if(n.surfaceOwned&&t?.surface===void 0&&(n.surfaceMap?.dispose(),r.map=null,r.color.set(__(e.body.data)),r.needsUpdate=!0,e.model&&fD(e.model,null,__(e.body.data)),n.surfaceOwned=void 0,n.surfaceUrl=void 0,n.surfaceMap=void 0,e.textureTier=void 0),n.nightUrl!==void 0&&t?.night===void 0){let e=n.displacedNight;n.nightMap?.dispose(),e?zj(r,e):Bj(r),n.nightUrl=void 0,n.nightMap=void 0,n.displacedNight=void 0}if(n.cloudsUrl!==void 0&&t?.clouds===void 0){n.cloudsMap?.dispose();let t=e.clouds;t&&n.ownCloudNode?(t.mesh.geometry.dispose(),t.material.dispose(),t.mesh.parent?.remove(t.mesh),e.clouds=null):t&&(t.material.map=n.displacedClouds??null,t.material.needsUpdate=!0,t.availableTiers=n.displacedCloudTiers??[],t.availableFrames=n.displacedCloudFrames??[]),n.cloudsUrl=void 0,n.cloudsMap=void 0,n.displacedClouds=void 0,n.ownCloudNode=void 0}}async function uM(e,t,n,r){let i=e.appearance??={};if(i.loading)return;let a=fM(e);if(!a)return;let o=t.surface!==void 0&&(t.surface!==i.surfaceUrl||a.map!==i.surfaceMap),s=t.night!==void 0&&(t.night!==i.nightUrl||a.emissiveMap!==i.nightMap),c=t.clouds!==void 0&&(t.clouds!==i.cloudsUrl||e.clouds?.material.map!==i.cloudsMap);if(!(!o&&!s&&!c)){i.loading=!0;try{if(o){let a=await pM(t.surface,n);if(r()!==t)return void a?.dispose();let o=fM(e);a&&o&&(pD(o,a),e.model&&fD(e.model,a,__(e.body.data)),i.surfaceUrl=t.surface,i.surfaceMap=a)}if(s){let a=await pM(t.night,n);if(r()!==t)return void a?.dispose();let o=fM(e);a&&o&&(i.displacedNight??=o.emissiveMap,zj(o,a),i.nightUrl=t.night,i.nightMap=a)}if(c){let a=await pM(t.clouds,n);if(r()!==t)return void a?.dispose();a&&e.mesh&&dM(e,i,a,t.clouds)}}finally{i.loading=!1}}}function dM(e,t,n,r){let i=e.clouds;if(i)t.ownCloudNode||(t.displacedClouds??=i.material.map,t.displacedCloudTiers??=i.availableTiers,t.displacedCloudFrames??=i.availableFrames),i.material.map=n,i.material.needsUpdate=!0;else{if(!e.mesh)return;i=jj(e.mesh,e.radiusScene,n),e.clouds=i,t.ownCloudNode=!0}i.availableTiers=[],i.availableFrames=[],t.cloudsUrl=r,t.cloudsMap=n}function fM(e){return e.mesh?e.mesh.material:null}async function pM(e,t){try{let n=await new Promise((n,r)=>{t.load(e,n,void 0,r)});return n.colorSpace=Xr,n}catch(t){return console.warn(`spacemap: could not load the picture at ${e}:`,t),null}}function mM(e){let t=new DataView(e),n=t.getUint32(0,!0);if(n!==1179536723)throw Error(`Invalid nomenclature file: bad magic 0x${n.toString(16)}`);let r=t.getUint16(4,!0);if(r!==1)throw Error(`Unsupported nomenclature file version: ${r}`);let i=t.getUint32(8,!0),a=Array(i);for(let e=0;e<i;e++){let n=16+e*20,r=t.getUint8(n+16),i=t.getUint8(n+17),o=i===0?String.fromCharCode(r):String.fromCharCode(r,i);a[e]={featureId:t.getUint32(n,!0),lat:t.getInt32(n+4,!0)/1e7,lon:t.getUint32(n+8,!0)/1e7,diameterM:t.getUint32(n+12,!0),typeCode:o,flags:t.getUint8(n+18)}}return a}var hM=new Map;async function gM(e){let t=Yt(`/v1/nomenclature/positions/${e}.bin.gz`,`nomenclature`),n=await fetch(t);if(!n.ok){if(n.status===404)return[];throw Error(`fetchPositions: ${t} returned ${n.status} ${n.statusText}`)}let r=new DecompressionStream(`gzip`);return mM(await new Response(n.body.pipeThrough(r)).arrayBuffer())}async function _M(e,t){let n=Yt(`/v1/nomenclature/labels/${t}/${e}.txt.gz`,`nomenclature`),r=await fetch(n);if(!r.ok){if(r.status===404)return[];throw Error(`fetchNomenclatureLabels: ${n} returned ${r.status} ${r.statusText}`)}let i=new DecompressionStream(`gzip`),a=await new Response(r.body.pipeThrough(i)).text();return a===``?[]:a.split(`
|
|
5513
|
+
`)}function vM(e,t=c()){let n=`${e}:${t}`,r=hM.get(n);return r||(r=(async()=>{let[n,r]=await Promise.all([gM(e),_M(e,t)]);return n.map((e,t)=>({...e,name:r[t]??`Feature ${e.featureId}`}))})(),hM.set(n,r),r.catch(()=>{hM.get(n)===r&&hM.delete(n)})),r}var yM=3;function bM(e,t,n=yM){let r=0,i=0;e.addEventListener(`pointerdown`,e=>{r=e.clientX,i=e.clientY}),e.addEventListener(`click`,e=>{e.stopPropagation();let a=e.clientX-r,o=e.clientY-i;a*a+o*o<=n*n&&t(e)})}function xM(e,t){if(e)return un(e)?e.featureAnchor.hostId:t.get(e.data.id)?.isLanded?e.data.parentId:e.data.id}var SM=Math.PI/180,CM=.9,wM=24,TM=.2,EM=100,DM=16,OM=new Set([`CA`,`CH`,`DO`,`FL`,`FO`,`LI`,`RI`,`RU`,`VA`]);async function kM(e,t,n){if(e.nomenclatureLabels||!e.mesh&&!e.model)return;let r=await hx(e.body.data.id,!1);if(!r.global?.has_nomenclature||e.nomenclatureLabels)return;let i=await vM(e.body.data.id);if(e.nomenclatureLabels)return;let a=i.filter(e=>!OM.has(e.typeCode));a.sort((e,t)=>{let n=e.diameterM>0?e.diameterM:EM;return(t.diameterM>0?t.diameterM:EM)-n});let o=a.length,s=e.model,c=new Float32Array(o),l;if(s){let t=await MM(s,a);if(e.nomenclatureLabels||e.model!==s)return;let n=nO(e);for(let e=0;e<o;e++)c[e]=t.radii[e]*n;e.nomenclatureNormals=t.normals;let r=new za,i=s.userData.centerOffset;i&&r.position.copy(i).multiplyScalar(-n),r.quaternion.copy(s.quaternion),e.group.add(r),e.nomenclatureAnchor=r,l=r}else{let t=e.mesh.geometry.parameters?.radius;if(!t)return;let n=null;if(r.global.displacement&&(n=await ww(e,e.body.data.id,r.global.displacement,gn(e.body.data),a.map(e=>({latRad:e.lat*SM,lonRad:e.lon*SM}))),e.nomenclatureLabels||!e.mesh))return;for(let e=0;e<o;e++)c[e]=t+(n?Q(n[e]):0);l=e.mesh}let u=Array(o),d=new Float32Array(o),f=new Float32Array(o).fill(-1),p=new Float32Array(o).fill(NaN),m=new Float32Array(o).fill(NaN),h=0;for(let e=0;e<o;e++){let r=a[e],i=r.diameterM>0?r.diameterM:EM;r.diameterM<=0&&h++;let o=document.createElement(`div`);o.className=`scene-feature-label`,o.dir=`auto`,o.textContent=r.name,o.dataset.featureId=String(r.featureId),Lk(o,t),n&&bM(o,()=>n(r.featureId,r.lat,r.lon,i));let[s,f,p]=lw(r.lat*SM,r.lon*SM),m=c[e],g=new $O(o);g.position.set(m*s,m*f,m*p),l.add(g),u[e]=g,d[e]=i}h>0&&console.log(`[nomenclature] ${e.body.data.id}: ${h}/${o} features have no diameter — using ${EM}m fallback`),e.nomenclatureLabels=u,e.nomenclatureDiamsM=d,e.nomenclatureWidths=f,e.nomenclatureSX=p,e.nomenclatureSY=m,e.nomenclatureActiveIndex=-1}var AM=8,jM=new J;async function MM(e,t){let n=t.length,r=new Float32Array(n),i=new Float32Array(n*3),a=e.userData.halfExtents;for(let o=0;o<n;o++){o>0&&o%AM===0&&await new Promise(e=>setTimeout(e));let n=t[o].lat*SM,s=t[o].lon*SM,c=TO(e,n,s,jM);if(c!==null)r[o]=c;else{let[e,t,i]=lw(n,s),c=Math.max(a?.x??1,.001),l=Math.max(a?.y??1,.001),u=Math.max(a?.z??1,.001);r[o]=1/Math.sqrt((e/c)**2+(t/l)**2+(i/u)**2),jM.set(e/(c*c),t/(l*l),i/(u*u)).normalize()}i[o*3]=jM.x,i[o*3+1]=jM.y,i[o*3+2]=jM.z}return{radii:r,normals:i}}function NM(e,t){let n=e.nomenclatureLabels;if(!n)return;let r=t===null?null:String(t),i=-1;for(let e=0;e<n.length;e++){let t=n[e].element,a=t.dataset.featureId===r;t.classList.toggle(`scene-feature-label--active`,a),a&&(i=e)}e.nomenclatureActiveIndex=i}function PM(e){if(e.nomenclatureLabels){for(let t of e.nomenclatureLabels)t.element.remove(),t.parent?.remove(t);e.nomenclatureAnchor&&=(e.nomenclatureAnchor.parent?.remove(e.nomenclatureAnchor),null),e.nomenclatureNormals=void 0,e.nomenclatureLabels=null,e.nomenclatureDiamsM=void 0,e.nomenclatureWidths=void 0,e.nomenclatureSX=void 0,e.nomenclatureSY=void 0,e.nomenclatureActiveIndex=void 0}}var FM=new J,IM=new J,LM=new J,RM=new J,zM=new J,BM=new Hi,VM=new J,HM=.12;function UM(e,t,n,r,i,a){let o=e.nomenclatureLabels;if(!o)return;if(!t||n<128){for(let e of o)e.visible=!1;return}let s=e.nomenclatureDiamsM,c=e.nomenclatureSX,l=e.nomenclatureSY,u=e.nomenclatureActiveIndex??-1,d=o.length,f=!!e.clouds?.mesh.visible,p=n/(gn(e.body.data)*1e3),m=TM*Math.min(i,a);if(u<0&&(d===0||f||s[0]*p<wM)){for(let e of o)e.visible=!1;return}e.group.getWorldPosition(FM),r.getWorldPosition(IM);let h=IM.x-FM.x,g=IM.y-FM.y,_=IM.z-FM.z;RM.copy(FM).project(r);let v=h*h+g*g+_*_,y=e.radiusScene*e.radiusScene,b=(CM*(n/Math.sqrt(Math.max(1-y/v,1e-6))))**2,x=.5*i,S=.5*a,C=e.nomenclatureNormals;C&&e.nomenclatureAnchor&&e.nomenclatureAnchor.getWorldQuaternion(BM);for(let e=0;e<d;e++){let t=o[e],n=e===u,d=s[e]*p;if(f&&!n||!n&&(d<wM||d>m)){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}t.getWorldPosition(LM);let v=LM.x-FM.x,y=LM.y-FM.y,w=LM.z-FM.z;if(v*h+y*g+w*_<=v*v+y*y+w*w){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}if(C){VM.set(C[e*3],C[e*3+1],C[e*3+2]).applyQuaternion(BM);let n=h-v,r=g-y,i=_-w,a=Math.sqrt(n*n+r*r+i*i);if(VM.x*n+VM.y*r+VM.z*i<HM*a){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}}zM.copy(LM).project(r);let T=(zM.x-RM.x)*x,E=(zM.y-RM.y)*S;if(!n&&T*T+E*E>=b){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}t.visible=!0,c[e]=(zM.x*.5+.5)*i,l[e]=(-zM.y*.5+.5)*a}}var WM=[];function GM(e){let t=WM[e];return t||(t={left:0,right:0,y:0,h:0},WM[e]=t),t}function KM(e,t,n,r){let i=e.nomenclatureLabels[t];if(!i.visible)return r;let a=e.nomenclatureSX[t],o=e.nomenclatureSY[t];if(Number.isNaN(a)||Number.isNaN(o))return r;let s=e.nomenclatureWidths,c=s[t];if(c<0){let e=i.element.offsetWidth;e>0?(s[t]=e,c=e):c=60}let l=c*.5,u=a-l,d=a+l;if(!n)for(let e=0;e<r;e++){let t=WM[e],n=(t.h+DM)*.5;if(u<t.right&&d>t.left&&Math.abs(o-t.y)<n)return i.visible=!1,r}let f=GM(r);return f.left=u,f.right=d,f.y=o,f.h=DM,r+1}function qM(e){let t=e.nomenclatureLabels;if(!t)return;let n=e.nomenclatureActiveIndex??-1,r=0,i=bk,a=i.count;for(let e=0;e<a;e++){let t=i.rects[e],n=GM(r++);n.left=t.left,n.right=t.right,n.y=t.y,n.h=t.h}n>=0&&(r=KM(e,n,!0,r));for(let i=0;i<t.length;i++)i!==n&&(r=KM(e,i,!1,r))}var JM=34028235e31,YM=3;function XM(e){return new X(e).multiplyScalar(.5)}function ZM(){let e=document.createElement(`canvas`);e.width=32,e.height=32;let t=e.getContext(`2d`);return t.beginPath(),t.arc(32/2,32/2,32/2-2,0,Math.PI*2),t.fillStyle=`#aaaaaa`,t.globalAlpha=.3,t.fill(),new Nc(e)}function QM(){return typeof window>`u`?3:window.matchMedia(`(max-width: 768px)`).matches?2:3}function $M(e,t,n,r=[0,0,0],i=4,a=null){let o=e.filter(e=>{let[t,n,r]=e.position;return isFinite(t)&&Math.abs(t)<=JM&&isFinite(n)&&Math.abs(n)<=JM&&isFinite(r)&&Math.abs(r)<=JM?!0:(console.warn(`Skipping body with non-finite position: id=${e.data.id} name=${e.data.name}`,e.position),!1)}),s=new Float32Array(o.length*3),c=a?new Float32Array(o.length*3):null,l=c?new X:null;for(let e=0;e<o.length;e++){let t=o[e];s[e*3]=t.position[0]-r[0],s[e*3+1]=t.position[1]-r[1],s[e*3+2]=t.position[2]-r[2],c&&l&&a&&(l.set(a(t)),c[e*3]=l.r,c[e*3+1]=l.g,c[e*3+2]=l.b)}let u=new Ho;u.setAttribute(`position`,new Ao(s,3)),c&&u.setAttribute(`color`,new Ao(c,3));let d=new Ac(u,new Tc({map:t,color:c?new X(.5,.5,.5):XM(n),vertexColors:!!c,transparent:!0,size:i,sizeAttenuation:!1,depthTest:!0,depthWrite:!1}));return d.frustumCulled=!1,d.renderOrder=YM,d}function eN(e,t,n,r,i=4,a=null){let o=new Ho;o.setAttribute(`position`,new Do(e,3)),a&&o.setAttribute(`color`,new Do(a,3)),o.setDrawRange(0,t);let s=new Ac(o,new Tc({map:n,color:a?new X(.5,.5,.5):XM(r),vertexColors:!!a,transparent:!0,size:i,sizeAttenuation:!1,depthTest:!0,depthWrite:!1}));return s.frustumCulled=!1,s.renderOrder=YM,s}function tN(e,t=512,n=50){let r=e.q??e.a;if(!isFinite(r)||r<=0)return[];let i=Math.max(2*r/n-1,-.999),a=Math.acos(i),o=[];for(let n=0;n<=t;n++){let i=-a+2*a*n/t,s=2*r/(1+Math.cos(i)),c=s*Math.cos(i),l=s*Math.sin(i);o.push(Gv(c,l,e.w,e.i,e.om,e.equatorial))}return o}function nN(e,t=128){let{a:n,i:r,om:i,w:a}=e,o=Math.min(e.e,.9999999),s=1+3*o,c=Math.sqrt(1-o*o),l=[];for(let u=0;u<=t;u++){let d=2*u/t-1,f=Math.PI*Math.sign(d)*Math.abs(d)**+s,p=Math.cos(f),m=Math.sin(f),h=1-o*p,g=c*m/h,_=(p-o)/h,v=Math.atan2(g,_),y=n*h,b=y*Math.cos(v),x=y*Math.sin(v);!isFinite(b)||!isFinite(x)||l.push(Gv(b,x,a,r,i,e.equatorial))}return l}function rN(e,t=512,n=50){let r=Math.abs(e.a),i=r>0?(n/r+1)/e.e:100,a=Math.min(Math.acosh(Math.max(i,1)),6),o=[];for(let n=0;n<=t;n++){let r=-a+2*a*n/t,i=e.e*Math.cosh(r)-1;if(Math.abs(i)<1e-15)continue;let s=Math.sqrt(e.e*e.e-1)*Math.sinh(r)/i,c=(e.e-Math.cosh(r))/i,l=Math.atan2(s,c),u=e.a*(1-e.e*Math.cosh(r)),d=u*Math.cos(l),f=u*Math.sin(l);o.push(Gv(d,f,e.w,e.i,e.om,e.equatorial))}return o}function iN(e,t,n,r=128){if(!isFinite(n)||n<=0)return[];let i=1/n,a=[];for(let n=0;n<=r;n++){let o=bg(e,t-i+i*n/r);o&&a.push(o)}return a}function aN(e){return!(isFinite(e.a)&&e.a>0)&&(e.q!=null||e.e>=1)}function oN(e,t=512){let n=isFinite(e.a)&&e.a>0;return!n&&e.q!=null?{points:tN(e,t),isOpen:!0}:!n&&e.e>=1?{points:rN(e,t),isOpen:!0}:{points:nN(e,t),isOpen:!1}}var sN=3;function cN(e){let t=2*e,n=new Float32Array(t*3),r=new Float32Array(t*3),i=new Float32Array(t),a=new Float32Array(t),o=new Float32Array(t);for(let t=0;t<e;t++)i[2*t]=-1,i[2*t+1]=1;let s=new Uint16Array(Math.max(0,6*(e-1)));for(let t=0;t<e-1;t++){let e=2*t,n=2*t+1,r=2*(t+1),i=2*(t+1)+1,a=t*6;s[a]=e,s[a+1]=n,s[a+2]=r,s[a+3]=r,s[a+4]=n,s[a+5]=i}let c=new Ho;return c.setAttribute(`position`,new Ao(n,3)),c.setAttribute(`nextPosition`,new Ao(r,3)),c.setAttribute(`side`,new Ao(i,1)),c.setAttribute(`trailAlpha`,new Ao(a,1)),c.setAttribute(`fullAlpha`,new Ao(o,1)),c.setIndex(new Oo(s,1)),c}function lN(e,t,n,r,i){let a=e.getAttribute(`position`),o=e.getAttribute(`nextPosition`),s=e.getAttribute(`trailAlpha`),c=e.getAttribute(`fullAlpha`),l=a.array,u=o.array,d=s.array,f=c.array,p=d.length/2,m=Math.min(i,p);for(let e=0;e<m;e++){let i=t[e*3],a=t[e*3+1],o=t[e*3+2],s=e<m-1?e+1:e,c=t[s*3],p=t[s*3+1],h=t[s*3+2],g=2*e*3;l[g]=i,l[g+1]=a,l[g+2]=o,l[g+3]=i,l[g+4]=a,l[g+5]=o,u[g]=c,u[g+1]=p,u[g+2]=h,u[g+3]=c,u[g+4]=p,u[g+5]=h;let _=n[e],v=r[e];d[2*e]=_,d[2*e+1]=_,f[2*e]=v,f[2*e+1]=v}a.needsUpdate=!0,o.needsUpdate=!0,s.needsUpdate=!0,c.needsUpdate=!0,e.setDrawRange(0,Math.max(0,6*(m-1)))}function uN(){let e=new Ho;e.setAttribute(`position`,new Ao(new Float32Array(6),3));let t=new yc(e,new fu({transparent:!0}));return t.matrixAutoUpdate=!1,t.visible=!1,t.renderOrder=sN,t}function dN(e,t,n,r,i){let a=new Ho;a.setAttribute(`position`,new Ao(e,3)),a.setAttribute(`trailAlpha`,new Ao(t,1)),a.setAttribute(`fullAlpha`,new Ao(n,1)),a.setDrawRange(0,r);let o=new yc(a,pT(i));return o.matrixAutoUpdate=!1,o.renderOrder=sN,o}function fN(e,t,n,r,i,a,o,s){let c=cN(e);lN(c,t,n,r,i);let l=new As(c,mT(a,o,s));return l.matrixAutoUpdate=!1,l.renderOrder=sN,l}function pN(e){if(e.userData.isFatLine){let t=e.userData.thinPositions;return{posArr:t,trailArr:e.userData.thinTrailAlphas,fullArr:e.userData.thinFullAlphas,capacity:t.length/3}}let t=e.geometry.getAttribute(`position`);return{posArr:t.array,trailArr:e.geometry.getAttribute(`trailAlpha`).array,fullArr:e.geometry.getAttribute(`fullAlpha`).array,capacity:t.count}}function mN(e,t,n,r,i,a,o){if(i<2){e.geometry.setDrawRange(0,0),e.userData.isFatLine||(e.geometry.getAttribute(`position`).needsUpdate=!0);return}if(tb(r.subarray(0,i),n.subarray(0,i),a,o),e.userData.isFatLine){lN(e.geometry,t,n,r,i);return}e.geometry.setDrawRange(0,i),e.geometry.getAttribute(`position`).needsUpdate=!0,e.geometry.getAttribute(`trailAlpha`).needsUpdate=!0,e.geometry.getAttribute(`fullAlpha`).needsUpdate=!0}function hN(e,t,n,r,i,a,o,s){let c=e.trailAnchor??e.position;n[0]=c[0]-o[0],n[1]=c[1]-o[1],n[2]=c[2]-o[2];let l=r-o[0],u=i-o[1],d=a-o[2];return 1+t.writeVertices(n.subarray(3),l,u,d,s)}function gN(e,t,n,r,i){let{orbitCenter:a,data:o}=e,s=a?.[0]??0,c=a?.[1]??0,l=a?.[2]??0,u=o.objectType===W.SPACECRAFT||o.objectType===W.DWARF_PLANET||o.objectType===W.MOON||o.objectType===W.COMET||_n(o.objectType),d=t.capacity+1,f=new Float32Array(d*3),p=hN(e,t,f,s,c,l,r),m=new Float32Array(d),h=new Float32Array(d);p>0&&tb(m.subarray(0,p),h.subarray(0,p),!0,u);let g=i>1,_=g?fN(d,f,h,m,p,n,i):dN(f,h,m,p,n);return _.frustumCulled=!1,_.visible=!1,_.userData.orbitCenter=new J(s,c,l),_.userData.trailBuffer=t,_.userData.useTrail=u,g&&(_.userData.isFatLine=!0,_.userData.thinPositions=f,_.userData.thinTrailAlphas=h,_.userData.thinFullAlphas=m),_}function _N(e,t,n=[0,0,0],r=Ng(new Date),i=1){if(e.trailBuffer)return gN(e,e.trailBuffer,t,n,i);let{orbitElements:a,orbitCenter:o,data:s}=e,c,l;if(s.satrec)c=iN(s.satrec,r,s.n/360,512),l=!0;else{if(!a)throw Error(`makeTrail called without orbitElements`);c=null,l=aN(a)}let u=o?.[0]??0,d=o?.[1]??0,f=o?.[2]??0,p=l||s.objectType===W.DWARF_PLANET||s.objectType===W.MOON||s.objectType===W.SPACECRAFT||s.objectType===W.COMET||_n(s.objectType),m=c?eb(e,c,l,u,d,f):[];if(c&&m.length<2)return uN();let h=c?Math.max(m.length,c.length):513,g=new Float32Array(h),_=new Float32Array(h);tb(g.subarray(0,m.length),_.subarray(0,m.length),l,p);let v=u-n[0],y=d-n[1],b=f-n[2],x=new Float32Array(h*3);for(let e=0;e<m.length;e++)x[e*3]=m[e][0]+v,x[e*3+1]=m[e][1]+y,x[e*3+2]=m[e][2]+b;let S=i>1,C=S?fN(h,x,_,g,m.length,t,i):dN(x,_,g,m.length,t);return C.frustumCulled=!1,C.visible=!1,C.userData.orbitCenter=new J(u,d,f),C.userData.trailLocalPositions=c?m:void 0,C.userData.sourceCurve=c??void 0,C.userData.curvePending=c===null,C.userData.isOpenCurve=l,C.userData.useTrail=p,C.userData.curveJd=r,C.userData.elementsJd=a?.epoch??r,S&&(C.userData.isFatLine=!0,C.userData.thinPositions=x,C.userData.thinTrailAlphas=_,C.userData.thinFullAlphas=g),C}function vN(e,t){if(!t||t.size===0)return[...e];let n=[];for(let r of e)t.has(r.data.id)||n.push(r);return n}function yN(e){return e.data.objectType===W.PLANET?4:(e.data.objectType===W.MOON||e.data.objectType===W.DWARF_PLANET)&&n_[e.data.id]?3:1}function bN(e,t,n=[0,0,0],r){for(let[,i]of e){if(i.trail!==null)continue;let{body:e}=i;if(e.data.objectType===W.STAR)continue;if(e.data.orbitalSource===U.SPICE_PROBE){if(i.isMinor&&!i.mesh)continue}else if(!i.mesh&&!i.focusUpgraded&&gj(e))continue;if(!e.orbitElements&&e.rederiveElements&&r!==void 0){let t=e.rederiveElements(r);t&&(e.orbitElements=t)}if(!e.orbitElements&&!e.trailBuffer)continue;let a=_N(e,h_(e.data),n,r,yN(e));t.add(a),i.trail=a}}function xN(e,t,n,r=[0,0,0],i,a){let o=new Map,s=new Map,c=new Map,l=QM();for(let[s,c]of e.bodies.asteroidBodiesByZone){let e=vN(c.values(),i);if(e.length===0)continue;let u=h_(e[0].data),{buckets:d}=b_(s,e,a);for(let e=0;e<d.length;e++){let i=d[e];if(i.length===0)continue;let a=$M(i,n,u,r,l);a.userData.groupId=`asteroid:${s}#${e}`,a.userData.parentVec=[0,0,0],o.set(`${s}#${e}`,a),t.add(a)}}for(let[o,c]of e.bodies.spacecraftByParent.entries()){let l=wv(e.layers,o,vN(c.values(),i));if(l.length===0)continue;let{buckets:u}=b_(o,l,a);for(let e=0;e<u.length;e++){let i=u[e];if(i.length===0)continue;let a=$M(i,n,`#ffffff`,r,void 0,e=>h_(e.data));a.userData.groupId=`spacecraft:${o}#${e}`,a.userData.parentBodyId=o,a.userData.parentVec=[0,0,0],s.set(`${o}#${e}`,a),t.add(a)}}let u=new Map;for(let t of e.bodies.majorBodies)if(t.data.objectType===W.MOON){let e=u.get(t.data.parentId)??[];e.push(t),u.set(t.data.parentId,e)}for(let[e,i]of u){let a=$M(i,n,h_(i[0].data),r),o=a.material;o.transparent=!1,o.alphaTest=.5,o.depthTest=!0,o.depthWrite=!0,a.visible=!1,c.set(e,a),t.add(a)}return{asteroidPoints:o,spacecraftPoints:s,moonPoints:c}}async function SN(e,t,n,r,i,a,o){let c;try{let t=await fetch(`${Kt()}/v1/systems/${e}.json`);if(!t.ok)return;c=await t.json()}catch{return}let l=[];for(let[u,d]of Object.entries(c)){let c=s([d.texture&&{...d.texture,id:u,tiers:d.tiers},...d.alternates??[]]);c&&o?.credits.registerImagery(`surface`,u,e,c);let f=t.get(u);if(f?.mesh){if(o?.bodies.orientationRead.add(u),d.orientation){if(gD(f,d.orientation,o,e),d.nut_prec){let e=u.match(/^naif-(-?\d+)$/),t=e?parseInt(e[1],10):null,n=t===null?void 0:Q_(Z_(t));n&&(f.body.nutPrec={...d.nut_prec,angles:n})}hC(f.mesh,d.orientation,i,f.body.nutPrec)}if(d.radii&&f.radiusScene>0&&!f.radiiApplied&&!d.displacement?.absolute_radius&&rM(f,d.radii),c?.tiers?.length&&(f.availableTiers=c.tiers,f.availableFrames=c.frames,f.textureBundleId=c.id===u?void 0:c.id,!f.textureTier)){let e=tM(i,f.availableFrames);l.push(sM(f,`low`,e,r))}l.push(...Jj(u,e,d,f,{textureLoader:r,currentJd:i,ctx:o})),d.rings?.length&&l.push(...xj(u,e,d.rings,d.radii,f,n,a,o))}}await Promise.allSettled(l)}function CN(e,t,n,r){for(let i of t.values())if(r.visibility.isBodyInSystem(i.body,e)){if(oM(i),Xj(i),i.terrainWindow&&i.mesh){i.terrainWindow=null;let e=Q(gn(i.body.data)),t=i.mesh.geometry;i.mesh.geometry=new ru(e,24,24),t.dispose(),i.currentSegments=24}for(let e of i.rings){e.planetShadow?.disable(),n.remove(e.mesh);let t=i.extraObjects.indexOf(e.mesh);t>=0&&i.extraObjects.splice(t,1),uA(e)}i.rings=[],PM(i)}}var wN=class{lastBaryId=null;pendingUnloads=new Set;prefetched=new Set;constructor(e,t,n,r,i,a,o){this.scene=e,this.ctx=t,this.renderer=n,this.textureLoader=r,this.bodyObjects=i,this.clock=a,this.onLoaded=o}syncToFocus(){let e=this.ctx.visibility.focusedSystemId,t=e?this.resolveBaryId(e):null;if(!t){this.lastBaryId&&=(this.pendingUnloads.add(this.lastBaryId),null);return}t!==this.lastBaryId&&(this.lastBaryId&&this.pendingUnloads.add(this.lastBaryId),this.pendingUnloads.delete(t),this.prefetched.delete(t),this.lastBaryId=t,this.load(t))}prefetch(e){let t=this.resolveBaryId(e);!t||t===this.lastBaryId||this.prefetched.has(t)||(this.prefetched.add(t),this.pendingUnloads.delete(t),this.load(t))}discardPrefetch(e){let t=this.resolveBaryId(e);!t||!this.prefetched.delete(t)||t!==this.lastBaryId&&this.pendingUnloads.add(t)}resolveBaryId(e){let t=this.ctx.getBody(e);if(t?.data.objectType===W.BARYCENTER)return e;let n=t?.data.parentId??e;return M_(n)?null:n}load(e){SN(e,this.bodyObjects,this.scene,this.textureLoader,this.clock.jd,this.renderer.capabilities.maxTextureSize,this.ctx).then(()=>{this.onLoaded(),this.ctx.bodies.orientationVersion++})}drainPendingUnloads(){if(this.pendingUnloads.size!==0){for(let e of this.pendingUnloads)CN(e,this.bodyObjects,this.scene,this.ctx);this.pendingUnloads.clear()}}hasPendingUnloads(){return this.pendingUnloads.size>0}},TN=Math.PI/180,EN=class{adjust={rxDeg:0,ryDeg:0,rzDeg:0};_q=new Hi;_adjustQ=new Hi;_tmpQ=new Hi;_axisX=new J(1,0,0);_axisY=new J(0,1,0);_axisZ=new J(0,0,1);constructor(e){this.scene=e}get(){return{...this.adjust}}set(e,t,n){this.adjust.rxDeg=e,this.adjust.ryDeg=t,this.adjust.rzDeg=n,this._adjustQ.setFromAxisAngle(this._axisX,e*TN).premultiply(this._tmpQ.setFromAxisAngle(this._axisY,t*TN)).premultiply(this._tmpQ.setFromAxisAngle(this._axisZ,n*TN)),this._q.copy(Qx).multiply(this._adjustQ),this.scene.backgroundRotation.setFromQuaternion(this._q)}},DN=Math.PI/180,ON=ag*DN,kN=Math.cos(ON),AN=Math.sin(ON),jN=5e3,MN=[{id:`galactic-center`,label:`Galactic Center`,raDeg:266.41683,decDeg:-29.00781,color:`#ff6b35`},{id:`galactic-anticenter`,label:`Galactic Anticenter`,raDeg:86.4,decDeg:28.93785,color:`#ff6b35`},{id:`galactic-np`,label:`Galactic NP`,raDeg:192.85948,decDeg:27.12825,color:`#ffb84d`},{id:`galactic-sp`,label:`Galactic SP`,raDeg:12.85948,decDeg:-27.12825,color:`#ffb84d`},{id:`ncp`,label:`NCP (Polaris ≈)`,raDeg:37.9542,decDeg:89.2641,color:`#4dd0ff`},{id:`scp`,label:`SCP`,raDeg:0,decDeg:-90,color:`#4dd0ff`},{id:`vernal`,label:`Vernal Equinox (γ)`,raDeg:0,decDeg:0,color:`#9d8cff`},{id:`autumnal`,label:`Autumnal Equinox`,raDeg:180,decDeg:0,color:`#9d8cff`},{id:`m31`,label:`M31 (Andromeda)`,raDeg:10.6847,decDeg:41.2692,color:`#ffffff`},{id:`lmc`,label:`LMC (Large Magellanic Cloud)`,raDeg:80.8942,decDeg:-69.7561,color:`#ffffff`},{id:`smc`,label:`SMC (Small Magellanic Cloud)`,raDeg:13.1583,decDeg:-72.8003,color:`#ffffff`},{id:`sirius`,label:`Sirius`,raDeg:101.2872,decDeg:-16.7161,color:`#ffffff`}],NN=192.85948,PN=27.12825,FN=266.40499,IN=-28.93617,LN=256,RN=[{name:`galactic-plane`,zero:zN(FN,IN,new J).normalize(),pole:zN(NN,PN,new J).normalize(),color:16739125},{name:`ecliptic-plane`,zero:new J(1,0,0),pole:new J(0,1,0),color:5099775},{name:`celestial-equator`,zero:zN(0,0,new J).normalize(),pole:zN(0,90,new J).normalize(),color:10325247}];function zN(e,t,n){let r=e*DN,i=t*DN,a=Math.cos(i),o=a*Math.cos(r),s=a*Math.sin(r),c=Math.sin(i),l=o,u=s*kN+c*AN,d=-s*AN+c*kN;return n.set(l,d,-u)}function BN(e){let t=document.createElement(`div`);t.className=`sky-debug-marker`,t.style.cssText=[`display:flex`,`align-items:center`,`gap:4px`,`font:11px/1 monospace`,`text-shadow:0 0 3px #000, 0 0 3px #000`,`pointer-events:none`,`white-space:nowrap`].join(`;`);let n=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);n.setAttribute(`width`,`48`),n.setAttribute(`height`,`48`),n.setAttribute(`viewBox`,`-24 -24 48 48`),n.style.cssText=`flex:0 0 auto;filter:drop-shadow(0 0 2px #000);margin-inline-start:-24px`;let r=e.color;n.innerHTML=`
|
|
5514
5514
|
<circle cx="0" cy="0" r="14" fill="none" stroke="${r}" stroke-width="1.6"/>
|
|
5515
5515
|
<line x1="-23" y1="0" x2="-10" y2="0" stroke="${r}" stroke-width="1.6"/>
|
|
5516
5516
|
<line x1="10" y1="0" x2="23" y2="0" stroke="${r}" stroke-width="1.6"/>
|
|
5517
5517
|
<line x1="0" y1="-23" x2="0" y2="-10" stroke="${r}" stroke-width="1.6"/>
|
|
5518
5518
|
<line x1="0" y1="10" x2="0" y2="23" stroke="${r}" stroke-width="1.6"/>
|
|
5519
|
-
`;let i=document.createElement(`span`);return i.textContent=e.label,i.style.color=e.color,i.style.marginInlineStart=`2px`,t.appendChild(n),t.appendChild(i),t}function IN(e,t,n,r,i){let a=new J().crossVectors(t,e).normalize(),o=new Float32Array(i*3),s=new J;for(let t=0;t<i;t++){let r=t/i*Math.PI*2,c=Math.cos(r),l=Math.sin(r);s.copy(e).multiplyScalar(c).addScaledVector(a,l).multiplyScalar(n),o[t*3]=s.x,o[t*3+1]=s.y,o[t*3+2]=s.z}let c=new Ho;c.setAttribute(`position`,new Ao(o,3));let l=new wc(c,new dc({color:r,transparent:!0,opacity:.55}));return l.frustumCulled=!1,l}function LN(){let e=new za;e.name=`sky-debug-markers`,e.visible=!1;let t=new J;for(let n of DN){PN(n.raDeg,n.decDeg,t).multiplyScalar(EN);let r=new YO(FN(n));r.center.set(0,.5),r.position.copy(t),e.add(r)}for(let t of NN){let n=IN(t.zero,t.pole,EN*.999,t.color,MN);n.name=t.name,e.add(n)}return e}function RN(e){e.traverse(e=>{e instanceof YO&&e.element.remove(),e instanceof wc&&(e.geometry.dispose(),e.material.dispose())}),e.parent?.remove(e)}var zN=class{group=null;constructor(e){this.scene=e}setVisible(e){e?(this.group||(this.group=LN(),this.scene.add(this.group)),this.group.visible=!0):this.group&&=(RN(this.group),null)}},BN=new J,VN=new J,HN=new J,UN=[BN,VN,HN];function WN(e,t,n){return BN.set(1,0,0).applyQuaternion(e).transformDirection(t),VN.set(0,1,0).applyQuaternion(e).transformDirection(t),HN.set(0,0,1).applyQuaternion(e).transformDirection(t),{e:UN,a:n}}function GN(e,t,n,r,i,a,o,s,c,l){let u=1/i;e.gxx=u,e.gxy=0,e.gxz=0,e.gyx=0,e.gyy=u,e.gyz=0,e.gzx=0,e.gzy=0,e.gzz=u,e.cpx=t*u,e.cpy=n*u,e.cpz=r*u,e.K=(t*t+n*n+r*r)*u*u-1,e.cx0=o,e.cy0=s,e.f=a,e.id=c,e.dist=l,e.ccx=t,e.ccy=n,e.ccz=r}function KN(e,t,n,r,i,a,o,s,c,l){let[u,d,f]=i.e,[p,m,h]=i.a;e.gxx=u.x/p,e.gxy=u.y/p,e.gxz=u.z/p,e.gyx=d.x/m,e.gyy=d.y/m,e.gyz=d.z/m,e.gzx=f.x/h,e.gzy=f.y/h,e.gzz=f.z/h;let g=(t*u.x+n*u.y+r*u.z)/p,_=(t*d.x+n*d.y+r*d.z)/m,v=(t*f.x+n*f.y+r*f.z)/h;e.cpx=g,e.cpy=_,e.cpz=v,e.K=g*g+_*_+v*v-1,e.cx0=o,e.cy0=s,e.f=a,e.id=c,e.dist=l,e.ccx=t,e.ccy=n,e.ccz=r}function qN(e,t,n,r,i,a){let[o,s,c]=r.e,[l,u,d]=r.a,f=1/(l*l),p=1/(u*u),m=1/(d*d),h=f*o.x*o.x+p*s.x*s.x+m*c.x*c.x,g=f*o.x*o.y+p*s.x*s.y+m*c.x*c.y,_=f*o.x*o.z+p*s.x*s.z+m*c.x*c.z,v=f*o.y*o.y+p*s.y*s.y+m*c.y*c.y,y=f*o.y*o.z+p*s.y*s.z+m*c.y*c.z,b=f*o.z*o.z+p*s.z*s.z+m*c.z*c.z,x=h*e+g*t+_*n,S=g*e+v*t+y*n,C=_*e+y*t+b*n,w=e*x+t*S+n*C-1,T=i,E=w*h-x*x,D=2*(w*g-x*S),O=w*v-S*S,k=-2*T*(w*_-x*C),A=-2*T*(w*y-S*C),j=4*E*O-D*D,M=(-2*O*k+D*A)/j,ee=(-2*E*A+D*k)/j,N=-n/T;a.ox=M*N-e,a.oy=ee*N-t}var JN=class{canvas=null;gfx=null;tmp=new J;tmpQ=new Hi;items=[];one=[];labelRect={x:0,left:0,right:0,y:0,h:0};constructor(e){this.anchor=e}get active(){return this.canvas!==null}setVisible(e){if(e){if(this.canvas)return;let e=document.createElement(`canvas`);e.style.cssText=`position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:5`,this.anchor.parentElement?.appendChild(e),this.canvas=e,this.gfx=e.getContext(`2d`)}else this.canvas&&(this.canvas.remove(),this.canvas=null,this.gfx=null)}draw(e,t,n,r,i,a){let o=this.gfx,s=this.canvas;if(!o||!s)return;let c=window.devicePixelRatio||1,l=Math.round(i*c),u=Math.round(a*c);(s.width!==l||s.height!==u)&&(s.width=l,s.height=u),o.setTransform(c,0,0,c,0,0),o.clearRect(0,0,i,a),o.font=`10px monospace`,o.textBaseline=`middle`;let d=t.fov*Math.PI/180,f=a/(2*Math.tan(d/2)),p=t.matrixWorldInverse,[m,h,g]=n,_=i*.5,v=a*.5,y=0;for(let o of e.values()){let{label:e,group:s,radiusScene:c}=o;if(!e||c<=0)continue;let[l,u,d]=o.body.position;this.tmp.set(l-m,u-h,d-g).applyMatrix4(p);let b=this.tmp.x,x=this.tmp.y,S=this.tmp.z;if(S>=0||b*b+x*x+S*S<=c*c)continue;let C=ZO(this.items,y++,YN),w=!!(o.semiAxesScene&&o.mesh);if(w){let e=WN(o.mesh.getWorldQuaternion(this.tmpQ),p,o.semiAxesScene);C.e0.copy(e.e[0]),C.e1.copy(e.e[1]),C.e2.copy(e.e[2]),C.sa[0]=e.a[0],C.sa[1]=e.a[1],C.sa[2]=e.a[2],KN(C.occ,b,x,S,e,f,_,v,o.body.data.id,o.cachedDist)}else C.e0.set(1,0,0),C.e1.set(0,1,0),C.e2.set(0,0,1),C.sa[0]=C.sa[1]=C.sa[2]=c,GN(C.occ,b,x,S,c,f,_,v,o.body.data.id,o.cachedDist);let T=S*S-c*c,E=T<=0,D=E?0:c*f/Math.sqrt(T),O=E||D>=16;this.tmp.set(l-m,u-h,d-g).project(t),C.cx=(this.tmp.x*.5+.5)*i,C.cy=(-this.tmp.y*.5+.5)*a,lk(o,t,n,i,a,this.labelRect),C.hx=this.labelRect.x,C.hy=this.labelRect.y,C.id=o.body.data.id,C.camX=b,C.camY=x,C.camZ=S,C.worldR=c,C.dist=o.cachedDist,C.isEllipsoid=w,C.degenerate=E,C.isOccluder=O,C.meshHidden=!s.visible,C.labelVisible=e.visible,C.maximized=o.labelMaximized!==!1,C.focused=o.body.data.id===r,C.occludedBy=-1}for(let e=0;e<y;e++){let t=this.items[e];for(let e=0;e<y;e++){let n=this.items[e];if(!(!n.isOccluder||n.id===t.id)&&(this.one[0]=n.occ,this.one.length=1,sk(t.hx,t.hy,t.dist,t.id,this.one))){t.occludedBy=e;break}}}for(let e=0;e<y;e++){let n=this.items[e];if(n.meshHidden&&!n.isOccluder)continue;let r=n.focused?`#7dff7d`:n.isOccluder?`#ff8c1a`:n.labelVisible?n.maximized?`#1ae5ff`:`#ffe11a`:`#ff3b3b`;if(o.beginPath(),n.meshHidden&&o.setLineDash([5,4]),this.strokeLimb(o,n,t,i,a)&&(o.strokeStyle=r,o.lineWidth=n.isOccluder?2:1,o.stroke(),n.isOccluder&&(o.fillStyle=`rgba(255,140,26,0.08)`,o.fill())),o.setLineDash([]),!n.degenerate){let e=n.hx-n.cx,t=n.hy-n.cy;if(e*e+t*t>1&&(o.beginPath(),o.moveTo(n.cx,n.cy),o.lineTo(n.hx,n.hy),o.strokeStyle=`rgba(255,225,26,0.5)`,o.lineWidth=1,o.stroke(),QN(o,n.cx,n.cy,4,`#ff3ad1`)),n.occludedBy>=0){let e=this.items[n.occludedBy];o.beginPath(),o.setLineDash([4,3]),o.moveTo(n.hx,n.hy),o.lineTo(e.cx,e.cy),o.strokeStyle=`rgba(255,59,59,0.9)`,o.lineWidth=1,o.stroke(),o.setLineDash([])}o.beginPath(),o.arc(n.hx,n.hy,1.5,0,Math.PI*2),o.fillStyle=r,o.fill(),o.fillStyle=`rgba(255,255,255,0.85)`,o.fillText(n.id,n.hx+8,n.hy)}}ZN(o,a)}strokeLimb(e,t,n,r,i){let{camX:a,camY:o,camZ:s,e0:c,e1:l,e2:u,sa:d}=t,f=(a*c.x+o*c.y+s*c.z)/d[0],p=(a*l.x+o*l.y+s*l.z)/d[1],m=(a*u.x+o*u.y+s*u.z)/d[2],h=f*f+p*p+m*m;if(h<=1)return!1;let g=Math.sqrt(h),_=(h-1)/h,v=Math.sqrt(h-1)/g,y=f*_,b=p*_,x=m*_,S=f/g,C=p/g,w=m/g,T=0,E=1;Math.abs(w)>.9&&(T=1,E=0);let D=C*E-w*0,O=w*T-S*E,k=S*0-C*T,A=Math.hypot(D,O,k)||1;D/=A,O/=A,k/=A;let j=C*k-w*O,M=w*D-S*k,ee=S*O-C*D,N=n.projectionMatrix.elements,te=!1;for(let t=0;t<=72;t++){let n=t/72*Math.PI*2,a=Math.cos(n),o=Math.sin(n),s=y+v*(a*D+o*j),f=b+v*(a*O+o*M),p=x+v*(a*k+o*ee),m=d[0]*s*c.x+d[1]*f*l.x+d[2]*p*u.x,h=d[0]*s*c.y+d[1]*f*l.y+d[2]*p*u.y,g=d[0]*s*c.z+d[1]*f*l.z+d[2]*p*u.z,_=N[3]*m+N[7]*h+N[11]*g+N[15];if(_<=1e-6){te=!1;continue}let S=(N[0]*m+N[4]*h+N[8]*g+N[12])/_,C=(N[1]*m+N[5]*h+N[9]*g+N[13])/_,w=(S*.5+.5)*r,T=(-C*.5+.5)*i;te?e.lineTo(w,T):(e.moveTo(w,T),te=!0)}return!0}dispose(){this.setVisible(!1)}};function YN(){return{id:``,camX:0,camY:0,camZ:0,worldR:0,e0:new J,e1:new J,e2:new J,sa:[0,0,0],occ:tk(),cx:0,cy:0,hx:0,hy:0,dist:0,isEllipsoid:!1,isOccluder:!1,degenerate:!1,meshHidden:!1,labelVisible:!1,maximized:!1,focused:!1,occludedBy:-1}}var XN=[[`#1ae5ff`,`label shown`],[`#ffe11a`,`dimmed`],[`#ff3b3b`,`hidden`],[`#ff8c1a`,`occluder silhouette`],[`#7dff7d`,`focused`]];function ZN(e,t){let n=t-8-(XN.length-1)*13;e.font=`10px monospace`,e.textBaseline=`middle`;for(let[t,r]of XN)e.fillStyle=t,e.fillRect(8,n-4,8,8),e.fillStyle=`rgba(255,255,255,0.9)`,e.fillText(r,20,n),n+=13}function QN(e,t,n,r,i){e.strokeStyle=i,e.lineWidth=1,e.beginPath(),e.moveTo(t-r,n),e.lineTo(t+r,n),e.moveTo(t,n-r),e.lineTo(t,n+r),e.stroke()}function $N(e){let{fps:t,orbitPool:n,renderer:r,bodyObjects:i,focusedBody:a,cameraDistanceScene:o}=e,s=r.info;return{fps:t,workers:n.workerCount,workerGroups:n.groupCount,drawCalls:s.render.calls,triangles:s.render.triangles,geometries:s.memory.geometries,textures:s.memory.textures,programs:s.programs?.length??0,promotedBodies:i.size,focusedId:a?.data.id,focusedName:a?.data.name??void 0,cameraDistanceAU:o/10,viewportW:r.domElement.clientWidth,viewportH:r.domElement.clientHeight,pixelRatio:r.getPixelRatio()}}var eP="function e(e,t,n=1e-10,r=50){let i=e;for(let a=0;a<r;a++){let r=(i-t*Math.sin(i)-e)/(1-t*Math.cos(i));if(i-=Math.max(-1,Math.min(1,r)),Math.abs(r)<n)break}return i}function t(e,t,n=1e-10,r=50){if(e===0)return 0;let i=e<0?-1:1,a=Math.abs(e),o=0,s=1;for(;t*Math.sinh(s)-s<a;)if(s*=2,s>700)return NaN;let c=.5*(o+s);for(let e=0;e<r;e++){let e=t*Math.sinh(c)-c-a;e>0?s=c:o=c;let r=c-e/(t*Math.cosh(c)-1);r>o&&r<s||(r=.5*(o+s));let i=Math.abs(r-c);if(c=r,i<n)break}return i*c}function n(e,t,n){let r=.01720209895*(n-t)/(Math.sqrt(2)*e**1.5),i=Math.cbrt(3*r+Math.sqrt(1+9*r*r)),a=i-1/i,o=2*Math.atan(a),s=e*(1+a*a);return!isFinite(o)||!isFinite(s)||s<=0?null:{nu:o,r:s}}const r=149597870.7,i=23.4392911;86400**2/r**3,1/r,Math.cos(Math.PI/180*i),Math.sin(Math.PI/180*i);const a=Math.PI,o=a*2,s=a/180;180/a;const c=6378.135,l=60/Math.sqrt(c*c*c/398600.8),u=c*l/60,d=1/l,f=.001082616,p=-253881e-11/f,m=2/3,ee=1440/(2*a);function te(e,t){let n=[31,e%4==0?29:28,31,30,31,30,31,31,30,31,30,31],r=Math.floor(t),i=1,a=0;for(;r>a+n[i-1]&&i<12;)a+=n[i-1],i+=1;let o=i,s=r-a,c=(t-r)*24,l=Math.floor(c);c=(c-l)*60;let u=Math.floor(c);return{mon:o,day:s,hr:l,minute:u,sec:(c-u)*60}}function h(e,t,n,r,i,a,o=0){return 367*e-Math.floor(7*(e+Math.floor((t+9)/12))*.25)+Math.floor(275*t/9)+n+1721013.5+((o/6e4+a/60+i)/60+r)/24}function g(e,t,n,r,i,a,o=0){if(e instanceof Date){let t=e;return h(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())}return h(e,t,n,r,i,a,o)}function ne(e,t){let{e3:n,ee2:r,peo:i,pgho:s,pho:c,pinco:l,plo:u,se2:d,se3:f,sgh2:p,sgh3:m,sgh4:ee,sh2:te,sh3:h,si2:g,si3:ne,sl2:_,sl3:v,sl4:y,t:b,xgh2:re,xgh3:ie,xgh4:x,xh2:ae,xh3:S,xi2:C,xi3:w,xl2:T,xl3:E,xl4:D,zmol:O,zmos:k}=e,{init:A,opsmode:j}=t,{ep:oe,inclp:M,nodep:N,argpp:se,mp:P}=t,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,le,Y,ue,de,X,fe;fe=k+119459e-10*b,A===`y`&&(fe=k),X=fe+2*.01675*Math.sin(fe),Y=Math.sin(X),U=.5*Y*Y-.25,W=-.5*Y*Math.cos(X);let pe=d*U+f*W,me=g*U+ne*W,he=_*U+v*W+y*Y,ge=p*U+m*W+ee*Y,Z=te*U+h*W;fe=O+.00015835218*b,A===`y`&&(fe=O),X=fe+2*.0549*Math.sin(fe),Y=Math.sin(X),U=.5*Y*Y-.25,W=-.5*Y*Math.cos(X);let _e=r*U+n*W,ve=C*U+w*W,ye=T*U+E*W+D*Y,be=re*U+ie*W+x*Y,xe=ae*U+S*W;return G=pe+_e,J=me+ve,le=he+ye,K=ge+be,q=Z+xe,A===`n`&&(G-=i,J-=l,le-=u,K-=s,q-=c,M+=J,oe+=G,R=Math.sin(M),L=Math.cos(M),M>=.2?(q/=R,K-=L*q,se+=K,N+=q,P+=le):(z=Math.sin(N),ce=Math.cos(N),F=R*z,I=R*ce,B=q*ce+J*L*z,V=-q*z+J*L*ce,F+=B,I+=V,N%=o,N<0&&j===`a`&&(N+=o),ue=P+se+L*N,H=le+K-J*N*R,ue+=H,de=N,N=Math.atan2(F,I),N<0&&j===`a`&&(N+=o),Math.abs(de-N)>a&&(N<de?N+=o:N-=o),P+=le,se=ue-P-L*N)),{ep:oe,inclp:M,nodep:N,argpp:se,mp:P}}function _(e){let{epoch:t,ep:n,argpp:r,tc:i,inclp:a,nodep:s,np:c}=e,l,u,d,f,p,m,ee,te,h,g,ne,_,v,y,b,re,ie,x,ae,S,C,w,T,E,D,O,k,A,j,oe,M,N,se,P,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,le,Y,ue,de,X,fe,pe,me,he,ge,Z,_e,ve,ye,be=.01675,xe=.0549,Se=c,Ce=n,we=Math.sin(s),Te=Math.cos(s),Ee=Math.sin(r),Q=Math.cos(r),De=Math.sin(a),Oe=Math.cos(a),$=Ce*Ce,ke=1-$,Ae=Math.sqrt(ke),je=t+18261.5+i/1440,Me=(4.523602-.00092422029*je)%o,Ne=Math.sin(Me),Pe=Math.cos(Me),Fe=.91375164-.03568096*Pe,Ie=Math.sqrt(1-Fe*Fe),Le=.089683511*Ne/Ie,Re=Math.sqrt(1-Le*Le),ze=5.8351514+.001944368*je,Be=.39785416*Ne/Ie,Ve=Re*Pe+.91744867*Le*Ne;Be=Math.atan2(Be,Ve),Be+=ze-Me;let He=Math.cos(Be),Ue=Math.sin(Be);S=.1945905,C=-.98088458,E=.91744867,D=.39785416,w=Te,T=we,ne=29864797e-13;let We=1/Se,Ge=0;for(;Ge<2;)Ge+=1,l=S*w+C*E*T,d=-C*w+S*E*T,ee=-S*T+C*E*w,te=C*D,h=C*T+S*E*w,g=S*D,u=Oe*ee+De*te,f=Oe*h+De*g,p=-De*ee+Oe*te,m=-De*h+Oe*g,_=l*Q+u*Ee,v=d*Q+f*Ee,y=-l*Ee+u*Q,b=-d*Ee+f*Q,re=p*Ee,ie=m*Ee,x=p*Q,ae=m*Q,_e=12*_*_-3*y*y,ve=24*_*v-6*y*b,ye=12*v*v-3*b*b,ue=3*(l*l+u*u)+_e*$,de=6*(l*d+u*f)+ve*$,X=3*(d*d+f*f)+ye*$,fe=-6*l*p+$*(-24*_*x-6*y*re),pe=-6*(l*m+d*p)+$*(-24*(v*x+_*ae)+-6*(y*ie+b*re)),me=-6*d*m+$*(-24*v*ae-6*b*ie),he=6*u*p+$*(24*_*re-6*y*x),ge=6*(f*p+u*m)+$*(24*(v*re+_*ie)-6*(b*x+y*ae)),Z=6*f*m+$*(24*v*ie-6*b*ae),ue=ue+ue+ke*_e,de=de+de+ke*ve,X=X+X+ke*ye,K=ne*We,G=-.5*K/Ae,q=K*Ae,W=-15*Ce*q,J=_*y+v*b,le=v*y+_*b,Y=v*b-_*y,Ge===1&&(O=W,k=G,A=K,j=q,oe=J,M=le,N=Y,se=ue,P=de,F=X,I=fe,L=pe,R=me,ce=he,z=ge,B=Z,V=_e,H=ve,U=ye,S=He,C=Ue,E=Fe,D=Ie,w=Re*Te+Le*we,T=we*Re-Te*Le,ne=4.7968065e-7);let Ke=(4.7199672+(.2299715*je-ze))%o,qe=(6.2565837+.017201977*je)%o,Je=2*O*M,Ye=2*O*N,Xe=2*k*L,Ze=2*k*(R-I),Qe=-2*A*P,$e=-2*A*(F-se),et=-2*A*(-21-9*$)*be,tt=2*j*H,nt=2*j*(U-V),rt=-18*j*be,it=-2*k*z,at=-2*k*(B-ce),ot=2*W*le,st=2*W*Y,ct=2*G*pe,lt=2*G*(me-fe),ut=-2*K*de,dt=-2*K*(X-ue),ft=-2*K*(-21-9*$)*xe,pt=2*q*ve,mt=2*q*(ye-_e),ht=-18*q*xe,gt=-2*G*ge,_t=-2*G*(Z-he);return{snodm:we,cnodm:Te,sinim:De,cosim:Oe,sinomm:Ee,cosomm:Q,day:je,e3:st,ee2:ot,em:Ce,emsq:$,gam:ze,peo:0,pgho:0,pho:0,pinco:0,plo:0,rtemsq:Ae,se2:Je,se3:Ye,sgh2:tt,sgh3:nt,sgh4:rt,sh2:it,sh3:at,si2:Xe,si3:Ze,sl2:Qe,sl3:$e,sl4:et,s1:W,s2:G,s3:K,s4:q,s5:J,s6:le,s7:Y,ss1:O,ss2:k,ss3:A,ss4:j,ss5:oe,ss6:M,ss7:N,sz1:se,sz2:P,sz3:F,sz11:I,sz12:L,sz13:R,sz21:ce,sz22:z,sz23:B,sz31:V,sz32:H,sz33:U,xgh2:pt,xgh3:mt,xgh4:ht,xh2:gt,xh3:_t,xi2:ct,xi3:lt,xl2:ut,xl3:dt,xl4:ft,nm:Se,z1:ue,z2:de,z3:X,z11:fe,z12:pe,z13:me,z21:he,z22:ge,z23:Z,z31:_e,z32:ve,z33:ye,zmol:Ke,zmos:qe}}function v(e){let{cosim:t,argpo:n,s1:r,s2:i,s3:s,s4:c,s5:u,sinim:d,ss1:f,ss2:p,ss3:ee,ss4:te,ss5:h,sz1:g,sz3:ne,sz11:_,sz13:v,sz21:y,sz23:b,sz31:re,sz33:ie,t:x,tc:ae,gsto:S,mo:C,mdot:w,no:T,nodeo:E,nodedot:D,xpidot:O,z1:k,z3:A,z11:j,z13:oe,z21:M,z23:N,z31:se,z33:P,ecco:F,eccsq:I}=e,{emsq:L,em:R,argpm:ce,inclm:z,mm:B,nm:V,nodem:H,irez:U,atime:W,d2201:G,d2211:K,d3210:q,d3222:J,d4410:le,d4422:Y,d5220:ue,d5232:de,d5421:X,d5433:fe,dedt:pe,didt:me,dmdt:he,dnodt:ge,domdt:Z,del1:_e,del2:ve,del3:ye,xfact:be,xlamo:xe,xli:Se,xni:Ce}=e,we,Te,Ee,Q,De,Oe,$,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,et=.0043752690880113,tt=.00015835218,nt=119459e-10;U=0,V<.0052359877&&V>.0034906585&&(U=1),V>=.00826&&V<=.00924&&R>=.5&&(U=2);let rt=f*nt*h,it=p*nt*(_+v),at=-nt*ee*(g+ne-14-6*L),ot=te*nt*(re+ie-6),st=-nt*p*(y+b);(z<.052359877||z>a-.052359877)&&(st=0),d!==0&&(st/=d);let ct=ot-t*st;pe=rt+r*tt*u,me=it+i*tt*(j+oe),he=at-tt*s*(k+A-14-6*L);let lt=c*tt*(se+P-6),ut=-tt*i*(M+N);(z<.052359877||z>a-.052359877)&&(ut=0),Z=ct+lt,ge=st,d!==0&&(Z-=t/d*ut,ge+=ut/d);let dt=(S+ae*et)%o;if(R+=pe*x,z+=me*x,ce+=Z*x,H+=ge*x,B+=he*x,U!==0){if(Ze=(V/l)**m,U===2){Qe=t*t;let e=R;R=F;let n=L;L=I,$e=R*L,Fe=-.306-(R-.64)*.44,R<=.65?(Ie=3.616-13.247*R+16.29*L,Re=-19.302+117.39*R-228.419*L+156.591*$e,ze=-18.9068+109.7927*R-214.6334*L+146.5816*$e,Be=-41.122+242.694*R-471.094*L+313.953*$e,Ve=-146.407+841.88*R-1629.014*L+1083.435*$e,He=-532.114+3017.977*R-5740.032*L+3708.276*$e):(Ie=-72.099+331.819*R-508.738*L+266.724*$e,Re=-346.844+1582.851*R-2415.925*L+1246.113*$e,ze=-342.585+1554.908*R-2366.899*L+1215.972*$e,Be=-1052.797+4758.686*R-7193.992*L+3651.957*$e,Ve=-3581.69+16178.11*R-24462.77*L+12422.52*$e,He=R>.715?-5149.66+29936.92*R-54087.36*L+31324.56*$e:1464.74-4664.75*R+3763.64*L),R<.7?(Ge=-919.2277+4988.61*R-9064.77*L+5542.21*$e,Ue=-822.71072+4568.6173*R-8491.4146*L+5337.524*$e,We=-853.666+4690.25*R-8624.77*L+5341.4*$e):(Ge=-37995.78+161616.52*R-229838.2*L+109377.94*$e,Ue=-51752.104+218913.95*R-309468.16*L+146349.42*$e,We=-40023.88+170470.89*R-242699.48*L+115605.82*$e),Ke=d*d,we=.75*(1+2*t+Qe),Te=1.5*Ke,Q=1.875*d*(1-2*t-3*Qe),De=-1.875*d*(1+2*t-3*Qe),$=35*Ke*we,ke=39.375*Ke*Ke,Ae=9.84375*d*(Ke*(1-2*t-5*Qe)+.33333333*(-2+4*t+6*Qe)),je=d*(4.92187512*Ke*(-2-4*t+10*Qe)+6.56250012*(1+2*t-3*Qe)),Me=29.53125*d*(2-8*t+Qe*(-12+8*t+10*Qe)),Ne=29.53125*d*(-2-8*t+Qe*(12+8*t-10*Qe)),Ye=V*V,Xe=Ze*Ze,Je=3*Ye*Xe,qe=Je*17891679e-13,G=qe*we*Fe,K=qe*Te*Ie,Je*=Ze,qe=Je*3.7393792e-7,q=qe*Q*Re,J=qe*De*ze,Je*=Ze,qe=2*Je*7.3636953e-9,le=qe*$*Be,Y=qe*ke*Ve,Je*=Ze,qe=Je*1.1428639e-7,ue=qe*Ae*He,de=qe*je*We,qe=2*Je*2.1765803e-9,X=qe*Me*Ue,fe=qe*Ne*Ge,xe=(C+E+E-(dt+dt))%o,be=w+he+2*(D+ge-et)-T,R=e,L=n}U===1&&(Pe=1+L*(-2.5+.8125*L),Re=1+2*L,Le=1+L*(-6+6.60937*L),we=.75*(1+t)*(1+t),Ee=.9375*d*d*(1+3*t)-.75*(1+t),Oe=1+t,Oe*=1.875*Oe*Oe,_e=3*V*V*Ze*Ze,ve=2*_e*we*Pe*17891679e-13,ye=3*_e*Oe*Le*2.2123015e-7*Ze,_e=_e*Ee*Re*21460748e-13*Ze,xe=(C+E+n-dt)%o,be=w+O+he+Z+ge-(T+et)),Se=xe,Ce=T,W=0,V=T+0}return{em:R,argpm:ce,inclm:z,mm:B,nm:V,nodem:H,irez:U,atime:W,d2201:G,d2211:K,d3210:q,d3222:J,d4410:le,d4422:Y,d5220:ue,d5232:de,d5421:X,d5433:fe,dedt:pe,didt:me,dmdt:he,dndt:0,dnodt:ge,domdt:Z,del1:_e,del2:ve,del3:ye,xfact:be,xlamo:xe,xli:Se,xni:Ce}}function y(e){let t=(e-2451545)/36525,n=-62e-7*t*t*t+.093104*t*t+3164400184.812866*t+67310.54841;return n=n*s/240%o,n<0&&(n+=o),n}function b(e,t,n,r,i,a,o){return e instanceof Date?y(g(e)):y(t===void 0?e:g(e,t,n,r,i,a,o))}function re(e){let{ecco:t,epoch:n,inclo:r,opsmode:i}=e,{no:a}=e,s=t*t,c=1-s,u=Math.sqrt(c),d=Math.cos(r),p=d*d,ee=(l/a)**m,te=.75*f*(3*p-1)/(u*c),h=te/(ee*ee),g=ee*(1-h*h-h*(1/3+134*h*h/81));h=te/(g*g),a/=1+h;let ne=(l/a)**m,_=Math.sin(r),v=ne*c,y=1-5*p,re=-y-p-p,ie=1/ne,x=v*v,ae=ne*(1-t),S;if(i===`a`){let e=n-7305,t=Math.floor(e+1e-8),r=e-t,i=.017202791694070362,a=i+o;S=(1.7321343856509375+i*t+a*r+e*e*5075514194322695e-30)%o,S<0&&(S+=o)}else S=b(n+2433281.5);return{no:a,method:`n`,ainv:ie,ao:ne,con41:re,con42:y,cosio:d,cosio2:p,eccsq:s,omeosq:c,posq:x,rp:ae,rteosq:u,sinio:_,gsto:S}}function ie(e){let{irez:t,d2201:n,d2211:r,d3210:i,d3222:a,d4410:s,d4422:c,d5220:l,d5232:u,d5421:d,d5433:f,dedt:p,del1:m,del2:ee,del3:te,didt:h,dmdt:g,dnodt:ne,domdt:_,argpo:v,argpdot:y,t:b,tc:re,gsto:ie,xfact:x,xlamo:ae,no:S}=e,{atime:C,em:w,argpm:T,inclm:E,xli:D,mm:O,xni:k,nodem:A,nm:j}=e,oe=.13130908,M=2.8843198,N=.37448087,se=5.7686396,P=.95240898,F=1.8014998,I=1.050833,L=4.4108898,R=259200,ce,z,B,V,H,U,W,G,K=0,q=0,J=(ie+re*.0043752690880113)%o;if(w+=p*b,E+=h*b,T+=_*b,A+=ne*b,O+=g*b,t!==0){(C===0||b*C<=0||Math.abs(b)<Math.abs(C))&&(C=0,k=S,D=ae),ce=b>0?720:-720;let e=381;for(;e===381;)t===2?(G=v+y*C,B=G+G,z=D+D,W=n*Math.sin(B+D-se)+r*Math.sin(D-se)+i*Math.sin(G+D-P)+a*Math.sin(-G+D-P)+s*Math.sin(B+z-F)+c*Math.sin(z-F)+l*Math.sin(G+D-I)+u*Math.sin(-G+D-I)+d*Math.sin(G+z-L)+f*Math.sin(-G+z-L),H=k+x,U=n*Math.cos(B+D-se)+r*Math.cos(D-se)+i*Math.cos(G+D-P)+a*Math.cos(-G+D-P)+l*Math.cos(G+D-I)+u*Math.cos(-G+D-I)+2*(s*Math.cos(B+z-F)+c*Math.cos(z-F)+d*Math.cos(G+z-L)+f*Math.cos(-G+z-L)),U*=H):(W=m*Math.sin(D-oe)+ee*Math.sin(2*(D-M))+te*Math.sin(3*(D-N)),H=k+x,U=m*Math.cos(D-oe)+2*ee*Math.cos(2*(D-M))+3*te*Math.cos(3*(D-N)),U*=H),Math.abs(b-C)>=720?e=381:(q=b-C,e=0),e===381&&(D+=H*ce+W*R,k+=W*ce+U*R,C+=ce);j=k+W*q+U*q*q*.5,V=D+H*q+W*q*q*.5,t===1?(O=V-A-T+J,K=j-S):(O=V-2*A+2*J,K=j-S),j=S+K}return{atime:C,em:w,argpm:T,inclm:E,xli:D,mm:O,xni:k,nodem:A,dndt:K,nm:j}}var x;(function(e){e[e.None=0]=`None`,e[e.MeanEccentricityOutOfRange=1]=`MeanEccentricityOutOfRange`,e[e.MeanMotionBelowZero=2]=`MeanMotionBelowZero`,e[e.PerturbedEccentricityOutOfRange=3]=`PerturbedEccentricityOutOfRange`,e[e.SemiLatusRectumBelowZero=4]=`SemiLatusRectumBelowZero`,e[e.Decayed=6]=`Decayed`})(x||={});function ae(e,t){let n,r,i,s,d,ee,te,h,g,_,v,y,b,re,ae,S,C,w,T,E,D,O,k,A,j,oe,M;e.t=t,e.error=x.None;let N=e.mo+e.mdot*e.t,se=e.argpo+e.argpdot*e.t,P=e.nodeo+e.nodedot*e.t;g=se,D=N;let F=e.t*e.t;if(k=P+e.nodecf*F,C=1-e.cc1*e.t,w=e.bstar*e.cc4*e.t,T=e.t2cof*F,e.isimp!==1){te=e.omgcof*e.t;let t=1+e.eta*Math.cos(N);ee=e.xmcof*(t*t*t-e.delmo),S=te+ee,D=N+S,g=se-S,y=F*e.t,b=y*e.t,C=C-e.d2*F-e.d3*y-e.d4*b,w+=e.bstar*e.cc5*(Math.sin(D)-e.sinmao),T=T+e.t3cof*y+b*(e.t4cof+e.t*e.t5cof)}O=e.no;let I=e.ecco;if(E=e.inclo,e.method===`d`){re=e.t;let t=ie({irez:e.irez,d2201:e.d2201,d2211:e.d2211,d3210:e.d3210,d3222:e.d3222,d4410:e.d4410,d4422:e.d4422,d5220:e.d5220,d5232:e.d5232,d5421:e.d5421,d5433:e.d5433,dedt:e.dedt,del1:e.del1,del2:e.del2,del3:e.del3,didt:e.didt,dmdt:e.dmdt,dnodt:e.dnodt,domdt:e.domdt,argpo:e.argpo,argpdot:e.argpdot,t:e.t,tc:re,gsto:e.gsto,xfact:e.xfact,xlamo:e.xlamo,no:e.no,atime:e.atime,em:I,argpm:g,inclm:E,xli:e.xli,mm:D,xni:e.xni,nodem:k,nm:O});({em:I,argpm:g,inclm:E,mm:D,nodem:k,nm:O}=t)}if(O<=0)return e.error=x.MeanMotionBelowZero,null;let L=(l/O)**m*C*C;if(O=l/L**1.5,I-=w,I>=1||I<-.001)return e.error=x.MeanEccentricityOutOfRange,null;I<1e-6&&(I=1e-6),D+=e.no*T,j=D+g+k,k%=o,g%=o,j%=o,D=(j-g-k)%o;let R={am:L,em:I,im:E,Om:k,om:g,mm:D,nm:O},ce=Math.sin(E),z=Math.cos(E),B=I;if(A=E,_=g,M=k,oe=D,s=ce,i=z,e.method===`d`){let t=ne(e,{inclo:e.inclo,init:`n`,ep:B,inclp:A,nodep:M,argpp:_,mp:oe,opsmode:e.operationmode});if({ep:B,nodep:M,argpp:_,mp:oe}=t,A=t.inclp,A<0&&(A=-A,M+=a,_-=a),B<0||B>1)return e.error=x.PerturbedEccentricityOutOfRange,null}e.method===`d`&&(s=Math.sin(A),i=Math.cos(A),e.aycof=-.5*p*s,Math.abs(i+1)>15e-13?e.xlcof=-.25*p*s*(3+5*i)/(1+i):e.xlcof=-.25*p*s*(3+5*i)/15e-13);let V=B*Math.cos(_);S=1/(L*(1-B*B));let H=B*Math.sin(_)+S*e.aycof,U=(oe+_+M+S*e.xlcof*V-M)%o;h=U,ae=9999.9;let W=1;for(;Math.abs(ae)>=1e-12&&W<=10;)r=Math.sin(h),n=Math.cos(h),ae=1-n*V-r*H,ae=(U-H*n+V*r-h)/ae,Math.abs(ae)>=.95&&(ae=ae>0?.95:-.95),h+=ae,W+=1;let G=V*n+H*r,K=V*r-H*n,q=V*V+H*H,J=L*(1-q);if(J<0)return e.error=x.SemiLatusRectumBelowZero,null;let le=L*(1-G),Y=Math.sqrt(L)*K/le,ue=Math.sqrt(J)/le,de=Math.sqrt(1-q);S=K/(1+de);let X=L/le*(r-H-V*S),fe=L/le*(n-V+H*S);v=Math.atan2(X,fe);let pe=(fe+fe)*X,me=1-2*X*X;S=1/J;let he=.5*f*S,ge=he*S;e.method===`d`&&(d=i*i,e.con41=3*d-1,e.x1mth2=1-d,e.x7thm1=7*d-1);let Z=le*(1-1.5*ge*de*e.con41)+.5*he*e.x1mth2*me;if(Z<1)return e.error=x.Decayed,null;v-=.25*ge*e.x7thm1*pe;let _e=M+1.5*ge*i*pe,ve=A+1.5*ge*i*s*me,ye=Y-O*he*e.x1mth2*pe/l,be=ue+O*he*(e.x1mth2*me+1.5*e.con41)/l,xe=Math.sin(v),Se=Math.cos(v),Ce=Math.sin(_e),we=Math.cos(_e),Te=Math.sin(ve),Ee=Math.cos(ve),Q=-Ce*Ee,De=we*Ee,Oe=Q*xe+we*Se,$=De*xe+Ce*Se,ke=Te*xe,Ae=Q*Se-we*xe,je=De*Se-Ce*xe,Me=Te*Se;return{position:{x:Z*Oe*c,y:Z*$*c,z:Z*ke*c},velocity:{x:(ye*Oe+be*Ae)*u,y:(ye*$+be*je)*u,z:(ye*ke+be*Me)*u},meanElements:R}}function S(e,t){let{opsmode:n,satn:r,epoch:i,xbstar:o,xecco:s,xargpo:l,xinclo:u,xmo:ee,xno:te,xnodeo:h}=t,g,y,b,ie,x,S,C,w,T,E,D,O,k,A,j,oe,M,N,se,P,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,le,Y,ue,de,X,fe,pe,me,he,ge,Z,_e,ve,ye,be,xe,Se,Ce,we,Te,Ee,Q=e;Q.isimp=0,Q.method=`n`,Q.aycof=0,Q.con41=0,Q.cc1=0,Q.cc4=0,Q.cc5=0,Q.d2=0,Q.d3=0,Q.d4=0,Q.delmo=0,Q.eta=0,Q.argpdot=0,Q.omgcof=0,Q.sinmao=0,Q.t=0,Q.t2cof=0,Q.t3cof=0,Q.t4cof=0,Q.t5cof=0,Q.x1mth2=0,Q.x7thm1=0,Q.mdot=0,Q.nodedot=0,Q.xlcof=0,Q.xmcof=0,Q.nodecf=0,Q.irez=0,Q.d2201=0,Q.d2211=0,Q.d3210=0,Q.d3222=0,Q.d4410=0,Q.d4422=0,Q.d5220=0,Q.d5232=0,Q.d5421=0,Q.d5433=0,Q.dedt=0,Q.del1=0,Q.del2=0,Q.del3=0,Q.didt=0,Q.dmdt=0,Q.dnodt=0,Q.domdt=0,Q.e3=0,Q.ee2=0,Q.peo=0,Q.pgho=0,Q.pho=0,Q.pinco=0,Q.plo=0,Q.se2=0,Q.se3=0,Q.sgh2=0,Q.sgh3=0,Q.sgh4=0,Q.sh2=0,Q.sh3=0,Q.si2=0,Q.si3=0,Q.sl2=0,Q.sl3=0,Q.sl4=0,Q.gsto=0,Q.xfact=0,Q.xgh2=0,Q.xgh3=0,Q.xgh4=0,Q.xh2=0,Q.xh3=0,Q.xi2=0,Q.xi3=0,Q.xl2=0,Q.xl3=0,Q.xl4=0,Q.xlamo=0,Q.zmol=0,Q.zmos=0,Q.atime=0,Q.xli=0,Q.xni=0,Q.bstar=o,Q.ecco=s,Q.argpo=l,Q.inclo=u,Q.mo=ee,Q.no=te,Q.nodeo=h,Q.operationmode=n,78/c+1;let De=42/c;De*De*De*De,Q.init=`y`,Q.t=0;let Oe=re({satn:r,ecco:Q.ecco,epoch:i,inclo:Q.inclo,no:Q.no,method:Q.method,opsmode:Q.operationmode}),{ao:$,con42:ke,cosio:Ae,cosio2:je,eccsq:Me,omeosq:Ne,posq:Pe,rp:Fe,rteosq:Ie,sinio:Le}=Oe;if(Q.no=Oe.no,Q.con41=Oe.con41,Q.gsto=Oe.gsto,Q.a=(Q.no*d)**(-2/3),Q.alta=Q.a*(1+Q.ecco)-1,Q.altp=Q.a*(1-Q.ecco)-1,Q.error=0,Ne>=0||Q.no>=0){if(Q.isimp=0,Fe<1.034492841559484&&(Q.isimp=1),B=1.0122292801892716,F=1.880279159015271e-9,N=(Fe-1)*c,N<156){B=N-78,N<98&&(B=20);let e=(120-B)/c;F=e*e*e*e,B=B/c+1}se=1/Pe,Z=1/($-B),Q.eta=$*Q.ecco*Z,O=Q.eta*Q.eta,D=Q.ecco*Q.eta,P=Math.abs(1-O),S=F*Z**4,C=S/P**3.5,ie=C*Q.no*($*(1+1.5*O+D*(4+O))+.375*f*Z/P*Q.con41*(8+3*O*(8+O))),Q.cc1=Q.bstar*ie,x=0,Q.ecco>1e-4&&(x=-2*S*Z*p*Q.no*Le/Q.ecco),Q.x1mth2=1-je,Q.cc4=2*Q.no*C*$*Ne*(Q.eta*(2+.5*O)+Q.ecco*(.5+2*O)-f*Z/($*P)*(-3*Q.con41*(1-2*D+O*(1.5-.5*D))+.75*Q.x1mth2*(2*O-D*(1+O))*Math.cos(2*Q.argpo))),Q.cc5=2*C*$*Ne*(1+2.75*(O+D)+D*O),w=je*je,me=1.5*f*se*Q.no,he=.5*me*f*se,ge=-.46875*-165597e-11*se*se*Q.no,Q.mdot=Q.no+.5*me*Ie*Q.con41+.0625*he*Ie*(13-78*je+137*w),Q.argpdot=-.5*me*ke+.0625*he*(7-114*je+395*w)+ge*(3-36*je+49*w),ve=-me*Ae,Q.nodedot=ve+(.5*he*(4-19*je)+2*ge*(3-7*je))*Ae,_e=Q.argpdot+Q.nodedot,Q.omgcof=Q.bstar*x*Math.cos(Q.argpo),Q.xmcof=0,Q.ecco>1e-4&&(Q.xmcof=-m*S*Q.bstar/D),Q.nodecf=3.5*Ne*ve*Q.cc1,Q.t2cof=1.5*Q.cc1,Math.abs(Ae+1)>15e-13?Q.xlcof=-.25*p*Le*(3+5*Ae)/(1+Ae):Q.xlcof=-.25*p*Le*(3+5*Ae)/15e-13,Q.aycof=-.5*p*Le;let e=1+Q.eta*Math.cos(Q.mo);if(Q.delmo=e*e*e,Q.sinmao=Math.sin(Q.mo),Q.x7thm1=7*je-1,2*a/Q.no>=225){Q.method=`d`,Q.isimp=1,fe=0,j=Q.inclo;let e=_({epoch:i,ep:Q.ecco,argpp:Q.argpo,tc:fe,inclp:Q.inclo,nodep:Q.nodeo,np:Q.no,e3:Q.e3,ee2:Q.ee2,peo:Q.peo,pgho:Q.pgho,pho:Q.pho,pinco:Q.pinco,plo:Q.plo,se2:Q.se2,se3:Q.se3,sgh2:Q.sgh2,sgh3:Q.sgh3,sgh4:Q.sgh4,sh2:Q.sh2,sh3:Q.sh3,si2:Q.si2,si3:Q.si3,sl2:Q.sl2,sl3:Q.sl3,sl4:Q.sl4,xgh2:Q.xgh2,xgh3:Q.xgh3,xgh4:Q.xgh4,xh2:Q.xh2,xh3:Q.xh3,xi2:Q.xi2,xi3:Q.xi3,xl2:Q.xl2,xl3:Q.xl3,xl4:Q.xl4,zmol:Q.zmol,zmos:Q.zmos});Q.e3=e.e3,Q.ee2=e.ee2,Q.peo=e.peo,Q.pgho=e.pgho,Q.pho=e.pho,Q.pinco=e.pinco,Q.plo=e.plo,Q.se2=e.se2,Q.se3=e.se3,Q.sgh2=e.sgh2,Q.sgh3=e.sgh3,Q.sgh4=e.sgh4,Q.sh2=e.sh2,Q.sh3=e.sh3,Q.si2=e.si2,Q.si3=e.si3,Q.sl2=e.sl2,Q.sl3=e.sl3,Q.sl4=e.sl4,{sinim:y,cosim:g,em:T,emsq:E,s1:I,s2:L,s3:R,s4:ce,s5:z,ss1:V,ss2:H,ss3:U,ss4:W,ss5:G,sz1:K,sz3:q,sz11:J,sz13:le,sz21:Y,sz23:ue,sz31:de,sz33:X}=e,Q.xgh2=e.xgh2,Q.xgh3=e.xgh3,Q.xgh4=e.xgh4,Q.xh2=e.xh2,Q.xh3=e.xh3,Q.xi2=e.xi2,Q.xi3=e.xi3,Q.xl2=e.xl2,Q.xl3=e.xl3,Q.xl4=e.xl4,Q.zmol=e.zmol,Q.zmos=e.zmos,{nm:M,z1:ye,z3:be,z11:xe,z13:Se,z21:Ce,z23:we,z31:Te,z33:Ee}=e;let t=ne(Q,{inclo:j,init:Q.init,ep:Q.ecco,inclp:Q.inclo,nodep:Q.nodeo,argpp:Q.argpo,mp:Q.mo,opsmode:Q.operationmode});Q.ecco=t.ep,Q.inclo=t.inclp,Q.nodeo=t.nodep,Q.argpo=t.argpp,Q.mo=t.mp,k=0,A=0,oe=0;let n=v({cosim:g,emsq:E,argpo:Q.argpo,s1:I,s2:L,s3:R,s4:ce,s5:z,sinim:y,ss1:V,ss2:H,ss3:U,ss4:W,ss5:G,sz1:K,sz3:q,sz11:J,sz13:le,sz21:Y,sz23:ue,sz31:de,sz33:X,t:Q.t,tc:fe,gsto:Q.gsto,mo:Q.mo,mdot:Q.mdot,no:Q.no,nodeo:Q.nodeo,nodedot:Q.nodedot,xpidot:_e,z1:ye,z3:be,z11:xe,z13:Se,z21:Ce,z23:we,z31:Te,z33:Ee,ecco:Q.ecco,eccsq:Me,em:T,argpm:k,inclm:j,mm:oe,nm:M,nodem:A,irez:Q.irez,atime:Q.atime,d2201:Q.d2201,d2211:Q.d2211,d3210:Q.d3210,d3222:Q.d3222,d4410:Q.d4410,d4422:Q.d4422,d5220:Q.d5220,d5232:Q.d5232,d5421:Q.d5421,d5433:Q.d5433,dedt:Q.dedt,didt:Q.didt,dmdt:Q.dmdt,dnodt:Q.dnodt,domdt:Q.domdt,del1:Q.del1,del2:Q.del2,del3:Q.del3,xfact:Q.xfact,xlamo:Q.xlamo,xli:Q.xli,xni:Q.xni});Q.irez=n.irez,Q.atime=n.atime,Q.d2201=n.d2201,Q.d2211=n.d2211,Q.d3210=n.d3210,Q.d3222=n.d3222,Q.d4410=n.d4410,Q.d4422=n.d4422,Q.d5220=n.d5220,Q.d5232=n.d5232,Q.d5421=n.d5421,Q.d5433=n.d5433,Q.dedt=n.dedt,Q.didt=n.didt,Q.dmdt=n.dmdt,Q.dnodt=n.dnodt,Q.domdt=n.domdt,Q.del1=n.del1,Q.del2=n.del2,Q.del3=n.del3,Q.xfact=n.xfact,Q.xlamo=n.xlamo,Q.xli=n.xli,Q.xni=n.xni}Q.isimp!==1&&(b=Q.cc1*Q.cc1,Q.d2=4*$*Z*b,pe=Q.d2*Z*Q.cc1/3,Q.d3=(17*$+B)*pe,Q.d4=.5*pe*$*Z*(221*$+31*B)*Q.cc1,Q.t3cof=Q.d2+2*b,Q.t4cof=.25*(3*Q.d3+Q.cc1*(12*Q.d2+10*b)),Q.t5cof=.2*(3*Q.d4+12*Q.cc1*Q.d3+6*Q.d2*Q.d2+15*b*(2*Q.d2+b)))}ae(Q,0),Q.init=`n`}function C(e,t=`i`){let n=e.NORAD_CAT_ID.toString(),r=new Date(e.EPOCH.endsWith(`Z`)?e.EPOCH:`${e.EPOCH}Z`),i=r.getUTCFullYear(),a=Number(i.toString().slice(-2)),o=(r.valueOf()-new Date(Date.UTC(i,0,1,0,0,0)).valueOf())/(86400*1e3)+1,c=Number(e.MEAN_MOTION_DOT),l=Number(e.MEAN_MOTION_DDOT);c/=ee*1440,l/=ee*1440*1440;let u=Number(e.BSTAR),d=Number(e.INCLINATION)*s,f=Number(e.RA_OF_ASC_NODE)*s,p=Number(e.ECCENTRICITY),m=Number(e.ARG_OF_PERICENTER)*s,h=Number(e.MEAN_ANOMALY)*s,ne=Number(e.MEAN_MOTION)/ee,{mon:_,day:v,hr:y,minute:b,sec:re}=te(i,o),ie=g(i,_,v,y,b,re),x={error:0,satnum:n,epochyr:a,epochdays:o,ndot:c,nddot:l,bstar:u,inclo:d,nodeo:f,ecco:p,argpo:m,mo:h,no:ne,jdsatepoch:ie};return S(x,{opsmode:t,satn:x.satnum,epoch:x.jdsatepoch-2433281.5,xbstar:x.bstar,xecco:x.ecco,xargpo:x.argpo,xinclo:x.inclo,xmo:x.mo,xno:x.no,xnodeo:x.nodeo}),x}3*Float64Array.BYTES_PER_ELEMENT;const w=Math.PI/180;Math.cos(i*w),Math.sin(i*w);function T(e){return new Date((e-2440587.5)*864e5).toISOString()}function E(e,t){let n=C({OBJECT_NAME:t??String(e.noradCatId),OBJECT_ID:String(e.noradCatId),EPOCH:T(e.epochJd),MEAN_MOTION:e.meanMotion,ECCENTRICITY:e.eccentricity,INCLINATION:e.inclination,RA_OF_ASC_NODE:e.raOfAscNode,ARG_OF_PERICENTER:e.argOfPericenter,MEAN_ANOMALY:e.meanAnomaly,EPHEMERIS_TYPE:0,CLASSIFICATION_TYPE:`U`,NORAD_CAT_ID:e.noradCatId,ELEMENT_SET_NO:e.elementSetNo,REV_AT_EPOCH:e.revAtEpoch,BSTAR:e.bstar,MEAN_MOTION_DOT:e.meanMotionDot,MEAN_MOTION_DDOT:e.meanMotionDdot});return n.error===x.None?n:(console.warn(`buildSatrec: SGP4 init failed for NORAD ${e.noradCatId} (error=${n.error})`),null)}const D=Math.PI/180,O=Math.cos(i*D),k=Math.sin(i*D),A=10/r;function j(e,t,n,r,i){return!isFinite(Math.fround(n))||!isFinite(Math.fround(r))||!isFinite(Math.fround(i))?!1:(e[t*3]=n,e[t*3+1]=r,e[t*3+2]=i,!0)}function oe(r,i,a,o,s,c,l,u,d,f=null,p=0){if(i<r.validityStart||i>r.validityEnd)return 0;let{count:m,kind:ee,equatorial:te,a:h,e:g,i:ne,om:_,w:v,ma:y,n:b,epoch:re,q:ie,tp:S,satrec:C,flags:w,visibleFromDays:T}=r,oe=p!==0&&r.applyFlagFilter,M=r.pickBase,N=d.length/3|0,se=i-2451545,P=0;for(let F=0;F<m&&!(P>=N);F++){let m=ee[F];if(m===0||T[F]>se||oe&&(w[F]&p)!==p)continue;if(m===3){let e=C[F];if(!e){if(e=E({noradCatId:r.satnum[F],epochJd:re[F],meanMotion:b[F]/360,eccentricity:g[F],inclination:ne[F],raOfAscNode:_[F],argOfPericenter:v[F],meanAnomaly:y[F],bstar:r.bstar[F],meanMotionDot:r.ndot[F],meanMotionDdot:r.nddot[F],elementSetNo:0,revAtEpoch:0}),!e){ee[F]=0;continue}C[F]=e}let t=(i-e.jdsatepoch)*1440,n=ae(e,t);if(!n||e.error!==x.None)continue;let p=n.position.x,m=n.position.y,te=n.position.z,h=p*A,ie=m*A,S=te*A,w=ie*O+S*k,T=-ie*k+S*O,D=h,oe=T,N=-w;if(!j(d,P,a+D-c,o+oe-l,s+N-u))continue;if(f){let e=M+F,t=P*4;f[t]=e&255,f[t+1]=e>>>8&255,f[t+2]=e>>>16&255,f[t+3]=e>>>24&255}P++;continue}let N,I,L=g[F],R=ne[F],ce=_[F],z=v[F];if(m===2){let e=n(ie[F],S[F],i);if(!e)continue;N=e.r*Math.cos(e.nu),I=e.r*Math.sin(e.nu)}else{let n=h[F];if(!isFinite(n)||!isFinite(L)||!isFinite(y[F])||!isFinite(b[F]))continue;let r=i-re[F],a=(y[F]+b[F]*r)*D,o,s;if(L<1||n>0){let t=Math.min(L,.9999999),r=e(a,t),i=Math.sqrt(1-t*t)*Math.sin(r)/(1-t*Math.cos(r)),c=(Math.cos(r)-t)/(1-t*Math.cos(r));o=Math.atan2(i,c),s=n*(1-t*Math.cos(r))}else{let e=t(a,L);if(!isFinite(e))continue;let r=L*Math.cosh(e)-1;if(Math.abs(r)<1e-15)continue;let i=Math.sqrt(L*L-1)*Math.sinh(e)/r,c=(L-Math.cosh(e))/r;o=Math.atan2(i,c),s=n*(1-L*Math.cosh(e))}N=s*Math.cos(o),I=s*Math.sin(o)}if(!isFinite(N)||!isFinite(I))continue;let B=Math.cos(z*D),V=Math.sin(z*D),H=Math.cos(R*D),U=Math.sin(R*D),W=Math.cos(ce*D),G=Math.sin(ce*D),K=(W*B-G*V*H)*N+(-W*V-G*B*H)*I,q=(G*B+W*V*H)*N+(-G*V+W*B*H)*I,J=V*U*N+B*U*I;if(te[F]){let e=q*O+J*k,t=-q*k+J*O;q=e,J=t}let le=K*10,Y=J*10,ue=-q*10;if(j(d,P,a+le-c,o+Y-l,s+ue-u)){if(f){let e=M+F,t=P*4;f[t]=e&255,f[t+1]=e>>>8&255,f[t+2]=e>>>16&255,f[t+3]=e>>>24&255}P++}}return P}const M=new Map;self.onmessage=e=>{let t=e.data;if(t.type===`ping`){self.postMessage({type:`pong`});return}if(t.type===`rewireDelta`){if(t.remove)for(let e of t.remove)M.delete(e);for(let e of t.set)M.set(e.id,e.cols);return}if(t.type===`tick`){let e=[],n=[],[r,i,a]=t.basis;for(let o of t.groups){let s=M.get(o.id);if(!s){e.push({id:o.id,count:0,buf:o.out.buffer,idbuf:o.outIds.buffer}),n.push(o.out.buffer,o.outIds.buffer);continue}let c=oe(s,t.jd,o.parent[0],o.parent[1],o.parent[2],r,i,a,o.out,o.outIds,t.requiredFlags??0);e.push({id:o.id,count:c,buf:o.out.buffer,idbuf:o.outIds.buffer}),n.push(o.out.buffer,o.outIds.buffer)}self.postMessage({type:`tickResult`,groups:e},n);return}};\n//# sourceMappingURL=worker-CK5Z1yOu.js.map",tP=typeof self<`u`&&self.Blob&&new Blob([`URL.revokeObjectURL(import.meta.url);`,eP],{type:`text/javascript;charset=utf-8`});function nP(e){let t;try{if(t=tP&&(self.URL||self.webkitURL).createObjectURL(tP),!t)throw``;let n=new Worker(t,{type:`module`,name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(eP),{type:`module`,name:e?.name})}}var rP=class{workers=[];groups=new Map;onResult=null;size;pendingPing=null;generation=0;constructor(e=navigator.hardwareConcurrency??4){this.size=Math.max(2,Math.min(8,e)),this.spawn()}spawn(){for(let e=0;e<this.size;e++){let e=new nP;e.onmessage=e=>this.onMessage(e.data),this.workers.push(e)}}ping(e=800){if(this.workers.length===0)return Promise.resolve(!1);if(this.pendingPing)return this.pendingPing.promise;let t,n=new Promise(e=>t=e),r={need:this.workers.length,got:0,promise:n,resolve:e=>{this.pendingPing===r&&(this.pendingPing=null,t(e))}};this.pendingPing=r,setTimeout(()=>r.resolve(!1),e);for(let e of this.workers)e.postMessage({type:`ping`});return n}respawn(){this.pendingPing?.resolve(!1);for(let e of this.workers)e.terminate();this.workers=[],this.groups.clear(),this.generation++,this.spawn()}get poolGeneration(){return this.generation}setResultHandler(e){this.onResult=e}get workerCount(){return this.workers.length}get groupCount(){return this.groups.size}async rewireOne(e,t,n,r,i=!1,a=0){if(t.length===0){this.unwireOne(e);return}let o=await Bg(t,n,i);o.pickBase=a,this.workers.length!==0&&this.wireCols(e,o,r,t.length)}rewireOneCols(e,t,n){if(this.workers.length!==0){if(t.count===0){this.unwireOne(e);return}this.wireCols(e,t,n,t.count)}}wireCols(e,t,n,r){let i=this.groups.get(e),a=i?.workerIdx??n%this.workers.length,o,s,c,l;if(i&&i.capacity===r)o=i.front,s=i.back,c=i.idFront,l=i.idBack;else if(o=new Float32Array(r*3),s=new Float32Array(r*3),c=new Uint8Array(r*4),l=new Uint8Array(r*4),i){let e=Math.min(i.front.length,o.length);o.set(i.front.subarray(0,e));let t=Math.min(i.idFront.length,c.length);c.set(i.idFront.subarray(0,t))}let u=!!i&&i.back===null;this.groups.set(e,{workerIdx:a,capacity:r,front:o,back:s,idFront:c,idBack:l,count:i?.count??r,pendingBasis:u?i.pendingBasis:null,pendingParent:u?i.pendingParent:null,pendingJd:u?i.pendingJd:null,frontBasis:i?.frontBasis??[0,0,0],frontParent:i?.frontParent??[0,0,0],frontJd:i?.frontJd??NaN}),this.workers[a].postMessage({type:`rewireDelta`,set:[{id:e,cols:t}]},Hg(t))}unwireOne(e){let t=this.groups.get(e);t&&(this.groups.delete(e),this.workers[t.workerIdx].postMessage({type:`rewireDelta`,set:[],remove:[e]}))}tick(e,t,n,r=0){let i=this.workers.map(()=>[]);for(let[r,a]of this.groups){if(!a.back||!a.idBack)continue;let o=n.get(r);o&&(i[a.workerIdx].push({id:r,parent:[o[0],o[1],o[2]],out:a.back,outIds:a.idBack}),a.back=null,a.idBack=null,a.pendingBasis=[t[0],t[1],t[2]],a.pendingParent=[o[0],o[1],o[2]],a.pendingJd=e)}for(let n=0;n<this.workers.length;n++){let a=i[n];if(a.length===0)continue;let o=a.flatMap(e=>[e.out.buffer,e.outIds.buffer]);this.workers[n].postMessage({type:`tick`,jd:e,basis:[t[0],t[1],t[2]],requiredFlags:r,groups:a},o)}}onMessage(e){if(e.type===`pong`){let e=this.pendingPing;e&&++e.got>=e.need&&e.resolve(!0);return}if(e.type===`tickResult`)for(let t of e.groups){let e=this.groups.get(t.id);if(!e)continue;let n=new Float32Array(t.buf),r=e.front;e.front=n,e.back=r;let i=new Uint8Array(t.idbuf),a=e.idFront;e.idFront=i,e.idBack=a,e.count=t.count;let o=e.pendingBasis??e.frontBasis,s=e.pendingParent??e.frontParent,c=e.pendingJd??e.frontJd;e.frontBasis=o,e.frontParent=s,e.frontJd=c,e.pendingBasis=null,e.pendingParent=null,e.pendingJd=null,this.onResult?.(t.id,n,t.count,o,s,c,i)}}destroy(){this.pendingPing?.resolve(!1);for(let e of this.workers)e.terminate();this.workers.length=0,this.groups.clear()}},iP=class{#e=1;#t=new Map;allocate(e,t){let n=this.#e;return this.#e+=t.length,this.#t.set(e,{base:n,keys:t}),n}release(e){this.#t.delete(e)}resolve(e){if(e===0)return null;for(let{base:t,keys:n}of this.#t.values())if(e>=t&&e<t+n.length)return _h(n[e-t]);return null}clear(){this.#t.clear(),this.#e=1}},aP=.01,oP=[`asteroid`,`spacecraft`],sP=.0002959122082855911,cP=.75,lP=Q(8*86400);function uP(e){let t=0,n=!1;for(let r=0;r<e.count;r++){if(e.kind[r]===0)continue;let i=e.a[r],a=e.e[r];if(e.kind[r]!==1||!(i>0)||!(a<1)||!isFinite(i)||!isFinite(a)){n=!0;continue}let o=Math.min(a,.9999999),s=Math.sqrt(sP/i*((1+o)/(1-o)));s>t&&(t=s)}return{maxSpeedScene:t*10,alwaysSolve:n}}function dP(e){return e<0?0:e>1?1:e}function fP(e,t){return t===`*`?e.startsWith(`small_bodies/`):e===t}function pP(e){return e===null?{tBright:0,tSize:0}:{tBright:dP((mP-e)/(mP-hP)),tSize:dP((gP-e)/(gP-_P))}}var mP=1e4,hP=500,gP=hP,_P=50,vP=4,yP=.5,bP=10,xP=1,SP=1,CP=3.5,wP=2.5,TP=2,EP=CP,DP=class{orbitPool=new rP;pickRegistry=new iP;workerPoints={asteroid:new Map,spacecraft:new Map};moonPoints=new Map;pointBudget=1/0;drawFraction=1;pendingSceneAdds=[];basisPos=[0,0,0];parentAtUpdate=new Map;_parentsScratch=new Map;moonsByParentCache=null;lastPackedSize=new Map;groupKinematics=new Map;lastSolvedJd=new Map;earthSatEmphasis={size:vP,dim:yP,opacity:SP};emphasizedSmallBodyZone=null;smallBodyEmphasis={sizeMult:1,brightMult:1,opacity:SP};constructor(e,t,n,r,i,a,o){this.ctx=e,this.scene=t,this.bodyObjects=n,this.circleTexture=r,this.focus=i,this.mapLayer=a,this.onBasisRebuilt=o,this.orbitPool.setResultHandler(this.onPoolResult)}basis(){return this.basisPos}setPointBudget(e){this.pointBudget=e,this.applyPointBudget()}applyPointBudget(){let e=0;for(let t of oP)for(let n of this.workerPoints[t].values())n.visible&&(e+=n.userData.solvedCount??0);let t=e>this.pointBudget?this.pointBudget/e:1;if(t!==this.drawFraction){this.drawFraction=t;for(let e of oP)for(let n of this.workerPoints[e].values()){let e=n.userData.solvedCount;e!==void 0&&n.geometry.setDrawRange(0,Math.ceil(e*t))}}}setEarthSatEmphasis(e){this.earthSatEmphasis=this.computeEarthSatEmphasis(e);for(let[e,t]of this.workerPoints.spacecraft)S_(e)===`naif-399`&&this.applyEarthSatEmphasis(t)}computeEarthSatEmphasis(e){let{tBright:t,tSize:n}=pP(e);return{size:vP+(bP-vP)*n,dim:yP+(xP-yP)*t,opacity:SP+(CP-SP)*t}}applyEarthSatEmphasis(e){let t=e.material,{size:n,dim:r,opacity:i}=this.earthSatEmphasis;t.size=n,t.color.setRGB(r,r,r),t.opacity=i}setEmphasizedSmallBodyZone(e,t){let n=this.emphasizedSmallBodyZone;if(this.emphasizedSmallBodyZone=e,this.smallBodyEmphasis=this.computeSmallBodyEmphasis(e===null?null:t),n!==null&&n!==e)for(let[e,t]of this.workerPoints.asteroid)fP(S_(e),n)&&this.resetSmallBodyEmphasis(t);if(e!==null)for(let[t,n]of this.workerPoints.asteroid)fP(S_(t),e)&&this.applySmallBodyEmphasis(n)}computeSmallBodyEmphasis(e){let{tBright:t,tSize:n}=pP(e);return{sizeMult:1+(wP-1)*n,brightMult:1+(TP-1)*t,opacity:SP+(EP-SP)*t}}applySmallBodyEmphasis(e){let t=e.material;e.userData.smallBodyBaseSize===void 0&&(e.userData.smallBodyBaseSize=t.size,e.userData.smallBodyBaseColor=t.color.clone());let n=e.userData.smallBodyBaseSize,r=e.userData.smallBodyBaseColor,{sizeMult:i,brightMult:a,opacity:o}=this.smallBodyEmphasis;t.size=n*i,t.color.copy(r).multiplyScalar(a),t.opacity=o}resetSmallBodyEmphasis(e){if(e.userData.smallBodyBaseSize===void 0)return;let t=e.material;t.size=e.userData.smallBodyBaseSize,t.color.copy(e.userData.smallBodyBaseColor),t.opacity=SP,e.userData.smallBodyBaseSize=void 0,e.userData.smallBodyBaseColor=void 0}seedBasis(e){this.basisPos=[...e]}buildInitial(e){let t=gN(this.ctx,this.scene,this.circleTexture,this.basisPos,e,this.orbitPool.workerCount);this.workerPoints.asteroid=t.asteroidPoints,this.workerPoints.spacecraft=t.spacecraftPoints,this.moonPoints=t.moonPoints;for(let e of oP)for(let[t,n]of this.workerPoints[e]){let r=S_(t);n.userData.parentBodyId=this.cloudParentId(e,r),this.emphasiseNewCloud(e,r,n)}this.assignMapLayer()}assignMapLayer(){for(let e of oP)for(let t of this.workerPoints[e].values())t.layers.set(this.mapLayer);for(let e of this.moonPoints.values())e.layers.set(this.mapLayer)}cloudParentId(e,t){return e===`asteroid`?f_:t}emphasiseNewCloud(e,t,n){if(e===`spacecraft`){t===`naif-399`&&this.applyEarthSatEmphasis(n);return}let r=this.emphasizedSmallBodyZone;r!==null&&fP(t,r)&&this.applySmallBodyEmphasis(n)}rebuildRunning=!1;rebuildQueued=!1;rebuildMinor(){if(this.rebuildRunning){this.rebuildQueued=!0;return}this.rebuildRunning=!0,(async()=>{try{do this.rebuildQueued=!1,await this.rebuildMinorPass();while(this.rebuildQueued)}finally{this.rebuildRunning=!1}})()}recovering=null;recoverWorkersIfDead(e){return this.recovering??=this.runRecovery(e).finally(()=>this.recovering=null),this.recovering}async runRecovery(e){if(await this.orbitPool.ping(e))return!1;this.orbitPool.respawn();for(let e of this.ctx.bodies.asteroidBodiesByZone.keys())this.ctx.bodies.dirtyAsteroidZones.add(e);for(let e of this.ctx.bodies.spacecraftByParent.keys())this.ctx.bodies.dirtySpacecraftGroups.add(e);return this.lastPackedSize.clear(),this.rebuildMinor(),!0}async rebuildMinorPass(){if(this.ctx.bodies.dirtyAsteroidZones.size===0&&this.ctx.bodies.dirtySpacecraftGroups.size===0)return;let e=[this.basisPos[0],this.basisPos[1],this.basisPos[2]],t=this.orbitPool.workerCount,n=this.orbitPool.poolGeneration,r=[],i=[];for(let n of[...this.ctx.bodies.dirtyAsteroidZones]){let i=this.ctx.bodies.asteroidBodiesByZone.get(n);if(this.deferPackWhileStreaming(`asteroid:${n}`,i?.size??0))continue;this.ctx.bodies.dirtyAsteroidZones.delete(n),r.push(n);let a=yh(this.bodyObjects.keys()),{groups:o,baseWorker:s}=i?await i.buildWorkerGroups(n,t,a,!1):{groups:[],baseWorker:0},c=i&&o.length>0?i.cloudColor():`#888888`;for(let r=0;r<t;r++){let i=`${n}#${r}`,a=`asteroid:${i}`,l=r<o.length?o[r]:null;if(!l||l.cols.count===0){this.unwireGroup(`asteroid`,i,a);continue}this.armGroupGate(a,uP(l.cols)),l.cols.pickBase=this.pickRegistry.allocate(a,l.keys),this.orbitPool.rewireOneCols(a,l.cols,(s+r)%t);let u=this.workerPoints.asteroid.get(i);if(u){this.resizeGeometryToCount(u.geometry,l.cols.count,null);continue}let d=YM(new Float32Array(l.cols.count*3),0,this.circleTexture,c,qM());this.adoptCloud(`asteroid`,i,a,d,e)}}for(let n of[...this.ctx.bodies.dirtySpacecraftGroups]){let r=this.ctx.bodies.spacecraftByParent.get(n);if(this.deferPackWhileStreaming(`spacecraft:${n}`,r?.size??0))continue;this.ctx.bodies.dirtySpacecraftGroups.delete(n),i.push(n);let{buckets:a,baseWorker:o}=await x_(n,wv(this.ctx.layers,n,r?Array.from(r.values()):[]),t),s=new Set(this.bodyObjects.keys());for(let r=0;r<t;r++){let i=`${n}#${r}`,c=`spacecraft:${i}`,l=r<a.length?a[r]:[];if(l.length===0){this.unwireGroup(`spacecraft`,i,c);continue}let u=this.pickRegistry.allocate(c,Float64Array.from(l,e=>vh(e.data.id)??fh));await this.orbitPool.rewireOne(c,l,s,(o+r)%t,!1,u),this.armGroupGate(c,{maxSpeedScene:lP,alwaysSolve:!1});let d=this.workerPoints.spacecraft.get(i);if(d){this.resizeGeometryIfNeeded(d.geometry,l);continue}let f=new Float32Array(l.length*3),p=new Float32Array(l.length*3);this.seedGeometryArray(f,l,p);let m=YM(f,l.length,this.circleTexture,`#ffffff`,void 0,p);this.adoptCloud(`spacecraft`,i,c,m,e)}}if(this.orbitPool.poolGeneration!==n){for(let e of r)this.ctx.bodies.dirtyAsteroidZones.add(e);for(let e of i)this.ctx.bodies.dirtySpacecraftGroups.add(e);this.lastPackedSize.clear(),this.rebuildQueued=!0}}unwireGroup(e,t,n){this.orbitPool.unwireOne(n),this.forgetGroupGate(n),this.pickRegistry.release(n);let r=this.workerPoints[e].get(t);r&&(this.scene.remove(r),this.workerPoints[e].delete(t))}armGroupGate(e,t){this.groupKinematics.set(e,t),this.lastSolvedJd.delete(e)}adoptCloud(e,t,n,r,i){let a=S_(t);r.userData.frontBasis=i,r.userData.groupId=n,r.userData.parentBodyId=this.cloudParentId(e,a),r.userData.parentVec=[0,0,0],this.emphasiseNewCloud(e,a,r),this.workerPoints[e].set(t,r),this.pendingSceneAdds.push(r)}deferPackWhileStreaming(e,t){if(!this.ctx.bodies.minorStreaming)return this.lastPackedSize.set(e,t),!1;let n=this.lastPackedSize.get(e);return n!==void 0&&t>n&&t<n*2?!0:(this.lastPackedSize.set(e,t),!1)}seedGeometryArray(e,t,n=null){let[r,i,a]=this.basisPos,o=Math.min(t.length,e.length/3),s=n?new X:null;for(let c=0;c<o;c++){let o=t[c],l=o.position;e[c*3]=l[0]-r,e[c*3+1]=l[1]-i,e[c*3+2]=l[2]-a,n&&s&&(s.set(h_(o.data)),n[c*3]=s.r,n[c*3+1]=s.g,n[c*3+2]=s.b)}}resizeGeometryIfNeeded(e,t){let n=t.length*3;if(e.getAttribute(`position`).array.length===n){e.setDrawRange(0,t.length);return}let r=!!e.getAttribute(`color`),i=new Float32Array(n),a=r?new Float32Array(n):null;this.seedGeometryArray(i,t,a),e.setAttribute(`position`,new Do(i,3)),a&&e.setAttribute(`color`,new Do(a,3)),e.setDrawRange(0,t.length)}resizeGeometryToCount(e,t,n){let r=t*3,i=e.getAttribute(`position`).array;if(n&&e.setAttribute(`color`,new Do(n,3)),i.length===r)return;let a=new Float32Array(r);a.set(i.subarray(0,Math.min(i.length,r))),e.setAttribute(`position`,new Do(a,3));let o=Math.min(e.drawRange.count,t);e.setDrawRange(0,Number.isFinite(o)?o:0)}onPoolResult=(e,t,n,r,i,a,o)=>{let[s,c]=e.split(`:`),l=this.workerPoints[s].get(c);if(!l)return;let u=l.geometry.getAttribute(`position`),d=u.array;if(d.length!==t.length)return;d.set(t),u.needsUpdate=!0,this.bindPickIds(l,o),l.userData.solvedCount=n,l.geometry.setDrawRange(0,Math.ceil(n*this.drawFraction)),this.lastSolvedJd.set(e,a),l.userData.frontBasis=[r[0],r[1],r[2]],this.parentAtUpdate.set(e,[i[0],i[1],i[2]]);let[f,p,m]=this.focus.focusTruePos,h=this.ctx.getBody(l.userData.parentBodyId)?.position,g=h?h[0]-i[0]:0,_=h?h[1]-i[1]:0,v=h?h[2]-i[2]:0;l.position.set(r[0]-f+g,r[1]-p+_,r[2]-m+v)};bindPickIds(e,t){let n=e.geometry.getAttribute(`pickColor`);n&&n.array.length===t.length?(n.array.set(t),n.needsUpdate=!0):e.geometry.setAttribute(`pickColor`,new Do(t.slice(),4,!0))}reposition(){let[e,t,n]=this.focus.focusTruePos,r=this.basisPos;for(let i of oP)for(let a of this.workerPoints[i].values()){let i=a.userData.frontBasis??r,[o,s,c]=this.parentShift(a.userData.groupId,a.userData.parentBodyId);a.position.set(i[0]-e+o,i[1]-t+s,i[2]-n+c)}let[i,a,o]=r,s=i-e,c=a-t,l=o-n;for(let e of this.moonPoints.values())e.position.set(s,c,l)}parentShift(e,t){let n=this.parentAtUpdate.get(e),r=this.ctx.getBody(t)?.position;return!n||!r?[0,0,0]:[r[0]-n[0],r[1]-n[1],r[2]-n[2]]}maybeRebase(){let[e,t,n]=this.focus.focusTruePos,[r,i,a]=this.basisPos,o=e-r,s=t-i,c=n-a,l=o*o+s*s+c*c,u=aP*10;l>u*u&&this.rebuildBasis()}rebuildBasis(){this.basisPos=[...this.focus.focusTruePos],this.rebuildMoons(),this.onBasisRebuilt(),this.reposition()}updateForJd(e,t){this.writeMoons();let n=this._parentsScratch;n.clear();let r=this.ctx.getBody(`naif-10`)?.position??[0,0,0];for(let[i,a]of this.workerPoints.asteroid){if(!this.ctx.visibility.isAsteroidGroupVisible(S_(i)))continue;let o=a.userData.groupId;if(!this.shouldSolveGroup(o,r,e,t))continue;let s=a.userData.parentVec;s[0]=r[0],s[1]=r[1],s[2]=r[2],n.set(o,s)}for(let[r,i]of this.workerPoints.spacecraft){if(!this.ctx.visibility.isSpacecraftGroupVisible(S_(r)))continue;let a=i.userData.groupId,o=this.ctx.getBody(i.userData.parentBodyId)?.position;if(o&&!this.shouldSolveGroup(a,o,e,t))continue;let s=i.userData.parentVec;o?(s[0]=o[0],s[1]=o[1],s[2]=o[2]):(s[0]=0,s[1]=0,s[2]=0),n.set(a,s)}this.orbitPool.tick(e,this.basisPos,n,this.ctx.visibility.getRequiredFlags())}shouldSolveGroup(e,t,n,r){let i=this.groupKinematics.get(e);if(!i||i.alwaysSolve)return!0;let a=this.lastSolvedJd.get(e);if(a===void 0||!isFinite(a))return!0;let[o,s,c]=this.focus.focusTruePos,l=r.camPos[0]-(t[0]-o),u=r.camPos[1]-(t[1]-s),d=r.camPos[2]-(t[2]-c),f=Math.max(1e-6,Math.sqrt(l*l+u*u+d*d)),p=Math.abs(n-a);return i.maxSpeedScene*p/f*r.pxPerRad>=cP}forgetGroupGate(e){this.groupKinematics.delete(e),this.lastSolvedJd.delete(e)}moonsByParent(){let e=this.ctx.bodies.majorBodies.length;if(this.moonsByParentCache?.len===e)return this.moonsByParentCache.map;let t=new Map;for(let e of this.ctx.bodies.majorBodies)if(e.data.objectType===W.MOON){let n=t.get(e.data.parentId)??[];n.push(e),t.set(e.data.parentId,n)}return this.moonsByParentCache={len:e,map:t},t}writeMoons(){let[e,t,n]=this.basisPos;for(let[r,i]of this.moonsByParent()){let a=this.moonPoints.get(r);if(!a||!this.ctx.visibility.isMoonGroupVisible(r))continue;let o=a.geometry.getAttribute(`position`),s=o.array,c=Math.min(i.length,s.length/3);for(let r=0;r<c;r++){let a=i[r];if(this.bodyObjects.get(a.data.id)?.outOfRange){s[r*3]=s[r*3+1]=s[r*3+2]=NaN;continue}s[r*3]=a.position[0]-e,s[r*3+1]=a.position[1]-t,s[r*3+2]=a.position[2]-n}o.needsUpdate=!0}}rebuildMoons(){let e=this.basisPos;for(let[t,n]of this.moonsByParent()){let r=this.moonPoints.get(t);if(!r)continue;let i=new Float32Array(n.length*3);for(let t=0;t<n.length;t++)i[t*3]=n[t].position[0]-e[0],i[t*3+1]=n[t].position[1]-e[1],i[t*3+2]=n[t].position[2]-e[2];r.geometry.setAttribute(`position`,new Ao(i,3))}}hasPendingSceneAdds(){return this.pendingSceneAdds.length>0}drainOnePendingSceneAdd(){if(this.pendingSceneAdds.length===0)return;let e=this.pendingSceneAdds.shift();e.layers.set(this.mapLayer),this.scene.add(e)}asteroids(){return this.workerPoints.asteroid}spacecraft(){return this.workerPoints.spacecraft}moons(){return this.moonPoints}dispose(){this.orbitPool.destroy(),this.pickRegistry.clear();for(let e of oP)this.disposeClouds(this.workerPoints[e]);this.disposeClouds(this.moonPoints);for(let e of this.pendingSceneAdds)e.geometry.dispose(),e.material.dispose();this.pendingSceneAdds.length=0}disposeClouds(e){for(let t of e.values())this.scene.remove(t),t.geometry.dispose(),t.material.dispose();e.clear()}},OP=Math.PI/180,kP=2451545,AP=1.00000261,jP=.01671123,MP=100.46457166*OP,NP=35999.37244981/36525*OP,PP=102.93768193*OP,FP=.32327364/36525*OP;function IP(e){let t=e-kP,n=PP+FP*t,r=MP+NP*t-n,i=r+(2*jP-jP**3/4)*Math.sin(r)+1.25*jP*jP*Math.sin(2*r);return{lon:n+i,r:AP*(1-jP*jP)/(1+jP*Math.cos(i))}}function LP(e){let t=IP(e).lon;return(e,n)=>{let r=t-IP(e).lon,i=Math.cos(r),a=Math.sin(r),o=n[0],s=n[2];n[0]=o*i+s*a,n[2]=-o*a+s*i}}var RP=.01,zP=1/100,BP=1;function VP(e,t,n){if(!n)return 0;let r=1/0;for(let i=0;i<t;i++){let t=e[i*3]-n.camX,a=e[i*3+1]-n.camY,o=e[i*3+2]-n.camZ,s=t*t+a*a+o*o;s<r&&(r=s)}return Math.sqrt(r)*n.tolAngle}function HP(e,t,n,r,i,a,o,s,c){if(t!==e.lastVersion||e.lastOffX===void 0)return!1;let l=e.rewriteTol;if(c){let t=c.camX-e.lastCamX,n=c.camY-e.lastCamY,r=c.camZ-e.lastCamZ;l=Math.max(0,l-Math.sqrt(t*t+n*n+r*r)*c.tolAngle)}let u=(n-e.lastOffX)**2+(r-e.lastOffY)**2+(i-e.lastOffZ)**2,d=(a-e.lastHeadX)**2+(o-e.lastHeadY)**2+(s-e.lastHeadZ)**2;return u<=l*l&&d<=l*l}function UP(e,t,n,r,i,a,o,s,c,l,u){e.lastVersion=t,e.lastOffX=n,e.lastOffY=r,e.lastOffZ=i,e.lastHeadX=a,e.lastHeadY=o,e.lastHeadZ=s,e.lastCamX=u?.camX??0,e.lastCamY=u?.camY??0,e.lastCamZ=u?.camZ??0,e.rewriteTol=VP(c,l,u)}function WP(e,t,n,r,i,a){let o=t.userData,s=o.useTrail,c=o.orbitCenter,l=e.trailAnchor??e.position,u=c.x-r[0],d=c.y-r[1],f=c.z-r[2],p=l[0]-c.x,m=l[1]-c.y,h=l[2]-c.z,g=e.lagrangeTrail?NaN:n.newestJd+n.count*1e-9;if(HP(o,g,u,d,f,p,m,h,a))return;let{posArr:_,trailArr:v,fullArr:y}=cN(t),b=e.lagrangeTrail?LP(i):null,x=uN(e,n,_,c.x,c.y,c.z,r,b??void 0);lN(t,_,v,y,x,!0,s),UP(o,g,u,d,f,p,m,h,_,x,a)}function GP(e,t,n,r,i){let{posArr:a,trailArr:o,fullArr:s,capacity:c}=cN(e),l=Math.min(t.length,c);for(let e=0;e<l;e++)a[e*3]=t[e][0]+n,a[e*3+1]=t[e][1]+r,a[e*3+2]=t[e][2]+i;if(e.userData.lastOffX=void 0,e.userData.isFatLine){iN(e.geometry,a,o,s,l);return}e.geometry.getAttribute(`position`).needsUpdate=!0}function KP(e,t,n,r,i){let a=t.userData.trailBuffer;if(a){WP(e,t,a,n,r,i);return}let o=t.userData.sourceCurve;if(!o){if(!t.userData.curvePending||!e.orbitElements)return;o=tN(Kv(e.orbitElements,r),512).points,t.userData.sourceCurve=o,t.userData.curveJd=r,t.userData.curvePending=!1}let s=t.userData.isOpenCurve,c=t.userData.useTrail,l=t.userData.orbitCenter,u=l.x,d=l.y,f=l.z;if(e.data.satrec){let n=e.data.n/360,i=n>0?1/n/512:0,a=t.userData.curveJd;(o.length===0||a===void 0||Math.abs(r-a)>=i)&&(o=$M(e.data.satrec,r,n,512),t.userData.sourceCurve=o,t.userData.curveJd=r)}else if(e.orbitElements){if(e.rederiveElements){let n=t.userData.elementsJd??r,i=e.orbitElements.n,a=i>0?360/i:1/0;if(Math.abs(r-n)>Math.min(a*zP,BP)){let n=e.rederiveElements(r);n&&(Object.assign(e.orbitElements,n),o=tN(e.orbitElements,512).points,t.userData.sourceCurve=o,t.userData.curveJd=r,t.userData.elementsJd=r)}}let n=e.orbitElements.omDot??0,i=e.orbitElements.wDot??0,a=Math.max(Math.abs(n),Math.abs(i));if(a>0){let n=t.userData.curveJd??r;a*Math.abs(r-n)>RP&&(o=tN(Kv(e.orbitElements,r),512).points,t.userData.sourceCurve=o,t.userData.curveJd=r)}}let p=e.trailAnchor??e.position,m=t.userData,h=u-n[0],g=d-n[1],_=f-n[2],v=p[0]-u,y=p[1]-d,b=p[2]-f;if(HP(m,o,h,g,_,v,y,b,i))return;let x=$y(e,o,s,u,d,f);if(x.length<2)return;let{posArr:S,trailArr:C,fullArr:w,capacity:T}=cN(t),E=u-n[0],D=d-n[1],O=f-n[2],k=Math.min(x.length,T);for(let e=0;e<k;e++)S[e*3]=x[e][0]+E,S[e*3+1]=x[e][1]+D,S[e*3+2]=x[e][2]+O;lN(t,S,C,w,k,s,c),m.trailLocalPositions=x,UP(m,o,h,g,_,v,y,b,S,k,i)}function qP(e,t,n){let r=e===$.CAPPED;return{groupVisible:e===$.CLOSE||e===$.FULL||r&&t,orbitVisible:e===$.FULL||e===$.CLOSE&&n,showLabel:e===$.FULL||r&&t,isClose:e===$.CLOSE}}function JP(e,t,n){return{groupVisible:e===$.CLOSE||e===$.FULL,orbitVisible:e===$.FULL&&t||e===$.CLOSE&&n,showLabel:e===$.FULL&&t,isClose:t&&e===$.CLOSE}}var YP=4/2,XP=(.1*10)**2,ZP=new J,QP=[],$P=QP;function eF(e){return ZO(QP,e,tk)}var tF={x:0,y:0,left:0,right:0,h:0},nF=new Hi,rF={ox:0,oy:0},iF=new J,aF=new J;function oF(e,t,n,r,i,o,s,c,l,u,d,f,p,m,h){let g=n.layers,_=!g.isVisible(`orbits`),v=g.isVisible(`nomenclature`),y=t.fov*Math.PI/180,b=f.domElement.clientWidth,x=f.domElement.clientHeight,S=x/(2*Math.tan(y/2)),C=[r[0]+t.position.x,r[1]+t.position.y,r[2]+t.position.z],w=r,T=t.matrixWorldInverse;for(let n of e.values()){if(n.cachedDist=R_(C,n.body.position),n.noPhysical){let e=n.noPhysical===`model`;JE(n,`missing`,cg(n.cachedDist)<(e?.1:1)?e?a().messages.body_note_no_model():a().messages.body_note_no_radius():null)}let e=n.label;if(!e)continue;n.labelAnchorOffscreen=!1;let r=n.noPhysical?0:n.radiusScene;if(!r){e.position.set(0,0,0);continue}let[i,o,s]=n.body.position;p.set(i-w[0],o-w[1],s-w[2]).applyMatrix4(T);let c=p.x,l=p.y,u=p.z,d=u*u,f=r*r;if(d<=f){e.position.set(0,0,0),n.labelAnchorOffscreen=!0;continue}let m=r/n.cachedDist*S;if(m<1){e.position.set(0,0,0);continue}if(m>=16){let a=n.cachedDist,d=1/a,f=c*d,m=l*d,h=u*d,g=r*d,_=Math.sqrt(Math.max(1-g*g,0)),v=1-f*f,y=-f*m,b=-f*h,x=Math.hypot(v,y,b);x<1e-4&&(v=-m*f,y=1-m*m,b=-m*h,x=Math.hypot(v,y,b));let S=g/x,C=f*_+v*S,T=m*_+y*S,E=h*_+b*S;p.set(C*a-c,T*a-l,E*a-u).applyQuaternion(t.quaternion),e.position.copy(p),aF.set(i-w[0]+p.x,o-w[1]+p.y,s-w[2]+p.z).project(t),n.labelAnchorOffscreen=Math.abs(aF.x)>1||Math.abs(aF.y)>1;continue}if(n.semiAxesScene&&n.mesh)qN(c,l,u,WN(n.mesh.getWorldQuaternion(nF),T,n.semiAxesScene),S,rF),p.set(rF.ox,rF.oy,0).applyQuaternion(t.quaternion);else{let e=f/(d-f);p.set(e*c,e*l,0).applyQuaternion(t.quaternion)}e.position.copy(p)}let E=QP,D=b*.5,O=x*.5,k=0;for(let t of e.values()){let e=t.noPhysical?0:t.radiusScene;if(!e)continue;let n=t.cachedDist,[r,i,a]=t.body.position,o=t.model?.userData.occluderSpheres;if(t.model&&o?.length){let e=QD(t),s=t.model.position;for(let c of o){let o=c.r*e;if(iF.copy(c.center).applyQuaternion(t.model.quaternion).add(s).multiplyScalar(e),p.set(r-w[0]+iF.x,i-w[1]+iF.y,a-w[2]+iF.z).applyMatrix4(T),p.z>=o||p.lengthSq()<=o*o)continue;let l=p.z*p.z;(l<=o*o||o*S/Math.sqrt(l-o*o)>=16)&&GN(eF(k++),p.x,p.y,p.z,o,S,D,O,t.body.data.id,n)}continue}p.set(r-w[0],i-w[1],a-w[2]).applyMatrix4(T);let s=p.x,c=p.y,l=p.z;if(l>=e)continue;let u=l*l;(u<=e*e||e*S/Math.sqrt(u-e*e)>=16)&&(t.semiAxesScene&&t.mesh?KN(eF(k++),s,c,l,WN(t.mesh.getWorldQuaternion(nF),T,t.semiAxesScene),S,D,O,t.body.data.id,n):GN(eF(k++),s,c,l,e,S,D,O,t.body.data.id,n))}E.length=k;let A=n.visibility.focusedSystemId,j=!1,M=i?gM(n.getBody(i),e):void 0;for(let r of e.values()){let{body:a,group:s,trail:c}=r,l=r.cachedDist,u,d,f=a.data.id===i,p=A!==null&&a.data.id===A;if(r.mesh===null&&!vn(a.data.objectType)){let t=a.data.objectType;if(t===W.BARYCENTER||t===W.LAGRANGE_POINT){let t=!0,r=f?void 0:P_(a.data.id);if(r){let i=e.get(r)?.body??n.getBody(r);i&&R_(a.position,i.position)/R_(C,i.position)*S<16&&(t=!1)}s.visible=t,c&&(c.visible=t),u=t,d=!1}else{let e=n.visibility.getPlanetVisibility(a,l)!==$.HIDE&&n.visibility.hasFullRendering(a);s.visible=e,c&&(c.visible=e),u=e,d=!1}}else{let e=a.data.objectType===W.MOON,t=e?n.visibility.getMoonVisibility(a):n.visibility.getPlanetVisibility(a,l),r=e?qP(t,o,f):JP(t,n.visibility.hasFullRendering(a),f||p);s.visible=r.groupVisible,c&&(c.visible=r.orbitVisible),u=r.showLabel,d=r.isClose}if(r.outOfRange&&(s.visible=!1,c&&(c.visible=!1),u=!1),r.starPoint){let e=r.radiusScene/l*S,t=e<YP;if(r.starPoint.visible=t,t){let t=r.starPoint.material,n=e/YP,i=Math.max(JA*n*n,3);t.uniforms.uIntensity.value=i}s.visible=!0,d=!t,u=!d}if(r.isMinor&&!f&&c&&(c.visible=!1),h&&c?.visible){let e=c.userData.orbitCenter;e&&e.distanceToSquared(ZP.set(w[0],w[1],w[2]))>XP&&(c.visible=!1)}_&&c&&(c.visible=!1),s.matrixWorldAutoUpdate=s.visible;let{label:m}=r;if(!s.visible&&m&&m.parent===s?(s.remove(m),m.element.remove()):s.visible&&m&&m.parent!==s&&s.add(m),r.mesh&&r.radiusScene>0){let e=!f&&!p&&r.radiusScene/l*S<.5;e!==r.meshSubPixel&&(r.meshSubPixel=e,e?r.mesh.layers.disable(0):r.mesh.layers.enable(0))}ok(r,u,d,l,S,i)&&(j=!0);let g=r.radiusScene>0?r.radiusScene/l*S:0;RM(r,v&&a.data.id===M,g,t,b,x)}for(let[e,t]of c)t.visible=n.visibility.isAsteroidGroupVisible(S_(e));for(let[e,t]of l)t.visible=n.visibility.isSpacecraftGroupVisible(S_(e));for(let[e,t]of u)t.visible=n.visibility.isMoonGroupVisible(e);if(E.length>0)for(let n of e.values())n.label?.visible&&lk(n,t,w,b,x,tF)&&sk(tF.x,tF.y,n.cachedDist,n.body.data.id,E)&&(n.label.visible=!1);if((m||j||++d>=3)&&(d=0,Sk(e,b,x,t,i,n,s,E,r)),Ck(e,b,x,t,r),M){let t=e.get(M);t&&HM(t)}for(let n of e.values()){let e=n.trail;if(!e?.visible)continue;let r=e.material;r.uniforms.uCenterOffset.value.set(-t.position.x,-t.position.y,-t.position.z);let a=n.body.data.id===i,o=s.has(n.body.data.id);r.uniforms.uAlphaMultiplier.value=o?2:a?1.75:1;let c=e.userData.isOpenCurve===!1;r.uniforms.uAlphaMin.value=a&&c?.15:0,r.uniforms.uShowFull.value=+!!a}return d}function sF(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function cF(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}function lF(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function uF(e,t){let n=e.arcs[t].points.length,r=t=>e.endOrbits.find(e=>e.at===t);return{from:t===0?r(`departure`)?.trimFrom??0:0,to:t===e.arcs.length-1?r(`arrival`)?.trimTo??n:n}}function dF(e,t){let n=e.arcs[0],r=e.arcs[e.arcs.length-1];if(!n||!r)return null;let i=t=>e.endOrbits.find(e=>e.at===t)??null,a=i(`departure`),o=i(`arrival`),s=e=>e&&e.approach.length>1?e:null,c=s(a),l=s(o),u=e=>e&&e.pointJds&&e.points.length>1&&e.pointJds.length===e.points.length?{points:e.points,jds:e.pointJds}:null,d=u(a),f=o?.surfaceJd===void 0?u(o):null,p=Math.min(n.startJd,a?.surfaceJd??1/0),m=Math.max(r.endJd,o?.surfaceJd??l?.jds[l.jds.length-1]??-1/0),h=d?p-fF(d):p,g=f?m+fF(f):m;if(t<h||t>g)return null;if(a&&d&&t<(c?.jds[0]??n.startJd))return{r:pF(d,t),centerId:a.anchorId};if(c&&t<=c.jds[c.jds.length-1])return{r:mF(c.approach,c.jds,t),centerId:c.anchorId};if(o&&t>=(l?.jds[0]??r.endJd)){let e=o.surfaceJd??l?.jds[l.jds.length-1]??r.endJd;if(f&&(!l||t>e))return{r:pF(f,t),centerId:o.anchorId};if(l)return{r:mF(l.approach,l.jds,Math.min(t,e)),centerId:o.anchorId}}let _=e.arcs.findIndex(e=>t>=e.startJd&&t<=e.endJd),v=_>=0?_:e.arcs.length-1,{points:y,jds:b}=e.arcs[v];if(y.length===0)return null;if(y.length===1||b.length!==y.length)return{r:y[0],centerId:e.centerId};let{from:x,to:S}=uF(e,v);return{r:mF(y,b,t,x,S),centerId:e.centerId}}function fF(e){return e.jds[e.jds.length-1]-e.jds[0]}function pF(e,t){let n=fF(e),r=e.jds[0],i=n>0?r+((t-r)%n+n)%n:t;return mF(e.points,e.jds,i)}function mF(e,t,n,r=0,i=e.length){if(i-r<2)return e[r];let a=r+1;for(;a<i-1&&t[a]<n;)a++;let o=t[a]-t[a-1],s=o>0?Math.min(1,Math.max(0,(n-t[a-1])/o)):0;return sF(e[a-1],lF(cF(e[a],e[a-1]),s))}var hF=Math.PI/180,gF=Math.cos(ag*hF),_F=Math.sin(ag*hF);function vF(e,t,n,r){let i=Math.cos(e*hF),a=Math.sin(e*hF),o=Math.cos(t*hF),s=Math.sin(t*hF),c=Math.cos(n*hF),l=Math.sin(n*hF);return{m11:c*i-l*a*o,m12:-c*a-l*i*o,m21:l*i+c*a*o,m22:-l*a+c*i*o,m31:a*s,m32:i*s,equatorial:r}}function yF(e,t,n){let r=n.m11*e+n.m12*t,i=n.m21*e+n.m22*t,a=n.m31*e+n.m32*t;if(n.equatorial){let e=i*gF+a*_F,t=-i*_F+a*gF;i=e,a=t}return[r,i,a]}function bF(e){let t=10/ig;return[e[0]*t,e[2]*t,-e[1]*t]}function xF(e,t,n){let{a:r,e:i,ma:a,n:o,epoch:s,q:c,tp:l}=e,{om:u,w:d}=Kv(e,t),f=e.equatorial??!1;if(!isFinite(r)||r===0||!isFinite(o)||o<=0){if(c==null||l==null||!isFinite(c)||!isFinite(l)||c<=0)return null;let r=wg(c,l,t);if(!r)return null;let i=n&&n>0?n:ev,a=r.r*ig,o=2*c*ig;return SF(a,r.nu,o,1,i,d,e.i,u,f)}if(!isFinite(i)||!isFinite(a))return null;let p=r*ig,m=o*hF/tv,h=n&&n>0?n:m*m*Math.abs(p)*Math.abs(p)*Math.abs(p);if(!isFinite(h)||h<=0)return null;let g=(a+o*(t-s))*hF,_,v;if(i<1||r>0){let e=Math.min(i,.9999999),t=xg(g,e),n=1-e*Math.cos(t);_=Math.atan2(Math.sqrt(1-e*e)*Math.sin(t),Math.cos(t)-e),v=p*n}else{let e=Cg(g,i);if(!isFinite(e))return null;let t=i*Math.cosh(e)-1;if(Math.abs(t)<1e-15)return null;_=Math.atan2(Math.sqrt(i*i-1)*Math.sinh(e)/t,(i-Math.cosh(e))/t),v=p*(1-i*Math.cosh(e))}if(!isFinite(v)||v<=0)return null;let y=p*(1-i*i);return!isFinite(y)||y<=0?null:SF(v,_,y,i,h,d,e.i,u,f)}function SF(e,t,n,r,i,a,o,s,c){let l=Math.cos(t),u=Math.sin(t),d=Math.sqrt(i/n),f=vF(a,o,s,c),p=yF(e*l,e*u,f),m=yF(-d*u,d*(r+l),f);return!isFinite(p[0]+p[1]+p[2])||!isFinite(m[0]+m[1]+m[2])?null:{r:p,v:m,mu:i}}var CF={cruise:`#7fdbff`,boost:`#ffb454`,brake:`#ff8c69`,spiral:`#c9a0ff`,"spiral-out":`#9b7fd4`,"spiral-in":`#9b7fd4`};CF.cruise,CF.boost,CF.brake,CF.spiral,CF[`spiral-out`],CF[`spiral-in`];var wF={notice:`#8ab4f8`,caution:`#f2b23e`,severe:`#ff6b5a`},TF=3,EF=1,DF=2,OF=.6,kF=1.5,AF=.3,jF=1.5,MF=.85,NF=60,PF=.018,FF=.026,IF=`#ffffff`,LF=4,RF=1.5,zF=9,BF=1,VF={notice:LF-3,caution:LF-2,severe:LF-1},HF=[`notice`,`caution`,`severe`],UF=.03,WF=.2;function GF(e){let t=document.createElement(`canvas`);t.width=t.height=64;let n=t.getContext(`2d`);return n.beginPath(),n.arc(64/2,64/2,64/2-10,0,Math.PI*2),n.fillStyle=e,n.fill(),n.lineWidth=6,n.strokeStyle=`rgba(0,0,0,0.65)`,n.stroke(),new Nc(t)}function KF(e){let t=document.createElement(`canvas`);t.width=t.height=64;let n=t.getContext(`2d`);return n.beginPath(),n.moveTo(64/2,8),n.lineTo(56,56),n.lineTo(8,56),n.closePath(),n.fillStyle=e,n.fill(),n.lineWidth=6,n.lineJoin=`round`,n.strokeStyle=`rgba(0,0,0,0.65)`,n.stroke(),new Nc(t)}function qF(e,t,n,r){let i=[];for(let a=r.from;a<r.to;a++)e.jds[a]>=t&&e.jds[a]<=n&&i.push(e.points[a]);return i}function JF(e,t){let n=new cs(new Jo({map:e,transparent:!0,sizeAttenuation:!1,depthTest:!1}));return n.scale.setScalar(t),n.renderOrder=LF,n}function YF(e,t,n,r){let{canvas:i,color:a,onSelect:o,onHover:s}=r,c=document.createElement(o?`button`:`div`);c instanceof HTMLButtonElement&&(c.type=`button`),c.className=e===`step`?`scene-path-label scene-path-label--step`:`scene-path-label${o?``:` scene-path-label--static`}`,c.setAttribute(`aria-label`,`${t} \u2014 ${n}`);let l=document.createElement(`span`);l.className=`scene-path-label__halo`,a&&(l.style.border=`2px solid ${a}`,l.style.background=`${a}22`);let u=document.createElement(`span`);u.className=`scene-path-label__text`;let d=document.createElement(`span`);d.className=`scene-path-label__name`,d.dir=`auto`,d.textContent=t;let f=document.createElement(`span`);f.className=`scene-path-label__when`,f.dir=`auto`,f.textContent=n,u.append(d,f),c.append(l,u),o&&(Mk(c,i),hM(c,o)),s&&(c.addEventListener(`mouseenter`,()=>s(!0)),c.addEventListener(`mouseleave`,()=>s(!1)));let p=new YO(c);return p.center.set(0,.5),p}var XF=class{group=new za;arcs=[];rings=[];markers=[];labels=[];drawnSteps=[];craft=null;path=null;center=null;layer=null;offset=new J;projected=new J;rects=[];order=[];hovered=null;tint=new X;constructor(e,t){this.scene=e,this.canvas=t,this.group.frustumCulled=!1,this.scene.add(this.group)}get centerId(){return this.center}get isEmpty(){return this.center===null}get plan(){return this.path}setLayer(e){this.layer=e,this.group.traverse(t=>t.layers.set(e))}set(e,t=[],n=[],r=[]){this.clear(),this.path=e?.path??null,this.center=e?.path.centerId??t[0]?.path.centerId??null;let i=e!==null;for(let e of t)this.addArcs(e.path,i?kF:DF,i?AF:OF,e.id),this.addEndLabels(e,i);e&&(this.addPlan(e,r),this.addHazards(e.path,n)),this.applyHover(),this.layer!==null&&this.setLayer(this.layer)}addHazards(e,t){let n=[...t].sort((e,t)=>HF.indexOf(e.severity)-HF.indexOf(t.severity));for(let t of n){let n=wF[t.severity];for(let n of t.bands)e.arcs.forEach((t,r)=>{this.addLine(qF(t,n.startJd,n.endJd,uF(e,r)),wF[n.severity],zF,BF,null,{renderOrder:VF[n.severity]})});if(this.mergeIntoStep(t,n))continue;let r=dF(e,t.startJd);if(!r)continue;let i=bF(r.r),a=r.centerId===e.centerId?null:r.centerId,o=JF(KF(n),UF);this.group.add(o),this.markers.push({sprite:o,local:i,anchorId:a});let s=document.createElement(`div`);s.className=`scene-hazard-label`,s.style.color=n,s.textContent=t.label;let c=new YO(s);c.center.set(0,.5),this.group.add(c),this.labels.push({object:c,local:i,anchorId:a,owner:null,width:0,height:0,dimmed:!1,faint:!0})}}mergeIntoStep(e,t){let n=e.kind===`aeroassist`?`aero-pass`:e.kind===`belt-crossing`?`assist`:null;if(!n)return!1;let r=null,i=1/0;for(let{step:t,label:a}of this.drawnSteps){if(t.kind!==n||e.bodyId&&t.bodyId!==e.bodyId)continue;let o=Math.abs(t.jd-e.peakJd);o<i&&(i=o,r=a)}if(!r)return!1;let a=r.object.element,o=document.createElement(`span`);return o.className=`scene-path-label__hazard`,o.style.color=t,o.dir=`auto`,o.textContent=e.label,a.querySelector(`.scene-path-label__text`)?.append(o),a.setAttribute(`aria-label`,`${a.getAttribute(`aria-label`)} — ${e.label}`),!0}addPlan(e,t){let n=e.path;this.addArcs(n,TF,EF,null,!0),this.addEndOrbits(n),this.addSteps(n,t);for(let e of this.markers)this.group.add(e.sprite);this.craft={sprite:JF(GF(IF),FF),local:[0,0,0],anchorId:null},this.craft.sprite.visible=!1,this.group.add(this.craft.sprite)}addSteps(e,t){for(let n of t){let t=dF(e,n.jd);if(!t)continue;let r=bF(t.r),i=t.centerId===e.centerId?null:t.centerId,a=JF(GF(IF),PF);this.markers.push({sprite:a,local:r,anchorId:i});let o=YF(`step`,n.name,n.when,{canvas:this.canvas,onSelect:n.onPick});this.group.add(o),this.labels.push({object:o,local:r,anchorId:i,owner:null,width:0,height:0,dimmed:!1,faint:!1,step:!0,sprite:a}),this.drawnSteps.push({step:n,label:this.labels[this.labels.length-1]})}}addEndLabels(e,t=!1){let{path:n,onSelect:r}=e,i=n.arcs[0],a=n.arcs[n.arcs.length-1],o=n.stops.find(e=>e.kind===`departure`),s=[{local:bF(n.meeting.r),end:e.arrival,color:CF[a?.kind??`cruise`]}];o&&s.push({local:bF(o.r),end:e.departure,color:CF[i?.kind??`cruise`]});for(let{local:n,end:i,color:a}of s){if(!i.name)continue;let o=YF(`end`,i.name,i.when,{canvas:this.canvas,color:a,onSelect:r,onHover:e.onHover});t&&o.element.classList.add(`scene-path-label--faint`),this.group.add(o),this.labels.push({object:o,local:n,anchorId:null,owner:r?e.id:null,width:0,height:0,dimmed:!1,faint:t})}}setHovered(e){this.hovered!==e&&(this.hovered=e,this.applyHover())}applyHover(){for(let e of this.arcs){if(e.owner===null)continue;let t=e.owner===this.hovered,n=e.line.material;n.uniforms.uColor.value.set(e.color).multiplyScalar(t?EF:e.brightness),n.uniforms.uLineWidth.value=t?TF:e.width}for(let e of this.labels)e.owner!==null&&e.object.element.classList.toggle(`scene-path-label--lit`,e.owner===this.hovered)}addArcs(e,t,n,r=null,i=!1){let a=i&&e.frame===`planetary`,o=t=>a&&e.endOrbits.some(e=>e.at===t&&e.approach.length>1);e.arcs.forEach((a,s)=>{let{from:c,to:l}=i?uF(e,s):{from:0,to:a.points.length};this.addLine(a.points.slice(c,l),CF[a.kind],t,n,r,{fadeIn:s===0&&o(`departure`),fadeOut:s===e.arcs.length-1&&o(`arrival`)})})}addEndOrbits(e){for(let t of e.endOrbits){let n=this.anchorOf(e,t),r=(t.ground??[]).filter(e=>e.to>e.from);if(r.length>0){let e=0;for(let i of r)i.from>e&&this.addLine(t.approach.slice(Math.max(0,e-1),i.from+1),CF.cruise,TF,EF,null,{anchorId:n}),this.addLine(t.approach.slice(i.from,i.to),CF.cruise,TF,EF,null,{anchorId:n,renderOrder:RF}),e=i.to;e<t.approach.length&&this.addLine(t.approach.slice(Math.max(0,e-1)),CF.cruise,TF,EF,null,{anchorId:n})}else if(t.turn){let{from:e,to:r}=t.turn,i=t.approach.slice(0,e+1),a=t.approach.slice(r-1);for(let e of[i,a])e.length<2||this.addLine(e,CF.cruise,TF,EF,null,{anchorId:n});this.addLine(t.approach.slice(e>0?e-1:0,r),CF.cruise,jF,MF,null,{anchorId:n})}else this.addLine(t.approach,CF.cruise,TF,EF,null,{anchorId:n});let i=this.addLine(t.points,CF.cruise,jF,MF,null,{anchorId:n});if(!i)continue;let a=n===null?bF(t.center):[0,0,0];i.line.visible=!1,this.rings.push({arc:i,local:a,radius:Q(t.radiusKm),world:new J})}}anchorOf(e,t){return t.anchorId===e.centerId?null:t.anchorId}addLine(e,t,n,r,i,a={}){let o=e.length;if(o<2)return null;let s=new Float64Array(o*3);for(let t=0;t<o;t++){let[n,r,i]=bF(e[t]);s[t*3]=n,s[t*3+1]=r,s[t*3+2]=i}let c=new Float32Array(o*3),l=new Float32Array(o).fill(1),u=Math.max(1,Math.round(o*WF));for(let e=0;e<u;e++){let t=(e+1)/(u+1);a.fadeIn&&(l[e]=t),a.fadeOut&&(l[o-1-e]=t)}let d=sN(o,c,l,l,o,t,n,r);d.frustumCulled=!1,d.renderOrder=a.renderOrder??LF,this.group.add(d);let f={line:d,owner:i,anchorId:a.anchorId??null,color:t,brightness:r,width:n,local:s,positions:c,alphas:l,count:o};return this.arcs.push(f),f}setClock(e){let t=this.craft;if(!t||!this.path)return;let n=dF(this.path,e);t.sprite.visible=n!==null,n&&(t.local=bF(n.r),t.anchorId=n.centerId===this.path.centerId?null:n.centerId)}reposition(e,t,n){if(this.center===null)return;let r=e[0]-t[0],i=e[1]-t[1],a=e[2]-t[2],o=new Map,s=e=>{if(e===null)return[r,i,a];let s=o.get(e);if(s)return s;let c=n(e),l=c?[c[0]-t[0],c[1]-t[1],c[2]-t[2]]:[r,i,a];return o.set(e,l),l};for(let e of this.arcs){let[t,n,r]=s(e.anchorId);for(let i=0;i<e.count;i++)e.positions[i*3]=e.local[i*3]+t,e.positions[i*3+1]=e.local[i*3+1]+n,e.positions[i*3+2]=e.local[i*3+2]+r;iN(e.line.geometry,e.positions,e.alphas,e.alphas,e.count)}for(let e of this.markers){let[t,n,r]=s(e.anchorId);e.sprite.position.set(e.local[0]+t,e.local[1]+n,e.local[2]+r)}for(let e of this.labels){let[t,n,r]=s(e.anchorId);e.object.position.set(e.local[0]+t,e.local[1]+n,e.local[2]+r)}if(this.craft){let{sprite:e,local:t,anchorId:n}=this.craft,[r,i,a]=s(n);e.position.set(t[0]+r,t[1]+i,t[2]+a)}for(let e of this.rings){let[t,n,r]=s(e.arc.anchorId);e.world.set(e.local[0]+t,e.local[1]+n,e.local[2]+r)}}updateCameraOffset(e){if(this.arcs.length!==0){this.offset.set(-e.x,-e.y,-e.z);for(let e of this.arcs)e.line.material.uniforms.uCenterOffset.value.copy(this.offset);for(let t of this.rings){let n=t.world.distanceTo(e);t.arc.line.visible=n<t.radius*NF}}}setVisible(e){this.group.visible=e}reserveLabelSpace(e,t,n){if(!this.group.visible||this.labels.length===0){bk(this.rects,0);return}this.order.length=0;for(let r of this.labels){if(r.faint)continue;let i=r.object.element;if(!r.width&&!r.dimmed&&(r.width=i.offsetWidth,r.height=i.offsetHeight),!r.width||(this.projected.copy(r.object.position).project(e),!rT(this.projected.z)))continue;let a=(this.projected.x*.5+.5)*t,o=(-this.projected.y*.5+.5)*n,s=r.object.position.distanceTo(e.position);if(r.step){let e=sk(a,o,s,``,$P);if(this.setStepVisible(r,!e),e)continue}this.order.push({label:r,left:a-16,y:o,distance:s})}this.order.sort((e,t)=>e.label.step===t.label.step?e.distance-t.distance:e.label.step?1:-1);let r=0;for(let{label:e,left:t,y:n}of this.order){let i=t+16+e.width,a=!1;for(let o=0;o<r;o++){let r=this.rects[o];if(t<r.right&&i>r.left&&Math.abs(n-r.y)<(e.height+r.h)/2){a=!0;break}}if(this.setLabelDimmed(e,a),a)continue;let o=this.rects[r];o||(o={left:0,right:0,y:0,h:0},this.rects[r]=o),o.left=t,o.right=i,o.y=n,o.h=e.height,r++}bk(this.rects,r)}setStepVisible(e,t){e.object.visible=t,e.sprite&&(e.sprite.visible=t)}setLabelDimmed(e,t){e.dimmed!==t&&(e.dimmed=t,e.object.element.classList.toggle(`scene-path-label--dim`,t))}clear(){for(let e of this.arcs)this.group.remove(e.line),e.line.geometry.dispose(),e.line.material.dispose();for(let e of[...this.markers,...this.craft?[this.craft]:[]]){this.group.remove(e.sprite);let t=e.sprite.material;t.map?.dispose(),t.dispose()}for(let e of this.labels)this.group.remove(e.object),e.object.element.remove();this.arcs=[],this.rings=[],this.markers=[],this.labels=[],this.drawnSteps=[],this.craft=null,this.path=null,this.center=null}dispose(){this.clear(),this.scene.remove(this.group)}},ZF=2,QF=1,$F=4,eI=200,tI=class{group=new za;slots=[];shown=0;layer=null;constructor(e){this.group.frustumCulled=!1,e.add(this.group)}get isEmpty(){return this.shown===0}set(e){let t=0;for(let n of e){if(n.pointsKm.length<2)continue;let e=this.slot(t++);e.bodyId=n.bodyId,e.count=Math.min(n.pointsKm.length,eI);for(let t=0;t<e.count;t++){let[r,i,a]=bF(n.pointsKm[t]);e.local[t*3]=r,e.local[t*3+1]=i,e.local[t*3+2]=a}}this.shown=t;for(let e=t;e<this.slots.length;e++)this.slots[e].line.visible=!1;this.group.visible=t>0}slot(e){for(;this.slots.length<=e;){let e=new Float32Array(eI*3),t=new Float32Array(eI).fill(1),n=sN(eI,e,t,t,0,CF.cruise,ZF,QF);n.frustumCulled=!1,n.renderOrder=$F,this.layer!==null&&n.layers.set(this.layer),this.group.add(n),this.slots.push({line:n,bodyId:``,local:new Float64Array(eI*3),positions:e,alphas:t,count:0})}return this.slots[e]}setLayer(e){this.layer=e,this.group.traverse(t=>t.layers.set(e))}reposition(e,t){for(let n=0;n<this.shown;n++){let r=this.slots[n],i=e(r.bodyId);if(r.line.visible=i!==null,!i)continue;let a=i[0]-t[0],o=i[1]-t[1],s=i[2]-t[2];for(let e=0;e<r.count;e++)r.positions[e*3]=r.local[e*3]+a,r.positions[e*3+1]=r.local[e*3+1]+o,r.positions[e*3+2]=r.local[e*3+2]+s;iN(r.line.geometry,r.positions,r.alphas,r.alphas,r.count)}}updateCameraOffset(e){for(let t of this.slots)t.line.material.uniforms.uCenterOffset.value.set(-e.x,-e.y,-e.z)}},nI=30034e-10,rI=.45,iI=1.6,aI=.85,oI=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],sI=e=>Math.hypot(e[0],e[1],e[2]);function cI(e,t,n=nI){let r=sI(t);if(!(r>0))return null;let i=r*Math.cbrt(n/3),a=oI(e,t)/r,o=sI(e);if(Math.sqrt(Math.max(0,o*o-a*a))>aI*i)return null;let s=a/i;return s>=rI&&s<=iI?`EL1`:s<=-rI&&s>=-iI?`EL2`:null}function lI(){return{count:0,earliestStart:1/0,latestEnd:-1/0}}var uI=class{focused=!1;satSide=null;satJd=NaN;majSide=null;majJd=NaN;constructor(e){this.notices=e}update(e){let{jd:t,majorBodies:n,satellites:r}=e,i=null,a=NaN;n.count>0&&(Number.isFinite(n.latestEnd)&&t>n.latestEnd?(i=`after`,a=n.latestEnd):Number.isFinite(n.earliestStart)&&t<n.earliestStart?(i=`before`,a=n.earliestStart):i=`outside`);let o=r.kind===`covered`?null:r.kind,s=r.kind===`after`?Mg(r.lastMs):NaN,c=e.focusedOutOfRange;if(!(c===this.focused&&o===this.satSide&&Object.is(s,this.satJd)&&i===this.majSide&&Object.is(a,this.majJd))){if(Object.assign(this,{focused:c,satSide:o,satJd:s,majSide:i,majJd:a}),!c&&o===null&&i===null){this.notices.dismiss(`out-of-range`);return}this.notices.notify({topic:`out-of-range`,focusedOutOfRange:c,satellites:o===`after`?{side:`after`,jd:s}:o===`gap`?{side:`gap`}:null,majorBodies:i===`after`||i===`before`?{side:i,jd:a}:i===`outside`?{side:`outside`}:null})}}},dI=new Map,fI=new J;function pI(e,t,n,r,i,a,o){let s=Ty(n,r,Cy(t));if(!s)return null;let c=`naif-${n.bodyNaifId}`,l=a.bodies.bodiesById.get(c);if(!l||!l.orientation)return null;let u=i.get(c);if(!u)return null;let d=l.data.radiusKm;if(!Number.isFinite(d)||d<=0)return null;let f=Math.PI/180,p=s.latDeg*f,m=s.lngDeg*f,h=Ow(o.get(c),c,d,p,m);h&&dI.set(e.id,h);let g=h??dI.get(e.id),_,v,y;if(g)[_,v,y]=g.pointKm;else{let e=Math.cos(p);_=d*e*Math.cos(m),v=d*Math.sin(p),y=-d*e*Math.sin(m)}let b=fC(l.orientation,r,l.nutPrec),x=new J(_,v,y).applyQuaternion(b),S=g?fI.set(g.normal[0],g.normal[1],g.normal[2]).applyQuaternion(b):null;return e.parentId=c,{x:u[0]+Q(x.x),y:u[1]+Q(x.y),z:u[2]+Q(x.z),parentPos:u,up:S}}var mI=[0,0,0],hI=new Hi,gI=4,_I=0,vI=new Map;function yI(e){return e.primary.target===`velocity`||e.secondary?.target===`velocity`}function bI(e,t,n){let r=vI.get(e),i=r?.dir??null;if(r&&t!==r.jd){let e=Math.sign(t-r.jd),a=(n[0]-r.pos[0])*e,o=(n[1]-r.pos[1])*e,s=(n[2]-r.pos[2])*e,c=Math.hypot(a,o,s);c>1e-12&&(i=[a/c,o/c,s/c])}return vI.set(e,{jd:t,pos:[n[0],n[1],n[2]],dir:i}),i??void 0}function xI(e){let{jd:t,ctx:n,bodyObjects:r,focus:i,focusedBody:o,positionMap:s,diagnostics:c,trailView:l,frame:u,outOfRange:d}=e;n.chebStore?.ensure(t),n.probeStore?.ensure(t);let f=n.visibility.activeSystemId,p=f?e=>n.bodies.isInSystem(`naif-${e}`,f):void 0,m={jd:t,satellites:{kind:`covered`},majorBodies:lI(),focusedOutOfRange:!1},h=o?.data.id,g=gx(n.probeStore?.ridesAt(t)??[],h,e=>n.getBody(e)?.data.name),_=[];if(o){let e=new Set([o.data.id]),t=n.getBody(o.data.parentId);for(;t&&!e.has(t.data.id);)e.add(t.data.id),_.push({id:t.data.id,oldPos:[t.position[0],t.position[1],t.position[2]],bo:r.get(t.data.id)}),t=n.getBody(t.data.parentId)}s.clear(),s.set(`naif-0`,[0,0,0]);for(let e of n.bodies.bodiesById.values())s.set(e.data.id,e.position);for(let e of r.values())n.bodies.bodiesById.has(e.body.data.id)||s.set(e.body.data.id,e.body.position);let v=new Set,y=e=>{if(v.has(e.data.id))return;v.add(e.data.id);let i=e.data,o=r.get(i.id);if(o&&u!==void 0&&i.id!==h&&!o.group.visible&&!o.trail?.visible&&(i.orbitalSource===U.SPICE_PROBE||!vn(i.objectType))&&(o.staggerSlot??=_I++%gI,u%gI!==o.staggerSlot))return;let l=(t=!1)=>{o&&(o.outOfRange=!0),e.positionUnknown=!0,!t&&i.id===h&&(m.focusedOutOfRange=!0)};if(i.unplaceable){l(!0);return}let d=n.chebStore?.has(i.id)??!1,f=i.orbitalSource===U.SPICE_PROBE;if(f){if(g.hidden.has(i.id)){l(!0);return}if(o){let e=g.credits.get(i.id);JE(o,`carrier`,e?a().messages.carried_by_scene_label({carrier:e}):null)}}if(i.visibleFromDays!==void 0&&t-2451545<i.visibleFromDays){l();return}let _;if(f)_=s.get(i.parentId)??[0,0,0];else{let e=s.get(i.parentId);if(!e){l(),c.warnOnce(`missing-parent`,i.id,()=>`computePosition[${i.id}]: parent ${i.parentId} not in positionMap — hiding`);return}_=e,c.clear(`missing-parent`,i.id)}let b=i.q!=null;if(!d&&!f&&(t<i.validityStart||t>i.validityEnd)){l(!i.satrec);return}let x,S,C;if(d){let e=n.chebStore.positionScene(i.id,t);if(!e){l(!0);let e=n.chebStore.zoneCoverage(i.id);e&&(t<e.start||t>e.end)&&(m.majorBodies.count++,e.start<m.majorBodies.earliestStart&&(m.majorBodies.earliestStart=e.start),e.end>m.majorBodies.latestEnd&&(m.majorBodies.latestEnd=e.end),i.id===h&&(m.focusedOutOfRange=!0)),c.warnOnce(`cheb-null`,i.id,()=>{let n=e?t>=e.start&&t<=e.end:void 0,r=e?`[${e.start.toFixed(1)},${e.end.toFixed(1)}]`:`unknown`;return`chebStore.positionScene[${i.id}] returned null at jd=${t.toFixed(3)} (coverage=${r}, insideCoverage=${n}) — children of this body will read stale positionMap entry (pre-seeded) instead of falling to SSB`});return}x=_[0]+e[0],S=_[1]+e[1],C=_[2]+e[2]}else if(f){let a=n.probeStore?.probeWithCenter(i.id,t,p)??null;if(!a){l(),c.warnOnce(`probe-unavailable`,i.id,()=>{let e=n.probeStore?`no zone has both a loaded chunk and a sub-chunk covering this jd`:`no ProbeStore`;return`probe ${i.id} (${i.name??`unnamed`}): hidden — ${e}`});return}let u=a.probe.landed;if(u&&wy(a.probe,t)){let d=i.parentId,f=pI(i,a.probe,u,t,s,n,r);if(!f){l();return}c.clear(`probe-unavailable`,i.id),e.positionUnknown=!1,d!==i.parentId&&e.trailBuffer?.clear(),o&&(o.outOfRange=!1,o.isLanded||=(Ek(o.labelHalo,!0),!0)),e.position[0]=f.x,e.position[1]=f.y,e.position[2]=f.z,e.orbitCenter&&(e.orbitCenter[0]=f.parentPos[0],e.orbitCenter[1]=f.parentPos[1],e.orbitCenter[2]=f.parentPos[2]),e.trailAnchor&&(e.trailAnchor[0]=f.parentPos[0],e.trailAnchor[1]=f.parentPos[1],e.trailAnchor[2]=f.parentPos[2]),s.set(i.id,e.position);let p=f.up;o?.mesh&&(p?_C(o.mesh,p):gC(o.mesh,e.position,f.parentPos)),o?.model&&(p?_C(o.model,p):gC(o.model,e.position,f.parentPos));return}let d=By(a.probe,t,a.fitCenterNaifId,n.chebStore??null,e=>s.has(e));if(!d){l(),c.warnOnce(`probe-unavailable`,i.id,()=>`probe ${i.id} (${i.name??`unnamed`}): hidden — stamped fit center is not placeable this frame`);return}let f=d.id,m=d.muKm3S2,g=xy(a.probe,t,m);if(!g){l(),c.warnOnce(`probe-unavailable`,i.id,()=>`probe ${i.id} (${i.name??`unnamed`}): hidden — sub-chunk evaluation returned null (uncoverable, non-finite fit, or missing mu for kepler_pure)`);return}c.clear(`probe-unavailable`,i.id),o?.isLanded&&(Ek(o.labelHalo,!1),o.isLanded=!1);let b=s.get(p_),w=s.get(f_),T=f===`naif-399`&&b!==void 0&&w!==void 0&&cI([Q(g[0]),Q(g[2]),-Q(g[1])],[w[0]-b[0],w[1]-b[1],w[2]-b[2]])!==null,E=T!==(e.lagrangeTrail??!1);e.lagrangeTrail=T;let D=i.parentId!==f;if((D||E)&&e.trailBuffer&&n.probeStore){let r=e.trailBuffer;r.clear(),r.needsPopulate=!1;let o=Wy(Ly(a.probe,t,m),i.validityEnd-i.validityStart,r.capacity,T);r.reconfigure(o.stepDays,o.epsilonScene,o.spanDays),Xy(r,n.probeStore,n.chebStore??null,i.id,f,t)}if(D&&(i.parentId=f),!v.has(f)){let e=n.bodies.bodiesById.get(f)??r.get(f)?.body;e&&y(e)}let O=s.get(f);if(!O){l(),c.warnOnce(`probe-unavailable`,i.id,()=>`probe ${i.id} (${i.name??`unnamed`}): hidden — fit center ${f} has no position this frame`);return}_=O;let k=Q(g[0]),A=Q(g[2]),j=-Q(g[1]);x=_[0]+k,S=_[1]+A,C=_[2]+j;let M=e.trailBuffer;if(M?.needsPopulate&&o?.trail?.visible&&n.probeStore&&(M.needsPopulate=!1,M.clear(),Xy(M,n.probeStore,n.chebStore??null,i.id,f,t)),M){let e=M.newestJd,r=t-e,o=M.stepDays*M.capacity,s=isFinite(e)&&(r<0||r>o);if(s&&i.id===h&&n.probeStore){M.clear();let e=Wy(Ly(a.probe,t,m),i.validityEnd-i.validityStart,M.capacity,T);M.reconfigure(e.stepDays,e.epsilonScene,e.spanDays),Xy(M,n.probeStore,n.chebStore??null,i.id,f,t)}else s?(M.clear(),M.append(t,k,A,j)):isFinite(e)?isFinite(M.epsilonScene)?r>=M.stepDays*.00390625&&n.probeStore&&M.readNewestPos(mI)&&Qy(M,Ky(n.probeStore,n.chebStore??null,i.id,f),e,[mI[0],mI[1],mI[2]],t):r>=M.stepDays&&M.append(t,k,A,j):M.append(t,k,A,j)}}else if(i.a===0&&!b&&!i.satrec)[x,S,C]=_;else{let e=i.satrec?bg(i.satrec,t):b?Xv(i,t):Jv(i,t);if(!e){l();return}x=_[0]+e[0],S=_[1]+e[1],C=_[2]+e[2]}if(o&&(o.outOfRange=!1),e.positionUnknown=!1,e.position[0]=x,e.position[1]=S,e.position[2]=C,(!Number.isFinite(x)||!Number.isFinite(S)||!Number.isFinite(C))&&c.warnOnce(`non-finite`,i.id,()=>{let e=s.has(i.parentId);return`computePosition[${i.id}] non-finite: pos=[${x},${S},${C}] parentId=${i.parentId} parentInPositionMap=${e} parentPos=[${_[0]},${_[1]},${_[2]}] isChebTracked=${d} isProbe=${f} objectType=${i.objectType}`}),e.orbitCenter&&(e.orbitCenter[0]=_[0],e.orbitCenter[1]=_[1],e.orbitCenter[2]=_[2]),e.trailAnchor&&(e.trailAnchor[0]=_[0],e.trailAnchor[1]=_[1],e.trailAnchor[2]=_[2]),s.set(i.id,e.position),o){if(o.trail&&e.orbitCenter){let e=o.trail.userData.orbitCenter;e&&e.set(_[0],_[1],_[2])}if(e.orientation&&(o.mesh||o.model))o.mesh&&pC(o.mesh,e.orientation,t,e.nutPrec),o.model&&pC(o.model,e.orientation,t,e.nutPrec),o.nomenclatureAnchor&&pC(o.nomenclatureAnchor,e.orientation,t,e.nutPrec);else if(KD(e)){let n=e.attitudeTrack;if(!e.pointingOverride&&n&&n.orientationAt(t,hI))o.mesh&&o.mesh.quaternion.copy(hI),o.model&&o.model.quaternion.copy(hI);else{let n=e.pointingOverride??e.pointing;if(n){let r=yI(n)?bI(i.id,t,e.position):void 0,a={bodyPos:e.position,parentPos:_,sunPos:s.get(f_),velocity:r};o.mesh&&jC(o.mesh,n,a),o.model&&jC(o.model,n,a)}else o.mesh&&gC(o.mesh,e.position,_),o.model&&gC(o.model,e.position,_)}}if(e.orientation)for(let n of o.rings)pC(n.mesh,e.orientation,t,e.nutPrec)}},b=n.visibility.focusedSystemId;for(let e of n.bodies.bodiesById.values()){if(e.data.objectType===W.MOON&&!(b!==null&&e.data.parentId===b)&&e.data.id!==h){s.set(e.data.id,e.position);continue}y(e)}for(let e of r.values())n.bodies.bodiesById.has(e.body.data.id)||y(e.body);if(m.satellites=n.refresher?.satelliteCoverage(t)??{kind:`covered`},d.update(m),o&&un(o)){let e=n.getBody(o.featureAnchor.hostId);e&&s.has(e.data.id)?zw(o,e,r.get(e.data.id),t):m.focusedOutOfRange=!0}let x=null;if(o&&m.focusedOutOfRange){let e=_.find(e=>e.bo&&!e.bo.outOfRange);if(e){x=e.id;let t=s.get(e.id)??e.oldPos;if(performance.now()-i.focusStartTime<i.focusDurationMs){i.focusTargetWorld[0]=t[0],i.focusTargetWorld[1]=t[1],i.focusTargetWorld[2]=t[2];let e=i.camTargetOffset;e&&i.camTargetWorld&&(i.camTargetWorld[0]=t[0]+e[0],i.camTargetWorld[1]=t[1]+e[1],i.camTargetWorld[2]=t[2]+e[2])}else{let n=t[0]-e.oldPos[0],r=t[1]-e.oldPos[1],a=t[2]-e.oldPos[2];i.focusTruePos[0]+=n,i.focusTruePos[1]+=r,i.focusTruePos[2]+=a,i.focusTargetWorld[0]=i.focusTruePos[0],i.focusTargetWorld[1]=i.focusTruePos[1],i.focusTargetWorld[2]=i.focusTruePos[2]}}}else if(o){let e=o.position,t=performance.now()-i.focusStartTime<i.focusDurationMs;i.focusTargetWorld[0]=e[0],i.focusTargetWorld[1]=e[1],i.focusTargetWorld[2]=e[2];let n=i.camTargetOffset;n&&i.camTargetWorld&&(i.camTargetWorld[0]=e[0]+n[0],i.camTargetWorld[1]=e[1]+n[1],i.camTargetWorld[2]=e[2]+n[2]);let r=i.camOriginOffset;r&&i.camOriginWorld&&(i.camOriginWorld[0]=e[0]+r[0],i.camOriginWorld[1]=e[1]+r[1],i.camOriginWorld[2]=e[2]+r[2]),t||(i.focusTruePos[0]=e[0],i.focusTruePos[1]=e[1],i.focusTruePos[2]=e[2])}let S=i.focusTruePos;for(let e of r.values()){let n=e.trail;if(n){if(!n.visible){n.userData.refreshDeferred=!0;continue}KP(e.body,n,S,t,l),n.userData.refreshDeferred=!1}}return{focusedOutOfRange:m.focusedOutOfRange,reanchorId:x}}function SI(e,t,n,r){let i=t.focusTruePos;for(let t of e.values()){let e=t.trail;!e||!e.visible||!e.userData.refreshDeferred||(KP(t.body,e,i,n,r),e.userData.refreshDeferred=!1)}}var CI=class{seen=new Map;bucket(e){let t=this.seen.get(e);return t||this.seen.set(e,t=new Set),t}warnOnce(e,t,n){let r=this.bucket(e);r.has(t)||(r.add(t),console.warn(n()))}clear(e,t){this.seen.get(e)?.delete(t)}},wI=Q(695700),TI=2,EI=new J;function DI(e,t,n,r,i){EI.subVectors(e,t);let a=EI.dot(n),o=Math.sqrt(Math.max(EI.lengthSq()-a*a,0)),s=o-Math.min(Math.max(o,r),i),c=Math.sqrt(s*s+a*a);return{dist:c,sinToPole:c>0?Math.abs(s)/c:1}}function OI(e,t,n,r,i,a){let o=e.get(f_)?.body.position;if(!o)return;let[s,c,l]=t;for(let t of e.values()){if(!t.rings.length)continue;let[e,u,d]=t.body.position;for(let f of t.rings){let p=r||f.intensityScale>=.000980392156862745;f.mesh.visible=p;let m=r?1:p?f.intensityScale:0;f.material.uniforms.uIntensityScale.value=m;let h=f.material.uniforms.uSunDir.value;h.set(o[0]-e,o[1]-u,o[2]-d);let g=h.length(),_=wI/g;f.material.uniforms.uSunAngularRadius.value=_,f.material.uniforms.uLightScale.value=n?vT(g):1,h.normalize();let v=f.planetShadowOnRing;if(v.uPlanetCenter.value.set(e-s,u-c,d-l),t.mesh&&v.uPlanetPoleDir.value.set(0,1,0).applyQuaternion(t.mesh.quaternion),f.layers){let{dist:e,sinToPole:t}=DI(i,v.uPlanetCenter.value,v.uPlanetPoleDir.value,f.innerScene,f.outerScene),n=f.thicknessScene*t/Math.max(e,1e-9)*a,r=Math.min(Math.max(Math.ceil(n*TI),1),48);f.layers.count!==r&&(f.layers.count=r,f.material.uniforms.uLayerCount.value=r,f.material.uniforms.uLayerAlphaExp.value=1/r)}let y=f.planetShadow;y&&(y.uRingShadowIntensity.value=m,y.uRingShadowSunAngularRadius.value=_,y.uRingShadowSunDir.value.copy(h),y.uRingShadowPoleDir.value.copy(v.uPlanetPoleDir.value),y.uRingShadowCenter.value.copy(v.uPlanetCenter.value))}}}var kI=Math.PI/180,AI=2451545;function jI(e){let t=e-AI,n=(19.3871+.52402073*t)*kI;return((270.3871+.524038496*t+((10.691+3e-7*t)*Math.sin(n)+.623*Math.sin(2*n)+.05*Math.sin(3*n)+.005*Math.sin(4*n)+5e-4*Math.sin(5*n)))%360+360)%360}function MI(e,t,n){let r=e.length,i=r-1;for(let t=0;t<r-1;t++)if(n<e[t+1]){i=t;break}let a=(i+1)%r,o=i===r-1?360-e[i]:e[a]-e[i],s=(n-e[i])/o;return t[i]+(t[a]-t[i])*s}function NI(e,t){let n=e.seasonal;if(!n)return e;let r=MI(n.lsDeg,n.dustTauFactor,t),i=MI(n.lsDeg,n.dustScaleHeightKm,t),a=MI(n.lsDeg,n.pressureFactor,t),o=r*e.mieScaleHeightKm/i,s=(e,t)=>[e[0]*t,e[1]*t,e[2]*t];return{...e,rayleighScatterPerKm:s(e.rayleighScatterPerKm,a),mieScatterPerKm:s(e.mieScatterPerKm,o),mieAbsorptionPerKm:s(e.mieAbsorptionPerKm,o),mieScaleHeightKm:i,seasonal:void 0}}var PI=new WeakMap,FI=.25;function II(e,t){if(!e.seasonal)return e;let n=Math.round(jI(t)/FI),r=PI.get(e);if(r&&r.lsQ===n)return r.params;let i=NI(e,n*FI);return PI.set(e,{lsQ:n,params:i}),i}var LI=new J,RI=new J,zI=[.2126,.7152,.0722];function BI(e,t,n){return n<=0?0:e<=t-n?n:e>=t+n?0:e<=t?n-(e-(t-n))**2/(2*n):(t+n-e)**2/(2*n)}function VI(e,t){let n=Math.max(t,0),r=e.rayleighScaleHeightKm*Math.exp(-n/e.rayleighScaleHeightKm),i=e.mieScaleHeightKm*Math.exp(-n/e.mieScaleHeightKm),a=BI(n,e.absorptionCenterKm,e.absorptionWidthKm),o=0;for(let t=0;t<3;t++){let n=e.rayleighScatterPerKm[t]*r+(e.mieScatterPerKm[t]+e.mieAbsorptionPerKm[t])*i+e.absorptionPerKm[t]*a;o+=zI[t]*Math.exp(-n)}return o}var HI=.4,UI=.05,WI=-.105,GI=.3,KI=.05;function qI(e,t,n){let r=VI(e,t),i=Math.min(1,-Math.log(Math.max(r,.001))/KI),a=Math.min(1,Math.max(0,(n-WI)/GI));return r*(1+(HI+(UI-HI)*a-1)*i)}function JI(e,t,n,r){let i=Math.sqrt(2*n/r),a=Math.sqrt(Math.PI*r/(2*n));return t>=0?e/(Math.tan(t)+1/a):e*a*Math.exp(t/i)}var YI=gT,XI=200,ZI=new J,QI=new J,$I=new J,eL=new J;function tL(e,t,n,r){e.uOccluderCount.value=RC(e.uOccluders.value,t,r,n)}function nL(e,t,n,r,i,a,o){let s={insideShell:!1,shellProminent:!1,skyboxIntensity:1,sunTint:ZI.set(1,1,1),sunRefraction:null};NA(n&&a.sunTint);let c=e.get(f_);oj(c?.mesh?.material,_b());let l=aj(c?.mesh?.material);l&&(l.uAtmoTEnable.value=0);let u=XI,d=c?.body.position;if(!d)return s;for(let c of e.values()){if(!c.atmosphere||(c.atmosphere.mesh.visible=n,!n))continue;TA(c.atmosphere,a);let e=gb(c.body.data.id);if(e?.seasonal){let t=a.seasonal?II(e,o):e;if(c.atmosphere.params!==t){EA(c.atmosphere,t);for(let e of c.sunTint??[])BA(e,t,c.atmosphere.surfaceRadiusScene,c.atmosphere.surfaceRadiusKm)}}let[f,p,m]=c.body.position,h=c.atmosphere.material.uniforms;h.uGroundAlbedo.value=a.groundAlbedo?c.atmosphere.params.groundAlbedo??0:0;let g=h.uSunDir.value.set(d[0]-f,d[1]-p,d[2]-m),_=c.atmosphere.params,v=r?vT(g.length()):_.realisticSunAlways?Math.sqrt(vT(g.length())):1;h.uSunIntensity.value=_.sunIntensity*v*i,g.normalize(),c.mesh&&(LI.set(0,1,0).applyQuaternion(c.mesh.quaternion),h.uSpinAxis.value.copy(LI));let y=c.atmosphere.mesh,b=c.atmosphere.geometryRadiusScene*y.scale.x,x=t.distanceTo(y.position);b>x*.1&&(s.shellProminent=!0),a.eclipseShadows&&tL(h,y.position,g,b);let S=a.insideView&&x<b,C=c.atmosphere.planetRadiusKm,w=x*((C+_.topAltitudeKm)/b)-C,T=S&&SA(_,w),E=S?CA(_,w):0;yA(c.atmosphere,S,T,E),h.uDeepIrradiance.value=YI*i;for(let e of c.sunTint??[])e.uAtmoTDeepIrradiance.value=YI*i,e.uAtmoTDeepBlend.value=E;if(S){s.insideShell=!0;let e=RI.copy(t).sub(y.position).divideScalar(x).dot(g),n=qI(_,w,e);if(s.skyboxIntensity*=n*(1-E),a.refraction&&_.refractivity&&!T){let t=JI(_.refractivity[1]*Math.exp(-Math.max(w,0)/_.rayleighScaleHeightKm),Math.asin(Math.min(1,Math.max(-1,e))),_.rayleighScaleHeightKm,c.atmosphere.planetRadiusKm);t>5e-6&&(s.sunRefraction={angleRad:t,up:eL.copy(RI)})}}let D=x/b;if(a.sunTint&&D<XI){let e=b/(1+_.topAltitudeKm/C)*(c.atmosphere.surfaceRadiusKm/C);$I.copy(t).sub(y.position);let n=h.uSpinAxis.value,r=h.uStretch.value;if(qA(_,$I,g,e,c.atmosphere.surfaceRadiusKm,QI,n,r)){let e=zI[0]*QI.x+zI[1]*QI.y+zI[2]*QI.z;e>1e-4&&s.sunTint.multiply(QI.divideScalar(e))}l&&D<u&&(u=D,HA(l,_,y.position,e,c.atmosphere.surfaceRadiusKm,n,r))}}return s}var rL=[];function iL(e,t){let n=IC(),r=e.get(f_);if(!r){n.uSunAngularRadius.value=0,n.uOccluderCount.value=0;return}let[i,a,o]=t,s=r.body.position,c=s[0]-i,l=s[1]-a,u=s[2]-o,d=Math.hypot(c,l,u);d>0?(n.uSunDir.value.set(c/d,l/d,u/d),n.uSunAngularRadius.value=Math.asin(Math.min(r.radiusScene/d,1))):n.uSunAngularRadius.value=0;let f=rL,p=0;for(let t of e.values()){if(t.body.data.objectType===W.STAR)continue;let e=t.body.data.radiusKm;!Number.isFinite(e)||e<=0||t.radiusScene<=0||(f[p++]=t)}f.length=p,p>32&&(f.sort((e,t)=>t.radiusScene-e.radiusScene),f.length=32,p=32);let m=n.uOccluders.value;for(let e=0;e<p;e++){let t=f[e],[n,r,s]=t.body.position;m[e].set(n-i,r-a,s-o,t.radiusScene)}n.uOccluderCount.value=p;for(let e=0;e<p;e++)f[e]=void 0;f.length=0;let h=n.uSunDir.value;for(let t of e.values()){let e=t.eclipseShadow;if(!e||t.cachedDist>0&&t.radiusScene<t.cachedDist*1e-4)continue;let[n,r,s]=t.body.position,c=e.uEclipseSelfPos.value.set(n-i,r-a,s-o);e.uOccluderCount.value=RC(e.uOccluders.value,c,t.radiusScene,h)}}var aL=10;function oL(e,t,n,r,i,a,o,s,c){let l=n.visibility.activeSystemId;if(!l){r.intensity=0,i&&yT(i,s,c);return}let u=e.get(f_)?.body.position,[d,f,p]=t,m=(u?.[0]??0)-d,h=(u?.[1]??0)-f,g=(u?.[2]??0)-p,_=Math.hypot(m,h,g),v=o.set(m,h,g).normalize();r.position.copy(v).multiplyScalar(aL),r.target.position.set(0,0,0),r.intensity=gT*(s?vT(_):1)*c,i&&(i.intensity=0);let y=Math.max(a*2,.001),b=n.bodies.getSystemExtent(l)*10*1.2,x=r.shadow.camera;x.left=x.bottom=-y,x.right=x.top=y,x.near=aL-b,x.far=aL+b,x.updateProjectionMatrix()}var sL=128,cL=256,lL=.25,uL=.32,dL=.35,fL=300,pL=1.25,mL=.05,hL=4e5,gL=new Y,_L=new J;function vL(e,t,n){let r=e=>t.some(([t,n])=>e>t+1e-9&&e<n-1e-9),i=e/sL,a=[];for(let t=0;t<=sL;t++){let n=t===sL?e:t*i;(t===0||t===sL||!r(n))&&a.push(n)}for(let[r,i]of t){let t=Math.ceil(Math.max(r,0)/n-1e-9),o=Math.floor(Math.min(i,e)/n+1e-9);for(let e=t;e<=o;e++)a.push(e*n)}a.sort((e,t)=>e-t);let o=n*.25,s=[];for(let e of a)s.length&&e-s[s.length-1]<o||s.push(e);return s[0]=0,s[s.length-1]=e,Float64Array.from(s)}function yL(e,t,n){let r=t.length,i=n.length,a=new Float32Array(r*i*3),o=new Float32Array(r*i*3),s=new Float32Array(r*i*2);for(let c=0;c<r;c++){let r=t[c],l=Math.sin(r),u=Math.cos(r);for(let t=0;t<i;t++){let d=n[t],f=-Math.cos(d)*l,p=u,m=Math.sin(d)*l,h=(c*i+t)*3;a[h]=e*f,a[h+1]=e*p,a[h+2]=e*m,o[h]=f,o[h+1]=p,o[h+2]=m;let g=(c*i+t)*2;s[g]=d/(2*Math.PI),s[g+1]=1-r/Math.PI}}let c=new Uint32Array((r-1)*(i-1)*6),l=0;for(let e=0;e<r-1;e++){let n=t[e]<=0,r=t[e+1]>=Math.PI;for(let t=0;t<i-1;t++){let a=e*i+t+1,o=e*i+t,s=(e+1)*i+t,u=(e+1)*i+t+1;n||(c[l++]=a,c[l++]=o,c[l++]=u),r||(c[l++]=o,c[l++]=s,c[l++]=u)}}let u=new Ho;return u.setAttribute(`position`,new Do(a,3)),u.setAttribute(`normal`,new Do(o,3)),u.setAttribute(`uv`,new Do(s,2)),u.setIndex(new Do(c.subarray(0,l),1)),u}function bL(e){e.terrainWindow&&(e.terrainWindow=null,e.currentSegments=void 0)}function xL(e,t,n){let r=e.mesh,i=e.displacementMap;if(!n||!r||!i)return e.terrainWindow&&console.debug(`terrain window exit ${e.body.data.id}: eligible=${n} mesh=${!!r} tex=${!!i}`),bL(e),!1;r.updateMatrixWorld(),gL.copy(r.matrixWorld).invert(),_L.copy(t.position).applyMatrix4(gL);let a=Q(gn(e.body.data)),o=_L.length(),s=Math.max(o/a-1,1e-6);if(s>(e.terrainWindow?uL:lL))return e.terrainWindow&&console.debug(`terrain window exit ${e.body.data.id}: alt=${s.toFixed(4)}`),bL(e),!1;let c=i.image?.width??2048,l=2*Math.PI/c,u=Math.acos(1/(1+s)),d=Math.max(l,2*u*pL/cL),f=Math.log2(d/l),p=Math.max(0,Math.ceil(f-1e-9)),m=e.terrainWindow;m&&m.texWidth===c&&f>m.stepLevel-.85&&f<m.stepLevel+.15&&(p=m.stepLevel);let h=l*2**p,g=h*cL/2,_=Math.acos(Math.min(1,Math.max(-1,_L.y/o))),v=Math.atan2(_L.z,-_L.x);if(v<0&&(v+=2*Math.PI),m&&m.texWidth===c){if(m.stepLevel===p){let e=Math.sin(_)*Math.sin(m.centerTheta)*Math.cos(v-m.centerPhi)+Math.cos(_)*Math.cos(m.centerTheta);if(Math.acos(Math.min(1,Math.max(-1,e)))<dL*m.angRadius)return!0}if(performance.now()-m.builtAt<fL)return!0}let y=Math.max(0,_-g),b=Math.min(Math.PI,_+g),x=vL(Math.PI,[[y,b]],h),S=Math.min(Math.PI,g/Math.max(Math.sin(_),mL)),C=Math.max(p,Math.ceil(Math.log2(2*S/cL/l)-1e-9)),w=l*2**Math.max(0,C),T=v-S,E=v+S,D=S>=Math.PI?[[0,2*Math.PI]]:T<0?[[0,E],[T+2*Math.PI,2*Math.PI]]:E>2*Math.PI?[[0,E-2*Math.PI],[T,2*Math.PI]]:[[T,E]],O=vL(2*Math.PI,D,w);if(x.length*O.length>hL)return console.warn(`terrain window for ${e.body.data.id} would need ${x.length}×${O.length} vertices — keeping the uniform sphere`),bL(e),!1;let k=r.geometry;return r.geometry=yL(a,x,O),k.dispose(),console.debug(`terrain window ${e.body.data.id}: ${x.length}×${O.length} grid, level ${p} (tex ${c})`),e.terrainWindow={thetas:x,phis:O,centerTheta:_,centerPhi:v,angRadius:g,stepLevel:p,texWidth:c,builtAt:performance.now()},e.currentSegments=sL,!0}var SL=[{up:150,segs:128},{up:40,segs:64},{up:0,segs:32}],CL=24;function wL(e,t,n,r){if(!n&&!t)return CL;let i=SL[SL.length-1].segs;for(let t of SL)if(e>=t.up){i=t.segs;break}if(i<r){let t=SL.find(e=>e.segs===r);if(t&&e>=t.up*.85)return r}return i}function TL(e,t,n,r,i){let a=t.fov*Math.PI/180,o=n.domElement.clientHeight/(2*Math.tan(a/2)),s=r.visibility.activeSystemId,c=i;for(let n of e.values()){if(!n.mesh||!n.radiusScene||!n.group.visible||n.cachedDist<=0)continue;let e=n.body.data.objectType===W.STAR,a=n.body.data.id;if((a===c||n.terrainWindow)&&xL(n,t,a===c))continue;let l=wL(n.radiusScene/n.cachedDist*o,e,s?a===s||r.visibility.isInActiveSystem(n.body.data.parentId):a===i,n.currentSegments??64);if(l===n.currentSegments)continue;let u=Q(gn(n.body.data)),d=n.mesh.geometry;n.mesh.geometry=new ru(u,l,l),d.dispose(),n.currentSegments=l}}function EL(e,t){let n=e<1.05?`high`:e<4?`medium`:`low`;if(qj(n)>qj(t))return n;let r=e>7?`low`:e>1.15?`medium`:`high`;return qj(r)<qj(t)?r:t}function DL(e,t,n,r,i,a,o,s){s.apply(e,i);let c=t.fov*Math.PI/180,l=n.domElement.clientHeight/(2*Math.tan(c/2)),u=r.visibility.activeSystemId,d=jx(),f=d.showClouds,p=qj(Kx());for(let t of e.values())t.clouds&&(t.clouds.mesh.visible=f);for(let t of e.values()){if(!t.mesh||!t.radiusScene||!t.group.visible||!t.availableTiers?.length||t.cachedDist<=0)continue;let e=t.body.data.id;if(u){if(e!==u&&!r.visibility.isInActiveSystem(t.body.data.parentId))continue}else if(e!==a)continue;let s=t.radiusScene/t.cachedDist*l,c=t.cachedDist/t.radiusScene,f;f=s<256&&c>10?`low`:s<1024&&c>2?`medium`:`high`;let m=qj(t.textureTier),h=Math.min(qj(f),p),g=Xj(o,t.availableFrames),_=g!==t.textureFrame,v=h>m;if(d.showSurfaceTexture&&!t.textureLoading&&(v||_)){let e=v?Jj(h,t.availableTiers):t.textureTier;e&&nM(t,e,g,i)}let y=t.displacementMeta?.tiers;if(t.displacementMap&&y?.length&&!t.displacementLoading){let e=n.capabilities.maxTextureSize,r=e>=16383?2:+(e>=8192),i=t.displacementTier??`low`,a=Jj(Math.min(qj(EL(c,i)),r,p),y);a&&a!==i&&rw(t,a)}if(t.clouds&&t.textureTier){let e=Jj(qj(t.textureTier),t.clouds.availableTiers),n=wj(o,t.clouds.availableFrames,t.clouds.availableCoverage);e&&n&&Dj(t.clouds,e,n)}}}var OL=BO.refMs,kL=new Y,AL=new J,jL=new J,ML=new Hi,NL=new Hi,PL=new J,FL=new J;function IL(e,t,n){return AL.set(e[0],e[1],e[2]),jL.set(t[0],t[1],t[2]),kL.lookAt(AL,jL,n),ML.setFromRotationMatrix(kL).clone()}function LL(e,t,n,r,i){let a=performance.now()-e.focusStartTime,o=e.focusDurationMs>0?Math.min(a/e.focusDurationMs,1):1,s=o<1,c=!!(e.camOriginWorld&&e.camTargetWorld&&e.flyQ0);if(s&&c){let n=o*o*(3-2*o);if(e.focusTruePos=L_(e.focusOriginWorld,e.focusTargetWorld,n),r(),e.orbitFly){let r=e.focusOriginWorld[0]!==e.focusTargetWorld[0]||e.focusOriginWorld[1]!==e.focusTargetWorld[1]||e.focusOriginWorld[2]!==e.focusTargetWorld[2],i;if(e.arcOrbit)i=z_(e.camOriginWorld,e.camTargetWorld,e.focusTargetWorld,n);else{let t=r?o*o*o:n;i=L_(e.camOriginWorld,e.camTargetWorld,t)}t.position.set(i[0]-e.focusTruePos[0],i[1]-e.focusTruePos[1],i[2]-e.focusTruePos[2]),r&&!e.arcOrbit?(t.lookAt(e.focusTargetWorld[0]-e.focusTruePos[0],e.focusTargetWorld[1]-e.focusTruePos[1],e.focusTargetWorld[2]-e.focusTruePos[2]),NL.copy(t.quaternion),t.quaternion.slerpQuaternions(e.flyQ0,NL,n)):t.lookAt(e.focusTargetWorld[0]-e.focusTruePos[0],e.focusTargetWorld[1]-e.focusTruePos[1],e.focusTargetWorld[2]-e.focusTruePos[2])}else{let r;if(e.cameraStaysOnBody)r=e.camTargetWorld;else{let t=o*o*o;r=L_(e.camOriginWorld,e.camTargetWorld,t)}let i=IL(r,e.focusTargetWorld,t.up);t.quaternion.slerpQuaternions(e.flyQ0,i,n),t.position.set(r[0]-e.focusTruePos[0],r[1]-e.focusTruePos[1],r[2]-e.focusTruePos[2])}return!1}if((e.focusTruePos[0]!==e.focusTargetWorld[0]||e.focusTruePos[1]!==e.focusTargetWorld[1]||e.focusTruePos[2]!==e.focusTargetWorld[2])&&(e.focusTruePos=[...e.focusTargetWorld],r(),i()),n.target.set(0,0,0),e.camTargetWorld){let r=e.camTargetWorld[0]-e.focusTruePos[0],i=e.camTargetWorld[1]-e.focusTruePos[1],a=e.camTargetWorld[2]-e.focusTruePos[2];t.position.set(r,i,a),n.enableDamping=!1,n.update(),n.enableDamping=!0,t.position.set(r,i,a),e.camOriginWorld=null,e.camTargetWorld=null,e.camTargetOffset=null,e.camOriginOffset=null,e.flyQ0=null,e.orbitFly=!1,e.arcOrbit=!1,e.cameraStaysOnBody=!1}return!n.update()}function RL(e,t,n,r,i,a=!1){if(e.focusOriginWorld=[...e.focusTruePos],e.focusTargetWorld=[...t],e.focusStartTime=performance.now(),e.arcOrbit=!1,e.camOriginOffset=null,i){e.camOriginWorld=r,e.camTargetWorld=[...i],e.camTargetOffset=[i[0]-t[0],i[1]-t[1],i[2]-t[2]],e.cameraStaysOnBody=!1,e.flyQ0=n.quaternion.clone();let a=IL([i[0]-e.focusTruePos[0],i[1]-e.focusTruePos[1],i[2]-e.focusTruePos[2]],[t[0]-e.focusTruePos[0],t[1]-e.focusTruePos[1],t[2]-e.focusTruePos[2]],n.up),o=R_(r,i),s=e.flyQ0.angleTo(a);e.focusDurationMs=Math.max(zO(o,HO),RO(s,UO))}else e.camOriginWorld=r,e.camTargetWorld=[...r],e.camTargetOffset=[r[0]-t[0],r[1]-t[1],r[2]-t[2]],e.cameraStaysOnBody=!0,e.flyQ0=n.quaternion.clone(),PL.set(0,0,-1).applyQuaternion(e.flyQ0),FL.set(t[0]-r[0],t[1]-r[1],t[2]-r[2]).normalize(),e.focusDurationMs=RO(PL.angleTo(FL),BO);if(a){let t=e.focusOriginWorld[0]!==e.focusTargetWorld[0]||e.focusOriginWorld[1]!==e.focusTargetWorld[1]||e.focusOriginWorld[2]!==e.focusTargetWorld[2];(i||t)&&(e.focusDurationMs=0)}}function zL(e,t,n,r,i=!1){e.camOriginWorld=n,e.camTargetWorld=[...r],e.camTargetOffset=[r[0]-e.focusTruePos[0],r[1]-e.focusTruePos[1],r[2]-e.focusTruePos[2]],e.camOriginOffset=[n[0]-e.focusTruePos[0],n[1]-e.focusTruePos[1],n[2]-e.focusTruePos[2]],e.focusOriginWorld=[...e.focusTruePos],e.focusTargetWorld=[...e.focusTruePos],e.focusStartTime=performance.now(),e.orbitFly=!0,e.arcOrbit=!0,e.cameraStaysOnBody=!1,e.flyQ0=t.quaternion.clone();let a=R_(n,r);PL.set(e.focusTruePos[0]-n[0],e.focusTruePos[1]-n[1],e.focusTruePos[2]-n[2]).normalize(),FL.set(e.focusTruePos[0]-r[0],e.focusTruePos[1]-r[1],e.focusTruePos[2]-r[2]).normalize();let o=PL.angleTo(FL);e.focusDurationMs=Math.max(zO(a,HO),RO(o,UO)),i&&(e.focusDurationMs=0)}var BL={[W.STAR]:1e3,[W.PLANET]:100,[W.DWARF_PLANET]:10,[W.ASTEROID]:.1,[W.ASTEROID_INNER]:.1,[W.ASTEROID_MAIN_BELT]:.1,[W.ASTEROID_CENTAUR]:1,[W.ASTEROID_TROJAN]:1,[W.ASTEROID_TNO]:1,[W.COMET]:1,[W.MOON]:1},VL=5e-4,HL=new J,UL=new J;function WL(e){return BL[e.data.objectType]??gn(e.data)*.25}function GL(e,t){return Q((t??gn(e.data))+WL(e))}function KL(e,t,n,r){let i=t.data.radiusKm;if(!Number.isFinite(i)||i<=0)return;let a=t.position[0]-n[0],o=t.position[1]-n[1],s=t.position[2]-n[2],c=Math.hypot(a,o,s),l=r?.centerOffsetScene,u=a+(l?l[0]:0),d=o+(l?l[1]:0),f=s+(l?l[2]:0),p=e.position.x-u,m=e.position.y-d,h=e.position.z-f,g=Math.hypot(p,m,h);if(r?.seated){if(g<1e-9){e.position.set(u,d+c+Q(VL),f);return}let t=Math.tan(e.fov*Math.PI/360)*e.near,n=t*e.aspect,i=0;for(let[a,o,s]of[[0,0,0],[-n,-t,-e.near],[n,-t,-e.near],[-n,t,-e.near],[n,t,-e.near]]){UL.set(a,o,s).applyQuaternion(e.quaternion);let t=p+UL.x,n=m+UL.y,l=h+UL.z,u=Math.hypot(t,n,l);if(u<1e-12)continue;HL.set(t/u,n/u,l/u).applyQuaternion(r.invQuat);let d=r.radialKm([HL.x,HL.y,HL.z]),f=(d===null?c:Q(d))+Q(VL);f-u>i&&(i=f-u)}if(i<=0)return;let a=i/g;e.position.set(e.position.x+p*a,e.position.y+m*a,e.position.z+h*a);return}let _=WL(t);if(g>=Q((r?.outerRadiusKm??i)+_))return;let v=i;r&&g>1e-9&&(HL.set(p/g,m/g,h/g).applyQuaternion(r.invQuat),v=r.radialKm([HL.x,HL.y,HL.z])??i);let y=Q(v+_),b=c>0?Math.min(y,c):y;if(!(g>=b)){if(g<1e-9)p=0,m=b,h=0;else{let e=b/g;p*=e,m*=e,h*=e}e.position.set(u+p,d+m,f+h)}}function qL(e,t,n){let r=e.position,{latitude:i,longitude:a,distance:o}=rC([r.x,r.y,r.z],[0,0,0],n),s=Math.min(Math.max(i,t.minLat??-90),t.maxLat??90),c=sC(a,t.minLon,t.maxLon),l=Math.min(Math.max(o,t.minDistance??0),t.maxDistance??1/0);if(s===i&&c===a&&l===o)return;let[u,d,f]=iC([0,0,0],s,c,l,n);r.set(u,d,f)}var JL=50,YL=20;function XL(e){return e<=0?`none`:e<YL?`full`:e<JL?`half`:`none`}function ZL(e,t){return e.data.validityStart<=t&&t<=e.data.validityEnd}var QL=class{pendingDefaults=new Set;defaults=new Set;userPromoted=new Set;autoPromoted=new Set;groupTargets=null;groupMode=`none`;smallBodyZone=null;countStableLo=1/0;countStableHi=-1/0;constructor(e){this.deps=e,e.ctx.bodies.onBodiesAdded(()=>{this.onBodiesAdded(),this.autoPromoteAsteroidMoons(),this.reevaluateEarthSatMode(),this.smallBodyZone!==null&&this.refreshSmallBodyEmphasis()}),e.ctx.onEarthSatRollover(()=>this.reevaluateEarthSatMode()),e.ctx.onGroupFilterChange(e=>this.applyGroupFilter(e)),this.applyGroupFilter(e.ctx.earthSatFilter),e.ctx.onSmallBodyFilterChange(e=>this.applySmallBodyFilter(e)),this.applySmallBodyFilter(e.ctx.smallBodyFilter),Vv().then(e=>{let t=[],n=e=>{if(!this.defaults.add(e)||this.deps.bodyObjects.has(e))return;let n=this.deps.ctx.getBody(e);if(!n){this.pendingDefaults.add(e);return}this.shouldAutoPromote(n,e)&&t.push(n)};for(let t of e.keys())n(t);for(let e of m_)n(e);this.buildBatch(t),this.autoPromoteAsteroidMoons();let r=!1;for(let e of this.userPromoted)this.defaults.has(e)&&(this.userPromoted.delete(e),r=!0);r&&this.emitUserPromotedCount()})}autoPromoteAsteroidMoons(){let e=this.deps.ctx.bodies.asteroidBodiesByZone.get(`small_body_moons`);if(!e||e.size===0)return;let t=[],n=new Set;for(let r of e.keys()){let i=e.getKey(r);if(!i||i.data.objectType!==W.MOON||!this.isDefault(i.data.parentId))continue;let a=this.deps.ctx.getBody(i.data.parentId);!a||!_n(a.data.objectType)||(!this.deps.bodyObjects.has(a.data.id)&&!n.has(a.data.id)&&(n.add(a.data.id),t.push(a)),this.deps.bodyObjects.has(i.data.id)||t.push(i))}this.buildBatch(t)}onBodiesAdded(){if(this.pendingDefaults.size===0)return;let e=[];for(let t of this.pendingDefaults){let n=this.deps.ctx.getBody(t);n&&(this.pendingDefaults.delete(t),this.shouldAutoPromote(n,t)&&e.push(n))}this.buildBatch(e)}shouldAutoPromote(e,t){return e.data.objectType!==W.BARYCENTER&&e.data.objectType!==W.LAGRANGE_POINT?!0:m_.has(t)}isDefault(e){return this.defaults.has(e)}ensureBodyObjects(e){this.buildBodyInstance(e)&&this.finalizeBuilds()}buildBodyInstance(e,t,n=!1){let{bodyObjects:r,ctx:i,clock:a,scene:o,clickables:s,meshToBody:c,circleTexture:l,renderer:u}=this.deps;if(r.has(e.data.id))return!1;if(TT(e,a.jd,i),!e.orbitElements&&!e.data.unplaceable&&e.data.orbitalSource!==U.SPICE_PROBE){e.orbitElements=e.data;let t=r.get(e.data.parentId);t&&(e.orbitCenter=[...t.body.position])}uj([e],o,s,c,r,l,u.domElement,this.deps.onBodyClick,(e,t)=>t?this.deps.hoveredBodyIds.add(e):this.deps.hoveredBodyIds.delete(e),t);let d=r.get(e.data.id);if(d&&!e.data.name&&eM(d),e.data.objectType===W.SPACECRAFT)i.bodies.dirtySpacecraftGroups.add(e.data.parentId);else if(_n(e.data.objectType)||e.data.objectType===W.COMET){let t=this.deps.ctx.bodies.findAsteroidZone(e.data.id);t&&i.bodies.dirtyAsteroidZones.add(t)}let f=e.data.id;return this.defaults.has(f)||(n?this.autoPromoted.add(f):(this.userPromoted.add(f),this.emitUserPromotedCount())),!0}finalizeBuilds(){hN(this.deps.bodyObjects,this.deps.scene,this.deps.pointClouds.basis(),this.deps.clock.jd),this.deps.assignMapLayerToTrails(),this.deps.repositionAll(),this.deps.pointClouds.rebuildMinor()}buildBatch(e,t,n=!1){let r=!1;for(let i of e)this.buildBodyInstance(i,t,n)&&(r=!0);r&&this.finalizeBuilds()}applyGroupFilter(e){this.groupTargets=e,this.reevaluateEarthSatMode()}applySmallBodyFilter(e){this.smallBodyZone=e?.kind===`class`?`small_bodies/${e.className}`:null,this.refreshSmallBodyEmphasis()}refreshSmallBodyEmphasis(){let e=this.smallBodyZone;if(e===null){this.deps.pointClouds.setEmphasizedSmallBodyZone(null,null);return}let t=this.deps.ctx.bodies.asteroidBodiesByZone.get(e)?.size??0;this.deps.pointClouds.setEmphasizedSmallBodyZone(e,t)}onSimTimeChanged(){let e=this.deps.clock.jd;e>this.countStableLo&&e<this.countStableHi||this.reevaluateEarthSatMode()}reevaluateEarthSatMode(){let e=this.deps.ctx.bodies.spacecraftByParent.get(p_),t=this.currentMemberCount(e),n=XL(t);this.deps.pointClouds.setEarthSatEmphasis(t);let r=n!==this.groupMode;if(this.teardownAutoPromoted(r),this.groupMode=n,n===`none`||!e)return;let i=this.deps.clock.jd,a=[];for(let t of e.values())this.groupTargets&&!this.groupTargets.has(t.data.id)||ZL(t,i)&&(this.deps.bodyObjects.has(t.data.id)||a.push(t));if(a.length===0)return;let o=n===`half`?new Set(a.map(e=>e.data.id)):void 0;this.buildBatch(a,o,!0)}currentMemberCount(e){if(this.countStableLo=-1/0,this.countStableHi=1/0,!e)return 0;let t=this.deps.clock.jd,n=0;for(let r of e.values()){if(this.groupTargets&&!this.groupTargets.has(r.data.id))continue;let{validityStart:e,validityEnd:i}=r.data;e<=t?e>this.countStableLo&&(this.countStableLo=e):e<this.countStableHi&&(this.countStableHi=e),i<t?i>this.countStableLo&&(this.countStableLo=i):i<this.countStableHi&&(this.countStableHi=i),ZL(r,t)&&n++}return n}teardownAutoPromoted(e){if(this.autoPromoted.size===0)return;let t=this.deps.getFocusedId(),n=this.deps.clock.jd,r=[];for(let i of this.autoPromoted){if(i===t)continue;if(e||this.groupTargets&&!this.groupTargets.has(i)){r.push(i);continue}let a=this.deps.bodyObjects.get(i)?.body;a&&!ZL(a,n)&&r.push(i)}r.length!==0&&this.tearDownBodies(r,this.autoPromoted)}clearUserPromoted(){let e=this.deps.getFocusedId(),t=[...this.userPromoted].filter(t=>t!==e);this.tearDownBodies(t,this.userPromoted),this.emitUserPromotedCount()}tearDownBodies(e,t){if(e.length===0)return;let{bodyObjects:n,ctx:r,scene:i,clickables:a,meshToBody:o,pointClouds:s}=this.deps,c=new Set,l=new Set;for(let r of e){let e=n.get(r);if(!e){t.delete(r);continue}e.label&&(e.label.element.remove(),e.label.removeFromParent()),e.loadingEl?.remove(),aO(e),tM(e),kM(e),i.remove(e.group);for(let t of e.extraObjects)i.remove(t);if(e.trail&&i.remove(e.trail),e.mesh){e.mesh.geometry.dispose(),sj(e.mesh.material);let t=a.indexOf(e.mesh);t>=0&&a.splice(t,1),o.delete(e.mesh)}e.atmosphere&&=(e.atmosphere.mesh.geometry.dispose(),sj(e.atmosphere.mesh.material),null),e.trail&&(e.trail.geometry.dispose(),sj(e.trail.material));let s=e.body.data.objectType;if(s===W.SPACECRAFT)c.add(e.body.data.parentId);else if(_n(s)||s===W.COMET){let e=this.deps.ctx.bodies.findAsteroidZone(r);e&&l.add(e)}n.delete(r),t.delete(r)}for(let e of c)r.bodies.dirtySpacecraftGroups.add(e);for(let e of l)r.bodies.dirtyAsteroidZones.add(e);(c.size>0||l.size>0)&&s.rebuildMinor()}emitUserPromotedCount(){if(!this.deps.onUserPromotedChange)return;let e=this.deps.getFocusedId(),t=this.userPromoted.size;e&&this.userPromoted.has(e)&&t--,this.deps.onUserPromotedChange(t)}},$L=class{promotion;readerFocusFilter=null;focusedBody;_tmpV3=new J;pendingInitialView=null;upgradeTargetIds=new Set;constructor(e,t,n,r,i){this.deps=e,this.focusedBody=t,this.promotion=new QL({scene:e.scene,bodyObjects:e.bodyObjects,ctx:e.ctx,clock:e.clock,renderer:i,circleTexture:r,clickables:e.clickables,meshToBody:e.meshToBody,hoveredBodyIds:n,pointClouds:e.pointClouds,onBodyClick:e=>this.handleFocus(e),assignMapLayerToTrails:e.assignMapLayerToTrails,repositionAll:e.repositionAll,getFocusedId:()=>this.focusedBody?.data.id,onUserPromotedChange:e.callbacks.onUserPromotedChange})}get current(){return this.focusedBody}setPendingInitialView(e){this.pendingInitialView=e}clearPendingInitialView(){this.pendingInitialView=null}focusedBodyQuat(e){let t=e??this.focusedBody;if(!t||KD(t))return;let n=this.deps.bodyObjects.get(t.data.id)?.mesh;if(!n)return;let r=n.quaternion;return[r.x,r.y,r.z,r.w]}cameraTruePos(){let{focus:e,camera:t}=this.deps;return[e.focusTruePos[0]+t.position.x,e.focusTruePos[1]+t.position.y,e.focusTruePos[2]+t.position.z]}syncUpgradeTargets(e){let{ctx:t,scene:n,clickables:r,meshToBody:i,bodyObjects:a,pointClouds:o,clock:s,loadTexture:c,assignMapLayerToTrails:l}=this.deps,u=eR(e,t),d=new Set(u.map(e=>e.data.id));for(let e of this.upgradeTargetIds){if(d.has(e))continue;let t=a.get(e);t&&(dj(t.body)?pj(t,n,r,i):aO(t))}let f=!1;for(let t of u){if(this.upgradeTargetIds.has(t.data.id))continue;this.promotion.ensureBodyObjects(t);let o=a.get(t.data.id);if(!o){d.delete(t.data.id);continue}dj(t)&&(fj(o,n,r,i),f=!0),t.data.id!==e?.data.id&&c(t)}return f&&(hN(a,n,o.basis(),s.jd),l()),this.upgradeTargetIds=d,d}panCameraToBody(e){if(e.positionUnknown)return;let{focus:t,camera:n}=this.deps;RL(t,[...e.position],n,this.cameraTruePos(),void 0,jx().resolvedReducedMotion)}focusOnPoint(e,t){let{focus:n,camera:r,callbacks:i}=this.deps,a=this.cameraTruePos(),o;if(t!==void 0){let n=this._tmpV3.set(e[0]-a[0],e[1]-a[1],e[2]-a[2]).normalize().negate();o=[e[0]+n.x*t,e[1]+n.y*t,e[2]+n.z*t]}this.focusedBody=void 0,RL(n,[...e],r,a,o,jx().resolvedReducedMotion);let s=rC(o??a,e,void 0);i.onCameraPosition?.(s.latitude,s.longitude,s.distance)}handleFocus(e){if(this.readerFocusFilter&&!this.readerFocusFilter(e))return;if(this.focusedBody?.data.id===e.data.id){this.deps.callbacks.onFocusChange(e);return}if(this.setFocusTarget(e),e.positionUnknown)return;let{latitude:t,longitude:n,distance:r}=rC(this.cameraTruePos(),e.position,this.focusedBodyQuat(e));this.deps.callbacks.onCameraPosition?.(t,n,r)}setFocusTarget(e,t){let{ctx:n,bodyObjects:r,controls:i,callbacks:a,focus:o,camera:s,systemData:c,loadTexture:l}=this.deps;un(e)||this.promotion.ensureBodyObjects(e);let u=this.focusedBody,d=gM(u,r),f=gM(e,r),p=u&&(un(u)?u.featureAnchor.hostId:u.data.id),m=un(e)?e.featureAnchor.hostId:e.data.id,h=this.syncUpgradeTargets(e);if(p&&p!==m&&!h.has(p)){let e=r.get(p);e&&aO(e)}if(d&&d!==f){let e=r.get(d);e&&kM(e)}this.focusedBody=e,un(e)||(n.bodies.focusFeature=null),i.minDistance=GL(e,EO(r.get(e.data.id)));let g=un(e)?n.getBody(e.featureAnchor.hostId):void 0;if(n.visibility.setFocused(g??e),a.onFocusChange(e),un(e)||l(e),f&&f!==e.data.id){let e=n.getBody(f);e&&l(e)}c.syncToFocus(),e.positionUnknown||RL(o,[...e.position],s,this.cameraTruePos(),t,jx().resolvedReducedMotion),this.promotion.emitUserPromotedCount()}focusOnBody(e,t,n,r){let{ctx:i,clock:a,focus:o,camera:s,callbacks:c,pointClouds:l}=this.deps,u=i.getBody(e);if(!u)return 0;if(i.bodies.bodiesById.has(e)||TT(u,a.jd,i),u.positionUnknown)return this.setFocusTarget(u),0;let d;if(t!==void 0)if(n!==void 0&&r!==void 0)d=iC(u.position,n,r,t,this.focusedBodyQuat(u));else{let e=this.cameraTruePos(),n=this._tmpV3.set(u.position[0]-e[0],u.position[1]-e[1],u.position[2]-e[2]).normalize().negate();d=[u.position[0]+n.x*t,u.position[1]+n.y*t,u.position[2]+n.z*t]}let f=rC(d??this.cameraTruePos(),u.position,this.focusedBodyQuat(u));return c.onCameraPosition?.(f.latitude,f.longitude,f.distance),t!==void 0&&d?this.focusedBody?.data.id===e&&R_(o.focusTruePos,u.position)<GL(u)?(o.focusTruePos=[...u.position],this.deps.repositionAll(),l.rebuildBasis(),zL(o,s,this.cameraTruePos(),d,jx().resolvedReducedMotion)):(this.setFocusTarget(u,d),n!==void 0&&r!==void 0&&(o.orbitFly=!0)):this.setFocusTarget(u),o.focusDurationMs}snapToBody(e,t,n,r){let i=this.deps.ctx.getBody(e);!i||i.positionUnknown||(this.settleOnBodyInstant(i),this.snapToBodyFrame(t,n,r))}snapToBodyFacing(e,t,n,r){let{ctx:i,camera:a,controls:o,callbacks:s}=this.deps,c=i.getBody(e);if(!c||c.positionUnknown)return;this.settleOnBodyInstant(c);let l=i.getBody(t)?.position??[0,0,0],u=aC(c.position,l,n,r);a.position.set(u[0],u[1],u[2]),o.update();let d=rC(u,[0,0,0]);s.onCameraPosition?.(d.latitude,d.longitude,d.distance),this.pendingInitialView=null}settleOnBodyInstant(e){let{focus:t,pointClouds:n}=this.deps;this.setFocusTarget(e),t.focusTruePos=[...e.position],t.focusOriginWorld=[...e.position],t.focusTargetWorld=[...e.position],t.focusStartTime=-OL,t.camOriginWorld=null,t.camTargetWorld=null,t.flyQ0=null,t.orbitFly=!1,t.arcOrbit=!1,t.cameraStaysOnBody=!1,this.deps.repositionAll(),n.rebuildBasis()}snapToBodyFrame(e,t,n){let r=this.focusedBody;if(!r)return;let{camera:i,controls:a,callbacks:o}=this.deps,s=!KD(r),c=s?this.focusedBodyQuat(r)??[0,0,0,1]:void 0,l=iC([0,0,0],e,t,n,c);i.position.set(l[0],l[1],l[2]),a.update();let u=rC(l,[0,0,0],c);o.onCameraPosition?.(u.latitude,u.longitude,u.distance),s&&c[0]===0&&c[1]===0&&c[2]===0&&c[3]===1&&(this.pendingInitialView={latitude:e,longitude:t,zoom:n})}reapplyInitialViewIfPending(){let e=this.pendingInitialView;if(!e)return;let t=this.focusedBodyQuat();if(!t||t[0]===0&&t[1]===0&&t[2]===0&&t[3]===1){this.pendingInitialView=null;return}let n=iC([0,0,0],e.latitude,e.longitude,e.zoom,t);this.deps.camera.position.set(...n),this.deps.controls.update(),this.pendingInitialView=null}};function eR(e,t){if(!e)return[];if(un(e)){let n=t.getBody(e.featureAnchor.hostId);return n&&dj(n)?[n]:[]}let n=[];if(dj(e)&&n.push(e),e.data.objectType===W.MOON||e.data.orbitalSource===U.SPICE_PROBE){let r=t.getBody(e.data.parentId);r&&n.push(r)}return n}var tR=1e-6;function nR(e){return e.data.name??e.data.id}var rR=class{armedProbeId=null;noticeShown=!1;coverage=new Map;pending=new Set;constructor(e,t){this.clock=e,this.notices=t}coverageFor(e){let t=this.coverage.get(e);if(t!==void 0)return t??void 0;this.pending.has(e)||(this.pending.add(e),mx(e,!1).then(t=>this.coverage.set(e,t.global?.coverage??null)).catch(()=>this.coverage.set(e,null)).finally(()=>this.pending.delete(e)))}sync(e,t){let n=e?.data.id??null,r=n===null?void 0:this.coverageFor(n);if(!e||!r){this.disarm();return}this.armedProbeId!==n&&(this.dismissNotice(),this.armedProbeId=n);let i=r.end_jd-tR,a=r.start_jd+tR;this.noticeShown&&t>a&&t<i&&this.dismissNotice(),this.clock.setBoundaryStops({forwardJd:i,backwardJd:a,onHit:t=>this.onHit(e,t,i)})}onHit(e,t,n){this.notices.notify({topic:`coverage-pause`,name:nR(e),direction:t>=n?`forward`:`backward`,jd:t}),this.noticeShown=!0}disarm(){this.armedProbeId!==null&&(this.armedProbeId=null,this.dismissNotice(),this.clock.setBoundaryStops(null))}dismissNotice(){this.noticeShown&&=(this.notices.dismiss(`coverage-pause`),!1)}},iR=class{group=new za;extensions=new Set;constructor(){this.group.matrixAutoUpdate=!1,this.group.frustumCulled=!1}add(e){this.extensions.add(e),this.group.add(e.object)}remove(e){this.extensions.delete(e)&&(this.group.remove(e.object),e.dispose())}update(e){for(let t of this.extensions)t.update(e)}clear(e){for(let t of[...this.extensions])e?.(t)||(this.extensions.delete(t),this.group.remove(t.object),t.dispose())}dispose(){this.clear()}},aR=Math.PI/180;function oR(e){return`latitude`in e}function sR(e,t){let n=e*aR,r=t*aR;return[Math.cos(n)*Math.cos(r),Math.sin(n),-Math.cos(n)*Math.sin(r)]}function cR(e,t,n,r,i,a){let o=2*(e.y*r-e.z*n),s=2*(e.z*t-e.x*r),c=2*(e.x*n-e.y*t);i[a]=t+e.w*o+(e.y*c-e.z*s),i[a+1]=n+e.w*s+(e.z*o-e.x*c),i[a+2]=r+e.w*c+(e.x*s-e.y*o)}function lR(e,t,n){let r=t.getBody(e.body);if(!r)return null;let[i,a,o]=r.position;if(oR(e)){let t=Q(gn(r.data)+(e.altitudeKm??0)),[s,c,l]=sR(e.latitude,e.longitude),u=r.orientation?fC(r.orientation,n,r.nutPrec):null;if(!u)return[i+s*t,a+c*t,o+l*t];let d=[0,0,0];return cR(u,s,c,l,d,0),[i+d[0]*t,a+d[1]*t,o+d[2]*t]}let s=typeof e.offsetKm==`function`?e.offsetKm(n):e.offsetKm;if(s===null)return null;if(s===void 0)return[i,a,o];let[c,l,u]=bF(s);return[i+c,a+l,o+u]}function uR(e,t,n){let r=n.getBody(e.body);if(!r)return null;let i=t[0]-r.position[0],a=t[1]-r.position[1],o=t[2]-r.position[2],s=Math.hypot(i,a,o);return s===0?null:[i/s,a/s,o/s]}function dR(e){let t=ig/10;return[e[0]*t,-e[2]*t,e[1]*t]}function fR(e,t,n){let r=lR(e.position,t,n),i=lR(e.target,t,n);if(!r||!i)return null;let[a,o,s]=e.up??[0,0,1];return{position:r,target:i,up:[a,s,-o]}}var pR=.02,mR=1e-4;function hR(e,t,n,r,i){let a=e.position.length();if(!(a>0))return{rotate:1,translate:1};let o=KD(n)?void 0:n,s=a;for(let n of[o,i?void 0:r]){if(!n)continue;let r=Q(gn(n.data));if(!(r>0))continue;let i=Math.hypot(e.position.x-(n.position[0]-t[0]),e.position.y-(n.position[1]-t[1]),e.position.z-(n.position[2]-t[2]));s=Math.min(s,i-r)}let c=o?Q(gn(o.data)):0,l=Math.tan(Vi.degToRad(e.getEffectiveFOV())/2);return{rotate:gR(c>0?(a-c)*l/(Math.PI*c):1,mR),translate:gR(s/a,pR)}}function gR(e,t){return Math.min(1,Math.max(t,e))}var _R=Math.PI/180;function vR(e,t){let n=e*_R,r=t*_R;return[Math.cos(n)*Math.cos(r),Math.sin(n),-Math.cos(n)*Math.sin(r)]}function yR(e,t,n,r){let i=document.createElement(`div`);i.className=`user-location-marker`;let a=new YO(i),[o,s,c]=vR(n,r);return a.position.set(o*t,s*t,c*t),e.add(a),a}function bR(e){e.parent?.remove(e),e.element.remove()}var xR=new J;function SR(e,t,n){if(!e)return;let r=t.get(p_);if(!r?.mesh)return;xR.copy(e.position).applyQuaternion(r.mesh.quaternion);let i=xR.x,a=xR.y,o=xR.z,s=r.mesh.position,c=n.position.x-s.x,l=n.position.y-s.y,u=n.position.z-s.z,d=r.radiusScene,f=d*d;e.visible=c*c+l*l+u*u<=f||i*c+a*l+o*u>f}var CR=-1,wR=.05,TR=.4,ER=1.2,DR=Q(1e6),OR=.02,kR=2,AR=2.3,jR=.9,MR=new J,NR=.25,PR=10,FR=4,IR=4,LR=28,RR=.02,zR=class e{renderer;composer;atmoDepthPass;bloomPass;labelRenderer;scene;camera;controls;motionScale={rotate:1,translate:1};pointerInteraction;gpuPick;canvas;ctx;clock;callbacks;selectedFeatureId=null;bodyObjects=new Map;circleTexture=KM();pointClouds;systemData;positionDiagnostics=new CI;clickables=[];meshToBody=new Map;hoveredBodyIds=new Set;cullFrameCounter=0;hideCappedMoonLabels=!1;focusController;coverageWatch=null;outOfRange;extensions=new iR;cameraHold=null;holdingCamera=!1;_tmpV3=new J;cameraBand=null;focusableBodies=null;limitsArmed=!1;bodySelectEnabled=!0;featureSelectEnabled=!0;modelScene;modelCamera;modelLight;overlayActive=!1;modelShadowPlane=null;_tmpUp=new J;_tmpSun=new J;_planeNormal=new J(0,0,1);_modelRaycaster=new Rd;_pickNdc=new q;showPointingAxes=!1;pointingAxes=null;cameraUp;skyboxAdjuster;skyDebugMarkers;haloDebug;travelPath;orbitPreview;previewFlyBodyId=null;travelFocus=null;focus={focusTruePos:[0,0,0],focusOriginWorld:[0,0,0],focusTargetWorld:[0,0,0],camOriginWorld:null,camTargetWorld:null,camTargetOffset:null,camOriginOffset:null,flyQ0:null,orbitFly:!1,arcOrbit:!1,cameraStaysOnBody:!1,focusStartTime:0,focusDurationMs:OL};lastUpdatedJd=NaN;lastUpdatedSystemId=null;lastSeatConfigKey=null;lastProbeVersion=0;focusWasOutOfRange=!1;_positionMapScratch=new Map;frameIndex=0;static WAKE_FRAMES=30;static IDLE_HEARTBEAT_FRAMES=10;static REALTIME_FRAME_MS=30;wakeUntilFrame=e.WAKE_FRAMES;lastRenderedFrame=0;lastRenderMs=0;lastRenderedJd=NaN;lastRenderedFocusKey=``;lastRenderedCamPos=new J(NaN,NaN,NaN);lastRenderedCamQuat=new Hi;unsubscribeBodiesAdded=null;_trailView={camX:0,camY:0,camZ:0,tolAngle:0};viewportH=1;tier=Jx();landedNomBodyId=null;rafId=0;paused=!1;covered=!1;firstFrame=!0;pendingUrlWrite=!1;lastTickMs=0;static FPS_SAMPLE_FRAMES=30;fpsSamples=[];fpsSampleHead=0;stashedSky=null;namesShown=!0;textureLoader=new Ju;appearances=new rM;shadowLight;ambientLights;get sunPointLight(){return this.bodyObjects.get(f_)?.extraObjects.find(e=>e instanceof dd)}tightFar=!1;sunProxyK=1;sunBaseMeshScale=1;sunBaseCoronaScale=0;userLocationMarker=null;labelContainer;static MAP_LAYER=1;static ATMO_DEPTH_LAYER=2;constructor(t,n,r,i,a,o){this.canvas=t,this.ctx=r,r.hasMeshBody=e=>this.bodyObjects.has(e),this.clock=i,this.callbacks=o,this.outOfRange=new uI(o.notices),this.labelContainer=n;let s=wT(t,n,r);this.viewportH=t.clientHeight||1,this.renderer=s.renderer,this.labelRenderer=s.labelRenderer,this.scene=s.scene,this.scene.add(this.extensions.group),this.camera=s.camera,this.composer=s.composer,this.bloomPass=s.bloomPass,this.shadowLight=s.shadowLight;let c=this.renderer.getDrawingBufferSize(new q);this.atmoDepthPass=new mj(c.x,c.y),this.modelScene=new qa,this.modelScene.environment=bT(this.renderer),this.modelScene.environmentIntensity=_T,this.modelCamera=new sd(60,1,.01,1e3),this.modelScene.add(this.modelCamera);let l=new hd(16777215,hT);this.modelScene.add(l),this.ambientLights=[s.ambientLight,l],this.modelLight=new md(16777215,gT),this.modelLight.castShadow=!0,this.modelLight.shadow.mapSize.set(this.tier.shadowMapSize,this.tier.shadowMapSize),this.modelLight.shadow.camera.left=-4,this.modelLight.shadow.camera.right=4,this.modelLight.shadow.camera.top=4,this.modelLight.shadow.camera.bottom=-4,this.modelLight.shadow.camera.near=4,this.modelLight.shadow.camera.far=28,this.modelLight.shadow.bias=-1e-4,this.modelLight.shadow.normalBias=.02,this.modelScene.add(this.modelLight),this.modelScene.add(this.modelLight.target),this.modelShadowPlane=new As(new $l(40,40),new iu({opacity:.55})),this.modelShadowPlane.receiveShadow=!0,this.modelShadowPlane.visible=!1,this.modelScene.add(this.modelShadowPlane),this.skyboxAdjuster=new xN(this.scene),this.skyDebugMarkers=new zN(this.scene),this.haloDebug=new JN(this.canvas),this.travelPath=new XF(this.scene,this.canvas),this.travelPath.setLayer(e.MAP_LAYER),this.orbitPreview=new tI(this.scene),this.orbitPreview.setLayer(e.MAP_LAYER),this.skyboxAdjuster.set(0,0,0),dS(this.scene,this.renderer,r);let u=r.bodies.majorBodies.find(e=>e.data.id===f_),d=r.getBody(a.id),f=d&&!d.positionUnknown?d:void 0,p=r.bodies.majorBodies.find(e=>e.data.id===cC)||u,m=f??p,h=m?.position??[0,0,0];this.focus.focusTruePos=[...h],this.focus.focusOriginWorld=[...h],this.focus.focusTargetWorld=[...h],this.focus.focusStartTime=-OL,this.pointClouds=new DP(r,this.scene,this.bodyObjects,this.circleTexture,this.focus,e.MAP_LAYER,()=>this.rebuildTrailBasis()),this.pointClouds.seedBasis(h),this.pointClouds.setPointBudget(this.tier.pointBudget),this.controls=new FS(this.camera,t),this.controls.enableDamping=!0,this.controls.dampingFactor=jx().resolvedReducedMotion?TR:wR,this.controls.minDistance=m?GL(m):Q(.01),this.controls.maxDistance=31620.5*10,this.controls.target.set(0,0,0),this.controls.update(),this.controls.addEventListener(`end`,this.onControlsEnd),this.controls.addEventListener(`start`,this.invalidate),this.controls.addEventListener(`start`,this.armLimits),this.controls.addEventListener(`end`,this.invalidate);for(let n of e.INPUT_EVENTS)t.addEventListener(n,this.invalidate,{passive:!0});window.addEventListener(`keydown`,this.invalidate),this.unsubscribeBodiesAdded=r.bodies.onBodiesAdded(this.invalidate),this.cameraUp=new JO(this.camera,this.controls,r,e=>this.isLanded(e)),this.systemData=new yN(this.scene,r,this.renderer,this.textureLoader,this.bodyObjects,i,()=>this.focusController.reapplyInitialViewIfPending()),this.focusController=new $L({ctx:r,clock:i,camera:this.camera,controls:this.controls,scene:this.scene,bodyObjects:this.bodyObjects,clickables:this.clickables,meshToBody:this.meshToBody,callbacks:o,focus:this.focus,pointClouds:this.pointClouds,systemData:this.systemData,loadTexture:e=>this.maybeLoadTexture(e),repositionAll:()=>this.repositionAll(),assignMapLayerToTrails:()=>this.assignMapLayerToTrails()},m,this.hoveredBodyIds,this.circleTexture,this.renderer),this.coverageWatch=new rR(i,o.notices);let g=f?a:{latitude:45,longitude:0,zoom:15},_=iC([0,0,0],g.latitude,g.longitude,g.zoom,this.focusController.focusedBodyQuat());this.camera.position.set(..._),this.focusController.setPendingInitialView({latitude:g.latitude,longitude:g.longitude,zoom:g.zoom}),m&&r.visibility.setFocused(m),r.visibility.updateCamera(g.zoom,this.clock.jd),o.onFocusChange(m),this.buildScene(),m&&this.focusController.promotion.ensureBodyObjects(m),m&&this.focusController.syncUpgradeTargets(m),this.repositionAll(),m&&this.maybeLoadTexture(m),this.systemData.syncToFocus(),this.focusController.readerFocusFilter=this.readerMayFocus,this.gpuPick=new IO(this.renderer,this.camera),this.pointerInteraction=new jO(t,this.camera,r,i,this.focus,this.clickables,this.meshToBody,e=>this.focusController.handleFocus(e),(e,t)=>this.pickFocusedModel(e,t),this.gpuPick,()=>[...this.pointClouds.asteroids().values(),...this.pointClouds.spacecraft().values()],this.pointClouds.pickRegistry),this.pointerInteraction.attach(),this.tick()}buildScene(){uj(this.ctx.bodies.majorBodies,this.scene,this.clickables,this.meshToBody,this.bodyObjects,this.circleTexture,this.renderer.domElement,e=>this.focusController.handleFocus(e),(e,t)=>{t?this.hoveredBodyIds.add(e):this.hoveredBodyIds.delete(e),this.invalidate()}),this.pointClouds.buildInitial(new Set(this.bodyObjects.keys()));let e=this.pointClouds.basis();(globalThis.requestIdleCallback??(e=>setTimeout(e,0)))(()=>{hN(this.bodyObjects,this.scene,e,this.clock.jd),this.assignMapLayerToTrails()})}setTravelPath(e,t=[],n=[],r=[]){this.travelPath.set(e,t,n,r),this.refreshTravelPath()}setTravelHover(e){this.travelPath.setHovered(e)}setOrbitPreview(e,t=null){this.orbitPreview.set(e),this.refreshOrbitPreview(),t&&this.frameOrbitPreview(t)}frameOrbitPreview(e){let t=this.ctx.getBody(e.bodyId);if(!t)return;let n=Q(e.radiusKm);if(!(n>0)||performance.now()-this.focus.focusStartTime<this.focus.focusDurationMs&&this.previewFlyBodyId===e.bodyId)return;let r=this.focus.focusTruePos,i=t.position[0]-r[0]-this.camera.position.x,a=t.position[1]-r[1]-this.camera.position.y,o=t.position[2]-r[2]-this.camera.position.z,s=Math.hypot(i,a,o);s>n*1.35&&s<n*45||(this.previewFlyBodyId=e.bodyId,this.focusController.focusOnBody(e.bodyId,n*4))}refreshOrbitPreview(){this.orbitPreview.isEmpty||(this.orbitPreview.reposition(e=>this.ctx.getBody(e)?.position??null,this.focus.focusTruePos),this.orbitPreview.updateCameraOffset(this.camera.position))}refreshTravelPath(){if(this.travelPath.isEmpty){this.reserveTravelLabelSpace();return}let e=this.travelPath.centerId,t=e?this.ctx.getBody(e):null;if(!t){this.travelPath.setVisible(!1),this.reserveTravelLabelSpace();return}this.travelPath.setVisible(!0),this.travelPath.setClock(this.clock.jd),this.travelPath.reposition(t.position,this.focus.focusTruePos,e=>this.ctx.getBody(e)?.position??null),this.travelPath.updateCameraOffset(this.camera.position),this.reserveTravelLabelSpace()}reserveTravelLabelSpace(){this.travelPath.reserveLabelSpace(this.camera,this.renderer.domElement.clientWidth,this.renderer.domElement.clientHeight)}focusOnPathPoint(e,t){this.disarmLimits();let n=this.ctx.getBody(e);if(!n)return;let[r,i,a]=bF(t);this.travelFocus={centerId:e,local:[r,i,a]};let o=this.travelFocusWorld(n.position);o&&this.focusController.focusOnPoint(o)}trackPathPoint(e,t){if(!this.travelFocus){this.focusOnPathPoint(e,t);return}let[n,r,i]=bF(t);this.travelFocus={centerId:e,local:[n,r,i]}}travelFocusWorld(e){let t=this.travelFocus;return t?[e[0]+t.local[0],e[1]+t.local[1],e[2]+t.local[2]]:null}refreshTravelFocus(){if(!this.travelFocus)return;if(this.focusController.current){this.travelFocus=null;return}let e=this.ctx.getBody(this.travelFocus.centerId);if(!e)return;let t=this.travelFocusWorld(e.position);if(!t)return;let n=this.focus;n.focusTargetWorld=t;let r=n.camTargetOffset;r&&n.camTargetWorld&&(n.camTargetWorld=[t[0]+r[0],t[1]+r[1],t[2]+r[2]]),performance.now()-n.focusStartTime>=n.focusDurationMs&&(n.focusTruePos=[...t])}updateTravelCraftSystem(){let e=this.travelFocus,t=this.travelPath.plan;if(!e||!t){this.ctx.visibility.clearTravelSystem();return}let n=this.ctx.getBody(e.centerId),r=n?this.travelFocusWorld(n.position):null;if(!r)return;let i=null;for(let e of t.stops){let t=this.ctx.getBody(e.bodyId);if(!t)continue;let n=this.ctx.visibility.resolveSystemId(t);if(!n)continue;let a=this.ctx.visibility.systemReachAU(n);if(!(a>0))continue;let o=R_(r,t.position)/10;!i&&o<=a?i=n:o<=a*2?this.systemData.prefetch(n):this.systemData.discardPrefetch(n)}this.ctx.visibility.setTravelSystem(i)}assignMapLayerToTrails(){for(let t of this.bodyObjects.values())t.trail&&t.trail.layers.set(e.MAP_LAYER)}setImmersive(t){t?(this.camera.layers.disable(e.MAP_LAYER),this.labelContainer.style.display=`none`):(this.camera.layers.enable(e.MAP_LAYER),this.labelContainer.style.display=``)}rebuildMinorPointClouds(){this.pointClouds.rebuildMinor()}repositionAll(){this.repositionBodies(),this.rebuildTrailBasis()}repositionBodies(){let[e,t,n]=this.focus.focusTruePos;for(let r of this.bodyObjects.values()){let[i,a,o]=r.body.position,s=i-e,c=a-t,l=o-n;r.group.position.set(s,c,l);for(let e of r.extraObjects)e.position.set(s,c,l)}this.pointClouds.reposition()}rebuildTrailBasis(){let e=this.focus.focusTruePos,[t,n,r]=e;for(let i of this.bodyObjects.values()){let a=i.trail;if(!a)continue;let o=a.userData.trailBuffer;if(o){WP(i.body,a,o,e,this.clock.jd);continue}let s=a.userData.trailLocalPositions;if(!s)continue;let c=a.userData.orbitCenter;GP(a,s,c.x-t,c.y-n,c.z-r)}}tick=()=>{this.rafId=requestAnimationFrame(this.tick),this.frameIndex++;let t=performance.now(),n=this.lastTickMs?t-this.lastTickMs:0;if(this.lastTickMs=t,this.holdingCamera||this.cameraUp.update(this.clock.jd),this.firstFrame&&(this.firstFrame=!1,this.controls.target.set(0,0,0),this.controls.update()),this.coverageWatch?.sync(this.focusController.current,this.clock.jd),this.clock.tick(performance.now()),!this.shouldRender(t)){this.controls.update(),this.applyReaderLimits(t);return}this.fpsSamples.length<e.FPS_SAMPLE_FRAMES?this.fpsSamples.push(t):(this.fpsSamples[this.fpsSampleHead]=t,this.fpsSampleHead=(this.fpsSampleHead+1)%e.FPS_SAMPLE_FRAMES);let r=this.lastRenderedFrame===this.frameIndex-1?n:0;this.lastRenderedFrame=this.frameIndex,this.lastRenderMs=t,this.lastRenderedJd=this.clock.jd,this.lastRenderedFocusKey=this.focusKey(),this.lastRenderedCamPos.copy(this.camera.position),this.lastRenderedCamQuat.copy(this.camera.quaternion),this.applyJdUpdate(!0),this.refreshTravelFocus(),this.callbacks.onFrame?.(this.clock.jd,r);let i=this.holdingCamera?this.applyHeldCamera():LL(this.focus,this.camera,this.controls,()=>this.repositionAll(),()=>this.pointClouds.rebuildBasis());this.applyReaderLimits(t);let a=this.holdingCamera?void 0:this.focusController.current;if(a){let e=F_(a.data.parentId),t=e?this.ctx.getBody(e):void 0,n=!!this.bodyObjects.get(a.data.id)?.isLanded||un(a);t&&KL(this.camera,t,this.focus.focusTruePos,this.surfaceClamp(t,n)),CO(this.bodyObjects.get(a.data.id))&&KL(this.camera,a,this.focus.focusTruePos,this.surfaceClamp(a,!1)),this.setMotionScale(hR(this.camera,this.focus.focusTruePos,a,t,n))}else this.setMotionScale({rotate:1,translate:1});if(this.pendingUrlWrite&&i){this.pendingUrlWrite=!1;let{latitude:e,longitude:t,distance:n}=this.getCameraState();this.callbacks.onCameraPosition?.(e,t,n)}this.systemData.hasPendingUnloads()&&performance.now()-this.focus.focusStartTime>=this.focus.focusDurationMs&&this.systemData.drainPendingUnloads();let{distance:o}=this.getCameraState();this.updateTravelCraftSystem(),this.ctx.visibility.updateCamera(o,this.clock.jd),this.updateTightFar(o),this.systemData.syncToFocus(),this.refreshTravelPath(),this.refreshOrbitPreview(),this.extensions.update({jd:this.clock.jd,basis:this.focus.focusTruePos,camera:this.camera,viewportPx:this.viewportH,ctx:this.ctx}),this.cullFrameCounter=oF(this.bodyObjects,this.camera,this.ctx,this.focus.focusTruePos,this.focusController.current?.data.id,this.hideCappedMoonLabels,this.hoveredBodyIds,this.pointClouds.asteroids(),this.pointClouds.spacecraft(),this.pointClouds.moons(),this.cullFrameCounter,this.renderer,this._tmpV3,!i,this.tightFar),this.pointClouds.applyPointBudget(),SI(this.bodyObjects,this.focus,this.lastUpdatedJd,this.trailView()),OI(this.bodyObjects,this.focus.focusTruePos,jx().realisticLighting,jx().overexposeRings,this.camera.position,this.pxPerRad()),iL(this.bodyObjects,this.focus.focusTruePos);let s=nL(this.bodyObjects,this.camera.position,jx().showAtmospheres,jx().realisticLighting,this.sunIntensityScale,Lk(),this.clock.jd);Jk(r,s.shellProminent),this.scene.backgroundIntensity=s.skyboxIntensity,this.applyLayerChrome();let c=this.bodyObjects.get(f_);c&&ij(c.corona,c.starPoint,s.sunTint);let l=jx().highAmbient?1:hT;if(!jx().highAmbient&&jx().realisticLighting){let e=this.bodyObjects.get(f_)?.body.position;if(e&&this.ctx.visibility.activeSystemId){let[t,n,r]=this.focus.focusTruePos;l*=vT(Math.hypot(e[0]-t,e[1]-n,e[2]-r))}}for(let e of this.ambientLights)e.intensity=l;SR(this.userLocationMarker,this.bodyObjects,this.camera);let u=gM(this.focusController.current,this.bodyObjects);DL(this.bodyObjects,this.camera,this.renderer,this.ctx,this.textureLoader,u,this.clock.jd,this.appearances),TL(this.bodyObjects,this.camera,this.renderer,this.ctx,u),oL(this.bodyObjects,this.focus.focusTruePos,this.ctx,this.shadowLight,this.sunPointLight,o,this._tmpV3,jx().realisticLighting,this.sunIntensityScale),this.updateModelMounts(),this.pointClouds.drainOnePendingSceneAdd(),this.updateDepthFar(),this.updateSunProxy(s.sunRefraction),s.insideShell&&this.atmoDepthPass.run(this.renderer,this.scene,this.camera,this.bodyObjects,e.ATMO_DEPTH_LAYER),this.composer.render(),this.renderModelOverlay(),this.labelRenderer.render(this.scene,this.camera),this.haloDebug.active&&this.haloDebug.draw(this.bodyObjects,this.camera,this.focus.focusTruePos,this.focusController.current?.data.id,this.renderer.domElement.clientWidth,this.renderer.domElement.clientHeight)};updateTightFar(e){if(nT())return;let t=this.focusController.current,n=t?gM(t,this.bodyObjects):void 0,r=n?this.bodyObjects.get(n):void 0,i=r?.radiusScene??0,a=e;if(t&&r&&n!==t.data.id){let[e,t,n]=this.focus.focusTruePos,[i,o,s]=r.body.position,c=this.camera.position;a=Math.hypot(e+c.x-i,t+c.y-o,n+c.z-s)}let o=this.tightFar?AR:kR;this.tightFar=i>0&&this.ctx.visibility.activeSystemId!==null&&a<i*o}updateDepthFar(){if(nT())return;let e=xT,t=this.ctx.visibility.activeSystemId;if(t){let[n,r,i]=this.focus.focusTruePos,a=this.camera.position.lengthSq(),o=e=>{let t=e[0]-n,o=e[1]-r,s=e[2]-i,c=t*t+o*o+s*s;c>a&&(a=c)},s=this.bodyObjects.get(f_);if(this.tightFar){let e=this.bodyObjects.get(t)?.body;if(e){let o=Math.hypot(e.position[0]-n,e.position[1]-r,e.position[2]-i)+this.ctx.bodies.getSystemExtent(t)*10*2;a=Math.max(a,o*o)}}else s&&o(s.body.position);for(let e of this.bodyObjects.values())this.ctx.visibility.hasFullRendering(e.body)&&o(e.body.position);e=Math.min(xT,Math.max(DR,Math.sqrt(a)*ER))}Math.abs(e-this.camera.far)>this.camera.far*OR&&(this.camera.far=e,this.camera.updateProjectionMatrix())}updateSunProxy(e){let t=this.bodyObjects.get(f_);if(!t)return;let[n,r,i]=this.focus.focusTruePos,[a,o,s]=t.body.position,c=a-n,l=o-r,u=s-i;if(e){let t=this.camera.position,n=this._tmpV3.set(c-t.x,l-t.y,u-t.z),r=n.length();n.divideScalar(r);let i=MR.copy(e.up).addScaledVector(n,-e.up.dot(n));i.lengthSq()>1e-12&&(n.addScaledVector(i.normalize(),e.angleRad).normalize(),c=t.x+n.x*r,l=t.y+n.y*r,u=t.z+n.z*r)}let d=1;if(this.tightFar){let e=this.camera.far*jR,t=Math.hypot(c,l,u);t>e&&(d=e/t)}if(!(d===1&&this.sunProxyK===1&&!e)){this.sunProxyK===1&&(this.sunBaseMeshScale=t.mesh?.scale.x??1,this.sunBaseCoronaScale=t.corona?.scale.x??0),t.group.position.set(c*d,l*d,u*d);for(let e of t.extraObjects)e.position.set(c*d,l*d,u*d);t.mesh?.scale.setScalar(this.sunBaseMeshScale*d),t.corona?.scale.set(this.sunBaseCoronaScale*d,this.sunBaseCoronaScale*d,1),this.sunProxyK=d}}setMotionScale(e){this.motionScale=e,this.controls.rotateSpeed=e.rotate,this.controls.panSpeed=e.translate,this.controls.zoomSpeed=e.translate}isLanded(e){return!!this.bodyObjects.get(e)?.isLanded}surfaceRadialKm(e,t,n){let r=this.ctx.getBody(e);if(!r)return null;let i=sw(t*Math.PI/180,n*Math.PI/180);return kw(this.bodyObjects.get(e),e,gn(r.data),i)}surfaceClamp(e,t){let n=this.bodyObjects.get(e.data.id);if(CO(n))return{invQuat:n.model.quaternion.clone().invert(),seated:t,outerRadiusKm:TO(n),centerOffsetScene:wO(n),radialKm:e=>SO(n,e)};if(!(!t||!e.orientation))return{invQuat:fC(e.orientation,this.clock.jd,e.nutPrec).invert(),seated:t,radialKm:t=>kw(n,e.data.id,e.data.radiusKm,t)}}updateModelMounts(){let e=!1;for(let t of this.bodyObjects.values())if(t.model&&KD(t.body)){e=!0;break}this.overlayActive=e;for(let t of this.bodyObjects.values()){let n=t.model,r=t.modelRoot;if(!(!n||!r)){if(e)n.parent!==this.modelScene&&this.modelScene.add(n);else if(n.parent!==r){r.add(n);let e=n.userData;n.scale.setScalar(e.fitScale??1),n.position.set(0,0,0),e.centerOffset&&n.position.addScaledVector(e.centerOffset,-1)}}}if(e){this.shadowLight.castShadow=!1;return}this.updateFocusedMountedModel()}updateFocusedMountedModel(){let e=this.overlayModelBo(),t=e?.model&&e.model.parent===e.modelRoot?e.modelRoot:null;if(!e||!t){this.shadowLight.castShadow=!1;return}let n=QD(e);t.scale.setScalar(n);let r=this.shadowLight.intensity>0;if(this.shadowLight.castShadow=r,!r)return;let i=this.bodyObjects.get(f_)?.body;if(!i)return;let[a,o,s]=i.position,[c,l,u]=e.body.position;this._tmpSun.set(a-c,o-l,s-u).normalize(),this.shadowLight.position.copy(e.group.position).addScaledVector(this._tmpSun,PR*n),this.shadowLight.target.position.copy(e.group.position);let d=this.shadowLight.shadow.camera;d.left=d.bottom=-FR*n,d.right=d.top=FR*n,d.near=IR*n,d.far=LR*n,d.updateProjectionMatrix(),this.shadowLight.shadow.normalBias=RR*n}renderModelOverlay(){if(!this.overlayActive)return;let e=this.overlayModelBo();if(!e?.model)return;let t=e.model.userData;e.model.scale.setScalar(t.fitScale??1),e.model.position.set(0,0,0),e.isLanded&&t.feetOffset?e.model.position.copy(t.feetOffset).applyQuaternion(e.model.quaternion).multiplyScalar(-1):t.centerOffset&&e.model.position.copy(t.centerOffset).multiplyScalar(-1),this._tmpV3.copy(this.camera.position).sub(e.group.position);let n=this._tmpV3.length(),r=QD(e),i=n/r;this.modelCamera.position.copy(this._tmpV3).normalize().multiplyScalar(i),this.modelCamera.quaternion.copy(this.camera.quaternion),this.modelCamera.aspect=this.camera.aspect;let a=0;for(let t of this.bodyObjects.values()){let n=t.model;if(!n||t===e)continue;let i=QD(t)/r,o=n.userData.fitScale??1;n.scale.setScalar(o*i),n.position.subVectors(t.group.position,e.group.position).divideScalar(r);let s=n.userData;s.centerOffset&&n.position.addScaledVector(s.centerOffset,-i);let c=n.position.length()+i;c>a&&(a=c)}this.modelCamera.near=Math.max(.01,i-5-a),this.modelCamera.far=i+50+a,this.modelCamera.updateProjectionMatrix();let o=this.bodyObjects.get(f_)?.body,s=1;if(o){let[t,n,r]=o.position,[i,a,c]=e.body.position;this._tmpSun.set(t-i,n-a,r-c),jx().realisticLighting&&(s=vT(this._tmpSun.length())),this._tmpSun.normalize(),this.modelLight.position.copy(this._tmpSun).multiplyScalar(10)}if(this.modelShadowPlane){this._tmpUp.set(0,1,0).applyQuaternion(e.model.quaternion);let t=this._tmpSun.dot(this._tmpUp)>.03;this.modelShadowPlane.visible=!!e.isLanded&&t,this.modelShadowPlane.visible&&this.modelShadowPlane.quaternion.setFromUnitVectors(this._planeNormal,this._tmpUp)}this._tmpV3.set(0,0,0);let c=zC(this._tmpV3,this._tmpV3)*s;this.modelLight.intensity=gT*c*this.sunIntensityScale,this.modelScene.environmentIntensity=_T*c,this.showPointingAxes?(this.pointingAxes||(this.pointingAxes=this.buildPointingAxes(),this.modelScene.add(this.pointingAxes)),this.pointingAxes.quaternion.copy(e.model.quaternion),this.pointingAxes.scale.setScalar(Math.min(.8,.45*i)),this.pointingAxes.visible=!0):this.pointingAxes&&(this.pointingAxes.visible=!1),this.renderer.autoClear=!1,this.renderer.clearDepth(),this.renderer.render(this.modelScene,this.modelCamera),this.renderer.autoClear=!0}pxPerRad(){return this.viewportH/2/Math.tan(this.camera.fov*Math.PI/360)}trailView(){let e=this._trailView,t=this.camera.position;return e.camX=t.x,e.camY=t.y,e.camZ=t.z,e.tolAngle=NR/this.pxPerRad(),e}cloudViewInfo(){let e=this.camera.position;return{camPos:[e.x,e.y,e.z],pxPerRad:this.pxPerRad()}}getCameraState(){let e=this.camera.position;return rC([e.x,e.y,e.z],[0,0,0],this.focusController.focusedBodyQuat())}setDragEnabled(e){this.controls.enableRotate=e,this.controls.enablePan=e}setZoomEnabled(e){this.controls.enableZoom=e}setBodySelectEnabled(e){this.bodySelectEnabled=e}setFeatureSelectEnabled(e){this.featureSelectEnabled=e}readerMayFocus=e=>this.bodySelectEnabled&&(this.focusableBodies?.has(e.data.id)??!0);setCooperativeTouch(e){this.controls.touches.ONE=e?CR:Tn.ROTATE,this.canvas.style.touchAction=e?`pan-x pan-y`:`none`}setCameraLimits(e,t){this.cameraBand=e,this.focusableBodies=t?new Set(t):null}armLimits=()=>{this.limitsArmed=!0};disarmLimits(){this.limitsArmed=!1}applyReaderLimits(e){!this.limitsArmed||!this.cameraBand||this.holdingCamera||e-this.focus.focusStartTime<this.focus.focusDurationMs||qL(this.camera,this.cameraBand,this.focusController.focusedBodyQuat())}static INPUT_EVENTS=[`pointerdown`,`pointermove`,`pointerup`,`wheel`];invalidate=()=>{this.wakeUntilFrame=this.frameIndex+e.WAKE_FRAMES};focusKey(){let e=this.ctx.visibility;return`${this.focusController.current?.data.id??``}|${e.focusedSystemId??``}|${e.activeSystemId??``}`}cameraOffsetFromFocus(){let e=this.focusController.current,t=this.focus.focusTruePos,n=this.camera.position;return e?[n.x+t[0]-e.position[0],n.y+t[1]-e.position[1],n.z+t[2]-e.position[2]]:[n.x,n.y,n.z]}holdCamera(){this.holdingCamera||(this.disarmLimits(),this.holdingCamera=!0,this.controls.enabled=!1,this.focus.camOriginWorld=null,this.focus.camTargetWorld=null,this.focus.camTargetOffset=null,this.focus.camOriginOffset=null,this.focus.flyQ0=null,this.focus.orbitFly=!1,this.focus.arcOrbit=!1,this.focus.cameraStaysOnBody=!1)}setHeldPose(e){this.cameraHold=e}releaseCamera(){this.holdingCamera&&(this.holdingCamera=!1,this.cameraHold=null,this.controls.enabled=!0,this.controls.target.set(0,0,0),this.controls.enableDamping=!1,this.controls.update(),this.controls.enableDamping=!0,this.invalidate())}applyHeldCamera(){let e=this.cameraHold,t=e&&fR(e,this.ctx,this.clock.jd);if(!t)return!0;let n=this.focus.focusTruePos;return this.camera.up.set(t.up[0],t.up[1],t.up[2]).normalize(),this.camera.position.set(t.position[0]-n[0],t.position[1]-n[1],t.position[2]-n[2]),this.camera.lookAt(t.target[0]-n[0],t.target[1]-n[1],t.target[2]-n[2]),!0}shouldRender(t){if(this.holdingCamera||t-this.focus.focusStartTime<this.focus.focusDurationMs||this.focusKey()!==this.lastRenderedFocusKey||this.ctx.bodies.minorStreaming||this.pointClouds.hasPendingSceneAdds()||this.systemData.hasPendingUnloads())return!0;if(this.covered)return!1;if(this.frameIndex-this.lastRenderedFrame>=e.IDLE_HEARTBEAT_FRAMES)return!0;let n=this.camera;return n.position.distanceToSquared(this.lastRenderedCamPos)>n.position.lengthSq()*1e-10||8*(1-Math.abs(n.quaternion.dot(this.lastRenderedCamQuat)))>1e-8||this.frameIndex<this.wakeUntilFrame||this.haloDebug.active?!0:this.clock.jd===this.lastRenderedJd?!1:Math.abs(this.clock.timeScale)>1||t-this.lastRenderMs>=e.REALTIME_FRAME_MS}onControlsEnd=()=>{this.pendingUrlWrite=!0,this.focusController.clearPendingInitialView()};nudgeCamera(e,t,n){this.armLimits();let{rotate:r,translate:i}=this.motionScale;e!==0&&this.controls.rotateLeft(e*r),t!==0&&this.controls.rotateUp(t*r),n!==1&&this.controls.dollyIn(1/n**+i),this.onControlsEnd()}maybeLoadTexture(e){let t=this.bodyObjects.get(e.data.id);t&&($j(t,this.textureLoader,this.clock.jd,this.scene,this.renderer.capabilities.maxTextureSize,this.ctx).then(()=>{this.focusController.current?.data.id===e.data.id&&e.orientation&&t.mesh&&(pC(t.mesh,e.orientation,this.clock.jd,e.nutPrec),this.focusController.reapplyInitialViewIfPending())}),nO(t,this.modelScene,this.ctx).then(()=>{if(this.focusController.current?.data.id===t.body.data.id&&(this.controls.minDistance=GL(t.body,EO(t))),!this.ctx.layers.skipped.has(`nomenclature`))return wM(t,this.canvas,(e,n,r,i)=>{this.featureSelectEnabled&&this.callbacks.onFeatureSelect?.(t.body.data.id,e,n,r,i)})}).then(()=>{this.selectedFeatureId!==null&&OM(t,this.selectedFeatureId)}))}reapplyBodyLayers(){let e=this.focusController.current;if(!e)return;let t=this.bodyObjects.get(e.data.id);t&&(aO(t),tM(t),this.maybeLoadTexture(e))}setSelectedFeature(e){this.selectedFeatureId=e;let t=gM(this.focusController.current,this.bodyObjects),n=t?this.bodyObjects.get(t):void 0;n&&OM(n,e)}syncLandedNomenclature(){let e=this.focusController.current,t=(e?this.bodyObjects.get(e.data.id):void 0)?.isLanded?e.data.parentId:null;if(t===this.landedNomBodyId||(this.landedNomBodyId=t,!t))return;let n=this.ctx.getBody(t);n&&this.maybeLoadTexture(n)}clearUserPromoted(){this.focusController.promotion.clearUserPromoted()}focusedSeatConfigKey(){let e=this.focusController.current;if(!e||e.data.objectType!==W.SPACECRAFT&&!un(e))return null;let t=F_(e.data.parentId),n=t?this.bodyObjects.get(t):void 0;if(!n)return null;let r=n.terrainWindow;return`${r?`w${r.stepLevel}x${r.texWidth}@${r.centerTheta.toFixed(6)},${r.centerPhi.toFixed(6)}`:`u${n.currentSegments??128}`}|${n.displacementMap?.uuid??`none`}|${gw()}`}lastProbeTargetCheck=null;requestedProbeTargets=new Set;askedProbeRides=new Set;ensureFocusedProbeTarget(){let e=this.focusController.current,t=this.ctx.probeStore;if(!e||!t?.fitCenterUsable||e.data.orbitalSource!==U.SPICE_PROBE)return;this.askedProbeRides.has(e.data.id)||(this.askedProbeRides.add(e.data.id),hx(e.data.id).then(e=>e&&t.registerCarried(e)));let n=`${e.data.id}@${this.clock.jd}`;if(n===this.lastProbeTargetCheck)return;this.lastProbeTargetCheck=n;let r=t.stampedFitCenterAt(e.data.id,this.clock.jd);if(!r)return;let i=this.ctx.getBody(r);if(!i){if(this.requestedProbeTargets.has(r))return;this.requestedProbeTargets.add(r),this.ctx.ensureBody(r,Pg(this.clock.jd));return}this.focusController.promotion.ensureBodyObjects(i),this.focusController.syncUpgradeTargets(e)}applyJdUpdate(e=!1){this.ensureFocusedProbeTarget();let t=this.ctx.visibility.focusedSystemId,n=this.focusedSeatConfigKey(),r=this.ctx.probeStore?.version??0;if(this.clock.jd===this.lastUpdatedJd&&t===this.lastUpdatedSystemId&&n===this.lastSeatConfigKey&&r===this.lastProbeVersion){this.clock.seeked=!1;return}let i=this.clock.seeked;this.clock.seeked=!1,this.lastUpdatedJd=this.clock.jd,this.lastUpdatedSystemId=t,this.lastSeatConfigKey=n,this.lastProbeVersion=r,this.ctx.refreshTick(Pg(this.clock.jd)),this.focusController.promotion.onSimTimeChanged();let a=xI({jd:this.clock.jd,ctx:this.ctx,bodyObjects:this.bodyObjects,focus:this.focus,focusedBody:this.focusController.current,positionMap:this._positionMapScratch,diagnostics:this.positionDiagnostics,trailView:this.trailView(),frame:this.frameIndex,outOfRange:this.outOfRange});this.pointClouds.updateForJd(this.clock.jd,this.cloudViewInfo()),this.refreshTravelFocus(),performance.now()-this.focus.focusStartTime>=this.focus.focusDurationMs&&(this.repositionBodies(),this.pointClouds.maybeRebase()),this.syncLandedNomenclature();let o=a.focusedOutOfRange&&!this.focusWasOutOfRange;if(this.focusWasOutOfRange=a.focusedOutOfRange,e&&i&&o&&a.reanchorId){let e=this.ctx.getBody(a.reanchorId);e&&this.focusController.panCameraToBody(e)}}setReducedMotion(e){this.controls.dampingFactor=e?TR:wR}focusOnBody(e,t,n,r){return this.disarmLimits(),this.applyJdUpdate(),this.focusWasOutOfRange=!1,this.focusController.focusOnBody(e,t,n,r)}focusOnFeature(e,t,n,r=`frame`,i){this.disarmLimits(),this.applyJdUpdate(),this.focusWasOutOfRange=!1;let a=this.ctx.getBody(e.hostId);if(!a)return 0;this.focusController.clearPendingInitialView();let o=gM(this.focusController.current,this.bodyObjects)===e.hostId,s=Mw(e,t);this.ctx.bodies.focusFeature=s;let c=this.bodyObjects.get(a.data.id);this.selectedFeatureId=e.featureId,c&&OM(c,e.featureId),zw(s,a,c,this.clock.jd);let l=s.position,u=this.focusController.focusedBodyQuat(s);if(r===`pan`){let e=rC(this.focusController.cameraTruePos(),l,u);return this.callbacks.onCameraPosition?.(e.latitude,e.longitude,e.distance),this.focusController.setFocusTarget(s),this.focus.focusDurationMs}let d=l[0]-a.position[0],f=l[1]-a.position[1],p=l[2]-a.position[2],m=Math.hypot(d,f,p);m>1e-9?(d/=m,f/=m,p/=m):(d=0,f=1,p=0);let h=r===`snap`&&i?iC(l,i.latitude,i.longitude,i.zoom,u):[l[0]+d*n,l[1]+f*n,l[2]+p*n],g=rC(h,l,u);if(this.callbacks.onCameraPosition?.(g.latitude,g.longitude,g.distance),r===`snap`){this.focusController.setFocusTarget(s,h);let e=this.focus;return e.focusTruePos=[...l],e.focusOriginWorld=[...l],e.focusTargetWorld=[...l],e.focusStartTime=-OL,e.camOriginWorld=null,e.camTargetWorld=null,e.camTargetOffset=null,e.camOriginOffset=null,e.flyQ0=null,e.orbitFly=!1,e.arcOrbit=!1,e.cameraStaysOnBody=!1,this.repositionAll(),this.pointClouds.rebuildBasis(),this.camera.position.set(h[0]-l[0],h[1]-l[1],h[2]-l[2]),this.controls.update(),0}if(o){let e=this.focusController.cameraTruePos();this.focusController.setFocusTarget(s),this.focus.focusTruePos=[...l],this.camera.position.set(e[0]-l[0],e[1]-l[1],e[2]-l[2]),this.repositionAll(),this.pointClouds.rebuildBasis(),zL(this.focus,this.camera,e,h,jx().resolvedReducedMotion)}else this.focusController.setFocusTarget(s,h),this.focus.orbitFly=!0;return this.focus.focusDurationMs}pickFocusedModel(e,t){if(!this.overlayActive||!this.overlayModelBo()?.model)return null;this._pickNdc.set(e,t),this._modelRaycaster.setFromCamera(this._pickNdc,this.modelCamera);let n=null,r=1/0;for(let e of this.bodyObjects.values()){if(!e.model)continue;let t=this._modelRaycaster.intersectObject(e.model,!0);t.length>0&&t[0].distance<r&&(r=t[0].distance,n=e.body)}return n}overlayModelBo(){let e=this.focusController.current;if(!e){let e=this.travelFocus?.centerId,t=e?this.bodyObjects.get(e):void 0;return t?.model?t:null}let t=un(e)?e.featureAnchor.hostId:e.data.id,n=this.bodyObjects.get(t);if(n?.model)return n;if(e.data.orbitalSource===U.SPICE_PROBE&&!n?.isLanded){let t=this.bodyObjects.get(e.data.parentId);if(t?.model)return t}return null}snapToBodyFacing(e,t,n,r){this.disarmLimits(),this.focusController.snapToBodyFacing(e,t,n,r)}snapToBody(e,t,n,r){this.disarmLimits(),this.focusController.snapToBody(e,t,n,r)}setFocusTarget(e,t){this.disarmLimits(),this.applyJdUpdate(),this.focusWasOutOfRange=!1,this.focusController.setFocusTarget(e,t)}getFocusedBody(){return this.focusController.current}getDebugStats(){let t=this.fpsSamples,n=0;if(t.length>=2){let r=t.length<e.FPS_SAMPLE_FRAMES?0:this.fpsSampleHead,i=t[r],a=(t[(r-1+t.length)%t.length]-i)/1e3;a>0&&(n=(t.length-1)/a)}return $N({fps:n,orbitPool:this.pointClouds.orbitPool,renderer:this.renderer,bodyObjects:this.bodyObjects,focusedBody:this.focusController.current,cameraDistanceScene:this.getCameraState().distance})}setBodyAppearance(e,t){this.appearances.set(e,t)}setNorthReference(e){this.cameraUp.setNorthReference(e)}getFocusedPointing(){let e=this.focusController.current;if(!e)return null;let t=e.pointing??{primary:{axis:`-y`,target:`parent`}};return{supported:KD(e),base:t}}setFocusedPointing(e){let t=this.focusController.current;t&&(t.pointingOverride=e??void 0)}setPointingAxesVisible(e){this.showPointingAxes=e}buildPointingAxes(){let e=new za,t=new J(0,0,0),n=(n,r,i,a)=>{let o=new Gd(n,t,1,r,.22,.12);o.line.material.depthTest=!1,o.cone.material.depthTest=!1,o.renderOrder=999,e.add(o);let s=this.makeAxisLabel(i,a);s.position.copy(n).multiplyScalar(1.12),e.add(s)};return n(new J(1,0,0),16729156,`+X`,`#ff9999`),n(new J(-1,0,0),8930372,`-X`,`#cc7777`),n(new J(0,1,0),4521796,`+Y`,`#99ff99`),n(new J(0,-1,0),4491332,`-Y`,`#77cc77`),n(new J(0,0,1),4491519,`+Z`,`#99bbff`),n(new J(0,0,-1),4478344,`-Z`,`#7799cc`),e}makeAxisLabel(e,t){let n=document.createElement(`canvas`);n.width=n.height=128;let r=n.getContext(`2d`);r.font=`bold 72px sans-serif`,r.textAlign=`center`,r.textBaseline=`middle`,r.fillStyle=t,r.fillText(e,128/2,128/2);let i=new cs(new Jo({map:new Nc(n),depthTest:!1,transparent:!0}));return i.scale.setScalar(.175),i.renderOrder=1e3,i}sunIntensityScale=1;getSunIntensityScale(){return this.sunIntensityScale}setSunIntensityScale(e){this.sunIntensityScale=e}getFocusedAtmosphere(){let e=this.focusController.current?.data.id;if(!e)return null;let t=this.bodyObjects.get(e)?.atmosphere,n=gb(e);return!t||!n?null:{id:e,current:t.params,shipped:n}}setFocusedAtmosphereParams(e){let t=this.focusController.current?.data.id,n=t?this.bodyObjects.get(t)?.atmosphere:void 0;n&&EA(n,e)}getSkyboxAdjust(){return this.skyboxAdjuster.get()}setSkyboxAdjust(e,t,n){this.skyboxAdjuster.set(e,t,n)}setSkyDebugMarkersVisible(e){this.skyDebugMarkers.setVisible(e)}applyLayerChrome(){this.ctx.layers.isVisible(`stars`)?this.stashedSky&&=(this.scene.background=this.stashedSky,null):this.scene.background&&(this.stashedSky=this.scene.background,this.scene.background=null);let e=this.ctx.layers.isVisible(`labels`);e!==this.namesShown&&(this.namesShown=e,this.labelContainer.classList.toggle(`scene-overlay--no-names`,!e))}setHaloDebugVisible(e){this.haloDebug.setVisible(e)}setUserLocation(e,t){let n=this.bodyObjects.get(p_);n?.mesh&&(this.userLocationMarker&&bR(this.userLocationMarker),this.userLocationMarker=yR(n.mesh,n.radiusScene,e,t))}clearUserLocation(){this.userLocationMarker&&=(bR(this.userLocationMarker),null)}pause(){this.paused||(this.paused=!0,cancelAnimationFrame(this.rafId),this.rafId=0)}resume(){this.paused&&(this.paused=!1,this.invalidate(),this.tick())}setCovered(e){this.covered!==e&&(this.covered=e,e||this.invalidate())}isContextLost(){return this.renderer.getContext().isContextLost()}handleContextRestored(){this.renderer.setPixelRatio(Yx()),this.composer.setPixelRatio(Yx()),this.resize(this.canvas.clientWidth,this.canvas.clientHeight),dS(this.scene,this.renderer,this.ctx),this.resume()}recoverWorkersIfDead(e){return this.pointClouds.recoverWorkersIfDead(e)}applyRenderTier(){this.tier=Jx();let e=Yx();e!==this.renderer.getPixelRatio()&&(this.renderer.setPixelRatio(e),this.composer.setPixelRatio(e),this.resize(this.canvas.clientWidth,this.canvas.clientHeight)),this.pointClouds.setPointBudget(this.tier.pointBudget)}resize(e,t){this.invalidate(),this.viewportH=t||1,this.renderer.setSize(e,t,!1),this.composer.setSize(e,t);let n=this.renderer.getDrawingBufferSize(new q);this.atmoDepthPass.setSize(n.x,n.y),this.bloomPass.setSize(e*this.tier.bloomScale,t*this.tier.bloomScale),this.labelRenderer.setSize(e,t),this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.ctx.visibility.updateViewport(t),uT(e,t)}dispose(){cancelAnimationFrame(this.rafId),this.pointerInteraction.detach(),this.gpuPick.dispose(),this.controls.removeEventListener(`end`,this.onControlsEnd),this.controls.removeEventListener(`start`,this.invalidate),this.controls.removeEventListener(`start`,this.armLimits),this.controls.removeEventListener(`end`,this.invalidate);for(let t of e.INPUT_EVENTS)this.canvas.removeEventListener(t,this.invalidate);window.removeEventListener(`keydown`,this.invalidate),this.unsubscribeBodiesAdded?.(),this.controls.dispose(),this.haloDebug.dispose(),this.travelPath.dispose(),this.extensions.dispose();for(let e of this.bodyObjects.values())e.model&&aO(e);this.pointClouds.dispose(),this.disposeScene(this.scene),this.disposeScene(this.modelScene),BR(this.scene.background),BR(this.scene.environment),BR(this.modelScene.environment),this.circleTexture.dispose(),this.bodyObjects.clear(),this.composer.dispose(),this.atmoDepthPass.dispose(),this.renderer.dispose()}disposeScene(e){let t=new Set;e.traverse(e=>{let n=e;n.geometry?.dispose();let r=n.material,i=Array.isArray(r)?r:r?[r]:[];for(let e of i)if(!t.has(e)){t.add(e);for(let t of Object.values(e))BR(t);e.dispose()}})}};function BR(e){e&&typeof e==`object`&&e.isTexture&&e.dispose()}var VR=$e({progress:null,bootPending:!1}),HR=6371;function UR(e){let t=[];for(let n=0;n<128;n++){let r=Math.PI*(n/127)**2,i=Math.cos(r);t.push(1/(4*Math.PI)*(1-e*e)/(1+e*e-2*e*i)**1.5)}return[...t,...t,...t]}var WR={topAltitudeKm:67,rayleighScatterPerKm:[.0058,.0136,.0331],rayleighScaleHeightKm:8.4,mieScatterPerKm:[.004,.004,.004],mieAbsorptionPerKm:[4e-4,4e-4,4e-4],mieScaleHeightKm:1.2,miePhase:UR(.75),absorptionPerKm:[65e-5,.001881,85e-6],absorptionCenterKm:25,absorptionWidthKm:15,bakedCompensation:1,multiScatterGain:.3,sunIntensity:5,sunColor:[1,1,1]},GR=1.6,KR=1.0005,qR=new J(.55,.25,.8).normalize(),JR=[`low`,`medium`,`high`,`ultra`],YR=4,XR=12,ZR=10,QR=16,$R=5;function ez(e){return!e.limb&&!e.sky?NaN:Math.max(e.limb?.medianMs??0,e.sky?.medianMs??0)}function tz(e,t){let n=`low`;for(let r of e.tiers){let e=ez(r);!Number.isNaN(e)&&e<=t&&(n=r.tier)}return n}var nz=new Set([`WebKit WebGL`,`Mozilla`,``]);function rz(e){let t=e.getContext(),n=String(t.getParameter(t.RENDERER)??``);if(!nz.has(n))return n;let r=t.getExtension(`WEBGL_debug_renderer_info`);return r?String(t.getParameter(r.UNMASKED_RENDERER_WEBGL)):n}function iz(e,t){let n=e.getContext(),r=new qa,i=new sd(50,n.drawingBufferWidth/Math.max(n.drawingBufferHeight,1),.005,100),a=new mu({color:7829367,roughness:1,metalness:0}),o=new As(new ru(1,64,64),a);o.renderOrder=1,r.add(o);let s=new md(16777215,2);s.position.copy(qR),r.add(s);let c=WR,l=vA(c,1,HR),u=l.material.uniforms;u.uSunDir.value.copy(qR),u.uSunIntensity.value=c.sunIntensity,r.add(l.mesh);let d=e=>{let t=e===`sky`;t?(i.position.set(0,KR,0),i.lookAt(1,KR+.1,0)):(i.position.set(0,0,GR),i.lookAt(0,0,0)),l.material.side=+!!t,l.material.depthWrite=!t,l.material.depthTest=!t},f=new Uint8Array(4),p=()=>new Promise((e,n)=>requestAnimationFrame(()=>t?.aborted?n(Error(`benchmark aborted`)):e())),m=t=>{let a=performance.now();for(let n=0;n<t;n++)e.render(r,i);return n.readPixels(0,0,1,1,n.RGBA,n.UNSIGNED_BYTE,f),(performance.now()-a)/t};return{measure:async(e,t,{decideMs:n,onFrame:r}={})=>{TA(l,Pk[e]),d(t);let i=0;for(let e=0;e<YR;e++)r?.(`warmup`,e+1),await p(),i=m(1);let a=Math.min(QR,Math.max(1,Math.ceil(ZR/Math.max(i,.25)))),o=[],s=()=>{let e=[...o].sort((e,t)=>e-t);return{medianMs:e[Math.floor(e.length/2)],p75Ms:e[Math.floor(e.length*.75)]}};for(let e=0;e<XR;e++)if(r?.(`measure`,e+1),await p(),o.push(m(a)),n!==void 0&&o.length>=$R){let{medianMs:e,p75Ms:t}=s();if(e>n*1.4||t<n*.7)break}return{...s(),repeats:a}},dispose:()=>{r.remove(o,s,l.mesh),o.geometry.dispose(),a.dispose(),s.dispose(),kA(l)}}}function az(e,t,n,r){let i=e.getContext();return{tiers:t.map(e=>{let t=n.get(e)??null,i=r.get(e)??null;return{tier:e,limb:t,sky:i,skipped:!t&&!i}}),drawWidth:i.drawingBufferWidth,drawHeight:i.drawingBufferHeight}}async function oz(e,t){let n=t.tiers??JR,{budgetMs:r,signal:i,onProgress:a}=t,o=Math.max(0,n.indexOf(t.startTier??n[n.length-1])),s=iz(e,i),c=YR+XR,l=0,u=0,d=(e,t,i)=>s.measure(n[e],t,{decideMs:r,onFrame:(r,o)=>{if(!a)return;l++;let s=c-((r===`measure`?YR:0)+o)+i*c;u=Math.max(u,l/(l+s)),a({tier:n[e],tierIndex:e,tierCount:n.length,scenario:t,phase:r,frame:o,frames:r===`measure`?XR:YR,fraction:u})}}),f=new Map,p=new Map,m=async e=>{let t=n[e];if(Pk[t].insideView){let n=await d(e,`sky`,1);if(p.set(t,n),n.medianMs>r)return!1}let i=await d(e,`limb`,0);return f.set(t,i),i.medianMs<=r};try{if(await m(o))for(let e=o+1;e<n.length&&await m(e);e++);else for(let e=o-1;e>=1&&!await m(e);e--);}finally{s.dispose()}return az(e,n,f,p)}var sz=60,cz=100,lz=3e4,uz=25e4,dz=`v1`,fz=!1,pz=null,mz=Promise.resolve();function hz(e){let t=e.getContext(),n=Math.round(t.drawingBufferWidth*t.drawingBufferHeight/uz);return`${rz(e)}|${n}|${dz}`}function gz(){fz||typeof window>`u`||(fz=!0,VR.bootPending=!0,mz=new Promise(e=>{let t=()=>{VR.bootPending=!1,e()};setTimeout(t,lz),setTimeout(()=>void vz(!1).finally(t),cz)}))}function _z(){return mz}function vz(e){return pz??=yz(e).finally(()=>pz=null),pz}async function yz(e){let t=jx();if(!e&&(t.atmosphereQuality!==`auto`||!t.showAtmospheres))return;let n=null;try{n=new dh({canvas:document.createElement(`canvas`),antialias:!0}),n.setPixelRatio(Wx()),n.setSize(window.innerWidth,window.innerHeight,!1);let r=hz(n);if(!e&&t.atmosphereCalibration?.key===r)return;VR.progress=0;let i=await oz(n,{budgetMs:1e3/sz,startTier:Fk(),onProgress:e=>VR.progress=e.fraction}),a={};for(let e of i.tiers){let t=ez(e);Number.isNaN(t)||(a[e.tier]=Math.round(t*100)/100)}let o=tz(i,1e3/sz);t.setAtmosphereCalibration({key:r,tier:o,worstMs:a}),t.setAtmosphereAutoTier(null),console.info(`atmosphere calibration: ${o}`,a)}catch(e){console.warn(`atmosphere calibration failed, keeping heuristic tier`,e)}finally{VR.progress=null,n?.dispose(),n?.forceContextLoss()}}var bz=class{object=new za;element;label;anchor;occlude;wanted=!0;removeSelf=null;constructor(e,t){this.anchor=e.anchor,this.occlude=e.occlude??!1,this.element=e.element,this.label=new YO(e.element);let[n,r]=e.align??[.5,.5];this.label.center.set(n,r),this.object.add(this.label),this.object.matrixAutoUpdate=!1,Mk(e.element,t)}bind(e){this.removeSelf=e}setAnchor(e){this.anchor=e}setVisible(e){this.wanted=e}remove(){this.removeSelf?.(),this.removeSelf=null}update(e){let{jd:t,basis:n,ctx:r}=e,i=this.wanted?lR(this.anchor,r,t):null;if(!i){this.label.visible=!1;return}let a=i[0]-n[0],o=i[1]-n[1],s=i[2]-n[2];this.label.position.set(a,o,s),this.label.visible=this.occlude?this.facesCamera(i,e):!0,this.object.updateMatrixWorld(!0)}facesCamera(e,{camera:t,ctx:n}){let r=uR(this.anchor,e,n);if(!r)return!0;let{position:i}=this.label,a=t.position.x-i.x,o=t.position.y-i.y,s=t.position.z-i.z;return r[0]*a+r[1]*o+r[2]*s>0}dispose(){this.label.removeFromParent(),this.element.remove()}},xz=1e-9,Sz=class{object=new za;anchor;color;widthPx;opacity;fade;closed;local;count=0;mesh=null;scratch=new Float32Array;alphas=new Float32Array;capacity=0;lastOrigin=[0,0,0];dirty=!0;wanted=!0;removeSelf=null;constructor(e){this.anchor=e.anchor,this.color=e.color??`#ffffff`,this.widthPx=e.widthPx??2,this.opacity=e.opacity??1,this.fade=e.fade??!1,this.closed=e.closed??!1,this.local=new Float64Array,this.object.matrixAutoUpdate=!1,this.setPoints(e.points)}bind(e){this.removeSelf=e}setPoints(e){let t=e.length+(this.closed&&e.length>2?1:0);this.local.length<t*3&&(this.local=new Float64Array(t*3));for(let t=0;t<e.length;t++){let[n,r,i]=e[t];this.local[t*3]=Q(n),this.local[t*3+1]=Q(i),this.local[t*3+2]=Q(-r)}t>e.length&&this.local.copyWithin(e.length*3,0,3),this.count=t,t>this.capacity&&this.rebuild(t),this.fillAlphas(),this.dirty=!0}fillAlphas(){let e=this.count;for(let t=0;t<e;t++)this.alphas[t]=this.fade&&e>1?this.opacity*(1-t/(e-1)):this.opacity}setAnchor(e){this.anchor=e}setVisible(e){this.wanted=e}remove(){this.removeSelf?.(),this.removeSelf=null}update({jd:e,basis:t,camera:n,ctx:r}){let i=this.mesh;if(!i)return;let a=this.wanted&&this.count>=2?lR(this.anchor,r,e):null;if(i.visible=a!==null,!a)return;let o=[a[0]-t[0],a[1]-t[1],a[2]-t[2]];(this.dirty||Math.abs(o[0]-this.lastOrigin[0])>xz||Math.abs(o[1]-this.lastOrigin[1])>xz||Math.abs(o[2]-this.lastOrigin[2])>xz)&&(this.writeVertices(i,o),this.lastOrigin=o,this.dirty=!1),i.material.uniforms.uCenterOffset.value.copy(n.position).negate()}writeVertices(e,t){for(let e=0;e<this.count;e++)this.scratch[e*3]=this.local[e*3]+t[0],this.scratch[e*3+1]=this.local[e*3+1]+t[1],this.scratch[e*3+2]=this.local[e*3+2]+t[2];iN(e.geometry,this.scratch,this.alphas,this.alphas,this.count)}rebuild(e){this.disposeMesh(),this.dirty=!0,this.scratch=new Float32Array(e*3),this.alphas=new Float32Array(e);let t=sN(e,this.scratch,this.alphas,this.alphas,e,this.color,this.widthPx,1);t.frustumCulled=!1,this.object.add(t),this.mesh=t,this.capacity=e}disposeMesh(){let e=this.mesh;e&&(this.object.remove(e),e.geometry.dispose(),e.material.dispose(),this.mesh=null)}dispose(){this.disposeMesh()}};function Cz(e){let t=Math.hypot(e[0],e[1],e[2]),n=t>0?[e[0]/t,e[1]/t,e[2]/t]:[0,0,1],r=wz(Math.abs(n[2])<.9?[0,0,1]:[1,0,0],n),i=Math.hypot(r[0],r[1],r[2]),a=[r[0]/i,r[1]/i,r[2]/i];return[a,wz(n,a)]}function wz(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function Tz(e,t={}){let[n,r]=Cz(t.normal??[0,0,1]),i=Math.max(3,Math.round(t.steps??128)),a=[];for(let t=0;t<i;t++){let o=2*Math.PI*t/i,s=Math.cos(o)*e,c=Math.sin(o)*e;a.push([n[0]*s+r[0]*c,n[1]*s+r[1]*c,n[2]*s+r[2]*c])}return a}function Ez(e){if(e.length<3)return[];let[t,n]=Cz(Dz(e)),r=e.map(e=>new q(e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[0]*n[0]+e[1]*n[1]+e[2]*n[2]));return Xl.triangulateShape(r,[]).flat()}function Dz(e){let t=0,n=0,r=0;for(let i=0;i<e.length;i++){let a=e[i],o=e[(i+1)%e.length];t+=(a[1]-o[1])*(a[2]+o[2]),n+=(a[2]-o[2])*(a[0]+o[0]),r+=(a[0]-o[0])*(a[1]+o[1])}return Math.hypot(t,n,r)>0?[t,n,r]:[0,0,1]}function Oz(e,t,n){let r=Math.min(1,Math.max(-1,e[0]*t[0]+e[1]*t[1]+e[2]*t[2])),i=Math.acos(r);if(i<1e-9||Math.PI-i<1e-9)return kz([e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]);let a=Math.sin(i),o=Math.sin((1-n)*i)/a,s=Math.sin(n*i)/a;return[e[0]*o+t[0]*s,e[1]*o+t[1]*s,e[2]*o+t[2]*s]}function kz(e){let t=Math.hypot(e[0],e[1],e[2]);return t>0?[e[0]/t,e[1]/t,e[2]/t]:[0,0,1]}function Az(e,t){let n=0,r=0,i=0;for(let a=0;a<t;a++)n+=e[a*3],r+=e[a*3+1],i+=e[a*3+2];return Math.hypot(n,r,i)<1e-9?[e[0],e[1],e[2]]:kz([n,r,i])}function jz(e,t){return new fu({transparent:!0,depthWrite:!1,side:2,uniforms:{uColor:{value:new X(e)},uOpacity:{value:t},uCenterOffset:{value:new J}},vertexShader:`
|
|
5519
|
+
`;let i=document.createElement(`span`);return i.textContent=e.label,i.style.color=e.color,i.style.marginInlineStart=`2px`,t.appendChild(n),t.appendChild(i),t}function VN(e,t,n,r,i){let a=new J().crossVectors(t,e).normalize(),o=new Float32Array(i*3),s=new J;for(let t=0;t<i;t++){let r=t/i*Math.PI*2,c=Math.cos(r),l=Math.sin(r);s.copy(e).multiplyScalar(c).addScaledVector(a,l).multiplyScalar(n),o[t*3]=s.x,o[t*3+1]=s.y,o[t*3+2]=s.z}let c=new Ho;c.setAttribute(`position`,new Ao(o,3));let l=new wc(c,new dc({color:r,transparent:!0,opacity:.55}));return l.frustumCulled=!1,l}function HN(){let e=new za;e.name=`sky-debug-markers`,e.visible=!1;let t=new J;for(let n of MN){zN(n.raDeg,n.decDeg,t).multiplyScalar(jN);let r=new $O(BN(n));r.center.set(0,.5),r.position.copy(t),e.add(r)}for(let t of RN){let n=VN(t.zero,t.pole,jN*.999,t.color,LN);n.name=t.name,e.add(n)}return e}function UN(e){e.traverse(e=>{e instanceof $O&&e.element.remove(),e instanceof wc&&(e.geometry.dispose(),e.material.dispose())}),e.parent?.remove(e)}var WN=class{group=null;constructor(e){this.scene=e}setVisible(e){e?(this.group||(this.group=HN(),this.scene.add(this.group)),this.group.visible=!0):this.group&&=(UN(this.group),null)}},GN=new J,KN=new J,qN=new J,JN=[GN,KN,qN];function YN(e,t,n){return GN.set(1,0,0).applyQuaternion(e).transformDirection(t),KN.set(0,1,0).applyQuaternion(e).transformDirection(t),qN.set(0,0,1).applyQuaternion(e).transformDirection(t),{e:JN,a:n}}function XN(e,t,n,r,i,a,o,s,c,l){let u=1/i;e.gxx=u,e.gxy=0,e.gxz=0,e.gyx=0,e.gyy=u,e.gyz=0,e.gzx=0,e.gzy=0,e.gzz=u,e.cpx=t*u,e.cpy=n*u,e.cpz=r*u,e.K=(t*t+n*n+r*r)*u*u-1,e.cx0=o,e.cy0=s,e.f=a,e.id=c,e.dist=l,e.ccx=t,e.ccy=n,e.ccz=r}function ZN(e,t,n,r,i,a,o,s,c,l){let[u,d,f]=i.e,[p,m,h]=i.a;e.gxx=u.x/p,e.gxy=u.y/p,e.gxz=u.z/p,e.gyx=d.x/m,e.gyy=d.y/m,e.gyz=d.z/m,e.gzx=f.x/h,e.gzy=f.y/h,e.gzz=f.z/h;let g=(t*u.x+n*u.y+r*u.z)/p,_=(t*d.x+n*d.y+r*d.z)/m,v=(t*f.x+n*f.y+r*f.z)/h;e.cpx=g,e.cpy=_,e.cpz=v,e.K=g*g+_*_+v*v-1,e.cx0=o,e.cy0=s,e.f=a,e.id=c,e.dist=l,e.ccx=t,e.ccy=n,e.ccz=r}function QN(e,t,n,r,i,a){let[o,s,c]=r.e,[l,u,d]=r.a,f=1/(l*l),p=1/(u*u),m=1/(d*d),h=f*o.x*o.x+p*s.x*s.x+m*c.x*c.x,g=f*o.x*o.y+p*s.x*s.y+m*c.x*c.y,_=f*o.x*o.z+p*s.x*s.z+m*c.x*c.z,v=f*o.y*o.y+p*s.y*s.y+m*c.y*c.y,y=f*o.y*o.z+p*s.y*s.z+m*c.y*c.z,b=f*o.z*o.z+p*s.z*s.z+m*c.z*c.z,x=h*e+g*t+_*n,S=g*e+v*t+y*n,C=_*e+y*t+b*n,w=e*x+t*S+n*C-1,T=i,E=w*h-x*x,D=2*(w*g-x*S),O=w*v-S*S,k=-2*T*(w*_-x*C),A=-2*T*(w*y-S*C),j=4*E*O-D*D,M=(-2*O*k+D*A)/j,ee=(-2*E*A+D*k)/j,N=-n/T;a.ox=M*N-e,a.oy=ee*N-t}var $N=class{canvas=null;gfx=null;tmp=new J;tmpQ=new Hi;items=[];one=[];labelRect={x:0,left:0,right:0,y:0,h:0};constructor(e){this.anchor=e}get active(){return this.canvas!==null}setVisible(e){if(e){if(this.canvas)return;let e=document.createElement(`canvas`);e.style.cssText=`position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:5`,this.anchor.parentElement?.appendChild(e),this.canvas=e,this.gfx=e.getContext(`2d`)}else this.canvas&&(this.canvas.remove(),this.canvas=null,this.gfx=null)}draw(e,t,n,r,i,a){let o=this.gfx,s=this.canvas;if(!o||!s)return;let c=window.devicePixelRatio||1,l=Math.round(i*c),u=Math.round(a*c);(s.width!==l||s.height!==u)&&(s.width=l,s.height=u),o.setTransform(c,0,0,c,0,0),o.clearRect(0,0,i,a),o.font=`10px monospace`,o.textBaseline=`middle`;let d=t.fov*Math.PI/180,f=a/(2*Math.tan(d/2)),p=t.matrixWorldInverse,[m,h,g]=n,_=i*.5,v=a*.5,y=0;for(let o of e.values()){let{label:e,group:s,radiusScene:c}=o;if(!e||c<=0)continue;let[l,u,d]=o.body.position;this.tmp.set(l-m,u-h,d-g).applyMatrix4(p);let b=this.tmp.x,x=this.tmp.y,S=this.tmp.z;if(S>=0||b*b+x*x+S*S<=c*c)continue;let C=tk(this.items,y++,eP),w=!!(o.semiAxesScene&&o.mesh);if(w){let e=YN(o.mesh.getWorldQuaternion(this.tmpQ),p,o.semiAxesScene);C.e0.copy(e.e[0]),C.e1.copy(e.e[1]),C.e2.copy(e.e[2]),C.sa[0]=e.a[0],C.sa[1]=e.a[1],C.sa[2]=e.a[2],ZN(C.occ,b,x,S,e,f,_,v,o.body.data.id,o.cachedDist)}else C.e0.set(1,0,0),C.e1.set(0,1,0),C.e2.set(0,0,1),C.sa[0]=C.sa[1]=C.sa[2]=c,XN(C.occ,b,x,S,c,f,_,v,o.body.data.id,o.cachedDist);let T=S*S-c*c,E=T<=0,D=E?0:c*f/Math.sqrt(T),O=E||D>=16;this.tmp.set(l-m,u-h,d-g).project(t),C.cx=(this.tmp.x*.5+.5)*i,C.cy=(-this.tmp.y*.5+.5)*a,pk(o,t,n,i,a,this.labelRect),C.hx=this.labelRect.x,C.hy=this.labelRect.y,C.id=o.body.data.id,C.camX=b,C.camY=x,C.camZ=S,C.worldR=c,C.dist=o.cachedDist,C.isEllipsoid=w,C.degenerate=E,C.isOccluder=O,C.meshHidden=!s.visible,C.labelVisible=e.visible,C.maximized=o.labelMaximized!==!1,C.focused=o.body.data.id===r,C.occludedBy=-1}for(let e=0;e<y;e++){let t=this.items[e];for(let e=0;e<y;e++){let n=this.items[e];if(!(!n.isOccluder||n.id===t.id)&&(this.one[0]=n.occ,this.one.length=1,dk(t.hx,t.hy,t.dist,t.id,this.one))){t.occludedBy=e;break}}}for(let e=0;e<y;e++){let n=this.items[e];if(n.meshHidden&&!n.isOccluder)continue;let r=n.focused?`#7dff7d`:n.isOccluder?`#ff8c1a`:n.labelVisible?n.maximized?`#1ae5ff`:`#ffe11a`:`#ff3b3b`;if(o.beginPath(),n.meshHidden&&o.setLineDash([5,4]),this.strokeLimb(o,n,t,i,a)&&(o.strokeStyle=r,o.lineWidth=n.isOccluder?2:1,o.stroke(),n.isOccluder&&(o.fillStyle=`rgba(255,140,26,0.08)`,o.fill())),o.setLineDash([]),!n.degenerate){let e=n.hx-n.cx,t=n.hy-n.cy;if(e*e+t*t>1&&(o.beginPath(),o.moveTo(n.cx,n.cy),o.lineTo(n.hx,n.hy),o.strokeStyle=`rgba(255,225,26,0.5)`,o.lineWidth=1,o.stroke(),rP(o,n.cx,n.cy,4,`#ff3ad1`)),n.occludedBy>=0){let e=this.items[n.occludedBy];o.beginPath(),o.setLineDash([4,3]),o.moveTo(n.hx,n.hy),o.lineTo(e.cx,e.cy),o.strokeStyle=`rgba(255,59,59,0.9)`,o.lineWidth=1,o.stroke(),o.setLineDash([])}o.beginPath(),o.arc(n.hx,n.hy,1.5,0,Math.PI*2),o.fillStyle=r,o.fill(),o.fillStyle=`rgba(255,255,255,0.85)`,o.fillText(n.id,n.hx+8,n.hy)}}nP(o,a)}strokeLimb(e,t,n,r,i){let{camX:a,camY:o,camZ:s,e0:c,e1:l,e2:u,sa:d}=t,f=(a*c.x+o*c.y+s*c.z)/d[0],p=(a*l.x+o*l.y+s*l.z)/d[1],m=(a*u.x+o*u.y+s*u.z)/d[2],h=f*f+p*p+m*m;if(h<=1)return!1;let g=Math.sqrt(h),_=(h-1)/h,v=Math.sqrt(h-1)/g,y=f*_,b=p*_,x=m*_,S=f/g,C=p/g,w=m/g,T=0,E=1;Math.abs(w)>.9&&(T=1,E=0);let D=C*E-w*0,O=w*T-S*E,k=S*0-C*T,A=Math.hypot(D,O,k)||1;D/=A,O/=A,k/=A;let j=C*k-w*O,M=w*D-S*k,ee=S*O-C*D,N=n.projectionMatrix.elements,te=!1;for(let t=0;t<=72;t++){let n=t/72*Math.PI*2,a=Math.cos(n),o=Math.sin(n),s=y+v*(a*D+o*j),f=b+v*(a*O+o*M),p=x+v*(a*k+o*ee),m=d[0]*s*c.x+d[1]*f*l.x+d[2]*p*u.x,h=d[0]*s*c.y+d[1]*f*l.y+d[2]*p*u.y,g=d[0]*s*c.z+d[1]*f*l.z+d[2]*p*u.z,_=N[3]*m+N[7]*h+N[11]*g+N[15];if(_<=1e-6){te=!1;continue}let S=(N[0]*m+N[4]*h+N[8]*g+N[12])/_,C=(N[1]*m+N[5]*h+N[9]*g+N[13])/_,w=(S*.5+.5)*r,T=(-C*.5+.5)*i;te?e.lineTo(w,T):(e.moveTo(w,T),te=!0)}return!0}dispose(){this.setVisible(!1)}};function eP(){return{id:``,camX:0,camY:0,camZ:0,worldR:0,e0:new J,e1:new J,e2:new J,sa:[0,0,0],occ:ak(),cx:0,cy:0,hx:0,hy:0,dist:0,isEllipsoid:!1,isOccluder:!1,degenerate:!1,meshHidden:!1,labelVisible:!1,maximized:!1,focused:!1,occludedBy:-1}}var tP=[[`#1ae5ff`,`label shown`],[`#ffe11a`,`dimmed`],[`#ff3b3b`,`hidden`],[`#ff8c1a`,`occluder silhouette`],[`#7dff7d`,`focused`]];function nP(e,t){let n=t-8-(tP.length-1)*13;e.font=`10px monospace`,e.textBaseline=`middle`;for(let[t,r]of tP)e.fillStyle=t,e.fillRect(8,n-4,8,8),e.fillStyle=`rgba(255,255,255,0.9)`,e.fillText(r,20,n),n+=13}function rP(e,t,n,r,i){e.strokeStyle=i,e.lineWidth=1,e.beginPath(),e.moveTo(t-r,n),e.lineTo(t+r,n),e.moveTo(t,n-r),e.lineTo(t,n+r),e.stroke()}function iP(e){let{fps:t,orbitPool:n,renderer:r,bodyObjects:i,focusedBody:a,cameraDistanceScene:o}=e,s=r.info;return{fps:t,workers:n.workerCount,workerGroups:n.groupCount,drawCalls:s.render.calls,triangles:s.render.triangles,geometries:s.memory.geometries,textures:s.memory.textures,programs:s.programs?.length??0,promotedBodies:i.size,focusedId:a?.data.id,focusedName:a?.data.name??void 0,cameraDistanceAU:o/10,viewportW:r.domElement.clientWidth,viewportH:r.domElement.clientHeight,pixelRatio:r.getPixelRatio()}}var aP="function e(e,t,n=1e-10,r=50){let i=e;for(let a=0;a<r;a++){let r=(i-t*Math.sin(i)-e)/(1-t*Math.cos(i));if(i-=Math.max(-1,Math.min(1,r)),Math.abs(r)<n)break}return i}function t(e,t,n=1e-10,r=50){if(e===0)return 0;let i=e<0?-1:1,a=Math.abs(e),o=0,s=1;for(;t*Math.sinh(s)-s<a;)if(s*=2,s>700)return NaN;let c=.5*(o+s);for(let e=0;e<r;e++){let e=t*Math.sinh(c)-c-a;e>0?s=c:o=c;let r=c-e/(t*Math.cosh(c)-1);r>o&&r<s||(r=.5*(o+s));let i=Math.abs(r-c);if(c=r,i<n)break}return i*c}function n(e,t,n){let r=.01720209895*(n-t)/(Math.sqrt(2)*e**1.5),i=Math.cbrt(3*r+Math.sqrt(1+9*r*r)),a=i-1/i,o=2*Math.atan(a),s=e*(1+a*a);return!isFinite(o)||!isFinite(s)||s<=0?null:{nu:o,r:s}}const r=149597870.7,i=23.4392911;86400**2/r**3,1/r,Math.cos(Math.PI/180*i),Math.sin(Math.PI/180*i);const a=Math.PI,o=a*2,s=a/180;180/a;const c=6378.135,l=60/Math.sqrt(c*c*c/398600.8),u=c*l/60,d=1/l,f=.001082616,p=-253881e-11/f,m=2/3,ee=1440/(2*a);function te(e,t){let n=[31,e%4==0?29:28,31,30,31,30,31,31,30,31,30,31],r=Math.floor(t),i=1,a=0;for(;r>a+n[i-1]&&i<12;)a+=n[i-1],i+=1;let o=i,s=r-a,c=(t-r)*24,l=Math.floor(c);c=(c-l)*60;let u=Math.floor(c);return{mon:o,day:s,hr:l,minute:u,sec:(c-u)*60}}function h(e,t,n,r,i,a,o=0){return 367*e-Math.floor(7*(e+Math.floor((t+9)/12))*.25)+Math.floor(275*t/9)+n+1721013.5+((o/6e4+a/60+i)/60+r)/24}function g(e,t,n,r,i,a,o=0){if(e instanceof Date){let t=e;return h(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())}return h(e,t,n,r,i,a,o)}function ne(e,t){let{e3:n,ee2:r,peo:i,pgho:s,pho:c,pinco:l,plo:u,se2:d,se3:f,sgh2:p,sgh3:m,sgh4:ee,sh2:te,sh3:h,si2:g,si3:ne,sl2:_,sl3:v,sl4:y,t:b,xgh2:re,xgh3:ie,xgh4:x,xh2:ae,xh3:S,xi2:C,xi3:w,xl2:T,xl3:E,xl4:D,zmol:O,zmos:k}=e,{init:A,opsmode:j}=t,{ep:oe,inclp:M,nodep:N,argpp:se,mp:P}=t,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,le,Y,ue,de,X,fe;fe=k+119459e-10*b,A===`y`&&(fe=k),X=fe+2*.01675*Math.sin(fe),Y=Math.sin(X),U=.5*Y*Y-.25,W=-.5*Y*Math.cos(X);let pe=d*U+f*W,me=g*U+ne*W,he=_*U+v*W+y*Y,ge=p*U+m*W+ee*Y,Z=te*U+h*W;fe=O+.00015835218*b,A===`y`&&(fe=O),X=fe+2*.0549*Math.sin(fe),Y=Math.sin(X),U=.5*Y*Y-.25,W=-.5*Y*Math.cos(X);let _e=r*U+n*W,ve=C*U+w*W,ye=T*U+E*W+D*Y,be=re*U+ie*W+x*Y,xe=ae*U+S*W;return G=pe+_e,J=me+ve,le=he+ye,K=ge+be,q=Z+xe,A===`n`&&(G-=i,J-=l,le-=u,K-=s,q-=c,M+=J,oe+=G,R=Math.sin(M),L=Math.cos(M),M>=.2?(q/=R,K-=L*q,se+=K,N+=q,P+=le):(z=Math.sin(N),ce=Math.cos(N),F=R*z,I=R*ce,B=q*ce+J*L*z,V=-q*z+J*L*ce,F+=B,I+=V,N%=o,N<0&&j===`a`&&(N+=o),ue=P+se+L*N,H=le+K-J*N*R,ue+=H,de=N,N=Math.atan2(F,I),N<0&&j===`a`&&(N+=o),Math.abs(de-N)>a&&(N<de?N+=o:N-=o),P+=le,se=ue-P-L*N)),{ep:oe,inclp:M,nodep:N,argpp:se,mp:P}}function _(e){let{epoch:t,ep:n,argpp:r,tc:i,inclp:a,nodep:s,np:c}=e,l,u,d,f,p,m,ee,te,h,g,ne,_,v,y,b,re,ie,x,ae,S,C,w,T,E,D,O,k,A,j,oe,M,N,se,P,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,le,Y,ue,de,X,fe,pe,me,he,ge,Z,_e,ve,ye,be=.01675,xe=.0549,Se=c,Ce=n,we=Math.sin(s),Te=Math.cos(s),Ee=Math.sin(r),Q=Math.cos(r),De=Math.sin(a),Oe=Math.cos(a),$=Ce*Ce,ke=1-$,Ae=Math.sqrt(ke),je=t+18261.5+i/1440,Me=(4.523602-.00092422029*je)%o,Ne=Math.sin(Me),Pe=Math.cos(Me),Fe=.91375164-.03568096*Pe,Ie=Math.sqrt(1-Fe*Fe),Le=.089683511*Ne/Ie,Re=Math.sqrt(1-Le*Le),ze=5.8351514+.001944368*je,Be=.39785416*Ne/Ie,Ve=Re*Pe+.91744867*Le*Ne;Be=Math.atan2(Be,Ve),Be+=ze-Me;let He=Math.cos(Be),Ue=Math.sin(Be);S=.1945905,C=-.98088458,E=.91744867,D=.39785416,w=Te,T=we,ne=29864797e-13;let We=1/Se,Ge=0;for(;Ge<2;)Ge+=1,l=S*w+C*E*T,d=-C*w+S*E*T,ee=-S*T+C*E*w,te=C*D,h=C*T+S*E*w,g=S*D,u=Oe*ee+De*te,f=Oe*h+De*g,p=-De*ee+Oe*te,m=-De*h+Oe*g,_=l*Q+u*Ee,v=d*Q+f*Ee,y=-l*Ee+u*Q,b=-d*Ee+f*Q,re=p*Ee,ie=m*Ee,x=p*Q,ae=m*Q,_e=12*_*_-3*y*y,ve=24*_*v-6*y*b,ye=12*v*v-3*b*b,ue=3*(l*l+u*u)+_e*$,de=6*(l*d+u*f)+ve*$,X=3*(d*d+f*f)+ye*$,fe=-6*l*p+$*(-24*_*x-6*y*re),pe=-6*(l*m+d*p)+$*(-24*(v*x+_*ae)+-6*(y*ie+b*re)),me=-6*d*m+$*(-24*v*ae-6*b*ie),he=6*u*p+$*(24*_*re-6*y*x),ge=6*(f*p+u*m)+$*(24*(v*re+_*ie)-6*(b*x+y*ae)),Z=6*f*m+$*(24*v*ie-6*b*ae),ue=ue+ue+ke*_e,de=de+de+ke*ve,X=X+X+ke*ye,K=ne*We,G=-.5*K/Ae,q=K*Ae,W=-15*Ce*q,J=_*y+v*b,le=v*y+_*b,Y=v*b-_*y,Ge===1&&(O=W,k=G,A=K,j=q,oe=J,M=le,N=Y,se=ue,P=de,F=X,I=fe,L=pe,R=me,ce=he,z=ge,B=Z,V=_e,H=ve,U=ye,S=He,C=Ue,E=Fe,D=Ie,w=Re*Te+Le*we,T=we*Re-Te*Le,ne=4.7968065e-7);let Ke=(4.7199672+(.2299715*je-ze))%o,qe=(6.2565837+.017201977*je)%o,Je=2*O*M,Ye=2*O*N,Xe=2*k*L,Ze=2*k*(R-I),Qe=-2*A*P,$e=-2*A*(F-se),et=-2*A*(-21-9*$)*be,tt=2*j*H,nt=2*j*(U-V),rt=-18*j*be,it=-2*k*z,at=-2*k*(B-ce),ot=2*W*le,st=2*W*Y,ct=2*G*pe,lt=2*G*(me-fe),ut=-2*K*de,dt=-2*K*(X-ue),ft=-2*K*(-21-9*$)*xe,pt=2*q*ve,mt=2*q*(ye-_e),ht=-18*q*xe,gt=-2*G*ge,_t=-2*G*(Z-he);return{snodm:we,cnodm:Te,sinim:De,cosim:Oe,sinomm:Ee,cosomm:Q,day:je,e3:st,ee2:ot,em:Ce,emsq:$,gam:ze,peo:0,pgho:0,pho:0,pinco:0,plo:0,rtemsq:Ae,se2:Je,se3:Ye,sgh2:tt,sgh3:nt,sgh4:rt,sh2:it,sh3:at,si2:Xe,si3:Ze,sl2:Qe,sl3:$e,sl4:et,s1:W,s2:G,s3:K,s4:q,s5:J,s6:le,s7:Y,ss1:O,ss2:k,ss3:A,ss4:j,ss5:oe,ss6:M,ss7:N,sz1:se,sz2:P,sz3:F,sz11:I,sz12:L,sz13:R,sz21:ce,sz22:z,sz23:B,sz31:V,sz32:H,sz33:U,xgh2:pt,xgh3:mt,xgh4:ht,xh2:gt,xh3:_t,xi2:ct,xi3:lt,xl2:ut,xl3:dt,xl4:ft,nm:Se,z1:ue,z2:de,z3:X,z11:fe,z12:pe,z13:me,z21:he,z22:ge,z23:Z,z31:_e,z32:ve,z33:ye,zmol:Ke,zmos:qe}}function v(e){let{cosim:t,argpo:n,s1:r,s2:i,s3:s,s4:c,s5:u,sinim:d,ss1:f,ss2:p,ss3:ee,ss4:te,ss5:h,sz1:g,sz3:ne,sz11:_,sz13:v,sz21:y,sz23:b,sz31:re,sz33:ie,t:x,tc:ae,gsto:S,mo:C,mdot:w,no:T,nodeo:E,nodedot:D,xpidot:O,z1:k,z3:A,z11:j,z13:oe,z21:M,z23:N,z31:se,z33:P,ecco:F,eccsq:I}=e,{emsq:L,em:R,argpm:ce,inclm:z,mm:B,nm:V,nodem:H,irez:U,atime:W,d2201:G,d2211:K,d3210:q,d3222:J,d4410:le,d4422:Y,d5220:ue,d5232:de,d5421:X,d5433:fe,dedt:pe,didt:me,dmdt:he,dnodt:ge,domdt:Z,del1:_e,del2:ve,del3:ye,xfact:be,xlamo:xe,xli:Se,xni:Ce}=e,we,Te,Ee,Q,De,Oe,$,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,et=.0043752690880113,tt=.00015835218,nt=119459e-10;U=0,V<.0052359877&&V>.0034906585&&(U=1),V>=.00826&&V<=.00924&&R>=.5&&(U=2);let rt=f*nt*h,it=p*nt*(_+v),at=-nt*ee*(g+ne-14-6*L),ot=te*nt*(re+ie-6),st=-nt*p*(y+b);(z<.052359877||z>a-.052359877)&&(st=0),d!==0&&(st/=d);let ct=ot-t*st;pe=rt+r*tt*u,me=it+i*tt*(j+oe),he=at-tt*s*(k+A-14-6*L);let lt=c*tt*(se+P-6),ut=-tt*i*(M+N);(z<.052359877||z>a-.052359877)&&(ut=0),Z=ct+lt,ge=st,d!==0&&(Z-=t/d*ut,ge+=ut/d);let dt=(S+ae*et)%o;if(R+=pe*x,z+=me*x,ce+=Z*x,H+=ge*x,B+=he*x,U!==0){if(Ze=(V/l)**m,U===2){Qe=t*t;let e=R;R=F;let n=L;L=I,$e=R*L,Fe=-.306-(R-.64)*.44,R<=.65?(Ie=3.616-13.247*R+16.29*L,Re=-19.302+117.39*R-228.419*L+156.591*$e,ze=-18.9068+109.7927*R-214.6334*L+146.5816*$e,Be=-41.122+242.694*R-471.094*L+313.953*$e,Ve=-146.407+841.88*R-1629.014*L+1083.435*$e,He=-532.114+3017.977*R-5740.032*L+3708.276*$e):(Ie=-72.099+331.819*R-508.738*L+266.724*$e,Re=-346.844+1582.851*R-2415.925*L+1246.113*$e,ze=-342.585+1554.908*R-2366.899*L+1215.972*$e,Be=-1052.797+4758.686*R-7193.992*L+3651.957*$e,Ve=-3581.69+16178.11*R-24462.77*L+12422.52*$e,He=R>.715?-5149.66+29936.92*R-54087.36*L+31324.56*$e:1464.74-4664.75*R+3763.64*L),R<.7?(Ge=-919.2277+4988.61*R-9064.77*L+5542.21*$e,Ue=-822.71072+4568.6173*R-8491.4146*L+5337.524*$e,We=-853.666+4690.25*R-8624.77*L+5341.4*$e):(Ge=-37995.78+161616.52*R-229838.2*L+109377.94*$e,Ue=-51752.104+218913.95*R-309468.16*L+146349.42*$e,We=-40023.88+170470.89*R-242699.48*L+115605.82*$e),Ke=d*d,we=.75*(1+2*t+Qe),Te=1.5*Ke,Q=1.875*d*(1-2*t-3*Qe),De=-1.875*d*(1+2*t-3*Qe),$=35*Ke*we,ke=39.375*Ke*Ke,Ae=9.84375*d*(Ke*(1-2*t-5*Qe)+.33333333*(-2+4*t+6*Qe)),je=d*(4.92187512*Ke*(-2-4*t+10*Qe)+6.56250012*(1+2*t-3*Qe)),Me=29.53125*d*(2-8*t+Qe*(-12+8*t+10*Qe)),Ne=29.53125*d*(-2-8*t+Qe*(12+8*t-10*Qe)),Ye=V*V,Xe=Ze*Ze,Je=3*Ye*Xe,qe=Je*17891679e-13,G=qe*we*Fe,K=qe*Te*Ie,Je*=Ze,qe=Je*3.7393792e-7,q=qe*Q*Re,J=qe*De*ze,Je*=Ze,qe=2*Je*7.3636953e-9,le=qe*$*Be,Y=qe*ke*Ve,Je*=Ze,qe=Je*1.1428639e-7,ue=qe*Ae*He,de=qe*je*We,qe=2*Je*2.1765803e-9,X=qe*Me*Ue,fe=qe*Ne*Ge,xe=(C+E+E-(dt+dt))%o,be=w+he+2*(D+ge-et)-T,R=e,L=n}U===1&&(Pe=1+L*(-2.5+.8125*L),Re=1+2*L,Le=1+L*(-6+6.60937*L),we=.75*(1+t)*(1+t),Ee=.9375*d*d*(1+3*t)-.75*(1+t),Oe=1+t,Oe*=1.875*Oe*Oe,_e=3*V*V*Ze*Ze,ve=2*_e*we*Pe*17891679e-13,ye=3*_e*Oe*Le*2.2123015e-7*Ze,_e=_e*Ee*Re*21460748e-13*Ze,xe=(C+E+n-dt)%o,be=w+O+he+Z+ge-(T+et)),Se=xe,Ce=T,W=0,V=T+0}return{em:R,argpm:ce,inclm:z,mm:B,nm:V,nodem:H,irez:U,atime:W,d2201:G,d2211:K,d3210:q,d3222:J,d4410:le,d4422:Y,d5220:ue,d5232:de,d5421:X,d5433:fe,dedt:pe,didt:me,dmdt:he,dndt:0,dnodt:ge,domdt:Z,del1:_e,del2:ve,del3:ye,xfact:be,xlamo:xe,xli:Se,xni:Ce}}function y(e){let t=(e-2451545)/36525,n=-62e-7*t*t*t+.093104*t*t+3164400184.812866*t+67310.54841;return n=n*s/240%o,n<0&&(n+=o),n}function b(e,t,n,r,i,a,o){return e instanceof Date?y(g(e)):y(t===void 0?e:g(e,t,n,r,i,a,o))}function re(e){let{ecco:t,epoch:n,inclo:r,opsmode:i}=e,{no:a}=e,s=t*t,c=1-s,u=Math.sqrt(c),d=Math.cos(r),p=d*d,ee=(l/a)**m,te=.75*f*(3*p-1)/(u*c),h=te/(ee*ee),g=ee*(1-h*h-h*(1/3+134*h*h/81));h=te/(g*g),a/=1+h;let ne=(l/a)**m,_=Math.sin(r),v=ne*c,y=1-5*p,re=-y-p-p,ie=1/ne,x=v*v,ae=ne*(1-t),S;if(i===`a`){let e=n-7305,t=Math.floor(e+1e-8),r=e-t,i=.017202791694070362,a=i+o;S=(1.7321343856509375+i*t+a*r+e*e*5075514194322695e-30)%o,S<0&&(S+=o)}else S=b(n+2433281.5);return{no:a,method:`n`,ainv:ie,ao:ne,con41:re,con42:y,cosio:d,cosio2:p,eccsq:s,omeosq:c,posq:x,rp:ae,rteosq:u,sinio:_,gsto:S}}function ie(e){let{irez:t,d2201:n,d2211:r,d3210:i,d3222:a,d4410:s,d4422:c,d5220:l,d5232:u,d5421:d,d5433:f,dedt:p,del1:m,del2:ee,del3:te,didt:h,dmdt:g,dnodt:ne,domdt:_,argpo:v,argpdot:y,t:b,tc:re,gsto:ie,xfact:x,xlamo:ae,no:S}=e,{atime:C,em:w,argpm:T,inclm:E,xli:D,mm:O,xni:k,nodem:A,nm:j}=e,oe=.13130908,M=2.8843198,N=.37448087,se=5.7686396,P=.95240898,F=1.8014998,I=1.050833,L=4.4108898,R=259200,ce,z,B,V,H,U,W,G,K=0,q=0,J=(ie+re*.0043752690880113)%o;if(w+=p*b,E+=h*b,T+=_*b,A+=ne*b,O+=g*b,t!==0){(C===0||b*C<=0||Math.abs(b)<Math.abs(C))&&(C=0,k=S,D=ae),ce=b>0?720:-720;let e=381;for(;e===381;)t===2?(G=v+y*C,B=G+G,z=D+D,W=n*Math.sin(B+D-se)+r*Math.sin(D-se)+i*Math.sin(G+D-P)+a*Math.sin(-G+D-P)+s*Math.sin(B+z-F)+c*Math.sin(z-F)+l*Math.sin(G+D-I)+u*Math.sin(-G+D-I)+d*Math.sin(G+z-L)+f*Math.sin(-G+z-L),H=k+x,U=n*Math.cos(B+D-se)+r*Math.cos(D-se)+i*Math.cos(G+D-P)+a*Math.cos(-G+D-P)+l*Math.cos(G+D-I)+u*Math.cos(-G+D-I)+2*(s*Math.cos(B+z-F)+c*Math.cos(z-F)+d*Math.cos(G+z-L)+f*Math.cos(-G+z-L)),U*=H):(W=m*Math.sin(D-oe)+ee*Math.sin(2*(D-M))+te*Math.sin(3*(D-N)),H=k+x,U=m*Math.cos(D-oe)+2*ee*Math.cos(2*(D-M))+3*te*Math.cos(3*(D-N)),U*=H),Math.abs(b-C)>=720?e=381:(q=b-C,e=0),e===381&&(D+=H*ce+W*R,k+=W*ce+U*R,C+=ce);j=k+W*q+U*q*q*.5,V=D+H*q+W*q*q*.5,t===1?(O=V-A-T+J,K=j-S):(O=V-2*A+2*J,K=j-S),j=S+K}return{atime:C,em:w,argpm:T,inclm:E,xli:D,mm:O,xni:k,nodem:A,dndt:K,nm:j}}var x;(function(e){e[e.None=0]=`None`,e[e.MeanEccentricityOutOfRange=1]=`MeanEccentricityOutOfRange`,e[e.MeanMotionBelowZero=2]=`MeanMotionBelowZero`,e[e.PerturbedEccentricityOutOfRange=3]=`PerturbedEccentricityOutOfRange`,e[e.SemiLatusRectumBelowZero=4]=`SemiLatusRectumBelowZero`,e[e.Decayed=6]=`Decayed`})(x||={});function ae(e,t){let n,r,i,s,d,ee,te,h,g,_,v,y,b,re,ae,S,C,w,T,E,D,O,k,A,j,oe,M;e.t=t,e.error=x.None;let N=e.mo+e.mdot*e.t,se=e.argpo+e.argpdot*e.t,P=e.nodeo+e.nodedot*e.t;g=se,D=N;let F=e.t*e.t;if(k=P+e.nodecf*F,C=1-e.cc1*e.t,w=e.bstar*e.cc4*e.t,T=e.t2cof*F,e.isimp!==1){te=e.omgcof*e.t;let t=1+e.eta*Math.cos(N);ee=e.xmcof*(t*t*t-e.delmo),S=te+ee,D=N+S,g=se-S,y=F*e.t,b=y*e.t,C=C-e.d2*F-e.d3*y-e.d4*b,w+=e.bstar*e.cc5*(Math.sin(D)-e.sinmao),T=T+e.t3cof*y+b*(e.t4cof+e.t*e.t5cof)}O=e.no;let I=e.ecco;if(E=e.inclo,e.method===`d`){re=e.t;let t=ie({irez:e.irez,d2201:e.d2201,d2211:e.d2211,d3210:e.d3210,d3222:e.d3222,d4410:e.d4410,d4422:e.d4422,d5220:e.d5220,d5232:e.d5232,d5421:e.d5421,d5433:e.d5433,dedt:e.dedt,del1:e.del1,del2:e.del2,del3:e.del3,didt:e.didt,dmdt:e.dmdt,dnodt:e.dnodt,domdt:e.domdt,argpo:e.argpo,argpdot:e.argpdot,t:e.t,tc:re,gsto:e.gsto,xfact:e.xfact,xlamo:e.xlamo,no:e.no,atime:e.atime,em:I,argpm:g,inclm:E,xli:e.xli,mm:D,xni:e.xni,nodem:k,nm:O});({em:I,argpm:g,inclm:E,mm:D,nodem:k,nm:O}=t)}if(O<=0)return e.error=x.MeanMotionBelowZero,null;let L=(l/O)**m*C*C;if(O=l/L**1.5,I-=w,I>=1||I<-.001)return e.error=x.MeanEccentricityOutOfRange,null;I<1e-6&&(I=1e-6),D+=e.no*T,j=D+g+k,k%=o,g%=o,j%=o,D=(j-g-k)%o;let R={am:L,em:I,im:E,Om:k,om:g,mm:D,nm:O},ce=Math.sin(E),z=Math.cos(E),B=I;if(A=E,_=g,M=k,oe=D,s=ce,i=z,e.method===`d`){let t=ne(e,{inclo:e.inclo,init:`n`,ep:B,inclp:A,nodep:M,argpp:_,mp:oe,opsmode:e.operationmode});if({ep:B,nodep:M,argpp:_,mp:oe}=t,A=t.inclp,A<0&&(A=-A,M+=a,_-=a),B<0||B>1)return e.error=x.PerturbedEccentricityOutOfRange,null}e.method===`d`&&(s=Math.sin(A),i=Math.cos(A),e.aycof=-.5*p*s,Math.abs(i+1)>15e-13?e.xlcof=-.25*p*s*(3+5*i)/(1+i):e.xlcof=-.25*p*s*(3+5*i)/15e-13);let V=B*Math.cos(_);S=1/(L*(1-B*B));let H=B*Math.sin(_)+S*e.aycof,U=(oe+_+M+S*e.xlcof*V-M)%o;h=U,ae=9999.9;let W=1;for(;Math.abs(ae)>=1e-12&&W<=10;)r=Math.sin(h),n=Math.cos(h),ae=1-n*V-r*H,ae=(U-H*n+V*r-h)/ae,Math.abs(ae)>=.95&&(ae=ae>0?.95:-.95),h+=ae,W+=1;let G=V*n+H*r,K=V*r-H*n,q=V*V+H*H,J=L*(1-q);if(J<0)return e.error=x.SemiLatusRectumBelowZero,null;let le=L*(1-G),Y=Math.sqrt(L)*K/le,ue=Math.sqrt(J)/le,de=Math.sqrt(1-q);S=K/(1+de);let X=L/le*(r-H-V*S),fe=L/le*(n-V+H*S);v=Math.atan2(X,fe);let pe=(fe+fe)*X,me=1-2*X*X;S=1/J;let he=.5*f*S,ge=he*S;e.method===`d`&&(d=i*i,e.con41=3*d-1,e.x1mth2=1-d,e.x7thm1=7*d-1);let Z=le*(1-1.5*ge*de*e.con41)+.5*he*e.x1mth2*me;if(Z<1)return e.error=x.Decayed,null;v-=.25*ge*e.x7thm1*pe;let _e=M+1.5*ge*i*pe,ve=A+1.5*ge*i*s*me,ye=Y-O*he*e.x1mth2*pe/l,be=ue+O*he*(e.x1mth2*me+1.5*e.con41)/l,xe=Math.sin(v),Se=Math.cos(v),Ce=Math.sin(_e),we=Math.cos(_e),Te=Math.sin(ve),Ee=Math.cos(ve),Q=-Ce*Ee,De=we*Ee,Oe=Q*xe+we*Se,$=De*xe+Ce*Se,ke=Te*xe,Ae=Q*Se-we*xe,je=De*Se-Ce*xe,Me=Te*Se;return{position:{x:Z*Oe*c,y:Z*$*c,z:Z*ke*c},velocity:{x:(ye*Oe+be*Ae)*u,y:(ye*$+be*je)*u,z:(ye*ke+be*Me)*u},meanElements:R}}function S(e,t){let{opsmode:n,satn:r,epoch:i,xbstar:o,xecco:s,xargpo:l,xinclo:u,xmo:ee,xno:te,xnodeo:h}=t,g,y,b,ie,x,S,C,w,T,E,D,O,k,A,j,oe,M,N,se,P,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,le,Y,ue,de,X,fe,pe,me,he,ge,Z,_e,ve,ye,be,xe,Se,Ce,we,Te,Ee,Q=e;Q.isimp=0,Q.method=`n`,Q.aycof=0,Q.con41=0,Q.cc1=0,Q.cc4=0,Q.cc5=0,Q.d2=0,Q.d3=0,Q.d4=0,Q.delmo=0,Q.eta=0,Q.argpdot=0,Q.omgcof=0,Q.sinmao=0,Q.t=0,Q.t2cof=0,Q.t3cof=0,Q.t4cof=0,Q.t5cof=0,Q.x1mth2=0,Q.x7thm1=0,Q.mdot=0,Q.nodedot=0,Q.xlcof=0,Q.xmcof=0,Q.nodecf=0,Q.irez=0,Q.d2201=0,Q.d2211=0,Q.d3210=0,Q.d3222=0,Q.d4410=0,Q.d4422=0,Q.d5220=0,Q.d5232=0,Q.d5421=0,Q.d5433=0,Q.dedt=0,Q.del1=0,Q.del2=0,Q.del3=0,Q.didt=0,Q.dmdt=0,Q.dnodt=0,Q.domdt=0,Q.e3=0,Q.ee2=0,Q.peo=0,Q.pgho=0,Q.pho=0,Q.pinco=0,Q.plo=0,Q.se2=0,Q.se3=0,Q.sgh2=0,Q.sgh3=0,Q.sgh4=0,Q.sh2=0,Q.sh3=0,Q.si2=0,Q.si3=0,Q.sl2=0,Q.sl3=0,Q.sl4=0,Q.gsto=0,Q.xfact=0,Q.xgh2=0,Q.xgh3=0,Q.xgh4=0,Q.xh2=0,Q.xh3=0,Q.xi2=0,Q.xi3=0,Q.xl2=0,Q.xl3=0,Q.xl4=0,Q.xlamo=0,Q.zmol=0,Q.zmos=0,Q.atime=0,Q.xli=0,Q.xni=0,Q.bstar=o,Q.ecco=s,Q.argpo=l,Q.inclo=u,Q.mo=ee,Q.no=te,Q.nodeo=h,Q.operationmode=n,78/c+1;let De=42/c;De*De*De*De,Q.init=`y`,Q.t=0;let Oe=re({satn:r,ecco:Q.ecco,epoch:i,inclo:Q.inclo,no:Q.no,method:Q.method,opsmode:Q.operationmode}),{ao:$,con42:ke,cosio:Ae,cosio2:je,eccsq:Me,omeosq:Ne,posq:Pe,rp:Fe,rteosq:Ie,sinio:Le}=Oe;if(Q.no=Oe.no,Q.con41=Oe.con41,Q.gsto=Oe.gsto,Q.a=(Q.no*d)**(-2/3),Q.alta=Q.a*(1+Q.ecco)-1,Q.altp=Q.a*(1-Q.ecco)-1,Q.error=0,Ne>=0||Q.no>=0){if(Q.isimp=0,Fe<1.034492841559484&&(Q.isimp=1),B=1.0122292801892716,F=1.880279159015271e-9,N=(Fe-1)*c,N<156){B=N-78,N<98&&(B=20);let e=(120-B)/c;F=e*e*e*e,B=B/c+1}se=1/Pe,Z=1/($-B),Q.eta=$*Q.ecco*Z,O=Q.eta*Q.eta,D=Q.ecco*Q.eta,P=Math.abs(1-O),S=F*Z**4,C=S/P**3.5,ie=C*Q.no*($*(1+1.5*O+D*(4+O))+.375*f*Z/P*Q.con41*(8+3*O*(8+O))),Q.cc1=Q.bstar*ie,x=0,Q.ecco>1e-4&&(x=-2*S*Z*p*Q.no*Le/Q.ecco),Q.x1mth2=1-je,Q.cc4=2*Q.no*C*$*Ne*(Q.eta*(2+.5*O)+Q.ecco*(.5+2*O)-f*Z/($*P)*(-3*Q.con41*(1-2*D+O*(1.5-.5*D))+.75*Q.x1mth2*(2*O-D*(1+O))*Math.cos(2*Q.argpo))),Q.cc5=2*C*$*Ne*(1+2.75*(O+D)+D*O),w=je*je,me=1.5*f*se*Q.no,he=.5*me*f*se,ge=-.46875*-165597e-11*se*se*Q.no,Q.mdot=Q.no+.5*me*Ie*Q.con41+.0625*he*Ie*(13-78*je+137*w),Q.argpdot=-.5*me*ke+.0625*he*(7-114*je+395*w)+ge*(3-36*je+49*w),ve=-me*Ae,Q.nodedot=ve+(.5*he*(4-19*je)+2*ge*(3-7*je))*Ae,_e=Q.argpdot+Q.nodedot,Q.omgcof=Q.bstar*x*Math.cos(Q.argpo),Q.xmcof=0,Q.ecco>1e-4&&(Q.xmcof=-m*S*Q.bstar/D),Q.nodecf=3.5*Ne*ve*Q.cc1,Q.t2cof=1.5*Q.cc1,Math.abs(Ae+1)>15e-13?Q.xlcof=-.25*p*Le*(3+5*Ae)/(1+Ae):Q.xlcof=-.25*p*Le*(3+5*Ae)/15e-13,Q.aycof=-.5*p*Le;let e=1+Q.eta*Math.cos(Q.mo);if(Q.delmo=e*e*e,Q.sinmao=Math.sin(Q.mo),Q.x7thm1=7*je-1,2*a/Q.no>=225){Q.method=`d`,Q.isimp=1,fe=0,j=Q.inclo;let e=_({epoch:i,ep:Q.ecco,argpp:Q.argpo,tc:fe,inclp:Q.inclo,nodep:Q.nodeo,np:Q.no,e3:Q.e3,ee2:Q.ee2,peo:Q.peo,pgho:Q.pgho,pho:Q.pho,pinco:Q.pinco,plo:Q.plo,se2:Q.se2,se3:Q.se3,sgh2:Q.sgh2,sgh3:Q.sgh3,sgh4:Q.sgh4,sh2:Q.sh2,sh3:Q.sh3,si2:Q.si2,si3:Q.si3,sl2:Q.sl2,sl3:Q.sl3,sl4:Q.sl4,xgh2:Q.xgh2,xgh3:Q.xgh3,xgh4:Q.xgh4,xh2:Q.xh2,xh3:Q.xh3,xi2:Q.xi2,xi3:Q.xi3,xl2:Q.xl2,xl3:Q.xl3,xl4:Q.xl4,zmol:Q.zmol,zmos:Q.zmos});Q.e3=e.e3,Q.ee2=e.ee2,Q.peo=e.peo,Q.pgho=e.pgho,Q.pho=e.pho,Q.pinco=e.pinco,Q.plo=e.plo,Q.se2=e.se2,Q.se3=e.se3,Q.sgh2=e.sgh2,Q.sgh3=e.sgh3,Q.sgh4=e.sgh4,Q.sh2=e.sh2,Q.sh3=e.sh3,Q.si2=e.si2,Q.si3=e.si3,Q.sl2=e.sl2,Q.sl3=e.sl3,Q.sl4=e.sl4,{sinim:y,cosim:g,em:T,emsq:E,s1:I,s2:L,s3:R,s4:ce,s5:z,ss1:V,ss2:H,ss3:U,ss4:W,ss5:G,sz1:K,sz3:q,sz11:J,sz13:le,sz21:Y,sz23:ue,sz31:de,sz33:X}=e,Q.xgh2=e.xgh2,Q.xgh3=e.xgh3,Q.xgh4=e.xgh4,Q.xh2=e.xh2,Q.xh3=e.xh3,Q.xi2=e.xi2,Q.xi3=e.xi3,Q.xl2=e.xl2,Q.xl3=e.xl3,Q.xl4=e.xl4,Q.zmol=e.zmol,Q.zmos=e.zmos,{nm:M,z1:ye,z3:be,z11:xe,z13:Se,z21:Ce,z23:we,z31:Te,z33:Ee}=e;let t=ne(Q,{inclo:j,init:Q.init,ep:Q.ecco,inclp:Q.inclo,nodep:Q.nodeo,argpp:Q.argpo,mp:Q.mo,opsmode:Q.operationmode});Q.ecco=t.ep,Q.inclo=t.inclp,Q.nodeo=t.nodep,Q.argpo=t.argpp,Q.mo=t.mp,k=0,A=0,oe=0;let n=v({cosim:g,emsq:E,argpo:Q.argpo,s1:I,s2:L,s3:R,s4:ce,s5:z,sinim:y,ss1:V,ss2:H,ss3:U,ss4:W,ss5:G,sz1:K,sz3:q,sz11:J,sz13:le,sz21:Y,sz23:ue,sz31:de,sz33:X,t:Q.t,tc:fe,gsto:Q.gsto,mo:Q.mo,mdot:Q.mdot,no:Q.no,nodeo:Q.nodeo,nodedot:Q.nodedot,xpidot:_e,z1:ye,z3:be,z11:xe,z13:Se,z21:Ce,z23:we,z31:Te,z33:Ee,ecco:Q.ecco,eccsq:Me,em:T,argpm:k,inclm:j,mm:oe,nm:M,nodem:A,irez:Q.irez,atime:Q.atime,d2201:Q.d2201,d2211:Q.d2211,d3210:Q.d3210,d3222:Q.d3222,d4410:Q.d4410,d4422:Q.d4422,d5220:Q.d5220,d5232:Q.d5232,d5421:Q.d5421,d5433:Q.d5433,dedt:Q.dedt,didt:Q.didt,dmdt:Q.dmdt,dnodt:Q.dnodt,domdt:Q.domdt,del1:Q.del1,del2:Q.del2,del3:Q.del3,xfact:Q.xfact,xlamo:Q.xlamo,xli:Q.xli,xni:Q.xni});Q.irez=n.irez,Q.atime=n.atime,Q.d2201=n.d2201,Q.d2211=n.d2211,Q.d3210=n.d3210,Q.d3222=n.d3222,Q.d4410=n.d4410,Q.d4422=n.d4422,Q.d5220=n.d5220,Q.d5232=n.d5232,Q.d5421=n.d5421,Q.d5433=n.d5433,Q.dedt=n.dedt,Q.didt=n.didt,Q.dmdt=n.dmdt,Q.dnodt=n.dnodt,Q.domdt=n.domdt,Q.del1=n.del1,Q.del2=n.del2,Q.del3=n.del3,Q.xfact=n.xfact,Q.xlamo=n.xlamo,Q.xli=n.xli,Q.xni=n.xni}Q.isimp!==1&&(b=Q.cc1*Q.cc1,Q.d2=4*$*Z*b,pe=Q.d2*Z*Q.cc1/3,Q.d3=(17*$+B)*pe,Q.d4=.5*pe*$*Z*(221*$+31*B)*Q.cc1,Q.t3cof=Q.d2+2*b,Q.t4cof=.25*(3*Q.d3+Q.cc1*(12*Q.d2+10*b)),Q.t5cof=.2*(3*Q.d4+12*Q.cc1*Q.d3+6*Q.d2*Q.d2+15*b*(2*Q.d2+b)))}ae(Q,0),Q.init=`n`}function C(e,t=`i`){let n=e.NORAD_CAT_ID.toString(),r=new Date(e.EPOCH.endsWith(`Z`)?e.EPOCH:`${e.EPOCH}Z`),i=r.getUTCFullYear(),a=Number(i.toString().slice(-2)),o=(r.valueOf()-new Date(Date.UTC(i,0,1,0,0,0)).valueOf())/(86400*1e3)+1,c=Number(e.MEAN_MOTION_DOT),l=Number(e.MEAN_MOTION_DDOT);c/=ee*1440,l/=ee*1440*1440;let u=Number(e.BSTAR),d=Number(e.INCLINATION)*s,f=Number(e.RA_OF_ASC_NODE)*s,p=Number(e.ECCENTRICITY),m=Number(e.ARG_OF_PERICENTER)*s,h=Number(e.MEAN_ANOMALY)*s,ne=Number(e.MEAN_MOTION)/ee,{mon:_,day:v,hr:y,minute:b,sec:re}=te(i,o),ie=g(i,_,v,y,b,re),x={error:0,satnum:n,epochyr:a,epochdays:o,ndot:c,nddot:l,bstar:u,inclo:d,nodeo:f,ecco:p,argpo:m,mo:h,no:ne,jdsatepoch:ie};return S(x,{opsmode:t,satn:x.satnum,epoch:x.jdsatepoch-2433281.5,xbstar:x.bstar,xecco:x.ecco,xargpo:x.argpo,xinclo:x.inclo,xmo:x.mo,xno:x.no,xnodeo:x.nodeo}),x}3*Float64Array.BYTES_PER_ELEMENT;const w=Math.PI/180;Math.cos(i*w),Math.sin(i*w);function T(e){return new Date((e-2440587.5)*864e5).toISOString()}function E(e,t){let n=C({OBJECT_NAME:t??String(e.noradCatId),OBJECT_ID:String(e.noradCatId),EPOCH:T(e.epochJd),MEAN_MOTION:e.meanMotion,ECCENTRICITY:e.eccentricity,INCLINATION:e.inclination,RA_OF_ASC_NODE:e.raOfAscNode,ARG_OF_PERICENTER:e.argOfPericenter,MEAN_ANOMALY:e.meanAnomaly,EPHEMERIS_TYPE:0,CLASSIFICATION_TYPE:`U`,NORAD_CAT_ID:e.noradCatId,ELEMENT_SET_NO:e.elementSetNo,REV_AT_EPOCH:e.revAtEpoch,BSTAR:e.bstar,MEAN_MOTION_DOT:e.meanMotionDot,MEAN_MOTION_DDOT:e.meanMotionDdot});return n.error===x.None?n:(console.warn(`buildSatrec: SGP4 init failed for NORAD ${e.noradCatId} (error=${n.error})`),null)}const D=Math.PI/180,O=Math.cos(i*D),k=Math.sin(i*D),A=10/r;function j(e,t,n,r,i){return!isFinite(Math.fround(n))||!isFinite(Math.fround(r))||!isFinite(Math.fround(i))?!1:(e[t*3]=n,e[t*3+1]=r,e[t*3+2]=i,!0)}function oe(r,i,a,o,s,c,l,u,d,f=null,p=0){if(i<r.validityStart||i>r.validityEnd)return 0;let{count:m,kind:ee,equatorial:te,a:h,e:g,i:ne,om:_,w:v,ma:y,n:b,epoch:re,q:ie,tp:S,satrec:C,flags:w,visibleFromDays:T}=r,oe=p!==0&&r.applyFlagFilter,M=r.pickBase,N=d.length/3|0,se=i-2451545,P=0;for(let F=0;F<m&&!(P>=N);F++){let m=ee[F];if(m===0||T[F]>se||oe&&(w[F]&p)!==p)continue;if(m===3){let e=C[F];if(!e){if(e=E({noradCatId:r.satnum[F],epochJd:re[F],meanMotion:b[F]/360,eccentricity:g[F],inclination:ne[F],raOfAscNode:_[F],argOfPericenter:v[F],meanAnomaly:y[F],bstar:r.bstar[F],meanMotionDot:r.ndot[F],meanMotionDdot:r.nddot[F],elementSetNo:0,revAtEpoch:0}),!e){ee[F]=0;continue}C[F]=e}let t=(i-e.jdsatepoch)*1440,n=ae(e,t);if(!n||e.error!==x.None)continue;let p=n.position.x,m=n.position.y,te=n.position.z,h=p*A,ie=m*A,S=te*A,w=ie*O+S*k,T=-ie*k+S*O,D=h,oe=T,N=-w;if(!j(d,P,a+D-c,o+oe-l,s+N-u))continue;if(f){let e=M+F,t=P*4;f[t]=e&255,f[t+1]=e>>>8&255,f[t+2]=e>>>16&255,f[t+3]=e>>>24&255}P++;continue}let N,I,L=g[F],R=ne[F],ce=_[F],z=v[F];if(m===2){let e=n(ie[F],S[F],i);if(!e)continue;N=e.r*Math.cos(e.nu),I=e.r*Math.sin(e.nu)}else{let n=h[F];if(!isFinite(n)||!isFinite(L)||!isFinite(y[F])||!isFinite(b[F]))continue;let r=i-re[F],a=(y[F]+b[F]*r)*D,o,s;if(L<1||n>0){let t=Math.min(L,.9999999),r=e(a,t),i=Math.sqrt(1-t*t)*Math.sin(r)/(1-t*Math.cos(r)),c=(Math.cos(r)-t)/(1-t*Math.cos(r));o=Math.atan2(i,c),s=n*(1-t*Math.cos(r))}else{let e=t(a,L);if(!isFinite(e))continue;let r=L*Math.cosh(e)-1;if(Math.abs(r)<1e-15)continue;let i=Math.sqrt(L*L-1)*Math.sinh(e)/r,c=(L-Math.cosh(e))/r;o=Math.atan2(i,c),s=n*(1-L*Math.cosh(e))}N=s*Math.cos(o),I=s*Math.sin(o)}if(!isFinite(N)||!isFinite(I))continue;let B=Math.cos(z*D),V=Math.sin(z*D),H=Math.cos(R*D),U=Math.sin(R*D),W=Math.cos(ce*D),G=Math.sin(ce*D),K=(W*B-G*V*H)*N+(-W*V-G*B*H)*I,q=(G*B+W*V*H)*N+(-G*V+W*B*H)*I,J=V*U*N+B*U*I;if(te[F]){let e=q*O+J*k,t=-q*k+J*O;q=e,J=t}let le=K*10,Y=J*10,ue=-q*10;if(j(d,P,a+le-c,o+Y-l,s+ue-u)){if(f){let e=M+F,t=P*4;f[t]=e&255,f[t+1]=e>>>8&255,f[t+2]=e>>>16&255,f[t+3]=e>>>24&255}P++}}return P}const M=new Map;self.onmessage=e=>{let t=e.data;if(t.type===`ping`){self.postMessage({type:`pong`});return}if(t.type===`rewireDelta`){if(t.remove)for(let e of t.remove)M.delete(e);for(let e of t.set)M.set(e.id,e.cols);return}if(t.type===`tick`){let e=[],n=[],[r,i,a]=t.basis;for(let o of t.groups){let s=M.get(o.id);if(!s){e.push({id:o.id,count:0,buf:o.out.buffer,idbuf:o.outIds.buffer}),n.push(o.out.buffer,o.outIds.buffer);continue}let c=oe(s,t.jd,o.parent[0],o.parent[1],o.parent[2],r,i,a,o.out,o.outIds,t.requiredFlags??0);e.push({id:o.id,count:c,buf:o.out.buffer,idbuf:o.outIds.buffer}),n.push(o.out.buffer,o.outIds.buffer)}self.postMessage({type:`tickResult`,groups:e},n);return}};\n//# sourceMappingURL=worker-CK5Z1yOu.js.map",oP=typeof self<`u`&&self.Blob&&new Blob([`URL.revokeObjectURL(import.meta.url);`,aP],{type:`text/javascript;charset=utf-8`});function sP(e){let t;try{if(t=oP&&(self.URL||self.webkitURL).createObjectURL(oP),!t)throw``;let n=new Worker(t,{type:`module`,name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(aP),{type:`module`,name:e?.name})}}var cP=class{workers=[];groups=new Map;onResult=null;size;pendingPing=null;generation=0;constructor(e=navigator.hardwareConcurrency??4){this.size=Math.max(2,Math.min(8,e)),this.spawn()}spawn(){for(let e=0;e<this.size;e++){let e=new sP;e.onmessage=e=>this.onMessage(e.data),this.workers.push(e)}}ping(e=800){if(this.workers.length===0)return Promise.resolve(!1);if(this.pendingPing)return this.pendingPing.promise;let t,n=new Promise(e=>t=e),r={need:this.workers.length,got:0,promise:n,resolve:e=>{this.pendingPing===r&&(this.pendingPing=null,t(e))}};this.pendingPing=r,setTimeout(()=>r.resolve(!1),e);for(let e of this.workers)e.postMessage({type:`ping`});return n}respawn(){this.pendingPing?.resolve(!1);for(let e of this.workers)e.terminate();this.workers=[],this.groups.clear(),this.generation++,this.spawn()}get poolGeneration(){return this.generation}setResultHandler(e){this.onResult=e}get workerCount(){return this.workers.length}get groupCount(){return this.groups.size}async rewireOne(e,t,n,r,i=!1,a=0){if(t.length===0){this.unwireOne(e);return}let o=await Bg(t,n,i);o.pickBase=a,this.workers.length!==0&&this.wireCols(e,o,r,t.length)}rewireOneCols(e,t,n){if(this.workers.length!==0){if(t.count===0){this.unwireOne(e);return}this.wireCols(e,t,n,t.count)}}wireCols(e,t,n,r){let i=this.groups.get(e),a=i?.workerIdx??n%this.workers.length,o,s,c,l;if(i&&i.capacity===r)o=i.front,s=i.back,c=i.idFront,l=i.idBack;else if(o=new Float32Array(r*3),s=new Float32Array(r*3),c=new Uint8Array(r*4),l=new Uint8Array(r*4),i){let e=Math.min(i.front.length,o.length);o.set(i.front.subarray(0,e));let t=Math.min(i.idFront.length,c.length);c.set(i.idFront.subarray(0,t))}let u=!!i&&i.back===null;this.groups.set(e,{workerIdx:a,capacity:r,front:o,back:s,idFront:c,idBack:l,count:i?.count??r,pendingBasis:u?i.pendingBasis:null,pendingParent:u?i.pendingParent:null,pendingJd:u?i.pendingJd:null,frontBasis:i?.frontBasis??[0,0,0],frontParent:i?.frontParent??[0,0,0],frontJd:i?.frontJd??NaN}),this.workers[a].postMessage({type:`rewireDelta`,set:[{id:e,cols:t}]},Hg(t))}unwireOne(e){let t=this.groups.get(e);t&&(this.groups.delete(e),this.workers[t.workerIdx].postMessage({type:`rewireDelta`,set:[],remove:[e]}))}tick(e,t,n,r=0){let i=this.workers.map(()=>[]);for(let[r,a]of this.groups){if(!a.back||!a.idBack)continue;let o=n.get(r);o&&(i[a.workerIdx].push({id:r,parent:[o[0],o[1],o[2]],out:a.back,outIds:a.idBack}),a.back=null,a.idBack=null,a.pendingBasis=[t[0],t[1],t[2]],a.pendingParent=[o[0],o[1],o[2]],a.pendingJd=e)}for(let n=0;n<this.workers.length;n++){let a=i[n];if(a.length===0)continue;let o=a.flatMap(e=>[e.out.buffer,e.outIds.buffer]);this.workers[n].postMessage({type:`tick`,jd:e,basis:[t[0],t[1],t[2]],requiredFlags:r,groups:a},o)}}onMessage(e){if(e.type===`pong`){let e=this.pendingPing;e&&++e.got>=e.need&&e.resolve(!0);return}if(e.type===`tickResult`)for(let t of e.groups){let e=this.groups.get(t.id);if(!e)continue;let n=new Float32Array(t.buf),r=e.front;e.front=n,e.back=r;let i=new Uint8Array(t.idbuf),a=e.idFront;e.idFront=i,e.idBack=a,e.count=t.count;let o=e.pendingBasis??e.frontBasis,s=e.pendingParent??e.frontParent,c=e.pendingJd??e.frontJd;e.frontBasis=o,e.frontParent=s,e.frontJd=c,e.pendingBasis=null,e.pendingParent=null,e.pendingJd=null,this.onResult?.(t.id,n,t.count,o,s,c,i)}}destroy(){this.pendingPing?.resolve(!1);for(let e of this.workers)e.terminate();this.workers.length=0,this.groups.clear()}},lP=class{#e=1;#t=new Map;allocate(e,t){let n=this.#e;return this.#e+=t.length,this.#t.set(e,{base:n,keys:t}),n}release(e){this.#t.delete(e)}resolve(e){if(e===0)return null;for(let{base:t,keys:n}of this.#t.values())if(e>=t&&e<t+n.length)return _h(n[e-t]);return null}clear(){this.#t.clear(),this.#e=1}},uP=.01,dP=[`asteroid`,`spacecraft`],fP=.0002959122082855911,pP=.75,mP=Q(8*86400);function hP(e){let t=0,n=!1;for(let r=0;r<e.count;r++){if(e.kind[r]===0)continue;let i=e.a[r],a=e.e[r];if(e.kind[r]!==1||!(i>0)||!(a<1)||!isFinite(i)||!isFinite(a)){n=!0;continue}let o=Math.min(a,.9999999),s=Math.sqrt(fP/i*((1+o)/(1-o)));s>t&&(t=s)}return{maxSpeedScene:t*10,alwaysSolve:n}}function gP(e){return e<0?0:e>1?1:e}function _P(e,t){return t===`*`?e.startsWith(`small_bodies/`):e===t}function vP(e){return e===null?{tBright:0,tSize:0}:{tBright:gP((yP-e)/(yP-bP)),tSize:gP((xP-e)/(xP-SP))}}var yP=1e4,bP=500,xP=bP,SP=50,CP=4,wP=.5,TP=10,EP=1,DP=1,OP=3.5,kP=2.5,AP=2,jP=OP,MP=class{orbitPool=new cP;pickRegistry=new lP;disposed=!1;workerPoints={asteroid:new Map,spacecraft:new Map};moonPoints=new Map;pointBudget=1/0;drawFraction=1;pendingSceneAdds=[];basisPos=[0,0,0];parentAtUpdate=new Map;_parentsScratch=new Map;moonsByParentCache=null;lastPackedSize=new Map;groupKinematics=new Map;lastSolvedJd=new Map;earthSatEmphasis={size:CP,dim:wP,opacity:DP};emphasizedSmallBodyZone=null;smallBodyEmphasis={sizeMult:1,brightMult:1,opacity:DP};constructor(e,t,n,r,i,a,o){this.ctx=e,this.scene=t,this.bodyObjects=n,this.circleTexture=r,this.focus=i,this.mapLayer=a,this.onBasisRebuilt=o,this.orbitPool.setResultHandler(this.onPoolResult)}basis(){return this.basisPos}setPointBudget(e){this.pointBudget=e,this.applyPointBudget()}applyPointBudget(){let e=0;for(let t of dP)for(let n of this.workerPoints[t].values())n.visible&&(e+=n.userData.solvedCount??0);let t=e>this.pointBudget?this.pointBudget/e:1;if(t!==this.drawFraction){this.drawFraction=t;for(let e of dP)for(let n of this.workerPoints[e].values()){let e=n.userData.solvedCount;e!==void 0&&n.geometry.setDrawRange(0,Math.ceil(e*t))}}}setEarthSatEmphasis(e){this.earthSatEmphasis=this.computeEarthSatEmphasis(e);for(let[e,t]of this.workerPoints.spacecraft)S_(e)===`naif-399`&&this.applyEarthSatEmphasis(t)}computeEarthSatEmphasis(e){let{tBright:t,tSize:n}=vP(e);return{size:CP+(TP-CP)*n,dim:wP+(EP-wP)*t,opacity:DP+(OP-DP)*t}}applyEarthSatEmphasis(e){let t=e.material,{size:n,dim:r,opacity:i}=this.earthSatEmphasis;t.size=n,t.color.setRGB(r,r,r),t.opacity=i}setEmphasizedSmallBodyZone(e,t){let n=this.emphasizedSmallBodyZone;if(this.emphasizedSmallBodyZone=e,this.smallBodyEmphasis=this.computeSmallBodyEmphasis(e===null?null:t),n!==null&&n!==e)for(let[e,t]of this.workerPoints.asteroid)_P(S_(e),n)&&this.resetSmallBodyEmphasis(t);if(e!==null)for(let[t,n]of this.workerPoints.asteroid)_P(S_(t),e)&&this.applySmallBodyEmphasis(n)}computeSmallBodyEmphasis(e){let{tBright:t,tSize:n}=vP(e);return{sizeMult:1+(kP-1)*n,brightMult:1+(AP-1)*t,opacity:DP+(jP-DP)*t}}applySmallBodyEmphasis(e){let t=e.material;e.userData.smallBodyBaseSize===void 0&&(e.userData.smallBodyBaseSize=t.size,e.userData.smallBodyBaseColor=t.color.clone());let n=e.userData.smallBodyBaseSize,r=e.userData.smallBodyBaseColor,{sizeMult:i,brightMult:a,opacity:o}=this.smallBodyEmphasis;t.size=n*i,t.color.copy(r).multiplyScalar(a),t.opacity=o}resetSmallBodyEmphasis(e){if(e.userData.smallBodyBaseSize===void 0)return;let t=e.material;t.size=e.userData.smallBodyBaseSize,t.color.copy(e.userData.smallBodyBaseColor),t.opacity=DP,e.userData.smallBodyBaseSize=void 0,e.userData.smallBodyBaseColor=void 0}seedBasis(e){this.basisPos=[...e]}buildInitial(e){let t=xN(this.ctx,this.scene,this.circleTexture,this.basisPos,e,this.orbitPool.workerCount);this.workerPoints.asteroid=t.asteroidPoints,this.workerPoints.spacecraft=t.spacecraftPoints,this.moonPoints=t.moonPoints;for(let e of dP)for(let[t,n]of this.workerPoints[e]){let r=S_(t);n.userData.parentBodyId=this.cloudParentId(e,r),this.emphasiseNewCloud(e,r,n)}this.assignMapLayer()}assignMapLayer(){for(let e of dP)for(let t of this.workerPoints[e].values())t.layers.set(this.mapLayer);for(let e of this.moonPoints.values())e.layers.set(this.mapLayer)}cloudParentId(e,t){return e===`asteroid`?f_:t}emphasiseNewCloud(e,t,n){if(e===`spacecraft`){t===`naif-399`&&this.applyEarthSatEmphasis(n);return}let r=this.emphasizedSmallBodyZone;r!==null&&_P(t,r)&&this.applySmallBodyEmphasis(n)}rebuildRunning=!1;rebuildQueued=!1;rebuildMinor(){if(this.rebuildRunning){this.rebuildQueued=!0;return}this.rebuildRunning=!0,(async()=>{try{do this.rebuildQueued=!1,await this.rebuildMinorPass();while(this.rebuildQueued)}finally{this.rebuildRunning=!1}})()}recovering=null;recoverWorkersIfDead(e){return this.recovering??=this.runRecovery(e).finally(()=>this.recovering=null),this.recovering}async runRecovery(e){if(await this.orbitPool.ping(e))return!1;this.orbitPool.respawn();for(let e of this.ctx.bodies.asteroidBodiesByZone.keys())this.ctx.bodies.dirtyAsteroidZones.add(e);for(let e of this.ctx.bodies.spacecraftByParent.keys())this.ctx.bodies.dirtySpacecraftGroups.add(e);return this.lastPackedSize.clear(),this.rebuildMinor(),!0}async rebuildMinorPass(){if(this.disposed||this.ctx.bodies.dirtyAsteroidZones.size===0&&this.ctx.bodies.dirtySpacecraftGroups.size===0)return;let e=[this.basisPos[0],this.basisPos[1],this.basisPos[2]],t=this.orbitPool.workerCount,n=this.orbitPool.poolGeneration,r=[],i=[];for(let n of[...this.ctx.bodies.dirtyAsteroidZones]){let i=this.ctx.bodies.asteroidBodiesByZone.get(n);if(this.deferPackWhileStreaming(`asteroid:${n}`,i?.size??0))continue;this.ctx.bodies.dirtyAsteroidZones.delete(n),r.push(n);let a=yh(this.bodyObjects.keys()),{groups:o,baseWorker:s}=i?await i.buildWorkerGroups(n,t,a,!1):{groups:[],baseWorker:0};if(this.disposed)return;let c=i&&o.length>0?i.cloudColor():`#888888`;for(let r=0;r<t;r++){let i=`${n}#${r}`,a=`asteroid:${i}`,l=r<o.length?o[r]:null;if(!l||l.cols.count===0){this.unwireGroup(`asteroid`,i,a);continue}this.armGroupGate(a,hP(l.cols)),l.cols.pickBase=this.pickRegistry.allocate(a,l.keys),this.orbitPool.rewireOneCols(a,l.cols,(s+r)%t);let u=this.workerPoints.asteroid.get(i);if(u){this.resizeGeometryToCount(u.geometry,l.cols.count,null);continue}let d=eN(new Float32Array(l.cols.count*3),0,this.circleTexture,c,QM());this.adoptCloud(`asteroid`,i,a,d,e)}}for(let n of[...this.ctx.bodies.dirtySpacecraftGroups]){let r=this.ctx.bodies.spacecraftByParent.get(n);if(this.deferPackWhileStreaming(`spacecraft:${n}`,r?.size??0))continue;this.ctx.bodies.dirtySpacecraftGroups.delete(n),i.push(n);let{buckets:a,baseWorker:o}=await x_(n,wv(this.ctx.layers,n,r?Array.from(r.values()):[]),t);if(this.disposed)return;let s=new Set(this.bodyObjects.keys());for(let r=0;r<t;r++){let i=`${n}#${r}`,c=`spacecraft:${i}`,l=r<a.length?a[r]:[];if(l.length===0){this.unwireGroup(`spacecraft`,i,c);continue}let u=this.pickRegistry.allocate(c,Float64Array.from(l,e=>vh(e.data.id)??fh));await this.orbitPool.rewireOne(c,l,s,(o+r)%t,!1,u),this.armGroupGate(c,{maxSpeedScene:mP,alwaysSolve:!1});let d=this.workerPoints.spacecraft.get(i);if(d){this.resizeGeometryIfNeeded(d.geometry,l);continue}let f=new Float32Array(l.length*3),p=new Float32Array(l.length*3);this.seedGeometryArray(f,l,p);let m=eN(f,l.length,this.circleTexture,`#ffffff`,void 0,p);this.adoptCloud(`spacecraft`,i,c,m,e)}}if(this.orbitPool.poolGeneration!==n){for(let e of r)this.ctx.bodies.dirtyAsteroidZones.add(e);for(let e of i)this.ctx.bodies.dirtySpacecraftGroups.add(e);this.lastPackedSize.clear(),this.rebuildQueued=!0}}unwireGroup(e,t,n){this.orbitPool.unwireOne(n),this.forgetGroupGate(n),this.pickRegistry.release(n);let r=this.workerPoints[e].get(t);r&&(this.scene.remove(r),this.workerPoints[e].delete(t))}armGroupGate(e,t){this.groupKinematics.set(e,t),this.lastSolvedJd.delete(e)}adoptCloud(e,t,n,r,i){let a=S_(t);r.userData.frontBasis=i,r.userData.groupId=n,r.userData.parentBodyId=this.cloudParentId(e,a),r.userData.parentVec=[0,0,0],this.emphasiseNewCloud(e,a,r),this.workerPoints[e].set(t,r),this.pendingSceneAdds.push(r)}deferPackWhileStreaming(e,t){if(!this.ctx.bodies.minorStreaming)return this.lastPackedSize.set(e,t),!1;let n=this.lastPackedSize.get(e);return n!==void 0&&t>n&&t<n*2?!0:(this.lastPackedSize.set(e,t),!1)}seedGeometryArray(e,t,n=null){let[r,i,a]=this.basisPos,o=Math.min(t.length,e.length/3),s=n?new X:null;for(let c=0;c<o;c++){let o=t[c],l=o.position;e[c*3]=l[0]-r,e[c*3+1]=l[1]-i,e[c*3+2]=l[2]-a,n&&s&&(s.set(h_(o.data)),n[c*3]=s.r,n[c*3+1]=s.g,n[c*3+2]=s.b)}}resizeGeometryIfNeeded(e,t){let n=t.length*3;if(e.getAttribute(`position`).array.length===n){e.setDrawRange(0,t.length);return}let r=!!e.getAttribute(`color`),i=new Float32Array(n),a=r?new Float32Array(n):null;this.seedGeometryArray(i,t,a),e.setAttribute(`position`,new Do(i,3)),a&&e.setAttribute(`color`,new Do(a,3)),e.setDrawRange(0,t.length)}resizeGeometryToCount(e,t,n){let r=t*3,i=e.getAttribute(`position`).array;if(n&&e.setAttribute(`color`,new Do(n,3)),i.length===r)return;let a=new Float32Array(r);a.set(i.subarray(0,Math.min(i.length,r))),e.setAttribute(`position`,new Do(a,3));let o=Math.min(e.drawRange.count,t);e.setDrawRange(0,Number.isFinite(o)?o:0)}onPoolResult=(e,t,n,r,i,a,o)=>{let[s,c]=e.split(`:`),l=this.workerPoints[s].get(c);if(!l)return;let u=l.geometry.getAttribute(`position`),d=u.array;if(d.length!==t.length)return;d.set(t),u.needsUpdate=!0,this.bindPickIds(l,o),l.userData.solvedCount=n,l.geometry.setDrawRange(0,Math.ceil(n*this.drawFraction)),this.lastSolvedJd.set(e,a),l.userData.frontBasis=[r[0],r[1],r[2]],this.parentAtUpdate.set(e,[i[0],i[1],i[2]]);let[f,p,m]=this.focus.focusTruePos,h=this.ctx.getBody(l.userData.parentBodyId)?.position,g=h?h[0]-i[0]:0,_=h?h[1]-i[1]:0,v=h?h[2]-i[2]:0;l.position.set(r[0]-f+g,r[1]-p+_,r[2]-m+v)};bindPickIds(e,t){let n=e.geometry.getAttribute(`pickColor`);n&&n.array.length===t.length?(n.array.set(t),n.needsUpdate=!0):e.geometry.setAttribute(`pickColor`,new Do(t.slice(),4,!0))}reposition(){let[e,t,n]=this.focus.focusTruePos,r=this.basisPos;for(let i of dP)for(let a of this.workerPoints[i].values()){let i=a.userData.frontBasis??r,[o,s,c]=this.parentShift(a.userData.groupId,a.userData.parentBodyId);a.position.set(i[0]-e+o,i[1]-t+s,i[2]-n+c)}let[i,a,o]=r,s=i-e,c=a-t,l=o-n;for(let e of this.moonPoints.values())e.position.set(s,c,l)}parentShift(e,t){let n=this.parentAtUpdate.get(e),r=this.ctx.getBody(t)?.position;return!n||!r?[0,0,0]:[r[0]-n[0],r[1]-n[1],r[2]-n[2]]}maybeRebase(){let[e,t,n]=this.focus.focusTruePos,[r,i,a]=this.basisPos,o=e-r,s=t-i,c=n-a,l=o*o+s*s+c*c,u=uP*10;l>u*u&&this.rebuildBasis()}rebuildBasis(){this.basisPos=[...this.focus.focusTruePos],this.rebuildMoons(),this.onBasisRebuilt(),this.reposition()}updateForJd(e,t){this.writeMoons();let n=this._parentsScratch;n.clear();let r=this.ctx.getBody(`naif-10`)?.position??[0,0,0];for(let[i,a]of this.workerPoints.asteroid){if(!this.ctx.visibility.isAsteroidGroupVisible(S_(i)))continue;let o=a.userData.groupId;if(!this.shouldSolveGroup(o,r,e,t))continue;let s=a.userData.parentVec;s[0]=r[0],s[1]=r[1],s[2]=r[2],n.set(o,s)}for(let[r,i]of this.workerPoints.spacecraft){if(!this.ctx.visibility.isSpacecraftGroupVisible(S_(r)))continue;let a=i.userData.groupId,o=this.ctx.getBody(i.userData.parentBodyId)?.position;if(o&&!this.shouldSolveGroup(a,o,e,t))continue;let s=i.userData.parentVec;o?(s[0]=o[0],s[1]=o[1],s[2]=o[2]):(s[0]=0,s[1]=0,s[2]=0),n.set(a,s)}this.orbitPool.tick(e,this.basisPos,n,this.ctx.visibility.getRequiredFlags())}shouldSolveGroup(e,t,n,r){let i=this.groupKinematics.get(e);if(!i||i.alwaysSolve)return!0;let a=this.lastSolvedJd.get(e);if(a===void 0||!isFinite(a))return!0;let[o,s,c]=this.focus.focusTruePos,l=r.camPos[0]-(t[0]-o),u=r.camPos[1]-(t[1]-s),d=r.camPos[2]-(t[2]-c),f=Math.max(1e-6,Math.sqrt(l*l+u*u+d*d)),p=Math.abs(n-a);return i.maxSpeedScene*p/f*r.pxPerRad>=pP}forgetGroupGate(e){this.groupKinematics.delete(e),this.lastSolvedJd.delete(e)}moonsByParent(){let e=this.ctx.bodies.majorBodies.length;if(this.moonsByParentCache?.len===e)return this.moonsByParentCache.map;let t=new Map;for(let e of this.ctx.bodies.majorBodies)if(e.data.objectType===W.MOON){let n=t.get(e.data.parentId)??[];n.push(e),t.set(e.data.parentId,n)}return this.moonsByParentCache={len:e,map:t},t}writeMoons(){let[e,t,n]=this.basisPos;for(let[r,i]of this.moonsByParent()){let a=this.moonPoints.get(r);if(!a||!this.ctx.visibility.isMoonGroupVisible(r))continue;let o=a.geometry.getAttribute(`position`),s=o.array,c=Math.min(i.length,s.length/3);for(let r=0;r<c;r++){let a=i[r];if(this.bodyObjects.get(a.data.id)?.outOfRange){s[r*3]=s[r*3+1]=s[r*3+2]=NaN;continue}s[r*3]=a.position[0]-e,s[r*3+1]=a.position[1]-t,s[r*3+2]=a.position[2]-n}o.needsUpdate=!0}}rebuildMoons(){let e=this.basisPos;for(let[t,n]of this.moonsByParent()){let r=this.moonPoints.get(t);if(!r)continue;let i=new Float32Array(n.length*3);for(let t=0;t<n.length;t++)i[t*3]=n[t].position[0]-e[0],i[t*3+1]=n[t].position[1]-e[1],i[t*3+2]=n[t].position[2]-e[2];r.geometry.setAttribute(`position`,new Ao(i,3))}}hasPendingSceneAdds(){return this.pendingSceneAdds.length>0}drainOnePendingSceneAdd(){if(this.pendingSceneAdds.length===0)return;let e=this.pendingSceneAdds.shift();e.layers.set(this.mapLayer),this.scene.add(e)}asteroids(){return this.workerPoints.asteroid}spacecraft(){return this.workerPoints.spacecraft}moons(){return this.moonPoints}dispose(){this.disposed=!0,this.orbitPool.destroy(),this.pickRegistry.clear();for(let e of dP)this.disposeClouds(this.workerPoints[e]);this.disposeClouds(this.moonPoints);for(let e of this.pendingSceneAdds)e.geometry.dispose(),e.material.dispose();this.pendingSceneAdds.length=0}disposeClouds(e){for(let t of e.values())this.scene.remove(t),t.geometry.dispose(),t.material.dispose();e.clear()}},NP=Math.PI/180,PP=2451545,FP=1.00000261,IP=.01671123,LP=100.46457166*NP,RP=35999.37244981/36525*NP,zP=102.93768193*NP,BP=.32327364/36525*NP;function VP(e){let t=e-PP,n=zP+BP*t,r=LP+RP*t-n,i=r+(2*IP-IP**3/4)*Math.sin(r)+1.25*IP*IP*Math.sin(2*r);return{lon:n+i,r:FP*(1-IP*IP)/(1+IP*Math.cos(i))}}function HP(e){let t=VP(e).lon;return(e,n)=>{let r=t-VP(e).lon,i=Math.cos(r),a=Math.sin(r),o=n[0],s=n[2];n[0]=o*i+s*a,n[2]=-o*a+s*i}}var UP=.01,WP=1/100,GP=1;function KP(e,t,n){if(!n)return 0;let r=1/0;for(let i=0;i<t;i++){let t=e[i*3]-n.camX,a=e[i*3+1]-n.camY,o=e[i*3+2]-n.camZ,s=t*t+a*a+o*o;s<r&&(r=s)}return Math.sqrt(r)*n.tolAngle}function qP(e,t,n,r,i,a,o,s,c){if(t!==e.lastVersion||e.lastOffX===void 0)return!1;let l=e.rewriteTol;if(c){let t=c.camX-e.lastCamX,n=c.camY-e.lastCamY,r=c.camZ-e.lastCamZ;l=Math.max(0,l-Math.sqrt(t*t+n*n+r*r)*c.tolAngle)}let u=(n-e.lastOffX)**2+(r-e.lastOffY)**2+(i-e.lastOffZ)**2,d=(a-e.lastHeadX)**2+(o-e.lastHeadY)**2+(s-e.lastHeadZ)**2;return u<=l*l&&d<=l*l}function JP(e,t,n,r,i,a,o,s,c,l,u){e.lastVersion=t,e.lastOffX=n,e.lastOffY=r,e.lastOffZ=i,e.lastHeadX=a,e.lastHeadY=o,e.lastHeadZ=s,e.lastCamX=u?.camX??0,e.lastCamY=u?.camY??0,e.lastCamZ=u?.camZ??0,e.rewriteTol=KP(c,l,u)}function YP(e,t,n,r,i,a){let o=t.userData,s=o.useTrail,c=o.orbitCenter,l=e.trailAnchor??e.position,u=c.x-r[0],d=c.y-r[1],f=c.z-r[2],p=l[0]-c.x,m=l[1]-c.y,h=l[2]-c.z,g=e.lagrangeTrail?NaN:n.newestJd+n.count*1e-9;if(qP(o,g,u,d,f,p,m,h,a))return;let{posArr:_,trailArr:v,fullArr:y}=pN(t),b=e.lagrangeTrail?HP(i):null,x=hN(e,n,_,c.x,c.y,c.z,r,b??void 0);mN(t,_,v,y,x,!0,s),JP(o,g,u,d,f,p,m,h,_,x,a)}function XP(e,t,n,r,i){let{posArr:a,trailArr:o,fullArr:s,capacity:c}=pN(e),l=Math.min(t.length,c);for(let e=0;e<l;e++)a[e*3]=t[e][0]+n,a[e*3+1]=t[e][1]+r,a[e*3+2]=t[e][2]+i;if(e.userData.lastOffX=void 0,e.userData.isFatLine){lN(e.geometry,a,o,s,l);return}e.geometry.getAttribute(`position`).needsUpdate=!0}function ZP(e,t,n,r,i){let a=t.userData.trailBuffer;if(a){YP(e,t,a,n,r,i);return}let o=t.userData.sourceCurve;if(!o){if(!t.userData.curvePending||!e.orbitElements)return;o=oN(Kv(e.orbitElements,r),512).points,t.userData.sourceCurve=o,t.userData.curveJd=r,t.userData.curvePending=!1}let s=t.userData.isOpenCurve,c=t.userData.useTrail,l=t.userData.orbitCenter,u=l.x,d=l.y,f=l.z;if(e.data.satrec){let n=e.data.n/360,i=n>0?1/n/512:0,a=t.userData.curveJd;(o.length===0||a===void 0||Math.abs(r-a)>=i)&&(o=iN(e.data.satrec,r,n,512),t.userData.sourceCurve=o,t.userData.curveJd=r)}else if(e.orbitElements){if(e.rederiveElements){let n=t.userData.elementsJd??r,i=e.orbitElements.n,a=i>0?360/i:1/0;if(Math.abs(r-n)>Math.min(a*WP,GP)){let n=e.rederiveElements(r);n&&(Object.assign(e.orbitElements,n),o=oN(e.orbitElements,512).points,t.userData.sourceCurve=o,t.userData.curveJd=r,t.userData.elementsJd=r)}}let n=e.orbitElements.omDot??0,i=e.orbitElements.wDot??0,a=Math.max(Math.abs(n),Math.abs(i));if(a>0){let n=t.userData.curveJd??r;a*Math.abs(r-n)>UP&&(o=oN(Kv(e.orbitElements,r),512).points,t.userData.sourceCurve=o,t.userData.curveJd=r)}}let p=e.trailAnchor??e.position,m=t.userData,h=u-n[0],g=d-n[1],_=f-n[2],v=p[0]-u,y=p[1]-d,b=p[2]-f;if(qP(m,o,h,g,_,v,y,b,i))return;let x=eb(e,o,s,u,d,f);if(x.length<2)return;let{posArr:S,trailArr:C,fullArr:w,capacity:T}=pN(t),E=u-n[0],D=d-n[1],O=f-n[2],k=Math.min(x.length,T);for(let e=0;e<k;e++)S[e*3]=x[e][0]+E,S[e*3+1]=x[e][1]+D,S[e*3+2]=x[e][2]+O;mN(t,S,C,w,k,s,c),m.trailLocalPositions=x,JP(m,o,h,g,_,v,y,b,S,k,i)}function QP(e,t,n){let r=e===$.CAPPED;return{groupVisible:e===$.CLOSE||e===$.FULL||r&&t,orbitVisible:e===$.FULL||e===$.CLOSE&&n,showLabel:e===$.FULL||r&&t,isClose:e===$.CLOSE}}function $P(e,t,n){return{groupVisible:e===$.CLOSE||e===$.FULL,orbitVisible:e===$.FULL&&t||e===$.CLOSE&&n,showLabel:e===$.FULL&&t,isClose:t&&e===$.CLOSE}}var eF=4/2,tF=(.1*10)**2,nF=new J,rF=[],iF=rF;function aF(e){return tk(rF,e,ak)}var oF={x:0,y:0,left:0,right:0,h:0},sF=new Hi,cF={ox:0,oy:0},lF=new J,uF=new J;function dF(e,t,n,r,i,o,s,c,l,u,d,f,p,m,h){let g=n.layers,_=!g.isVisible(`orbits`),v=g.isVisible(`nomenclature`),y=t.fov*Math.PI/180,b=f.domElement.clientWidth,x=f.domElement.clientHeight,S=x/(2*Math.tan(y/2)),C=[r[0]+t.position.x,r[1]+t.position.y,r[2]+t.position.z],w=r,T=t.matrixWorldInverse;for(let n of e.values()){if(n.cachedDist=R_(C,n.body.position),n.isCrashed||n.noPhysical){let e=n.noPhysical===`model`,t=cg(n.cachedDist)<(n.isCrashed||e?.1:1),r=null;if(t){let t=a().messages;r=n.isCrashed?t.body_note_crash_site():e?t.body_note_no_model():t.body_note_no_radius()}QE(n,`missing`,r)}let e=n.label;if(!e)continue;n.labelAnchorOffscreen=!1;let r=n.noPhysical?0:n.radiusScene;if(!r){e.position.set(0,0,0);continue}let[i,o,s]=n.body.position;p.set(i-w[0],o-w[1],s-w[2]).applyMatrix4(T);let c=p.x,l=p.y,u=p.z,d=u*u,f=r*r;if(d<=f){e.position.set(0,0,0),n.labelAnchorOffscreen=!0;continue}let m=r/n.cachedDist*S;if(m<1){e.position.set(0,0,0);continue}if(m>=16){let a=n.cachedDist,d=1/a,f=c*d,m=l*d,h=u*d,g=r*d,_=Math.sqrt(Math.max(1-g*g,0)),v=1-f*f,y=-f*m,b=-f*h,x=Math.hypot(v,y,b);x<1e-4&&(v=-m*f,y=1-m*m,b=-m*h,x=Math.hypot(v,y,b));let S=g/x,C=f*_+v*S,T=m*_+y*S,E=h*_+b*S;p.set(C*a-c,T*a-l,E*a-u).applyQuaternion(t.quaternion),e.position.copy(p),uF.set(i-w[0]+p.x,o-w[1]+p.y,s-w[2]+p.z).project(t),n.labelAnchorOffscreen=Math.abs(uF.x)>1||Math.abs(uF.y)>1;continue}if(n.semiAxesScene&&n.mesh)QN(c,l,u,YN(n.mesh.getWorldQuaternion(sF),T,n.semiAxesScene),S,cF),p.set(cF.ox,cF.oy,0).applyQuaternion(t.quaternion);else{let e=f/(d-f);p.set(e*c,e*l,0).applyQuaternion(t.quaternion)}e.position.copy(p)}let E=rF,D=b*.5,O=x*.5,k=0;for(let t of e.values()){let e=t.noPhysical?0:t.radiusScene;if(!e)continue;let n=t.cachedDist,[r,i,a]=t.body.position,o=t.model?.userData.occluderSpheres;if(t.model&&o?.length){let e=nO(t),s=t.model.position;for(let c of o){let o=c.r*e;if(lF.copy(c.center).applyQuaternion(t.model.quaternion).add(s).multiplyScalar(e),p.set(r-w[0]+lF.x,i-w[1]+lF.y,a-w[2]+lF.z).applyMatrix4(T),p.z>=o||p.lengthSq()<=o*o)continue;let l=p.z*p.z;(l<=o*o||o*S/Math.sqrt(l-o*o)>=16)&&XN(aF(k++),p.x,p.y,p.z,o,S,D,O,t.body.data.id,n)}continue}p.set(r-w[0],i-w[1],a-w[2]).applyMatrix4(T);let s=p.x,c=p.y,l=p.z;if(l>=e)continue;let u=l*l;(u<=e*e||e*S/Math.sqrt(u-e*e)>=16)&&(t.semiAxesScene&&t.mesh?ZN(aF(k++),s,c,l,YN(t.mesh.getWorldQuaternion(sF),T,t.semiAxesScene),S,D,O,t.body.data.id,n):XN(aF(k++),s,c,l,e,S,D,O,t.body.data.id,n))}E.length=k;let A=n.visibility.focusedSystemId,j=!1,M=i?xM(n.getBody(i),e):void 0;for(let r of e.values()){let{body:a,group:s,trail:c}=r,l=r.cachedDist,u,d,f=a.data.id===i,p=A!==null&&a.data.id===A;if(r.mesh===null&&!vn(a.data.objectType)){let t=a.data.objectType;if(t===W.BARYCENTER||t===W.LAGRANGE_POINT){let t=!0,r=f?void 0:P_(a.data.id);if(r){let i=e.get(r)?.body??n.getBody(r);i&&R_(a.position,i.position)/R_(C,i.position)*S<16&&(t=!1)}s.visible=t,c&&(c.visible=t),u=t,d=!1}else{let e=n.visibility.getPlanetVisibility(a,l)!==$.HIDE&&n.visibility.hasFullRendering(a);s.visible=e,c&&(c.visible=e),u=e,d=!1}}else{let e=a.data.objectType===W.MOON,t=e?n.visibility.getMoonVisibility(a):n.visibility.getPlanetVisibility(a,l),r=e?QP(t,o,f):$P(t,n.visibility.hasFullRendering(a),f||p);s.visible=r.groupVisible,c&&(c.visible=r.orbitVisible),u=r.showLabel,d=r.isClose}if(r.outOfRange&&(s.visible=!1,c&&(c.visible=!1),u=!1),r.starPoint){let e=r.radiusScene/l*S,t=e<eF;if(r.starPoint.visible=t,t){let t=r.starPoint.material,n=e/eF,i=Math.max($A*n*n,3);t.uniforms.uIntensity.value=i}s.visible=!0,d=!t,u=!d}if(r.isMinor&&!f&&c&&(c.visible=!1),h&&c?.visible){let e=c.userData.orbitCenter;e&&e.distanceToSquared(nF.set(w[0],w[1],w[2]))>tF&&(c.visible=!1)}_&&c&&(c.visible=!1),s.matrixWorldAutoUpdate=s.visible;let{label:m}=r;if(!s.visible&&m&&m.parent===s?(s.remove(m),m.element.remove()):s.visible&&m&&m.parent!==s&&s.add(m),r.mesh&&r.radiusScene>0){let e=!f&&!p&&r.radiusScene/l*S<.5;e!==r.meshSubPixel&&(r.meshSubPixel=e,e?r.mesh.layers.disable(0):r.mesh.layers.enable(0))}uk(r,u,d,l,S,i)&&(j=!0);let g=r.radiusScene>0?r.radiusScene/l*S:0;UM(r,v&&a.data.id===M,g,t,b,x)}for(let[e,t]of c)t.visible=n.visibility.isAsteroidGroupVisible(S_(e));for(let[e,t]of l)t.visible=n.visibility.isSpacecraftGroupVisible(S_(e));for(let[e,t]of u)t.visible=n.visibility.isMoonGroupVisible(e);if(E.length>0)for(let n of e.values())n.label?.visible&&pk(n,t,w,b,x,oF)&&dk(oF.x,oF.y,n.cachedDist,n.body.data.id,E)&&(n.label.visible=!1);if((m||j||++d>=3)&&(d=0,Ek(e,b,x,t,i,n,s,E,r)),Dk(e,b,x,t,r),M){let t=e.get(M);t&&qM(t)}for(let n of e.values()){let e=n.trail;if(!e?.visible)continue;let r=e.material;r.uniforms.uCenterOffset.value.set(-t.position.x,-t.position.y,-t.position.z);let a=n.body.data.id===i,o=s.has(n.body.data.id);r.uniforms.uAlphaMultiplier.value=o?2:a?1.75:1;let c=e.userData.isOpenCurve===!1;r.uniforms.uAlphaMin.value=a&&c?.15:0,r.uniforms.uShowFull.value=+!!a}return d}function fF(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function pF(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}function mF(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function hF(e,t){let n=e.arcs[t].points.length,r=t=>e.endOrbits.find(e=>e.at===t);return{from:t===0?r(`departure`)?.trimFrom??0:0,to:t===e.arcs.length-1?r(`arrival`)?.trimTo??n:n}}function gF(e,t){let n=e.arcs[0],r=e.arcs[e.arcs.length-1];if(!n||!r)return null;let i=t=>e.endOrbits.find(e=>e.at===t)??null,a=i(`departure`),o=i(`arrival`),s=e=>e&&e.approach.length>1?e:null,c=s(a),l=s(o),u=e=>e&&e.pointJds&&e.points.length>1&&e.pointJds.length===e.points.length?{points:e.points,jds:e.pointJds}:null,d=u(a),f=o?.surfaceJd===void 0?u(o):null,p=Math.min(n.startJd,a?.surfaceJd??1/0),m=Math.max(r.endJd,o?.surfaceJd??l?.jds[l.jds.length-1]??-1/0),h=d?p-_F(d):p,g=f?m+_F(f):m;if(t<h||t>g)return null;if(a&&d&&t<(c?.jds[0]??n.startJd))return{r:vF(d,t),centerId:a.anchorId};if(c&&t<=c.jds[c.jds.length-1])return{r:yF(c.approach,c.jds,t),centerId:c.anchorId};if(o&&t>=(l?.jds[0]??r.endJd)){let e=o.surfaceJd??l?.jds[l.jds.length-1]??r.endJd;if(f&&(!l||t>e))return{r:vF(f,t),centerId:o.anchorId};if(l)return{r:yF(l.approach,l.jds,Math.min(t,e)),centerId:o.anchorId}}let _=e.arcs.findIndex(e=>t>=e.startJd&&t<=e.endJd),v=_>=0?_:e.arcs.length-1,{points:y,jds:b}=e.arcs[v];if(y.length===0)return null;if(y.length===1||b.length!==y.length)return{r:y[0],centerId:e.centerId};let{from:x,to:S}=hF(e,v);return{r:yF(y,b,t,x,S),centerId:e.centerId}}function _F(e){return e.jds[e.jds.length-1]-e.jds[0]}function vF(e,t){let n=_F(e),r=e.jds[0],i=n>0?r+((t-r)%n+n)%n:t;return yF(e.points,e.jds,i)}function yF(e,t,n,r=0,i=e.length){if(i-r<2)return e[r];let a=r+1;for(;a<i-1&&t[a]<n;)a++;let o=t[a]-t[a-1],s=o>0?Math.min(1,Math.max(0,(n-t[a-1])/o)):0;return fF(e[a-1],mF(pF(e[a],e[a-1]),s))}var bF=Math.PI/180,xF=Math.cos(ag*bF),SF=Math.sin(ag*bF);function CF(e,t,n,r){let i=Math.cos(e*bF),a=Math.sin(e*bF),o=Math.cos(t*bF),s=Math.sin(t*bF),c=Math.cos(n*bF),l=Math.sin(n*bF);return{m11:c*i-l*a*o,m12:-c*a-l*i*o,m21:l*i+c*a*o,m22:-l*a+c*i*o,m31:a*s,m32:i*s,equatorial:r}}function wF(e,t,n){let r=n.m11*e+n.m12*t,i=n.m21*e+n.m22*t,a=n.m31*e+n.m32*t;if(n.equatorial){let e=i*xF+a*SF,t=-i*SF+a*xF;i=e,a=t}return[r,i,a]}function TF(e){let t=10/ig;return[e[0]*t,e[2]*t,-e[1]*t]}function EF(e,t,n){let{a:r,e:i,ma:a,n:o,epoch:s,q:c,tp:l}=e,{om:u,w:d}=Kv(e,t),f=e.equatorial??!1;if(!isFinite(r)||r===0||!isFinite(o)||o<=0){if(c==null||l==null||!isFinite(c)||!isFinite(l)||c<=0)return null;let r=wg(c,l,t);if(!r)return null;let i=n&&n>0?n:ev,a=r.r*ig,o=2*c*ig;return DF(a,r.nu,o,1,i,d,e.i,u,f)}if(!isFinite(i)||!isFinite(a))return null;let p=r*ig,m=o*bF/tv,h=n&&n>0?n:m*m*Math.abs(p)*Math.abs(p)*Math.abs(p);if(!isFinite(h)||h<=0)return null;let g=(a+o*(t-s))*bF,_,v;if(i<1||r>0){let e=Math.min(i,.9999999),t=xg(g,e),n=1-e*Math.cos(t);_=Math.atan2(Math.sqrt(1-e*e)*Math.sin(t),Math.cos(t)-e),v=p*n}else{let e=Cg(g,i);if(!isFinite(e))return null;let t=i*Math.cosh(e)-1;if(Math.abs(t)<1e-15)return null;_=Math.atan2(Math.sqrt(i*i-1)*Math.sinh(e)/t,(i-Math.cosh(e))/t),v=p*(1-i*Math.cosh(e))}if(!isFinite(v)||v<=0)return null;let y=p*(1-i*i);return!isFinite(y)||y<=0?null:DF(v,_,y,i,h,d,e.i,u,f)}function DF(e,t,n,r,i,a,o,s,c){let l=Math.cos(t),u=Math.sin(t),d=Math.sqrt(i/n),f=CF(a,o,s,c),p=wF(e*l,e*u,f),m=wF(-d*u,d*(r+l),f);return!isFinite(p[0]+p[1]+p[2])||!isFinite(m[0]+m[1]+m[2])?null:{r:p,v:m,mu:i}}var OF={cruise:`#7fdbff`,boost:`#ffb454`,brake:`#ff8c69`,spiral:`#c9a0ff`,"spiral-out":`#9b7fd4`,"spiral-in":`#9b7fd4`};OF.cruise,OF.boost,OF.brake,OF.spiral,OF[`spiral-out`],OF[`spiral-in`];var kF={notice:`#8ab4f8`,caution:`#f2b23e`,severe:`#ff6b5a`},AF=3,jF=1,MF=2,NF=.6,PF=1.5,FF=.3,IF=1.5,LF=.85,RF=60,zF=.018,BF=.026,VF=`#ffffff`,HF=4,UF=1.5,WF=9,GF=1,KF={notice:HF-3,caution:HF-2,severe:HF-1},qF=[`notice`,`caution`,`severe`],JF=.03,YF=.2;function XF(e){let t=document.createElement(`canvas`);t.width=t.height=64;let n=t.getContext(`2d`);return n.beginPath(),n.arc(64/2,64/2,64/2-10,0,Math.PI*2),n.fillStyle=e,n.fill(),n.lineWidth=6,n.strokeStyle=`rgba(0,0,0,0.65)`,n.stroke(),new Nc(t)}function ZF(e){let t=document.createElement(`canvas`);t.width=t.height=64;let n=t.getContext(`2d`);return n.beginPath(),n.moveTo(64/2,8),n.lineTo(56,56),n.lineTo(8,56),n.closePath(),n.fillStyle=e,n.fill(),n.lineWidth=6,n.lineJoin=`round`,n.strokeStyle=`rgba(0,0,0,0.65)`,n.stroke(),new Nc(t)}function QF(e,t,n,r){let i=[];for(let a=r.from;a<r.to;a++)e.jds[a]>=t&&e.jds[a]<=n&&i.push(e.points[a]);return i}function $F(e,t){let n=new cs(new Jo({map:e,transparent:!0,sizeAttenuation:!1,depthTest:!1}));return n.scale.setScalar(t),n.renderOrder=HF,n}function eI(e,t,n,r){let{canvas:i,color:a,onSelect:o,onHover:s}=r,c=document.createElement(o?`button`:`div`);c instanceof HTMLButtonElement&&(c.type=`button`),c.className=e===`step`?`scene-path-label scene-path-label--step`:`scene-path-label${o?``:` scene-path-label--static`}`,c.setAttribute(`aria-label`,`${t} \u2014 ${n}`);let l=document.createElement(`span`);l.className=`scene-path-label__halo`,a&&(l.style.border=`2px solid ${a}`,l.style.background=`${a}22`);let u=document.createElement(`span`);u.className=`scene-path-label__text`;let d=document.createElement(`span`);d.className=`scene-path-label__name`,d.dir=`auto`,d.textContent=t;let f=document.createElement(`span`);f.className=`scene-path-label__when`,f.dir=`auto`,f.textContent=n,u.append(d,f),c.append(l,u),o&&(Lk(c,i),bM(c,o)),s&&(c.addEventListener(`mouseenter`,()=>s(!0)),c.addEventListener(`mouseleave`,()=>s(!1)));let p=new $O(c);return p.center.set(0,.5),p}var tI=class{group=new za;arcs=[];rings=[];markers=[];labels=[];drawnSteps=[];craft=null;path=null;center=null;layer=null;offset=new J;projected=new J;rects=[];order=[];hovered=null;tint=new X;constructor(e,t){this.scene=e,this.canvas=t,this.group.frustumCulled=!1,this.scene.add(this.group)}get centerId(){return this.center}get isEmpty(){return this.center===null}get plan(){return this.path}setLayer(e){this.layer=e,this.group.traverse(t=>t.layers.set(e))}set(e,t=[],n=[],r=[]){this.clear(),this.path=e?.path??null,this.center=e?.path.centerId??t[0]?.path.centerId??null;let i=e!==null;for(let e of t)this.addArcs(e.path,i?PF:MF,i?FF:NF,e.id),this.addEndLabels(e,i);e&&(this.addPlan(e,r),this.addHazards(e.path,n)),this.applyHover(),this.layer!==null&&this.setLayer(this.layer)}addHazards(e,t){let n=[...t].sort((e,t)=>qF.indexOf(e.severity)-qF.indexOf(t.severity));for(let t of n){let n=kF[t.severity];for(let n of t.bands)e.arcs.forEach((t,r)=>{this.addLine(QF(t,n.startJd,n.endJd,hF(e,r)),kF[n.severity],WF,GF,null,{renderOrder:KF[n.severity]})});if(this.mergeIntoStep(t,n))continue;let r=gF(e,t.startJd);if(!r)continue;let i=TF(r.r),a=r.centerId===e.centerId?null:r.centerId,o=$F(ZF(n),JF);this.group.add(o),this.markers.push({sprite:o,local:i,anchorId:a});let s=document.createElement(`div`);s.className=`scene-hazard-label`,s.style.color=n,s.textContent=t.label;let c=new $O(s);c.center.set(0,.5),this.group.add(c),this.labels.push({object:c,local:i,anchorId:a,owner:null,width:0,height:0,dimmed:!1,faint:!0})}}mergeIntoStep(e,t){let n=e.kind===`aeroassist`?`aero-pass`:e.kind===`belt-crossing`?`assist`:null;if(!n)return!1;let r=null,i=1/0;for(let{step:t,label:a}of this.drawnSteps){if(t.kind!==n||e.bodyId&&t.bodyId!==e.bodyId)continue;let o=Math.abs(t.jd-e.peakJd);o<i&&(i=o,r=a)}if(!r)return!1;let a=r.object.element,o=document.createElement(`span`);return o.className=`scene-path-label__hazard`,o.style.color=t,o.dir=`auto`,o.textContent=e.label,a.querySelector(`.scene-path-label__text`)?.append(o),a.setAttribute(`aria-label`,`${a.getAttribute(`aria-label`)} — ${e.label}`),!0}addPlan(e,t){let n=e.path;this.addArcs(n,AF,jF,null,!0),this.addEndOrbits(n),this.addSteps(n,t);for(let e of this.markers)this.group.add(e.sprite);this.craft={sprite:$F(XF(VF),BF),local:[0,0,0],anchorId:null},this.craft.sprite.visible=!1,this.group.add(this.craft.sprite)}addSteps(e,t){for(let n of t){let t=gF(e,n.jd);if(!t)continue;let r=TF(t.r),i=t.centerId===e.centerId?null:t.centerId,a=$F(XF(VF),zF);this.markers.push({sprite:a,local:r,anchorId:i});let o=eI(`step`,n.name,n.when,{canvas:this.canvas,onSelect:n.onPick});this.group.add(o),this.labels.push({object:o,local:r,anchorId:i,owner:null,width:0,height:0,dimmed:!1,faint:!1,step:!0,sprite:a}),this.drawnSteps.push({step:n,label:this.labels[this.labels.length-1]})}}addEndLabels(e,t=!1){let{path:n,onSelect:r}=e,i=n.arcs[0],a=n.arcs[n.arcs.length-1],o=n.stops.find(e=>e.kind===`departure`),s=[{local:TF(n.meeting.r),end:e.arrival,color:OF[a?.kind??`cruise`]}];o&&s.push({local:TF(o.r),end:e.departure,color:OF[i?.kind??`cruise`]});for(let{local:n,end:i,color:a}of s){if(!i.name)continue;let o=eI(`end`,i.name,i.when,{canvas:this.canvas,color:a,onSelect:r,onHover:e.onHover});t&&o.element.classList.add(`scene-path-label--faint`),this.group.add(o),this.labels.push({object:o,local:n,anchorId:null,owner:r?e.id:null,width:0,height:0,dimmed:!1,faint:t})}}setHovered(e){this.hovered!==e&&(this.hovered=e,this.applyHover())}applyHover(){for(let e of this.arcs){if(e.owner===null)continue;let t=e.owner===this.hovered,n=e.line.material;n.uniforms.uColor.value.set(e.color).multiplyScalar(t?jF:e.brightness),n.uniforms.uLineWidth.value=t?AF:e.width}for(let e of this.labels)e.owner!==null&&e.object.element.classList.toggle(`scene-path-label--lit`,e.owner===this.hovered)}addArcs(e,t,n,r=null,i=!1){let a=i&&e.frame===`planetary`,o=t=>a&&e.endOrbits.some(e=>e.at===t&&e.approach.length>1);e.arcs.forEach((a,s)=>{let{from:c,to:l}=i?hF(e,s):{from:0,to:a.points.length};this.addLine(a.points.slice(c,l),OF[a.kind],t,n,r,{fadeIn:s===0&&o(`departure`),fadeOut:s===e.arcs.length-1&&o(`arrival`)})})}addEndOrbits(e){for(let t of e.endOrbits){let n=this.anchorOf(e,t),r=(t.ground??[]).filter(e=>e.to>e.from);if(r.length>0){let e=0;for(let i of r)i.from>e&&this.addLine(t.approach.slice(Math.max(0,e-1),i.from+1),OF.cruise,AF,jF,null,{anchorId:n}),this.addLine(t.approach.slice(i.from,i.to),OF.cruise,AF,jF,null,{anchorId:n,renderOrder:UF}),e=i.to;e<t.approach.length&&this.addLine(t.approach.slice(Math.max(0,e-1)),OF.cruise,AF,jF,null,{anchorId:n})}else if(t.turn){let{from:e,to:r}=t.turn,i=t.approach.slice(0,e+1),a=t.approach.slice(r-1);for(let e of[i,a])e.length<2||this.addLine(e,OF.cruise,AF,jF,null,{anchorId:n});this.addLine(t.approach.slice(e>0?e-1:0,r),OF.cruise,IF,LF,null,{anchorId:n})}else this.addLine(t.approach,OF.cruise,AF,jF,null,{anchorId:n});let i=this.addLine(t.points,OF.cruise,IF,LF,null,{anchorId:n});if(!i)continue;let a=n===null?TF(t.center):[0,0,0];i.line.visible=!1,this.rings.push({arc:i,local:a,radius:Q(t.radiusKm),world:new J})}}anchorOf(e,t){return t.anchorId===e.centerId?null:t.anchorId}addLine(e,t,n,r,i,a={}){let o=e.length;if(o<2)return null;let s=new Float64Array(o*3);for(let t=0;t<o;t++){let[n,r,i]=TF(e[t]);s[t*3]=n,s[t*3+1]=r,s[t*3+2]=i}let c=new Float32Array(o*3),l=new Float32Array(o).fill(1),u=Math.max(1,Math.round(o*YF));for(let e=0;e<u;e++){let t=(e+1)/(u+1);a.fadeIn&&(l[e]=t),a.fadeOut&&(l[o-1-e]=t)}let d=fN(o,c,l,l,o,t,n,r);d.frustumCulled=!1,d.renderOrder=a.renderOrder??HF,this.group.add(d);let f={line:d,owner:i,anchorId:a.anchorId??null,color:t,brightness:r,width:n,local:s,positions:c,alphas:l,count:o};return this.arcs.push(f),f}setClock(e){let t=this.craft;if(!t||!this.path)return;let n=gF(this.path,e);t.sprite.visible=n!==null,n&&(t.local=TF(n.r),t.anchorId=n.centerId===this.path.centerId?null:n.centerId)}reposition(e,t,n){if(this.center===null)return;let r=e[0]-t[0],i=e[1]-t[1],a=e[2]-t[2],o=new Map,s=e=>{if(e===null)return[r,i,a];let s=o.get(e);if(s)return s;let c=n(e),l=c?[c[0]-t[0],c[1]-t[1],c[2]-t[2]]:[r,i,a];return o.set(e,l),l};for(let e of this.arcs){let[t,n,r]=s(e.anchorId);for(let i=0;i<e.count;i++)e.positions[i*3]=e.local[i*3]+t,e.positions[i*3+1]=e.local[i*3+1]+n,e.positions[i*3+2]=e.local[i*3+2]+r;lN(e.line.geometry,e.positions,e.alphas,e.alphas,e.count)}for(let e of this.markers){let[t,n,r]=s(e.anchorId);e.sprite.position.set(e.local[0]+t,e.local[1]+n,e.local[2]+r)}for(let e of this.labels){let[t,n,r]=s(e.anchorId);e.object.position.set(e.local[0]+t,e.local[1]+n,e.local[2]+r)}if(this.craft){let{sprite:e,local:t,anchorId:n}=this.craft,[r,i,a]=s(n);e.position.set(t[0]+r,t[1]+i,t[2]+a)}for(let e of this.rings){let[t,n,r]=s(e.arc.anchorId);e.world.set(e.local[0]+t,e.local[1]+n,e.local[2]+r)}}updateCameraOffset(e){if(this.arcs.length!==0){this.offset.set(-e.x,-e.y,-e.z);for(let e of this.arcs)e.line.material.uniforms.uCenterOffset.value.copy(this.offset);for(let t of this.rings){let n=t.world.distanceTo(e);t.arc.line.visible=n<t.radius*RF}}}setVisible(e){this.group.visible=e}reserveLabelSpace(e,t,n){if(!this.group.visible||this.labels.length===0){wk(this.rects,0);return}this.order.length=0;for(let r of this.labels){if(r.faint)continue;let i=r.object.element;if(!r.width&&!r.dimmed&&(r.width=i.offsetWidth,r.height=i.offsetHeight),!r.width||(this.projected.copy(r.object.position).project(e),!aT(this.projected.z)))continue;let a=(this.projected.x*.5+.5)*t,o=(-this.projected.y*.5+.5)*n,s=r.object.position.distanceTo(e.position);if(r.step){let e=dk(a,o,s,``,iF);if(this.setStepVisible(r,!e),e)continue}this.order.push({label:r,left:a-16,y:o,distance:s})}this.order.sort((e,t)=>e.label.step===t.label.step?e.distance-t.distance:e.label.step?1:-1);let r=0;for(let{label:e,left:t,y:n}of this.order){let i=t+16+e.width,a=!1;for(let o=0;o<r;o++){let r=this.rects[o];if(t<r.right&&i>r.left&&Math.abs(n-r.y)<(e.height+r.h)/2){a=!0;break}}if(this.setLabelDimmed(e,a),a)continue;let o=this.rects[r];o||(o={left:0,right:0,y:0,h:0},this.rects[r]=o),o.left=t,o.right=i,o.y=n,o.h=e.height,r++}wk(this.rects,r)}setStepVisible(e,t){e.object.visible=t,e.sprite&&(e.sprite.visible=t)}setLabelDimmed(e,t){e.dimmed!==t&&(e.dimmed=t,e.object.element.classList.toggle(`scene-path-label--dim`,t))}clear(){for(let e of this.arcs)this.group.remove(e.line),e.line.geometry.dispose(),e.line.material.dispose();for(let e of[...this.markers,...this.craft?[this.craft]:[]]){this.group.remove(e.sprite);let t=e.sprite.material;t.map?.dispose(),t.dispose()}for(let e of this.labels)this.group.remove(e.object),e.object.element.remove();this.arcs=[],this.rings=[],this.markers=[],this.labels=[],this.drawnSteps=[],this.craft=null,this.path=null,this.center=null}dispose(){this.clear(),this.scene.remove(this.group)}},nI=2,rI=1,iI=4,aI=200,oI=class{group=new za;slots=[];shown=0;layer=null;constructor(e){this.group.frustumCulled=!1,e.add(this.group)}get isEmpty(){return this.shown===0}set(e){let t=0;for(let n of e){if(n.pointsKm.length<2)continue;let e=this.slot(t++);e.bodyId=n.bodyId,e.count=Math.min(n.pointsKm.length,aI);for(let t=0;t<e.count;t++){let[r,i,a]=TF(n.pointsKm[t]);e.local[t*3]=r,e.local[t*3+1]=i,e.local[t*3+2]=a}}this.shown=t;for(let e=t;e<this.slots.length;e++)this.slots[e].line.visible=!1;this.group.visible=t>0}slot(e){for(;this.slots.length<=e;){let e=new Float32Array(aI*3),t=new Float32Array(aI).fill(1),n=fN(aI,e,t,t,0,OF.cruise,nI,rI);n.frustumCulled=!1,n.renderOrder=iI,this.layer!==null&&n.layers.set(this.layer),this.group.add(n),this.slots.push({line:n,bodyId:``,local:new Float64Array(aI*3),positions:e,alphas:t,count:0})}return this.slots[e]}setLayer(e){this.layer=e,this.group.traverse(t=>t.layers.set(e))}reposition(e,t){for(let n=0;n<this.shown;n++){let r=this.slots[n],i=e(r.bodyId);if(r.line.visible=i!==null,!i)continue;let a=i[0]-t[0],o=i[1]-t[1],s=i[2]-t[2];for(let e=0;e<r.count;e++)r.positions[e*3]=r.local[e*3]+a,r.positions[e*3+1]=r.local[e*3+1]+o,r.positions[e*3+2]=r.local[e*3+2]+s;lN(r.line.geometry,r.positions,r.alphas,r.alphas,r.count)}}updateCameraOffset(e){for(let t of this.slots)t.line.material.uniforms.uCenterOffset.value.set(-e.x,-e.y,-e.z)}},sI=30034e-10,cI=.45,lI=1.6,uI=.85,dI=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],fI=e=>Math.hypot(e[0],e[1],e[2]);function pI(e,t,n=sI){let r=fI(t);if(!(r>0))return null;let i=r*Math.cbrt(n/3),a=dI(e,t)/r,o=fI(e);if(Math.sqrt(Math.max(0,o*o-a*a))>uI*i)return null;let s=a/i;return s>=cI&&s<=lI?`EL1`:s<=-cI&&s>=-lI?`EL2`:null}function mI(){return{count:0,earliestStart:1/0,latestEnd:-1/0}}var hI=class{focused=!1;satSide=null;satJd=NaN;majSide=null;majJd=NaN;constructor(e){this.notices=e}update(e){let{jd:t,majorBodies:n,satellites:r}=e,i=null,a=NaN;n.count>0&&(Number.isFinite(n.latestEnd)&&t>n.latestEnd?(i=`after`,a=n.latestEnd):Number.isFinite(n.earliestStart)&&t<n.earliestStart?(i=`before`,a=n.earliestStart):i=`outside`);let o=r.kind===`covered`?null:r.kind,s=r.kind===`after`?Mg(r.lastMs):NaN,c=e.focusedOutOfRange;if(!(c===this.focused&&o===this.satSide&&Object.is(s,this.satJd)&&i===this.majSide&&Object.is(a,this.majJd))){if(Object.assign(this,{focused:c,satSide:o,satJd:s,majSide:i,majJd:a}),!c&&o===null&&i===null){this.notices.dismiss(`out-of-range`);return}this.notices.notify({topic:`out-of-range`,focusedOutOfRange:c,satellites:o===`after`?{side:`after`,jd:s}:o===`gap`?{side:`gap`}:null,majorBodies:i===`after`||i===`before`?{side:i,jd:a}:i===`outside`?{side:`outside`}:null})}}},gI=new Map,_I=new J;function vI(e,t,n,r,i,a,o){let s=Ey(n,r,wy(t));if(!s)return null;let c=`naif-${n.bodyNaifId}`,l=a.bodies.bodiesById.get(c);if(!l||!l.orientation)return null;let u=i.get(c);if(!u)return null;let d=l.data.radiusKm;if(!Number.isFinite(d)||d<=0)return null;let f=Math.PI/180,p=s.latDeg*f,m=s.lngDeg*f,h=Aw(o.get(c),c,d,p,m);h&&gI.set(e.id,h);let g=h??gI.get(e.id),_,v,y;if(g)[_,v,y]=g.pointKm;else{let e=Math.cos(p);_=d*e*Math.cos(m),v=d*Math.sin(p),y=-d*e*Math.sin(m)}let b=mC(l.orientation,r,l.nutPrec),x=new J(_,v,y).applyQuaternion(b),S=g?_I.set(g.normal[0],g.normal[1],g.normal[2]).applyQuaternion(b):null;return e.parentId=c,{x:u[0]+Q(x.x),y:u[1]+Q(x.y),z:u[2]+Q(x.z),parentPos:u,up:S}}var yI=[0,0,0],bI=new Hi,xI=4,SI=0,CI=new Map;function wI(e){return e.primary.target===`velocity`||e.secondary?.target===`velocity`}function TI(e,t,n){let r=CI.get(e),i=r?.dir??null;if(r&&t!==r.jd){let e=Math.sign(t-r.jd),a=(n[0]-r.pos[0])*e,o=(n[1]-r.pos[1])*e,s=(n[2]-r.pos[2])*e,c=Math.hypot(a,o,s);c>1e-12&&(i=[a/c,o/c,s/c])}return CI.set(e,{jd:t,pos:[n[0],n[1],n[2]],dir:i}),i??void 0}function EI(e){let{jd:t,ctx:n,bodyObjects:r,focus:i,focusedBody:o,positionMap:s,diagnostics:c,trailView:l,frame:u,outOfRange:d}=e;n.chebStore?.ensure(t),n.probeStore?.ensure(t);let f=n.visibility.activeSystemId,p=f?e=>n.bodies.isInSystem(`naif-${e}`,f):void 0,m={jd:t,satellites:{kind:`covered`},majorBodies:mI(),focusedOutOfRange:!1},h=o?.data.id,g=_x(n.probeStore?.ridesAt(t)??[],h,e=>n.getBody(e)?.data.name),_=[];if(o){let e=new Set([o.data.id]),t=n.getBody(o.data.parentId);for(;t&&!e.has(t.data.id);)e.add(t.data.id),_.push({id:t.data.id,oldPos:[t.position[0],t.position[1],t.position[2]],bo:r.get(t.data.id)}),t=n.getBody(t.data.parentId)}s.clear(),s.set(`naif-0`,[0,0,0]);for(let e of n.bodies.bodiesById.values())s.set(e.data.id,e.position);for(let e of r.values())n.bodies.bodiesById.has(e.body.data.id)||s.set(e.body.data.id,e.body.position);let v=new Set,y=e=>{if(v.has(e))return;let t=n.bodies.bodiesById.get(e)??r.get(e)?.body;t&&S(t)},b=performance.now(),x=e=>{let t=n.bodies.hostRead.get(e);return t===void 0?!1:b-t<2e3?!0:(n.bodies.hostRead.delete(e),!1)},S=e=>{if(v.has(e.data.id))return;v.add(e.data.id);let i=e.data,o=r.get(i.id);if(o&&u!==void 0&&i.id!==h&&!x(i.id)&&!o.group.visible&&!o.trail?.visible&&(i.orbitalSource===U.SPICE_PROBE||!vn(i.objectType))&&(o.staggerSlot??=SI++%xI,u%xI!==o.staggerSlot))return;let l=(n=!1)=>{o&&(o.outOfRange=!0),e.positionUnknown=!0,e.placedJd=t,!n&&i.id===h&&(m.focusedOutOfRange=!0)};if(i.unplaceable){l(!0);return}let d=n.chebStore?.has(i.id)??!1,f=i.orbitalSource===U.SPICE_PROBE;if(f){if(g.hidden.has(i.id)){l(!0);return}if(o){let e=g.credits.get(i.id);QE(o,`carrier`,e?a().messages.carried_by_scene_label({carrier:e}):null)}}if(i.visibleFromDays!==void 0&&t-2451545<i.visibleFromDays){l();return}let _;if(f)_=s.get(i.parentId)??[0,0,0];else{let e=s.get(i.parentId);if(!e){l(),c.warnOnce(`missing-parent`,i.id,()=>`computePosition[${i.id}]: parent ${i.parentId} not in positionMap — hiding`);return}_=e,c.clear(`missing-parent`,i.id)}let b=i.q!=null;if(!d&&!f&&(t<i.validityStart||t>i.validityEnd)){l(!i.satrec);return}let S,C,w;if(d){let e=n.chebStore.positionScene(i.id,t);if(!e){l(!0);let e=n.chebStore.zoneCoverage(i.id);e&&(t<e.start||t>e.end)&&(m.majorBodies.count++,e.start<m.majorBodies.earliestStart&&(m.majorBodies.earliestStart=e.start),e.end>m.majorBodies.latestEnd&&(m.majorBodies.latestEnd=e.end),i.id===h&&(m.focusedOutOfRange=!0)),c.warnOnce(`cheb-null`,i.id,()=>{let n=e?t>=e.start&&t<=e.end:void 0,r=e?`[${e.start.toFixed(1)},${e.end.toFixed(1)}]`:`unknown`;return`chebStore.positionScene[${i.id}] returned null at jd=${t.toFixed(3)} (coverage=${r}, insideCoverage=${n}) — children of this body will read stale positionMap entry (pre-seeded) instead of falling to SSB`});return}S=_[0]+e[0],C=_[1]+e[1],w=_[2]+e[2]}else if(f){let a=n.probeStore?.probeWithCenter(i.id,t,p)??null;if(!a){l(),c.warnOnce(`probe-unavailable`,i.id,()=>{let e=n.probeStore?`no zone has both a loaded chunk and a sub-chunk covering this jd`:`no ProbeStore`;return`probe ${i.id} (${i.name??`unnamed`}): hidden — ${e}`});return}let u=a.probe.landed;if(u&&Ty(a.probe,t)){let d=i.parentId;y(`naif-${u.bodyNaifId}`);let f=vI(i,a.probe,u,t,s,n,r);if(!f){l();return}if(c.clear(`probe-unavailable`,i.id),e.positionUnknown=!1,e.placedJd=t,d!==i.parentId&&e.trailBuffer?.clear(),o){o.outOfRange=!1;let e=u.isDestroyed;(!o.isLanded||o.isCrashed!==e)&&(jk(o.labelHalo,e?`crashed`:`landed`),o.isLanded=!0,o.isCrashed=e),o.model&&(o.model.visible=!e)}e.position[0]=f.x,e.position[1]=f.y,e.position[2]=f.z,e.orbitCenter&&(e.orbitCenter[0]=f.parentPos[0],e.orbitCenter[1]=f.parentPos[1],e.orbitCenter[2]=f.parentPos[2]),e.trailAnchor&&(e.trailAnchor[0]=f.parentPos[0],e.trailAnchor[1]=f.parentPos[1],e.trailAnchor[2]=f.parentPos[2]),s.set(i.id,e.position);let p=f.up;o?.mesh&&(p?yC(o.mesh,p):vC(o.mesh,e.position,f.parentPos)),o?.model&&(p?yC(o.model,p):vC(o.model,e.position,f.parentPos));return}let d=Vy(a.probe,t,a.fitCenterNaifId,n.chebStore??null,e=>s.has(e));if(!d){l(),c.warnOnce(`probe-unavailable`,i.id,()=>`probe ${i.id} (${i.name??`unnamed`}): hidden — stamped fit center is not placeable this frame`);return}let f=d.id,m=d.muKm3S2,g=Sy(a.probe,t,m);if(!g){l(),c.warnOnce(`probe-unavailable`,i.id,()=>`probe ${i.id} (${i.name??`unnamed`}): hidden — sub-chunk evaluation returned null (uncoverable, non-finite fit, or missing mu for kepler_pure)`);return}c.clear(`probe-unavailable`,i.id),o?.isLanded&&(jk(o.labelHalo,`flying`),o.isLanded=!1,o.isCrashed&&(o.isCrashed=!1,o.model&&(o.model.visible=!0),o.noPhysical||QE(o,`missing`,null)));let v=s.get(p_),b=s.get(f_),x=f===`naif-399`&&v!==void 0&&b!==void 0&&pI([Q(g[0]),Q(g[2]),-Q(g[1])],[b[0]-v[0],b[1]-v[1],b[2]-v[2]])!==null,T=x!==(e.lagrangeTrail??!1);e.lagrangeTrail=x;let E=i.parentId!==f;if((E||T)&&e.trailBuffer&&n.probeStore){let r=e.trailBuffer;r.clear(),r.needsPopulate=!1;let o=Gy(Ry(a.probe,t,m),i.validityEnd-i.validityStart,r.capacity,x);r.reconfigure(o.stepDays,o.epsilonScene,o.spanDays),Zy(r,n.probeStore,n.chebStore??null,i.id,f,t)}E&&(i.parentId=f),y(f);let D=s.get(f);if(!D){l(),c.warnOnce(`probe-unavailable`,i.id,()=>`probe ${i.id} (${i.name??`unnamed`}): hidden — fit center ${f} has no position this frame`);return}_=D;let O=Q(g[0]),k=Q(g[2]),A=-Q(g[1]);S=_[0]+O,C=_[1]+k,w=_[2]+A;let j=e.trailBuffer;if(j?.needsPopulate&&o?.trail?.visible&&n.probeStore&&(j.needsPopulate=!1,j.clear(),Zy(j,n.probeStore,n.chebStore??null,i.id,f,t)),j){let e=j.newestJd,r=t-e,o=j.stepDays*j.capacity,s=isFinite(e)&&(r<0||r>o);if(s&&i.id===h&&n.probeStore){j.clear();let e=Gy(Ry(a.probe,t,m),i.validityEnd-i.validityStart,j.capacity,x);j.reconfigure(e.stepDays,e.epsilonScene,e.spanDays),Zy(j,n.probeStore,n.chebStore??null,i.id,f,t)}else s?(j.clear(),j.append(t,O,k,A)):isFinite(e)?isFinite(j.epsilonScene)?r>=j.stepDays*.00390625&&n.probeStore&&j.readNewestPos(yI)&&$y(j,qy(n.probeStore,n.chebStore??null,i.id,f),e,[yI[0],yI[1],yI[2]],t):r>=j.stepDays&&j.append(t,O,k,A):j.append(t,O,k,A)}}else if(i.a===0&&!b&&!i.satrec)[S,C,w]=_;else{let e=i.satrec?bg(i.satrec,t):b?Xv(i,t):Jv(i,t);if(!e){l();return}S=_[0]+e[0],C=_[1]+e[1],w=_[2]+e[2]}if(o&&(o.outOfRange=!1),e.positionUnknown=!1,e.placedJd=t,e.position[0]=S,e.position[1]=C,e.position[2]=w,(!Number.isFinite(S)||!Number.isFinite(C)||!Number.isFinite(w))&&c.warnOnce(`non-finite`,i.id,()=>{let e=s.has(i.parentId);return`computePosition[${i.id}] non-finite: pos=[${S},${C},${w}] parentId=${i.parentId} parentInPositionMap=${e} parentPos=[${_[0]},${_[1]},${_[2]}] isChebTracked=${d} isProbe=${f} objectType=${i.objectType}`}),e.orbitCenter&&(e.orbitCenter[0]=_[0],e.orbitCenter[1]=_[1],e.orbitCenter[2]=_[2]),e.trailAnchor&&(e.trailAnchor[0]=_[0],e.trailAnchor[1]=_[1],e.trailAnchor[2]=_[2]),s.set(i.id,e.position),o){if(o.trail&&e.orbitCenter){let e=o.trail.userData.orbitCenter;e&&e.set(_[0],_[1],_[2])}if(e.orientation&&(o.mesh||o.model))o.mesh&&hC(o.mesh,e.orientation,t,e.nutPrec),o.model&&hC(o.model,e.orientation,t,e.nutPrec),o.nomenclatureAnchor&&hC(o.nomenclatureAnchor,e.orientation,t,e.nutPrec);else if(XD(e)){let n=e.attitudeTrack;if(!e.pointingOverride&&n&&n.orientationAt(t,bI))o.mesh&&o.mesh.quaternion.copy(bI),o.model&&o.model.quaternion.copy(bI);else{let n=e.pointingOverride??e.pointing;if(n){let r=wI(n)?TI(i.id,t,e.position):void 0,a={bodyPos:e.position,parentPos:_,sunPos:s.get(f_),velocity:r};o.mesh&&NC(o.mesh,n,a),o.model&&NC(o.model,n,a)}else o.mesh&&vC(o.mesh,e.position,_),o.model&&vC(o.model,e.position,_)}}if(e.orientation)for(let n of o.rings)hC(n.mesh,e.orientation,t,e.nutPrec)}},C=n.visibility.focusedSystemId;for(let e of n.bodies.bodiesById.values()){if(e.data.objectType===W.MOON&&!(C!==null&&e.data.parentId===C)&&e.data.id!==h){s.set(e.data.id,e.position);continue}S(e)}for(let e of r.values())n.bodies.bodiesById.has(e.body.data.id)||S(e.body);if(m.satellites=n.refresher?.satelliteCoverage(t)??{kind:`covered`},d.update(m),o&&un(o)){let e=n.getBody(o.featureAnchor.hostId);e&&s.has(e.data.id)?Vw(o,e,r.get(e.data.id),t):m.focusedOutOfRange=!0}let w=null;if(o&&m.focusedOutOfRange){let e=_.find(e=>e.bo&&!e.bo.outOfRange);if(e){w=e.id;let t=s.get(e.id)??e.oldPos;if(performance.now()-i.focusStartTime<i.focusDurationMs){i.focusTargetWorld[0]=t[0],i.focusTargetWorld[1]=t[1],i.focusTargetWorld[2]=t[2];let e=i.camTargetOffset;e&&i.camTargetWorld&&(i.camTargetWorld[0]=t[0]+e[0],i.camTargetWorld[1]=t[1]+e[1],i.camTargetWorld[2]=t[2]+e[2])}else{let n=t[0]-e.oldPos[0],r=t[1]-e.oldPos[1],a=t[2]-e.oldPos[2];i.focusTruePos[0]+=n,i.focusTruePos[1]+=r,i.focusTruePos[2]+=a,i.focusTargetWorld[0]=i.focusTruePos[0],i.focusTargetWorld[1]=i.focusTruePos[1],i.focusTargetWorld[2]=i.focusTruePos[2]}}}else if(o){let e=o.position,t=performance.now()-i.focusStartTime<i.focusDurationMs;i.focusTargetWorld[0]=e[0],i.focusTargetWorld[1]=e[1],i.focusTargetWorld[2]=e[2];let n=i.camTargetOffset;n&&i.camTargetWorld&&(i.camTargetWorld[0]=e[0]+n[0],i.camTargetWorld[1]=e[1]+n[1],i.camTargetWorld[2]=e[2]+n[2]);let r=i.camOriginOffset;r&&i.camOriginWorld&&(i.camOriginWorld[0]=e[0]+r[0],i.camOriginWorld[1]=e[1]+r[1],i.camOriginWorld[2]=e[2]+r[2]),t||(i.focusTruePos[0]=e[0],i.focusTruePos[1]=e[1],i.focusTruePos[2]=e[2])}let T=i.focusTruePos;for(let e of r.values()){let n=e.trail;if(n){if(!n.visible){n.userData.refreshDeferred=!0;continue}ZP(e.body,n,T,t,l),n.userData.refreshDeferred=!1}}return{focusedOutOfRange:m.focusedOutOfRange,reanchorId:w}}function DI(e,t,n,r){let i=t.focusTruePos;for(let t of e.values()){let e=t.trail;!e||!e.visible||!e.userData.refreshDeferred||(ZP(t.body,e,i,n,r),e.userData.refreshDeferred=!1)}}var OI=class{seen=new Map;bucket(e){let t=this.seen.get(e);return t||this.seen.set(e,t=new Set),t}warnOnce(e,t,n){let r=this.bucket(e);r.has(t)||(r.add(t),console.warn(n()))}clear(e,t){this.seen.get(e)?.delete(t)}},kI=Q(695700),AI=2,jI=new J;function MI(e,t,n,r,i){jI.subVectors(e,t);let a=jI.dot(n),o=Math.sqrt(Math.max(jI.lengthSq()-a*a,0)),s=o-Math.min(Math.max(o,r),i),c=Math.sqrt(s*s+a*a);return{dist:c,sinToPole:c>0?Math.abs(s)/c:1}}function NI(e,t,n,r,i,a){let o=e.get(f_)?.body.position;if(!o)return;let[s,c,l]=t;for(let t of e.values()){if(!t.rings.length)continue;let[e,u,d]=t.body.position;for(let f of t.rings){let p=r||f.intensityScale>=.000980392156862745;f.mesh.visible=p;let m=r?1:p?f.intensityScale:0;f.material.uniforms.uIntensityScale.value=m;let h=f.material.uniforms.uSunDir.value;h.set(o[0]-e,o[1]-u,o[2]-d);let g=h.length(),_=kI/g;f.material.uniforms.uSunAngularRadius.value=_,f.material.uniforms.uLightScale.value=n?bT(g):1,h.normalize();let v=f.planetShadowOnRing;if(v.uPlanetCenter.value.set(e-s,u-c,d-l),t.mesh&&v.uPlanetPoleDir.value.set(0,1,0).applyQuaternion(t.mesh.quaternion),f.layers){let{dist:e,sinToPole:t}=MI(i,v.uPlanetCenter.value,v.uPlanetPoleDir.value,f.innerScene,f.outerScene),n=f.thicknessScene*t/Math.max(e,1e-9)*a,r=Math.min(Math.max(Math.ceil(n*AI),1),48);f.layers.count!==r&&(f.layers.count=r,f.material.uniforms.uLayerCount.value=r,f.material.uniforms.uLayerAlphaExp.value=1/r)}let y=f.planetShadow;y&&(y.uRingShadowIntensity.value=m,y.uRingShadowSunAngularRadius.value=_,y.uRingShadowSunDir.value.copy(h),y.uRingShadowPoleDir.value.copy(v.uPlanetPoleDir.value),y.uRingShadowCenter.value.copy(v.uPlanetCenter.value))}}}var PI=Math.PI/180,FI=2451545;function II(e){let t=e-FI,n=(19.3871+.52402073*t)*PI;return((270.3871+.524038496*t+((10.691+3e-7*t)*Math.sin(n)+.623*Math.sin(2*n)+.05*Math.sin(3*n)+.005*Math.sin(4*n)+5e-4*Math.sin(5*n)))%360+360)%360}function LI(e,t,n){let r=e.length,i=r-1;for(let t=0;t<r-1;t++)if(n<e[t+1]){i=t;break}let a=(i+1)%r,o=i===r-1?360-e[i]:e[a]-e[i],s=(n-e[i])/o;return t[i]+(t[a]-t[i])*s}function RI(e,t){let n=e.seasonal;if(!n)return e;let r=LI(n.lsDeg,n.dustTauFactor,t),i=LI(n.lsDeg,n.dustScaleHeightKm,t),a=LI(n.lsDeg,n.pressureFactor,t),o=r*e.mieScaleHeightKm/i,s=(e,t)=>[e[0]*t,e[1]*t,e[2]*t];return{...e,rayleighScatterPerKm:s(e.rayleighScatterPerKm,a),mieScatterPerKm:s(e.mieScatterPerKm,o),mieAbsorptionPerKm:s(e.mieAbsorptionPerKm,o),mieScaleHeightKm:i,seasonal:void 0}}var zI=new WeakMap,BI=.25;function VI(e,t){if(!e.seasonal)return e;let n=Math.round(II(t)/BI),r=zI.get(e);if(r&&r.lsQ===n)return r.params;let i=RI(e,n*BI);return zI.set(e,{lsQ:n,params:i}),i}var HI=new J,UI=new J,WI=[.2126,.7152,.0722];function GI(e,t,n){return n<=0?0:e<=t-n?n:e>=t+n?0:e<=t?n-(e-(t-n))**2/(2*n):(t+n-e)**2/(2*n)}function KI(e,t){let n=Math.max(t,0),r=e.rayleighScaleHeightKm*Math.exp(-n/e.rayleighScaleHeightKm),i=e.mieScaleHeightKm*Math.exp(-n/e.mieScaleHeightKm),a=GI(n,e.absorptionCenterKm,e.absorptionWidthKm),o=0;for(let t=0;t<3;t++){let n=e.rayleighScatterPerKm[t]*r+(e.mieScatterPerKm[t]+e.mieAbsorptionPerKm[t])*i+e.absorptionPerKm[t]*a;o+=WI[t]*Math.exp(-n)}return o}var qI=.4,JI=.05,YI=-.105,XI=.3,ZI=.05;function QI(e,t,n){let r=KI(e,t),i=Math.min(1,-Math.log(Math.max(r,.001))/ZI),a=Math.min(1,Math.max(0,(n-YI)/XI));return r*(1+(qI+(JI-qI)*a-1)*i)}function $I(e,t,n,r){let i=Math.sqrt(2*n/r),a=Math.sqrt(Math.PI*r/(2*n));return t>=0?e/(Math.tan(t)+1/a):e*a*Math.exp(t/i)}var eL=vT,tL=200,nL=new J,rL=new J,iL=new J,aL=new J;function oL(e,t,n,r){e.uOccluderCount.value=BC(e.uOccluders.value,t,r,n)}function sL(e,t,n,r,i,a,o){let s={insideShell:!1,shellProminent:!1,skyboxIntensity:1,sunTint:nL.set(1,1,1),sunRefraction:null};RA(n&&a.sunTint);let c=e.get(f_);dj(c?.mesh?.material,vb());let l=uj(c?.mesh?.material);l&&(l.uAtmoTEnable.value=0);let u=tL,d=c?.body.position;if(!d)return s;for(let c of e.values()){if(!c.atmosphere||(c.atmosphere.mesh.visible=n,!n))continue;AA(c.atmosphere,a);let e=_b(c.body.data.id);if(e?.seasonal){let t=a.seasonal?VI(e,o):e;if(c.atmosphere.params!==t){jA(c.atmosphere,t);for(let e of c.sunTint??[])GA(e,t,c.atmosphere.surfaceRadiusScene,c.atmosphere.surfaceRadiusKm)}}let[f,p,m]=c.body.position,h=c.atmosphere.material.uniforms;h.uGroundAlbedo.value=a.groundAlbedo?c.atmosphere.params.groundAlbedo??0:0;let g=h.uSunDir.value.set(d[0]-f,d[1]-p,d[2]-m),_=c.atmosphere.params,v=r?bT(g.length()):_.realisticSunAlways?Math.sqrt(bT(g.length())):1;h.uSunIntensity.value=_.sunIntensity*v*i,g.normalize(),c.mesh&&(HI.set(0,1,0).applyQuaternion(c.mesh.quaternion),h.uSpinAxis.value.copy(HI));let y=c.atmosphere.mesh,b=c.atmosphere.geometryRadiusScene*y.scale.x,x=t.distanceTo(y.position);b>x*.1&&(s.shellProminent=!0),a.eclipseShadows&&oL(h,y.position,g,b);let S=a.insideView&&x<b,C=c.atmosphere.planetRadiusKm,w=x*((C+_.topAltitudeKm)/b)-C,T=S&&DA(_,w),E=S?OA(_,w):0;wA(c.atmosphere,S,T,E),h.uDeepIrradiance.value=eL*i;for(let e of c.sunTint??[])e.uAtmoTDeepIrradiance.value=eL*i,e.uAtmoTDeepBlend.value=E;if(S){s.insideShell=!0;let e=UI.copy(t).sub(y.position).divideScalar(x).dot(g),n=QI(_,w,e);if(s.skyboxIntensity*=n*(1-E),a.refraction&&_.refractivity&&!T){let t=$I(_.refractivity[1]*Math.exp(-Math.max(w,0)/_.rayleighScaleHeightKm),Math.asin(Math.min(1,Math.max(-1,e))),_.rayleighScaleHeightKm,c.atmosphere.planetRadiusKm);t>5e-6&&(s.sunRefraction={angleRad:t,up:aL.copy(UI)})}}let D=x/b;if(a.sunTint&&D<tL){let e=b/(1+_.topAltitudeKm/C)*(c.atmosphere.surfaceRadiusKm/C);iL.copy(t).sub(y.position);let n=h.uSpinAxis.value,r=h.uStretch.value;if(QA(_,iL,g,e,c.atmosphere.surfaceRadiusKm,rL,n,r)){let e=WI[0]*rL.x+WI[1]*rL.y+WI[2]*rL.z;e>1e-4&&s.sunTint.multiply(rL.divideScalar(e))}l&&D<u&&(u=D,qA(l,_,y.position,e,c.atmosphere.surfaceRadiusKm,n,r))}}return s}var cL=[];function lL(e,t){let n=RC(),r=e.get(f_);if(!r){n.uSunAngularRadius.value=0,n.uOccluderCount.value=0;return}let[i,a,o]=t,s=r.body.position,c=s[0]-i,l=s[1]-a,u=s[2]-o,d=Math.hypot(c,l,u);d>0?(n.uSunDir.value.set(c/d,l/d,u/d),n.uSunAngularRadius.value=Math.asin(Math.min(r.radiusScene/d,1))):n.uSunAngularRadius.value=0;let f=cL,p=0;for(let t of e.values()){if(t.body.data.objectType===W.STAR)continue;let e=t.body.data.radiusKm;!Number.isFinite(e)||e<=0||t.radiusScene<=0||(f[p++]=t)}f.length=p,p>32&&(f.sort((e,t)=>t.radiusScene-e.radiusScene),f.length=32,p=32);let m=n.uOccluders.value;for(let e=0;e<p;e++){let t=f[e],[n,r,s]=t.body.position;m[e].set(n-i,r-a,s-o,t.radiusScene)}n.uOccluderCount.value=p;for(let e=0;e<p;e++)f[e]=void 0;f.length=0;let h=n.uSunDir.value;for(let t of e.values()){let e=t.eclipseShadow;if(!e||t.cachedDist>0&&t.radiusScene<t.cachedDist*1e-4)continue;let[n,r,s]=t.body.position,c=e.uEclipseSelfPos.value.set(n-i,r-a,s-o);e.uOccluderCount.value=BC(e.uOccluders.value,c,t.radiusScene,h)}}var uL=10;function dL(e,t,n,r,i,a,o,s,c){let l=n.visibility.activeSystemId;if(!l){r.intensity=0,i&&xT(i,s,c);return}let u=e.get(f_)?.body.position,[d,f,p]=t,m=(u?.[0]??0)-d,h=(u?.[1]??0)-f,g=(u?.[2]??0)-p,_=Math.hypot(m,h,g),v=o.set(m,h,g).normalize();r.position.copy(v).multiplyScalar(uL),r.target.position.set(0,0,0),r.intensity=vT*(s?bT(_):1)*c,i&&(i.intensity=0);let y=Math.max(a*2,.001),b=n.bodies.getSystemExtent(l)*10*1.2,x=r.shadow.camera;x.left=x.bottom=-y,x.right=x.top=y,x.near=uL-b,x.far=uL+b,x.updateProjectionMatrix()}var fL=128,pL=256,mL=.25,hL=.32,gL=.35,_L=300,vL=1.25,yL=.05,bL=4e5,xL=new Y,SL=new J;function CL(e,t,n){let r=e=>t.some(([t,n])=>e>t+1e-9&&e<n-1e-9),i=e/fL,a=[];for(let t=0;t<=fL;t++){let n=t===fL?e:t*i;(t===0||t===fL||!r(n))&&a.push(n)}for(let[r,i]of t){let t=Math.ceil(Math.max(r,0)/n-1e-9),o=Math.floor(Math.min(i,e)/n+1e-9);for(let e=t;e<=o;e++)a.push(e*n)}a.sort((e,t)=>e-t);let o=n*.25,s=[];for(let e of a)s.length&&e-s[s.length-1]<o||s.push(e);return s[0]=0,s[s.length-1]=e,Float64Array.from(s)}function wL(e,t,n){let r=t.length,i=n.length,a=new Float32Array(r*i*3),o=new Float32Array(r*i*3),s=new Float32Array(r*i*2);for(let c=0;c<r;c++){let r=t[c],l=Math.sin(r),u=Math.cos(r);for(let t=0;t<i;t++){let d=n[t],f=-Math.cos(d)*l,p=u,m=Math.sin(d)*l,h=(c*i+t)*3;a[h]=e*f,a[h+1]=e*p,a[h+2]=e*m,o[h]=f,o[h+1]=p,o[h+2]=m;let g=(c*i+t)*2;s[g]=d/(2*Math.PI),s[g+1]=1-r/Math.PI}}let c=new Uint32Array((r-1)*(i-1)*6),l=0;for(let e=0;e<r-1;e++){let n=t[e]<=0,r=t[e+1]>=Math.PI;for(let t=0;t<i-1;t++){let a=e*i+t+1,o=e*i+t,s=(e+1)*i+t,u=(e+1)*i+t+1;n||(c[l++]=a,c[l++]=o,c[l++]=u),r||(c[l++]=o,c[l++]=s,c[l++]=u)}}let u=new Ho;return u.setAttribute(`position`,new Do(a,3)),u.setAttribute(`normal`,new Do(o,3)),u.setAttribute(`uv`,new Do(s,2)),u.setIndex(new Do(c.subarray(0,l),1)),u}function TL(e){e.terrainWindow&&(e.terrainWindow=null,e.currentSegments=void 0)}function EL(e,t,n){let r=e.mesh,i=e.displacementMap;if(!n||!r||!i)return e.terrainWindow&&console.debug(`terrain window exit ${e.body.data.id}: eligible=${n} mesh=${!!r} tex=${!!i}`),TL(e),!1;r.updateMatrixWorld(),xL.copy(r.matrixWorld).invert(),SL.copy(t.position).applyMatrix4(xL);let a=Q(gn(e.body.data)),o=SL.length(),s=Math.max(o/a-1,1e-6);if(s>(e.terrainWindow?hL:mL))return e.terrainWindow&&console.debug(`terrain window exit ${e.body.data.id}: alt=${s.toFixed(4)}`),TL(e),!1;let c=i.image?.width??2048,l=2*Math.PI/c,u=Math.acos(1/(1+s)),d=Math.max(l,2*u*vL/pL),f=Math.log2(d/l),p=Math.max(0,Math.ceil(f-1e-9)),m=e.terrainWindow;m&&m.texWidth===c&&f>m.stepLevel-.85&&f<m.stepLevel+.15&&(p=m.stepLevel);let h=l*2**p,g=h*pL/2,_=Math.acos(Math.min(1,Math.max(-1,SL.y/o))),v=Math.atan2(SL.z,-SL.x);if(v<0&&(v+=2*Math.PI),m&&m.texWidth===c){if(m.stepLevel===p){let e=Math.sin(_)*Math.sin(m.centerTheta)*Math.cos(v-m.centerPhi)+Math.cos(_)*Math.cos(m.centerTheta);if(Math.acos(Math.min(1,Math.max(-1,e)))<gL*m.angRadius)return!0}if(performance.now()-m.builtAt<_L)return!0}let y=Math.max(0,_-g),b=Math.min(Math.PI,_+g),x=CL(Math.PI,[[y,b]],h),S=Math.min(Math.PI,g/Math.max(Math.sin(_),yL)),C=Math.max(p,Math.ceil(Math.log2(2*S/pL/l)-1e-9)),w=l*2**Math.max(0,C),T=v-S,E=v+S,D=S>=Math.PI?[[0,2*Math.PI]]:T<0?[[0,E],[T+2*Math.PI,2*Math.PI]]:E>2*Math.PI?[[0,E-2*Math.PI],[T,2*Math.PI]]:[[T,E]],O=CL(2*Math.PI,D,w);if(x.length*O.length>bL)return console.warn(`terrain window for ${e.body.data.id} would need ${x.length}×${O.length} vertices — keeping the uniform sphere`),TL(e),!1;let k=r.geometry;return r.geometry=wL(a,x,O),k.dispose(),console.debug(`terrain window ${e.body.data.id}: ${x.length}×${O.length} grid, level ${p} (tex ${c})`),e.terrainWindow={thetas:x,phis:O,centerTheta:_,centerPhi:v,angRadius:g,stepLevel:p,texWidth:c,builtAt:performance.now()},e.currentSegments=fL,!0}var DL=[{up:150,segs:128},{up:40,segs:64},{up:0,segs:32}],OL=24;function kL(e,t,n,r){if(!n&&!t)return OL;let i=DL[DL.length-1].segs;for(let t of DL)if(e>=t.up){i=t.segs;break}if(i<r){let t=DL.find(e=>e.segs===r);if(t&&e>=t.up*.85)return r}return i}function AL(e,t,n,r,i){let a=t.fov*Math.PI/180,o=n.domElement.clientHeight/(2*Math.tan(a/2)),s=r.visibility.activeSystemId,c=i;for(let n of e.values()){if(!n.mesh||!n.radiusScene||!n.group.visible||n.cachedDist<=0)continue;let e=n.body.data.objectType===W.STAR,a=n.body.data.id;if((a===c||n.terrainWindow)&&EL(n,t,a===c))continue;let l=kL(n.radiusScene/n.cachedDist*o,e,s?a===s||r.visibility.isInActiveSystem(n.body.data.parentId):a===i,n.currentSegments??64);if(l===n.currentSegments)continue;let u=Q(gn(n.body.data)),d=n.mesh.geometry;n.mesh.geometry=new ru(u,l,l),d.dispose(),n.currentSegments=l}}function jL(e,t){let n=e<1.05?`high`:e<4?`medium`:`low`;if(Qj(n)>Qj(t))return n;let r=e>7?`low`:e>1.15?`medium`:`high`;return Qj(r)<Qj(t)?r:t}function ML(e,t,n,r,i,a,o,s){s.apply(e,i);let c=t.fov*Math.PI/180,l=n.domElement.clientHeight/(2*Math.tan(c/2)),u=r.visibility.activeSystemId,d=Mx(),f=d.showClouds,p=Qj(qx());for(let t of e.values())t.clouds&&(t.clouds.mesh.visible=f);for(let t of e.values()){if(!t.mesh||!t.radiusScene||!t.group.visible||!t.availableTiers?.length||t.cachedDist<=0)continue;let e=t.body.data.id;if(u){if(e!==u&&!r.visibility.isInActiveSystem(t.body.data.parentId))continue}else if(e!==a)continue;let s=t.radiusScene/t.cachedDist*l,c=t.cachedDist/t.radiusScene,f;f=s<256&&c>10?`low`:s<1024&&c>2?`medium`:`high`;let m=Qj(t.textureTier),h=Math.min(Qj(f),p),g=tM(o,t.availableFrames),_=g!==t.textureFrame,v=h>m;if(d.showSurfaceTexture&&!t.textureLoading&&(v||_)){let e=v?$j(h,t.availableTiers):t.textureTier;e&&sM(t,e,g,i)}let y=t.displacementMeta?.tiers;if(t.displacementMap&&y?.length&&!t.displacementLoading){let e=n.capabilities.maxTextureSize,r=e>=16383?2:+(e>=8192),i=t.displacementTier??`low`,a=$j(Math.min(Qj(jL(c,i)),r,p),y);a&&a!==i&&aw(t,a)}if(t.clouds&&t.textureTier){let e=$j(Qj(t.textureTier),t.clouds.availableTiers),n=kj(o,t.clouds.availableFrames,t.clouds.availableCoverage);e&&n&&Mj(t.clouds,e,n)}}}var NL=WO.refMs,PL=new Y,FL=new J,IL=new J,LL=new Hi,RL=new Hi,zL=new J,BL=new J;function VL(e,t,n){return FL.set(e[0],e[1],e[2]),IL.set(t[0],t[1],t[2]),PL.lookAt(FL,IL,n),LL.setFromRotationMatrix(PL).clone()}function HL(e,t,n,r,i){let a=performance.now()-e.focusStartTime,o=e.focusDurationMs>0?Math.min(a/e.focusDurationMs,1):1,s=o<1,c=!!(e.camOriginWorld&&e.camTargetWorld&&e.flyQ0);if(s&&c){let n=o*o*(3-2*o);if(e.focusTruePos=L_(e.focusOriginWorld,e.focusTargetWorld,n),r(),e.orbitFly){let r=e.focusOriginWorld[0]!==e.focusTargetWorld[0]||e.focusOriginWorld[1]!==e.focusTargetWorld[1]||e.focusOriginWorld[2]!==e.focusTargetWorld[2],i;if(e.arcOrbit)i=z_(e.camOriginWorld,e.camTargetWorld,e.focusTargetWorld,n);else{let t=r?o*o*o:n;i=L_(e.camOriginWorld,e.camTargetWorld,t)}t.position.set(i[0]-e.focusTruePos[0],i[1]-e.focusTruePos[1],i[2]-e.focusTruePos[2]),r&&!e.arcOrbit?(t.lookAt(e.focusTargetWorld[0]-e.focusTruePos[0],e.focusTargetWorld[1]-e.focusTruePos[1],e.focusTargetWorld[2]-e.focusTruePos[2]),RL.copy(t.quaternion),t.quaternion.slerpQuaternions(e.flyQ0,RL,n)):t.lookAt(e.focusTargetWorld[0]-e.focusTruePos[0],e.focusTargetWorld[1]-e.focusTruePos[1],e.focusTargetWorld[2]-e.focusTruePos[2])}else{let r;if(e.cameraStaysOnBody)r=e.camTargetWorld;else{let t=o*o*o;r=L_(e.camOriginWorld,e.camTargetWorld,t)}let i=VL(r,e.focusTargetWorld,t.up);t.quaternion.slerpQuaternions(e.flyQ0,i,n),t.position.set(r[0]-e.focusTruePos[0],r[1]-e.focusTruePos[1],r[2]-e.focusTruePos[2])}return!1}if((e.focusTruePos[0]!==e.focusTargetWorld[0]||e.focusTruePos[1]!==e.focusTargetWorld[1]||e.focusTruePos[2]!==e.focusTargetWorld[2])&&(e.focusTruePos=[...e.focusTargetWorld],r(),i()),n.target.set(0,0,0),e.camTargetWorld){let r=e.camTargetWorld[0]-e.focusTruePos[0],i=e.camTargetWorld[1]-e.focusTruePos[1],a=e.camTargetWorld[2]-e.focusTruePos[2];t.position.set(r,i,a),n.enableDamping=!1,n.update(),n.enableDamping=!0,t.position.set(r,i,a),e.camOriginWorld=null,e.camTargetWorld=null,e.camTargetOffset=null,e.camOriginOffset=null,e.flyQ0=null,e.orbitFly=!1,e.arcOrbit=!1,e.cameraStaysOnBody=!1}return!n.update()}function UL(e,t,n,r,i,a=!1){if(e.focusOriginWorld=[...e.focusTruePos],e.focusTargetWorld=[...t],e.focusStartTime=performance.now(),e.arcOrbit=!1,e.camOriginOffset=null,i){e.camOriginWorld=r,e.camTargetWorld=[...i],e.camTargetOffset=[i[0]-t[0],i[1]-t[1],i[2]-t[2]],e.cameraStaysOnBody=!1,e.flyQ0=n.quaternion.clone();let a=VL([i[0]-e.focusTruePos[0],i[1]-e.focusTruePos[1],i[2]-e.focusTruePos[2]],[t[0]-e.focusTruePos[0],t[1]-e.focusTruePos[1],t[2]-e.focusTruePos[2]],n.up),o=R_(r,i),s=e.flyQ0.angleTo(a);e.focusDurationMs=Math.max(UO(o,KO),HO(s,qO))}else e.camOriginWorld=r,e.camTargetWorld=[...r],e.camTargetOffset=[r[0]-t[0],r[1]-t[1],r[2]-t[2]],e.cameraStaysOnBody=!0,e.flyQ0=n.quaternion.clone(),zL.set(0,0,-1).applyQuaternion(e.flyQ0),BL.set(t[0]-r[0],t[1]-r[1],t[2]-r[2]).normalize(),e.focusDurationMs=HO(zL.angleTo(BL),WO);if(a){let t=e.focusOriginWorld[0]!==e.focusTargetWorld[0]||e.focusOriginWorld[1]!==e.focusTargetWorld[1]||e.focusOriginWorld[2]!==e.focusTargetWorld[2];(i||t)&&(e.focusDurationMs=0)}}function WL(e,t,n,r,i=!1){e.camOriginWorld=n,e.camTargetWorld=[...r],e.camTargetOffset=[r[0]-e.focusTruePos[0],r[1]-e.focusTruePos[1],r[2]-e.focusTruePos[2]],e.camOriginOffset=[n[0]-e.focusTruePos[0],n[1]-e.focusTruePos[1],n[2]-e.focusTruePos[2]],e.focusOriginWorld=[...e.focusTruePos],e.focusTargetWorld=[...e.focusTruePos],e.focusStartTime=performance.now(),e.orbitFly=!0,e.arcOrbit=!0,e.cameraStaysOnBody=!1,e.flyQ0=t.quaternion.clone();let a=R_(n,r);zL.set(e.focusTruePos[0]-n[0],e.focusTruePos[1]-n[1],e.focusTruePos[2]-n[2]).normalize(),BL.set(e.focusTruePos[0]-r[0],e.focusTruePos[1]-r[1],e.focusTruePos[2]-r[2]).normalize();let o=zL.angleTo(BL);e.focusDurationMs=Math.max(UO(a,KO),HO(o,qO)),i&&(e.focusDurationMs=0)}var GL={[W.STAR]:1e3,[W.PLANET]:100,[W.DWARF_PLANET]:10,[W.ASTEROID]:.1,[W.ASTEROID_INNER]:.1,[W.ASTEROID_MAIN_BELT]:.1,[W.ASTEROID_CENTAUR]:1,[W.ASTEROID_TROJAN]:1,[W.ASTEROID_TNO]:1,[W.COMET]:1,[W.MOON]:1},KL=5e-4,qL=new J,JL=new J;function YL(e){return GL[e.data.objectType]??gn(e.data)*.25}function XL(e,t){return Q((t??gn(e.data))+YL(e))}function ZL(e,t,n,r){let i=t.data.radiusKm;if(!Number.isFinite(i)||i<=0)return;let a=t.position[0]-n[0],o=t.position[1]-n[1],s=t.position[2]-n[2],c=Math.hypot(a,o,s),l=r?.centerOffsetScene,u=a+(l?l[0]:0),d=o+(l?l[1]:0),f=s+(l?l[2]:0),p=e.position.x-u,m=e.position.y-d,h=e.position.z-f,g=Math.hypot(p,m,h);if(r?.seated){if(g<1e-9){e.position.set(u,d+c+Q(KL),f);return}let t=Math.tan(e.fov*Math.PI/360)*e.near,n=t*e.aspect,i=0;for(let[a,o,s]of[[0,0,0],[-n,-t,-e.near],[n,-t,-e.near],[-n,t,-e.near],[n,t,-e.near]]){JL.set(a,o,s).applyQuaternion(e.quaternion);let t=p+JL.x,n=m+JL.y,l=h+JL.z,u=Math.hypot(t,n,l);if(u<1e-12)continue;qL.set(t/u,n/u,l/u).applyQuaternion(r.invQuat);let d=r.radialKm([qL.x,qL.y,qL.z]),f=(d===null?c:Q(d))+Q(KL);f-u>i&&(i=f-u)}if(i<=0)return;let a=i/g;e.position.set(e.position.x+p*a,e.position.y+m*a,e.position.z+h*a);return}let _=YL(t);if(g>=Q((r?.outerRadiusKm??i)+_))return;let v=i;r&&g>1e-9&&(qL.set(p/g,m/g,h/g).applyQuaternion(r.invQuat),v=r.radialKm([qL.x,qL.y,qL.z])??i);let y=Q(v+_),b=c>0?Math.min(y,c):y;if(!(g>=b)){if(g<1e-9)p=0,m=b,h=0;else{let e=b/g;p*=e,m*=e,h*=e}e.position.set(u+p,d+m,f+h)}}function QL(e,t,n){let r=e.position,{latitude:i,longitude:a,distance:o}=aC([r.x,r.y,r.z],[0,0,0],n),s=Math.min(Math.max(i,t.minLat??-90),t.maxLat??90),c=lC(a,t.minLon,t.maxLon),l=Math.min(Math.max(o,t.minDistance??0),t.maxDistance??1/0);if(s===i&&c===a&&l===o)return;let[u,d,f]=oC([0,0,0],s,c,l,n);r.set(u,d,f)}var $L=50,eR=20;function tR(e){return e<=0?`none`:e<eR?`full`:e<$L?`half`:`none`}function nR(e,t){return e.data.validityStart<=t&&t<=e.data.validityEnd}var rR=class{pendingDefaults=new Set;defaults=new Set;userPromoted=new Set;autoPromoted=new Set;groupTargets=null;groupMode=`none`;smallBodyZone=null;countStableLo=1/0;countStableHi=-1/0;constructor(e){this.deps=e,e.ctx.bodies.onBodiesAdded(()=>{this.onBodiesAdded(),this.autoPromoteAsteroidMoons(),this.reevaluateEarthSatMode(),this.smallBodyZone!==null&&this.refreshSmallBodyEmphasis()}),e.ctx.onEarthSatRollover(()=>this.reevaluateEarthSatMode()),e.ctx.onGroupFilterChange(e=>this.applyGroupFilter(e)),this.applyGroupFilter(e.ctx.earthSatFilter),e.ctx.onSmallBodyFilterChange(e=>this.applySmallBodyFilter(e)),this.applySmallBodyFilter(e.ctx.smallBodyFilter),Vv().then(e=>{let t=[],n=e=>{if(!this.defaults.add(e)||this.deps.bodyObjects.has(e))return;let n=this.deps.ctx.getBody(e);if(!n){this.pendingDefaults.add(e);return}this.shouldAutoPromote(n,e)&&t.push(n)};for(let t of e.keys())n(t);for(let e of m_)n(e);this.buildBatch(t),this.autoPromoteAsteroidMoons();let r=!1;for(let e of this.userPromoted)this.defaults.has(e)&&(this.userPromoted.delete(e),r=!0);r&&this.emitUserPromotedCount()})}autoPromoteAsteroidMoons(){let e=this.deps.ctx.bodies.asteroidBodiesByZone.get(`small_body_moons`);if(!e||e.size===0)return;let t=[],n=new Set;for(let r of e.keys()){let i=e.getKey(r);if(!i||i.data.objectType!==W.MOON||!this.isDefault(i.data.parentId))continue;let a=this.deps.ctx.getBody(i.data.parentId);!a||!_n(a.data.objectType)||(!this.deps.bodyObjects.has(a.data.id)&&!n.has(a.data.id)&&(n.add(a.data.id),t.push(a)),this.deps.bodyObjects.has(i.data.id)||t.push(i))}this.buildBatch(t)}onBodiesAdded(){if(this.pendingDefaults.size===0)return;let e=[];for(let t of this.pendingDefaults){let n=this.deps.ctx.getBody(t);n&&(this.pendingDefaults.delete(t),this.shouldAutoPromote(n,t)&&e.push(n))}this.buildBatch(e)}shouldAutoPromote(e,t){return e.data.objectType!==W.BARYCENTER&&e.data.objectType!==W.LAGRANGE_POINT?!0:m_.has(t)}isDefault(e){return this.defaults.has(e)}ensureBodyObjects(e){this.buildBodyInstance(e)&&this.finalizeBuilds()}buildBodyInstance(e,t,n=!1){let{bodyObjects:r,ctx:i,clock:a,scene:o,clickables:s,meshToBody:c,circleTexture:l,renderer:u}=this.deps;if(r.has(e.data.id))return!1;if(DT(e,a.jd,i),!e.orbitElements&&!e.data.unplaceable&&e.data.orbitalSource!==U.SPICE_PROBE){e.orbitElements=e.data;let t=r.get(e.data.parentId);t&&(e.orbitCenter=[...t.body.position])}hj([e],o,s,c,r,l,u.domElement,this.deps.onBodyClick,(e,t)=>t?this.deps.hoveredBodyIds.add(e):this.deps.hoveredBodyIds.delete(e),t);let d=r.get(e.data.id);if(d&&!e.data.name&&aM(d),e.data.objectType===W.SPACECRAFT)i.bodies.dirtySpacecraftGroups.add(e.data.parentId);else if(_n(e.data.objectType)||e.data.objectType===W.COMET){let t=this.deps.ctx.bodies.findAsteroidZone(e.data.id);t&&i.bodies.dirtyAsteroidZones.add(t)}let f=e.data.id;return this.defaults.has(f)||(n?this.autoPromoted.add(f):(this.userPromoted.add(f),this.emitUserPromotedCount())),!0}finalizeBuilds(){bN(this.deps.bodyObjects,this.deps.scene,this.deps.pointClouds.basis(),this.deps.clock.jd),this.deps.assignMapLayerToTrails(),this.deps.repositionAll(),this.deps.pointClouds.rebuildMinor()}buildBatch(e,t,n=!1){let r=!1;for(let i of e)this.buildBodyInstance(i,t,n)&&(r=!0);r&&this.finalizeBuilds()}applyGroupFilter(e){this.groupTargets=e,this.reevaluateEarthSatMode()}applySmallBodyFilter(e){this.smallBodyZone=e?.kind===`class`?`small_bodies/${e.className}`:null,this.refreshSmallBodyEmphasis()}refreshSmallBodyEmphasis(){let e=this.smallBodyZone;if(e===null){this.deps.pointClouds.setEmphasizedSmallBodyZone(null,null);return}let t=this.deps.ctx.bodies.asteroidBodiesByZone.get(e)?.size??0;this.deps.pointClouds.setEmphasizedSmallBodyZone(e,t)}onSimTimeChanged(){let e=this.deps.clock.jd;e>this.countStableLo&&e<this.countStableHi||this.reevaluateEarthSatMode()}reevaluateEarthSatMode(){let e=this.deps.ctx.bodies.spacecraftByParent.get(p_),t=this.currentMemberCount(e),n=tR(t);this.deps.pointClouds.setEarthSatEmphasis(t);let r=n!==this.groupMode;if(this.teardownAutoPromoted(r),this.groupMode=n,n===`none`||!e)return;let i=this.deps.clock.jd,a=[];for(let t of e.values())this.groupTargets&&!this.groupTargets.has(t.data.id)||nR(t,i)&&(this.deps.bodyObjects.has(t.data.id)||a.push(t));if(a.length===0)return;let o=n===`half`?new Set(a.map(e=>e.data.id)):void 0;this.buildBatch(a,o,!0)}currentMemberCount(e){if(this.countStableLo=-1/0,this.countStableHi=1/0,!e)return 0;let t=this.deps.clock.jd,n=0;for(let r of e.values()){if(this.groupTargets&&!this.groupTargets.has(r.data.id))continue;let{validityStart:e,validityEnd:i}=r.data;e<=t?e>this.countStableLo&&(this.countStableLo=e):e<this.countStableHi&&(this.countStableHi=e),i<t?i>this.countStableLo&&(this.countStableLo=i):i<this.countStableHi&&(this.countStableHi=i),nR(r,t)&&n++}return n}teardownAutoPromoted(e){if(this.autoPromoted.size===0)return;let t=this.deps.getFocusedId(),n=this.deps.clock.jd,r=[];for(let i of this.autoPromoted){if(i===t)continue;if(e||this.groupTargets&&!this.groupTargets.has(i)){r.push(i);continue}let a=this.deps.bodyObjects.get(i)?.body;a&&!nR(a,n)&&r.push(i)}r.length!==0&&this.tearDownBodies(r,this.autoPromoted)}clearUserPromoted(){let e=this.deps.getFocusedId(),t=[...this.userPromoted].filter(t=>t!==e);this.tearDownBodies(t,this.userPromoted),this.emitUserPromotedCount()}tearDownBodies(e,t){if(e.length===0)return;let{bodyObjects:n,ctx:r,scene:i,clickables:a,meshToBody:o,pointClouds:s}=this.deps,c=new Set,l=new Set;for(let r of e){let e=n.get(r);if(!e){t.delete(r);continue}e.label&&(e.label.element.remove(),e.label.removeFromParent()),e.loadingEl?.remove(),lO(e),oM(e),PM(e),i.remove(e.group);for(let t of e.extraObjects)i.remove(t);if(e.trail&&i.remove(e.trail),e.mesh){e.mesh.geometry.dispose(),fj(e.mesh.material);let t=a.indexOf(e.mesh);t>=0&&a.splice(t,1),o.delete(e.mesh)}e.atmosphere&&=(e.atmosphere.mesh.geometry.dispose(),fj(e.atmosphere.mesh.material),null),e.trail&&(e.trail.geometry.dispose(),fj(e.trail.material));let s=e.body.data.objectType;if(s===W.SPACECRAFT)c.add(e.body.data.parentId);else if(_n(s)||s===W.COMET){let e=this.deps.ctx.bodies.findAsteroidZone(r);e&&l.add(e)}n.delete(r),t.delete(r)}for(let e of c)r.bodies.dirtySpacecraftGroups.add(e);for(let e of l)r.bodies.dirtyAsteroidZones.add(e);(c.size>0||l.size>0)&&s.rebuildMinor()}emitUserPromotedCount(){if(!this.deps.onUserPromotedChange)return;let e=this.deps.getFocusedId(),t=this.userPromoted.size;e&&this.userPromoted.has(e)&&t--,this.deps.onUserPromotedChange(t)}},iR=class{promotion;readerFocusFilter=null;focusedBody;_tmpV3=new J;pendingInitialView=null;upgradeTargetIds=new Set;constructor(e,t,n,r,i){this.deps=e,this.focusedBody=t,this.promotion=new rR({scene:e.scene,bodyObjects:e.bodyObjects,ctx:e.ctx,clock:e.clock,renderer:i,circleTexture:r,clickables:e.clickables,meshToBody:e.meshToBody,hoveredBodyIds:n,pointClouds:e.pointClouds,onBodyClick:e=>this.handleFocus(e),assignMapLayerToTrails:e.assignMapLayerToTrails,repositionAll:e.repositionAll,getFocusedId:()=>this.focusedBody?.data.id,onUserPromotedChange:e.callbacks.onUserPromotedChange})}get current(){return this.focusedBody}setPendingInitialView(e){this.pendingInitialView=e}clearPendingInitialView(){this.pendingInitialView=null}focusedBodyQuat(e){let t=e??this.focusedBody;if(!t||XD(t))return;let n=this.deps.bodyObjects.get(t.data.id)?.mesh;if(!n)return;let r=n.quaternion;return[r.x,r.y,r.z,r.w]}cameraTruePos(){let{focus:e,camera:t}=this.deps;return[e.focusTruePos[0]+t.position.x,e.focusTruePos[1]+t.position.y,e.focusTruePos[2]+t.position.z]}syncUpgradeTargets(e){let{ctx:t,scene:n,clickables:r,meshToBody:i,bodyObjects:a,pointClouds:o,clock:s,loadTexture:c,assignMapLayerToTrails:l}=this.deps,u=aR(e,t),d=new Set(u.map(e=>e.data.id));for(let e of this.upgradeTargetIds){if(d.has(e))continue;let t=a.get(e);t&&(gj(t.body)?vj(t,n,r,i):lO(t))}let f=!1;for(let t of u){if(this.upgradeTargetIds.has(t.data.id))continue;this.promotion.ensureBodyObjects(t);let o=a.get(t.data.id);if(!o){d.delete(t.data.id);continue}gj(t)&&(_j(o,n,r,i),f=!0),t.data.id!==e?.data.id&&c(t)}return f&&(bN(a,n,o.basis(),s.jd),l()),this.upgradeTargetIds=d,d}panCameraToBody(e){if(e.positionUnknown)return;let{focus:t,camera:n}=this.deps;UL(t,[...e.position],n,this.cameraTruePos(),void 0,Mx().resolvedReducedMotion)}focusOnPoint(e,t){let{focus:n,camera:r,callbacks:i}=this.deps,a=this.cameraTruePos(),o;if(t!==void 0){let n=this._tmpV3.set(e[0]-a[0],e[1]-a[1],e[2]-a[2]).normalize().negate();o=[e[0]+n.x*t,e[1]+n.y*t,e[2]+n.z*t]}this.focusedBody=void 0,UL(n,[...e],r,a,o,Mx().resolvedReducedMotion);let s=aC(o??a,e,void 0);i.onCameraPosition?.(s.latitude,s.longitude,s.distance)}handleFocus(e){if(this.readerFocusFilter&&!this.readerFocusFilter(e))return;if(this.focusedBody?.data.id===e.data.id){this.deps.callbacks.onFocusChange(e);return}if(this.setFocusTarget(e),e.positionUnknown)return;let{latitude:t,longitude:n,distance:r}=aC(this.cameraTruePos(),e.position,this.focusedBodyQuat(e));this.deps.callbacks.onCameraPosition?.(t,n,r)}setFocusTarget(e,t){let{ctx:n,bodyObjects:r,controls:i,callbacks:a,focus:o,camera:s,systemData:c,loadTexture:l}=this.deps;un(e)||this.promotion.ensureBodyObjects(e);let u=this.focusedBody,d=xM(u,r),f=xM(e,r),p=u&&(un(u)?u.featureAnchor.hostId:u.data.id),m=un(e)?e.featureAnchor.hostId:e.data.id,h=this.syncUpgradeTargets(e);if(p&&p!==m&&!h.has(p)){let e=r.get(p);e&&lO(e)}if(d&&d!==f){let e=r.get(d);e&&PM(e)}this.focusedBody=e,un(e)||(n.bodies.focusFeature=null),i.minDistance=XL(e,AO(r.get(e.data.id)));let g=un(e)?n.getBody(e.featureAnchor.hostId):void 0;if(n.visibility.setFocused(g??e),a.onFocusChange(e),un(e)||l(e),f&&f!==e.data.id){let e=n.getBody(f);e&&l(e)}c.syncToFocus(),e.positionUnknown||UL(o,[...e.position],s,this.cameraTruePos(),t,Mx().resolvedReducedMotion),this.promotion.emitUserPromotedCount()}focusOnBody(e,t,n,r){let{ctx:i,clock:a,focus:o,camera:s,callbacks:c,pointClouds:l}=this.deps,u=i.getBody(e);if(!u)return 0;if(i.bodies.bodiesById.has(e)||DT(u,a.jd,i),u.positionUnknown)return this.setFocusTarget(u),0;let d;if(t!==void 0)if(n!==void 0&&r!==void 0)d=oC(u.position,n,r,t,this.focusedBodyQuat(u));else{let e=this.cameraTruePos(),n=this._tmpV3.set(u.position[0]-e[0],u.position[1]-e[1],u.position[2]-e[2]).normalize().negate();d=[u.position[0]+n.x*t,u.position[1]+n.y*t,u.position[2]+n.z*t]}let f=aC(d??this.cameraTruePos(),u.position,this.focusedBodyQuat(u));return c.onCameraPosition?.(f.latitude,f.longitude,f.distance),t!==void 0&&d?this.focusedBody?.data.id===e&&R_(o.focusTruePos,u.position)<XL(u)?(o.focusTruePos=[...u.position],this.deps.repositionAll(),l.rebuildBasis(),WL(o,s,this.cameraTruePos(),d,Mx().resolvedReducedMotion)):(this.setFocusTarget(u,d),n!==void 0&&r!==void 0&&(o.orbitFly=!0)):this.setFocusTarget(u),o.focusDurationMs}snapToBody(e,t,n,r){let i=this.deps.ctx.getBody(e);!i||i.positionUnknown||(this.settleOnBodyInstant(i),this.snapToBodyFrame(t,n,r))}snapToBodyFacing(e,t,n,r){let{ctx:i,camera:a,controls:o,callbacks:s}=this.deps,c=i.getBody(e);if(!c||c.positionUnknown)return;this.settleOnBodyInstant(c);let l=i.getBody(t)?.position??[0,0,0],u=sC(c.position,l,n,r);a.position.set(u[0],u[1],u[2]),o.update();let d=aC(u,[0,0,0]);s.onCameraPosition?.(d.latitude,d.longitude,d.distance),this.pendingInitialView=null}settleOnBodyInstant(e){let{focus:t,pointClouds:n}=this.deps;this.setFocusTarget(e),t.focusTruePos=[...e.position],t.focusOriginWorld=[...e.position],t.focusTargetWorld=[...e.position],t.focusStartTime=-NL,t.camOriginWorld=null,t.camTargetWorld=null,t.flyQ0=null,t.orbitFly=!1,t.arcOrbit=!1,t.cameraStaysOnBody=!1,this.deps.repositionAll(),n.rebuildBasis()}snapToBodyFrame(e,t,n){let r=this.focusedBody;if(!r)return;let{camera:i,controls:a,callbacks:o}=this.deps,s=!XD(r),c=s?this.focusedBodyQuat(r)??[0,0,0,1]:void 0,l=oC([0,0,0],e,t,n,c);i.position.set(l[0],l[1],l[2]),a.update();let u=aC(l,[0,0,0],c);o.onCameraPosition?.(u.latitude,u.longitude,u.distance),s&&c[0]===0&&c[1]===0&&c[2]===0&&c[3]===1&&(this.pendingInitialView={latitude:e,longitude:t,zoom:n})}reapplyInitialViewIfPending(){let e=this.pendingInitialView;if(!e)return;let t=this.focusedBodyQuat();if(!t||t[0]===0&&t[1]===0&&t[2]===0&&t[3]===1){this.pendingInitialView=null;return}let n=oC([0,0,0],e.latitude,e.longitude,e.zoom,t);this.deps.camera.position.set(...n),this.deps.controls.update(),this.pendingInitialView=null}};function aR(e,t){if(!e)return[];if(un(e)){let n=t.getBody(e.featureAnchor.hostId);return n&&gj(n)?[n]:[]}let n=[];if(gj(e)&&n.push(e),e.data.objectType===W.MOON||e.data.orbitalSource===U.SPICE_PROBE){let r=t.getBody(e.data.parentId);r&&n.push(r)}return n}var oR=1e-6;function sR(e){return e.data.name??e.data.id}var cR=class{armedProbeId=null;noticeShown=!1;coverage=new Map;pending=new Set;constructor(e,t){this.clock=e,this.notices=t}coverageFor(e){let t=this.coverage.get(e);if(t!==void 0)return t??void 0;this.pending.has(e)||(this.pending.add(e),hx(e,!1).then(t=>this.coverage.set(e,t.global?.coverage??null)).catch(()=>this.coverage.set(e,null)).finally(()=>this.pending.delete(e)))}sync(e,t){let n=e?.data.id??null,r=n===null?void 0:this.coverageFor(n);if(!e||!r){this.disarm();return}this.armedProbeId!==n&&(this.dismissNotice(),this.armedProbeId=n);let i=r.end_jd-oR,a=r.start_jd+oR;this.noticeShown&&t>a&&t<i&&this.dismissNotice(),this.clock.setBoundaryStops({forwardJd:i,backwardJd:a,onHit:t=>this.onHit(e,t,i)})}onHit(e,t,n){this.notices.notify({topic:`coverage-pause`,name:sR(e),direction:t>=n?`forward`:`backward`,jd:t}),this.noticeShown=!0}disarm(){this.armedProbeId!==null&&(this.armedProbeId=null,this.dismissNotice(),this.clock.setBoundaryStops(null))}dismissNotice(){this.noticeShown&&=(this.notices.dismiss(`coverage-pause`),!1)}},lR=class{group=new za;extensions=new Set;constructor(){this.group.matrixAutoUpdate=!1,this.group.frustumCulled=!1}add(e){this.extensions.add(e),this.group.add(e.object)}remove(e){this.extensions.delete(e)&&(this.group.remove(e.object),e.dispose())}update(e){for(let t of this.extensions)t.update(e)}clear(e){for(let t of[...this.extensions])e?.(t)||(this.extensions.delete(t),this.group.remove(t.object),t.dispose())}dispose(){this.clear()}},uR=Math.PI/180;function dR(e){return`latitude`in e}function fR(e,t){let n=e*uR,r=t*uR;return[Math.cos(n)*Math.cos(r),Math.sin(n),-Math.cos(n)*Math.sin(r)]}function pR(e,t,n,r,i,a){let o=2*(e.y*r-e.z*n),s=2*(e.z*t-e.x*r),c=2*(e.x*n-e.y*t);i[a]=t+e.w*o+(e.y*c-e.z*s),i[a+1]=n+e.w*s+(e.z*o-e.x*c),i[a+2]=r+e.w*c+(e.x*s-e.y*o)}function mR(e,t,n){return kT(e,n,t)?e.position:null}function hR(e,t,n){let r=t.getBody(e.body),i=r&&mR(r,t,n);if(!i)return null;let[a,o,s]=i;if(dR(e)){let t=Q(gn(r.data)+(e.altitudeKm??0)),[i,c,l]=fR(e.latitude,e.longitude),u=r.orientation?mC(r.orientation,n,r.nutPrec):null;if(!u)return[a+i*t,o+c*t,s+l*t];let d=[0,0,0];return pR(u,i,c,l,d,0),[a+d[0]*t,o+d[1]*t,s+d[2]*t]}let c=typeof e.offsetKm==`function`?e.offsetKm(n):e.offsetKm;if(c===null)return null;if(c===void 0)return[a,o,s];let[l,u,d]=TF(c);return[a+l,o+u,s+d]}function gR(e,t,n,r){let i=n.getBody(e.body),a=i&&mR(i,n,r);if(!a)return null;let o=t[0]-a[0],s=t[1]-a[1],c=t[2]-a[2],l=Math.hypot(o,s,c);return l===0?null:[o/l,s/l,c/l]}function _R(e){let t=ig/10;return[e[0]*t,-e[2]*t,e[1]*t]}function vR(e,t,n){let r=hR(e.position,t,n),i=hR(e.target,t,n);if(!r||!i)return null;let[a,o,s]=e.up??[0,0,1];return{position:r,target:i,up:[a,s,-o]}}var yR=.02,bR=1e-4;function xR(e){return e?.4:.05}function SR(e,t,n,r,i){let a=e.position.length();if(!(a>0))return{rotate:1,translate:1};let o=XD(n)?void 0:n,s=a;for(let n of[o,i?void 0:r]){if(!n)continue;let r=Q(gn(n.data));if(!(r>0))continue;let i=Math.hypot(e.position.x-(n.position[0]-t[0]),e.position.y-(n.position[1]-t[1]),e.position.z-(n.position[2]-t[2]));s=Math.min(s,i-r)}let c=o?Q(gn(o.data)):0,l=Math.tan(Vi.degToRad(e.getEffectiveFOV())/2);return{rotate:CR(c>0?(a-c)*l/(Math.PI*c):1,bR),translate:CR(s/a,yR)}}function CR(e,t){return Math.min(1,Math.max(t,e))}var wR=Math.PI/180;function TR(e,t){let n=e*wR,r=t*wR;return[Math.cos(n)*Math.cos(r),Math.sin(n),-Math.cos(n)*Math.sin(r)]}function ER(e,t,n,r){let i=document.createElement(`div`);i.className=`user-location-marker`;let a=new $O(i),[o,s,c]=TR(n,r);return a.position.set(o*t,s*t,c*t),e.add(a),a}function DR(e){e.parent?.remove(e),e.element.remove()}var OR=new J;function kR(e,t,n){if(!e)return;let r=t.get(p_);if(!r?.mesh)return;OR.copy(e.position).applyQuaternion(r.mesh.quaternion);let i=OR.x,a=OR.y,o=OR.z,s=r.mesh.position,c=n.position.x-s.x,l=n.position.y-s.y,u=n.position.z-s.z,d=r.radiusScene,f=d*d;e.visible=c*c+l*l+u*u<=f||i*c+a*l+o*u>f}var AR=-1,jR=1.2,MR=Q(1e6),NR=.02,PR=2,FR=2.3,IR=.9,LR=new J,RR=.25,zR=10,BR=4,VR=4,HR=28,UR=.02,WR=class e{renderer;composer;atmoDepthPass;bloomPass;labelRenderer;scene;camera;controls;motionScale={rotate:1,translate:1};pointerInteraction;gpuPick;canvas;ctx;clock;callbacks;selectedFeatureId=null;bodyObjects=new Map;circleTexture=ZM();pointClouds;systemData;positionDiagnostics=new OI;clickables=[];meshToBody=new Map;hoveredBodyIds=new Set;cullFrameCounter=0;hideCappedMoonLabels=!1;focusController;coverageWatch=null;outOfRange;extensions=new lR;cameraHold=null;holdingCamera=!1;_tmpV3=new J;cameraBand=null;focusableBodies=null;limitsArmed=!1;bodySelectEnabled=!0;featureSelectEnabled=!0;modelScene;modelCamera;modelLight;overlayActive=!1;modelShadowPlane=null;_tmpUp=new J;_tmpSun=new J;_planeNormal=new J(0,0,1);_modelRaycaster=new Rd;_pickNdc=new q;showPointingAxes=!1;pointingAxes=null;cameraUp;skyboxAdjuster;skyDebugMarkers;haloDebug;travelPath;orbitPreview;previewFlyBodyId=null;travelFocus=null;focus={focusTruePos:[0,0,0],focusOriginWorld:[0,0,0],focusTargetWorld:[0,0,0],camOriginWorld:null,camTargetWorld:null,camTargetOffset:null,camOriginOffset:null,flyQ0:null,orbitFly:!1,arcOrbit:!1,cameraStaysOnBody:!1,focusStartTime:0,focusDurationMs:NL};lastUpdatedJd=NaN;get placedJd(){return this.lastUpdatedJd}lastUpdatedSystemId=null;lastSeatConfigKey=null;lastProbeVersion=0;disposed=!1;lastHostReadVersion=0;focusWasOutOfRange=!1;_positionMapScratch=new Map;frameIndex=0;static WAKE_FRAMES=30;static IDLE_HEARTBEAT_FRAMES=10;static REALTIME_FRAME_MS=30;wakeUntilFrame=e.WAKE_FRAMES;lastRenderedFrame=0;lastRenderMs=0;lastRenderedJd=NaN;lastRenderedFocusKey=``;lastRenderedCamPos=new J(NaN,NaN,NaN);lastRenderedCamQuat=new Hi;unsubscribeBodiesAdded=null;_trailView={camX:0,camY:0,camZ:0,tolAngle:0};viewportH=1;tier=Yx();landedNomBodyId=null;rafId=0;paused=!1;covered=!1;firstFrame=!0;pendingUrlWrite=!1;lastTickMs=0;static FPS_SAMPLE_FRAMES=30;fpsSamples=[];fpsSampleHead=0;stashedSky=null;namesShown=!0;textureLoader=new Ju;appearances=new cM;shadowLight;ambientLights;get sunPointLight(){return this.bodyObjects.get(f_)?.extraObjects.find(e=>e instanceof dd)}tightFar=!1;sunProxyK=1;sunBaseMeshScale=1;sunBaseCoronaScale=0;userLocationMarker=null;labelContainer;static MAP_LAYER=1;static ATMO_DEPTH_LAYER=2;constructor(t,n,r,i,a,o){this.canvas=t,this.ctx=r,r.hasMeshBody=e=>this.bodyObjects.has(e),this.clock=i,this.callbacks=o,this.outOfRange=new hI(o.notices),this.labelContainer=n;let s=ET(t,n,r);this.viewportH=t.clientHeight||1,this.renderer=s.renderer,this.labelRenderer=s.labelRenderer,this.scene=s.scene,this.scene.add(this.extensions.group),this.camera=s.camera,this.composer=s.composer,this.bloomPass=s.bloomPass,this.shadowLight=s.shadowLight;let c=this.renderer.getDrawingBufferSize(new q);this.atmoDepthPass=new yj(c.x,c.y),this.modelScene=new qa,this.modelScene.environment=ST(this.renderer),this.modelScene.environmentIntensity=yT,this.modelCamera=new sd(60,1,.01,1e3),this.modelScene.add(this.modelCamera);let l=new hd(16777215,_T);this.modelScene.add(l),this.ambientLights=[s.ambientLight,l],this.modelLight=new md(16777215,vT),this.modelLight.castShadow=!0,this.modelLight.shadow.mapSize.set(this.tier.shadowMapSize,this.tier.shadowMapSize),this.modelLight.shadow.camera.left=-4,this.modelLight.shadow.camera.right=4,this.modelLight.shadow.camera.top=4,this.modelLight.shadow.camera.bottom=-4,this.modelLight.shadow.camera.near=4,this.modelLight.shadow.camera.far=28,this.modelLight.shadow.bias=-1e-4,this.modelLight.shadow.normalBias=.02,this.modelScene.add(this.modelLight),this.modelScene.add(this.modelLight.target),this.modelShadowPlane=new As(new $l(40,40),new iu({opacity:.55})),this.modelShadowPlane.receiveShadow=!0,this.modelShadowPlane.visible=!1,this.modelScene.add(this.modelShadowPlane),this.skyboxAdjuster=new EN(this.scene),this.skyDebugMarkers=new WN(this.scene),this.haloDebug=new $N(this.canvas),this.travelPath=new tI(this.scene,this.canvas),this.travelPath.setLayer(e.MAP_LAYER),this.orbitPreview=new oI(this.scene),this.orbitPreview.setLayer(e.MAP_LAYER),this.skyboxAdjuster.set(0,0,0),pS(this.scene,this.renderer,r,()=>this.disposed);let u=r.bodies.majorBodies.find(e=>e.data.id===f_),d=r.getBody(a.id),f=d&&!d.positionUnknown?d:void 0,p=r.bodies.majorBodies.find(e=>e.data.id===uC)||u,m=f??p,h=m?.position??[0,0,0];this.focus.focusTruePos=[...h],this.focus.focusOriginWorld=[...h],this.focus.focusTargetWorld=[...h],this.focus.focusStartTime=-NL,this.pointClouds=new MP(r,this.scene,this.bodyObjects,this.circleTexture,this.focus,e.MAP_LAYER,()=>this.rebuildTrailBasis()),this.pointClouds.seedBasis(h),this.pointClouds.setPointBudget(this.tier.pointBudget),this.controls=new LS(this.camera,t),this.controls.enableDamping=!0,this.controls.dampingFactor=xR(Mx().resolvedReducedMotion),this.controls.minDistance=m?XL(m):Q(.01),this.controls.maxDistance=31620.5*10,this.controls.target.set(0,0,0),this.controls.update(),this.controls.addEventListener(`end`,this.onControlsEnd),this.controls.addEventListener(`start`,this.invalidate),this.controls.addEventListener(`start`,this.armLimits),this.controls.addEventListener(`end`,this.invalidate);for(let n of e.INPUT_EVENTS)t.addEventListener(n,this.invalidate,{passive:!0});window.addEventListener(`keydown`,this.invalidate),this.unsubscribeBodiesAdded=r.bodies.onBodiesAdded(this.invalidate),this.cameraUp=new QO(this.camera,this.controls,r,e=>this.isLanded(e)),this.systemData=new wN(this.scene,r,this.renderer,this.textureLoader,this.bodyObjects,i,()=>this.focusController.reapplyInitialViewIfPending()),this.focusController=new iR({ctx:r,clock:i,camera:this.camera,controls:this.controls,scene:this.scene,bodyObjects:this.bodyObjects,clickables:this.clickables,meshToBody:this.meshToBody,callbacks:o,focus:this.focus,pointClouds:this.pointClouds,systemData:this.systemData,loadTexture:e=>this.maybeLoadTexture(e),repositionAll:()=>this.repositionAll(),assignMapLayerToTrails:()=>this.assignMapLayerToTrails()},m,this.hoveredBodyIds,this.circleTexture,this.renderer),this.coverageWatch=new cR(i,o.notices);let g=f?a:{latitude:45,longitude:0,zoom:15},_=oC([0,0,0],g.latitude,g.longitude,g.zoom,this.focusController.focusedBodyQuat());this.camera.position.set(..._),this.focusController.setPendingInitialView({latitude:g.latitude,longitude:g.longitude,zoom:g.zoom}),m&&r.visibility.setFocused(m),r.visibility.updateCamera(g.zoom,this.clock.jd),o.onFocusChange(m),this.buildScene(),m&&this.focusController.promotion.ensureBodyObjects(m),m&&this.focusController.syncUpgradeTargets(m),this.repositionAll(),m&&this.maybeLoadTexture(m),this.systemData.syncToFocus(),this.focusController.readerFocusFilter=this.readerMayFocus,this.gpuPick=new BO(this.renderer,this.camera),this.pointerInteraction=new FO(t,this.camera,r,i,this.focus,this.clickables,this.meshToBody,e=>this.focusController.handleFocus(e),(e,t)=>this.pickFocusedModel(e,t),this.gpuPick,()=>[...this.pointClouds.asteroids().values(),...this.pointClouds.spacecraft().values()],this.pointClouds.pickRegistry),this.pointerInteraction.attach(),this.tick()}buildScene(){hj(this.ctx.bodies.majorBodies,this.scene,this.clickables,this.meshToBody,this.bodyObjects,this.circleTexture,this.renderer.domElement,e=>this.focusController.handleFocus(e),(e,t)=>{t?this.hoveredBodyIds.add(e):this.hoveredBodyIds.delete(e),this.invalidate()}),this.pointClouds.buildInitial(new Set(this.bodyObjects.keys()));let e=this.pointClouds.basis();(globalThis.requestIdleCallback??(e=>setTimeout(e,0)))(()=>{bN(this.bodyObjects,this.scene,e,this.clock.jd),this.assignMapLayerToTrails()})}setTravelPath(e,t=[],n=[],r=[]){this.travelPath.set(e,t,n,r),this.refreshTravelPath()}setTravelHover(e){this.travelPath.setHovered(e)}setOrbitPreview(e,t=null){this.orbitPreview.set(e),this.refreshOrbitPreview(),t&&this.frameOrbitPreview(t)}frameOrbitPreview(e){let t=this.ctx.getBody(e.bodyId);if(!t)return;let n=Q(e.radiusKm);if(!(n>0)||performance.now()-this.focus.focusStartTime<this.focus.focusDurationMs&&this.previewFlyBodyId===e.bodyId)return;let r=this.focus.focusTruePos,i=t.position[0]-r[0]-this.camera.position.x,a=t.position[1]-r[1]-this.camera.position.y,o=t.position[2]-r[2]-this.camera.position.z,s=Math.hypot(i,a,o);s>n*1.35&&s<n*45||(this.previewFlyBodyId=e.bodyId,this.focusController.focusOnBody(e.bodyId,n*4))}refreshOrbitPreview(){this.orbitPreview.isEmpty||(this.orbitPreview.reposition(e=>this.ctx.getBody(e)?.position??null,this.focus.focusTruePos),this.orbitPreview.updateCameraOffset(this.camera.position))}refreshTravelPath(){if(this.travelPath.isEmpty){this.reserveTravelLabelSpace();return}let e=this.travelPath.centerId,t=e?this.ctx.getBody(e):null;if(!t){this.travelPath.setVisible(!1),this.reserveTravelLabelSpace();return}this.travelPath.setVisible(!0),this.travelPath.setClock(this.clock.jd),this.travelPath.reposition(t.position,this.focus.focusTruePos,e=>this.ctx.getBody(e)?.position??null),this.travelPath.updateCameraOffset(this.camera.position),this.reserveTravelLabelSpace()}reserveTravelLabelSpace(){this.travelPath.reserveLabelSpace(this.camera,this.renderer.domElement.clientWidth,this.renderer.domElement.clientHeight)}focusOnPathPoint(e,t){this.disarmLimits();let n=this.ctx.getBody(e);if(!n)return;let[r,i,a]=TF(t);this.travelFocus={centerId:e,local:[r,i,a]};let o=this.travelFocusWorld(n.position);o&&this.focusController.focusOnPoint(o)}trackPathPoint(e,t){if(!this.travelFocus){this.focusOnPathPoint(e,t);return}let[n,r,i]=TF(t);this.travelFocus={centerId:e,local:[n,r,i]}}travelFocusWorld(e){let t=this.travelFocus;return t?[e[0]+t.local[0],e[1]+t.local[1],e[2]+t.local[2]]:null}refreshTravelFocus(){if(!this.travelFocus)return;if(this.focusController.current){this.travelFocus=null;return}let e=this.ctx.getBody(this.travelFocus.centerId);if(!e)return;let t=this.travelFocusWorld(e.position);if(!t)return;let n=this.focus;n.focusTargetWorld=t;let r=n.camTargetOffset;r&&n.camTargetWorld&&(n.camTargetWorld=[t[0]+r[0],t[1]+r[1],t[2]+r[2]]),performance.now()-n.focusStartTime>=n.focusDurationMs&&(n.focusTruePos=[...t])}updateTravelCraftSystem(){let e=this.travelFocus,t=this.travelPath.plan;if(!e||!t){this.ctx.visibility.clearTravelSystem();return}let n=this.ctx.getBody(e.centerId),r=n?this.travelFocusWorld(n.position):null;if(!r)return;let i=null;for(let e of t.stops){let t=this.ctx.getBody(e.bodyId);if(!t)continue;let n=this.ctx.visibility.resolveSystemId(t);if(!n)continue;let a=this.ctx.visibility.systemReachAU(n);if(!(a>0))continue;let o=R_(r,t.position)/10;!i&&o<=a?i=n:o<=a*2?this.systemData.prefetch(n):this.systemData.discardPrefetch(n)}this.ctx.visibility.setTravelSystem(i)}assignMapLayerToTrails(){for(let t of this.bodyObjects.values())t.trail&&t.trail.layers.set(e.MAP_LAYER)}setImmersive(t){t?(this.camera.layers.disable(e.MAP_LAYER),this.labelContainer.style.display=`none`):(this.camera.layers.enable(e.MAP_LAYER),this.labelContainer.style.display=``)}rebuildMinorPointClouds(){this.pointClouds.rebuildMinor()}repositionAll(){this.repositionBodies(),this.rebuildTrailBasis()}repositionBodies(){let[e,t,n]=this.focus.focusTruePos;for(let r of this.bodyObjects.values()){let[i,a,o]=r.body.position,s=i-e,c=a-t,l=o-n;r.group.position.set(s,c,l);for(let e of r.extraObjects)e.position.set(s,c,l)}this.pointClouds.reposition()}rebuildTrailBasis(){let e=this.focus.focusTruePos,[t,n,r]=e;for(let i of this.bodyObjects.values()){let a=i.trail;if(!a)continue;let o=a.userData.trailBuffer;if(o){YP(i.body,a,o,e,this.clock.jd);continue}let s=a.userData.trailLocalPositions;if(!s)continue;let c=a.userData.orbitCenter;XP(a,s,c.x-t,c.y-n,c.z-r)}}tick=()=>{this.rafId=requestAnimationFrame(this.tick),this.frameIndex++;let t=performance.now(),n=this.lastTickMs?t-this.lastTickMs:0;if(this.lastTickMs=t,this.holdingCamera||this.cameraUp.update(this.clock.jd),this.firstFrame&&(this.firstFrame=!1,this.controls.target.set(0,0,0),this.controls.update()),this.coverageWatch?.sync(this.focusController.current,this.clock.jd),this.clock.tick(performance.now()),!this.shouldRender(t)){this.controls.update(),this.applyReaderLimits(t);return}this.fpsSamples.length<e.FPS_SAMPLE_FRAMES?this.fpsSamples.push(t):(this.fpsSamples[this.fpsSampleHead]=t,this.fpsSampleHead=(this.fpsSampleHead+1)%e.FPS_SAMPLE_FRAMES);let r=this.lastRenderedFrame===this.frameIndex-1?n:0;this.lastRenderedFrame=this.frameIndex,this.lastRenderMs=t,this.lastRenderedJd=this.clock.jd,this.lastRenderedFocusKey=this.focusKey(),this.lastRenderedCamPos.copy(this.camera.position),this.lastRenderedCamQuat.copy(this.camera.quaternion),this.applyJdUpdate(!0),this.refreshTravelFocus(),this.callbacks.onFrame?.(this.clock.jd,r);let i=this.holdingCamera?this.applyHeldCamera():HL(this.focus,this.camera,this.controls,()=>this.repositionAll(),()=>this.pointClouds.rebuildBasis());this.applyReaderLimits(t);let a=this.holdingCamera?void 0:this.focusController.current;if(a){let e=F_(a.data.parentId),t=e?this.ctx.getBody(e):void 0,n=!!this.bodyObjects.get(a.data.id)?.isLanded||un(a);t&&ZL(this.camera,t,this.focus.focusTruePos,this.surfaceClamp(t,n)),DO(this.bodyObjects.get(a.data.id))&&ZL(this.camera,a,this.focus.focusTruePos,this.surfaceClamp(a,!1)),this.setMotionScale(SR(this.camera,this.focus.focusTruePos,a,t,n))}else this.setMotionScale({rotate:1,translate:1});if(this.pendingUrlWrite&&i){this.pendingUrlWrite=!1;let{latitude:e,longitude:t,distance:n}=this.getCameraState();this.callbacks.onCameraPosition?.(e,t,n)}this.systemData.hasPendingUnloads()&&performance.now()-this.focus.focusStartTime>=this.focus.focusDurationMs&&this.systemData.drainPendingUnloads();let{distance:o}=this.getCameraState();this.updateTravelCraftSystem(),this.ctx.visibility.updateCamera(o,this.clock.jd),this.updateTightFar(o),this.systemData.syncToFocus(),this.refreshTravelPath(),this.refreshOrbitPreview(),this.extensions.update({jd:this.clock.jd,basis:this.focus.focusTruePos,camera:this.camera,viewportPx:this.viewportH,ctx:this.ctx}),this.cullFrameCounter=dF(this.bodyObjects,this.camera,this.ctx,this.focus.focusTruePos,this.focusController.current?.data.id,this.hideCappedMoonLabels,this.hoveredBodyIds,this.pointClouds.asteroids(),this.pointClouds.spacecraft(),this.pointClouds.moons(),this.cullFrameCounter,this.renderer,this._tmpV3,!i,this.tightFar),this.pointClouds.applyPointBudget(),DI(this.bodyObjects,this.focus,this.lastUpdatedJd,this.trailView()),NI(this.bodyObjects,this.focus.focusTruePos,Mx().realisticLighting,Mx().overexposeRings,this.camera.position,this.pxPerRad()),lL(this.bodyObjects,this.focus.focusTruePos);let s=sL(this.bodyObjects,this.camera.position,Mx().showAtmospheres,Mx().realisticLighting,this.sunIntensityScale,Hk(),this.clock.jd);$k(r,s.shellProminent),this.scene.backgroundIntensity=s.skyboxIntensity,this.applyLayerChrome();let c=this.bodyObjects.get(f_);c&&lj(c.corona,c.starPoint,s.sunTint);let l=Mx().highAmbient?1:_T;if(!Mx().highAmbient&&Mx().realisticLighting){let e=this.bodyObjects.get(f_)?.body.position;if(e&&this.ctx.visibility.activeSystemId){let[t,n,r]=this.focus.focusTruePos;l*=bT(Math.hypot(e[0]-t,e[1]-n,e[2]-r))}}for(let e of this.ambientLights)e.intensity=l;kR(this.userLocationMarker,this.bodyObjects,this.camera);let u=xM(this.focusController.current,this.bodyObjects);ML(this.bodyObjects,this.camera,this.renderer,this.ctx,this.textureLoader,u,this.clock.jd,this.appearances),AL(this.bodyObjects,this.camera,this.renderer,this.ctx,u),dL(this.bodyObjects,this.focus.focusTruePos,this.ctx,this.shadowLight,this.sunPointLight,o,this._tmpV3,Mx().realisticLighting,this.sunIntensityScale),this.updateModelMounts(),this.pointClouds.drainOnePendingSceneAdd(),this.updateDepthFar(),this.updateSunProxy(s.sunRefraction),s.insideShell&&this.atmoDepthPass.run(this.renderer,this.scene,this.camera,this.bodyObjects,e.ATMO_DEPTH_LAYER),this.composer.render(),this.renderModelOverlay(),this.labelRenderer.render(this.scene,this.camera),this.haloDebug.active&&this.haloDebug.draw(this.bodyObjects,this.camera,this.focus.focusTruePos,this.focusController.current?.data.id,this.renderer.domElement.clientWidth,this.renderer.domElement.clientHeight)};updateTightFar(e){if(iT())return;let t=this.focusController.current,n=t?xM(t,this.bodyObjects):void 0,r=n?this.bodyObjects.get(n):void 0,i=r?.radiusScene??0,a=e;if(t&&r&&n!==t.data.id){let[e,t,n]=this.focus.focusTruePos,[i,o,s]=r.body.position,c=this.camera.position;a=Math.hypot(e+c.x-i,t+c.y-o,n+c.z-s)}let o=this.tightFar?FR:PR;this.tightFar=i>0&&this.ctx.visibility.activeSystemId!==null&&a<i*o}updateDepthFar(){if(iT())return;let e=CT,t=this.ctx.visibility.activeSystemId;if(t){let[n,r,i]=this.focus.focusTruePos,a=this.camera.position.lengthSq(),o=e=>{let t=e[0]-n,o=e[1]-r,s=e[2]-i,c=t*t+o*o+s*s;c>a&&(a=c)},s=this.bodyObjects.get(f_);if(this.tightFar){let e=this.bodyObjects.get(t)?.body;if(e){let o=Math.hypot(e.position[0]-n,e.position[1]-r,e.position[2]-i)+this.ctx.bodies.getSystemExtent(t)*10*2;a=Math.max(a,o*o)}}else s&&o(s.body.position);for(let e of this.bodyObjects.values())this.ctx.visibility.hasFullRendering(e.body)&&o(e.body.position);e=Math.min(CT,Math.max(MR,Math.sqrt(a)*jR))}Math.abs(e-this.camera.far)>this.camera.far*NR&&(this.camera.far=e,this.camera.updateProjectionMatrix())}updateSunProxy(e){let t=this.bodyObjects.get(f_);if(!t)return;let[n,r,i]=this.focus.focusTruePos,[a,o,s]=t.body.position,c=a-n,l=o-r,u=s-i;if(e){let t=this.camera.position,n=this._tmpV3.set(c-t.x,l-t.y,u-t.z),r=n.length();n.divideScalar(r);let i=LR.copy(e.up).addScaledVector(n,-e.up.dot(n));i.lengthSq()>1e-12&&(n.addScaledVector(i.normalize(),e.angleRad).normalize(),c=t.x+n.x*r,l=t.y+n.y*r,u=t.z+n.z*r)}let d=1;if(this.tightFar){let e=this.camera.far*IR,t=Math.hypot(c,l,u);t>e&&(d=e/t)}if(!(d===1&&this.sunProxyK===1&&!e)){this.sunProxyK===1&&(this.sunBaseMeshScale=t.mesh?.scale.x??1,this.sunBaseCoronaScale=t.corona?.scale.x??0),t.group.position.set(c*d,l*d,u*d);for(let e of t.extraObjects)e.position.set(c*d,l*d,u*d);t.mesh?.scale.setScalar(this.sunBaseMeshScale*d),t.corona?.scale.set(this.sunBaseCoronaScale*d,this.sunBaseCoronaScale*d,1),this.sunProxyK=d}}setMotionScale(e){this.motionScale=e,this.controls.rotateSpeed=e.rotate,this.controls.panSpeed=e.translate,this.controls.zoomSpeed=e.translate}isLanded(e){return!!this.bodyObjects.get(e)?.isLanded}surfaceRadialKm(e,t,n){let r=this.ctx.getBody(e);if(!r)return null;let i=lw(t*Math.PI/180,n*Math.PI/180);return jw(this.bodyObjects.get(e),e,gn(r.data),i)}surfaceClamp(e,t){let n=this.bodyObjects.get(e.data.id);if(DO(n))return{invQuat:n.model.quaternion.clone().invert(),seated:t,outerRadiusKm:kO(n),centerOffsetScene:OO(n),radialKm:e=>EO(n,e)};if(!(!t||!e.orientation))return{invQuat:mC(e.orientation,this.clock.jd,e.nutPrec).invert(),seated:t,radialKm:t=>jw(n,e.data.id,e.data.radiusKm,t)}}updateModelMounts(){let e=!1;for(let t of this.bodyObjects.values())if(t.model&&XD(t.body)){e=!0;break}this.overlayActive=e;for(let t of this.bodyObjects.values()){let n=t.model,r=t.modelRoot;if(!(!n||!r)){if(e)n.parent!==this.modelScene&&this.modelScene.add(n);else if(n.parent!==r){r.add(n);let e=n.userData;n.scale.setScalar(e.fitScale??1),n.position.set(0,0,0),e.centerOffset&&n.position.addScaledVector(e.centerOffset,-1)}}}if(e){this.shadowLight.castShadow=!1;return}this.updateFocusedMountedModel()}updateFocusedMountedModel(){let e=this.overlayModelBo(),t=e?.model&&e.model.parent===e.modelRoot?e.modelRoot:null;if(!e||!t){this.shadowLight.castShadow=!1;return}let n=nO(e);t.scale.setScalar(n);let r=this.shadowLight.intensity>0;if(this.shadowLight.castShadow=r,!r)return;let i=this.bodyObjects.get(f_)?.body;if(!i)return;let[a,o,s]=i.position,[c,l,u]=e.body.position;this._tmpSun.set(a-c,o-l,s-u).normalize(),this.shadowLight.position.copy(e.group.position).addScaledVector(this._tmpSun,zR*n),this.shadowLight.target.position.copy(e.group.position);let d=this.shadowLight.shadow.camera;d.left=d.bottom=-BR*n,d.right=d.top=BR*n,d.near=VR*n,d.far=HR*n,d.updateProjectionMatrix(),this.shadowLight.shadow.normalBias=UR*n}renderModelOverlay(){if(!this.overlayActive)return;let e=this.overlayModelBo();if(!e?.model)return;let t=e.model.userData;e.model.scale.setScalar(t.fitScale??1),e.model.position.set(0,0,0),e.isLanded&&t.feetOffset?e.model.position.copy(t.feetOffset).applyQuaternion(e.model.quaternion).multiplyScalar(-1):t.centerOffset&&e.model.position.copy(t.centerOffset).multiplyScalar(-1),this._tmpV3.copy(this.camera.position).sub(e.group.position);let n=this._tmpV3.length(),r=nO(e),i=n/r;this.modelCamera.position.copy(this._tmpV3).normalize().multiplyScalar(i),this.modelCamera.quaternion.copy(this.camera.quaternion),this.modelCamera.aspect=this.camera.aspect;let a=0;for(let t of this.bodyObjects.values()){let n=t.model;if(!n||t===e)continue;let i=nO(t)/r,o=n.userData.fitScale??1;n.scale.setScalar(o*i),n.position.subVectors(t.group.position,e.group.position).divideScalar(r);let s=n.userData;s.centerOffset&&n.position.addScaledVector(s.centerOffset,-i);let c=n.position.length()+i;c>a&&(a=c)}this.modelCamera.near=Math.max(.01,i-5-a),this.modelCamera.far=i+50+a,this.modelCamera.updateProjectionMatrix();let o=this.bodyObjects.get(f_)?.body,s=1;if(o){let[t,n,r]=o.position,[i,a,c]=e.body.position;this._tmpSun.set(t-i,n-a,r-c),Mx().realisticLighting&&(s=bT(this._tmpSun.length())),this._tmpSun.normalize(),this.modelLight.position.copy(this._tmpSun).multiplyScalar(10)}if(this.modelShadowPlane){this._tmpUp.set(0,1,0).applyQuaternion(e.model.quaternion);let t=this._tmpSun.dot(this._tmpUp)>.03;this.modelShadowPlane.visible=!!e.isLanded&&!e.isCrashed&&t,this.modelShadowPlane.visible&&this.modelShadowPlane.quaternion.setFromUnitVectors(this._planeNormal,this._tmpUp)}this._tmpV3.set(0,0,0);let c=VC(this._tmpV3,this._tmpV3)*s;this.modelLight.intensity=vT*c*this.sunIntensityScale,this.modelScene.environmentIntensity=yT*c,this.showPointingAxes?(this.pointingAxes||(this.pointingAxes=this.buildPointingAxes(),this.modelScene.add(this.pointingAxes)),this.pointingAxes.quaternion.copy(e.model.quaternion),this.pointingAxes.scale.setScalar(Math.min(.8,.45*i)),this.pointingAxes.visible=!0):this.pointingAxes&&(this.pointingAxes.visible=!1),this.renderer.autoClear=!1,this.renderer.clearDepth(),this.renderer.render(this.modelScene,this.modelCamera),this.renderer.autoClear=!0}pxPerRad(){return this.viewportH/2/Math.tan(this.camera.fov*Math.PI/360)}trailView(){let e=this._trailView,t=this.camera.position;return e.camX=t.x,e.camY=t.y,e.camZ=t.z,e.tolAngle=RR/this.pxPerRad(),e}cloudViewInfo(){let e=this.camera.position;return{camPos:[e.x,e.y,e.z],pxPerRad:this.pxPerRad()}}getCameraState(){let e=this.camera.position;return aC([e.x,e.y,e.z],[0,0,0],this.focusController.focusedBodyQuat())}setDragEnabled(e){this.controls.enableRotate=e,this.controls.enablePan=e}setZoomEnabled(e){this.controls.enableZoom=e}setBodySelectEnabled(e){this.bodySelectEnabled=e}setFeatureSelectEnabled(e){this.featureSelectEnabled=e}readerMayFocus=e=>this.bodySelectEnabled&&(this.focusableBodies?.has(e.data.id)??!0);setCooperativeTouch(e){this.controls.touches.ONE=e?AR:Tn.ROTATE,this.canvas.style.touchAction=e?`pan-x pan-y`:`none`}setCameraLimits(e,t){this.cameraBand=e,this.focusableBodies=t?new Set(t):null}armLimits=()=>{this.limitsArmed=!0};disarmLimits(){this.limitsArmed=!1}applyReaderLimits(e){!this.limitsArmed||!this.cameraBand||this.holdingCamera||e-this.focus.focusStartTime<this.focus.focusDurationMs||QL(this.camera,this.cameraBand,this.focusController.focusedBodyQuat())}static INPUT_EVENTS=[`pointerdown`,`pointermove`,`pointerup`,`wheel`];invalidate=()=>{this.wakeUntilFrame=this.frameIndex+e.WAKE_FRAMES};focusKey(){let e=this.ctx.visibility;return`${this.focusController.current?.data.id??``}|${e.focusedSystemId??``}|${e.activeSystemId??``}`}cameraOffsetFromFocus(){let e=this.focusController.current,t=this.focus.focusTruePos,n=this.camera.position;return e?[n.x+t[0]-e.position[0],n.y+t[1]-e.position[1],n.z+t[2]-e.position[2]]:[n.x,n.y,n.z]}holdCamera(){this.holdingCamera||(this.disarmLimits(),this.holdingCamera=!0,this.controls.enabled=!1,this.focus.camOriginWorld=null,this.focus.camTargetWorld=null,this.focus.camTargetOffset=null,this.focus.camOriginOffset=null,this.focus.flyQ0=null,this.focus.orbitFly=!1,this.focus.arcOrbit=!1,this.focus.cameraStaysOnBody=!1)}setHeldPose(e){this.cameraHold=e}releaseCamera(){this.holdingCamera&&(this.holdingCamera=!1,this.cameraHold=null,this.controls.enabled=!0,this.controls.target.set(0,0,0),this.controls.enableDamping=!1,this.controls.update(),this.controls.enableDamping=!0,this.invalidate())}applyHeldCamera(){let e=this.cameraHold,t=e&&vR(e,this.ctx,this.clock.jd);if(!t)return!0;let n=this.focus.focusTruePos;return this.camera.up.set(t.up[0],t.up[1],t.up[2]).normalize(),this.camera.position.set(t.position[0]-n[0],t.position[1]-n[1],t.position[2]-n[2]),this.camera.lookAt(t.target[0]-n[0],t.target[1]-n[1],t.target[2]-n[2]),!0}shouldRender(t){if(this.holdingCamera||t-this.focus.focusStartTime<this.focus.focusDurationMs||this.focusKey()!==this.lastRenderedFocusKey||this.ctx.bodies.minorStreaming||this.pointClouds.hasPendingSceneAdds()||this.systemData.hasPendingUnloads())return!0;if(this.covered)return!1;if(this.frameIndex-this.lastRenderedFrame>=e.IDLE_HEARTBEAT_FRAMES)return!0;let n=this.camera;return n.position.distanceToSquared(this.lastRenderedCamPos)>n.position.lengthSq()*1e-10||8*(1-Math.abs(n.quaternion.dot(this.lastRenderedCamQuat)))>1e-8||this.frameIndex<this.wakeUntilFrame||this.haloDebug.active?!0:this.clock.jd===this.lastRenderedJd?!1:Math.abs(this.clock.timeScale)>1||t-this.lastRenderMs>=e.REALTIME_FRAME_MS}onControlsEnd=()=>{this.pendingUrlWrite=!0,this.focusController.clearPendingInitialView()};nudgeCamera(e,t,n){this.armLimits();let{rotate:r,translate:i}=this.motionScale;e!==0&&this.controls.rotateLeft(e*r),t!==0&&this.controls.rotateUp(t*r),n!==1&&this.controls.dollyIn(1/n**+i),this.onControlsEnd()}maybeLoadTexture(e){let t=this.bodyObjects.get(e.data.id);t&&(iM(t,this.textureLoader,this.clock.jd,this.scene,this.renderer.capabilities.maxTextureSize,this.ctx).then(()=>{this.focusController.current?.data.id===e.data.id&&e.orientation&&t.mesh&&(hC(t.mesh,e.orientation,this.clock.jd,e.nutPrec),this.focusController.reapplyInitialViewIfPending())}),oO(t,this.modelScene,this.ctx).then(()=>{if(this.focusController.current?.data.id===t.body.data.id&&(this.controls.minDistance=XL(t.body,AO(t))),!this.ctx.layers.skipped.has(`nomenclature`))return kM(t,this.canvas,(e,n,r,i)=>{this.featureSelectEnabled&&this.callbacks.onFeatureSelect?.(t.body.data.id,e,n,r,i)})}).then(()=>{this.selectedFeatureId!==null&&NM(t,this.selectedFeatureId)}))}reapplyBodyLayers(){let e=this.focusController.current;if(!e)return;let t=this.bodyObjects.get(e.data.id);t&&(lO(t),oM(t),this.maybeLoadTexture(e))}setSelectedFeature(e){this.selectedFeatureId=e;let t=xM(this.focusController.current,this.bodyObjects),n=t?this.bodyObjects.get(t):void 0;n&&NM(n,e)}syncLandedNomenclature(){let e=this.focusController.current,t=(e?this.bodyObjects.get(e.data.id):void 0)?.isLanded?e.data.parentId:null;if(t===this.landedNomBodyId||(this.landedNomBodyId=t,!t))return;let n=this.ctx.getBody(t);n&&this.maybeLoadTexture(n)}clearUserPromoted(){this.focusController.promotion.clearUserPromoted()}focusedSeatConfigKey(){let e=this.focusController.current;if(!e||e.data.objectType!==W.SPACECRAFT&&!un(e))return null;let t=F_(e.data.parentId),n=t?this.bodyObjects.get(t):void 0;if(!n)return null;let r=n.terrainWindow;return`${r?`w${r.stepLevel}x${r.texWidth}@${r.centerTheta.toFixed(6)},${r.centerPhi.toFixed(6)}`:`u${n.currentSegments??128}`}|${n.displacementMap?.uuid??`none`}|${vw()}`}lastProbeTargetCheck=null;requestedProbeTargets=new Set;askedProbeRides=new Set;ensureFocusedProbeTarget(){let e=this.focusController.current,t=this.ctx.probeStore;if(!e||!t?.fitCenterUsable||e.data.orbitalSource!==U.SPICE_PROBE)return;this.askedProbeRides.has(e.data.id)||(this.askedProbeRides.add(e.data.id),gx(e.data.id).then(e=>e&&t.registerCarried(e)));let n=`${e.data.id}@${this.clock.jd}`;if(n===this.lastProbeTargetCheck)return;this.lastProbeTargetCheck=n;let r=t.stampedFitCenterAt(e.data.id,this.clock.jd);if(!r)return;let i=this.ctx.getBody(r);if(!i){if(this.requestedProbeTargets.has(r))return;this.requestedProbeTargets.add(r),this.ctx.ensureBody(r,Pg(this.clock.jd));return}this.focusController.promotion.ensureBodyObjects(i),this.focusController.syncUpgradeTargets(e)}applyJdUpdate(e=!1){this.ensureFocusedProbeTarget();let t=this.ctx.visibility.focusedSystemId,n=this.focusedSeatConfigKey(),r=this.ctx.probeStore?.version??0,i=this.ctx.bodies.hostReadVersion;if(this.clock.jd===this.lastUpdatedJd&&t===this.lastUpdatedSystemId&&n===this.lastSeatConfigKey&&r===this.lastProbeVersion&&i===this.lastHostReadVersion){this.clock.seeked=!1;return}let a=this.clock.seeked;this.clock.seeked=!1,this.lastUpdatedJd=this.clock.jd,this.lastUpdatedSystemId=t,this.lastSeatConfigKey=n,this.lastProbeVersion=r,this.lastHostReadVersion=i,this.ctx.refreshTick(Pg(this.clock.jd)),this.focusController.promotion.onSimTimeChanged();let o=EI({jd:this.clock.jd,ctx:this.ctx,bodyObjects:this.bodyObjects,focus:this.focus,focusedBody:this.focusController.current,positionMap:this._positionMapScratch,diagnostics:this.positionDiagnostics,trailView:this.trailView(),frame:this.frameIndex,outOfRange:this.outOfRange});this.pointClouds.updateForJd(this.clock.jd,this.cloudViewInfo()),this.refreshTravelFocus(),performance.now()-this.focus.focusStartTime>=this.focus.focusDurationMs&&(this.repositionBodies(),this.pointClouds.maybeRebase()),this.syncLandedNomenclature();let s=o.focusedOutOfRange&&!this.focusWasOutOfRange;if(this.focusWasOutOfRange=o.focusedOutOfRange,e&&a&&s&&o.reanchorId){let e=this.ctx.getBody(o.reanchorId);e&&this.focusController.panCameraToBody(e)}}setReducedMotion(e){this.controls.dampingFactor=xR(e)}focusOnBody(e,t,n,r){return this.disarmLimits(),this.applyJdUpdate(),this.focusWasOutOfRange=!1,this.focusController.focusOnBody(e,t,n,r)}focusOnFeature(e,t,n,r=`frame`,i){this.disarmLimits(),this.applyJdUpdate(),this.focusWasOutOfRange=!1;let a=this.ctx.getBody(e.hostId);if(!a)return 0;this.focusController.clearPendingInitialView();let o=xM(this.focusController.current,this.bodyObjects)===e.hostId,s=Pw(e,t);this.ctx.bodies.focusFeature=s;let c=this.bodyObjects.get(a.data.id);this.selectedFeatureId=e.featureId,c&&NM(c,e.featureId),Vw(s,a,c,this.clock.jd);let l=s.position,u=this.focusController.focusedBodyQuat(s);if(r===`pan`){let e=aC(this.focusController.cameraTruePos(),l,u);return this.callbacks.onCameraPosition?.(e.latitude,e.longitude,e.distance),this.focusController.setFocusTarget(s),this.focus.focusDurationMs}let d=l[0]-a.position[0],f=l[1]-a.position[1],p=l[2]-a.position[2],m=Math.hypot(d,f,p);m>1e-9?(d/=m,f/=m,p/=m):(d=0,f=1,p=0);let h=r===`snap`&&i?oC(l,i.latitude,i.longitude,i.zoom,u):[l[0]+d*n,l[1]+f*n,l[2]+p*n],g=aC(h,l,u);if(this.callbacks.onCameraPosition?.(g.latitude,g.longitude,g.distance),r===`snap`){this.focusController.setFocusTarget(s,h);let e=this.focus;return e.focusTruePos=[...l],e.focusOriginWorld=[...l],e.focusTargetWorld=[...l],e.focusStartTime=-NL,e.camOriginWorld=null,e.camTargetWorld=null,e.camTargetOffset=null,e.camOriginOffset=null,e.flyQ0=null,e.orbitFly=!1,e.arcOrbit=!1,e.cameraStaysOnBody=!1,this.repositionAll(),this.pointClouds.rebuildBasis(),this.camera.position.set(h[0]-l[0],h[1]-l[1],h[2]-l[2]),this.controls.update(),0}if(o){let e=this.focusController.cameraTruePos();this.focusController.setFocusTarget(s),this.focus.focusTruePos=[...l],this.camera.position.set(e[0]-l[0],e[1]-l[1],e[2]-l[2]),this.repositionAll(),this.pointClouds.rebuildBasis(),WL(this.focus,this.camera,e,h,Mx().resolvedReducedMotion)}else this.focusController.setFocusTarget(s,h),this.focus.orbitFly=!0;return this.focus.focusDurationMs}pickFocusedModel(e,t){if(!this.overlayActive||!this.overlayModelBo()?.model)return null;this._pickNdc.set(e,t),this._modelRaycaster.setFromCamera(this._pickNdc,this.modelCamera);let n=null,r=1/0;for(let e of this.bodyObjects.values()){if(!e.model)continue;let t=this._modelRaycaster.intersectObject(e.model,!0);t.length>0&&t[0].distance<r&&(r=t[0].distance,n=e.body)}return n}overlayModelBo(){let e=this.focusController.current;if(!e){let e=this.travelFocus?.centerId,t=e?this.bodyObjects.get(e):void 0;return t?.model?t:null}let t=un(e)?e.featureAnchor.hostId:e.data.id,n=this.bodyObjects.get(t);if(n?.model)return n;if(e.data.orbitalSource===U.SPICE_PROBE&&!n?.isLanded){let t=this.bodyObjects.get(e.data.parentId);if(t?.model)return t}return null}snapToBodyFacing(e,t,n,r){this.disarmLimits(),this.focusController.snapToBodyFacing(e,t,n,r)}snapToBody(e,t,n,r){this.disarmLimits(),this.focusController.snapToBody(e,t,n,r)}setFocusTarget(e,t){this.disarmLimits(),this.applyJdUpdate(),this.focusWasOutOfRange=!1,this.focusController.setFocusTarget(e,t)}getFocusedBody(){return this.focusController.current}getDebugStats(){let t=this.fpsSamples,n=0;if(t.length>=2){let r=t.length<e.FPS_SAMPLE_FRAMES?0:this.fpsSampleHead,i=t[r],a=(t[(r-1+t.length)%t.length]-i)/1e3;a>0&&(n=(t.length-1)/a)}return iP({fps:n,orbitPool:this.pointClouds.orbitPool,renderer:this.renderer,bodyObjects:this.bodyObjects,focusedBody:this.focusController.current,cameraDistanceScene:this.getCameraState().distance})}setBodyAppearance(e,t){this.appearances.set(e,t)}setNorthReference(e){this.cameraUp.setNorthReference(e)}getFocusedPointing(){let e=this.focusController.current;if(!e)return null;let t=e.pointing??{primary:{axis:`-y`,target:`parent`}};return{supported:XD(e),base:t}}setFocusedPointing(e){let t=this.focusController.current;t&&(t.pointingOverride=e??void 0)}setPointingAxesVisible(e){this.showPointingAxes=e}buildPointingAxes(){let e=new za,t=new J(0,0,0),n=(n,r,i,a)=>{let o=new Gd(n,t,1,r,.22,.12);o.line.material.depthTest=!1,o.cone.material.depthTest=!1,o.renderOrder=999,e.add(o);let s=this.makeAxisLabel(i,a);s.position.copy(n).multiplyScalar(1.12),e.add(s)};return n(new J(1,0,0),16729156,`+X`,`#ff9999`),n(new J(-1,0,0),8930372,`-X`,`#cc7777`),n(new J(0,1,0),4521796,`+Y`,`#99ff99`),n(new J(0,-1,0),4491332,`-Y`,`#77cc77`),n(new J(0,0,1),4491519,`+Z`,`#99bbff`),n(new J(0,0,-1),4478344,`-Z`,`#7799cc`),e}makeAxisLabel(e,t){let n=document.createElement(`canvas`);n.width=n.height=128;let r=n.getContext(`2d`);r.font=`bold 72px sans-serif`,r.textAlign=`center`,r.textBaseline=`middle`,r.fillStyle=t,r.fillText(e,128/2,128/2);let i=new cs(new Jo({map:new Nc(n),depthTest:!1,transparent:!0}));return i.scale.setScalar(.175),i.renderOrder=1e3,i}sunIntensityScale=1;getSunIntensityScale(){return this.sunIntensityScale}setSunIntensityScale(e){this.sunIntensityScale=e}getFocusedAtmosphere(){let e=this.focusController.current?.data.id;if(!e)return null;let t=this.bodyObjects.get(e)?.atmosphere,n=_b(e);return!t||!n?null:{id:e,current:t.params,shipped:n}}setFocusedAtmosphereParams(e){let t=this.focusController.current?.data.id,n=t?this.bodyObjects.get(t)?.atmosphere:void 0;n&&jA(n,e)}getSkyboxAdjust(){return this.skyboxAdjuster.get()}setSkyboxAdjust(e,t,n){this.skyboxAdjuster.set(e,t,n)}setSkyDebugMarkersVisible(e){this.skyDebugMarkers.setVisible(e)}applyLayerChrome(){this.ctx.layers.isVisible(`stars`)?this.stashedSky&&=(this.scene.background=this.stashedSky,null):this.scene.background&&(this.stashedSky=this.scene.background,this.scene.background=null);let e=this.ctx.layers.isVisible(`labels`);e!==this.namesShown&&(this.namesShown=e,this.labelContainer.classList.toggle(`scene-overlay--no-names`,!e))}setHaloDebugVisible(e){this.haloDebug.setVisible(e)}setUserLocation(e,t){let n=this.bodyObjects.get(p_);n?.mesh&&(this.userLocationMarker&&DR(this.userLocationMarker),this.userLocationMarker=ER(n.mesh,n.radiusScene,e,t))}clearUserLocation(){this.userLocationMarker&&=(DR(this.userLocationMarker),null)}pause(){this.paused||(this.paused=!0,cancelAnimationFrame(this.rafId),this.rafId=0)}resume(){this.paused&&(this.paused=!1,this.invalidate(),this.tick())}setCovered(e){this.covered!==e&&(this.covered=e,e||this.invalidate())}isContextLost(){return this.renderer.getContext().isContextLost()}handleContextRestored(){this.renderer.setPixelRatio(Xx()),this.composer.setPixelRatio(Xx()),this.resize(this.canvas.clientWidth,this.canvas.clientHeight),pS(this.scene,this.renderer,this.ctx,()=>this.disposed),this.resume()}recoverWorkersIfDead(e){return this.pointClouds.recoverWorkersIfDead(e)}applyRenderTier(){this.tier=Yx();let e=Xx();e!==this.renderer.getPixelRatio()&&(this.renderer.setPixelRatio(e),this.composer.setPixelRatio(e),this.resize(this.canvas.clientWidth,this.canvas.clientHeight)),this.pointClouds.setPointBudget(this.tier.pointBudget)}resize(e,t){this.invalidate(),this.viewportH=t||1,this.renderer.setSize(e,t,!1),this.composer.setSize(e,t);let n=this.renderer.getDrawingBufferSize(new q);this.atmoDepthPass.setSize(n.x,n.y),this.bloomPass.setSize(e*this.tier.bloomScale,t*this.tier.bloomScale),this.labelRenderer.setSize(e,t),this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.ctx.visibility.updateViewport(t),fT(e,t)}dispose(){this.disposed=!0,cancelAnimationFrame(this.rafId),this.pointerInteraction.detach(),this.gpuPick.dispose(),this.controls.removeEventListener(`end`,this.onControlsEnd),this.controls.removeEventListener(`start`,this.invalidate),this.controls.removeEventListener(`start`,this.armLimits),this.controls.removeEventListener(`end`,this.invalidate);for(let t of e.INPUT_EVENTS)this.canvas.removeEventListener(t,this.invalidate);window.removeEventListener(`keydown`,this.invalidate),this.unsubscribeBodiesAdded?.(),this.controls.dispose(),this.haloDebug.dispose(),this.travelPath.dispose(),this.extensions.dispose();for(let e of this.bodyObjects.values())e.model&&lO(e);this.pointClouds.dispose(),this.disposeScene(this.scene),this.disposeScene(this.modelScene),GR(this.scene.background),GR(this.scene.environment),GR(this.modelScene.environment),this.circleTexture.dispose(),this.bodyObjects.clear(),this.composer.dispose(),this.atmoDepthPass.dispose(),this.renderer.dispose()}disposeScene(e){let t=new Set;e.traverse(e=>{let n=e;n.geometry?.dispose();let r=n.material,i=Array.isArray(r)?r:r?[r]:[];for(let e of i)if(!t.has(e)){t.add(e);for(let t of Object.values(e))GR(t);e.dispose()}})}};function GR(e){e&&typeof e==`object`&&e.isTexture&&e.dispose()}var KR=$e({progress:null,bootPending:!1}),qR=6371;function JR(e){let t=[];for(let n=0;n<128;n++){let r=Math.PI*(n/127)**2,i=Math.cos(r);t.push(1/(4*Math.PI)*(1-e*e)/(1+e*e-2*e*i)**1.5)}return[...t,...t,...t]}var YR={topAltitudeKm:67,rayleighScatterPerKm:[.0058,.0136,.0331],rayleighScaleHeightKm:8.4,mieScatterPerKm:[.004,.004,.004],mieAbsorptionPerKm:[4e-4,4e-4,4e-4],mieScaleHeightKm:1.2,miePhase:JR(.75),absorptionPerKm:[65e-5,.001881,85e-6],absorptionCenterKm:25,absorptionWidthKm:15,bakedCompensation:1,multiScatterGain:.3,sunIntensity:5,sunColor:[1,1,1]},XR=1.6,ZR=1.0005,QR=new J(.55,.25,.8).normalize(),$R=[`low`,`medium`,`high`,`ultra`],ez=4,tz=12,nz=10,rz=16,iz=5;function az(e){return!e.limb&&!e.sky?NaN:Math.max(e.limb?.medianMs??0,e.sky?.medianMs??0)}function oz(e,t){let n=`low`;for(let r of e.tiers){let e=az(r);!Number.isNaN(e)&&e<=t&&(n=r.tier)}return n}var sz=new Set([`WebKit WebGL`,`Mozilla`,``]);function cz(e){let t=e.getContext(),n=String(t.getParameter(t.RENDERER)??``);if(!sz.has(n))return n;let r=t.getExtension(`WEBGL_debug_renderer_info`);return r?String(t.getParameter(r.UNMASKED_RENDERER_WEBGL)):n}function lz(e,t){let n=e.getContext(),r=new qa,i=new sd(50,n.drawingBufferWidth/Math.max(n.drawingBufferHeight,1),.005,100),a=new mu({color:7829367,roughness:1,metalness:0}),o=new As(new ru(1,64,64),a);o.renderOrder=1,r.add(o);let s=new md(16777215,2);s.position.copy(QR),r.add(s);let c=YR,l=CA(c,1,qR),u=l.material.uniforms;u.uSunDir.value.copy(QR),u.uSunIntensity.value=c.sunIntensity,r.add(l.mesh);let d=e=>{let t=e===`sky`;t?(i.position.set(0,ZR,0),i.lookAt(1,ZR+.1,0)):(i.position.set(0,0,XR),i.lookAt(0,0,0)),l.material.side=+!!t,l.material.depthWrite=!t,l.material.depthTest=!t},f=new Uint8Array(4),p=()=>new Promise((e,n)=>requestAnimationFrame(()=>t?.aborted?n(Error(`benchmark aborted`)):e())),m=t=>{let a=performance.now();for(let n=0;n<t;n++)e.render(r,i);return n.readPixels(0,0,1,1,n.RGBA,n.UNSIGNED_BYTE,f),(performance.now()-a)/t};return{measure:async(e,t,{decideMs:n,onFrame:r}={})=>{AA(l,zk[e]),d(t);let i=0;for(let e=0;e<ez;e++)r?.(`warmup`,e+1),await p(),i=m(1);let a=Math.min(rz,Math.max(1,Math.ceil(nz/Math.max(i,.25)))),o=[],s=()=>{let e=[...o].sort((e,t)=>e-t);return{medianMs:e[Math.floor(e.length/2)],p75Ms:e[Math.floor(e.length*.75)]}};for(let e=0;e<tz;e++)if(r?.(`measure`,e+1),await p(),o.push(m(a)),n!==void 0&&o.length>=iz){let{medianMs:e,p75Ms:t}=s();if(e>n*1.4||t<n*.7)break}return{...s(),repeats:a}},dispose:()=>{r.remove(o,s,l.mesh),o.geometry.dispose(),a.dispose(),s.dispose(),PA(l)}}}function uz(e,t,n,r){let i=e.getContext();return{tiers:t.map(e=>{let t=n.get(e)??null,i=r.get(e)??null;return{tier:e,limb:t,sky:i,skipped:!t&&!i}}),drawWidth:i.drawingBufferWidth,drawHeight:i.drawingBufferHeight}}async function dz(e,t){let n=t.tiers??$R,{budgetMs:r,signal:i,onProgress:a}=t,o=Math.max(0,n.indexOf(t.startTier??n[n.length-1])),s=lz(e,i),c=ez+tz,l=0,u=0,d=(e,t,i)=>s.measure(n[e],t,{decideMs:r,onFrame:(r,o)=>{if(!a)return;l++;let s=c-((r===`measure`?ez:0)+o)+i*c;u=Math.max(u,l/(l+s)),a({tier:n[e],tierIndex:e,tierCount:n.length,scenario:t,phase:r,frame:o,frames:r===`measure`?tz:ez,fraction:u})}}),f=new Map,p=new Map,m=async e=>{let t=n[e];if(zk[t].insideView){let n=await d(e,`sky`,1);if(p.set(t,n),n.medianMs>r)return!1}let i=await d(e,`limb`,0);return f.set(t,i),i.medianMs<=r};try{if(await m(o))for(let e=o+1;e<n.length&&await m(e);e++);else for(let e=o-1;e>=1&&!await m(e);e--);}finally{s.dispose()}return uz(e,n,f,p)}var fz=60,pz=100,mz=3e4,hz=25e4,gz=`v1`,_z=!1,vz=null,yz=Promise.resolve();function bz(e){let t=e.getContext(),n=Math.round(t.drawingBufferWidth*t.drawingBufferHeight/hz);return`${cz(e)}|${n}|${gz}`}function xz(){_z||typeof window>`u`||(_z=!0,KR.bootPending=!0,yz=new Promise(e=>{let t=()=>{KR.bootPending=!1,e()};setTimeout(t,mz),setTimeout(()=>void Cz(!1).finally(t),pz)}))}function Sz(){return yz}function Cz(e){return vz??=wz(e).finally(()=>vz=null),vz}async function wz(e){let t=Mx();if(!e&&(t.atmosphereQuality!==`auto`||!t.showAtmospheres))return;let n=null;try{n=new dh({canvas:document.createElement(`canvas`),antialias:!0}),n.setPixelRatio(Gx()),n.setSize(window.innerWidth,window.innerHeight,!1);let r=bz(n);if(!e&&t.atmosphereCalibration?.key===r)return;KR.progress=0;let i=await dz(n,{budgetMs:1e3/fz,startTier:Bk(),onProgress:e=>KR.progress=e.fraction}),a={};for(let e of i.tiers){let t=az(e);Number.isNaN(t)||(a[e.tier]=Math.round(t*100)/100)}let o=oz(i,1e3/fz);t.setAtmosphereCalibration({key:r,tier:o,worstMs:a}),t.setAtmosphereAutoTier(null),console.info(`atmosphere calibration: ${o}`,a)}catch(e){console.warn(`atmosphere calibration failed, keeping heuristic tier`,e)}finally{KR.progress=null,n?.dispose(),n?.forceContextLoss()}}var Tz=class{object=new za;element;label;anchor;occlude;wanted=!0;removeSelf=null;constructor(e,t){this.anchor=e.anchor,this.occlude=e.occlude??!1,this.element=e.element,this.label=new $O(e.element);let[n,r]=e.align??[.5,.5];this.label.center.set(n,r),this.object.add(this.label),this.object.matrixAutoUpdate=!1,Lk(e.element,t)}bind(e){this.removeSelf=e}setAnchor(e){this.anchor=e}setVisible(e){this.wanted=e}remove(){this.removeSelf?.(),this.removeSelf=null}update(e){let{jd:t,basis:n,ctx:r}=e,i=this.wanted?hR(this.anchor,r,t):null;if(!i){this.label.visible=!1;return}let a=i[0]-n[0],o=i[1]-n[1],s=i[2]-n[2];this.label.position.set(a,o,s),this.label.visible=this.occlude?this.facesCamera(i,e):!0,this.object.updateMatrixWorld(!0)}facesCamera(e,{camera:t,ctx:n,jd:r}){let i=gR(this.anchor,e,n,r);if(!i)return!0;let{position:a}=this.label,o=t.position.x-a.x,s=t.position.y-a.y,c=t.position.z-a.z;return i[0]*o+i[1]*s+i[2]*c>0}dispose(){this.label.removeFromParent(),this.element.remove()}},Ez=1e-9,Dz=class{object=new za;anchor;color;widthPx;opacity;fade;closed;local;count=0;mesh=null;scratch=new Float32Array;alphas=new Float32Array;capacity=0;lastOrigin=[0,0,0];dirty=!0;wanted=!0;removeSelf=null;constructor(e){this.anchor=e.anchor,this.color=e.color??`#ffffff`,this.widthPx=e.widthPx??2,this.opacity=e.opacity??1,this.fade=e.fade??!1,this.closed=e.closed??!1,this.local=new Float64Array,this.object.matrixAutoUpdate=!1,this.setPoints(e.points)}bind(e){this.removeSelf=e}setPoints(e){let t=e.length+(this.closed&&e.length>2?1:0);this.local.length<t*3&&(this.local=new Float64Array(t*3));for(let t=0;t<e.length;t++){let[n,r,i]=e[t];this.local[t*3]=Q(n),this.local[t*3+1]=Q(i),this.local[t*3+2]=Q(-r)}t>e.length&&this.local.copyWithin(e.length*3,0,3),this.count=t,t>this.capacity&&this.rebuild(t),this.fillAlphas(),this.dirty=!0}fillAlphas(){let e=this.count;for(let t=0;t<e;t++)this.alphas[t]=this.fade&&e>1?this.opacity*(1-t/(e-1)):this.opacity}setAnchor(e){this.anchor=e}setVisible(e){this.wanted=e}remove(){this.removeSelf?.(),this.removeSelf=null}update({jd:e,basis:t,camera:n,ctx:r}){let i=this.mesh;if(!i)return;let a=this.wanted&&this.count>=2?hR(this.anchor,r,e):null;if(i.visible=a!==null,!a)return;let o=[a[0]-t[0],a[1]-t[1],a[2]-t[2]];(this.dirty||Math.abs(o[0]-this.lastOrigin[0])>Ez||Math.abs(o[1]-this.lastOrigin[1])>Ez||Math.abs(o[2]-this.lastOrigin[2])>Ez)&&(this.writeVertices(i,o),this.lastOrigin=o,this.dirty=!1),i.material.uniforms.uCenterOffset.value.copy(n.position).negate()}writeVertices(e,t){for(let e=0;e<this.count;e++)this.scratch[e*3]=this.local[e*3]+t[0],this.scratch[e*3+1]=this.local[e*3+1]+t[1],this.scratch[e*3+2]=this.local[e*3+2]+t[2];lN(e.geometry,this.scratch,this.alphas,this.alphas,this.count)}rebuild(e){this.disposeMesh(),this.dirty=!0,this.scratch=new Float32Array(e*3),this.alphas=new Float32Array(e);let t=fN(e,this.scratch,this.alphas,this.alphas,e,this.color,this.widthPx,1);t.frustumCulled=!1,this.object.add(t),this.mesh=t,this.capacity=e}disposeMesh(){let e=this.mesh;e&&(this.object.remove(e),e.geometry.dispose(),e.material.dispose(),this.mesh=null)}dispose(){this.disposeMesh()}};function Oz(e){let t=Math.hypot(e[0],e[1],e[2]),n=t>0?[e[0]/t,e[1]/t,e[2]/t]:[0,0,1],r=kz(Math.abs(n[2])<.9?[0,0,1]:[1,0,0],n),i=Math.hypot(r[0],r[1],r[2]),a=[r[0]/i,r[1]/i,r[2]/i];return[a,kz(n,a)]}function kz(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function Az(e,t={}){let[n,r]=Oz(t.normal??[0,0,1]),i=Math.max(3,Math.round(t.steps??128)),a=[];for(let t=0;t<i;t++){let o=2*Math.PI*t/i,s=Math.cos(o)*e,c=Math.sin(o)*e;a.push([n[0]*s+r[0]*c,n[1]*s+r[1]*c,n[2]*s+r[2]*c])}return a}function jz(e){if(e.length<3)return[];let[t,n]=Oz(Mz(e)),r=e.map(e=>new q(e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[0]*n[0]+e[1]*n[1]+e[2]*n[2]));return Xl.triangulateShape(r,[]).flat()}function Mz(e){let t=0,n=0,r=0;for(let i=0;i<e.length;i++){let a=e[i],o=e[(i+1)%e.length];t+=(a[1]-o[1])*(a[2]+o[2]),n+=(a[2]-o[2])*(a[0]+o[0]),r+=(a[0]-o[0])*(a[1]+o[1])}return Math.hypot(t,n,r)>0?[t,n,r]:[0,0,1]}function Nz(e,t,n){let r=Math.min(1,Math.max(-1,e[0]*t[0]+e[1]*t[1]+e[2]*t[2])),i=Math.acos(r);if(i<1e-9||Math.PI-i<1e-9)return Pz([e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]);let a=Math.sin(i),o=Math.sin((1-n)*i)/a,s=Math.sin(n*i)/a;return[e[0]*o+t[0]*s,e[1]*o+t[1]*s,e[2]*o+t[2]*s]}function Pz(e){let t=Math.hypot(e[0],e[1],e[2]);return t>0?[e[0]/t,e[1]/t,e[2]/t]:[0,0,1]}function Fz(e,t){let n=0,r=0,i=0;for(let a=0;a<t;a++)n+=e[a*3],r+=e[a*3+1],i+=e[a*3+2];return Math.hypot(n,r,i)<1e-9?[e[0],e[1],e[2]]:Pz([n,r,i])}function Iz(e,t){return new fu({transparent:!0,depthWrite:!1,side:2,uniforms:{uColor:{value:new X(e)},uOpacity:{value:t},uCenterOffset:{value:new J}},vertexShader:`
|
|
5520
5520
|
#include <common>
|
|
5521
5521
|
#include <logdepthbuf_pars_vertex>
|
|
5522
5522
|
uniform vec3 uCenterOffset;
|
|
@@ -5533,6 +5533,6 @@ uniform float uOceanRoughness;`).replace(`#include <roughnessmap_fragment>`,`flo
|
|
|
5533
5533
|
gl_FragColor = vec4(uColor, uOpacity);
|
|
5534
5534
|
#include <logdepthbuf_fragment>
|
|
5535
5535
|
}
|
|
5536
|
-
`})}var Mz=.25,Nz=1e-9,Pz=3,Fz=class{object=new za;anchor;outline;fillColor;fillOpacity;local=new Float64Array;count=0;mesh=null;scratch=new Float32Array;lastOrigin=[0,0,0];dirty=!0;wanted=!0;removeSelf=null;constructor(e){this.anchor=e.anchor;let t=e.widthPx??2;this.fillColor=e.fill??null,this.fillOpacity=e.fillOpacity??Mz,this.outline=t>0?new Sz({anchor:e.anchor,points:e.points,color:e.color,widthPx:t,opacity:e.opacity,closed:!0}):null,this.outline&&this.object.add(this.outline.object),this.object.matrixAutoUpdate=!1,this.setPoints(e.points)}bind(e){this.removeSelf=e}setPoints(e){this.outline?.setPoints(e),this.local.length<e.length*3&&(this.local=new Float64Array(e.length*3));for(let t=0;t<e.length;t++){let[n,r,i]=e[t];this.local[t*3]=Q(n),this.local[t*3+1]=Q(i),this.local[t*3+2]=Q(-r)}this.count=e.length,this.rebuild(e)}setAnchor(e){this.anchor=e,this.outline?.setAnchor(e)}setVisible(e){this.wanted=e,this.outline?.setVisible(e)}remove(){this.removeSelf?.(),this.removeSelf=null}update(e){this.outline?.update(e);let t=this.mesh;if(!t)return;let{jd:n,basis:r,camera:i,ctx:a}=e,o=this.wanted?lR(this.anchor,a,n):null;if(t.visible=o!==null,!o)return;let s=[o[0]-r[0],o[1]-r[1],o[2]-r[2]];if(this.dirty||Math.abs(s[0]-this.lastOrigin[0])>Nz||Math.abs(s[1]-this.lastOrigin[1])>Nz||Math.abs(s[2]-this.lastOrigin[2])>Nz){let e=t.geometry.getAttribute(`position`);for(let e=0;e<this.count*3;e+=3)this.scratch[e]=this.local[e]+s[0],this.scratch[e+1]=this.local[e+1]+s[1],this.scratch[e+2]=this.local[e+2]+s[2];e.needsUpdate=!0,this.lastOrigin=s,this.dirty=!1}t.material.uniforms.uCenterOffset.value.copy(i.position).negate()}rebuild(e){this.disposeMesh(),this.dirty=!0;let t=this.fillColor;if(!t)return;let n=Ez(e);if(!n.length)return;let r=new Ho;r.setAttribute(`position`,new Ao(new Float32Array(e.length*3),3)),r.setIndex(n),this.scratch=r.getAttribute(`position`).array;let i=new As(r,jz(t,this.fillOpacity));i.matrixAutoUpdate=!1,i.renderOrder=Pz,i.frustumCulled=!1,this.object.add(i),this.mesh=i}disposeMesh(){let e=this.mesh;e&&(this.object.remove(e),e.geometry.dispose(),e.material.dispose(),this.mesh=null)}dispose(){this.disposeMesh(),this.outline?.dispose()}},Iz=class extends Fz{normal;steps;constructor(e){let{radiusKm:t,normal:n,steps:r,...i}=e;super({...i,points:Tz(t,{normal:n,steps:r})}),this.normal=n,this.steps=r}setRadiusKm(e){this.setPoints(Tz(e,{normal:this.normal,steps:this.steps}))}},Lz=class extends bz{constructor(e,t){let n=document.createElement(`div`);n.className=`sm-drawing-label`,e.interactive&&n.classList.add(`sm-drawing--interactive`),e.className&&n.classList.add(e.className),n.textContent=e.text,e.color&&(n.style.color=e.color),e.fontSizePx!==void 0&&(n.style.fontSize=`${e.fontSizePx}px`),super({anchor:e.anchor,element:n,align:e.align,occlude:e.occlude},t)}setText(e){this.element.textContent=e}},Rz=class extends bz{constructor(e,t){let n=document.createElement(`img`);n.className=`sm-drawing-icon`,e.interactive&&n.classList.add(`sm-drawing--interactive`),e.className&&n.classList.add(e.className),n.src=e.url,n.alt=e.alt??``,e.widthPx!==void 0&&(n.style.width=`${e.widthPx}px`),e.heightPx!==void 0&&(n.style.height=`${e.heightPx}px`),e.opacity!==void 0&&(n.style.opacity=String(e.opacity)),super({anchor:e.anchor,element:n,align:e.align,occlude:e.occlude},t)}setUrl(e){this.element.src=e}},zz=Math.PI/180,Bz=180/Math.PI;function Vz(e){return e>=-180&&e<180?e:((e+180)%360+360)%360-180}function Hz(e,t){return(n,r)=>{let i=e(r);return!i||Math.abs(n)>i.maxAbsX+1e-9?null:[Vz(n*i.lonPerX+t),i.lat]}}function Uz(e){let{minX:t,maxX:n,minY:r,maxY:i}=e.extent;return(n-t)/(i-r)}function Wz(e){let t=1/0,n=1/0,r=-1/0,i=-1/0,a=179.999999999;for(let o=0;o<=720;o++){let s=-90+180*o/720;for(let o=0;o<=720;o++){let c=e(-a+2*a*o/720,s);c&&(c[0]<t&&(t=c[0]),c[0]>r&&(r=c[0]),c[1]<n&&(n=c[1]),c[1]>i&&(i=c[1]))}}return{minX:t,minY:n,maxX:r,maxY:i}}function Gz(e){let t=e.centerLon??0,n=e=>Math.abs(e)>Math.PI/2?null:{lat:e*Bz,lonPerX:Bz,maxAbsX:Math.PI};return{id:`equirectangular`,centerLon:t,cyclic:!0,rectangular:!0,azimuthal:!1,extent:{minX:-Math.PI,minY:-Math.PI/2,maxX:Math.PI,maxY:Math.PI/2},forward:(e,n)=>[Vz(e-t)*zz,n*zz],rowInverse:n,inverse:Hz(n,t)}}var Kz=1.340264,qz=-.081106,Jz=893e-6,Yz=.003796,Xz=Math.sqrt(3),Zz=e=>Yz*e**9+Jz*e**7+qz*e**3+Kz*e,Qz=e=>9*Yz*e**8+7*Jz*e**6+3*qz*e**2+Kz;function $z(e){let t=e.centerLon??0,n=(e,n)=>{let r=Math.asin(hB(Xz/2*Math.sin(n*zz))),i=Vz(e-t)*zz;return[2*Xz*i*Math.cos(r)/(3*Qz(r)),Zz(r)]},r=e=>{let t=e;for(let n=0;n<12;n++){let n=(Zz(t)-e)/Qz(t);if(t-=n,Math.abs(n)<1e-12)break}return t},i=e=>{let t=r(e),n=2/Xz*Math.sin(t);if(Math.abs(n)>1)return null;let i=3*Qz(t)/(2*Xz*Math.cos(t))*Bz;return{lat:Math.asin(n)*Bz,lonPerX:i,maxAbsX:180/i}};return{id:`equalEarth`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:Wz(n),forward:n,rowInverse:i,inverse:Hz(i,t)}}var eB=Math.SQRT2;function tB(e){let t=e.centerLon??0,n=e=>{let t=e/eB;if(Math.abs(t)>1)return null;let n=Math.asin(t),r=(2*n+Math.sin(2*n))/Math.PI;if(Math.abs(r)>1)return null;let i=Math.cos(n);if(i<1e-12)return{lat:Math.sign(e)*90,lonPerX:0,maxAbsX:0};let a=Math.PI/(2*eB*i)*Bz;return{lat:Math.asin(r)*Bz,lonPerX:a,maxAbsX:180/a}};return{id:`mollweide`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-2*eB,minY:-eB,maxX:2*eB,maxY:eB},forward:(e,n)=>{let r=n*zz,i=r;if(Math.abs(Math.abs(r)-Math.PI/2)<1e-9)i=Math.PI/2*Math.sign(r);else{let e=Math.PI*Math.sin(r);for(let t=0;t<20;t++){let t=(2*i+Math.sin(2*i)-e)/(2+2*Math.cos(2*i));if(i-=t,Math.abs(t)<1e-12)break}}let a=Vz(e-t)*zz;return[2*eB/Math.PI*a*Math.cos(i),eB*Math.sin(i)]},rowInverse:n,inverse:Hz(n,t)}}function nB(e){let t=e.centerLon??0,n=e=>{if(Math.abs(e)>Math.PI/2)return null;let t=Math.cos(e);return t<1e-12?{lat:Math.sign(e)*90,lonPerX:0,maxAbsX:0}:{lat:e*Bz,lonPerX:Bz/t,maxAbsX:Math.PI*t}};return{id:`sinusoidal`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-Math.PI,minY:-Math.PI/2,maxX:Math.PI,maxY:Math.PI/2},forward:(e,n)=>{let r=n*zz;return[Vz(e-t)*zz*Math.cos(r),r]},rowInverse:n,inverse:Hz(n,t)}}var rB=[1,.9986,.9954,.99,.9822,.973,.96,.9427,.9216,.8962,.8679,.835,.7986,.7597,.7186,.6732,.6213,.5722,.5322],iB=[0,.062,.124,.186,.248,.31,.372,.434,.4958,.5571,.6176,.6769,.7346,.7903,.8435,.8936,.9394,.9761,1],aB=.8487,oB=1.3523,sB=5;function cB(e,t){let n=e[Math.max(t-1,0)],r=e[t],i=e[t+1],a=e[Math.min(t+2,e.length-1)];return[r,.5*(i-n),.5*(2*n-5*r+4*i-a),.5*(-n+3*r-3*i+a)]}var lB=(e,t)=>e[0]+t*(e[1]+t*(e[2]+t*e[3])),uB=(e,t)=>e[1]+t*(2*e[2]+3*e[3]*t);function dB(e){let t=Math.min(Math.max(Math.floor(e),0),rB.length-2);return[t,e-t]}function fB(e){let[t,n]=dB(e);return aB*lB(cB(rB,t),n)*Math.PI}function pB(e){let t=0,n=iB.length-1;for(;n-t>1;){let r=t+n>>1;iB[r]<=e?t=r:n=r}let r=Math.min(t,iB.length-2),i=cB(iB,r),a=(e-iB[r])/(iB[r+1]-iB[r]);for(let t=0;t<8;t++){let t=uB(i,a);if(t===0)break;let n=(lB(i,a)-e)/t;if(a-=n,Math.abs(n)<1e-14)break}return r+Math.min(Math.max(a,0),1)}function mB(e){let t=e.centerLon??0,n=e=>{let t=Math.abs(e)/oB;if(t>1)return null;let n=pB(t),r=fB(n);return{lat:Math.sign(e)*n*sB,lonPerX:180/r,maxAbsX:r}};return{id:`robinson`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-aB*Math.PI,minY:-oB,maxX:aB*Math.PI,maxY:oB},forward:(e,n)=>{let[r,i]=dB(Math.abs(n)/sB),a=lB(cB(rB,r),i),o=lB(cB(iB,r),i);return[aB*a*Vz(e-t)*zz,oB*o*Math.sign(n)]},rowInverse:n,inverse:Hz(n,t)}}function hB(e){return e<-1?-1:e>1?1:e}function gB(e,t,n,r,i,a,o){let s=Math.asin(hB(n*a+t*r*o));return[Vz(i+Math.atan2(e*r,n*o-t*r*a)*Bz),s*Bz]}function _B(e){return{minX:-e,minY:-e,maxX:e,maxY:e}}function vB(e,t,n,r){let i=Vz(e-n)*zz,a=t*zz;return[Math.cos(a)*Math.sin(i),Math.cos(r)*Math.sin(a)-Math.sin(r)*Math.cos(a)*Math.cos(i)]}function yB(e){let t=e.centerLon??0,n=(e.centerLat??0)*zz,r=Math.min(e.clipAngle??90,90)*zz,i=Math.cos(r),a=Math.sin(r),o=Math.sin(n),s=Math.cos(n);return{id:`orthographic`,centerLon:t,cyclic:!1,rectangular:!1,azimuthal:!0,extent:_B(a),forward:(e,r)=>{let a=Vz(e-t)*zz,o=r*zz;return Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos(a)<i?null:vB(e,r,t,n)},inverse:(e,n)=>{let r=e*e+n*n;return r>a*a?null:gB(e,n,Math.sqrt(1-r),1,t,o,s)}}}var bB=120;function xB(e){let t=e.centerLon??0,n=(e.centerLat??90)*zz,r=Math.min(e.clipAngle??bB,170)*zz,i=Math.cos(r),a=2*Math.tan(r/2),o=Math.sin(n),s=Math.cos(n);return{id:`stereographic`,centerLon:t,cyclic:!1,rectangular:!1,azimuthal:!0,extent:_B(a),forward:(e,r)=>{let a=Vz(e-t)*zz,o=r*zz,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos(a);if(s<i)return null;let c=2/(1+s),[l,u]=vB(e,r,t,n);return[c*l,c*u]},inverse:(e,n)=>{let r=e*e+n*n;if(r>a*a)return null;let i=4/(4+r);return gB(e,n,(4-r)*i*.25,i,t,o,s)}}}var SB={equirectangular:Gz,equalEarth:$z,mollweide:tB,sinusoidal:nB,robinson:mB,orthographic:yB,stereographic:xB},CB=Object.keys(SB);function wB(e,t={}){let n=SB[e];if(!n)throw Error(`spacemap: unknown projection "${e}"`);return n(t)}var TB=Math.PI/180,EB=2*Math.PI,DB=2*TB,OB=180/Math.PI,kB=512,AB=2;function jB(e,t){let n=e.lat*TB,r=t.lat*TB,i=r-n,a=Vz(t.lon-e.lon)*TB,o=Math.sin(i/2)**2+Math.cos(n)*Math.cos(r)*Math.sin(a/2)**2;return 2*Math.asin(Math.min(1,Math.sqrt(o)))*OB}function MB(e,t,n){let r=jB(e,t)*TB;if(r<1e-12)return e;let i=Math.sin(r),a=Math.sin((1-n)*r)/i,o=Math.sin(n*r)/i,s=e.lat*TB,c=e.lon*TB,l=t.lat*TB,u=(e.lon+Vz(t.lon-e.lon))*TB,d=a*Math.cos(s)*Math.cos(c)+o*Math.cos(l)*Math.cos(u),f=a*Math.cos(s)*Math.sin(c)+o*Math.cos(l)*Math.sin(u),p=a*Math.sin(s)+o*Math.sin(l);return{lon:Math.atan2(f,d)*OB,lat:Math.atan2(p,Math.hypot(d,f))*OB}}function NB(e,t,n){return{lon:e.lon+Vz(t.lon-e.lon)*n,lat:e.lat+(t.lat-e.lat)*n}}function PB(e,t={}){let n=t.interpolate??`linear`,r=t.stepDeg??AB,i=n===`geodesic`?MB:NB,a=t.closed&&e.length>2?[...e,e[0]]:e;if(a.length<2)return[...a];let o=[a[0]];for(let e=1;e<a.length;e++){let t=a[e-1],n=a[e],s=Math.min(kB,Math.max(1,Math.ceil(jB(t,n)/r)));for(let e=1;e<=s;e++)o.push(e===s?n:i(t,n,e/s))}return o}function FB(e,t,n){let r=0,i=1;for(let a=0;a<20;a++){let a=(r+i)/2,o=NB(e,t,a);n.forward(o.lon,o.lat)?r=a:i=a}return NB(e,t,r)}function IB(e,t){let n=t.projection.cyclic?t.worldWidthPx/2:1/0,{projection:r}=t,i=[],a=[],o=null,s=0;for(let c=0;c<e.length;c++){let l=e[c],u=t.project(l.lon,l.lat);if(!u){if(a.length&&c>0){let n=FB(e[c-1],l,r);a.push(t.project(n.lon,n.lat))}a.length>1&&i.push(a),a=[],o=null,s++;continue}if(o&&Math.abs(u[0]-o[0])>n&&(a.length>1&&i.push(a),a=[]),!a.length&&c>0&&!t.project(e[c-1].lon,e[c-1].lat)){let n=FB(l,e[c-1],r);a.push(t.project(n.lon,n.lat))}a.push(u),o=u}return a.length>1&&i.push(a),{runs:i,whole:i.length===1&&s===0}}function LB(e,t){let n=[...e];for(let r of t.repeatShifts)if(r!==0)for(let i of e){let e=1/0,a=-1/0;for(let[t]of i)t<e&&(e=t),t>a&&(a=t);e+r>t.width||a+r<0||n.push(i.map(([e,t])=>[e+r,t]))}return n}function RB(e,t){let n=`M${e[0][0].toFixed(2)} ${e[0][1].toFixed(2)}`;for(let t=1;t<e.length;t++)n+=`L${e[t][0].toFixed(2)} ${e[t][1].toFixed(2)}`;return t?`${n}Z`:n}var zB=179.999999;function BB(e,t){let n=e=>e>zB?zB:e<-zB?-zB:e,r=e.length;if(r<3)return[e];let i=[],a=[],o=Vz(e[0].lon-t);a.push({lon:n(o),lat:e[0].lat});for(let t=0;t<r;t++){let s=e[t],c=e[(t+1)%r],l=Vz(c.lon-s.lon),u=o+l,d=u>180?1:u<-180?-1:0;if(d!==0){let e=s.lat+(c.lat-s.lat)*((d*180-o)/l);a.push({lon:d*zB,lat:e}),i.push(a),a=[{lon:-d*zB,lat:e}],o=u-d*360}else o=u;t<r-1&&a.push({lon:n(o),lat:c.lat})}return i.length===0?[a.map(e=>({lon:e.lon+t,lat:e.lat}))]:(i[0]=a.concat(i[0]),i.map(e=>e.map(e=>({lon:e.lon+t,lat:e.lat}))))}function VB(e,t,n={}){if(e.length<2)return``;let{projection:r}=t;return(n.closed&&r.cyclic?BB(e,r.centerLon):[e]).map(e=>{let{runs:r,whole:i}=IB(PB(e,n),t),a=!!n.closed&&i;return LB(r,t).map(e=>RB(e,a)).join(``)}).join(``)}function HB(e,t,n={}){let{projection:r}=t;if(!r.azimuthal)return VB(e,t,{...n,closed:!0});if(e.length<2)return``;let i=PB(e,{...n,closed:!0}),a=e.length>2?i.slice(0,-1):i,o=a.map(e=>r.forward(e.lon,e.lat)),s=([e,n])=>t.toScreen(e,n),c=o.filter(Boolean).length;if(c===0)return``;if(c===a.length)return RB(o.map(e=>s(e)),!0);let l=a.length,u=0;for(;!o[u]||o[(u+l-1)%l];)u++;let d=[],f=null;for(let e=0;e<l;e++){let t=(u+e)%l,n=(t+l-1)%l,i=o[t];if(i){if(!f){let e=FB(a[t],a[n],r);f=[r.forward(e.lon,e.lat)]}f.push(i)}else if(f){let e=FB(a[n],a[t],r);f.push(r.forward(e.lon,e.lat)),d.push(f),f=null}}let p=UB(a),m=([e,t])=>Math.atan2(t,e),h=Math.hypot(...d[0][0]),g=[],_=new Set;for(let e=0;e<d.length;e++){if(_.has(e))continue;let t=[],n=e;do{_.add(n),t.push(...d[n]);let r=m(d[n][d[n].length-1]),i=e,a=1/0;for(let e=0;e<d.length;e++){let t=m(d[e][0]),n=((p?t-r:r-t)%EB+EB)%EB;n<a&&(a=n,i=e)}let o=Math.ceil(a/DB);for(let e=1;e<o;e++){let n=r+(p?1:-1)*a*e/o;t.push([h*Math.cos(n),h*Math.sin(n)])}n=i}while(n!==e&&!_.has(n));g.push(t)}return g.map(e=>RB(e.map(s),!0)).join(``)}function UB(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n],i=e[(n+1)%e.length];t+=Vz(i.lon-r.lon)*TB*(2+Math.sin(r.lat*TB)+Math.sin(i.lat*TB))}let n=-t/2;return n>0?n<EB:n<-EB}function WB(e,t=2){let{projection:n}=e,r=179.999999,i=[],a=(r,a,o)=>{let s=a<o?t:-t;for(let t=a;s>0?t<=o:t>=o;t+=s){let a=n.forward(r,t);a&&i.push(e.toScreen(a[0],a[1]))}};return a(n.centerLon-r,-90,90),a(n.centerLon+r,90,-90),i.length<3?``:LB([i],e).map(e=>RB(e,!0)).join(``)}function GB(e,t,n,r){let i=n+r,a=[],o=(e,t,n)=>{let r=Math.max(1,Math.ceil(Math.abs(n-t)/5));for(let i=0;i<=r;i++)a.push({lon:t+(n-t)*i/r,lat:e})};return o(e,n,i),o(t,i,n),a}function KB(e,t,n=128){let r=e.lat*TB,i=e.lon*TB,a=[Math.cos(r)*Math.cos(i),Math.cos(r)*Math.sin(i),Math.sin(r)],o=[-a[1],a[0],0],s=Math.hypot(o[0],o[1]);o=s<1e-9?[1,0,0]:[o[0]/s,o[1]/s,0];let c=[a[1]*o[2]-a[2]*o[1],a[2]*o[0]-a[0]*o[2],a[0]*o[1]-a[1]*o[0]],l=t*TB,u=Math.sin(l),d=Math.cos(l),f=[];for(let e=0;e<n;e++){let t=2*Math.PI*e/n,r=Math.sin(t)*u,i=Math.cos(t)*u,s=a[0]*d+o[0]*r+c[0]*i,l=a[1]*d+o[1]*r+c[1]*i,p=a[2]*d+o[2]*r+c[2]*i;f.push({lon:Vz(Math.atan2(l,s)*OB),lat:Math.atan2(p,Math.hypot(s,l))*OB})}return f}var qB=24;function JB(e=30){let t=[];for(let n=-180;n<180;n+=e)t.push([{lon:n,lat:-90},{lon:n,lat:90}]);let n=179.999999;for(let r=-90+e;r<90;r+=e){let e=[];for(let t=0;t<=qB;t++)e.push({lon:-n+2*n*t/qB,lat:r});t.push(e)}return t}var YB=.005,XB=1.5,ZB=5,QB=24,$B=class{object=new za;body;altitudeKm;closed;interpolate;stepDeg;color;widthPx;opacity;fillColor;fillOpacity;dirs=new Float64Array;count=0;line=null;scratch=new Float32Array;alphas=new Float32Array;fanDirs=new Float64Array;fill=null;fillScratch=new Float32Array;turned=[0,0,0];wanted=!0;removeSelf=null;constructor(e){this.body=e.body,this.altitudeKm=e.altitudeKm??null,this.closed=e.closed??!1,this.interpolate=e.interpolate??`linear`,this.stepDeg=e.stepDeg,this.color=e.color??`#ffffff`,this.widthPx=e.widthPx??2,this.opacity=e.opacity??1,this.fillColor=e.fill??null,this.fillOpacity=e.fillOpacity??.25,this.object.matrixAutoUpdate=!1,this.setPoints(e.points)}bind(e){this.removeSelf=e}setPoints(e){let t=PB(e,{interpolate:this.interpolate,stepDeg:this.stepDeg,closed:this.closed});this.dirs=new Float64Array(t.length*3);for(let e=0;e<t.length;e++){let[n,r,i]=sR(t[e].lat,t[e].lon);this.dirs[e*3]=n,this.dirs[e*3+1]=r,this.dirs[e*3+2]=i}this.count=t.length,this.buildLine(),this.buildFill()}setVisible(e){this.wanted=e}remove(){this.removeSelf?.(),this.removeSelf=null}update({jd:e,basis:t,camera:n,ctx:r}){let i=this.wanted&&this.count>=2?r.getBody(this.body):void 0;if(this.line&&(this.line.visible=i!==void 0),this.fill&&(this.fill.visible=i!==void 0),!i)return;let a=gn(i.data),o=Q(a+(this.altitudeKm??a*YB)),s=i.orientation?fC(i.orientation,e,i.nutPrec):null,c=[i.position[0]-t[0],i.position[1]-t[1],i.position[2]-t[2]];if(this.line&&(this.place(this.dirs,this.count,s,o,c,this.scratch),iN(this.line.geometry,this.scratch,this.alphas,this.alphas,this.count),this.line.material.uniforms.uCenterOffset.value.copy(n.position).negate()),this.fill){let e=this.fill.geometry.getAttribute(`position`);this.place(this.fanDirs,this.fillScratch.length/3,s,o,c,this.fillScratch),e.needsUpdate=!0,this.fill.material.uniforms.uCenterOffset.value.copy(n.position).negate()}}place(e,t,n,r,i,a){for(let o=0;o<t;o++){let t=o*3;n?cR(n,e[t],e[t+1],e[t+2],this.turned,0):(this.turned[0]=e[t],this.turned[1]=e[t+1],this.turned[2]=e[t+2]),a[t]=this.turned[0]*r+i[0],a[t+1]=this.turned[1]*r+i[1],a[t+2]=this.turned[2]*r+i[2]}}buildLine(){if(this.disposeLine(),this.count<2||this.widthPx<=0)return;this.scratch=new Float32Array(this.count*3),this.alphas=new Float32Array(this.count).fill(this.opacity);let e=sN(this.count,this.scratch,this.alphas,this.alphas,this.count,this.color,this.widthPx,1);e.frustumCulled=!1,e.renderOrder=XB,this.object.add(e),this.line=e}buildFill(){if(this.disposeFill(),!this.fillColor||this.count<3)return;let e=Az(this.dirs,this.count),t=0;for(let n=0;n<this.count;n++){let r=e[0]*this.dirs[n*3]+e[1]*this.dirs[n*3+1]+e[2]*this.dirs[n*3+2];t=Math.max(t,Math.acos(Math.min(1,Math.max(-1,r))))}let n=Math.min(QB,Math.max(1,Math.ceil(t*180/Math.PI/ZB))),r=1+n*this.count;this.fanDirs=new Float64Array(r*3),this.fanDirs[0]=e[0],this.fanDirs[1]=e[1],this.fanDirs[2]=e[2];for(let t=1;t<=n;t++)for(let r=0;r<this.count;r++){let[i,a,o]=Oz(e,[this.dirs[r*3],this.dirs[r*3+1],this.dirs[r*3+2]],t/n),s=(1+(t-1)*this.count+r)*3;this.fanDirs[s]=i,this.fanDirs[s+1]=a,this.fanDirs[s+2]=o}let i=[],a=(e,t)=>1+(e-1)*this.count+t;for(let e=0;e<this.count-1;e++)i.push(0,a(1,e),a(1,e+1));for(let e=1;e<n;e++)for(let t=0;t<this.count-1;t++){let n=a(e,t),r=a(e,t+1),o=a(e+1,t),s=a(e+1,t+1);i.push(n,o,r,r,o,s)}let o=new Ho;o.setAttribute(`position`,new Ao(new Float32Array(r*3),3)),o.setIndex(i),this.fillScratch=o.getAttribute(`position`).array;let s=new As(o,jz(this.fillColor,this.fillOpacity));s.matrixAutoUpdate=!1,s.frustumCulled=!1,s.renderOrder=XB,this.object.add(s),this.fill=s}disposeLine(){this.line&&=(this.object.remove(this.line),this.line.geometry.dispose(),this.line.material.dispose(),null)}disposeFill(){this.fill&&=(this.object.remove(this.fill),this.fill.geometry.dispose(),this.fill.material.dispose(),null)}dispose(){this.disposeLine(),this.disposeFill()}},eV=class{object=new za;id;name;anchor;model;trueScale;spanScene;minPx;label;wanted=!0;removeSelf=null;constructor(e,t,n){this.id=t,this.name=e.name??null,this.anchor=e.position,this.object.matrixAutoUpdate=!1,this.object.frustumCulled=!1;let r=e.model;this.model=r?.object3d??null,this.minPx=r?.minPx??0;let i=r?tV(r.object3d):0;this.trueScale=r?.scaleM!==void 0&&i>0?Q(r.scaleM/1e3)/i:1,this.spanScene=i*this.trueScale,this.model&&this.object.add(this.model),this.label=e.label&&this.name?new Lz({anchor:e.position,text:this.name,align:[.5,1.4],occlude:e.occludeLabel},n):null,this.label&&this.object.add(this.label.object)}bind(e){this.removeSelf=e}get position(){return this.anchor}positionKm(e){let t=this.anchor;if(`latitude`in t)return null;let n=typeof t.offsetKm==`function`?t.offsetKm(e):t.offsetKm;return n===void 0?[0,0,0]:n}setPosition(e){this.anchor=e,this.label?.setAnchor(e)}setVisible(e){this.wanted=e,this.label?.setVisible(e)}remove(){this.removeSelf?.(),this.removeSelf=null}update(e){let{basis:t,camera:n,jd:r,ctx:i}=e,a=this.model,o=this.wanted?lR(this.anchor,i,r):null;if(this.label?.update(e),!a||(a.visible=o!==null,!o))return;a.position.set(o[0]-t[0],o[1]-t[1],o[2]-t[2]);let s=this.drawnScale(a.position,n,e.viewportPx);a.scale.setScalar(s),a.updateMatrixWorld(!0)}drawnScale(e,t,n){if(this.minPx<=0||this.spanScene<=0)return this.trueScale;let r=t.position.distanceTo(e);if(r<=0)return this.trueScale;let i=n/(2*Math.tan(t.fov*Math.PI/180/2)*r),a=this.spanScene*i;return a>=this.minPx?this.trueScale:this.trueScale*(this.minPx/a)}dispose(){this.label?.dispose(),this.model&&this.object.remove(this.model)}};function tV(e){let t=new co().setFromObject(e).getSize(new J);return Math.max(t.x,t.y,t.z)}var nV=class{byId=new Map;nextId=1;constructor(e,t){this.registry=e,this.canvas=t}add(e){let t=e.id??`object-${this.nextId++}`;this.byId.get(t)?.remove();let n=new eV(e,t,this.canvas()),r=this.registry();return n.bind(()=>{this.byId.delete(t),r.remove(n)}),this.byId.set(t,n),r.add(n),n}get(e){return this.byId.get(e)}all(){return[...this.byId.values()]}clear(){for(let e of[...this.byId.values()])e.remove()}},rV=class{enabled;apply;constructor(e,t){this.enabled=e,this.apply=t}enable(){this.set(!0)}disable(){this.set(!1)}isEnabled(){return this.enabled}set(e){this.enabled!==e&&(this.enabled=e,this.apply?.(e))}};function iV(e,t){return e??t??!0}var aV=1400,oV=class{enabled;element=document.createElement(`div`);timer;constructor(e,t){this.enabled=t,this.element.className=`sm-cooperative-hint`,this.element.setAttribute(`aria-hidden`,`true`),e.append(this.element)}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e,e||this.hide()}allowsWheel(e){if(!this.enabled||e.ctrlKey||e.metaKey)return!0;let{cooperative_wheel:t,cooperative_wheel_mac:n}=a().messages;return this.show(sV()?n():t()),!1}allowsTouchDrag(e){return!this.enabled||e>1?!0:(this.show(a().messages.cooperative_touch()),!1)}dispose(){clearTimeout(this.timer),this.element.remove()}show(e){this.element.textContent=e,this.element.classList.add(`sm-cooperative-hint--shown`),clearTimeout(this.timer),this.timer=setTimeout(()=>this.hide(),aV)}hide(){clearTimeout(this.timer),this.element.classList.remove(`sm-cooperative-hint--shown`)}};function sV(){return/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent)}var cV={[W.BARYCENTER]:`barycenter`,[W.LAGRANGE_POINT]:`lagrange-point`,[W.STAR]:`star`,[W.PLANET]:`planet`,[W.DWARF_PLANET]:`dwarf-planet`,[W.MOON]:`moon`,[W.ASTEROID]:`asteroid`,[W.ASTEROID_INNER]:`asteroid`,[W.ASTEROID_MAIN_BELT]:`asteroid`,[W.ASTEROID_TROJAN]:`asteroid`,[W.ASTEROID_CENTAUR]:`asteroid`,[W.ASTEROID_TNO]:`asteroid`,[W.COMET]:`comet`,[W.SPACECRAFT]:`spacecraft`,[W.DEBRIS]:`debris`,[W.UNDOCUMENTED]:`unknown`,[W.SURFACE_FEATURE]:`surface-feature`},lV={[W.ASTEROID_INNER]:`inner`,[W.ASTEROID_MAIN_BELT]:`main-belt`,[W.ASTEROID_TROJAN]:`trojan`,[W.ASTEROID_CENTAUR]:`centaur`,[W.ASTEROID_TNO]:`tno`};function uV(e){let{id:t,name:n,objectType:r,parentId:i,radiusKm:a,unplaceable:o}=e.data,s={id:t,name:n,type:cV[r],parentId:i,radiusKm:Number.isFinite(a)&&a>0?a:null,placed:o!==!0&&e.positionUnknown!==!0},c=lV[r];return c&&(s.orbitClass=c),s}var dV=[`top-left`,`top-right`,`bottom-left`,`bottom-right`],fV=class{corners=new Map;added=new Map;constructor(e,t){this.map=e,this.root=t}add(e,t){if(this.added.has(e))return;let n=e.onAdd(this.map);this.added.set(e,n),this.corner(t??e.getDefaultPosition?.()??`top-right`).append(n)}remove(e){let t=this.added.get(e);t&&(this.added.delete(e),e.onRemove?.(this.map),t.remove())}clear(){for(let e of[...this.added.keys()])this.remove(e);for(let e of this.corners.values())e.remove();this.corners.clear()}corner(e){let t=this.corners.get(e);return t||(t=document.createElement(`div`),t.className=`sm-ctrl sm-ctrl--${e}`,this.corners.set(e,t),this.root.append(...dV.map(e=>this.corners.get(e)).filter(e=>e!==void 0)),t)}},pV=[(e,t)=>e.setReducedMotion(t.resolvedReducedMotion),(e,t)=>e.setImmersive(t.viewMode===`immersive`),(e,t)=>e.setHaloDebugVisible(t.showHaloDebug),(e,t)=>{t.atmosphereCalibration,e.applyRenderTier()}],mV=.05,hV=1.15,gV=2e3,_V=4e3,vV=new WeakMap,yV=class{ctx=new SS;clock;initialView;#e=qe(null);get renderer(){return Ut(this.#e)}set renderer(e){Je(this.#e,e)}#t=qe(!1);get webglError(){return Ut(this.#t)}set webglError(e){Je(this.#t,e,!0)}#n=qe(!1);get contextLost(){return Ut(this.#n)}set contextLost(e){Je(this.#n,e,!0)}#r=qe();get focusedBody(){return Ut(this.#r)}set focusedBody(e){Je(this.#r,e)}attribution=null;objects=new nV(()=>this.requireRenderer().extensions,()=>this.requireCanvas());dragRotate;scrollZoom;keyboard;bodySelect;featureSelect;cooperativeGestures;container=null;canvas=null;labelLayer=null;stopWatching=null;controls=null;lostPanelTimer;cooperative=null;limits={};initialFocusPending=!0;pendingFocusId=null;retireCameraHold=null;listeners={focuschange:new Set,camera:new Set,featureselect:new Set,userpromoted:new Set,contextlost:new Set,contextrestored:new Set,clock:new Set,loading:new Set,progress:new Set,error:new Set,datastale:new Set,notice:new Set,noticedismiss:new Set,layerschange:new Set,frame:new Set};constructor(e={}){e.settings&&Mx(e.settings),this.clock=new wS(Ng(e.date??new Date),e.live??e.date===void 0);let t=e.view??{};this.initialView={id:t.body??cC,latitude:t.lat??45,longitude:t.lon??0,zoom:t.distanceKm===void 0?15:Q(t.distanceKm)};let n=t=>new rV(iV(e.interactions?.[t],e.interactive),()=>this.applyGestures());this.dragRotate=n(`dragRotate`),this.scrollZoom=n(`scrollZoom`),this.keyboard=n(`keyboard`),this.bodySelect=n(`bodySelect`),this.featureSelect=n(`featureSelect`),this.cooperativeGestures=new rV(e.cooperativeGestures??!1,()=>this.applyGestures()),e.limits&&(this.limits={...e.limits}),this.ctx.layers=new Cv(e.layers),this.ctx.layers.onChange=()=>this.onLayerChange(),this.ctx.onDataStale=()=>this.emit(`datastale`),gz()}on(e,t){return this.listeners[e].add(t),()=>this.listeners[e].delete(t)}once(e,t){let n=(...e)=>{r(),t(...e)};vV.set(n,t);let r=this.on(e,n);return r}off(e,t){let n=this.listeners[e];n.delete(t);for(let e of n)vV.get(e)===t&&n.delete(e)}emit(e,...t){for(let n of this.listeners[e])n(...t)}getBody(e){let t=this.ctx.getBody(e);return t&&uV(t)}getFocusedBody(){let e=this.focusedBody;if(!e)return;let t=un(e)?this.ctx.getBody(e.featureAnchor.hostId):e;return t&&uV(t)}getChildren(e){return[...this.ctx.bodies.getChildren(e)??[]]}load(e=this.initialView.id){return this.ctx.load(Pg(this.clock.jd),e)}async open(e=this.initialView.id){let t=this.load(e);t.catch(()=>{});let n=!0,r=new Promise(t=>{let r=()=>{n&&(this.renderer&&this.ctx.getBody(e)?t():document.hidden?setTimeout(r,100):requestAnimationFrame(r))};r()});try{await Promise.race([t,r])}finally{n=!1}}applyInitialView(){let{id:e,latitude:t,longitude:n,zoom:r}=this.initialView;this.focusedBody||!this.ctx.getBody(e)||this.renderer?.snapToBody(e,t,n,r)}mount(e){if(this.container)throw Error(`SpaceMap is already mounted`);this.container=e,e.classList.add(`sm-map`),this.controls=new fV(this,e);let t=document.createElement(`canvas`);t.className=`sm-map__canvas`,t.tabIndex=0,t.setAttribute(`role`,`application`),t.setAttribute(`aria-label`,a().messages.scene_canvas_label());let n=document.createElement(`div`);n.className=`scene-overlay`,e.append(t,n),this.canvas=t,this.labelLayer=n,this.cooperative=new oV(e,this.cooperativeGestures.isEnabled()),t.addEventListener(`keydown`,this.onKeyDown),t.addEventListener(`touchmove`,this.onTouchMove,{passive:!0}),e.addEventListener(`wheel`,this.onWheelCapture,{capture:!0,passive:!0}),t.addEventListener(`webglcontextlost`,this.onContextLost,!1),t.addEventListener(`webglcontextrestored`,this.onContextRestored,!1),document.addEventListener(`visibilitychange`,this.onVisibility);let r;try{r=new zR(t,n,this.ctx,this.clock,this.initialView,this.callbacks())}catch(e){console.error(`[scene] renderer init failed:`,e),this.webglError=!0;return}this.renderer=r,this.applyGestures(),this.applyLimits(),this.pendingFocusId!==null&&(r.focusOnBody(this.pendingFocusId),this.pendingFocusId=null);let i=new ResizeObserver(()=>r.resize(t.clientWidth,t.clientHeight));i.observe(t);let o=lt(()=>this.watch(r));this.stopWatching=()=>{i.disconnect(),o()}}addControl(e,t){if(!this.controls)throw Error(`spacemap: the map is not mounted`);return this.controls.add(e,t),this}removeControl(e){if(e===this.attribution)throw Error(`spacemap: the attribution control cannot be removed`);return this.controls?.remove(e),this}remove(){this.unmount()}unmount(){let{container:e,canvas:t}=this;!e||!t||(this.controls?.clear(),this.controls=null,this.stopWatching?.(),this.stopWatching=null,clearTimeout(this.lostPanelTimer),t.removeEventListener(`keydown`,this.onKeyDown),t.removeEventListener(`touchmove`,this.onTouchMove),e.removeEventListener(`wheel`,this.onWheelCapture,{capture:!0}),this.cooperative?.dispose(),this.cooperative=null,t.removeEventListener(`webglcontextlost`,this.onContextLost),t.removeEventListener(`webglcontextrestored`,this.onContextRestored),document.removeEventListener(`visibilitychange`,this.onVisibility),this.retireCameraHold?.(),this.retireCameraHold=null,this.renderer?.dispose(),this.renderer=null,t.remove(),this.labelLayer?.remove(),e.classList.remove(`sm-map`),this.container=this.canvas=this.labelLayer=null)}watch(e){st(()=>{this.ctx.bodies.minorBodyVersion,e.rebuildMinorPointClouds()});let t=jx();for(let n of pV)st(()=>n(e,t));let n=this.clock;st(()=>{let{jd:e,playing:t,timeScale:r,direction:i,live:a}=n;this.listeners.clock.size!==0&&this.emit(`clock`,{jd:e,date:Pg(e),playing:t,timeScale:r,direction:i,live:a})}),st(()=>{let e=this.ctx.loading,t=VR.bootPending;this.emit(`loading`,e||t)}),st(()=>this.emit(`progress`,U_.value)),st(()=>{let e=this.ctx.error;e!==null&&this.emit(`error`,e)}),st(()=>{VR.progress===null?e.isContextLost()||e.resume():e.pause()})}applySettings(){let e=this.renderer;if(!e)return;let t=jx();for(let n of pV)n(e,t)}callbacks(){return{notices:{notify:e=>this.emit(`notice`,e),dismiss:e=>this.emit(`noticedismiss`,e)},onFocusChange:e=>{let t=this.initialFocusPending;this.initialFocusPending=!1,this.focusedBody=e;let n=e!==void 0&&un(e);this.emit(`focuschange`,{body:this.getFocusedBody(),initial:t,feature:n})},onFrame:(e,t)=>{this.listeners.frame.size>0&&this.emit(`frame`,{jd:e,dtMs:t})},onCameraPosition:(e,t,n)=>{let r=this.focusedBody?.data.id;r!==void 0&&this.emit(`camera`,{body:r,lat:e,lon:t,distanceKm:cg(n)})},onUserPromotedChange:e=>this.emit(`userpromoted`,e),onFeatureSelect:(e,t,n,r,i)=>this.emit(`featureselect`,{bodyId:e,featureId:t,lat:n,lon:r,diameterM:i})}}onKeyDown=e=>{if(!this.keyboard.isEnabled()||e.ctrlKey||e.metaKey||e.altKey)return;let t=(e.shiftKey?4:1)*mV,n=0,r=0,i=1;switch(e.key){case`ArrowLeft`:n=t;break;case`ArrowRight`:n=-t;break;case`ArrowUp`:r=t;break;case`ArrowDown`:r=-t;break;case`+`:case`=`:i=hV;break;case`-`:case`_`:i=1/hV;break;default:return}e.preventDefault(),this.renderer?.nudgeCamera(n,r,i)};onContextLost=e=>{e.preventDefault(),console.warn(`[scene] WebGL context lost`),this.renderer?.pause(),clearTimeout(this.lostPanelTimer),this.lostPanelTimer=setTimeout(()=>{this.contextLost=!0,this.emit(`contextlost`)},gV)};onContextRestored=()=>{console.warn(`[scene] WebGL context restored`),clearTimeout(this.lostPanelTimer),this.contextLost=!1,this.renderer?.handleContextRestored(),this.renderer?.recoverWorkersIfDead(_V),this.emit(`contextrestored`)};onVisibility=()=>{document.visibilityState===`visible`&&(this.renderer?.isContextLost()||this.renderer?.recoverWorkersIfDead())};flyTo(e){let t=this.targetBody(e);return e.feature?this.toFeature(t,e.feature,`frame`):this.settled(this.focusOnBody(t,this.framing(e,t),e.lat,e.lon))}panTo(e){return this.toFeature(this.targetBody(e),e.feature,`pan`)}jumpTo(e){let t=this.targetBody(e);if(e.facing!==void 0)return this.snapToBodyFacing(t,e.facing,e.elevationDeg??0,this.framing(e,t)),this;if(e.feature){let{featureId:n,lat:r,lon:i,diameterM:a}=e.feature;return this.focusOnFeature(t,n,r,i,a,null,`snap`),this}let n=this.getCamera();return this.snapToBody(t,e.lat??n?.lat??45,e.lon??n?.lon??0,this.framing(e,t)),this}getCamera(){let e=this.renderer,t=this.focusedBody?.data.id;if(!e||t===void 0)return null;let{latitude:n,longitude:r,distance:i}=e.getCameraState();return{body:t,lat:n,lon:r,distanceKm:cg(i)}}setLayerVisible(e,t){return this.ctx.layers.setVisible(e,t),this}isLayerVisible(e){return this.ctx.layers.isVisible(e)}getLayers(){return[...gv]}onLayerChange(){for(let e of this.ctx.bodies.spacecraftByParent.keys())this.ctx.bodies.dirtySpacecraftGroups.add(e);this.ctx.bodies.minorBodyVersion++,this.emit(`layerschange`,gv.filter(e=>this.ctx.layers.isVisible(e)))}setLimits(e){return this.limits={...e},this.applyLimits(),this}getLimits(){return{...this.limits}}applyLimits(){let e=this.limits,t={};e.minDistanceKm!==void 0&&(t.minDistance=Q(e.minDistanceKm)),e.maxDistanceKm!==void 0&&(t.maxDistance=Q(e.maxDistanceKm)),e.minLat!==void 0&&(t.minLat=e.minLat),e.maxLat!==void 0&&(t.maxLat=e.maxLat),e.minLon!==void 0&&(t.minLon=e.minLon),e.maxLon!==void 0&&(t.maxLon=e.maxLon);let n=Object.keys(t).length>0;this.renderer?.setCameraLimits(n?t:null,e.bodies??null)}applyGestures(){let e=this.cooperativeGestures.isEnabled();this.cooperative?.setEnabled(e);let t=this.renderer;t&&(t.setDragEnabled(this.dragRotate.isEnabled()),t.setZoomEnabled(this.scrollZoom.isEnabled()),t.setBodySelectEnabled(this.bodySelect.isEnabled()),t.setFeatureSelectEnabled(this.featureSelect.isEnabled()),t.setCooperativeTouch(e))}onWheelCapture=e=>{this.scrollZoom.isEnabled()&&this.cooperative&&!this.cooperative.allowsWheel(e)&&e.stopPropagation()};onTouchMove=e=>{this.cooperative?.allowsTouchDrag(e.touches.length)};toFeature(e,t,n){let{featureId:r,lat:i,lon:a,diameterM:o}=t;return this.settled(this.focusOnFeature(e,r,i,a,o,null,n))}settled(e){return new Promise(t=>{setTimeout(()=>requestAnimationFrame(()=>t()),e)})}targetBody(e){let t=e.body??this.focusedBody?.data.id;if(t===void 0)throw Error(`spacemap: no body to move to, and none focused`);return t}framing(e,t){if(e.distanceKm!==void 0)return Q(e.distanceKm);let n=this.ctx.getBody(t);return n&&n.data.radiusKm>0?GL(n)*5:this.renderer?.getCameraState().distance??15}focusOnBody(e,t,n,r){return this.renderer?this.renderer.focusOnBody(e,t,n,r):(this.pendingFocusId=e,0)}snapToBody(e,t,n,r){this.renderer?.snapToBody(e,t,n,r)}snapToBodyFacing(e,t,n,r){this.renderer?.snapToBodyFacing(e,t,n,r)}focusOnFeature(e,t,n,r,i,a,o=`frame`,s=null){let c=this.ctx.getBody(e);if(!c)return 0;let l=Q(i*4/1e3),u=Q(.02),d=Q(gn(c.data)*5),f=Math.min(Math.max(l,u),d),p={hostId:e,featureId:t,lat:n,lon:r,diameterM:i};return this.renderer?.focusOnFeature(p,a,f,o,s)??0}setFocusTarget(e,t){this.renderer?.setFocusTarget(e,t)}getPose(){let e=this.renderer,t=this.focusedBody;if(!e||!t)return null;let n=t.data.id;return{position:{body:n,offsetKm:dR(e.cameraOffsetFromFocus())},target:{body:n}}}holdCamera(){let e=this.renderer;if(!e)throw Error(`SpaceMap is not mounted`);this.retireCameraHold?.(),e.holdCamera();let t=!0,n=()=>{t=!1};return this.retireCameraHold=n,{get held(){return t},set:n=>{t&&e.setHeldPose(n)},release:()=>{t&&(n(),this.retireCameraHold=null,e.releaseCamera())}}}addMarker(e){return this.track(new bz(e,this.requireCanvas()))}addPolyline(e){return this.track(new Sz(e))}addPolygon(e){return this.track(new Fz({fill:e.color??`#ffffff`,...e}))}addCircle(e){return this.track(new Iz(e))}addLabel(e){return this.track(new Lz(e,this.requireCanvas()))}addIcon(e){return this.track(new Rz(e,this.requireCanvas()))}addSurfacePolyline(e){return this.track(new $B(e))}addSurfacePolygon(e){return this.track(new $B({fill:e.color??`#ffffff`,...e,closed:!0}))}addSurfaceCircle(e){return this.addSurfacePolygon({...e,points:KB(e.center,this.capRadiusDeg(e),e.steps)})}clearDrawings(){this.renderer?.extensions.clear(e=>e instanceof eV)}setBodyAppearance(e,t){return this.requireRenderer().setBodyAppearance(e,t),this}capRadiusDeg(e){if(e.radiusDeg!==void 0)return e.radiusDeg;let t=this.getBody(e.body)?.radiusKm;return e.radiusKm!==void 0&&t?e.radiusKm/t*(180/Math.PI):1}track(e){let t=this.requireRenderer();return e.bind(()=>t.extensions.remove(e)),t.extensions.add(e),e}requireCanvas(){let e=this.canvas;if(!e)throw Error(`SpaceMap is not mounted`);return e}requireRenderer(){let e=this.renderer;if(!e)throw Error(`SpaceMap is not mounted`);return e}setNorthReference(e){this.renderer?.setNorthReference(e)}setUserLocation(e,t){this.renderer?.setUserLocation(e,t)}clearUserPromoted(){this.renderer?.clearUserPromoted()}setSelectedFeature(e){this.renderer?.setSelectedFeature(e)}setTravelPath(e,t=[],n=[],r=[]){this.renderer?.setTravelPath(e,t,n,r)}setOrbitPreview(e,t){this.renderer?.setOrbitPreview(e,t)}setTravelHover(e){this.renderer?.setTravelHover(e)}focusOnPathPoint(e,t){this.renderer?.focusOnPathPoint(e,t)}trackPathPoint(e,t){this.renderer?.trackPathPoint(e,t)}setCovered(e){this.renderer?.setCovered(e)}},bV=`http://www.w3.org/2000/svg`;function xV(e){return{id:e.id,label:e.label,kind:e.kind,visible:e.visible,credit:e.credit}}function SV(e){return{organisation:e.organisation,source:e.source,attribution:e.attribution}}function CV(e,t){let n=document.createElementNS(bV,`path`);return n.setAttribute(`d`,e),n.setAttribute(`class`,t),n}function wV(e,t=30){return{kind:`vector`,id:`graticule`,label:e,visible:!1,render(e,n){for(let r of JB(t)){let t=VB(r,e,{stepDeg:2});t&&n.append(CV(t,`sm-flat__graticule`))}if(e.projection.azimuthal){let t=e.toScreen(0,0),r=e.toScreen(e.projection.extent.maxX,0),i=document.createElementNS(bV,`circle`);i.setAttribute(`cx`,String(t[0])),i.setAttribute(`cy`,String(t[1])),i.setAttribute(`r`,String(Math.abs(r[0]-t[0]))),i.setAttribute(`class`,`sm-flat__frame`),n.append(i)}else{let t=WB(e);t&&n.append(CV(t,`sm-flat__frame`))}}}}var TV=120;function EV(e,t){let n=[];return{kind:`vector`,id:`nomenclature`,label:t,visible:!1,credit:{organisation:`IAU`,source:`https://planetarynames.wr.usgs.gov/`},async prepare(){n.length||(n=[...await pM(e)].sort((e,t)=>t.diameterM-e.diameterM).slice(0,TV))},render(e,t){let r=e.repeatShifts;for(let i of n){let n=e.project(i.lon,i.lat);if(!(!n||n[1]<0||n[1]>e.height))for(let a of r){let r=n[0]+a;if(r<0||r>e.width)continue;let o=document.createElementNS(bV,`circle`);o.setAttribute(`cx`,r.toFixed(1)),o.setAttribute(`cy`,n[1].toFixed(1)),o.setAttribute(`r`,`1.6`),o.setAttribute(`class`,`sm-flat__feature-dot`);let s=document.createElementNS(bV,`text`);s.setAttribute(`x`,(r+4).toFixed(1)),s.setAttribute(`y`,(n[1]+3).toFixed(1)),s.setAttribute(`class`,`sm-flat__feature-label`),s.textContent=i.name,t.append(o,s)}}}}}function DV(e,t){e.setAttribute(`fill`,t.fill??`none`),t.fill&&t.fillOpacity!==void 0&&e.setAttribute(`fill-opacity`,String(t.fillOpacity)),e.setAttribute(`stroke`,t.color??`#ffffff`),e.setAttribute(`stroke-width`,String(t.widthPx??2)),e.setAttribute(`stroke-linejoin`,`round`),e.setAttribute(`stroke-linecap`,`round`),t.opacity!==void 0&&e.setAttribute(`opacity`,String(t.opacity)),t.dash&&e.setAttribute(`stroke-dasharray`,t.dash),t.className&&e.setAttribute(`class`,t.className),e.style.pointerEvents=t.interactive?`auto`:`none`,t.ariaLabel&&(e.setAttribute(`role`,`img`),e.setAttribute(`aria-label`,t.ariaLabel))}function OV(e,t){t.onclick&&e.addEventListener(`click`,t.onclick),t.onpointerenter&&e.addEventListener(`pointerenter`,t.onpointerenter),t.onpointerleave&&e.addEventListener(`pointerleave`,t.onpointerleave)}var kV=class{node;area;edge;points;visible=!0;constructor(e,t,n,r,i,a){this.closed=n,this.interpolate=r,this.onRemove=i,this.onChange=a,this.points=e,this.node=document.createElementNS(bV,`g`),DV(this.node,t),OV(this.node,t),this.area=n?document.createElementNS(bV,`path`):null,this.area?.setAttribute(`stroke`,`none`),this.edge=document.createElementNS(bV,`path`),this.edge.setAttribute(`fill`,`none`),this.area&&this.node.append(this.area),this.node.append(this.edge)}redraw(e){if(!this.visible)return;let t={closed:this.closed,interpolate:this.interpolate};this.edge.setAttribute(`d`,VB(this.points,e,t)),this.area?.setAttribute(`d`,HB(this.points,e,t))}setPoints(e){this.points=e,this.onChange()}setVisible(e){this.visible=e,this.node.style.display=e?``:`none`,this.onChange()}detach(){this.node.remove()}remove(){this.onRemove(this)}},AV=class{element;at;visible=!0;align;constructor(e,t,n){this.onRemove=t,this.onChange=n,this.at=e.at,this.align=e.align??[.5,.5],this.element=e.element??document.createElement(`div`),e.element||(this.element.className=`sm-flat__marker-dot`),e.className&&this.element.classList.add(e.className),this.element.style.position=`absolute`,this.element.style.left=`0`,this.element.style.top=`0`,this.element.style.pointerEvents=e.interactive?`auto`:`none`}redraw(e){let t=this.visible?e.project(this.at.lon,this.at.lat):null;if(this.element.style.display=t?``:`none`,!t)return;let n=e.repeatShifts.find(n=>t[0]+n>=0&&t[0]+n<=e.width)??0;this.element.style.transform=`translate(${t[0]+n}px, ${t[1]}px) translate(${-this.align[0]*100}%, ${-this.align[1]*100}%)`}setPosition(e){this.at=e,this.onChange()}setVisible(e){this.visible=e,this.onChange()}detach(){this.element.remove()}remove(){this.onRemove(this)}},jV=class{drawings=new Set;constructor(e,t,n=()=>{},r=null){this.shapes=e,this.markers=t,this.onChange=n,this.radiusKm=r}setBodyRadiusKm(e){this.radiusKm=e}track(e,t){return this.drawings.add(e),t instanceof HTMLElement?this.markers.append(t):this.shapes.append(t),e}drop=e=>{this.drawings.delete(e)&&e.detach()};addPolyline(e){let t=new kV(e.points,e,e.closed??!1,e.interpolate??`linear`,this.drop,this.onChange);return this.track(t,t.node)}addPolygon(e){let t=new kV(e.points,{fill:`rgb(255 255 255 / 25%)`,...e},!0,e.interpolate??`linear`,this.drop,this.onChange);return this.track(t,t.node)}addBox(e){let t=new kV(GB(e.latMin,e.latMax,e.lonMin,e.lonSpan),{fill:`rgb(255 255 255 / 15%)`,...e},!0,`linear`,this.drop,this.onChange);return this.track(t,t.node)}addCircle(e){let t=this.circleRadiusDeg(e),n=new kV(KB(e.center,t),{fill:`rgb(255 255 255 / 20%)`,...e},!0,`linear`,this.drop,this.onChange);return this.track(n,n.node)}circleRadiusDeg(e){return e.radiusDeg===void 0?e.radiusKm!==void 0&&this.radiusKm?e.radiusKm/this.radiusKm*(180/Math.PI):1:e.radiusDeg}addMarker(e){let t=new AV(e,this.drop,this.onChange);return this.track(t,t.element)}redraw(e){for(let t of this.drawings)t.redraw(e)}clear(){for(let e of this.drawings)e.detach();this.drawings.clear()}};function MV(e){let t=`width`in e?e.width:e.codedWidth,n=`height`in e?e.height:e.codedHeight;return typeof t!=`number`||typeof n!=`number`||!t||!n?null:[t,n]}function NV(e,t){let[n,r]=MV(e)??[t,t/2],i=Math.max(2,Math.min(n,Math.round(t))),a=Math.max(1,Math.round(i*r/n)),o=document.createElement(`canvas`);o.width=i,o.height=a;let s=o.getContext(`2d`,{willReadFrequently:!0});if(!s)return null;s.imageSmoothingEnabled=!0,s.imageSmoothingQuality=`high`,s.drawImage(e,0,0,i,a);try{let{data:e}=s.getImageData(0,0,i,a);return{width:i,height:a,data:e}}catch{return null}}var PV=class{width;height;u;v;inside;constructor(e,t,n){this.width=t,this.height=n;let r=t*n;this.u=new Float32Array(r),this.v=new Float32Array(r),this.inside=new Uint8Array(r);let{projection:i}=e,a=1/e.scale,o=e.view.centerX-e.width/2*a,s=e.view.centerY+e.height/2*a;for(let r=0;r<n;r++){let n=s-(r+.5)*a,c=r*t;i.rowInverse?this.fillRow(i,c,n,o,a,e):this.walkRow(i,c,n,o,a)}}fillRow(e,t,n,r,i,a){let o=e.rowInverse(n);if(!o)return;let{width:s}=this,c=(90-o.lat)/180,{minX:l,maxX:u}=e.extent,d=u-l,f=a.repeatsHorizontally;for(let n=0;n<s;n++){let a=r+(n+.5)*i;if(f)a=((a-l)%d+d)%d+l;else if(a<l||a>u)continue;if(a<-o.maxAbsX||a>o.maxAbsX)continue;let s=(a*o.lonPerX+e.centerLon+180)/360,p=t+n;this.u[p]=s-Math.floor(s),this.v[p]=c,this.inside[p]=1}}walkRow(e,t,n,r,i){let{width:a}=this,o=0,s=a-1;if(e.azimuthal){let t=e.extent.maxX;if(Math.abs(n)>t)return;let c=Math.sqrt(t*t-n*n);o=Math.max(0,Math.ceil((-c-r)/i-.5)),s=Math.min(a-1,Math.floor((c-r)/i-.5))}for(let a=o;a<=s;a++){let o=r+(a+.5)*i,s=e.inverse(o,n);if(!s)continue;let c=t+a;this.u[c]=(s[0]+180)/360,this.v[c]=(90-s[1])/180,this.inside[c]=1}}};function FV(e,t,n){let r=n.data;r.fill(0);let{width:i,height:a,u:o,v:s,inside:c}=e,l=i*a;for(let e of t){let{image:t,opacity:n,blend:i}=e;if(n<=0)continue;let a=t.data,u=t.width,d=t.height,f=i===`add`;for(let e=0;e<l;e++){if(!c[e])continue;let t=Math.floor(o[e]*u),i=Math.floor(s[e]*d);t=t<0?t+u:t>=u?t-u:t,i=i<0?0:i>=d?d-1:i;let l=(i*u+t)*4,p=a[l+3]/255*n;if(p<=0)continue;let m=e*4;if(f){r[m]=Math.min(255,r[m]+a[l]*p),r[m+1]=Math.min(255,r[m+1]+a[l+1]*p),r[m+2]=Math.min(255,r[m+2]+a[l+2]*p);continue}let h=r[m+3]/255,g=p+h*(1-p);if(!(g<=0)){if(p>=1)r[m]=a[l],r[m+1]=a[l+1],r[m+2]=a[l+2];else{let e=h*(1-p);r[m]=(a[l]*p+r[m]*e)/g,r[m+1]=(a[l+1]*p+r[m+1]*e)/g,r[m+2]=(a[l+2]*p+r[m+2]*e)/g}r[m+3]=g*255}}}}function IV(e,t,n){let{minX:r,maxX:i,minY:a,maxY:o}=t.projection.extent,s=t.projection.centerLon*Math.PI/180,[c,l]=t.toScreen(r-s,o),[u,d]=t.toScreen(i-s,a),f=t.repeatsHorizontally?0:t.toScreen(r,o)[0],p=t.repeatsHorizontally?e.canvas.width:t.toScreen(i,o)[0];e.save(),e.imageSmoothingEnabled=!0,e.imageSmoothingQuality=`high`;for(let t of n){if(t.opacity<=0)continue;let n=MV(t.image),r=n&&e.createPattern(t.image,`repeat-x`);r&&(r.setTransform(new DOMMatrix().translateSelf(c,l).scaleSelf((u-c)/n[0],(d-l)/n[1])),e.globalAlpha=t.opacity,e.globalCompositeOperation=t.blend===`add`?`lighter`:`source-over`,e.fillStyle=r,e.fillRect(f,l,p-f,d-l))}e.restore()}var LV=[`low`,`medium`,`high`];function RV(e){let t=/^naif-(\d)\d\d$/.exec(e);return t?`naif-${t[1]}`:null}async function zV(e){try{let t=await fetch(e);return t.ok?await t.json():null}catch{return null}}async function BV(e){let t=await zV(Yt(`/v1/textures/${e}/metadata.json`,`textures`));if(!t||!o(t.distribution))return{};let n=Object.keys(t.exports??{}).filter(e=>[`low`,`medium`,`high`].includes(e));return n.length===0?{}:{surface:{id:e,tiers:n,source:String(t.source??``),organisation:String(t.organisation??``),type:String(t.type??`cylindrical`),attribution:t.attribution,description:t.description,license:t.license,distribution:t.distribution}}}async function VV(e){let t=RV(e);if(!t)return BV(e);let n=(await zV(`${Kt()}/v1/systems/${t}.json`))?.[e];if(!n?.texture||!n.tiers?.length)return BV(e);let r=s([{...n.texture,id:e,tiers:n.tiers},...n.alternates??[]]);if(!r)return BV(e);let{frames:i,...a}=r,o=n.radii;return{surface:{...a,monthlyFrames:i},clouds:n.clouds,night:n.night,radiusKm:o?(o.a+o.b+o.c)/3:void 0}}var HV={low:2048,medium:8192,high:16383};function UV(e){return LV.find(t=>HV[t]>=e)??LV[LV.length-1]}function WV(e,t){return LV.indexOf(e)<=LV.indexOf(t)?e:t}function GV(e,t){let n=LV.indexOf(t);for(let t=n<0?LV.length-1:n;t>=0;t--)if(e.includes(LV[t]))return LV[t];return e[0]??`low`}function KV(e,t,n){let r=e.id;if(e.frames?.length){let i=wj(n,e.frames,e.coverage);if(i)return Yt(`/v1/textures/${r}/${t}_${i}.webp`,`textures`)}let i=Xj(n,e.monthlyFrames);return Yt(i===void 0?`/v1/textures/${r}/${t}.webp`:`/v1/textures/${r}/${t}_${String(i).padStart(2,`0`)}.webp`,`textures`)}function qV(e,t){return e*t*4}function JV(){let e=navigator.deviceMemory??4;return Math.max(1,Math.min(e,8))*24*1024*1024}var YV=class{entries=new Map;clock=0;constructor(e){this.free=e}claim(e){let t=this.entries.get(e);return t?(t.claims++,t.used=++this.clock,t.value):null}put(e,t,n){let r=this.entries.get(e);return r?(r.value!==t&&this.free(t),r.claims++,r.used=++this.clock,r.value):(this.entries.set(e,{value:t,bytes:n,claims:1,used:++this.clock}),this.evict(),t)}release(e){let t=this.entries.get(e);t&&(t.claims=Math.max(0,t.claims-1),this.evict())}evict(){let e=0;for(let t of this.entries.values())t.claims||(e+=t.bytes);let t=JV();if(e<=t)return;let n=[...this.entries].filter(([,e])=>!e.claims).sort((e,t)=>e[1].used-t[1].used);for(let[r,i]of n){if(e<=t)return;this.entries.delete(r),this.free(i.value),e-=i.bytes}}clear(){for(let e of this.entries.values())this.free(e.value);this.entries.clear()}},XV=new YV(e=>e.close()),ZV=new YV(()=>{}),QV=new Map;function $V(e,t){return t?`${e}@${t}`:e}async function eH(e,t){let n=$V(e,t),r=XV.claim(n);if(r)return{key:n,bitmap:r};let i=QV.get(n);i||(i=tH(e,t),QV.set(n,i),i.finally(()=>QV.delete(n)));let a=await i;return a?{key:n,bitmap:XV.put(n,a,qV(a.width,a.height))}:null}async function tH(e,t){let n=await fetch(e);if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.blob();if(!t)return createImageBitmap(r);try{return await createImageBitmap(r,{resizeWidth:t,resizeQuality:`high`})}catch{return createImageBitmap(r)}}function nH(e){XV.release(e)}function rH(e,t,n){let r=$V(e,t),i=ZV.claim(r);if(i)return{key:r,raster:i};let a=NV(n,t);return a?{key:r,raster:ZV.put(r,a,qV(a.width,a.height))}:null}function iH(e){ZV.release(e)}function aH(e,t,n){return[sC(e,n.minLon,n.maxLon),Math.min(Math.max(t,n.minLat??-90),n.maxLat??90)]}var oH=class{projection;width;height;view;scale;constructor(e,t,n,r){this.projection=e,this.width=t,this.height=n,this.view=r;let{minX:i,maxX:a,minY:o,maxY:s}=e.extent,c=Math.min(t/(a-i),n/(s-o));this.scale=c*r.zoom}toScreen(e,t){return[this.width/2+(e-this.view.centerX)*this.scale,this.height/2-(t-this.view.centerY)*this.scale]}fromScreen(e,t){return[this.view.centerX+(e-this.width/2)/this.scale,this.view.centerY-(t-this.height/2)/this.scale]}project(e,t){let n=this.projection.forward(e,t);return n?this.toScreen(n[0],n[1]):null}unproject(e,t){let[n,r]=this.fromScreen(e,t);return this.projection.inverse(n,r)}get worldWidthPx(){let{minX:e,maxX:t}=this.projection.extent;return(t-e)*this.scale}get repeatsHorizontally(){return sH(this.projection,this.worldWidthPx,this.width)}get repeatShifts(){if(!this.repeatsHorizontally)return[0];let e=this.worldWidthPx,t=this.toScreen(this.projection.extent.minX,0)[0];return[0,-e,e].filter(n=>t+n<this.width&&t+n+e>0)}};function sH(e,t,n){return e.cyclic&&e.rectangular&&t>=n-.5}function cH(e,t,n,r,i){let a=Math.min(Math.max(e.zoom,1,i.minZoom??1),i.maxZoom??1/0),o=lH(e,t,i),s=t.extent,c=s.maxX-s.minX,l=s.maxY-s.minY,u=Math.min(n/c,r/l)*a,d=n/2/u,f=r/2/u,p=(s.minX+s.maxX)/2,m=(s.minY+s.maxY)/2,h=(e,t,n,r)=>n>=r/2?t:Math.min(t+r/2-n,Math.max(t-r/2+n,e));return{zoom:a,centerX:sH(t,c*u,n)?((o.centerX-s.minX)%c+c)%c+s.minX:h(o.centerX,p,d,c),centerY:h(o.centerY,m,f,l)}}function lH(e,t,n){if(!(n.minLon!==void 0||n.maxLon!==void 0||n.minLat!==void 0||n.maxLat!==void 0)||t.azimuthal)return e;let r=t.inverse(e.centerX,e.centerY);if(!r)return e;let[i,a]=aH(r[0],r[1],n);if(i===r[0]&&a===r[1])return e;let o=t.forward(i,a);return o?{centerX:o[0],centerY:o[1]}:e}var uH=[[6,`high`],[2.5,`medium`]],dH=22e5,fH=4096,pH=11,mH=.4,hH=.8,gH=140,_H=`naif-399`,vH=[{kind:`surface`,label:e=>e.layer_surface(),visible:!0,opacity:1,blend:`normal`},{kind:`clouds`,label:e=>e.layer_clouds(),visible:!0,opacity:1,blend:`normal`},{kind:`night`,label:e=>e.layer_night(),visible:!1,opacity:.85,blend:`add`}];function yH(e){return e.kind===`raster`}var bH=new WeakMap,xH=class{container=null;root=document.createElement(`div`);canvas=document.createElement(`canvas`);svg=document.createElementNS(bV,`svg`);layerGroup=document.createElementNS(bV,`g`);shapeGroup=document.createElementNS(bV,`g`);markerLayer=document.createElement(`div`);ctx;overlay;bodyId;sources={};layerList=[];projection;projectionId;projectionOptions;view;limits;limitsArmed=!1;jd;cooperative=null;bodyRadiusKm=null;bitmaps=new Map;rasters=new Map;pending=new Set;missing=new Set;generation=0;controls=null;attribution=null;dragPan;scrollZoom;cooperativeGestures;lookup=null;lookupKey=``;buffer=null;frame=0;resizeObserver=null;listeners=new Map;announcedReady=!1;disposed=!1;moving=!1;sharpWidth=0;msPerPixel=0;settleTimer=0;chosenVisibility=new Map;customLayers=[];constructor(e={}){this.bodyId=e.body??_H,this.projectionId=e.projection??`equirectangular`,this.projectionOptions={centerLon:e.centerLon??0,centerLat:e.centerLat,clipAngle:e.clipAngle},this.projection=wB(this.projectionId,this.projectionOptions),this.limits={maxZoom:16,...e.limits},this.view={zoom:e.zoom??1,centerX:0,centerY:0},this.jd=e.jd??Ng(new Date),this.dragPan=new rV(iV(e.interactions?.dragPan,e.interactive),e=>this.root.classList.toggle(`sm-flat--interactive`,e)),this.scrollZoom=new rV(iV(e.interactions?.scrollZoom,e.interactive)),this.cooperativeGestures=new rV(e.cooperativeGestures??!1,e=>this.applyCooperative(e)),this.root.className=`sm-flat`,this.canvas.className=`sm-flat__raster`,this.svg.setAttribute(`class`,`sm-flat__vector`),this.markerLayer.className=`sm-flat__markers`,this.svg.append(this.layerGroup,this.shapeGroup),this.root.append(this.canvas,this.svg,this.markerLayer),this.ctx=this.canvas.getContext(`2d`),this.overlay=new jV(this.shapeGroup,this.markerLayer,()=>this.render()),this.root.classList.toggle(`sm-flat--interactive`,this.dragPan.isEnabled()),this.applyCooperative(this.cooperativeGestures.isEnabled());for(let[t,n]of Object.entries(e.layers??{}))this.chosenVisibility.set(t,n)}mount(e){this.container=e,e.append(this.root),this.controls=new fV(this,this.root),this.cooperative=new oV(this.root,this.cooperativeGestures.isEnabled()),this.resizeObserver=new ResizeObserver(()=>this.renderMoving()),this.resizeObserver.observe(this.root),this.attachInteraction()}addControl(e,t){if(!this.controls)throw Error(`spacemap: the map is not mounted`);return this.controls.add(e,t),this}removeControl(e){if(e===this.attribution)throw Error(`spacemap: the attribution control cannot be removed`);return this.controls?.remove(e),this}remove(){this.unmount()}unmount(){this.disposed=!0,this.controls?.clear(),this.controls=null,this.cooperative?.dispose(),this.cooperative=null,this.resizeObserver?.disconnect(),this.resizeObserver=null,cancelAnimationFrame(this.frame),clearTimeout(this.settleTimer);for(let e of this.layerList)yH(e)||e.dispose?.();this.overlay.clear(),this.dropTextures(),this.root.remove(),this.container=null}async load(){await this.adopt(this.bodyId)}async adopt(e){let t=await VV(e);if(!this.disposed){if(!t.surface){let t=Error(`spacemap: no map texture for ${e}`);throw this.emit(`error`,t),t}e!==this.bodyId&&this.release(),this.bodyId=e,this.sources=t,this.bodyRadiusKm=t.radiusKm??null,this.overlay.setBodyRadiusKm(this.bodyRadiusKm),this.buildLayers(),await this.loadVisible(),!this.disposed&&this.render()}}release(){this.generation++,this.dropTextures(),this.missing.clear();for(let e of this.layerList)!yH(e)&&!this.customLayers.includes(e)&&e.dispose?.()}buildLayers(){let{messages:e}=a(),t=[];for(let n of vH){let r=this.sources[n.kind];r&&t.push({kind:`raster`,id:n.kind,label:n.label(e),visible:n.visible,opacity:n.opacity,blend:n.blend,credit:SV(r),tiers:r.tiers,url:(e,t)=>KV(r,t,e)})}t.push(wV(e.layer_graticule())),t.push(EV(this.bodyId,e.layer_nomenclature())),t.push(...this.customLayers);for(let e of t){let t=this.chosenVisibility.get(e.id);t!==void 0&&(e.visible=t)}this.layerList=t,this.emit(`layerschange`,this.layers)}get layers(){return this.layerList.map(xV)}getLayers(){return this.layerList.map(e=>e.id)}isLayerVisible(e){return this.layerList.find(t=>t.id===e)?.visible??!1}get credits(){let e=new Set,t=[];for(let n of this.layerList)!n.visible||!n.credit||e.has(n.credit.organisation)||(e.add(n.credit.organisation),t.push(n.credit));return t}setLayerVisible(e,t){this.chosenVisibility.set(e,t);let n=this.layerList.find(t=>t.id===e);!n||n.visible===t||(n.visible=t,this.emit(`layerschange`,this.layers),this.loadVisible(),this.render())}setLayerOpacity(e,t){let n=this.layerList.find(t=>t.id===e);!n||!yH(n)||(n.opacity=Math.min(1,Math.max(0,t)),this.render())}addRasterLayer(e){let t={kind:`raster`,id:e.id,label:e.label??e.id,visible:e.visible??!0,opacity:e.opacity??1,blend:e.blend??`normal`,credit:e.credit,tiers:[`low`],url:()=>e.url};this.customLayers.push(t),this.layerList.push(t),this.emit(`layerschange`,this.layers),this.loadVisible()}addVectorLayer(e){let t={kind:`vector`,id:e.id,label:e.label??e.id,visible:e.visible??!0,credit:e.credit,render:e.render,prepare:e.prepare};this.customLayers.push(t),this.layerList.push(t),this.emit(`layerschange`,this.layers),this.loadVisible()}get projectionName(){return this.projectionId}static get projections(){return CB}setProjection(e,t={}){this.limitsArmed=!1,this.projectionId=e,this.projectionOptions={...this.projectionOptions,...t},this.projection=wB(e,this.projectionOptions),this.view={...this.view,centerX:0,centerY:0},this.render(),this.emit(`viewchange`,this.viewState)}get viewState(){let e=this.viewport(),t=e.unproject(e.width/2,e.height/2);return{projection:this.projectionId,zoom:this.view.zoom,centerLon:t?.[0]??this.projectionOptions.centerLon??0,centerLat:t?.[1]??this.projectionOptions.centerLat??0}}setView(e){if(e.projection&&e.projection!==this.projectionId&&this.setProjection(e.projection),this.limitsArmed=!1,e.zoom!==void 0&&(this.view={...this.view,zoom:e.zoom}),e.centerLon!==void 0||e.centerLat!==void 0){let t=this.viewState,n=e.centerLon??t.centerLon,r=e.centerLat??t.centerLat;if(this.projection.azimuthal)this.projectionOptions={...this.projectionOptions,centerLon:n,centerLat:r},this.projection=wB(this.projectionId,this.projectionOptions);else{let e=this.projection.forward(n,r);e&&(this.view={...this.view,centerX:e[0],centerY:e[1]})}}this.loadVisible(),this.render(),this.emit(`viewchange`,this.viewState)}setLimits(e){return this.limits={maxZoom:16,...e},this.render(),this}getLimits(){return{...this.limits}}setTime(e){this.jd=e,this.loadVisible(),this.render()}async setBody(e){e!==this.bodyId&&(this.limitsArmed=!1,await this.adopt(e))}project(e,t){return this.viewport().project(e,t)}unproject(e,t){let n=this.viewport().unproject(e,t);return n?{lon:n[0],lat:n[1]}:null}addPolyline(e){let t=this.overlay.addPolyline(e);return this.render(),t}addPolygon(e){let t=this.overlay.addPolygon(e);return this.render(),t}addBox(e){let t=this.overlay.addBox(e);return this.render(),t}addCircle(e){let t=this.overlay.addCircle(e);return this.render(),t}addMarker(e){let t=this.overlay.addMarker(e);return this.render(),t}clearDrawings(){this.overlay.clear(),this.render()}on(e,t){let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),()=>n.delete(t)}once(e,t){let n=((...e)=>{r(),t(...e)});bH.set(n,t);let r=this.on(e,n);return r}off(e,t){let n=this.listeners.get(e);if(n){n.delete(t);for(let e of n)bH.get(e)===t&&n.delete(e)}}emit(e,...t){let n=this.listeners.get(e);if(n)for(let e of[...n])e(...t)}tier(e){return GV(e,WV(uH.find(([e])=>this.view.zoom>=e)?.[1]??`low`,UV(this.usableSourceWidth())))}usableSourceWidth(){return this.projectionId===`equirectangular`?this.deviceWidth()*this.view.zoom:this.workingWidth()}deviceWidth(){return this.sharpWidth||Math.max(1,this.root.clientWidth)}workingWidth(){let e=this.deviceWidth()*2*this.view.zoom;return Math.min(fH,2**Math.ceil(Math.log2(Math.max(256,e))))}decodeWidth(e){return this.projectionId===`equirectangular`?null:Math.min(this.workingWidth(),HV[e]??fH)}picturesInUse(){return this.layerList.filter(e=>yH(e)&&e.visible).map(e=>{let t=this.tier(e.tiers);return{url:e.url(this.jd,t),tier:t}})}async loadVisible(){let e=this.picturesInUse(),t=this.layerList.filter(e=>!yH(e)&&e.visible&&!!e.prepare).map(e=>e.prepare().then(()=>this.render(),()=>{})),n=e.filter(({url:e,tier:t})=>this.bitmaps.get(e)?.key!==$V(e,this.decodeWidth(t))).filter(({url:e})=>!this.pending.has(e)&&!this.missing.has(e)).map(async({url:e,tier:t})=>{this.pending.add(e);let n=this.generation;try{let r=await eH(e,this.decodeWidth(t));if(!r)return;if(this.disposed||n!==this.generation){nH(r.key);return}this.hold(this.bitmaps,e,r,nH),this.render()}catch(t){if(n!==this.generation)return;this.missing.add(e),this.emit(`error`,Error(`spacemap: could not load ${e}`,{cause:t}))}finally{this.pending.delete(e)}});await Promise.all([...t,...n]),this.dropUnused(new Set(this.picturesInUse().map(({url:e})=>e)))}dropUnused(e){for(let[t,n]of this.bitmaps)e.has(t)||(nH(n.key),this.bitmaps.delete(t));for(let[t,n]of this.rasters)e.has(t)||(iH(n.key),this.rasters.delete(t))}hold(e,t,n,r){let i=e.get(t);i?.key!==n.key&&(i&&r(i.key),e.set(t,n))}rasterFor(e,t){let n=this.rasters.get(e);if(n?.key===$V(e,t))return n.raster;let r=this.bitmaps.get(e)?.bitmap;if(!r)return null;let i=rH(e,t,r);return i?(this.hold(this.rasters,e,i,iH),i.raster):null}dropTextures(){for(let e of this.bitmaps.values())nH(e.key);for(let e of this.rasters.values())iH(e.key);this.bitmaps.clear(),this.rasters.clear()}viewport(e,t){let n=e??this.root.clientWidth??1,r=t??this.root.clientHeight??1;return this.view=cH(this.view,this.projection,n,r,this.limitsArmed?this.limits:{}),new oH(this.projection,Math.max(1,n),Math.max(1,r),this.view)}render(){this.disposed||(cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(()=>this.draw()))}renderMoving(){this.moving=!0,clearTimeout(this.settleTimer),this.settleTimer=window.setTimeout(()=>{this.moving=!1,this.render()},gH),this.render()}draw(){let e=this.root.clientWidth,t=this.root.clientHeight;if(!this.ctx||e===0||t===0)return;let n=Math.min(window.devicePixelRatio||1,2),r=Math.sqrt(dH/(e*t*n*n)),i=n*Math.min(1,r),a=Math.max(1,Math.round(e*i));a!==this.sharpWidth&&(this.sharpWidth=a,this.loadVisible());let o=e*i*t*i,s=i*(this.moving?this.interactionScale(o):1),c=Math.max(1,Math.round(e*s)),l=Math.max(1,Math.round(t*s));(this.canvas.width!==c||this.canvas.height!==l)&&(this.canvas.width=c,this.canvas.height=l,this.buffer=null,this.lookup=null);let u=this.viewport(e,t),d=new oH(this.projection,c,l,this.view);this.clipToDisc(u),this.drawRaster(d,c,l),this.drawVector(u),!this.announcedReady&&this.bitmaps.size>0&&(this.announcedReady=!0,this.emit(`ready`))}record(e,t){if(t<=0)return;let n=e/t;this.msPerPixel=this.msPerPixel===0?n:this.msPerPixel*.7+n*.3}interactionScale(e){if(this.msPerPixel<=0||e<=0)return 1;let t=Math.sqrt(pH/this.msPerPixel/e);return t>hH?1:Math.max(mH,t)}clipToDisc(e){let{projection:t}=e;if(!t.azimuthal){this.canvas.style.clipPath=``;return}let[n,r]=e.toScreen(0,0),i=t.extent.maxX*e.scale;this.canvas.style.clipPath=`circle(${i}px at ${n}px ${r}px)`}drawRaster(e,t,n){let r=this.ctx;r.clearRect(0,0,t,n);let i=this.layerList.filter(e=>yH(e)&&e.visible);if(i.length===0)return;if(this.projectionId===`equirectangular`){let t=i.map(e=>({image:this.bitmaps.get(e.url(this.jd,this.tier(e.tiers)))?.bitmap,opacity:e.opacity,blend:e.blend})).filter(e=>!!e.image);t.length&&IV(r,e,t);return}let a=this.workingWidth(),o=i.map(e=>({image:this.rasterFor(e.url(this.jd,this.tier(e.tiers)),a),opacity:e.opacity,blend:e.blend})).filter(e=>!!e.image);if(o.length===0)return;(!this.buffer||this.buffer.width!==t||this.buffer.height!==n)&&(this.buffer=r.createImageData(t,n));let s=`${this.projectionId}|${JSON.stringify(this.projectionOptions)}|${this.view.zoom}|${this.view.centerX}|${this.view.centerY}|${t}x${n}`,c=!this.lookup||this.lookupKey!==s,l=performance.now();c&&(this.lookup=new PV(e,t,n),this.lookupKey=s),FV(this.lookup,o,this.buffer),r.putImageData(this.buffer,0,0),c&&this.record(performance.now()-l,t*n)}drawVector(e){this.svg.setAttribute(`viewBox`,`0 0 ${e.width} ${e.height}`),this.layerGroup.replaceChildren();for(let t of this.layerList){if(yH(t)||!t.visible)continue;let n=document.createElementNS(bV,`g`);n.setAttribute(`data-layer`,t.id),t.render(e,n),this.layerGroup.append(n)}this.overlay.redraw(e)}applyCooperative(e){this.root.classList.toggle(`sm-flat--cooperative`,e),this.cooperative?.setEnabled(e)}attachInteraction(){let e=!1,t=0,n=0,r=!1,i=!1,a=new Map,o=-1,s=0,c=null,l=()=>{let[e,t]=[...a.values()];if(!t)return null;let n=this.root.getBoundingClientRect();return{gap:Math.hypot(e.x-t.x,e.y-t.y),x:(e.x+t.x)/2-n.left,y:(e.y+t.y)/2-n.top}},u=e=>{let t=this.root.getBoundingClientRect();return[e.clientX-t.left,e.clientY-t.top]};this.root.addEventListener(`pointerdown`,u=>{u.pointerType===`touch`&&a.set(u.pointerId,{x:u.clientX,y:u.clientY}),c=l(),s=c?.gap??0,u.button===0&&(o=u.pointerId,e=!0,r=!1,i=u.pointerType===`touch`&&this.cooperative.isEnabled()&&a.size<2,this.root.setPointerCapture(u.pointerId),t=u.clientX,n=u.clientY,!i&&this.dragPan.isEnabled()&&this.root.classList.add(`sm-flat--dragging`))}),this.root.addEventListener(`pointermove`,d=>{let[f,p]=u(d);a.has(d.pointerId)&&a.set(d.pointerId,{x:d.clientX,y:d.clientY});let m=l();if(m){r=!0,c&&this.dragPan.isEnabled()&&this.drag(m.x-c.x,m.y-c.y),s>0&&this.scrollZoom.isEnabled()&&this.zoomBy(m.gap/s,m.x,m.y),s=m.gap,c=m;return}if(!e){this.emit(`pointermove`,this.unproject(f,p),d);return}if(d.pointerId!==o)return;let h=d.clientX-t,g=d.clientY-n;if(t=d.clientX,n=d.clientY,(Math.abs(h)>1||Math.abs(g)>1)&&(r=!0),i){r&&this.cooperative.allowsTouchDrag(a.size);return}this.dragPan.isEnabled()&&this.drag(h,g)});let d=l=>{a.delete(l.pointerId),s=0,c=null;let[d]=[...a.entries()];if(d&&e){o=d[0],t=d[1].x,n=d[1].y,i=this.cooperative.isEnabled()&&a.size<2;return}if(!(!e||l.pointerId!==o)&&(e=!1,this.root.releasePointerCapture?.(l.pointerId),this.root.classList.remove(`sm-flat--dragging`),!r)){let[e,t]=u(l);this.emit(`click`,this.unproject(e,t),l)}};this.root.addEventListener(`pointerup`,d),this.root.addEventListener(`pointercancel`,d),this.root.addEventListener(`wheel`,e=>{if(!this.scrollZoom.isEnabled()||!this.cooperative.allowsWheel(e))return;e.preventDefault();let[t,n]=u(e);this.zoomBy(Math.exp(-e.deltaY/400),t,n)},{passive:!1})}drag(e,t){this.limitsArmed=!0;let n=this.viewport();if(this.projection.azimuthal){let r=n.scale,i=e=>e/r*(180/Math.PI),[a,o]=aH((this.projectionOptions.centerLon??0)-i(e),Math.max(-90,Math.min(90,(this.projectionOptions.centerLat??0)+i(t))),this.limits);this.projectionOptions={...this.projectionOptions,centerLon:a,centerLat:o},this.projection=wB(this.projectionId,this.projectionOptions)}else this.view={...this.view,centerX:this.view.centerX-e/n.scale,centerY:this.view.centerY+t/n.scale};this.renderMoving(),this.emit(`viewchange`,this.viewState)}zoomBy(e,t,n){this.limitsArmed=!0;let r=this.viewport().fromScreen(t,n),i=Math.min(this.limits.maxZoom??1/0,Math.max(1,this.limits.minZoom??1,this.view.zoom*e));if(i===this.view.zoom)return;this.view={...this.view,zoom:i};let a=this.viewport();if(!this.projection.azimuthal){let e=a.fromScreen(t,n);this.view={...this.view,centerX:this.view.centerX+r[0]-e[0],centerY:this.view.centerY+r[1]-e[1]}}this.loadVisible(),this.renderMoving(),this.emit(`viewchange`,this.viewState)}};function SH(e){let t=e?.radii;if(t)return(t.a+t.b+t.c)/3;let n=e?.wikidata?.radius;if(n)return n.unit===`kilometre`?n.value:n.unit===`metre`?n.value/1e3:null;let r=e?.sbdb?.diameter;return r?r/2:null}function CH(){return typeof window>`u`?`unsupported`:window.isSecureContext?`DeviceOrientationEvent`in window&&window.matchMedia(`(pointer: coarse)`).matches?`available`:`unsupported`:`insecure`}async function wH(){let e=DeviceOrientationEvent.requestPermission;if(typeof e!=`function`)return!0;try{return await e.call(DeviceOrientationEvent)===`granted`}catch{return!1}}var TH=Math.PI/180,EH=256,DH=128,OH=.05,kH=.25;function AH(e){try{let t=document.createElement(`canvas`);t.width=EH,t.height=DH;let n=t.getContext(`2d`,{willReadFrequently:!0});if(!n)return null;n.drawImage(e,0,0,EH,DH);let{data:r}=n.getImageData(0,0,EH,DH),i=new Uint8Array(EH*DH);for(let e=0;e<i.length;e++)i[e]=+(r[e*4+3]>127);return{width:EH,height:DH,covered:i}}catch{return null}}function jH(e,t,n){let{width:r,height:i,covered:a}=e,o=new Float64Array(r);for(let e=0;e<r;e++)o[e]=(e+.5)*360/r;let s=new Float64Array(i);for(let e=0;e<i;e++)s[e]=90-(e+.5)*180/i;let c=0,l=0,u=0;for(let e=0;e<i;e++){let t=Math.cos(s[e]*TH);for(let n=0;n<r;n++)a[e*r+n]&&(c+=t*Math.sin(o[n]*TH),l+=t*Math.cos(o[n]*TH),u+=t)}if(u===0)return t;let d=Math.hypot(c,l)/u<OH?t.heading:MH(Math.atan2(c,l)/TH-n.northOffsetDeg),f=MH(d+n.northOffsetDeg),p=Math.min(180,n.hfovDeg/2),m=new Float64Array(i),h=0;for(let e=0;e<r;e++)if(!(Math.abs((o[e]-f+540)%360-180)>p))for(let t=0;t<i;t++)a[t*r+e]&&(h=Math.max(h,++m[t]));let g=-1/0,_=1/0;for(let e=0;e<i;e++)m[e]<h*kH||(g=Math.max(g,s[e]),_=Math.min(_,s[e]));if(g<_)return{heading:d,pitch:t.pitch};let v=Math.min(n.vfovDeg/3,(g-_)/2);return{heading:d,pitch:Math.max(_+v,Math.min(g-v,t.pitch))}}function MH(e){return(e%360+360)%360}Math.PI/180;function NH(e){return e.orientation!==`unknown`&&e.north_offset_deg!==void 0}function PH(e){return e.id}function FH(e){return`${e.time},${e.lat},${e.lon}`}function IH(e,t){return t?e.find(e=>PH(e)===t||FH(e)===t)??null:null}function LH(e,t,n){let r=e.findIndex(e=>e.id===t.id),i=e=>e&&e.mission===t.mission,a=e=>i(e)?{entry:e,distanceM:zH(t,e,n),bearingDeg:BH(t,e)}:null;return{previous:a(e[r-1]),next:a(e[r+1])}}var RH=Math.PI/180;function zH(e,t,n){return jB(e,t)*RH*n*1e3}function BH(e,t){let n=e.lat*RH,r=t.lat*RH,i=(t.lon-e.lon)*RH,a=Math.sin(i)*Math.cos(r),o=Math.cos(n)*Math.sin(r)-Math.sin(n)*Math.cos(r)*Math.cos(i);return(Math.atan2(a,o)/RH%360+360)%360}var VH=Math.PI/180,HH=30,UH=110,WH=85,GH=75,KH=-22,qH=9,JH=6,YH=10,XH=1,ZH=1,QH=new Hi(-Math.SQRT1_2,0,0,Math.SQRT1_2),$H=new J(0,0,1);function eU(e){return(e%360+360)%360}function tU(e,[t,n]){let r=eU(n-t),i=eU(e-t);return i<=r?eU(e):i-r<360-i?eU(n):eU(t)}function nU(e,t,n){return Math.max(t,Math.min(n,e))}function rU(e,t,n=new J){let r=e*VH,i=t*VH;return n.set(Math.sin(r)*Math.cos(i),Math.sin(i),-Math.cos(r)*Math.cos(i))}function iU(){let e=new hl;return e.moveTo(0,1),e.lineTo(.85,.05),e.lineTo(.38,.05),e.lineTo(.38,-.9),e.lineTo(-.38,-.9),e.lineTo(-.38,.05),e.lineTo(-.85,.05),e.closePath(),e}var aU=class{bodyId;openAt;openingView;interactive;followArrows;limits={};attribution=null;container=null;root=document.createElement(`div`);renderer=null;controls=null;resizeObserver=null;scene=new qa;camera=new sd(GH,1,.1,1e3);sphere;angleCanvas=document.createElement(`canvas`);angleContext=this.angleCanvas.getContext(`2d`);angleGridVisible=!1;arrows=new za;arrowGeometry=new tu(iU());raycaster=new Rd;loader=new Ju;texture=null;loadToken=0;frame=0;disposed=!1;entries=[];radiusKm=0;current=null;neighbours=null;view;pointers=new Map;pinchDistance=0;dragStart=null;hovered=null;gyroEnabled=!1;gyroOrigin=null;gyroEuler=new xa;gyroQuaternion=new Hi;gyroScreen=new Hi;gyroDirection=new J;lookAt=new J;ndc=new J;gridPoint=new J;viewDirection=new J;listeners={ready:new Set,load:new Set,error:new Set,viewchange:new Set,step:new Set,arrows:new Set};constructor(e){this.bodyId=e.body,this.openAt=e.at,this.interactive=e.interactive??!0,this.arrows.visible=e.arrows??!0,this.followArrows=e.followArrows??!0,this.openingView=e.heading!==void 0||e.pitch!==void 0?{heading:e.heading,pitch:e.pitch}:null,this.view={heading:e.heading??0,pitch:e.pitch??0,fov:e.fov??GH},e.limits&&this.setLimits(e.limits),this.root.className=`sm-panorama`,this.root.style.cssText=`position:relative;width:100%;height:100%;overflow:hidden`,this.scene.background=new X(`#0b0d12`),this.sphere=new As(new ru(500,96,48).scale(-1,1,1),new vs({transparent:!0,visible:!1,depthWrite:!1})),this.sphere.renderOrder=-2,this.scene.add(this.sphere,this.arrows)}mount(e){this.container=e,e.append(this.root),this.renderer=new dh({antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2));let t=this.renderer.domElement;t.style.cssText=`display:block;width:100%;height:100%;touch-action:none`,t.tabIndex=0,this.root.append(t),this.angleCanvas.style.cssText=`position:absolute;inset:0;display:block;width:100%;height:100%;pointer-events:none`,this.angleCanvas.setAttribute(`aria-hidden`,`true`),this.angleCanvas.hidden=!0,this.root.append(this.angleCanvas),this.controls=new fV(this,this.root),this.resizeObserver=new ResizeObserver(()=>this.resize()),this.resizeObserver.observe(this.root),this.resize(),this.interactive?(t.addEventListener(`pointerdown`,this.onPointerDown),t.addEventListener(`pointermove`,this.onPointerMove),t.addEventListener(`pointerup`,this.onPointerUp),t.addEventListener(`pointercancel`,this.onPointerCancel),t.addEventListener(`wheel`,this.onWheel,{passive:!1}),t.addEventListener(`keydown`,this.onKeyDown)):(t.addEventListener(`pointermove`,this.onPointerMove),t.addEventListener(`pointerup`,this.onPointerUp))}async load(){let e=await mx(this.bodyId,!1);if(this.disposed)return;this.entries=(e.global?.panoramas??[]).filter(px),this.radiusKm=SH(e.global)??0,this.emit(`ready`);let t=this.openAt?this.byKey(this.openAt):this.entries[0]??null;if(!t){let e=Error(this.openAt?`spacemap: no panorama ${this.openAt} on ${this.bodyId}`:`spacemap: no panoramas on ${this.bodyId}`);throw this.emit(`error`,e),e}await this.open(t)}addControl(e,t){return this.controls?.add(e,t),this}removeControl(e){if(e===this.attribution)throw Error(`spacemap: the attribution control cannot be removed`);return this.controls?.remove(e),this}remove(){this.disposed=!0,this.setGyroEnabled(!1),this.loadToken++,cancelAnimationFrame(this.frame),this.frame=0,this.controls?.clear(),this.resizeObserver?.disconnect();let e=this.renderer?.domElement;e&&(e.removeEventListener(`pointerdown`,this.onPointerDown),e.removeEventListener(`pointermove`,this.onPointerMove),e.removeEventListener(`pointerup`,this.onPointerUp),e.removeEventListener(`pointercancel`,this.onPointerCancel),e.removeEventListener(`wheel`,this.onWheel),e.removeEventListener(`keydown`,this.onKeyDown)),this.setArrowTargets([]),this.texture?.dispose(),this.sphere.geometry.dispose(),this.sphere.material.dispose(),this.arrowGeometry.dispose(),this.renderer?.dispose(),this.renderer=null,this.root.remove(),this.container=null}getPanoramas(){return this.entries}getCurrent(){return this.current}getNeighbours(){return this.neighbours}async open(e){let t=typeof e==`string`?this.byKey(e):e;if(!t){let t=Error(`spacemap: no panorama ${String(e)} on ${this.bodyId}`);throw this.emit(`error`,t),t}this.current=t,this.neighbours=this.radiusKm?LH(this.entries,t,this.radiusKm):null;let n=this.openingView;this.openingView=null,n&&this.setView({heading:n.heading,pitch:n.pitch??0}),this.setArrowTargets(this.neighbours&&NH(t)?[`previous`,`next`].map(e=>({key:e,n:this.neighbours?.[e]??null})).filter(e=>e.n&&e.n.distanceM>=ZH).map(e=>({key:e.key,bearingDeg:e.n.bearingDeg})):[]),await this.loadTexture(Yt(`/v1/panoramas/${t.id}.webp`,`panoramas`),t.north_offset_deg??0,!n),this.current===t&&this.emit(`load`,t)}async step(e){let t=this.neighbours?.[e];t&&await this.open(t.entry)}byKey(e){return this.entries.find(t=>t.id===e)??IH(this.entries,e)}getView(){return{...this.view}}setView(e){let t=e.heading??this.view.heading,n=e.pitch??this.view.pitch,r=e.fov??this.view.fov,{limits:i}=this;this.view={heading:i.heading?tU(t,i.heading):eU(t),pitch:nU(n,i.pitch?.[0]??-WH,i.pitch?.[1]??WH),fov:nU(r,i.fov?.[0]??HH,i.fov?.[1]??UH)},this.invalidate(),this.emit(`viewchange`,this.getView())}getLimits(){return structuredClone(this.limits)}setLimits(e){let t=(e,t,n)=>e&&[nU(e[0],t,n),nU(e[1],t,n)];this.limits={heading:e.heading&&[eU(e.heading[0]),eU(e.heading[1])],pitch:t(e.pitch,-WH,WH),fov:t(e.fov,HH,UH)},this.setView({})}async setGyroEnabled(e){return e===this.gyroEnabled?this.gyroEnabled:e?CH()!==`available`||!await wH()||this.disposed?!1:(this.gyroOrigin=null,this.gyroEnabled=!0,window.addEventListener(`deviceorientation`,this.onDeviceOrientation),!0):(window.removeEventListener(`deviceorientation`,this.onDeviceOrientation),this.gyroEnabled=!1,!1)}isGyroEnabled(){return this.gyroEnabled}onDeviceOrientation=e=>{if(e.alpha===null||e.beta===null||e.gamma===null)return;this.gyroEuler.set(e.beta*VH,e.alpha*VH,-e.gamma*VH,`YXZ`),this.gyroQuaternion.setFromEuler(this.gyroEuler).multiply(QH).multiply(this.gyroScreen.setFromAxisAngle($H,-(screen.orientation?.angle??0)*VH)),this.gyroDirection.set(0,0,-1).applyQuaternion(this.gyroQuaternion);let t=Math.atan2(this.gyroDirection.x,-this.gyroDirection.z)/VH,n=Math.asin(nU(this.gyroDirection.y,-1,1))/VH;this.gyroOrigin===null&&(this.gyroOrigin=eU(t-this.view.heading)),this.setView({heading:t-this.gyroOrigin,pitch:n})};on(e,t){return this.listeners[e].add(t),()=>this.off(e,t)}once(e,t){let n=this.on(e,((...e)=>{n(),t(...e)}));return n}off(e,t){this.listeners[e].delete(t)}emit(e,...t){for(let n of this.listeners[e])n(...t)}faceCoverage(e,t){let n=AH(e);if(!n)return;let r=this.view.fov,i=2*Math.atan(Math.tan(r/2*VH)*this.camera.aspect)/VH;this.setView(jH(n,this.view,{northOffsetDeg:t,hfovDeg:i,vfovDeg:r}))}loadTexture(e,t,n){let r=++this.loadToken;return new Promise((i,a)=>{this.loader.load(e,e=>{if(r!==this.loadToken){e.dispose(),i();return}e.colorSpace=Xr,this.renderer&&(e.anisotropy=this.renderer.capabilities.getMaxAnisotropy()),this.texture?.dispose(),this.texture=e,this.sphere.material.map=e,this.sphere.material.visible=!0,this.sphere.material.needsUpdate=!0,this.sphere.rotation.y=Math.PI/2+t*VH,n&&this.faceCoverage(e.image,t),this.invalidate(),i()},void 0,()=>{if(r!==this.loadToken)return i();let t=Error(`spacemap: panorama failed to load: ${e}`);this.emit(`error`,t),a(t)})})}setArrowTargets(e){for(let e of[...this.arrows.children])this.arrows.remove(e),e.traverse(e=>{e instanceof As&&e.material.dispose()});for(let t of e){let e=new za;e.name=t.key;let n=new As(this.arrowGeometry,new vs({color:`#000000`,transparent:!0,opacity:.45,side:2,depthWrite:!1}));n.scale.setScalar(1.3);let r=new As(this.arrowGeometry,new vs({color:`#ffffff`,transparent:!0,opacity:.85,side:2,depthWrite:!1}));r.position.y=.02;for(let e of[n,r])e.rotation.x=-Math.PI/2;e.add(n,r),e.position.copy(rU(t.bearingDeg,KH)).multiplyScalar(qH),e.rotation.y=-t.bearingDeg*VH,this.arrows.add(e)}this.invalidate()}invalidate(){this.disposed||this.frame||!this.renderer||(this.frame=requestAnimationFrame(()=>{this.frame=0,this.render()}))}setAngleGridVisible(e){e!==this.angleGridVisible&&(this.angleGridVisible=e,this.angleCanvas.hidden=!e,this.invalidate())}setArrowsVisible(e){e!==this.arrows.visible&&(this.arrows.visible=e,e||(this.hovered=null,this.renderer&&(this.renderer.domElement.style.cursor=``)),this.invalidate())}resize(){let{clientWidth:e,clientHeight:t}=this.root;if(!e||!t||!this.renderer)return;this.renderer.setSize(e,t,!1);let n=Math.min(window.devicePixelRatio,2);this.angleCanvas.width=Math.round(e*n),this.angleCanvas.height=Math.round(t*n),this.angleContext.setTransform(n,0,0,n,0,0),this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.invalidate()}render(){if(!this.renderer)return;this.camera.fov=this.view.fov,this.camera.updateProjectionMatrix(),this.camera.lookAt(rU(this.view.heading,this.view.pitch,this.lookAt)),this.renderer.render(this.scene,this.camera);let{clientWidth:e,clientHeight:t}=this.root;if(this.drawAngleGrid(e,t),this.listeners.arrows.size===0)return;let n={};for(let r of this.arrows.visible?this.arrows.children:[])this.ndc.copy(r.position).project(this.camera),n[r.name]={x:(this.ndc.x+1)/2*e,y:(1-this.ndc.y)/2*t,visible:this.ndc.z<1&&Math.abs(this.ndc.x)<.98&&Math.abs(this.ndc.y)<.98};this.emit(`arrows`,n)}drawAngleGrid(e,t){let n=this.angleContext;if(n.clearRect(0,0,e,t),this.angleGridVisible){this.camera.getWorldDirection(this.viewDirection),n.strokeStyle=`rgba(255, 255, 255, 0.24)`,n.lineWidth=1,n.beginPath();for(let r=0;r<360;r+=YH)this.traceAngleLine(n,e,t,r,!0);for(let r=-80;r<=80;r+=YH)this.traceAngleLine(n,e,t,r,!1);n.stroke(),n.font=`12px system-ui, sans-serif`,n.lineWidth=3,n.strokeStyle=`rgba(0, 0, 0, 0.7)`,n.fillStyle=`rgba(255, 255, 255, 0.85)`,n.textAlign=`center`,n.textBaseline=`bottom`;for(let r=0;r<360;r+=YH){if(!this.projectAngle(r,0,e,t,!0))continue;let i=`${r}°`;n.strokeText(i,this.gridPoint.x,this.gridPoint.y-3),n.fillText(i,this.gridPoint.x,this.gridPoint.y-3)}n.textAlign=`left`,n.textBaseline=`middle`;for(let r of[0,90,180,270])for(let i=-80;i<=80;i+=YH){if(i===0||!this.projectAngle(r,i,e,t,!0))continue;let a=`${i>0?`+`:``}${i}°`;n.strokeText(a,this.gridPoint.x+4,this.gridPoint.y),n.fillText(a,this.gridPoint.x+4,this.gridPoint.y)}}}traceAngleLine(e,t,n,r,i){let a=!1,o=0,s=0,c=Math.max(t,n)*2,l=i?-90:0,u=i?90:360;for(let d=l;d<=u;d+=XH){let l=i?r:d,u=i?d:r;if(!this.projectAngle(l,u,t,n)){a=!1;continue}let{x:f,y:p}=this.gridPoint;!a||Math.hypot(f-o,p-s)>c?e.moveTo(f,p):e.lineTo(f,p),a=!0,o=f,s=p}}projectAngle(e,t,n,r,i=!1){return rU(e,t,this.gridPoint),this.gridPoint.dot(this.viewDirection)<=.001||(this.gridPoint.project(this.camera),!Number.isFinite(this.gridPoint.x)||!Number.isFinite(this.gridPoint.y))||i&&(Math.abs(this.gridPoint.x)>=.98||Math.abs(this.gridPoint.y)>=.98)||Math.abs(this.gridPoint.x)>4||Math.abs(this.gridPoint.y)>4?!1:(this.gridPoint.x=(this.gridPoint.x+1)/2*n,this.gridPoint.y=(1-this.gridPoint.y)/2*r,!0)}degreesPerPixel(){return this.view.fov/Math.max(1,this.root.clientHeight)}arrowAt(e,t){if(!this.renderer||!this.arrows.visible||this.arrows.children.length===0)return null;let n=this.renderer.domElement.getBoundingClientRect(),r=new q((e-n.left)/n.width*2-1,-((t-n.top)/n.height)*2+1);this.raycaster.setFromCamera(r,this.camera);let i=this.raycaster.intersectObjects(this.arrows.children,!0)[0];return i?i.object.parent.name:null}pressArrow(e){let t=this.neighbours?.[e];t&&(this.emit(`step`,{key:e,entry:t.entry}),this.followArrows&&this.open(t.entry).catch(()=>{}))}onPointerDown=e=>{try{this.renderer?.domElement.setPointerCapture(e.pointerId)}catch{}this.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.dragStart=this.pointers.size===1?{x:e.clientX,y:e.clientY}:null,this.pointers.size===2&&(this.pinchDistance=this.pinchSpan())};onPointerMove=e=>{let t=this.pointers.get(e.pointerId);if(!t){let t=this.arrowAt(e.clientX,e.clientY);t!==this.hovered&&this.renderer&&(this.hovered=t,this.renderer.domElement.style.cursor=t?`pointer`:``);return}let n=e.clientX-t.x,r=e.clientY-t.y;if(this.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.pointers.size===1){if(this.gyroEnabled)return;let e=this.degreesPerPixel();this.setView({heading:this.view.heading-n*e,pitch:this.view.pitch+r*e})}else if(this.pointers.size===2){let e=this.pinchSpan();this.pinchDistance>0&&this.zoom(this.pinchDistance/e),this.pinchDistance=e}};onPointerUp=e=>{this.pointers.delete(e.pointerId);let t=this.dragStart;if(this.dragStart=null,this.pointers.size>0||!(!this.interactive||t!==null&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<JH))return;let n=this.arrowAt(e.clientX,e.clientY);n&&this.pressArrow(n)};onPointerCancel=e=>{this.pointers.delete(e.pointerId),this.dragStart=null};pinchSpan(){let[e,t]=[...this.pointers.values()];return Math.hypot(e.x-t.x,e.y-t.y)}zoom(e){this.setView({fov:this.view.fov*e})}onWheel=e=>{e.preventDefault(),this.zoom(Math.exp(e.deltaY*.0015))};onKeyDown=e=>{let t=this.view.fov/10,{heading:n,pitch:r}=this.view,i={ArrowLeft:()=>this.setView({heading:n-t}),ArrowRight:()=>this.setView({heading:n+t}),ArrowUp:()=>this.setView({pitch:r+t}),ArrowDown:()=>this.setView({pitch:r-t}),"+":()=>this.zoom(.8),"-":()=>this.zoom(1.25)}[e.key];i&&(e.preventDefault(),i())}},oU=Object.fromEntries(xn.map(e=>[e,bn[e].label]));function sU(e,t){let n=e.credits.orbitSourceParents.get(t);if(!n)return!0;let r=e.visibility.focusedSystemId;for(let t of n)if(e.bodies.isInSystem(t,r))return!0;return!1}function cU(e){return xn.filter(t=>e.credits.orbitSources.has(t)).filter(t=>!bn[t].scoped||sU(e,t)).map(e=>({source:e,info:bn[e]}))}function lU(e,t){let n=e.visibility.focusedSystemId,r=e.visibility.focusedBodyId;return[...t].filter(e=>e.bodyId===r||n&&e.systemId===n)}function uU(e,t=oU){let n=e.credits;n.imageryVersion,n.modelVersion;let r=[...new Set(cU(e).map(({source:e})=>t[e]))],i=new Set;for(let t of lU(e,n.imagery.values()))i.add(t.organisation);let a=e.visibility.focusedBodyId,o=a?n.model.get(a):void 0;return o&&i.add(o.organisation),{orbits:r,imagery:[...i].sort()}}var dU=`https://spacemap.co`,fU=`https://spacemap.co/credits`;function pU(){let e=document.createElement(`div`);return e.className=`sm-attribution`,e}function mU(){let e=document.createElement(`span`);return e.className=`sm-attribution__group`,e}function hU(e,t,n){let r=document.createElement(`a`);return r.href=e,r.target=`_blank`,r.rel=`noopener noreferrer`,r.textContent=t,n&&(r.className=n),r}var gU=class{stop=null;onAdd(e){let t=pU(),n=mU(),r=mU();return t.append(hU(dU,`spacemap`,`sm-attribution__home`),n,r,hU(fU,a().messages.credits_see_all())),this.stop=lt(()=>{st(()=>{let t=uU(e.ctx);_U(n,a().messages.attribution_orbits(),t.orbits),_U(r,a().messages.attribution_imagery(),t.imagery)})}),t}onRemove(){this.stop?.(),this.stop=null}getDefaultPosition(){return`bottom-right`}};function _U(e,t,n){if(e.hidden=n.length===0,e.hidden)return;let r=document.createElement(`span`);r.className=`sm-attribution__label`,r.textContent=`${t}:`,e.replaceChildren(r,` ${n.join(` · `)}`)}var vU=class{off=null;onAdd(e){let t=pU(),n=mU();t.append(hU(dU,`spacemap`,`sm-attribution__home`),n,hU(fU,a().messages.credits_see_all()));let r=()=>{let t=[...new Set(e.credits.map(e=>e.organisation))].filter(Boolean);if(n.hidden=t.length===0,n.hidden)return;let r=document.createElement(`span`);r.className=`sm-attribution__label`,r.textContent=`${a().messages.attribution_imagery()}:`,n.replaceChildren(r,` ${t.join(` · `)}`)};return r(),this.off=e.on(`layerschange`,r),t}onRemove(){this.off?.(),this.off=null}getDefaultPosition(){return`bottom-right`}};function yU(e){if(e)try{let t=typeof window<`u`?window.location.href:`https://spacemap.co`,{protocol:n}=new URL(e,t);return n===`http:`||n===`https:`?e:void 0}catch{return}}var bU=class{off=null;onAdd(e){let t=pU(),n=mU();t.append(hU(dU,`spacemap`,`sm-attribution__home`),n,hU(fU,a().messages.credits_see_all()));let r=()=>{let t=e.getCurrent();if(n.hidden=!t?.credit,!t?.credit)return;let r=document.createElement(`span`);r.className=`sm-attribution__label`,r.textContent=`${a().messages.attribution_imagery()}:`;let i=yU(t.credit_url),o=i?hU(i,t.credit):t.credit;n.replaceChildren(r,` `,o)};return r(),this.off=e.on(`load`,r),t}onRemove(){this.off?.(),this.off=null}getDefaultPosition(){return`bottom-right`}},xU=Math.PI/180,SU=Math.cos(ag*xU),CU=Math.sin(ag*xU);function wU(e){return e}function TU(e){let t=[...e.samples].sort((e,t)=>e.jd-t.jd);return{body:e.body??`naif-10`,offsetKm:e=>kU(t,e)}}function EU(e){return{body:e.body??`naif-10`,offsetKm:t=>xF(e.elements,t)?.r??null}}function DU(e,t){let n=ng(e,t);return n.error!==$h.None&&console.warn(`spacemap: SGP4 will not take this element set (error=${n.error})`),{body:p_,offsetKm:e=>{if(n.error!==$h.None)return null;let t=vg(n,e);return t&&OU(t[0],t[1],t[2])}}}function OU(e,t,n){return[e,t*SU+n*CU,-t*CU+n*SU]}function kU(e,t){let n=e.length;if(n<2||t<e[0].jd||t>e[n-1].jd)return null;let r=0,i=n-1;for(;r<i;){let n=r+i>>1;e[n].jd<t?r=n+1:i=n}let a=Math.max(r,1),o=e[a-1],s=e[a],c=s.jd-o.jd;if(c<=0)return s.km;let l=(t-o.jd)/c,u=l*l,d=u*l,f=2*d-3*u+1,p=d-2*u+l,m=-2*d+3*u,h=d-u,g=[0,0,0];for(let t=0;t<3;t++){let n=o.km[t],r=s.km[t],i=AU(e,a-1,t),l=AU(e,a,t);g[t]=f*n+p*c*i+m*r+h*c*l}return g}function AU(e,t,n){let r=e[t-1]??e[t],i=e[t+1]??e[t],a=i.jd-r.jd;return a<=0?0:(i.km[n]-r.km[n])/a}function jU(e){return e/ig}async function MU(e=K_){let t=await e(`${Kt()}/v1/panoramas.json`);if(!t.ok)throw Error(`Failed to load panoramas.json: ${t.status}`);return(await t.json()).bodies??[]}async function NU(e){return(await mx(e,!1)).global?.panoramas??[]}async function PU(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,controls:s,events:c,...l}=e,u=LU(t);RU({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let d=new yV(l);if(d.mount(u),d.webglError)throw d.unmount(),Error(`spacemap: WebGL is not available`);for(let[e,t]of Object.entries(c??{}))d.on(e,t);d.attribution=new gU,d.addControl(d.attribution);for(let e of s??[])d.addControl(e);return await d.open(),d.applyInitialView(),await _z(),d}async function FU(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,controls:s,events:c,...l}=e,u=LU(t);RU({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let d=new xH(l);d.mount(u);for(let[e,t]of Object.entries(c??{}))d.on(e,t);d.attribution=new vU,d.addControl(d.attribution);for(let e of s??[])d.addControl(e);return await d.load(),d}async function IU(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,controls:s,events:c,...l}=e,u=LU(t);RU({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let d=new aU(l);d.mount(u);for(let[e,t]of Object.entries(c??{}))d.on(e,t);d.attribution=new bU,d.addControl(d.attribution);for(let e of s??[])d.addControl(e);return await d.load(),d}function LU(e){if(typeof e!=`string`)return e;let t=document.querySelector(e);if(!(t instanceof HTMLElement))throw Error(`spacemap: no element matches ${e}`);return t}function RU(e){let t={};e.dataUrl!==void 0&&(t.dataUrl=e.dataUrl),e.imagesUrl!==void 0&&(t.imagesUrl=e.imagesUrl),e.locale!==void 0&&(t.locale=()=>e.locale),e.messages!==void 0&&(t.messages=e.messages),e.includeNonCommercial&&(t.textures=`non-commercial`),i(t)}return e.AttributionControl=gU,e.FlatAttributionControl=vU,e.FlatMap=xH,e.GestureHandler=rV,e.MAP_LAYERS=gv,e.PROJECTION_IDS=CB,e.PanoramaAttributionControl=bU,e.PanoramaView=aU,e.SpaceMap=yV,e.Viewport=oH,e.bearingDeg=BH,e.boxRing=GB,e.circlePoints=Tz,e.configureHost=i,e.createFlatMap=FU,e.createMap=PU,e.createPanorama=IU,e.createProjection=wB,e.dateToJD=Ng,e.defaultSceneSettings=kx,e.elements=EU,e.fetchPanoramaIndex=MU,e.fetchPanoramas=NU,e.findPanorama=IH,e.fixed=wU,e.graticule=JB,e.groundDistanceM=zH,e.jdToDate=Pg,e.kmToAu=jU,e.neighboursOf=LH,e.panoramaAt=PH,e.pathFor=VB,e.planeBasis=Cz,e.projectionAspect=Uz,e.samples=TU,e.smallCircle=KB,e.tle=DU,e})({});
|
|
5536
|
+
`})}var Lz=.25,Rz=1e-9,zz=3,Bz=class{object=new za;anchor;outline;fillColor;fillOpacity;local=new Float64Array;count=0;mesh=null;scratch=new Float32Array;lastOrigin=[0,0,0];dirty=!0;wanted=!0;removeSelf=null;constructor(e){this.anchor=e.anchor;let t=e.widthPx??2;this.fillColor=e.fill??null,this.fillOpacity=e.fillOpacity??Lz,this.outline=t>0?new Dz({anchor:e.anchor,points:e.points,color:e.color,widthPx:t,opacity:e.opacity,closed:!0}):null,this.outline&&this.object.add(this.outline.object),this.object.matrixAutoUpdate=!1,this.setPoints(e.points)}bind(e){this.removeSelf=e}setPoints(e){this.outline?.setPoints(e),this.local.length<e.length*3&&(this.local=new Float64Array(e.length*3));for(let t=0;t<e.length;t++){let[n,r,i]=e[t];this.local[t*3]=Q(n),this.local[t*3+1]=Q(i),this.local[t*3+2]=Q(-r)}this.count=e.length,this.rebuild(e)}setAnchor(e){this.anchor=e,this.outline?.setAnchor(e)}setVisible(e){this.wanted=e,this.outline?.setVisible(e)}remove(){this.removeSelf?.(),this.removeSelf=null}update(e){this.outline?.update(e);let t=this.mesh;if(!t)return;let{jd:n,basis:r,camera:i,ctx:a}=e,o=this.wanted?hR(this.anchor,a,n):null;if(t.visible=o!==null,!o)return;let s=[o[0]-r[0],o[1]-r[1],o[2]-r[2]];if(this.dirty||Math.abs(s[0]-this.lastOrigin[0])>Rz||Math.abs(s[1]-this.lastOrigin[1])>Rz||Math.abs(s[2]-this.lastOrigin[2])>Rz){let e=t.geometry.getAttribute(`position`);for(let e=0;e<this.count*3;e+=3)this.scratch[e]=this.local[e]+s[0],this.scratch[e+1]=this.local[e+1]+s[1],this.scratch[e+2]=this.local[e+2]+s[2];e.needsUpdate=!0,this.lastOrigin=s,this.dirty=!1}t.material.uniforms.uCenterOffset.value.copy(i.position).negate()}rebuild(e){this.disposeMesh(),this.dirty=!0;let t=this.fillColor;if(!t)return;let n=jz(e);if(!n.length)return;let r=new Ho;r.setAttribute(`position`,new Ao(new Float32Array(e.length*3),3)),r.setIndex(n),this.scratch=r.getAttribute(`position`).array;let i=new As(r,Iz(t,this.fillOpacity));i.matrixAutoUpdate=!1,i.renderOrder=zz,i.frustumCulled=!1,this.object.add(i),this.mesh=i}disposeMesh(){let e=this.mesh;e&&(this.object.remove(e),e.geometry.dispose(),e.material.dispose(),this.mesh=null)}dispose(){this.disposeMesh(),this.outline?.dispose()}},Vz=class extends Bz{normal;steps;constructor(e){let{radiusKm:t,normal:n,steps:r,...i}=e;super({...i,points:Az(t,{normal:n,steps:r})}),this.normal=n,this.steps=r}setRadiusKm(e){this.setPoints(Az(e,{normal:this.normal,steps:this.steps}))}},Hz=class extends Tz{constructor(e,t){let n=document.createElement(`div`);n.className=`sm-drawing-label`,e.interactive&&n.classList.add(`sm-drawing--interactive`),e.className&&n.classList.add(e.className),n.textContent=e.text,e.color&&(n.style.color=e.color),e.fontSizePx!==void 0&&(n.style.fontSize=`${e.fontSizePx}px`),super({anchor:e.anchor,element:n,align:e.align,occlude:e.occlude},t)}setText(e){this.element.textContent=e}},Uz=class extends Tz{constructor(e,t){let n=document.createElement(`img`);n.className=`sm-drawing-icon`,e.interactive&&n.classList.add(`sm-drawing--interactive`),e.className&&n.classList.add(e.className),n.src=e.url,n.alt=e.alt??``,e.widthPx!==void 0&&(n.style.width=`${e.widthPx}px`),e.heightPx!==void 0&&(n.style.height=`${e.heightPx}px`),e.opacity!==void 0&&(n.style.opacity=String(e.opacity)),super({anchor:e.anchor,element:n,align:e.align,occlude:e.occlude},t)}setUrl(e){this.element.src=e}},Wz=Math.PI/180,Gz=180/Math.PI;function Kz(e){return e>=-180&&e<180?e:((e+180)%360+360)%360-180}function qz(e,t){return(n,r)=>{let i=e(r);return!i||Math.abs(n)>i.maxAbsX+1e-9?null:[Kz(n*i.lonPerX+t),i.lat]}}function Jz(e){let{minX:t,maxX:n,minY:r,maxY:i}=e.extent;return(n-t)/(i-r)}function Yz(e){let t=1/0,n=1/0,r=-1/0,i=-1/0,a=179.999999999;for(let o=0;o<=720;o++){let s=-90+180*o/720;for(let o=0;o<=720;o++){let c=e(-a+2*a*o/720,s);c&&(c[0]<t&&(t=c[0]),c[0]>r&&(r=c[0]),c[1]<n&&(n=c[1]),c[1]>i&&(i=c[1]))}}return{minX:t,minY:n,maxX:r,maxY:i}}function Xz(e){let t=e.centerLon??0,n=e=>Math.abs(e)>Math.PI/2?null:{lat:e*Gz,lonPerX:Gz,maxAbsX:Math.PI};return{id:`equirectangular`,centerLon:t,cyclic:!0,rectangular:!0,azimuthal:!1,extent:{minX:-Math.PI,minY:-Math.PI/2,maxX:Math.PI,maxY:Math.PI/2},forward:(e,n)=>[Kz(e-t)*Wz,n*Wz],rowInverse:n,inverse:qz(n,t)}}var Zz=1.340264,Qz=-.081106,$z=893e-6,eB=.003796,tB=Math.sqrt(3),nB=e=>eB*e**9+$z*e**7+Qz*e**3+Zz*e,rB=e=>9*eB*e**8+7*$z*e**6+3*Qz*e**2+Zz;function iB(e){let t=e.centerLon??0,n=(e,n)=>{let r=Math.asin(bB(tB/2*Math.sin(n*Wz))),i=Kz(e-t)*Wz;return[2*tB*i*Math.cos(r)/(3*rB(r)),nB(r)]},r=e=>{let t=e;for(let n=0;n<12;n++){let n=(nB(t)-e)/rB(t);if(t-=n,Math.abs(n)<1e-12)break}return t},i=e=>{let t=r(e),n=2/tB*Math.sin(t);if(Math.abs(n)>1)return null;let i=3*rB(t)/(2*tB*Math.cos(t))*Gz;return{lat:Math.asin(n)*Gz,lonPerX:i,maxAbsX:180/i}};return{id:`equalEarth`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:Yz(n),forward:n,rowInverse:i,inverse:qz(i,t)}}var aB=Math.SQRT2;function oB(e){let t=e.centerLon??0,n=e=>{let t=e/aB;if(Math.abs(t)>1)return null;let n=Math.asin(t),r=(2*n+Math.sin(2*n))/Math.PI;if(Math.abs(r)>1)return null;let i=Math.cos(n);if(i<1e-12)return{lat:Math.sign(e)*90,lonPerX:0,maxAbsX:0};let a=Math.PI/(2*aB*i)*Gz;return{lat:Math.asin(r)*Gz,lonPerX:a,maxAbsX:180/a}};return{id:`mollweide`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-2*aB,minY:-aB,maxX:2*aB,maxY:aB},forward:(e,n)=>{let r=n*Wz,i=r;if(Math.abs(Math.abs(r)-Math.PI/2)<1e-9)i=Math.PI/2*Math.sign(r);else{let e=Math.PI*Math.sin(r);for(let t=0;t<20;t++){let t=(2*i+Math.sin(2*i)-e)/(2+2*Math.cos(2*i));if(i-=t,Math.abs(t)<1e-12)break}}let a=Kz(e-t)*Wz;return[2*aB/Math.PI*a*Math.cos(i),aB*Math.sin(i)]},rowInverse:n,inverse:qz(n,t)}}function sB(e){let t=e.centerLon??0,n=e=>{if(Math.abs(e)>Math.PI/2)return null;let t=Math.cos(e);return t<1e-12?{lat:Math.sign(e)*90,lonPerX:0,maxAbsX:0}:{lat:e*Gz,lonPerX:Gz/t,maxAbsX:Math.PI*t}};return{id:`sinusoidal`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-Math.PI,minY:-Math.PI/2,maxX:Math.PI,maxY:Math.PI/2},forward:(e,n)=>{let r=n*Wz;return[Kz(e-t)*Wz*Math.cos(r),r]},rowInverse:n,inverse:qz(n,t)}}var cB=[1,.9986,.9954,.99,.9822,.973,.96,.9427,.9216,.8962,.8679,.835,.7986,.7597,.7186,.6732,.6213,.5722,.5322],lB=[0,.062,.124,.186,.248,.31,.372,.434,.4958,.5571,.6176,.6769,.7346,.7903,.8435,.8936,.9394,.9761,1],uB=.8487,dB=1.3523,fB=5;function pB(e,t){let n=e[Math.max(t-1,0)],r=e[t],i=e[t+1],a=e[Math.min(t+2,e.length-1)];return[r,.5*(i-n),.5*(2*n-5*r+4*i-a),.5*(-n+3*r-3*i+a)]}var mB=(e,t)=>e[0]+t*(e[1]+t*(e[2]+t*e[3])),hB=(e,t)=>e[1]+t*(2*e[2]+3*e[3]*t);function gB(e){let t=Math.min(Math.max(Math.floor(e),0),cB.length-2);return[t,e-t]}function _B(e){let[t,n]=gB(e);return uB*mB(pB(cB,t),n)*Math.PI}function vB(e){let t=0,n=lB.length-1;for(;n-t>1;){let r=t+n>>1;lB[r]<=e?t=r:n=r}let r=Math.min(t,lB.length-2),i=pB(lB,r),a=(e-lB[r])/(lB[r+1]-lB[r]);for(let t=0;t<8;t++){let t=hB(i,a);if(t===0)break;let n=(mB(i,a)-e)/t;if(a-=n,Math.abs(n)<1e-14)break}return r+Math.min(Math.max(a,0),1)}function yB(e){let t=e.centerLon??0,n=e=>{let t=Math.abs(e)/dB;if(t>1)return null;let n=vB(t),r=_B(n);return{lat:Math.sign(e)*n*fB,lonPerX:180/r,maxAbsX:r}};return{id:`robinson`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-uB*Math.PI,minY:-dB,maxX:uB*Math.PI,maxY:dB},forward:(e,n)=>{let[r,i]=gB(Math.abs(n)/fB),a=mB(pB(cB,r),i),o=mB(pB(lB,r),i);return[uB*a*Kz(e-t)*Wz,dB*o*Math.sign(n)]},rowInverse:n,inverse:qz(n,t)}}function bB(e){return e<-1?-1:e>1?1:e}function xB(e,t,n,r,i,a,o){let s=Math.asin(bB(n*a+t*r*o));return[Kz(i+Math.atan2(e*r,n*o-t*r*a)*Gz),s*Gz]}function SB(e){return{minX:-e,minY:-e,maxX:e,maxY:e}}function CB(e,t,n,r){let i=Kz(e-n)*Wz,a=t*Wz;return[Math.cos(a)*Math.sin(i),Math.cos(r)*Math.sin(a)-Math.sin(r)*Math.cos(a)*Math.cos(i)]}function wB(e){let t=e.centerLon??0,n=(e.centerLat??0)*Wz,r=Math.min(e.clipAngle??90,90)*Wz,i=Math.cos(r),a=Math.sin(r),o=Math.sin(n),s=Math.cos(n);return{id:`orthographic`,centerLon:t,cyclic:!1,rectangular:!1,azimuthal:!0,extent:SB(a),forward:(e,r)=>{let a=Kz(e-t)*Wz,o=r*Wz;return Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos(a)<i?null:CB(e,r,t,n)},inverse:(e,n)=>{let r=e*e+n*n;return r>a*a?null:xB(e,n,Math.sqrt(1-r),1,t,o,s)}}}var TB=120;function EB(e){let t=e.centerLon??0,n=(e.centerLat??90)*Wz,r=Math.min(e.clipAngle??TB,170)*Wz,i=Math.cos(r),a=2*Math.tan(r/2),o=Math.sin(n),s=Math.cos(n);return{id:`stereographic`,centerLon:t,cyclic:!1,rectangular:!1,azimuthal:!0,extent:SB(a),forward:(e,r)=>{let a=Kz(e-t)*Wz,o=r*Wz,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos(a);if(s<i)return null;let c=2/(1+s),[l,u]=CB(e,r,t,n);return[c*l,c*u]},inverse:(e,n)=>{let r=e*e+n*n;if(r>a*a)return null;let i=4/(4+r);return xB(e,n,(4-r)*i*.25,i,t,o,s)}}}var DB={equirectangular:Xz,equalEarth:iB,mollweide:oB,sinusoidal:sB,robinson:yB,orthographic:wB,stereographic:EB},OB=Object.keys(DB);function kB(e,t={}){let n=DB[e];if(!n)throw Error(`spacemap: unknown projection "${e}"`);return n(t)}var AB=Math.PI/180,jB=2*Math.PI,MB=2*AB,NB=180/Math.PI,PB=512,FB=2;function IB(e,t){let n=e.lat*AB,r=t.lat*AB,i=r-n,a=Kz(t.lon-e.lon)*AB,o=Math.sin(i/2)**2+Math.cos(n)*Math.cos(r)*Math.sin(a/2)**2;return 2*Math.asin(Math.min(1,Math.sqrt(o)))*NB}function LB(e,t,n){let r=IB(e,t)*AB;if(r<1e-12)return e;let i=Math.sin(r),a=Math.sin((1-n)*r)/i,o=Math.sin(n*r)/i,s=e.lat*AB,c=e.lon*AB,l=t.lat*AB,u=(e.lon+Kz(t.lon-e.lon))*AB,d=a*Math.cos(s)*Math.cos(c)+o*Math.cos(l)*Math.cos(u),f=a*Math.cos(s)*Math.sin(c)+o*Math.cos(l)*Math.sin(u),p=a*Math.sin(s)+o*Math.sin(l);return{lon:Math.atan2(f,d)*NB,lat:Math.atan2(p,Math.hypot(d,f))*NB}}function RB(e,t,n){return{lon:e.lon+Kz(t.lon-e.lon)*n,lat:e.lat+(t.lat-e.lat)*n}}function zB(e,t={}){let n=t.interpolate??`linear`,r=t.stepDeg??FB,i=n===`geodesic`?LB:RB,a=t.closed&&e.length>2?[...e,e[0]]:e;if(a.length<2)return[...a];let o=[a[0]];for(let e=1;e<a.length;e++){let t=a[e-1],n=a[e],s=Math.min(PB,Math.max(1,Math.ceil(IB(t,n)/r)));for(let e=1;e<=s;e++)o.push(e===s?n:i(t,n,e/s))}return o}function BB(e,t,n){let r=0,i=1;for(let a=0;a<20;a++){let a=(r+i)/2,o=RB(e,t,a);n.forward(o.lon,o.lat)?r=a:i=a}return RB(e,t,r)}function VB(e,t){let n=t.projection.cyclic?t.worldWidthPx/2:1/0,{projection:r}=t,i=[],a=[],o=null,s=0;for(let c=0;c<e.length;c++){let l=e[c],u=t.project(l.lon,l.lat);if(!u){if(a.length&&c>0){let n=BB(e[c-1],l,r);a.push(t.project(n.lon,n.lat))}a.length>1&&i.push(a),a=[],o=null,s++;continue}if(o&&Math.abs(u[0]-o[0])>n&&(a.length>1&&i.push(a),a=[]),!a.length&&c>0&&!t.project(e[c-1].lon,e[c-1].lat)){let n=BB(l,e[c-1],r);a.push(t.project(n.lon,n.lat))}a.push(u),o=u}return a.length>1&&i.push(a),{runs:i,whole:i.length===1&&s===0}}function HB(e,t){let n=[...e];for(let r of t.repeatShifts)if(r!==0)for(let i of e){let e=1/0,a=-1/0;for(let[t]of i)t<e&&(e=t),t>a&&(a=t);e+r>t.width||a+r<0||n.push(i.map(([e,t])=>[e+r,t]))}return n}function UB(e,t){let n=`M${e[0][0].toFixed(2)} ${e[0][1].toFixed(2)}`;for(let t=1;t<e.length;t++)n+=`L${e[t][0].toFixed(2)} ${e[t][1].toFixed(2)}`;return t?`${n}Z`:n}var WB=179.999999;function GB(e,t){let n=e=>e>WB?WB:e<-WB?-WB:e,r=e.length;if(r<3)return[e];let i=[],a=[],o=Kz(e[0].lon-t);a.push({lon:n(o),lat:e[0].lat});for(let t=0;t<r;t++){let s=e[t],c=e[(t+1)%r],l=Kz(c.lon-s.lon),u=o+l,d=u>180?1:u<-180?-1:0;if(d!==0){let e=s.lat+(c.lat-s.lat)*((d*180-o)/l);a.push({lon:d*WB,lat:e}),i.push(a),a=[{lon:-d*WB,lat:e}],o=u-d*360}else o=u;t<r-1&&a.push({lon:n(o),lat:c.lat})}return i.length===0?[a.map(e=>({lon:e.lon+t,lat:e.lat}))]:(i[0]=a.concat(i[0]),i.map(e=>e.map(e=>({lon:e.lon+t,lat:e.lat}))))}function KB(e,t,n={}){if(e.length<2)return``;let{projection:r}=t;return(n.closed&&r.cyclic?GB(e,r.centerLon):[e]).map(e=>{let{runs:r,whole:i}=VB(zB(e,n),t),a=!!n.closed&&i;return HB(r,t).map(e=>UB(e,a)).join(``)}).join(``)}function qB(e,t,n={}){let{projection:r}=t;if(!r.azimuthal)return KB(e,t,{...n,closed:!0});if(e.length<2)return``;let i=zB(e,{...n,closed:!0}),a=e.length>2?i.slice(0,-1):i,o=a.map(e=>r.forward(e.lon,e.lat)),s=([e,n])=>t.toScreen(e,n),c=o.filter(Boolean).length;if(c===0)return``;if(c===a.length)return UB(o.map(e=>s(e)),!0);let l=a.length,u=0;for(;!o[u]||o[(u+l-1)%l];)u++;let d=[],f=null;for(let e=0;e<l;e++){let t=(u+e)%l,n=(t+l-1)%l,i=o[t];if(i){if(!f){let e=BB(a[t],a[n],r);f=[r.forward(e.lon,e.lat)]}f.push(i)}else if(f){let e=BB(a[n],a[t],r);f.push(r.forward(e.lon,e.lat)),d.push(f),f=null}}let p=JB(a),m=([e,t])=>Math.atan2(t,e),h=Math.hypot(...d[0][0]),g=[],_=new Set;for(let e=0;e<d.length;e++){if(_.has(e))continue;let t=[],n=e;do{_.add(n),t.push(...d[n]);let r=m(d[n][d[n].length-1]),i=e,a=1/0;for(let e=0;e<d.length;e++){let t=m(d[e][0]),n=((p?t-r:r-t)%jB+jB)%jB;n<a&&(a=n,i=e)}let o=Math.ceil(a/MB);for(let e=1;e<o;e++){let n=r+(p?1:-1)*a*e/o;t.push([h*Math.cos(n),h*Math.sin(n)])}n=i}while(n!==e&&!_.has(n));g.push(t)}return g.map(e=>UB(e.map(s),!0)).join(``)}function JB(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n],i=e[(n+1)%e.length];t+=Kz(i.lon-r.lon)*AB*(2+Math.sin(r.lat*AB)+Math.sin(i.lat*AB))}let n=-t/2;return n>0?n<jB:n<-jB}function YB(e,t=2){let{projection:n}=e,r=179.999999,i=[],a=(r,a,o)=>{let s=a<o?t:-t;for(let t=a;s>0?t<=o:t>=o;t+=s){let a=n.forward(r,t);a&&i.push(e.toScreen(a[0],a[1]))}};return a(n.centerLon-r,-90,90),a(n.centerLon+r,90,-90),i.length<3?``:HB([i],e).map(e=>UB(e,!0)).join(``)}function XB(e,t,n,r){let i=n+r,a=[],o=(e,t,n)=>{let r=Math.max(1,Math.ceil(Math.abs(n-t)/5));for(let i=0;i<=r;i++)a.push({lon:t+(n-t)*i/r,lat:e})};return o(e,n,i),o(t,i,n),a}function ZB(e,t,n=128){let r=e.lat*AB,i=e.lon*AB,a=[Math.cos(r)*Math.cos(i),Math.cos(r)*Math.sin(i),Math.sin(r)],o=[-a[1],a[0],0],s=Math.hypot(o[0],o[1]);o=s<1e-9?[1,0,0]:[o[0]/s,o[1]/s,0];let c=[a[1]*o[2]-a[2]*o[1],a[2]*o[0]-a[0]*o[2],a[0]*o[1]-a[1]*o[0]],l=t*AB,u=Math.sin(l),d=Math.cos(l),f=[];for(let e=0;e<n;e++){let t=2*Math.PI*e/n,r=Math.sin(t)*u,i=Math.cos(t)*u,s=a[0]*d+o[0]*r+c[0]*i,l=a[1]*d+o[1]*r+c[1]*i,p=a[2]*d+o[2]*r+c[2]*i;f.push({lon:Kz(Math.atan2(l,s)*NB),lat:Math.atan2(p,Math.hypot(s,l))*NB})}return f}var QB=24;function $B(e=30){let t=[];for(let n=-180;n<180;n+=e)t.push([{lon:n,lat:-90},{lon:n,lat:90}]);let n=179.999999;for(let r=-90+e;r<90;r+=e){let e=[];for(let t=0;t<=QB;t++)e.push({lon:-n+2*n*t/QB,lat:r});t.push(e)}return t}var eV=.005,tV=1.5,nV=5,rV=24,iV=class{object=new za;body;altitudeKm;closed;interpolate;stepDeg;color;widthPx;opacity;fillColor;fillOpacity;dirs=new Float64Array;count=0;line=null;scratch=new Float32Array;alphas=new Float32Array;fanDirs=new Float64Array;fill=null;fillScratch=new Float32Array;turned=[0,0,0];wanted=!0;removeSelf=null;constructor(e){this.body=e.body,this.altitudeKm=e.altitudeKm??null,this.closed=e.closed??!1,this.interpolate=e.interpolate??`linear`,this.stepDeg=e.stepDeg,this.color=e.color??`#ffffff`,this.widthPx=e.widthPx??2,this.opacity=e.opacity??1,this.fillColor=e.fill??null,this.fillOpacity=e.fillOpacity??.25,this.object.matrixAutoUpdate=!1,this.setPoints(e.points)}bind(e){this.removeSelf=e}setPoints(e){let t=zB(e,{interpolate:this.interpolate,stepDeg:this.stepDeg,closed:this.closed});this.dirs=new Float64Array(t.length*3);for(let e=0;e<t.length;e++){let[n,r,i]=fR(t[e].lat,t[e].lon);this.dirs[e*3]=n,this.dirs[e*3+1]=r,this.dirs[e*3+2]=i}this.count=t.length,this.buildLine(),this.buildFill()}setVisible(e){this.wanted=e}remove(){this.removeSelf?.(),this.removeSelf=null}update({jd:e,basis:t,camera:n,ctx:r}){let i=this.wanted&&this.count>=2?r.getBody(this.body):void 0,a=i&&mR(i,r,e);if(this.line&&(this.line.visible=!!a),this.fill&&(this.fill.visible=!!a),!i||!a)return;let o=gn(i.data),s=Q(o+(this.altitudeKm??o*eV)),c=i.orientation?mC(i.orientation,e,i.nutPrec):null,l=[a[0]-t[0],a[1]-t[1],a[2]-t[2]];if(this.line&&(this.place(this.dirs,this.count,c,s,l,this.scratch),lN(this.line.geometry,this.scratch,this.alphas,this.alphas,this.count),this.line.material.uniforms.uCenterOffset.value.copy(n.position).negate()),this.fill){let e=this.fill.geometry.getAttribute(`position`);this.place(this.fanDirs,this.fillScratch.length/3,c,s,l,this.fillScratch),e.needsUpdate=!0,this.fill.material.uniforms.uCenterOffset.value.copy(n.position).negate()}}place(e,t,n,r,i,a){for(let o=0;o<t;o++){let t=o*3;n?pR(n,e[t],e[t+1],e[t+2],this.turned,0):(this.turned[0]=e[t],this.turned[1]=e[t+1],this.turned[2]=e[t+2]),a[t]=this.turned[0]*r+i[0],a[t+1]=this.turned[1]*r+i[1],a[t+2]=this.turned[2]*r+i[2]}}buildLine(){if(this.disposeLine(),this.count<2||this.widthPx<=0)return;this.scratch=new Float32Array(this.count*3),this.alphas=new Float32Array(this.count).fill(this.opacity);let e=fN(this.count,this.scratch,this.alphas,this.alphas,this.count,this.color,this.widthPx,1);e.frustumCulled=!1,e.renderOrder=tV,this.object.add(e),this.line=e}buildFill(){if(this.disposeFill(),!this.fillColor||this.count<3)return;let e=Fz(this.dirs,this.count),t=0;for(let n=0;n<this.count;n++){let r=e[0]*this.dirs[n*3]+e[1]*this.dirs[n*3+1]+e[2]*this.dirs[n*3+2];t=Math.max(t,Math.acos(Math.min(1,Math.max(-1,r))))}let n=Math.min(rV,Math.max(1,Math.ceil(t*180/Math.PI/nV))),r=1+n*this.count;this.fanDirs=new Float64Array(r*3),this.fanDirs[0]=e[0],this.fanDirs[1]=e[1],this.fanDirs[2]=e[2];for(let t=1;t<=n;t++)for(let r=0;r<this.count;r++){let[i,a,o]=Nz(e,[this.dirs[r*3],this.dirs[r*3+1],this.dirs[r*3+2]],t/n),s=(1+(t-1)*this.count+r)*3;this.fanDirs[s]=i,this.fanDirs[s+1]=a,this.fanDirs[s+2]=o}let i=[],a=(e,t)=>1+(e-1)*this.count+t;for(let e=0;e<this.count-1;e++)i.push(0,a(1,e),a(1,e+1));for(let e=1;e<n;e++)for(let t=0;t<this.count-1;t++){let n=a(e,t),r=a(e,t+1),o=a(e+1,t),s=a(e+1,t+1);i.push(n,o,r,r,o,s)}let o=new Ho;o.setAttribute(`position`,new Ao(new Float32Array(r*3),3)),o.setIndex(i),this.fillScratch=o.getAttribute(`position`).array;let s=new As(o,Iz(this.fillColor,this.fillOpacity));s.matrixAutoUpdate=!1,s.frustumCulled=!1,s.renderOrder=tV,this.object.add(s),this.fill=s}disposeLine(){this.line&&=(this.object.remove(this.line),this.line.geometry.dispose(),this.line.material.dispose(),null)}disposeFill(){this.fill&&=(this.object.remove(this.fill),this.fill.geometry.dispose(),this.fill.material.dispose(),null)}dispose(){this.disposeLine(),this.disposeFill()}},aV=class{object=new za;id;name;anchor;model;trueScale;spanScene;minPx;label;wanted=!0;removeSelf=null;constructor(e,t,n){this.id=t,this.name=e.name??null,this.anchor=e.position,this.object.matrixAutoUpdate=!1,this.object.frustumCulled=!1;let r=e.model;this.model=r?.object3d??null,this.minPx=r?.minPx??0;let i=r?oV(r.object3d):0;this.trueScale=r?.scaleM!==void 0&&i>0?Q(r.scaleM/1e3)/i:1,this.spanScene=i*this.trueScale,this.model&&this.object.add(this.model),this.label=e.label&&this.name?new Hz({anchor:e.position,text:this.name,align:[.5,1.4],occlude:e.occludeLabel},n):null,this.label&&this.object.add(this.label.object)}bind(e){this.removeSelf=e}get position(){return this.anchor}positionKm(e){let t=this.anchor;if(`latitude`in t)return null;let n=typeof t.offsetKm==`function`?t.offsetKm(e):t.offsetKm;return n===void 0?[0,0,0]:n}setPosition(e){this.anchor=e,this.label?.setAnchor(e)}setVisible(e){this.wanted=e,this.label?.setVisible(e)}remove(){this.removeSelf?.(),this.removeSelf=null}update(e){let{basis:t,camera:n,jd:r,ctx:i}=e,a=this.model,o=this.wanted?hR(this.anchor,i,r):null;if(this.label?.update(e),!a||(a.visible=o!==null,!o))return;a.position.set(o[0]-t[0],o[1]-t[1],o[2]-t[2]);let s=this.drawnScale(a.position,n,e.viewportPx);a.scale.setScalar(s),a.updateMatrixWorld(!0)}drawnScale(e,t,n){if(this.minPx<=0||this.spanScene<=0)return this.trueScale;let r=t.position.distanceTo(e);if(r<=0)return this.trueScale;let i=n/(2*Math.tan(t.fov*Math.PI/180/2)*r),a=this.spanScene*i;return a>=this.minPx?this.trueScale:this.trueScale*(this.minPx/a)}dispose(){this.label?.dispose(),this.model&&this.object.remove(this.model)}};function oV(e){let t=new co().setFromObject(e).getSize(new J);return Math.max(t.x,t.y,t.z)}var sV=class{byId=new Map;nextId=1;constructor(e,t){this.registry=e,this.canvas=t}add(e){let t=e.id??`object-${this.nextId++}`;this.byId.get(t)?.remove();let n=new aV(e,t,this.canvas()),r=this.registry();return n.bind(()=>{this.byId.delete(t),r.remove(n)}),this.byId.set(t,n),r.add(n),n}get(e){return this.byId.get(e)}all(){return[...this.byId.values()]}clear(){for(let e of[...this.byId.values()])e.remove()}};function cV(e,t,n,r){let i=hR(e,n,r),a=hR(t,n,r);return!i||!a?null:_R([a[0]-i[0],a[1]-i[1],a[2]-i[2]])}function lV(e,t,n,r){let i=cV(e,t,n,r);return i&&Math.hypot(...i)}function uV(e,t,n){let r=t.getBody(e),i=t.getBody(f_);if(!r||!i||r===i||!r.orientation&&!t.bodies.orientationRead.has(e))return null;let a=mR(r,t,n);if(!a)return null;let o=r.orientation?mC(r.orientation,n,r.nutPrec).toArray():[0,0,0,1],{latitude:s,longitude:c,distance:l}=aC([i.position[0],i.position[1],i.position[2]],[a[0],a[1],a[2]],o);return l>0?{lon:c,lat:s}:null}var dV=class{enabled;apply;constructor(e,t){this.enabled=e,this.apply=t}enable(){this.set(!0)}disable(){this.set(!1)}isEnabled(){return this.enabled}set(e){this.enabled!==e&&(this.enabled=e,this.apply?.(e))}};function fV(e,t){return e??t??!0}var pV=1400,mV=class{enabled;element=document.createElement(`div`);timer;constructor(e,t){this.enabled=t,this.element.className=`sm-cooperative-hint`,this.element.setAttribute(`aria-hidden`,`true`),e.append(this.element)}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e,e||this.hide()}allowsWheel(e){if(!this.enabled||e.ctrlKey||e.metaKey)return!0;let{cooperative_wheel:t,cooperative_wheel_mac:n}=a().messages;return this.show(hV()?n():t()),!1}allowsTouchDrag(e){return!this.enabled||e>1?!0:(this.show(a().messages.cooperative_touch()),!1)}dispose(){clearTimeout(this.timer),this.element.remove()}show(e){this.element.textContent=e,this.element.classList.add(`sm-cooperative-hint--shown`),clearTimeout(this.timer),this.timer=setTimeout(()=>this.hide(),pV)}hide(){clearTimeout(this.timer),this.element.classList.remove(`sm-cooperative-hint--shown`)}};function hV(){return/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent)}var gV={[W.BARYCENTER]:`barycenter`,[W.LAGRANGE_POINT]:`lagrange-point`,[W.STAR]:`star`,[W.PLANET]:`planet`,[W.DWARF_PLANET]:`dwarf-planet`,[W.MOON]:`moon`,[W.ASTEROID]:`asteroid`,[W.ASTEROID_INNER]:`asteroid`,[W.ASTEROID_MAIN_BELT]:`asteroid`,[W.ASTEROID_TROJAN]:`asteroid`,[W.ASTEROID_CENTAUR]:`asteroid`,[W.ASTEROID_TNO]:`asteroid`,[W.COMET]:`comet`,[W.SPACECRAFT]:`spacecraft`,[W.DEBRIS]:`debris`,[W.UNDOCUMENTED]:`unknown`,[W.SURFACE_FEATURE]:`surface-feature`},_V={[W.ASTEROID_INNER]:`inner`,[W.ASTEROID_MAIN_BELT]:`main-belt`,[W.ASTEROID_TROJAN]:`trojan`,[W.ASTEROID_CENTAUR]:`centaur`,[W.ASTEROID_TNO]:`tno`};function vV(e){let{id:t,name:n,objectType:r,parentId:i,radiusKm:a,unplaceable:o}=e.data,s={id:t,name:n,type:gV[r],parentId:i,radiusKm:Number.isFinite(a)&&a>0?a:null,placed:o!==!0&&e.positionUnknown!==!0},c=_V[r];return c&&(s.orbitClass=c),s}var yV=[`top-left`,`top-right`,`bottom-left`,`bottom-right`],bV=class{corners=new Map;added=new Map;constructor(e,t){this.map=e,this.root=t}add(e,t){if(this.added.has(e))return;let n=e.onAdd(this.map);this.added.set(e,n),this.corner(t??e.getDefaultPosition?.()??`top-right`).append(n)}remove(e){let t=this.added.get(e);t&&(this.added.delete(e),e.onRemove?.(this.map),t.remove())}clear(){for(let e of[...this.added.keys()])this.remove(e);for(let e of this.corners.values())e.remove();this.corners.clear()}corner(e){let t=this.corners.get(e);return t||(t=document.createElement(`div`),t.className=`sm-ctrl sm-ctrl--${e}`,this.corners.set(e,t),this.root.append(...yV.map(e=>this.corners.get(e)).filter(e=>e!==void 0)),t)}},xV=[(e,t)=>e.setReducedMotion(t.resolvedReducedMotion),(e,t)=>e.setImmersive(t.viewMode===`immersive`),(e,t)=>e.setHaloDebugVisible(t.showHaloDebug),(e,t)=>{t.atmosphereCalibration,e.applyRenderTier()}],SV=.05,CV=1.15,wV=2e3,TV=4e3,EV=new WeakMap,DV=new WeakMap,OV=class{ctx=new wS;clock;initialView;#e=qe(null);get renderer(){return Ut(this.#e)}set renderer(e){Je(this.#e,e)}#t=qe(!1);get webglError(){return Ut(this.#t)}set webglError(e){Je(this.#t,e,!0)}#n=qe(!1);get contextLost(){return Ut(this.#n)}set contextLost(e){Je(this.#n,e,!0)}#r=qe();get focusedBody(){return Ut(this.#r)}set focusedBody(e){Je(this.#r,e)}attribution=null;objects=new sV(()=>this.requireRenderer().extensions,()=>this.requireCanvas());dragRotate;scrollZoom;keyboard;bodySelect;featureSelect;cooperativeGestures;container=null;canvas=null;labelLayer=null;stopWatching=null;controls=null;lostPanelTimer;cooperative=null;limits={};initialFocusPending=!0;pendingFocusId=null;retireCameraHold=null;listeners={focuschange:new Set,camera:new Set,featureselect:new Set,userpromoted:new Set,contextlost:new Set,contextrestored:new Set,clock:new Set,loading:new Set,progress:new Set,error:new Set,datastale:new Set,notice:new Set,noticedismiss:new Set,layerschange:new Set,frame:new Set};constructor(e={}){e.settings&&Nx(e.settings),this.clock=new ES(Ng(e.date??new Date),e.live??e.date===void 0);let t=e.view??{};this.initialView={id:t.body??uC,latitude:t.lat??45,longitude:t.lon??0,zoom:t.distanceKm===void 0?15:Q(t.distanceKm)};let n=t=>new dV(fV(e.interactions?.[t],e.interactive),()=>this.applyGestures());this.dragRotate=n(`dragRotate`),this.scrollZoom=n(`scrollZoom`),this.keyboard=n(`keyboard`),this.bodySelect=n(`bodySelect`),this.featureSelect=n(`featureSelect`),this.cooperativeGestures=new dV(e.cooperativeGestures??!1,()=>this.applyGestures()),e.limits&&(this.limits={...e.limits}),this.ctx.layers=new Cv(e.layers),this.ctx.layers.onChange=()=>this.onLayerChange(),this.ctx.onDataStale=()=>this.emit(`datastale`),xz()}on(e,t){return this.listeners[e].add(t),()=>this.listeners[e].delete(t)}once(e,t){let n=(...e)=>{r(),t(...e)};DV.set(n,t);let r=this.on(e,n);return r}off(e,t){let n=this.listeners[e];n.delete(t);for(let e of n)DV.get(e)===t&&n.delete(e)}emit(e,...t){for(let n of this.listeners[e])n(...t)}getBody(e){let t=this.ctx.getBody(e);return t&&vV(t)}getFocusedBody(){let e=this.focusedBody;if(!e)return;let t=un(e)?this.ctx.getBody(e.featureAnchor.hostId):e;return t&&vV(t)}getChildren(e){return[...this.ctx.bodies.getChildren(e)??[]]}get placedJd(){let e=this.renderer?.placedJd;return e===void 0||Number.isNaN(e)?this.clock.jd:e}distanceKm(e,t){return lV(e,t,this.ctx,this.placedJd)}offsetKm(e,t){return cV(e,t,this.ctx,this.placedJd)}getSubsolarPoint(e){return uV(e,this.ctx,this.placedJd)}load(e=this.initialView.id){return this.ctx.load(Pg(this.clock.jd),e)}async open(e=this.initialView.id){let t=this.load(e);t.catch(()=>{});let n=!0,r=new Promise(t=>{let r=()=>{n&&(this.renderer&&this.ctx.getBody(e)?t():document.hidden?setTimeout(r,100):requestAnimationFrame(r))};r()});try{await Promise.race([t,r])}finally{n=!1}}applyInitialView(){let{id:e,latitude:t,longitude:n,zoom:r}=this.initialView;this.focusedBody||!this.ctx.getBody(e)||this.renderer?.snapToBody(e,t,n,r)}mount(e){if(this.container)throw Error(`SpaceMap is already mounted`);this.container=e,e.classList.add(`sm-map`),EV.set(e,(EV.get(e)??0)+1),this.controls=new bV(this,e);let t=document.createElement(`canvas`);t.className=`sm-map__canvas`,t.tabIndex=0,t.setAttribute(`role`,`application`),t.setAttribute(`aria-label`,a().messages.scene_canvas_label());let n=document.createElement(`div`);n.className=`scene-overlay`,e.append(t,n),this.canvas=t,this.labelLayer=n,this.cooperative=new mV(e,this.cooperativeGestures.isEnabled()),t.addEventListener(`keydown`,this.onKeyDown),t.addEventListener(`touchmove`,this.onTouchMove,{passive:!0}),e.addEventListener(`wheel`,this.onWheelCapture,{capture:!0,passive:!0}),t.addEventListener(`webglcontextlost`,this.onContextLost,!1),t.addEventListener(`webglcontextrestored`,this.onContextRestored,!1),document.addEventListener(`visibilitychange`,this.onVisibility);let r;try{r=new WR(t,n,this.ctx,this.clock,this.initialView,this.callbacks())}catch(e){console.error(`[scene] renderer init failed:`,e),this.webglError=!0;return}this.renderer=r,this.applyGestures(),this.applyLimits(),this.pendingFocusId!==null&&(r.focusOnBody(this.pendingFocusId),this.pendingFocusId=null);let i=new ResizeObserver(()=>r.resize(t.clientWidth,t.clientHeight));i.observe(t);let o=lt(()=>this.watch(r));this.stopWatching=()=>{i.disconnect(),o()}}addControl(e,t){if(!this.controls)throw Error(`spacemap: the map is not mounted`);return this.controls.add(e,t),this}removeControl(e){if(e===this.attribution)throw Error(`spacemap: the attribution control cannot be removed`);return this.controls?.remove(e),this}remove(){this.unmount()}unmount(){let{container:e,canvas:t}=this;if(!e||!t)return;this.controls?.clear(),this.controls=null,this.stopWatching?.(),this.stopWatching=null,clearTimeout(this.lostPanelTimer),t.removeEventListener(`keydown`,this.onKeyDown),t.removeEventListener(`touchmove`,this.onTouchMove),e.removeEventListener(`wheel`,this.onWheelCapture,{capture:!0}),this.cooperative?.dispose(),this.cooperative=null,t.removeEventListener(`webglcontextlost`,this.onContextLost),t.removeEventListener(`webglcontextrestored`,this.onContextRestored),document.removeEventListener(`visibilitychange`,this.onVisibility),this.retireCameraHold?.(),this.retireCameraHold=null,this.renderer?.dispose(),this.renderer=null,t.remove(),this.labelLayer?.remove();let n=(EV.get(e)??1)-1;EV.set(e,n),n===0&&e.classList.remove(`sm-map`),this.container=this.canvas=this.labelLayer=null}watch(e){st(()=>{this.ctx.bodies.minorBodyVersion,e.rebuildMinorPointClouds()});let t=Mx();for(let n of xV)st(()=>n(e,t));let n=this.clock;st(()=>{let{jd:e,playing:t,timeScale:r,direction:i,live:a}=n;this.listeners.clock.size!==0&&this.emit(`clock`,{jd:e,date:Pg(e),playing:t,timeScale:r,direction:i,live:a})}),st(()=>{let e=this.ctx.loading,t=KR.bootPending;this.emit(`loading`,e||t)}),st(()=>this.emit(`progress`,U_.value)),st(()=>{let e=this.ctx.error;e!==null&&this.emit(`error`,e)}),st(()=>{KR.progress===null?e.isContextLost()||e.resume():e.pause()})}applySettings(){let e=this.renderer;if(!e)return;let t=Mx();for(let n of xV)n(e,t)}callbacks(){return{notices:{notify:e=>this.emit(`notice`,e),dismiss:e=>this.emit(`noticedismiss`,e)},onFocusChange:e=>{let t=this.initialFocusPending;this.initialFocusPending=!1,this.focusedBody=e;let n=e!==void 0&&un(e);this.emit(`focuschange`,{body:this.getFocusedBody(),initial:t,feature:n})},onFrame:(e,t)=>{this.listeners.frame.size>0&&this.emit(`frame`,{jd:e,dtMs:t})},onCameraPosition:(e,t,n)=>{let r=this.focusedBody?.data.id;r!==void 0&&this.emit(`camera`,{body:r,lat:e,lon:t,distanceKm:cg(n)})},onUserPromotedChange:e=>this.emit(`userpromoted`,e),onFeatureSelect:(e,t,n,r,i)=>this.emit(`featureselect`,{bodyId:e,featureId:t,lat:n,lon:r,diameterM:i})}}onKeyDown=e=>{if(!this.keyboard.isEnabled()||e.ctrlKey||e.metaKey||e.altKey)return;let t=(e.shiftKey?4:1)*SV,n=0,r=0,i=1;switch(e.key){case`ArrowLeft`:n=t;break;case`ArrowRight`:n=-t;break;case`ArrowUp`:r=t;break;case`ArrowDown`:r=-t;break;case`+`:case`=`:i=CV;break;case`-`:case`_`:i=1/CV;break;default:return}e.preventDefault(),this.renderer?.nudgeCamera(n,r,i)};onContextLost=e=>{e.preventDefault(),console.warn(`[scene] WebGL context lost`),this.renderer?.pause(),clearTimeout(this.lostPanelTimer),this.lostPanelTimer=setTimeout(()=>{this.contextLost=!0,this.emit(`contextlost`)},wV)};onContextRestored=()=>{console.warn(`[scene] WebGL context restored`),clearTimeout(this.lostPanelTimer),this.contextLost=!1,this.renderer?.handleContextRestored(),this.renderer?.recoverWorkersIfDead(TV),this.emit(`contextrestored`)};onVisibility=()=>{document.visibilityState===`visible`&&(this.renderer?.isContextLost()||this.renderer?.recoverWorkersIfDead())};flyTo(e){let t=this.targetBody(e);return e.feature?this.toFeature(t,e.feature,`frame`):this.settled(this.focusOnBody(t,this.framing(e,t),e.lat,e.lon))}panTo(e){return this.toFeature(this.targetBody(e),e.feature,`pan`)}jumpTo(e){let t=this.targetBody(e);if(e.facing!==void 0)return this.snapToBodyFacing(t,e.facing,e.elevationDeg??0,this.framing(e,t)),this;if(e.feature){let{featureId:n,lat:r,lon:i,diameterM:a}=e.feature;return this.focusOnFeature(t,n,r,i,a,null,`snap`),this}let n=this.getCamera();return this.snapToBody(t,e.lat??n?.lat??45,e.lon??n?.lon??0,this.framing(e,t)),this}getCamera(){let e=this.renderer,t=this.focusedBody?.data.id;if(!e||t===void 0)return null;let{latitude:n,longitude:r,distance:i}=e.getCameraState();return{body:t,lat:n,lon:r,distanceKm:cg(i)}}setLayerVisible(e,t){return this.ctx.layers.setVisible(e,t),this}isLayerVisible(e){return this.ctx.layers.isVisible(e)}getLayers(){return[...gv]}onLayerChange(){for(let e of this.ctx.bodies.spacecraftByParent.keys())this.ctx.bodies.dirtySpacecraftGroups.add(e);this.ctx.bodies.minorBodyVersion++,this.emit(`layerschange`,gv.filter(e=>this.ctx.layers.isVisible(e)))}setLimits(e){return this.limits={...e},this.applyLimits(),this}getLimits(){return{...this.limits}}applyLimits(){let e=this.limits,t={};e.minDistanceKm!==void 0&&(t.minDistance=Q(e.minDistanceKm)),e.maxDistanceKm!==void 0&&(t.maxDistance=Q(e.maxDistanceKm)),e.minLat!==void 0&&(t.minLat=e.minLat),e.maxLat!==void 0&&(t.maxLat=e.maxLat),e.minLon!==void 0&&(t.minLon=e.minLon),e.maxLon!==void 0&&(t.maxLon=e.maxLon);let n=Object.keys(t).length>0;this.renderer?.setCameraLimits(n?t:null,e.bodies??null)}applyGestures(){let e=this.cooperativeGestures.isEnabled();this.cooperative?.setEnabled(e);let t=this.renderer;t&&(t.setDragEnabled(this.dragRotate.isEnabled()),t.setZoomEnabled(this.scrollZoom.isEnabled()),t.setBodySelectEnabled(this.bodySelect.isEnabled()),t.setFeatureSelectEnabled(this.featureSelect.isEnabled()),t.setCooperativeTouch(e))}onWheelCapture=e=>{this.scrollZoom.isEnabled()&&this.cooperative&&!this.cooperative.allowsWheel(e)&&e.stopPropagation()};onTouchMove=e=>{this.cooperative?.allowsTouchDrag(e.touches.length)};toFeature(e,t,n){let{featureId:r,lat:i,lon:a,diameterM:o}=t;return this.settled(this.focusOnFeature(e,r,i,a,o,null,n))}settled(e){return new Promise(t=>{setTimeout(()=>requestAnimationFrame(()=>t()),e)})}targetBody(e){let t=e.body??this.focusedBody?.data.id;if(t===void 0)throw Error(`spacemap: no body to move to, and none focused`);return t}framing(e,t){if(e.distanceKm!==void 0)return Q(e.distanceKm);let n=this.ctx.getBody(t);return n&&n.data.radiusKm>0?XL(n)*5:this.renderer?.getCameraState().distance??15}focusOnBody(e,t,n,r){return this.renderer?this.renderer.focusOnBody(e,t,n,r):(this.pendingFocusId=e,0)}snapToBody(e,t,n,r){this.renderer?.snapToBody(e,t,n,r)}snapToBodyFacing(e,t,n,r){this.renderer?.snapToBodyFacing(e,t,n,r)}focusOnFeature(e,t,n,r,i,a,o=`frame`,s=null){let c=this.ctx.getBody(e);if(!c)return 0;let l=Q(i*4/1e3),u=Q(.02),d=Q(gn(c.data)*5),f=Math.min(Math.max(l,u),d),p={hostId:e,featureId:t,lat:n,lon:r,diameterM:i};return this.renderer?.focusOnFeature(p,a,f,o,s)??0}setFocusTarget(e,t){this.renderer?.setFocusTarget(e,t)}getPose(){let e=this.renderer,t=this.focusedBody;if(!e||!t)return null;let n=t.data.id;return{position:{body:n,offsetKm:_R(e.cameraOffsetFromFocus())},target:{body:n}}}holdCamera(){let e=this.renderer;if(!e)throw Error(`SpaceMap is not mounted`);this.retireCameraHold?.(),e.holdCamera();let t=!0,n=()=>{t=!1};return this.retireCameraHold=n,{get held(){return t},set:n=>{t&&e.setHeldPose(n)},release:()=>{t&&(n(),this.retireCameraHold=null,e.releaseCamera())}}}addMarker(e){return this.track(new Tz(e,this.requireCanvas()))}addPolyline(e){return this.track(new Dz(e))}addPolygon(e){return this.track(new Bz({fill:e.color??`#ffffff`,...e}))}addCircle(e){return this.track(new Vz(e))}addLabel(e){return this.track(new Hz(e,this.requireCanvas()))}addIcon(e){return this.track(new Uz(e,this.requireCanvas()))}addSurfacePolyline(e){return this.track(new iV(e))}addSurfacePolygon(e){return this.track(new iV({fill:e.color??`#ffffff`,...e,closed:!0}))}addSurfaceCircle(e){return this.addSurfacePolygon({...e,points:ZB(e.center,this.capRadiusDeg(e),e.steps)})}clearDrawings(){this.renderer?.extensions.clear(e=>e instanceof aV)}setBodyAppearance(e,t){return this.requireRenderer().setBodyAppearance(e,t),this}capRadiusDeg(e){if(e.radiusDeg!==void 0)return e.radiusDeg;let t=this.getBody(e.body)?.radiusKm;return e.radiusKm!==void 0&&t?e.radiusKm/t*(180/Math.PI):1}track(e){let t=this.requireRenderer();return e.bind(()=>t.extensions.remove(e)),t.extensions.add(e),e}requireCanvas(){let e=this.canvas;if(!e)throw Error(`SpaceMap is not mounted`);return e}requireRenderer(){let e=this.renderer;if(!e)throw Error(`SpaceMap is not mounted`);return e}setNorthReference(e){this.renderer?.setNorthReference(e)}setUserLocation(e,t){this.renderer?.setUserLocation(e,t)}clearUserPromoted(){this.renderer?.clearUserPromoted()}setSelectedFeature(e){this.renderer?.setSelectedFeature(e)}setTravelPath(e,t=[],n=[],r=[]){this.renderer?.setTravelPath(e,t,n,r)}setOrbitPreview(e,t){this.renderer?.setOrbitPreview(e,t)}setTravelHover(e){this.renderer?.setTravelHover(e)}focusOnPathPoint(e,t){this.renderer?.focusOnPathPoint(e,t)}trackPathPoint(e,t){this.renderer?.trackPathPoint(e,t)}setCovered(e){this.renderer?.setCovered(e)}},kV=`http://www.w3.org/2000/svg`;function AV(e){return{id:e.id,label:e.label,kind:e.kind,visible:e.visible,credit:e.credit}}function jV(e){return{organisation:e.organisation,source:e.source,attribution:e.attribution}}function MV(e,t){let n=document.createElementNS(kV,`path`);return n.setAttribute(`d`,e),n.setAttribute(`class`,t),n}function NV(e,t=30){return{kind:`vector`,id:`graticule`,label:e,visible:!1,render(e,n){for(let r of $B(t)){let t=KB(r,e,{stepDeg:2});t&&n.append(MV(t,`sm-flat__graticule`))}if(e.projection.azimuthal){let t=e.toScreen(0,0),r=e.toScreen(e.projection.extent.maxX,0),i=document.createElementNS(kV,`circle`);i.setAttribute(`cx`,String(t[0])),i.setAttribute(`cy`,String(t[1])),i.setAttribute(`r`,String(Math.abs(r[0]-t[0]))),i.setAttribute(`class`,`sm-flat__frame`),n.append(i)}else{let t=YB(e);t&&n.append(MV(t,`sm-flat__frame`))}}}}var PV=120;function FV(e,t){let n=[];return{kind:`vector`,id:`nomenclature`,label:t,visible:!1,credit:{organisation:`IAU`,source:`https://planetarynames.wr.usgs.gov/`},async prepare(){n.length||(n=[...await vM(e)].sort((e,t)=>t.diameterM-e.diameterM).slice(0,PV))},render(e,t){let r=e.repeatShifts;for(let i of n){let n=e.project(i.lon,i.lat);if(!(!n||n[1]<0||n[1]>e.height))for(let a of r){let r=n[0]+a;if(r<0||r>e.width)continue;let o=document.createElementNS(kV,`circle`);o.setAttribute(`cx`,r.toFixed(1)),o.setAttribute(`cy`,n[1].toFixed(1)),o.setAttribute(`r`,`1.6`),o.setAttribute(`class`,`sm-flat__feature-dot`);let s=document.createElementNS(kV,`text`);s.setAttribute(`x`,(r+4).toFixed(1)),s.setAttribute(`y`,(n[1]+3).toFixed(1)),s.setAttribute(`class`,`sm-flat__feature-label`),s.textContent=i.name,t.append(o,s)}}}}}function IV(e,t){e.setAttribute(`fill`,t.fill??`none`),t.fill&&t.fillOpacity!==void 0&&e.setAttribute(`fill-opacity`,String(t.fillOpacity)),e.setAttribute(`stroke`,t.color??`#ffffff`),e.setAttribute(`stroke-width`,String(t.widthPx??2)),e.setAttribute(`stroke-linejoin`,`round`),e.setAttribute(`stroke-linecap`,`round`),t.opacity!==void 0&&e.setAttribute(`opacity`,String(t.opacity)),t.dash&&e.setAttribute(`stroke-dasharray`,t.dash),t.className&&e.setAttribute(`class`,t.className),e.style.pointerEvents=t.interactive?`auto`:`none`,t.ariaLabel&&(e.setAttribute(`role`,`img`),e.setAttribute(`aria-label`,t.ariaLabel))}function LV(e,t){t.onclick&&e.addEventListener(`click`,t.onclick),t.onpointerenter&&e.addEventListener(`pointerenter`,t.onpointerenter),t.onpointerleave&&e.addEventListener(`pointerleave`,t.onpointerleave)}var RV=class{node;area;edge;points;visible=!0;constructor(e,t,n,r,i,a){this.closed=n,this.interpolate=r,this.onRemove=i,this.onChange=a,this.points=e,this.node=document.createElementNS(kV,`g`),IV(this.node,t),LV(this.node,t),this.area=n?document.createElementNS(kV,`path`):null,this.area?.setAttribute(`stroke`,`none`),this.edge=document.createElementNS(kV,`path`),this.edge.setAttribute(`fill`,`none`),this.area&&this.node.append(this.area),this.node.append(this.edge)}redraw(e){if(!this.visible)return;let t={closed:this.closed,interpolate:this.interpolate};this.edge.setAttribute(`d`,KB(this.points,e,t)),this.area?.setAttribute(`d`,qB(this.points,e,t))}setPoints(e){this.points=e,this.onChange()}setVisible(e){this.visible=e,this.node.style.display=e?``:`none`,this.onChange()}detach(){this.node.remove()}remove(){this.onRemove(this)}},zV=class{element;at;visible=!0;align;constructor(e,t,n){this.onRemove=t,this.onChange=n,this.at=e.at,this.align=e.align??[.5,.5],this.element=e.element??document.createElement(`div`),e.element||(this.element.className=`sm-flat__marker-dot`),e.className&&this.element.classList.add(e.className),this.element.style.position=`absolute`,this.element.style.left=`0`,this.element.style.top=`0`,this.element.style.pointerEvents=e.interactive?`auto`:`none`}redraw(e){let t=this.visible?e.project(this.at.lon,this.at.lat):null;if(this.element.style.display=t?``:`none`,!t)return;let n=e.repeatShifts.find(n=>t[0]+n>=0&&t[0]+n<=e.width)??0;this.element.style.transform=`translate(${t[0]+n}px, ${t[1]}px) translate(${-this.align[0]*100}%, ${-this.align[1]*100}%)`}setPosition(e){this.at=e,this.onChange()}setVisible(e){this.visible=e,this.onChange()}detach(){this.element.remove()}remove(){this.onRemove(this)}},BV=class{drawings=new Set;constructor(e,t,n=()=>{},r=null){this.shapes=e,this.markers=t,this.onChange=n,this.radiusKm=r}setBodyRadiusKm(e){this.radiusKm=e}track(e,t){return this.drawings.add(e),t instanceof HTMLElement?this.markers.append(t):this.shapes.append(t),e}drop=e=>{this.drawings.delete(e)&&e.detach()};addPolyline(e){let t=new RV(e.points,e,e.closed??!1,e.interpolate??`linear`,this.drop,this.onChange);return this.track(t,t.node)}addPolygon(e){let t=new RV(e.points,{fill:`rgb(255 255 255 / 25%)`,...e},!0,e.interpolate??`linear`,this.drop,this.onChange);return this.track(t,t.node)}addBox(e){let t=new RV(XB(e.latMin,e.latMax,e.lonMin,e.lonSpan),{fill:`rgb(255 255 255 / 15%)`,...e},!0,`linear`,this.drop,this.onChange);return this.track(t,t.node)}addCircle(e){let t=this.circleRadiusDeg(e),n=new RV(ZB(e.center,t),{fill:`rgb(255 255 255 / 20%)`,...e},!0,`linear`,this.drop,this.onChange);return this.track(n,n.node)}circleRadiusDeg(e){return e.radiusDeg===void 0?e.radiusKm!==void 0&&this.radiusKm?e.radiusKm/this.radiusKm*(180/Math.PI):1:e.radiusDeg}addMarker(e){let t=new zV(e,this.drop,this.onChange);return this.track(t,t.element)}redraw(e){for(let t of this.drawings)t.redraw(e)}clear(){for(let e of this.drawings)e.detach();this.drawings.clear()}};function VV(e){let t=`width`in e?e.width:e.codedWidth,n=`height`in e?e.height:e.codedHeight;return typeof t!=`number`||typeof n!=`number`||!t||!n?null:[t,n]}function HV(e,t){let[n,r]=VV(e)??[t,t/2],i=Math.max(2,Math.min(n,Math.round(t))),a=Math.max(1,Math.round(i*r/n)),o=document.createElement(`canvas`);o.width=i,o.height=a;let s=o.getContext(`2d`,{willReadFrequently:!0});if(!s)return null;s.imageSmoothingEnabled=!0,s.imageSmoothingQuality=`high`,s.drawImage(e,0,0,i,a);try{let{data:e}=s.getImageData(0,0,i,a);return{width:i,height:a,data:e}}catch{return null}}var UV=class{width;height;u;v;inside;constructor(e,t,n){this.width=t,this.height=n;let r=t*n;this.u=new Float32Array(r),this.v=new Float32Array(r),this.inside=new Uint8Array(r);let{projection:i}=e,a=1/e.scale,o=e.view.centerX-e.width/2*a,s=e.view.centerY+e.height/2*a;for(let r=0;r<n;r++){let n=s-(r+.5)*a,c=r*t;i.rowInverse?this.fillRow(i,c,n,o,a,e):this.walkRow(i,c,n,o,a)}}fillRow(e,t,n,r,i,a){let o=e.rowInverse(n);if(!o)return;let{width:s}=this,c=(90-o.lat)/180,{minX:l,maxX:u}=e.extent,d=u-l,f=a.repeatsHorizontally;for(let n=0;n<s;n++){let a=r+(n+.5)*i;if(f)a=((a-l)%d+d)%d+l;else if(a<l||a>u)continue;if(a<-o.maxAbsX||a>o.maxAbsX)continue;let s=(a*o.lonPerX+e.centerLon+180)/360,p=t+n;this.u[p]=s-Math.floor(s),this.v[p]=c,this.inside[p]=1}}walkRow(e,t,n,r,i){let{width:a}=this,o=0,s=a-1;if(e.azimuthal){let t=e.extent.maxX;if(Math.abs(n)>t)return;let c=Math.sqrt(t*t-n*n);o=Math.max(0,Math.ceil((-c-r)/i-.5)),s=Math.min(a-1,Math.floor((c-r)/i-.5))}for(let a=o;a<=s;a++){let o=r+(a+.5)*i,s=e.inverse(o,n);if(!s)continue;let c=t+a;this.u[c]=(s[0]+180)/360,this.v[c]=(90-s[1])/180,this.inside[c]=1}}};function WV(e,t,n){let r=n.data;r.fill(0);let{width:i,height:a,u:o,v:s,inside:c}=e,l=i*a;for(let e of t){let{image:t,opacity:n,blend:i}=e;if(n<=0)continue;let a=t.data,u=t.width,d=t.height,f=i===`add`;for(let e=0;e<l;e++){if(!c[e])continue;let t=Math.floor(o[e]*u),i=Math.floor(s[e]*d);t=t<0?t+u:t>=u?t-u:t,i=i<0?0:i>=d?d-1:i;let l=(i*u+t)*4,p=a[l+3]/255*n;if(p<=0)continue;let m=e*4;if(f){r[m]=Math.min(255,r[m]+a[l]*p),r[m+1]=Math.min(255,r[m+1]+a[l+1]*p),r[m+2]=Math.min(255,r[m+2]+a[l+2]*p);continue}let h=r[m+3]/255,g=p+h*(1-p);if(!(g<=0)){if(p>=1)r[m]=a[l],r[m+1]=a[l+1],r[m+2]=a[l+2];else{let e=h*(1-p);r[m]=(a[l]*p+r[m]*e)/g,r[m+1]=(a[l+1]*p+r[m+1]*e)/g,r[m+2]=(a[l+2]*p+r[m+2]*e)/g}r[m+3]=g*255}}}}function GV(e,t,n){let{minX:r,maxX:i,minY:a,maxY:o}=t.projection.extent,s=t.projection.centerLon*Math.PI/180,[c,l]=t.toScreen(r-s,o),[u,d]=t.toScreen(i-s,a),f=t.repeatsHorizontally?0:t.toScreen(r,o)[0],p=t.repeatsHorizontally?e.canvas.width:t.toScreen(i,o)[0];e.save(),e.imageSmoothingEnabled=!0,e.imageSmoothingQuality=`high`;for(let t of n){if(t.opacity<=0)continue;let n=VV(t.image),r=n&&e.createPattern(t.image,`repeat-x`);r&&(r.setTransform(new DOMMatrix().translateSelf(c,l).scaleSelf((u-c)/n[0],(d-l)/n[1])),e.globalAlpha=t.opacity,e.globalCompositeOperation=t.blend===`add`?`lighter`:`source-over`,e.fillStyle=r,e.fillRect(f,l,p-f,d-l))}e.restore()}var KV=[`low`,`medium`,`high`];function qV(e){let t=/^naif-(\d)\d\d$/.exec(e);return t?`naif-${t[1]}`:null}async function JV(e){try{let t=await fetch(e);return t.ok?await t.json():null}catch{return null}}async function YV(e){let t=await Promise.all(KV.map(t=>fetch(Yt(`/v1/textures/${e}/${t}.webp`,`textures`),{method:`HEAD`}).then(e=>e.ok).catch(()=>!1)));return KV.filter((e,n)=>t[n])}async function XV(e,t,n=YV){if(!t?.map_texture_available||!t.texture)return{};let r=s([{...t.texture,id:e,tiers:void 0},...t.alternates??[]]);if(!r)return{};let i=r.tiers??await n(r.id);if(i.length===0)return{};let{frames:a,...o}=r,c=t.radii;return{surface:{...o,tiers:i,monthlyFrames:a},radiusKm:c?(c.a+c.b+c.c)/3:void 0}}async function ZV(e){return XV(e,(await hx(e,!1).catch(()=>null))?.global)}async function QV(e){let t=qV(e);if(!t)return ZV(e);let n=(await JV(`${Kt()}/v1/systems/${t}.json`))?.[e];if(!n?.texture||!n.tiers?.length)return ZV(e);let r=s([{...n.texture,id:e,tiers:n.tiers},...n.alternates??[]]);if(!r)return ZV(e);let{frames:i,...a}=r,o=n.radii;return{surface:{...a,monthlyFrames:i},clouds:n.clouds,night:n.night,radiusKm:o?(o.a+o.b+o.c)/3:void 0}}var $V={low:2048,medium:8192,high:16383};function eH(e){return KV.find(t=>$V[t]>=e)??KV[KV.length-1]}function tH(e,t){return KV.indexOf(e)<=KV.indexOf(t)?e:t}function nH(e,t){let n=KV.indexOf(t);for(let t=n<0?KV.length-1:n;t>=0;t--)if(e.includes(KV[t]))return KV[t];return e[0]??`low`}function rH(e,t,n){let r=e.id;if(e.frames?.length){let i=kj(n,e.frames,e.coverage);if(i)return Yt(`/v1/textures/${r}/${t}_${i}.webp`,`textures`)}let i=tM(n,e.monthlyFrames);return Yt(i===void 0?`/v1/textures/${r}/${t}.webp`:`/v1/textures/${r}/${t}_${String(i).padStart(2,`0`)}.webp`,`textures`)}function iH(e,t){return e*t*4}function aH(){let e=navigator.deviceMemory??4;return Math.max(1,Math.min(e,8))*24*1024*1024}var oH=class{entries=new Map;clock=0;constructor(e){this.free=e}claim(e){let t=this.entries.get(e);return t?(t.claims++,t.used=++this.clock,t.value):null}put(e,t,n){let r=this.entries.get(e);return r?(r.value!==t&&this.free(t),r.claims++,r.used=++this.clock,r.value):(this.entries.set(e,{value:t,bytes:n,claims:1,used:++this.clock}),this.evict(),t)}release(e){let t=this.entries.get(e);t&&(t.claims=Math.max(0,t.claims-1),this.evict())}evict(){let e=0;for(let t of this.entries.values())t.claims||(e+=t.bytes);let t=aH();if(e<=t)return;let n=[...this.entries].filter(([,e])=>!e.claims).sort((e,t)=>e[1].used-t[1].used);for(let[r,i]of n){if(e<=t)return;this.entries.delete(r),this.free(i.value),e-=i.bytes}}clear(){for(let e of this.entries.values())this.free(e.value);this.entries.clear()}},sH=new oH(e=>e.close()),cH=new oH(()=>{}),lH=new Map;function uH(e,t){return t?`${e}@${t}`:e}async function dH(e,t){let n=uH(e,t),r=sH.claim(n);if(r)return{key:n,bitmap:r};let i=lH.get(n);i||(i=fH(e,t),lH.set(n,i),i.finally(()=>lH.delete(n)));let a=await i;return a?{key:n,bitmap:sH.put(n,a,iH(a.width,a.height))}:null}async function fH(e,t){let n=await fetch(e);if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.blob();if(!t)return createImageBitmap(r);try{return await createImageBitmap(r,{resizeWidth:t,resizeQuality:`high`})}catch{return createImageBitmap(r)}}function pH(e){sH.release(e)}function mH(e,t,n){let r=uH(e,t),i=cH.claim(r);if(i)return{key:r,raster:i};let a=HV(n,t);return a?{key:r,raster:cH.put(r,a,iH(a.width,a.height))}:null}function hH(e){cH.release(e)}function gH(e,t,n){return[lC(e,n.minLon,n.maxLon),Math.min(Math.max(t,n.minLat??-90),n.maxLat??90)]}var _H=class{projection;width;height;view;scale;constructor(e,t,n,r){this.projection=e,this.width=t,this.height=n,this.view=r;let{minX:i,maxX:a,minY:o,maxY:s}=e.extent,c=Math.min(t/(a-i),n/(s-o));this.scale=c*r.zoom}toScreen(e,t){return[this.width/2+(e-this.view.centerX)*this.scale,this.height/2-(t-this.view.centerY)*this.scale]}fromScreen(e,t){return[this.view.centerX+(e-this.width/2)/this.scale,this.view.centerY-(t-this.height/2)/this.scale]}project(e,t){let n=this.projection.forward(e,t);return n?this.toScreen(n[0],n[1]):null}unproject(e,t){let[n,r]=this.fromScreen(e,t);return this.projection.inverse(n,r)}get worldWidthPx(){let{minX:e,maxX:t}=this.projection.extent;return(t-e)*this.scale}get repeatsHorizontally(){return vH(this.projection,this.worldWidthPx,this.width)}get repeatShifts(){if(!this.repeatsHorizontally)return[0];let e=this.worldWidthPx,t=this.toScreen(this.projection.extent.minX,0)[0];return[0,-e,e].filter(n=>t+n<this.width&&t+n+e>0)}};function vH(e,t,n){return e.cyclic&&e.rectangular&&t>=n-.5}function yH(e,t,n,r,i){let a=Math.min(Math.max(e.zoom,1,i.minZoom??1),i.maxZoom??1/0),o=bH(e,t,i),s=t.extent,c=s.maxX-s.minX,l=s.maxY-s.minY,u=Math.min(n/c,r/l)*a,d=n/2/u,f=r/2/u,p=(s.minX+s.maxX)/2,m=(s.minY+s.maxY)/2,h=(e,t,n,r)=>n>=r/2?t:Math.min(t+r/2-n,Math.max(t-r/2+n,e));return{zoom:a,centerX:vH(t,c*u,n)?((o.centerX-s.minX)%c+c)%c+s.minX:h(o.centerX,p,d,c),centerY:h(o.centerY,m,f,l)}}function bH(e,t,n){if(!(n.minLon!==void 0||n.maxLon!==void 0||n.minLat!==void 0||n.maxLat!==void 0)||t.azimuthal)return e;let r=t.inverse(e.centerX,e.centerY);if(!r)return e;let[i,a]=gH(r[0],r[1],n);if(i===r[0]&&a===r[1])return e;let o=t.forward(i,a);return o?{centerX:o[0],centerY:o[1]}:e}var xH=[[6,`high`],[2.5,`medium`]],SH=22e5,CH=4096,wH=11,TH=.4,EH=.8,DH=140,OH=`naif-399`,kH=[{kind:`surface`,label:e=>e.layer_surface(),visible:!0,opacity:1,blend:`normal`},{kind:`clouds`,label:e=>e.layer_clouds(),visible:!0,opacity:1,blend:`normal`},{kind:`night`,label:e=>e.layer_night(),visible:!1,opacity:.85,blend:`add`}];function AH(e){return e.kind===`raster`}var jH=new WeakMap,MH=class{container=null;root=document.createElement(`div`);canvas=document.createElement(`canvas`);svg=document.createElementNS(kV,`svg`);layerGroup=document.createElementNS(kV,`g`);shapeGroup=document.createElementNS(kV,`g`);markerLayer=document.createElement(`div`);ctx;overlay;bodyId;sources={};layerList=[];projection;projectionId;projectionOptions;view;limits;limitsArmed=!1;jd;cooperative=null;bodyRadiusKm=null;bitmaps=new Map;rasters=new Map;pending=new Set;missing=new Set;generation=0;controls=null;attribution=null;dragPan;scrollZoom;cooperativeGestures;lookup=null;lookupKey=``;buffer=null;frame=0;resizeObserver=null;listeners=new Map;announcedReady=!1;disposed=!1;moving=!1;sharpWidth=0;msPerPixel=0;settleTimer=0;chosenVisibility=new Map;customLayers=[];constructor(e={}){this.bodyId=e.body??OH,this.projectionId=e.projection??`equirectangular`,this.projectionOptions={centerLon:e.centerLon??0,centerLat:e.centerLat,clipAngle:e.clipAngle},this.projection=kB(this.projectionId,this.projectionOptions),this.limits={maxZoom:16,...e.limits},this.view={zoom:e.zoom??1,centerX:0,centerY:0},this.jd=e.jd??Ng(new Date),this.dragPan=new dV(fV(e.interactions?.dragPan,e.interactive),e=>this.root.classList.toggle(`sm-flat--interactive`,e)),this.scrollZoom=new dV(fV(e.interactions?.scrollZoom,e.interactive)),this.cooperativeGestures=new dV(e.cooperativeGestures??!1,e=>this.applyCooperative(e)),this.root.className=`sm-flat`,this.canvas.className=`sm-flat__raster`,this.svg.setAttribute(`class`,`sm-flat__vector`),this.markerLayer.className=`sm-flat__markers`,this.svg.append(this.layerGroup,this.shapeGroup),this.root.append(this.canvas,this.svg,this.markerLayer),this.ctx=this.canvas.getContext(`2d`),this.overlay=new BV(this.shapeGroup,this.markerLayer,()=>this.render()),this.root.classList.toggle(`sm-flat--interactive`,this.dragPan.isEnabled()),this.applyCooperative(this.cooperativeGestures.isEnabled());for(let[t,n]of Object.entries(e.layers??{}))this.chosenVisibility.set(t,n)}mount(e){this.container=e,e.append(this.root),this.controls=new bV(this,this.root),this.cooperative=new mV(this.root,this.cooperativeGestures.isEnabled()),this.resizeObserver=new ResizeObserver(()=>this.renderMoving()),this.resizeObserver.observe(this.root),this.attachInteraction()}addControl(e,t){if(!this.controls)throw Error(`spacemap: the map is not mounted`);return this.controls.add(e,t),this}removeControl(e){if(e===this.attribution)throw Error(`spacemap: the attribution control cannot be removed`);return this.controls?.remove(e),this}remove(){this.unmount()}unmount(){this.disposed=!0,this.controls?.clear(),this.controls=null,this.cooperative?.dispose(),this.cooperative=null,this.resizeObserver?.disconnect(),this.resizeObserver=null,cancelAnimationFrame(this.frame),clearTimeout(this.settleTimer);for(let e of this.layerList)AH(e)||e.dispose?.();this.overlay.clear(),this.dropTextures(),this.root.remove(),this.container=null}async load(){await this.adopt(this.bodyId)}async adopt(e){let t=await QV(e);if(!this.disposed){if(!t.surface){let t=Error(`spacemap: no map texture for ${e}`);throw this.emit(`error`,t),t}e!==this.bodyId&&this.release(),this.bodyId=e,this.sources=t,this.bodyRadiusKm=t.radiusKm??null,this.overlay.setBodyRadiusKm(this.bodyRadiusKm),this.buildLayers(),await this.loadVisible(),!this.disposed&&this.render()}}release(){this.generation++,this.dropTextures(),this.missing.clear();for(let e of this.layerList)!AH(e)&&!this.customLayers.includes(e)&&e.dispose?.()}buildLayers(){let{messages:e}=a(),t=[];for(let n of kH){let r=this.sources[n.kind];r&&t.push({kind:`raster`,id:n.kind,label:n.label(e),visible:n.visible,opacity:n.opacity,blend:n.blend,credit:jV(r),tiers:r.tiers,url:(e,t)=>rH(r,t,e)})}t.push(NV(e.layer_graticule())),t.push(FV(this.bodyId,e.layer_nomenclature())),t.push(...this.customLayers);for(let e of t){let t=this.chosenVisibility.get(e.id);t!==void 0&&(e.visible=t)}this.layerList=t,this.emit(`layerschange`,this.layers)}get layers(){return this.layerList.map(AV)}getLayers(){return this.layerList.map(e=>e.id)}isLayerVisible(e){return this.layerList.find(t=>t.id===e)?.visible??!1}get credits(){let e=new Set,t=[];for(let n of this.layerList)!n.visible||!n.credit||e.has(n.credit.organisation)||(e.add(n.credit.organisation),t.push(n.credit));return t}setLayerVisible(e,t){this.chosenVisibility.set(e,t);let n=this.layerList.find(t=>t.id===e);!n||n.visible===t||(n.visible=t,this.emit(`layerschange`,this.layers),this.loadVisible(),this.render())}setLayerOpacity(e,t){let n=this.layerList.find(t=>t.id===e);!n||!AH(n)||(n.opacity=Math.min(1,Math.max(0,t)),this.render())}addRasterLayer(e){let t={kind:`raster`,id:e.id,label:e.label??e.id,visible:e.visible??!0,opacity:e.opacity??1,blend:e.blend??`normal`,credit:e.credit,tiers:[`low`],url:()=>e.url};this.customLayers.push(t),this.layerList.push(t),this.emit(`layerschange`,this.layers),this.loadVisible()}addVectorLayer(e){let t={kind:`vector`,id:e.id,label:e.label??e.id,visible:e.visible??!0,credit:e.credit,render:e.render,prepare:e.prepare};this.customLayers.push(t),this.layerList.push(t),this.emit(`layerschange`,this.layers),this.loadVisible()}get projectionName(){return this.projectionId}static get projections(){return OB}setProjection(e,t={}){this.limitsArmed=!1,this.projectionId=e,this.projectionOptions={...this.projectionOptions,...t},this.projection=kB(e,this.projectionOptions),this.view={...this.view,centerX:0,centerY:0},this.render(),this.emit(`viewchange`,this.viewState)}get viewState(){let e=this.viewport(),t=e.unproject(e.width/2,e.height/2);return{projection:this.projectionId,zoom:this.view.zoom,centerLon:t?.[0]??this.projectionOptions.centerLon??0,centerLat:t?.[1]??this.projectionOptions.centerLat??0}}setView(e){if(e.projection&&e.projection!==this.projectionId&&this.setProjection(e.projection),this.limitsArmed=!1,e.zoom!==void 0&&(this.view={...this.view,zoom:e.zoom}),e.centerLon!==void 0||e.centerLat!==void 0){let t=this.viewState,n=e.centerLon??t.centerLon,r=e.centerLat??t.centerLat;if(this.projection.azimuthal)this.projectionOptions={...this.projectionOptions,centerLon:n,centerLat:r},this.projection=kB(this.projectionId,this.projectionOptions);else{let e=this.projection.forward(n,r);e&&(this.view={...this.view,centerX:e[0],centerY:e[1]})}}this.loadVisible(),this.render(),this.emit(`viewchange`,this.viewState)}setLimits(e){return this.limits={maxZoom:16,...e},this.render(),this}getLimits(){return{...this.limits}}setTime(e){this.jd=e,this.loadVisible(),this.render()}async setBody(e){e!==this.bodyId&&(this.limitsArmed=!1,await this.adopt(e))}project(e,t){return this.viewport().project(e,t)}unproject(e,t){let n=this.viewport().unproject(e,t);return n?{lon:n[0],lat:n[1]}:null}addPolyline(e){let t=this.overlay.addPolyline(e);return this.render(),t}addPolygon(e){let t=this.overlay.addPolygon(e);return this.render(),t}addBox(e){let t=this.overlay.addBox(e);return this.render(),t}addCircle(e){let t=this.overlay.addCircle(e);return this.render(),t}addMarker(e){let t=this.overlay.addMarker(e);return this.render(),t}clearDrawings(){this.overlay.clear(),this.render()}on(e,t){let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),()=>n.delete(t)}once(e,t){let n=((...e)=>{r(),t(...e)});jH.set(n,t);let r=this.on(e,n);return r}off(e,t){let n=this.listeners.get(e);if(n){n.delete(t);for(let e of n)jH.get(e)===t&&n.delete(e)}}emit(e,...t){let n=this.listeners.get(e);if(n)for(let e of[...n])e(...t)}tier(e){return nH(e,tH(xH.find(([e])=>this.view.zoom>=e)?.[1]??`low`,eH(this.usableSourceWidth())))}usableSourceWidth(){return this.projectionId===`equirectangular`?this.deviceWidth()*this.view.zoom:this.workingWidth()}deviceWidth(){return this.sharpWidth||Math.max(1,this.root.clientWidth)}workingWidth(){let e=this.deviceWidth()*2*this.view.zoom;return Math.min(CH,2**Math.ceil(Math.log2(Math.max(256,e))))}decodeWidth(e){return this.projectionId===`equirectangular`?null:Math.min(this.workingWidth(),$V[e]??CH)}picturesInUse(){return this.layerList.filter(e=>AH(e)&&e.visible).map(e=>{let t=this.tier(e.tiers);return{url:e.url(this.jd,t),tier:t}})}async loadVisible(){let e=this.picturesInUse(),t=this.layerList.filter(e=>!AH(e)&&e.visible&&!!e.prepare).map(e=>e.prepare().then(()=>this.render(),()=>{})),n=e.filter(({url:e,tier:t})=>this.bitmaps.get(e)?.key!==uH(e,this.decodeWidth(t))).filter(({url:e})=>!this.pending.has(e)&&!this.missing.has(e)).map(async({url:e,tier:t})=>{this.pending.add(e);let n=this.generation;try{let r=await dH(e,this.decodeWidth(t));if(!r)return;if(this.disposed||n!==this.generation){pH(r.key);return}this.hold(this.bitmaps,e,r,pH),this.render()}catch(t){if(n!==this.generation)return;this.missing.add(e),this.emit(`error`,Error(`spacemap: could not load ${e}`,{cause:t}))}finally{this.pending.delete(e)}});await Promise.all([...t,...n]),this.dropUnused(new Set(this.picturesInUse().map(({url:e})=>e)))}dropUnused(e){for(let[t,n]of this.bitmaps)e.has(t)||(pH(n.key),this.bitmaps.delete(t));for(let[t,n]of this.rasters)e.has(t)||(hH(n.key),this.rasters.delete(t))}hold(e,t,n,r){let i=e.get(t);i?.key!==n.key&&(i&&r(i.key),e.set(t,n))}rasterFor(e,t){let n=this.rasters.get(e);if(n?.key===uH(e,t))return n.raster;let r=this.bitmaps.get(e)?.bitmap;if(!r)return null;let i=mH(e,t,r);return i?(this.hold(this.rasters,e,i,hH),i.raster):null}dropTextures(){for(let e of this.bitmaps.values())pH(e.key);for(let e of this.rasters.values())hH(e.key);this.bitmaps.clear(),this.rasters.clear()}viewport(e,t){let n=e??this.root.clientWidth??1,r=t??this.root.clientHeight??1;return this.view=yH(this.view,this.projection,n,r,this.limitsArmed?this.limits:{}),new _H(this.projection,Math.max(1,n),Math.max(1,r),this.view)}render(){this.disposed||(cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(()=>this.draw()))}renderMoving(){this.moving=!0,clearTimeout(this.settleTimer),this.settleTimer=window.setTimeout(()=>{this.moving=!1,this.render()},DH),this.render()}draw(){let e=this.root.clientWidth,t=this.root.clientHeight;if(!this.ctx||e===0||t===0)return;let n=Math.min(window.devicePixelRatio||1,2),r=Math.sqrt(SH/(e*t*n*n)),i=n*Math.min(1,r),a=Math.max(1,Math.round(e*i));a!==this.sharpWidth&&(this.sharpWidth=a,this.loadVisible());let o=e*i*t*i,s=i*(this.moving?this.interactionScale(o):1),c=Math.max(1,Math.round(e*s)),l=Math.max(1,Math.round(t*s));(this.canvas.width!==c||this.canvas.height!==l)&&(this.canvas.width=c,this.canvas.height=l,this.buffer=null,this.lookup=null);let u=this.viewport(e,t),d=new _H(this.projection,c,l,this.view);this.clipToDisc(u),this.drawRaster(d,c,l),this.drawVector(u),!this.announcedReady&&this.bitmaps.size>0&&(this.announcedReady=!0,this.emit(`ready`))}record(e,t){if(t<=0)return;let n=e/t;this.msPerPixel=this.msPerPixel===0?n:this.msPerPixel*.7+n*.3}interactionScale(e){if(this.msPerPixel<=0||e<=0)return 1;let t=Math.sqrt(wH/this.msPerPixel/e);return t>EH?1:Math.max(TH,t)}clipToDisc(e){let{projection:t}=e;if(!t.azimuthal){this.canvas.style.clipPath=``;return}let[n,r]=e.toScreen(0,0),i=t.extent.maxX*e.scale;this.canvas.style.clipPath=`circle(${i}px at ${n}px ${r}px)`}drawRaster(e,t,n){let r=this.ctx;r.clearRect(0,0,t,n);let i=this.layerList.filter(e=>AH(e)&&e.visible);if(i.length===0)return;if(this.projectionId===`equirectangular`){let t=i.map(e=>({image:this.bitmaps.get(e.url(this.jd,this.tier(e.tiers)))?.bitmap,opacity:e.opacity,blend:e.blend})).filter(e=>!!e.image);t.length&&GV(r,e,t);return}let a=this.workingWidth(),o=i.map(e=>({image:this.rasterFor(e.url(this.jd,this.tier(e.tiers)),a),opacity:e.opacity,blend:e.blend})).filter(e=>!!e.image);if(o.length===0)return;(!this.buffer||this.buffer.width!==t||this.buffer.height!==n)&&(this.buffer=r.createImageData(t,n));let s=`${this.projectionId}|${JSON.stringify(this.projectionOptions)}|${this.view.zoom}|${this.view.centerX}|${this.view.centerY}|${t}x${n}`,c=!this.lookup||this.lookupKey!==s,l=performance.now();c&&(this.lookup=new UV(e,t,n),this.lookupKey=s),WV(this.lookup,o,this.buffer),r.putImageData(this.buffer,0,0),c&&this.record(performance.now()-l,t*n)}drawVector(e){this.svg.setAttribute(`viewBox`,`0 0 ${e.width} ${e.height}`),this.layerGroup.replaceChildren();for(let t of this.layerList){if(AH(t)||!t.visible)continue;let n=document.createElementNS(kV,`g`);n.setAttribute(`data-layer`,t.id),t.render(e,n),this.layerGroup.append(n)}this.overlay.redraw(e)}applyCooperative(e){this.root.classList.toggle(`sm-flat--cooperative`,e),this.cooperative?.setEnabled(e)}attachInteraction(){let e=!1,t=0,n=0,r=!1,i=!1,a=new Map,o=-1,s=0,c=null,l=()=>{let[e,t]=[...a.values()];if(!t)return null;let n=this.root.getBoundingClientRect();return{gap:Math.hypot(e.x-t.x,e.y-t.y),x:(e.x+t.x)/2-n.left,y:(e.y+t.y)/2-n.top}},u=e=>{let t=this.root.getBoundingClientRect();return[e.clientX-t.left,e.clientY-t.top]};this.root.addEventListener(`pointerdown`,u=>{u.pointerType===`touch`&&a.set(u.pointerId,{x:u.clientX,y:u.clientY}),c=l(),s=c?.gap??0,u.button===0&&(o=u.pointerId,e=!0,r=!1,i=u.pointerType===`touch`&&this.cooperative.isEnabled()&&a.size<2,this.root.setPointerCapture(u.pointerId),t=u.clientX,n=u.clientY,!i&&this.dragPan.isEnabled()&&this.root.classList.add(`sm-flat--dragging`))}),this.root.addEventListener(`pointermove`,d=>{let[f,p]=u(d);a.has(d.pointerId)&&a.set(d.pointerId,{x:d.clientX,y:d.clientY});let m=l();if(m){r=!0,c&&this.dragPan.isEnabled()&&this.drag(m.x-c.x,m.y-c.y),s>0&&this.scrollZoom.isEnabled()&&this.zoomBy(m.gap/s,m.x,m.y),s=m.gap,c=m;return}if(!e){this.emit(`pointermove`,this.unproject(f,p),d);return}if(d.pointerId!==o)return;let h=d.clientX-t,g=d.clientY-n;if(t=d.clientX,n=d.clientY,(Math.abs(h)>1||Math.abs(g)>1)&&(r=!0),i){r&&this.cooperative.allowsTouchDrag(a.size);return}this.dragPan.isEnabled()&&this.drag(h,g)});let d=l=>{a.delete(l.pointerId),s=0,c=null;let[d]=[...a.entries()];if(d&&e){o=d[0],t=d[1].x,n=d[1].y,i=this.cooperative.isEnabled()&&a.size<2;return}if(!(!e||l.pointerId!==o)&&(e=!1,this.root.releasePointerCapture?.(l.pointerId),this.root.classList.remove(`sm-flat--dragging`),!r)){let[e,t]=u(l);this.emit(`click`,this.unproject(e,t),l)}};this.root.addEventListener(`pointerup`,d),this.root.addEventListener(`pointercancel`,d),this.root.addEventListener(`wheel`,e=>{if(!this.scrollZoom.isEnabled()||!this.cooperative.allowsWheel(e))return;e.preventDefault();let[t,n]=u(e);this.zoomBy(Math.exp(-e.deltaY/400),t,n)},{passive:!1})}drag(e,t){this.limitsArmed=!0;let n=this.viewport();if(this.projection.azimuthal){let r=n.scale,i=e=>e/r*(180/Math.PI),[a,o]=gH((this.projectionOptions.centerLon??0)-i(e),Math.max(-90,Math.min(90,(this.projectionOptions.centerLat??0)+i(t))),this.limits);this.projectionOptions={...this.projectionOptions,centerLon:a,centerLat:o},this.projection=kB(this.projectionId,this.projectionOptions)}else this.view={...this.view,centerX:this.view.centerX-e/n.scale,centerY:this.view.centerY+t/n.scale};this.renderMoving(),this.emit(`viewchange`,this.viewState)}zoomBy(e,t,n){this.limitsArmed=!0;let r=this.viewport().fromScreen(t,n),i=Math.min(this.limits.maxZoom??1/0,Math.max(1,this.limits.minZoom??1,this.view.zoom*e));if(i===this.view.zoom)return;this.view={...this.view,zoom:i};let a=this.viewport();if(!this.projection.azimuthal){let e=a.fromScreen(t,n);this.view={...this.view,centerX:this.view.centerX+r[0]-e[0],centerY:this.view.centerY+r[1]-e[1]}}this.loadVisible(),this.renderMoving(),this.emit(`viewchange`,this.viewState)}};function NH(e){let t=e?.radii;if(t)return(t.a+t.b+t.c)/3;let n=e?.wikidata?.radius;if(n)return n.unit===`kilometre`?n.value:n.unit===`metre`?n.value/1e3:null;let r=e?.sbdb?.diameter;return r?r/2:null}function PH(){return typeof window>`u`?`unsupported`:window.isSecureContext?`DeviceOrientationEvent`in window&&window.matchMedia(`(pointer: coarse)`).matches?`available`:`unsupported`:`insecure`}async function FH(){let e=DeviceOrientationEvent.requestPermission;if(typeof e!=`function`)return!0;try{return await e.call(DeviceOrientationEvent)===`granted`}catch{return!1}}var IH=Math.PI/180,LH=256,RH=128,zH=.05,BH=.25;function VH(e){try{let t=document.createElement(`canvas`);t.width=LH,t.height=RH;let n=t.getContext(`2d`,{willReadFrequently:!0});if(!n)return null;n.drawImage(e,0,0,LH,RH);let{data:r}=n.getImageData(0,0,LH,RH),i=new Uint8Array(LH*RH);for(let e=0;e<i.length;e++)i[e]=+(r[e*4+3]>127);return{width:LH,height:RH,covered:i}}catch{return null}}function HH(e,t,n){let{width:r,height:i,covered:a}=e,o=new Float64Array(r);for(let e=0;e<r;e++)o[e]=(e+.5)*360/r;let s=new Float64Array(i);for(let e=0;e<i;e++)s[e]=90-(e+.5)*180/i;let c=0,l=0,u=0;for(let e=0;e<i;e++){let t=Math.cos(s[e]*IH);for(let n=0;n<r;n++)a[e*r+n]&&(c+=t*Math.sin(o[n]*IH),l+=t*Math.cos(o[n]*IH),u+=t)}if(u===0)return t;let d=Math.hypot(c,l)/u<zH?t.heading:UH(Math.atan2(c,l)/IH-n.northOffsetDeg),f=UH(d+n.northOffsetDeg),p=Math.min(180,n.hfovDeg/2),m=new Float64Array(i),h=0;for(let e=0;e<r;e++)if(!(Math.abs((o[e]-f+540)%360-180)>p))for(let t=0;t<i;t++)a[t*r+e]&&(h=Math.max(h,++m[t]));let g=-1/0,_=1/0;for(let e=0;e<i;e++)m[e]<h*BH||(g=Math.max(g,s[e]),_=Math.min(_,s[e]));if(g<_)return{heading:d,pitch:t.pitch};let v=Math.min(n.vfovDeg/3,(g-_)/2);return{heading:d,pitch:Math.max(_+v,Math.min(g-v,t.pitch))}}function UH(e){return(e%360+360)%360}Math.PI/180;function WH(e){return e.orientation!==`unknown`&&e.north_offset_deg!==void 0}function GH(e){return e.id}function KH(e){return`${e.time},${e.lat},${e.lon}`}function qH(e,t){return t?e.find(e=>GH(e)===t||KH(e)===t)??null:null}function JH(e,t,n){let r=e.findIndex(e=>e.id===t.id),i=e=>e&&e.mission===t.mission,a=e=>i(e)?{entry:e,distanceM:XH(t,e,n),bearingDeg:ZH(t,e)}:null;return{previous:a(e[r-1]),next:a(e[r+1])}}var YH=Math.PI/180;function XH(e,t,n){return IB(e,t)*YH*n*1e3}function ZH(e,t){let n=e.lat*YH,r=t.lat*YH,i=(t.lon-e.lon)*YH,a=Math.sin(i)*Math.cos(r),o=Math.cos(n)*Math.sin(r)-Math.sin(n)*Math.cos(r)*Math.cos(i);return(Math.atan2(a,o)/YH%360+360)%360}var QH=Math.PI/180,$H=30,eU=110,tU=85,nU=75,rU=-22,iU=9,aU=6,oU=10,sU=1,cU=1,lU=new Hi(-Math.SQRT1_2,0,0,Math.SQRT1_2),uU=new J(0,0,1);function dU(e){return(e%360+360)%360}function fU(e,[t,n]){let r=dU(n-t),i=dU(e-t);return i<=r?dU(e):i-r<360-i?dU(n):dU(t)}function pU(e,t,n){return Math.max(t,Math.min(n,e))}function mU(e,t,n=new J){let r=e*QH,i=t*QH;return n.set(Math.sin(r)*Math.cos(i),Math.sin(i),-Math.cos(r)*Math.cos(i))}function hU(){let e=new hl;return e.moveTo(0,1),e.lineTo(.85,.05),e.lineTo(.38,.05),e.lineTo(.38,-.9),e.lineTo(-.38,-.9),e.lineTo(-.38,.05),e.lineTo(-.85,.05),e.closePath(),e}var gU=class{bodyId;openAt;openingView;interactive;followArrows;limits={};attribution=null;container=null;root=document.createElement(`div`);renderer=null;controls=null;resizeObserver=null;scene=new qa;camera=new sd(nU,1,.1,1e3);sphere;angleCanvas=document.createElement(`canvas`);angleContext=this.angleCanvas.getContext(`2d`);angleGridVisible=!1;arrows=new za;arrowGeometry=new tu(hU());raycaster=new Rd;loader=new Ju;texture=null;loadToken=0;frame=0;disposed=!1;entries=[];radiusKm=0;current=null;neighbours=null;view;pointers=new Map;pinchDistance=0;dragStart=null;hovered=null;gyroEnabled=!1;gyroOrigin=null;gyroEuler=new xa;gyroQuaternion=new Hi;gyroScreen=new Hi;gyroDirection=new J;lookAt=new J;ndc=new J;gridPoint=new J;viewDirection=new J;listeners={ready:new Set,load:new Set,error:new Set,viewchange:new Set,step:new Set,arrows:new Set};constructor(e){this.bodyId=e.body,this.openAt=e.at,this.interactive=e.interactive??!0,this.arrows.visible=e.arrows??!0,this.followArrows=e.followArrows??!0,this.openingView=e.heading!==void 0||e.pitch!==void 0?{heading:e.heading,pitch:e.pitch}:null,this.view={heading:e.heading??0,pitch:e.pitch??0,fov:e.fov??nU},e.limits&&this.setLimits(e.limits),this.root.className=`sm-panorama`,this.root.style.cssText=`position:relative;width:100%;height:100%;overflow:hidden`,this.scene.background=new X(`#0b0d12`),this.sphere=new As(new ru(500,96,48).scale(-1,1,1),new vs({transparent:!0,visible:!1,depthWrite:!1})),this.sphere.renderOrder=-2,this.scene.add(this.sphere,this.arrows)}mount(e){this.container=e,e.append(this.root),this.renderer=new dh({antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2));let t=this.renderer.domElement;t.style.cssText=`display:block;width:100%;height:100%;touch-action:none`,t.tabIndex=0,this.root.append(t),this.angleCanvas.style.cssText=`position:absolute;inset:0;display:block;width:100%;height:100%;pointer-events:none`,this.angleCanvas.setAttribute(`aria-hidden`,`true`),this.angleCanvas.hidden=!0,this.root.append(this.angleCanvas),this.controls=new bV(this,this.root),this.resizeObserver=new ResizeObserver(()=>this.resize()),this.resizeObserver.observe(this.root),this.resize(),this.interactive?(t.addEventListener(`pointerdown`,this.onPointerDown),t.addEventListener(`pointermove`,this.onPointerMove),t.addEventListener(`pointerup`,this.onPointerUp),t.addEventListener(`pointercancel`,this.onPointerCancel),t.addEventListener(`wheel`,this.onWheel,{passive:!1}),t.addEventListener(`keydown`,this.onKeyDown)):(t.addEventListener(`pointermove`,this.onPointerMove),t.addEventListener(`pointerup`,this.onPointerUp))}async load(){let e=await hx(this.bodyId,!1);if(this.disposed)return;this.entries=(e.global?.panoramas??[]).filter(mx),this.radiusKm=NH(e.global)??0,this.emit(`ready`);let t=this.openAt?this.byKey(this.openAt):this.entries[0]??null;if(!t){let e=Error(this.openAt?`spacemap: no panorama ${this.openAt} on ${this.bodyId}`:`spacemap: no panoramas on ${this.bodyId}`);throw this.emit(`error`,e),e}await this.open(t)}addControl(e,t){return this.controls?.add(e,t),this}removeControl(e){if(e===this.attribution)throw Error(`spacemap: the attribution control cannot be removed`);return this.controls?.remove(e),this}remove(){this.disposed=!0,this.setGyroEnabled(!1),this.loadToken++,cancelAnimationFrame(this.frame),this.frame=0,this.controls?.clear(),this.resizeObserver?.disconnect();let e=this.renderer?.domElement;e&&(e.removeEventListener(`pointerdown`,this.onPointerDown),e.removeEventListener(`pointermove`,this.onPointerMove),e.removeEventListener(`pointerup`,this.onPointerUp),e.removeEventListener(`pointercancel`,this.onPointerCancel),e.removeEventListener(`wheel`,this.onWheel),e.removeEventListener(`keydown`,this.onKeyDown)),this.setArrowTargets([]),this.texture?.dispose(),this.sphere.geometry.dispose(),this.sphere.material.dispose(),this.arrowGeometry.dispose(),this.renderer?.dispose(),this.renderer=null,this.root.remove(),this.container=null}getPanoramas(){return this.entries}getCurrent(){return this.current}getNeighbours(){return this.neighbours}async open(e){let t=typeof e==`string`?this.byKey(e):e;if(!t){let t=Error(`spacemap: no panorama ${String(e)} on ${this.bodyId}`);throw this.emit(`error`,t),t}this.current=t,this.neighbours=this.radiusKm?JH(this.entries,t,this.radiusKm):null;let n=this.openingView;this.openingView=null,n&&this.setView({heading:n.heading,pitch:n.pitch??0}),this.setArrowTargets(this.neighbours&&WH(t)?[`previous`,`next`].map(e=>({key:e,n:this.neighbours?.[e]??null})).filter(e=>e.n&&e.n.distanceM>=cU).map(e=>({key:e.key,bearingDeg:e.n.bearingDeg})):[]),await this.loadTexture(Yt(`/v1/panoramas/${t.id}.webp`,`panoramas`),t.north_offset_deg??0,!n),this.current===t&&this.emit(`load`,t)}async step(e){let t=this.neighbours?.[e];t&&await this.open(t.entry)}byKey(e){return this.entries.find(t=>t.id===e)??qH(this.entries,e)}getView(){return{...this.view}}setView(e){let t=e.heading??this.view.heading,n=e.pitch??this.view.pitch,r=e.fov??this.view.fov,{limits:i}=this;this.view={heading:i.heading?fU(t,i.heading):dU(t),pitch:pU(n,i.pitch?.[0]??-tU,i.pitch?.[1]??tU),fov:pU(r,i.fov?.[0]??$H,i.fov?.[1]??eU)},this.invalidate(),this.emit(`viewchange`,this.getView())}getLimits(){return structuredClone(this.limits)}setLimits(e){let t=(e,t,n)=>e&&[pU(e[0],t,n),pU(e[1],t,n)];this.limits={heading:e.heading&&[dU(e.heading[0]),dU(e.heading[1])],pitch:t(e.pitch,-tU,tU),fov:t(e.fov,$H,eU)},this.setView({})}async setGyroEnabled(e){return e===this.gyroEnabled?this.gyroEnabled:e?PH()!==`available`||!await FH()||this.disposed?!1:(this.gyroOrigin=null,this.gyroEnabled=!0,window.addEventListener(`deviceorientation`,this.onDeviceOrientation),!0):(window.removeEventListener(`deviceorientation`,this.onDeviceOrientation),this.gyroEnabled=!1,!1)}isGyroEnabled(){return this.gyroEnabled}onDeviceOrientation=e=>{if(e.alpha===null||e.beta===null||e.gamma===null)return;this.gyroEuler.set(e.beta*QH,e.alpha*QH,-e.gamma*QH,`YXZ`),this.gyroQuaternion.setFromEuler(this.gyroEuler).multiply(lU).multiply(this.gyroScreen.setFromAxisAngle(uU,-(screen.orientation?.angle??0)*QH)),this.gyroDirection.set(0,0,-1).applyQuaternion(this.gyroQuaternion);let t=Math.atan2(this.gyroDirection.x,-this.gyroDirection.z)/QH,n=Math.asin(pU(this.gyroDirection.y,-1,1))/QH;this.gyroOrigin===null&&(this.gyroOrigin=dU(t-this.view.heading)),this.setView({heading:t-this.gyroOrigin,pitch:n})};on(e,t){return this.listeners[e].add(t),()=>this.off(e,t)}once(e,t){let n=this.on(e,((...e)=>{n(),t(...e)}));return n}off(e,t){this.listeners[e].delete(t)}emit(e,...t){for(let n of this.listeners[e])n(...t)}faceCoverage(e,t){let n=VH(e);if(!n)return;let r=this.view.fov,i=2*Math.atan(Math.tan(r/2*QH)*this.camera.aspect)/QH;this.setView(HH(n,this.view,{northOffsetDeg:t,hfovDeg:i,vfovDeg:r}))}loadTexture(e,t,n){let r=++this.loadToken;return new Promise((i,a)=>{this.loader.load(e,e=>{if(r!==this.loadToken){e.dispose(),i();return}e.colorSpace=Xr,this.renderer&&(e.anisotropy=this.renderer.capabilities.getMaxAnisotropy()),this.texture?.dispose(),this.texture=e,this.sphere.material.map=e,this.sphere.material.visible=!0,this.sphere.material.needsUpdate=!0,this.sphere.rotation.y=Math.PI/2+t*QH,n&&this.faceCoverage(e.image,t),this.invalidate(),i()},void 0,()=>{if(r!==this.loadToken)return i();let t=Error(`spacemap: panorama failed to load: ${e}`);this.emit(`error`,t),a(t)})})}setArrowTargets(e){for(let e of[...this.arrows.children])this.arrows.remove(e),e.traverse(e=>{e instanceof As&&e.material.dispose()});for(let t of e){let e=new za;e.name=t.key;let n=new As(this.arrowGeometry,new vs({color:`#000000`,transparent:!0,opacity:.45,side:2,depthWrite:!1}));n.scale.setScalar(1.3);let r=new As(this.arrowGeometry,new vs({color:`#ffffff`,transparent:!0,opacity:.85,side:2,depthWrite:!1}));r.position.y=.02;for(let e of[n,r])e.rotation.x=-Math.PI/2;e.add(n,r),e.position.copy(mU(t.bearingDeg,rU)).multiplyScalar(iU),e.rotation.y=-t.bearingDeg*QH,this.arrows.add(e)}this.invalidate()}invalidate(){this.disposed||this.frame||!this.renderer||(this.frame=requestAnimationFrame(()=>{this.frame=0,this.render()}))}setAngleGridVisible(e){e!==this.angleGridVisible&&(this.angleGridVisible=e,this.angleCanvas.hidden=!e,this.invalidate())}setArrowsVisible(e){e!==this.arrows.visible&&(this.arrows.visible=e,e||(this.hovered=null,this.renderer&&(this.renderer.domElement.style.cursor=``)),this.invalidate())}resize(){let{clientWidth:e,clientHeight:t}=this.root;if(!e||!t||!this.renderer)return;this.renderer.setSize(e,t,!1);let n=Math.min(window.devicePixelRatio,2);this.angleCanvas.width=Math.round(e*n),this.angleCanvas.height=Math.round(t*n),this.angleContext.setTransform(n,0,0,n,0,0),this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.invalidate()}render(){if(!this.renderer)return;this.camera.fov=this.view.fov,this.camera.updateProjectionMatrix(),this.camera.lookAt(mU(this.view.heading,this.view.pitch,this.lookAt)),this.renderer.render(this.scene,this.camera);let{clientWidth:e,clientHeight:t}=this.root;if(this.drawAngleGrid(e,t),this.listeners.arrows.size===0)return;let n={};for(let r of this.arrows.visible?this.arrows.children:[])this.ndc.copy(r.position).project(this.camera),n[r.name]={x:(this.ndc.x+1)/2*e,y:(1-this.ndc.y)/2*t,visible:this.ndc.z<1&&Math.abs(this.ndc.x)<.98&&Math.abs(this.ndc.y)<.98};this.emit(`arrows`,n)}drawAngleGrid(e,t){let n=this.angleContext;if(n.clearRect(0,0,e,t),this.angleGridVisible){this.camera.getWorldDirection(this.viewDirection),n.strokeStyle=`rgba(255, 255, 255, 0.24)`,n.lineWidth=1,n.beginPath();for(let r=0;r<360;r+=oU)this.traceAngleLine(n,e,t,r,!0);for(let r=-80;r<=80;r+=oU)this.traceAngleLine(n,e,t,r,!1);n.stroke(),n.font=`12px system-ui, sans-serif`,n.lineWidth=3,n.strokeStyle=`rgba(0, 0, 0, 0.7)`,n.fillStyle=`rgba(255, 255, 255, 0.85)`,n.textAlign=`center`,n.textBaseline=`bottom`;for(let r=0;r<360;r+=oU){if(!this.projectAngle(r,0,e,t,!0))continue;let i=`${r}°`;n.strokeText(i,this.gridPoint.x,this.gridPoint.y-3),n.fillText(i,this.gridPoint.x,this.gridPoint.y-3)}n.textAlign=`left`,n.textBaseline=`middle`;for(let r of[0,90,180,270])for(let i=-80;i<=80;i+=oU){if(i===0||!this.projectAngle(r,i,e,t,!0))continue;let a=`${i>0?`+`:``}${i}°`;n.strokeText(a,this.gridPoint.x+4,this.gridPoint.y),n.fillText(a,this.gridPoint.x+4,this.gridPoint.y)}}}traceAngleLine(e,t,n,r,i){let a=!1,o=0,s=0,c=Math.max(t,n)*2,l=i?-90:0,u=i?90:360;for(let d=l;d<=u;d+=sU){let l=i?r:d,u=i?d:r;if(!this.projectAngle(l,u,t,n)){a=!1;continue}let{x:f,y:p}=this.gridPoint;!a||Math.hypot(f-o,p-s)>c?e.moveTo(f,p):e.lineTo(f,p),a=!0,o=f,s=p}}projectAngle(e,t,n,r,i=!1){return mU(e,t,this.gridPoint),this.gridPoint.dot(this.viewDirection)<=.001||(this.gridPoint.project(this.camera),!Number.isFinite(this.gridPoint.x)||!Number.isFinite(this.gridPoint.y))||i&&(Math.abs(this.gridPoint.x)>=.98||Math.abs(this.gridPoint.y)>=.98)||Math.abs(this.gridPoint.x)>4||Math.abs(this.gridPoint.y)>4?!1:(this.gridPoint.x=(this.gridPoint.x+1)/2*n,this.gridPoint.y=(1-this.gridPoint.y)/2*r,!0)}degreesPerPixel(){return this.view.fov/Math.max(1,this.root.clientHeight)}arrowAt(e,t){if(!this.renderer||!this.arrows.visible||this.arrows.children.length===0)return null;let n=this.renderer.domElement.getBoundingClientRect(),r=new q((e-n.left)/n.width*2-1,-((t-n.top)/n.height)*2+1);this.raycaster.setFromCamera(r,this.camera);let i=this.raycaster.intersectObjects(this.arrows.children,!0)[0];return i?i.object.parent.name:null}pressArrow(e){let t=this.neighbours?.[e];t&&(this.emit(`step`,{key:e,entry:t.entry}),this.followArrows&&this.open(t.entry).catch(()=>{}))}onPointerDown=e=>{try{this.renderer?.domElement.setPointerCapture(e.pointerId)}catch{}this.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.dragStart=this.pointers.size===1?{x:e.clientX,y:e.clientY}:null,this.pointers.size===2&&(this.pinchDistance=this.pinchSpan())};onPointerMove=e=>{let t=this.pointers.get(e.pointerId);if(!t){let t=this.arrowAt(e.clientX,e.clientY);t!==this.hovered&&this.renderer&&(this.hovered=t,this.renderer.domElement.style.cursor=t?`pointer`:``);return}let n=e.clientX-t.x,r=e.clientY-t.y;if(this.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.pointers.size===1){if(this.gyroEnabled)return;let e=this.degreesPerPixel();this.setView({heading:this.view.heading-n*e,pitch:this.view.pitch+r*e})}else if(this.pointers.size===2){let e=this.pinchSpan();this.pinchDistance>0&&this.zoom(this.pinchDistance/e),this.pinchDistance=e}};onPointerUp=e=>{this.pointers.delete(e.pointerId);let t=this.dragStart;if(this.dragStart=null,this.pointers.size>0||!(!this.interactive||t!==null&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<aU))return;let n=this.arrowAt(e.clientX,e.clientY);n&&this.pressArrow(n)};onPointerCancel=e=>{this.pointers.delete(e.pointerId),this.dragStart=null};pinchSpan(){let[e,t]=[...this.pointers.values()];return Math.hypot(e.x-t.x,e.y-t.y)}zoom(e){this.setView({fov:this.view.fov*e})}onWheel=e=>{e.preventDefault(),this.zoom(Math.exp(e.deltaY*.0015))};onKeyDown=e=>{let t=this.view.fov/10,{heading:n,pitch:r}=this.view,i={ArrowLeft:()=>this.setView({heading:n-t}),ArrowRight:()=>this.setView({heading:n+t}),ArrowUp:()=>this.setView({pitch:r+t}),ArrowDown:()=>this.setView({pitch:r-t}),"+":()=>this.zoom(.8),"-":()=>this.zoom(1.25)}[e.key];i&&(e.preventDefault(),i())}},_U=ax(()=>`${Kt()}/v1/groups/__planetary_systems_map__.json.gz`,{error:e=>`Failed to fetch planetary systems map: ${e.status}`}),vU=ax(()=>`${Kt()}/v1/groups/__solar_system_map__.json.gz`,{error:e=>`Failed to fetch solar system map: ${e.status}`});function yU({onScrub:e,onEnd:t}){let n=null,r=0,i=!1;function a(){i&&t(),n=null,i=!1}return{onpointerdown(e){e.pointerType!==`mouse`&&(n=e.clientX,r=e.clientY,i=!1)},onpointermove(t){t.pointerType===`mouse`||n===null||!i&&Math.hypot(t.clientX-n,t.clientY-r)<8||(i=!0,e(t.clientX,t.clientY))},onpointerup:a,onpointercancel:a,onpointerleave:a}}var bU=2.2,xU=84,SU=40,CU=4,wU=3,TU=1e4,EU=34,DU=7,OU=.42,kU=30;function AU(e,t,n){let r=1/0;for(let i of n)r=Math.min(r,Math.hypot(i.cx-e,i.cy-t));return r}function jU(e){return e>90?180-e:e}function MU(e){let t=Math.log10(e.domain[0]),n=Math.log10(e.domain[1])-t,r=r=>44+(Math.log10(Math.max(r/e.unitKm,1e-9))-t)/n*656,i=[];for(let t of[...e.bodies].sort((e,t)=>e.aKm-t.aKm)){let n=r(t.aKm),a=Math.max(bU,t.radiusKm*e.pxPerKm),o=120;if(t.tiltDeg>0){let r=Math.min(jU(t.tiltDeg)*e.pxPerDeg,xU),a=120-r,s=120+r;o=AU(n,a,i)>=AU(n,s,i)?a:s}i.push({...t,cx:n,cy:o,r:a})}let a=[];for(let t of i){if(!t.satellites?.length)continue;let n=t.rings?t.r*t.rings.outer*OU:0,r=t.cy-Math.max(t.r,n)-CU,i=[];for(let n of[...t.satellites].sort((e,t)=>t.radiusKm-e.radiusKm)){let a=Math.max(bU,n.radiusKm*e.pxPerKm);r-=a,i.push({...n,cx:t.cx,cy:r,r:a,hitY:0,hitHeight:0}),r-=a+wU}let o=Math.min(...i.map(e=>e.cy-e.r))-DU,s=Math.max(...i.map(e=>e.cy+e.r))+DU;i.forEach((e,t)=>{let n=t===0?s:(i[t-1].cy+e.cy)/2,r=t===i.length-1?o:(i[t+1].cy+e.cy)/2;e.hitY=r,e.hitHeight=n-r}),a.push({parent:t,moons:i,x:t.cx-EU/2,y:o,width:EU,height:s-o,perMoon:!t.grouped&&!t.satellitesLink&&i.some(e=>e.link)})}let o=e.bands.map(e=>{let t=r(e.innerKm),n=r(e.outerKm)-t,i=Math.max(n,kU);return{...e,x:t,width:n,hitX:t+(n-i)/2,hitWidth:i}}).sort((e,t)=>t.width-e.width),s=``;e.cloud?.points.forEach((t,n)=>{let i=t.aKm/e.unitKm;if(i<e.domain[0]||i>e.domain[1])return;let a=Math.min(Math.max(jU(t.tiltDeg),0)*e.pxPerDeg,xU),o=120+(n%2==0?-a:a);s+=`M${r(t.aKm).toFixed(1)} ${o.toFixed(1)}h0.01`});let c=e.primary.radiusKm*e.pxPerKm;return{bodies:i,moonZones:a,bands:o,cloudPath:s,primaryR:c,primaryCx:SU-c,xOf:r}}function NU(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function PU(e,t,n,r){for(let i of[!0,!1]){let a=null,o=r;for(let r of e.bodies){if(!!r.link!==i)continue;let e=Math.hypot(t-r.cx,n-r.cy),s=e<=r.r?e-TU:e-r.r;s>o||(a=r,o=s)}if(a)return a}return null}function FU(e,t,n){let r=PU(e,t,n,0);if(r)return{kind:`body`,id:r.id};for(let r of e.moonZones){if(!NU(r,t,n))continue;if(r.parent.grouped)return{kind:`body`,id:r.parent.id};if(!r.perMoon)return{kind:`stack`,id:r.parent.id};let e=r.moons.find(e=>n>=e.hitY&&n<=e.hitY+e.hitHeight);if(e)return{kind:`moon`,parent:r.parent.id,id:e.id}}let i=PU(e,t,n,16);if(i)return{kind:`body`,id:i.id};for(let r=e.bands.length-1;r>=0;r--){let i=e.bands[r];if(t>=i.hitX&&t<=i.hitX+i.hitWidth&&n>=26&&n<=206)return{kind:`band`,key:i.key}}return Math.hypot(t-e.primaryCx,n-120)<=e.primaryR?{kind:`primary`}:null}function IU(e,t,n){if(!n)return null;let{text:r}=e;switch(n.kind){case`primary`:return{cx:Math.max(44,t.primaryCx),cy:120-Math.min(t.primaryR,80),title:e.primary.name,sub:r.primary};case`body`:{let e=t.bodies.find(e=>e.id===n.id);if(!e)return null;let i=[r.distance(e.aKm)];return e.tiltDeg>90&&i.push(r.retrograde),e.grouped&&e.satellites?.length&&i.push(r.moons(e.satelliteCount??e.satellites.length)),{cx:e.cx,cy:e.cy-e.r-4,title:e.name,sub:i.join(` · `)}}case`stack`:{let e=t.moonZones.find(e=>e.parent.id===n.id);if(!e)return null;let i=e.x+e.width/2;return e.parent.satellitesTab?{cx:i,cy:e.y,title:e.parent.name,sub:r.moons(e.parent.satelliteCount??e.moons.length)}:{cx:i,cy:e.y,title:e.moons[0].name,sub:e.parent.name}}case`moon`:{let e=t.moonZones.find(e=>e.parent.id===n.parent),r=e?.moons.find(e=>e.id===n.id);return!e||!r?null:{cx:r.cx,cy:r.cy-r.r-4,title:r.name,sub:e.parent.name}}case`band`:{let e=t.bands.find(e=>e.key===n.key);return e?{cx:e.x+e.width/2,cy:44,title:e.name??e.label,sub:e.sub??`${r.distance(e.innerKm)}–${r.distance(e.outerKm)}`}:null}}}var LU=`http://www.w3.org/2000/svg`,RU=10,zU=-18,BU=1.2,VU=28,HU=6,UU=4,WU=18,GU=12,KU=190;function qU(e,t={},...n){let r=document.createElementNS(LU,e);for(let[e,n]of Object.entries(t))n!==void 0&&r.setAttribute(e,String(n));for(let e of n)e&&r.append(e);return r}function JU(e,t){return JSON.stringify(e)===JSON.stringify(t)}function YU(e,t){let n=new Map,r=(e,t)=>{(t?.href||t?.onclick)&&n.set(JSON.stringify(e),t)};for(let e of t.bands)r({kind:`band`,key:e.key},e);r({kind:`primary`},e.primary.link);for(let e of t.bodies)r({kind:`body`,id:e.id},e.link);for(let e of t.moonZones)if(!e.parent.grouped)if(!e.perMoon)r({kind:`stack`,id:e.parent.id},e.parent.satellitesLink);else for(let t of e.moons)r({kind:`moon`,parent:e.parent.id,id:t.id},t.link);return n}var XU=0,ZU=class{root=document.createElement(`div`);svg=qU(`svg`);tip=document.createElement(`div`);tipTitle=document.createElement(`span`);tipSub=document.createElement(`span`);uid=`sm-system-map-${XU++}`;resize=new ResizeObserver(()=>{this.fitLabels(),this.placeTip()});model=null;placed=null;background=!1;hover=null;highlights=new Map;targets=new Map;links=new Map;shape=``;labels=[];constructor(){this.tip.className=`sm-system-map__tip`,this.tipTitle.className=`sm-system-map__tip-title`,this.tipSub.className=`sm-system-map__tip-sub`,this.tip.append(this.tipTitle,this.tipSub),this.tip.hidden=!0,this.root.append(this.svg,this.tip),this.resize.observe(this.root);let e=yU({onScrub:(e,t)=>this.setHover(this.hitAt(e,t)),onEnd:()=>this.setHover(null)});this.svg.addEventListener(`pointerdown`,e.onpointerdown),this.svg.addEventListener(`pointermove`,e.onpointermove),this.svg.addEventListener(`pointerup`,e.onpointerup),this.svg.addEventListener(`pointercancel`,e.onpointercancel),this.svg.addEventListener(`pointerleave`,e.onpointerleave);let t=[0,0],n=e=>{t=[e.clientX,e.clientY]};this.svg.addEventListener(`pointerdown`,n),this.svg.addEventListener(`pointerup`,n),this.svg.addEventListener(`pointermove`,e=>{n(e),e.pointerType===`mouse`&&this.setHover(this.hitAt(e.clientX,e.clientY))}),this.svg.addEventListener(`pointerleave`,e=>{e.pointerType===`mouse`&&this.setHover(null)}),this.svg.addEventListener(`click`,e=>{if(e.detail===0)return;let n=Math.abs(t[0]-e.clientX)<1&&Math.abs(t[1]-e.clientY)<1?this.hitAt(...t):this.hitAt(e.clientX,e.clientY);if(!n)return;let r=this.targets.get(JSON.stringify(n));r?.contains(e.target)||(e.stopPropagation(),e.preventDefault(),r?.dispatchEvent(new MouseEvent(`click`,{bubbles:!0,cancelable:!0,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,altKey:e.altKey,button:e.button})))},!0)}destroy(){this.resize.disconnect(),this.root.remove()}update(e,t){this.model=e,this.placed=MU(e);let n=YU(e,this.placed),r=JSON.stringify([JSON.stringify(e,(e,t)=>e===`href`?void 0:t),t,[...n].map(([e,t])=>[e,!!t.href,!!t.onclick])]);if(this.links=n,r===this.shape){for(let[e,t]of this.targets){let r=n.get(e)?.href;r&&t.setAttribute(`href`,r)}return}this.shape=r,this.background=t.variant===`background`,this.hover=null,this.root.className=this.background?`sm-system-map sm-system-map--background`:`sm-system-map`,this.draw(e,this.placed,t.ariaLabel),this.fitLabels(),this.placeTip()}draw(e,t,n){let r=this.background;this.highlights=new Map,this.targets=new Map,this.labels=[];let i=this.svg;i.replaceChildren(),i.setAttribute(`viewBox`,r&&e.backgroundView||`0 0 720 240`),i.setAttribute(`preserveAspectRatio`,r?e.backgroundFit===`fit`?`xMidYMid meet`:e.backgroundView?`xMinYMid slice`:`xMidYMid slice`:`xMidYMid meet`),i.setAttribute(`class`,`sm-system-map__svg`),i.setAttribute(`role`,`group`),i.setAttribute(`aria-label`,n),i.setAttribute(`data-vaul-no-drag`,``);let a=(t,n)=>qU(`stop`,{offset:t,"stop-color":e.primary.color,"stop-opacity":n});i.append(qU(`defs`,{},qU(`radialGradient`,{id:`${this.uid}-primary`,gradientUnits:`userSpaceOnUse`,cx:t.primaryCx,cy:120,r:t.primaryR},a(`0%`,1),a(Math.max(0,1-RU/t.primaryR),.85),a(`100%`,.35)),qU(`pattern`,{id:`${this.uid}-band`,width:9,height:9,patternUnits:`userSpaceOnUse`},qU(`circle`,{cx:2,cy:2,r:.9,fill:`currentColor`,opacity:.55}),qU(`circle`,{cx:6.5,cy:6,r:.9,fill:`currentColor`,opacity:.55})))),r||this.drawAxis(e,t),t.cloudPath&&i.append(qU(`path`,{d:t.cloudPath,stroke:e.cloud?.color,"stroke-width":BU*2,"stroke-linecap":`round`,fill:`none`,opacity:.45,"pointer-events":`none`}));for(let e of t.bands){let t=qU(`rect`,{x:e.x,y:26,width:e.width,height:180,fill:`url(#${this.uid}-band)`,class:`sm-system-map__band sm-system-map__band--${e.tone}`});if(r){i.append(t);continue}let n=qU(`text`,{x:e.x+e.width/2,y:232,"text-anchor":`middle`,"font-size":WU,class:`sm-system-map__band-label sm-system-map__band-label--${e.tone}`});n.textContent=e.label,this.labels.push(n),i.append(this.target(e,e.name??e.label,{kind:`band`,key:e.key},t,qU(`rect`,{x:e.hitX,y:26,width:e.hitWidth,height:180,fill:`transparent`}),n))}let o=qU(`circle`,{cx:t.primaryCx,cy:120,r:t.primaryR,fill:`url(#${this.uid}-primary)`});i.append(r?o:this.target(e.primary.link,e.primary.name,{kind:`primary`},o));for(let e of t.bodies){if(!e.rings)continue;let t=e.r*(e.rings.inner+e.rings.outer)/2;i.append(qU(`ellipse`,{cx:e.cx,cy:e.cy,rx:t,ry:t*OU,transform:`rotate(${zU} ${e.cx} ${e.cy})`,fill:`none`,stroke:`#d9c89f`,"stroke-width":e.r*(e.rings.outer-e.rings.inner),opacity:.45}))}let s=new Map(t.moonZones.map(e=>[e.parent.id,e]));for(let e of t.bodies)i.append(this.body(e,s.get(e.id)));for(let e of t.moonZones)e.parent.grouped||this.stack(e)}drawAxis(e,t){for(let n of e.ticks){let r=t.xOf(n*e.unitKm),i=qU(`text`,{x:r,y:16,"text-anchor":`middle`,"font-size":16,fill:`currentColor`,opacity:.85});i.textContent=String(n),this.svg.append(qU(`line`,{x1:r,x2:r,y1:20,y2:212,stroke:`currentColor`,"stroke-width":.5,opacity:.12}),i)}let n=qU(`text`,{x:700,y:16,"text-anchor":`end`,"font-size":14,fill:`currentColor`,opacity:.65});n.textContent=e.axisLabel,this.svg.append(n)}body(e,t){let n=e.reference?qU(`circle`,{cx:e.cx,cy:e.cy,r:e.r+1,fill:`none`,stroke:e.color,"stroke-width":1.2,class:`sm-system-map__reference`}):qU(`circle`,{cx:e.cx,cy:e.cy,r:e.r,fill:e.color});if(this.background)return!t||!e.grouped?n:qU(`g`,{},n,...this.moonDots(t));let r={kind:`body`,id:e.id},i=this.highlight(r,qU(`circle`,{cx:e.cx,cy:e.cy,r:e.r+3.5,fill:`none`,stroke:`currentColor`,"stroke-width":1,opacity:.8})),a=qU(`circle`,{cx:e.cx,cy:e.cy,r:e.r+16,fill:`transparent`});return!t||!e.grouped?this.target(e.link,e.name,r,i,n,a):this.target(e.link,e.name,r,this.highlight(r,this.zoneWash(t)),i,n,a,...this.moonDots(t),this.zoneHit(t))}stack(e){if(this.background){this.svg.append(...this.moonDots(e));return}let t=e.parent;if(e.perMoon){this.svg.append(...this.moonDots(e));for(let n of e.moons){let r={kind:`moon`,parent:t.id,id:n.id};this.svg.append(this.target(n.link,n.name,r,this.highlight(r,qU(`circle`,{cx:n.cx,cy:n.cy,r:n.r+2.5,fill:`none`,stroke:`currentColor`,"stroke-width":1,opacity:.8})),qU(`rect`,{x:e.x,y:n.hitY,width:e.width,height:n.hitHeight,fill:`transparent`})))}return}let n={kind:`stack`,id:t.id},r=e.moons[0];this.svg.append(this.highlight(n,this.zoneWash(e)),...this.moonDots(e),this.target(t.satellitesLink,t.satellitesTab?`${t.name} · ${this.model.text.moons(t.satelliteCount??e.moons.length)}`:r.name,n,this.zoneHit(e)))}moonDots(e){return e.moons.map(e=>qU(`circle`,{cx:e.cx,cy:e.cy,r:e.r,fill:e.color}))}zoneWash(e){return qU(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:4,fill:`currentColor`,opacity:.1,"pointer-events":`none`})}zoneHit(e){return qU(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,fill:`transparent`})}highlight(e,t){let n=JSON.stringify(e),r=this.highlights.get(n);return r?r.push(t):this.highlights.set(n,[t]),t.style.display=`none`,t}target(e,t,n,...r){let i=!!(e?.href||e?.onclick),a=e?.href?qU(`a`,{href:e.href,"aria-label":t}):i?qU(`g`,{role:`button`,tabindex:0,"aria-label":t,class:`sm-system-map__button`}):qU(`g`);if(a.append(...r),!i)return a;let o=JSON.stringify(n);return this.targets.set(o,a),a.addEventListener(`focus`,()=>this.setHover(n)),a.addEventListener(`blur`,()=>{JU(this.hover,n)&&this.setHover(null)}),a.addEventListener(`click`,e=>this.links.get(o)?.onclick?.(e)),e?.href||a.addEventListener(`keydown`,e=>{let t=e.key;t!==`Enter`&&t!==` `||(e.preventDefault(),a.dispatchEvent(new MouseEvent(`click`,{bubbles:!0})))}),a}setHover(e){if(JU(this.hover,e))return;for(let e of this.highlights.get(JSON.stringify(this.hover))??[])e.style.display=`none`;this.targets.get(JSON.stringify(this.hover))?.removeAttribute(`data-near`),this.hover=e;for(let t of this.highlights.get(JSON.stringify(e))??[])t.style.display=``;let t=this.targets.get(JSON.stringify(e));t?.setAttribute(`data-near`,``),this.svg.classList.toggle(`sm-system-map__svg--near`,!!t),this.placeTip()}hitAt(e,t){if(!this.placed||this.background)return null;let n=this.svg.getBoundingClientRect();if(!n.width||!n.height)return null;let r=(e-n.left)/n.width*720,i=(t-n.top)/n.height*240;return FU(this.placed,r,i)}fitLabels(){for(let e of this.labels){let t=0;e.setAttribute(`font-size`,String(WU));try{t=e.getComputedTextLength()}catch{}if(!t)continue;if(t>KU){let n=Math.max(GU,WU*KU/t);e.setAttribute(`font-size`,String(n)),t*=n/WU}let n=Number(e.dataset.centre??e.getAttribute(`x`));e.dataset.centre=String(n);let r=t/2,i=Math.min(Math.max(n,r+UU),Math.max(r,720-r-UU));e.setAttribute(`x`,String(i))}}placeTip(){let e=this.model&&this.placed&&!this.background?IU(this.model,this.placed,this.hover):null;if(this.tip.hidden=!e,!e)return;this.tipTitle.textContent=e.title,this.tipSub.textContent=e.sub?` · ${e.sub}`:``;let t=this.root.clientWidth,n=t/720;this.tip.style.maxWidth=`${Math.max(0,t-2*HU)}px`;let r=this.tip.offsetWidth/2,i=Math.min(Math.max(e.cx*n,r+HU),Math.max(r,t-r-HU));this.tip.style.left=`${i}px`,this.tip.style.top=`${Math.max(4,e.cy*n-VU)}px`}};function QU(e,t){return{planetId:e.primary.id,planetName:t,planetRadiusKm:e.primary.radius_km,planetColor:n_[e.primary.id]??`#cccccc`,moons:e.moons.map(e=>({id:e.id,name:e.id,aRp:e.a_rp,tiltDeg:e.tilt_deg,radiusKm:e.radius_km,color:n_[e.id]??e.color??`#cccccc`})),rings:e.rings?{innerRp:e.rings.inner_rp,outerRp:e.rings.outer_rp}:null,moonCount:e.moon_count}}var $U=14,eW=1.001,tW=.62,nW=[1,2,3,5,10,20,30,50,100,200,300,500,1e3,2e3,5e3],rW=`0 96 320 144`,iW=`0 96 720 144`,aW=[1,100];function oW(e,t){let n=Math.min(...e.moons.map(e=>e.aRp)),r=Math.max(...e.moons.map(e=>e.aRp));for(let i of t)n=Math.min(n,i.innerKm/e.planetRadiusKm),r=Math.max(r,i.outerKm/e.planetRadiusKm);return!Number.isFinite(n)||!Number.isFinite(r)?aW:(r<=n&&(n/=2,r*=2),n=n<=eW?1:n,[n>1?10**(Math.log10(n)-.12):1,10**(Math.log10(r)+.12)])}function sW(e,t){let n=e.planetRadiusKm,r=oW(e,t.bands);return{primary:{id:e.planetId,name:e.planetName,radiusKm:n,color:e.planetColor,link:t.primaryLink},bodies:e.moons.map(e=>({id:e.id,name:e.name,aKm:e.aRp*n,tiltDeg:e.tiltDeg,radiusKm:e.radiusKm,color:e.color,link:t.moonLink?.(e)})),bands:t.bands,cloud:t.cloud,unitKm:n,domain:r,ticks:nW.filter(e=>e>=r[0]&&e<=r[1]),axisLabel:t.axisLabel,pxPerKm:$U/Math.max(...e.moons.map(e=>e.radiusKm).filter(e=>e>0),1),pxPerDeg:tW,text:t.text,backgroundView:t.wide?iW:rW,backgroundFit:t.wide?`fit`:`slice`}}var cW=224e-6,lW=1.8,uW=[.3,50],dW=[.3,1,3,10,30],fW=`#ffdd44`;function pW(e){let t=e.replace(/^\d+\s+/,``);return t===t.toUpperCase()&&/[A-Z]/.test(t)?t.charAt(0)+t.slice(1).toLowerCase():t}function mW(e){return e.color||n_[e.id]||`#cccccc`}function hW(e,t){let n=new Map,r=new Map(e.objects.map(e=>[e.id,e]));for(let i of e.objects){if(i.kind!==`moon`||!i.parent)continue;let e=n.get(i.parent)??{satellites:[],count:r.get(i.parent)?.moon_count,tab:!1};e.satellites.push({id:i.id,name:t(i),radiusKm:i.diameter_km/2,color:mW(i)}),e.tab||=!!i.link_parent,n.set(i.parent,e)}return n}function gW(e,t){let n=e.objects.find(e=>e.kind===`star`);if(!n)return null;let r=hW(e,t.name),i=t.stack??(e=>r.get(e.id)),a=e.objects.filter(e=>e.kind!==`moon`&&e.kind!==`star`&&(t.keep?.(e)??!0)).map(e=>{let n=i(e);return{id:e.id,name:t.name(e),aKm:e.a*ig,tiltDeg:e.i,radiusKm:e.diameter_km/2,color:mW(e),rings:e.rings,satellites:n?.satellites,satelliteCount:n?.count,satellitesTab:n?.tab??!1,...t.links(e,n)}});return{primary:{id:n.id,name:t.name(n),radiusKm:n.diameter_km/2,color:fW,link:t.primaryLink},bodies:a,bands:e.belts.map(e=>({key:e.slug,innerKm:e.inner_au*ig,outerKm:e.outer_au*ig,tone:e.kind===`kuiper_belt`?`sky`:`muted`,...t.band(e)})),unitKm:ig,domain:uW,ticks:dW,axisLabel:t.text.axisAu,pxPerKm:cW,pxPerDeg:lW,text:t.text}}function _W(e){return{id:e.id,name:e.name??e.id,moon:e.moon??!1,aAu:e.aAu??0,tiltDeg:e.tiltDeg??0,radiusKm:e.radiusKm??0,color:e.color??n_[e.id]??`#cccccc`,parent:e.parent}}var vW=4,yW=10,bW={inner:[.6,5.5],outer:[4.5,55]},xW=[.1,.2,.3,.5,1,2,3,5,10,20,30,50,100,200,500,1e3],SW=.9,CW=.76;function wW(e,t){return Math.log(e/t[0])/Math.log(t[1]/t[0])}var TW=`naif-599`;function EW(e,t,n,r=[]){if(!n)return[];let i=new Set([...e.objects.map(e=>e.id),...r]);for(let e of Object.values(t)){i.add(e.primary.id);for(let t of e.moons)i.add(t.id)}return[...n].filter(e=>!i.has(e))}function DW(e){let t=e.type===`moon`,n=e.orbit?.parent_id,r=n===void 0||n===`naif-10`||n===`naif-0`?e.orbit?.a??e.orbit?.q:void 0;if(r===void 0&&!t)return null;let i=e.radii;return{id:e.id,name:pW(e.name??e.id),moon:t,aAu:r??0,tiltDeg:e.orbit?.i??0,radiusKm:i?(i.a+i.b+i.c)/3:(e.sbdb?.diameter??0)/2,color:n_[e.id]??e.sbdb?.color??e.color??`#cccccc`,parent:e.orbit?.parent_id}}var OW=.92;function kW(e,t){return e<t*OW?`inner`:`outer`}function AW(e,t){return Object.values(e).find(e=>e.primary.id===t)}function jW(e){return e.kind===`zone`?`zone:${e.zone}`:`${e.kind}:${e.id}`}var MW=class{targets=new Map;constructor(e,t,n){this.data=e,this.options=t,this.pick=n}has(e){return!this.options.bodies||this.options.bodies.has(e)}name(e,t){return this.options.names[e]??(t?pW(t):e)}named(e,t){return this.options.names[e]??t}link(e){return this.targets.set(jW(e),e),{onclick:()=>this.pick(e)}}body(e,t){return this.has(e)?this.link({kind:`body`,id:e,name:t}):void 0}stack(e,t){if(t&&!this.options.bodies)return t;let n=(AW(this.data.systems,e)?.moons??[]).filter(e=>this.has(e.id)).map(e=>({id:e.id,name:this.name(e.id),radiusKm:e.radius_km,color:n_[e.id]??e.color??`#cccccc`}));if(n.length)return n.sort((e,t)=>t.radiusKm-e.radiusKm),{satellites:n.slice(0,vW),count:n.length,tab:!0}}links(e,t,n){if(!n)return{link:this.body(e,t)};let r=()=>this.link({kind:`system`,id:e,name:t});if(this.options.grouping===`systems`)return{link:r(),grouped:!0};let i=n.satellites[0];return{link:this.body(e,t),satellitesLink:n.tab?r():this.body(i.id,i.name)}}built(e,t){return{model:e,targets:[...this.targets.values()],label:t}}};function NW(e,t,n,r){let i=new MW(e,t,r),a=e=>i.name(e.id,e.name),o=hW(e.solar,a),s=new Map(e.solar.objects.map(e=>[e.id,i.stack(e.id,o.get(e.id))])),c=e.solar.objects.find(e=>e.kind===`star`),l=e=>{let t=e===`inner`?n.zoneInner:n.zoneOuter;return{label:t,sub:``,...i.link({kind:`zone`,zone:e,name:t})}},u=gW(e.solar,{text:n,name:a,primaryLink:c&&i.body(c.id,a(c)),keep:e=>i.has(e.id)||!!s.get(e.id),stack:e=>s.get(e.id),links:(e,t)=>i.links(e.id,a(e),t),band:e=>t.zones===`belts`?{label:e.label}:l(e.kind===`kuiper_belt`?`outer`:`inner`)});if(!u)throw Error(`spacemap: the Solar System map names no Sun`);return i.built(u,n.solarSystem)}function PW(e,t,n,r,i,a){let o=AW(e.systems,t);if(!o)throw Error(`spacemap: no planetary system around ${t}`);let s=new MW(e,r,a),c=QU(o,s.name(t,n[t]));c.moons=c.moons.filter(e=>s.has(e.id)).map(e=>({...e,name:s.name(e.id,n[e.id])}));let l=c.planetRadiusKm,u=c.rings?[{key:`rings`,label:i.rings,innerKm:c.rings.innerRp*l,outerKm:c.rings.outerRp*l,tone:`amber`}]:[],d=sW(c,{text:i,axisLabel:i.axisRadii,bands:u,primaryLink:s.body(t,c.planetName),moonLink:e=>s.body(e.id,e.name)});return d.ticks=d.ticks.filter(e=>wW(e,d.domain)<CW),s.built(d,c.planetName)}function FW(e,t,n,r,i){let a=new MW(e,n,i),{solar:o,extras:s}=e,c=o.objects.find(e=>e.kind===`star`),l=o.objects.find(e=>e.id===TW)?.a;if(!c||l===void 0)throw Error(`spacemap: the Solar System map names no Sun or no Jupiter`);let u=o.objects.filter(e=>e.kind===`dwarf`||e.kind===`asteroid`).map(e=>({id:e.id,name:a.name(e.id,e.name),aAu:e.a,tiltDeg:e.i,radiusKm:e.diameter_km/2,color:mW(e)}));for(let e of s)e.moon||u.some(t=>t.id===e.id)||e.aAu>0&&u.push({...e,name:a.named(e.id,e.name)});let d=[];for(let e of u){if(kW(e.aAu,l)!==t)continue;let n={...e,aKm:e.aAu*ig},r=a.stack(e.id);if(r){d.push({...n,satellites:r.satellites,satelliteCount:r.count,satellitesTab:!0,...a.links(e.id,e.name,r)});continue}let i=s.filter(t=>t.moon&&t.parent===e.id&&a.has(t.id)).map(e=>{let t=a.named(e.id,e.name);return{...e,name:t,link:a.body(e.id,t)}});!a.has(e.id)&&!i.length||d.push({...n,link:a.body(e.id,e.name),satellites:i.length?i:void 0})}let[f,p]=bW[t],m=[Math.min(f,...d.map(e=>e.aKm/ig*.85)),Math.max(p,...d.map(e=>e.aKm/ig*1.15))],h=e=>e>=m[0]&&e<=m[1],g=yW/Math.max(...d.map(e=>e.radiusKm),1);for(let e of o.objects)e.kind!==`planet`||!h(e.a)||d.push({id:e.id,name:a.name(e.id,e.name),aKm:e.a*ig,tiltDeg:0,radiusKm:0,color:mW(e),reference:!0});let _=t===`inner`?r.zoneInner:r.zoneOuter;return a.built({primary:{id:c.id,name:a.name(c.id,c.name),radiusKm:c.diameter_km/2*cW/g,color:fW},bodies:d,bands:o.belts.filter(e=>h(e.inner_au)&&h(e.outer_au)).map(e=>({key:e.slug,label:e.label,innerKm:e.inner_au*ig,outerKm:e.outer_au*ig,tone:e.kind===`kuiper_belt`?`sky`:`muted`})),unitKm:ig,domain:m,ticks:xW.filter(e=>h(e)&&wW(e,m)<SW),axisLabel:r.axisAu,pxPerKm:g,pxPerDeg:lW,text:r},_)}var IW=new WeakMap,LW=.01;function RW(){let{messages:e,locale:t}=a(),n=new Intl.NumberFormat(t(),{maximumSignificantDigits:3}),r=new Intl.NumberFormat(t(),{style:`unit`,unit:`kilometer`,maximumSignificantDigits:3}),i=e.unit_symbol_astronomical_unit();return{primary:e.planetary_system_primary(),retrograde:e.planetary_system_retrograde(),moons:t=>e.system_map_moons({count:t}),distance:e=>{let t=e/ig;return t>0&&t<LW?r.format(e):`${n.format(t)} ${i}`},axisAu:e.system_map_axis_au(),solarSystem:e.system_map_solar_system(),rings:e.tab_rings(),axisRadii:e.planetary_system_axis_unit(),zoneInner:e.system_map_zone_inner(),zoneOuter:e.system_map_zone_outer()}}var zW=class{chart=new ZU;listeners=new Map;view;bodies;names;grouping;zones;places;targets=[];extras=new Map;queue=Promise.resolve();disposed=!1;constructor(e={}){this.view=e.view??{kind:`solar-system`},this.bodies=e.bodies?new Set(e.bodies):null,this.names=e.names??{},this.grouping=e.grouping??`bodies`,this.zones=e.zones??`belts`,this.places=(e.places??[]).map(_W)}mount(e){e.append(this.chart.root)}remove(){this.disposed=!0,this.chart.destroy()}load(){return this.draw()}async setView(e){await this.draw(e)}getView(){return this.view}setBodies(e){let t=e?new Set(e):null;return this.draw(void 0,t).catch(()=>{})}getTargets(){return[...this.targets]}draw(e,t){let n=this.queue.then(()=>(t!==void 0&&(this.bodies=t),this.drawNow(e??this.view)));return this.queue=n.catch(()=>{}),n}async drawNow(e){let t;try{t=await this.build(e)}catch(e){let t=e instanceof Error?e:Error(String(e));throw this.disposed||this.emit(`error`,t),t}if(this.disposed)return;let n=JSON.stringify(e)!==JSON.stringify(this.view);this.view=e,this.targets=t.targets,this.chart.update(t.model,{ariaLabel:t.label}),n&&this.emit(`viewchange`,e)}async build(e){let[t,n]=await Promise.all([vU(),_U()]),r={bodies:this.bodies,names:this.names,grouping:this.grouping,zones:this.zones},i=RW(),a=e=>this.emit(`select`,e),o={solar:t,systems:n,extras:[]};switch(e.kind){case`solar-system`:return NW(o,r,i,a);case`system`:return PW(o,e.id,await this.exportedNames(e.id,n),r,i,a);case`zone`:{let s=EW(t,n,this.bodies,this.places.map(e=>e.id)),c=(await Promise.all(s.map(e=>this.extra(e)))).filter(e=>e!==null),l=[...this.places,...c],u=EW(t,n,new Set(l.flatMap(e=>e.moon&&e.parent?[e.parent]:[])),l.map(e=>e.id)),d=await Promise.all(u.map(e=>this.extra(e))),f=[...l,...d.filter(e=>e!==null)];return FW({...o,extras:f},e.zone,r,i,a)}}}extra(e){let t=this.extras.get(e);return t||(t=hx(e,!1).then(t=>{if(!t.global)throw Error(`spacemap: no such body as ${e}`);return DW(t.global)}).catch(t=>(this.extras.delete(e),this.emit(`error`,t instanceof Error?t:Error(String(t))),null)),this.extras.set(e,t)),t}async exportedNames(e,t){if(![e,...(AW(t,e)?.moons??[]).map(e=>e.id)].some(t=>!(t in this.names)&&(t===e||!this.bodies||this.bodies.has(t))))return{};try{let{global:t,localized:n}=await hx(e,!0,a().locale()),r={};for(let e of t?.notable_moons??[])e.id&&(r[e.id]=e.name);Object.assign(r,n?.notable_moon_names);let i=n?.name??t?.name;return i&&(r[e]=i),r}catch{return{}}}on(e,t){let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),()=>n.delete(t)}once(e,t){let n=((...e)=>{r(),t(...e)});IW.set(n,t);let r=this.on(e,n);return r}off(e,t){let n=this.listeners.get(e);if(n){n.delete(t);for(let e of n)IW.get(e)===t&&n.delete(e)}}emit(e,...t){let n=this.listeners.get(e);if(n)for(let e of[...n])e(...t)}},BW=Object.fromEntries(xn.map(e=>[e,bn[e].label]));function VW(e,t){let n=e.credits.orbitSourceParents.get(t);if(!n)return!0;let r=e.visibility.focusedSystemId;for(let t of n)if(e.bodies.isInSystem(t,r))return!0;return!1}function HW(e){return xn.filter(t=>e.credits.orbitSources.has(t)).filter(t=>!bn[t].scoped||VW(e,t)).map(e=>({source:e,info:bn[e]}))}function UW(e,t){let n=e.visibility.focusedSystemId,r=e.visibility.focusedBodyId;return[...t].filter(e=>e.bodyId===r||n&&e.systemId===n)}function WW(e,t=BW){let n=e.credits;n.imageryVersion,n.modelVersion;let r=[...new Set(HW(e).map(({source:e})=>t[e]))],i=new Set;for(let t of UW(e,n.imagery.values()))i.add(t.organisation);let a=e.visibility.focusedBodyId,o=a?n.model.get(a):void 0;return o&&i.add(o.organisation),{orbits:r,imagery:[...i].sort()}}var GW=`https://spacemap.co`,KW=`https://spacemap.co/credits`;function qW(){let e=document.createElement(`div`);return e.className=`sm-attribution`,e}function JW(){let e=document.createElement(`span`);return e.className=`sm-attribution__group`,e}function YW(e,t,n){let r=document.createElement(`a`);return r.href=e,r.target=`_blank`,r.rel=`noopener noreferrer`,r.textContent=t,n&&(r.className=n),r}var XW=class{stop=null;onAdd(e){let t=qW(),n=JW(),r=JW();return t.append(YW(GW,`spacemap`,`sm-attribution__home`),n,r,YW(KW,a().messages.credits_see_all())),this.stop=lt(()=>{st(()=>{let t=WW(e.ctx);ZW(n,a().messages.attribution_orbits(),t.orbits),ZW(r,a().messages.attribution_imagery(),t.imagery)})}),t}onRemove(){this.stop?.(),this.stop=null}getDefaultPosition(){return`bottom-right`}};function ZW(e,t,n){if(e.hidden=n.length===0,e.hidden)return;let r=document.createElement(`span`);r.className=`sm-attribution__label`,r.textContent=`${t}:`,e.replaceChildren(r,` ${n.join(` · `)}`)}var QW=class{off=null;onAdd(e){let t=qW(),n=JW();t.append(YW(GW,`spacemap`,`sm-attribution__home`),n,YW(KW,a().messages.credits_see_all()));let r=()=>{let t=[...new Set(e.credits.map(e=>e.organisation))].filter(Boolean);if(n.hidden=t.length===0,n.hidden)return;let r=document.createElement(`span`);r.className=`sm-attribution__label`,r.textContent=`${a().messages.attribution_imagery()}:`,n.replaceChildren(r,` ${t.join(` · `)}`)};return r(),this.off=e.on(`layerschange`,r),t}onRemove(){this.off?.(),this.off=null}getDefaultPosition(){return`bottom-right`}};function $W(e){if(e)try{let t=typeof window<`u`?window.location.href:`https://spacemap.co`,{protocol:n}=new URL(e,t);return n===`http:`||n===`https:`?e:void 0}catch{return}}var eG=class{off=null;onAdd(e){let t=qW(),n=JW();t.append(YW(GW,`spacemap`,`sm-attribution__home`),n,YW(KW,a().messages.credits_see_all()));let r=()=>{let t=e.getCurrent();if(n.hidden=!t?.credit,!t?.credit)return;let r=document.createElement(`span`);r.className=`sm-attribution__label`,r.textContent=`${a().messages.attribution_imagery()}:`;let i=$W(t.credit_url),o=i?YW(i,t.credit):t.credit;n.replaceChildren(r,` `,o)};return r(),this.off=e.on(`load`,r),t}onRemove(){this.off?.(),this.off=null}getDefaultPosition(){return`bottom-right`}},tG=Math.PI/180,nG=Math.cos(ag*tG),rG=Math.sin(ag*tG);function iG(e){return e}function aG(e){let t=[...e.samples].sort((e,t)=>e.jd-t.jd);return{body:e.body??`naif-10`,offsetKm:e=>lG(t,e)}}function oG(e){return{body:e.body??`naif-10`,offsetKm:t=>EF(e.elements,t)?.r??null}}function sG(e,t){let n=ng(e,t);return n.error!==$h.None&&console.warn(`spacemap: SGP4 will not take this element set (error=${n.error})`),{body:p_,offsetKm:e=>{if(n.error!==$h.None)return null;let t=vg(n,e);return t&&cG(t[0],t[1],t[2])}}}function cG(e,t,n){return[e,t*nG+n*rG,-t*rG+n*nG]}function lG(e,t){let n=e.length;if(n<2||t<e[0].jd||t>e[n-1].jd)return null;let r=0,i=n-1;for(;r<i;){let n=r+i>>1;e[n].jd<t?r=n+1:i=n}let a=Math.max(r,1),o=e[a-1],s=e[a],c=s.jd-o.jd;if(c<=0)return s.km;let l=(t-o.jd)/c,u=l*l,d=u*l,f=2*d-3*u+1,p=d-2*u+l,m=-2*d+3*u,h=d-u,g=[0,0,0];for(let t=0;t<3;t++){let n=o.km[t],r=s.km[t],i=uG(e,a-1,t),l=uG(e,a,t);g[t]=f*n+p*c*i+m*r+h*c*l}return g}function uG(e,t,n){let r=e[t-1]??e[t],i=e[t+1]??e[t],a=i.jd-r.jd;return a<=0?0:(i.km[n]-r.km[n])/a}function dG(e){return e/ig}var fG=null;function pG(e=K_){return fG||(fG=(async()=>{let t=await e(`${Kt()}/v1/panoramas.json`);if(!t.ok)throw Error(`Failed to load panoramas.json: ${t.status}`);return(await t.json()).bodies??[]})(),fG.catch(()=>fG=null),fG)}async function mG(e){return(await hx(e,!1)).global?.panoramas??[]}async function hG(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,controls:s,events:c,...l}=e,u=yG(t);bG({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let d=new OV(l);if(d.mount(u),d.webglError)throw d.unmount(),Error(`spacemap: WebGL is not available`);for(let[e,t]of Object.entries(c??{}))d.on(e,t);d.attribution=new XW,d.addControl(d.attribution);for(let e of s??[])d.addControl(e);return await d.open(),d.applyInitialView(),await Sz(),d}async function gG(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,controls:s,events:c,...l}=e,u=yG(t);bG({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let d=new MH(l);d.mount(u);for(let[e,t]of Object.entries(c??{}))d.on(e,t);d.attribution=new QW,d.addControl(d.attribution);for(let e of s??[])d.addControl(e);return await d.load(),d}async function _G(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,controls:s,events:c,...l}=e,u=yG(t);bG({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let d=new gU(l);d.mount(u);for(let[e,t]of Object.entries(c??{}))d.on(e,t);d.attribution=new eG,d.addControl(d.attribution);for(let e of s??[])d.addControl(e);return await d.load(),d}async function vG(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,events:s,...c}=e,l=yG(t);bG({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let u=new zW(c);u.mount(l);for(let[e,t]of Object.entries(s??{}))u.on(e,t);try{await u.load()}catch(e){throw u.remove(),e}return u}function yG(e){if(typeof e!=`string`)return e;let t=document.querySelector(e);if(!(t instanceof HTMLElement))throw Error(`spacemap: no element matches ${e}`);return t}function bG(e){let t={};e.dataUrl!==void 0&&(t.dataUrl=e.dataUrl),e.imagesUrl!==void 0&&(t.imagesUrl=e.imagesUrl),e.locale!==void 0&&(t.locale=()=>e.locale),e.messages!==void 0&&(t.messages=e.messages),e.includeNonCommercial&&(t.textures=`non-commercial`),i(t)}return e.AttributionControl=XW,e.FlatAttributionControl=QW,e.FlatMap=MH,e.GestureHandler=dV,e.MAP_LAYERS=gv,e.PROJECTION_IDS=OB,e.PanoramaAttributionControl=eG,e.PanoramaView=gU,e.SpaceMap=OV,e.SystemMap=zW,e.Viewport=_H,e.bearingDeg=ZH,e.boxRing=XB,e.circlePoints=Az,e.configureHost=i,e.createFlatMap=gG,e.createMap=hG,e.createPanorama=_G,e.createProjection=kB,e.createSystemMap=vG,e.dateToJD=Ng,e.defaultSceneSettings=Ax,e.elements=oG,e.fetchPanoramaIndex=pG,e.fetchPanoramas=mG,e.findPanorama=qH,e.fixed=iG,e.graticule=$B,e.groundDistanceM=XH,e.isViewable=mx,e.jdToDate=Pg,e.kmToAu=dG,e.neighboursOf=JH,e.panoramaAt=GH,e.pathFor=KB,e.planeBasis=Oz,e.projectionAspect=Jz,e.samples=aG,e.smallCircle=ZB,e.tle=sG,e})({});
|
|
5537
5537
|
//# sourceMappingURL=spacemap.iife.js.map
|
|
5538
|
-
(function(){if(typeof document==='undefined')return;var s=document.createElement('style');s.textContent=".scene-label{pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;color:inherit;touch-action:none;z-index:1;width:32px;height:32px;text-decoration:none;display:block;position:relative;left:0}.scene-label__halo{border-radius:50%;width:100%;height:100%;transition:transform .1s}.scene-label__halo--spacecraft,.scene-label__halo--debris{overflow:visible}.scene-label__loader{box-sizing:border-box;pointer-events:none;border:2px solid #fff;border-color:#fff #fff #fff3 #fff3;border-radius:50%;width:32px;height:32px;margin:auto;animation:.9s linear infinite scene-label-loader-spin;position:fixed;inset:0}@keyframes scene-label-loader-spin{to{transform:rotate(360deg)}}.reduce-motion .scene-label__loader{animation-duration:.9s!important;animation-iteration-count:infinite!important}.scene-label__name{white-space:nowrap;pointer-events:auto;cursor:pointer;color:#fff;text-shadow:0 0 4px #000,0 0 4px #000;padding-left:8px;font-size:14px;font-weight:700;text-decoration:none;position:absolute;top:50%;left:32px;transform:translateY(-50%)}.scene-label__name--large{font-size:16px}.scene-label__annotations{top:28px;pointer-events:none;flex-direction:column;padding-inline-start:8px;display:flex;position:absolute;inset-inline-start:32px}.scene-label__annotation{opacity:0;white-space:nowrap;color:#fff9;text-shadow:0 0 3px #000,0 0 3px #000;transition:opacity .15s, display .15s allow-discrete;font-size:11px;line-height:1.3;display:none}.scene-label__annotation--visible{opacity:1;display:block}@starting-style{.scene-label__annotation--visible{opacity:0}}.scene-feature-label{color:#ffffffb3;white-space:nowrap;pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;text-shadow:0 0 2px #000,0 0 2px #000;z-index:0;font-size:12px;transition:color .1s;left:0}.scene-feature-label:hover{color:#fff;text-shadow:0 0 3px #000,0 0 3px #000}.scene-feature-label--active{color:#fff;font-size:14px;font-weight:600}.scene-path-label{color:#fff;font:inherit;white-space:nowrap;text-align:start;text-shadow:0 0 4px #000,0 0 4px #000;pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;touch-action:none;z-index:2;background:0 0;border:0;align-items:center;gap:8px;padding:0;line-height:1.15;display:flex;left:0}.scene-path-label--static{pointer-events:none;cursor:default}.scene-path-label__halo{border-radius:50%;flex-shrink:0;width:32px;height:32px;margin-inline-start:-16px;transition:transform .1s}.scene-path-label:hover .scene-path-label__halo{transform:scale(1.15)}.scene-path-label__text{flex-direction:column;gap:1px;display:flex}.scene-path-label__name{font-size:14px;font-weight:700}.scene-path-label__when{opacity:.8;font-variant-numeric:tabular-nums;font-size:12px}.scene-path-label--dim .scene-path-label__text{display:none}.scene-path-label--dim .scene-path-label__halo{transform:scale(.55)}.scene-path-label--dim:hover .scene-path-label__halo{transform:scale(.75)}.scene-path-label--step .scene-path-label__halo{background:0 0;border:0}.scene-path-label--step:hover .scene-path-label__halo{background:#ffffff1f}.scene-path-label--step .scene-path-label__name{font-size:12px;font-weight:600}.scene-path-label--step .scene-path-label__when{font-size:11px}.scene-path-label__hazard{font-size:11px;font-weight:700}.scene-path-label--lit{color:#fff}.scene-path-label--lit .scene-path-label__halo{transform:scale(1.15)}.scene-path-label--lit.scene-path-label--dim .scene-path-label__halo{transform:scale(.75)}.scene-path-label--faint .scene-path-label__text{display:none}.scene-path-label--faint .scene-path-label__halo{opacity:.45;transform:scale(.5)}.scene-path-label--faint:hover .scene-path-label__halo{opacity:1;transform:scale(.75)}.scene-overlay--no-names .scene-label__name,.scene-overlay--no-names .scene-label__annotations{display:none}.scene-hazard-label{white-space:nowrap;pointer-events:none;-webkit-user-select:none;user-select:none;text-shadow:0 0 4px #000,0 0 4px #000;margin-inline-start:16px;font-size:12px;font-weight:700;position:relative;left:0}.user-location-marker{pointer-events:none;background:#1a73e8;border:2px solid #fff;border-radius:50%;width:16px;height:16px;box-shadow:0 0 6px #0006}.sm-drawing-label{white-space:nowrap;color:#fff;text-shadow:0 0 4px #000,0 0 4px #000;-webkit-user-select:none;user-select:none;pointer-events:none;font:700 14px/1.2 system-ui,sans-serif}.sm-drawing-icon{-webkit-user-select:none;user-select:none;pointer-events:none;display:block}.sm-drawing--interactive{pointer-events:auto;cursor:pointer;touch-action:none}.sm-cooperative-hint{z-index:4;color:#fff;text-align:center;pointer-events:none;opacity:0;background:#0000008c;place-content:center;padding:16px;font:15px/1.4 system-ui,sans-serif;transition:opacity .2s;display:grid;position:absolute;inset:0}.sm-cooperative-hint--shown{opacity:1}@media (prefers-reduced-motion:reduce){.sm-cooperative-hint{transition:none}}.sm-ctrl{z-index:2;pointer-events:none;flex-direction:column;gap:6px;max-width:100%;padding:6px;display:flex;position:absolute}.sm-ctrl>*{pointer-events:auto}.sm-ctrl--top-left{align-items:flex-start;top:0;left:0}.sm-ctrl--top-right{align-items:flex-end;top:0;right:0}.sm-ctrl--bottom-left{align-items:flex-start;bottom:0;left:0}.sm-ctrl--bottom-right{align-items:flex-end;bottom:0;right:0}.sm-map{-webkit-user-select:none;user-select:none;width:100%;height:100%;position:relative}.sm-map__canvas{pointer-events:auto;touch-action:none;width:100%;height:100%;display:block}.sm-map__canvas:focus-visible{outline:2px solid var(--ring,Highlight)}.sm-map .scene-overlay{pointer-events:none;z-index:0;position:absolute;inset:0}.sm-flat{touch-action:none;background:#05070e;width:100%;height:100%;position:relative;overflow:hidden}.sm-flat__raster,.sm-flat__vector,.sm-flat__markers{width:100%;height:100%;position:absolute;inset:0}.sm-flat__raster{display:block}.sm-flat__vector,.sm-flat__markers{pointer-events:none}.sm-flat--interactive{cursor:grab}.sm-flat--cooperative{touch-action:pan-x pan-y}.sm-flat--dragging{cursor:grabbing}.sm-flat__graticule{fill:none;stroke:#ffffff47;stroke-width:1px}.sm-flat__frame{fill:none;stroke:#ffffff73;stroke-width:1px}.sm-flat__feature-dot{fill:#fffc}.sm-flat__feature-label{fill:#ffffffd9;paint-order:stroke;stroke:#000000a6;stroke-width:2.5px;font:10px/1 system-ui,sans-serif}.sm-flat__marker-dot{background:#4ea3ff;border:2px solid #fff;border-radius:50%;width:10px;height:10px;box-shadow:0 0 0 1px #00000073}.sm-ctrl:has(>.sm-attribution:only-child){padding:0}.sm-ctrl--top-left:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 0 var(--sm-attribution-radius) 0}.sm-ctrl--top-right:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 0 0 var(--sm-attribution-radius)}.sm-ctrl--bottom-left:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 var(--sm-attribution-radius) 0 0}.sm-ctrl--bottom-right:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:var(--sm-attribution-radius) 0 0 0}.sm-attribution{--sm-attribution-radius:3px;border-radius:var(--sm-attribution-radius);color:#ffffffbf;white-space:nowrap;background:#0006;align-items:center;gap:.5em;max-width:100%;padding:1px 6px;font:11px/1.45 system-ui,sans-serif;display:flex}.sm-attribution a{color:inherit;text-decoration:none}.sm-attribution a:hover{color:#fff;text-decoration:underline}.sm-attribution__home{font-weight:600}.sm-attribution__group{text-overflow:ellipsis;overflow:hidden}.sm-attribution__label{color:#ffffff80}\n/*$vite$:1*/.scene-label{pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;color:inherit;touch-action:none;z-index:1;width:32px;height:32px;text-decoration:none;display:block;position:relative;left:0}.scene-label__halo{border-radius:50%;width:100%;height:100%;transition:transform .1s}.scene-label__halo--spacecraft,.scene-label__halo--debris{overflow:visible}.scene-label__loader{box-sizing:border-box;pointer-events:none;border:2px solid #fff;border-color:#fff #fff #fff3 #fff3;border-radius:50%;width:32px;height:32px;margin:auto;animation:.9s linear infinite scene-label-loader-spin;position:fixed;inset:0}@keyframes scene-label-loader-spin{to{transform:rotate(360deg)}}.reduce-motion .scene-label__loader{animation-duration:.9s!important;animation-iteration-count:infinite!important}.scene-label__name{white-space:nowrap;pointer-events:auto;cursor:pointer;color:#fff;text-shadow:0 0 4px #000,0 0 4px #000;padding-left:8px;font-size:14px;font-weight:700;text-decoration:none;position:absolute;top:50%;left:32px;transform:translateY(-50%)}.scene-label__name--large{font-size:16px}.scene-label__annotations{top:28px;pointer-events:none;flex-direction:column;padding-inline-start:8px;display:flex;position:absolute;inset-inline-start:32px}.scene-label__annotation{opacity:0;white-space:nowrap;color:#fff9;text-shadow:0 0 3px #000,0 0 3px #000;transition:opacity .15s, display .15s allow-discrete;font-size:11px;line-height:1.3;display:none}.scene-label__annotation--visible{opacity:1;display:block}@starting-style{.scene-label__annotation--visible{opacity:0}}.scene-feature-label{color:#ffffffb3;white-space:nowrap;pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;text-shadow:0 0 2px #000,0 0 2px #000;z-index:0;font-size:12px;transition:color .1s;left:0}.scene-feature-label:hover{color:#fff;text-shadow:0 0 3px #000,0 0 3px #000}.scene-feature-label--active{color:#fff;font-size:14px;font-weight:600}.scene-path-label{color:#fff;font:inherit;white-space:nowrap;text-align:start;text-shadow:0 0 4px #000,0 0 4px #000;pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;touch-action:none;z-index:2;background:0 0;border:0;align-items:center;gap:8px;padding:0;line-height:1.15;display:flex;left:0}.scene-path-label--static{pointer-events:none;cursor:default}.scene-path-label__halo{border-radius:50%;flex-shrink:0;width:32px;height:32px;margin-inline-start:-16px;transition:transform .1s}.scene-path-label:hover .scene-path-label__halo{transform:scale(1.15)}.scene-path-label__text{flex-direction:column;gap:1px;display:flex}.scene-path-label__name{font-size:14px;font-weight:700}.scene-path-label__when{opacity:.8;font-variant-numeric:tabular-nums;font-size:12px}.scene-path-label--dim .scene-path-label__text{display:none}.scene-path-label--dim .scene-path-label__halo{transform:scale(.55)}.scene-path-label--dim:hover .scene-path-label__halo{transform:scale(.75)}.scene-path-label--step .scene-path-label__halo{background:0 0;border:0}.scene-path-label--step:hover .scene-path-label__halo{background:#ffffff1f}.scene-path-label--step .scene-path-label__name{font-size:12px;font-weight:600}.scene-path-label--step .scene-path-label__when{font-size:11px}.scene-path-label__hazard{font-size:11px;font-weight:700}.scene-path-label--lit{color:#fff}.scene-path-label--lit .scene-path-label__halo{transform:scale(1.15)}.scene-path-label--lit.scene-path-label--dim .scene-path-label__halo{transform:scale(.75)}.scene-path-label--faint .scene-path-label__text{display:none}.scene-path-label--faint .scene-path-label__halo{opacity:.45;transform:scale(.5)}.scene-path-label--faint:hover .scene-path-label__halo{opacity:1;transform:scale(.75)}.scene-overlay--no-names .scene-label__name,.scene-overlay--no-names .scene-label__annotations{display:none}.scene-hazard-label{white-space:nowrap;pointer-events:none;-webkit-user-select:none;user-select:none;text-shadow:0 0 4px #000,0 0 4px #000;margin-inline-start:16px;font-size:12px;font-weight:700;position:relative;left:0}.user-location-marker{pointer-events:none;background:#1a73e8;border:2px solid #fff;border-radius:50%;width:16px;height:16px;box-shadow:0 0 6px #0006}.sm-drawing-label{white-space:nowrap;color:#fff;text-shadow:0 0 4px #000,0 0 4px #000;-webkit-user-select:none;user-select:none;pointer-events:none;font:700 14px/1.2 system-ui,sans-serif}.sm-drawing-icon{-webkit-user-select:none;user-select:none;pointer-events:none;display:block}.sm-drawing--interactive{pointer-events:auto;cursor:pointer;touch-action:none}.sm-cooperative-hint{z-index:4;color:#fff;text-align:center;pointer-events:none;opacity:0;background:#0000008c;place-content:center;padding:16px;font:15px/1.4 system-ui,sans-serif;transition:opacity .2s;display:grid;position:absolute;inset:0}.sm-cooperative-hint--shown{opacity:1}@media (prefers-reduced-motion:reduce){.sm-cooperative-hint{transition:none}}.sm-ctrl{z-index:2;pointer-events:none;flex-direction:column;gap:6px;max-width:100%;padding:6px;display:flex;position:absolute}.sm-ctrl>*{pointer-events:auto}.sm-ctrl--top-left{align-items:flex-start;top:0;left:0}.sm-ctrl--top-right{align-items:flex-end;top:0;right:0}.sm-ctrl--bottom-left{align-items:flex-start;bottom:0;left:0}.sm-ctrl--bottom-right{align-items:flex-end;bottom:0;right:0}.sm-map{-webkit-user-select:none;user-select:none;width:100%;height:100%;position:relative}.sm-map__canvas{pointer-events:auto;touch-action:none;width:100%;height:100%;display:block}.sm-map__canvas:focus-visible{outline:2px solid var(--ring,Highlight)}.sm-map .scene-overlay{pointer-events:none;z-index:0;position:absolute;inset:0}.sm-flat{touch-action:none;background:#05070e;width:100%;height:100%;position:relative;overflow:hidden}.sm-flat__raster,.sm-flat__vector,.sm-flat__markers{width:100%;height:100%;position:absolute;inset:0}.sm-flat__raster{display:block}.sm-flat__vector,.sm-flat__markers{pointer-events:none}.sm-flat--interactive{cursor:grab}.sm-flat--cooperative{touch-action:pan-x pan-y}.sm-flat--dragging{cursor:grabbing}.sm-flat__graticule{fill:none;stroke:#ffffff47;stroke-width:1px}.sm-flat__frame{fill:none;stroke:#ffffff73;stroke-width:1px}.sm-flat__feature-dot{fill:#fffc}.sm-flat__feature-label{fill:#ffffffd9;paint-order:stroke;stroke:#000000a6;stroke-width:2.5px;font:10px/1 system-ui,sans-serif}.sm-flat__marker-dot{background:#4ea3ff;border:2px solid #fff;border-radius:50%;width:10px;height:10px;box-shadow:0 0 0 1px #00000073}.sm-ctrl:has(>.sm-attribution:only-child){padding:0}.sm-ctrl--top-left:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 0 var(--sm-attribution-radius) 0}.sm-ctrl--top-right:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 0 0 var(--sm-attribution-radius)}.sm-ctrl--bottom-left:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 var(--sm-attribution-radius) 0 0}.sm-ctrl--bottom-right:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:var(--sm-attribution-radius) 0 0 0}.sm-attribution{--sm-attribution-radius:3px;border-radius:var(--sm-attribution-radius);color:#ffffffbf;white-space:nowrap;background:#0006;align-items:center;gap:.5em;max-width:100%;padding:1px 6px;font:11px/1.45 system-ui,sans-serif;display:flex}.sm-attribution a{color:inherit;text-decoration:none}.sm-attribution a:hover{color:#fff;text-decoration:underline}.sm-attribution__home{font-weight:600}.sm-attribution__group{text-overflow:ellipsis;overflow:hidden}.sm-attribution__label{color:#ffffff80}\n/*$vite$:1*/";document.head.appendChild(s);})();
|
|
5538
|
+
(function(){if(typeof document==='undefined')return;var s=document.createElement('style');s.textContent=".scene-label{pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;color:inherit;touch-action:none;z-index:1;width:32px;height:32px;text-decoration:none;display:block;position:relative;left:0}.scene-label__halo{border-radius:50%;width:100%;height:100%;transition:transform .1s}.scene-label__halo--spacecraft,.scene-label__halo--debris{overflow:visible}.scene-label__loader{box-sizing:border-box;pointer-events:none;border:2px solid #fff;border-color:#fff #fff #fff3 #fff3;border-radius:50%;width:32px;height:32px;margin:auto;animation:.9s linear infinite scene-label-loader-spin;position:fixed;inset:0}@keyframes scene-label-loader-spin{to{transform:rotate(360deg)}}.reduce-motion .scene-label__loader{animation-duration:.9s!important;animation-iteration-count:infinite!important}.scene-label__name{white-space:nowrap;pointer-events:auto;cursor:pointer;color:#fff;text-shadow:0 0 4px #000,0 0 4px #000;padding-left:8px;font-size:14px;font-weight:700;text-decoration:none;position:absolute;top:50%;left:32px;transform:translateY(-50%)}.scene-label__name--large{font-size:16px}.scene-label__annotations{top:28px;pointer-events:none;flex-direction:column;padding-inline-start:8px;display:flex;position:absolute;inset-inline-start:32px}.scene-label__annotation{opacity:0;white-space:nowrap;color:#fff9;text-shadow:0 0 3px #000,0 0 3px #000;transition:opacity .15s, display .15s allow-discrete;font-size:11px;line-height:1.3;display:none}.scene-label__annotation--visible{opacity:1;display:block}@starting-style{.scene-label__annotation--visible{opacity:0}}.scene-feature-label{color:#ffffffb3;white-space:nowrap;pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;text-shadow:0 0 2px #000,0 0 2px #000;z-index:0;font-size:12px;transition:color .1s;left:0}.scene-feature-label:hover{color:#fff;text-shadow:0 0 3px #000,0 0 3px #000}.scene-feature-label--active{color:#fff;font-size:14px;font-weight:600}.scene-path-label{color:#fff;font:inherit;white-space:nowrap;text-align:start;text-shadow:0 0 4px #000,0 0 4px #000;pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;touch-action:none;z-index:2;background:0 0;border:0;align-items:center;gap:8px;padding:0;line-height:1.15;display:flex;left:0}.scene-path-label--static{pointer-events:none;cursor:default}.scene-path-label__halo{border-radius:50%;flex-shrink:0;width:32px;height:32px;margin-inline-start:-16px;transition:transform .1s}.scene-path-label:hover .scene-path-label__halo{transform:scale(1.15)}.scene-path-label__text{flex-direction:column;gap:1px;display:flex}.scene-path-label__name{font-size:14px;font-weight:700}.scene-path-label__when{opacity:.8;font-variant-numeric:tabular-nums;font-size:12px}.scene-path-label--dim .scene-path-label__text{display:none}.scene-path-label--dim .scene-path-label__halo{transform:scale(.55)}.scene-path-label--dim:hover .scene-path-label__halo{transform:scale(.75)}.scene-path-label--step .scene-path-label__halo{background:0 0;border:0}.scene-path-label--step:hover .scene-path-label__halo{background:#ffffff1f}.scene-path-label--step .scene-path-label__name{font-size:12px;font-weight:600}.scene-path-label--step .scene-path-label__when{font-size:11px}.scene-path-label__hazard{font-size:11px;font-weight:700}.scene-path-label--lit{color:#fff}.scene-path-label--lit .scene-path-label__halo{transform:scale(1.15)}.scene-path-label--lit.scene-path-label--dim .scene-path-label__halo{transform:scale(.75)}.scene-path-label--faint .scene-path-label__text{display:none}.scene-path-label--faint .scene-path-label__halo{opacity:.45;transform:scale(.5)}.scene-path-label--faint:hover .scene-path-label__halo{opacity:1;transform:scale(.75)}.scene-overlay--no-names .scene-label__name,.scene-overlay--no-names .scene-label__annotations{display:none}.scene-hazard-label{white-space:nowrap;pointer-events:none;-webkit-user-select:none;user-select:none;text-shadow:0 0 4px #000,0 0 4px #000;margin-inline-start:16px;font-size:12px;font-weight:700;position:relative;left:0}.user-location-marker{pointer-events:none;background:#1a73e8;border:2px solid #fff;border-radius:50%;width:16px;height:16px;box-shadow:0 0 6px #0006}.sm-drawing-label{white-space:nowrap;color:#fff;text-shadow:0 0 4px #000,0 0 4px #000;-webkit-user-select:none;user-select:none;pointer-events:none;font:700 14px/1.2 system-ui,sans-serif}.sm-drawing-icon{-webkit-user-select:none;user-select:none;pointer-events:none;display:block}.sm-drawing--interactive{pointer-events:auto;cursor:pointer;touch-action:none}.sm-cooperative-hint{z-index:4;color:#fff;text-align:center;pointer-events:none;opacity:0;background:#0000008c;place-content:center;padding:16px;font:15px/1.4 system-ui,sans-serif;transition:opacity .2s;display:grid;position:absolute;inset:0}.sm-cooperative-hint--shown{opacity:1}@media (prefers-reduced-motion:reduce){.sm-cooperative-hint{transition:none}}.sm-ctrl{z-index:2;pointer-events:none;flex-direction:column;gap:6px;max-width:100%;padding:6px;display:flex;position:absolute}.sm-ctrl>*{pointer-events:auto}.sm-ctrl--top-left{align-items:flex-start;top:0;left:0}.sm-ctrl--top-right{align-items:flex-end;top:0;right:0}.sm-ctrl--bottom-left{align-items:flex-start;bottom:0;left:0}.sm-ctrl--bottom-right{align-items:flex-end;bottom:0;right:0}.sm-map{-webkit-user-select:none;user-select:none}:where(.sm-map){width:100%;height:100%;position:relative}.sm-map__canvas{pointer-events:auto;touch-action:none;width:100%;height:100%;display:block}.sm-map__canvas:focus-visible{outline:2px solid var(--ring,Highlight)}.sm-map .scene-overlay{pointer-events:none;z-index:0;position:absolute;inset:0}.sm-flat{touch-action:none;background:#05070e;width:100%;height:100%;position:relative;overflow:hidden}.sm-flat__raster,.sm-flat__vector,.sm-flat__markers{width:100%;height:100%;position:absolute;inset:0}.sm-flat__raster{display:block}.sm-flat__vector,.sm-flat__markers{pointer-events:none}.sm-flat--interactive{cursor:grab}.sm-flat--cooperative{touch-action:pan-x pan-y}.sm-flat--dragging{cursor:grabbing}.sm-flat__graticule{fill:none;stroke:#ffffff47;stroke-width:1px}.sm-flat__frame{fill:none;stroke:#ffffff73;stroke-width:1px}.sm-flat__feature-dot{fill:#fffc}.sm-flat__feature-label{fill:#ffffffd9;paint-order:stroke;stroke:#000000a6;stroke-width:2.5px;font:10px/1 system-ui,sans-serif}.sm-flat__marker-dot{background:#4ea3ff;border:2px solid #fff;border-radius:50%;width:10px;height:10px;box-shadow:0 0 0 1px #00000073}.sm-system-map{border-radius:var(--sm-system-map-radius,6px);background:var(--sm-system-map-background,#ffffff0d);width:100%;color:var(--sm-system-map-ink,#ffffff9e);position:relative;overflow:hidden}.sm-system-map--background{pointer-events:none;background:0 0;border-radius:0;height:100%}.sm-system-map__svg{touch-action:pan-y;width:100%;height:auto;display:block}.sm-system-map--background .sm-system-map__svg{height:100%}.sm-system-map__svg--near :is(a,.sm-system-map__button):not([data-near]){pointer-events:none}.sm-system-map__button{cursor:pointer}.sm-system-map__button:focus{outline:none}.sm-system-map__reference{opacity:.6}.sm-system-map__band--muted{color:var(--sm-system-map-ink,#ffffff9e)}.sm-system-map__band--sky{color:var(--sm-system-map-sky,oklch(74.6% .16 232.661/.7))}.sm-system-map__band--amber{color:var(--sm-system-map-amber,oklch(92.4% .12 95.746/.8))}.sm-system-map__band-label{font-weight:600}.sm-system-map__band-label--muted{fill:var(--sm-system-map-ink,#ffffff9e)}.sm-system-map__band-label--sky{fill:var(--sm-system-map-sky-label,oklch(74.6% .16 232.661))}.sm-system-map__band-label--amber{fill:var(--sm-system-map-amber-label,oklch(92.4% .12 95.746/.9))}.sm-system-map__tip{z-index:10;background:var(--sm-system-map-tip-background,#0a0c14e6);width:max-content;color:var(--sm-system-map-tip-ink,#fffffff2);white-space:nowrap;pointer-events:none;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border-radius:.25rem;padding:.25rem .5rem;font-size:.75rem;line-height:1.33333;position:absolute;transform:translate(-50%);box-shadow:0 1px 3px #0000001a,0 1px 2px -1px #0000001a}.sm-system-map__tip[hidden]{display:none}.sm-system-map__tip-title{font-weight:500}.sm-system-map__tip-sub{color:var(--sm-system-map-ink,#ffffff9e)}.sm-ctrl:has(>.sm-attribution:only-child){padding:0}.sm-ctrl--top-left:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 0 var(--sm-attribution-radius) 0}.sm-ctrl--top-right:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 0 0 var(--sm-attribution-radius)}.sm-ctrl--bottom-left:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 var(--sm-attribution-radius) 0 0}.sm-ctrl--bottom-right:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:var(--sm-attribution-radius) 0 0 0}.sm-attribution{--sm-attribution-radius:3px;border-radius:var(--sm-attribution-radius);color:#ffffffbf;white-space:nowrap;background:#0006;align-items:center;gap:.5em;max-width:100%;padding:1px 6px;font:11px/1.45 system-ui,sans-serif;display:flex}.sm-attribution a{color:inherit;text-decoration:none}.sm-attribution a:hover{color:#fff;text-decoration:underline}.sm-attribution__home{font-weight:600}.sm-attribution__group{text-overflow:ellipsis;overflow:hidden}.sm-attribution__label{color:#ffffff80}\n/*$vite$:1*/.scene-label{pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;color:inherit;touch-action:none;z-index:1;width:32px;height:32px;text-decoration:none;display:block;position:relative;left:0}.scene-label__halo{border-radius:50%;width:100%;height:100%;transition:transform .1s}.scene-label__halo--spacecraft,.scene-label__halo--debris{overflow:visible}.scene-label__loader{box-sizing:border-box;pointer-events:none;border:2px solid #fff;border-color:#fff #fff #fff3 #fff3;border-radius:50%;width:32px;height:32px;margin:auto;animation:.9s linear infinite scene-label-loader-spin;position:fixed;inset:0}@keyframes scene-label-loader-spin{to{transform:rotate(360deg)}}.reduce-motion .scene-label__loader{animation-duration:.9s!important;animation-iteration-count:infinite!important}.scene-label__name{white-space:nowrap;pointer-events:auto;cursor:pointer;color:#fff;text-shadow:0 0 4px #000,0 0 4px #000;padding-left:8px;font-size:14px;font-weight:700;text-decoration:none;position:absolute;top:50%;left:32px;transform:translateY(-50%)}.scene-label__name--large{font-size:16px}.scene-label__annotations{top:28px;pointer-events:none;flex-direction:column;padding-inline-start:8px;display:flex;position:absolute;inset-inline-start:32px}.scene-label__annotation{opacity:0;white-space:nowrap;color:#fff9;text-shadow:0 0 3px #000,0 0 3px #000;transition:opacity .15s, display .15s allow-discrete;font-size:11px;line-height:1.3;display:none}.scene-label__annotation--visible{opacity:1;display:block}@starting-style{.scene-label__annotation--visible{opacity:0}}.scene-feature-label{color:#ffffffb3;white-space:nowrap;pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;text-shadow:0 0 2px #000,0 0 2px #000;z-index:0;font-size:12px;transition:color .1s;left:0}.scene-feature-label:hover{color:#fff;text-shadow:0 0 3px #000,0 0 3px #000}.scene-feature-label--active{color:#fff;font-size:14px;font-weight:600}.scene-path-label{color:#fff;font:inherit;white-space:nowrap;text-align:start;text-shadow:0 0 4px #000,0 0 4px #000;pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;touch-action:none;z-index:2;background:0 0;border:0;align-items:center;gap:8px;padding:0;line-height:1.15;display:flex;left:0}.scene-path-label--static{pointer-events:none;cursor:default}.scene-path-label__halo{border-radius:50%;flex-shrink:0;width:32px;height:32px;margin-inline-start:-16px;transition:transform .1s}.scene-path-label:hover .scene-path-label__halo{transform:scale(1.15)}.scene-path-label__text{flex-direction:column;gap:1px;display:flex}.scene-path-label__name{font-size:14px;font-weight:700}.scene-path-label__when{opacity:.8;font-variant-numeric:tabular-nums;font-size:12px}.scene-path-label--dim .scene-path-label__text{display:none}.scene-path-label--dim .scene-path-label__halo{transform:scale(.55)}.scene-path-label--dim:hover .scene-path-label__halo{transform:scale(.75)}.scene-path-label--step .scene-path-label__halo{background:0 0;border:0}.scene-path-label--step:hover .scene-path-label__halo{background:#ffffff1f}.scene-path-label--step .scene-path-label__name{font-size:12px;font-weight:600}.scene-path-label--step .scene-path-label__when{font-size:11px}.scene-path-label__hazard{font-size:11px;font-weight:700}.scene-path-label--lit{color:#fff}.scene-path-label--lit .scene-path-label__halo{transform:scale(1.15)}.scene-path-label--lit.scene-path-label--dim .scene-path-label__halo{transform:scale(.75)}.scene-path-label--faint .scene-path-label__text{display:none}.scene-path-label--faint .scene-path-label__halo{opacity:.45;transform:scale(.5)}.scene-path-label--faint:hover .scene-path-label__halo{opacity:1;transform:scale(.75)}.scene-overlay--no-names .scene-label__name,.scene-overlay--no-names .scene-label__annotations{display:none}.scene-hazard-label{white-space:nowrap;pointer-events:none;-webkit-user-select:none;user-select:none;text-shadow:0 0 4px #000,0 0 4px #000;margin-inline-start:16px;font-size:12px;font-weight:700;position:relative;left:0}.user-location-marker{pointer-events:none;background:#1a73e8;border:2px solid #fff;border-radius:50%;width:16px;height:16px;box-shadow:0 0 6px #0006}.sm-drawing-label{white-space:nowrap;color:#fff;text-shadow:0 0 4px #000,0 0 4px #000;-webkit-user-select:none;user-select:none;pointer-events:none;font:700 14px/1.2 system-ui,sans-serif}.sm-drawing-icon{-webkit-user-select:none;user-select:none;pointer-events:none;display:block}.sm-drawing--interactive{pointer-events:auto;cursor:pointer;touch-action:none}.sm-cooperative-hint{z-index:4;color:#fff;text-align:center;pointer-events:none;opacity:0;background:#0000008c;place-content:center;padding:16px;font:15px/1.4 system-ui,sans-serif;transition:opacity .2s;display:grid;position:absolute;inset:0}.sm-cooperative-hint--shown{opacity:1}@media (prefers-reduced-motion:reduce){.sm-cooperative-hint{transition:none}}.sm-ctrl{z-index:2;pointer-events:none;flex-direction:column;gap:6px;max-width:100%;padding:6px;display:flex;position:absolute}.sm-ctrl>*{pointer-events:auto}.sm-ctrl--top-left{align-items:flex-start;top:0;left:0}.sm-ctrl--top-right{align-items:flex-end;top:0;right:0}.sm-ctrl--bottom-left{align-items:flex-start;bottom:0;left:0}.sm-ctrl--bottom-right{align-items:flex-end;bottom:0;right:0}.sm-map{-webkit-user-select:none;user-select:none}:where(.sm-map){width:100%;height:100%;position:relative}.sm-map__canvas{pointer-events:auto;touch-action:none;width:100%;height:100%;display:block}.sm-map__canvas:focus-visible{outline:2px solid var(--ring,Highlight)}.sm-map .scene-overlay{pointer-events:none;z-index:0;position:absolute;inset:0}.sm-flat{touch-action:none;background:#05070e;width:100%;height:100%;position:relative;overflow:hidden}.sm-flat__raster,.sm-flat__vector,.sm-flat__markers{width:100%;height:100%;position:absolute;inset:0}.sm-flat__raster{display:block}.sm-flat__vector,.sm-flat__markers{pointer-events:none}.sm-flat--interactive{cursor:grab}.sm-flat--cooperative{touch-action:pan-x pan-y}.sm-flat--dragging{cursor:grabbing}.sm-flat__graticule{fill:none;stroke:#ffffff47;stroke-width:1px}.sm-flat__frame{fill:none;stroke:#ffffff73;stroke-width:1px}.sm-flat__feature-dot{fill:#fffc}.sm-flat__feature-label{fill:#ffffffd9;paint-order:stroke;stroke:#000000a6;stroke-width:2.5px;font:10px/1 system-ui,sans-serif}.sm-flat__marker-dot{background:#4ea3ff;border:2px solid #fff;border-radius:50%;width:10px;height:10px;box-shadow:0 0 0 1px #00000073}.sm-system-map{border-radius:var(--sm-system-map-radius,6px);background:var(--sm-system-map-background,#ffffff0d);width:100%;color:var(--sm-system-map-ink,#ffffff9e);position:relative;overflow:hidden}.sm-system-map--background{pointer-events:none;background:0 0;border-radius:0;height:100%}.sm-system-map__svg{touch-action:pan-y;width:100%;height:auto;display:block}.sm-system-map--background .sm-system-map__svg{height:100%}.sm-system-map__svg--near :is(a,.sm-system-map__button):not([data-near]){pointer-events:none}.sm-system-map__button{cursor:pointer}.sm-system-map__button:focus{outline:none}.sm-system-map__reference{opacity:.6}.sm-system-map__band--muted{color:var(--sm-system-map-ink,#ffffff9e)}.sm-system-map__band--sky{color:var(--sm-system-map-sky,oklch(74.6% .16 232.661/.7))}.sm-system-map__band--amber{color:var(--sm-system-map-amber,oklch(92.4% .12 95.746/.8))}.sm-system-map__band-label{font-weight:600}.sm-system-map__band-label--muted{fill:var(--sm-system-map-ink,#ffffff9e)}.sm-system-map__band-label--sky{fill:var(--sm-system-map-sky-label,oklch(74.6% .16 232.661))}.sm-system-map__band-label--amber{fill:var(--sm-system-map-amber-label,oklch(92.4% .12 95.746/.9))}.sm-system-map__tip{z-index:10;background:var(--sm-system-map-tip-background,#0a0c14e6);width:max-content;color:var(--sm-system-map-tip-ink,#fffffff2);white-space:nowrap;pointer-events:none;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border-radius:.25rem;padding:.25rem .5rem;font-size:.75rem;line-height:1.33333;position:absolute;transform:translate(-50%);box-shadow:0 1px 3px #0000001a,0 1px 2px -1px #0000001a}.sm-system-map__tip[hidden]{display:none}.sm-system-map__tip-title{font-weight:500}.sm-system-map__tip-sub{color:var(--sm-system-map-ink,#ffffff9e)}.sm-ctrl:has(>.sm-attribution:only-child){padding:0}.sm-ctrl--top-left:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 0 var(--sm-attribution-radius) 0}.sm-ctrl--top-right:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 0 0 var(--sm-attribution-radius)}.sm-ctrl--bottom-left:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 var(--sm-attribution-radius) 0 0}.sm-ctrl--bottom-right:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:var(--sm-attribution-radius) 0 0 0}.sm-attribution{--sm-attribution-radius:3px;border-radius:var(--sm-attribution-radius);color:#ffffffbf;white-space:nowrap;background:#0006;align-items:center;gap:.5em;max-width:100%;padding:1px 6px;font:11px/1.45 system-ui,sans-serif;display:flex}.sm-attribution a{color:inherit;text-decoration:none}.sm-attribution a:hover{color:#fff;text-decoration:underline}.sm-attribution__home{font-weight:600}.sm-attribution__group{text-overflow:ellipsis;overflow:hidden}.sm-attribution__label{color:#ffffff80}\n/*$vite$:1*/";document.head.appendChild(s);})();
|