@fnndsc/argus 0.39.0 → 0.39.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/dist/assets/{Settings-5MjiZs3m.js → Settings-BoMHOSp6.js} +1 -1
  2. package/dist/assets/{Texture-DOfcDQbS.js → Texture-D960GMMA.js} +1 -1
  3. package/dist/assets/{addVolumesToViewports-Bb0m3THm.js → addVolumesToViewports-BpHHdOxc.js} +1 -1
  4. package/dist/assets/{cornerstoneEngine-C-Ad7wRm.js → cornerstoneEngine-BUPxTjGN.js} +2 -2
  5. package/dist/assets/{field-Dry3W437.js → field-jqfvruDC.js} +3 -3
  6. package/dist/assets/{index-CgXV7KHK.js → index-BKyk2vIR.js} +1 -1
  7. package/dist/assets/{index-wXc13Noh.js → index-C9RWVPhr.js} +8 -8
  8. package/dist/assets/{index-BM66Iqpq.js → index-CU-JQxpu.js} +1 -1
  9. package/dist/assets/{index-CrjhBgBA.js → index-CmKwQ1nF.js} +1 -1
  10. package/dist/assets/{index-CErCsopW.js → index-DQhDp_5U.js} +1 -1
  11. package/dist/assets/{index-BeBkGdY4.js → index-DTOkxzz6.js} +1 -1
  12. package/dist/assets/{index-CpqNW11B.js → index-DWaiH0NG.js} +1 -1
  13. package/dist/assets/{index-B6eZOqOc.js → index-Dad2ItcR.js} +1 -1
  14. package/dist/assets/{index-BPtfl54C.js → index-OB5dTpAp.js} +1 -1
  15. package/dist/assets/{index-DQf3qxtA.js → index-SjhRgchg.js} +1 -1
  16. package/dist/assets/{index-3-iYk56R.js → index-gjhljxIT.js} +1 -1
  17. package/dist/assets/{index-CrXkv4Vv.js → index-ix2Bt1gn.js} +1 -1
  18. package/dist/assets/{index-C3nSyvq6.js → index-pxFc125y.js} +1 -1
  19. package/dist/assets/{index-DPfj2TXJ.js → index-q-9-3MNr.js} +1 -1
  20. package/dist/assets/{niivueEngine-mmgElHY8.js → niivueEngine-Dv8fpk3P.js} +2 -2
  21. package/dist/assets/{slabScene-Cw83Xw1C.js → slabScene-9NYXy_sk.js} +1 -1
  22. package/dist/build.json +1 -1
  23. package/dist/index.html +1 -1
  24. package/dist/notes.json +1 -1
  25. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./cornerstoneEngine-C-Ad7wRm.js","./refusal-DOpm8I8L.js","./_commonjsHelpers-CE1G-McA.js","./niivueEngine-mmgElHY8.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./cornerstoneEngine-BUPxTjGN.js","./refusal-DOpm8I8L.js","./_commonjsHelpers-CE1G-McA.js","./niivueEngine-Dv8fpk3P.js"])))=>i.map(i=>d[i]);
2
2
  (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))i(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function s(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(n){if(n.ep)return;n.ep=!0;const r=s(n);fetch(n.href,r)}})();const Zx=450,k_=12;function xo(t,e,s=Date.now()){const i=Number(t.dataset.edgeAt??0);return t.dataset.edge===e&&s-i<Zx?!1:(delete t.dataset.edge,t.offsetWidth,t.dataset.edge=e,t.dataset.edgeAt=String(s),!0)}function Jx(t,e){return e?"▲ TOP":`▼ ${t} MORE`}function Qx(t,e){const s=t.getBoundingClientRect().bottom;let i=0;for(const n of t.querySelectorAll(e)){const r=n.getBoundingClientRect();r.height>0&&r.top>=s-2&&(i+=1)}return i}function eO(t){const e=parseFloat(getComputedStyle(t).lineHeight)||16;return Math.max(0,Math.ceil((t.scrollHeight-t.scrollTop-t.clientHeight)/e))}function Mi(t,e={}){t.dataset.more="wired",t.classList.add("holds-more");const s=document.createElement("button");s.type="button",s.className=`more-chip${e.className!==void 0?` ${e.className}`:""}`,s.hidden=!0;const i=e.label??Jx,n=()=>t.scrollTop+t.clientHeight>=t.scrollHeight-2;s.addEventListener("click",l=>{if(l.stopPropagation(),e.press!==void 0){e.press();return}t.scrollBy({top:n()?-t.scrollHeight:Math.max(1,t.clientHeight-s.offsetHeight),behavior:"smooth"})});const r=e.mount??t;r.appendChild(s);let o=!1;const a=()=>{if(!o){o=!0;try{r===t&&t.lastElementChild!==s&&t.appendChild(s);const l=(e.scrolls?.()??!0)&&t.scrollHeight>t.clientHeight+2;if(s.hidden!==!l&&(s.hidden=!l),!l)return;const c=e.rows!==void 0?Qx(t,e.rows):eO(t),h=i(c,n());s.textContent!==h&&(s.textContent=h)}finally{o=!1}}};return t.addEventListener("scroll",a,{passive:!0}),tO(t,n),typeof ResizeObserver<"u"&&new ResizeObserver(a).observe(t),new MutationObserver(a).observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden","class","style"]}),a(),s}function tO(t,e){const s=()=>t.scrollHeight>t.clientHeight+2,i=()=>t.scrollTop<=0;let n=t.scrollTop;t.addEventListener("scrollend",()=>{const o=t.scrollTop!==n;n=t.scrollTop,!(!o||!s())&&(i()?xo(t,"top"):e()&&xo(t,"bottom"))}),t.addEventListener("wheel",o=>{!s()||o.deltaY===0||(o.deltaY<0&&i()?xo(t,"top"):o.deltaY>0&&e()&&xo(t,"bottom"))},{passive:!0});let r=null;t.addEventListener("touchstart",o=>{r=o.touches[0]?.clientY??null},{passive:!0}),t.addEventListener("touchmove",o=>{const a=o.touches[0]?.clientY;r===null||a===void 0||!s()||(a-r>k_&&i()?(xo(t,"top"),r=null):r-a>k_&&e()&&(xo(t,"bottom"),r=null))},{passive:!0}),t.addEventListener("animationend",o=>{o.target===t&&o.animationName.startsWith("edge-flare")&&delete t.dataset.edge})}function Qe(t){const e=document.getElementById(t);if(e===null)throw new Error(`required element #${t} is missing`);return e}function qi(t){const e=Qe(t);if(!(e instanceof HTMLTemplateElement))throw new Error(`#${t} is not a template`);const s=e.content.firstElementChild;if(!(s instanceof HTMLElement))throw new Error(`template #${t} is empty`);return s.cloneNode(!0)}function Ks(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`pane template is missing ${e}`);return s}const Xw=24,kf="argus.dormant";class sO{constructor(e=Xw,s){this.cap=e,this.store=s,this.rehydrate()}cap;store;groups=new Map;add(e){for(this.groups.delete(e.id),this.groups.set(e.id,e);this.groups.size>this.cap;){const s=this.oldest_id();if(s===void 0)break;this.groups.delete(s)}this.persist()}list(){return[...this.groups.values()].sort((e,s)=>s.lastTouched-e.lastTouched)}get(e){return this.groups.get(e)}has(e){return this.groups.has(e)}dismiss(e){const s=this.groups.delete(e);return s&&this.persist(),s}oldest_id(){let e;for(const s of this.groups.values())(e===void 0||s.lastTouched<e.lastTouched)&&(e=s);return e?.id}persist(){if(this.store!==void 0)try{this.store.setItem(kf,JSON.stringify([...this.groups.values()]))}catch{}}rehydrate(){if(this.store!==void 0)try{const e=this.store.getItem(kf);if(e===null)return;const s=JSON.parse(e);if(!Array.isArray(s))return;for(const i of s)i!==null&&typeof i=="object"&&typeof i.id=="string"&&this.groups.set(i.id,i)}catch{}}}function Zw(){try{const t=globalThis.localStorage;return t===void 0?void 0:(t.getItem(kf),t)}catch{return}}function iO(t){if(!t.startsWith("#/"))return null;let e;try{e=decodeURI(t.slice(1))}catch{return null}e=e.replace(/\/+$/,"")||"/";const s=e.split("/").filter(o=>o!==""),i=s[s.length-1]??"";return!s.includes("data")&&(/^feed_\d+$/.test(i)||/^[\w.-]+_\d+$/.test(i)&&s.some(o=>/^feed_\d+$/.test(o)))?{kind:"runs",target:i}:{kind:"folder",path:/\.[A-Za-z0-9]{1,8}$/.test(i)&&!/_\d+$/.test(i)?`/${s.slice(0,-1).join("/")}`:e}}function Jw(t,e){return`${t.replace(/\/+$/,"")}/#${encodeURI(e)}`}const nO=2500;function Qw(t){const e=document.createElement("div");e.className="link-line";const s=document.createElement("button");s.type="button",s.className="link-pill",s.textContent="LINK";const i=document.createElement("span");i.className="link-address",e.append(s,i),tg(e,t);const n=r=>{r.stopPropagation(),ey(e)};return s.addEventListener("click",n),i.addEventListener("click",n),e}function tg(t,e){const s=Jw(window.location.origin,e),i=t.querySelector(".link-address");i!==null&&i.textContent!==s&&(i.textContent=s),t.dataset.link=s,t.title=`a link that opens ARGUS at ${e} — press to copy`}async function ey(t,e=navigator.clipboard){const s=t.dataset.link??"",i=t.querySelector(".link-pill");let n=!1;try{if(e===void 0)throw new Error("no clipboard");await e.writeText(s),n=!0}catch{const o=t.querySelector(".link-address"),a=window.getSelection();if(o!==null&&a!==null){const l=document.createRange();l.selectNodeContents(o),a.removeAllRanges(),a.addRange(l)}}t.dataset.copied=n?"yes":"no",i!==null&&(i.textContent=n?"COPIED":"SELECT + COPY");const r=Date.now();return t.dataset.shown=String(r),setTimeout(()=>{t.dataset.shown===String(r)&&(delete t.dataset.copied,i!==null&&(i.textContent="LINK"))},nO),n}const rO="desktop clear";function ty(t){const e=t.split(`
3
3
  `).map(s=>s.trim()).filter(s=>s!==""&&!s.startsWith("#"));return["# ARGUS view: run these lines in the ARGUS console to see what I see",rO,...e].join(`
4
4
  `)}const N_=2500;function oO(t,e=navigator.clipboard){document.querySelector(".share-sheet")?.remove();const s=document.createElement("div");s.className="share-sheet",s.setAttribute("role","dialog"),s.setAttribute("aria-label","share this view");const i=document.createElement("div");i.className="share-head",i.textContent="SHARE VIEW · THESE LINES, OR THE LINK, PUT ANYONE WHERE YOU ARE";const n=document.createElement("pre");n.className="share-script",n.textContent=t;const r=document.createElement("button");r.type="button",r.className="share-copy share-lines",r.textContent="COPY";const o=document.createElement("button");o.type="button",o.className="share-copy share-link",o.textContent="COPY LINK";const a=document.createElement("button");a.type="button",a.className="share-close",a.textContent="CLOSE";const l=document.createElement("div");l.className="share-pills",l.append(o,r,a),s.append(i,n,l),document.body.appendChild(s),Mi(n,{mount:s});let c=0;const h=async()=>{let d=!1;try{if(e===void 0)throw new Error("no clipboard");await e.writeText(t),d=!0}catch{const p=window.getSelection();if(p!==null){const f=document.createRange();f.selectNodeContents(n),p.removeAllRanges(),p.addRange(f)}}s.dataset.copied=d?"yes":"no",r.textContent=d?"COPIED":"SELECT + COPY";const u=++c;window.setTimeout(()=>{u===c&&(delete s.dataset.copied,r.textContent="COPY")},N_)};return r.addEventListener("click",()=>{h()}),o.addEventListener("click",()=>{const d=aO(window.location.origin,t);(e===void 0?Promise.reject(new Error("no clipboard")):e.writeText(d)).then(()=>{o.textContent="LINK COPIED"},()=>{n.textContent=d,o.textContent="LINK SHOWN: SELECT + COPY"}).finally(()=>{window.setTimeout(()=>{o.textContent="COPY LINK"},N_)})}),a.addEventListener("click",()=>s.remove()),s.addEventListener("keydown",d=>{d.key==="Escape"&&s.remove()}),h(),a.focus(),s}const Nf="view=";function aO(t,e){return`${t.replace(/\/+$/,"")}/#${Nf}${encodeURIComponent(e)}`}function lO(t){if(!t.startsWith(`#${Nf}`))return null;try{const e=decodeURIComponent(t.slice(Nf.length+1));return e.trim()===""?null:e}catch{return null}}function cO(t,e,s){document.querySelector(".share-sheet")?.remove();const i=document.createElement("div");i.className="share-sheet view-ask",i.setAttribute("role","dialog");const n=document.createElement("div");n.className="share-head",n.textContent=e.size>0?`A VIEW FROM ${s.toUpperCase()} · IT ASKS FOR MORE THAN A VIEW, SO IT WILL NOT RUN`:`A VIEW FROM ${s.toUpperCase()} · RUN THESE LINES?`;const r=document.createElement("pre");r.className="share-script",t.forEach((c,h)=>{const d=document.createElement("div");d.textContent=c;const u=e.get(h);u!==void 0&&(d.className="view-refused",d.textContent=`${c} ← ${u}`),r.appendChild(d)});const o=document.createElement("button");o.type="button",o.className="share-copy view-run",o.textContent="RUN",o.disabled=e.size>0;const a=document.createElement("button");a.type="button",a.className="share-close",a.textContent="NOT NOW";const l=document.createElement("div");return l.className="share-pills",l.append(o,a),i.append(n,r,l),document.body.appendChild(i),Mi(r,{mount:i}),(e.size>0?a:o).focus(),new Promise(c=>{const h=d=>{i.remove(),c(d)};o.addEventListener("click",()=>h(!0)),a.addEventListener("click",()=>h(!1)),i.addEventListener("keydown",d=>{d.key==="Escape"&&h(!1)})})}class hO{constructor(e,s){this.host=s,this.grid=e.querySelector(".panes-grid"),this.empty=e.querySelector(".panes-empty"),this.grid.addEventListener("click",this.click_handle)}host;grid;empty;render(){const e=this.host.list();this.empty.hidden=e.length>0,this.grid.replaceChildren(...e.map(s=>this.card_build(s)))}card_build(e){const s=document.createElement("button");s.className="panes-card",s.dataset.restore=e.id,s.title=`restore ${e.label}`;const i=document.createElement("span");if(i.className="panes-card-figure",e.thumbnail!==void 0){const a=document.createElement("img");a.src=e.thumbnail,a.alt="",i.appendChild(a)}else i.classList.add("panes-card-glyph"),i.textContent=e.members.includes("files")&&!e.members.includes("viewer")?"▤":"▣";s.appendChild(i);const n=document.createElement("span");n.className="panes-card-label",n.textContent=e.label,s.appendChild(n);const r=document.createElement("span");r.className="panes-card-badges";for(const a of dO(e.members)){const l=document.createElement("span");l.className="panes-card-badge",l.textContent=a.toUpperCase(),r.appendChild(l)}s.appendChild(r);const o=document.createElement("button");return o.className="panes-card-dismiss",o.dataset.dismiss=e.id,o.title=`forget ${e.label}`,o.textContent="DISMISS",s.appendChild(o),s}click_handle=e=>{const s=e.target,i=s.closest("[data-dismiss]");if(i!==null){e.stopPropagation();const r=i.dataset.dismiss??"";this.host.dismiss(r),this.render();return}const n=s.closest("[data-restore]");n!==null&&this.host.restore(n.dataset.restore??"")}}function dO(t){return[...new Set(t)]}const uO="G1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtChtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA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DswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsybSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzk7MTc7MjRtIBtbMG0bWzM4OzI7MjM7NDU7NjJtLhtbMG0bWzM4OzI7NDE7Nzk7MTA5bTobWzBtG1szODsyOzU5OzExMzsxNTVtPRtbMG0bWzM4OzI7NzU7MTQ0OzE5NW0rG1swbRtbMzg7Mjs3NjsxNDQ7MTkzbSsbWzBtG1szODsyOzE0OzI3OzM3bSAbWzBtG1szODsyOzc1OzE0MjsxODltKxtbMG0bWzM4OzI7Nzc7MTQ1OzE5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OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzE7MjsybSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtChtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg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AbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtCg==",fO=/\x1b\[[0-9;]*m/g,B_="\x1B[0m",G_="\x1B[7m",sy=atob(uO).trimEnd().split(`
@@ -102,7 +102,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
102
102
  `)[0]??""))return`desktop load: cannot read ${s}`;const r=(t.identity_get()??"").split("@")[0]??"",o=r!==""&&(s==="~"||s.startsWith("~/")||s.startsWith(`/home/${r}/`));return`loaded ${s}
103
103
  ${await rp(t,n,o?null:s)}`}let i=window.localStorage.getItem(Eo+s);if(i===null){const n=await t.session_run(`cat ${f0}/${s}.desk`);n.trim().length>0&&!n.includes("No such")&&!n.toLowerCase().includes("error")&&(i=n)}return i===null?`(no desktop '${s}')`:`loaded '${s}'
104
104
  ${await rp(t,i,null)}`}return"desktop save|load|show|list|delete [name] · load <ChRIS file> · clear · share"}const hn={universe:{text:"Every analysis, drawn as a galaxy. Alike analyses cluster; failures glow red. Rearrange it:",list:["GALAXY: grouped by pipeline (the default)","SPOKES · CLUMPS: the same groups, tidier","CONSTELLATIONS: grouped by the tools they used","DATA: hung from the data they began with (format, modality, series)","ACCRETION: grown oldest-first, like next to like"],tail:"Replay its history, or fly in to any one analysis to see its steps."},domains:{text:"The Trusted Domains built in this tenancy: each one's last finished build step, its cluster and what it costs per hour. A domain with a step gone wrong shows in red. Opening the tile, or a domain on it, opens the TD controller: its condition, spec, steps and cost, and the lines that build, verify and tear it down."},capacity:{text:"What this region has free for the machine families your domains use, zone by zone: the cores and memory a new domain or a bigger one could take."},analyses:{text:"Your analyses, newest first. Open one to follow it, read its logs and browse its results."},files:{text:"Your home: the files this session holds."},pacs:{text:"Find studies in the hospital PACS and pull the series you need into ChRIS."},panes:{text:"Saved workspaces: return to a piece of work as you left it."},keys:{text:"Keyboard shortcuts and the commands ARGUS understands."},notes:{text:"A list of updates since the previous release."},console:{text:"A command line into the same session; what you do here shows in the panes, and the other way round."}};function vB(t){return async()=>{const[e,s,i]=await Promise.all([t.ask("ls ~"),t.notes_latest(),t.contribution?.()??Promise.resolve({afterFiles:[],afterPanes:[]})]);let n=[],r="~";for(const m of e.envelopes){if(m.model?.kind!=="fs.listing")continue;const y=m.model.data[0];y!==void 0&&Array.isArray(y.items)&&(n=y.items,typeof y.path=="string"&&(r=y.path))}const o=n.filter(m=>m.type==="dir"),a=t.desktops(),l={key:"files",name:"FILES",hue:"--harvestgold",numeral:"2",figures:[{text:`${n.length} ENTRIES`}],rows:o.slice(0,5).map(m=>({text:m.name,open:()=>t.home_cd(r.endsWith("/")?`${r}${m.name}`:`${r}/${m.name}`)})),verb:"OPEN HOME",about:i.about?.files??hn.files,enter:()=>t.home_open()},c={key:"panes",name:"PANES",hue:"--butter",numeral:"6",figures:[{text:a.length===0?"EMPTY":`${a.length} DESKTOPS`}],rows:a.slice(0,5).map(m=>({text:m.label,open:()=>t.desktop_restore(m.id)})),verb:"SEE DESKTOPS",about:hn.panes,enter:()=>t.panes_open()},h={key:"help",name:"KEYS",hue:"--butter",numeral:"",figures:[{text:`${pn.length} KEYS`},{text:`${ma.length} VERBS`}],rows:pn.slice(0,5).map(m=>({text:`${m.key.padEnd(6)} ${m.does}`,open:()=>t.keys_open()})),verb:"OPEN THE KEYS",about:hn.keys,enter:()=>t.keys_open()},d=s?.releases[0],u=d?.entries.flatMap(m=>m.changes.filter(w=>!w.internal))??[],p={key:"notes",name:"WHAT'S NEW",hue:"--butter",numeral:"",figures:d===void 0?[{text:"NO NOTES"}]:[{text:t.daemon_stale()?"AFTER RESTART":d.date??"UNDATED"},{text:`${u.length} CHANGE${u.length===1?"":"S"}`}],rows:u.slice(0,3).map(m=>({text:`${m.package.padEnd(7)} ${m.headline}`,open:()=>t.notes_open()})),verb:"OPEN THE NOTES",about:hn.notes,enter:()=>t.notes_open()},f={key:"console",name:"CONSOLE",hue:"--daybreak",numeral:"5",figures:[],rows:[],verb:"OPEN THE CONSOLE",about:hn.console,enter:()=>t.console_open()},_=i.lead===void 0?[]:[i.lead.tile],g=[...i.afterFiles,c,...i.afterPanes,h,p,f];return i.lead!==void 0&&i.lead.weight>=n.length?[..._,l,...g]:[l,..._,...g]}}const wB=/\s--(?:\s|$)/;function Ad(t){const e=wB.exec(t),s=e===null?t:t.slice(0,e.index),i=e===null?"":t.slice(e.index),n=s.lastIndexOf(";"),r=n===-1?0:n+1,o=s.slice(r),a=/^\s*\S+/.exec(o),l=r+(a===null?o.length:a[0].length);return{head:s.slice(0,l),args:s.slice(l),tail:i}}function Zz(t,e){return`cd "${t}"; ${e}`}function yB(t){return/^[A-Za-z0-9_./:@+=,-]+$/.test(t)?t:`"${t.replace(/(["\\])/g,"\\$1")}"`}function Jz(t){const e=[],s=/"(?:[^"\\]|\\.)*"|\S+/g;let i=s.exec(t);for(;i!==null;)e.push(i[0]),i=s.exec(t);return e}function _0(t){return t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/\\(["\\])/g,"$1"):t}function Qz(t){return t.startsWith("-")&&t!=="-"&&!/^-\d/.test(t)}function zB(t,e){const s=Jz(Ad(t).args);for(let i=0;i<s.length;i++){const n=s[i]??"";if(n===e){const r=s[i+1];return r===void 0||Qz(r)?!0:_0(r)}if(n.startsWith(`${e}=`))return _0(n.slice(e.length+1))}return null}function b0(t,e,s){const i=Ad(t),n=Jz(i.args),r=[];let o=!1;const a=s===null||s===""?[]:s===!0?[e]:[e,yB(s)];for(let c=0;c<n.length;c++){const h=n[c]??"";if(h===e||h.startsWith(`${e}=`)){if(h===e){const d=n[c+1];d!==void 0&&!Qz(d)&&c++}o||(r.push(...a),o=!0);continue}r.push(h)}o||r.push(...a);const l=r.length===0?"":` ${r.join(" ")}`;return`${i.head}${l}${i.tail}`}function SB(t){return/\bfeed_title=/.test(Ad(t).tail)}function xB(t,e){return`${t} -- feed_title="${e.replace(/(["\\])/g,"\\$1")}"`}function eS(t){return Ad(t).head.replace(/^.*;\s*/,"").trim()}function OB(t,e,s){return/^[A-Za-z0-9_-]+$/.test(t)&&s.filter(n=>n===t).length===1?t:`@${e}`}const tS={listing:"files.row",rules:[{name:"image",label:()=>"IMAGE",offered:t=>t.kind==="seriesFolder"},{name:"gather",label:()=>"GATHER",offered:t=>t.kind!=="catalogue"&&t.projection!==!0},{name:"process",label:()=>"PROCESS",offered:t=>(t.kind==="directory"||t.kind==="seriesFolder")&&(t.feed===null||(t.node??null)!==null)},{name:"run",label:()=>"RUN",offered:t=>t.kind==="catalogue"&&t.bound===!0},{name:"edit",label:()=>"EDIT",offered:t=>t.kind==="file"&&t.editable===!0},{name:"download",label:()=>"DOWNLOAD",offered:t=>t.kind==="file"},{name:"link",label:()=>"LINK",offered:t=>t.kind!=="catalogue"},{name:"move",label:()=>"MOVE",offered:t=>t.kind!=="catalogue"&&t.projection!==!0},{name:"copy",label:()=>"COPY",offered:t=>t.kind!=="catalogue"&&t.projection!==!0},{name:"delete",label:()=>"DELETE",offered:t=>t.kind!=="catalogue"&&t.projection!==!0},{name:"share",label:t=>`SHARE FEED ${t.feed??""}`,offered:t=>t.kind!=="catalogue"&&t.feed!==null&&t.projection!==!0}],states:[{name:"a plain file outside a feed",facts:{kind:"file",feed:null}},{name:"a file inside a feed",facts:{kind:"file",feed:12}},{name:"a directory",facts:{kind:"directory",feed:null}},{name:"a directory inside a feed that is not a node",facts:{kind:"directory",feed:12,node:null}},{name:"a node's data inside a feed",facts:{kind:"directory",feed:12,node:456}},{name:"a DICOM series folder",facts:{kind:"seriesFolder",feed:null}},{name:"a catalogue entry",facts:{kind:"catalogue",feed:null}},{name:"a catalogue entry in a bound catalogue",facts:{kind:"catalogue",feed:null,bound:!0}},{name:"a node's data seen through /proc",facts:{kind:"directory",feed:12,node:456,projection:!0}},{name:"a file seen through /proc",facts:{kind:"file",feed:12,projection:!0}},{name:"a text file",facts:{kind:"file",feed:null,editable:!0}},{name:"a feed's note seen through /proc",facts:{kind:"file",feed:12,projection:!0,editable:!0}}]},sS={listing:"files.selection",rules:[{name:"delete",label:t=>`DELETE ${t.count}`,offered:()=>!0},{name:"move",label:t=>`MOVE ${t.count}`,offered:()=>!0},{name:"copy",label:t=>`COPY ${t.count}`,offered:()=>!0},{name:"share",label:t=>t.feeds.length===1?`SHARE FEED ${t.feeds[0]}`:`SHARE ${t.feeds.length} FEEDS`,offered:t=>t.feeds.length>0}],states:[{name:"a selection outside any feed",facts:{count:3,feeds:[]}},{name:"a selection in one feed",facts:{count:2,feeds:[12]}},{name:"a selection spanning feeds",facts:{count:5,feeds:[12,13]}}]},iS={listing:"runs.row",rules:[{name:"note",label:()=>"NOTE",offered:()=>!0},{name:"tag",label:()=>"TAG",offered:()=>!0},{name:"rename",label:()=>"RENAME",offered:()=>!0},{name:"share",label:()=>"SHARE",offered:()=>!0},{name:"delete",label:()=>"DELETE",offered:()=>!0}],states:[{name:"any feed",facts:{feedId:12}}]},ul={listing:"pacs.study",rules:[{name:"pullStudy",label:()=>"PULL STUDY",offered:t=>t.addressable},{name:"gather",label:()=>"GATHER",offered:t=>t.addressable},{name:"process",label:()=>"PROCESS",offered:t=>t.allInCube}],states:[{name:"a study with a path",facts:{addressable:!0,allInCube:!1}},{name:"a study with none",facts:{addressable:!1,allInCube:!1}},{name:"a study wholly home",facts:{addressable:!0,allInCube:!0,anyInCube:!0}},{name:"a study partly home",facts:{addressable:!0,allInCube:!1,anyInCube:!0}}]},Zr={listing:"pacs.series",rules:[{name:"gather",label:()=>"GATHER",offered:t=>t.addressable||t.inCube},{name:"image",label:()=>"IMAGE",offered:t=>t.inCube&&t.folderKnown},{name:"dir",label:()=>"DIR",offered:t=>t.inCube&&t.folderKnown},{name:"process",label:()=>"PROCESS",offered:t=>t.inCube&&t.folderKnown},{name:"pull",label:()=>"PULL",offered:t=>!t.inCube}],states:[{name:"not yet retrieved",facts:{inCube:!1,folderKnown:!1,addressable:!0}},{name:"not retrieved and unaddressable",facts:{inCube:!1,folderKnown:!1,addressable:!1}},{name:"home, folder not yet named",facts:{inCube:!0,folderKnown:!1,addressable:!0}},{name:"home, folder named",facts:{inCube:!0,folderKnown:!0,addressable:!0}}]},nS={listing:"gather.series",rules:[{name:"remove",label:()=>"REMOVE",offered:()=>!0},{name:"pull",label:()=>"PULL",offered:t=>t.pullable===!0},{name:"image",label:()=>"IMAGE",offered:t=>t.folderKnown&&t.imagery!==!1},{name:"process",label:()=>"PROCESS",offered:()=>!0}],states:[{name:"folder named",facts:{folderKnown:!0}},{name:"a place that is not imagery",facts:{folderKnown:!0,imagery:!1}},{name:"folder not yet named",facts:{folderKnown:!1}},{name:"not retrieved yet",facts:{folderKnown:!1,pullable:!0}}]},rS={listing:"gather.cohort",rules:[{name:"save",label:()=>"SAVE",offered:t=>t.count>0},{name:"export",label:()=>"EXPORT CSV",offered:t=>t.count>0},{name:"feed",label:()=>"CREATE FEED",offered:t=>t.count>0&&t.feed===null},{name:"process",label:()=>"PROCESS",offered:t=>t.count>0},{name:"dismiss",label:()=>"DISMISS",offered:()=>!0}],states:[{name:"holding series",facts:{count:2,feed:null}},{name:"holding series, rooted in a feed",facts:{count:2,feed:4501}},{name:"emptied",facts:{count:0,feed:null}}]};function Fr(t){return{listing:t.listing,visit(e){return e(t)}}}Fr(tS),Fr(sS),Fr(iS),Fr(ul),Fr(Zr),Fr(rS),Fr(nS);function on(t,e){const s=t.rules.find(i=>i.name===e);if(s===void 0)throw new Error(`${t.listing} declares no verb '${e}'`);return s}const Ao={fold:"5.2em",patient:"13em",mrn:"7.5em"};function EB(t){return{inCube:t.pulled===!0,folderKnown:t.folderPath!==void 0,addressable:t.vfsPath!==void 0}}function M0(t){if(t.series.length===0)return null;const e=[];for(const i of t.series){if(i.pulled!==!0||i.folderPath===void 0)return null;e.push(i.folderPath.replace(/\/[^/]+\/?$/,""))}const s=e[0]??"";return e.every(i=>i===s)&&s!==""?s:null}function wn(t){const e=EB(t),s=i=>on(Zr,i).offered(e);return{gather:s("gather"),image:s("image"),dir:s("dir"),pull:s("pull")}}function AB(t,e,s,i){let n=!1;for(const r of t.studies)for(const o of r.series)o.seriesUID===e&&(i!==void 0&&o.folderPath!==i&&(o.folderPath=i,n=!0),o.pulled!==!0&&(o.pulled=!0,s!==void 0&&s>0&&(o.pulledFiles=s),n=!0));return n}const v0=[{id:"pacs-f-name",term:"PatientName"},{id:"pacs-f-mrn",term:"PatientID"},{id:"pacs-f-date",term:"StudyDate"},{id:"pacs-f-accession",term:"AccessionNumber"},{id:"pacs-f-modality",term:"Modality"}],fc={running:"RETRIEVING",done:"✓ PULLED",error:"✗ ERROR",unconfirmed:"? UNCONFIRMED",stalled:"STALLED",queued:"QUEUED",idle:"NOT RETRIEVED"},TB="--fresh",w0="--anon",IB=/\s*--anon\b/,DB=["pacs-f-name","pacs-f-mrn","pacs-f-accession","pacs-f-date"],y0=/\s*--fresh\b/;function z0(t){const e=Date.parse(t);if(Number.isNaN(e))return null;const s=Math.max(0,Math.round((Date.now()-e)/1e3)),i=[{limit:60,size:1,name:"SECOND"},{limit:3600,size:60,name:"MINUTE"},{limit:86400,size:3600,name:"HOUR"},{limit:2592e3,size:86400,name:"DAY"},{limit:31536e3,size:2592e3,name:"MONTH"},{limit:1/0,size:31536e3,name:"YEAR"}];for(const n of i){if(s>=n.limit)continue;const r=Math.max(1,Math.floor(s/n.size));return`${r} ${n.name}${r===1?"":"S"} AGO`}return null}const Vh=new Map;function oS(t,e){const s=Vh.get(t)??new Set;s.add(e),Vh.set(t,s)}const aS=new Map;function lS(t,e){t.replaceChildren(),t.dataset.state=e.status,e.reason!==void 0?t.title=e.reason:t.removeAttribute("title");const s=document.createElement("span");if(s.className="pacs-badge-note",e.status==="idle"){s.textContent=fc.idle,t.append(Uh({done:0,total:0}),s);return}if(e.status==="done"){const a=document.createElement("span");a.className="pacs-bar-full",s.textContent=e.total!==void 0&&e.total>0?`✓ ${e.total} IN CUBE`:"✓ IN CUBE",t.append(a,s);return}if(e.status!=="running"&&e.status!=="queued"){t.textContent=fc[e.status]??e.status.toUpperCase();return}const i=e.total!==void 0?` ${e.current??0}/${e.total}`:"",n=CB(e),r=document.createElement("span");r.className=n===null?"pacs-bar pacs-bar-pacing":"pacs-bar";const o=document.createElement("span");o.className="pacs-bar-fill",n!==null&&(o.style.width=`${Math.round(n*100)}%`),r.appendChild(o),s.textContent=e.status==="queued"?fc.queued:`${fc.running}${i}`,t.append(r,s)}function CB(t){return t.status==="queued"||t.total===void 0||t.total===0||(t.current??0)===0?null:Math.min(1,(t.current??0)/t.total)}function RB(t,e){return t.pulled===!0&&e.status!=="done"&&e.status!=="running"&&e.status!=="queued"}function kB(t,e){const s=Vh.get(t);if(s!==void 0){for(const i of[...s]){if(!i.isConnected){s.delete(i);continue}e(i)}s.size===0&&Vh.delete(t)}}function NB(t){const e=document.createElement("span");if(e.className="pacs-badge",t.pulled===!0){const r=document.createElement("span");r.className="pacs-bar-full";const o=document.createElement("span");return o.className="pacs-badge-note",o.textContent=t.pulledFiles!==void 0?`✓ ${t.pulledFiles} IN CUBE`:"✓ IN CUBE",e.append(r,o),e.dataset.state="done",e}const s=document.createElement("span");s.className="pacs-bar";const i=document.createElement("span");i.className="pacs-badge-note",i.textContent="NOT RETRIEVED",e.append(s,i),e.dataset.state="idle",oS(t.seriesUID,e);const n=aS.get(t.seriesUID);return n!==void 0&&lS(e,n),e}function cS(t,e){return[{key:"series",label:"SERIES",className:"pacs-series-desc",width:"35.5em",cell:s=>t(s).description??""},{key:"state",label:"STATE",className:"pacs-badge",width:"1fr",cell:s=>e(t(s)),compare:s=>t(s).pulled===!0?"done":"idle"},{key:"modality",label:"MODALITY",className:"pacs-series-modality",width:"4em",cell:s=>t(s).modality},{key:"files",label:"FILES",className:"pacs-series-files",width:"6em",cell:s=>{const i=t(s).fileCount;return i!==void 0?`${i} FILES`:""},compare:s=>t(s).fileCount??-1}]}class BB{root;command;results;handlers;litFolders=new Map;badgeStates=new Map;seriesProgress=new Map;studyTracks=new Map;traits;actions;studyTraits;studyActions;patientTraits;listing;patientTracks=new Map;provenance;run;model=null;anon=!1;revealed=!1;anonPill;revealPill;replayed=!1;serverCell;serverStrip;servers=[];chosen=new Set;constructor(e,s){this.root=e,this.handlers=s,this.command=pc(e,"#pacs-command"),this.results=Hi(e,"#pacs-results"),this.traits=this.traits_declare(),this.actions=this.actions_declare(),this.studyTraits=this.studyTraits_declare(),this.studyActions=this.studyActions_declare(),this.patientTraits=this.patientTraits_declare(),this.listing=new Ir({mount:this.results,traits:this.patientTraits,key:i=>i.key,chrome:{root:e,prefix:"pacs"},activatable:i=>i.studies.length>0,address:i=>i.studies.length>0?uk(i.patient):void 0,control:"fold",row:{className:()=>"pacs-patient-row",groupClassName:i=>i.patient.status==="unasked"?"pacs-patient pacs-patient-unasked":"pacs-patient",decorate:(i,n)=>{n.studies.length>0&&(i.title="unfold this patient's studies (the patient keeps its place)")}},child:sa(i=>i.studies.map((n,r)=>({study:n,key:S0(n,r)})),{traits:this.studyTraits,key:i=>i.key,address:i=>i.study.vfsPath,control:"fold",actions:{of:()=>this.studyActions},row:{className:()=>"pacs-study-row",groupClassName:()=>"pacs-study",decorate:i=>{i.title="unfold this study's series (the study keeps its place)"}},child:sa(i=>i.study.series.map(n=>({study:i.study,studyKey:i.key,series:n})),{traits:this.traits,key:i=>i.series.seriesUID,address:i=>i.series.vfsPath,actions:{of:()=>this.actions},row:{className:()=>"pacs-series",decorate:(i,n)=>{i.dataset.seriesuid=n.series.seriesUID}}})}),state:i=>this.stateLine_compose(i),empty:()=>O0("NO STUDIES FOUND")}),e.style.setProperty("--roster-cols",this.listing.template_get(1)),this.listing.rows_set([],{field:"pacs"});for(const{id:i}of v0){const n=pc(e,`#${i}`);n.addEventListener("input",()=>this.command_regenerate()),n.addEventListener("keydown",r=>{r.key==="Enter"&&(r.preventDefault(),this.query_run())})}this.serverCell=Hi(e,"#pacs-f-server"),this.serverStrip=Hi(e,"#pacs-server-strip"),this.serverCell.addEventListener("click",()=>this.serverStrip_toggle()),this.serverCell_sync(),this.provenance=Hi(e,"#pacs-provenance"),this.anonPill=Hi(e,"#pacs-anon"),this.revealPill=Hi(e,"#pacs-reveal"),this.anonPill.addEventListener("click",()=>this.anon_set(!this.anon)),this.revealPill.addEventListener("click",()=>this.reveal_set(!this.revealed)),this.run=Hi(e,"#pacs-run"),this.run.addEventListener("click",()=>this.query_run(this.replayed)),this.command.addEventListener("keydown",i=>{i.key==="Enter"&&this.query_run()}),Hi(e,"#pacs-export").addEventListener("click",()=>this.answer_export()),Hi(e,"#pacs-gather-shown").addEventListener("click",()=>this.shown_gather()),Hi(e,"#pacs-pull-shown").addEventListener("click",()=>this.shown_pull())}patientTraits_declare(){return[{key:"fold",label:"",className:"pacs-fold",capped:!1,width:Ao.fold,cell:e=>{const s=document.createElement("span");return s.className=e.studies.length===0?"pacs-fold pacs-fold-none":"pacs-fold",s}},{key:"patient",label:"PATIENT",className:"pacs-patient-name",width:Ao.patient,cell:e=>e.patient.patientName||"(unknown)"},{key:"mrn",label:"MRN",className:"pacs-patient-mrn",width:Ao.mrn,cell:e=>e.patient.patientId||"—"},{key:"answered",label:"ANSWERED",className:"pacs-patient-answered",width:"12em",cell:e=>{const s=document.createElement("span");if(s.className=e.patient.status==="unasked"?"pacs-patient-answered pacs-unasked":"pacs-patient-answered",e.patient.status==="unasked")return s.textContent="UNASKED",e.patient.error!==void 0&&(s.title=e.patient.error),s;const i=e.patient.provenance?.answeredAt;return s.textContent=i===void 0?"—":z0(i)??"—",i!==void 0&&(s.title=i),s},compare:e=>{const s=e.patient.provenance?.answeredAt;if(s===void 0)return Number.MAX_SAFE_INTEGER;const i=Date.parse(s);return Number.isNaN(i)?Number.MAX_SAFE_INTEGER:i}},{key:"progress",label:"PROGRESS",className:"pacs-patient-progress",width:"1fr",cell:e=>{const s=document.createElement("span");return s.className="pacs-patient-progress",this.patientTracks.set(e.key,{mount:s,uids:e.studies.flatMap(i=>i.series.map(n=>n.seriesUID))}),this.patientTrack_paint(e.key),s},compare:e=>{const s=this.patientProgress_compute(e);return s.total===0?-1:s.done/s.total}},{key:"studies",shed:3,label:"STUDIES",className:"pacs-patient-count",width:"6em",cell:e=>e.patient.status==="unasked"?"—":String(e.patient.studyCount),compare:e=>e.patient.status==="unasked"?-1:e.patient.studyCount},{key:"series",shed:2,label:"SERIES",className:"pacs-patient-count",width:"5em",cell:e=>e.patient.status==="unasked"?"—":String(e.patient.seriesCount),compare:e=>e.patient.status==="unasked"?-1:e.patient.seriesCount},{key:"server",shed:1,label:"SERVER",className:"pacs-patient-server",width:"9em",cell:e=>e.patient.server??this.model?.pacsName??"—"}]}patientProgress_compute(e){return ac(e.studies.flatMap(s=>s.series.map(i=>this.seriesProgress.get(i.seriesUID)??{done:0,total:0})))}patientTrack_paint(e){const s=this.patientTracks.get(e);if(s===void 0)return;const i=s.uids.map(n=>this.seriesProgress.get(n)??{done:0,total:0});s.mount.replaceChildren(Uh(ac(i)))}patientRows_build(e){const s=(r,o)=>e.studies.filter(a=>a.patientId===r&&(o===void 0||a.server===void 0||a.server===o));if(e.patients!==void 0&&e.patients.length>0)return e.patients.map((r,o)=>({patient:r,key:`${r.patientId}::${r.server??""}::${o}`,studies:s(r.patientId,r.server)}));const i=[],n=new Map;for(const r of e.studies){const o=r.patientId;n.has(o)||(n.set(o,[]),i.push(o)),n.get(o).push(r)}return i.map((r,o)=>{const a=n.get(r)??[];return{key:`${r}::${o}`,studies:a,patient:{patientId:r,...a[0]?.patientName?{patientName:a[0].patientName}:{},status:"found",studyCount:a.length,seriesCount:a.reduce((l,c)=>l+c.series.length,0),...e.provenance===void 0?{}:{provenance:e.provenance}}}})}studyTraits_declare(){return[{key:"fold",label:"",className:"pacs-fold",capped:!1,width:Ao.fold,cell:()=>{const e=document.createElement("span");return e.className="pacs-fold",e}},{key:"patient",label:"PATIENT",className:"pacs-study-patient",width:Ao.patient,cell:e=>e.study.patientName||"(unknown)"},{key:"mrn",label:"MRN",className:"pacs-study-mrn",width:Ao.mrn,cell:e=>e.study.patientId||"—"},{key:"study",label:"STUDY",className:"pacs-study-desc",width:"12em",cell:e=>e.study.description||"(no description)"},{key:"progress",label:"PROGRESS",className:"pacs-study-progress",width:"1fr",cell:e=>{const s=document.createElement("span");return s.className="pacs-study-progress",this.studyTracks.set(e.key,{mount:s,uids:e.study.series.map(i=>i.seriesUID)}),this.studyTrack_paint(e.key),s},compare:e=>{const s=this.studyProgress_compute(e);return s.total===0?-1:s.done/s.total}},{key:"date",label:"DATE",className:"pacs-study-date",width:"7.5em",cell:e=>e.study.date},{key:"accession",label:"ACCESSION",className:"pacs-study-accession",width:"9em",cell:e=>e.study.accession||"—"},{key:"modality",label:"MODALITY",className:"pacs-study-modalities",width:"6.5em",cell:e=>e.study.modalities},{key:"server",label:"SERVER",className:"pacs-study-server",width:"9em",cell:e=>e.study.server??this.model?.pacsName??"—"},{key:"series",label:"SERIES",className:"pacs-study-count",width:"6.5em",cell:e=>String(e.study.series.length),compare:e=>e.study.series.length}]}studyActions_declare(){return[{label:on(ul,"pullStudy").label({addressable:!0,allInCube:!1}),offered:e=>on(ul,"pullStudy").offered({addressable:e.study.vfsPath!==void 0,allInCube:!1}),run:e=>{const s=e.study.vfsPath;if(s!==void 0){this.handlers.command_run(`pull ${s}`);for(const i of e.study.series)i.vfsPath!==void 0&&i.pulled!==!0&&this.badgeState_set(i.seriesUID,{status:"queued"})}}},{label:on(ul,"gather").label({addressable:!0,allInCube:!1,anyInCube:!0}),offered:e=>e.study.series.some(s=>wn(s).gather),run:e=>{const s=e.study.series.filter(n=>wn(n).gather);for(const n of s)this.gather_note(e.study,n);const i=e.study.series.length-s.length;this.handlers.note(`gather: ${s.length} series gathered${i>0?`, ${i} not in CUBE (pull them first)`:""}`)}},{label:on(ul,"process").label({addressable:!0,allInCube:!0}),offered:e=>M0(e.study)!==null,run:e=>{const s=M0(e.study);s!==null&&this.handlers.process_open(s)}}]}studyProgress_compute(e){return ac(e.study.series.map(s=>this.seriesProgress.get(s.seriesUID)??{done:0,total:0}))}traits_declare(){return cS(e=>e.series,e=>this.badge_build(e))}actions_declare(){return[{label:on(Zr,"gather").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>wn(e.series).gather,selected:e=>this.handlers.gathered_is(e.series.seriesUID),run:e=>this.gather_note(e.study,e.series)},{label:on(Zr,"image").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>wn(e.series).image,selected:e=>e.series.folderPath!==void 0&&(this.litFolders.get(x0(e.series.folderPath))?.viewer??!1),run:e=>{e.series.folderPath!==void 0&&this.handlers.image_open(e.series.folderPath)}},{label:on(Zr,"dir").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>wn(e.series).dir,selected:e=>e.series.folderPath!==void 0&&(this.litFolders.get(x0(e.series.folderPath))?.browser??!1),run:e=>{e.series.folderPath!==void 0&&this.handlers.dir_open(e.series.folderPath)}},{label:on(Zr,"process").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>wn(e.series).image,run:e=>{e.series.folderPath!==void 0&&this.handlers.process_open(e.series.folderPath)}},{label:on(Zr,"pull").label({inCube:!1,folderKnown:!1,addressable:!0}),offered:e=>wn(e.series).pull,disabled:e=>e.series.vfsPath===void 0,run:e=>{const s=e.series.vfsPath;s!==void 0&&(this.handlers.command_run(`pull ${s}`),this.badgeState_set(e.series.seriesUID,{status:"queued"}))}}]}state_name(e){return e.pulled===!0?"pulled":this.badgeStates.get(e.seriesUID)?.status??"idle"}command_regenerate(){const e=[];for(const{id:n,term:r}of v0){const o=pc(this.root,`#${n}`).value.trim();o.length>0&&e.push(`${r}:${o}`)}const s=this.chosen.size>1?` --pacsserver ${[...this.chosen].join(",")}`:"",i=this.anon?` ${w0}`:"";this.command.value=e.length>0||s!==""?`pacs query ${e.join(",")}${s}${i}`:""}anon_set(e){e!==this.anon&&(this.anon=e,this.revealed=!1,this.anonPill.textContent=e?"ANON ON":"ANON OFF",this.anonPill.classList.toggle("pacs-capsule-off",!e),this.revealPill.hidden=!e,this.model=null,this.listing.rows_set([],{field:"pending"}),this.provenance_show(void 0),this.command.value=e?`${this.command.value.trim()} ${w0}`.trim():this.command.value.replace(IB,"").trimEnd(),this.masking_apply())}reveal_set(e){this.revealed=e,this.revealPill.textContent=e?"HIDE":"REVEAL",this.revealPill.classList.toggle("pacs-capsule-off",!e),this.masking_apply()}masking_apply(){const e=this.anon&&!this.revealed;for(const s of DB)pc(this.root,`#${s}`).type=e?"password":"text";this.command.type=e?"password":"text"}serverStrip_toggle(e){const s=e??this.serverStrip.hidden;this.serverStrip.hidden=!s,this.serverCell.classList.toggle("pacs-server-open",s),s&&this.servers.length===0&&this.servers_ask(),s&&this.serverStrip_paint()}query_get(){return this.model===null?null:`pacs query ${this.model.expression}`}serverStrip_isOpen(){return!this.serverStrip.hidden}serverStrip_close(){this.serverStrip_toggle(!1)}servers_ask(){this.handlers.command_run("pacs list")}servers_take(e){this.servers=e,this.serverStrip_paint(),this.serverCell_sync()}serverStrip_paint(){if(this.serverStrip.replaceChildren(),this.servers.length===0){this.serverStrip.appendChild(O0("ASKING THE SESSION FOR REGISTERED SERVERS"));return}for(const e of this.servers){const s=document.createElement("button");s.className=this.chosen.has(e.identifier)?"pacs-server-segment pacs-server-chosen":"pacs-server-segment",s.dataset.server=e.identifier,s.textContent=e.identifier,e.active&&(s.title="the session is connected to this server"),s.addEventListener("click",()=>this.server_choose(e.identifier)),this.serverStrip.appendChild(s)}}server_choose(e){if(this.chosen.has(e)?this.chosen.delete(e):this.chosen.add(e),this.chosen.size===1){const s=[...this.chosen][0];this.handlers.command_show(`pacs connect ${s}`)}this.serverStrip_paint(),this.serverCell_sync(),this.command_regenerate()}serverCell_sync(){const e=[...this.chosen];if(e.length===0){const s=this.servers.find(i=>i.active);this.serverCell.textContent=s?.identifier??"—",this.serverCell.classList.remove("pacs-server-many");return}this.serverCell.textContent=e.length===1?e[0]:`${e[0]} +${e.length-1}`,this.serverCell.classList.toggle("pacs-server-many",e.length>1)}wrote_show(e){const s=this.root.querySelector("#pacs-wrote");s!==null&&(s.textContent=`WROTE ${e}`,s.title="open the folder this landed in",s.classList.add("pacs-wrote-opens"),s.onclick=()=>{const i=e.lastIndexOf("/");this.handlers.dir_open(i<=0?e:e.slice(0,i))},s.hidden=!1)}answer_export(){if(this.model===null)return;const e=this.command.value.trim(),s=e===""?`pacs query ${this.model.expression}`:e;this.handlers.command_show(`${s} --csv-to`)}query_run(e=!1){e&&!y0.test(this.command.value)&&(this.command.value=`${this.command.value.trim()} ${TB}`);const s=this.command.value.trim();s.length!==0&&(this.model=null,this.listing.rows_set([],{field:"pending"}),this.listing.field_get()?.appendChild(this.waiting_build()),this.handlers.command_run(s))}provenance_show(e){if(this.replayed=e?.replayed===!0,this.run.textContent=this.replayed?"RE-QUERY":"QUERY",this.run.classList.toggle("pacs-capsule-requery",this.replayed),this.provenance.hidden=!this.replayed,!this.replayed){this.provenance.textContent="",this.command.value=this.command.value.replace(y0,"").trimEnd();return}const s=e?.answeredAt??"",i=z0(s),n=s.slice(0,10);this.provenance.textContent=i===null?`RESULTS ${n}`:`RESULTS ${n} · ${i}`,this.provenance.title=s}waiting_build(){const e=document.createElement("div");e.className="pacs-waiting";const s=document.createElement("span");s.className="pacs-bar pacs-bar-pacing";const i=document.createElement("span");i.className="pacs-bar-fill",s.appendChild(i);const n=document.createElement("span");return n.className="pacs-waiting-note",n.textContent="QUERYING THE PACS…",e.append(s,n),e}envelope_observe(e){const s=/✓ wrote (\S+)/.exec((e.rendered??"").replace(/\x1b\[[0-9;]*m/g,""));if(s!==null&&this.wrote_show(s[1]),e.model?.kind===hk){const n=ck.safeParse(e.model.data);n.success&&this.servers_take(n.data.servers);return}if(e.model?.kind!==dk)return;const i=ak.safeParse(e.model.data);i.success&&this.results_render(i.data)}progress_observe(e){if(e.operation!=="pull"||e.itemId===void 0)return;const s=e.status??"running",i={status:s};e.current!==void 0&&(i.current=e.current),e.total!==void 0&&(i.total=e.total),e.reason!==void 0&&(i.reason=e.reason),this.badgeState_set(e.itemId,i),s==="done"&&this.model!==null&&AB(this.model,e.itemId,e.current??e.total,e.path)&&this.results_repaint()}badgeState_set(e,s){this.badgeStates.set(e,s),aS.set(e,s),this.seriesProgress.set(e,PB(s,this.seriesProgress.get(e))),kB(e,i=>this.badge_paint(i,s));for(const[i,n]of this.studyTracks)n.uids.includes(e)&&this.studyTrack_paint(i);for(const[i,n]of this.patientTracks)n.uids.includes(e)&&this.patientTrack_paint(i)}badge_build(e){const s=document.createElement("span");if(s.className="pacs-badge",e.pulled===!0){const i=document.createElement("span");i.className="pacs-bar-full";const n=document.createElement("span");return n.className="pacs-badge-note",n.textContent=e.pulledFiles!==void 0?`✓ ${e.pulledFiles} IN CUBE`:"✓ IN CUBE",s.append(i,n),s.dataset.state="done",s}return oS(e.seriesUID,s),this.badge_paint(s,this.badgeStates.get(e.seriesUID)??{status:"idle"}),s}badge_paint(e,s){lS(e,s)}results_render(e){const s=this.model!==null&&this.model.queryId===e.queryId;if(this.model=e,this.provenance_show(e.provenance),!s){this.listing.open_clear(),this.badgeStates.clear();const i=this.patientRows_build(e),n=i.length===1?i[0]:void 0;n!==void 0&&n.studies.length>0&&this.listing.open_set(0,[n.key]),e.studies.length===1&&this.listing.open_set(1,[S0(e.studies[0],0)])}for(const i of e.studies)for(const n of i.series){const r=this.badgeStates.get(n.seriesUID);if(r!==void 0&&RB(n,r)){this.badgeState_set(n.seriesUID,{status:"done",...n.pulledFiles!==void 0?{total:n.pulledFiles}:{}});continue}s&&r!==void 0||this.seriesProgress.set(n.seriesUID,GB(n))}this.results_repaint()}results_repaint(){const e=this.model;if(this.studyTracks.clear(),this.patientTracks.clear(),e===null){this.listing.rows_set([],{field:"pacs"});return}this.listing.rows_set([{key:String(e.queryId),rows:this.patientRows_build(e)}],{field:String(e.queryId)})}studyTrack_paint(e){const s=this.studyTracks.get(e);if(s===void 0)return;const i=s.uids.map(n=>this.seriesProgress.get(n)??{done:0,total:0});s.mount.replaceChildren(Uh(ac(i)))}stateLine_compose(e){queueMicrotask(()=>{this.shownGather_render(),this.shownPull_render()});const s=[],i=this.model?.patients??[];if(i.length>0){const n=r=>i.filter(o=>o.status===r).length;s.push(`FOUND ${n("found")} · NONE ${n("none")} · UNASKED ${n("unasked")}`)}return e.filter!==""&&s.push(e.filter),s.join(" · ")}filter_toggle(e){this.listing.filter_toggle(e)}shown_candidates(){const e=[];if(!this.filtering()){for(const s of this.model?.studies??[])for(const i of s.series)e.push({study:s,series:i});return e}for(const s of this.root.querySelectorAll("#pacs-results .pacs-series")){const i=s.dataset.seriesuid;if(i!==void 0)for(const n of this.model?.studies??[]){const r=n.series.find(o=>o.seriesUID===i);r!==void 0&&e.push({study:n,series:r})}}return e}filtering(){return this.listing.filterText_get()!==""}shown_gatherable(){return this.shown_candidates().filter(({series:e})=>wn(e).gather&&!this.handlers.gathered_is(e.seriesUID))}shownGather_render(){const e=this.root.querySelector("#pacs-gather-shown");if(e===null)return;const s=this.shown_gatherable().length;e.hidden=s===0,e.textContent=this.filtering()?`GATHER ${s} SHOWN`:`GATHER ${s}`}shown_pullable(){return this.shown_candidates().map(({series:e})=>e).filter(e=>wn(e).pull&&e.vfsPath!==void 0)}shownPull_render(){const e=this.root.querySelector("#pacs-pull-shown");if(e===null)return;const s=this.shown_pullable().length;e.hidden=s===0,e.textContent=this.filtering()?`PULL ${s} SHOWN`:`PULL ${s}`}shown_pull(){const e=this.shown_pullable();if(e.length===0)return;const s=e.map(i=>`"${i.vfsPath}"`).join(" ");this.handlers.command_show(`pull ${s}`);for(const i of e)this.badgeState_set(i.seriesUID,{status:"queued"});this.handlers.note(`pull: ${e.length} series asked for`),this.shownPull_render()}shown_gather(){const e=this.shown_gatherable();if(e.length!==0){for(const{study:s,series:i}of e)this.gather_note(s,i);this.handlers.note(this.filtering()?`gather: ${e.length} series gathered from what the filter left showing`:`gather: ${e.length} series gathered from the whole answer`),this.shownGather_render()}}gather_note(e,s){s.vfsPath!==void 0&&(this.handlers.gather_add({seriesUID:s.seriesUID,description:s.description,modality:s.modality,series:s,patient:e.patientId||e.patientName,...e.description===void 0||e.description===""?{}:{study:e.description},vfsPath:s.vfsPath,...s.folderPath!==void 0?{folderPath:s.folderPath}:{},...s.fileCount!==void 0?{files:s.fileCount}:{}}),this.selected_refresh())}stage_lit(e){this.litFolders=e,this.selected_refresh()}selected_refresh(){this.listing.indication_refresh()}}function S0(t,e){return t.studyUID??`study-${e}`}function x0(t){return t.replace(/\/$/,"")}function GB(t){const e=t.pulledFiles??0,s=Math.max(t.fileCount??0,e);return t.pulled===!0?{done:s,total:s}:{done:e,total:s}}function PB(t,e){const s=t.total??e?.total??0;return t.status==="error"?{done:t.current??e?.done??0,total:s,failed:!0}:t.status==="done"?{done:s,total:s}:{done:t.current??e?.done??0,total:s}}function Hi(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`PACS workspace is missing '${e}'`);return s}function pc(t,e){const s=Hi(t,e);if(!(s instanceof HTMLInputElement))throw new Error(`'${e}' is not an input`);return s}function O0(t){const e=document.createElement("p");return e.className="files-empty",e.textContent=t,e}class LB{result;handlers;constructor(e,s){this.handlers=s,this.result=Pa(e,".empty-result"),Mi(this.result);const i=Pa(e,".empty-prompt");i.addEventListener("keydown",n=>{n.key==="Enter"&&i.value.trim().length>0&&(this.line_run(i.value.trim()),i.value="")}),Pa(e,".empty-go-files").addEventListener("click",()=>{this.line_run("ls .")}),Pa(e,".empty-go-dag").addEventListener("click",()=>{this.line_run("proc feeds")}),Pa(e,".empty-go-pacs").addEventListener("click",()=>{this.handlers.claim("pacs",[])}),window.setTimeout(()=>i.focus(),0)}async line_run(e){this.result.textContent="…";let s;try{s=await this.handlers.execute(e)}catch(n){this.result.textContent=n instanceof Error?n.message:String(n);return}for(const n of s.envelopes){const r=n.model?.kind!==void 0?this.handlers.claimKind_find(n.model.kind):void 0;if(r!==void 0){this.handlers.claim(r,s.envelopes);return}}const i=s.envelopes.map(n=>n.rendered).join(`
105
- `);this.result.textContent=WB(i)||"(no output)"}}function Pa(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`empty pane template is missing ${e}`);return s}function WB(t){return t.replace(/\x1b\[[0-9;:]*[A-Za-z]/g,"")}class FB{routes=new Map([["console",new Map],["ambient",new Map]]);observers=new Map([["console",[]],["ambient",[]]]);claims=new Map;claimers=new Map;watchers=[];route_add(e,s,i){const n=this.routes.get(e);for(const r of s)n.set(r,[...n.get(r)??[],i])}observer_add(e,s){this.observers.get(e).push(i=>(s(i),!1))}route(e,s){const i=s.model?.kind;if(i===void 0)return!1;let n=!1;for(const r of this.routes.get(e).get(i)??[])n=r(s)||n;return n}observe(e,s){for(const i of this.observers.get(e))i(s)}claim_add(e,s,i){this.claims.set(e,s),i!==void 0&&this.claimers.set(s,i)}claimKind_find(e){return this.claims.get(e)}claimer_get(e){return this.claimers.get(e)}watcher_add(e){this.watchers.push(e)}watched(e,s){for(const i of this.watchers)i(e,s)}}function UB(t,e){t.route_add("console",[_k.view],i=>{const n=gk.safeParse(i.model?.data);return n.success&&e.image_open(n.data.path,n.data.force===!0),!0}),t.route_add("console",["feed.dag","feed.list",br.feedIndexing],i=>(e.dag_target().envelope_observe(i),!0)),t.observer_add("console",i=>e.pacs().envelope_observe(i)),t.route_add("ambient",["feed.dag"],i=>{const n=bg.safeParse(i.model?.data);if(!n.success)return!0;for(const r of e.dags())r.model_refresh(n.data);for(const r of e.universes())r.model_refresh(n.data);return!0}),t.watcher_add((i,n)=>{for(const r of e.dags())r.watched_observe(i,n);for(const r of e.universes())r.watched_observe(i,n)});const s=(i,n)=>{const r=e.dag_get(e.pane_replace(i,"dag"));for(const o of n)r?.envelope_observe(o)};t.claim_add("feed.dag","dag",s),t.claim_add("feed.list","dag",s),t.claim_add("pacs.query","pacs",(i,n)=>{e.pacs_present();for(const r of n)e.pacs().envelope_observe(r)}),t.claim_add(Qo.series,"image",(i,n)=>{const r=e.image_get(e.pane_replace(i,"image"));for(const o of n){if(o.model?.kind!==Qo.series)continue;const a=hz.safeParse(o.model.data);a.success&&r?.series_show(a.data)}}),t.claim_add(Qo.tags,"tags",(i,n)=>{const r=e.tags_get(e.pane_replace(i,"tags"));for(const o of n){if(o.model?.kind!==Qo.tags)continue;const a=cz.safeParse(o.model.data);a.success&&r?.model_show(a.data)}})}const Bg="185",$B=0,E0=1,jB=2,mh=1,HB=2,fl=3,Cr=0,si=1,Nn=2,Wn=0,ao=1,Rr=2,A0=3,T0=4,VB=5,Jr=100,qB=101,KB=102,YB=103,XB=104,ZB=200,JB=201,QB=202,eG=203,op=204,ap=205,tG=206,sG=207,iG=208,nG=209,rG=210,oG=211,aG=212,lG=213,cG=214,lp=0,cp=1,hp=2,ga=3,dp=4,up=5,fp=6,pp=7,hS=0,hG=1,dG=2,mn=0,dS=1,uS=2,fS=3,pS=4,mS=5,gS=6,_S=7,bS=300,mo=301,_a=302,fu=303,pu=304,Td=306,mp=1e3,Bn=1001,gp=1002,Is=1003,uG=1004,mc=1005,Ls=1006,mu=1007,eo=1008,bi=1009,MS=1010,vS=1011,Gl=1012,Gg=1013,Mn=1014,Xi=1015,jn=1016,Pg=1017,Lg=1018,Pl=1020,wS=35902,yS=35899,zS=1021,SS=1022,Zi=1023,Hn=1026,to=1027,Wg=1028,Fg=1029,go=1030,Ug=1031,$g=1033,gh=33776,_h=33777,bh=33778,Mh=33779,_p=35840,bp=35841,Mp=35842,vp=35843,wp=36196,yp=37492,zp=37496,Sp=37488,xp=37489,qh=37490,Op=37491,Ep=37808,Ap=37809,Tp=37810,Ip=37811,Dp=37812,Cp=37813,Rp=37814,kp=37815,Np=37816,Bp=37817,Gp=37818,Pp=37819,Lp=37820,Wp=37821,Fp=36492,Up=36494,$p=36495,jp=36283,Hp=36284,Kh=36285,Vp=36286,fG=3200,qp=0,pG=1,ur="",Oi="srgb",Yh="srgb-linear",Xh="linear",Dt="srgb",To=7680,I0=519,mG=512,gG=513,_G=514,jg=515,bG=516,MG=517,Hg=518,vG=519,Kp=35044,D0="300 es",un=2e3,Ll=2001;function wG(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Zh(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function yG(){const t=Zh("canvas");return t.style.display="block",t}const C0={};function Jh(...t){const e="THREE."+t.shift();console.log(e,...t)}function xS(t){const e=t[0];if(typeof e=="string"&&e.startsWith("TSL:")){const s=t[1];s&&s.isStackTrace?t[0]+=" "+s.getLocation():t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}function Je(...t){t=xS(t);const e="THREE."+t.shift();{const s=t[0];s&&s.isStackTrace?console.warn(s.getError(e)):console.warn(e,...t)}}function _t(...t){t=xS(t);const e="THREE."+t.shift();{const s=t[0];s&&s.isStackTrace?console.error(s.getError(e)):console.error(e,...t)}}function ia(...t){const e=t.join(" ");e in C0||(C0[e]=!0,Je(...t))}function zG(t,e,s){return new Promise(function(i,n){function r(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:n();break;case t.TIMEOUT_EXPIRED:setTimeout(r,s);break;default:i()}}setTimeout(r,s)})}const SG={[lp]:cp,[hp]:fp,[dp]:pp,[ga]:up,[cp]:lp,[fp]:hp,[pp]:dp,[up]:ga};class Mo{addEventListener(e,s){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(s)===-1&&i[e].push(s)}hasEventListener(e,s){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(s)!==-1}removeEventListener(e,s){const i=this._listeners;if(i===void 0)return;const n=i[e];if(n!==void 0){const r=n.indexOf(s);r!==-1&&n.splice(r,1)}}dispatchEvent(e){const s=this._listeners;if(s===void 0)return;const i=s[e.type];if(i!==void 0){e.target=this;const n=i.slice(0);for(let r=0,o=n.length;r<o;r++)n[r].call(this,e);e.target=null}}}const ks=["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"],gu=Math.PI/180,Yp=180/Math.PI;function zr(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(ks[t&255]+ks[t>>8&255]+ks[t>>16&255]+ks[t>>24&255]+"-"+ks[e&255]+ks[e>>8&255]+"-"+ks[e>>16&15|64]+ks[e>>24&255]+"-"+ks[s&63|128]+ks[s>>8&255]+"-"+ks[s>>16&255]+ks[s>>24&255]+ks[i&255]+ks[i>>8&255]+ks[i>>16&255]+ks[i>>24&255]).toLowerCase()}function Mt(t,e,s){return Math.max(e,Math.min(s,t))}function xG(t,e){return(t%e+e)%e}function _u(t,e,s){return(1-s)*t+s*e}function dn(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function kt(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const O_=class O_{constructor(e=0,s=0){this.x=e,this.y=s}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,s){return this.x=e,this.y=s,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,s){switch(e){case 0:this.x=s;break;case 1:this.y=s;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: 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,s){return this.x=e.x+s.x,this.y=e.y+s.y,this}addScaledVector(e,s){return this.x+=e.x*s,this.y+=e.y*s,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,s){return this.x=e.x-s.x,this.y=e.y-s.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){const s=this.x,i=this.y,n=e.elements;return this.x=n[0]*s+n[3]*i+n[6],this.y=n[1]*s+n[4]*i+n[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,s){return this.x=Mt(this.x,e.x,s.x),this.y=Mt(this.y,e.y,s.y),this}clampScalar(e,s){return this.x=Mt(this.x,e,s),this.y=Mt(this.y,e,s),this}clampLength(e,s){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Mt(i,e,s))}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){const s=Math.sqrt(this.lengthSq()*e.lengthSq());if(s===0)return Math.PI/2;const i=this.dot(e)/s;return Math.acos(Mt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const s=this.x-e.x,i=this.y-e.y;return s*s+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,s){return this.x+=(e.x-this.x)*s,this.y+=(e.y-this.y)*s,this}lerpVectors(e,s,i){return this.x=e.x+(s.x-e.x)*i,this.y=e.y+(s.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,s=0){return this.x=e[s],this.y=e[s+1],this}toArray(e=[],s=0){return e[s]=this.x,e[s+1]=this.y,e}fromBufferAttribute(e,s){return this.x=e.getX(s),this.y=e.getY(s),this}rotateAround(e,s){const i=Math.cos(s),n=Math.sin(s),r=this.x-e.x,o=this.y-e.y;return this.x=r*i-o*n+e.x,this.y=r*n+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};O_.prototype.isVector2=!0;let tt=O_;class vo{constructor(e=0,s=0,i=0,n=1){this.isQuaternion=!0,this._x=e,this._y=s,this._z=i,this._w=n}static slerpFlat(e,s,i,n,r,o,a){let l=i[n+0],c=i[n+1],h=i[n+2],d=i[n+3],u=r[o+0],p=r[o+1],f=r[o+2],_=r[o+3];if(d!==_||l!==u||c!==p||h!==f){let g=l*u+c*p+h*f+d*_;g<0&&(u=-u,p=-p,f=-f,_=-_,g=-g);let m=1-a;if(g<.9995){const w=Math.acos(g),y=Math.sin(w);m=Math.sin(m*w)/y,a=Math.sin(a*w)/y,l=l*m+u*a,c=c*m+p*a,h=h*m+f*a,d=d*m+_*a}else{l=l*m+u*a,c=c*m+p*a,h=h*m+f*a,d=d*m+_*a;const w=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=w,c*=w,h*=w,d*=w}}e[s]=l,e[s+1]=c,e[s+2]=h,e[s+3]=d}static multiplyQuaternionsFlat(e,s,i,n,r,o){const a=i[n],l=i[n+1],c=i[n+2],h=i[n+3],d=r[o],u=r[o+1],p=r[o+2],f=r[o+3];return e[s]=a*f+h*d+l*p-c*u,e[s+1]=l*f+h*u+c*d-a*p,e[s+2]=c*f+h*p+a*u-l*d,e[s+3]=h*f-a*d-l*u-c*p,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,s,i,n){return this._x=e,this._y=s,this._z=i,this._w=n,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,s=!0){const i=e._x,n=e._y,r=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(i/2),h=a(n/2),d=a(r/2),u=l(i/2),p=l(n/2),f=l(r/2);switch(o){case"XYZ":this._x=u*h*d+c*p*f,this._y=c*p*d-u*h*f,this._z=c*h*f+u*p*d,this._w=c*h*d-u*p*f;break;case"YXZ":this._x=u*h*d+c*p*f,this._y=c*p*d-u*h*f,this._z=c*h*f-u*p*d,this._w=c*h*d+u*p*f;break;case"ZXY":this._x=u*h*d-c*p*f,this._y=c*p*d+u*h*f,this._z=c*h*f+u*p*d,this._w=c*h*d-u*p*f;break;case"ZYX":this._x=u*h*d-c*p*f,this._y=c*p*d+u*h*f,this._z=c*h*f-u*p*d,this._w=c*h*d+u*p*f;break;case"YZX":this._x=u*h*d+c*p*f,this._y=c*p*d+u*h*f,this._z=c*h*f-u*p*d,this._w=c*h*d-u*p*f;break;case"XZY":this._x=u*h*d-c*p*f,this._y=c*p*d-u*h*f,this._z=c*h*f+u*p*d,this._w=c*h*d+u*p*f;break;default:Je("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return s===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,s){const i=s/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const s=e.elements,i=s[0],n=s[4],r=s[8],o=s[1],a=s[5],l=s[9],c=s[2],h=s[6],d=s[10],u=i+a+d;if(u>0){const p=.5/Math.sqrt(u+1);this._w=.25/p,this._x=(h-l)*p,this._y=(r-c)*p,this._z=(o-n)*p}else if(i>a&&i>d){const p=2*Math.sqrt(1+i-a-d);this._w=(h-l)/p,this._x=.25*p,this._y=(n+o)/p,this._z=(r+c)/p}else if(a>d){const p=2*Math.sqrt(1+a-i-d);this._w=(r-c)/p,this._x=(n+o)/p,this._y=.25*p,this._z=(l+h)/p}else{const p=2*Math.sqrt(1+d-i-a);this._w=(o-n)/p,this._x=(r+c)/p,this._y=(l+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,s){let i=e.dot(s)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*s.z-e.z*s.y,this._y=e.z*s.x-e.x*s.z,this._z=e.x*s.y-e.y*s.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Mt(this.dot(e),-1,1)))}rotateTowards(e,s){const i=this.angleTo(e);if(i===0)return this;const n=Math.min(1,s/i);return this.slerp(e,n),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=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,s){const i=e._x,n=e._y,r=e._z,o=e._w,a=s._x,l=s._y,c=s._z,h=s._w;return this._x=i*h+o*a+n*c-r*l,this._y=n*h+o*l+r*a-i*c,this._z=r*h+o*c+i*l-n*a,this._w=o*h-i*a-n*l-r*c,this._onChangeCallback(),this}slerp(e,s){let i=e._x,n=e._y,r=e._z,o=e._w,a=this.dot(e);a<0&&(i=-i,n=-n,r=-r,o=-o,a=-a);let l=1-s;if(a<.9995){const c=Math.acos(a),h=Math.sin(c);l=Math.sin(l*c)/h,s=Math.sin(s*c)/h,this._x=this._x*l+i*s,this._y=this._y*l+n*s,this._z=this._z*l+r*s,this._w=this._w*l+o*s,this._onChangeCallback()}else this._x=this._x*l+i*s,this._y=this._y*l+n*s,this._z=this._z*l+r*s,this._w=this._w*l+o*s,this.normalize();return this}slerpQuaternions(e,s,i){return this.copy(e).slerp(s,i)}random(){const e=2*Math.PI*Math.random(),s=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(n*Math.sin(e),n*Math.cos(e),r*Math.sin(s),r*Math.cos(s))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,s=0){return this._x=e[s],this._y=e[s+1],this._z=e[s+2],this._w=e[s+3],this._onChangeCallback(),this}toArray(e=[],s=0){return e[s]=this._x,e[s+1]=this._y,e[s+2]=this._z,e[s+3]=this._w,e}fromBufferAttribute(e,s){return this._x=e.getX(s),this._y=e.getY(s),this._z=e.getZ(s),this._w=e.getW(s),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}}const E_=class E_{constructor(e=0,s=0,i=0){this.x=e,this.y=s,this.z=i}set(e,s,i){return i===void 0&&(i=this.z),this.x=e,this.y=s,this.z=i,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,s){switch(e){case 0:this.x=s;break;case 1:this.y=s;break;case 2:this.z=s;break;default:throw new Error("THREE.Vector3: 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 new Error("THREE.Vector3: 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,s){return this.x=e.x+s.x,this.y=e.y+s.y,this.z=e.z+s.z,this}addScaledVector(e,s){return this.x+=e.x*s,this.y+=e.y*s,this.z+=e.z*s,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,s){return this.x=e.x-s.x,this.y=e.y-s.y,this.z=e.z-s.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,s){return this.x=e.x*s.x,this.y=e.y*s.y,this.z=e.z*s.z,this}applyEuler(e){return this.applyQuaternion(R0.setFromEuler(e))}applyAxisAngle(e,s){return this.applyQuaternion(R0.setFromAxisAngle(e,s))}applyMatrix3(e){const s=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*s+r[3]*i+r[6]*n,this.y=r[1]*s+r[4]*i+r[7]*n,this.z=r[2]*s+r[5]*i+r[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const s=this.x,i=this.y,n=this.z,r=e.elements,o=1/(r[3]*s+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*s+r[4]*i+r[8]*n+r[12])*o,this.y=(r[1]*s+r[5]*i+r[9]*n+r[13])*o,this.z=(r[2]*s+r[6]*i+r[10]*n+r[14])*o,this}applyQuaternion(e){const s=this.x,i=this.y,n=this.z,r=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*n-a*i),h=2*(a*s-r*n),d=2*(r*i-o*s);return this.x=s+l*c+o*d-a*h,this.y=i+l*h+a*c-r*d,this.z=n+l*d+r*h-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const s=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*s+r[4]*i+r[8]*n,this.y=r[1]*s+r[5]*i+r[9]*n,this.z=r[2]*s+r[6]*i+r[10]*n,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,s){return this.x=Mt(this.x,e.x,s.x),this.y=Mt(this.y,e.y,s.y),this.z=Mt(this.z,e.z,s.z),this}clampScalar(e,s){return this.x=Mt(this.x,e,s),this.y=Mt(this.y,e,s),this.z=Mt(this.z,e,s),this}clampLength(e,s){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Mt(i,e,s))}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,s){return this.x+=(e.x-this.x)*s,this.y+=(e.y-this.y)*s,this.z+=(e.z-this.z)*s,this}lerpVectors(e,s,i){return this.x=e.x+(s.x-e.x)*i,this.y=e.y+(s.y-e.y)*i,this.z=e.z+(s.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,s){const i=e.x,n=e.y,r=e.z,o=s.x,a=s.y,l=s.z;return this.x=n*l-r*a,this.y=r*o-i*l,this.z=i*a-n*o,this}projectOnVector(e){const s=e.lengthSq();if(s===0)return this.set(0,0,0);const i=e.dot(this)/s;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return bu.copy(this).projectOnVector(e),this.sub(bu)}reflect(e){return this.sub(bu.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const s=Math.sqrt(this.lengthSq()*e.lengthSq());if(s===0)return Math.PI/2;const i=this.dot(e)/s;return Math.acos(Mt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const s=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return s*s+i*i+n*n}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,s,i){const n=Math.sin(s)*e;return this.x=n*Math.sin(i),this.y=Math.cos(s)*e,this.z=n*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,s,i){return this.x=e*Math.sin(s),this.y=i,this.z=e*Math.cos(s),this}setFromMatrixPosition(e){const s=e.elements;return this.x=s[12],this.y=s[13],this.z=s[14],this}setFromMatrixScale(e){const s=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=s,this.y=i,this.z=n,this}setFromMatrixColumn(e,s){return this.fromArray(e.elements,s*4)}setFromMatrix3Column(e,s){return this.fromArray(e.elements,s*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,s=0){return this.x=e[s],this.y=e[s+1],this.z=e[s+2],this}toArray(e=[],s=0){return e[s]=this.x,e[s+1]=this.y,e[s+2]=this.z,e}fromBufferAttribute(e,s){return this.x=e.getX(s),this.y=e.getY(s),this.z=e.getZ(s),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,s=Math.random()*2-1,i=Math.sqrt(1-s*s);return this.x=i*Math.cos(e),this.y=s,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};E_.prototype.isVector3=!0;let W=E_;const bu=new W,R0=new vo,A_=class A_{constructor(e,s,i,n,r,o,a,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,s,i,n,r,o,a,l,c)}set(e,s,i,n,r,o,a,l,c){const h=this.elements;return h[0]=e,h[1]=n,h[2]=a,h[3]=s,h[4]=r,h[5]=l,h[6]=i,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const s=this.elements,i=e.elements;return s[0]=i[0],s[1]=i[1],s[2]=i[2],s[3]=i[3],s[4]=i[4],s[5]=i[5],s[6]=i[6],s[7]=i[7],s[8]=i[8],this}extractBasis(e,s,i){return e.setFromMatrix3Column(this,0),s.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const s=e.elements;return this.set(s[0],s[4],s[8],s[1],s[5],s[9],s[2],s[6],s[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,s){const i=e.elements,n=s.elements,r=this.elements,o=i[0],a=i[3],l=i[6],c=i[1],h=i[4],d=i[7],u=i[2],p=i[5],f=i[8],_=n[0],g=n[3],m=n[6],w=n[1],y=n[4],b=n[7],v=n[2],z=n[5],x=n[8];return r[0]=o*_+a*w+l*v,r[3]=o*g+a*y+l*z,r[6]=o*m+a*b+l*x,r[1]=c*_+h*w+d*v,r[4]=c*g+h*y+d*z,r[7]=c*m+h*b+d*x,r[2]=u*_+p*w+f*v,r[5]=u*g+p*y+f*z,r[8]=u*m+p*b+f*x,this}multiplyScalar(e){const s=this.elements;return s[0]*=e,s[3]*=e,s[6]*=e,s[1]*=e,s[4]*=e,s[7]*=e,s[2]*=e,s[5]*=e,s[8]*=e,this}determinant(){const e=this.elements,s=e[0],i=e[1],n=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8];return s*o*h-s*a*c-i*r*h+i*a*l+n*r*c-n*o*l}invert(){const e=this.elements,s=e[0],i=e[1],n=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],d=h*o-a*c,u=a*l-h*r,p=c*r-o*l,f=s*d+i*u+n*p;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/f;return e[0]=d*_,e[1]=(n*c-h*i)*_,e[2]=(a*i-n*o)*_,e[3]=u*_,e[4]=(h*s-n*l)*_,e[5]=(n*r-a*s)*_,e[6]=p*_,e[7]=(i*l-c*s)*_,e[8]=(o*s-i*r)*_,this}transpose(){let e;const s=this.elements;return e=s[1],s[1]=s[3],s[3]=e,e=s[2],s[2]=s[6],s[6]=e,e=s[5],s[5]=s[7],s[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const s=this.elements;return e[0]=s[0],e[1]=s[3],e[2]=s[6],e[3]=s[1],e[4]=s[4],e[5]=s[7],e[6]=s[2],e[7]=s[5],e[8]=s[8],this}setUvTransform(e,s,i,n,r,o,a){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*o+c*a)+o+e,-n*c,n*l,-n*(-c*o+l*a)+a+s,0,0,1),this}scale(e,s){return ia("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Mu.makeScale(e,s)),this}rotate(e){return ia("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Mu.makeRotation(-e)),this}translate(e,s){return ia("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Mu.makeTranslation(e,s)),this}makeTranslation(e,s){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,s,0,0,1),this}makeRotation(e){const s=Math.cos(e),i=Math.sin(e);return this.set(s,-i,0,i,s,0,0,0,1),this}makeScale(e,s){return this.set(e,0,0,0,s,0,0,0,1),this}equals(e){const s=this.elements,i=e.elements;for(let n=0;n<9;n++)if(s[n]!==i[n])return!1;return!0}fromArray(e,s=0){for(let i=0;i<9;i++)this.elements[i]=e[i+s];return this}toArray(e=[],s=0){const i=this.elements;return e[s]=i[0],e[s+1]=i[1],e[s+2]=i[2],e[s+3]=i[3],e[s+4]=i[4],e[s+5]=i[5],e[s+6]=i[6],e[s+7]=i[7],e[s+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};A_.prototype.isMatrix3=!0;let rt=A_;const Mu=new rt,k0=new rt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),N0=new rt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function OG(){const t={enabled:!0,workingColorSpace:Yh,spaces:{},convert:function(n,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===Dt&&(n.r=Fn(n.r),n.g=Fn(n.g),n.b=Fn(n.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(n.applyMatrix3(this.spaces[r].toXYZ),n.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Dt&&(n.r=na(n.r),n.g=na(n.g),n.b=na(n.b))),n},workingToColorSpace:function(n,r){return this.convert(n,this.workingColorSpace,r)},colorSpaceToWorking:function(n,r){return this.convert(n,r,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===ur?Xh:this.spaces[n].transfer},getToneMappingMode:function(n){return this.spaces[n].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(n,r=this.workingColorSpace){return n.fromArray(this.spaces[r].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,r,o){return n.copy(this.spaces[r].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(n,r){return ia("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(n,r)},toWorkingColorSpace:function(n,r){return ia("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(n,r)}},e=[.64,.33,.3,.6,.15,.06],s=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[Yh]:{primaries:e,whitePoint:i,transfer:Xh,toXYZ:k0,fromXYZ:N0,luminanceCoefficients:s,workingColorSpaceConfig:{unpackColorSpace:Oi},outputColorSpaceConfig:{drawingBufferColorSpace:Oi}},[Oi]:{primaries:e,whitePoint:i,transfer:Dt,toXYZ:k0,fromXYZ:N0,luminanceCoefficients:s,outputColorSpaceConfig:{drawingBufferColorSpace:Oi}}}),t}const bt=OG();function Fn(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function na(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Io;class EG{static getDataURL(e,s="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Io===void 0&&(Io=Zh("canvas")),Io.width=e.width,Io.height=e.height;const n=Io.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),i=Io}return i.toDataURL(s)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const s=Zh("canvas");s.width=e.width,s.height=e.height;const i=s.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const n=i.getImageData(0,0,e.width,e.height),r=n.data;for(let o=0;o<r.length;o++)r[o]=Fn(r[o]/255)*255;return i.putImageData(n,0,0),s}else if(e.data){const s=e.data.slice(0);for(let i=0;i<s.length;i++)s instanceof Uint8Array||s instanceof Uint8ClampedArray?s[i]=Math.floor(Fn(s[i]/255)*255):s[i]=Fn(s[i]);return{data:s,width:e.width,height:e.height}}else return Je("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let AG=0;class Vg{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:AG++}),this.uuid=zr(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const s=this.data;return typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement?e.set(s.videoWidth,s.videoHeight,0):typeof VideoFrame<"u"&&s instanceof VideoFrame?e.set(s.displayWidth,s.displayHeight,0):s!==null?e.set(s.width,s.height,s.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const s=e===void 0||typeof e=="string";if(!s&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(n!==null){let r;if(Array.isArray(n)){r=[];for(let o=0,a=n.length;o<a;o++)n[o].isDataTexture?r.push(vu(n[o].image)):r.push(vu(n[o]))}else r=vu(n);i.url=r}return s||(e.images[this.uuid]=i),i}}function vu(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?EG.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Je("Texture: Unable to serialize Texture."),{})}let TG=0;const wu=new W;class Ws extends Mo{constructor(e=Ws.DEFAULT_IMAGE,s=Ws.DEFAULT_MAPPING,i=Bn,n=Bn,r=Ls,o=eo,a=Zi,l=bi,c=Ws.DEFAULT_ANISOTROPY,h=ur){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:TG++}),this.uuid=zr(),this.name="",this.source=new Vg(e),this.mipmaps=[],this.mapping=s,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new tt(0,0),this.repeat=new tt(1,1),this.center=new tt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new rt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(wu).x}get height(){return this.source.getSize(wu).y}get depth(){return this.source.getSize(wu).z}get image(){return this.source.data}set image(e){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,s){this.updateRanges.push({start:e,count:s})}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.normalized=e.normalized,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(const s in e){const i=e[s];if(i===void 0){Je(`Texture.setValues(): parameter '${s}' has value of undefined.`);continue}const n=this[s];if(n===void 0){Je(`Texture.setValues(): property '${s}' does not exist.`);continue}n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[s]=i}}toJSON(e){const s=e===void 0||typeof e=="string";if(!s&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={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,normalized:this.normalized,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&&(i.userData=this.userData),s||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==bS)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case mp:e.x=e.x-Math.floor(e.x);break;case Bn:e.x=e.x<0?0:1;break;case gp:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case mp:e.y=e.y-Math.floor(e.y);break;case Bn:e.y=e.y<0?0:1;break;case gp:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-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++}}Ws.DEFAULT_IMAGE=null;Ws.DEFAULT_MAPPING=bS;Ws.DEFAULT_ANISOTROPY=1;const T_=class T_{constructor(e=0,s=0,i=0,n=1){this.x=e,this.y=s,this.z=i,this.w=n}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,s,i,n){return this.x=e,this.y=s,this.z=i,this.w=n,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,s){switch(e){case 0:this.x=s;break;case 1:this.y=s;break;case 2:this.z=s;break;case 3:this.w=s;break;default:throw new Error("THREE.Vector4: 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 new Error("THREE.Vector4: 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?e.w:1,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,s){return this.x=e.x+s.x,this.y=e.y+s.y,this.z=e.z+s.z,this.w=e.w+s.w,this}addScaledVector(e,s){return this.x+=e.x*s,this.y+=e.y*s,this.z+=e.z*s,this.w+=e.w*s,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,s){return this.x=e.x-s.x,this.y=e.y-s.y,this.z=e.z-s.z,this.w=e.w-s.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){const s=this.x,i=this.y,n=this.z,r=this.w,o=e.elements;return this.x=o[0]*s+o[4]*i+o[8]*n+o[12]*r,this.y=o[1]*s+o[5]*i+o[9]*n+o[13]*r,this.z=o[2]*s+o[6]*i+o[10]*n+o[14]*r,this.w=o[3]*s+o[7]*i+o[11]*n+o[15]*r,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);const s=Math.sqrt(1-e.w*e.w);return s<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/s,this.y=e.y/s,this.z=e.z/s),this}setAxisAngleFromRotationMatrix(e){let s,i,n,r;const l=e.elements,c=l[0],h=l[4],d=l[8],u=l[1],p=l[5],f=l[9],_=l[2],g=l[6],m=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-_)<.01&&Math.abs(f-g)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+_)<.1&&Math.abs(f+g)<.1&&Math.abs(c+p+m-3)<.1)return this.set(1,0,0,0),this;s=Math.PI;const y=(c+1)/2,b=(p+1)/2,v=(m+1)/2,z=(h+u)/4,x=(d+_)/4,M=(f+g)/4;return y>b&&y>v?y<.01?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(y),n=z/i,r=x/i):b>v?b<.01?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(b),i=z/n,r=M/n):v<.01?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(v),i=x/r,n=M/r),this.set(i,n,r,s),this}let w=Math.sqrt((g-f)*(g-f)+(d-_)*(d-_)+(u-h)*(u-h));return Math.abs(w)<.001&&(w=1),this.x=(g-f)/w,this.y=(d-_)/w,this.z=(u-h)/w,this.w=Math.acos((c+p+m-1)/2),this}setFromMatrixPosition(e){const s=e.elements;return this.x=s[12],this.y=s[13],this.z=s[14],this.w=s[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,s){return this.x=Mt(this.x,e.x,s.x),this.y=Mt(this.y,e.y,s.y),this.z=Mt(this.z,e.z,s.z),this.w=Mt(this.w,e.w,s.w),this}clampScalar(e,s){return this.x=Mt(this.x,e,s),this.y=Mt(this.y,e,s),this.z=Mt(this.z,e,s),this.w=Mt(this.w,e,s),this}clampLength(e,s){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Mt(i,e,s))}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,s){return this.x+=(e.x-this.x)*s,this.y+=(e.y-this.y)*s,this.z+=(e.z-this.z)*s,this.w+=(e.w-this.w)*s,this}lerpVectors(e,s,i){return this.x=e.x+(s.x-e.x)*i,this.y=e.y+(s.y-e.y)*i,this.z=e.z+(s.z-e.z)*i,this.w=e.w+(s.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,s=0){return this.x=e[s],this.y=e[s+1],this.z=e[s+2],this.w=e[s+3],this}toArray(e=[],s=0){return e[s]=this.x,e[s+1]=this.y,e[s+2]=this.z,e[s+3]=this.w,e}fromBufferAttribute(e,s){return this.x=e.getX(s),this.y=e.getY(s),this.z=e.getZ(s),this.w=e.getW(s),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}};T_.prototype.isVector4=!0;let Yt=T_;class IG extends Mo{constructor(e=1,s=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ls,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=s,this.depth=i.depth,this.scissor=new Yt(0,0,e,s),this.scissorTest=!1,this.viewport=new Yt(0,0,e,s),this.textures=[];const n={width:e,height:s,depth:i.depth},r=new Ws(n),o=i.count;for(let a=0;a<o;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview,this.useArrayDepthTexture=i.useArrayDepthTexture}_setTextureOptions(e={}){const s={minFilter:Ls,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(s.mapping=e.mapping),e.wrapS!==void 0&&(s.wrapS=e.wrapS),e.wrapT!==void 0&&(s.wrapT=e.wrapT),e.wrapR!==void 0&&(s.wrapR=e.wrapR),e.magFilter!==void 0&&(s.magFilter=e.magFilter),e.minFilter!==void 0&&(s.minFilter=e.minFilter),e.format!==void 0&&(s.format=e.format),e.type!==void 0&&(s.type=e.type),e.anisotropy!==void 0&&(s.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(s.colorSpace=e.colorSpace),e.flipY!==void 0&&(s.flipY=e.flipY),e.generateMipmaps!==void 0&&(s.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(s.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(s)}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,s,i=1){if(this.width!==e||this.height!==s||this.depth!==i){this.width=e,this.height=s,this.depth=i;for(let n=0,r=this.textures.length;n<r;n++)this.textures[n].image.width=e,this.textures[n].image.height=s,this.textures[n].image.depth=i,this.textures[n].isData3DTexture!==!0&&(this.textures[n].isArrayTexture=this.textures[n].image.depth>1);this.dispose()}this.viewport.set(0,0,e,s),this.scissor.set(0,0,e,s)}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 s=0,i=e.textures.length;s<i;s++){this.textures[s]=e.textures[s].clone(),this.textures[s].isRenderTargetTexture=!0,this.textures[s].renderTarget=this;const n=Object.assign({},e.textures[s].image);this.textures[s].source=new Vg(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.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class gn extends IG{constructor(e=1,s=1,i={}){super(e,s,i),this.isWebGLRenderTarget=!0}}class OS extends Ws{constructor(e=null,s=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:s,height:i,depth:n},this.magFilter=Is,this.minFilter=Is,this.wrapR=Bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class DG extends Ws{constructor(e=null,s=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:s,height:i,depth:n},this.magFilter=Is,this.minFilter=Is,this.wrapR=Bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const _d=class _d{constructor(e,s,i,n,r,o,a,l,c,h,d,u,p,f,_,g){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,s,i,n,r,o,a,l,c,h,d,u,p,f,_,g)}set(e,s,i,n,r,o,a,l,c,h,d,u,p,f,_,g){const m=this.elements;return m[0]=e,m[4]=s,m[8]=i,m[12]=n,m[1]=r,m[5]=o,m[9]=a,m[13]=l,m[2]=c,m[6]=h,m[10]=d,m[14]=u,m[3]=p,m[7]=f,m[11]=_,m[15]=g,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 _d().fromArray(this.elements)}copy(e){const s=this.elements,i=e.elements;return s[0]=i[0],s[1]=i[1],s[2]=i[2],s[3]=i[3],s[4]=i[4],s[5]=i[5],s[6]=i[6],s[7]=i[7],s[8]=i[8],s[9]=i[9],s[10]=i[10],s[11]=i[11],s[12]=i[12],s[13]=i[13],s[14]=i[14],s[15]=i[15],this}copyPosition(e){const s=this.elements,i=e.elements;return s[12]=i[12],s[13]=i[13],s[14]=i[14],this}setFromMatrix3(e){const s=e.elements;return this.set(s[0],s[3],s[6],0,s[1],s[4],s[7],0,s[2],s[5],s[8],0,0,0,0,1),this}extractBasis(e,s,i){return this.determinantAffine()===0?(e.set(1,0,0),s.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),s.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,s,i){return this.set(e.x,s.x,i.x,0,e.y,s.y,i.y,0,e.z,s.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const s=this.elements,i=e.elements,n=1/Do.setFromMatrixColumn(e,0).length(),r=1/Do.setFromMatrixColumn(e,1).length(),o=1/Do.setFromMatrixColumn(e,2).length();return s[0]=i[0]*n,s[1]=i[1]*n,s[2]=i[2]*n,s[3]=0,s[4]=i[4]*r,s[5]=i[5]*r,s[6]=i[6]*r,s[7]=0,s[8]=i[8]*o,s[9]=i[9]*o,s[10]=i[10]*o,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,this}makeRotationFromEuler(e){const s=this.elements,i=e.x,n=e.y,r=e.z,o=Math.cos(i),a=Math.sin(i),l=Math.cos(n),c=Math.sin(n),h=Math.cos(r),d=Math.sin(r);if(e.order==="XYZ"){const u=o*h,p=o*d,f=a*h,_=a*d;s[0]=l*h,s[4]=-l*d,s[8]=c,s[1]=p+f*c,s[5]=u-_*c,s[9]=-a*l,s[2]=_-u*c,s[6]=f+p*c,s[10]=o*l}else if(e.order==="YXZ"){const u=l*h,p=l*d,f=c*h,_=c*d;s[0]=u+_*a,s[4]=f*a-p,s[8]=o*c,s[1]=o*d,s[5]=o*h,s[9]=-a,s[2]=p*a-f,s[6]=_+u*a,s[10]=o*l}else if(e.order==="ZXY"){const u=l*h,p=l*d,f=c*h,_=c*d;s[0]=u-_*a,s[4]=-o*d,s[8]=f+p*a,s[1]=p+f*a,s[5]=o*h,s[9]=_-u*a,s[2]=-o*c,s[6]=a,s[10]=o*l}else if(e.order==="ZYX"){const u=o*h,p=o*d,f=a*h,_=a*d;s[0]=l*h,s[4]=f*c-p,s[8]=u*c+_,s[1]=l*d,s[5]=_*c+u,s[9]=p*c-f,s[2]=-c,s[6]=a*l,s[10]=o*l}else if(e.order==="YZX"){const u=o*l,p=o*c,f=a*l,_=a*c;s[0]=l*h,s[4]=_-u*d,s[8]=f*d+p,s[1]=d,s[5]=o*h,s[9]=-a*h,s[2]=-c*h,s[6]=p*d+f,s[10]=u-_*d}else if(e.order==="XZY"){const u=o*l,p=o*c,f=a*l,_=a*c;s[0]=l*h,s[4]=-d,s[8]=c*h,s[1]=u*d+_,s[5]=o*h,s[9]=p*d-f,s[2]=f*d-p,s[6]=a*h,s[10]=_*d+u}return s[3]=0,s[7]=0,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,this}makeRotationFromQuaternion(e){return this.compose(CG,e,RG)}lookAt(e,s,i){const n=this.elements;return ci.subVectors(e,s),ci.lengthSq()===0&&(ci.z=1),ci.normalize(),Xn.crossVectors(i,ci),Xn.lengthSq()===0&&(Math.abs(i.z)===1?ci.x+=1e-4:ci.z+=1e-4,ci.normalize(),Xn.crossVectors(i,ci)),Xn.normalize(),gc.crossVectors(ci,Xn),n[0]=Xn.x,n[4]=gc.x,n[8]=ci.x,n[1]=Xn.y,n[5]=gc.y,n[9]=ci.y,n[2]=Xn.z,n[6]=gc.z,n[10]=ci.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,s){const i=e.elements,n=s.elements,r=this.elements,o=i[0],a=i[4],l=i[8],c=i[12],h=i[1],d=i[5],u=i[9],p=i[13],f=i[2],_=i[6],g=i[10],m=i[14],w=i[3],y=i[7],b=i[11],v=i[15],z=n[0],x=n[4],M=n[8],S=n[12],T=n[1],I=n[5],E=n[9],O=n[13],R=n[2],C=n[6],k=n[10],B=n[14],L=n[3],F=n[7],ee=n[11],X=n[15];return r[0]=o*z+a*T+l*R+c*L,r[4]=o*x+a*I+l*C+c*F,r[8]=o*M+a*E+l*k+c*ee,r[12]=o*S+a*O+l*B+c*X,r[1]=h*z+d*T+u*R+p*L,r[5]=h*x+d*I+u*C+p*F,r[9]=h*M+d*E+u*k+p*ee,r[13]=h*S+d*O+u*B+p*X,r[2]=f*z+_*T+g*R+m*L,r[6]=f*x+_*I+g*C+m*F,r[10]=f*M+_*E+g*k+m*ee,r[14]=f*S+_*O+g*B+m*X,r[3]=w*z+y*T+b*R+v*L,r[7]=w*x+y*I+b*C+v*F,r[11]=w*M+y*E+b*k+v*ee,r[15]=w*S+y*O+b*B+v*X,this}multiplyScalar(e){const s=this.elements;return s[0]*=e,s[4]*=e,s[8]*=e,s[12]*=e,s[1]*=e,s[5]*=e,s[9]*=e,s[13]*=e,s[2]*=e,s[6]*=e,s[10]*=e,s[14]*=e,s[3]*=e,s[7]*=e,s[11]*=e,s[15]*=e,this}determinant(){const e=this.elements,s=e[0],i=e[4],n=e[8],r=e[12],o=e[1],a=e[5],l=e[9],c=e[13],h=e[2],d=e[6],u=e[10],p=e[14],f=e[3],_=e[7],g=e[11],m=e[15],w=l*p-c*u,y=a*p-c*d,b=a*u-l*d,v=o*p-c*h,z=o*u-l*h,x=o*d-a*h;return s*(_*w-g*y+m*b)-i*(f*w-g*v+m*z)+n*(f*y-_*v+m*x)-r*(f*b-_*z+g*x)}determinantAffine(){const e=this.elements,s=e[0],i=e[4],n=e[8],r=e[1],o=e[5],a=e[9],l=e[2],c=e[6],h=e[10];return s*(o*h-a*c)-i*(r*h-a*l)+n*(r*c-o*l)}transpose(){const e=this.elements;let s;return s=e[1],e[1]=e[4],e[4]=s,s=e[2],e[2]=e[8],e[8]=s,s=e[6],e[6]=e[9],e[9]=s,s=e[3],e[3]=e[12],e[12]=s,s=e[7],e[7]=e[13],e[13]=s,s=e[11],e[11]=e[14],e[14]=s,this}setPosition(e,s,i){const n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=s,n[14]=i),this}invert(){const e=this.elements,s=e[0],i=e[1],n=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],d=e[9],u=e[10],p=e[11],f=e[12],_=e[13],g=e[14],m=e[15],w=s*a-i*o,y=s*l-n*o,b=s*c-r*o,v=i*l-n*a,z=i*c-r*a,x=n*c-r*l,M=h*_-d*f,S=h*g-u*f,T=h*m-p*f,I=d*g-u*_,E=d*m-p*_,O=u*m-p*g,R=w*O-y*E+b*I+v*T-z*S+x*M;if(R===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/R;return e[0]=(a*O-l*E+c*I)*C,e[1]=(n*E-i*O-r*I)*C,e[2]=(_*x-g*z+m*v)*C,e[3]=(u*z-d*x-p*v)*C,e[4]=(l*T-o*O-c*S)*C,e[5]=(s*O-n*T+r*S)*C,e[6]=(g*b-f*x-m*y)*C,e[7]=(h*x-u*b+p*y)*C,e[8]=(o*E-a*T+c*M)*C,e[9]=(i*T-s*E-r*M)*C,e[10]=(f*z-_*b+m*w)*C,e[11]=(d*b-h*z-p*w)*C,e[12]=(a*S-o*I-l*M)*C,e[13]=(s*I-i*S+n*M)*C,e[14]=(_*y-f*v-g*w)*C,e[15]=(h*v-d*y+u*w)*C,this}scale(e){const s=this.elements,i=e.x,n=e.y,r=e.z;return s[0]*=i,s[4]*=n,s[8]*=r,s[1]*=i,s[5]*=n,s[9]*=r,s[2]*=i,s[6]*=n,s[10]*=r,s[3]*=i,s[7]*=n,s[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,s=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(s,i,n))}makeTranslation(e,s,i){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,s,0,0,1,i,0,0,0,1),this}makeRotationX(e){const s=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,s,-i,0,0,i,s,0,0,0,0,1),this}makeRotationY(e){const s=Math.cos(e),i=Math.sin(e);return this.set(s,0,i,0,0,1,0,0,-i,0,s,0,0,0,0,1),this}makeRotationZ(e){const s=Math.cos(e),i=Math.sin(e);return this.set(s,-i,0,0,i,s,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,s){const i=Math.cos(s),n=Math.sin(s),r=1-i,o=e.x,a=e.y,l=e.z,c=r*o,h=r*a;return this.set(c*o+i,c*a-n*l,c*l+n*a,0,c*a+n*l,h*a+i,h*l-n*o,0,c*l-n*a,h*l+n*o,r*l*l+i,0,0,0,0,1),this}makeScale(e,s,i){return this.set(e,0,0,0,0,s,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,s,i,n,r,o){return this.set(1,i,r,0,e,1,o,0,s,n,1,0,0,0,0,1),this}compose(e,s,i){const n=this.elements,r=s._x,o=s._y,a=s._z,l=s._w,c=r+r,h=o+o,d=a+a,u=r*c,p=r*h,f=r*d,_=o*h,g=o*d,m=a*d,w=l*c,y=l*h,b=l*d,v=i.x,z=i.y,x=i.z;return n[0]=(1-(_+m))*v,n[1]=(p+b)*v,n[2]=(f-y)*v,n[3]=0,n[4]=(p-b)*z,n[5]=(1-(u+m))*z,n[6]=(g+w)*z,n[7]=0,n[8]=(f+y)*x,n[9]=(g-w)*x,n[10]=(1-(u+_))*x,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,s,i){const n=this.elements;e.x=n[12],e.y=n[13],e.z=n[14];const r=this.determinantAffine();if(r===0)return i.set(1,1,1),s.identity(),this;let o=Do.set(n[0],n[1],n[2]).length();const a=Do.set(n[4],n[5],n[6]).length(),l=Do.set(n[8],n[9],n[10]).length();r<0&&(o=-o),Fi.copy(this);const c=1/o,h=1/a,d=1/l;return Fi.elements[0]*=c,Fi.elements[1]*=c,Fi.elements[2]*=c,Fi.elements[4]*=h,Fi.elements[5]*=h,Fi.elements[6]*=h,Fi.elements[8]*=d,Fi.elements[9]*=d,Fi.elements[10]*=d,s.setFromRotationMatrix(Fi),i.x=o,i.y=a,i.z=l,this}makePerspective(e,s,i,n,r,o,a=un,l=!1){const c=this.elements,h=2*r/(s-e),d=2*r/(i-n),u=(s+e)/(s-e),p=(i+n)/(i-n);let f,_;if(l)f=r/(o-r),_=o*r/(o-r);else if(a===un)f=-(o+r)/(o-r),_=-2*o*r/(o-r);else if(a===Ll)f=-o/(o-r),_=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=d,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=_,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,s,i,n,r,o,a=un,l=!1){const c=this.elements,h=2/(s-e),d=2/(i-n),u=-(s+e)/(s-e),p=-(i+n)/(i-n);let f,_;if(l)f=1/(o-r),_=o/(o-r);else if(a===un)f=-2/(o-r),_=-(o+r)/(o-r);else if(a===Ll)f=-1/(o-r),_=-r/(o-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=0,c[12]=u,c[1]=0,c[5]=d,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=f,c[14]=_,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const s=this.elements,i=e.elements;for(let n=0;n<16;n++)if(s[n]!==i[n])return!1;return!0}fromArray(e,s=0){for(let i=0;i<16;i++)this.elements[i]=e[i+s];return this}toArray(e=[],s=0){const i=this.elements;return e[s]=i[0],e[s+1]=i[1],e[s+2]=i[2],e[s+3]=i[3],e[s+4]=i[4],e[s+5]=i[5],e[s+6]=i[6],e[s+7]=i[7],e[s+8]=i[8],e[s+9]=i[9],e[s+10]=i[10],e[s+11]=i[11],e[s+12]=i[12],e[s+13]=i[13],e[s+14]=i[14],e[s+15]=i[15],e}};_d.prototype.isMatrix4=!0;let Ot=_d;const Do=new W,Fi=new Ot,CG=new W(0,0,0),RG=new W(1,1,1),Xn=new W,gc=new W,ci=new W,B0=new Ot,G0=new vo;class kr{constructor(e=0,s=0,i=0,n=kr.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=s,this._z=i,this._order=n}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,s,i,n=this._order){return this._x=e,this._y=s,this._z=i,this._order=n,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,s=this._order,i=!0){const n=e.elements,r=n[0],o=n[4],a=n[8],l=n[1],c=n[5],h=n[9],d=n[2],u=n[6],p=n[10];switch(s){case"XYZ":this._y=Math.asin(Mt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Mt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(Mt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-Mt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Mt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-Mt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,p),this._y=0);break;default:Je("Euler: .setFromRotationMatrix() encountered an unknown order: "+s)}return this._order=s,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,s,i){return B0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(B0,s,i)}setFromVector3(e,s=this._order){return this.set(e.x,e.y,e.z,s)}reorder(e){return G0.setFromEuler(this),this.setFromQuaternion(G0,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=[],s=0){return e[s]=this._x,e[s+1]=this._y,e[s+2]=this._z,e[s+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}}kr.DEFAULT_ORDER="XYZ";class qg{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}}let kG=0;const P0=new W,Co=new vo,yn=new Ot,_c=new W,La=new W,NG=new W,BG=new vo,L0=new W(1,0,0),W0=new W(0,1,0),F0=new W(0,0,1),U0={type:"added"},GG={type:"removed"},Ro={type:"childadded",child:null},yu={type:"childremoved",child:null};class Zt extends Mo{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:kG++}),this.uuid=zr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Zt.DEFAULT_UP.clone();const e=new W,s=new kr,i=new vo,n=new W(1,1,1);function r(){i.setFromEuler(s,!1)}function o(){s.setFromQuaternion(i,void 0,!1)}s._onChange(r),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:s},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Ot},normalMatrix:{value:new rt}}),this.matrix=new Ot,this.matrixWorld=new Ot,this.matrixAutoUpdate=Zt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Zt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new qg,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,s){this.quaternion.setFromAxisAngle(e,s)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,s){return Co.setFromAxisAngle(e,s),this.quaternion.multiply(Co),this}rotateOnWorldAxis(e,s){return Co.setFromAxisAngle(e,s),this.quaternion.premultiply(Co),this}rotateX(e){return this.rotateOnAxis(L0,e)}rotateY(e){return this.rotateOnAxis(W0,e)}rotateZ(e){return this.rotateOnAxis(F0,e)}translateOnAxis(e,s){return P0.copy(e).applyQuaternion(this.quaternion),this.position.add(P0.multiplyScalar(s)),this}translateX(e){return this.translateOnAxis(L0,e)}translateY(e){return this.translateOnAxis(W0,e)}translateZ(e){return this.translateOnAxis(F0,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(yn.copy(this.matrixWorld).invert())}lookAt(e,s,i){e.isVector3?_c.copy(e):_c.set(e,s,i);const n=this.parent;this.updateWorldMatrix(!0,!1),La.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?yn.lookAt(La,_c,this.up):yn.lookAt(_c,La,this.up),this.quaternion.setFromRotationMatrix(yn),n&&(yn.extractRotation(n.matrixWorld),Co.setFromRotationMatrix(yn),this.quaternion.premultiply(Co.invert()))}add(e){if(arguments.length>1){for(let s=0;s<arguments.length;s++)this.add(arguments[s]);return this}return e===this?(_t("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(U0),Ro.child=e,this.dispatchEvent(Ro),Ro.child=null):_t("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const s=this.children.indexOf(e);return s!==-1&&(e.parent=null,this.children.splice(s,1),e.dispatchEvent(GG),yu.child=e,this.dispatchEvent(yu),yu.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),yn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),yn.multiply(e.parent.matrixWorld)),e.applyMatrix4(yn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(U0),Ro.child=e,this.dispatchEvent(Ro),Ro.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,s){if(this[e]===s)return this;for(let i=0,n=this.children.length;i<n;i++){const o=this.children[i].getObjectByProperty(e,s);if(o!==void 0)return o}}getObjectsByProperty(e,s,i=[]){this[e]===s&&i.push(this);const n=this.children;for(let r=0,o=n.length;r<o;r++)n[r].getObjectsByProperty(e,s,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(La,e,NG),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(La,BG,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const s=this.matrixWorld.elements;return e.set(s[8],s[9],s[10]).normalize()}raycast(){}traverse(e){e(this);const s=this.children;for(let i=0,n=s.length;i<n;i++)s[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const s=this.children;for(let i=0,n=s.length;i<n;i++)s[i].traverseVisible(e)}traverseAncestors(e){const s=this.parent;s!==null&&(e(s),s.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const s=e.x,i=e.y,n=e.z,r=this.matrix.elements;r[12]+=s-r[0]*s-r[4]*i-r[8]*n,r[13]+=i-r[1]*s-r[5]*i-r[9]*n,r[14]+=n-r[2]*s-r[6]*i-r[10]*n}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);const s=this.children;for(let i=0,n=s.length;i<n;i++)s[i].updateMatrixWorld(e)}updateWorldMatrix(e,s,i=!1){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||i)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,i=!0),s===!0){const r=this.children;for(let o=0,a=r.length;o<a;o++)r[o].updateWorldMatrix(!1,!0,i)}}toJSON(e){const s=e===void 0||typeof e=="string",i={};s&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),this.static!==!1&&(n.static=this.static),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),this.pivot!==null&&(n.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(n.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(n.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(a=>({...a})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(e),n.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.toJSON()));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=r(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const d=l[c];r(e.shapes,d)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(r(e.materials,this.material[l]));n.material=a}else n.material=r(e.materials,this.material);if(this.children.length>0){n.children=[];for(let a=0;a<this.children.length;a++)n.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){n.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];n.animations.push(r(e.animations,l))}}if(s){const a=o(e.geometries),l=o(e.materials),c=o(e.textures),h=o(e.images),d=o(e.shapes),u=o(e.skeletons),p=o(e.animations),f=o(e.nodes);a.length>0&&(i.geometries=a),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),h.length>0&&(i.images=h),d.length>0&&(i.shapes=d),u.length>0&&(i.skeletons=u),p.length>0&&(i.animations=p),f.length>0&&(i.nodes=f)}return i.object=n,i;function o(a){const l=[];for(const c in a){const h=a[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,s=!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),this.pivot=e.pivot!==null?e.pivot.clone():null,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)),s===!0)for(let i=0;i<e.children.length;i++){const n=e.children[i];this.add(n.clone())}return this}}Zt.DEFAULT_UP=new W(0,1,0);Zt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Zt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class pl extends Zt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const PG={type:"move"};class zu{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new pl,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 pl,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new W,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new W),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new pl,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new W,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new W,this._grip.eventsEnabled=!1),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){const s=this._hand;if(s)for(const i of e.hand.values())this._getHandJoint(s,i)}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,s,i){let n=null,r=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&s.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const _ of e.hand.values()){const g=s.getJointPose(_,i),m=this._getHandJoint(c,_);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius),m.visible=g!==null}const h=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],u=h.position.distanceTo(d.position),p=.02,f=.005;c.inputState.pinching&&u>p+f?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=p-f&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=s.getPose(e.gripSpace,i),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));a!==null&&(n=s.getPose(e.targetRaySpace,i),n===null&&r!==null&&(n=r),n!==null&&(a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,n.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(n.linearVelocity)):a.hasLinearVelocity=!1,n.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(n.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(PG)))}return a!==null&&(a.visible=n!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,s){if(e.joints[s.jointName]===void 0){const i=new pl;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[s.jointName]=i,e.add(i)}return e.joints[s.jointName]}}const ES={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},Zn={h:0,s:0,l:0},bc={h:0,s:0,l:0};function Su(t,e,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+(e-t)*6*s:s<1/2?e:s<2/3?t+(e-t)*6*(2/3-s):t}class Ke{constructor(e,s,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,s,i)}set(e,s,i){if(s===void 0&&i===void 0){const n=e;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(e,s,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,s=Oi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,bt.colorSpaceToWorking(this,s),this}setRGB(e,s,i,n=bt.workingColorSpace){return this.r=e,this.g=s,this.b=i,bt.colorSpaceToWorking(this,n),this}setHSL(e,s,i,n=bt.workingColorSpace){if(e=xG(e,1),s=Mt(s,0,1),i=Mt(i,0,1),s===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+s):i+s-i*s,o=2*i-r;this.r=Su(o,r,e+1/3),this.g=Su(o,r,e),this.b=Su(o,r,e-1/3)}return bt.colorSpaceToWorking(this,n),this}setStyle(e,s=Oi){function i(r){r!==void 0&&parseFloat(r)<1&&Je("Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const o=n[1],a=n[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,s);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,s);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,s);break;default:Je("Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=n[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,s);if(o===6)return this.setHex(parseInt(r,16),s);Je("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,s);return this}setColorName(e,s=Oi){const i=ES[e.toLowerCase()];return i!==void 0?this.setHex(i,s):Je("Color: Unknown color "+e),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=Fn(e.r),this.g=Fn(e.g),this.b=Fn(e.b),this}copyLinearToSRGB(e){return this.r=na(e.r),this.g=na(e.g),this.b=na(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Oi){return bt.workingToColorSpace(Ns.copy(this),e),Math.round(Mt(Ns.r*255,0,255))*65536+Math.round(Mt(Ns.g*255,0,255))*256+Math.round(Mt(Ns.b*255,0,255))}getHexString(e=Oi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,s=bt.workingColorSpace){bt.workingToColorSpace(Ns.copy(this),s);const i=Ns.r,n=Ns.g,r=Ns.b,o=Math.max(i,n,r),a=Math.min(i,n,r);let l,c;const h=(a+o)/2;if(a===o)l=0,c=0;else{const d=o-a;switch(c=h<=.5?d/(o+a):d/(2-o-a),o){case i:l=(n-r)/d+(n<r?6:0);break;case n:l=(r-i)/d+2;break;case r:l=(i-n)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,s=bt.workingColorSpace){return bt.workingToColorSpace(Ns.copy(this),s),e.r=Ns.r,e.g=Ns.g,e.b=Ns.b,e}getStyle(e=Oi){bt.workingToColorSpace(Ns.copy(this),e);const s=Ns.r,i=Ns.g,n=Ns.b;return e!==Oi?`color(${e} ${s.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(s*255)},${Math.round(i*255)},${Math.round(n*255)})`}offsetHSL(e,s,i){return this.getHSL(Zn),this.setHSL(Zn.h+e,Zn.s+s,Zn.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,s){return this.r=e.r+s.r,this.g=e.g+s.g,this.b=e.b+s.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,s){return this.r+=(e.r-this.r)*s,this.g+=(e.g-this.g)*s,this.b+=(e.b-this.b)*s,this}lerpColors(e,s,i){return this.r=e.r+(s.r-e.r)*i,this.g=e.g+(s.g-e.g)*i,this.b=e.b+(s.b-e.b)*i,this}lerpHSL(e,s){this.getHSL(Zn),e.getHSL(bc);const i=_u(Zn.h,bc.h,s),n=_u(Zn.s,bc.s,s),r=_u(Zn.l,bc.l,s);return this.setHSL(i,n,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const s=this.r,i=this.g,n=this.b,r=e.elements;return this.r=r[0]*s+r[3]*i+r[6]*n,this.g=r[1]*s+r[4]*i+r[7]*n,this.b=r[2]*s+r[5]*i+r[8]*n,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,s=0){return this.r=e[s],this.g=e[s+1],this.b=e[s+2],this}toArray(e=[],s=0){return e[s]=this.r,e[s+1]=this.g,e[s+2]=this.b,e}fromBufferAttribute(e,s){return this.r=e.getX(s),this.g=e.getY(s),this.b=e.getZ(s),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Ns=new Ke;Ke.NAMES=ES;class LG extends Zt{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 kr,this.environmentIntensity=1,this.environmentRotation=new kr,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,s){return super.copy(e,s),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){const s=super.toJSON(e);return this.fog!==null&&(s.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(s.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(s.object.backgroundIntensity=this.backgroundIntensity),s.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(s.object.environmentIntensity=this.environmentIntensity),s.object.environmentRotation=this.environmentRotation.toArray(),s}}const Ui=new W,zn=new W,xu=new W,Sn=new W,ko=new W,No=new W,$0=new W,Ou=new W,Eu=new W,Au=new W,Tu=new Yt,Iu=new Yt,Du=new Yt;class Di{constructor(e=new W,s=new W,i=new W){this.a=e,this.b=s,this.c=i}static getNormal(e,s,i,n){n.subVectors(i,s),Ui.subVectors(e,s),n.cross(Ui);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(e,s,i,n,r){Ui.subVectors(n,s),zn.subVectors(i,s),xu.subVectors(e,s);const o=Ui.dot(Ui),a=Ui.dot(zn),l=Ui.dot(xu),c=zn.dot(zn),h=zn.dot(xu),d=o*c-a*a;if(d===0)return r.set(0,0,0),null;const u=1/d,p=(c*l-a*h)*u,f=(o*h-a*l)*u;return r.set(1-p-f,f,p)}static containsPoint(e,s,i,n){return this.getBarycoord(e,s,i,n,Sn)===null?!1:Sn.x>=0&&Sn.y>=0&&Sn.x+Sn.y<=1}static getInterpolation(e,s,i,n,r,o,a,l){return this.getBarycoord(e,s,i,n,Sn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,Sn.x),l.addScaledVector(o,Sn.y),l.addScaledVector(a,Sn.z),l)}static getInterpolatedAttribute(e,s,i,n,r,o){return Tu.setScalar(0),Iu.setScalar(0),Du.setScalar(0),Tu.fromBufferAttribute(e,s),Iu.fromBufferAttribute(e,i),Du.fromBufferAttribute(e,n),o.setScalar(0),o.addScaledVector(Tu,r.x),o.addScaledVector(Iu,r.y),o.addScaledVector(Du,r.z),o}static isFrontFacing(e,s,i,n){return Ui.subVectors(i,s),zn.subVectors(e,s),Ui.cross(zn).dot(n)<0}set(e,s,i){return this.a.copy(e),this.b.copy(s),this.c.copy(i),this}setFromPointsAndIndices(e,s,i,n){return this.a.copy(e[s]),this.b.copy(e[i]),this.c.copy(e[n]),this}setFromAttributeAndIndices(e,s,i,n){return this.a.fromBufferAttribute(e,s),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,n),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 Ui.subVectors(this.c,this.b),zn.subVectors(this.a,this.b),Ui.cross(zn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Di.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,s){return Di.getBarycoord(e,this.a,this.b,this.c,s)}getInterpolation(e,s,i,n,r){return Di.getInterpolation(e,this.a,this.b,this.c,s,i,n,r)}containsPoint(e){return Di.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Di.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,s){const i=this.a,n=this.b,r=this.c;let o,a;ko.subVectors(n,i),No.subVectors(r,i),Ou.subVectors(e,i);const l=ko.dot(Ou),c=No.dot(Ou);if(l<=0&&c<=0)return s.copy(i);Eu.subVectors(e,n);const h=ko.dot(Eu),d=No.dot(Eu);if(h>=0&&d<=h)return s.copy(n);const u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return o=l/(l-h),s.copy(i).addScaledVector(ko,o);Au.subVectors(e,r);const p=ko.dot(Au),f=No.dot(Au);if(f>=0&&p<=f)return s.copy(r);const _=p*c-l*f;if(_<=0&&c>=0&&f<=0)return a=c/(c-f),s.copy(i).addScaledVector(No,a);const g=h*f-p*d;if(g<=0&&d-h>=0&&p-f>=0)return $0.subVectors(r,n),a=(d-h)/(d-h+(p-f)),s.copy(n).addScaledVector($0,a);const m=1/(g+_+u);return o=_*m,a=u*m,s.copy(i).addScaledVector(ko,o).addScaledVector(No,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class wo{constructor(e=new W(1/0,1/0,1/0),s=new W(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=s}set(e,s){return this.min.copy(e),this.max.copy(s),this}setFromArray(e){this.makeEmpty();for(let s=0,i=e.length;s<i;s+=3)this.expandByPoint($i.fromArray(e,s));return this}setFromBufferAttribute(e){this.makeEmpty();for(let s=0,i=e.count;s<i;s++)this.expandByPoint($i.fromBufferAttribute(e,s));return this}setFromPoints(e){this.makeEmpty();for(let s=0,i=e.length;s<i;s++)this.expandByPoint(e[s]);return this}setFromCenterAndSize(e,s){const i=$i.copy(s).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,s=!1){return this.makeEmpty(),this.expandByObject(e,s)}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,s=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const r=i.getAttribute("position");if(s===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,$i):$i.fromBufferAttribute(r,o),$i.applyMatrix4(e.matrixWorld),this.expandByPoint($i);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Mc.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Mc.copy(i.boundingBox)),Mc.applyMatrix4(e.matrixWorld),this.union(Mc)}const n=e.children;for(let r=0,o=n.length;r<o;r++)this.expandByObject(n[r],s);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,s){return s.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,$i),$i.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let s,i;return e.normal.x>0?(s=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(s=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(s+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(s+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(s+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(s+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),s<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Wa),vc.subVectors(this.max,Wa),Bo.subVectors(e.a,Wa),Go.subVectors(e.b,Wa),Po.subVectors(e.c,Wa),Jn.subVectors(Go,Bo),Qn.subVectors(Po,Go),Ur.subVectors(Bo,Po);let s=[0,-Jn.z,Jn.y,0,-Qn.z,Qn.y,0,-Ur.z,Ur.y,Jn.z,0,-Jn.x,Qn.z,0,-Qn.x,Ur.z,0,-Ur.x,-Jn.y,Jn.x,0,-Qn.y,Qn.x,0,-Ur.y,Ur.x,0];return!Cu(s,Bo,Go,Po,vc)||(s=[1,0,0,0,1,0,0,0,1],!Cu(s,Bo,Go,Po,vc))?!1:(wc.crossVectors(Jn,Qn),s=[wc.x,wc.y,wc.z],Cu(s,Bo,Go,Po,vc))}clampPoint(e,s){return s.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,$i).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize($i).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:(xn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),xn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),xn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),xn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),xn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),xn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),xn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),xn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(xn),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}}const xn=[new W,new W,new W,new W,new W,new W,new W,new W],$i=new W,Mc=new wo,Bo=new W,Go=new W,Po=new W,Jn=new W,Qn=new W,Ur=new W,Wa=new W,vc=new W,wc=new W,$r=new W;function Cu(t,e,s,i,n){for(let r=0,o=t.length-3;r<=o;r+=3){$r.fromArray(t,r);const a=n.x*Math.abs($r.x)+n.y*Math.abs($r.y)+n.z*Math.abs($r.z),l=e.dot($r),c=s.dot($r),h=i.dot($r);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const os=new W,yc=new tt;let WG=0;class Es extends Mo{constructor(e,s,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:WG++}),this.name="",this.array=e,this.itemSize=s,this.count=e!==void 0?e.length/s:0,this.normalized=i,this.usage=Kp,this.updateRanges=[],this.gpuType=Xi,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,s){this.updateRanges.push({start:e,count:s})}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,s,i){e*=this.itemSize,i*=s.itemSize;for(let n=0,r=this.itemSize;n<r;n++)this.array[e+n]=s.array[i+n];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let s=0,i=this.count;s<i;s++)yc.fromBufferAttribute(this,s),yc.applyMatrix3(e),this.setXY(s,yc.x,yc.y);else if(this.itemSize===3)for(let s=0,i=this.count;s<i;s++)os.fromBufferAttribute(this,s),os.applyMatrix3(e),this.setXYZ(s,os.x,os.y,os.z);return this}applyMatrix4(e){for(let s=0,i=this.count;s<i;s++)os.fromBufferAttribute(this,s),os.applyMatrix4(e),this.setXYZ(s,os.x,os.y,os.z);return this}applyNormalMatrix(e){for(let s=0,i=this.count;s<i;s++)os.fromBufferAttribute(this,s),os.applyNormalMatrix(e),this.setXYZ(s,os.x,os.y,os.z);return this}transformDirection(e){for(let s=0,i=this.count;s<i;s++)os.fromBufferAttribute(this,s),os.transformDirection(e),this.setXYZ(s,os.x,os.y,os.z);return this}set(e,s=0){return this.array.set(e,s),this}getComponent(e,s){let i=this.array[e*this.itemSize+s];return this.normalized&&(i=dn(i,this.array)),i}setComponent(e,s,i){return this.normalized&&(i=kt(i,this.array)),this.array[e*this.itemSize+s]=i,this}getX(e){let s=this.array[e*this.itemSize];return this.normalized&&(s=dn(s,this.array)),s}setX(e,s){return this.normalized&&(s=kt(s,this.array)),this.array[e*this.itemSize]=s,this}getY(e){let s=this.array[e*this.itemSize+1];return this.normalized&&(s=dn(s,this.array)),s}setY(e,s){return this.normalized&&(s=kt(s,this.array)),this.array[e*this.itemSize+1]=s,this}getZ(e){let s=this.array[e*this.itemSize+2];return this.normalized&&(s=dn(s,this.array)),s}setZ(e,s){return this.normalized&&(s=kt(s,this.array)),this.array[e*this.itemSize+2]=s,this}getW(e){let s=this.array[e*this.itemSize+3];return this.normalized&&(s=dn(s,this.array)),s}setW(e,s){return this.normalized&&(s=kt(s,this.array)),this.array[e*this.itemSize+3]=s,this}setXY(e,s,i){return e*=this.itemSize,this.normalized&&(s=kt(s,this.array),i=kt(i,this.array)),this.array[e+0]=s,this.array[e+1]=i,this}setXYZ(e,s,i,n){return e*=this.itemSize,this.normalized&&(s=kt(s,this.array),i=kt(i,this.array),n=kt(n,this.array)),this.array[e+0]=s,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,s,i,n,r){return e*=this.itemSize,this.normalized&&(s=kt(s,this.array),i=kt(i,this.array),n=kt(n,this.array),r=kt(r,this.array)),this.array[e+0]=s,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const 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!==Kp&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class AS extends Es{constructor(e,s,i){super(new Uint16Array(e),s,i)}}class TS extends Es{constructor(e,s,i){super(new Uint32Array(e),s,i)}}class Tt extends Es{constructor(e,s,i){super(new Float32Array(e),s,i)}}const FG=new wo,Fa=new W,Ru=new W;class yo{constructor(e=new W,s=-1){this.isSphere=!0,this.center=e,this.radius=s}set(e,s){return this.center.copy(e),this.radius=s,this}setFromPoints(e,s){const i=this.center;s!==void 0?i.copy(s):FG.setFromPoints(e).getCenter(i);let n=0;for(let r=0,o=e.length;r<o;r++)n=Math.max(n,i.distanceToSquared(e[r]));return this.radius=Math.sqrt(n),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){const s=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=s*s}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,s){const i=this.center.distanceToSquared(e);return s.copy(e),i>this.radius*this.radius&&(s.sub(this.center).normalize(),s.multiplyScalar(this.radius).add(this.center)),s}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=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;Fa.subVectors(e,this.center);const s=Fa.lengthSq();if(s>this.radius*this.radius){const i=Math.sqrt(s),n=(i-this.radius)*.5;this.center.addScaledVector(Fa,n/i),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):(Ru.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Fa.copy(e.center).add(Ru)),this.expandByPoint(Fa.copy(e.center).sub(Ru))),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}}let UG=0;const vi=new Ot,ku=new Zt,Lo=new W,hi=new wo,Ua=new wo,_s=new W;class cs extends Mo{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:UG++}),this.uuid=zr(),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={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(wG(e)?TS:AS)(e,1):this.index=e,this}setIndirect(e,s=0){return this.indirect=e,this.indirectOffset=s,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,s){return this.attributes[e]=s,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,s,i=0){this.groups.push({start:e,count:s,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,s){this.drawRange.start=e,this.drawRange.count=s}applyMatrix4(e){const s=this.attributes.position;s!==void 0&&(s.applyMatrix4(e),s.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new rt().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return vi.makeRotationFromQuaternion(e),this.applyMatrix4(vi),this}rotateX(e){return vi.makeRotationX(e),this.applyMatrix4(vi),this}rotateY(e){return vi.makeRotationY(e),this.applyMatrix4(vi),this}rotateZ(e){return vi.makeRotationZ(e),this.applyMatrix4(vi),this}translate(e,s,i){return vi.makeTranslation(e,s,i),this.applyMatrix4(vi),this}scale(e,s,i){return vi.makeScale(e,s,i),this.applyMatrix4(vi),this}lookAt(e){return ku.lookAt(e),ku.updateMatrix(),this.applyMatrix4(ku.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Lo).negate(),this.translate(Lo.x,Lo.y,Lo.z),this}setFromPoints(e){const s=this.getAttribute("position");if(s===void 0){const i=[];for(let n=0,r=e.length;n<r;n++){const o=e[n];i.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Tt(i,3))}else{const i=Math.min(e.length,s.count);for(let n=0;n<i;n++){const r=e[n];s.setXYZ(n,r.x,r.y,r.z||0)}e.length>s.count&&Je("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),s.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new wo);const e=this.attributes.position,s=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){_t("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new W(-1/0,-1/0,-1/0),new W(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),s)for(let i=0,n=s.length;i<n;i++){const r=s[i];hi.setFromBufferAttribute(r),this.morphTargetsRelative?(_s.addVectors(this.boundingBox.min,hi.min),this.boundingBox.expandByPoint(_s),_s.addVectors(this.boundingBox.max,hi.max),this.boundingBox.expandByPoint(_s)):(this.boundingBox.expandByPoint(hi.min),this.boundingBox.expandByPoint(hi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&_t('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 yo);const e=this.attributes.position,s=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){_t("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new W,1/0);return}if(e){const i=this.boundingSphere.center;if(hi.setFromBufferAttribute(e),s)for(let r=0,o=s.length;r<o;r++){const a=s[r];Ua.setFromBufferAttribute(a),this.morphTargetsRelative?(_s.addVectors(hi.min,Ua.min),hi.expandByPoint(_s),_s.addVectors(hi.max,Ua.max),hi.expandByPoint(_s)):(hi.expandByPoint(Ua.min),hi.expandByPoint(Ua.max))}hi.getCenter(i);let n=0;for(let r=0,o=e.count;r<o;r++)_s.fromBufferAttribute(e,r),n=Math.max(n,i.distanceToSquared(_s));if(s)for(let r=0,o=s.length;r<o;r++){const a=s[r],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)_s.fromBufferAttribute(a,c),l&&(Lo.fromBufferAttribute(e,c),_s.add(Lo)),n=Math.max(n,i.distanceToSquared(_s))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&_t('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,s=this.attributes;if(e===null||s.position===void 0||s.normal===void 0||s.uv===void 0){_t("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=s.position,n=s.normal,r=s.uv;let o=this.getAttribute("tangent");(o===void 0||o.count!==i.count)&&(o=new Es(new Float32Array(4*i.count),4),this.setAttribute("tangent",o));const a=[],l=[];for(let M=0;M<i.count;M++)a[M]=new W,l[M]=new W;const c=new W,h=new W,d=new W,u=new tt,p=new tt,f=new tt,_=new W,g=new W;function m(M,S,T){c.fromBufferAttribute(i,M),h.fromBufferAttribute(i,S),d.fromBufferAttribute(i,T),u.fromBufferAttribute(r,M),p.fromBufferAttribute(r,S),f.fromBufferAttribute(r,T),h.sub(c),d.sub(c),p.sub(u),f.sub(u);const I=1/(p.x*f.y-f.x*p.y);isFinite(I)&&(_.copy(h).multiplyScalar(f.y).addScaledVector(d,-p.y).multiplyScalar(I),g.copy(d).multiplyScalar(p.x).addScaledVector(h,-f.x).multiplyScalar(I),a[M].add(_),a[S].add(_),a[T].add(_),l[M].add(g),l[S].add(g),l[T].add(g))}let w=this.groups;w.length===0&&(w=[{start:0,count:e.count}]);for(let M=0,S=w.length;M<S;++M){const T=w[M],I=T.start,E=T.count;for(let O=I,R=I+E;O<R;O+=3)m(e.getX(O+0),e.getX(O+1),e.getX(O+2))}const y=new W,b=new W,v=new W,z=new W;function x(M){v.fromBufferAttribute(n,M),z.copy(v);const S=a[M];y.copy(S),y.sub(v.multiplyScalar(v.dot(S))).normalize(),b.crossVectors(z,S);const I=b.dot(l[M])<0?-1:1;o.setXYZW(M,y.x,y.y,y.z,I)}for(let M=0,S=w.length;M<S;++M){const T=w[M],I=T.start,E=T.count;for(let O=I,R=I+E;O<R;O+=3)x(e.getX(O+0)),x(e.getX(O+1)),x(e.getX(O+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,s=this.getAttribute("position");if(s!==void 0){let i=this.getAttribute("normal");if(i===void 0||i.count!==s.count)i=new Es(new Float32Array(s.count*3),3),this.setAttribute("normal",i);else for(let u=0,p=i.count;u<p;u++)i.setXYZ(u,0,0,0);const n=new W,r=new W,o=new W,a=new W,l=new W,c=new W,h=new W,d=new W;if(e)for(let u=0,p=e.count;u<p;u+=3){const f=e.getX(u+0),_=e.getX(u+1),g=e.getX(u+2);n.fromBufferAttribute(s,f),r.fromBufferAttribute(s,_),o.fromBufferAttribute(s,g),h.subVectors(o,r),d.subVectors(n,r),h.cross(d),a.fromBufferAttribute(i,f),l.fromBufferAttribute(i,_),c.fromBufferAttribute(i,g),a.add(h),l.add(h),c.add(h),i.setXYZ(f,a.x,a.y,a.z),i.setXYZ(_,l.x,l.y,l.z),i.setXYZ(g,c.x,c.y,c.z)}else for(let u=0,p=s.count;u<p;u+=3)n.fromBufferAttribute(s,u+0),r.fromBufferAttribute(s,u+1),o.fromBufferAttribute(s,u+2),h.subVectors(o,r),d.subVectors(n,r),h.cross(d),i.setXYZ(u+0,h.x,h.y,h.z),i.setXYZ(u+1,h.x,h.y,h.z),i.setXYZ(u+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let s=0,i=e.count;s<i;s++)_s.fromBufferAttribute(e,s),_s.normalize(),e.setXYZ(s,_s.x,_s.y,_s.z)}toNonIndexed(){function e(a,l){const c=a.array,h=a.itemSize,d=a.normalized,u=new c.constructor(l.length*h);let p=0,f=0;for(let _=0,g=l.length;_<g;_++){a.isInterleavedBufferAttribute?p=l[_]*a.data.stride+a.offset:p=l[_]*h;for(let m=0;m<h;m++)u[f++]=c[p++]}return new Es(u,h,d)}if(this.index===null)return Je("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const s=new cs,i=this.index.array,n=this.attributes;for(const a in n){const l=n[a],c=e(l,i);s.setAttribute(a,c)}const r=this.morphAttributes;for(const a in r){const l=[],c=r[a];for(let h=0,d=c.length;h<d;h++){const u=c[h],p=e(u,i);l.push(p)}s.morphAttributes[a]=l}s.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];s.addGroup(c.start,c.count,c.materialIndex)}return s}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const s=this.index;s!==null&&(e.data.index={type:s.array.constructor.name,array:Array.prototype.slice.call(s.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const n={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d<u;d++){const p=c[d];h.push(p.toJSON(e.data))}h.length>0&&(n[l]=h,r=!0)}r&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.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;const s={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const n=e.attributes;for(const c in n){const h=n[c];this.setAttribute(c,h.clone(s))}const r=e.morphAttributes;for(const c in r){const h=[],d=r[c];for(let u=0,p=d.length;u<p;u++)h.push(d[u].clone(s));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let c=0,h=o.length;c<h;c++){const d=o[c];this.addGroup(d.start,d.count,d.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class $G{constructor(e,s){this.isInterleavedBuffer=!0,this.array=e,this.stride=s,this.count=e!==void 0?e.length/s:0,this.usage=Kp,this.updateRanges=[],this.version=0,this.uuid=zr()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,s){this.updateRanges.push({start:e,count:s})}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,s,i){e*=this.stride,i*=s.stride;for(let n=0,r=this.stride;n<r;n++)this.array[e+n]=s.array[i+n];return this}set(e,s=0){return this.array.set(e,s),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=zr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const s=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(s,this.stride);return i.setUsage(this.usage),i}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=zr()),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}}}const js=new W;class Qh{constructor(e,s,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=s,this.offset=i,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let s=0,i=this.data.count;s<i;s++)js.fromBufferAttribute(this,s),js.applyMatrix4(e),this.setXYZ(s,js.x,js.y,js.z);return this}applyNormalMatrix(e){for(let s=0,i=this.count;s<i;s++)js.fromBufferAttribute(this,s),js.applyNormalMatrix(e),this.setXYZ(s,js.x,js.y,js.z);return this}transformDirection(e){for(let s=0,i=this.count;s<i;s++)js.fromBufferAttribute(this,s),js.transformDirection(e),this.setXYZ(s,js.x,js.y,js.z);return this}getComponent(e,s){let i=this.array[e*this.data.stride+this.offset+s];return this.normalized&&(i=dn(i,this.array)),i}setComponent(e,s,i){return this.normalized&&(i=kt(i,this.array)),this.data.array[e*this.data.stride+this.offset+s]=i,this}setX(e,s){return this.normalized&&(s=kt(s,this.array)),this.data.array[e*this.data.stride+this.offset]=s,this}setY(e,s){return this.normalized&&(s=kt(s,this.array)),this.data.array[e*this.data.stride+this.offset+1]=s,this}setZ(e,s){return this.normalized&&(s=kt(s,this.array)),this.data.array[e*this.data.stride+this.offset+2]=s,this}setW(e,s){return this.normalized&&(s=kt(s,this.array)),this.data.array[e*this.data.stride+this.offset+3]=s,this}getX(e){let s=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(s=dn(s,this.array)),s}getY(e){let s=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(s=dn(s,this.array)),s}getZ(e){let s=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(s=dn(s,this.array)),s}getW(e){let s=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(s=dn(s,this.array)),s}setXY(e,s,i){return e=e*this.data.stride+this.offset,this.normalized&&(s=kt(s,this.array),i=kt(i,this.array)),this.data.array[e+0]=s,this.data.array[e+1]=i,this}setXYZ(e,s,i,n){return e=e*this.data.stride+this.offset,this.normalized&&(s=kt(s,this.array),i=kt(i,this.array),n=kt(n,this.array)),this.data.array[e+0]=s,this.data.array[e+1]=i,this.data.array[e+2]=n,this}setXYZW(e,s,i,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(s=kt(s,this.array),i=kt(i,this.array),n=kt(n,this.array),r=kt(r,this.array)),this.data.array[e+0]=s,this.data.array[e+1]=i,this.data.array[e+2]=n,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Jh("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const s=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)s.push(this.data.array[n+r])}return new Es(new this.array.constructor(s),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Qh(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Jh("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const s=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)s.push(this.data.array[n+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:s,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}}}let jG=0;class qn extends Mo{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:jG++}),this.uuid=zr(),this.name="",this.type="Material",this.blending=ao,this.side=Cr,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=op,this.blendDst=ap,this.blendEquation=Jr,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ke(0,0,0),this.blendAlpha=0,this.depthFunc=ga,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=I0,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=To,this.stencilZFail=To,this.stencilZPass=To,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(const s in e){const i=e[s];if(i===void 0){Je(`Material: parameter '${s}' has value of undefined.`);continue}const n=this[s];if(n===void 0){Je(`Material: '${s}' is not a property of THREE.${this.type}.`);continue}n&&n.isColor?n.set(i):n&&n.isVector2&&i&&i.isVector2||n&&n.isEuler&&i&&i.isEuler||n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[s]=i}}toJSON(e){const s=e===void 0||typeof e=="string";s&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==ao&&(i.blending=this.blending),this.side!==Cr&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==op&&(i.blendSrc=this.blendSrc),this.blendDst!==ap&&(i.blendDst=this.blendDst),this.blendEquation!==Jr&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==ga&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==I0&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==To&&(i.stencilFail=this.stencilFail),this.stencilZFail!==To&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==To&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function n(r){const o=[];for(const a in r){const l=r[a];delete l.metadata,o.push(l)}return o}if(s){const r=n(e.textures),o=n(e.images);r.length>0&&(i.textures=r),o.length>0&&(i.images=o)}return i}fromJSON(e,s){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Ke().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=s[e.map]||null),e.matcap!==void 0&&(this.matcap=s[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=s[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=s[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=s[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new tt().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=s[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=s[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=s[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=s[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=s[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=s[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=s[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=s[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=s[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=s[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=s[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=s[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=s[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=s[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new tt().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=s[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=s[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=s[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=s[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=s[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=s[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=s[e.sheenRoughnessMap]||null),this}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;const s=e.clippingPlanes;let i=null;if(s!==null){const n=s.length;i=new Array(n);for(let r=0;r!==n;++r)i[r]=s[r].clone()}return this.clippingPlanes=i,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++}}class Kl extends qn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ke(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}}let Wo;const $a=new W,Fo=new W,Uo=new W,$o=new tt,ja=new tt,IS=new Ot,zc=new W,Ha=new W,Sc=new W,j0=new tt,Nu=new tt,H0=new tt;class Id extends Zt{constructor(e=new Kl){if(super(),this.isSprite=!0,this.type="Sprite",Wo===void 0){Wo=new cs;const s=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new $G(s,5);Wo.setIndex([0,1,2,0,2,3]),Wo.setAttribute("position",new Qh(i,3,0,!1)),Wo.setAttribute("uv",new Qh(i,2,3,!1))}this.geometry=Wo,this.material=e,this.center=new tt(.5,.5),this.count=1}raycast(e,s){e.camera===null&&_t('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Fo.setFromMatrixScale(this.matrixWorld),IS.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Uo.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Fo.multiplyScalar(-Uo.z);const i=this.material.rotation;let n,r;i!==0&&(r=Math.cos(i),n=Math.sin(i));const o=this.center;xc(zc.set(-.5,-.5,0),Uo,o,Fo,n,r),xc(Ha.set(.5,-.5,0),Uo,o,Fo,n,r),xc(Sc.set(.5,.5,0),Uo,o,Fo,n,r),j0.set(0,0),Nu.set(1,0),H0.set(1,1);let a=e.ray.intersectTriangle(zc,Ha,Sc,!1,$a);if(a===null&&(xc(Ha.set(-.5,.5,0),Uo,o,Fo,n,r),Nu.set(0,1),a=e.ray.intersectTriangle(zc,Sc,Ha,!1,$a),a===null))return;const l=e.ray.origin.distanceTo($a);l<e.near||l>e.far||s.push({distance:l,point:$a.clone(),uv:Di.getInterpolation($a,zc,Ha,Sc,j0,Nu,H0,new tt),face:null,object:this})}copy(e,s){return super.copy(e,s),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function xc(t,e,s,i,n,r){$o.subVectors(t,s).addScalar(.5).multiply(i),n!==void 0?(ja.x=r*$o.x-n*$o.y,ja.y=n*$o.x+r*$o.y):ja.copy($o),t.copy(e),t.x+=ja.x,t.y+=ja.y,t.applyMatrix4(IS)}const On=new W,Bu=new W,Oc=new W,er=new W,Gu=new W,Ec=new W,Pu=new W;class Dd{constructor(e=new W,s=new W(0,0,-1)){this.origin=e,this.direction=s}set(e,s){return this.origin.copy(e),this.direction.copy(s),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,s){return s.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,On)),this}closestPointToPoint(e,s){s.subVectors(e,this.origin);const i=s.dot(this.direction);return i<0?s.copy(this.origin):s.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const s=On.subVectors(e,this.origin).dot(this.direction);return s<0?this.origin.distanceToSquared(e):(On.copy(this.origin).addScaledVector(this.direction,s),On.distanceToSquared(e))}distanceSqToSegment(e,s,i,n){Bu.copy(e).add(s).multiplyScalar(.5),Oc.copy(s).sub(e).normalize(),er.copy(this.origin).sub(Bu);const r=e.distanceTo(s)*.5,o=-this.direction.dot(Oc),a=er.dot(this.direction),l=-er.dot(Oc),c=er.lengthSq(),h=Math.abs(1-o*o);let d,u,p,f;if(h>0)if(d=o*l-a,u=o*a-l,f=r*h,d>=0)if(u>=-f)if(u<=f){const _=1/h;d*=_,u*=_,p=d*(d+o*u+2*a)+u*(o*d+u+2*l)+c}else u=r,d=Math.max(0,-(o*u+a)),p=-d*d+u*(u+2*l)+c;else u=-r,d=Math.max(0,-(o*u+a)),p=-d*d+u*(u+2*l)+c;else u<=-f?(d=Math.max(0,-(-o*r+a)),u=d>0?-r:Math.min(Math.max(-r,-l),r),p=-d*d+u*(u+2*l)+c):u<=f?(d=0,u=Math.min(Math.max(-r,-l),r),p=u*(u+2*l)+c):(d=Math.max(0,-(o*r+a)),u=d>0?r:Math.min(Math.max(-r,-l),r),p=-d*d+u*(u+2*l)+c);else u=o>0?-r:r,d=Math.max(0,-(o*u+a)),p=-d*d+u*(u+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),n&&n.copy(Bu).addScaledVector(Oc,u),p}intersectSphere(e,s){On.subVectors(e.center,this.origin);const i=On.dot(this.direction),n=On.dot(On)-i*i,r=e.radius*e.radius;if(n>r)return null;const o=Math.sqrt(r-n),a=i-o,l=i+o;return l<0?null:a<0?this.at(l,s):this.at(a,s)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const s=e.normal.dot(this.direction);if(s===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/s;return i>=0?i:null}intersectPlane(e,s){const i=this.distanceToPlane(e);return i===null?null:this.at(i,s)}intersectsPlane(e){const s=e.distanceToPoint(this.origin);return s===0||e.normal.dot(this.direction)*s<0}intersectBox(e,s){let i,n,r,o,a,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(i=(e.min.x-u.x)*c,n=(e.max.x-u.x)*c):(i=(e.max.x-u.x)*c,n=(e.min.x-u.x)*c),h>=0?(r=(e.min.y-u.y)*h,o=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,o=(e.min.y-u.y)*h),i>o||r>n||((r>i||isNaN(i))&&(i=r),(o<n||isNaN(n))&&(n=o),d>=0?(a=(e.min.z-u.z)*d,l=(e.max.z-u.z)*d):(a=(e.max.z-u.z)*d,l=(e.min.z-u.z)*d),i>l||a>n)||((a>i||i!==i)&&(i=a),(l<n||n!==n)&&(n=l),n<0)?null:this.at(i>=0?i:n,s)}intersectsBox(e){return this.intersectBox(e,On)!==null}intersectTriangle(e,s,i,n,r){Gu.subVectors(s,e),Ec.subVectors(i,e),Pu.crossVectors(Gu,Ec);let o=this.direction.dot(Pu),a;if(o>0){if(n)return null;a=1}else if(o<0)a=-1,o=-o;else return null;er.subVectors(this.origin,e);const l=a*this.direction.dot(Ec.crossVectors(er,Ec));if(l<0)return null;const c=a*this.direction.dot(Gu.cross(er));if(c<0||l+c>o)return null;const h=-a*er.dot(Pu);return h<0?null:this.at(h/o,r)}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)}}class Kg extends qn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ke(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 kr,this.combine=hS,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}}const V0=new Ot,jr=new Dd,Ac=new yo,q0=new W,Tc=new W,Ic=new W,Dc=new W,Lu=new W,Cc=new W,K0=new W,Rc=new W;class ii extends Zt{constructor(e=new cs,s=new Kg){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=s,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,s){return super.copy(e,s),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(){const s=this.geometry.morphAttributes,i=Object.keys(s);if(i.length>0){const n=s[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r<o;r++){const a=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,s){const i=this.geometry,n=i.attributes.position,r=i.morphAttributes.position,o=i.morphTargetsRelative;s.fromBufferAttribute(n,e);const a=this.morphTargetInfluences;if(r&&a){Cc.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const h=a[l],d=r[l];h!==0&&(Lu.fromBufferAttribute(d,e),o?Cc.addScaledVector(Lu,h):Cc.addScaledVector(Lu.sub(s),h))}s.add(Cc)}return s}raycast(e,s){const i=this.geometry,n=this.material,r=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Ac.copy(i.boundingSphere),Ac.applyMatrix4(r),jr.copy(e.ray).recast(e.near),!(Ac.containsPoint(jr.origin)===!1&&(jr.intersectSphere(Ac,q0)===null||jr.origin.distanceToSquared(q0)>(e.far-e.near)**2))&&(V0.copy(r).invert(),jr.copy(e.ray).applyMatrix4(V0),!(i.boundingBox!==null&&jr.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,s,jr)))}_computeIntersections(e,s,i){let n;const r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,p=r.drawRange;if(a!==null)if(Array.isArray(o))for(let f=0,_=u.length;f<_;f++){const g=u[f],m=o[g.materialIndex],w=Math.max(g.start,p.start),y=Math.min(a.count,Math.min(g.start+g.count,p.start+p.count));for(let b=w,v=y;b<v;b+=3){const z=a.getX(b),x=a.getX(b+1),M=a.getX(b+2);n=kc(this,m,e,i,c,h,d,z,x,M),n&&(n.faceIndex=Math.floor(b/3),n.face.materialIndex=g.materialIndex,s.push(n))}}else{const f=Math.max(0,p.start),_=Math.min(a.count,p.start+p.count);for(let g=f,m=_;g<m;g+=3){const w=a.getX(g),y=a.getX(g+1),b=a.getX(g+2);n=kc(this,o,e,i,c,h,d,w,y,b),n&&(n.faceIndex=Math.floor(g/3),s.push(n))}}else if(l!==void 0)if(Array.isArray(o))for(let f=0,_=u.length;f<_;f++){const g=u[f],m=o[g.materialIndex],w=Math.max(g.start,p.start),y=Math.min(l.count,Math.min(g.start+g.count,p.start+p.count));for(let b=w,v=y;b<v;b+=3){const z=b,x=b+1,M=b+2;n=kc(this,m,e,i,c,h,d,z,x,M),n&&(n.faceIndex=Math.floor(b/3),n.face.materialIndex=g.materialIndex,s.push(n))}}else{const f=Math.max(0,p.start),_=Math.min(l.count,p.start+p.count);for(let g=f,m=_;g<m;g+=3){const w=g,y=g+1,b=g+2;n=kc(this,o,e,i,c,h,d,w,y,b),n&&(n.faceIndex=Math.floor(g/3),s.push(n))}}}}function HG(t,e,s,i,n,r,o,a){let l;if(e.side===si?l=i.intersectTriangle(o,r,n,!0,a):l=i.intersectTriangle(n,r,o,e.side===Cr,a),l===null)return null;Rc.copy(a),Rc.applyMatrix4(t.matrixWorld);const c=s.ray.origin.distanceTo(Rc);return c<s.near||c>s.far?null:{distance:c,point:Rc.clone(),object:t}}function kc(t,e,s,i,n,r,o,a,l,c){t.getVertexPosition(a,Tc),t.getVertexPosition(l,Ic),t.getVertexPosition(c,Dc);const h=HG(t,e,s,i,Tc,Ic,Dc,K0);if(h){const d=new W;Di.getBarycoord(K0,Tc,Ic,Dc,d),n&&(h.uv=Di.getInterpolatedAttribute(n,a,l,c,d,new tt)),r&&(h.uv1=Di.getInterpolatedAttribute(r,a,l,c,d,new tt)),o&&(h.normal=Di.getInterpolatedAttribute(o,a,l,c,d,new W),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const u={a,b:l,c,normal:new W,materialIndex:0};Di.getNormal(Tc,Ic,Dc,u.normal),h.face=u,h.barycoord=d}return h}class DS extends Ws{constructor(e=null,s=1,i=1,n,r,o,a,l,c=Is,h=Is,d,u){super(null,o,a,l,c,h,n,r,d,u),this.isDataTexture=!0,this.image={data:e,width:s,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Sr extends Es{constructor(e,s,i,n=1){super(e,s,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const jo=new Ot,Y0=new Ot,Nc=[],X0=new wo,VG=new Ot,Va=new ii,qa=new yo;class Yg extends ii{constructor(e,s,i){super(e,s),this.isInstancedMesh=!0,this.instanceMatrix=new Sr(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<i;n++)this.setMatrixAt(n,VG)}computeBoundingBox(){const e=this.geometry,s=this.count;this.boundingBox===null&&(this.boundingBox=new wo),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<s;i++)this.getMatrixAt(i,jo),X0.copy(e.boundingBox).applyMatrix4(jo),this.boundingBox.union(X0)}computeBoundingSphere(){const e=this.geometry,s=this.count;this.boundingSphere===null&&(this.boundingSphere=new yo),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<s;i++)this.getMatrixAt(i,jo),qa.copy(e.boundingSphere).applyMatrix4(jo),this.boundingSphere.union(qa)}copy(e,s){return super.copy(e,s),this.instanceMatrix.copy(e.instanceMatrix),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,s){return this.instanceColor===null?s.setRGB(1,1,1):s.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,s){return s.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,s){const i=s.morphTargetInfluences,n=this.morphTexture.source.data.data,r=i.length+1,o=e*r+1;for(let a=0;a<i.length;a++)i[a]=n[o+a]}raycast(e,s){const i=this.matrixWorld,n=this.count;if(Va.geometry=this.geometry,Va.material=this.material,Va.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),qa.copy(this.boundingSphere),qa.applyMatrix4(i),e.ray.intersectsSphere(qa)!==!1))for(let r=0;r<n;r++){this.getMatrixAt(r,jo),Y0.multiplyMatrices(i,jo),Va.matrixWorld=Y0,Va.raycast(e,Nc);for(let o=0,a=Nc.length;o<a;o++){const l=Nc[o];l.instanceId=r,l.object=this,s.push(l)}Nc.length=0}}setColorAt(e,s){return this.instanceColor===null&&(this.instanceColor=new Sr(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),s.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,s){return s.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,s){const i=s.morphTargetInfluences,n=i.length+1;this.morphTexture===null&&(this.morphTexture=new DS(new Float32Array(n*this.count),n,this.count,Wg,Xi));const r=this.morphTexture.source.data.data;let o=0;for(let c=0;c<i.length;c++)o+=i[c];const a=this.geometry.morphTargetsRelative?1:1-o,l=n*e;return r[l]=a,r.set(i,l+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Wu=new W,qG=new W,KG=new rt;class cr{constructor(e=new W(1,0,0),s=0){this.isPlane=!0,this.normal=e,this.constant=s}set(e,s){return this.normal.copy(e),this.constant=s,this}setComponents(e,s,i,n){return this.normal.set(e,s,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,s){return this.normal.copy(e),this.constant=-s.dot(this.normal),this}setFromCoplanarPoints(e,s,i){const n=Wu.subVectors(i,s).cross(qG.subVectors(e,s)).normalize();return this.setFromNormalAndCoplanarPoint(n,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const 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,s){return s.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,s,i=!0){const n=e.delta(Wu),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?s.copy(e.start):null;const o=-(e.start.dot(this.normal)+this.constant)/r;return i===!0&&(o<0||o>1)?null:s.copy(e.start).addScaledVector(n,o)}intersectsLine(e){const s=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return s<0&&i>0||i<0&&s>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,s){const i=s||KG.getNormalMatrix(e),n=this.coplanarPoint(Wu).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),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)}}const Hr=new yo,YG=new tt(.5,.5),Bc=new W;class Xg{constructor(e=new cr,s=new cr,i=new cr,n=new cr,r=new cr,o=new cr){this.planes=[e,s,i,n,r,o]}set(e,s,i,n,r,o){const a=this.planes;return a[0].copy(e),a[1].copy(s),a[2].copy(i),a[3].copy(n),a[4].copy(r),a[5].copy(o),this}copy(e){const s=this.planes;for(let i=0;i<6;i++)s[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,s=un,i=!1){const n=this.planes,r=e.elements,o=r[0],a=r[1],l=r[2],c=r[3],h=r[4],d=r[5],u=r[6],p=r[7],f=r[8],_=r[9],g=r[10],m=r[11],w=r[12],y=r[13],b=r[14],v=r[15];if(n[0].setComponents(c-o,p-h,m-f,v-w).normalize(),n[1].setComponents(c+o,p+h,m+f,v+w).normalize(),n[2].setComponents(c+a,p+d,m+_,v+y).normalize(),n[3].setComponents(c-a,p-d,m-_,v-y).normalize(),i)n[4].setComponents(l,u,g,b).normalize(),n[5].setComponents(c-l,p-u,m-g,v-b).normalize();else if(n[4].setComponents(c-l,p-u,m-g,v-b).normalize(),s===un)n[5].setComponents(c+l,p+u,m+g,v+b).normalize();else if(s===Ll)n[5].setComponents(l,u,g,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+s);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Hr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const s=e.geometry;s.boundingSphere===null&&s.computeBoundingSphere(),Hr.copy(s.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Hr)}intersectsSprite(e){Hr.center.set(0,0,0);const s=YG.distanceTo(e.center);return Hr.radius=.7071067811865476+s,Hr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Hr)}intersectsSphere(e){const s=this.planes,i=e.center,n=-e.radius;for(let r=0;r<6;r++)if(s[r].distanceToPoint(i)<n)return!1;return!0}intersectsBox(e){const s=this.planes;for(let i=0;i<6;i++){const n=s[i];if(Bc.x=n.normal.x>0?e.max.x:e.min.x,Bc.y=n.normal.y>0?e.max.y:e.min.y,Bc.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(Bc)<0)return!1}return!0}containsPoint(e){const s=this.planes;for(let i=0;i<6;i++)if(s[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Cd extends qn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ke(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}}const ed=new W,td=new W,Z0=new Ot,Ka=new Dd,Gc=new yo,Fu=new W,J0=new W;class Xp extends Zt{constructor(e=new cs,s=new Cd){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=s,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,s){return super.copy(e,s),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const s=e.attributes.position,i=[0];for(let n=1,r=s.count;n<r;n++)ed.fromBufferAttribute(s,n-1),td.fromBufferAttribute(s,n),i[n]=i[n-1],i[n]+=ed.distanceTo(td);e.setAttribute("lineDistance",new Tt(i,1))}else Je("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,s){const i=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Gc.copy(i.boundingSphere),Gc.applyMatrix4(n),Gc.radius+=r,e.ray.intersectsSphere(Gc)===!1)return;Z0.copy(n).invert(),Ka.copy(e.ray).applyMatrix4(Z0);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,h=i.index,u=i.attributes.position;if(h!==null){const p=Math.max(0,o.start),f=Math.min(h.count,o.start+o.count);for(let _=p,g=f-1;_<g;_+=c){const m=h.getX(_),w=h.getX(_+1),y=Pc(this,e,Ka,l,m,w,_);y&&s.push(y)}if(this.isLineLoop){const _=h.getX(f-1),g=h.getX(p),m=Pc(this,e,Ka,l,_,g,f-1);m&&s.push(m)}}else{const p=Math.max(0,o.start),f=Math.min(u.count,o.start+o.count);for(let _=p,g=f-1;_<g;_+=c){const m=Pc(this,e,Ka,l,_,_+1,_);m&&s.push(m)}if(this.isLineLoop){const _=Pc(this,e,Ka,l,f-1,p,f-1);_&&s.push(_)}}}updateMorphTargets(){const s=this.geometry.morphAttributes,i=Object.keys(s);if(i.length>0){const n=s[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r<o;r++){const a=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Pc(t,e,s,i,n,r,o){const a=t.geometry.attributes.position;if(ed.fromBufferAttribute(a,n),td.fromBufferAttribute(a,r),s.distanceSqToSegment(ed,td,Fu,J0)>i)return;Fu.applyMatrix4(t.matrixWorld);const c=e.ray.origin.distanceTo(Fu);if(!(c<e.near||c>e.far))return{distance:c,point:J0.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const Q0=new W,eM=new W;class Zp extends Xp{constructor(e,s){super(e,s),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const s=e.attributes.position,i=[];for(let n=0,r=s.count;n<r;n+=2)Q0.fromBufferAttribute(s,n),eM.fromBufferAttribute(s,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+Q0.distanceTo(eM);e.setAttribute("lineDistance",new Tt(i,1))}else Je("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class XG extends qn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ke(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}}const tM=new Ot,Jp=new Dd,Lc=new yo,Wc=new W;class ZG extends Zt{constructor(e=new cs,s=new XG){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=s,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,s){return super.copy(e,s),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,s){const i=this.geometry,n=this.matrixWorld,r=e.params.Points.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Lc.copy(i.boundingSphere),Lc.applyMatrix4(n),Lc.radius+=r,e.ray.intersectsSphere(Lc)===!1)return;tM.copy(n).invert(),Jp.copy(e.ray).applyMatrix4(tM);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=i.index,d=i.attributes.position;if(c!==null){const u=Math.max(0,o.start),p=Math.min(c.count,o.start+o.count);for(let f=u,_=p;f<_;f++){const g=c.getX(f);Wc.fromBufferAttribute(d,g),sM(Wc,g,l,n,e,s,this)}}else{const u=Math.max(0,o.start),p=Math.min(d.count,o.start+o.count);for(let f=u,_=p;f<_;f++)Wc.fromBufferAttribute(d,f),sM(Wc,f,l,n,e,s,this)}}updateMorphTargets(){const s=this.geometry.morphAttributes,i=Object.keys(s);if(i.length>0){const n=s[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r<o;r++){const a=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function sM(t,e,s,i,n,r,o){const a=Jp.distanceSqToPoint(t);if(a<s){const l=new W;Jp.closestPointToPoint(t,l),l.applyMatrix4(i);const c=n.ray.origin.distanceTo(l);if(c<n.near||c>n.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}class CS extends Ws{constructor(e=[],s=mo,i,n,r,o,a,l,c,h){super(e,s,i,n,r,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class RS extends Ws{constructor(e,s,i,n,r,o,a,l,c){super(e,s,i,n,r,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class ba extends Ws{constructor(e,s,i=Mn,n,r,o,a=Is,l=Is,c,h=Hn,d=1){if(h!==Hn&&h!==to)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:e,height:s,depth:d};super(u,n,r,o,a,l,h,i,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Vg(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const s=super.toJSON(e);return this.compareFunction!==null&&(s.compareFunction=this.compareFunction),s}}class JG extends ba{constructor(e,s=Mn,i=mo,n,r,o=Is,a=Is,l,c=Hn){const h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,s,i,n,r,o,a,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class kS extends Ws{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Yl extends cs{constructor(e=1,s=1,i=1,n=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:s,depth:i,widthSegments:n,heightSegments:r,depthSegments:o};const a=this;n=Math.floor(n),r=Math.floor(r),o=Math.floor(o);const l=[],c=[],h=[],d=[];let u=0,p=0;f("z","y","x",-1,-1,i,s,e,o,r,0),f("z","y","x",1,-1,i,s,-e,o,r,1),f("x","z","y",1,1,e,i,s,n,o,2),f("x","z","y",1,-1,e,i,-s,n,o,3),f("x","y","z",1,-1,e,s,i,n,r,4),f("x","y","z",-1,-1,e,s,-i,n,r,5),this.setIndex(l),this.setAttribute("position",new Tt(c,3)),this.setAttribute("normal",new Tt(h,3)),this.setAttribute("uv",new Tt(d,2));function f(_,g,m,w,y,b,v,z,x,M,S){const T=b/x,I=v/M,E=b/2,O=v/2,R=z/2,C=x+1,k=M+1;let B=0,L=0;const F=new W;for(let ee=0;ee<k;ee++){const X=ee*I-O;for(let he=0;he<C;he++){const Oe=he*T-E;F[_]=Oe*w,F[g]=X*y,F[m]=R,c.push(F.x,F.y,F.z),F[_]=0,F[g]=0,F[m]=z>0?1:-1,h.push(F.x,F.y,F.z),d.push(he/x),d.push(1-ee/M),B+=1}}for(let ee=0;ee<M;ee++)for(let X=0;X<x;X++){const he=u+X+C*ee,Oe=u+X+C*(ee+1),De=u+(X+1)+C*(ee+1),ke=u+(X+1)+C*ee;l.push(he,Oe,ke),l.push(Oe,De,ke),L+=6}a.addGroup(p,L,S),p+=L,u+=B}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Yl(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Zg extends cs{constructor(e=1,s=32,i=0,n=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:s,thetaStart:i,thetaLength:n},s=Math.max(3,s);const r=[],o=[],a=[],l=[],c=new W,h=new tt;o.push(0,0,0),a.push(0,0,1),l.push(.5,.5);for(let d=0,u=3;d<=s;d++,u+=3){const p=i+d/s*n;c.x=e*Math.cos(p),c.y=e*Math.sin(p),o.push(c.x,c.y,c.z),a.push(0,0,1),h.x=(o[u]/e+1)/2,h.y=(o[u+1]/e+1)/2,l.push(h.x,h.y)}for(let d=1;d<=s;d++)r.push(d,d+1,0);this.setIndex(r),this.setAttribute("position",new Tt(o,3)),this.setAttribute("normal",new Tt(a,3)),this.setAttribute("uv",new Tt(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Zg(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Jg extends cs{constructor(e=1,s=1,i=1,n=32,r=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:s,height:i,radialSegments:n,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:l};const c=this;n=Math.floor(n),r=Math.floor(r);const h=[],d=[],u=[],p=[];let f=0;const _=[],g=i/2;let m=0;w(),o===!1&&(e>0&&y(!0),s>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new Tt(d,3)),this.setAttribute("normal",new Tt(u,3)),this.setAttribute("uv",new Tt(p,2));function w(){const b=new W,v=new W;let z=0;const x=(s-e)/i;for(let M=0;M<=r;M++){const S=[],T=M/r,I=T*(s-e)+e;for(let E=0;E<=n;E++){const O=E/n,R=O*l+a,C=Math.sin(R),k=Math.cos(R);v.x=I*C,v.y=-T*i+g,v.z=I*k,d.push(v.x,v.y,v.z),b.set(C,x,k).normalize(),u.push(b.x,b.y,b.z),p.push(O,1-T),S.push(f++)}_.push(S)}for(let M=0;M<n;M++)for(let S=0;S<r;S++){const T=_[S][M],I=_[S+1][M],E=_[S+1][M+1],O=_[S][M+1];(e>0||S!==0)&&(h.push(T,I,O),z+=3),(s>0||S!==r-1)&&(h.push(I,E,O),z+=3)}c.addGroup(m,z,0),m+=z}function y(b){const v=f,z=new tt,x=new W;let M=0;const S=b===!0?e:s,T=b===!0?1:-1;for(let E=1;E<=n;E++)d.push(0,g*T,0),u.push(0,T,0),p.push(.5,.5),f++;const I=f;for(let E=0;E<=n;E++){const R=E/n*l+a,C=Math.cos(R),k=Math.sin(R);x.x=S*k,x.y=g*T,x.z=S*C,d.push(x.x,x.y,x.z),u.push(0,T,0),z.x=C*.5+.5,z.y=k*.5*T+.5,p.push(z.x,z.y),f++}for(let E=0;E<n;E++){const O=v+E,R=I+E;b===!0?h.push(R,R+1,O):h.push(R+1,R,O),M+=3}c.addGroup(m,M,b===!0?1:2),m+=M}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Jg(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Qg extends cs{constructor(e=[],s=[],i=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:s,radius:i,detail:n};const r=[],o=[];a(n),c(i),h(),this.setAttribute("position",new Tt(r,3)),this.setAttribute("normal",new Tt(r.slice(),3)),this.setAttribute("uv",new Tt(o,2)),n===0?this.computeVertexNormals():this.normalizeNormals();function a(w){const y=new W,b=new W,v=new W;for(let z=0;z<s.length;z+=3)p(s[z+0],y),p(s[z+1],b),p(s[z+2],v),l(y,b,v,w)}function l(w,y,b,v){const z=v+1,x=[];for(let M=0;M<=z;M++){x[M]=[];const S=w.clone().lerp(b,M/z),T=y.clone().lerp(b,M/z),I=z-M;for(let E=0;E<=I;E++)E===0&&M===z?x[M][E]=S:x[M][E]=S.clone().lerp(T,E/I)}for(let M=0;M<z;M++)for(let S=0;S<2*(z-M)-1;S++){const T=Math.floor(S/2);S%2===0?(u(x[M][T+1]),u(x[M+1][T]),u(x[M][T])):(u(x[M][T+1]),u(x[M+1][T+1]),u(x[M+1][T]))}}function c(w){const y=new W;for(let b=0;b<r.length;b+=3)y.x=r[b+0],y.y=r[b+1],y.z=r[b+2],y.normalize().multiplyScalar(w),r[b+0]=y.x,r[b+1]=y.y,r[b+2]=y.z}function h(){const w=new W;for(let y=0;y<r.length;y+=3){w.x=r[y+0],w.y=r[y+1],w.z=r[y+2];const b=g(w)/2/Math.PI+.5,v=m(w)/Math.PI+.5;o.push(b,1-v)}f(),d()}function d(){for(let w=0;w<o.length;w+=6){const y=o[w+0],b=o[w+2],v=o[w+4],z=Math.max(y,b,v),x=Math.min(y,b,v);z>.9&&x<.1&&(y<.2&&(o[w+0]+=1),b<.2&&(o[w+2]+=1),v<.2&&(o[w+4]+=1))}}function u(w){r.push(w.x,w.y,w.z)}function p(w,y){const b=w*3;y.x=e[b+0],y.y=e[b+1],y.z=e[b+2]}function f(){const w=new W,y=new W,b=new W,v=new W,z=new tt,x=new tt,M=new tt;for(let S=0,T=0;S<r.length;S+=9,T+=6){w.set(r[S+0],r[S+1],r[S+2]),y.set(r[S+3],r[S+4],r[S+5]),b.set(r[S+6],r[S+7],r[S+8]),z.set(o[T+0],o[T+1]),x.set(o[T+2],o[T+3]),M.set(o[T+4],o[T+5]),v.copy(w).add(y).add(b).divideScalar(3);const I=g(v);_(z,T+0,w,I),_(x,T+2,y,I),_(M,T+4,b,I)}}function _(w,y,b,v){v<0&&w.x===1&&(o[y]=w.x-1),b.x===0&&b.z===0&&(o[y]=v/2/Math.PI+.5)}function g(w){return Math.atan2(w.z,-w.x)}function m(w){return Math.atan2(-w.y,Math.sqrt(w.x*w.x+w.z*w.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qg(e.vertices,e.indices,e.radius,e.detail)}}class e_ extends Qg{constructor(e=1,s=0){const i=(1+Math.sqrt(5))/2,n=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],r=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(n,r,e,s),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:s}}static fromJSON(e){return new e_(e.radius,e.detail)}}class Rd extends cs{constructor(e=1,s=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:s,widthSegments:i,heightSegments:n};const r=e/2,o=s/2,a=Math.floor(i),l=Math.floor(n),c=a+1,h=l+1,d=e/a,u=s/l,p=[],f=[],_=[],g=[];for(let m=0;m<h;m++){const w=m*u-o;for(let y=0;y<c;y++){const b=y*d-r;f.push(b,-w,0),_.push(0,0,1),g.push(y/a),g.push(1-m/l)}}for(let m=0;m<l;m++)for(let w=0;w<a;w++){const y=w+c*m,b=w+c*(m+1),v=w+1+c*(m+1),z=w+1+c*m;p.push(y,b,z),p.push(b,v,z)}this.setIndex(p),this.setAttribute("position",new Tt(f,3)),this.setAttribute("normal",new Tt(_,3)),this.setAttribute("uv",new Tt(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Rd(e.width,e.height,e.widthSegments,e.heightSegments)}}class kd extends cs{constructor(e=1,s=32,i=16,n=0,r=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:s,heightSegments:i,phiStart:n,phiLength:r,thetaStart:o,thetaLength:a},s=Math.max(3,Math.floor(s)),i=Math.max(2,Math.floor(i));const l=Math.min(o+a,Math.PI);let c=0;const h=[],d=new W,u=new W,p=[],f=[],_=[],g=[];for(let m=0;m<=i;m++){const w=[],y=m/i,b=o+y*a,v=e*Math.cos(b),z=Math.sqrt(e*e-v*v);let x=0;m===0&&o===0?x=.5/s:m===i&&l===Math.PI&&(x=-.5/s);for(let M=0;M<=s;M++){const S=M/s,T=n+S*r;d.x=-z*Math.cos(T),d.y=v,d.z=z*Math.sin(T),f.push(d.x,d.y,d.z),u.copy(d).normalize(),_.push(u.x,u.y,u.z),g.push(S+x,1-y),w.push(c++)}h.push(w)}for(let m=0;m<i;m++)for(let w=0;w<s;w++){const y=h[m][w+1],b=h[m][w],v=h[m+1][w],z=h[m+1][w+1];(m!==0||o>0)&&p.push(y,b,z),(m!==i-1||l<Math.PI)&&p.push(b,v,z)}this.setIndex(p),this.setAttribute("position",new Tt(f,3)),this.setAttribute("normal",new Tt(_,3)),this.setAttribute("uv",new Tt(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new kd(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function Ma(t){const e={};for(const s in t){e[s]={};for(const i in t[s]){const n=t[s][i];if(iM(n))n.isRenderTargetTexture?(Je("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[s][i]=null):e[s][i]=n.clone();else if(Array.isArray(n))if(iM(n[0])){const r=[];for(let o=0,a=n.length;o<a;o++)r[o]=n[o].clone();e[s][i]=r}else e[s][i]=n.slice();else e[s][i]=n}}return e}function qs(t){const e={};for(let s=0;s<t.length;s++){const i=Ma(t[s]);for(const n in i)e[n]=i[n]}return e}function iM(t){return t&&(t.isColor||t.isMatrix3||t.isMatrix4||t.isVector2||t.isVector3||t.isVector4||t.isTexture||t.isQuaternion)}function QG(t){const e=[];for(let s=0;s<t.length;s++)e.push(t[s].clone());return e}function NS(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:bt.workingColorSpace}const eP={clone:Ma,merge:qs};var tP=`void main() {
105
+ `);this.result.textContent=WB(i)||"(no output)"}}function Pa(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`empty pane template is missing ${e}`);return s}function WB(t){return t.replace(/\x1b\[[0-9;:]*[A-Za-z]/g,"")}class FB{routes=new Map([["console",new Map],["ambient",new Map]]);observers=new Map([["console",[]],["ambient",[]]]);claims=new Map;claimers=new Map;watchers=[];route_add(e,s,i){const n=this.routes.get(e);for(const r of s)n.set(r,[...n.get(r)??[],i])}observer_add(e,s){this.observers.get(e).push(i=>(s(i),!1))}route(e,s){const i=s.model?.kind;if(i===void 0)return!1;let n=!1;for(const r of this.routes.get(e).get(i)??[])n=r(s)||n;return n}observe(e,s){for(const i of this.observers.get(e))i(s)}claim_add(e,s,i){this.claims.set(e,s),i!==void 0&&this.claimers.set(s,i)}claimKind_find(e){return this.claims.get(e)}claimer_get(e){return this.claimers.get(e)}watcher_add(e){this.watchers.push(e)}watched(e,s){for(const i of this.watchers)i(e,s)}}function UB(t,e){t.route_add("console",[_k.view],i=>{const n=gk.safeParse(i.model?.data);return n.success&&e.image_open(n.data.path,n.data.force===!0),!0}),t.route_add("console",["feed.dag","feed.list",br.feedIndexing],i=>(e.dag_target().envelope_observe(i),!0)),t.observer_add("console",i=>e.pacs().envelope_observe(i)),t.route_add("ambient",["feed.dag"],i=>{const n=bg.safeParse(i.model?.data);if(!n.success)return!0;for(const r of e.dags())r.model_refresh(n.data);for(const r of e.universes())r.model_refresh(n.data);return!0}),t.route_add("ambient",["gather.cohort"],i=>(e.cohort_adopt(i),!0)),t.watcher_add((i,n)=>{for(const r of e.dags())r.watched_observe(i,n);for(const r of e.universes())r.watched_observe(i,n)});const s=(i,n)=>{const r=e.dag_get(e.pane_replace(i,"dag"));for(const o of n)r?.envelope_observe(o)};t.claim_add("feed.dag","dag",s),t.claim_add("feed.list","dag",s),t.claim_add("pacs.query","pacs",(i,n)=>{e.pacs_present();for(const r of n)e.pacs().envelope_observe(r)}),t.claim_add(Qo.series,"image",(i,n)=>{const r=e.image_get(e.pane_replace(i,"image"));for(const o of n){if(o.model?.kind!==Qo.series)continue;const a=hz.safeParse(o.model.data);a.success&&r?.series_show(a.data)}}),t.claim_add(Qo.tags,"tags",(i,n)=>{const r=e.tags_get(e.pane_replace(i,"tags"));for(const o of n){if(o.model?.kind!==Qo.tags)continue;const a=cz.safeParse(o.model.data);a.success&&r?.model_show(a.data)}})}const Bg="185",$B=0,E0=1,jB=2,mh=1,HB=2,fl=3,Cr=0,si=1,Nn=2,Wn=0,ao=1,Rr=2,A0=3,T0=4,VB=5,Jr=100,qB=101,KB=102,YB=103,XB=104,ZB=200,JB=201,QB=202,eG=203,op=204,ap=205,tG=206,sG=207,iG=208,nG=209,rG=210,oG=211,aG=212,lG=213,cG=214,lp=0,cp=1,hp=2,ga=3,dp=4,up=5,fp=6,pp=7,hS=0,hG=1,dG=2,mn=0,dS=1,uS=2,fS=3,pS=4,mS=5,gS=6,_S=7,bS=300,mo=301,_a=302,fu=303,pu=304,Td=306,mp=1e3,Bn=1001,gp=1002,Is=1003,uG=1004,mc=1005,Ls=1006,mu=1007,eo=1008,bi=1009,MS=1010,vS=1011,Gl=1012,Gg=1013,Mn=1014,Xi=1015,jn=1016,Pg=1017,Lg=1018,Pl=1020,wS=35902,yS=35899,zS=1021,SS=1022,Zi=1023,Hn=1026,to=1027,Wg=1028,Fg=1029,go=1030,Ug=1031,$g=1033,gh=33776,_h=33777,bh=33778,Mh=33779,_p=35840,bp=35841,Mp=35842,vp=35843,wp=36196,yp=37492,zp=37496,Sp=37488,xp=37489,qh=37490,Op=37491,Ep=37808,Ap=37809,Tp=37810,Ip=37811,Dp=37812,Cp=37813,Rp=37814,kp=37815,Np=37816,Bp=37817,Gp=37818,Pp=37819,Lp=37820,Wp=37821,Fp=36492,Up=36494,$p=36495,jp=36283,Hp=36284,Kh=36285,Vp=36286,fG=3200,qp=0,pG=1,ur="",Oi="srgb",Yh="srgb-linear",Xh="linear",Dt="srgb",To=7680,I0=519,mG=512,gG=513,_G=514,jg=515,bG=516,MG=517,Hg=518,vG=519,Kp=35044,D0="300 es",un=2e3,Ll=2001;function wG(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Zh(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function yG(){const t=Zh("canvas");return t.style.display="block",t}const C0={};function Jh(...t){const e="THREE."+t.shift();console.log(e,...t)}function xS(t){const e=t[0];if(typeof e=="string"&&e.startsWith("TSL:")){const s=t[1];s&&s.isStackTrace?t[0]+=" "+s.getLocation():t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}function Je(...t){t=xS(t);const e="THREE."+t.shift();{const s=t[0];s&&s.isStackTrace?console.warn(s.getError(e)):console.warn(e,...t)}}function _t(...t){t=xS(t);const e="THREE."+t.shift();{const s=t[0];s&&s.isStackTrace?console.error(s.getError(e)):console.error(e,...t)}}function ia(...t){const e=t.join(" ");e in C0||(C0[e]=!0,Je(...t))}function zG(t,e,s){return new Promise(function(i,n){function r(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:n();break;case t.TIMEOUT_EXPIRED:setTimeout(r,s);break;default:i()}}setTimeout(r,s)})}const SG={[lp]:cp,[hp]:fp,[dp]:pp,[ga]:up,[cp]:lp,[fp]:hp,[pp]:dp,[up]:ga};class Mo{addEventListener(e,s){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(s)===-1&&i[e].push(s)}hasEventListener(e,s){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(s)!==-1}removeEventListener(e,s){const i=this._listeners;if(i===void 0)return;const n=i[e];if(n!==void 0){const r=n.indexOf(s);r!==-1&&n.splice(r,1)}}dispatchEvent(e){const s=this._listeners;if(s===void 0)return;const i=s[e.type];if(i!==void 0){e.target=this;const n=i.slice(0);for(let r=0,o=n.length;r<o;r++)n[r].call(this,e);e.target=null}}}const ks=["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"],gu=Math.PI/180,Yp=180/Math.PI;function zr(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(ks[t&255]+ks[t>>8&255]+ks[t>>16&255]+ks[t>>24&255]+"-"+ks[e&255]+ks[e>>8&255]+"-"+ks[e>>16&15|64]+ks[e>>24&255]+"-"+ks[s&63|128]+ks[s>>8&255]+"-"+ks[s>>16&255]+ks[s>>24&255]+ks[i&255]+ks[i>>8&255]+ks[i>>16&255]+ks[i>>24&255]).toLowerCase()}function Mt(t,e,s){return Math.max(e,Math.min(s,t))}function xG(t,e){return(t%e+e)%e}function _u(t,e,s){return(1-s)*t+s*e}function dn(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function kt(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const O_=class O_{constructor(e=0,s=0){this.x=e,this.y=s}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,s){return this.x=e,this.y=s,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,s){switch(e){case 0:this.x=s;break;case 1:this.y=s;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: 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,s){return this.x=e.x+s.x,this.y=e.y+s.y,this}addScaledVector(e,s){return this.x+=e.x*s,this.y+=e.y*s,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,s){return this.x=e.x-s.x,this.y=e.y-s.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){const s=this.x,i=this.y,n=e.elements;return this.x=n[0]*s+n[3]*i+n[6],this.y=n[1]*s+n[4]*i+n[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,s){return this.x=Mt(this.x,e.x,s.x),this.y=Mt(this.y,e.y,s.y),this}clampScalar(e,s){return this.x=Mt(this.x,e,s),this.y=Mt(this.y,e,s),this}clampLength(e,s){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Mt(i,e,s))}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){const s=Math.sqrt(this.lengthSq()*e.lengthSq());if(s===0)return Math.PI/2;const i=this.dot(e)/s;return Math.acos(Mt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const s=this.x-e.x,i=this.y-e.y;return s*s+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,s){return this.x+=(e.x-this.x)*s,this.y+=(e.y-this.y)*s,this}lerpVectors(e,s,i){return this.x=e.x+(s.x-e.x)*i,this.y=e.y+(s.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,s=0){return this.x=e[s],this.y=e[s+1],this}toArray(e=[],s=0){return e[s]=this.x,e[s+1]=this.y,e}fromBufferAttribute(e,s){return this.x=e.getX(s),this.y=e.getY(s),this}rotateAround(e,s){const i=Math.cos(s),n=Math.sin(s),r=this.x-e.x,o=this.y-e.y;return this.x=r*i-o*n+e.x,this.y=r*n+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};O_.prototype.isVector2=!0;let tt=O_;class vo{constructor(e=0,s=0,i=0,n=1){this.isQuaternion=!0,this._x=e,this._y=s,this._z=i,this._w=n}static slerpFlat(e,s,i,n,r,o,a){let l=i[n+0],c=i[n+1],h=i[n+2],d=i[n+3],u=r[o+0],p=r[o+1],f=r[o+2],_=r[o+3];if(d!==_||l!==u||c!==p||h!==f){let g=l*u+c*p+h*f+d*_;g<0&&(u=-u,p=-p,f=-f,_=-_,g=-g);let m=1-a;if(g<.9995){const w=Math.acos(g),y=Math.sin(w);m=Math.sin(m*w)/y,a=Math.sin(a*w)/y,l=l*m+u*a,c=c*m+p*a,h=h*m+f*a,d=d*m+_*a}else{l=l*m+u*a,c=c*m+p*a,h=h*m+f*a,d=d*m+_*a;const w=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=w,c*=w,h*=w,d*=w}}e[s]=l,e[s+1]=c,e[s+2]=h,e[s+3]=d}static multiplyQuaternionsFlat(e,s,i,n,r,o){const a=i[n],l=i[n+1],c=i[n+2],h=i[n+3],d=r[o],u=r[o+1],p=r[o+2],f=r[o+3];return e[s]=a*f+h*d+l*p-c*u,e[s+1]=l*f+h*u+c*d-a*p,e[s+2]=c*f+h*p+a*u-l*d,e[s+3]=h*f-a*d-l*u-c*p,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,s,i,n){return this._x=e,this._y=s,this._z=i,this._w=n,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,s=!0){const i=e._x,n=e._y,r=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(i/2),h=a(n/2),d=a(r/2),u=l(i/2),p=l(n/2),f=l(r/2);switch(o){case"XYZ":this._x=u*h*d+c*p*f,this._y=c*p*d-u*h*f,this._z=c*h*f+u*p*d,this._w=c*h*d-u*p*f;break;case"YXZ":this._x=u*h*d+c*p*f,this._y=c*p*d-u*h*f,this._z=c*h*f-u*p*d,this._w=c*h*d+u*p*f;break;case"ZXY":this._x=u*h*d-c*p*f,this._y=c*p*d+u*h*f,this._z=c*h*f+u*p*d,this._w=c*h*d-u*p*f;break;case"ZYX":this._x=u*h*d-c*p*f,this._y=c*p*d+u*h*f,this._z=c*h*f-u*p*d,this._w=c*h*d+u*p*f;break;case"YZX":this._x=u*h*d+c*p*f,this._y=c*p*d+u*h*f,this._z=c*h*f-u*p*d,this._w=c*h*d-u*p*f;break;case"XZY":this._x=u*h*d-c*p*f,this._y=c*p*d-u*h*f,this._z=c*h*f+u*p*d,this._w=c*h*d+u*p*f;break;default:Je("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return s===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,s){const i=s/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const s=e.elements,i=s[0],n=s[4],r=s[8],o=s[1],a=s[5],l=s[9],c=s[2],h=s[6],d=s[10],u=i+a+d;if(u>0){const p=.5/Math.sqrt(u+1);this._w=.25/p,this._x=(h-l)*p,this._y=(r-c)*p,this._z=(o-n)*p}else if(i>a&&i>d){const p=2*Math.sqrt(1+i-a-d);this._w=(h-l)/p,this._x=.25*p,this._y=(n+o)/p,this._z=(r+c)/p}else if(a>d){const p=2*Math.sqrt(1+a-i-d);this._w=(r-c)/p,this._x=(n+o)/p,this._y=.25*p,this._z=(l+h)/p}else{const p=2*Math.sqrt(1+d-i-a);this._w=(o-n)/p,this._x=(r+c)/p,this._y=(l+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,s){let i=e.dot(s)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*s.z-e.z*s.y,this._y=e.z*s.x-e.x*s.z,this._z=e.x*s.y-e.y*s.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Mt(this.dot(e),-1,1)))}rotateTowards(e,s){const i=this.angleTo(e);if(i===0)return this;const n=Math.min(1,s/i);return this.slerp(e,n),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=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,s){const i=e._x,n=e._y,r=e._z,o=e._w,a=s._x,l=s._y,c=s._z,h=s._w;return this._x=i*h+o*a+n*c-r*l,this._y=n*h+o*l+r*a-i*c,this._z=r*h+o*c+i*l-n*a,this._w=o*h-i*a-n*l-r*c,this._onChangeCallback(),this}slerp(e,s){let i=e._x,n=e._y,r=e._z,o=e._w,a=this.dot(e);a<0&&(i=-i,n=-n,r=-r,o=-o,a=-a);let l=1-s;if(a<.9995){const c=Math.acos(a),h=Math.sin(c);l=Math.sin(l*c)/h,s=Math.sin(s*c)/h,this._x=this._x*l+i*s,this._y=this._y*l+n*s,this._z=this._z*l+r*s,this._w=this._w*l+o*s,this._onChangeCallback()}else this._x=this._x*l+i*s,this._y=this._y*l+n*s,this._z=this._z*l+r*s,this._w=this._w*l+o*s,this.normalize();return this}slerpQuaternions(e,s,i){return this.copy(e).slerp(s,i)}random(){const e=2*Math.PI*Math.random(),s=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(n*Math.sin(e),n*Math.cos(e),r*Math.sin(s),r*Math.cos(s))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,s=0){return this._x=e[s],this._y=e[s+1],this._z=e[s+2],this._w=e[s+3],this._onChangeCallback(),this}toArray(e=[],s=0){return e[s]=this._x,e[s+1]=this._y,e[s+2]=this._z,e[s+3]=this._w,e}fromBufferAttribute(e,s){return this._x=e.getX(s),this._y=e.getY(s),this._z=e.getZ(s),this._w=e.getW(s),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}}const E_=class E_{constructor(e=0,s=0,i=0){this.x=e,this.y=s,this.z=i}set(e,s,i){return i===void 0&&(i=this.z),this.x=e,this.y=s,this.z=i,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,s){switch(e){case 0:this.x=s;break;case 1:this.y=s;break;case 2:this.z=s;break;default:throw new Error("THREE.Vector3: 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 new Error("THREE.Vector3: 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,s){return this.x=e.x+s.x,this.y=e.y+s.y,this.z=e.z+s.z,this}addScaledVector(e,s){return this.x+=e.x*s,this.y+=e.y*s,this.z+=e.z*s,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,s){return this.x=e.x-s.x,this.y=e.y-s.y,this.z=e.z-s.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,s){return this.x=e.x*s.x,this.y=e.y*s.y,this.z=e.z*s.z,this}applyEuler(e){return this.applyQuaternion(R0.setFromEuler(e))}applyAxisAngle(e,s){return this.applyQuaternion(R0.setFromAxisAngle(e,s))}applyMatrix3(e){const s=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*s+r[3]*i+r[6]*n,this.y=r[1]*s+r[4]*i+r[7]*n,this.z=r[2]*s+r[5]*i+r[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const s=this.x,i=this.y,n=this.z,r=e.elements,o=1/(r[3]*s+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*s+r[4]*i+r[8]*n+r[12])*o,this.y=(r[1]*s+r[5]*i+r[9]*n+r[13])*o,this.z=(r[2]*s+r[6]*i+r[10]*n+r[14])*o,this}applyQuaternion(e){const s=this.x,i=this.y,n=this.z,r=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*n-a*i),h=2*(a*s-r*n),d=2*(r*i-o*s);return this.x=s+l*c+o*d-a*h,this.y=i+l*h+a*c-r*d,this.z=n+l*d+r*h-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const s=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*s+r[4]*i+r[8]*n,this.y=r[1]*s+r[5]*i+r[9]*n,this.z=r[2]*s+r[6]*i+r[10]*n,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,s){return this.x=Mt(this.x,e.x,s.x),this.y=Mt(this.y,e.y,s.y),this.z=Mt(this.z,e.z,s.z),this}clampScalar(e,s){return this.x=Mt(this.x,e,s),this.y=Mt(this.y,e,s),this.z=Mt(this.z,e,s),this}clampLength(e,s){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Mt(i,e,s))}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,s){return this.x+=(e.x-this.x)*s,this.y+=(e.y-this.y)*s,this.z+=(e.z-this.z)*s,this}lerpVectors(e,s,i){return this.x=e.x+(s.x-e.x)*i,this.y=e.y+(s.y-e.y)*i,this.z=e.z+(s.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,s){const i=e.x,n=e.y,r=e.z,o=s.x,a=s.y,l=s.z;return this.x=n*l-r*a,this.y=r*o-i*l,this.z=i*a-n*o,this}projectOnVector(e){const s=e.lengthSq();if(s===0)return this.set(0,0,0);const i=e.dot(this)/s;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return bu.copy(this).projectOnVector(e),this.sub(bu)}reflect(e){return this.sub(bu.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const s=Math.sqrt(this.lengthSq()*e.lengthSq());if(s===0)return Math.PI/2;const i=this.dot(e)/s;return Math.acos(Mt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const s=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return s*s+i*i+n*n}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,s,i){const n=Math.sin(s)*e;return this.x=n*Math.sin(i),this.y=Math.cos(s)*e,this.z=n*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,s,i){return this.x=e*Math.sin(s),this.y=i,this.z=e*Math.cos(s),this}setFromMatrixPosition(e){const s=e.elements;return this.x=s[12],this.y=s[13],this.z=s[14],this}setFromMatrixScale(e){const s=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=s,this.y=i,this.z=n,this}setFromMatrixColumn(e,s){return this.fromArray(e.elements,s*4)}setFromMatrix3Column(e,s){return this.fromArray(e.elements,s*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,s=0){return this.x=e[s],this.y=e[s+1],this.z=e[s+2],this}toArray(e=[],s=0){return e[s]=this.x,e[s+1]=this.y,e[s+2]=this.z,e}fromBufferAttribute(e,s){return this.x=e.getX(s),this.y=e.getY(s),this.z=e.getZ(s),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,s=Math.random()*2-1,i=Math.sqrt(1-s*s);return this.x=i*Math.cos(e),this.y=s,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};E_.prototype.isVector3=!0;let W=E_;const bu=new W,R0=new vo,A_=class A_{constructor(e,s,i,n,r,o,a,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,s,i,n,r,o,a,l,c)}set(e,s,i,n,r,o,a,l,c){const h=this.elements;return h[0]=e,h[1]=n,h[2]=a,h[3]=s,h[4]=r,h[5]=l,h[6]=i,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const s=this.elements,i=e.elements;return s[0]=i[0],s[1]=i[1],s[2]=i[2],s[3]=i[3],s[4]=i[4],s[5]=i[5],s[6]=i[6],s[7]=i[7],s[8]=i[8],this}extractBasis(e,s,i){return e.setFromMatrix3Column(this,0),s.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const s=e.elements;return this.set(s[0],s[4],s[8],s[1],s[5],s[9],s[2],s[6],s[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,s){const i=e.elements,n=s.elements,r=this.elements,o=i[0],a=i[3],l=i[6],c=i[1],h=i[4],d=i[7],u=i[2],p=i[5],f=i[8],_=n[0],g=n[3],m=n[6],w=n[1],y=n[4],b=n[7],v=n[2],z=n[5],x=n[8];return r[0]=o*_+a*w+l*v,r[3]=o*g+a*y+l*z,r[6]=o*m+a*b+l*x,r[1]=c*_+h*w+d*v,r[4]=c*g+h*y+d*z,r[7]=c*m+h*b+d*x,r[2]=u*_+p*w+f*v,r[5]=u*g+p*y+f*z,r[8]=u*m+p*b+f*x,this}multiplyScalar(e){const s=this.elements;return s[0]*=e,s[3]*=e,s[6]*=e,s[1]*=e,s[4]*=e,s[7]*=e,s[2]*=e,s[5]*=e,s[8]*=e,this}determinant(){const e=this.elements,s=e[0],i=e[1],n=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8];return s*o*h-s*a*c-i*r*h+i*a*l+n*r*c-n*o*l}invert(){const e=this.elements,s=e[0],i=e[1],n=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],d=h*o-a*c,u=a*l-h*r,p=c*r-o*l,f=s*d+i*u+n*p;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/f;return e[0]=d*_,e[1]=(n*c-h*i)*_,e[2]=(a*i-n*o)*_,e[3]=u*_,e[4]=(h*s-n*l)*_,e[5]=(n*r-a*s)*_,e[6]=p*_,e[7]=(i*l-c*s)*_,e[8]=(o*s-i*r)*_,this}transpose(){let e;const s=this.elements;return e=s[1],s[1]=s[3],s[3]=e,e=s[2],s[2]=s[6],s[6]=e,e=s[5],s[5]=s[7],s[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const s=this.elements;return e[0]=s[0],e[1]=s[3],e[2]=s[6],e[3]=s[1],e[4]=s[4],e[5]=s[7],e[6]=s[2],e[7]=s[5],e[8]=s[8],this}setUvTransform(e,s,i,n,r,o,a){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*o+c*a)+o+e,-n*c,n*l,-n*(-c*o+l*a)+a+s,0,0,1),this}scale(e,s){return ia("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Mu.makeScale(e,s)),this}rotate(e){return ia("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Mu.makeRotation(-e)),this}translate(e,s){return ia("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Mu.makeTranslation(e,s)),this}makeTranslation(e,s){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,s,0,0,1),this}makeRotation(e){const s=Math.cos(e),i=Math.sin(e);return this.set(s,-i,0,i,s,0,0,0,1),this}makeScale(e,s){return this.set(e,0,0,0,s,0,0,0,1),this}equals(e){const s=this.elements,i=e.elements;for(let n=0;n<9;n++)if(s[n]!==i[n])return!1;return!0}fromArray(e,s=0){for(let i=0;i<9;i++)this.elements[i]=e[i+s];return this}toArray(e=[],s=0){const i=this.elements;return e[s]=i[0],e[s+1]=i[1],e[s+2]=i[2],e[s+3]=i[3],e[s+4]=i[4],e[s+5]=i[5],e[s+6]=i[6],e[s+7]=i[7],e[s+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};A_.prototype.isMatrix3=!0;let rt=A_;const Mu=new rt,k0=new rt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),N0=new rt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function OG(){const t={enabled:!0,workingColorSpace:Yh,spaces:{},convert:function(n,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===Dt&&(n.r=Fn(n.r),n.g=Fn(n.g),n.b=Fn(n.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(n.applyMatrix3(this.spaces[r].toXYZ),n.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Dt&&(n.r=na(n.r),n.g=na(n.g),n.b=na(n.b))),n},workingToColorSpace:function(n,r){return this.convert(n,this.workingColorSpace,r)},colorSpaceToWorking:function(n,r){return this.convert(n,r,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===ur?Xh:this.spaces[n].transfer},getToneMappingMode:function(n){return this.spaces[n].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(n,r=this.workingColorSpace){return n.fromArray(this.spaces[r].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,r,o){return n.copy(this.spaces[r].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(n,r){return ia("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(n,r)},toWorkingColorSpace:function(n,r){return ia("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(n,r)}},e=[.64,.33,.3,.6,.15,.06],s=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[Yh]:{primaries:e,whitePoint:i,transfer:Xh,toXYZ:k0,fromXYZ:N0,luminanceCoefficients:s,workingColorSpaceConfig:{unpackColorSpace:Oi},outputColorSpaceConfig:{drawingBufferColorSpace:Oi}},[Oi]:{primaries:e,whitePoint:i,transfer:Dt,toXYZ:k0,fromXYZ:N0,luminanceCoefficients:s,outputColorSpaceConfig:{drawingBufferColorSpace:Oi}}}),t}const bt=OG();function Fn(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function na(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Io;class EG{static getDataURL(e,s="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Io===void 0&&(Io=Zh("canvas")),Io.width=e.width,Io.height=e.height;const n=Io.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),i=Io}return i.toDataURL(s)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const s=Zh("canvas");s.width=e.width,s.height=e.height;const i=s.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const n=i.getImageData(0,0,e.width,e.height),r=n.data;for(let o=0;o<r.length;o++)r[o]=Fn(r[o]/255)*255;return i.putImageData(n,0,0),s}else if(e.data){const s=e.data.slice(0);for(let i=0;i<s.length;i++)s instanceof Uint8Array||s instanceof Uint8ClampedArray?s[i]=Math.floor(Fn(s[i]/255)*255):s[i]=Fn(s[i]);return{data:s,width:e.width,height:e.height}}else return Je("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let AG=0;class Vg{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:AG++}),this.uuid=zr(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const s=this.data;return typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement?e.set(s.videoWidth,s.videoHeight,0):typeof VideoFrame<"u"&&s instanceof VideoFrame?e.set(s.displayWidth,s.displayHeight,0):s!==null?e.set(s.width,s.height,s.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const s=e===void 0||typeof e=="string";if(!s&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(n!==null){let r;if(Array.isArray(n)){r=[];for(let o=0,a=n.length;o<a;o++)n[o].isDataTexture?r.push(vu(n[o].image)):r.push(vu(n[o]))}else r=vu(n);i.url=r}return s||(e.images[this.uuid]=i),i}}function vu(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?EG.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Je("Texture: Unable to serialize Texture."),{})}let TG=0;const wu=new W;class Ws extends Mo{constructor(e=Ws.DEFAULT_IMAGE,s=Ws.DEFAULT_MAPPING,i=Bn,n=Bn,r=Ls,o=eo,a=Zi,l=bi,c=Ws.DEFAULT_ANISOTROPY,h=ur){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:TG++}),this.uuid=zr(),this.name="",this.source=new Vg(e),this.mipmaps=[],this.mapping=s,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new tt(0,0),this.repeat=new tt(1,1),this.center=new tt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new rt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(wu).x}get height(){return this.source.getSize(wu).y}get depth(){return this.source.getSize(wu).z}get image(){return this.source.data}set image(e){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,s){this.updateRanges.push({start:e,count:s})}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.normalized=e.normalized,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(const s in e){const i=e[s];if(i===void 0){Je(`Texture.setValues(): parameter '${s}' has value of undefined.`);continue}const n=this[s];if(n===void 0){Je(`Texture.setValues(): property '${s}' does not exist.`);continue}n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[s]=i}}toJSON(e){const s=e===void 0||typeof e=="string";if(!s&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={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,normalized:this.normalized,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&&(i.userData=this.userData),s||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==bS)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case mp:e.x=e.x-Math.floor(e.x);break;case Bn:e.x=e.x<0?0:1;break;case gp:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case mp:e.y=e.y-Math.floor(e.y);break;case Bn:e.y=e.y<0?0:1;break;case gp:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-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++}}Ws.DEFAULT_IMAGE=null;Ws.DEFAULT_MAPPING=bS;Ws.DEFAULT_ANISOTROPY=1;const T_=class T_{constructor(e=0,s=0,i=0,n=1){this.x=e,this.y=s,this.z=i,this.w=n}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,s,i,n){return this.x=e,this.y=s,this.z=i,this.w=n,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,s){switch(e){case 0:this.x=s;break;case 1:this.y=s;break;case 2:this.z=s;break;case 3:this.w=s;break;default:throw new Error("THREE.Vector4: 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 new Error("THREE.Vector4: 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?e.w:1,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,s){return this.x=e.x+s.x,this.y=e.y+s.y,this.z=e.z+s.z,this.w=e.w+s.w,this}addScaledVector(e,s){return this.x+=e.x*s,this.y+=e.y*s,this.z+=e.z*s,this.w+=e.w*s,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,s){return this.x=e.x-s.x,this.y=e.y-s.y,this.z=e.z-s.z,this.w=e.w-s.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){const s=this.x,i=this.y,n=this.z,r=this.w,o=e.elements;return this.x=o[0]*s+o[4]*i+o[8]*n+o[12]*r,this.y=o[1]*s+o[5]*i+o[9]*n+o[13]*r,this.z=o[2]*s+o[6]*i+o[10]*n+o[14]*r,this.w=o[3]*s+o[7]*i+o[11]*n+o[15]*r,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);const s=Math.sqrt(1-e.w*e.w);return s<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/s,this.y=e.y/s,this.z=e.z/s),this}setAxisAngleFromRotationMatrix(e){let s,i,n,r;const l=e.elements,c=l[0],h=l[4],d=l[8],u=l[1],p=l[5],f=l[9],_=l[2],g=l[6],m=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-_)<.01&&Math.abs(f-g)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+_)<.1&&Math.abs(f+g)<.1&&Math.abs(c+p+m-3)<.1)return this.set(1,0,0,0),this;s=Math.PI;const y=(c+1)/2,b=(p+1)/2,v=(m+1)/2,z=(h+u)/4,x=(d+_)/4,M=(f+g)/4;return y>b&&y>v?y<.01?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(y),n=z/i,r=x/i):b>v?b<.01?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(b),i=z/n,r=M/n):v<.01?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(v),i=x/r,n=M/r),this.set(i,n,r,s),this}let w=Math.sqrt((g-f)*(g-f)+(d-_)*(d-_)+(u-h)*(u-h));return Math.abs(w)<.001&&(w=1),this.x=(g-f)/w,this.y=(d-_)/w,this.z=(u-h)/w,this.w=Math.acos((c+p+m-1)/2),this}setFromMatrixPosition(e){const s=e.elements;return this.x=s[12],this.y=s[13],this.z=s[14],this.w=s[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,s){return this.x=Mt(this.x,e.x,s.x),this.y=Mt(this.y,e.y,s.y),this.z=Mt(this.z,e.z,s.z),this.w=Mt(this.w,e.w,s.w),this}clampScalar(e,s){return this.x=Mt(this.x,e,s),this.y=Mt(this.y,e,s),this.z=Mt(this.z,e,s),this.w=Mt(this.w,e,s),this}clampLength(e,s){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Mt(i,e,s))}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,s){return this.x+=(e.x-this.x)*s,this.y+=(e.y-this.y)*s,this.z+=(e.z-this.z)*s,this.w+=(e.w-this.w)*s,this}lerpVectors(e,s,i){return this.x=e.x+(s.x-e.x)*i,this.y=e.y+(s.y-e.y)*i,this.z=e.z+(s.z-e.z)*i,this.w=e.w+(s.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,s=0){return this.x=e[s],this.y=e[s+1],this.z=e[s+2],this.w=e[s+3],this}toArray(e=[],s=0){return e[s]=this.x,e[s+1]=this.y,e[s+2]=this.z,e[s+3]=this.w,e}fromBufferAttribute(e,s){return this.x=e.getX(s),this.y=e.getY(s),this.z=e.getZ(s),this.w=e.getW(s),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}};T_.prototype.isVector4=!0;let Yt=T_;class IG extends Mo{constructor(e=1,s=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ls,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=s,this.depth=i.depth,this.scissor=new Yt(0,0,e,s),this.scissorTest=!1,this.viewport=new Yt(0,0,e,s),this.textures=[];const n={width:e,height:s,depth:i.depth},r=new Ws(n),o=i.count;for(let a=0;a<o;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview,this.useArrayDepthTexture=i.useArrayDepthTexture}_setTextureOptions(e={}){const s={minFilter:Ls,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(s.mapping=e.mapping),e.wrapS!==void 0&&(s.wrapS=e.wrapS),e.wrapT!==void 0&&(s.wrapT=e.wrapT),e.wrapR!==void 0&&(s.wrapR=e.wrapR),e.magFilter!==void 0&&(s.magFilter=e.magFilter),e.minFilter!==void 0&&(s.minFilter=e.minFilter),e.format!==void 0&&(s.format=e.format),e.type!==void 0&&(s.type=e.type),e.anisotropy!==void 0&&(s.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(s.colorSpace=e.colorSpace),e.flipY!==void 0&&(s.flipY=e.flipY),e.generateMipmaps!==void 0&&(s.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(s.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(s)}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,s,i=1){if(this.width!==e||this.height!==s||this.depth!==i){this.width=e,this.height=s,this.depth=i;for(let n=0,r=this.textures.length;n<r;n++)this.textures[n].image.width=e,this.textures[n].image.height=s,this.textures[n].image.depth=i,this.textures[n].isData3DTexture!==!0&&(this.textures[n].isArrayTexture=this.textures[n].image.depth>1);this.dispose()}this.viewport.set(0,0,e,s),this.scissor.set(0,0,e,s)}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 s=0,i=e.textures.length;s<i;s++){this.textures[s]=e.textures[s].clone(),this.textures[s].isRenderTargetTexture=!0,this.textures[s].renderTarget=this;const n=Object.assign({},e.textures[s].image);this.textures[s].source=new Vg(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.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class gn extends IG{constructor(e=1,s=1,i={}){super(e,s,i),this.isWebGLRenderTarget=!0}}class OS extends Ws{constructor(e=null,s=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:s,height:i,depth:n},this.magFilter=Is,this.minFilter=Is,this.wrapR=Bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class DG extends Ws{constructor(e=null,s=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:s,height:i,depth:n},this.magFilter=Is,this.minFilter=Is,this.wrapR=Bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const _d=class _d{constructor(e,s,i,n,r,o,a,l,c,h,d,u,p,f,_,g){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,s,i,n,r,o,a,l,c,h,d,u,p,f,_,g)}set(e,s,i,n,r,o,a,l,c,h,d,u,p,f,_,g){const m=this.elements;return m[0]=e,m[4]=s,m[8]=i,m[12]=n,m[1]=r,m[5]=o,m[9]=a,m[13]=l,m[2]=c,m[6]=h,m[10]=d,m[14]=u,m[3]=p,m[7]=f,m[11]=_,m[15]=g,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 _d().fromArray(this.elements)}copy(e){const s=this.elements,i=e.elements;return s[0]=i[0],s[1]=i[1],s[2]=i[2],s[3]=i[3],s[4]=i[4],s[5]=i[5],s[6]=i[6],s[7]=i[7],s[8]=i[8],s[9]=i[9],s[10]=i[10],s[11]=i[11],s[12]=i[12],s[13]=i[13],s[14]=i[14],s[15]=i[15],this}copyPosition(e){const s=this.elements,i=e.elements;return s[12]=i[12],s[13]=i[13],s[14]=i[14],this}setFromMatrix3(e){const s=e.elements;return this.set(s[0],s[3],s[6],0,s[1],s[4],s[7],0,s[2],s[5],s[8],0,0,0,0,1),this}extractBasis(e,s,i){return this.determinantAffine()===0?(e.set(1,0,0),s.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),s.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,s,i){return this.set(e.x,s.x,i.x,0,e.y,s.y,i.y,0,e.z,s.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const s=this.elements,i=e.elements,n=1/Do.setFromMatrixColumn(e,0).length(),r=1/Do.setFromMatrixColumn(e,1).length(),o=1/Do.setFromMatrixColumn(e,2).length();return s[0]=i[0]*n,s[1]=i[1]*n,s[2]=i[2]*n,s[3]=0,s[4]=i[4]*r,s[5]=i[5]*r,s[6]=i[6]*r,s[7]=0,s[8]=i[8]*o,s[9]=i[9]*o,s[10]=i[10]*o,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,this}makeRotationFromEuler(e){const s=this.elements,i=e.x,n=e.y,r=e.z,o=Math.cos(i),a=Math.sin(i),l=Math.cos(n),c=Math.sin(n),h=Math.cos(r),d=Math.sin(r);if(e.order==="XYZ"){const u=o*h,p=o*d,f=a*h,_=a*d;s[0]=l*h,s[4]=-l*d,s[8]=c,s[1]=p+f*c,s[5]=u-_*c,s[9]=-a*l,s[2]=_-u*c,s[6]=f+p*c,s[10]=o*l}else if(e.order==="YXZ"){const u=l*h,p=l*d,f=c*h,_=c*d;s[0]=u+_*a,s[4]=f*a-p,s[8]=o*c,s[1]=o*d,s[5]=o*h,s[9]=-a,s[2]=p*a-f,s[6]=_+u*a,s[10]=o*l}else if(e.order==="ZXY"){const u=l*h,p=l*d,f=c*h,_=c*d;s[0]=u-_*a,s[4]=-o*d,s[8]=f+p*a,s[1]=p+f*a,s[5]=o*h,s[9]=_-u*a,s[2]=-o*c,s[6]=a,s[10]=o*l}else if(e.order==="ZYX"){const u=o*h,p=o*d,f=a*h,_=a*d;s[0]=l*h,s[4]=f*c-p,s[8]=u*c+_,s[1]=l*d,s[5]=_*c+u,s[9]=p*c-f,s[2]=-c,s[6]=a*l,s[10]=o*l}else if(e.order==="YZX"){const u=o*l,p=o*c,f=a*l,_=a*c;s[0]=l*h,s[4]=_-u*d,s[8]=f*d+p,s[1]=d,s[5]=o*h,s[9]=-a*h,s[2]=-c*h,s[6]=p*d+f,s[10]=u-_*d}else if(e.order==="XZY"){const u=o*l,p=o*c,f=a*l,_=a*c;s[0]=l*h,s[4]=-d,s[8]=c*h,s[1]=u*d+_,s[5]=o*h,s[9]=p*d-f,s[2]=f*d-p,s[6]=a*h,s[10]=_*d+u}return s[3]=0,s[7]=0,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,this}makeRotationFromQuaternion(e){return this.compose(CG,e,RG)}lookAt(e,s,i){const n=this.elements;return ci.subVectors(e,s),ci.lengthSq()===0&&(ci.z=1),ci.normalize(),Xn.crossVectors(i,ci),Xn.lengthSq()===0&&(Math.abs(i.z)===1?ci.x+=1e-4:ci.z+=1e-4,ci.normalize(),Xn.crossVectors(i,ci)),Xn.normalize(),gc.crossVectors(ci,Xn),n[0]=Xn.x,n[4]=gc.x,n[8]=ci.x,n[1]=Xn.y,n[5]=gc.y,n[9]=ci.y,n[2]=Xn.z,n[6]=gc.z,n[10]=ci.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,s){const i=e.elements,n=s.elements,r=this.elements,o=i[0],a=i[4],l=i[8],c=i[12],h=i[1],d=i[5],u=i[9],p=i[13],f=i[2],_=i[6],g=i[10],m=i[14],w=i[3],y=i[7],b=i[11],v=i[15],z=n[0],x=n[4],M=n[8],S=n[12],T=n[1],I=n[5],E=n[9],O=n[13],R=n[2],C=n[6],k=n[10],B=n[14],L=n[3],F=n[7],ee=n[11],X=n[15];return r[0]=o*z+a*T+l*R+c*L,r[4]=o*x+a*I+l*C+c*F,r[8]=o*M+a*E+l*k+c*ee,r[12]=o*S+a*O+l*B+c*X,r[1]=h*z+d*T+u*R+p*L,r[5]=h*x+d*I+u*C+p*F,r[9]=h*M+d*E+u*k+p*ee,r[13]=h*S+d*O+u*B+p*X,r[2]=f*z+_*T+g*R+m*L,r[6]=f*x+_*I+g*C+m*F,r[10]=f*M+_*E+g*k+m*ee,r[14]=f*S+_*O+g*B+m*X,r[3]=w*z+y*T+b*R+v*L,r[7]=w*x+y*I+b*C+v*F,r[11]=w*M+y*E+b*k+v*ee,r[15]=w*S+y*O+b*B+v*X,this}multiplyScalar(e){const s=this.elements;return s[0]*=e,s[4]*=e,s[8]*=e,s[12]*=e,s[1]*=e,s[5]*=e,s[9]*=e,s[13]*=e,s[2]*=e,s[6]*=e,s[10]*=e,s[14]*=e,s[3]*=e,s[7]*=e,s[11]*=e,s[15]*=e,this}determinant(){const e=this.elements,s=e[0],i=e[4],n=e[8],r=e[12],o=e[1],a=e[5],l=e[9],c=e[13],h=e[2],d=e[6],u=e[10],p=e[14],f=e[3],_=e[7],g=e[11],m=e[15],w=l*p-c*u,y=a*p-c*d,b=a*u-l*d,v=o*p-c*h,z=o*u-l*h,x=o*d-a*h;return s*(_*w-g*y+m*b)-i*(f*w-g*v+m*z)+n*(f*y-_*v+m*x)-r*(f*b-_*z+g*x)}determinantAffine(){const e=this.elements,s=e[0],i=e[4],n=e[8],r=e[1],o=e[5],a=e[9],l=e[2],c=e[6],h=e[10];return s*(o*h-a*c)-i*(r*h-a*l)+n*(r*c-o*l)}transpose(){const e=this.elements;let s;return s=e[1],e[1]=e[4],e[4]=s,s=e[2],e[2]=e[8],e[8]=s,s=e[6],e[6]=e[9],e[9]=s,s=e[3],e[3]=e[12],e[12]=s,s=e[7],e[7]=e[13],e[13]=s,s=e[11],e[11]=e[14],e[14]=s,this}setPosition(e,s,i){const n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=s,n[14]=i),this}invert(){const e=this.elements,s=e[0],i=e[1],n=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],d=e[9],u=e[10],p=e[11],f=e[12],_=e[13],g=e[14],m=e[15],w=s*a-i*o,y=s*l-n*o,b=s*c-r*o,v=i*l-n*a,z=i*c-r*a,x=n*c-r*l,M=h*_-d*f,S=h*g-u*f,T=h*m-p*f,I=d*g-u*_,E=d*m-p*_,O=u*m-p*g,R=w*O-y*E+b*I+v*T-z*S+x*M;if(R===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/R;return e[0]=(a*O-l*E+c*I)*C,e[1]=(n*E-i*O-r*I)*C,e[2]=(_*x-g*z+m*v)*C,e[3]=(u*z-d*x-p*v)*C,e[4]=(l*T-o*O-c*S)*C,e[5]=(s*O-n*T+r*S)*C,e[6]=(g*b-f*x-m*y)*C,e[7]=(h*x-u*b+p*y)*C,e[8]=(o*E-a*T+c*M)*C,e[9]=(i*T-s*E-r*M)*C,e[10]=(f*z-_*b+m*w)*C,e[11]=(d*b-h*z-p*w)*C,e[12]=(a*S-o*I-l*M)*C,e[13]=(s*I-i*S+n*M)*C,e[14]=(_*y-f*v-g*w)*C,e[15]=(h*v-d*y+u*w)*C,this}scale(e){const s=this.elements,i=e.x,n=e.y,r=e.z;return s[0]*=i,s[4]*=n,s[8]*=r,s[1]*=i,s[5]*=n,s[9]*=r,s[2]*=i,s[6]*=n,s[10]*=r,s[3]*=i,s[7]*=n,s[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,s=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(s,i,n))}makeTranslation(e,s,i){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,s,0,0,1,i,0,0,0,1),this}makeRotationX(e){const s=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,s,-i,0,0,i,s,0,0,0,0,1),this}makeRotationY(e){const s=Math.cos(e),i=Math.sin(e);return this.set(s,0,i,0,0,1,0,0,-i,0,s,0,0,0,0,1),this}makeRotationZ(e){const s=Math.cos(e),i=Math.sin(e);return this.set(s,-i,0,0,i,s,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,s){const i=Math.cos(s),n=Math.sin(s),r=1-i,o=e.x,a=e.y,l=e.z,c=r*o,h=r*a;return this.set(c*o+i,c*a-n*l,c*l+n*a,0,c*a+n*l,h*a+i,h*l-n*o,0,c*l-n*a,h*l+n*o,r*l*l+i,0,0,0,0,1),this}makeScale(e,s,i){return this.set(e,0,0,0,0,s,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,s,i,n,r,o){return this.set(1,i,r,0,e,1,o,0,s,n,1,0,0,0,0,1),this}compose(e,s,i){const n=this.elements,r=s._x,o=s._y,a=s._z,l=s._w,c=r+r,h=o+o,d=a+a,u=r*c,p=r*h,f=r*d,_=o*h,g=o*d,m=a*d,w=l*c,y=l*h,b=l*d,v=i.x,z=i.y,x=i.z;return n[0]=(1-(_+m))*v,n[1]=(p+b)*v,n[2]=(f-y)*v,n[3]=0,n[4]=(p-b)*z,n[5]=(1-(u+m))*z,n[6]=(g+w)*z,n[7]=0,n[8]=(f+y)*x,n[9]=(g-w)*x,n[10]=(1-(u+_))*x,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,s,i){const n=this.elements;e.x=n[12],e.y=n[13],e.z=n[14];const r=this.determinantAffine();if(r===0)return i.set(1,1,1),s.identity(),this;let o=Do.set(n[0],n[1],n[2]).length();const a=Do.set(n[4],n[5],n[6]).length(),l=Do.set(n[8],n[9],n[10]).length();r<0&&(o=-o),Fi.copy(this);const c=1/o,h=1/a,d=1/l;return Fi.elements[0]*=c,Fi.elements[1]*=c,Fi.elements[2]*=c,Fi.elements[4]*=h,Fi.elements[5]*=h,Fi.elements[6]*=h,Fi.elements[8]*=d,Fi.elements[9]*=d,Fi.elements[10]*=d,s.setFromRotationMatrix(Fi),i.x=o,i.y=a,i.z=l,this}makePerspective(e,s,i,n,r,o,a=un,l=!1){const c=this.elements,h=2*r/(s-e),d=2*r/(i-n),u=(s+e)/(s-e),p=(i+n)/(i-n);let f,_;if(l)f=r/(o-r),_=o*r/(o-r);else if(a===un)f=-(o+r)/(o-r),_=-2*o*r/(o-r);else if(a===Ll)f=-o/(o-r),_=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=d,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=_,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,s,i,n,r,o,a=un,l=!1){const c=this.elements,h=2/(s-e),d=2/(i-n),u=-(s+e)/(s-e),p=-(i+n)/(i-n);let f,_;if(l)f=1/(o-r),_=o/(o-r);else if(a===un)f=-2/(o-r),_=-(o+r)/(o-r);else if(a===Ll)f=-1/(o-r),_=-r/(o-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=0,c[12]=u,c[1]=0,c[5]=d,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=f,c[14]=_,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const s=this.elements,i=e.elements;for(let n=0;n<16;n++)if(s[n]!==i[n])return!1;return!0}fromArray(e,s=0){for(let i=0;i<16;i++)this.elements[i]=e[i+s];return this}toArray(e=[],s=0){const i=this.elements;return e[s]=i[0],e[s+1]=i[1],e[s+2]=i[2],e[s+3]=i[3],e[s+4]=i[4],e[s+5]=i[5],e[s+6]=i[6],e[s+7]=i[7],e[s+8]=i[8],e[s+9]=i[9],e[s+10]=i[10],e[s+11]=i[11],e[s+12]=i[12],e[s+13]=i[13],e[s+14]=i[14],e[s+15]=i[15],e}};_d.prototype.isMatrix4=!0;let Ot=_d;const Do=new W,Fi=new Ot,CG=new W(0,0,0),RG=new W(1,1,1),Xn=new W,gc=new W,ci=new W,B0=new Ot,G0=new vo;class kr{constructor(e=0,s=0,i=0,n=kr.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=s,this._z=i,this._order=n}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,s,i,n=this._order){return this._x=e,this._y=s,this._z=i,this._order=n,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,s=this._order,i=!0){const n=e.elements,r=n[0],o=n[4],a=n[8],l=n[1],c=n[5],h=n[9],d=n[2],u=n[6],p=n[10];switch(s){case"XYZ":this._y=Math.asin(Mt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Mt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(Mt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-Mt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Mt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-Mt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,p),this._y=0);break;default:Je("Euler: .setFromRotationMatrix() encountered an unknown order: "+s)}return this._order=s,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,s,i){return B0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(B0,s,i)}setFromVector3(e,s=this._order){return this.set(e.x,e.y,e.z,s)}reorder(e){return G0.setFromEuler(this),this.setFromQuaternion(G0,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=[],s=0){return e[s]=this._x,e[s+1]=this._y,e[s+2]=this._z,e[s+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}}kr.DEFAULT_ORDER="XYZ";class qg{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}}let kG=0;const P0=new W,Co=new vo,yn=new Ot,_c=new W,La=new W,NG=new W,BG=new vo,L0=new W(1,0,0),W0=new W(0,1,0),F0=new W(0,0,1),U0={type:"added"},GG={type:"removed"},Ro={type:"childadded",child:null},yu={type:"childremoved",child:null};class Zt extends Mo{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:kG++}),this.uuid=zr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Zt.DEFAULT_UP.clone();const e=new W,s=new kr,i=new vo,n=new W(1,1,1);function r(){i.setFromEuler(s,!1)}function o(){s.setFromQuaternion(i,void 0,!1)}s._onChange(r),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:s},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Ot},normalMatrix:{value:new rt}}),this.matrix=new Ot,this.matrixWorld=new Ot,this.matrixAutoUpdate=Zt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Zt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new qg,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,s){this.quaternion.setFromAxisAngle(e,s)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,s){return Co.setFromAxisAngle(e,s),this.quaternion.multiply(Co),this}rotateOnWorldAxis(e,s){return Co.setFromAxisAngle(e,s),this.quaternion.premultiply(Co),this}rotateX(e){return this.rotateOnAxis(L0,e)}rotateY(e){return this.rotateOnAxis(W0,e)}rotateZ(e){return this.rotateOnAxis(F0,e)}translateOnAxis(e,s){return P0.copy(e).applyQuaternion(this.quaternion),this.position.add(P0.multiplyScalar(s)),this}translateX(e){return this.translateOnAxis(L0,e)}translateY(e){return this.translateOnAxis(W0,e)}translateZ(e){return this.translateOnAxis(F0,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(yn.copy(this.matrixWorld).invert())}lookAt(e,s,i){e.isVector3?_c.copy(e):_c.set(e,s,i);const n=this.parent;this.updateWorldMatrix(!0,!1),La.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?yn.lookAt(La,_c,this.up):yn.lookAt(_c,La,this.up),this.quaternion.setFromRotationMatrix(yn),n&&(yn.extractRotation(n.matrixWorld),Co.setFromRotationMatrix(yn),this.quaternion.premultiply(Co.invert()))}add(e){if(arguments.length>1){for(let s=0;s<arguments.length;s++)this.add(arguments[s]);return this}return e===this?(_t("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(U0),Ro.child=e,this.dispatchEvent(Ro),Ro.child=null):_t("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const s=this.children.indexOf(e);return s!==-1&&(e.parent=null,this.children.splice(s,1),e.dispatchEvent(GG),yu.child=e,this.dispatchEvent(yu),yu.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),yn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),yn.multiply(e.parent.matrixWorld)),e.applyMatrix4(yn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(U0),Ro.child=e,this.dispatchEvent(Ro),Ro.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,s){if(this[e]===s)return this;for(let i=0,n=this.children.length;i<n;i++){const o=this.children[i].getObjectByProperty(e,s);if(o!==void 0)return o}}getObjectsByProperty(e,s,i=[]){this[e]===s&&i.push(this);const n=this.children;for(let r=0,o=n.length;r<o;r++)n[r].getObjectsByProperty(e,s,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(La,e,NG),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(La,BG,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const s=this.matrixWorld.elements;return e.set(s[8],s[9],s[10]).normalize()}raycast(){}traverse(e){e(this);const s=this.children;for(let i=0,n=s.length;i<n;i++)s[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const s=this.children;for(let i=0,n=s.length;i<n;i++)s[i].traverseVisible(e)}traverseAncestors(e){const s=this.parent;s!==null&&(e(s),s.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const s=e.x,i=e.y,n=e.z,r=this.matrix.elements;r[12]+=s-r[0]*s-r[4]*i-r[8]*n,r[13]+=i-r[1]*s-r[5]*i-r[9]*n,r[14]+=n-r[2]*s-r[6]*i-r[10]*n}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);const s=this.children;for(let i=0,n=s.length;i<n;i++)s[i].updateMatrixWorld(e)}updateWorldMatrix(e,s,i=!1){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||i)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,i=!0),s===!0){const r=this.children;for(let o=0,a=r.length;o<a;o++)r[o].updateWorldMatrix(!1,!0,i)}}toJSON(e){const s=e===void 0||typeof e=="string",i={};s&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),this.static!==!1&&(n.static=this.static),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),this.pivot!==null&&(n.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(n.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(n.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(a=>({...a})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(e),n.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.toJSON()));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=r(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const d=l[c];r(e.shapes,d)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(r(e.materials,this.material[l]));n.material=a}else n.material=r(e.materials,this.material);if(this.children.length>0){n.children=[];for(let a=0;a<this.children.length;a++)n.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){n.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];n.animations.push(r(e.animations,l))}}if(s){const a=o(e.geometries),l=o(e.materials),c=o(e.textures),h=o(e.images),d=o(e.shapes),u=o(e.skeletons),p=o(e.animations),f=o(e.nodes);a.length>0&&(i.geometries=a),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),h.length>0&&(i.images=h),d.length>0&&(i.shapes=d),u.length>0&&(i.skeletons=u),p.length>0&&(i.animations=p),f.length>0&&(i.nodes=f)}return i.object=n,i;function o(a){const l=[];for(const c in a){const h=a[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,s=!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),this.pivot=e.pivot!==null?e.pivot.clone():null,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)),s===!0)for(let i=0;i<e.children.length;i++){const n=e.children[i];this.add(n.clone())}return this}}Zt.DEFAULT_UP=new W(0,1,0);Zt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Zt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class pl extends Zt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const PG={type:"move"};class zu{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new pl,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 pl,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new W,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new W),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new pl,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new W,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new W,this._grip.eventsEnabled=!1),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){const s=this._hand;if(s)for(const i of e.hand.values())this._getHandJoint(s,i)}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,s,i){let n=null,r=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&s.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const _ of e.hand.values()){const g=s.getJointPose(_,i),m=this._getHandJoint(c,_);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius),m.visible=g!==null}const h=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],u=h.position.distanceTo(d.position),p=.02,f=.005;c.inputState.pinching&&u>p+f?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=p-f&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=s.getPose(e.gripSpace,i),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));a!==null&&(n=s.getPose(e.targetRaySpace,i),n===null&&r!==null&&(n=r),n!==null&&(a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,n.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(n.linearVelocity)):a.hasLinearVelocity=!1,n.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(n.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(PG)))}return a!==null&&(a.visible=n!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,s){if(e.joints[s.jointName]===void 0){const i=new pl;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[s.jointName]=i,e.add(i)}return e.joints[s.jointName]}}const ES={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},Zn={h:0,s:0,l:0},bc={h:0,s:0,l:0};function Su(t,e,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+(e-t)*6*s:s<1/2?e:s<2/3?t+(e-t)*6*(2/3-s):t}class Ke{constructor(e,s,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,s,i)}set(e,s,i){if(s===void 0&&i===void 0){const n=e;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(e,s,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,s=Oi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,bt.colorSpaceToWorking(this,s),this}setRGB(e,s,i,n=bt.workingColorSpace){return this.r=e,this.g=s,this.b=i,bt.colorSpaceToWorking(this,n),this}setHSL(e,s,i,n=bt.workingColorSpace){if(e=xG(e,1),s=Mt(s,0,1),i=Mt(i,0,1),s===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+s):i+s-i*s,o=2*i-r;this.r=Su(o,r,e+1/3),this.g=Su(o,r,e),this.b=Su(o,r,e-1/3)}return bt.colorSpaceToWorking(this,n),this}setStyle(e,s=Oi){function i(r){r!==void 0&&parseFloat(r)<1&&Je("Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const o=n[1],a=n[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,s);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,s);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,s);break;default:Je("Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=n[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,s);if(o===6)return this.setHex(parseInt(r,16),s);Je("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,s);return this}setColorName(e,s=Oi){const i=ES[e.toLowerCase()];return i!==void 0?this.setHex(i,s):Je("Color: Unknown color "+e),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=Fn(e.r),this.g=Fn(e.g),this.b=Fn(e.b),this}copyLinearToSRGB(e){return this.r=na(e.r),this.g=na(e.g),this.b=na(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Oi){return bt.workingToColorSpace(Ns.copy(this),e),Math.round(Mt(Ns.r*255,0,255))*65536+Math.round(Mt(Ns.g*255,0,255))*256+Math.round(Mt(Ns.b*255,0,255))}getHexString(e=Oi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,s=bt.workingColorSpace){bt.workingToColorSpace(Ns.copy(this),s);const i=Ns.r,n=Ns.g,r=Ns.b,o=Math.max(i,n,r),a=Math.min(i,n,r);let l,c;const h=(a+o)/2;if(a===o)l=0,c=0;else{const d=o-a;switch(c=h<=.5?d/(o+a):d/(2-o-a),o){case i:l=(n-r)/d+(n<r?6:0);break;case n:l=(r-i)/d+2;break;case r:l=(i-n)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,s=bt.workingColorSpace){return bt.workingToColorSpace(Ns.copy(this),s),e.r=Ns.r,e.g=Ns.g,e.b=Ns.b,e}getStyle(e=Oi){bt.workingToColorSpace(Ns.copy(this),e);const s=Ns.r,i=Ns.g,n=Ns.b;return e!==Oi?`color(${e} ${s.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(s*255)},${Math.round(i*255)},${Math.round(n*255)})`}offsetHSL(e,s,i){return this.getHSL(Zn),this.setHSL(Zn.h+e,Zn.s+s,Zn.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,s){return this.r=e.r+s.r,this.g=e.g+s.g,this.b=e.b+s.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,s){return this.r+=(e.r-this.r)*s,this.g+=(e.g-this.g)*s,this.b+=(e.b-this.b)*s,this}lerpColors(e,s,i){return this.r=e.r+(s.r-e.r)*i,this.g=e.g+(s.g-e.g)*i,this.b=e.b+(s.b-e.b)*i,this}lerpHSL(e,s){this.getHSL(Zn),e.getHSL(bc);const i=_u(Zn.h,bc.h,s),n=_u(Zn.s,bc.s,s),r=_u(Zn.l,bc.l,s);return this.setHSL(i,n,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const s=this.r,i=this.g,n=this.b,r=e.elements;return this.r=r[0]*s+r[3]*i+r[6]*n,this.g=r[1]*s+r[4]*i+r[7]*n,this.b=r[2]*s+r[5]*i+r[8]*n,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,s=0){return this.r=e[s],this.g=e[s+1],this.b=e[s+2],this}toArray(e=[],s=0){return e[s]=this.r,e[s+1]=this.g,e[s+2]=this.b,e}fromBufferAttribute(e,s){return this.r=e.getX(s),this.g=e.getY(s),this.b=e.getZ(s),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Ns=new Ke;Ke.NAMES=ES;class LG extends Zt{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 kr,this.environmentIntensity=1,this.environmentRotation=new kr,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,s){return super.copy(e,s),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){const s=super.toJSON(e);return this.fog!==null&&(s.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(s.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(s.object.backgroundIntensity=this.backgroundIntensity),s.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(s.object.environmentIntensity=this.environmentIntensity),s.object.environmentRotation=this.environmentRotation.toArray(),s}}const Ui=new W,zn=new W,xu=new W,Sn=new W,ko=new W,No=new W,$0=new W,Ou=new W,Eu=new W,Au=new W,Tu=new Yt,Iu=new Yt,Du=new Yt;class Di{constructor(e=new W,s=new W,i=new W){this.a=e,this.b=s,this.c=i}static getNormal(e,s,i,n){n.subVectors(i,s),Ui.subVectors(e,s),n.cross(Ui);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(e,s,i,n,r){Ui.subVectors(n,s),zn.subVectors(i,s),xu.subVectors(e,s);const o=Ui.dot(Ui),a=Ui.dot(zn),l=Ui.dot(xu),c=zn.dot(zn),h=zn.dot(xu),d=o*c-a*a;if(d===0)return r.set(0,0,0),null;const u=1/d,p=(c*l-a*h)*u,f=(o*h-a*l)*u;return r.set(1-p-f,f,p)}static containsPoint(e,s,i,n){return this.getBarycoord(e,s,i,n,Sn)===null?!1:Sn.x>=0&&Sn.y>=0&&Sn.x+Sn.y<=1}static getInterpolation(e,s,i,n,r,o,a,l){return this.getBarycoord(e,s,i,n,Sn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,Sn.x),l.addScaledVector(o,Sn.y),l.addScaledVector(a,Sn.z),l)}static getInterpolatedAttribute(e,s,i,n,r,o){return Tu.setScalar(0),Iu.setScalar(0),Du.setScalar(0),Tu.fromBufferAttribute(e,s),Iu.fromBufferAttribute(e,i),Du.fromBufferAttribute(e,n),o.setScalar(0),o.addScaledVector(Tu,r.x),o.addScaledVector(Iu,r.y),o.addScaledVector(Du,r.z),o}static isFrontFacing(e,s,i,n){return Ui.subVectors(i,s),zn.subVectors(e,s),Ui.cross(zn).dot(n)<0}set(e,s,i){return this.a.copy(e),this.b.copy(s),this.c.copy(i),this}setFromPointsAndIndices(e,s,i,n){return this.a.copy(e[s]),this.b.copy(e[i]),this.c.copy(e[n]),this}setFromAttributeAndIndices(e,s,i,n){return this.a.fromBufferAttribute(e,s),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,n),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 Ui.subVectors(this.c,this.b),zn.subVectors(this.a,this.b),Ui.cross(zn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Di.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,s){return Di.getBarycoord(e,this.a,this.b,this.c,s)}getInterpolation(e,s,i,n,r){return Di.getInterpolation(e,this.a,this.b,this.c,s,i,n,r)}containsPoint(e){return Di.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Di.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,s){const i=this.a,n=this.b,r=this.c;let o,a;ko.subVectors(n,i),No.subVectors(r,i),Ou.subVectors(e,i);const l=ko.dot(Ou),c=No.dot(Ou);if(l<=0&&c<=0)return s.copy(i);Eu.subVectors(e,n);const h=ko.dot(Eu),d=No.dot(Eu);if(h>=0&&d<=h)return s.copy(n);const u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return o=l/(l-h),s.copy(i).addScaledVector(ko,o);Au.subVectors(e,r);const p=ko.dot(Au),f=No.dot(Au);if(f>=0&&p<=f)return s.copy(r);const _=p*c-l*f;if(_<=0&&c>=0&&f<=0)return a=c/(c-f),s.copy(i).addScaledVector(No,a);const g=h*f-p*d;if(g<=0&&d-h>=0&&p-f>=0)return $0.subVectors(r,n),a=(d-h)/(d-h+(p-f)),s.copy(n).addScaledVector($0,a);const m=1/(g+_+u);return o=_*m,a=u*m,s.copy(i).addScaledVector(ko,o).addScaledVector(No,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class wo{constructor(e=new W(1/0,1/0,1/0),s=new W(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=s}set(e,s){return this.min.copy(e),this.max.copy(s),this}setFromArray(e){this.makeEmpty();for(let s=0,i=e.length;s<i;s+=3)this.expandByPoint($i.fromArray(e,s));return this}setFromBufferAttribute(e){this.makeEmpty();for(let s=0,i=e.count;s<i;s++)this.expandByPoint($i.fromBufferAttribute(e,s));return this}setFromPoints(e){this.makeEmpty();for(let s=0,i=e.length;s<i;s++)this.expandByPoint(e[s]);return this}setFromCenterAndSize(e,s){const i=$i.copy(s).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,s=!1){return this.makeEmpty(),this.expandByObject(e,s)}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,s=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const r=i.getAttribute("position");if(s===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,$i):$i.fromBufferAttribute(r,o),$i.applyMatrix4(e.matrixWorld),this.expandByPoint($i);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Mc.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Mc.copy(i.boundingBox)),Mc.applyMatrix4(e.matrixWorld),this.union(Mc)}const n=e.children;for(let r=0,o=n.length;r<o;r++)this.expandByObject(n[r],s);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,s){return s.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,$i),$i.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let s,i;return e.normal.x>0?(s=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(s=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(s+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(s+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(s+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(s+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),s<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Wa),vc.subVectors(this.max,Wa),Bo.subVectors(e.a,Wa),Go.subVectors(e.b,Wa),Po.subVectors(e.c,Wa),Jn.subVectors(Go,Bo),Qn.subVectors(Po,Go),Ur.subVectors(Bo,Po);let s=[0,-Jn.z,Jn.y,0,-Qn.z,Qn.y,0,-Ur.z,Ur.y,Jn.z,0,-Jn.x,Qn.z,0,-Qn.x,Ur.z,0,-Ur.x,-Jn.y,Jn.x,0,-Qn.y,Qn.x,0,-Ur.y,Ur.x,0];return!Cu(s,Bo,Go,Po,vc)||(s=[1,0,0,0,1,0,0,0,1],!Cu(s,Bo,Go,Po,vc))?!1:(wc.crossVectors(Jn,Qn),s=[wc.x,wc.y,wc.z],Cu(s,Bo,Go,Po,vc))}clampPoint(e,s){return s.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,$i).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize($i).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:(xn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),xn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),xn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),xn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),xn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),xn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),xn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),xn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(xn),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}}const xn=[new W,new W,new W,new W,new W,new W,new W,new W],$i=new W,Mc=new wo,Bo=new W,Go=new W,Po=new W,Jn=new W,Qn=new W,Ur=new W,Wa=new W,vc=new W,wc=new W,$r=new W;function Cu(t,e,s,i,n){for(let r=0,o=t.length-3;r<=o;r+=3){$r.fromArray(t,r);const a=n.x*Math.abs($r.x)+n.y*Math.abs($r.y)+n.z*Math.abs($r.z),l=e.dot($r),c=s.dot($r),h=i.dot($r);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const os=new W,yc=new tt;let WG=0;class Es extends Mo{constructor(e,s,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:WG++}),this.name="",this.array=e,this.itemSize=s,this.count=e!==void 0?e.length/s:0,this.normalized=i,this.usage=Kp,this.updateRanges=[],this.gpuType=Xi,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,s){this.updateRanges.push({start:e,count:s})}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,s,i){e*=this.itemSize,i*=s.itemSize;for(let n=0,r=this.itemSize;n<r;n++)this.array[e+n]=s.array[i+n];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let s=0,i=this.count;s<i;s++)yc.fromBufferAttribute(this,s),yc.applyMatrix3(e),this.setXY(s,yc.x,yc.y);else if(this.itemSize===3)for(let s=0,i=this.count;s<i;s++)os.fromBufferAttribute(this,s),os.applyMatrix3(e),this.setXYZ(s,os.x,os.y,os.z);return this}applyMatrix4(e){for(let s=0,i=this.count;s<i;s++)os.fromBufferAttribute(this,s),os.applyMatrix4(e),this.setXYZ(s,os.x,os.y,os.z);return this}applyNormalMatrix(e){for(let s=0,i=this.count;s<i;s++)os.fromBufferAttribute(this,s),os.applyNormalMatrix(e),this.setXYZ(s,os.x,os.y,os.z);return this}transformDirection(e){for(let s=0,i=this.count;s<i;s++)os.fromBufferAttribute(this,s),os.transformDirection(e),this.setXYZ(s,os.x,os.y,os.z);return this}set(e,s=0){return this.array.set(e,s),this}getComponent(e,s){let i=this.array[e*this.itemSize+s];return this.normalized&&(i=dn(i,this.array)),i}setComponent(e,s,i){return this.normalized&&(i=kt(i,this.array)),this.array[e*this.itemSize+s]=i,this}getX(e){let s=this.array[e*this.itemSize];return this.normalized&&(s=dn(s,this.array)),s}setX(e,s){return this.normalized&&(s=kt(s,this.array)),this.array[e*this.itemSize]=s,this}getY(e){let s=this.array[e*this.itemSize+1];return this.normalized&&(s=dn(s,this.array)),s}setY(e,s){return this.normalized&&(s=kt(s,this.array)),this.array[e*this.itemSize+1]=s,this}getZ(e){let s=this.array[e*this.itemSize+2];return this.normalized&&(s=dn(s,this.array)),s}setZ(e,s){return this.normalized&&(s=kt(s,this.array)),this.array[e*this.itemSize+2]=s,this}getW(e){let s=this.array[e*this.itemSize+3];return this.normalized&&(s=dn(s,this.array)),s}setW(e,s){return this.normalized&&(s=kt(s,this.array)),this.array[e*this.itemSize+3]=s,this}setXY(e,s,i){return e*=this.itemSize,this.normalized&&(s=kt(s,this.array),i=kt(i,this.array)),this.array[e+0]=s,this.array[e+1]=i,this}setXYZ(e,s,i,n){return e*=this.itemSize,this.normalized&&(s=kt(s,this.array),i=kt(i,this.array),n=kt(n,this.array)),this.array[e+0]=s,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,s,i,n,r){return e*=this.itemSize,this.normalized&&(s=kt(s,this.array),i=kt(i,this.array),n=kt(n,this.array),r=kt(r,this.array)),this.array[e+0]=s,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const 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!==Kp&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class AS extends Es{constructor(e,s,i){super(new Uint16Array(e),s,i)}}class TS extends Es{constructor(e,s,i){super(new Uint32Array(e),s,i)}}class Tt extends Es{constructor(e,s,i){super(new Float32Array(e),s,i)}}const FG=new wo,Fa=new W,Ru=new W;class yo{constructor(e=new W,s=-1){this.isSphere=!0,this.center=e,this.radius=s}set(e,s){return this.center.copy(e),this.radius=s,this}setFromPoints(e,s){const i=this.center;s!==void 0?i.copy(s):FG.setFromPoints(e).getCenter(i);let n=0;for(let r=0,o=e.length;r<o;r++)n=Math.max(n,i.distanceToSquared(e[r]));return this.radius=Math.sqrt(n),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){const s=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=s*s}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,s){const i=this.center.distanceToSquared(e);return s.copy(e),i>this.radius*this.radius&&(s.sub(this.center).normalize(),s.multiplyScalar(this.radius).add(this.center)),s}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=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;Fa.subVectors(e,this.center);const s=Fa.lengthSq();if(s>this.radius*this.radius){const i=Math.sqrt(s),n=(i-this.radius)*.5;this.center.addScaledVector(Fa,n/i),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):(Ru.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Fa.copy(e.center).add(Ru)),this.expandByPoint(Fa.copy(e.center).sub(Ru))),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}}let UG=0;const vi=new Ot,ku=new Zt,Lo=new W,hi=new wo,Ua=new wo,_s=new W;class cs extends Mo{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:UG++}),this.uuid=zr(),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={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(wG(e)?TS:AS)(e,1):this.index=e,this}setIndirect(e,s=0){return this.indirect=e,this.indirectOffset=s,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,s){return this.attributes[e]=s,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,s,i=0){this.groups.push({start:e,count:s,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,s){this.drawRange.start=e,this.drawRange.count=s}applyMatrix4(e){const s=this.attributes.position;s!==void 0&&(s.applyMatrix4(e),s.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new rt().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return vi.makeRotationFromQuaternion(e),this.applyMatrix4(vi),this}rotateX(e){return vi.makeRotationX(e),this.applyMatrix4(vi),this}rotateY(e){return vi.makeRotationY(e),this.applyMatrix4(vi),this}rotateZ(e){return vi.makeRotationZ(e),this.applyMatrix4(vi),this}translate(e,s,i){return vi.makeTranslation(e,s,i),this.applyMatrix4(vi),this}scale(e,s,i){return vi.makeScale(e,s,i),this.applyMatrix4(vi),this}lookAt(e){return ku.lookAt(e),ku.updateMatrix(),this.applyMatrix4(ku.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Lo).negate(),this.translate(Lo.x,Lo.y,Lo.z),this}setFromPoints(e){const s=this.getAttribute("position");if(s===void 0){const i=[];for(let n=0,r=e.length;n<r;n++){const o=e[n];i.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Tt(i,3))}else{const i=Math.min(e.length,s.count);for(let n=0;n<i;n++){const r=e[n];s.setXYZ(n,r.x,r.y,r.z||0)}e.length>s.count&&Je("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),s.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new wo);const e=this.attributes.position,s=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){_t("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new W(-1/0,-1/0,-1/0),new W(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),s)for(let i=0,n=s.length;i<n;i++){const r=s[i];hi.setFromBufferAttribute(r),this.morphTargetsRelative?(_s.addVectors(this.boundingBox.min,hi.min),this.boundingBox.expandByPoint(_s),_s.addVectors(this.boundingBox.max,hi.max),this.boundingBox.expandByPoint(_s)):(this.boundingBox.expandByPoint(hi.min),this.boundingBox.expandByPoint(hi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&_t('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 yo);const e=this.attributes.position,s=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){_t("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new W,1/0);return}if(e){const i=this.boundingSphere.center;if(hi.setFromBufferAttribute(e),s)for(let r=0,o=s.length;r<o;r++){const a=s[r];Ua.setFromBufferAttribute(a),this.morphTargetsRelative?(_s.addVectors(hi.min,Ua.min),hi.expandByPoint(_s),_s.addVectors(hi.max,Ua.max),hi.expandByPoint(_s)):(hi.expandByPoint(Ua.min),hi.expandByPoint(Ua.max))}hi.getCenter(i);let n=0;for(let r=0,o=e.count;r<o;r++)_s.fromBufferAttribute(e,r),n=Math.max(n,i.distanceToSquared(_s));if(s)for(let r=0,o=s.length;r<o;r++){const a=s[r],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)_s.fromBufferAttribute(a,c),l&&(Lo.fromBufferAttribute(e,c),_s.add(Lo)),n=Math.max(n,i.distanceToSquared(_s))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&_t('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,s=this.attributes;if(e===null||s.position===void 0||s.normal===void 0||s.uv===void 0){_t("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=s.position,n=s.normal,r=s.uv;let o=this.getAttribute("tangent");(o===void 0||o.count!==i.count)&&(o=new Es(new Float32Array(4*i.count),4),this.setAttribute("tangent",o));const a=[],l=[];for(let M=0;M<i.count;M++)a[M]=new W,l[M]=new W;const c=new W,h=new W,d=new W,u=new tt,p=new tt,f=new tt,_=new W,g=new W;function m(M,S,T){c.fromBufferAttribute(i,M),h.fromBufferAttribute(i,S),d.fromBufferAttribute(i,T),u.fromBufferAttribute(r,M),p.fromBufferAttribute(r,S),f.fromBufferAttribute(r,T),h.sub(c),d.sub(c),p.sub(u),f.sub(u);const I=1/(p.x*f.y-f.x*p.y);isFinite(I)&&(_.copy(h).multiplyScalar(f.y).addScaledVector(d,-p.y).multiplyScalar(I),g.copy(d).multiplyScalar(p.x).addScaledVector(h,-f.x).multiplyScalar(I),a[M].add(_),a[S].add(_),a[T].add(_),l[M].add(g),l[S].add(g),l[T].add(g))}let w=this.groups;w.length===0&&(w=[{start:0,count:e.count}]);for(let M=0,S=w.length;M<S;++M){const T=w[M],I=T.start,E=T.count;for(let O=I,R=I+E;O<R;O+=3)m(e.getX(O+0),e.getX(O+1),e.getX(O+2))}const y=new W,b=new W,v=new W,z=new W;function x(M){v.fromBufferAttribute(n,M),z.copy(v);const S=a[M];y.copy(S),y.sub(v.multiplyScalar(v.dot(S))).normalize(),b.crossVectors(z,S);const I=b.dot(l[M])<0?-1:1;o.setXYZW(M,y.x,y.y,y.z,I)}for(let M=0,S=w.length;M<S;++M){const T=w[M],I=T.start,E=T.count;for(let O=I,R=I+E;O<R;O+=3)x(e.getX(O+0)),x(e.getX(O+1)),x(e.getX(O+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,s=this.getAttribute("position");if(s!==void 0){let i=this.getAttribute("normal");if(i===void 0||i.count!==s.count)i=new Es(new Float32Array(s.count*3),3),this.setAttribute("normal",i);else for(let u=0,p=i.count;u<p;u++)i.setXYZ(u,0,0,0);const n=new W,r=new W,o=new W,a=new W,l=new W,c=new W,h=new W,d=new W;if(e)for(let u=0,p=e.count;u<p;u+=3){const f=e.getX(u+0),_=e.getX(u+1),g=e.getX(u+2);n.fromBufferAttribute(s,f),r.fromBufferAttribute(s,_),o.fromBufferAttribute(s,g),h.subVectors(o,r),d.subVectors(n,r),h.cross(d),a.fromBufferAttribute(i,f),l.fromBufferAttribute(i,_),c.fromBufferAttribute(i,g),a.add(h),l.add(h),c.add(h),i.setXYZ(f,a.x,a.y,a.z),i.setXYZ(_,l.x,l.y,l.z),i.setXYZ(g,c.x,c.y,c.z)}else for(let u=0,p=s.count;u<p;u+=3)n.fromBufferAttribute(s,u+0),r.fromBufferAttribute(s,u+1),o.fromBufferAttribute(s,u+2),h.subVectors(o,r),d.subVectors(n,r),h.cross(d),i.setXYZ(u+0,h.x,h.y,h.z),i.setXYZ(u+1,h.x,h.y,h.z),i.setXYZ(u+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let s=0,i=e.count;s<i;s++)_s.fromBufferAttribute(e,s),_s.normalize(),e.setXYZ(s,_s.x,_s.y,_s.z)}toNonIndexed(){function e(a,l){const c=a.array,h=a.itemSize,d=a.normalized,u=new c.constructor(l.length*h);let p=0,f=0;for(let _=0,g=l.length;_<g;_++){a.isInterleavedBufferAttribute?p=l[_]*a.data.stride+a.offset:p=l[_]*h;for(let m=0;m<h;m++)u[f++]=c[p++]}return new Es(u,h,d)}if(this.index===null)return Je("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const s=new cs,i=this.index.array,n=this.attributes;for(const a in n){const l=n[a],c=e(l,i);s.setAttribute(a,c)}const r=this.morphAttributes;for(const a in r){const l=[],c=r[a];for(let h=0,d=c.length;h<d;h++){const u=c[h],p=e(u,i);l.push(p)}s.morphAttributes[a]=l}s.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];s.addGroup(c.start,c.count,c.materialIndex)}return s}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const s=this.index;s!==null&&(e.data.index={type:s.array.constructor.name,array:Array.prototype.slice.call(s.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const n={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d<u;d++){const p=c[d];h.push(p.toJSON(e.data))}h.length>0&&(n[l]=h,r=!0)}r&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.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;const s={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const n=e.attributes;for(const c in n){const h=n[c];this.setAttribute(c,h.clone(s))}const r=e.morphAttributes;for(const c in r){const h=[],d=r[c];for(let u=0,p=d.length;u<p;u++)h.push(d[u].clone(s));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let c=0,h=o.length;c<h;c++){const d=o[c];this.addGroup(d.start,d.count,d.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class $G{constructor(e,s){this.isInterleavedBuffer=!0,this.array=e,this.stride=s,this.count=e!==void 0?e.length/s:0,this.usage=Kp,this.updateRanges=[],this.version=0,this.uuid=zr()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,s){this.updateRanges.push({start:e,count:s})}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,s,i){e*=this.stride,i*=s.stride;for(let n=0,r=this.stride;n<r;n++)this.array[e+n]=s.array[i+n];return this}set(e,s=0){return this.array.set(e,s),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=zr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const s=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(s,this.stride);return i.setUsage(this.usage),i}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=zr()),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}}}const js=new W;class Qh{constructor(e,s,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=s,this.offset=i,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let s=0,i=this.data.count;s<i;s++)js.fromBufferAttribute(this,s),js.applyMatrix4(e),this.setXYZ(s,js.x,js.y,js.z);return this}applyNormalMatrix(e){for(let s=0,i=this.count;s<i;s++)js.fromBufferAttribute(this,s),js.applyNormalMatrix(e),this.setXYZ(s,js.x,js.y,js.z);return this}transformDirection(e){for(let s=0,i=this.count;s<i;s++)js.fromBufferAttribute(this,s),js.transformDirection(e),this.setXYZ(s,js.x,js.y,js.z);return this}getComponent(e,s){let i=this.array[e*this.data.stride+this.offset+s];return this.normalized&&(i=dn(i,this.array)),i}setComponent(e,s,i){return this.normalized&&(i=kt(i,this.array)),this.data.array[e*this.data.stride+this.offset+s]=i,this}setX(e,s){return this.normalized&&(s=kt(s,this.array)),this.data.array[e*this.data.stride+this.offset]=s,this}setY(e,s){return this.normalized&&(s=kt(s,this.array)),this.data.array[e*this.data.stride+this.offset+1]=s,this}setZ(e,s){return this.normalized&&(s=kt(s,this.array)),this.data.array[e*this.data.stride+this.offset+2]=s,this}setW(e,s){return this.normalized&&(s=kt(s,this.array)),this.data.array[e*this.data.stride+this.offset+3]=s,this}getX(e){let s=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(s=dn(s,this.array)),s}getY(e){let s=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(s=dn(s,this.array)),s}getZ(e){let s=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(s=dn(s,this.array)),s}getW(e){let s=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(s=dn(s,this.array)),s}setXY(e,s,i){return e=e*this.data.stride+this.offset,this.normalized&&(s=kt(s,this.array),i=kt(i,this.array)),this.data.array[e+0]=s,this.data.array[e+1]=i,this}setXYZ(e,s,i,n){return e=e*this.data.stride+this.offset,this.normalized&&(s=kt(s,this.array),i=kt(i,this.array),n=kt(n,this.array)),this.data.array[e+0]=s,this.data.array[e+1]=i,this.data.array[e+2]=n,this}setXYZW(e,s,i,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(s=kt(s,this.array),i=kt(i,this.array),n=kt(n,this.array),r=kt(r,this.array)),this.data.array[e+0]=s,this.data.array[e+1]=i,this.data.array[e+2]=n,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Jh("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const s=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)s.push(this.data.array[n+r])}return new Es(new this.array.constructor(s),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Qh(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Jh("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const s=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)s.push(this.data.array[n+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:s,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}}}let jG=0;class qn extends Mo{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:jG++}),this.uuid=zr(),this.name="",this.type="Material",this.blending=ao,this.side=Cr,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=op,this.blendDst=ap,this.blendEquation=Jr,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ke(0,0,0),this.blendAlpha=0,this.depthFunc=ga,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=I0,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=To,this.stencilZFail=To,this.stencilZPass=To,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(const s in e){const i=e[s];if(i===void 0){Je(`Material: parameter '${s}' has value of undefined.`);continue}const n=this[s];if(n===void 0){Je(`Material: '${s}' is not a property of THREE.${this.type}.`);continue}n&&n.isColor?n.set(i):n&&n.isVector2&&i&&i.isVector2||n&&n.isEuler&&i&&i.isEuler||n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[s]=i}}toJSON(e){const s=e===void 0||typeof e=="string";s&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==ao&&(i.blending=this.blending),this.side!==Cr&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==op&&(i.blendSrc=this.blendSrc),this.blendDst!==ap&&(i.blendDst=this.blendDst),this.blendEquation!==Jr&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==ga&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==I0&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==To&&(i.stencilFail=this.stencilFail),this.stencilZFail!==To&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==To&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function n(r){const o=[];for(const a in r){const l=r[a];delete l.metadata,o.push(l)}return o}if(s){const r=n(e.textures),o=n(e.images);r.length>0&&(i.textures=r),o.length>0&&(i.images=o)}return i}fromJSON(e,s){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Ke().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=s[e.map]||null),e.matcap!==void 0&&(this.matcap=s[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=s[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=s[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=s[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new tt().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=s[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=s[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=s[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=s[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=s[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=s[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=s[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=s[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=s[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=s[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=s[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=s[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=s[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=s[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new tt().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=s[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=s[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=s[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=s[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=s[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=s[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=s[e.sheenRoughnessMap]||null),this}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;const s=e.clippingPlanes;let i=null;if(s!==null){const n=s.length;i=new Array(n);for(let r=0;r!==n;++r)i[r]=s[r].clone()}return this.clippingPlanes=i,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++}}class Kl extends qn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ke(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}}let Wo;const $a=new W,Fo=new W,Uo=new W,$o=new tt,ja=new tt,IS=new Ot,zc=new W,Ha=new W,Sc=new W,j0=new tt,Nu=new tt,H0=new tt;class Id extends Zt{constructor(e=new Kl){if(super(),this.isSprite=!0,this.type="Sprite",Wo===void 0){Wo=new cs;const s=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new $G(s,5);Wo.setIndex([0,1,2,0,2,3]),Wo.setAttribute("position",new Qh(i,3,0,!1)),Wo.setAttribute("uv",new Qh(i,2,3,!1))}this.geometry=Wo,this.material=e,this.center=new tt(.5,.5),this.count=1}raycast(e,s){e.camera===null&&_t('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Fo.setFromMatrixScale(this.matrixWorld),IS.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Uo.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Fo.multiplyScalar(-Uo.z);const i=this.material.rotation;let n,r;i!==0&&(r=Math.cos(i),n=Math.sin(i));const o=this.center;xc(zc.set(-.5,-.5,0),Uo,o,Fo,n,r),xc(Ha.set(.5,-.5,0),Uo,o,Fo,n,r),xc(Sc.set(.5,.5,0),Uo,o,Fo,n,r),j0.set(0,0),Nu.set(1,0),H0.set(1,1);let a=e.ray.intersectTriangle(zc,Ha,Sc,!1,$a);if(a===null&&(xc(Ha.set(-.5,.5,0),Uo,o,Fo,n,r),Nu.set(0,1),a=e.ray.intersectTriangle(zc,Sc,Ha,!1,$a),a===null))return;const l=e.ray.origin.distanceTo($a);l<e.near||l>e.far||s.push({distance:l,point:$a.clone(),uv:Di.getInterpolation($a,zc,Ha,Sc,j0,Nu,H0,new tt),face:null,object:this})}copy(e,s){return super.copy(e,s),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function xc(t,e,s,i,n,r){$o.subVectors(t,s).addScalar(.5).multiply(i),n!==void 0?(ja.x=r*$o.x-n*$o.y,ja.y=n*$o.x+r*$o.y):ja.copy($o),t.copy(e),t.x+=ja.x,t.y+=ja.y,t.applyMatrix4(IS)}const On=new W,Bu=new W,Oc=new W,er=new W,Gu=new W,Ec=new W,Pu=new W;class Dd{constructor(e=new W,s=new W(0,0,-1)){this.origin=e,this.direction=s}set(e,s){return this.origin.copy(e),this.direction.copy(s),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,s){return s.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,On)),this}closestPointToPoint(e,s){s.subVectors(e,this.origin);const i=s.dot(this.direction);return i<0?s.copy(this.origin):s.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const s=On.subVectors(e,this.origin).dot(this.direction);return s<0?this.origin.distanceToSquared(e):(On.copy(this.origin).addScaledVector(this.direction,s),On.distanceToSquared(e))}distanceSqToSegment(e,s,i,n){Bu.copy(e).add(s).multiplyScalar(.5),Oc.copy(s).sub(e).normalize(),er.copy(this.origin).sub(Bu);const r=e.distanceTo(s)*.5,o=-this.direction.dot(Oc),a=er.dot(this.direction),l=-er.dot(Oc),c=er.lengthSq(),h=Math.abs(1-o*o);let d,u,p,f;if(h>0)if(d=o*l-a,u=o*a-l,f=r*h,d>=0)if(u>=-f)if(u<=f){const _=1/h;d*=_,u*=_,p=d*(d+o*u+2*a)+u*(o*d+u+2*l)+c}else u=r,d=Math.max(0,-(o*u+a)),p=-d*d+u*(u+2*l)+c;else u=-r,d=Math.max(0,-(o*u+a)),p=-d*d+u*(u+2*l)+c;else u<=-f?(d=Math.max(0,-(-o*r+a)),u=d>0?-r:Math.min(Math.max(-r,-l),r),p=-d*d+u*(u+2*l)+c):u<=f?(d=0,u=Math.min(Math.max(-r,-l),r),p=u*(u+2*l)+c):(d=Math.max(0,-(o*r+a)),u=d>0?r:Math.min(Math.max(-r,-l),r),p=-d*d+u*(u+2*l)+c);else u=o>0?-r:r,d=Math.max(0,-(o*u+a)),p=-d*d+u*(u+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),n&&n.copy(Bu).addScaledVector(Oc,u),p}intersectSphere(e,s){On.subVectors(e.center,this.origin);const i=On.dot(this.direction),n=On.dot(On)-i*i,r=e.radius*e.radius;if(n>r)return null;const o=Math.sqrt(r-n),a=i-o,l=i+o;return l<0?null:a<0?this.at(l,s):this.at(a,s)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const s=e.normal.dot(this.direction);if(s===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/s;return i>=0?i:null}intersectPlane(e,s){const i=this.distanceToPlane(e);return i===null?null:this.at(i,s)}intersectsPlane(e){const s=e.distanceToPoint(this.origin);return s===0||e.normal.dot(this.direction)*s<0}intersectBox(e,s){let i,n,r,o,a,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(i=(e.min.x-u.x)*c,n=(e.max.x-u.x)*c):(i=(e.max.x-u.x)*c,n=(e.min.x-u.x)*c),h>=0?(r=(e.min.y-u.y)*h,o=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,o=(e.min.y-u.y)*h),i>o||r>n||((r>i||isNaN(i))&&(i=r),(o<n||isNaN(n))&&(n=o),d>=0?(a=(e.min.z-u.z)*d,l=(e.max.z-u.z)*d):(a=(e.max.z-u.z)*d,l=(e.min.z-u.z)*d),i>l||a>n)||((a>i||i!==i)&&(i=a),(l<n||n!==n)&&(n=l),n<0)?null:this.at(i>=0?i:n,s)}intersectsBox(e){return this.intersectBox(e,On)!==null}intersectTriangle(e,s,i,n,r){Gu.subVectors(s,e),Ec.subVectors(i,e),Pu.crossVectors(Gu,Ec);let o=this.direction.dot(Pu),a;if(o>0){if(n)return null;a=1}else if(o<0)a=-1,o=-o;else return null;er.subVectors(this.origin,e);const l=a*this.direction.dot(Ec.crossVectors(er,Ec));if(l<0)return null;const c=a*this.direction.dot(Gu.cross(er));if(c<0||l+c>o)return null;const h=-a*er.dot(Pu);return h<0?null:this.at(h/o,r)}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)}}class Kg extends qn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ke(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 kr,this.combine=hS,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}}const V0=new Ot,jr=new Dd,Ac=new yo,q0=new W,Tc=new W,Ic=new W,Dc=new W,Lu=new W,Cc=new W,K0=new W,Rc=new W;class ii extends Zt{constructor(e=new cs,s=new Kg){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=s,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,s){return super.copy(e,s),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(){const s=this.geometry.morphAttributes,i=Object.keys(s);if(i.length>0){const n=s[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r<o;r++){const a=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,s){const i=this.geometry,n=i.attributes.position,r=i.morphAttributes.position,o=i.morphTargetsRelative;s.fromBufferAttribute(n,e);const a=this.morphTargetInfluences;if(r&&a){Cc.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const h=a[l],d=r[l];h!==0&&(Lu.fromBufferAttribute(d,e),o?Cc.addScaledVector(Lu,h):Cc.addScaledVector(Lu.sub(s),h))}s.add(Cc)}return s}raycast(e,s){const i=this.geometry,n=this.material,r=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Ac.copy(i.boundingSphere),Ac.applyMatrix4(r),jr.copy(e.ray).recast(e.near),!(Ac.containsPoint(jr.origin)===!1&&(jr.intersectSphere(Ac,q0)===null||jr.origin.distanceToSquared(q0)>(e.far-e.near)**2))&&(V0.copy(r).invert(),jr.copy(e.ray).applyMatrix4(V0),!(i.boundingBox!==null&&jr.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,s,jr)))}_computeIntersections(e,s,i){let n;const r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,p=r.drawRange;if(a!==null)if(Array.isArray(o))for(let f=0,_=u.length;f<_;f++){const g=u[f],m=o[g.materialIndex],w=Math.max(g.start,p.start),y=Math.min(a.count,Math.min(g.start+g.count,p.start+p.count));for(let b=w,v=y;b<v;b+=3){const z=a.getX(b),x=a.getX(b+1),M=a.getX(b+2);n=kc(this,m,e,i,c,h,d,z,x,M),n&&(n.faceIndex=Math.floor(b/3),n.face.materialIndex=g.materialIndex,s.push(n))}}else{const f=Math.max(0,p.start),_=Math.min(a.count,p.start+p.count);for(let g=f,m=_;g<m;g+=3){const w=a.getX(g),y=a.getX(g+1),b=a.getX(g+2);n=kc(this,o,e,i,c,h,d,w,y,b),n&&(n.faceIndex=Math.floor(g/3),s.push(n))}}else if(l!==void 0)if(Array.isArray(o))for(let f=0,_=u.length;f<_;f++){const g=u[f],m=o[g.materialIndex],w=Math.max(g.start,p.start),y=Math.min(l.count,Math.min(g.start+g.count,p.start+p.count));for(let b=w,v=y;b<v;b+=3){const z=b,x=b+1,M=b+2;n=kc(this,m,e,i,c,h,d,z,x,M),n&&(n.faceIndex=Math.floor(b/3),n.face.materialIndex=g.materialIndex,s.push(n))}}else{const f=Math.max(0,p.start),_=Math.min(l.count,p.start+p.count);for(let g=f,m=_;g<m;g+=3){const w=g,y=g+1,b=g+2;n=kc(this,o,e,i,c,h,d,w,y,b),n&&(n.faceIndex=Math.floor(g/3),s.push(n))}}}}function HG(t,e,s,i,n,r,o,a){let l;if(e.side===si?l=i.intersectTriangle(o,r,n,!0,a):l=i.intersectTriangle(n,r,o,e.side===Cr,a),l===null)return null;Rc.copy(a),Rc.applyMatrix4(t.matrixWorld);const c=s.ray.origin.distanceTo(Rc);return c<s.near||c>s.far?null:{distance:c,point:Rc.clone(),object:t}}function kc(t,e,s,i,n,r,o,a,l,c){t.getVertexPosition(a,Tc),t.getVertexPosition(l,Ic),t.getVertexPosition(c,Dc);const h=HG(t,e,s,i,Tc,Ic,Dc,K0);if(h){const d=new W;Di.getBarycoord(K0,Tc,Ic,Dc,d),n&&(h.uv=Di.getInterpolatedAttribute(n,a,l,c,d,new tt)),r&&(h.uv1=Di.getInterpolatedAttribute(r,a,l,c,d,new tt)),o&&(h.normal=Di.getInterpolatedAttribute(o,a,l,c,d,new W),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const u={a,b:l,c,normal:new W,materialIndex:0};Di.getNormal(Tc,Ic,Dc,u.normal),h.face=u,h.barycoord=d}return h}class DS extends Ws{constructor(e=null,s=1,i=1,n,r,o,a,l,c=Is,h=Is,d,u){super(null,o,a,l,c,h,n,r,d,u),this.isDataTexture=!0,this.image={data:e,width:s,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Sr extends Es{constructor(e,s,i,n=1){super(e,s,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const jo=new Ot,Y0=new Ot,Nc=[],X0=new wo,VG=new Ot,Va=new ii,qa=new yo;class Yg extends ii{constructor(e,s,i){super(e,s),this.isInstancedMesh=!0,this.instanceMatrix=new Sr(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<i;n++)this.setMatrixAt(n,VG)}computeBoundingBox(){const e=this.geometry,s=this.count;this.boundingBox===null&&(this.boundingBox=new wo),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<s;i++)this.getMatrixAt(i,jo),X0.copy(e.boundingBox).applyMatrix4(jo),this.boundingBox.union(X0)}computeBoundingSphere(){const e=this.geometry,s=this.count;this.boundingSphere===null&&(this.boundingSphere=new yo),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<s;i++)this.getMatrixAt(i,jo),qa.copy(e.boundingSphere).applyMatrix4(jo),this.boundingSphere.union(qa)}copy(e,s){return super.copy(e,s),this.instanceMatrix.copy(e.instanceMatrix),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,s){return this.instanceColor===null?s.setRGB(1,1,1):s.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,s){return s.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,s){const i=s.morphTargetInfluences,n=this.morphTexture.source.data.data,r=i.length+1,o=e*r+1;for(let a=0;a<i.length;a++)i[a]=n[o+a]}raycast(e,s){const i=this.matrixWorld,n=this.count;if(Va.geometry=this.geometry,Va.material=this.material,Va.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),qa.copy(this.boundingSphere),qa.applyMatrix4(i),e.ray.intersectsSphere(qa)!==!1))for(let r=0;r<n;r++){this.getMatrixAt(r,jo),Y0.multiplyMatrices(i,jo),Va.matrixWorld=Y0,Va.raycast(e,Nc);for(let o=0,a=Nc.length;o<a;o++){const l=Nc[o];l.instanceId=r,l.object=this,s.push(l)}Nc.length=0}}setColorAt(e,s){return this.instanceColor===null&&(this.instanceColor=new Sr(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),s.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,s){return s.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,s){const i=s.morphTargetInfluences,n=i.length+1;this.morphTexture===null&&(this.morphTexture=new DS(new Float32Array(n*this.count),n,this.count,Wg,Xi));const r=this.morphTexture.source.data.data;let o=0;for(let c=0;c<i.length;c++)o+=i[c];const a=this.geometry.morphTargetsRelative?1:1-o,l=n*e;return r[l]=a,r.set(i,l+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Wu=new W,qG=new W,KG=new rt;class cr{constructor(e=new W(1,0,0),s=0){this.isPlane=!0,this.normal=e,this.constant=s}set(e,s){return this.normal.copy(e),this.constant=s,this}setComponents(e,s,i,n){return this.normal.set(e,s,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,s){return this.normal.copy(e),this.constant=-s.dot(this.normal),this}setFromCoplanarPoints(e,s,i){const n=Wu.subVectors(i,s).cross(qG.subVectors(e,s)).normalize();return this.setFromNormalAndCoplanarPoint(n,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const 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,s){return s.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,s,i=!0){const n=e.delta(Wu),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?s.copy(e.start):null;const o=-(e.start.dot(this.normal)+this.constant)/r;return i===!0&&(o<0||o>1)?null:s.copy(e.start).addScaledVector(n,o)}intersectsLine(e){const s=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return s<0&&i>0||i<0&&s>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,s){const i=s||KG.getNormalMatrix(e),n=this.coplanarPoint(Wu).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),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)}}const Hr=new yo,YG=new tt(.5,.5),Bc=new W;class Xg{constructor(e=new cr,s=new cr,i=new cr,n=new cr,r=new cr,o=new cr){this.planes=[e,s,i,n,r,o]}set(e,s,i,n,r,o){const a=this.planes;return a[0].copy(e),a[1].copy(s),a[2].copy(i),a[3].copy(n),a[4].copy(r),a[5].copy(o),this}copy(e){const s=this.planes;for(let i=0;i<6;i++)s[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,s=un,i=!1){const n=this.planes,r=e.elements,o=r[0],a=r[1],l=r[2],c=r[3],h=r[4],d=r[5],u=r[6],p=r[7],f=r[8],_=r[9],g=r[10],m=r[11],w=r[12],y=r[13],b=r[14],v=r[15];if(n[0].setComponents(c-o,p-h,m-f,v-w).normalize(),n[1].setComponents(c+o,p+h,m+f,v+w).normalize(),n[2].setComponents(c+a,p+d,m+_,v+y).normalize(),n[3].setComponents(c-a,p-d,m-_,v-y).normalize(),i)n[4].setComponents(l,u,g,b).normalize(),n[5].setComponents(c-l,p-u,m-g,v-b).normalize();else if(n[4].setComponents(c-l,p-u,m-g,v-b).normalize(),s===un)n[5].setComponents(c+l,p+u,m+g,v+b).normalize();else if(s===Ll)n[5].setComponents(l,u,g,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+s);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Hr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const s=e.geometry;s.boundingSphere===null&&s.computeBoundingSphere(),Hr.copy(s.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Hr)}intersectsSprite(e){Hr.center.set(0,0,0);const s=YG.distanceTo(e.center);return Hr.radius=.7071067811865476+s,Hr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Hr)}intersectsSphere(e){const s=this.planes,i=e.center,n=-e.radius;for(let r=0;r<6;r++)if(s[r].distanceToPoint(i)<n)return!1;return!0}intersectsBox(e){const s=this.planes;for(let i=0;i<6;i++){const n=s[i];if(Bc.x=n.normal.x>0?e.max.x:e.min.x,Bc.y=n.normal.y>0?e.max.y:e.min.y,Bc.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(Bc)<0)return!1}return!0}containsPoint(e){const s=this.planes;for(let i=0;i<6;i++)if(s[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Cd extends qn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ke(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}}const ed=new W,td=new W,Z0=new Ot,Ka=new Dd,Gc=new yo,Fu=new W,J0=new W;class Xp extends Zt{constructor(e=new cs,s=new Cd){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=s,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,s){return super.copy(e,s),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const s=e.attributes.position,i=[0];for(let n=1,r=s.count;n<r;n++)ed.fromBufferAttribute(s,n-1),td.fromBufferAttribute(s,n),i[n]=i[n-1],i[n]+=ed.distanceTo(td);e.setAttribute("lineDistance",new Tt(i,1))}else Je("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,s){const i=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Gc.copy(i.boundingSphere),Gc.applyMatrix4(n),Gc.radius+=r,e.ray.intersectsSphere(Gc)===!1)return;Z0.copy(n).invert(),Ka.copy(e.ray).applyMatrix4(Z0);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,h=i.index,u=i.attributes.position;if(h!==null){const p=Math.max(0,o.start),f=Math.min(h.count,o.start+o.count);for(let _=p,g=f-1;_<g;_+=c){const m=h.getX(_),w=h.getX(_+1),y=Pc(this,e,Ka,l,m,w,_);y&&s.push(y)}if(this.isLineLoop){const _=h.getX(f-1),g=h.getX(p),m=Pc(this,e,Ka,l,_,g,f-1);m&&s.push(m)}}else{const p=Math.max(0,o.start),f=Math.min(u.count,o.start+o.count);for(let _=p,g=f-1;_<g;_+=c){const m=Pc(this,e,Ka,l,_,_+1,_);m&&s.push(m)}if(this.isLineLoop){const _=Pc(this,e,Ka,l,f-1,p,f-1);_&&s.push(_)}}}updateMorphTargets(){const s=this.geometry.morphAttributes,i=Object.keys(s);if(i.length>0){const n=s[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r<o;r++){const a=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Pc(t,e,s,i,n,r,o){const a=t.geometry.attributes.position;if(ed.fromBufferAttribute(a,n),td.fromBufferAttribute(a,r),s.distanceSqToSegment(ed,td,Fu,J0)>i)return;Fu.applyMatrix4(t.matrixWorld);const c=e.ray.origin.distanceTo(Fu);if(!(c<e.near||c>e.far))return{distance:c,point:J0.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const Q0=new W,eM=new W;class Zp extends Xp{constructor(e,s){super(e,s),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const s=e.attributes.position,i=[];for(let n=0,r=s.count;n<r;n+=2)Q0.fromBufferAttribute(s,n),eM.fromBufferAttribute(s,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+Q0.distanceTo(eM);e.setAttribute("lineDistance",new Tt(i,1))}else Je("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class XG extends qn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ke(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}}const tM=new Ot,Jp=new Dd,Lc=new yo,Wc=new W;class ZG extends Zt{constructor(e=new cs,s=new XG){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=s,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,s){return super.copy(e,s),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,s){const i=this.geometry,n=this.matrixWorld,r=e.params.Points.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Lc.copy(i.boundingSphere),Lc.applyMatrix4(n),Lc.radius+=r,e.ray.intersectsSphere(Lc)===!1)return;tM.copy(n).invert(),Jp.copy(e.ray).applyMatrix4(tM);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=i.index,d=i.attributes.position;if(c!==null){const u=Math.max(0,o.start),p=Math.min(c.count,o.start+o.count);for(let f=u,_=p;f<_;f++){const g=c.getX(f);Wc.fromBufferAttribute(d,g),sM(Wc,g,l,n,e,s,this)}}else{const u=Math.max(0,o.start),p=Math.min(d.count,o.start+o.count);for(let f=u,_=p;f<_;f++)Wc.fromBufferAttribute(d,f),sM(Wc,f,l,n,e,s,this)}}updateMorphTargets(){const s=this.geometry.morphAttributes,i=Object.keys(s);if(i.length>0){const n=s[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r<o;r++){const a=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function sM(t,e,s,i,n,r,o){const a=Jp.distanceSqToPoint(t);if(a<s){const l=new W;Jp.closestPointToPoint(t,l),l.applyMatrix4(i);const c=n.ray.origin.distanceTo(l);if(c<n.near||c>n.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}class CS extends Ws{constructor(e=[],s=mo,i,n,r,o,a,l,c,h){super(e,s,i,n,r,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class RS extends Ws{constructor(e,s,i,n,r,o,a,l,c){super(e,s,i,n,r,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class ba extends Ws{constructor(e,s,i=Mn,n,r,o,a=Is,l=Is,c,h=Hn,d=1){if(h!==Hn&&h!==to)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:e,height:s,depth:d};super(u,n,r,o,a,l,h,i,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Vg(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const s=super.toJSON(e);return this.compareFunction!==null&&(s.compareFunction=this.compareFunction),s}}class JG extends ba{constructor(e,s=Mn,i=mo,n,r,o=Is,a=Is,l,c=Hn){const h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,s,i,n,r,o,a,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class kS extends Ws{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Yl extends cs{constructor(e=1,s=1,i=1,n=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:s,depth:i,widthSegments:n,heightSegments:r,depthSegments:o};const a=this;n=Math.floor(n),r=Math.floor(r),o=Math.floor(o);const l=[],c=[],h=[],d=[];let u=0,p=0;f("z","y","x",-1,-1,i,s,e,o,r,0),f("z","y","x",1,-1,i,s,-e,o,r,1),f("x","z","y",1,1,e,i,s,n,o,2),f("x","z","y",1,-1,e,i,-s,n,o,3),f("x","y","z",1,-1,e,s,i,n,r,4),f("x","y","z",-1,-1,e,s,-i,n,r,5),this.setIndex(l),this.setAttribute("position",new Tt(c,3)),this.setAttribute("normal",new Tt(h,3)),this.setAttribute("uv",new Tt(d,2));function f(_,g,m,w,y,b,v,z,x,M,S){const T=b/x,I=v/M,E=b/2,O=v/2,R=z/2,C=x+1,k=M+1;let B=0,L=0;const F=new W;for(let ee=0;ee<k;ee++){const X=ee*I-O;for(let he=0;he<C;he++){const Oe=he*T-E;F[_]=Oe*w,F[g]=X*y,F[m]=R,c.push(F.x,F.y,F.z),F[_]=0,F[g]=0,F[m]=z>0?1:-1,h.push(F.x,F.y,F.z),d.push(he/x),d.push(1-ee/M),B+=1}}for(let ee=0;ee<M;ee++)for(let X=0;X<x;X++){const he=u+X+C*ee,Oe=u+X+C*(ee+1),De=u+(X+1)+C*(ee+1),ke=u+(X+1)+C*ee;l.push(he,Oe,ke),l.push(Oe,De,ke),L+=6}a.addGroup(p,L,S),p+=L,u+=B}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Yl(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Zg extends cs{constructor(e=1,s=32,i=0,n=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:s,thetaStart:i,thetaLength:n},s=Math.max(3,s);const r=[],o=[],a=[],l=[],c=new W,h=new tt;o.push(0,0,0),a.push(0,0,1),l.push(.5,.5);for(let d=0,u=3;d<=s;d++,u+=3){const p=i+d/s*n;c.x=e*Math.cos(p),c.y=e*Math.sin(p),o.push(c.x,c.y,c.z),a.push(0,0,1),h.x=(o[u]/e+1)/2,h.y=(o[u+1]/e+1)/2,l.push(h.x,h.y)}for(let d=1;d<=s;d++)r.push(d,d+1,0);this.setIndex(r),this.setAttribute("position",new Tt(o,3)),this.setAttribute("normal",new Tt(a,3)),this.setAttribute("uv",new Tt(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Zg(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Jg extends cs{constructor(e=1,s=1,i=1,n=32,r=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:s,height:i,radialSegments:n,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:l};const c=this;n=Math.floor(n),r=Math.floor(r);const h=[],d=[],u=[],p=[];let f=0;const _=[],g=i/2;let m=0;w(),o===!1&&(e>0&&y(!0),s>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new Tt(d,3)),this.setAttribute("normal",new Tt(u,3)),this.setAttribute("uv",new Tt(p,2));function w(){const b=new W,v=new W;let z=0;const x=(s-e)/i;for(let M=0;M<=r;M++){const S=[],T=M/r,I=T*(s-e)+e;for(let E=0;E<=n;E++){const O=E/n,R=O*l+a,C=Math.sin(R),k=Math.cos(R);v.x=I*C,v.y=-T*i+g,v.z=I*k,d.push(v.x,v.y,v.z),b.set(C,x,k).normalize(),u.push(b.x,b.y,b.z),p.push(O,1-T),S.push(f++)}_.push(S)}for(let M=0;M<n;M++)for(let S=0;S<r;S++){const T=_[S][M],I=_[S+1][M],E=_[S+1][M+1],O=_[S][M+1];(e>0||S!==0)&&(h.push(T,I,O),z+=3),(s>0||S!==r-1)&&(h.push(I,E,O),z+=3)}c.addGroup(m,z,0),m+=z}function y(b){const v=f,z=new tt,x=new W;let M=0;const S=b===!0?e:s,T=b===!0?1:-1;for(let E=1;E<=n;E++)d.push(0,g*T,0),u.push(0,T,0),p.push(.5,.5),f++;const I=f;for(let E=0;E<=n;E++){const R=E/n*l+a,C=Math.cos(R),k=Math.sin(R);x.x=S*k,x.y=g*T,x.z=S*C,d.push(x.x,x.y,x.z),u.push(0,T,0),z.x=C*.5+.5,z.y=k*.5*T+.5,p.push(z.x,z.y),f++}for(let E=0;E<n;E++){const O=v+E,R=I+E;b===!0?h.push(R,R+1,O):h.push(R+1,R,O),M+=3}c.addGroup(m,M,b===!0?1:2),m+=M}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Jg(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Qg extends cs{constructor(e=[],s=[],i=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:s,radius:i,detail:n};const r=[],o=[];a(n),c(i),h(),this.setAttribute("position",new Tt(r,3)),this.setAttribute("normal",new Tt(r.slice(),3)),this.setAttribute("uv",new Tt(o,2)),n===0?this.computeVertexNormals():this.normalizeNormals();function a(w){const y=new W,b=new W,v=new W;for(let z=0;z<s.length;z+=3)p(s[z+0],y),p(s[z+1],b),p(s[z+2],v),l(y,b,v,w)}function l(w,y,b,v){const z=v+1,x=[];for(let M=0;M<=z;M++){x[M]=[];const S=w.clone().lerp(b,M/z),T=y.clone().lerp(b,M/z),I=z-M;for(let E=0;E<=I;E++)E===0&&M===z?x[M][E]=S:x[M][E]=S.clone().lerp(T,E/I)}for(let M=0;M<z;M++)for(let S=0;S<2*(z-M)-1;S++){const T=Math.floor(S/2);S%2===0?(u(x[M][T+1]),u(x[M+1][T]),u(x[M][T])):(u(x[M][T+1]),u(x[M+1][T+1]),u(x[M+1][T]))}}function c(w){const y=new W;for(let b=0;b<r.length;b+=3)y.x=r[b+0],y.y=r[b+1],y.z=r[b+2],y.normalize().multiplyScalar(w),r[b+0]=y.x,r[b+1]=y.y,r[b+2]=y.z}function h(){const w=new W;for(let y=0;y<r.length;y+=3){w.x=r[y+0],w.y=r[y+1],w.z=r[y+2];const b=g(w)/2/Math.PI+.5,v=m(w)/Math.PI+.5;o.push(b,1-v)}f(),d()}function d(){for(let w=0;w<o.length;w+=6){const y=o[w+0],b=o[w+2],v=o[w+4],z=Math.max(y,b,v),x=Math.min(y,b,v);z>.9&&x<.1&&(y<.2&&(o[w+0]+=1),b<.2&&(o[w+2]+=1),v<.2&&(o[w+4]+=1))}}function u(w){r.push(w.x,w.y,w.z)}function p(w,y){const b=w*3;y.x=e[b+0],y.y=e[b+1],y.z=e[b+2]}function f(){const w=new W,y=new W,b=new W,v=new W,z=new tt,x=new tt,M=new tt;for(let S=0,T=0;S<r.length;S+=9,T+=6){w.set(r[S+0],r[S+1],r[S+2]),y.set(r[S+3],r[S+4],r[S+5]),b.set(r[S+6],r[S+7],r[S+8]),z.set(o[T+0],o[T+1]),x.set(o[T+2],o[T+3]),M.set(o[T+4],o[T+5]),v.copy(w).add(y).add(b).divideScalar(3);const I=g(v);_(z,T+0,w,I),_(x,T+2,y,I),_(M,T+4,b,I)}}function _(w,y,b,v){v<0&&w.x===1&&(o[y]=w.x-1),b.x===0&&b.z===0&&(o[y]=v/2/Math.PI+.5)}function g(w){return Math.atan2(w.z,-w.x)}function m(w){return Math.atan2(-w.y,Math.sqrt(w.x*w.x+w.z*w.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qg(e.vertices,e.indices,e.radius,e.detail)}}class e_ extends Qg{constructor(e=1,s=0){const i=(1+Math.sqrt(5))/2,n=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],r=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(n,r,e,s),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:s}}static fromJSON(e){return new e_(e.radius,e.detail)}}class Rd extends cs{constructor(e=1,s=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:s,widthSegments:i,heightSegments:n};const r=e/2,o=s/2,a=Math.floor(i),l=Math.floor(n),c=a+1,h=l+1,d=e/a,u=s/l,p=[],f=[],_=[],g=[];for(let m=0;m<h;m++){const w=m*u-o;for(let y=0;y<c;y++){const b=y*d-r;f.push(b,-w,0),_.push(0,0,1),g.push(y/a),g.push(1-m/l)}}for(let m=0;m<l;m++)for(let w=0;w<a;w++){const y=w+c*m,b=w+c*(m+1),v=w+1+c*(m+1),z=w+1+c*m;p.push(y,b,z),p.push(b,v,z)}this.setIndex(p),this.setAttribute("position",new Tt(f,3)),this.setAttribute("normal",new Tt(_,3)),this.setAttribute("uv",new Tt(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Rd(e.width,e.height,e.widthSegments,e.heightSegments)}}class kd extends cs{constructor(e=1,s=32,i=16,n=0,r=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:s,heightSegments:i,phiStart:n,phiLength:r,thetaStart:o,thetaLength:a},s=Math.max(3,Math.floor(s)),i=Math.max(2,Math.floor(i));const l=Math.min(o+a,Math.PI);let c=0;const h=[],d=new W,u=new W,p=[],f=[],_=[],g=[];for(let m=0;m<=i;m++){const w=[],y=m/i,b=o+y*a,v=e*Math.cos(b),z=Math.sqrt(e*e-v*v);let x=0;m===0&&o===0?x=.5/s:m===i&&l===Math.PI&&(x=-.5/s);for(let M=0;M<=s;M++){const S=M/s,T=n+S*r;d.x=-z*Math.cos(T),d.y=v,d.z=z*Math.sin(T),f.push(d.x,d.y,d.z),u.copy(d).normalize(),_.push(u.x,u.y,u.z),g.push(S+x,1-y),w.push(c++)}h.push(w)}for(let m=0;m<i;m++)for(let w=0;w<s;w++){const y=h[m][w+1],b=h[m][w],v=h[m+1][w],z=h[m+1][w+1];(m!==0||o>0)&&p.push(y,b,z),(m!==i-1||l<Math.PI)&&p.push(b,v,z)}this.setIndex(p),this.setAttribute("position",new Tt(f,3)),this.setAttribute("normal",new Tt(_,3)),this.setAttribute("uv",new Tt(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new kd(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function Ma(t){const e={};for(const s in t){e[s]={};for(const i in t[s]){const n=t[s][i];if(iM(n))n.isRenderTargetTexture?(Je("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[s][i]=null):e[s][i]=n.clone();else if(Array.isArray(n))if(iM(n[0])){const r=[];for(let o=0,a=n.length;o<a;o++)r[o]=n[o].clone();e[s][i]=r}else e[s][i]=n.slice();else e[s][i]=n}}return e}function qs(t){const e={};for(let s=0;s<t.length;s++){const i=Ma(t[s]);for(const n in i)e[n]=i[n]}return e}function iM(t){return t&&(t.isColor||t.isMatrix3||t.isMatrix4||t.isVector2||t.isVector3||t.isVector4||t.isTexture||t.isQuaternion)}function QG(t){const e=[];for(let s=0;s<t.length;s++)e.push(t[s].clone());return e}function NS(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:bt.workingColorSpace}const eP={clone:Ma,merge:qs};var tP=`void main() {
106
106
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
107
107
  }`,sP=`void main() {
108
108
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
@@ -4340,17 +4340,17 @@ void main() {
4340
4340
  }`;function ZS(t,e){const s=performance.now();return new is({uniforms:{time:{value:s},opacity:{value:e.opacity},born:{value:s},cycle:{value:t}},vertexShader:xF,fragmentShader:OF,transparent:!0,depthWrite:!e.additive,...e.additive?{blending:Rr}:{}})}function JS(t,e,s){const i=e.length,n=new Float32Array(i*2),r=new Float32Array(i*2),o=new Float32Array(i*2);for(let a=0;a<i;a++)n[a*2]=e[a]??0,n[a*2+1]=e[a]??0,r[a*2]=s[a]??0,r[a*2+1]=s[a]??0,o[a*2+1]=1;t.setAttribute("aMode",new Tt(n,1)),t.setAttribute("aStart",new Tt(r,1)),t.setAttribute("aAlong",new Tt(o,1))}let Xu=null;function nm(){return Xu===null&&(Xu=new Jg(1,1,1,10,1,!0)),Xu}function EF(t,e){const s=performance.now(),i=new is({uniforms:{time:{value:s},opacity:{value:1},born:{value:s},cycle:{value:e}},vertexShader:KS,fragmentShader:XS,transparent:!0}),n=nm().clone(),r=new Float32Array(t.length*3),o=new Float32Array(t.length),a=new Float32Array(t.length),l=new Yg(n,i,t.length),c=new W(0,1,0),h=new Zt;return t.forEach((d,u)=>{const p=d.to.clone().sub(d.from),f=p.length();h.position.copy(d.from).addScaledVector(p,.5),h.quaternion.setFromUnitVectors(c,f>0?p.divideScalar(f):c),h.scale.set(d.width,f,d.width),h.updateMatrix(),l.setMatrixAt(u,h.matrix),r.set([d.color.r,d.color.g,d.color.b],u*3),o[u]=d.mode,a[u]=d.start}),n.setAttribute("aColor",new Sr(r,3)),n.setAttribute("aMode",new Sr(o,1)),n.setAttribute("aStart",new Sr(a,1)),l.instanceMatrix.needsUpdate=!0,l.frustumCulled=!1,l}function AF(t,e,s){const i=new Float32Array(t.length*6),n=new Float32Array(t.length*6);t.forEach((a,l)=>{i.set([a.from.x,a.from.y,a.from.z,a.to.x,a.to.y,a.to.z],l*6);const c=a.color.r*s.tint,h=a.color.g*s.tint,d=a.color.b*s.tint;n.set([c,h,d,c,h,d],l*6)});const r=new cs;r.setAttribute("position",new Tt(i,3)),r.setAttribute("aColor",new Tt(n,3)),JS(r,t.map(a=>a.mode),t.map(a=>a.start));const o=new Zp(r,ZS(e,s));return o.frustumCulled=!1,o}class TF{parent;stars=[];index=new Map;nebulaList=[];materials=[];layers=[];threads=null;threadMaterial=null;nebulaSprites=new Map;starsById=null;starsTouched=!1;threadsTouched=!1;constructor(e){this.parent=e}count(){return this.stars.length}list(){return this.stars}entry(e){const s=this.index.get(e);return s===void 0?void 0:this.stars[s]}ids(){return this.index.keys()}nebulae(){return this.nebulaList}draw(e,s,i,n){for(const r of e)this.index.has(r.id)||this.index.set(r.id,this.stars.length),this.stars.push(r);this.starsById=null;for(const[r,o]of[[!1,!1],[!0,!1],[!1,!0]]){const a=e.filter(c=>c.ring===!0===o&&(o||c.ember===r));if(a.length===0)continue;const l=yF(a,r,this.layers.length,s,o);this.layers.push({alpha:l.alpha,base:l.base,flash:l.flash}),this.parent.add(l.points),this.materials.push(l.material)}this.scale_update(i,n)}scale_update(e,s){if(this.materials.length===0)return;const i=zF(e,s);for(const n of this.materials){const r=n.uniforms.scale;r!==void 0&&(r.value=i)}}threads_draw(e,s,i=[],n){if(e.length===0)return;const r=new cs;r.setAttribute("position",new Tt(e,3));const o=new Tt(s,3);if(this.threads={attribute:o,base:Float32Array.from(s),ends:i},n===void 0){r.setAttribute("color",o),this.parent.add(new Zp(r,new Cd({vertexColors:!0,transparent:!0,opacity:sm,blending:Rr,depthWrite:!1})));return}r.setAttribute("aColor",o),JS(r,n.modes,n.starts),this.threadMaterial=ZS(n.cycle,{opacity:sm,additive:!0});const a=new Zp(r,this.threadMaterial);a.frustumCulled=!1,this.parent.add(a)}frame(e){const s=this.threadMaterial?.uniforms.time;s!==void 0&&(s.value=e)}threadsCarryWave(){return this.threadMaterial!==null}nebula_add(e,s,i,n,r){const o=new Id(new Kl({map:s_(),color:n,transparent:!0,opacity:r?BM/3:BM,blending:Rr,depthWrite:!1}));o.position.copy(s),o.scale.setScalar(i*2),o.renderOrder=0,this.parent.add(o),this.nebulaList.push({id:e,position:s.clone(),radius:i}),this.nebulaSprites.set(e,{material:o.material,base:o.material.opacity})}stars_fade(e,s){for(const i of e){const n=i.layer===void 0?void 0:this.layers[i.layer];n===void 0||i.slot===void 0||(n.alpha.setX(i.slot,(n.base[i.slot]??1)*s),this.starsTouched=!0)}}threads_fade(e,s){if(this.threads===null||e.length===0)return;const i=this.threads.attribute.array,n=this.threads.base;for(const r of e)for(let o=r*6;o<r*6+6;o++)i[o]=(n[o]??0)*s;this.threadsTouched=!0}flush(){if(this.starsTouched)for(const e of this.layers)e.alpha.needsUpdate=!0;this.threadsTouched&&this.threads!==null&&(this.threads.attribute.needsUpdate=!0),this.starsTouched=!1,this.threadsTouched=!1}clear(){this.stars=[],this.index=new Map,this.nebulaList=[],this.materials=[],this.layers=[],this.threads=null,this.threadMaterial=null,this.nebulaSprites=new Map,this.starsById=null,this.starsTouched=!1,this.threadsTouched=!1}presence_set(e,s){for(const i of e){for(const r of this.stars_list(i)){const o=r.layer===void 0?void 0:this.layers[r.layer];o===void 0||r.slot===void 0||(o.alpha.setX(r.slot,(o.base[r.slot]??1)*s),this.starsTouched=!0)}const n=this.nebulaSprites.get(i);n!==void 0&&(n.material.opacity=n.base*s)}}flash_set(e,s){for(const i of this.stars_list(e)){const n=i.layer===void 0?void 0:this.layers[i.layer];n===void 0||i.slot===void 0||(n.flash.setX(i.slot,s),n.flash.needsUpdate=!0)}}threads_present(e){const s=this.threads;if(s===null||s.ends.length===0)return;const i=s.attribute.array,n=s.ends.length/2;for(let r=0;r<n;r++){const o=e(s.ends[r*2]??"")&&e(s.ends[r*2+1]??"")?1:0;for(let a=r*6;a<r*6+6;a++)i[a]=(s.base[a]??0)*o}this.threadsTouched=!0}stars_list(e){if(this.starsById===null){this.starsById=new Map;for(const s of this.stars)this.starsById.set(s.id,[...this.starsById.get(s.id)??[],s])}return this.starsById.get(e)??[]}}class IF{parent;geometries=new mF;byId=new Map;edges=[];constructor(e){this.parent=e}get map(){return this.byId}sphere_add(e,s,i,n){const r=n.flat===!0?new Zg(i,36):this.geometries.of(i),o=new lo({color:n.color,roughness:.35,metalness:.15,emissive:n.selected===!0?new Ke("#ffffff"):new Ke("#000000"),emissiveIntensity:n.selected===!0?.35:0,...n.dim===!0?{transparent:!0,opacity:wh}:{},...n.fade!==void 0?{transparent:!0,opacity:n.fade}:{}}),a=new ii(r,o);return n.flat===!0&&(o.transparent=!0,o.depthTest=!1,a.renderOrder=2),a.position.copy(s),a.userData.nodeId=e,a.userData.dim=n.dim===!0,this.parent.add(a),this.byId.set(e,a),a}halo_add(e,s,i,n,r){const o=new ii(new kd(i,24,18),new Kg({color:n,transparent:!0,opacity:r?NM*.4:NM,depthWrite:!1}));o.position.copy(s),o.renderOrder=1,o.userData.nodeId=e,o.userData.halo=!0,o.userData.dim=r,this.parent.add(o),this.byId.set(e,o)}edge_add(e,s,i,n,r,o,a=!1){const l=new cs().setFromPoints([i,n]);let c;o?(c=new Xp(l,new oP({color:r,dashSize:.25,gapSize:.18,transparent:!0,opacity:a?wh:.9})),c.computeLineDistances()):c=new Xp(l,new Cd({color:r,transparent:!0,opacity:a?wh:.75})),this.parent.add(c),this.edges.push({line:c,fromId:e,toId:s,dashed:o})}edges_follow(){for(const e of this.edges){const s=this.byId.get(e.fromId),i=this.byId.get(e.toId);s===void 0||i===void 0||(e.line.geometry.setFromPoints([s.position,i.position]),e.dashed&&e.line.computeLineDistances())}}recolor(e,s){const i=this.byId.get(e);i===void 0||!(i.material instanceof lo)||(i.material.color=s,delete i.userData.lampBase)}select(e){for(const[s,i]of this.byId){if(!(i.material instanceof lo))continue;const n=s===e;i.material.emissive.set(n?"#ffffff":"#000000"),i.material.emissiveIntensity=n?.35:0}}remove(e){this.parent.remove(e),e.material instanceof qn&&e.material.dispose();const s=e.userData.nodeId;typeof s=="string"&&this.byId.get(s)===e&&this.byId.delete(s)}clear(){this.byId=new Map,this.edges=[]}dispose(){this.geometries.dispose()}}function i_(t){return t==="live"?1:t==="done"||t==="failed"?2:0}class DF{host;sets=[];materials=[];glows=new Map;stale=!1;census=0;censusLines=0;constructor(e){this.host=e}materialCount(){return this.materials.length}censusCount(){return this.census}censusLineCount(){return this.censusLines}holds(e){return this.sets.some(s=>s.members.has(e))}stale_mark(){this.stale=!0}build(e,s,i){const n=e.mix,r=this.host.palette(),o=[];for(const z of s){const x=this.host.node(z);if(x!==void 0){for(const M of x.parents){const S=this.host.node(M);S!==void 0&&i.has(M)&&o.push({fromId:M,from:S,toId:z,to:x,join:!1})}for(const M of x.joins){const S=this.host.node(M);S!==void 0&&i.has(M)&&o.push({fromId:M,from:S,toId:z,to:x,join:!0})}}}if(o.length===0)return;const a=new Map,l=(z,x=new Set)=>{const M=a.get(z);if(M!==void 0)return M;if(x.has(z))return 0;x.add(z);const S=this.host.node(z),T=S===void 0?[]:[...S.parents,...S.joins].filter(E=>i.has(E)),I=T.length===0?0:1+Math.max(...T.map(E=>l(E,x)));return a.set(z,I),I},c=performance.now(),h=new Float32Array(o.length*3),d=new Float32Array(o.length),u=new Float32Array(o.length),p=r.edge.clone().lerp(new Ke("#ffffff"),.45),f=new Yg(nm(),new is({uniforms:{time:{value:c},opacity:{value:n},born:{value:c},cycle:{value:1}},vertexShader:KS,fragmentShader:XS,transparent:!0}),o.length),_=new W(0,1,0),g=new Zt;let m=0;const w=[],y=new Map,b=new Set;o.forEach(({fromId:z,from:x,toId:M,to:S,join:T},I)=>{const E=S.position.clone().sub(x.position),O=E.length(),R=Math.max(.06,Math.min(x.radius,S.radius)*.34)*(e.thickness??1);g.position.copy(x.position).addScaledVector(E,.5),g.quaternion.setFromUnitVectors(_,O>0?E.clone().divideScalar(O):_),g.scale.set(R,O,R),g.updateMatrix(),f.setMatrixAt(I,g.matrix),w.push({from:z,to:M,width:R});const C=S.state==="failed"?r.error:T?r.join:p;h.set([C.r,C.g,C.b],I*3),d[I]=i_(S.state);const k=l(z);if(m=Math.max(m,k),u[I]=k*Gn,d[I]===1&&b.add(M),d[I]===2){const B=u[I]+Vi/2;y.set(M,Math.min(y.get(M)??1/0,B)),k===0&&y.set(z,0)}}),f.instanceMatrix.needsUpdate=!0;const v=nm().clone();if(v.setAttribute("aColor",new Sr(h,3)),v.setAttribute("aMode",new Sr(d,1)),v.setAttribute("aStart",new Sr(u,1)),f.geometry=v,f.frustumCulled=!1,this.host.parent.add(f),e.tubes=f,f.material instanceof is){this.materials.push(f.material);const z=f.material.uniforms.cycle;z!==void 0&&(z.value=(m+1)*Gn+Vi/2+yh)}this.sets.push({mesh:f,edges:w,lamps:y,blinks:b,owner:e,entries:s,members:i})}census_build(e,s){if(e.length===0)return;const i=EF(e,(s+1)*Gn+Vi/2+yh);this.host.parent.add(i),i.material instanceof is&&this.materials.push(i.material),this.census=e.length}censusLines_build(e,s,i){if(e.length===0)return;const n=AF(e,(s+1)*Gn+Vi/2+yh,i);this.host.parent.add(n),n.material instanceof is&&this.materials.push(n.material),this.censusLines=e.length}frame(e){if(this.materials.length!==0){for(const s of this.materials){const i=s.uniforms.time;i!==void 0&&(i.value=e)}this.stale&&this.restatus(),this.lamps_animate(e)}}follow(){const e=new W(0,1,0),s=new Zt;for(const{mesh:i,edges:n}of this.sets)n.forEach(({from:r,to:o,width:a},l)=>{const c=this.host.sphere(r),h=this.host.sphere(o);if(c===void 0||h===void 0)return;const d=h.position.clone().sub(c.position),u=d.length();s.position.copy(c.position).addScaledVector(d,.5),s.quaternion.setFromUnitVectors(e,u>0?d.clone().divideScalar(u):e),s.scale.set(a,u,a),s.updateMatrix(),i.setMatrixAt(l,s.matrix)}),i.instanceMatrix.needsUpdate=!0}release(e){if(this.host.parent.remove(e),this.sets=this.sets.filter(s=>s.mesh!==e),e.geometry.dispose(),e.material instanceof is){const s=e.material;this.materials=this.materials.filter(i=>i!==s),s.dispose()}}clear(){this.materials=[],this.census=0,this.censusLines=0,this.sets=[];for(const e of this.glows.values())e.material.dispose();this.glows=new Map}restatus(){this.stale=!1;const e=this.sets;this.sets=[];for(const s of e){if(this.host.parent.remove(s.mesh),s.mesh.geometry.dispose(),s.mesh.material instanceof is){const i=s.mesh.material;this.materials=this.materials.filter(n=>n!==i),i.dispose()}s.owner.tubes=null,this.build(s.owner,s.entries,s.members)}this.follow()}lamps_animate(e){const s=new Set;for(const{mesh:i,lamps:n,blinks:r}of this.sets){if(n.size===0&&r.size===0||!(i.material instanceof is))continue;const o=Number(i.material.uniforms.born?.value??e),a=Number(i.material.uniforms.cycle?.value??1),l=((e-o)%a+a)%a,c=Math.min(1,Math.max(0,(a-l)/fF));for(const[d,u]of n){const p=l-u;this.lamp_paint(d,p<0?0:c,p>=0&&p<Hc?p/Hc:-1,s)}const h=(e%Vi+Vi)%Vi;for(const d of r){if(n.has(d))continue;const u=Math.max(0,1-h/(Vi*.8));this.lamp_paint(d,u*u,h<Hc?h/Hc:-1,s)}}for(const[i,n]of this.glows)s.has(i)||(n.visible=!1,this.host.sphere(i)===void 0&&(this.host.parent.remove(n),n.material.dispose(),this.glows.delete(i)))}lamp_paint(e,s,i,n){const r=this.host.sphere(e);if(r===void 0||!(r.material instanceof lo))return;let o=r.userData.lampBase;o instanceof Ke||(o=r.material.color.clone(),r.userData.lampBase=o);const a=i<0?0:(1-i)**2;if(r.material.color.copy(o).multiplyScalar(GM+(1-GM)*Math.max(s,a)).lerp(im,Math.min(1,.22*s+.7*a)),i<0)return;let l=this.glows.get(e);l===void 0&&(l=new Id(new Kl({map:s_(),color:o.clone().lerp(im,.35),transparent:!0,blending:Rr,depthWrite:!1})),this.glows.set(e,l),this.host.parent.add(l));const c=r.geometry.parameters?.radius??.55,h=1-(1-i)**3;l.position.copy(r.position),l.scale.setScalar(c*(2+VS*h)*r.scale.x),l.material.opacity=.9*(1-i)**1.5,l.visible=!0,n.add(e)}}class CF{host;groups=new Map;lastAt=0;constructor(e){this.host=e}size(){return this.groups.size}solidCount(){let e=0;for(const s of this.groups.values())s.mix>0&&(e+=1);return e}gather(e,s){for(const i of e){if(i.dim)continue;const n=s(i.id);if(n===null)continue;let r=this.groups.get(n);r===void 0&&(r={entries:[],center:new W,maxRadius:0,mix:0,target:0,meshes:[],tubes:null,threadSegments:[]},this.groups.set(n,r)),r.entries.push(i),r.maxRadius=Math.max(r.maxRadius,i.radius)}for(const i of this.groups.values()){for(const n of i.entries)i.center.add(n.position);i.center.divideScalar(Math.max(1,i.entries.length))}}thread_note(e,s){this.groups.get(e)?.threadSegments.push(s)}step(e,s,i){if(this.groups.size===0)return;const n=this.lastAt===0?0:Math.min(100,i-this.lastAt);this.lastAt=i;const r=e.elements;for(const o of this.groups.values()){let a=1/0;for(const h of o.entries){const d=h.position,u=-(r[2]*d.x+r[6]*d.y+r[10]*d.z+r[14]);u>0&&u<a&&(a=u)}const l=a===1/0?0:2*o.maxRadius*s/a;if(o.target===0&&l>hF?o.target=1:o.target===1&&l<dF&&(o.target=0),o.mix===o.target)continue;const c=n===0?1:n/uF;o.mix=o.target>o.mix?Math.min(1,o.mix+c):Math.max(0,o.mix-c),o.mix>0&&o.meshes.length===0&&this.solid_build(o);for(const h of o.meshes)h.material instanceof lo&&(h.material.opacity=o.mix);if(o.tubes!==null&&o.tubes.material instanceof is){const h=o.tubes.material.uniforms.opacity;h!==void 0&&(h.value=o.mix)}this.host.stars.stars_fade(o.entries,1-o.mix),this.host.stars.threads_fade(o.threadSegments,1-o.mix),o.mix===0&&this.solid_release(o)}this.host.stars.flush()}clear(){this.groups=new Map}solid_build(e){const s=new Set(e.entries.map(i=>i.id));for(const i of e.entries){const n=this.host.look(i.id);n!==void 0&&e.meshes.push(this.host.spheres.sphere_add(i.id,n.position,n.radius,{color:n.color,fade:e.mix}))}this.host.tubes.build(e,e.entries.map(i=>i.id),s)}solid_release(e){for(const s of e.meshes)this.host.spheres.remove(s);e.tubes!==null&&(this.host.tubes.release(e.tubes),e.tubes=null),e.meshes=[]}}const RF=400;function kF(t){return t<=2e3?6:t<=2e4?3:1}class NF{host;mesh=null;base=null;memberIds=[];memberPositions=[];glows=[];constructor(e){this.host=e}drawn(){return this.mesh!==null}ids(){return this.memberIds}positions(){return this.memberPositions}build(e,s,i){let n=0;for(const w of e)w.ghost!==!0&&(n+=Math.max(1,w.count));const r=new e_(1,kF(n)),o=new lo({color:"#ffffff",roughness:.5,metalness:.1}),a=[],l=new Yg(r,o,s?1:n),c=new Ke,h=new Zt,d=new Map,u=new Map;let p=0,f=1;const _=new W;for(const w of e)_.add(w.position);_.divideScalar(Math.max(1,e.length));for(const w of e){if(w.ghost===!0)continue;const y=Math.max(1,w.count),b=y===1?0:w.radius*(1.6+.55*Math.cbrt(y)),v=y===1?w.radius:Math.max(.06,Math.min(w.radius*.5,2.2*b/Math.sqrt(y))),z=[];for(let x=0;x<y;x++){const M=y===1?w.position.clone():pF(x,y,b).add(w.position);z.push(M),c.set(w.color),s?a.push({id:w.id,position:M,radius:v,color:c.clone(),dim:w.dim,ember:w.ember}):(h.position.copy(M),h.scale.setScalar(v),h.updateMatrix(),l.setMatrixAt(p,h.matrix),l.setColorAt(p,c)),this.memberIds.push(w.id),this.memberPositions.push(M),p+=1,f=Math.max(f,_.distanceTo(M)+v)}d.set(w.id,z),u.set(w.id,v),!s&&e.length<=RF&&this.glow_add(w,b+v)}if(s){const w=this.host.starsView();this.host.stars.draw(a,w.pixelRatio,w.heightPx,w.fovDeg)}else l.instanceColor&&(l.instanceColor.needsUpdate=!0),this.host.parent.add(l),this.mesh=l,this.base=l.instanceColor?Float32Array.from(l.instanceColor.array):null;const{specs:g,deepest:m}=BF(e,d,u,i);return!s&&g.length>0&&g.length<=SF?this.host.tubes.census_build(g,m):g.length>0&&this.host.tubes.censusLines_build(g,m,s?{tint:1,opacity:sm,additive:!0}:{tint:1,opacity:.35,additive:!1}),{center:_,radius:f}}flare(e,s,i,n){let r=0;if(this.mesh===null||this.base===null||!this.mesh.instanceColor)return r;const o=this.mesh.instanceColor.array,a=this.base;for(let l=0;l<this.memberIds.length;l++){const c=e(this.memberIds[l]??"");if(c===void 0)continue;r=Math.max(r,c);const h=s-c,d=h>=0&&h<=n?Math.sin(h/n*Math.PI):0,u=l*3;o[u]=a[u]+(i.r-a[u])*d,o[u+1]=a[u+1]+(i.g-a[u+1])*d,o[u+2]=a[u+2]+(i.b-a[u+2])*d}this.mesh.instanceColor.needsUpdate=!0;for(const{id:l,sprite:c,reach:h}of this.glows){const d=e(l),u=d===void 0?-1:s-d,p=u>=0&&u<=n?Math.sin(u/n*Math.PI):0;c.visible=p>0,c.scale.setScalar(h*(2+VS*p)),c.material.opacity=.9*p}return r}glow_add(e,s){const i=new Id(new Kl({map:s_(),color:e.color.clone().lerp(im,.35),transparent:!0,blending:Rr,depthWrite:!1}));i.position.copy(e.position),i.visible=!1,this.host.parent.add(i),this.glows.push({id:e.id,sprite:i,reach:s})}pick(e){if(this.mesh===null)return null;const s=e.intersectObject(this.mesh)[0];return s===void 0||s.instanceId===void 0?null:(this.mesh.setColorAt(s.instanceId,new Ke("#ffffff")),this.mesh.instanceColor&&(this.mesh.instanceColor.needsUpdate=!0),this.memberIds[s.instanceId]??null)}clear(){this.mesh=null,this.base=null,this.memberIds=[],this.memberPositions=[];for(const{sprite:e}of this.glows)e.removeFromParent(),e.material.dispose();this.glows=[]}}function BF(t,e,s,i){const n=new Map(t.map(h=>[h.id,h])),r=new Map,o=(h,d=new Set)=>{const u=r.get(h);if(u!==void 0)return u;if(d.has(h))return 0;d.add(h);const p=(n.get(h)?.parents??[]).filter(_=>n.has(_)),f=p.length===0?0:1+Math.max(...p.map(_=>o(_,d)));return r.set(h,f),f},a=i.edge.clone().lerp(new Ke("#ffffff"),.45),l=[];let c=0;for(const h of t){const d=e.get(h.id)??[];for(const u of h.parents){const p=e.get(u);if(!p||p.length===0)continue;const f=Math.max(.02,Math.min(s.get(h.id)??.1,s.get(u)??.1)*.34),_=o(u)*Gn;c=Math.max(c,o(u));for(let g=0;g<d.length;g++){const m=d[g],w=p.length===d.length?p[g]:p[g%p.length];w===void 0||m===void 0||l.push({from:w,to:m,width:f,color:h.state==="failed"?i.error:a,mode:i_(h.state),start:_})}}}return{specs:l,deepest:c}}const LM=.028,GF=.25,PF="rgba(0, 0, 0, 0.7)",Za=48;class LF{parent;captions=new Map;shown=!0;constructor(e){this.parent=e}count(){return this.captions.size}caption_add(e,s,i,n,r,o,a=0){const l=document.createElement("canvas"),c=l.getContext("2d"),h=`600 ${Za}px sans-serif`;let d=s.length*Za*.6;if(c!==null&&(c.font=h,d=Math.ceil(c.measureText(s).width)),l.width=Math.max(1,d+Za),l.height=Math.round(Za*1.5),c!==null){c.font=h,c.textBaseline="middle";const _=l.height/4;c.fillStyle=PF,c.beginPath(),c.roundRect(0,0,l.width,l.height,_),c.fill(),c.fillStyle=`#${r.getHexString()}`,c.fillText(s,Za/2,l.height/2)}const u=new RS(l),p=new Kl({map:u,transparent:!0,depthWrite:!1,depthTest:!1,sizeAttenuation:!1,opacity:o?GF:.9}),f=new Id(p);f.scale.set(LM*(l.width/l.height),LM,1),f.center.set(.5,0),f.position.set(i.x,i.y+n,i.z),f.renderOrder=4,f.visible=this.shown,this.parent.add(f),this.captions.get(e)?.texture.dispose(),this.captions.set(e,{sprite:f,texture:u,rank:a})}declutter(e){if(!this.shown)return 0;const s=[...this.captions.values()].sort((a,l)=>l.rank-a.rank),i=[],n=new W,r=e.projectionMatrix.elements[0]??1,o=e.projectionMatrix.elements[5]??1;for(const a of s){if(a.sprite.getWorldPosition(n).project(e),n.z>1){a.sprite.visible=!1;continue}const l=a.sprite.scale.x*r/2,c={left:n.x-l,right:n.x+l,bottom:n.y,top:n.y+a.sprite.scale.y*o},h=i.some(d=>c.left<d.right&&d.left<c.right&&c.bottom<d.top&&d.bottom<c.top);a.sprite.visible=!h,h||i.push(c)}return i.length}shown_set(e){if(this.shown=e,!e)for(const s of this.captions.values())s.sprite.visible=!1}shown_get(){return this.shown}clear(){for(const e of this.captions.values())e.texture.dispose();this.captions=new Map}}const WF=.0022,FF=.006,UF=.0035,$F=1e4,WM=700,FM=new W(0,1,0),jF={minDistance:8,margin:1.15,stance:"axis",farFloor:200,farScale:2};function HF(t){return t*t*(3-2*t)}class VF{camera;world;clock;focus=new W;flight=null;home=null;holding=!1;touched=!1;spinIdleUntil=0;tumbleAxis=new W(0,1,0);tumblePhase;constructor(e,s,i=Date.now,n=Math.random()*Math.PI*2){this.camera=e,this.world=s,this.clock=i,this.tumblePhase=n}flying(){return this.flight!==null}holding_get(){return this.holding}touched_get(){return this.touched}touch_note(){this.touched=!0}spin_pause(){this.spinIdleUntil=this.clock()+$F}eyeDistance(){return this.camera.position.distanceTo(this.focus)}turn_about(e,s){const i=new vo().setFromAxisAngle(e,s);this.world.position.sub(this.focus).applyQuaternion(i).add(this.focus),this.world.quaternion.premultiply(i)}orbit(e,s){this.turn_about(FM,e*.005),this.turn_about(new W().setFromMatrixColumn(this.camera.matrixWorld,0).normalize(),s*.005)}dolly(e,s=!1){if(this.spin_pause(),this.touched=!0,s){const o=this.camera.getWorldDirection(new W),a=Math.max(4,this.camera.position.length())*.0012;this.camera.position.addScaledVector(o,-e*a);return}const i=this.camera.position.clone().sub(this.focus),n=i.length(),r=Math.min(Math.max(n*Math.exp(e*.001),1.5),Math.max(40,this.camera.far*.45));this.camera.position.copy(this.focus).addScaledVector(i,r/Math.max(1e-4,n))}pan(e,s){const i=this.camera.position.distanceTo(this.focus)*.0016,n=new W().setFromMatrixColumn(this.camera.matrixWorld,0).multiplyScalar(-e*i).add(new W().setFromMatrixColumn(this.camera.matrixWorld,1).multiplyScalar(s*i));this.camera.position.add(n),this.focus.add(n)}frame(e,s,i={}){const n={...jF,...i},r=Math.max(n.minDistance,this.fitDistance(s)*n.margin);this.world.position.copy(e).applyQuaternion(this.world.quaternion).negate(),this.focus.set(0,0,0),n.stance==="threeQuarter"?this.camera.position.set(r*.5,r*.4,r*.85):this.camera.position.set(0,0,r),this.camera.far=Math.max(n.farFloor,(r+s)*n.farScale),this.camera.updateProjectionMatrix(),this.camera.lookAt(0,0,0)}touch_clear(){this.touched=!1}flyToFit(e,s,i,n=1,r=1.15){if(e.length===0){i();return}let o=0;const a=new W;for(const u of e)a.add(u.position),o=Math.max(o,u.radius);a.divideScalar(e.length);const l=e.map(u=>a.distanceTo(u.position)).sort((u,p)=>u-p),c=Math.max(1,Math.min(l.length,Math.ceil(l.length*Math.min(1,Math.max(.1,n))))),h=Math.max(1,(l[c-1]??1)+o),d=Math.max(3,this.fitDistance(h)*r);this.camera.far=Math.max(this.camera.far,(d+h)*2),this.camera.updateProjectionMatrix(),this.flyAlongLine(a,d,s,i)}flyToward(e,s,i,n){this.flyAlongLine(e.position,Math.max(s,e.radius*4),i,n)}flyInto(e,s){if(this.flight!==null||this.holding)return!1;this.holding=!0,this.home={position:this.camera.position.clone(),quaternion:this.camera.quaternion.clone()};const i=e.clone().add(this.camera.position.clone().sub(e).normalize().multiplyScalar(.4));return this.flight_begin(i,this.aim_compute(this.camera.position,e),WM,s),!0}flyBack(e){const s=this.home;if(s===null){this.holding=!1,e();return}this.flight_begin(s.position.clone(),s.quaternion.clone(),WM,()=>{this.home=null,this.holding=!1,this.spin_pause(),e()})}flight_step(){const e=this.flight;if(e===null)return;const s=Math.min(1,(this.clock()-e.startedAt)/e.durationMs),i=HF(s);this.camera.position.lerpVectors(e.fromPos,e.toPos,i),this.camera.quaternion.slerpQuaternions(e.fromQuat,e.toQuat,i),s>=1&&(this.flight=null,e.onDone())}spin_step(e){!e||this.holding||this.flight!==null||this.clock()<this.spinIdleUntil||this.turn_about(FM,WF)}tumble_step(){this.tumblePhase+=UF,this.tumbleAxis.set(Math.sin(this.tumblePhase*.7),Math.cos(this.tumblePhase*.4)+.6,Math.sin(this.tumblePhase*.3)*.8).normalize(),this.world.rotateOnWorldAxis(this.tumbleAxis,FF)}fitDistance(e){const s=this.camera.fov*Math.PI/180,i=e/Math.tan(s/2),n=e/(Math.tan(s/2)*Math.max(.1,this.camera.aspect));return Math.max(i,n)}aim_compute(e,s){const i=this.camera.clone();return i.position.copy(e),i.lookAt(s),i.quaternion.clone()}flyAlongLine(e,s,i,n){const r=this.camera.position.clone().sub(e);r.lengthSq()<1e-4&&r.set(0,0,1),r.normalize();const o=e.clone().add(r.multiplyScalar(s));this.focus.copy(e),this.flight_begin(o,this.aim_compute(o,e),i,n)}flight_begin(e,s,i,n){this.flight={fromPos:this.camera.position.clone(),toPos:e,fromQuat:this.camera.quaternion.clone(),toQuat:s,startedAt:this.clock(),durationMs:i,onDone:n}}}const QS=4,qF=350,KF=30,YF=600,XF=400;class ZF{element;rig;target;mode;clock;touches=new Map;pinch=null;gestureHeld=!1;lastTap=null;kind="mouse";tapActivatedAt=0;suppressClick=!1;viewDrag=null;grabbing=!1;over=!1;detachers=[];constructor(e,s,i,n,r=Date.now){this.element=e,this.rig=s,this.target=i,this.mode=n,this.clock=r,e.style.touchAction="none",this.listen("click",o=>this.click_handle(o)),this.listen("dblclick",o=>{this.clock()-this.tapActivatedAt<YF||this.target.tap(o,"activate")}),this.listen("pointerdown",o=>this.down_handle(o)),this.listen("pointerup",o=>this.up_handle(o)),this.listen("pointercancel",o=>this.up_handle(o)),this.listen("pointermove",o=>this.move_handle(o)),this.listen("pointerleave",o=>{this.over=!1,this.target.leave(o)}),this.listen("wheel",o=>{o.preventDefault(),this.rig.dolly(o.deltaY,this.mode.untethered())},{passive:!1}),this.listen("contextmenu",o=>o.preventDefault())}pointerOver(){return this.over}pressKind(){return this.kind}fingersDown(){return this.touches.size}detach(){for(const e of this.detachers.splice(0))e()}listen(e,s,i){this.element.addEventListener(e,s,i),this.detachers.push(()=>this.element.removeEventListener(e,s,i))}click_handle(e){if(this.suppressClick){this.suppressClick=!1;return}if(this.kind==="touch"){const s=this.clock(),i=this.lastTap;if(i!==null&&s-i.at<=qF&&Math.hypot(e.clientX-i.x,e.clientY-i.y)<=KF){this.lastTap=null,this.tapActivatedAt=s,this.target.tap(e,"activate");return}this.lastTap={at:s,x:e.clientX,y:e.clientY}}this.target.tap(e,"select")}down_handle(e){if(this.kind=e.pointerType,e.pointerType==="touch"){if(e.isPrimary&&(this.touches.clear(),this.pinch=null,this.gestureHeld=!1),this.touches.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.touches.size===2){this.gesture_begin();return}if(this.touches.size>2||this.gestureHeld)return;this.press(e),this.hover(e);return}this.press(e)}up_handle(e){if(e.pointerType==="touch"&&(this.touches.delete(e.pointerId),this.touches.size<2&&(this.pinch=null),this.touches.size===0&&this.gestureHeld)){this.gestureHeld=!1,this.suppressClick=!0,setTimeout(()=>{this.suppressClick=!1},XF),this.release(),this.target.gesture_end?.();return}this.release()}move_handle(e){if(e.pointerType==="touch"&&this.touches.has(e.pointerId)){if(this.touches.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.pinch!==null){this.gesture_move();return}if(this.gestureHeld)return}this.grabbing?this.target.grab_move(e):this.viewDrag!==null?this.view_move(e):this.hover(e)}hover(e){this.over=!0,this.target.hover(e)}press(e){if(!(this.rig.holding_get()||this.rig.flying())){this.rig.spin_pause(),this.target.grab_begin(e)?this.grabbing=!0:this.viewDrag={lastX:e.clientX,lastY:e.clientY,startX:e.clientX,startY:e.clientY,pan:e.shiftKey||e.button===2||e.button===1,moved:!1};try{this.element.setPointerCapture(e.pointerId)}catch{}this.target.tip_hide()}}release(){this.viewDrag!==null&&(this.viewDrag.moved&&(this.suppressClick=!0),this.viewDrag=null,this.rig.spin_pause()),this.grabbing&&(this.grabbing=!1,this.rig.spin_pause(),this.target.grab_end()&&(this.suppressClick=!0))}view_move(e){const s=this.viewDrag;if(s===null)return;this.rig.spin_pause();const i=e.clientX-s.lastX,n=e.clientY-s.lastY;s.lastX=e.clientX,s.lastY=e.clientY,!s.moved&&Math.abs(e.clientX-s.startX)+Math.abs(e.clientY-s.startY)>QS&&(s.moved=!0,this.rig.touch_note()),s.moved&&(s.pan||this.mode.flat()?this.rig.pan(i,n):this.rig.orbit(i,n))}fingers_read(){const[e,s]=[...this.touches.values()];return e===void 0||s===void 0?null:{spread:Math.hypot(e.x-s.x,e.y-s.y),midX:(e.x+s.x)/2,midY:(e.y+s.y)/2}}gesture_begin(){this.release(),this.gestureHeld=!0,this.pinch=this.fingers_read(),this.rig.spin_pause(),this.target.tip_hide()}gesture_move(){const e=this.fingers_read();e===null||this.pinch===null||(e.spread>0&&this.pinch.spread>0&&this.rig.dolly(Math.log(this.pinch.spread/e.spread)/.001,this.mode.untethered()),(this.mode.flat()||!this.mode.untethered())&&this.rig.pan(e.midX-this.pinch.midX,e.midY-this.pinch.midY),this.pinch=e)}}const JF=14,QF=4;class eU{camera;world;element;sources;starGlow;raycaster=new fP;constructor(e,s,i,n,r){this.camera=e,this.world=s,this.element=i,this.sources=n,this.starGlow=r}ray_aim(e){const s=this.element.getBoundingClientRect(),i=new tt((e.clientX-s.left)/s.width*2-1,-((e.clientY-s.top)/s.height)*2+1);return this.world.updateMatrixWorld(!0),this.raycaster.setFromCamera(i,this.camera),this.raycaster}mesh_under(e){const s=this.ray_aim(e).intersectObjects([...this.sources.meshes()]).filter(r=>r.object.userData.dim!==!0),n=(s.find(r=>r.object.userData.halo!==!0)??s[0])?.object;return n instanceof ii?n:null}meshNode_under(e){const s=this.mesh_under(e)?.userData.nodeId;return typeof s=="string"?s:null}node_under(e,s){const i=this.meshNode_under(e);if(i!==null)return i;const n=this.sources.census();return n!==null?n.pick(this.ray_aim(e)):this.star_under(e,s)}star_under(e,s){const i=this.sources.stars(),n=this.sources.nebulae(),r=this.element.getBoundingClientRect(),o=e.clientX-r.left,a=e.clientY-r.top;this.world.updateMatrixWorld(!0),this.camera.updateMatrixWorld();const l=r.height/(2*Math.tan(this.camera.fov*Math.PI/360)),c=new Ot().multiplyMatrices(this.camera.matrixWorldInverse,this.world.matrixWorld),d=new Ot().multiplyMatrices(this.camera.projectionMatrix,c).elements,u=c.elements,p=m=>{const w=-(u[2]*m.x+u[6]*m.y+u[10]*m.z+u[14]);if(w<=0)return null;const y=d[3]*m.x+d[7]*m.y+d[11]*m.z+d[15],b=(d[0]*m.x+d[4]*m.y+d[8]*m.z+d[12])/y,v=(d[1]*m.x+d[5]*m.y+d[9]*m.z+d[13])/y;return{x:(b+1)/2*r.width,y:(1-v)/2*r.height,depth:w}},f=s?JF:QF;let _=null,g=1/0;for(const m of i){if(m.dim)continue;const w=p(m.position);if(w===null)continue;const y=Math.max(f,this.starGlow*m.radius*l/w.depth),b=Math.hypot(w.x-o,w.y-a);if(b>y)continue;const v=b/y;v<g&&(g=v,_=m.id)}if(_!==null)return _;for(const m of n){const w=p(m.position);if(w!==null&&Math.hypot(w.x-o,w.y-a)<=m.radius*l/w.depth)return m.id}return null}}const tU=3e4,sU=900;class iU{clock;order;first;last;shown=0;moment;speed=1;running=!1;lastWall;flashes=new Map;constructor(e,s=Date.now){this.clock=s,this.order=[...e].map(([i,n])=>({id:i,at:n})).sort((i,n)=>i.at-n.at||(i.id<n.id?-1:1)),this.first=this.order[0]?.at??0,this.last=this.order[this.order.length-1]?.at??0,this.moment=this.first,this.lastWall=s()}span(){return[this.first,this.last]}ids(){return this.order.map(e=>e.id)}playing(){return this.running}at(){return this.moment}play(e=this.speed){this.speed=Math.max(.05,e),this.moment>=this.last&&this.shown>=this.order.length&&this.seek(this.first),this.running=!0,this.lastWall=this.clock()}pause(){this.running=!1}seek(e){this.moment=Math.max(this.first,Math.min(this.last,e));const s=[],i=[];for(;this.shown<this.order.length&&this.order[this.shown].at<=this.moment;)s.push(this.order[this.shown].id),this.shown+=1;for(;this.shown>0&&this.order[this.shown-1].at>this.moment;){this.shown-=1;const n=this.order[this.shown].id;i.push(n),this.flashes.delete(n)}return{at:this.moment,arrived:s,departed:i,done:this.moment>=this.last}}step(){const e=this.clock(),s=e-this.lastWall;if(this.lastWall=e,!this.running)return{at:this.moment,arrived:[],departed:[],done:this.moment>=this.last};const i=(this.last-this.first)/tU*this.speed,n=this.seek(i>0?this.moment+s*i:this.last);for(const r of n.arrived)this.flashes.set(r,e);return n.done&&(this.running=!1),n}flashing(){const e=this.clock(),s=new Map;for(const[i,n]of this.flashes){const r=(e-n)/sU;r>=1?(this.flashes.delete(i),s.set(i,0)):s.set(i,1-r)}return s}}function nU(t){const e=new Set(t.map(a=>a.id)),s=a=>!a.parentIds.some(l=>e.has(l)),i=t.filter(s),n=t.filter(a=>!s(a));if(i.length===0||n.length===0)return!1;const r=Math.min(...i.map(a=>a.y)),o=Math.max(...n.map(a=>a.y));return r>=o-1e-6}function rU(t,e){const s=new Set(t.filter(r=>r.ghost===!0||r.halo===!0).map(r=>r.id)),i=[];let n=null;for(const r of t){if(s.has(r.id))continue;const o=e.get(r.id);if(o!==void 0)for(const a of r.parentIds){if(s.has(a))continue;const l=e.get(a);if(l===void 0)continue;const c=Math.hypot(o.x-l.x,o.y-l.y,o.z-l.z);i.push(c),(n===null||c>n.length)&&(n={length:c,from:a,to:r.id})}}return i.length===0||n===null?{}:(i.sort((r,o)=>r-o),{edgeMedian:(i[Math.floor(i.length/2)]??0).toFixed(1),edgeLongest:`${n.length.toFixed(1)}(${n.from}->${n.to})`})}const oU=90*400,aU=12;function e1(t){const e={id:t.id,parents:[...t.parentIds,...t.joinParentIds]};return t.metric!==void 0&&(e.metric=t.metric),e}function lU(t){const e=kg(t.map(s=>{const i={id:s.id,parentIds:s.parentIds};return s.metric!==void 0&&(i.metric=s.metric),i}));return t.map((s,i)=>{const n=e[i];return{node:s,position:new W(...n?.position??[0,0,0]),radius:n?.radius??Bt}})}function t1(t){return kz(t.map(e1))}function s1(t,e=3,s=new Map,i=Dr,n=new Set){const r=new Map([...s].map(([a,l])=>[a,[l.x,l.y,l.z]])),o=Nz(t.map(e1),e,r,i,n);return{total:o.total,moving:o.moving,step:o.step,place:()=>o.place().map((a,l)=>({node:t[l],position:new W(...a.position),radius:a.radius}))}}function cU(t,e=3,s=new Map,i=Dr,n=new Set){const r=s1(t,e,s,i,n);return r.step(r.total),r.place()}function hU(t,e,s){const i=new Map(t.map(a=>[a.node.id,a])),n=new Map;for(const a of t)for(const l of a.node.parentIds)n.set(l,[...n.get(l)??[],a]);const r=a=>{const l=n.get(a)??[];if(l.length===0)return null;const c=new W;for(const h of l)c.add(h.position);return c.divideScalar(l.length)},o=[];for(const{node:a,position:l,radius:c}of t){if(a.caption!==void 0){const h=a.ghost===!0?r(a.id):null,d=h!==null?0:a.halo===!0?Yu(a.count??1):c;s.labels.caption_add(a.id,a.caption,h??l,d,e.done,a.dim===!0,a.count??1)}if(!(a.ghost===!0&&a.halo!==!0)){if(s.starring&&a.solid!==!0){if(a.halo===!0){s.stars.nebula_add(a.id,l,Yu(a.count??1),e.edge,a.dim===!0);continue}o.push({id:a.id,position:l.clone(),radius:c,color:va(a.look.paint,e).clone(),dim:a.dim===!0,ember:a.look.ember,...a.ring===!0?{ring:!0}:{}});continue}if(a.halo===!0){s.spheres.halo_add(a.id,l,Yu(a.count??1),e.edge,a.dim===!0);continue}s.spheres.sphere_add(a.id,l,c,{color:va(a.look.paint,e),dim:a.dim===!0,selected:a.id===s.selected,flat:s.flat})}}return{starred:o,byId:i}}function dU(t,e,s,i){const n=[],r=[],o=f=>!i.starring||f.node.solid===!0,a=[],l=[],c=[];let h=0;const d=new Map,u=(f,_=new Set)=>{const g=d.get(f);if(g!==void 0)return g;if(_.has(f))return 0;_.add(f);const m=e.get(f)?.node,w=m===void 0?[]:[...m.parentIds,...m.joinParentIds].filter(b=>e.get(b)?.node.ghost!==!0&&e.has(b)),y=w.length===0?0:1+Math.max(...w.map(b=>u(b,_)));return d.set(f,y),y},p=(f,_,g,m,w,y)=>{const b=m?.35:1,v=n.length/6;n.push(f.x,f.y,f.z,_.x,_.y,_.z),a.push(y,w.id),r.push(g.r*b,g.g*b,g.b*b,g.r*b,g.g*b,g.b*b);const z=m?0:i_(w.look.state),x=z===0?0:u(y);h=Math.max(h,x),l.push(z),c.push(x*Gn);const M=m||i.handoffKey===void 0?null:i.handoffKey(w);M!==null&&i.handoff.thread_note(M,v)};for(const f of t){const{node:_,position:g}=f;if(_.ghost!==!0){for(const m of _.parentIds){const w=e.get(m);if(!w||w.node.ghost===!0)continue;const y=_.dim===!0||w.node.dim===!0;o(f)&&o(w)?!i.starring&&y&&i.spheres.edge_add(m,_.id,w.position,g,s.edge,!1,y):p(w.position,g,s.edge,y,_,m)}for(const m of _.joinParentIds){const w=e.get(m);if(!w)continue;if(_.joinFaint===!0){p(w.position,g,s.join,!0,_,m);continue}const y=_.dim===!0||w.node.dim===!0;o(f)&&o(w)?!i.starring&&y&&i.spheres.edge_add(m,_.id,w.position,g,s.join,!0,y):p(w.position,g,s.join,y,_,m)}}}i.stars.threads_draw(n,r,a,{modes:l,starts:c,cycle:(h+1)*Gn+Vi/2+yh})}function uU(t,e,s,i,n){const r=t.filter(b=>e.has(b.id)),o=new Map;if(r.length===0)return o;const a=new W;for(const b of r)a.add(e.get(b.id));a.divideScalar(r.length);const l=s.clone().normalize(),c=new W().crossVectors(i,l);c.lengthSq()<1e-9&&c.set(1,0,0).cross(l),c.normalize();const h=new W().crossVectors(l,c).normalize(),d=new Map;for(const b of r){const v=e.get(b.id).clone().sub(a);d.set(b.id,new W(v.dot(c),v.dot(h),0))}const u=new Set(r.map(b=>b.id)),p=r.map(b=>({...b,parentIds:b.parentIds.filter(v=>u.has(v)),joinParentIds:b.joinParentIds.filter(v=>u.has(v))})),f=cU(p,2,d,{...n,gravity:!1}),_=new W;for(const b of f)_.add(b.position);_.divideScalar(f.length);const g=b=>Math.sqrt(b.reduce((v,z)=>v+z*z,0)/Math.max(1,b.length)),m=g(r.map(b=>e.get(b.id).distanceTo(a))),w=g(f.map(b=>Math.hypot(b.position.x-_.x,b.position.y-_.y))),y=w>1e-9&&m>1e-9?m/w:1;for(const b of f){const v=(b.position.x-_.x)*y,z=(b.position.y-_.y)*y;o.set(b.node.id,a.clone().addScaledVector(c,v).addScaledVector(h,z))}return o}class fU{restore=null;active(){return this.restore!==null}clear(){this.restore=null}set(e,s,i,n,r){if(e===null||e.length===0){if(this.restore===null)return!1;for(const[d,u]of this.restore)i.set(d,u);return this.restore=null,!0}if(this.restore!==null)return!1;const o=new Set(e),a=n.world.quaternion.clone().invert(),l=n.camera.position.clone().sub(n.focus).normalize().applyQuaternion(a),c=new W(0,1,0).applyQuaternion(n.camera.quaternion).applyQuaternion(a),h=uU(s.filter(d=>o.has(d.id)),i,l,c,r);if(h.size===0)return!1;this.restore=new Map([...h.keys()].map(d=>[d,i.get(d).clone()]));for(const[d,u]of h)i.set(d,u);return!0}}class pU{ports;constructor(e){this.ports=e}ids(){return[...this.ports.meshes().keys(),...this.ports.stars.ids()]}world_find(e){const s=this.ports.meshes().get(e);if(s!==void 0){const n=s.geometry;return n.boundingSphere===null&&n.computeBoundingSphere(),{position:s.getWorldPosition(new W),radius:n.boundingSphere?.radius??Bt}}const i=this.ports.stars.entry(e);return i!==void 0?{position:this.ports.group.localToWorld(i.position.clone()),radius:i.radius}:null}diveTarget_find(e){const s=this.ports.meshes().get(e),i=s===void 0?this.ports.census.ids().indexOf(e):-1;return s===void 0&&i<0?null:(this.ports.group.updateMatrixWorld(!0),s!==void 0?s.getWorldPosition(new W):this.ports.group.localToWorld((this.ports.census.positions()[i]??new W).clone()))}reaches_list(e){const s=new Set(e),i=[];this.ports.group.updateMatrixWorld(!0);for(const n of this.ids()){if(s.size>0&&!s.has(n))continue;const r=this.world_find(n);r!==null&&i.push(r)}return i}}function mU(t,e){return t.map(s=>{const i=s.node;return{id:i.id,position:s.position,radius:s.radius,count:Math.max(1,i.count??1),color:va(i.look.paint,e),dim:i.dim===!0,ember:i.look.ember,state:i.look.state,parents:i.parentIds,ghost:i.ghost===!0}})}function gU(t,e){return{position:t.position,radius:t.radius,color:va(t.node.look.paint,e)}}function _U(t){return{position:t.position,radius:t.radius,parents:t.node.parentIds,joins:t.node.joinFaint===!0?[]:t.node.joinParentIds,state:t.node.look.state}}function bU(t,e){return e.updateMatrixWorld(!0),t.updateMatrixWorld(),new Ot().multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)}function MU(t,e){return t/(2*Math.tan(e*Math.PI/360))}const Zu=.5;class vU{ports;busy=!1;constructor(e){this.ports=e}moving(){return this.busy}frame(e,s,i,n,r){this.busy=!0,this.ports.flyToFit(e,s,()=>{this.busy=!1,i()},n,r)}relight(e,s,i,n,r){this.busy=!0,this.ports.graph_set(e,{wave:!1,fit:!1,frozen:e.nodes.map(o=>o.id)}),r?.(),this.ports.flyToFit(s,i,()=>{this.busy=!1,n()})}unfold(e,s){this.busy=!0;const i=this.ports.positions_get(),n=wU(i,e.from),r=this.ports.random??(()=>Math.random()-.5);for(const l of e.unfolding){const c=e.placed?.[l];i[l]=c!==void 0?[n[0]+c[0],n[1]+c[1],n[2]+c[2]]:[n[0]+r()*Zu,n[1]+r()*Zu,n[2]+r()*Zu]}this.ports.positions_seed(i);const o=new Set(e.unfolding.filter(l=>e.placed?.[l]===void 0)),a=e.graph.nodes.filter(l=>!o.has(l.id)).map(l=>l.id);this.ports.graph_set(e.graph,{wave:!1,fit:!1,frozen:a,...e.physics!==void 0?{physics:e.physics}:{}}),e.drawn?.(),this.ports.flyToFit(e.frame,e.durationMs,()=>{this.busy=!1,s()},e.bulk,e.margin)}descent(e,s,i,n){this.busy=!0;const r=()=>{s().then(o=>{if(this.ports.alive()){if(o===null){this.busy=!1,n();return}this.unfold(o,i)}})};"toward"in e?this.ports.flyToward(e.toward,e.distance,e.durationMs,r):this.ports.flyToFit(e.fit,e.durationMs,r)}}function wU(t,e){for(const s of e){const i=[0,0,0];let n=0;for(const r of s){const o=t[r];o!==void 0&&(i[0]+=o[0],i[1]+=o[1],i[2]+=o[2],n+=1)}if(n>0)return[i[0]/n,i[1]/n,i[2]/n]}return[0,0,0]}const yU=1e3;class zU{workerOf;generation;worker=null;disposed=!1;constructor(e,s){this.workerOf=e,this.generation=s}dispose(){this.disposed=!0,this.worker?.terminate(),this.worker=null}run(e){const s=t1(e.nodes),i=new Map([...e.seeds].map(([h,d])=>[h,[d.x,d.y,d.z]])),n=d7(e.nodes,e.keyOf,i,e.frozen),r=yU,o=n.length;e.progress(0,r,o);const a=h=>{e.placed(e.nodes.map(d=>{const u=h[d.id]??[0,0,0];return{node:d,position:new W(u[0],u[1],u[2]),radius:s.get(d.id)??Bt}})),e.progress(r,r,o)},l=h=>e.progress(Math.min(r-1,Math.floor(h*r)),r,o);if(this.worker===null){if(this.workerOf===void 0){const h=P7(e.arrangement);if(h===void 0){console.error(`layout: no engine named ${e.arrangement}`),e.progress(r,r,o);return}a(h.run({nodes:n,physics:e.physics},l).positions);return}this.worker=this.workerOf()}const c=this.worker;c.onmessage=h=>{const d=h.data;if(!(d.generation!==this.generation()||this.disposed)){if(d.type==="progress"){l(d.fraction??0);return}if(d.type==="failed"){console.error(`layout: ${d.reason??"the engine failed"}`),e.progress(r,r,o);return}a(d.positions??{})}},c.postMessage({generation:e.generation,nodes:n,physics:e.physics,arrangement:e.arrangement})}}const Ja=700,SU=2500;function xU(t){const e=new Map,s=new Set(t.map(r=>r.id)),i=r=>r.look.waved;let n=!1;for(;!n;){n=!0;for(const r of t){if(e.has(r.id)||!i(r))continue;const o=[...r.parentIds,...r.joinParentIds].filter(l=>s.has(l));if(!o.every(l=>e.has(l)))continue;const a=o.reduce((l,c)=>Math.max(l,e.get(c)??0),-Gn);e.set(r.id,a+Gn),n=!1}}return e}class OU{ports;color=new Ke("#48d8f0");times=new Map;startAt=null;looping=!1;constructor(e){this.ports=e}start(){this.times=xU(this.ports.nodes()),this.startAt=this.times.size>0?this.now():null}loop_set(e){this.looping=e,e&&this.start()}loop_get(){return this.looping}animate(){if(this.startAt===null)return;const e=this.now()-this.startAt;let s=0;const i=this.ports.census();if(i!==null){s=i.flare(r=>this.times.get(r),e,this.color,Ja),e>s+Ja&&(this.startAt=this.renewal());return}const n=this.ports.selected();for(const[r,o]of this.times){s=Math.max(s,o);const a=this.ports.mesh(r);if(a===void 0||!(a.material instanceof lo))continue;const l=e-o,c=l>=0&&l<=Ja?Math.sin(l/Ja*Math.PI):0;a.scale.setScalar(1+c*.45),c>0?(a.material.emissive.copy(this.color),a.material.emissiveIntensity=c*1.2):(a.material.emissive.setScalar(r===n?1:0),a.material.emissiveIntensity=r===n?.35:0)}e>s+Ja&&(this.startAt=this.renewal())}now(){return(this.ports.now??Date.now)()}renewal(){return this.ports.ambient||this.looping?this.now()+SU:null}}class EU{ports;running=null;constructor(e){this.ports=e}active(){return this.running!==null}begin(e,s=1){const i=new iU(e,this.ports.now??Date.now);this.running={clock:i,arrivals:e,shown:new Set},this.ports.redraw(),this.paintAll(),i.play(s)}play(e){this.running?.clock.play(e)}pause(){this.running?.clock.pause()}seek(e){this.running!==null&&this.apply(this.running.clock.seek(e))}stop(){this.running!==null&&(this.running=null,this.ports.redraw())}state(){return this.running===null?null:{playing:this.running.clock.playing(),at:this.running.clock.at(),span:this.running.clock.span()}}step(){const e=this.running;if(e===null)return;const s=e.clock.playing(),i=e.clock.step();this.apply(i);for(const[n,r]of e.clock.flashing())this.ports.stars.flash_set(n,r);this.ports.stars.flush(),(s||i.arrived.length>0)&&this.ports.moved?.(i.at,e.clock.playing())}paintAll(){const e=this.running;if(e===null)return;const s=[...e.arrivals.keys()].filter(i=>!e.shown.has(i));this.ports.stars.presence_set(s,0),this.ports.stars.presence_set(e.shown,1),this.ports.stars.threads_present(i=>e.shown.has(i)||!e.arrivals.has(i)),this.ports.stars.flush()}apply(e){const s=this.running;if(!(s===null||e.arrived.length===0&&e.departed.length===0)){for(const i of e.arrived)s.shown.add(i);for(const i of e.departed)s.shown.delete(i),this.ports.stars.flash_set(i,0);this.ports.stars.presence_set(e.arrived,1),this.ports.stars.presence_set(e.departed,0),this.ports.stars.threads_present(i=>s.shown.has(i)||!s.arrivals.has(i)),this.ports.stars.flush()}}}class AU{ports;drag=null;pull=null;returns=[];constructor(e){this.ports=e}dragging(){return this.drag!==null}clear(){this.drag=null,this.pull=null}positions(){return this.pull?.positions()??[]}begin(e){const s=this.ports.picker.mesh_under(e),i=s?.userData.nodeId;if(s===null||typeof i!="string")return!1;const n=this.ports.camera.getWorldDirection(new W).negate();this.ports.group.updateMatrixWorld(!0);const r=new cr().setFromNormalAndCoplanarPoint(n,s.getWorldPosition(new W));return this.drag={nodeId:i,plane:r,startX:e.clientX,startY:e.clientY,moved:!1,solo:this.ports.solo(),home:s.position.clone()},!0}move(e){if(this.drag===null||(this.ports.spin_pause(),!this.drag.moved&&Math.abs(e.clientX-this.drag.startX)+Math.abs(e.clientY-this.drag.startY)>QS&&(this.drag.moved=!0,this.drag.solo||this.simulation_begin(this.drag.nodeId)),!this.drag.moved))return!1;const s=new W;if(this.ports.picker.ray_aim(e).ray.intersectPlane(this.drag.plane,s)===null)return!1;if(this.ports.group.worldToLocal(s),this.drag.solo){const i=this.ports.meshes().get(this.drag.nodeId);return i===void 0?!1:(i.position.copy(s),!0)}return this.pull?.pin([s.x,s.y,s.z]),!1}end(){if(this.drag===null)return!1;const e=this.drag.moved;if(this.drag.solo&&this.drag.moved){const s=this.ports.meshes().get(this.drag.nodeId);s!==void 0&&this.returns.push({mesh:s,from:s.position.clone(),to:this.drag.home.clone(),startedAt:this.now()})}return this.pull?.release(),this.drag=null,e}step(){const e=this.now();let s=!1;return this.pull!==null&&(this.pull.step(this.drag!==null)?s=!0:this.pull=null),this.returns.length>0&&(this.returns=this.returns.filter(i=>{const n=Math.min(1,(e-i.startedAt)/300),r=n*n*(3-2*n);return i.mesh.position.lerpVectors(i.from,i.to,r),n<1}),s=!0),s}now(){return(this.ports.now??Date.now)()}simulation_begin(e){const s=this.ports.nodes(),i=t1(s),n=[...this.ports.meshes()].map(([o,a])=>({id:o,position:[a.position.x,a.position.y,a.position.z],radius:i.get(o)??Bt,dim:a.userData.dim===!0,halo:a.userData.halo===!0})),r=[];for(const o of s)for(const a of[...o.parentIds,...o.joinParentIds])r.push({from:a,to:o.id});this.pull=new A7({grabbed:e,nodes:n,edges:r,dimensions:this.ports.dimensions(),baseRadius:Bt})}}const TU=1500;class IU{ports;tip;hovered=null;tapTimer=null;constructor(e,s){this.ports=s,this.tip=document.createElement("div"),this.tip.className="dag-node-tip",this.tip.hidden=!0,e.appendChild(this.tip)}hide(){this.tip.hidden=!0}leave(e){if(this.hovered=null,e.pointerType==="touch"&&!this.tip.hidden){this.tapTimer!==null&&window.clearTimeout(this.tapTimer),this.tapTimer=window.setTimeout(()=>{this.tapTimer=null,this.ports.fingersDown()===0&&(this.tip.hidden=!0)},TU);return}this.tip.hidden=!0}hover(e){const s=this.ports.picker.node_under(e,this.ports.pressKind()==="touch"),i=s===null?void 0:this.ports.nodes().find(r=>r.id===s);if(i===void 0){this.tip.hidden=!0,this.ports.canvas.style.cursor="",this.hovered=null;return}this.hovered={id:i.id,x:e.clientX,y:e.clientY};const n=this.ports.canvas.getBoundingClientRect();this.tip.textContent=this.ports.words(i)??i.label,this.tip.style.left=`${e.clientX-n.left+14}px`,this.tip.style.top=`${e.clientY-n.top+10}px`,this.tip.hidden=!1,this.ports.canvas.style.cursor="pointer"}pick(e,s){const i=this.hovered,n=i!==null&&Math.hypot(e.clientX-i.x,e.clientY-i.y)<=6?i.id:this.ports.picker.node_under(e,this.ports.pressKind()==="touch");if(n===null){s==="select"&&this.ports.selected_get()!==null&&(this.ports.selected_set(null),this.ports.selection_paint(),this.ports.deselect?.());return}const r=this.ports.nodes().find(o=>o.id===n);r&&(s==="select"?(this.ports.selected_set(n),this.ports.census()||this.ports.selection_paint(),this.ports.select?.(r)):this.ports.activate?.(r))}}function DU(){return{running:new Ke("#ff7700"),done:new Ke("#ffeecc"),error:new Ke("#ff2222"),template:new Ke("#ffaa44"),unknown:new Ke("#555555"),edge:new Ke("#cc5500"),join:new Ke("#ffcc99"),root:new Ke("#6fbfae"),pulse:new Ke("#48d8f0")}}class CU{container;handlers;paletteOf;ambient;renderer;scene;camera;group=new pl;picker;spheres=new IF(this.group);get meshes(){return this.spheres.map}starField=new TF(this.group);labels=new LF(this.group);tubes=new DF({parent:this.group,node:e=>this.tubeNode_find(e),sphere:e=>this.meshes.get(e),palette:()=>this.palette_read()});handoffField=new CF({spheres:this.spheres,stars:this.starField,tubes:this.tubes,look:e=>this.handoffLook_find(e)});censusField=new NF({parent:this.group,stars:this.starField,tubes:this.tubes,starsView:()=>({pixelRatio:window.devicePixelRatio,heightPx:this.renderer.domElement.height,fovDeg:this.camera.fov})});drawn=new pU({meshes:()=>this.meshes,stars:this.starField,census:this.censusField,group:this.group});flights=new vU({positions_get:()=>this.positions_get(),positions_seed:e=>this.positions_seed(e),graph_set:(e,s)=>this.graph_set(e,s),flyToFit:(e,s,i,n,r)=>this.camera_flyToFit(e,s,i,n,r),flyToward:(e,s,i,n)=>this.camera_flyToward(e,s,i,n),alive:()=>!this.disposed});hierarchy;wave;replay;grab;hover=null;rig;gestures=null;lastPositions=new Map;frozen=new Set;physicsOnce=void 0;census=!1;physics={...Dr};graph={nodes:[]};drawMode="spheres";placedById=new Map;fits=0;strategy="ranked";selectedId=null;frameHandle=null;disposed=!1;projection="3d";flat=new fU;rebuildGen=0;slicing=!1;arrangement="galaxy";arrangementMemory=new Map;constructor(e,s={},i={}){this.container=e,this.handlers=s,this.paletteOf=i.palette??DU,this.hierarchy=new zU(i.layoutWorker,()=>this.rebuildGen),this.ambient=i.ambient===!0,this.renderer=new cF({antialias:!0,alpha:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.classList.add("dag-scene-canvas"),this.scene=new LG,this.camera=new Ti(50,1,.1,200),this.camera.position.set(0,0,14),this.rig=new VF(this.camera,this.group),this.picker=new eU(this.camera,this.group,this.renderer.domElement,{meshes:()=>this.meshes.values(),stars:()=>this.starField.list(),nebulae:()=>this.starField.nebulae(),census:()=>this.census&&this.censusField.drawn()?this.censusField:null},qS),this.wave=new OU({nodes:()=>this.graph.nodes,mesh:r=>this.meshes.get(r),census:()=>this.census&&this.censusField.drawn()?this.censusField:null,selected:()=>this.selectedId,ambient:this.ambient}),this.replay=new EU({stars:this.starField,redraw:()=>this.rebuild(!1,"hold"),...s.replay!==void 0?{moved:s.replay}:{}}),this.grab=new AU({picker:this.picker,camera:this.camera,group:this.group,meshes:()=>this.meshes,nodes:()=>this.graph.nodes,solo:()=>this.strategy==="ranked",dimensions:()=>this.projection==="2d"?2:3,spin_pause:()=>this.rig.spin_pause()}),this.scene.add(new hP(16777215,.9));const n=new cP(16777215,1.2);n.position.set(4,6,8),this.scene.add(n),this.scene.add(this.group),e.appendChild(this.renderer.domElement),this.size_fit(),this.ambient||(this.hover=this.pointer_wire(e)),new ResizeObserver(()=>this.size_fit()).observe(e),this.tick()}pointer_wire(e){const s=new IU(e,{picker:this.picker,canvas:this.renderer.domElement,nodes:()=>this.graph.nodes,pressKind:()=>this.gestures?.pressKind(),fingersDown:()=>this.gestures?.fingersDown()??0,words:i=>this.handlers.tip?.(i)??null,census:()=>this.census,selected_get:()=>this.selectedId,selected_set:i=>{this.selectedId=i},selection_paint:()=>this.selection_paint(),...this.handlers.select!==void 0?{select:this.handlers.select}:{},...this.handlers.activate!==void 0?{activate:this.handlers.activate}:{},...this.handlers.deselect!==void 0?{deselect:this.handlers.deselect}:{}});return this.gestures=new ZF(this.renderer.domElement,this.rig,{grab_begin:i=>this.grab.begin(i),grab_move:i=>{this.grab.move(i)&&this.positions_sync()},grab_end:()=>this.grab.end(),hover:i=>s.hover(i),leave:i=>s.leave(i),tap:(i,n)=>s.pick(i,n),tip_hide:()=>s.hide(),gesture_end:()=>this.handlers.gesture_end?.()},{flat:()=>this.projection==="2d",untethered:()=>this.census}),s}tick(){if(this.disposed)return;this.ambient?(this.rig.tumble_step(),this.wave.animate()):(this.rig.spin_step(!(this.gestures?.pointerOver()??!1)&&this.projection==="3d"&&!this.flat.active()),this.grab.step()&&this.positions_sync(),this.wave.animate(),this.rig.flight_step()),this.starField.scale_update(this.renderer.domElement.height,this.camera.fov),this.handoff_step(),this.replay.step();const e=performance.now();this.tubes.frame(e),this.starField.frame(e),this.labels.declutter(this.camera),this.renderer.render(this.scene,this.camera),this.frameHandle=window.requestAnimationFrame(()=>this.tick())}physics_set(e,s=!0){this.physics={...this.physics,...e},s&&this.rebuild()}physics_get(){return{...this.physics}}census_set(e){this.census!==e&&(this.census=e,this.rebuild(!0,"hold"))}census_get(){return this.census}graph_set(e,s={}){this.graph=e,this.flat.clear(),this.frozen=new Set(s.frozen??[]),this.physicsOnce=s.physics,this.rebuild(s.fit!==!1,s.settle??"full"),s.wave!==!1&&this.wave.start()}waveLoop_set(e){this.wave.loop_set(e)}waveLoop_get(){return this.wave.loop_get()}wave_start(){this.wave.start()}positions_get(){const e={};for(const[s,i]of this.lastPositions)e[s]=[Math.round(i.x*100)/100,Math.round(i.y*100)/100,Math.round(i.z*100)/100];return e}positions_seed(e){this.lastPositions=new Map(Object.entries(e).map(([s,[i,n,r]])=>[s,new W(i,n,r)]))}flight_into(e,s){if(this.rig.flying()||this.rig.holding_get())return;const i=this.drawn.diveTarget_find(e);i!==null&&this.rig.flyInto(i,s)}camera_flyToFit(e,s,i,n=1,r=1.15){this.rig.flyToFit(this.drawn.reaches_list(e),s,i,n,r)}camera_distance(){return this.rig.eyeDistance()}camera_touched(){return this.rig.touched_get()}moving(){return this.flights.moving()}frame(e,s,i=()=>{},n,r){this.flights.frame(e,s,i,n,r)}relight(e,s,i,n=()=>{},r){this.flights.relight(e,s,i,n,r)}unfold(e,s=()=>{}){this.flights.unfold(e,s)}descent(e,s,i=()=>{},n=()=>{}){this.flights.descent(e,s,i,n)}draw_set(e){e!==this.drawMode&&(this.drawMode=e,this.rebuild(!1,"hold"))}captions_set(e){this.labels.shown_set(e)}draw_get(){return this.drawMode}state_get(){const e=this.graph.nodes.filter(i=>i.solid===!0).map(i=>i.id),s=e.filter(i=>this.meshes.has(i)).length;return{draw:this.drawMode,arrangement:this.arrangement,captions:this.labels.shown_get()?this.labels.count():"off",known:this.lastPositions.size,census:this.census,nodes:this.graph.nodes.length,meshes:this.meshes.size,stars:this.starField.count(),solidMarked:e.length,solidDrawn:s,tubes:this.tubes.materialCount(),censusTubes:this.tubes.censusCount(),censusLines:this.tubes.censusLineCount(),censusMembers:this.census?this.censusField.ids().length:0,handoffGroups:this.handoffField.size(),handoffSolid:this.handoffField.solidCount(),camera:this.rig.eyeDistance().toFixed(1),settling:this.slicing,...rU(this.graph.nodes,this.lastPositions)}}camera_flyToward(e,s,i,n){const r=this.drawn.world_find(e);if(r===null){n();return}this.rig.flyToward(r,s,i,n)}holding_get(){return this.rig.holding_get()}flight_back(e){this.rig.flyBack(e)}strategy_set(e){this.strategy=e,this.rebuild()}selection_clear(){this.selectedId=null,this.selection_paint()}selection_set(e){const s=this.graph.nodes.find(i=>i.id===e);return s===void 0?!1:(this.selectedId=e,this.selection_paint(),this.handlers.select?.(s),!0)}selection_paint(){this.spheres.select(this.selectedId)}strategy_get(){return this.strategy}projection_set(e){this.projection=e,e==="2d"&&this.group.quaternion.identity(),this.rebuild()}projection_get(){return this.projection}flat_set(e){this.flat.set(e,this.graph.nodes,this.lastPositions,{camera:this.camera,focus:this.rig.focus,world:this.group},this.physics)&&this.rebuild(!1,"hold")}flat_get(){return this.flat.active()}look_update(e,s){const i=this.graph.nodes.find(n=>n.id===e);i&&(i.look=s,this.spheres.recolor(e,va(s.paint,this.palette_read())),this.tubes.holds(e)&&this.tubes.stale_mark())}palette_read(){return this.paletteOf()}palette_refresh(){this.rebuild(!0,"hold")}size_fit(){const e=Math.max(1,this.container.clientWidth),s=Math.max(1,this.container.clientHeight);this.renderer.setSize(e,s,!1),this.camera.aspect=e/s,this.camera.updateProjectionMatrix()}dispose(){this.disposed=!0,this.hierarchy.dispose(),this.frameHandle!==null&&window.cancelAnimationFrame(this.frameHandle),this.gestures?.detach(),this.renderer.dispose(),this.renderer.domElement.remove(),this.spheres.dispose()}arrangement_set(e,s,i=!0){if(e===this.arrangement)return;this.arrangementMemory.set(this.arrangement,new Map(this.lastPositions)),this.arrangement=e;let n=this.arrangementMemory.get(e);n===void 0&&s!==void 0&&Object.keys(s).length>0&&(n=new Map(Object.entries(s).map(([r,[o,a,l]])=>[r,new W(o,a,l)]))),this.lastPositions=n??new Map,i&&this.rebuild(!0,n===void 0?"full":"hold")}arrangement_get(){return this.arrangement}replay_begin(e,s=1){this.replay.begin(e,s)}replay_play(e){this.replay.play(e)}replay_pause(){this.replay.pause()}replay_seek(e){this.replay.seek(e)}replay_stop(){this.replay.stop()}replay_state(){return this.replay.state()}censusBuild(e,s,i=!0){const n=mU(e,s),r=this.censusField.build(n,this.drawMode==="stars",s);this.renderer.domElement.dataset.census=String(this.censusField.ids().length);const o=r.center,a=r.radius;!this.ambient&&i&&this.rig.frame(o,a,{stance:"threeQuarter",farScale:2.5})}camera_fit(e){if(e.length===0)return;this.rig.touch_clear(),this.fits+=1,this.renderer.domElement.dataset.fits=String(this.fits);const s=new W;for(const o of e)s.add(o.position);s.divideScalar(e.length);const i=e.map(o=>s.distanceTo(o.position)+o.radius).sort((o,a)=>o-a),n=this.handlers.handoffKey!==void 0?.95:1,r=Math.max(1,i[Math.max(0,Math.ceil(i.length*n)-1)]??1);this.rig.frame(s,r)}rebuild(e=!0,s="full"){const i=++this.rebuildGen;if(this.slicing&&(this.slicing=!1,this.handlers.progress?.(1,1,0)),this.strategy!=="molecule"){this.draw(lU(this.graph.nodes),e);return}let n=this.frozen;if(s!=="full"&&n.size===0){const l=this.graph.nodes.map(c=>c.id).filter(c=>this.lastPositions.has(c));l.length>0&&(n=new Set(l))}const r=s1(this.graph.nodes,this.projection==="2d"?2:3,this.lastPositions,this.physics_current(),n);if(r.moving===0){this.draw(r.place(),e);return}const o=this.handlers.progress,a=r.total*r.moving<oU;if((!a||this.arrangement!=="galaxy")&&o!==void 0&&this.handlers.handoffKey!==void 0&&this.frozen.size===0){this.hierarchy_run(i,e,n,o);return}if(o===void 0||a){r.step(r.total),this.draw(r.place(),e);return}this.settle_slice(r,i,e,o)}physics_current(){return this.physicsOnce!==void 0?{...this.physics,...this.physicsOnce}:this.physics}settle_slice(e,s,i,n){const r=this.graph.nodes.length;let o=0;this.slicing=!0,n(0,e.total,r);const a=()=>{if(s!==this.rebuildGen||this.disposed)return;const l=performance.now();for(;o<e.total&&performance.now()-l<aU;)e.step(1),o+=1;if(o<e.total){n(o,e.total,r),window.requestAnimationFrame(a);return}this.slicing=!1,this.draw(e.place(),i),n(e.total,e.total,r)};window.requestAnimationFrame(a)}hierarchy_run(e,s,i,n){const r=this.handlers.handoffKey;r!==void 0&&(this.slicing=!0,this.hierarchy.run({generation:e,nodes:this.graph.nodes,keyOf:r,seeds:this.lastPositions,frozen:i,physics:this.physics_current(),arrangement:this.arrangement,progress:(o,a,l)=>{o===a&&(this.slicing=!1),n(o,a,l)},placed:o=>{this.slicing=!1,this.draw(o,s)}}))}draw(e,s){const i=this.drawn_clear(e);if(this.census){const c=e.filter(h=>h.node.solid===!0&&h.node.ghost!==!0);this.censusBuild(e.filter(h=>h.node.solid!==!0),i,s),c.length>0&&this.solid_draw(c,i);return}!this.ambient&&s&&this.camera_fit(e);const n=this.drawMode==="stars",r=n&&!this.replay.active()?this.handlers.handoffKey:void 0,o={spheres:this.spheres,labels:this.labels,stars:this.starField,handoff:this.handoffField,selected:this.selectedId,flat:this.projection==="2d",starring:n,handoffKey:r},a=hU(e,i,o);a.starred.length>0&&this.starField.draw(a.starred,window.devicePixelRatio,this.renderer.domElement.height,this.camera.fov);for(const c of e)this.placedById.set(c.node.id,c);if(r!==void 0){const c=new Map(this.graph.nodes.map(h=>[h.id,h]));this.handoffField.gather(a.starred,h=>{const d=c.get(h);return d===void 0?null:r(d)})}dU(e,a.byId,i,o);const l=e.filter(c=>c.node.ghost!==!0&&c.node.halo!==!0&&(n?c.node.solid===!0||c.node.tubed===!0:c.node.dim!==!0)).map(c=>c.node.id);if(l.length>0){const h={tubes:null,mix:1,...!n||e.some(d=>d.node.solid===!0&&l.includes(d.node.id))?{}:{thickness:.25}};this.tubes.build(h,l,new Set(l))}this.renderer.domElement.dataset.rootsTop=nU(e.filter(c=>c.node.dim!==!0&&c.node.ghost!==!0&&c.node.halo!==!0).map(c=>({id:c.node.id,parentIds:c.node.parentIds,y:c.position.y})))?"yes":"no",this.replay.active()&&this.replay.paintAll()}drawn_clear(e){this.group.clear(),this.spheres.clear(),this.censusField.clear(),this.renderer.domElement.dataset.census="0",this.grab.clear(),this.starField.clear(),this.labels.clear(),this.handoffField.clear(),this.placedById=new Map,this.tubes.clear();const s=this.palette_read();if(this.wave.color=s.pulse,this.lastPositions=new Map(e.map(i=>[i.node.id,i.position.clone()])),this.projection==="2d")for(const i of e)i.position.z=0;return s}handoff_step(){if(this.handoffField.size()===0)return;const e=this.renderer.domElement.clientHeight||1;this.handoffField.step(bU(this.camera,this.group),MU(e,this.camera.fov),performance.now())}handoffLook_find(e){const s=this.placedById.get(e);return s===void 0?void 0:gU(s,this.palette_read())}tubeNode_find(e){const s=this.placedById.get(e);return s===void 0?void 0:_U(s)}positions_sync(){for(const{id:e,position:s}of this.grab.positions())this.meshes.get(e)?.position.set(...s),this.lastPositions.set(e,new W(...s));this.tubes.follow(),this.spheres.edges_follow()}solid_draw(e,s){for(const r of e)this.placedById.set(r.node.id,r),this.spheres.sphere_add(r.node.id,r.position,r.radius,{color:va(r.node.look.paint,s)});const i=e.map(r=>r.node.id),n={tubes:null,mix:1};this.tubes.build(n,i,new Set(i))}}const i1=new Set(["created","waiting","scheduled","started","registeringFiles"]);function RU(t){return t.status!==void 0&&i1.has(t.status)?"live":t.status==="finishedWithError"||t.share!==void 0&&t.share>=1?"failed":t.status==="finishedSuccessfully"||t.share!==void 0&&t.status!==void 0?"done":"rest"}function kU(t){return t.share!==void 0&&t.status!=="cancelled"?t.share>=1?{token:"error"}:{blend:["done","error"],share:Math.sqrt(Math.max(0,t.share))}:t.status==="finishedWithError"||t.status==="cancelled"?{token:"error"}:t.hue!==void 0?{hue:t.hue}:t.parentIds.length===0&&t.joinParentIds.length===0?{token:"root"}:t.status===void 0?{token:"template"}:t.status==="finishedSuccessfully"?{token:"done"}:i1.has(t.status)?{token:"running"}:{token:"unknown"}}function UM(t){return{state:RU(t),paint:kU(t),ember:t.share!==void 0&&t.share>0||t.status==="finishedWithError",waved:t.status===void 0||t.status==="finishedSuccessfully"||t.status==="finishedWithError"}}function NU(){const t=getComputedStyle(document.documentElement),e=(s,i)=>new Ke(t.getPropertyValue(s).trim()||i);return{running:e("--orange","#f70"),done:e("--butter","#fec"),error:new Ke("#f22"),template:e("--harvestgold","#fa4"),unknown:new Ke("#555"),edge:e("--pumpkin-pie","#c50"),join:e("--honey","#fc9"),root:e("--dag-root","#6fbfae"),pulse:e("--dag-pulse","#48d8f0")}}class Gd extends CU{byId=new Map;constructor(e,s={},i={}){const n={palette:NU,layoutWorker:()=>new Worker(new URL(""+new URL("layoutWorker-CfJVM55D.js",import.meta.url).href,import.meta.url),{type:"module"})};i.ambient!==void 0&&(n.ambient=i.ambient),super(e,s,n)}graph_set(e,s={}){const i=e.nodes.map(n=>Object.assign(n,{look:UM(n)}));this.byId=new Map(i.map(n=>[n.id,n])),super.graph_set({nodes:i},s)}relight(e,s,i,n,r){super.relight(e,s,i,n,r)}unfold(e,s){super.unfold(e,s)}descent(e,s,i,n){super.descent(e,s,i,n)}status_update(e,s){const i=this.byId.get(e);i===void 0||i.status===s||(i.status=s,this.look_update(e,UM(i)))}}function $M(t){if(t.jobsTotal===void 0||t.jobsDone===void 0)return null;const e=t.status==="finishedWithError"||t.status==="cancelled",s=t.jobsErrored===void 0?void 0:t.jobsDone-t.jobsErrored;return{done:t.jobsDone,total:t.jobsTotal,...e?{failed:!0}:{},...s!==void 0?{succeeded:s}:{}}}function BU(t){const e=t.title||"(untitled)",s=t.tags??[];if(s.length===0)return e;const i=document.createElement("span");i.className="feedlist-title feedlist-titled";const n=document.createElement("span");n.className="feedlist-title-text",n.textContent=e,i.append(n);for(const r of s){const o=document.createElement("span");o.className="feedlist-tag",o.dataset.tag=r,o.title=`tag:${r} — press to filter the roster by it`,o.textContent=`#${r}`;const a=document.createElement("span");a.className="feedlist-tag-x",a.title=`take ${r} off this feed (setfattr -x)`,a.textContent="×",o.append(a),i.append(o)}return i}const GU=[{key:"control",label:"",className:"feedlist-control",capped:!1,width:"5.2em",cell:()=>{const t=document.createElement("span");return t.className="feedlist-control listing-capsule",t.textContent="OPEN",t}},{key:"id",label:"ID",className:"feedlist-id",width:"4em",cell:t=>String(t.id),compare:t=>t.id},{key:"title",label:"TITLE",className:"feedlist-title",width:"minmax(12em, 24em)",cell:t=>BU(t),compare:t=>t.title},{key:"progress",shed:5,label:"PROGRESS",className:"feedlist-progress",width:"minmax(8em, 1fr)",cell:t=>Uh($M(t)),compare:t=>{const e=$M(t);return e===null||e.total===0?-1:e.done/e.total}},{key:"status",label:"STATUS",className:"feedlist-status",width:"8em",cell:t=>t.status.toUpperCase(),compare:t=>t.status},{key:"nodes",shed:1,label:"NODES",className:"feedlist-nodes",width:"4em",cell:t=>t.jobsTotal===void 0?"—":String(t.jobsTotal),compare:t=>t.jobsTotal??-1},{key:"sizeBytes",shed:3,label:"SIZE",className:"feedlist-size",width:"5.5em",cell:t=>t.sizeBytes===void 0?"—":r1(t.sizeBytes),compare:t=>t.sizeBytes??-1},{key:"wallSeconds",shed:2,label:"TIME",className:"feedlist-time",width:"6em",cell:t=>t.wallSeconds===void 0?"—":n1(t.wallSeconds),compare:t=>t.wallSeconds??-1},{key:"owner",shed:4,label:"OWNER",className:"feedlist-owner",width:"7em",cell:t=>t.owner},{key:"createdAt",label:"CREATED",className:"feedlist-created",width:"7em",cell:t=>t.createdAt.slice(0,10),compare:t=>t.createdAt}];function n1(t){const e=Math.round(t);return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${String(e%60).padStart(2,"0")}s`:`${Math.floor(e/3600)}h ${String(Math.floor(e%3600/60)).padStart(2,"0")}m`}function r1(t){if(t<1024)return`${t}B`;const e=["K","M","G","T"];let s=t,i=-1;for(;s>=1024&&i<e.length-1;)s=s/1024,i=i+1;return`${s<10?s.toFixed(1):Math.round(s)}${e[i]}`}function PU(t){const s=t.status==="finishedSuccessfully"||t.status==="finishedWithError"||t.status==="cancelled"?"awaiting warmup":"in flight",i=t.tally;return[["PLUGIN",t.pluginName],[i?"REP. INSTANCE":"INSTANCE",String(t.instanceId)],["STATUS",t.status],...i?[["COUNT",`×${i.count} — ${i.done} done, ${i.error} err, ${i.running} live, ${i.other} other`]]:[],...i?.anomalies!==void 0&&i.anomalies.length>0?[["FAULTS",i.anomalies.map(n=>n.id).join(" ")+(i.count>i.done+i.anomalies.length?" …":"")]]:[],["WALL",t.metrics?.computeSeconds!==void 0?n1(t.metrics.computeSeconds):s],["SIZE",t.metrics?.dataBytes!==void 0?r1(t.metrics.dataBytes):s],["DATA",t.vfsPath]]}function o1(t,e,s){t.replaceChildren();for(const[n,r]of PU(e)){const o=document.createElement("div");o.className="telemetry-row";const a=document.createElement("span");a.className="telemetry-label",a.textContent=n;const l=document.createElement("span");l.className="telemetry-value",l.textContent=r,o.append(a,l),t.appendChild(o)}t.appendChild(LU(e.status));const i=document.createElement("div");if(i.className="feed-node-verbs",s.enter!==void 0){const n=document.createElement("button");n.className="pacs-capsule feed-node-enter",n.textContent="ENTER NODE",n.title="fly into the node: its data, browsable inside (Esc flies out)",n.addEventListener("click",s.enter),i.appendChild(n)}if(s.process!==void 0){const n=s.process,r=document.createElement("button");r.className="pacs-capsule dag-process",r.textContent="PROCESS",e.tally!==void 0?(r.disabled=!0,r.title=`${e.tally.count} instances stand here: open one to process it`,r.classList.add("pacs-capsule-off")):(r.title=`open /bin bound to ${e.label} — a run appends to this node`,r.addEventListener("click",()=>n({vfsPath:e.vfsPath,instanceId:e.instanceId,label:e.label}))),i.appendChild(r)}i.childElementCount>0&&t.appendChild(i)}const Ju=[{key:"created",label:"CREATED"},{key:"waiting",label:"WAITING"},{key:"scheduled",label:"SCHEDULED"},{key:"started",label:"STARTED"},{key:"registeringFiles",label:"REGISTERING"}];function LU(t){const e=document.createElement("div");e.className="dag-subway";const s=t==="finishedSuccessfully",i=t==="finishedWithError"||t==="cancelled",n=Ju.findIndex(l=>l.key===t),r=s||i?Ju.length:n;!s&&!i&&e.classList.add("dag-subway-live");const o=(l,c,h)=>{const d=document.createElement("span");d.className=`subway-step${h?" subway-step-here":""}`;const u=document.createElement("span");u.className=c;const p=document.createElement("span");return p.className="subway-label",p.textContent=l,d.append(u,p),d};Ju.forEach((l,c)=>{if(c>0){const d=document.createElement("span");d.className="subway-link"+(c<=r?" subway-passed":""),e.appendChild(d)}const h=c===n&&!s&&!i;e.appendChild(o(l.label,"subway-stop"+(c<r?" subway-passed":"")+(h?" subway-here":""),h))});const a=document.createElement("span");return a.className="subway-link"+(s||i?" subway-passed":""),e.appendChild(a),e.appendChild(o(s?"FINISHED":i?t==="cancelled"?"CANCELLED":"ERROR":"FINISHED","subway-stop subway-terminal"+(s?" subway-done":"")+(i?" subway-failed":""),!1)),e}class a1{notePill;tagPill;renamePill;marks;handlers;readFeedId=null;tags=[];constructor(e,s){this.handlers=s,this.notePill=e?.querySelector(".dag-note")??null,this.tagPill=e?.querySelector(".dag-tag")??null,this.renamePill=e?.querySelector(".dag-rename")??null,this.marks=e?.querySelector(".dag-marks")??null;const i=(n,r)=>{n?.addEventListener("click",()=>{const o=s.shown();o!==null&&r(o)})};i(this.notePill,n=>s.feed_note?.(n)),i(this.tagPill,n=>s.feed_tag?.(n,this.tags)),i(this.renamePill,n=>s.feed_rename?.(n,s.name()))}shown_set(e){for(const s of[this.notePill,this.tagPill,this.renamePill,this.marks])s!==null&&(s.hidden=!e);e||(this.readFeedId=null)}arrived(e){this.readFeedId!==e&&this.refresh()}refresh(){const e=this.handlers.shown();e!==null&&(this.readFeedId=e,this.handlers.feed_entered?.(e))}show(e,s){if(e!==this.handlers.shown()||this.marks===null)return;s.title!==void 0&&s.title!==""&&this.handlers.renamed(e,s.title),this.tags=[...s.tags];const i=(s.note??"").trim();this.notePill!==null&&(this.notePill.textContent=s.note===null?"NOTE":i===""?"ADD NOTE":"EDIT NOTE"),this.marks.replaceChildren();for(const n of s.tags){const r=document.createElement("span");r.className="feedlist-tag dag-mark",r.dataset.tag=n,r.textContent=`#${n}`;const o=document.createElement("span");o.className="feedlist-tag-x",o.title=`take ${n} off this feed (setfattr -x)`,o.textContent="×",o.addEventListener("click",()=>this.handlers.feed_untag?.(e,n)),r.append(o),this.marks.append(r)}if(i!==""){const n=document.createElement("span");n.className="dag-note-line",n.textContent=i.split(`
4341
4341
  `)[0]??"",n.title=i,this.marks.append(n)}}}const jM="#555";function l1(t,e){return e==="time"?t.metrics?.computeSeconds:t.metrics?.dataBytes}function WU(t,e){const s=new Map;for(const i of t.nodes){const n=i.computeResource;n===void 0||n==="mixed"||s.has(n)||s.set(n,e[s.size%Math.max(1,e.length)]??"#888")}return s}function c1(t,e){const s=e.id_map??(a=>a),i=new Set(t.nodes.map(a=>a.id)),n=a=>{if(e.hue==="compute")return a.computeResource===void 0?jM:e.legend.get(a.computeResource)??jM},r=[],o=new Map;for(const a of t.nodes){const l=s(a.id),c=a.tally?.count??1,h=a.tally?.error??(a.status==="finishedWithError"?1:0),d=h>0&&c>1?Math.min(1,h/c):void 0,u=n(a);r.push({id:l,label:a.label,parentIds:a.parentIds.filter(p=>i.has(p)).map(s),joinParentIds:a.joinParentIds.filter(p=>i.has(p)).map(s),status:a.status,metric:l1(a,e.metric),tubed:!0,...c>1?{count:c}:{},...d!==void 0?{share:d}:{},...u!==void 0?{hue:u}:{}}),o.set(l,a)}return{nodes:r,payloads:o}}const xl={strategy:"ranked",projection:"3d",pulse:!0,metric:"time",hue:"status",census:!1,gravity:!1,draw:"spheres"},n_="argus.feedview",h1=2;function FU(){try{const t=globalThis.localStorage;return t===void 0?null:(t.getItem(n_),t)}catch{return null}}function HM(t){if(sd!==null)return{...sd};let e={};try{const n=t?.getItem(n_)??null,r=n===null?null:JSON.parse(n);r!==null&&typeof r=="object"&&(e=r)}catch{}const s=(n,r)=>r.includes(e[n])?e[n]:xl[n],i=n=>typeof e[n]=="boolean"?e[n]:xl[n];return{strategy:s("strategy",["ranked","molecule"]),projection:s("projection",["3d","2d"]),pulse:e.v===h1?i("pulse"):xl.pulse,metric:s("metric",["time","size"]),hue:s("hue",["status","compute"]),census:i("census"),gravity:i("gravity"),draw:s("draw",["spheres","stars"])}}let d1=!1,sd=null;function UU(t){d1=t}function VM(t,e){if(d1){sd={...e};return}sd=null;try{t?.setItem(n_,JSON.stringify({...e,v:h1}))}catch{}}function $U(t,e){switch(t){case"strategy":return e.strategy.toUpperCase();case"projection":return e.projection.toUpperCase();case"pulse":return e.pulse?"PULSE ON":"PULSE OFF";case"metric":return e.metric==="time"?"TIME":"SIZE";case"hue":return e.hue.toUpperCase();case"census":return e.census?"CENSUS":"SHAPE";case"gravity":return e.gravity?"GRAVITY ON":"GRAVITY OFF";case"draw":return e.draw.toUpperCase()}}function jU(t,e){switch(t){case"strategy":return{...e,strategy:e.strategy==="ranked"?"molecule":"ranked"};case"projection":return{...e,projection:e.projection==="3d"?"2d":"3d"};case"pulse":return{...e,pulse:!e.pulse};case"metric":return{...e,metric:e.metric==="time"?"size":"time"};case"hue":return{...e,hue:e.hue==="status"?"compute":"status"};case"census":return{...e,census:!e.census};case"gravity":return{...e,gravity:!e.gravity};case"draw":return{...e,draw:e.draw==="spheres"?"stars":"spheres"}}}const HU=new Set(["pulse","gravity"]);function u1(t){const e=getComputedStyle(document.documentElement),s=["--harvestgold","--daybreak","--orange","--honey","--butter","--october-sunset"].map(i=>e.getPropertyValue(i).trim()).filter(i=>i!=="");return WU(t,s)}function rm(t,e){return t.nodes.length===e.nodes.length&&e.nodes.every((s,i)=>{const n=t.nodes[i];return n!==void 0&&n.id===s.id&&(n.tally?.count??1)===(s.tally?.count??1)&&n.parentIds.length===s.parentIds.length&&n.joinParentIds.length===s.joinParentIds.length})}function f1(t,e,s=i=>i){for(const i of e.nodes)t.status_update(s(i.id),i.status)}class p1{constructor(e,s,i=FU()){this.hooks=s,this.store=i,this.modes=HM(i);for(const n of e?.querySelectorAll("[data-feed-verb]")??[]){const r=n.dataset.feedVerb;this.pills.set(r,n),n.addEventListener("click",()=>this.press(r))}this.paint()}hooks;store;modes;pills=new Map;recall(){return this.modes=HM(this.store),this.paint(),this.modes_get()}modes_get(){return{...this.modes}}pill_find(e){return this.pills.get(e)??null}press(e){this.modes=jU(e,this.modes),VM(this.store,this.modes),this.paint(),this.hooks.changed(e,this.modes_get())}set(e,s){this.modes={...this.modes,[e]:s},VM(this.store,this.modes),this.paint()}paint(){for(const[e,s]of this.pills)s.textContent=$U(e,this.modes),HU.has(e)&&s.classList.toggle("rail-off",e==="pulse"?!this.modes.pulse:!this.modes.gravity)}}class VU{abandoned=null;pick(e,s){this.abandoned=e!==null&&e!==s?e:null}drops(e,s){return this.abandoned!==e||s===null||s===e?!1:(this.abandoned=null,!0)}}function Qu(t){return(t.replace(/\[[0-9;]*m/g,"").split(`
4342
4342
  `).find(i=>i.trim().length>0)?.trim()??"").replace(/\s*\((?:[\d,]+\/[\d,]+(?:,\s*\d+%)?|initializing)\)(?=\.?$)/,"")}const Ol=[];function m1(){const t=Ol[Ol.length-1];return t===void 0?!1:(t(),!0)}function qU(t){const e=t.querySelector(":scope > .pane-drawer");if(e!==null)return e.nextElementSibling;const s=t.querySelector(":scope > .lcars-terminal-header-bar");return s===null?t.firstElementChild:s.nextElementSibling}function id(t,e){if(t.querySelector(":scope > .ask-bar")!==null)return Promise.resolve(null);const s=document.createElement("div");s.className=e.kind==="choose"?"ask-bar ask-bar-choose":"ask-bar";const i=document.createElement("span");i.className="ask-bar-glyph",i.textContent="?";const n=document.createElement("span");n.className="ask-bar-caption",n.textContent=e.message.trim(),s.append(i,n);const r=document.createElement("input"),o=document.createElement("button"),a=document.createElement("button"),l=document.createElement("button"),c=document.createElement("button");if(c.className="pacs-capsule ask-bar-abandon",c.textContent=e.close??"ABANDON",c.title="abandon the question (Esc)",e.kind==="confirm")o.className="pacs-capsule ask-bar-yes",o.textContent="YES",a.className="pacs-capsule ask-bar-no",a.textContent="NO",s.append(o,a,c);else{for(const d of e.choices??[]){const u=document.createElement("button");u.className=`pacs-capsule ask-bar-choice${d.held===!0?" ask-bar-held":""}`,u.textContent=d.label??d.value,u.dataset.value=d.value,u.disabled=d.held===!0,s.append(u)}r.className="ask-bar-field",r.spellcheck=!1,e.kind==="secret"?r.type="password":e.suggest!==void 0&&(r.value=e.suggest),l.className="pacs-capsule ask-bar-commit",l.textContent=e.commit??"ANSWER",s.append(r,l,c)}const h=qU(t);return h===null?t.appendChild(s):t.insertBefore(s,h),window.requestAnimationFrame(()=>s.classList.add("ask-bar-shown")),new Promise(d=>{let u=!1;const p=g=>{if(u)return;u=!0;const m=Ol.indexOf(f);m>=0&&Ol.splice(m,1),s.remove(),d(g)},f=()=>p(null);Ol.push(f);const _=()=>{const g=r.value.trim();p(g===""?null:g)};l.addEventListener("click",_);for(const g of s.querySelectorAll(".ask-bar-choice"))g.addEventListener("click",()=>p(g.dataset.value??null));o.addEventListener("click",()=>p("y")),a.addEventListener("click",()=>p("n")),c.addEventListener("click",f),s.addEventListener("keydown",g=>{if(g.key==="Escape"){g.stopPropagation(),f();return}if(e.kind==="confirm"){g.key==="y"||g.key==="Y"?(g.stopPropagation(),p("y")):g.key==="n"||g.key==="N"||g.key==="Enter"&&g.target===a?(g.stopPropagation(),p("n")):g.key==="Enter"&&(g.stopPropagation(),p("y"));return}g.key==="Enter"&&(g.stopPropagation(),_())}),e.kind==="confirm"?o.focus():(r.focus(),r.select())})}const KU=6e4,qM=1e4,KM=5e3,YU=new Set(["running","scheduled","created","started"]),XU=[/\/proc\/jobs\/feed_(\d+)(?:\/|$)/,/\/feeds?\/feed_(\d+)(?:\/|$)/];function ZU(t){const e=[];return(t.layout==="ranked"||t.layout==="molecule")&&e.push(`dag layout ${t.layout}`),(t.projection==="2d"||t.projection==="3d")&&e.push(`dag projection ${t.projection}`),(t.draw==="spheres"||t.draw==="stars")&&e.push(`dag draw ${t.draw}`),(t.pulse==="pulse on"||t.pulse==="pulse off")&&e.push(`dag ${t.pulse}`),(t.scale==="time"||t.scale==="size")&&e.push(`dag scale ${t.scale}`),(t.census==="census"||t.census==="shape")&&e.push(`dag census ${t.census==="census"?"on":"off"}`),(t.gravity==="gravity on"||t.gravity==="gravity off")&&e.push(`dag ${t.gravity}`),(t.hue==="status"||t.hue==="compute")&&e.push(`dag hue ${t.hue}`),t.place!==void 0&&t.place!==null&&e.push(`dag select ${t.place}`),e}const JU={running:"started",done:"finishedSuccessfully",error:"finishedWithError"};function YM(t){const e=/^(?:feed_)?(\d+)$/.exec(t.trim());return e===null?null:Number(e[1])}class QU{scene;canvas;title;facts;linkLine;empty;strategyPill;backPill=null;feedFrame;feedList;handlers;rosterTimer=null;shownFeedId=null;pinnedFeedId=null;requestedFeedId=null;follow=new VU;defaultTitle;metricMode="time";feedView;modesApplied=null;lastModel=null;lastRoster=[];arrivals=new Set;feedAsks=new Map;filterMissText="";filterMissNote=null;rosterCheck=null;rosterCheckTimer=null;paneRoot=null;clearNewPill=null;jumpPending=!1;jumpNode=null;jumpEnter=!1;arrivalsKey="";listing;stateSpan;watchedFeedId=null;liveState=null;pendingFeedId=null;lastCwd=null;constructor(e,s,i,n,r,o,a){this.feedList=o,this.canvas=e,e.style.display="none",this.title=s,this.defaultTitle=s.textContent??"",this.facts=i,this.empty=n,this.strategyPill=r,this.handlers=a;const l=r.closest(".pane-dag");this.paneRoot=l,l?.querySelector(".runs-jump")?.addEventListener("click",()=>{this.jump_ask()}),this.clearNewPill=l?.querySelector(".runs-clearnew")??null,this.clearNewPill?.addEventListener("click",()=>this.unseen_clear("all")),this.linkLine=Qw("/proc/jobs"),this.linkLine.classList.add("dag-linkline"),this.linkLine.hidden=!0,i.parentElement?.appendChild(this.linkLine),new MutationObserver(()=>this.linkLine_refresh()).observe(i,{childList:!0}),this.stateSpan=l?.querySelector(".pane-state")??null,this.modeSpan=l?.querySelector(".pane-mode")??null;const c=a.feed_verbs;this.listing=new Ir({mount:this.feedList,traits:GU,key:d=>String(d.id),chrome:l===null?void 0:{root:l,prefix:"runs"},actions:c===void 0?void 0:{of:d=>c(d)},control:"control",terms:[{key:"tag",value:d=>(d.tags??[]).join(" ")}],activate:d=>this.feed_activate(d),indicated:d=>this.handlers.feed_indicated?.(d),row:{className:d=>`feedlist-row feedlist-${d.status}${this.arrivals.has(d.id)?" feedlist-arrived":""}${d.new===!0?" feedlist-new":""}`,decorate:(d,u)=>{if(d.dataset.feed=String(u.id),u.new===!0){const p=document.createElement("span");p.className="feedlist-newmark",p.textContent=`NEW · FROM ${u.owner.toUpperCase()}`,d.querySelector(".feedlist-title")?.append(p)}d.title=c===void 0?"enter the feed (Esc returns to this list)":"click to indicate, double-click to enter (Esc returns to this list)"}},state:d=>this.canvas.style.display==="block"?null:[d.filter,(d.shed??0)>0?`${d.shed} COLUMN${d.shed===1?"":"S"} HIDDEN`:"",this.rosterCheck_line()||this.newCount_line()].filter(Boolean).join(" · "),refresh:()=>this.handlers.command_run("proc feeds --fresh"),filteredEmpty:d=>this.filterMiss_note(d),defaultSort:{key:"createdAt",dir:"desc"}}),this.feedList.addEventListener("click",d=>this.tagMark_press(d),{capture:!0}),this.feedList.addEventListener("dblclick",d=>{d.target instanceof Element&&d.target.closest(".feedlist-tag")!==null&&d.stopPropagation()},{capture:!0}),this.rosterTimer=setInterval(()=>{if(!this.feedList.isConnected||!this.rosterShown||this.rosterPending||document.visibilityState!=="visible")return;const u=this.lastRoster.some(p=>YU.has(p.status))?qM:KU;Date.now()-this.rosterAskedAt<u||(this.rosterAskedAt=Date.now(),this.handlers.command_run("proc feeds"))},qM),this.scene=new Gd(e,{select:d=>this.facts_show(d),activate:d=>this.node_activate(d),deselect:()=>this.facts.replaceChildren()}),this.backPill=r.parentElement?.querySelector(".dag-back")??null,this.feedFrame=new a1(r.parentElement,{...a,shown:()=>this.shownFeedId,name:()=>this.lastModel?.feedName??"",renamed:(d,u)=>{this.lastModel!==null&&(this.lastModel={...this.lastModel,feedName:u}),this.title.textContent=`DAG · FEED ${d} — ${u}`.toUpperCase()}}),this.backPill?.addEventListener("click",()=>{this.nav_pop()||this.feedsChooser_request()}),this.facts.addEventListener("click",d=>{d.target instanceof Element&&d.target.closest("button, a, input")===null&&(this.facts.classList.contains("dag-facts-immersed")||(this.scene.selection_clear(),this.factsShown=null,this.facts.replaceChildren()))}),this.feedView=new p1(r.parentElement,{changed:(d,u)=>this.feedMode_apply(d,u)}),this.metricMode=this.feedView.modes_get().metric,this.hueMode=this.feedView.modes_get().hue,this.scalePill=this.feedView.pill_find("metric"),this.huePill=this.feedView.pill_find("hue"),this.feedModes_recall(),r.closest(".pane-dag")?.addEventListener("argus:dag-physics",d=>{const u=d.detail;if(u==="reset"){this.scene.physics_set({charge:!0,link:!0,collide:!0});return}if(u.term==="gravity"){this.scene.physics_get().gravity!==u.on&&this.feedView.press("gravity");return}this.scene.physics_set({[u.term]:u.on})}),new MutationObserver(()=>this.scene.palette_refresh()).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),window.addEventListener("resize",()=>this.scene.size_fit()),new MutationObserver(()=>{window.setTimeout(()=>this.scene.size_fit(),600)}).observe(document.body,{attributes:!0,attributeFilter:["data-zoom"]})}envelope_observe(e){if(!this.jump_take(e)&&!this.feedAsk_take(e)){if(e.model?.kind===Kf){const s=this.rosterPending||this.rosterShown;this.rosterPending=!1;const i=qf.safeParse(e.model.data);i.success&&(s||this.canvas.style.display==="none")&&this.chooser_show(i.data.feeds);return}if(this.pendingFeedId!==null&&e.status==="error"&&e.model===void 0){this.feedRequest_refuse(e.renderedErr??e.rendered??"");return}if(this.rosterPending&&e.status==="error"){this.rosterPending=!1,this.rosterRefusal_show(e);return}if(e.model?.kind===br.feedIndexing){this.feedIndexing_take(e.model.data);return}e.model?.kind===br.feedDag&&this.feedDag_take(e.model.data)}}feedIndexing_take(e){const s=UR.safeParse(e);!s.success||this.follow.drops(s.data.feedId,this.pinnedFeedId)||(this.requestedFeedId===s.data.feedId?this.requestedFeedId=null:this.pendingFeedId!==s.data.feedId&&(this.pinnedFeedId=s.data.feedId,this.pendingFeedId=s.data.feedId),this.feedIndexing_show(s.data))}feedDag_take(e){const s=bg.safeParse(e);if(!s.success)return;const i=s.data;if(this.follow.drops(i.feedId,this.pinnedFeedId))return;this.requestedFeedId===i.feedId?this.requestedFeedId=null:this.pinnedFeedId=i.feedId,this.shownFeedId=i.feedId,this.pendingFeedId=null,this.linkLine_refresh(),this.listing.activation_settle(),ea(this.stateSpan,"wait"),this.title.textContent=`DAG · FEED ${i.feedId} — ${i.feedName}`.toUpperCase(),this.empty.style.display="none",this.roster_show(!1),this.canvas.style.display="block",this.lastModel!==null&&this.lastModel.feedId!==i.feedId&&(this.facts.replaceChildren(),this.scene.selection_clear());const n=this.lastModel;this.lastModel=i,this.feedModes_recall(),n!==null&&n.feedId===i.feedId&&rm(n,i)?this.statuses_patch(i):this.graph_show(i),this.watch_open(i.feedId),this.lastRoster.some(r=>r.id===i.feedId&&r.new===!0)&&this.unseen_clear([i.feedId]),this.jumpNode!==null&&this.scene.selection_set(String(this.jumpNode))&&(this.jumpNode=null,this.jumpEnter&&(this.jumpEnter=!1,window.setTimeout(()=>{[...this.facts.querySelectorAll("button")].find(r=>r.textContent?.trim()==="ENTER NODE")?.click()},0))),this.feedFrame.arrived(i.feedId),this.handlers.feed_shown?.()}feedModes_recall(){const e=this.feedView.recall(),s=this.modesApplied;return this.modesApplied=e,(s===null||s.strategy!==e.strategy)&&this.scene.strategy_set(e.strategy),(s===null||s.projection!==e.projection)&&this.scene.projection_set(e.projection),(s===null||s.draw!==e.draw)&&this.scene.draw_set(e.draw),(s===null||s.pulse!==e.pulse)&&this.scene.waveLoop_set(e.pulse),(s===null||s.census!==e.census)&&this.scene.census_set(e.census),(s===null||s.gravity!==e.gravity)&&this.scene.physics_set({gravity:e.gravity}),this.metricMode=e.metric,this.hueMode=e.hue,this.modes_render(),s!==null&&(s.metric!==e.metric||s.hue!==e.hue||s.draw!==e.draw)}stage_returned(){this.feedModes_recall()&&this.lastModel!==null&&this.canvas.style.display!=="none"&&this.graph_show(this.lastModel,!1)}feedMode_apply(e,s){switch(this.modesApplied=s,e){case"strategy":this.scene.strategy_set(s.strategy);break;case"projection":this.scene.projection_set(s.projection);break;case"draw":this.scene.draw_set(s.draw),this.lastModel!==null&&this.graph_show(this.lastModel,!1);break;case"pulse":this.scene.waveLoop_set(s.pulse);break;case"census":this.scene.census_set(s.census);break;case"gravity":this.scene.physics_set({gravity:s.gravity});break;case"metric":this.metricMode=s.metric,this.lastModel!==null&&this.graph_show(this.lastModel,!1);break;case"hue":this.hueMode=s.hue,this.lastModel!==null&&this.graph_show(this.lastModel,!1),this.hueMode==="compute"&&!this.computeKnown&&this.shownFeedId!==null&&this.canvas.style.display!=="none"&&(this.computeRereading=!0,this.handlers.command_run(`proc refresh ${this.shownFeedId}`),this.refresh());break}this.modes_render()}marks_refresh(){this.feedFrame.refresh()}feedMarks_show(e,s){this.feedFrame.show(e,s)}watch_open(e){this.watchedFeedId!==e&&(this.watch_release(),this.watchedFeedId=e,this.liveState_show(null),this.handlers.watch_set?.(`/proc/jobs/feed_${e}`,!0))}watch_release(){this.watchedFeedId!==null&&(this.handlers.watch_set?.(`/proc/jobs/feed_${this.watchedFeedId}`,!1),this.watchedFeedId=null,this.liveState_show(null))}modeSpan=null;hueMode="status";huePill=null;hueLegend=new Map;computeKnown=!1;computeRereading=!1;hueLegend_build(e){return u1(e)}modes_render(){if(this.modeSpan===null)return;const e=[];if(this.scene.strategy_get()!=="ranked"&&e.push("MOLECULE"),this.scene.projection_get()!=="3d"&&e.push("2D"),this.metricMode!=="time"&&e.push("SIZE"),this.scene.census_get()&&e.push("CENSUS"),this.scene.waveLoop_get()&&e.push("PULSE"),this.scene.physics_get().gravity&&e.push("GRAVITY"),this.modeSpan.replaceChildren(document.createTextNode(e.join(" · "))),this.hueMode==="compute"){const s=document.createElement("span");s.className="pane-legend",s.append(document.createTextNode(e.length>0?" · COMPUTE":"COMPUTE"));for(const[i,n]of this.hueLegend){const r=document.createElement("span");r.className="legend-swatch",r.style.backgroundColor=n;const o=document.createElement("span");o.textContent=i,s.append(document.createTextNode(" "),r,o)}this.hueLegend.size===0&&s.append(document.createTextNode(this.computeRereading?" (re-reading the feed…)":" (none reported)")),this.modeSpan.appendChild(s)}}liveState_show(e){if(this.liveState=e,this.stateSpan!==null){if(e===null){ys(this.stateSpan,null,this.canvas.style.display!=="none"?"":void 0);return}ys(this.stateSpan,e,e.toUpperCase())}}liveState_get(){return this.liveState}feed_get(){return this.pendingFeedId??this.shownFeedId}graph_isShown(){return this.canvas.style.display==="block"}feedTitle_get(){return(this.title.textContent??"").replace(/^DAG\s*·\s*/i,"").trim()}place_name(){const s=(this.factsShown===null||this.facts.childElementCount===0?void 0:this.factsPayloads.get(this.factsShown.id))?.vfsPath.replace(/\/data$/,"").split("/").pop();return s!==void 0&&s!==""?s:this.shownFeedId===null?null:`feed_${this.shownFeedId}`}view_lines(){const e=this.strategyPill.parentElement,s=i=>e?.querySelector(i)?.textContent?.trim().toLowerCase()??"";return ZU({layout:s(".dag-strategy"),projection:s(".dag-projection"),scale:s(".dag-scale"),hue:s(".dag-hue"),census:s(".dag-census"),draw:s(".dag-draw"),pulse:s(".dag-pulse"),gravity:s(".dag-gravity"),place:this.place_name()})}watched_observe(e,s){const i=/feed_(\d+)$/.exec(e);!i||Number(i[1])!==this.watchedFeedId||this.liveState_show(s)}model_refresh(e){if(this.pendingFeedId===e.feedId&&this.canvas.style.display==="none"){this.envelope_observe({status:"ok",rendered:"",model:{kind:br.feedDag,data:e}});return}if(this.shownFeedId!==e.feedId||this.canvas.style.display==="none")return;const s=this.lastModel;if(this.lastModel=e,s!==null&&rm(s,e)){this.statuses_patch(e);return}this.graph_show(e,!1)}statuses_patch(e){f1(this.scene,e);for(const s of e.nodes)this.factsPayloads.set(s.id,s);this.factsShown!==null&&this.facts_show(this.factsShown)}refresh(){this.shownFeedId===null||this.canvas.style.display==="none"||(this.requestedFeedId=this.shownFeedId,this.handlers.command_run(`feed diagram feed_${this.shownFeedId}`))}scalePill=null;graph_show(e,s=!0){const i=e.nodes.some(r=>l1(r,this.metricMode)!==void 0);this.scalePill?.classList.toggle("rail-na",!i),this.scalePill!==null&&(this.scalePill.title=i?"molecule node size: wall time or output bytes":`no ${this.metricMode==="time"?"wall-time":"output-size"} data in this feed's cache yet`),this.hueLegend=this.hueLegend_build(e);const n=e.nodes.some(r=>r.computeResource!==void 0);this.computeKnown=n,n&&(this.computeRereading=!1),this.huePill?.classList.toggle("rail-na",!n),this.huePill!==null&&(this.huePill.title=n?"what colors a node: its status, or the compute resource it ran on":"no compute resource reported for this feed's nodes yet"),this.scene.graph_set({nodes:c1(e,{metric:this.metricMode,hue:this.hueMode,legend:this.hueLegend,draw:this.feedView.modes_get().draw}).nodes},{wave:s}),this.scene.size_fit(),this.hueMode==="compute"&&this.modes_render(),this.factsPayloads.clear();for(const r of e.nodes)this.factsPayloads.set(r.id,r);this.factsShown!==null&&(this.factsPayloads.has(this.factsShown.id)?this.facts_show(this.factsShown):this.factsShown=null)}factsPayloads=new Map;factsShown=null;promptContext_observe(e){if(this.rosterProgress!==null&&this.rosterProgress.isConnected){const o=e.procWarmup;if(o?.total!==void 0&&o.total>0&&o.sweeping!==!1){const a=Math.floor(o.loaded/o.total*100);this.rosterProgress.textContent=`INDEX WARMING — ${o.loaded}/${o.total} (${a}%). The roster opens when the index is whole.`}(o===void 0||o.sweeping===!1||o.state==="cached")&&(this.rosterProgress=null,this.feedsChooser_request())}this.arrivals_observe(e.procWarmup?.arrived??[]),this.rosterCheck_observe(e.procWarmup?.roster,e.procWarmup?.arrived??[]);const i=(e.procWarmup?.feeds??(e.procWarmup?.feed!==void 0?[e.procWarmup.feed]:[])).find(o=>o.id===this.pendingFeedId);i!==void 0&&this.feedIndexing_show({feedId:i.id,loaded:i.loaded,total:i.total,...i.failed!==void 0?{failed:i.failed}:{}});const n=this.lastCwd!==null&&e.cwd!==this.lastCwd;if(this.lastCwd=e.cwd,!this.canvas.isConnected||this.rosterShown||this.pendingFeedId!==null||!n)return;const r=e5(e.cwd);r!==null&&r!==this.shownFeedId&&(this.pinnedFeedId!==null&&r===this.pinnedFeedId||(this.pinnedFeedId=null,this.requestedFeedId=r,this.handlers.command_run(`feed diagram feed_${r}`)))}progress_observe(e){if(e.itemId===void 0)return;const s=e.status!==void 0?JU[e.status]:void 0;s!==void 0&&this.scene.status_update(String(e.itemId),s)}size_fit(){this.scene.size_fit()}dispose(){this.watch_release(),this.rosterTimer!==null&&clearInterval(this.rosterTimer),this.scene.dispose()}feed_enter(e){this.follow.pick(this.requestedFeedId,e),this.pinnedFeedId=e,this.requestedFeedId=null,this.feedRequest_show(e),this.handlers.command_run(`feed diagram feed_${e}`)}feedRequest_show(e){this.pendingFeedId=e,this.roster_show(!1),this.canvas.style.display="none",this.facts.replaceChildren(),this.title.textContent=`DAG · FEED ${e}`,this.empty.textContent=`RETRIEVING FEED ${e}…`,this.empty.style.display="block",ys(this.stateSpan,"wait","LOADING")}feedIndexing_show(e){this.pendingFeedId===null&&(this.pendingFeedId=e.feedId),this.roster_show(!1),this.canvas.style.display="none",this.title.textContent=`DAG · FEED ${e.feedId}`;const s=e.total>0?`${e.loaded.toLocaleString()} / ${e.total.toLocaleString()}`:`${e.loaded.toLocaleString()} / ?`;this.empty.textContent=e.failed!==void 0?`INDEXING FEED ${e.feedId} FAILED AT ${s} — ${e.failed.toUpperCase()} — REFRESH RETRIES`:`INDEXING FEED ${e.feedId} — ${s}`,this.empty.style.display="block",ys(this.stateSpan,"wait",e.failed!==void 0?"FAILED":"LOADING"),e.failed===void 0&&this.watch_open(e.feedId)}feedRequest_refuse(e){const s=this.pendingFeedId;this.pendingFeedId=null,this.listing.activation_settle(),this.empty.textContent=`FEED ${s??"?"}: ${e.trim()||"not available"}`.toUpperCase(),this.empty.style.display="block",this.roster_show(!0),this.title.textContent=this.defaultTitle,ea(this.stateSpan,"wait"),this.listing.state_refresh()}feedsChooser_request(){const e=document.createElement("div");e.className="feedlist-loading",e.textContent="RETRIEVING FEED ROSTER…",this.feedList.replaceChildren(e),this.canvas.style.display!=="none"&&this.graph_leave(),this.roster_show(!0),this.rosterPending=!0,this.rosterAskedAt=Date.now(),this.handlers.command_run("proc feeds")}rosterPending=!1;target_jumpTo(e,s=!1){this.jumpEnter=s,this.jump_ask(e)}linkLine_refresh(){if(this.shownFeedId===null){this.linkLine.hidden=!0;return}const e=this.factsShown===null||this.facts.childElementCount===0?void 0:this.factsPayloads.get(this.factsShown.id);tg(this.linkLine,e?.vfsPath.replace(/\/data$/,"")??`/proc/jobs/feed_${this.shownFeedId}`),this.linkLine.hidden=!1}async jump_ask(e){if(this.paneRoot===null)return;const s=(e??await id(this.paneRoot,{kind:"text",message:"Jump to a feed or node (4389, feed_4389, pl-dircopy_639204): ",commit:"JUMP"})??"").trim();s===""||/\s/.test(s)||(this.jumpPending=!0,this.handlers.command_run(`proc jump --where ${s}`))}jump_take(e){if(!this.jumpPending)return!1;if(e.model?.kind===HR){this.jumpPending=!1;const s=jR.safeParse(e.model.data);if(!s.success)return!0;const i=s.data;if(i.choices.length===1){const n=i.choices[0];return this.jumpNode=n.nodeId??null,this.feed_enter(n.feedId),!0}return this.jump_choose(i),!0}return e.status==="error"&&e.model===void 0?(this.jumpPending=!1,this.jumpNote_show(Qu(e.renderedErr||e.rendered||"").replace(/^proc jump:\s*/,"")),!0):!1}async jump_choose(e){if(this.paneRoot===null)return;const s=e.choices.map(n=>({value:n.name,label:n.kind==="feed"?`FEED ${n.feedId} · ${n.title}`:`NODE ${n.nodeId??""} · ${n.name.replace(/_\d+$/,"")} IN FEED ${n.feedId}`})),i=await id(this.paneRoot,{kind:"choose",message:`${e.target} is both a feed and a node: `,choices:s,commit:"JUMP"});i!==null&&i.trim()!==""&&await this.jump_ask(i.trim())}jumpNote_show(e){this.rosterCheckTimer!==null&&clearTimeout(this.rosterCheckTimer),this.rosterCheck={landed:e.toUpperCase()},this.canvas.style.display==="block"?this.stateSpan!==null&&(this.stateSpan.textContent=e.toUpperCase()):this.listing.state_refresh(),this.rosterCheckTimer=setTimeout(()=>{this.rosterCheck=null,this.rosterCheckTimer=null,this.listing.state_refresh()},KM*2)}rosterCheck_observe(e,s){if(e==="full"){if(this.rosterCheck==="checking")return;this.rosterCheckTimer!==null&&(clearTimeout(this.rosterCheckTimer),this.rosterCheckTimer=null),this.rosterCheck="checking",this.listing.state_refresh();return}if(this.rosterCheck!=="checking")return;const i=s.filter(n=>!this.lastRoster.some(r=>r.id===n)).length;this.rosterCheck={landed:i>0?`FEED LIST CURRENT · ${i} NEW`:"FEED LIST CURRENT · NOTHING NEW"},this.listing.state_refresh(),this.rosterCheckTimer=setTimeout(()=>{this.rosterCheck=null,this.rosterCheckTimer=null,this.listing.state_refresh()},KM)}newCount_line(){const e=this.lastRoster.filter(s=>s.new===!0).length;return e===0?"":`${e} NEW SINCE YOUR LAST VISIT`}unseen_clear(e){this.handlers.command_run(e==="all"?"proc seen all":`proc seen ${e.map(i=>`feed_${i}`).join(" ")}`);const s=this.lastRoster.map(i=>{if(i.new!==!0||e!=="all"&&!e.includes(i.id))return i;const{new:n,...r}=i;return r});this.rosterShown?this.chooser_show(s):this.lastRoster=s,this.listing.state_refresh()}rosterCheck_line(){return this.rosterCheck===null?"":this.rosterCheck==="checking"?"CHECKING CUBE FOR THE FEED LIST…":this.rosterCheck.landed}filterMiss_note(e){e!==this.filterMissText&&(this.filterMissText=e,this.feedAsks.clear());const s=document.createElement("div");s.className="feedlist-refusal feedlist-miss";const i=YM(e);return i===null?s.textContent=`no feed matches "${e}"`:this.feedAsks.has(i)?s.textContent=this.feedAsks.get(i)??`feed_${i} is not in the roster; asking CUBE…`:(this.feedAsks.set(i,null),s.textContent=`feed_${i} is not in the roster; asking CUBE…`,this.handlers.command_run(`proc feeds ${i}`)),this.filterMissNote=s,s}feedAsk_take(e){if(this.feedAsks.size===0)return!1;if(e.model?.kind===Kf){const n=qf.safeParse(e.model.data),r=n.success&&n.data.feeds.length===1?n.data.feeds[0]:void 0;return r===void 0||this.feedAsks.get(r.id)!==null?!1:(this.feedAsks.set(r.id,"listed"),this.arrivals.add(r.id),this.chooser_show([...this.lastRoster.filter(o=>o.id!==r.id),r]),!0)}if(e.status!=="error"||e.model!==void 0)return!1;const s=Qu(e.renderedErr||e.rendered||""),i=YM(/feed_(\d+)/.exec(s)?.[0]??"");return i===null||this.feedAsks.get(i)!==null?!1:(this.feedAsks.set(i,s),this.filterMissNote!==null&&this.filterMissNote.isConnected&&(this.filterMissNote.textContent=s),!0)}rosterShown=!1;rosterAskedAt=0;rosterProgress=null;rosterRefusal_show(e){const s=Qu(e.renderedErr||e.rendered||""),i=s.length>0?s:"the roster request was refused",n=document.createElement("div");n.className="feedlist-refusal",n.textContent=i;const r=document.createElement("div");r.className="feedlist-warming",r.textContent="INDEX WARMING… the roster opens when the index is whole.",this.feedList.replaceChildren(n,r),this.roster_show(!0),this.rosterProgress=r}list_reset(){this.pendingFeedId=null,ea(this.stateSpan,"wait"),this.watch_release(),this.facts.replaceChildren(),this.scene.selection_clear(),this.canvas.style.display="none",this.pinnedFeedId=null,this.requestedFeedId=null,this.title.textContent=this.defaultTitle,this.empty.style.display="none"}nav_pop(){return this.pendingFeedId!==null&&this.feedList.childElementCount>0?(this.pendingFeedId=null,this.pinnedFeedId=null,this.requestedFeedId=null,this.listing.activation_settle(),this.empty.style.display="none",this.roster_show(!0),this.title.textContent=this.defaultTitle,ea(this.stateSpan,"wait"),this.listing.state_refresh(),!0):this.canvas.style.display==="none"||this.feedList.childElementCount===0?!1:(this.graph_leave(),this.roster_show(!0),this.listing.state_refresh(),!0)}graph_leave(){this.watch_release(),this.canvas.style.display="none",this.pinnedFeedId=null,this.requestedFeedId=null,this.title.textContent=this.defaultTitle,this.facts.replaceChildren(),this.scene.selection_clear()}arrivals_observe(e){const s=e.join(",");if(s===this.arrivalsKey)return;this.arrivalsKey=s,this.arrivals=new Set(e);for(const r of this.lastRoster)this.listing.row_element(String(r.id))?.classList.toggle("feedlist-arrived",this.arrivals.has(r.id));const i=new Set(this.lastRoster.map(r=>r.id));e.some(r=>!i.has(r))&&this.rosterShown&&this.feedsChooser_request()}chooser_show(e){this.lastRoster=e,this.empty.style.display="none",this.roster_show(!0);const s=e.filter(i=>i.new===!0);if(this.clearNewPill!==null&&(this.clearNewPill.hidden=s.length===0),s.length===0)this.listing.rows_set([{key:"roster",rows:e}],{field:"roster"});else{const i=document.createElement("div");i.className="feedlist-newhead",i.textContent=`NEW SINCE YOUR LAST VISIT · ${s.length}`;const n=e.filter(r=>r.new!==!0);this.listing.rows_set([{key:"new",rows:s,header:i},{key:"roster",rows:n}],{field:"roster"})}this.rosterFrame_track()}feed_activate(e){this.follow.pick(this.requestedFeedId,e.id),this.pinnedFeedId=e.id,this.requestedFeedId=null,this.handlers.feed_regard?.(`/proc/jobs/feed_${e.id}`),this.feedRequest_show(e.id),this.handlers.command_run(`feed diagram feed_${e.id}`)}row_indicate(e){this.listing.row_indicate(e===null?null:String(e.id))}indicated_refresh(){const e=this.listing.indicated_get(),s=e===null?void 0:this.lastRoster.find(i=>String(i.id)===e);s!==void 0&&this.handlers.feed_indicated?.(s)}roster_ask(){this.rosterAskedAt=Date.now(),this.handlers.command_run("proc feeds")}tagMark_press(e){const s=e.target instanceof Element?e.target:null,i=s?.closest(".feedlist-tag")??null;if(i===null)return;e.stopPropagation(),e.preventDefault();const n=i.dataset.tag??"",r=Number(i.closest("[data-feed]")?.dataset.feed);if(s?.closest(".feedlist-tag-x")!==null&&Number.isFinite(r)){this.handlers.feed_untag?.(r,n);return}this.roster_filter(`tag:${n}`)}rowReadout_show(e,s){this.listing.readout_show(String(e),s)}filter_toggle(e){this.listing.filter_toggle(e)}roster_filter(e){this.listing.filter_toggle(e!==""),this.listing.filter_set(e)}rosterFrameObserver=null;rosterFrame_track(){const e=this.feedList.parentElement,s=this.feedList.querySelector(".roster-order");if(this.rosterFrameObserver?.disconnect(),this.rosterFrameObserver=null,e===null)return;if(s===null){e.style.removeProperty("--mode-frame-top");return}const i=()=>{e.style.setProperty("--mode-frame-top",`${Math.ceil(s.getBoundingClientRect().bottom-e.getBoundingClientRect().top)}px`)};i(),this.rosterFrameObserver=new ResizeObserver(i),this.rosterFrameObserver.observe(s)}roster_show(e){this.rosterShown=e,this.backPill!==null&&(this.backPill.hidden=e),this.feedFrame.shown_set(!e),this.feedList.style.display=e?"flex":"none",this.feedList.parentElement?.classList.toggle("roster-shown",e)}facts_show(e){this.factsShown=e;const s=this.factsPayloads.get(e.id);if(!s){this.facts.textContent=e.label;return}this.handlers.node_regard?.(s.vfsPath),o1(this.facts,s,{...this.handlers.node_dive!==void 0||this.handlers.node_enter!==void 0?{enter:()=>this.node_activate(e)}:{},...this.handlers.node_process!==void 0?{process:this.handlers.node_process}:{}})}node_activate(e){const s=this.factsPayloads.get(e.id);if(s)if(this.handlers.node_dive!==void 0){const i=this.handlers.node_dive;this.scene.flight_into(e.id,()=>i(s.vfsPath))}else this.handlers.node_enter(s.vfsPath)}detail_clear(){this.scene.selection_clear(),this.facts.replaceChildren()}wave_start(){this.scene.wave_start()}inside_isHeld(){return this.scene.holding_get()}flight_back(e){this.scene.flight_back(e)}node_flyTo(e){for(const[s,i]of this.factsPayloads){if(i.instanceId!==e)continue;if(this.handlers.node_dive===void 0)return!1;const n=this.handlers.node_dive;return this.facts_show({id:s,label:i.label,parentIds:[],joinParentIds:[]}),this.scene.flight_into(s,()=>n(i.vfsPath)),!0}return!1}}function e5(t){for(const e of XU){const s=t.match(e);if(s?.[1]!==void 0)return parseInt(s[1],10)}return null}function ef(t,e){const s=Xf(t);if(s===null)return null;let i=0,n=0,r=0;for(const a of e.all()){const l=a.groups.filter(c=>c.plugin===s);if(l.length!==0){i+=1;for(const c of l)n+=c.count,r+=c.errored}}const o=n===0?0:Math.round(r/n*100);return`${s} · ${i.toLocaleString("en-US")} feed${i===1?"":"s"} · ${o}% errored`}class t5{byId=new Map;take(e){let s=!1;for(const i of e){const n=this.byId.get(i.id);n!==void 0&&n.status===i.status&&n.jobs===i.jobs&&JSON.stringify(n.groups)===JSON.stringify(i.groups)||(this.byId.set(i.id,{...i,chain:[...i.chain],groups:i.groups.map(r=>({...r}))}),s=!0)}return s}size(){return this.byId.size}shapes(){return new Set([...this.byId.values()].map(Ps)).size}all(){return[...this.byId.values()]}get(e){return this.byId.get(e)}clear(){this.byId.clear()}}function s5(t,e){const s=t.match(/^feed:(\d+):(\d+)$/);if(s===null)return null;const i=e.get(Number(s[1])),n=i?.groups[Number(s[2])];if(i===void 0||n===void 0)return null;const r=n.count>1?` ×${n.count.toLocaleString("en-US")}`:"",o=i.title.length>0?` · ${i.title}`:"",a=n.errored>0&&n.count>1?`${n.errored.toLocaleString("en-US")} errored`:n.status;return`${n.plugin}${r} · ${a} · feed ${i.id}${o}`}function i5(t,e){return`argus.universe.${t}@${e}`}const hr={draw:"stars",view:"feeds",scale:"jobs",density:"shape",arrangement:"galaxy",captions:!0};function n5(t,e,s,i,n=hr.arrangement,r=hr.captions){return{draw:t,view:e,scale:s,density:i,arrangement:n,captions:r}}function r5(t){let e={};try{const i=t===null?null:JSON.parse(t);i!==null&&typeof i=="object"&&!Array.isArray(i)&&(e=i)}catch{}const s=(i,n,r)=>typeof i=="string"&&n.includes(i)?i:r;return{draw:s(e.draw,["stars","spheres"],hr.draw),view:s(e.view,["feeds","shapes"],hr.view),scale:s(e.scale,["jobs","feeds"],hr.scale),density:s(e.density,["shape","census"],hr.density),arrangement:s(e.arrangement,["galaxy","spokes","clumps","constellations","data","accretion"],hr.arrangement),captions:typeof e.captions=="boolean"?e.captions:hr.captions}}function XM(t){if(t===null||t.length===0)return{};try{const e=JSON.parse(t);if(e===null||typeof e!="object"||Array.isArray(e))return{};const s={};for(const[i,n]of Object.entries(e))Array.isArray(n)&&n.length===3&&n.every(r=>typeof r=="number"&&Number.isFinite(r))&&(s[i]=[n[0],n[1],n[2]]);return s}catch{return{}}}function tf(t,e){return`inst:${t}:${e}`}function o5(t,e,s,i="jobs",n=!1,r){const o=r??(n?vg(t,i):yd(t,i)),a=`feed:${e}:`;return{nodes:[...o.nodes.filter(c=>!c.id.startsWith(a)).map(c=>({...c,dim:!0})),...s.nodes]}}function g1(t,e){return e.groups.map((s,i)=>Mr(t,i))}function _1(t,e=3){const s=zd(t).split(" > ");return s.length<=e?s.join(" > "):`${s.slice(0,e).join(" > ")} … +${s.length-e}`}function a5(t,e){if(!t.startsWith("shape:"))return null;const s=t.slice(6),i=e.all().filter(n=>Ps(n)===s).length;return`${zd(s)} · ${i} feed${i===1?"":"s"}`}function l5(t,e){const s=[];for(const i of e.all())Ps(i)===t&&s.push(...g1(i.id,i));return s}function c5(t,e,s="jobs"){const i=yd(t,s),n=new Set(t.filter(o=>Ps(o)===e).map(o=>o.id));return{nodes:i.nodes.map(o=>{if(o.ghost===!0)return o.id===dz(e)?o:{...o,dim:!0};const a=o.id.match(/^feed:(\d+):/);return a!==null&&n.has(Number(a[1]))?o:{...o,dim:!0}})}}function b1(t,e="jobs"){const s=new Map;for(const n of[...t].sort((r,o)=>r.id-o.id)){if(n.groups.length===0)continue;const r=Ps(n),o=s.get(r)??[];o.push(n),s.set(r,o)}const i=[];for(const[n,r]of s)r[0].groups.forEach((a,l)=>{let c=0,h=0;for(const u of r){const p=u.groups[l];p!==void 0&&(c+=p.count,p.errored>0&&(h+=1))}const d=h>0?Math.min(1,h/r.length):void 0;i.push({id:ep(n,l),label:a.plugin,parentIds:a.parent===null?[]:[ep(n,a.parent)],joinParentIds:[],status:h===r.length?"finishedWithError":"finishedSuccessfully",metric:Nl(e==="feeds"?r.length:c),...r.length>1?{count:r.length}:{},...d!==void 0?{share:d}:{}})});return{nodes:i}}function h5(t,e){const s=t.match(/^fold:(.+):(\d+)$/);if(s===null)return null;const i=s[1],n=Number(s[2]),r=e.all().filter(h=>Ps(h)===i),o=r[0]?.groups[n]?.plugin;if(o===void 0)return null;const a=r.filter(h=>(h.groups[n]?.errored??0)>0).length,l=`${r.length.toLocaleString("en-US")} feed${r.length===1?"":"s"}`,c=a>0?` · ${a.toLocaleString("en-US")} with errors`:"";return`${o} · ${l}${c} · ${_1(i)}`}function ZM(t,e){const s=e.all().find(i=>Ps(i)===t);return s===void 0?[]:s.groups.map((i,n)=>ep(t,n))}function JM(t,e,s="jobs"){const i=t.filter(l=>Ps(l)===e),n=t.filter(l=>Ps(l)!==e),r=b1(n,s),o=yd(i,s),a=o.nodes.filter(l=>l.ghost!==!0).map(l=>l.id);return{graph:{nodes:[...r.nodes.map(l=>({...l,dim:!0})),...o.nodes]},memberIds:a}}class d5{root;label;fill;constructor(e){this.root=document.createElement("div"),this.root.className="wait-progress",this.root.hidden=!0,this.root.setAttribute("role","progressbar"),this.root.setAttribute("aria-valuemin","0"),this.root.setAttribute("aria-valuemax","100"),this.label=document.createElement("span"),this.label.className="wait-progress-label";const s=document.createElement("span");s.className="wait-progress-track",this.fill=document.createElement("span"),this.fill.className="wait-progress-fill",s.appendChild(this.fill),this.root.append(this.label,s),e.appendChild(this.root)}show(e,s){this.root.hidden=!1,this.label.textContent=s===null?e:`${e} · ${Math.floor(s*100)}%`,this.root.classList.toggle("wait-progress-indeterminate",s===null),this.fill.style.width=s===null?"":`${Math.max(0,Math.min(1,s))*100}%`,s===null?this.root.removeAttribute("aria-valuenow"):this.root.setAttribute("aria-valuenow",String(Math.floor(s*100)))}hide(){this.root.hidden=!0}shown(){return!this.root.hidden}}const u5=600;function f5(t,e){if(e===null)return t.projection_set(t.projection_get()==="3d"?"2d":"3d"),null;if(t.projection_get()==="2d")return"universe: the whole space is 2D; BACK and press 2D to stand it up";const s=[...e];return t.flat_set(t.flat_get()?null:s),t.camera_flyToFit(s,u5,()=>{},1,.95),null}function p5(t,e){return t.projection_get()==="2d"||e&&t.flat_get()?"2D":"3D"}function om(t,e,s){const i=t?.querySelector(".universe-projection");i!=null&&(i.textContent=p5(e,s))}function m5(t,e,s,i){const n=f5(e,s);n!==null&&i(n),om(t,e,s!==null)}const g5=4e3;function _5(t){const e={...Dr,gravity:!0};return t.charge===e.charge&&t.link===e.link&&t.collide===e.collide&&t.gravity===e.gravity}function QM(t){let e=0;for(const s of Object.values(t))e+=s[0]*1.3+s[1]*1.7+s[2]*1.9;return`${Object.keys(t).length}:${e.toFixed(2)}`}function sf(t){return t==="constellations"||t==="data"||t==="accretion"}const b5=18e4,M5=1500,v5=1e3,w5=5e3,y5=3e3,Ko=650,z5=650,S5=1.5;class x5{scene;wait;asking=!1;spaceKey="";landed=new t5;canvas;title;state;noteTimer=null;empty;handlers;store;whole=!1;shown=!1;warming="";repaintTimer=null;lastReask=0;rememberTimer=null;putSignatures=new Map;sessionPlaces=new Map;sessionWait=null;storeKey=null;arrivalsKey="";feedsCount=null;disposed=!1;scale="jobs";view="feeds";inside=null;cluster=null;framedAt=null;entering=null;facts;viewPill=null;gravityPill=null;densityPill=null;density="shape";drawMode="stars";drawPill=null;captionsPill=null;captions=!0;arrangement="galaxy";arrangementPill=null;scalePill=null;physics={...Dr,gravity:!0};backPill;openPill;pane;feedFrame=null;feedView=null;insideModel=null;insideEntered=null;insideModes=null;watchedFeedId=null;liveState=null;escape_listen;lit=null;dataHubs=new Map;litHub=null;replayPill=null;replayDay="";reach=null;constructor(e,s,i){this.canvas=e.canvas,this.title=e.title,this.state=e.state,this.empty=e.empty,this.handlers=s,this.store=i,this.facts=e.facts,this.backPill=e.backPill,this.openPill=e.openPill,this.pane=e.canvas.closest(".workspace-pane"),this.wait=new d5(e.canvas),this.scene=new Gd(e.canvas,{progress:(n,r,o)=>this.settle_progress(n,r,o),handoffKey:n=>kk(n.id),tip:n=>this.inside===null?Dk(n.id,this.dataHubs)??ef(n.id,this.landed)??h5(n.id,this.landed)??s5(n.id,this.landed)??a5(n.id,this.landed):null,select:n=>this.node_select(n),activate:n=>{const r=this.inside===null?Xf(n.id):null;r!==null?this.plugin_frame(r):this.node_dive(n)},deselect:()=>{this.facts_clear(),this.lit!==null&&this.plugin_light(null)},replay:()=>this.replay_paint(),gesture_end:()=>this.pinch_leave()}),this.scene.strategy_set("molecule"),this.scene.physics_set(this.physics),this.frame_wire(e),this.feedFrame=new a1(e.frame??null,{...s.feed_entered!==void 0?{feed_entered:s.feed_entered}:{},...s.feed_note!==void 0?{feed_note:s.feed_note}:{},...s.feed_tag!==void 0?{feed_tag:s.feed_tag}:{},...s.feed_rename!==void 0?{feed_rename:s.feed_rename}:{},...s.feed_untag!==void 0?{feed_untag:s.feed_untag}:{},shown:()=>this.inside?.feedId??null,name:()=>this.inside?.title??"",renamed:(n,r)=>{this.inside?.feedId===n&&(this.inside={...this.inside,title:r},this.title_paint())}}),this.feedView=new p1(e.frame??null,{changed:(n,r)=>this.feedMode_apply(n,r)}),this.escape_listen=this.escape_wire(),this.scene.draw_set(this.drawMode),this.canvas.style.display="none",this.title_paint()}frame_wire(e){e.backPill?.addEventListener("click",()=>this.ascend()),e.openPill?.addEventListener("click",()=>{this.inside!==null&&this.handlers.feed_open?.(this.inside.feedId)}),e.projectionPill?.addEventListener("click",()=>m5(this.pane,this.scene,this.inside?.ids??null,s=>this.bar_note(s))),e.refreshPill?.addEventListener("click",()=>this.request()),this.replayPill=e.replayPill??null,e.replayPill?.addEventListener("click",()=>{const s=this.scene.replay_state();s===null?this.bar_note(this.replay_start(1)):s.playing?this.scene.replay_pause():this.scene.replay_play(),this.replay_paint()}),e.scalePill?.addEventListener("click",()=>{this.scale=this.scale==="jobs"?"feeds":"jobs",e.scalePill!==null&&(e.scalePill.textContent=this.scale==="jobs"?"JOBS":"ALIKE"),this.shown&&this.paint(!0,"full"),this.settings_save()}),e.viewPill?.addEventListener("click",()=>this.view_set(this.view==="feeds"?"shapes":"feeds")),this.viewPill=e.viewPill,this.gravityPill=e.gravityPill,e.gravityPill?.addEventListener("click",()=>{this.physics_set("gravity",!this.physics.gravity)}),this.densityPill=e.densityPill,e.densityPill?.addEventListener("click",()=>{this.density_set(this.density==="shape"?"census":"shape")}),this.drawPill=e.drawPill??null,this.scalePill=e.scalePill,e.drawPill?.addEventListener("click",()=>{if(this.inside!==null){this.feedView?.press("draw");return}this.draw_set(this.drawMode==="stars"?"spheres":"stars")}),this.captionsPill=e.captionsPill??null,e.captionsPill?.addEventListener("click",()=>{this.bar_note(this.captions_set(!this.captions))}),this.arrangementPill=e.arrangementPill??null,e.arrangementPill?.addEventListener("click",()=>{const s=["galaxy","spokes","clumps","constellations","data","accretion"];this.bar_note(this.arrangement_set(s[(s.indexOf(this.arrangement)+1)%s.length]))})}escape_wire(){const e=s=>{if(s.key==="Escape"&&this.scene.replay_state()!==null&&(this.pane===null||this.pane.offsetParent!==null)){this.replay_end();return}s.key!=="Escape"||this.inside===null&&this.cluster===null||this.scene.moving()||this.scene.holding_get()||this.pane!==null&&this.pane.offsetParent===null||this.ascend()};return window.addEventListener("keydown",e),e}request(){this.asking=!0,this.shown||this.wait.show("ASKING THE SESSION FOR THE SPACE",null),this.title_paint(),this.shown||this.handlers.command_run(`proc layout ${this.sessionLayoutName_derive(this.arrangement)}`),this.handlers.command_run("proc universe")}settle_progress(e,s,i){if(e>=s){this.wait.hide(),this.remember_later();return}this.wait.show(`SETTLING ${i.toLocaleString("en-US")} SPHERES`,s===0?1:e/s)}envelope_observe(e){if(e.model?.kind===JR){const i=ZR.safeParse(e.model.data);i.success&&this.sessionLayout_take(i.data.name,i.data.positions,i.data.laying??null);return}if(e.model?.kind!==XR)return;const s=YR.safeParse(e.model.data);s.success&&this.space_show(s.data)}promptContext_observe(e){if(this.disposed)return;this.identity_note(e.user,e.uri);const s=e.procWarmup?.landed??[];s.length>0&&this.shown&&this.landings_take(s);const i=e.procWarmup;if(i?.total!==void 0&&i.total>0&&i.sweeping!==!1&&!this.whole){const n=Math.floor(i.loaded/i.total*100),r=`INDEX WARMING ${i.loaded.toLocaleString()}/${i.total.toLocaleString()} (${n}%)`;r!==this.warming&&(this.warming=r,this.title_paint())}else this.shown&&!this.whole&&(i===void 0||i.sweeping===!1||i.state==="cached")&&(this.warming="",this.request());if(this.shown&&this.whole){const n=(i?.arrived??[]).join(","),r=e.procIndex?.feeds??null,o=n.length>0&&n!==this.arrivalsKey||r!==null&&this.feedsCount!==null&&r!==this.feedsCount;this.arrivalsKey=n,r!==null&&(this.feedsCount=r),o&&Date.now()-this.lastReask>w5&&(this.lastReask=Date.now(),this.request())}}size_fit(){this.scene.size_fit()}verbs_get(){return{enter:e=>this.verb_enter(e),node:e=>this.verb_node(e),state:()=>this.verb_state(),plugin:e=>this.verb_plugin(e),replay:e=>this.verb_replay(e),layout:e=>this.verb_layout(e),draw:e=>this.verb_draw(e),regrow:()=>this.verb_regrow(),captions:e=>this.verb_captions(e),density:e=>this.verb_density(e),physics:e=>this.verb_physics(e),view:e=>this.verb_view(e),cluster:e=>this.verb_cluster(e),back:()=>this.verb_back(),open:()=>this.verb_open()}}control(e,s){if(this.scene.moving()&&(e==="cluster"||e==="back"))return"universe: still moving; ask again";const i=this.verbs_get()[e];return i===void 0?"universe enter <feed>|node <instance>|cluster <feed>|view feeds|shapes|density shape|census|draw stars|spheres|captions on|off|layout galaxy|spokes|clumps|constellations|data|accretion|regrow|plugin <name>|off|replay [speed]|pause|stop|at <date>|state|physics <term> on|off|reset|back|open":i(s)}verb_enter(e){const s=parseInt(e[0]??"",10);return Number.isFinite(s)?this.landed.get(s)===void 0?`universe enter: feed ${s} has not landed here`:this.inside!==null?`universe enter: already inside feed ${this.inside.feedId}; universe back first`:(this.descend(s),`entering feed ${s}`):"universe enter <feed id>"}verb_node(e){const s=parseInt(e[0]??"",10);return Number.isFinite(s)?this.inside===null?"universe node: not inside a feed (universe enter <feed> first)":this.node_flyTo(s)?`flying into instance ${s}`:`universe node: no node of feed ${this.inside.feedId} hosts instance ${s}`:"universe node <instance id>: fly into the entered feed's node that hosts it"}verb_state(){const e=this.scene.state_get(),s=(()=>{const i=this.settingsKey_get();try{return i===null||this.store===void 0?null:this.store.getItem(i)}catch{return null}})();return[`universe: ${this.inside!==null?`inside feed ${this.inside.feedId}`:this.cluster!==null?"in a cluster":"the whole space"}; view ${this.view}, scale ${this.scale}, density ${this.density}`,`scene: ${Object.entries(e).map(([i,n])=>`${i}=${String(n)}`).join(" ")}`,`kept settings: ${s??"(none)"}`,`lit: ${this.lit??"none"}`,`captions: ${this.captions?"on":"off"}`,`session layout: ${(()=>{const i=this.sessionPlaces.get(this.sessionLayoutName_derive(this.arrangement));return i===void 0?"not asked":i===null?"none kept":`${i} places kept`})()}`,`replay: ${(()=>{const i=this.scene.replay_state();return i===null?"none":`${i.playing?"playing":"paused"} at ${new Date(i.at).toISOString().slice(0,10)} of ${new Date(i.span[0]).toISOString().slice(0,10)}..${new Date(i.span[1]).toISOString().slice(0,10)}`})()}`].join(`
4343
- `)}verb_plugin(e){const s=e[0]??"";return s===""?"universe plugin <name> | off":this.arrangement!=="constellations"||this.inside!==null||this.cluster!==null?"universe plugin: the CONSTELLATIONS layout only (universe layout constellations)":s.toLowerCase()==="off"?(this.plugin_light(null),"no plugin lit"):this.landed.all().some(i=>i.groups.some(n=>n.plugin===s))?(this.plugin_light(s),ef(`plugin:${s}`,this.landed)??s):`universe plugin: no feed here ran ${s}`}verb_replay(e){const s=(e[0]??"").toLowerCase();if(s==="stop")return this.scene.replay_state()===null?"universe replay: none is running":(this.replay_end(),"replay stopped; the space is whole");if(s==="pause")return this.scene.replay_state()===null?"universe replay: none is running":(this.scene.replay_pause(),this.replay_paint(),"replay paused");if(s==="at"){if(this.scene.replay_state()===null)return"universe replay: none is running (universe replay first)";const n=Date.parse(e[1]??"");return Number.isFinite(n)?(this.scene.replay_pause(),this.scene.replay_seek(n),this.replay_paint(),`replay at ${new Date(this.scene.replay_state()?.at??n).toISOString().slice(0,10)}`):"universe replay at <YYYY-MM-DD>"}const i=s===""?1:Number(s);return!Number.isFinite(i)||i<=0?"universe replay [speed] | pause | stop | at <YYYY-MM-DD>":this.scene.replay_state()!==null?(this.scene.replay_play(i),this.replay_paint(),`replaying at ×${i}`):this.replay_start(i)}verb_layout(e){const s=(e[0]??"").toLowerCase();return s!=="galaxy"&&s!=="spokes"&&s!=="clumps"&&s!=="constellations"&&s!=="data"&&s!=="accretion"?"universe layout galaxy|spokes|clumps|constellations|data|accretion":this.arrangement_set(s)}verb_draw(e){const s=(e[0]??"").toLowerCase();return s!=="stars"&&s!=="spheres"?"universe draw stars|spheres":this.draw_set(s)}verb_regrow(){if(this.arrangement!=="accretion"||this.inside!==null||this.cluster!==null)return"universe regrow: the ACCRETION layout only (universe layout accretion)";this.replay_end();const e=this.positionsKey_derive("accretion");try{e!==null&&this.store?.setItem(e,"{}")}catch{}return this.paint(!0,"full"),"the space regrown from its first feed"}verb_captions(e){const s=(e[0]??"").toLowerCase();return s!=="on"&&s!=="off"?"universe captions on|off":this.captions_set(s==="on")}verb_density(e){const s=(e[0]??"").toLowerCase();return s!=="shape"&&s!=="census"?"universe density shape|census":this.density_set(s)}verb_physics(e){const s=(e[0]??"").toLowerCase();if(s==="reset")return this.physics_reset();if(!["charge","link","collide","gravity"].includes(s))return"universe physics charge|link|collide|gravity [on|off] | reset";const i=(e[1]??"on").toLowerCase()!=="off";return this.physics_set(s,i)}verb_view(e){const s=(e[0]??"").toLowerCase();return s!=="feeds"&&s!=="shapes"?"universe view feeds|shapes":this.inside!==null||this.cluster!==null?"universe view: climb out first (universe back)":(this.view_set(s),s==="feeds"?"every feed its own molecule":"the shapes folded, one molecule each")}verb_cluster(e){const s=parseInt(e[0]??"",10),i=Number.isFinite(s)?this.landed.get(s):void 0;return i===void 0?"universe cluster <feed id>: the cluster of a feed that landed here":this.inside!==null?`universe cluster: inside feed ${this.inside.feedId}; universe back first`:(this.cluster_enter(Ps(i)),`viewing the cluster of feed ${s}: ${zd(Ps(i))}`)}verb_back(){return this.inside===null&&this.cluster===null?"universe back: not inside a feed or a cluster":(this.ascend(),"climbing out")}verb_open(){return this.inside===null?"universe open: not inside a feed":(this.handlers.feed_open?.(this.inside.feedId),`opening feed ${this.inside.feedId}`)}physics_set(e,s){return this.inside!==null||this.cluster!==null?"universe physics: climb out first (universe back)":e==="reach"?"universe physics: reach is the pane's own":(this.physics={...this.physics,[e]:s},this.physics_apply(),`physics ${e} ${s?"on":"off"}`)}draw_set(e){return this.replay_end(),this.drawMode=e,this.drawPill!==null&&(this.drawPill.textContent=e.toUpperCase()),this.scene.draw_set(e),this.settings_save(),e==="stars"?"every sphere a point of light":"every sphere lit and solid"}captions_set(e){return this.captions=e,this.captionsPill!==null&&(this.captionsPill.textContent=e?"CAPTIONS ON":"CAPTIONS OFF"),this.scene.captions_set(e),this.settings_save(),e?"captions on: each hub names itself and its count":"captions off: a hub names itself on hover"}arrangement_set(e){if(sf(e)&&this.view!=="feeds")return`universe layout ${e}: the FEEDS view only (universe view feeds)`;this.replay_end();const s=n=>sf(n)?n:"hubs",i=s(e)!==s(this.arrangement);return this.litHub=null,this.remember_now(),this.arrangement=e,this.arrangementPill!==null&&(this.arrangementPill.textContent=e.toUpperCase()),this.positions_recalled(e)===void 0&&this.handlers.command_run(`proc layout ${this.sessionLayoutName_derive(e)}`),this.inside===null&&this.cluster===null&&(this.scene.arrangement_set(e==="data"?"hubs":e,this.positions_recalled(e),!i),i&&this.paint(!0,this.positions_recalled(e)===void 0?"full":"hold")),this.settings_save(),e==="galaxy"?"the space finds its own shape: every sphere pushing, every edge holding":e==="spokes"?"each molecule a spoke round its hub":e==="clumps"?"molecules packed round their hub":e==="constellations"?"every plugin a star, placed by what runs with what; every feed pulled to the stars it ran":e==="data"?"every feed hung from what it began from: its format, its modality, its series":"the space grown in the order it was made: each feed wandering until it sticks, to its kin more readily than to strangers"}settingsKey_get(){return this.storeKey===null?null:this.storeKey.replace(/^argus\.universe\./,"argus.universe.settings.")}settings_save(){const e=this.settingsKey_get();if(!(this.store===void 0||e===null))try{this.store.setItem(e,JSON.stringify(n5(this.drawMode,this.view,this.scale,this.density,this.arrangement,this.captions)))}catch{}}settings_recall(){const e=this.settingsKey_get();if(this.store===void 0||e===null)return!1;let s=null;try{s=this.store.getItem(e)}catch{return!1}const i=r5(s),n=i.view!==this.view||i.scale!==this.scale;return this.drawMode=i.draw,this.view=i.view,this.scale=i.scale,this.density=i.density,this.arrangement=i.arrangement,this.arrangementPill!==null&&(this.arrangementPill.textContent=i.arrangement.toUpperCase()),this.scene.arrangement_set(i.arrangement==="data"?"hubs":i.arrangement,this.positions_recalled(i.arrangement)),this.drawPill!==null&&(this.drawPill.textContent=i.draw.toUpperCase()),this.viewPill!==null&&(this.viewPill.textContent=i.view.toUpperCase()),this.scalePill!==null&&(this.scalePill.textContent=i.scale==="jobs"?"JOBS":"ALIKE"),this.densityPill!==null&&(this.densityPill.textContent=i.density.toUpperCase()),this.scene.draw_set(i.draw),this.scene.census_set(i.density==="census"),this.captions=i.captions,this.captionsPill!==null&&(this.captionsPill.textContent=i.captions?"CAPTIONS ON":"CAPTIONS OFF"),this.scene.captions_set(i.captions),n}density_set(e){return this.replay_end(),this.density=e,this.densityPill!==null&&(this.densityPill.textContent=e.toUpperCase()),this.scene.census_set(e==="census"),this.settings_save(),e==="census"?"every job its own point":"a stage one sphere, with its count"}physics_reset(){return this.inside!==null||this.cluster!==null?"universe physics: climb out first (universe back)":(this.physics={...Dr,gravity:!0},this.physics_apply(),"physics reset")}physics_apply(){this.gravityPill!==null&&(this.gravityPill.textContent=this.physics.gravity?"GRAVITY ON":"GRAVITY OFF"),this.scene.physics_set({...this.physics,reach:this.reach??void 0}),this.title_paint()}view_set(e){if(this.replay_end(),e==="shapes"&&sf(this.arrangement)&&(this.arrangement="galaxy",this.arrangementPill!==null&&(this.arrangementPill.textContent="GALAXY"),this.scene.arrangement_set("galaxy",this.positions_recalled("galaxy"),!1)),this.remember_now(),this.view=e,this.viewPill!==null&&(this.viewPill.textContent=e.toUpperCase()),this.shown&&this.inside===null&&this.cluster===null){const s=this.positions_recalled(this.arrangement);s!==void 0?(this.scene.positions_seed(s),this.paint(!0,"new")):this.paint(!0,"full")}this.settings_save()}inside_get(){return this.inside?.feedId??null}shown_get(){return this.shown}dispose(){this.disposed=!0,this.watch_hold(null),window.removeEventListener("keydown",this.escape_listen),this.repaintTimer!==null&&window.clearTimeout(this.repaintTimer),this.rememberTimer!==null&&window.clearTimeout(this.rememberTimer),this.remember_now(),this.scene.dispose()}space_show(e){this.asking=!1;const s=`${e.whole?"W":"L"}|${e.feeds.map(i=>`${i.id}:${i.jobs}:${i.status}`).join(",")}`;if(this.shown&&s===this.spaceKey){this.title_paint();return}this.spaceKey=s,this.wait.hide(),this.whole=e.whole,this.shown||(this.shown=!0,this.seed_recall()),this.landed.clear(),this.landed.take(e.feeds),this.whole&&(this.warming=""),this.empty.style.display="none",this.canvas.style.display="block",this.inside===null&&this.cluster===null&&this.entering===null&&!this.scene.moving()?this.paint(!this.scene.camera_touched()):this.title_paint()}landings_take(e){!this.landed.take(e)||this.repaintTimer!==null||this.inside!==null||this.cluster!==null||this.entering!==null||(this.repaintTimer=window.setTimeout(()=>{this.repaintTimer=null,!(this.disposed||this.entering!==null||this.inside!==null||this.cluster!==null||this.scene.moving())&&this.paint(!this.scene.camera_touched())},v5))}paint(e=!0,s="new"){if(this.sessionWait_holds()){this.title_paint();return}const i=this.view==="shapes"?b1(this.landed.all(),this.scale):this.arrangement==="constellations"?vg(this.landed.all(),this.scale):this.arrangement==="data"?this.dataGraph_paint():this.arrangement==="accretion"?zb(this.landed.all(),this.scale):yd(this.landed.all(),this.scale),n=this.arrangement==="constellations"?this.lit:null,r=n===null?i:{nodes:i.nodes.map(a=>a.attrs?.kind==="star"||a.attrs?.plugin===n?a:{...a,dim:!0})},o=Rk(r.nodes.length);o!==this.reach&&(this.reach=o,this.scene.physics_set({reach:o},!1)),this.scene.graph_set(r,{wave:!1,fit:e,settle:s}),this.title_paint(),this.remember_later()}descend(e,s){this.replay_end();const i=this.landed.get(e),n=this.handlers.feed_dag;if(i===void 0||n===void 0||this.scene.moving()||this.inside!==null)return;this.facts_clear(),this.feedView?.recall();const r=g1(e,i);this.entering=e,this.title_paint();const o=Date.now(),a=s!==void 0?{toward:s,distance:14,durationMs:Ko}:{fit:r,durationMs:Ko};this.scene.descent(a,async()=>{const l=await n(e);if(this.disposed)return null;if(this.entering=null,l===null)return this.title_paint(),this.handlers.note?.(`universe: feed ${e}: the session gave no graph for it (feed diagram feed_${e} refused or answered nothing after ${Math.round((Date.now()-o)/1e3)}s)`),null;const c=this.insidePlan_build(e,i,l,[r,ZM(Ps(i),this.landed)],Ko);return{...c,drawn:()=>{const h=new Set(c.unfolding);this.inside={feedId:e,title:l.feedName,entered:this.insideEntered,ids:h},this.insideModel=l,this.pane?.classList.add("universe-inside"),om(this.pane,this.scene,this.inside!==null);const d=this.feedView?.modes_get()??{...xl};this.insideModes=d,this.scene.draw_set(d.draw),this.drawPill!==null&&(this.drawPill.textContent=d.draw.toUpperCase()),this.scene.waveLoop_set(d.pulse),this.feedFrame?.shown_set(!0),this.feedFrame?.arrived(e),this.watch_hold(e),this.title_paint()}}},()=>this.landed_note())}insidePlan_build(e,s,i,n,r){const o=this.feedView?.modes_get()??{...xl},a=c1(i,{metric:o.metric,hue:o.hue,legend:o.hue==="compute"?u1(i):new Map,draw:o.draw,id_map:u=>tf(e,u)});this.insideEntered=a;let l;if(o.strategy==="ranked"){l={};for(const u of kg(a.nodes.map(p=>({id:p.id,parentIds:p.parentIds,...p.metric!==void 0?{metric:p.metric}:{}}))))l[u.id]=[u.position[0],u.position[1],u.position[2]]}const c=`feed:${e}:`,h=this.view==="feeds"?o5(this.landed.all(),e,a,this.scale,this.arrangement==="constellations",this.arrangement==="data"?Sb(this.landed.all(),this.scale).graph:this.arrangement==="accretion"?zb(this.landed.all(),this.scale):void 0):{nodes:[...JM(this.landed.all(),Ps(s),this.scale).graph.nodes.filter(u=>!u.id.startsWith(c)).map(u=>({...u,dim:!0})),...a.nodes]},d=a.nodes.map(u=>u.id);return{graph:h,unfolding:d,from:n,physics:{reach:Qf,gravity:!1},...l!==void 0?{placed:l}:{},frame:d,durationMs:r,bulk:1,margin:.95}}feedMode_apply(e,s){if(this.inside===null)return;if(this.insideModes=s,e==="pulse"){this.scene.waveLoop_set(s.pulse);return}e==="draw"&&(this.scene.draw_set(s.draw),this.drawPill!==null&&(this.drawPill.textContent=s.draw.toUpperCase()));const i=this.landed.get(this.inside.feedId);if(i===void 0||this.insideModel===null||this.scene.moving())return;const n=this.inside,r=this.insidePlan_build(n.feedId,i,this.insideModel,[[...n.ids]],400);this.scene.unfold({...r,drawn:()=>{this.inside={...n,entered:this.insideEntered}}})}stage_returned(){if(this.inside===null||this.feedView===null)return;const e=this.insideModes,s=this.feedView.recall();e===null||JSON.stringify(e)===JSON.stringify(s)||(e.draw!==s.draw&&this.feedMode_apply("draw",s),e.pulse!==s.pulse&&this.feedMode_apply("pulse",s),(e.strategy!==s.strategy||e.metric!==s.metric||e.hue!==s.hue)&&this.feedMode_apply("strategy",s),this.insideModes=s)}watch_hold(e){this.watchedFeedId!==e&&(this.watchedFeedId!==null&&this.handlers.watch_set?.(`/proc/jobs/feed_${this.watchedFeedId}`,!1),this.watchedFeedId=e,this.liveState=null,e!==null&&this.handlers.watch_set?.(`/proc/jobs/feed_${e}`,!0))}watched_observe(e,s){const i=/feed_(\d+)$/.exec(e);i===null||Number(i[1])!==this.watchedFeedId||(this.liveState=s,this.title_paint())}model_refresh(e){const s=this.inside;if(s===null||s.feedId!==e.feedId||this.insideModel===null)return;const i=this.insideModel;if(this.insideModel=e,rm(i,e)){f1(this.scene,e,a=>tf(e.feedId,a));for(const a of e.nodes)this.insideEntered?.payloads.set(tf(e.feedId,a.id),a);return}const n=this.landed.get(e.feedId);if(n===void 0||this.scene.moving())return;const r=this.insidePlan_build(e.feedId,n,e,[[...s.ids]],400),o=new Set(r.unfolding);this.scene.unfold({...r,drawn:()=>{this.inside={...s,entered:this.insideEntered,ids:o},this.title_paint()}})}feedMarks_show(e,s){this.feedFrame?.show(e,s)}ascend(){if(!this.scene.moving()){if(this.framedAt=null,this.inside!==null){if(this.inside=null,this.insideModel=null,this.facts_clear(),this.pane?.classList.remove("universe-inside"),this.scene.waveLoop_set(!1),this.scene.draw_set(this.drawMode),this.drawPill!==null&&(this.drawPill.textContent=this.drawMode.toUpperCase()),this.feedFrame?.shown_set(!1),this.watch_hold(null),om(this.pane,this.scene,this.inside!==null),this.cluster!==null){this.cluster_show(this.cluster.shape);return}}else{if(this.cluster===null)return;this.cluster=null,this.pane?.classList.remove("universe-cluster")}this.paint(!1),this.scene.frame([],z5)}}cluster_enter(e){this.replay_end(),!(this.scene.moving()||this.inside!==null)&&this.cluster_show(e)}cluster_show(e){if(this.view==="feeds"){const r=l5(e,this.landed);if(r.length===0)return;this.cluster={shape:e,ids:r},this.pane?.classList.add("universe-cluster"),this.scene.relight(c5(this.landed.all(),e,this.scale),r,Ko,()=>this.landed_note(),()=>this.title_paint());return}const{graph:s,memberIds:i}=JM(this.landed.all(),e,this.scale);if(i.length===0)return;this.cluster={shape:e,ids:i},this.pane?.classList.add("universe-cluster");const n=new Set(i);this.scene.unfold({graph:s,unfolding:s.nodes.filter(r=>n.has(r.id)||r.ghost===!0).map(r=>r.id),from:[ZM(e,this.landed)],physics:{reach:Qf,gravity:!1},frame:i,durationMs:Ko,drawn:()=>this.title_paint()},()=>this.landed_note())}landed_note(){this.framedAt=this.scene.camera_distance()}pinch_leave(){this.inside===null&&this.cluster===null||this.scene.moving()||this.scene.holding_get()||this.framedAt===null||this.scene.camera_distance()<=this.framedAt*S5||this.ascend()}node_dive(e){const s=this.inside?.entered.payloads.get(e.id),i=this.handlers.node_dive;s===void 0||i===void 0||this.scene.moving()||this.scene.flight_into(e.id,()=>i(s.vfsPath))}flight_back(e){this.scene.flight_back(e)}node_flyTo(e){if(this.inside===null)return!1;for(const[s,i]of this.inside.entered.payloads){if(i.instanceId!==e)continue;const n=this.handlers.node_dive;return n===void 0?!1:(this.scene.flight_into(s,()=>n(i.vfsPath)),!0)}return!1}node_select(e){if(this.scene.moving())return;if(this.inside===null){const i=Xf(e.id);if(i!==null){this.plugin_light(this.lit===i?null:i);return}const n=Jf(e.id);if(n!==null){this.litHub=this.litHub===n?null:n,this.paint(!1,"hold");return}const r=e.id.match(/^feed:(\d+):\d+$/),o=pz(e.id);r!==null?this.descend(Number(r[1]),e.id):o!==null?this.cluster_enter(o):e.id.startsWith("shape:")&&this.cluster_enter(e.id.slice(6));return}const s=this.inside.entered.payloads.get(e.id);s!==void 0&&this.facts_show(e,s)}facts_show(e,s){this.facts!==null&&(o1(this.facts,s,{enter:()=>{this.handlers.node_dive!==void 0?this.node_dive(e):this.handlers.node_enter?.(s.vfsPath)},...this.handlers.node_process!==void 0?{process:this.handlers.node_process}:{}}),this.facts.hidden=!1)}facts_clear(){this.facts!==null&&(this.facts.replaceChildren(),this.facts.hidden=!0)}state_stand(e,s){this.state!==null&&this.noteTimer===null&&ys(this.state,e,s)}bar_note(e){this.state!==null&&(this.noteTimer!==null&&clearTimeout(this.noteTimer),this.noteTimer=null,ys(this.state,"note",e),this.noteTimer=setTimeout(()=>{this.noteTimer=null,ea(this.state,"note"),this.title_paint()},g5))}title_paint(){if(this.entering!==null&&this.inside===null){const s=this.landed.get(this.entering);this.title.textContent=`UNIVERSE — ENTERING FEED ${this.entering}${s!==void 0&&s.title.length>0?` · ${s.title}`:""} …`,this.state_stand("wait","ASKING");return}if(this.inside!==null){const s=this.inside.entered.nodes.reduce((i,n)=>i+(n.count??1),0);this.title.textContent=`UNIVERSE — INSIDE FEED ${this.inside.feedId} · ${this.inside.title} · ${s.toLocaleString("en-US")} JOBS`,this.state_stand(this.liveState==="stale"?"stale":"live",this.liveState===null?"INSIDE":`INSIDE · ${this.liveState.toUpperCase()}`);return}if(this.cluster!==null){const s=this.landed.all().filter(i=>Ps(i)===this.cluster?.shape).length;this.title.textContent=`UNIVERSE — SHAPE ${_1(this.cluster.shape)} · ${s} FEED${s===1?"":"S"}`,this.state_stand("live","CLUSTER");return}if(this.asking&&!this.shown){this.title.textContent="UNIVERSE — ASKING THE SESSION …",this.state_stand("wait","ASKING");return}const e=`${this.landed.size()} FEEDS · ${this.landed.shapes()} SHAPES`;this.title.textContent=this.whole?`UNIVERSE — ${e}`:`UNIVERSE — ${e}${this.warming.length>0?` · ${this.warming}`:" · INDEX WARMING"}`,this.state_stand(this.whole?"settled":"wait",this.whole?"WHOLE":"LANDING"),this.scene.replay_state()!==null&&this.replay_paint()}replay_start(e){if(this.inside!==null||this.cluster!==null)return"universe replay: climb out first (universe back)";if(this.view!=="feeds")return"universe replay: the FEEDS view only (universe view feeds)";if(this.density!=="shape")return"universe replay: SHAPE density only (universe density shape)";if(this.drawMode!=="stars")return"universe replay: it draws stars (universe draw stars)";const s=new Map;for(const a of this.landed.all()){const l=Date.parse(a.createdAt??"");Number.isFinite(l)&&s.set(a.id,l)}if(s.size===0)return"universe replay: the session does not say when its feeds were made (a daemon from before the replay: restart it)";const i=new Map;for(const a of Object.keys(this.scene.positions_get())){const l=a.match(/^feed:(\d+):/),c=l===null?void 0:s.get(Number(l[1]));c!==void 0&&i.set(a,c)}this.facts_clear(),this.replayDay="",this.scene.replay_begin(i,e),this.replay_paint();const n=this.scene.replay_state(),r=new Date(n?.span[0]??0).toISOString().slice(0,10),o=new Date(n?.span[1]??0).toISOString().slice(0,10);return`replaying ${s.size} feeds, ${r} to ${o}, at ×${e} (universe replay pause | stop | at <date>; Esc stops)`}plugin_light(e){this.lit=e,e===null?this.facts_clear():this.pluginFacts_show(e),this.shown&&this.inside===null&&this.cluster===null&&this.paint(!1,"hold")}plugin_frame(e){this.lit!==e&&this.plugin_light(e);const s=[];for(const i of this.landed.all())i.groups.forEach((n,r)=>{n.plugin===e&&s.push(`feed:${i.id}:${r}`)});s.length===0||this.scene.moving()||this.scene.frame(s,Ko,void 0,.9)}pluginFacts_show(e){if(this.facts===null)return;this.facts.replaceChildren();const s=ef(`plugin:${e}`,this.landed)??e,[,i="",n=""]=s.split(" · ");for(const[a,l]of[["PLUGIN",e],["FEEDS",i.replace(/ feeds?$/,"")],["ERRORED",n.replace(/ errored$/,"")]]){const c=document.createElement("div");c.className="telemetry-row";const h=document.createElement("span");h.className="telemetry-label",h.textContent=a;const d=document.createElement("span");d.className="telemetry-value",d.textContent=l,c.append(h,d),this.facts.append(c)}const r=document.createElement("div");r.className="universe-node-verbs";const o=document.createElement("button");o.className="pacs-capsule universe-plugin-open",o.textContent="OPEN IN /BIN",o.title="the plugin in the files browser: its one-node graph, its parameters",o.addEventListener("click",()=>this.handlers.plugin_open?.(e)),r.append(o),this.facts.append(r),this.facts.hidden=!1}dataGraph_paint(){const{graph:e,hubs:s}=Sb(this.landed.all(),this.scale);this.dataHubs=s;const i=this.litHub;if(i===null)return e;const n=uz(this.landed.all().map(o=>o.data?.seriesDescription).filter(o=>o!==void 0)),r=new Set(this.landed.all().filter(o=>fz(o,n).some(a=>a.key===i)).map(o=>o.id));return{nodes:e.nodes.map(o=>{if(Jf(o.id)!==null)return o;const a=o.id.match(/^feed:(\d+):/);return a!==null&&r.has(Number(a[1]))?o:{...o,dim:!0}})}}replay_end(){this.scene.replay_state()!==null&&(this.scene.replay_stop(),this.replayDay="",this.title_paint(),this.replay_paint())}replay_paint(){const e=this.scene.replay_state();if(this.replayPill!==null){const i=e!==null&&!e.playing&&e.at>=e.span[1];this.replayPill.textContent=e===null?"REPLAY":e.playing?"PLAYING":i?"REPLAYED":"PAUSED",this.replayPill.classList.toggle("rail-off",e===null)}if(e===null||this.state===null)return;const s=`${e.playing?"REPLAY":"PAUSED"} ${new Date(e.at).toISOString().slice(0,10)}`;s!==this.replayDay&&(this.replayDay=s,this.state_stand("live",s))}identity_note(e,s){const i=i5(e,s);if(i===this.storeKey)return;this.storeKey=i;const n=this.settings_recall();if(this.shown){const r=this.seed_recall();(n||r)&&this.inside===null&&this.cluster===null&&this.paint(!1)}}positionsKey_derive(e){if(this.storeKey===null)return null;const s=e==="galaxy"?this.storeKey:`${this.storeKey}.${e}`;return this.view==="shapes"?`${s}.shapes`:s}positions_recalled(e){const s=this.positionsKey_derive(e);if(!(this.store===void 0||s===null))try{const i=XM(this.store.getItem(s));return Object.keys(i).length>0?i:void 0}catch{return}}seed_recall(){const e=this.positionsKey_derive(this.arrangement);if(this.store===void 0||e===null)return!1;const s=XM(this.store.getItem(e));return Object.keys(s).length===0?!1:(this.scene.positions_seed(s),!0)}remember_later(){this.rememberTimer===null&&(this.rememberTimer=window.setTimeout(()=>{this.rememberTimer=null,this.remember_now()},y5))}remember_now(){if(!(this.store===void 0||this.storeKey===null||!this.shown)&&this.positions_matchView(this.scene.positions_get())){try{const e=this.positionsKey_derive(this.arrangement);e!==null&&this.store.setItem(e,JSON.stringify(this.scene.positions_get()))}catch{}this.sessionLayout_put()}}positions_matchView(e){const s=Object.keys(e),i=s.some(r=>r.startsWith("fold:")),n=s.some(r=>r.startsWith("feed:"));return this.view==="shapes"?i&&!n:!i}sessionLayoutName_derive(e){return`${e}${this.view==="shapes"?"-shapes":""}${this.scale==="feeds"?"-alike":""}`}sessionLayout_take(e,s,i=null){if((s!==null||!this.sessionPlaces.has(e))&&this.sessionPlaces.set(e,s===null?null:Object.keys(s).length),s===null&&i!==null){this.sessionWait_hold(e,i);return}const n=this.sessionWait?.name===e;if(n&&this.sessionWait_end(),s===null||this.store===void 0){n&&this.shown&&this.paint(!0,"full");return}const r=["galaxy","spokes","clumps","constellations","data","accretion"].find(a=>this.sessionLayoutName_derive(a)===e);if(r===void 0||this.positions_recalled(r)!==void 0)return;const o=this.positionsKey_derive(r);if(o!==null){try{this.store.setItem(o,JSON.stringify(s))}catch{return}this.putSignatures.set(e,QM(s)),r===this.arrangement&&this.shown&&this.inside===null&&this.cluster===null&&this.entering===null&&(this.scene.positions_seed(s),this.paint(n,"new"))}}sessionWait_hold(e,s){if(e!==this.sessionLayoutName_derive(this.arrangement)||this.positions_recalled(this.arrangement)!==void 0)return;const i=this.sessionWait?.name===e?this.sessionWait.until:Date.now()+b5;if(this.sessionWait?.timer!==void 0&&this.sessionWait?.timer!==null&&window.clearTimeout(this.sessionWait.timer),Date.now()>=i){this.sessionWait_end(),this.shown&&this.paint(!0,"full");return}this.wait.show(`LAYING OUT ${s.nodes.toLocaleString("en-US")} SPHERES · THE SESSION`,s.fraction);const n=window.setTimeout(()=>{this.handlers.command_run(`proc layout ${e}`)},M5);this.sessionWait={name:e,until:i,timer:n}}sessionWait_end(){this.sessionWait?.timer!==void 0&&this.sessionWait?.timer!==null&&window.clearTimeout(this.sessionWait.timer),this.sessionWait=null,this.wait.hide()}sessionWait_holds(){return this.sessionWait!==null&&this.sessionWait.name===this.sessionLayoutName_derive(this.arrangement)&&Date.now()<this.sessionWait.until&&this.inside===null&&this.cluster===null}sessionLayout_put(){if(this.inside!==null||this.cluster!==null||this.scene.replay_state()!==null||!this.whole||!_5(this.physics))return;const e={};for(const[n,r]of Object.entries(this.scene.positions_get()))r.every(o=>Number.isFinite(o))&&(e[n]=[Math.round(r[0]*100)/100,Math.round(r[1]*100)/100,Math.round(r[2]*100)/100]);if(Object.keys(e).length===0)return;const s=this.sessionLayoutName_derive(this.arrangement),i=QM(e);this.putSignatures.get(s)!==i&&(this.putSignatures.set(s,i),this.sessionPlaces.set(s,Object.keys(e).length),this.handlers.command_run(`proc layout put ${s} '${JSON.stringify(e).replace(/'/g,"'\\''")}'`))}}function Ji(t){return`'${t.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}'`}function M1(t,e){return`touch --withContents=${Ji(e)} ${Ji(t)}`}function v1(t){return`edit ${Ji(t)}`}function O5(t,e,s){return e<s?null:`edit: ${t} is ${(e/(1024*1024)).toFixed(1)} MB; open it in the editor? `}async function ra(t,e){const{terminal:s,client:i}=t;s.line_echo(e);let n;try{n=await i.line_execute(e)}catch(r){return s.output_write("err",`\x1B[31m${r instanceof Error?r.message:String(r)}\x1B[0m
4343
+ `)}verb_plugin(e){const s=e[0]??"";return s===""?"universe plugin <name> | off":this.arrangement!=="constellations"||this.inside!==null||this.cluster!==null?"universe plugin: the CONSTELLATIONS layout only (universe layout constellations)":s.toLowerCase()==="off"?(this.plugin_light(null),"no plugin lit"):this.landed.all().some(i=>i.groups.some(n=>n.plugin===s))?(this.plugin_light(s),ef(`plugin:${s}`,this.landed)??s):`universe plugin: no feed here ran ${s}`}verb_replay(e){const s=(e[0]??"").toLowerCase();if(s==="stop")return this.scene.replay_state()===null?"universe replay: none is running":(this.replay_end(),"replay stopped; the space is whole");if(s==="pause")return this.scene.replay_state()===null?"universe replay: none is running":(this.scene.replay_pause(),this.replay_paint(),"replay paused");if(s==="at"){if(this.scene.replay_state()===null)return"universe replay: none is running (universe replay first)";const n=Date.parse(e[1]??"");return Number.isFinite(n)?(this.scene.replay_pause(),this.scene.replay_seek(n),this.replay_paint(),`replay at ${new Date(this.scene.replay_state()?.at??n).toISOString().slice(0,10)}`):"universe replay at <YYYY-MM-DD>"}const i=s===""?1:Number(s);return!Number.isFinite(i)||i<=0?"universe replay [speed] | pause | stop | at <YYYY-MM-DD>":this.scene.replay_state()!==null?(this.scene.replay_play(i),this.replay_paint(),`replaying at ×${i}`):this.replay_start(i)}verb_layout(e){const s=(e[0]??"").toLowerCase();return s!=="galaxy"&&s!=="spokes"&&s!=="clumps"&&s!=="constellations"&&s!=="data"&&s!=="accretion"?"universe layout galaxy|spokes|clumps|constellations|data|accretion":this.arrangement_set(s)}verb_draw(e){const s=(e[0]??"").toLowerCase();return s!=="stars"&&s!=="spheres"?"universe draw stars|spheres":this.draw_set(s)}verb_regrow(){if(this.arrangement!=="accretion"||this.inside!==null||this.cluster!==null)return"universe regrow: the ACCRETION layout only (universe layout accretion)";this.replay_end();const e=this.positionsKey_derive("accretion");try{e!==null&&this.store?.setItem(e,"{}")}catch{}return this.paint(!0,"full"),"the space regrown from its first feed"}verb_captions(e){const s=(e[0]??"").toLowerCase();return s!=="on"&&s!=="off"?"universe captions on|off":this.captions_set(s==="on")}verb_density(e){const s=(e[0]??"").toLowerCase();return s!=="shape"&&s!=="census"?"universe density shape|census":this.density_set(s)}verb_physics(e){const s=(e[0]??"").toLowerCase();if(s==="reset")return this.physics_reset();if(!["charge","link","collide","gravity"].includes(s))return"universe physics charge|link|collide|gravity [on|off] | reset";const i=(e[1]??"on").toLowerCase()!=="off";return this.physics_set(s,i)}verb_view(e){const s=(e[0]??"").toLowerCase();return s!=="feeds"&&s!=="shapes"?"universe view feeds|shapes":this.inside!==null||this.cluster!==null?"universe view: climb out first (universe back)":(this.view_set(s),s==="feeds"?"every feed its own molecule":"the shapes folded, one molecule each")}verb_cluster(e){const s=parseInt(e[0]??"",10),i=Number.isFinite(s)?this.landed.get(s):void 0;return i===void 0?"universe cluster <feed id>: the cluster of a feed that landed here":this.inside!==null?`universe cluster: inside feed ${this.inside.feedId}; universe back first`:(this.cluster_enter(Ps(i)),`viewing the cluster of feed ${s}: ${zd(Ps(i))}`)}verb_back(){return this.inside===null&&this.cluster===null?"universe back: not inside a feed or a cluster":(this.ascend(),"climbing out")}verb_open(){return this.inside===null?"universe open: not inside a feed":(this.handlers.feed_open?.(this.inside.feedId),`opening feed ${this.inside.feedId}`)}physics_set(e,s){return this.inside!==null||this.cluster!==null?"universe physics: climb out first (universe back)":e==="reach"?"universe physics: reach is the pane's own":(this.physics={...this.physics,[e]:s},this.physics_apply(),`physics ${e} ${s?"on":"off"}`)}draw_set(e){return this.replay_end(),this.drawMode=e,this.drawPill!==null&&(this.drawPill.textContent=e.toUpperCase()),this.scene.draw_set(e),this.settings_save(),e==="stars"?"every sphere a point of light":"every sphere lit and solid"}captions_set(e){return this.captions=e,this.captionsPill!==null&&(this.captionsPill.textContent=e?"CAPTIONS ON":"CAPTIONS OFF"),this.scene.captions_set(e),this.settings_save(),e?"captions on: each hub names itself and its count":"captions off: a hub names itself on hover"}arrangement_set(e){if(sf(e)&&this.view!=="feeds")return`universe layout ${e}: the FEEDS view only (universe view feeds)`;this.replay_end();const s=n=>sf(n)?n:"hubs",i=s(e)!==s(this.arrangement);return this.litHub=null,this.remember_now(),this.arrangement=e,this.arrangementPill!==null&&(this.arrangementPill.textContent=e.toUpperCase()),this.positions_recalled(e)===void 0&&this.handlers.command_run(`proc layout ${this.sessionLayoutName_derive(e)}`),this.inside===null&&this.cluster===null&&(this.scene.arrangement_set(e==="data"?"hubs":e,this.positions_recalled(e),!i),i&&this.paint(!0,this.positions_recalled(e)===void 0?"full":"hold")),this.settings_save(),e==="galaxy"?"the space finds its own shape: every sphere pushing, every edge holding":e==="spokes"?"each molecule a spoke round its hub":e==="clumps"?"molecules packed round their hub":e==="constellations"?"every plugin a star, placed by what runs with what; every feed pulled to the stars it ran":e==="data"?"every feed hung from what it began from: its format, its modality, its series":"the space grown in the order it was made: each feed wandering until it sticks, to its kin more readily than to strangers"}settingsKey_get(){return this.storeKey===null?null:this.storeKey.replace(/^argus\.universe\./,"argus.universe.settings.")}settings_save(){const e=this.settingsKey_get();if(!(this.store===void 0||e===null))try{this.store.setItem(e,JSON.stringify(n5(this.drawMode,this.view,this.scale,this.density,this.arrangement,this.captions)))}catch{}}settings_recall(){const e=this.settingsKey_get();if(this.store===void 0||e===null)return!1;let s=null;try{s=this.store.getItem(e)}catch{return!1}const i=r5(s),n=i.view!==this.view||i.scale!==this.scale;return this.drawMode=i.draw,this.view=i.view,this.scale=i.scale,this.density=i.density,this.arrangement=i.arrangement,this.arrangementPill!==null&&(this.arrangementPill.textContent=i.arrangement.toUpperCase()),this.scene.arrangement_set(i.arrangement==="data"?"hubs":i.arrangement,this.positions_recalled(i.arrangement)),this.drawPill!==null&&(this.drawPill.textContent=i.draw.toUpperCase()),this.viewPill!==null&&(this.viewPill.textContent=i.view.toUpperCase()),this.scalePill!==null&&(this.scalePill.textContent=i.scale==="jobs"?"JOBS":"ALIKE"),this.densityPill!==null&&(this.densityPill.textContent=i.density.toUpperCase()),this.scene.draw_set(i.draw),this.scene.census_set(i.density==="census"),this.captions=i.captions,this.captionsPill!==null&&(this.captionsPill.textContent=i.captions?"CAPTIONS ON":"CAPTIONS OFF"),this.scene.captions_set(i.captions),n}density_set(e){return this.replay_end(),this.density=e,this.densityPill!==null&&(this.densityPill.textContent=e.toUpperCase()),this.scene.census_set(e==="census"),this.settings_save(),e==="census"?"every job its own point":"a stage one sphere, with its count"}physics_reset(){return this.inside!==null||this.cluster!==null?"universe physics: climb out first (universe back)":(this.physics={...Dr,gravity:!0},this.physics_apply(),"physics reset")}physics_apply(){this.gravityPill!==null&&(this.gravityPill.textContent=this.physics.gravity?"GRAVITY ON":"GRAVITY OFF"),this.scene.physics_set({...this.physics,reach:this.reach??void 0}),this.title_paint()}view_set(e){if(this.replay_end(),e==="shapes"&&sf(this.arrangement)&&(this.arrangement="galaxy",this.arrangementPill!==null&&(this.arrangementPill.textContent="GALAXY"),this.scene.arrangement_set("galaxy",this.positions_recalled("galaxy"),!1)),this.remember_now(),this.view=e,this.viewPill!==null&&(this.viewPill.textContent=e.toUpperCase()),this.shown&&this.inside===null&&this.cluster===null){const s=this.positions_recalled(this.arrangement);s!==void 0?(this.scene.positions_seed(s),this.paint(!0,"new")):this.paint(!0,"full")}this.settings_save()}inside_get(){return this.inside?.feedId??null}shown_get(){return this.shown}dispose(){this.disposed=!0,this.watch_hold(null),window.removeEventListener("keydown",this.escape_listen),this.repaintTimer!==null&&window.clearTimeout(this.repaintTimer),this.rememberTimer!==null&&window.clearTimeout(this.rememberTimer),this.remember_now(),this.scene.dispose()}space_show(e){this.asking=!1;const s=`${e.whole?"W":"L"}|${e.feeds.map(i=>`${i.id}:${i.jobs}:${i.status}`).join(",")}`;if(this.shown&&s===this.spaceKey){this.title_paint();return}this.spaceKey=s,this.wait.hide(),this.whole=e.whole,this.shown||(this.shown=!0,this.seed_recall()),this.landed.clear(),this.landed.take(e.feeds),this.whole&&(this.warming=""),this.empty.style.display="none",this.canvas.style.display="block",this.inside===null&&this.cluster===null&&this.entering===null&&!this.scene.moving()?this.paint(!this.scene.camera_touched()):this.title_paint()}landings_take(e){!this.landed.take(e)||this.repaintTimer!==null||this.inside!==null||this.cluster!==null||this.entering!==null||(this.repaintTimer=window.setTimeout(()=>{this.repaintTimer=null,!(this.disposed||this.entering!==null||this.inside!==null||this.cluster!==null||this.scene.moving())&&this.paint(!this.scene.camera_touched())},v5))}paint(e=!0,s="new"){if(this.sessionWait_holds()){this.title_paint();return}const i=this.view==="shapes"?b1(this.landed.all(),this.scale):this.arrangement==="constellations"?vg(this.landed.all(),this.scale):this.arrangement==="data"?this.dataGraph_paint():this.arrangement==="accretion"?zb(this.landed.all(),this.scale):yd(this.landed.all(),this.scale),n=this.arrangement==="constellations"?this.lit:null,r=n===null?i:{nodes:i.nodes.map(a=>a.attrs?.kind==="star"||a.attrs?.plugin===n?a:{...a,dim:!0})},o=Rk(r.nodes.length);o!==this.reach&&(this.reach=o,this.scene.physics_set({reach:o},!1)),this.scene.graph_set(r,{wave:!1,fit:e,settle:s}),this.title_paint(),this.remember_later()}descend(e,s){this.replay_end();const i=this.landed.get(e),n=this.handlers.feed_dag;if(i===void 0||n===void 0||this.scene.moving()||this.inside!==null)return;this.facts_clear(),this.feedView?.recall();const r=g1(e,i);this.entering=e,this.title_paint();const o=Date.now(),a=s!==void 0?{toward:s,distance:14,durationMs:Ko}:{fit:r,durationMs:Ko};this.scene.descent(a,async()=>{const l=await n(e);if(this.disposed)return null;if(this.entering=null,l===null)return this.title_paint(),this.handlers.note?.(`universe: feed ${e}: the session gave no graph for it (feed diagram feed_${e} refused or answered nothing after ${Math.round((Date.now()-o)/1e3)}s)`),null;const c=this.insidePlan_build(e,i,l,[r,ZM(Ps(i),this.landed)],Ko);return{...c,drawn:()=>{const h=new Set(c.unfolding);this.inside={feedId:e,title:l.feedName,entered:this.insideEntered,ids:h},this.insideModel=l,this.pane?.classList.add("universe-inside"),om(this.pane,this.scene,this.inside!==null);const d=this.feedView?.modes_get()??{...xl};this.insideModes=d,this.scene.draw_set(d.draw),this.drawPill!==null&&(this.drawPill.textContent=d.draw.toUpperCase()),this.scene.waveLoop_set(d.pulse),this.feedFrame?.shown_set(!0),this.feedFrame?.arrived(e),this.watch_hold(e),this.title_paint()}}},()=>this.landed_note())}insidePlan_build(e,s,i,n,r){const o=this.feedView?.modes_get()??{...xl},a=c1(i,{metric:o.metric,hue:o.hue,legend:o.hue==="compute"?u1(i):new Map,draw:o.draw,id_map:u=>tf(e,u)});this.insideEntered=a;let l;if(o.strategy==="ranked"){l={};for(const u of kg(a.nodes.map(p=>({id:p.id,parentIds:p.parentIds,...p.metric!==void 0?{metric:p.metric}:{}}))))l[u.id]=[u.position[0],u.position[1],u.position[2]]}const c=`feed:${e}:`,h=this.view==="feeds"?o5(this.landed.all(),e,a,this.scale,this.arrangement==="constellations",this.arrangement==="data"?Sb(this.landed.all(),this.scale).graph:this.arrangement==="accretion"?zb(this.landed.all(),this.scale):void 0):{nodes:[...JM(this.landed.all(),Ps(s),this.scale).graph.nodes.filter(u=>!u.id.startsWith(c)).map(u=>({...u,dim:!0})),...a.nodes]},d=a.nodes.map(u=>u.id);return{graph:h,unfolding:d,from:n,physics:{reach:Qf,gravity:!1},...l!==void 0?{placed:l}:{},frame:d,durationMs:r,bulk:1,margin:.95}}feedMode_apply(e,s){if(this.inside===null)return;if(this.insideModes=s,e==="pulse"){this.scene.waveLoop_set(s.pulse);return}e==="draw"&&(this.scene.draw_set(s.draw),this.drawPill!==null&&(this.drawPill.textContent=s.draw.toUpperCase()));const i=this.landed.get(this.inside.feedId);if(i===void 0||this.insideModel===null||this.scene.moving())return;const n=this.inside,r=this.insidePlan_build(n.feedId,i,this.insideModel,[[...n.ids]],400);this.scene.unfold({...r,drawn:()=>{this.inside={...n,entered:this.insideEntered}}})}stage_returned(){if(this.inside===null||this.feedView===null)return;const e=this.insideModes,s=this.feedView.recall();e===null||JSON.stringify(e)===JSON.stringify(s)||(e.draw!==s.draw&&this.feedMode_apply("draw",s),e.pulse!==s.pulse&&this.feedMode_apply("pulse",s),(e.strategy!==s.strategy||e.metric!==s.metric||e.hue!==s.hue)&&this.feedMode_apply("strategy",s),this.insideModes=s)}watch_hold(e){this.watchedFeedId!==e&&(this.watchedFeedId!==null&&this.handlers.watch_set?.(`/proc/jobs/feed_${this.watchedFeedId}`,!1),this.watchedFeedId=e,this.liveState=null,e!==null&&this.handlers.watch_set?.(`/proc/jobs/feed_${e}`,!0))}watched_observe(e,s){const i=/feed_(\d+)$/.exec(e);i===null||Number(i[1])!==this.watchedFeedId||(this.liveState=s,this.title_paint())}model_refresh(e){const s=this.inside;if(s===null||s.feedId!==e.feedId||this.insideModel===null)return;const i=this.insideModel;if(this.insideModel=e,rm(i,e)){f1(this.scene,e,a=>tf(e.feedId,a));for(const a of e.nodes)this.insideEntered?.payloads.set(tf(e.feedId,a.id),a);return}const n=this.landed.get(e.feedId);if(n===void 0||this.scene.moving())return;const r=this.insidePlan_build(e.feedId,n,e,[[...s.ids]],400),o=new Set(r.unfolding);this.scene.unfold({...r,drawn:()=>{this.inside={...s,entered:this.insideEntered,ids:o},this.title_paint()}})}feedMarks_show(e,s){this.feedFrame?.show(e,s)}ascend(){if(!this.scene.moving()){if(this.framedAt=null,this.inside!==null){if(this.inside=null,this.insideModel=null,this.facts_clear(),this.pane?.classList.remove("universe-inside"),this.scene.waveLoop_set(!1),this.scene.draw_set(this.drawMode),this.drawPill!==null&&(this.drawPill.textContent=this.drawMode.toUpperCase()),this.feedFrame?.shown_set(!1),this.watch_hold(null),om(this.pane,this.scene,this.inside!==null),this.cluster!==null){this.cluster_show(this.cluster.shape);return}}else{if(this.cluster===null)return;this.cluster=null,this.pane?.classList.remove("universe-cluster")}this.paint(!1),this.scene.frame([],z5)}}cluster_enter(e){this.replay_end(),!(this.scene.moving()||this.inside!==null)&&this.cluster_show(e)}cluster_show(e){if(this.view==="feeds"){const r=l5(e,this.landed);if(r.length===0)return;this.cluster={shape:e,ids:r},this.pane?.classList.add("universe-cluster"),this.scene.relight(c5(this.landed.all(),e,this.scale),r,Ko,()=>this.landed_note(),()=>this.title_paint());return}const{graph:s,memberIds:i}=JM(this.landed.all(),e,this.scale);if(i.length===0)return;this.cluster={shape:e,ids:i},this.pane?.classList.add("universe-cluster");const n=new Set(i);this.scene.unfold({graph:s,unfolding:s.nodes.filter(r=>n.has(r.id)||r.ghost===!0).map(r=>r.id),from:[ZM(e,this.landed)],physics:{reach:Qf,gravity:!1},frame:i,durationMs:Ko,drawn:()=>this.title_paint()},()=>this.landed_note())}landed_note(){this.framedAt=this.scene.camera_distance()}pinch_leave(){this.inside===null&&this.cluster===null||this.scene.moving()||this.scene.holding_get()||this.framedAt===null||this.scene.camera_distance()<=this.framedAt*S5||this.ascend()}node_dive(e){const s=this.inside?.entered.payloads.get(e.id),i=this.handlers.node_dive;s===void 0||i===void 0||this.scene.moving()||this.scene.flight_into(e.id,()=>i(s.vfsPath))}flight_back(e){this.scene.flight_back(e)}node_flyTo(e){if(this.inside===null)return!1;for(const[s,i]of this.inside.entered.payloads){if(i.instanceId!==e)continue;const n=this.handlers.node_dive;return n===void 0?!1:(this.scene.flight_into(s,()=>n(i.vfsPath)),!0)}return!1}node_select(e){if(this.scene.moving())return;if(this.inside===null){const i=Xf(e.id);if(i!==null){this.plugin_light(this.lit===i?null:i);return}const n=Jf(e.id);if(n!==null){this.litHub=this.litHub===n?null:n,this.paint(!1,"hold");return}const r=e.id.match(/^feed:(\d+):\d+$/),o=pz(e.id);r!==null?this.descend(Number(r[1]),e.id):o!==null?this.cluster_enter(o):e.id.startsWith("shape:")&&this.cluster_enter(e.id.slice(6));return}const s=this.inside.entered.payloads.get(e.id);s!==void 0&&this.facts_show(e,s)}facts_show(e,s){this.facts!==null&&(o1(this.facts,s,{enter:()=>{this.handlers.node_dive!==void 0?this.node_dive(e):this.handlers.node_enter?.(s.vfsPath)},...this.handlers.node_process!==void 0?{process:this.handlers.node_process}:{}}),this.facts.hidden=!1)}facts_clear(){this.facts!==null&&(this.facts.replaceChildren(),this.facts.hidden=!0)}state_stand(e,s){this.state!==null&&this.noteTimer===null&&ys(this.state,e,s)}bar_note(e){this.state!==null&&(this.noteTimer!==null&&clearTimeout(this.noteTimer),this.noteTimer=null,ys(this.state,"note",e),this.noteTimer=setTimeout(()=>{this.noteTimer=null,ea(this.state,"note"),this.title_paint()},g5))}title_paint(){if(this.entering!==null&&this.inside===null){const s=this.landed.get(this.entering);this.title.textContent=`UNIVERSE — ENTERING FEED ${this.entering}${s!==void 0&&s.title.length>0?` · ${s.title}`:""} …`,this.state_stand("wait","ASKING");return}if(this.inside!==null){const s=this.inside.entered.nodes.reduce((i,n)=>i+(n.count??1),0);this.title.textContent=`UNIVERSE — INSIDE FEED ${this.inside.feedId} · ${this.inside.title} · ${s.toLocaleString("en-US")} JOBS`,this.state_stand(this.liveState==="stale"?"stale":"live",this.liveState===null?"INSIDE":`INSIDE · ${this.liveState.toUpperCase()}`);return}if(this.cluster!==null){const s=this.landed.all().filter(i=>Ps(i)===this.cluster?.shape).length;this.title.textContent=`UNIVERSE — SHAPE ${_1(this.cluster.shape)} · ${s} FEED${s===1?"":"S"}`,this.state_stand("live","CLUSTER");return}if(this.asking&&!this.shown){this.title.textContent="UNIVERSE — ASKING THE SESSION …",this.state_stand("wait","ASKING");return}const e=`${this.landed.size()} FEEDS · ${this.landed.shapes()} SHAPES`;this.title.textContent=this.whole?`UNIVERSE — ${e}`:`UNIVERSE — ${e}${this.warming.length>0?` · ${this.warming}`:" · INDEX WARMING"}`,this.state_stand(this.whole?"settled":"wait",this.whole?"WHOLE":"LANDING"),this.scene.replay_state()!==null&&this.replay_paint()}replay_start(e){if(this.inside!==null||this.cluster!==null)return"universe replay: climb out first (universe back)";if(this.view!=="feeds")return"universe replay: the FEEDS view only (universe view feeds)";if(this.density!=="shape")return"universe replay: SHAPE density only (universe density shape)";if(this.drawMode!=="stars")return"universe replay: it draws stars (universe draw stars)";const s=new Map;for(const a of this.landed.all()){const l=Date.parse(a.createdAt??"");Number.isFinite(l)&&s.set(a.id,l)}if(s.size===0)return"universe replay: the session does not say when its feeds were made (a daemon from before the replay: restart it)";const i=new Map;for(const a of Object.keys(this.scene.positions_get())){const l=a.match(/^feed:(\d+):/),c=l===null?void 0:s.get(Number(l[1]));c!==void 0&&i.set(a,c)}this.facts_clear(),this.replayDay="",this.scene.replay_begin(i,e),this.replay_paint();const n=this.scene.replay_state(),r=new Date(n?.span[0]??0).toISOString().slice(0,10),o=new Date(n?.span[1]??0).toISOString().slice(0,10);return`replaying ${s.size} feeds, ${r} to ${o}, at ×${e} (universe replay pause | stop | at <date>; Esc stops)`}plugin_light(e){this.lit=e,e===null?this.facts_clear():this.pluginFacts_show(e),this.shown&&this.inside===null&&this.cluster===null&&this.paint(!1,"hold")}plugin_frame(e){this.lit!==e&&this.plugin_light(e);const s=[];for(const i of this.landed.all())i.groups.forEach((n,r)=>{n.plugin===e&&s.push(`feed:${i.id}:${r}`)});s.length===0||this.scene.moving()||this.scene.frame(s,Ko,void 0,.9)}pluginFacts_show(e){if(this.facts===null)return;this.facts.replaceChildren();const s=ef(`plugin:${e}`,this.landed)??e,[,i="",n=""]=s.split(" · ");for(const[a,l]of[["PLUGIN",e],["FEEDS",i.replace(/ feeds?$/,"")],["ERRORED",n.replace(/ errored$/,"")]]){const c=document.createElement("div");c.className="telemetry-row";const h=document.createElement("span");h.className="telemetry-label",h.textContent=a;const d=document.createElement("span");d.className="telemetry-value",d.textContent=l,c.append(h,d),this.facts.append(c)}const r=document.createElement("div");r.className="universe-node-verbs";const o=document.createElement("button");o.className="pacs-capsule universe-plugin-open",o.textContent="OPEN IN /BIN",o.title="the plugin in the files browser: its one-node graph, its parameters",o.addEventListener("click",()=>this.handlers.plugin_open?.(e)),r.append(o),this.facts.append(r),this.facts.hidden=!1}dataGraph_paint(){const{graph:e,hubs:s}=Sb(this.landed.all(),this.scale);this.dataHubs=s;const i=this.litHub;if(i===null)return e;const n=uz(this.landed.all().map(o=>o.data?.seriesDescription).filter(o=>o!==void 0)),r=new Set(this.landed.all().filter(o=>fz(o,n).some(a=>a.key===i)).map(o=>o.id));return{nodes:e.nodes.map(o=>{if(Jf(o.id)!==null)return o;const a=o.id.match(/^feed:(\d+):/);return a!==null&&r.has(Number(a[1]))?o:{...o,dim:!0}})}}replay_end(){this.scene.replay_state()!==null&&(this.scene.replay_stop(),this.replayDay="",this.title_paint(),this.replay_paint())}replay_paint(){const e=this.scene.replay_state();if(this.replayPill!==null){const i=e!==null&&!e.playing&&e.at>=e.span[1];this.replayPill.textContent=e===null?"REPLAY":e.playing?"PLAYING":i?"REPLAYED":"PAUSED",this.replayPill.classList.toggle("rail-off",e===null)}if(e===null||this.state===null)return;const s=`${e.playing?"REPLAY":"PAUSED"} ${new Date(e.at).toISOString().slice(0,10)}`;s!==this.replayDay&&(this.replayDay=s,this.state_stand("live",s))}identity_note(e,s){const i=i5(e,s);if(i===this.storeKey)return;this.storeKey=i;const n=this.settings_recall();if(this.shown){const r=this.seed_recall();(n||r)&&this.inside===null&&this.cluster===null&&this.paint(!1)}}positionsKey_derive(e){if(this.storeKey===null)return null;const s=e==="galaxy"?this.storeKey:`${this.storeKey}.${e}`;return this.view==="shapes"?`${s}.shapes`:s}positions_recalled(e){const s=this.positionsKey_derive(e);if(!(this.store===void 0||s===null))try{const i=XM(this.store.getItem(s));return Object.keys(i).length>0?i:void 0}catch{return}}seed_recall(){const e=this.positionsKey_derive(this.arrangement);if(this.store===void 0||e===null)return!1;const s=XM(this.store.getItem(e));return Object.keys(s).length===0?!1:(this.scene.positions_seed(s),!0)}remember_later(){this.rememberTimer===null&&(this.rememberTimer=window.setTimeout(()=>{this.rememberTimer=null,this.remember_now()},y5))}remember_now(){if(!(this.store===void 0||this.storeKey===null||!this.shown)&&this.positions_matchView(this.scene.positions_get())){try{const e=this.positionsKey_derive(this.arrangement);e!==null&&this.store.setItem(e,JSON.stringify(this.scene.positions_get()))}catch{}this.sessionLayout_put()}}positions_matchView(e){const s=Object.keys(e),i=s.some(r=>r.startsWith("fold:")),n=s.some(r=>r.startsWith("feed:"));return this.view==="shapes"?i&&!n:!i}sessionLayoutName_derive(e){return`${e}${this.view==="shapes"?"-shapes":""}${this.scale==="feeds"?"-alike":""}`}sessionLayout_take(e,s,i=null){if((s!==null||!this.sessionPlaces.has(e))&&this.sessionPlaces.set(e,s===null?null:Object.keys(s).length),s===null&&i!==null){this.sessionWait_hold(e,i);return}const n=this.sessionWait?.name===e;if(n&&this.sessionWait_end(),s===null||this.store===void 0){n&&this.shown&&this.paint(!0,"full");return}const r=["galaxy","spokes","clumps","constellations","data","accretion"].find(a=>this.sessionLayoutName_derive(a)===e);if(r===void 0||this.positions_recalled(r)!==void 0)return;const o=this.positionsKey_derive(r);if(o!==null){try{this.store.setItem(o,JSON.stringify(s))}catch{return}this.putSignatures.set(e,QM(s)),r===this.arrangement&&this.shown&&this.inside===null&&this.cluster===null&&this.entering===null&&(this.scene.positions_seed(s),this.paint(n,"new"))}}sessionWait_hold(e,s){if(e!==this.sessionLayoutName_derive(this.arrangement)||this.positions_recalled(this.arrangement)!==void 0)return;const i=this.sessionWait?.name===e?this.sessionWait.until:Date.now()+b5;if(this.sessionWait?.timer!==void 0&&this.sessionWait?.timer!==null&&window.clearTimeout(this.sessionWait.timer),Date.now()>=i){this.sessionWait_end(),this.shown&&this.paint(!0,"full");return}this.wait.show(`LAYING OUT ${s.nodes.toLocaleString("en-US")} SPHERES · THE SESSION`,s.fraction);const n=window.setTimeout(()=>{this.handlers.command_run(`proc layout ${e}`)},M5);this.sessionWait={name:e,until:i,timer:n}}sessionWait_end(){this.sessionWait?.timer!==void 0&&this.sessionWait?.timer!==null&&window.clearTimeout(this.sessionWait.timer),this.sessionWait=null,this.wait.hide()}sessionWait_holds(){return this.sessionWait!==null&&this.sessionWait.name===this.sessionLayoutName_derive(this.arrangement)&&Date.now()<this.sessionWait.until&&this.inside===null&&this.cluster===null}sessionLayout_put(){if(this.inside!==null||this.cluster!==null||this.scene.replay_state()!==null||!this.whole||!_5(this.physics))return;const e={};for(const[n,r]of Object.entries(this.scene.positions_get()))r.every(o=>Number.isFinite(o))&&(e[n]=[Math.round(r[0]*100)/100,Math.round(r[1]*100)/100,Math.round(r[2]*100)/100]);if(Object.keys(e).length===0)return;const s=this.sessionLayoutName_derive(this.arrangement),i=QM(e);this.putSignatures.get(s)!==i&&(this.putSignatures.set(s,i),this.sessionPlaces.set(s,Object.keys(e).length),this.handlers.command_run(`proc layout put ${s} '${JSON.stringify(e).replace(/'/g,"'\\''")}'`))}}function Ji(t){return`'${t.replace(/'/g,"'\\''")}'`}function M1(t,e){return`touch --withContents=${Ji(e)} ${Ji(t)}`}function v1(t){return`edit ${Ji(t)}`}function O5(t,e,s){return e<s?null:`edit: ${t} is ${(e/(1024*1024)).toFixed(1)} MB; open it in the editor? `}async function ra(t,e){const{terminal:s,client:i}=t;s.line_echo(e);let n;try{n=await i.line_execute(e)}catch(r){return s.output_write("err",`\x1B[31m${r instanceof Error?r.message:String(r)}\x1B[0m
4344
4344
  `),!1}return s.outcome_write(n),n.envelopes.length>0&&n.envelopes.every(r=>r.status==="ok")}function E5(t){for(const e of t.envelopes){if(e.model?.kind!=="fs.acl")continue;const s=e.model.data[0];return s===void 0?null:{users:s.usernames??[],groups:s.groups??[],public:s.public===!0}}return null}function A5(t,e){return t.split(`
4345
4345
  `).map(s=>s.trim().split(":")).filter(s=>s.length>=4&&(s[3]??"").split(",").includes(e)).map(s=>s[0]??"").filter(s=>s!=="")}function T5(t){return/^(u|user|g|group|o|other):/.test(t)?t:`u:${t}:r`}function I5(t,e){return e.kind==="public"?`setfacl -m o::- feed_${t}`:`setfacl -x ${e.kind==="user"?"u":"g"}:${Ji(e.name)} feed_${t}`}function qc(t){return t.kind==="public"?"PUBLIC":t.kind==="group"?`group ${t.name}`:t.name}function D5(t,e){const s={silent:!0,observe:!1},i=async c=>{try{return E5(await t.client.line_execute(`getfacl feed_${c}`,s))}catch{return null}},n=async()=>{const c=e.promptUser();if(c===null)return[];try{const h=await t.client.line_execute("cat /etc/group",s);return A5(h.envelopes.map(d=>d.rendered).join(""),c)}catch{return[]}},r=async(c,h,d)=>{await e.askOnPane_await(c,{kind:"confirm",message:`Stop sharing feed_${h} with ${qc(d)}? `})==="y"&&await ra(t,I5(h,d))&&e.changed(h)};return{holders_read:i,holders_build:(c,h,d)=>{const u=document.createElement("span");u.className="holder-marks";const p=[...d.users.map(f=>({kind:"user",name:f})),...d.groups.map(f=>({kind:"group",name:f})),...d.public?[{kind:"public"}]:[]];if(p.length===0)return u.textContent="SHARED WITH NOBODY",u;u.append("SHARED WITH ");for(const f of p){const _=document.createElement("span");_.className=`holder-mark holder-${f.kind}`,_.title=qc(f);const g=document.createElement("span");g.className="holder-mark-name",g.textContent=qc(f),_.append(g);const m=document.createElement("span");m.className="holder-mark-x",m.title=`stop sharing with ${qc(f)} (asks first)`,m.textContent="×",m.addEventListener("click",w=>{w.stopPropagation(),r(c,h,f)}),_.append(m),u.append(_)}return u},share_choose:async(c,h)=>{for(;;){const[d,u]=await Promise.all([i(h),n()]),p=d??{groups:[],public:!1},f=[{value:"o::r",label:"EVERYONE",held:p.public},...u.map(g=>({value:`g:${g}:r`,label:g,held:p.groups.includes(g)}))],_=(await e.askOnPane_await(c,{kind:"choose",message:`Share feed_${h} with a group, everyone, or a user: `,choices:f,commit:"SHARE",close:"DONE"})??"").trim();if(_===""||!await ra(t,`setfacl -m ${T5(_)} feed_${h}`))return;e.changed(h)}},rename:async(c,h,d)=>{const u=(await e.askOnPane_await(c,{kind:"text",message:`Rename feed_${h} to: `,suggest:d,commit:"RENAME"})??"").trim();u===""||u===d||await ra(t,M1(`/proc/jobs/feed_${h}/title`,u))&&e.changed(h)}}}function C5(t){for(const e of t.envelopes){if(e.model?.kind!=="fs.listing")continue;return(e.model.data[0]?.items??[]).map(i=>String(i.name??"")).filter(i=>i!=="")}return[]}function R5(t,e,s){const i=`setfattr -n tag -v ${Ji(e)} feed_${t}`;return s.includes(e)?[i]:[`mkdir ${Ji(`/proc/tags/${e}`)}`,i]}function k5(t,e){const s=async()=>{try{return C5(await t.client.line_execute("ls /proc/tags",{silent:!0,observe:!1}))}catch{return[]}};return{tag_choose:async(r,o,a)=>{const l=new Set(a);for(;;){const c=await s(),h=c.map(_=>({value:_,held:l.has(_)})),d=c.filter(_=>!l.has(_)).join(", "),p=(await e.askOnPane_await(r,{kind:"choose",message:`Tag feed_${o}${d===""?"":` (${d})`}, or a new tag: `,choices:h,commit:"TAG",close:"DONE"})??"").trim();if(p===""||p.includes("/"))return;if(l.has(p))continue;let f=!0;for(const _ of R5(o,p,c))if(f=await ra(t,_),!f)break;if(!f)return;l.add(p),e.tags_changed(o)}},tag_remove:async(r,o)=>{const a=await ra(t,`setfattr -x tag -v ${Ji(o)} feed_${r}`);return a&&e.tags_changed(r),a}}}function N5(t,e){return{tags:k5(t,{askOnPane_await:e.askOnPane_await,tags_changed:e.changed}),access:D5(t,e)}}function B5(t){for(const e of t.envelopes){if(e.model?.kind!=="fs.xattr")continue;return e.model.data[0]?.tags??[]}return[]}function w1(t,e,s){const{panels:i,subjects:n}=t,{tags:r,access:o}=s;return{feed_verbs:a=>{const l={feedId:a.id},c={note:()=>t.terminal.line_run(`edit /proc/jobs/feed_${a.id}/note`),tag:()=>{r.tag_choose(e,a.id,a.tags??[])},rename:()=>{o.rename(e,a.id,a.title)},share:()=>{o.share_choose(e,a.id)},delete:()=>t.terminal.line_run(`feed rm feed_${a.id}`)};return iS.rules.filter(h=>h.offered(l)).map(h=>({label:h.label(l),run:()=>c[h.name]?.()}))},feed_indicated:a=>{n.regard_write(e,{address:`/proc/jobs/feed_${a.id}`,modelKind:"feed"}),o.holders_read(a.id).then(l=>{i.get("dag",e)?.rowReadout_show(a.id,l===null?"ACCESS UNREAD":o.holders_build(e,a.id,l))})},feed_untag:(a,l)=>{r.tag_remove(a,l)},feed_entered:a=>{const l={silent:!0,observe:!1},c=h=>h!==null&&h.envelopes.every(d=>d.status==="ok")?h.envelopes.map(d=>d.rendered).join("").replace(/\x1b\[[0-9;]*m/g,""):null;Promise.all([t.client.line_execute(`cat /proc/jobs/feed_${a}/note`,l).catch(()=>null),t.client.line_execute(`getfattr feed_${a}`,l).catch(()=>null),t.client.line_execute(`cat /proc/jobs/feed_${a}/title`,l).catch(()=>null)]).then(([h,d,u])=>{(i.get("dag",e)??i.get("universe",e))?.feedMarks_show(a,{note:c(h),tags:d===null?[]:B5(d),title:(c(u)??"").trim()})})},feed_note:a=>t.terminal.line_run(`edit /proc/jobs/feed_${a}/note`),feed_tag:(a,l)=>{r.tag_choose(e,a,l)},feed_rename:(a,l)=>{o.rename(e,a,l)}}}const G5=256*1024*1024;function P5(t,e){const s=e.split("/").filter(o=>o.length>0).pop()??"download";if(t===null)return s;const i=/filename\*\s*=\s*UTF-8''([^;]+)/i.exec(t);if(i!==null)try{const o=decodeURIComponent((i[1]??"").trim());if(o.length>0)return o}catch{}const r=/filename\s*=\s*"([^"]*)"/i.exec(t)?.[1]??"";return r.length>0?r:s}function ev(t){return t.redirected?"the session asked to log in again — nothing was saved":t.status===410?"cancelled — nothing was saved":t.ok?t.headers.get("content-disposition")===null?"the session answered with something other than the file — nothing was saved":null:t.status===404?"the session could not read that file — nothing was saved":`the session refused the file (HTTP ${t.status}) — nothing was saved`}function tv(t,e){const s=document.createElement("a");s.href=t,s.download=e,s.rel="noopener",document.body.append(s),s.click(),s.remove()}function y1(){return`dl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}async function L5(t,e,s=fetch,i=y1()){const n=`${t}&dl=${encodeURIComponent(i)}`;let r;try{r=await s(`${n}&probe=1`,{method:"HEAD",credentials:"same-origin"})}catch(p){return{ok:!1,reason:`the session did not answer (${p instanceof Error?p.message:String(p)}) — nothing was saved`}}const o=ev(r);if(o!==null)return{ok:!1,reason:o};const a=P5(r.headers.get("content-disposition"),e),l=Number(r.headers.get("content-length")??NaN);if(!Number.isFinite(l)||l>G5)return tv(n,a),{ok:!0,name:a,bytes:Number.isFinite(l)?l:null,streamed:!0};let c;try{c=await s(n,{credentials:"same-origin"})}catch(p){return{ok:!1,reason:`the session did not answer (${p instanceof Error?p.message:String(p)}) — nothing was saved`}}const h=ev(c);if(h!==null)return{ok:!1,reason:h};const d=await c.blob(),u=URL.createObjectURL(d);return tv(u,a),setTimeout(()=>URL.revokeObjectURL(u),6e4),{ok:!0,name:a,bytes:d.size,streamed:!1}}const W5=1e3,F5=5e3,U5=3,$5=2e4;function Qa(t){const e=["B","KB","MB","GB","TB"];let s=t,i=0;for(;s>=1e3&&i<e.length-1;)s/=1e3,i+=1;return`${i===0?s.toFixed(0):s.toFixed(1)} ${e[i]}`}function Kc(t){const e=Math.max(0,Math.round(t/1e3)),s=Math.floor(e/3600),i=Math.floor(e%3600/60),n=String(e%60).padStart(2,"0");return s>0?`${s}:${String(i).padStart(2,"0")}:${n}`:`${i}:${n}`}function j5(t,e){switch(t.phase){case"opening":return`WAITING FOR CUBE · ${Kc(t.elapsedMs)}`;case"ready":return"CUBE ANSWERED · HANDING TO THE BROWSER";case"streaming":{if(t.bytes===0)return`WAITING FOR CUBE'S FIRST BYTE · ${Kc(t.elapsedMs)}`;const s=[t.size!==void 0?`${Qa(t.bytes)} OF ${Qa(t.size)}`:Qa(t.bytes)];return t.size!==void 0&&t.size>0&&s.push(`${Math.floor(100*t.bytes/t.size)}%`),e!==null&&e>0&&(s.push(`${Qa(e)}/S`),t.size!==void 0&&s.push(`${Kc(1e3*(t.size-t.bytes)/e)} LEFT`)),s.join(" · ")}case"done":return`DONE · ${Qa(t.bytes)} IN ${Kc(t.elapsedMs)}`;case"failed":return`FAILED · ${t.reason??"the session did not say why"}`;case"cancelled":return"CANCELLED"}}function sv(t){return t==="done"||t==="failed"||t==="cancelled"}function iv(t,e,s){const i=new URL(t,window.location.href),n=i.searchParams.get("token");return i.search="",i.searchParams.set(e,s),n!==null&&i.searchParams.set("token",n),i.toString()}function H5(){let t=document.querySelector(".transfer-stack");return t===null&&(t=document.createElement("div"),t.className="transfer-stack",t.setAttribute("role","status"),document.body.appendChild(t)),t}function V5(t,e,s,i=fetch){const n=document.createElement("div");n.className="transfer-row",n.dataset.download=s,n.dataset.phase="opening";const r=document.createElement("span");r.className="transfer-name",r.textContent=t,r.title=t;const o=document.createElement("span");o.className="transfer-bar";const a=document.createElement("span");a.className="transfer-fill",o.appendChild(a);const l=document.createElement("span");l.className="transfer-words",l.textContent="ASKING THE SESSION";const c=document.createElement("button");c.type="button",c.className="transfer-action",c.textContent="CANCEL",n.append(r,o,l,c),H5().appendChild(n);let h=null,d=null,u=!1,p=null;const f=[],_=()=>n.remove(),g=()=>{u=!0,h!==null&&clearTimeout(h),c.textContent="CLOSE",c.title="dismiss this row",d=setTimeout(_,$5)},m=x=>{const M=Date.now();for(f.push({at:M,bytes:x});f.length>1&&M-(f[0]?.at??M)>6e3;)f.shift();const S=f[0];return S===void 0||M-S.at<900?null:(x-S.bytes)*1e3/(M-S.at)};let w=!1,y=0;const b=x=>{n.dataset.phase=x.phase;const M=j5(x,x.phase==="streaming"?m(x.bytes):null);l.textContent=w&&!sv(x.phase)?`CANCELLING · ${M}`:M;const S=x.phase==="done"?1:x.size!==void 0&&x.size>0?x.bytes/x.size:0;a.style.width=`${(100*S).toFixed(1)}%`,sv(x.phase)&&g()},v=async x=>{const M=new AbortController,S=setTimeout(()=>M.abort(),F5);try{const T=await i(iv(e,x,s),{credentials:"same-origin",cache:"no-store",signal:M.signal});return T.ok?await T.json():"unknown"}catch{return null}finally{clearTimeout(S)}},z=async()=>{if(u)return;const x=await v("progress");if(!u){if(x===null)y+=1,y>=U5&&(l.textContent="LOST TOUCH WITH THE SESSION · STILL ASKING");else if(x==="unknown"){if(y=0,p??=Date.now(),Date.now()-p>5e3){n.dataset.phase="handed",l.textContent="HANDED TO THE BROWSER · SEE ITS DOWNLOADS",g();return}}else y=0,p=null,b(x);u||(h=setTimeout(()=>{z()},W5))}};return c.addEventListener("click",()=>{if(u){_();return}c.disabled=!0,w=!0,l.textContent="CANCELLING",v("cancel").then(x=>{c.disabled=!1,!u&&(x===null?(w=!1,l.textContent="THE CANCEL GOT NO ANSWER FROM THE SESSION · PRESS CANCEL AGAIN"):x==="unknown"?(w=!1,n.dataset.phase="handed",l.textContent="THE SESSION DOES NOT KNOW THIS DOWNLOAD · CANCEL IT IN THE BROWSER'S DOWNLOADS",g()):b(x))})}),z(),{element:n,show:b,fail:x=>{u||i(iv(e,"progress",s),{credentials:"same-origin",cache:"no-store"}).then(async M=>M.ok?await M.json():null).catch(()=>null).then(M=>{u||b(M!==null&&M.phase==="failed"?M:{phase:"failed",bytes:0,reason:x,elapsedMs:0})})},stop:()=>{u=!0,h!==null&&clearTimeout(h),d!==null&&clearTimeout(d)}}}const z1=/\.(csv|tsv)$/i;function nv(t){return t.replace(/\x1b\[[0-9;:]*[A-Za-z]/g,"")}function S1(t){return sp.test(t)||$h.test(t)}function am(t){const e=/_(\d+)\/data\/?$/.exec(t);return e===null?null:parseInt(e[1]??"",10)}function El(t){const e=t.match(/\/(?:feeds|jobs)\/feed_(\d+)(?:\/|$)/);return e===null?null:Number(e[1])}function q5(t){return/^\/(proc|net|etc|usr)(\/|$)/.test(t)}function K5(t){for(const e of t.envelopes){const s=e.model;if(typeof s!="object"||s===null)continue;const i=s.data;if(s.kind!=="fs.acl"||!Array.isArray(i))continue;const n=[];for(const r of i)Array.isArray(r.usernames)&&n.push(...r.usernames.map(String)),Array.isArray(r.groups)&&n.push(...r.groups.map(o=>`group ${String(o)}`)),r.public===!0&&n.push("PUBLIC");return n.length===0?"SHARED WITH NOBODY":`SHARED WITH ${n.join(", ")}`}return"ACCESS UNREAD"}function Y5(t,e){const{panels:s,subjects:i}=t,n=new Map,r=new Map,o=new Map,a=S=>{const T=e.downloadUrl_build(S),I=y1(),E=S.split("/").filter(R=>R.length>0).pop()??S,O=V5(E,T,I);t.terminal.line_note(`download: asking the session for ${E}`),L5(T,S,fetch,I).then(R=>{R.ok||O.fail(R.reason),t.terminal.line_note(R.ok?`download: ${R.name}${R.streamed?" — handed to the browser; its progress is on the transfer row":""}`:`download: ${S}: ${R.reason}`)})},l=S=>t.client.line_execute(`cat "${S}"`,{silent:!0,observe:!1}).then(T=>{if(!T.envelopes.some(O=>O.status==="error"))return{ok:!0,text:nv(T.envelopes.map(O=>O.rendered).join(`
4346
4346
  `))};const E=T.envelopes.flatMap(O=>(O.errors??[]).map(R=>R.message)).concat(T.envelopes.map(O=>O.renderedErr??"")).map(O=>nv(O).trim()).filter(O=>O!=="").join(`
4347
- `);return{ok:!1,text:E===""?"the session refused this read and said nothing further":E}}),c=async(S,T)=>{const I=await fetch(e.vfsUrl_build(S));if(!I.ok||I.body===null)return(await l(S)).text.slice(0,T);const E=I.body.getReader(),O=new TextDecoder;let R="";for(;R.length<T;){const{done:C,value:k}=await E.read();if(C)break;R+=O.decode(k,{stream:!0})}return E.cancel().catch(()=>{}),R.slice(0,T)},h=async S=>{const T=/_id(\d+)$/.exec(S)?.[1]??S.replace(/^.*\//,""),I=await t.client.line_execute(`pipeline diagram ${T}`,{silent:!0,observe:!1});for(const E of I.envelopes){if(E.model?.kind!==br.pipelineDiagram)continue;const O=_g.safeParse(E.model.data);if(O.success)return O.data.nodes.map(R=>({id:R.id,parentIds:[...R.parentIds,...R.joinParentIds??[]]}))}return null},d={imageUrl:e.vfsUrl_build,download:a,textHead:c,pipelineGlimpse:h},u=(S,T,I)=>{const E=I==="~"?"ls ~":`ls "${I}"`;t.client.line_execute(E,{silent:!0,observe:!1}).then(O=>{for(const R of O.envelopes)T.envelope_observe(R);if(I!=="~"&&T.path_current()!==I.replace(/\/+$/,"")){const R=O.envelopes.find(k=>k.status==="error"),C=R!==void 0?Uz(R):"the session answered no listing";T.listing_fail(C),t.terminal.line_note(`files: ${I}: ${C}`)}},O=>{const R=O instanceof Error?O.message:String(O);T.listing_fail(R),t.terminal.line_note(`files: ${I}: ${R}`)})},p=(S,T,I)=>{const E=T.path_current();E!==null&&n.get(S)?.push(E),u(S,T,I)},f=(S,T)=>{const I=n.get(S)?.pop();I!==void 0&&u(S,T,I)},_=S=>{o.get(S)?.()},g=(S,T)=>{r.set(S,T),_(S);const I=s.get("files",S);I?.follow_set(T),T&&I!==void 0&&t.client.line_execute("ls",{silent:!0,observe:!1}).then(E=>{for(const O of E.envelopes)I.envelope_observe(O)})},m=(S,T)=>{const I=s.get("files",S);I!==void 0&&(r.get(S)===!0?t.terminal.line_run("ls"):u(S,I,T))},w=(S,T)=>{e.askOnPane_await(S,{message:`New directory in ${T}: `,kind:"text",commit:"MAKE IT"}).then(I=>{const E=(I??"").trim();E!==""&&(t.terminal.line_run(`mkdir "${T}/${E}"`),m(S,T))})},y=async(S,T,I)=>{for(const E of I){const O=`${T}/${E.name}`;t.terminal.line_note(`putting ${E.name} in ${T}…`);try{const R=await fetch(e.vfsUrl_build(O),{method:"POST",body:E});if(!R.ok){t.terminal.line_note(`upload: ${E.name}: ${(await R.text()).trim()||R.statusText}`);continue}t.terminal.line_note(`✓ ${O}`)}catch(R){t.terminal.line_note(`upload: ${E.name}: ${R instanceof Error?R.message:String(R)}`)}}m(S,T)},b=(S,T,I)=>{if(I.kind==="dir"){r.get(S)===!0?t.terminal.line_run(`cd "${I.path}"`):p(S,T,I.path);return}if(I.kind==="plugin"||I.kind==="pipeline"){e.binEntry_show(S,T,I.path,I.kind);return}if(S1(I.path)){e.image_open(S,I.path).then(E=>t.terminal.line_note(E));return}if(i.regard_write(S,{address:I.path,modelKind:"fs.file"}),!i.groupHasViewer(S)){if(Od(I.path)){T.contentImage_show(I.path,e.vfsUrl_build(I.path));return}l(I.path).then(E=>{if(!E.ok){T.contentRefused_show(I.path,E.text);return}z1.test(I.path)?T.contentTable_show(I.path,E.text):T.content_show(I.path,E.text)})}},v=()=>{const S=e.template_stamp("tpl-pane-files").querySelector(".files-body");if(S===null)throw new Error("tpl-pane-files has no files-body");return S},z=(S,T,I)=>{const E=`"${I}"`,O=T.type==="dir"||T.type==="vfs"||T.type==="job",R=El(I),C={kind:T.type==="plugin"||T.type==="pipeline"?"catalogue":O&&iu(I,T.name)?"seriesFolder":T.type==="file"?"file":"directory",feed:R,node:R===null?null:am(I),bound:e.catalogue_find(S)!==void 0,projection:q5(I),editable:T.type==="file"&&mC(I)},k={image:()=>{e.image_open(S,I).then(B=>t.terminal.line_note(B))},download:()=>a(I),link:()=>{const B=Jw(window.location.origin,I);(s.get("files",S)?.link_copy(I)??navigator.clipboard.writeText(B).then(()=>!0,()=>!1)).then(F=>t.terminal.line_note(F?`link copied: ${B}`:`link (copy it): ${B}`))},process:()=>e.process_open(S,{input:I,feed:R,node:R===null?null:am(I)}),gather:()=>e.cohort_gather([{kind:O?"dir":"file",seriesUID:I,description:T.name,imagery:iu(I,T.name),modality:iu(I,T.name)?"MR":"—",patient:e.promptUser()??"",vfsPath:I,folderPath:I}]),run:()=>e.run_press(S,T.name,T.type==="pipeline"?"pipeline":"plugin"),edit:()=>{const B=v1(I),L=O5(T.name,T.size,pC);if(L===null){e.verbLine_run(S,B);return}e.askOnPane_await(S,{kind:"confirm",message:L}).then(F=>{F==="y"&&e.verbLine_run(S,B)})},move:()=>e.verbLine_run(S,`mv ${E}`),copy:()=>e.verbLine_run(S,`cp ${E}`),delete:()=>e.verbLine_run(S,`rm ${O?"-ri":"-i"} ${E}`),share:()=>e.verbLine_run(S,`setfacl ${E}`)};return tS.rules.filter(B=>B.offered(C)).map(B=>({label:B.label(C),run:()=>k[B.name]?.()}))},x=(S,T)=>{const I=T.map(([k])=>k),E=I.map(k=>`"${k}"`).join(" "),O=[];for(const k of I){const B=El(k);B!==null&&!O.includes(B)&&O.push(B)}const R={count:I.length,feeds:O},C={delete:()=>e.verbLine_run(S,`rm -rI ${E}`),move:()=>t.terminal.line_run(`mv -t ${E}`),copy:()=>t.terminal.line_run(`cp -t ${E}`),share:()=>t.terminal.line_run(`setfacl ${O.map(k=>`feed_${k}`).join(" ")}`)};return sS.rules.filter(k=>k.offered(R)).map(k=>({label:k.label(R),run:()=>C[k.name]?.()}))};return{previewProvider:d,fileText_fetch:l,file_save:a,rootedListing_show:u,listing_refresh:m,directory_make:w,files_deliver:y,follows:S=>r.get(S)===!0,follow_set:g,cwdBind_sync_register:(S,T)=>{o.set(S,T)},cwdBind_sync:_,rooted_walk:p,rooted_back:f,filesBody_stamp:v,rowVerbs_build:z,instance_build:(S,T,I=!1)=>{const E=e.template_stamp("tpl-pane-files"),O=new jz(e.pane_find(E,".files-panel"),C=>b(S,O,C),d,{catalogue:I});O.selectionVerbs_declare(C=>x(S,C)),O.rowVerbs_declare((C,k)=>z(S,C,k),(C,k)=>{i.regard_write(S,{address:k,modelKind:"fs.file"}),El(k)!==null&&t.client.line_execute(`getfacl "${k}"`,{silent:!0,observe:!1}).then(B=>{O.rowReadout_show(k,K5(B))}).catch(()=>{O.rowReadout_show(k,"ACCESS UNREAD")})}),s.set("files",S,O);const R=e.promptUser();return R!==null&&R!==""&&O.home_set(`/home/${R}`),n.set(S,[]),r.set(S,T),_(S),O.follow_set(T),{id:S,kind:"files",mount:E,dispose:()=>{s.delete(S),n.delete(S),i.pane_leave(S)}}}}}function X5(t,e){const s=qi("tpl-pane-universe"),i=new x5({canvas:Ks(s,".universe-canvas"),title:Ks(s,".universe-title"),state:s.querySelector(".pane-state"),empty:Ks(s,".universe-empty"),projectionPill:s.querySelector(".universe-projection"),refreshPill:s.querySelector(".universe-refresh"),replayPill:s.querySelector(".universe-replay"),scalePill:s.querySelector(".universe-scale"),viewPill:s.querySelector(".universe-view"),gravityPill:s.querySelector(".universe-gravity"),densityPill:s.querySelector(".universe-density"),drawPill:s.querySelector(".universe-draw"),captionsPill:s.querySelector(".universe-captions"),arrangementPill:s.querySelector(".universe-arrangement"),facts:s.querySelector(".universe-facts"),backPill:s.querySelector(".universe-back"),openPill:s.querySelector(".universe-open"),frame:s.querySelector(".mode-frame")},{watch_set:(n,r)=>{r?t.client().watch_send(n):t.client().unwatch_send(n)},...(({feed_entered:n,feed_note:r,feed_tag:o,feed_rename:a,feed_untag:l})=>({feed_entered:n,feed_note:r,feed_tag:o,feed_rename:a,feed_untag:l}))(w1(t.context(),e,t.feedVerbs())),command_run:n=>{t.client().line_execute(n,{silent:!0,observe:!1}).then(r=>{for(const o of r.envelopes)i.envelope_observe(o)})},feed_dag:async n=>{const r=await t.client().line_execute(`feed diagram feed_${n}`,{silent:!0,observe:!1});for(const o of r.envelopes){if(o.model?.kind!==br.feedDag)continue;const a=bg.safeParse(o.model.data);if(a.success)return a.data}return null},node_enter:n=>{t.terminal().line_run(`cd "${n}"`)},node_dive:n=>{t.nodeOverlay_open(e,n.replace(/\/data$/,""))},node_process:n=>{const r=El(n.vfsPath)??(/\/feed_(\d+)(?:\/|$)/.exec(n.vfsPath)===null?null:Number(/\/feed_(\d+)(?:\/|$)/.exec(n.vfsPath)[1])),o=t.promptUser()===null?n.vfsPath:n.vfsPath.replace(/^\/proc\/jobs\//,`/home/${t.promptUser()}/feeds/`);t.process_open(e,{input:o,feed:r,node:n.instanceId})},feed_open:n=>{t.runs_show(),t.dag_primary().feed_enter(n)},plugin_open:n=>{(async()=>{const r=await t.client().line_execute("ls /bin",{silent:!0,observe:!1}),o=[];for(const l of r.envelopes){if(l.model?.kind!=="fs.listing")continue;const c=l.model.data,h=Array.isArray(c)?c:[c];for(const d of h)for(const u of d.items??[])o.push(u.name)}const a=o.filter(l=>l.startsWith(`${n}-v`)).sort((l,c)=>l.localeCompare(c,void 0,{numeric:!0})).pop();if(a===void 0){t.terminal().line_note(`universe: ${n} is not in /bin`);return}Qe("gutter-files").click(),t.binEntry_show("files",t.panels().get("files","files"),`/bin/${a}`,"plugin")})().catch(r=>{t.terminal().line_note(`universe: could not open ${n} in /bin: ${r instanceof Error?r.message:String(r)}`)})},note:n=>t.terminal().line_note(n)},Zw());return t.panels().set("universe",e,i),{id:e,kind:"universe",mount:s,dispose:()=>{t.panels().delete(e),t.subjects().pane_leave(e),i.dispose()}}}function Z5(t,e,s){const i=qi("tpl-pane-dag"),n=new QU(Ks(i,".dag-canvas"),Ks(i,".dag-title"),Ks(i,".dag-facts"),Ks(i,".dag-empty"),Ks(i,".dag-strategy"),Ks(i,".dag-feedlist"),{command_run:r=>{t.client().line_execute(r,{silent:!0,observe:!1}).then(o=>{for(const a of o.envelopes)n.envelope_observe(a)})},watch_set:(r,o)=>{o?t.client().watch_send(r):t.client().unwatch_send(r)},node_enter:r=>{t.terminal().line_run(`cd "${r}"`)},node_dive:r=>{t.nodeOverlay_open(e,r.replace(/\/data$/,""))},node_regard:r=>{t.subjects().regard_write(e,{address:r,modelKind:"feed.node"})},node_process:r=>{const o=El(r.vfsPath)??(/\/feed_(\d+)(?:\/|$)/.exec(r.vfsPath)===null?null:Number(/\/feed_(\d+)(?:\/|$)/.exec(r.vfsPath)[1])),a=t.promptUser()===null?r.vfsPath:r.vfsPath.replace(/^\/proc\/jobs\//,`/home/${t.promptUser()}/feeds/`);t.process_open(e,{input:a,feed:o,node:r.instanceId})},feed_regard:r=>{t.subjects().regard_write(e,{address:r,modelKind:"feed"})},...w1(t.context(),e,t.feedVerbs()),...s?{feed_shown:()=>t.dag_summon()}:{}});return t.panels().set("dag",e,n),{id:e,kind:"dag",mount:i,dispose:()=>{t.nodeOverlay().dispose(e),t.panels().delete(e),t.subjects().pane_leave(e),n.dispose()}}}function J5(t){return{universe_build:e=>X5(t,e),dag_build:(e,s)=>Z5(t,e,s)}}const x1=new Set(["files"]);function Q5(t){x1.add(t)}function rv(t){return x1.has(t)}const O1=new Map,wa=new Map;let e$=0;function En(t,e){O1.set(t,e)}function t$(t){const e=O1.get(t);if(e===void 0)throw new Error(`no pane factory registered for kind '${t}'`);const s=e(`${t}-${e$++}`);return wa.set(s.id,s),s}function Yc(t){wa.set(t.id,t)}function zh(t){return wa.get(t)}function Sh(){return[...wa.values()]}function As(t){const e=wa.get(t);e!==void 0&&(wa.delete(t),e.dispose?.(),e.mount.remove())}class s${byId=new Map;set(e,s,i){this.byId.set(s,{kind:e,panel:i})}get(e,s){const i=this.byId.get(s);return i!==void 0&&i.kind===e?i.panel:void 0}has(e,s){return this.byId.get(s)?.kind===e}delete(e){return this.byId.delete(e)}ids(e){return this.entries(e).map(([s])=>s)}entries(e){const s=[];for(const[i,n]of this.byId)n.kind===e&&s.push([i,n.panel]);return s}values(e){return this.entries(e).map(([,s])=>s)}idOf(e,s){for(const[i,n]of this.byId)if(n.kind===e&&n.panel===s)return i;return null}}const i$="modulepreload",n$=function(t,e){return new URL(t,e).href},ov={},lm=function(e,s,i){let n=Promise.resolve();if(s&&s.length>0){let c=function(h){return Promise.all(h.map(d=>Promise.resolve(d).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};const o=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");n=c(s.map(h=>{if(h=n$(h,i),h in ov)return;ov[h]=!0;const d=h.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(i)for(let f=o.length-1;f>=0;f--){const _=o[f];if(_.href===h&&(!d||_.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${u}`))return;const p=document.createElement("link");if(p.rel=d?"stylesheet":i$,d||(p.as="script"),p.crossOrigin="",p.href=h,l&&p.setAttribute("nonce",l),document.head.appendChild(p),d)return new Promise((f,_)=>{p.addEventListener("load",f),p.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return n.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return e().catch(r)})},r$=/Failed to fetch dynamically imported module|error loading dynamically imported module|Importing a module script failed/i;function r_(t){const e=t instanceof Error?t.message:String(t??"");return r$.test(e)}const oa={before:"ARGUS has been updated in the background — ",refresh:"refresh",after:" this page"},o$=`${oa.before}${oa.refresh}${oa.after}`,nd="ARGUS UPDATED IN THE BACKGROUND · REFRESH THIS PAGE";function a$(t,e=document.body){let s=!1;const i=()=>{if(s)return;s=!0,t(`argus: ${o$} (what failed to load was part of the old build)`);const n=document.createElement("div");n.className="stale-page",n.setAttribute("role","alert");const r=document.createElement("span");r.className="stale-page-words";const o=document.createElement("button");o.type="button",o.className="stale-page-reload",o.textContent=oa.refresh,o.title="load the argus the server has now",o.addEventListener("click",()=>{window.location.reload()}),r.append(document.createTextNode(oa.before),o,document.createTextNode(oa.after)),n.append(r),e.appendChild(n)};window.addEventListener("vite:preloadError",()=>{i()}),window.addEventListener("unhandledrejection",n=>{r_(n.reason)&&i()})}const l$=[{label:"",tag:"PatientName"},{label:"MRN",tag:"PatientID"},{label:"ACC",tag:"AccessionNumber"},{label:"",tag:"StudyDescription"},{label:"",tag:"SeriesDescription"},{label:"",tag:"StudyDate"},{label:"",tag:"PatientAge"},{label:"",tag:"PatientSex"}],c$=256*1024*1024;function Xc(t){const e=["B","KB","MB","GB","TB"];let s=t,i=0;for(;s>=1024&&i<e.length-1;)s/=1024,i++;return i===0?`${t} B`:`${s.toFixed(1)} ${e[i]}`}function h$(t){const e=t.toUpperCase();return e==="MR"||e==="CT"||e==="PT"?e:"OT"}class d${pane;field;title;modeSpan;stateSpan;layoutPills=new Map;overlayPill;colormapPill;savePill;loadPill;retryPill;presetPill;focusMark;guardBytes=c$;forced=!1;pendingLayout=null;progressNote=null;overlayNote=null;probeNote=null;overlay=!1;overlayLines=[];presetIndex=-1;toolPills=new Map;handlers;engine=null;series=null;siblings=[];colormap="gray";tool="wl";constructor(e,s){this.handlers=s,this.pane=e,this.field=di(e,".image-field"),this.title=di(e,".pane-title"),this.modeSpan=di(e,".pane-mode"),this.stateSpan=di(e,".pane-state");for(const i of e.querySelectorAll(".image-layout")){const n=i.dataset.layout??"single";this.layoutPills.set(n,i),i.addEventListener("click",()=>{this.layout_set(n)})}this.overlayPill=di(e,".image-overlay"),this.overlayPill.addEventListener("click",()=>{this.overlay_set(!this.overlay)}),this.colormapPill=di(e,".image-colormap"),this.savePill=di(e,".image-save"),this.loadPill=di(e,".image-load"),this.retryPill=di(e,".image-retry"),this.presetPill=di(e,".image-preset"),this.focusMark=di(e,".image-focus"),this.field.tabIndex=0,this.colormapPill.addEventListener("click",()=>{this.colormap_cycle()}),this.savePill.addEventListener("click",()=>{this.annotations_save()}),this.loadPill.addEventListener("click",()=>{this.load_press()}),this.retryPill.addEventListener("click",()=>{this.retry_press()}),this.presetPill.addEventListener("click",()=>this.preset_cycle()),di(e,".image-tags").addEventListener("click",()=>this.handlers.tags_open());for(const i of Rb){const n=di(e,`.image-tool[data-tool="${i}"]`);this.toolPills.set(i,n),n.addEventListener("click",()=>{this.tool_set(i)})}this.toolPills_paint(),this.field.addEventListener("mousedown",()=>{this.field.focus(),this.focusMark_paint(!0)}),this.field.addEventListener("focusin",()=>this.focusMark_paint(!0)),this.field.addEventListener("focusout",i=>{(!(i.relatedTarget instanceof Node)||!this.field.contains(i.relatedTarget))&&this.focusMark_paint(!1)}),this.field.addEventListener("keydown",i=>{if(i.key==="Escape"){this.field_release(),i.stopPropagation();return}i.stopPropagation()})}field_hasFocus(){return document.activeElement instanceof Node&&this.field.contains(document.activeElement)}field_release(){return this.field_hasFocus()?(document.activeElement.blur(),this.focusMark_paint(!1),!0):!1}async series_show(e,s={}){if(this.engine_dispose(),this.series=e,this.forced=s.force===!0,this.pendingLayout=null,this.loadPill.hidden=!0,this.retryPill.hidden=!0,this.presets_paint(e.modality),this.siblings=s.siblings??[],this.pane.dataset.modality=h$(e.modality),this.title.textContent=`IMAGE ${e.modality.toUpperCase()} ${e.seriesDescription}`.trim(),this.title.title=this.title.textContent,this.siblings.length>1){const o=this.siblings.findIndex(a=>a.path===e.path)+1;this.handlers.note(`image: series ${o} of ${this.siblings.length} in this study; image series <n> switches`)}const i=await this.chunk_import(()=>lm(()=>import("./cornerstoneEngine-C-Ad7wRm.js").then(o=>o.b2),__vite__mapDeps([0,1,2]),import.meta.url));if(i===null)return;const{CornerstoneEngine:n}=i,r=new n(this.engineHost_get(),e,s.startAt??1);await this.engine_open(r),this.engine===r&&(this.guard_trips()?(this.loadPill.hidden=!1,this.stateSpan.textContent=`SERIES ${Xc(e.bytes)} · LOAD FOR STACK`,this.handlers.note(`image: ${Xc(e.bytes)} to fetch before the stack scrolls; press LOAD, image load, or image --force <path>`)):r.slices_fill(),await this.annotations_reload(r,e))}async annotations_reload(e,s){let i=0;for(const n of s.annotations.filter(r=>/\.dcm$/i.test(r))){if(this.engine!==e)return;const r=n.split("/").pop()??n;try{const o=await fetch(this.handlers.source.url_resolve(n));if(!o.ok){this.handlers.note(`image: ${r}: HTTP ${o.status}`);continue}const a=await e.annotations_import(await o.arrayBuffer());i+=a,this.handlers.note(a>0?`image: ${a} measurement${a===1?"":"s"} from ${r}`:`image: ${r}: no measurements this engine can place`)}catch(o){this.handlers.note(`image: ${r}: ${o instanceof Error?o.message:String(o)}`)}}this.pane.dataset.annotations=String(i)}async volume_show(e){this.engine_dispose(),this.series=null,this.siblings=[],this.pane.dataset.modality="NIFTI",this.title.textContent=`IMAGE ${e.split("/").pop()??""}`,this.title.title=e,this.forced=!0,this.loadPill.hidden=!0,this.retryPill.hidden=!0,this.presets_paint("NIFTI");const s=await this.chunk_import(()=>lm(()=>import("./niivueEngine-mmgElHY8.js"),__vite__mapDeps([3,1]),import.meta.url));if(s===null)return;const{NiivueEngine:i}=s;await this.engine_open(new i(this.engineHost_get(),e))}async chunk_import(e){try{const s=await e();if(s!==void 0)return s}catch(s){if(!r_(s))throw s}return ys(this.stateSpan,"stale",nd),this.handlers.note(`image: ${nd.toLowerCase()} — the viewer's code is of an older build than the server has`),null}opening_show(e){const s=e.replace(/\/$/,"").split("/").pop()??e;this.stateSpan.textContent="OPENING",this.progress_show({label:`OPENING ${s}`,done:0,total:0})}opening_fail(e,s){this.stateSpan.textContent=s,this.progress_show({label:s,done:0,total:0});const i=this.progressNote;i!==null&&(i.classList.add("image-working-failed"),i.querySelector(".image-working-count").textContent=e)}siblings_get(){return this.siblings}series_get(){return this.series}state_get(){return this.engine===null?null:{...this.engine.state_get(),colormap:this.colormap,path:this.series?.path??null,guard:this.guardBytes,waiting:this.pendingLayout}}async layout_set(e){if(this.engine===null)return!1;if(e!=="single"&&this.guard_trips())return this.pendingLayout=e,this.loadPill.hidden=!1,this.stateSpan.textContent=`SERIES ${Xc(this.series?.bytes??0)} · LOAD FOR ${e.toUpperCase()}`,this.handlers.note(`image: ${Xc(this.series?.bytes??0)} to fetch for ${e}; press LOAD, image load, or image --force <path>`),!1;const s=this.engine.state_get().layout;return this.layoutPills_paint(e),this.modeSpan.textContent=e==="single"?"":e.toUpperCase(),this.overlay_hide(),await this.engine.layout_set(e)?(this.progress_show(null),this.overlay_paint(),this.toolPills_paint(),!0):(this.progress_show(null),this.layoutPills_paint(s),this.modeSpan.textContent=s==="single"?"":s.toUpperCase(),this.handlers.note(`image: layout ${e}: not offered by ${this.engine.name}`),!1)}layoutPills_paint(e){for(const[s,i]of this.layoutPills)i.classList.toggle("rail-off",s!==e)}guard_trips(){return this.guardBytes!==null&&!this.forced&&this.engine?.name==="cornerstone"&&(this.series?.bytes??0)>this.guardBytes}async load_press(){this.forced=!0,this.loadPill.hidden=!0,this.retryPill.hidden=!0;const e=this.pendingLayout;return this.pendingLayout=null,e!==null?this.layout_set(e):this.engine===null||this.engine.state_get().filled?!1:this.engine.slices_fill()}guard_set(e){this.guardBytes=e}guard_get(){return this.guardBytes}preset_cycle(){const e=this.presets_select(this.series?.modality??"NIFTI");if(e.length===0)return;this.presetIndex=(this.presetIndex+1)%e.length;const s=e[this.presetIndex];s!==void 0&&this.wl_set(s.lower,s.upper)&&(this.presetPill.textContent=s.name.toUpperCase())}presets_select(e){const s=e.toUpperCase();return zz.filter(i=>i.modalities.length===0||i.modalities.includes(s))}presets_paint(e){this.presetIndex=-1;const s=this.presets_select(e);this.presetPill.hidden=s.length===0,this.presetPill.textContent="PRESET"}slice_set(e){if(this.engine===null)return!1;const s=this.engine.slice_set(e);return s||this.handlers.note(`image: slice ${e}: not offered in ${this.engine.state_get().layout} layout by ${this.engine.name}`),s}wl_set(e,s){if(this.engine===null)return!1;const i=this.engine.wl_set(e,s);return i||this.handlers.note(`image: wl: not offered by ${this.engine.name}`),i}ghost_set(e){if(this.engine===null)return!1;const s=this.engine.ghost_set(e);return s||this.handlers.note("image: ghost applies to the SLAB layout"),s}wlPreset_set(e){const s=this.series?.modality??"NIFTI",i=j2(e,s);return i===void 0?(this.handlers.note(`image: wl preset ${e}: none for ${s}`),!1):this.wl_set(i.lower,i.upper)}colormap_set(e){return this.engine===null?!1:this.engine.colormap_set(e)?(this.colormap=e,this.colormapPill.textContent=e.toUpperCase(),!0):(this.handlers.note(`image: colormap ${e}: not offered by ${this.engine.name}`),!1)}tool_set(e){return this.engine===null?!1:this.engine.tool_set(e)?(this.tool=e,this.toolPills_paint(),!0):(this.handlers.note(`image: ${e}: not offered by ${this.engine.name}`),!1)}async annotations_save(){if(this.engine===null)return!1;const e=this.series?.seriesInstanceUID,s=/^(\/home\/[^/]+)\//.exec(this.series?.path??"")?.[1];if(e===void 0||s===void 0)return this.handlers.note("image: save: this series has no UID to file an annotation under"),!1;const i=await this.engine.annotations_export();if(i===null)return this.handlers.note(`image: save: nothing measured, or ${this.engine.name} writes no report`),!1;const n=`${s}/annotations/${e}/measurements.dcm`,r=await this.handlers.file_put(n,i);return this.handlers.note(r===200?`✓ ${n}`:`image: save: ${n}: HTTP ${r}`),r===200}dispose(){this.engine_dispose()}async colormap_cycle(){const e=dh[(dh.indexOf(this.colormap)+1)%dh.length]??"gray";this.colormap_set(e)}async engine_open(e){this.engine=e,this.field.replaceChildren(),this.progressNote=null,this.overlayNote=null,this.probeNote=null,this.layoutPills_paint("single"),this.modeSpan.textContent="",this.colormapPill.textContent=this.colormap.toUpperCase();try{await e.open(this.field)}catch(i){this.stateSpan.textContent="REFUSED",this.handlers.note(`image: ${i instanceof Error?i.message:String(i)}`);return}const s=e.state_get().layout;this.layoutPills_paint(s),this.modeSpan.textContent=s==="single"?"":s.toUpperCase(),e.tool_set(this.tool),this.toolPills_paint(),this.progress_show(null),this.overlay_fill()}engine_dispose(){this.engine?.dispose(),this.engine=null,this.progressNote=null,this.overlayNote=null,this.probeNote=null,this.field.replaceChildren(),this.stateSpan.textContent=""}retryPill_paint(){const e=this.engine===null?0:this.engine.state_get().refused,s=this.engine?.refused_retry!==void 0;this.retryPill.hidden=!s||e===0,this.retryPill.disabled||(this.retryPill.textContent=`RETRY ${e}`)}async retry_press(){if(!(this.engine?.refused_retry===void 0||this.retryPill.disabled)){this.retryPill.disabled=!0,this.retryPill.textContent="ASKING…";try{await this.engine.refused_retry()}finally{this.retryPill.disabled=!1,this.retryPill_paint()}}}engineHost_get(){return{source:this.handlers.source,readout_set:e=>{this.stateSpan.textContent=e,this.retryPill_paint()},progress_set:e=>this.progress_show(e),note:this.handlers.note,regard:e=>{this.handlers.regard(e),this.overlaySlice_paint()},probe_set:e=>this.probe_show(e)}}probe_show(e){if(e===null){this.probeNote?.remove(),this.probeNote=null;return}if(this.probeNote===null||this.probeNote.parentElement===null){const s=document.createElement("div");s.className="image-probe-note",this.field.appendChild(s),this.probeNote=s}this.probeNote.textContent=e}overlaySlice_paint(){const e=this.overlayNote?.querySelector(".image-overlay-slice")??null;if(e===null||this.engine===null)return;const s=this.engine.state_get();e.textContent=s.slices>1?`SLICE ${Math.max(1,s.slice)} OF ${s.slices}`:"",e.hidden=s.slices<=1}progress_show(e){if(e===null){this.progressNote?.remove(),this.progressNote=null;return}if(this.progressNote===null||this.progressNote.parentElement===null){const o=document.createElement("div");o.className="image-working",o.innerHTML='<span class="image-working-label"></span><span class="image-working-track"><span class="image-working-fill"></span></span><span class="image-working-count"></span>',this.field.appendChild(o),this.progressNote=o}const s=this.progressNote;s.classList.remove("image-working-failed");const i=e.total>0,n=i?Math.min(1,e.done/e.total):0;s.querySelector(".image-working-label").textContent=e.label,s.querySelector(".image-working-count").textContent=i?`${e.done} / ${e.total} · ${Math.round(n*100)}%`:"";const r=s.querySelector(".image-working-fill");r.classList.toggle("image-working-pacing",!i),r.style.width=i?`${Math.round(n*100)}%`:""}async overlay_set(e){if(this.overlay=e,this.overlayPill.textContent=e?"OVERLAY ON":"OVERLAY OFF",this.overlayPill.classList.toggle("rail-off",!e),!e){this.overlay_hide();return}await this.overlay_fill()}overlay_hide(){this.overlayNote?.remove(),this.overlayNote=null}async overlay_fill(){if(!this.overlay||this.series===null)return;const e=this.series.files[0]??this.series.path,s=await this.handlers.tags_read(e);if(s===null){this.handlers.note(`image: overlay: ${e}: no header to read`);return}this.overlayLines=l$.flatMap(i=>{const r=(s.constant.find(o=>o.name===i.tag)?.value??"").trim();return r===""?[]:[i.label===""?r:`${i.label} ${r}`]}),this.overlay_paint()}overlay_paint(){if(!this.overlay||this.overlayLines.length===0)return;this.overlay_hide();const e=document.createElement("div");e.className="image-overlay-note";const s=document.createElement("span");s.className="image-overlay-slice",e.appendChild(s);for(const i of this.overlayLines){const n=document.createElement("span");n.textContent=i,e.appendChild(n)}this.field.appendChild(e),this.overlayNote=e,this.overlaySlice_paint()}toolPills_paint(){const e=new Set(this.engine?.toolsOffered_get()??Rb),s=this.engine!==null?this.engine.state_get().primaryTool:this.tool;for(const[i,n]of this.toolPills){const r=e.has(i);n.classList.toggle("rail-na",!r),n.classList.toggle("rail-off",r&&i!==s),n.disabled=!r}}focusMark_paint(e){this.focusMark.hidden=!e,this.pane.classList.toggle("image-field-focused",e)}}function di(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`image pane: missing ${e}`);return s}const E1=["patient","study","series","image","equipment","meta","private","other","varying"],u$=new Set(["meta","private"]),av="••••";class f${pane;title;modeSpan;redactBlock;listing;handlers;redact=!0;model=null;groups=[];constructor(e,s){this.handlers=s,this.pane=e,this.title=Zc(e,".pane-title"),this.modeSpan=Zc(e,".pane-mode"),this.redactBlock=Zc(e,".tags-redact"),this.redactBlock.addEventListener("click",()=>this.redact_set(!this.redact));const i=Zc(e,".tags-panel");this.listing=new Ir({mount:i,traits:this.groupTraits_declare(),key:n=>n.group,chrome:{root:e,prefix:"tags"},caps:"root",row:{className:()=>"tags-group-row",groupClassName:n=>`tags-group tags-group-${n.group}`,decorate:n=>{n.title="fold this group open or shut (it keeps its place)"}},child:sa(n=>n.rows,{traits:this.tagTraits_declare(),key:n=>n.key,activatable:n=>n.items.length>0,row:{className:n=>`tags-row${n.phi?" tags-phi":""}`,groupClassName:()=>"tags-sequence",decorate:(n,r)=>{n.title=r.items.length>0?`${r.name}: fold the sequence open or shut`:`${r.tag} ${r.name}`}},child:sa(n=>n.items,{traits:this.itemTraits_declare(),key:n=>n.key,row:{className:()=>"tags-item-row",groupClassName:()=>"tags-item"},child:sa(n=>n.rows,{traits:this.tagTraits_declare(),key:n=>n.key,activatable:()=>!1,row:{className:n=>`tags-row tags-row-deep${n.phi?" tags-phi":""}`}})})}),state:n=>this.stateLine_compose(n),empty:()=>_$("NO TAGS")}),this.redactBlock_paint(),this.listing.rows_set([],{field:"tags"})}model_show(e){this.model=e,this.title.textContent=`TAGS ${m$(e)}`,this.pane.dataset.modality=g$(e),this.groups=p$(e),this.listing.rows_set([{key:e.path,rows:this.groups}],{field:e.path}),this.listing.open_set(0,this.groups.map(s=>s.group).filter(s=>!u$.has(s))),this.modeSpan.textContent=e.subject==="folder"?"FOLDER":""}path_get(){return this.model?.path??null}redact_get(){return this.redact}redact_set(e){this.redact=e,this.redactBlock_paint(),this.model!==null&&this.listing.rows_set([{key:this.model.path,rows:this.groups}],{field:this.model.path})}filter_set(e){if(e===null){this.listing.filter_toggle(!1);return}this.listing.filter_toggle(!0),this.listing.filter_set(e)}stateLine_compose(e){const s=this.groups.reduce((n,r)=>n+r.rows.length,0),i=[];return this.model!==null&&this.model.subject==="folder"&&(i.push(this.model.read===this.model.of?`${this.model.read} FILES`:`${this.model.read} OF ${this.model.of} FILES`),this.model.refused.length>0&&i.push(`REFUSED ${this.model.refused.length}`)),i.push(e.filter!==""?e.filter:`${s} TAGS`),this.redact&&i.push("REDACTED"),i.join(" · ")}redactBlock_paint(){this.redactBlock.textContent=this.redact?"REDACT ON":"REDACT OFF",this.redactBlock.classList.toggle("rail-off",!this.redact),this.pane.classList.toggle("tags-redacted",this.redact)}value_cell(e){const s=document.createElement("span");if(s.className="tags-value",e.phi&&this.redact)return s.textContent=av,s.title="identifying value, redacted; the REDACT block on the frame reveals it",s;if(s.textContent=e.value,e.decoded!==void 0){const i=document.createElement("span");i.className="tags-decoded",i.textContent=` ${e.decoded}`,s.appendChild(i)}if(e.distinct!==void 0){const i=document.createElement("span");i.className="tags-decoded",i.textContent=` (${e.distinct} distinct)`,s.appendChild(i)}return s}groupTraits_declare(){return[nf(()=>!0),{key:"group",label:"GROUP",className:"tags-group-name",width:"minmax(12em, 1fr)",cell:e=>e.group.toUpperCase(),compare:e=>E1.indexOf(e.group)},{key:"count",label:"TAGS",className:"tags-group-count",width:"5em",cell:e=>String(e.rows.length),compare:e=>e.rows.length}]}tagTraits_declare(){return[nf(e=>e.items.length>0),{key:"tag",label:"TAG",className:"tags-tag",width:"7em",cell:e=>e.tag,compare:e=>e.tag},{key:"name",label:"NAME",className:"tags-name",width:"minmax(8em, 1.4fr)",cell:e=>e.name,compare:e=>e.name.toLowerCase()},{key:"vr",label:"VR",className:"tags-vr",width:"2.4em",cell:e=>e.vr,compare:e=>e.vr},{key:"value",label:"VALUE",className:"tags-value-cell",width:"minmax(6em, 2fr)",cell:e=>this.value_cell(e),compare:e=>(e.phi&&this.redact?av:`${e.value} ${e.decoded??""}`).toLowerCase()}]}itemTraits_declare(){return[nf(()=>!0),{key:"item",label:"ITEM",className:"tags-item-name",width:"minmax(12em, 1fr)",cell:e=>`ITEM ${e.index}`,compare:e=>e.index},{key:"count",label:"TAGS",className:"tags-group-count",width:"5em",cell:e=>String(e.rows.length),compare:e=>e.rows.length}]}}function nf(t){return{key:"fold",label:"",className:"tags-fold",capped:!1,width:"1.4em",cell:e=>{const s=document.createElement("span");return s.className=t(e)?"tags-fold":"tags-fold tags-fold-none",s}}}function p$(t){const e=new Map;for(const s of t.constant){const i=s.group;e.has(i)||e.set(i,[]),e.get(i)?.push(A1(s,`${i}/${s.tag}`))}return t.varying.length>0&&e.set("varying",t.varying.map(s=>({tag:s.tag,name:s.name,vr:s.vr,value:s.distinct===1?s.first:`${s.first} .. ${s.last}`,phi:s.phi,items:[],distinct:s.distinct,key:`varying/${s.tag}`}))),E1.filter(s=>e.has(s)).map(s=>({group:s,rows:e.get(s)??[]}))}function A1(t,e){return{tag:t.tag,name:t.name,vr:t.vr,value:t.value,...t.decoded!==void 0?{decoded:t.decoded}:{},phi:t.phi,items:(t.items??[]).map((s,i)=>({index:i+1,key:`${e}/${i+1}`,rows:s.map(n=>A1(n,`${e}/${i+1}/${n.tag}`))})),key:e}}function m$(t){const e=t.path.replace(/\/$/,"").split("/").pop()??t.path;if(t.subject==="folder")return e.length>24?`${e.slice(0,22)}…`:e;const s=/^(\d+)-/.exec(e)?.[1];return s!==void 0?`INSTANCE ${Number(s)}`:e.length>24?`${e.slice(0,22)}…`:e}function g$(t){const e=(t.constant.find(s=>s.name==="Modality")?.value??"").toUpperCase();return e==="MR"||e==="CT"||e==="PT"?e:"OT"}function _$(t){const e=document.createElement("div");return e.className="tags-note",e.textContent=t,e}function Zc(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`tags pane: missing ${e}`);return s}function b$(t,e){const s=qi("tpl-pane-image"),i=new d$(s,{source:{url_resolve:n=>t.vfsUrl_build(n)},note:n=>t.terminal().line_note(n),regard:n=>t.subjects().regard_write(e,{address:n,modelKind:"dicom.instance"}),file_put:async(n,r)=>{try{return(await fetch(t.vfsUrl_build(n),{method:"POST",body:r})).status}catch{return 0}},tags_read:n=>o_(t,n),tags_open:()=>{t.terminal().line_note(T1(t,e))}});return t.panels().set("image",e,i),{id:e,kind:"image",mount:s,dispose:()=>{i.dispose(),t.panels().delete(e),t.subjects().pane_leave(e)}}}function M$(t,e){const s=qi("tpl-pane-tags"),i=new f$(s,{note:n=>t.terminal().line_note(n)});return t.panels().set("tags",e,i),{id:e,kind:"tags",mount:s,dispose:()=>{t.panels().delete(e),t.subjects().pane_leave(e)}}}async function o_(t,e){try{const s=await t.client().line_execute(`dcm tags "${e}"`,{silent:!0,observe:!1});for(const i of s.envelopes){if(i.model?.kind!==Qo.tags)continue;const n=cz.safeParse(i.model.data);if(n.success)return n.data}}catch{}return null}function v$(t,e,s){const i=t.panels().get("tags",e);i===void 0||i.path_get()===s||o_(t,s).then(n=>{if(n===null){t.terminal().line_note(`tags: ${s}: not a readable DICOM file`);return}t.panels().get("tags",e)?.model_show(n)})}function T1(t,e){const s=new Set(t.layout().panes_shown()),i=t.subjects().group_resolve(e);for(const r of t.panels().ids("tags"))if(s.has(r)&&t.subjects().group_resolve(r)===i)return t.layout().focus_set(r),"image tags";if(!s.has(e))return"image tags: the image pane is not on stage";const n=t.instance_spawn("tags",e);return t.layout().leaf_split(e,t.desktop().replayPlace_get()?.dir??"col",n.id,t.desktop().replayPlace_get()?.before??!1)?(t.birth_record(n.id,e,t.desktop().replayPlace_get()?.dir??"col",t.desktop().replayPlace_get()?.before??!1),"image tags"):(As(n.id),t.layout().mount_remove(n.id),"image tags: could not open beside the image pane")}async function cm(t,e){try{const s=await t.client().line_execute(`dcm series "${e}"`,{silent:!0,observe:!1});for(const i of s.envelopes){if(i.model?.kind!==Qo.series)continue;const n=hz.safeParse(i.model.data);if(n.success)return n.data}}catch{}return null}async function I1(t,e){try{const s=await t.client().line_execute(`ls "${e}"`,{silent:!0,observe:!1});for(const i of s.envelopes){if(i.model?.kind!=="fs.listing")continue;const n=i.model.data,r=(Array.isArray(n)?n[0]:n)??{},o=(r.path??e).replace(/\/$/,"");return(r.items??[]).filter(a=>a.type==="dir").map(a=>`${o}/${a.name}`)}}catch{}return[]}function D1(t,e,s){const i=l=>{s!==void 0&&t.subjects().regard_write(l,s)};if(e!==null&&t.panels().has("image",e))return i(e),t.panels().get("image",e)??null;const n=new Set(t.layout().panes_shown());if(s!==void 0){for(const[l,c]of t.panels().entries("image"))if(n.has(l)&&t.subjects().regard_get(l)?.address===s.address)return i(l),c}const r=e!==null?t.subjects().group_resolve(e):null;for(const[l,c]of t.panels().entries("image"))if(n.has(l)&&r!==null&&t.subjects().group_resolve(l)===r)return c;const o=e!==null&&n.has(e)?e:t.errandHost_find();if(o===null)return null;const a=t.instance_spawn("image",e??void 0);return t.layout().leaf_split(o,t.desktop().replayPlace_get()?.dir??"col",a.id,t.desktop().replayPlace_get()?.before??!1)?(t.birth_record(a.id,o,t.desktop().replayPlace_get()?.dir??"col",t.desktop().replayPlace_get()?.before??!1),i(a.id),t.panels().get("image",a.id)??null):(As(a.id),t.layout().mount_remove(a.id),null)}async function w$(t,e,s,i={},n){t.launcher_yield();const r=e!==null?void 0:sp.test(s)?{address:s,modelKind:"image.volume"}:{address:$h.test(s)?s.slice(0,s.lastIndexOf("/")):s.replace(/\/$/,""),modelKind:"dicom.series"},o=D1(t,e,r);if(o===null)return"image: no pane to open beside";const a=t.panels().idOf("image",o);if(a!==null&&n?.(a),sp.test(s))return o.opening_show(s),o.volume_show(s),`image ${s}`;const l=$h.test(s),c=l?s.slice(0,s.lastIndexOf("/")):s.replace(/\/$/,"");o.opening_show(c);let h=await cm(t,c),d=[];if(h===null&&!l){const p=(await I1(t,c)).slice(0,32);for(const f of p){const _=await cm(t,f);if(_!==null){d=p.map(g=>({path:g,label:g.split("/").pop()??g})),h=_;break}}}if(h===null)return o.opening_fail(s,"NOT A READABLE SERIES"),`image: ${s}: not a readable DICOM series, study, or volume`;const u=l?Math.max(1,h.files.indexOf(s)+1):1;return o.series_show(h,{siblings:d,startAt:u,...i.force===!0?{force:!0}:{}}),`image ${h.path}${d.length>1?` (1 of ${d.length} series)`:""}`}function y$(t){return{imageInstance_build:e=>b$(t,e),tagsInstance_build:e=>M$(t,e),tags_ask:e=>o_(t,e),tagsPane_follow:(e,s)=>v$(t,e,s),tagsPane_open:e=>T1(t,e),series_ask:e=>cm(t,e),subfolders_ask:e=>I1(t,e),imagePane_resolve:(e,s)=>D1(t,e,s),image_open:(e,s,i={},n)=>w$(t,e,s,i,n)}}function z$(t){return{primaries:[t.panes.dag_build("dag",!0),t.panes.universe_build("universe"),{id:"pacs",kind:"pacs",mount:t.pacsMount}],domains:["dag","pacs"],presets:[["pacs",()=>({pane:"pacs"})],["dag",()=>({pane:"dag"})],["universe",()=>({pane:"universe"})]],factories:[["dag",e=>t.panes.dag_build(e,!1)],["universe",t.panes.universe_build],["image",t.dicom.imageInstance_build],["tags",t.dicom.tagsInstance_build],["gather",t.gather_build]]}}function S$(t){return async()=>{const e=await t.ask("proc feeds");let s=[];for(const d of e.envelopes){const u=d.model;if(u===void 0||u.kind!==Kf)continue;const p=qf.safeParse(u.data);p.success&&(s=p.data.feeds)}const n=s.length===0&&e.envelopes.some(d=>d.status==="error")?"INDEX WARMING":`${s.length} FEEDS`,r=s.filter(d=>/error/i.test(d.status)).length,o=s.filter(d=>/running|scheduled|created|started/i.test(d.status)).length,a={key:"universe",name:"UNIVERSE",hue:"--honey",numeral:"",figures:[{text:n}],rows:[],verb:"SEE THE SPACE",about:hn.universe,enter:()=>t.universe_show()},l={key:"analyses",name:"ANALYSES",hue:"--october-sunset",numeral:"3",figures:[{text:n},...o>0?[{text:`${o} RUNNING`}]:[],...r>0?[{text:`${r} ERRORED`,errored:!0,open:()=>t.runs_show("status:error")}]:[]],rows:s.slice(0,6).map(d=>({text:`${d.id} ${d.title}`,errored:/error/i.test(d.status),open:()=>t.feed_enter(d.id)})),verb:"OPEN THE ROSTER",about:hn.analyses,enter:()=>t.runs_show()},c=t.pacs_query(),h={key:"pacs",name:"PACS",hue:"--daybreak",numeral:"4",figures:[{text:c===""?"NO ANSWER":"ANSWERED"}],rows:c===""?[{text:"pacs query PatientID:…",open:()=>t.line_offer("pacs query PatientID:")},{text:"pacs query AccessionNumber:…",open:()=>t.line_offer("pacs query AccessionNumber:")}]:[{text:c.slice(0,48)}],verb:"ASK A PACS",about:hn.pacs,enter:()=>t.pacs_open()};return{lead:{tile:l,weight:s.length},afterFiles:[h],afterPanes:[a],about:{files:{text:"Your ChRIS home: uploads, results and what others shared with you."}}}}}const x$=["expired","failed","error"];function lv(t,e,s){for(const i of t.envelopes){if(i.model?.kind!==e)continue;const n=s(i.model.data);if(n.success&&n.data!==void 0)return n.data}return null}function O$(t){return t===null?"REGION":t.includes(":")?t.slice(t.indexOf(":")+1):t}function E$(t){return t.limit.replace(new RegExp(`^(standard-)?${t.family.toLowerCase()}-`),"").replace(/-count$/,"")}function A$(t){const e=t.available===null?`${t.value} PERMITTED`:`${t.available} / ${t.value} FREE`;return`${t.family.toUpperCase()} ${O$(t.zone)} ${E$(t)} ${e}`}function cv(t,e){return`${e==="USD"?"$":`${e} `}${t.toFixed(2)}`}function T$(t){return async()=>{const[e,s]=await Promise.all([t.ask("domain status"),t.ask("capacity")]),i=lv(e,mz,u=>bz.safeParse(u)),n=i?.domains??[];i!==null&&t.names_seen?.(n.map(u=>u.name));const r=u=>u.steps.some(p=>x$.includes(p.state)),o=n.filter(r).length,a=n.filter(u=>u.cost!==void 0&&u.cost!==null),l=a.reduce((u,p)=>u+(p.cost?.hourly??0),0),c={key:"domains",name:"DOMAINS",hue:"--october-sunset",numeral:"",figures:[{text:n.length===0?"NONE":`${n.length} DOMAIN${n.length===1?"":"S"}`},...o>0?[{text:`${o} NEED${o===1?"S":""} A LOOK`,errored:!0}]:[],...a.length>0?[{text:`${cv(l,a[0]?.cost?.currency??"USD")}/H`}]:[]],rows:n.slice(0,6).map(u=>({text:`${u.name} ${u.lastDone??"NOTHING DONE"}${u.cost!==void 0&&u.cost!==null?` ${cv(u.cost.hourly,u.cost.currency)}/h`:""} ${u.cluster??""}`.trimEnd(),errored:r(u),open:()=>t.domain_open(u.name)})),verb:"OPEN THE CONTROLLER",about:hn.domains,enter:()=>t.domain_open("")},h=lv(s,Hk,u=>qk.safeParse(u)),d={key:"capacity",name:"CAPACITY",hue:"--honey",numeral:"",figures:h===null?[{text:"NO FAMILY"}]:[{text:h.region.toUpperCase()}],rows:h===null?[{text:"capacity E5",open:()=>t.line_run("capacity E5")}]:h.rows.slice(0,6).map(u=>({text:A$(u),errored:u.available===0,open:()=>t.line_run(`capacity ${u.family}`)})),verb:"READ CAPACITY",about:hn.capacity,enter:()=>t.line_run("capacity")};return{lead:{tile:c,weight:n.length},afterFiles:[d],afterPanes:[],about:{files:{text:"Your home: the Trusted Domains this session knows, each a folder of its spec, settings, state and steps."}}}}}const gl=new Set([""]);function I$(t){const e=new Set(["",...t]);if(e.size===gl.size&&[...e].every(s=>gl.has(s)))return!1;gl.clear();for(const s of e)gl.add(s);return!0}function D$(t){return{subjects:{domain:gl},views:{},claims:{},listings:{},chords:[],lines:[{after:"view",line:"domain [<name>] (the TD controller takes the screen; every other domain line is the session's)"}],run:(e,s)=>{if(s.subject==="domain")return t().controller_open(s.words[0]??"")}}}function C$(t){return t>=6e4?`${Math.max(1,Math.round(t/6e4))} MIN`:`${Math.max(1,Math.round(t/1e3))} S`}function wi(t){return t.toLocaleString("en-US")}class R${mount;counts=null;context=null;msPerPage=null;walkSamples=new Map;clock;acts;state=void 0;constructor(e,s=()=>Date.now(),i={}){this.mount=e,this.clock=s,this.acts=i,this.render()}state_show(e){this.state=e,this.render()}pace_show(e){this.msPerPage=e,this.render()}eta_compute(e,s,i){const n=this.clock(),r=this.walkSamples.get(e);let o=r?.rowsPerMs??null;r!==void 0&&s>r.loaded&&n>r.at&&(o=(s-r.loaded)/(n-r.at)),(r===void 0||s!==r.loaded)&&this.walkSamples.set(e,{loaded:s,at:n,rowsPerMs:o});const a=Math.max(0,i-s);return i<=0?null:o!==null&&o>0?a/o:this.msPerPage!==null&&this.msPerPage>0?Math.ceil(a/100/4)*this.msPerPage:null}counts_show(e){this.counts=e,this.render()}promptContext_show(e){this.context=e,e.procIndex!==void 0&&(this.counts={jobs:e.procIndex.jobs,feeds:e.procIndex.feeds}),this.render()}rows_compose(){const e=[],s=this.context?.procWarmup,i=this.context?.warmupFailures??[],n=s!==void 0&&s.sweeping!==!1,r=this.counts!==null?`${wi(this.counts.jobs)} JOBS · ${wi(this.counts.feeds)} FEEDS`:"";if(i.length>0)e.push({label:"INDEX",bar:null,value:`${r}${r?" · ":""}FAILED: ${i.map(l=>l.label.toUpperCase()).join(" ")}`,title:i.map(l=>`${l.label}: ${l.message}`).join(`
4347
+ `);return{ok:!1,text:E===""?"the session refused this read and said nothing further":E}}),c=async(S,T)=>{const I=await fetch(e.vfsUrl_build(S));if(!I.ok||I.body===null)return(await l(S)).text.slice(0,T);const E=I.body.getReader(),O=new TextDecoder;let R="";for(;R.length<T;){const{done:C,value:k}=await E.read();if(C)break;R+=O.decode(k,{stream:!0})}return E.cancel().catch(()=>{}),R.slice(0,T)},h=async S=>{const T=/_id(\d+)$/.exec(S)?.[1]??S.replace(/^.*\//,""),I=await t.client.line_execute(`pipeline diagram ${T}`,{silent:!0,observe:!1});for(const E of I.envelopes){if(E.model?.kind!==br.pipelineDiagram)continue;const O=_g.safeParse(E.model.data);if(O.success)return O.data.nodes.map(R=>({id:R.id,parentIds:[...R.parentIds,...R.joinParentIds??[]]}))}return null},d={imageUrl:e.vfsUrl_build,download:a,textHead:c,pipelineGlimpse:h},u=(S,T,I)=>{const E=I==="~"?"ls ~":`ls "${I}"`;t.client.line_execute(E,{silent:!0,observe:!1}).then(O=>{for(const R of O.envelopes)T.envelope_observe(R);if(I!=="~"&&T.path_current()!==I.replace(/\/+$/,"")){const R=O.envelopes.find(k=>k.status==="error"),C=R!==void 0?Uz(R):"the session answered no listing";T.listing_fail(C),t.terminal.line_note(`files: ${I}: ${C}`)}},O=>{const R=O instanceof Error?O.message:String(O);T.listing_fail(R),t.terminal.line_note(`files: ${I}: ${R}`)})},p=(S,T,I)=>{const E=T.path_current();E!==null&&n.get(S)?.push(E),u(S,T,I)},f=(S,T)=>{const I=n.get(S)?.pop();I!==void 0&&u(S,T,I)},_=S=>{o.get(S)?.()},g=(S,T)=>{r.set(S,T),_(S);const I=s.get("files",S);I?.follow_set(T),T&&I!==void 0&&t.client.line_execute("ls",{silent:!0,observe:!1}).then(E=>{for(const O of E.envelopes)I.envelope_observe(O)})},m=(S,T)=>{const I=s.get("files",S);I!==void 0&&(r.get(S)===!0?t.terminal.line_run("ls"):u(S,I,T))},w=(S,T)=>{e.askOnPane_await(S,{message:`New directory in ${T}: `,kind:"text",commit:"MAKE IT"}).then(I=>{const E=(I??"").trim();E!==""&&(t.terminal.line_run(`mkdir "${T}/${E}"`),m(S,T))})},y=async(S,T,I)=>{for(const E of I){const O=`${T}/${E.name}`;t.terminal.line_note(`putting ${E.name} in ${T}…`);try{const R=await fetch(e.vfsUrl_build(O),{method:"POST",body:E});if(!R.ok){t.terminal.line_note(`upload: ${E.name}: ${(await R.text()).trim()||R.statusText}`);continue}t.terminal.line_note(`✓ ${O}`)}catch(R){t.terminal.line_note(`upload: ${E.name}: ${R instanceof Error?R.message:String(R)}`)}}m(S,T)},b=(S,T,I)=>{if(I.kind==="dir"){r.get(S)===!0?t.terminal.line_run(`cd "${I.path}"`):p(S,T,I.path);return}if(I.kind==="plugin"||I.kind==="pipeline"){e.binEntry_show(S,T,I.path,I.kind);return}if(S1(I.path)){e.image_open(S,I.path).then(E=>t.terminal.line_note(E));return}if(i.regard_write(S,{address:I.path,modelKind:"fs.file"}),!i.groupHasViewer(S)){if(Od(I.path)){T.contentImage_show(I.path,e.vfsUrl_build(I.path));return}l(I.path).then(E=>{if(!E.ok){T.contentRefused_show(I.path,E.text);return}z1.test(I.path)?T.contentTable_show(I.path,E.text):T.content_show(I.path,E.text)})}},v=()=>{const S=e.template_stamp("tpl-pane-files").querySelector(".files-body");if(S===null)throw new Error("tpl-pane-files has no files-body");return S},z=(S,T,I)=>{const E=`"${I}"`,O=T.type==="dir"||T.type==="vfs"||T.type==="job",R=El(I),C={kind:T.type==="plugin"||T.type==="pipeline"?"catalogue":O&&iu(I,T.name)?"seriesFolder":T.type==="file"?"file":"directory",feed:R,node:R===null?null:am(I),bound:e.catalogue_find(S)!==void 0,projection:q5(I),editable:T.type==="file"&&mC(I)},k={image:()=>{e.image_open(S,I).then(B=>t.terminal.line_note(B))},download:()=>a(I),link:()=>{const B=Jw(window.location.origin,I);(s.get("files",S)?.link_copy(I)??navigator.clipboard.writeText(B).then(()=>!0,()=>!1)).then(F=>t.terminal.line_note(F?`link copied: ${B}`:`link (copy it): ${B}`))},process:()=>e.process_open(S,{input:I,feed:R,node:R===null?null:am(I)}),gather:()=>e.cohort_gather([{kind:O?"dir":"file",seriesUID:I,description:T.name,imagery:iu(I,T.name),modality:iu(I,T.name)?"MR":"—",patient:e.promptUser()??"",vfsPath:I,folderPath:I}]),run:()=>e.run_press(S,T.name,T.type==="pipeline"?"pipeline":"plugin"),edit:()=>{const B=v1(I),L=O5(T.name,T.size,pC);if(L===null){e.verbLine_run(S,B);return}e.askOnPane_await(S,{kind:"confirm",message:L}).then(F=>{F==="y"&&e.verbLine_run(S,B)})},move:()=>e.verbLine_run(S,`mv ${E}`),copy:()=>e.verbLine_run(S,`cp ${E}`),delete:()=>e.verbLine_run(S,`rm ${O?"-ri":"-i"} ${E}`),share:()=>e.verbLine_run(S,`setfacl ${E}`)};return tS.rules.filter(B=>B.offered(C)).map(B=>({label:B.label(C),run:()=>k[B.name]?.()}))},x=(S,T)=>{const I=T.map(([k])=>k),E=I.map(k=>`"${k}"`).join(" "),O=[];for(const k of I){const B=El(k);B!==null&&!O.includes(B)&&O.push(B)}const R={count:I.length,feeds:O},C={delete:()=>e.verbLine_run(S,`rm -rI ${E}`),move:()=>t.terminal.line_run(`mv -t ${E}`),copy:()=>t.terminal.line_run(`cp -t ${E}`),share:()=>t.terminal.line_run(`setfacl ${O.map(k=>`feed_${k}`).join(" ")}`)};return sS.rules.filter(k=>k.offered(R)).map(k=>({label:k.label(R),run:()=>C[k.name]?.()}))};return{previewProvider:d,fileText_fetch:l,file_save:a,rootedListing_show:u,listing_refresh:m,directory_make:w,files_deliver:y,follows:S=>r.get(S)===!0,follow_set:g,cwdBind_sync_register:(S,T)=>{o.set(S,T)},cwdBind_sync:_,rooted_walk:p,rooted_back:f,filesBody_stamp:v,rowVerbs_build:z,instance_build:(S,T,I=!1)=>{const E=e.template_stamp("tpl-pane-files"),O=new jz(e.pane_find(E,".files-panel"),C=>b(S,O,C),d,{catalogue:I});O.selectionVerbs_declare(C=>x(S,C)),O.rowVerbs_declare((C,k)=>z(S,C,k),(C,k)=>{i.regard_write(S,{address:k,modelKind:"fs.file"}),El(k)!==null&&t.client.line_execute(`getfacl "${k}"`,{silent:!0,observe:!1}).then(B=>{O.rowReadout_show(k,K5(B))}).catch(()=>{O.rowReadout_show(k,"ACCESS UNREAD")})}),s.set("files",S,O);const R=e.promptUser();return R!==null&&R!==""&&O.home_set(`/home/${R}`),n.set(S,[]),r.set(S,T),_(S),O.follow_set(T),{id:S,kind:"files",mount:E,dispose:()=>{s.delete(S),n.delete(S),i.pane_leave(S)}}}}}function X5(t,e){const s=qi("tpl-pane-universe"),i=new x5({canvas:Ks(s,".universe-canvas"),title:Ks(s,".universe-title"),state:s.querySelector(".pane-state"),empty:Ks(s,".universe-empty"),projectionPill:s.querySelector(".universe-projection"),refreshPill:s.querySelector(".universe-refresh"),replayPill:s.querySelector(".universe-replay"),scalePill:s.querySelector(".universe-scale"),viewPill:s.querySelector(".universe-view"),gravityPill:s.querySelector(".universe-gravity"),densityPill:s.querySelector(".universe-density"),drawPill:s.querySelector(".universe-draw"),captionsPill:s.querySelector(".universe-captions"),arrangementPill:s.querySelector(".universe-arrangement"),facts:s.querySelector(".universe-facts"),backPill:s.querySelector(".universe-back"),openPill:s.querySelector(".universe-open"),frame:s.querySelector(".mode-frame")},{watch_set:(n,r)=>{r?t.client().watch_send(n):t.client().unwatch_send(n)},...(({feed_entered:n,feed_note:r,feed_tag:o,feed_rename:a,feed_untag:l})=>({feed_entered:n,feed_note:r,feed_tag:o,feed_rename:a,feed_untag:l}))(w1(t.context(),e,t.feedVerbs())),command_run:n=>{t.client().line_execute(n,{silent:!0,observe:!1}).then(r=>{for(const o of r.envelopes)i.envelope_observe(o)})},feed_dag:async n=>{const r=await t.client().line_execute(`feed diagram feed_${n}`,{silent:!0,observe:!1});for(const o of r.envelopes){if(o.model?.kind!==br.feedDag)continue;const a=bg.safeParse(o.model.data);if(a.success)return a.data}return null},node_enter:n=>{t.terminal().line_run(`cd "${n}"`)},node_dive:n=>{t.nodeOverlay_open(e,n.replace(/\/data$/,""))},node_process:n=>{const r=El(n.vfsPath)??(/\/feed_(\d+)(?:\/|$)/.exec(n.vfsPath)===null?null:Number(/\/feed_(\d+)(?:\/|$)/.exec(n.vfsPath)[1])),o=t.promptUser()===null?n.vfsPath:n.vfsPath.replace(/^\/proc\/jobs\//,`/home/${t.promptUser()}/feeds/`);t.process_open(e,{input:o,feed:r,node:n.instanceId})},feed_open:n=>{t.runs_show(),t.dag_primary().feed_enter(n)},plugin_open:n=>{(async()=>{const r=await t.client().line_execute("ls /bin",{silent:!0,observe:!1}),o=[];for(const l of r.envelopes){if(l.model?.kind!=="fs.listing")continue;const c=l.model.data,h=Array.isArray(c)?c:[c];for(const d of h)for(const u of d.items??[])o.push(u.name)}const a=o.filter(l=>l.startsWith(`${n}-v`)).sort((l,c)=>l.localeCompare(c,void 0,{numeric:!0})).pop();if(a===void 0){t.terminal().line_note(`universe: ${n} is not in /bin`);return}Qe("gutter-files").click(),t.binEntry_show("files",t.panels().get("files","files"),`/bin/${a}`,"plugin")})().catch(r=>{t.terminal().line_note(`universe: could not open ${n} in /bin: ${r instanceof Error?r.message:String(r)}`)})},note:n=>t.terminal().line_note(n)},Zw());return t.panels().set("universe",e,i),{id:e,kind:"universe",mount:s,dispose:()=>{t.panels().delete(e),t.subjects().pane_leave(e),i.dispose()}}}function Z5(t,e,s){const i=qi("tpl-pane-dag"),n=new QU(Ks(i,".dag-canvas"),Ks(i,".dag-title"),Ks(i,".dag-facts"),Ks(i,".dag-empty"),Ks(i,".dag-strategy"),Ks(i,".dag-feedlist"),{command_run:r=>{t.client().line_execute(r,{silent:!0,observe:!1}).then(o=>{for(const a of o.envelopes)n.envelope_observe(a)})},watch_set:(r,o)=>{o?t.client().watch_send(r):t.client().unwatch_send(r)},node_enter:r=>{t.terminal().line_run(`cd "${r}"`)},node_dive:r=>{t.nodeOverlay_open(e,r.replace(/\/data$/,""))},node_regard:r=>{t.subjects().regard_write(e,{address:r,modelKind:"feed.node"})},node_process:r=>{const o=El(r.vfsPath)??(/\/feed_(\d+)(?:\/|$)/.exec(r.vfsPath)===null?null:Number(/\/feed_(\d+)(?:\/|$)/.exec(r.vfsPath)[1])),a=t.promptUser()===null?r.vfsPath:r.vfsPath.replace(/^\/proc\/jobs\//,`/home/${t.promptUser()}/feeds/`);t.process_open(e,{input:a,feed:o,node:r.instanceId})},feed_regard:r=>{t.subjects().regard_write(e,{address:r,modelKind:"feed"})},...w1(t.context(),e,t.feedVerbs()),...s?{feed_shown:()=>t.dag_summon()}:{}});return t.panels().set("dag",e,n),{id:e,kind:"dag",mount:i,dispose:()=>{t.nodeOverlay().dispose(e),t.panels().delete(e),t.subjects().pane_leave(e),n.dispose()}}}function J5(t){return{universe_build:e=>X5(t,e),dag_build:(e,s)=>Z5(t,e,s)}}const x1=new Set(["files"]);function Q5(t){x1.add(t)}function rv(t){return x1.has(t)}const O1=new Map,wa=new Map;let e$=0;function En(t,e){O1.set(t,e)}function t$(t){const e=O1.get(t);if(e===void 0)throw new Error(`no pane factory registered for kind '${t}'`);const s=e(`${t}-${e$++}`);return wa.set(s.id,s),s}function Yc(t){wa.set(t.id,t)}function zh(t){return wa.get(t)}function Sh(){return[...wa.values()]}function As(t){const e=wa.get(t);e!==void 0&&(wa.delete(t),e.dispose?.(),e.mount.remove())}class s${byId=new Map;set(e,s,i){this.byId.set(s,{kind:e,panel:i})}get(e,s){const i=this.byId.get(s);return i!==void 0&&i.kind===e?i.panel:void 0}has(e,s){return this.byId.get(s)?.kind===e}delete(e){return this.byId.delete(e)}ids(e){return this.entries(e).map(([s])=>s)}entries(e){const s=[];for(const[i,n]of this.byId)n.kind===e&&s.push([i,n.panel]);return s}values(e){return this.entries(e).map(([,s])=>s)}idOf(e,s){for(const[i,n]of this.byId)if(n.kind===e&&n.panel===s)return i;return null}}const i$="modulepreload",n$=function(t,e){return new URL(t,e).href},ov={},lm=function(e,s,i){let n=Promise.resolve();if(s&&s.length>0){let c=function(h){return Promise.all(h.map(d=>Promise.resolve(d).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};const o=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");n=c(s.map(h=>{if(h=n$(h,i),h in ov)return;ov[h]=!0;const d=h.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(i)for(let f=o.length-1;f>=0;f--){const _=o[f];if(_.href===h&&(!d||_.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${u}`))return;const p=document.createElement("link");if(p.rel=d?"stylesheet":i$,d||(p.as="script"),p.crossOrigin="",p.href=h,l&&p.setAttribute("nonce",l),document.head.appendChild(p),d)return new Promise((f,_)=>{p.addEventListener("load",f),p.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return n.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return e().catch(r)})},r$=/Failed to fetch dynamically imported module|error loading dynamically imported module|Importing a module script failed/i;function r_(t){const e=t instanceof Error?t.message:String(t??"");return r$.test(e)}const oa={before:"ARGUS has been updated in the background — ",refresh:"refresh",after:" this page"},o$=`${oa.before}${oa.refresh}${oa.after}`,nd="ARGUS UPDATED IN THE BACKGROUND · REFRESH THIS PAGE";function a$(t,e=document.body){let s=!1;const i=()=>{if(s)return;s=!0,t(`argus: ${o$} (what failed to load was part of the old build)`);const n=document.createElement("div");n.className="stale-page",n.setAttribute("role","alert");const r=document.createElement("span");r.className="stale-page-words";const o=document.createElement("button");o.type="button",o.className="stale-page-reload",o.textContent=oa.refresh,o.title="load the argus the server has now",o.addEventListener("click",()=>{window.location.reload()}),r.append(document.createTextNode(oa.before),o,document.createTextNode(oa.after)),n.append(r),e.appendChild(n)};window.addEventListener("vite:preloadError",()=>{i()}),window.addEventListener("unhandledrejection",n=>{r_(n.reason)&&i()})}const l$=[{label:"",tag:"PatientName"},{label:"MRN",tag:"PatientID"},{label:"ACC",tag:"AccessionNumber"},{label:"",tag:"StudyDescription"},{label:"",tag:"SeriesDescription"},{label:"",tag:"StudyDate"},{label:"",tag:"PatientAge"},{label:"",tag:"PatientSex"}],c$=256*1024*1024;function Xc(t){const e=["B","KB","MB","GB","TB"];let s=t,i=0;for(;s>=1024&&i<e.length-1;)s/=1024,i++;return i===0?`${t} B`:`${s.toFixed(1)} ${e[i]}`}function h$(t){const e=t.toUpperCase();return e==="MR"||e==="CT"||e==="PT"?e:"OT"}class d${pane;field;title;modeSpan;stateSpan;layoutPills=new Map;overlayPill;colormapPill;savePill;loadPill;retryPill;presetPill;focusMark;guardBytes=c$;forced=!1;pendingLayout=null;progressNote=null;overlayNote=null;probeNote=null;overlay=!1;overlayLines=[];presetIndex=-1;toolPills=new Map;handlers;engine=null;series=null;siblings=[];colormap="gray";tool="wl";constructor(e,s){this.handlers=s,this.pane=e,this.field=di(e,".image-field"),this.title=di(e,".pane-title"),this.modeSpan=di(e,".pane-mode"),this.stateSpan=di(e,".pane-state");for(const i of e.querySelectorAll(".image-layout")){const n=i.dataset.layout??"single";this.layoutPills.set(n,i),i.addEventListener("click",()=>{this.layout_set(n)})}this.overlayPill=di(e,".image-overlay"),this.overlayPill.addEventListener("click",()=>{this.overlay_set(!this.overlay)}),this.colormapPill=di(e,".image-colormap"),this.savePill=di(e,".image-save"),this.loadPill=di(e,".image-load"),this.retryPill=di(e,".image-retry"),this.presetPill=di(e,".image-preset"),this.focusMark=di(e,".image-focus"),this.field.tabIndex=0,this.colormapPill.addEventListener("click",()=>{this.colormap_cycle()}),this.savePill.addEventListener("click",()=>{this.annotations_save()}),this.loadPill.addEventListener("click",()=>{this.load_press()}),this.retryPill.addEventListener("click",()=>{this.retry_press()}),this.presetPill.addEventListener("click",()=>this.preset_cycle()),di(e,".image-tags").addEventListener("click",()=>this.handlers.tags_open());for(const i of Rb){const n=di(e,`.image-tool[data-tool="${i}"]`);this.toolPills.set(i,n),n.addEventListener("click",()=>{this.tool_set(i)})}this.toolPills_paint(),this.field.addEventListener("mousedown",()=>{this.field.focus(),this.focusMark_paint(!0)}),this.field.addEventListener("focusin",()=>this.focusMark_paint(!0)),this.field.addEventListener("focusout",i=>{(!(i.relatedTarget instanceof Node)||!this.field.contains(i.relatedTarget))&&this.focusMark_paint(!1)}),this.field.addEventListener("keydown",i=>{if(i.key==="Escape"){this.field_release(),i.stopPropagation();return}i.stopPropagation()})}field_hasFocus(){return document.activeElement instanceof Node&&this.field.contains(document.activeElement)}field_release(){return this.field_hasFocus()?(document.activeElement.blur(),this.focusMark_paint(!1),!0):!1}async series_show(e,s={}){if(this.engine_dispose(),this.series=e,this.forced=s.force===!0,this.pendingLayout=null,this.loadPill.hidden=!0,this.retryPill.hidden=!0,this.presets_paint(e.modality),this.siblings=s.siblings??[],this.pane.dataset.modality=h$(e.modality),this.title.textContent=`IMAGE ${e.modality.toUpperCase()} ${e.seriesDescription}`.trim(),this.title.title=this.title.textContent,this.siblings.length>1){const o=this.siblings.findIndex(a=>a.path===e.path)+1;this.handlers.note(`image: series ${o} of ${this.siblings.length} in this study; image series <n> switches`)}const i=await this.chunk_import(()=>lm(()=>import("./cornerstoneEngine-BUPxTjGN.js").then(o=>o.b2),__vite__mapDeps([0,1,2]),import.meta.url));if(i===null)return;const{CornerstoneEngine:n}=i,r=new n(this.engineHost_get(),e,s.startAt??1);await this.engine_open(r),this.engine===r&&(this.guard_trips()?(this.loadPill.hidden=!1,this.stateSpan.textContent=`SERIES ${Xc(e.bytes)} · LOAD FOR STACK`,this.handlers.note(`image: ${Xc(e.bytes)} to fetch before the stack scrolls; press LOAD, image load, or image --force <path>`)):r.slices_fill(),await this.annotations_reload(r,e))}async annotations_reload(e,s){let i=0;for(const n of s.annotations.filter(r=>/\.dcm$/i.test(r))){if(this.engine!==e)return;const r=n.split("/").pop()??n;try{const o=await fetch(this.handlers.source.url_resolve(n));if(!o.ok){this.handlers.note(`image: ${r}: HTTP ${o.status}`);continue}const a=await e.annotations_import(await o.arrayBuffer());i+=a,this.handlers.note(a>0?`image: ${a} measurement${a===1?"":"s"} from ${r}`:`image: ${r}: no measurements this engine can place`)}catch(o){this.handlers.note(`image: ${r}: ${o instanceof Error?o.message:String(o)}`)}}this.pane.dataset.annotations=String(i)}async volume_show(e){this.engine_dispose(),this.series=null,this.siblings=[],this.pane.dataset.modality="NIFTI",this.title.textContent=`IMAGE ${e.split("/").pop()??""}`,this.title.title=e,this.forced=!0,this.loadPill.hidden=!0,this.retryPill.hidden=!0,this.presets_paint("NIFTI");const s=await this.chunk_import(()=>lm(()=>import("./niivueEngine-Dv8fpk3P.js"),__vite__mapDeps([3,1]),import.meta.url));if(s===null)return;const{NiivueEngine:i}=s;await this.engine_open(new i(this.engineHost_get(),e))}async chunk_import(e){try{const s=await e();if(s!==void 0)return s}catch(s){if(!r_(s))throw s}return ys(this.stateSpan,"stale",nd),this.handlers.note(`image: ${nd.toLowerCase()} — the viewer's code is of an older build than the server has`),null}opening_show(e){const s=e.replace(/\/$/,"").split("/").pop()??e;this.stateSpan.textContent="OPENING",this.progress_show({label:`OPENING ${s}`,done:0,total:0})}opening_fail(e,s){this.stateSpan.textContent=s,this.progress_show({label:s,done:0,total:0});const i=this.progressNote;i!==null&&(i.classList.add("image-working-failed"),i.querySelector(".image-working-count").textContent=e)}siblings_get(){return this.siblings}series_get(){return this.series}state_get(){return this.engine===null?null:{...this.engine.state_get(),colormap:this.colormap,path:this.series?.path??null,guard:this.guardBytes,waiting:this.pendingLayout}}async layout_set(e){if(this.engine===null)return!1;if(e!=="single"&&this.guard_trips())return this.pendingLayout=e,this.loadPill.hidden=!1,this.stateSpan.textContent=`SERIES ${Xc(this.series?.bytes??0)} · LOAD FOR ${e.toUpperCase()}`,this.handlers.note(`image: ${Xc(this.series?.bytes??0)} to fetch for ${e}; press LOAD, image load, or image --force <path>`),!1;const s=this.engine.state_get().layout;return this.layoutPills_paint(e),this.modeSpan.textContent=e==="single"?"":e.toUpperCase(),this.overlay_hide(),await this.engine.layout_set(e)?(this.progress_show(null),this.overlay_paint(),this.toolPills_paint(),!0):(this.progress_show(null),this.layoutPills_paint(s),this.modeSpan.textContent=s==="single"?"":s.toUpperCase(),this.handlers.note(`image: layout ${e}: not offered by ${this.engine.name}`),!1)}layoutPills_paint(e){for(const[s,i]of this.layoutPills)i.classList.toggle("rail-off",s!==e)}guard_trips(){return this.guardBytes!==null&&!this.forced&&this.engine?.name==="cornerstone"&&(this.series?.bytes??0)>this.guardBytes}async load_press(){this.forced=!0,this.loadPill.hidden=!0,this.retryPill.hidden=!0;const e=this.pendingLayout;return this.pendingLayout=null,e!==null?this.layout_set(e):this.engine===null||this.engine.state_get().filled?!1:this.engine.slices_fill()}guard_set(e){this.guardBytes=e}guard_get(){return this.guardBytes}preset_cycle(){const e=this.presets_select(this.series?.modality??"NIFTI");if(e.length===0)return;this.presetIndex=(this.presetIndex+1)%e.length;const s=e[this.presetIndex];s!==void 0&&this.wl_set(s.lower,s.upper)&&(this.presetPill.textContent=s.name.toUpperCase())}presets_select(e){const s=e.toUpperCase();return zz.filter(i=>i.modalities.length===0||i.modalities.includes(s))}presets_paint(e){this.presetIndex=-1;const s=this.presets_select(e);this.presetPill.hidden=s.length===0,this.presetPill.textContent="PRESET"}slice_set(e){if(this.engine===null)return!1;const s=this.engine.slice_set(e);return s||this.handlers.note(`image: slice ${e}: not offered in ${this.engine.state_get().layout} layout by ${this.engine.name}`),s}wl_set(e,s){if(this.engine===null)return!1;const i=this.engine.wl_set(e,s);return i||this.handlers.note(`image: wl: not offered by ${this.engine.name}`),i}ghost_set(e){if(this.engine===null)return!1;const s=this.engine.ghost_set(e);return s||this.handlers.note("image: ghost applies to the SLAB layout"),s}wlPreset_set(e){const s=this.series?.modality??"NIFTI",i=j2(e,s);return i===void 0?(this.handlers.note(`image: wl preset ${e}: none for ${s}`),!1):this.wl_set(i.lower,i.upper)}colormap_set(e){return this.engine===null?!1:this.engine.colormap_set(e)?(this.colormap=e,this.colormapPill.textContent=e.toUpperCase(),!0):(this.handlers.note(`image: colormap ${e}: not offered by ${this.engine.name}`),!1)}tool_set(e){return this.engine===null?!1:this.engine.tool_set(e)?(this.tool=e,this.toolPills_paint(),!0):(this.handlers.note(`image: ${e}: not offered by ${this.engine.name}`),!1)}async annotations_save(){if(this.engine===null)return!1;const e=this.series?.seriesInstanceUID,s=/^(\/home\/[^/]+)\//.exec(this.series?.path??"")?.[1];if(e===void 0||s===void 0)return this.handlers.note("image: save: this series has no UID to file an annotation under"),!1;const i=await this.engine.annotations_export();if(i===null)return this.handlers.note(`image: save: nothing measured, or ${this.engine.name} writes no report`),!1;const n=`${s}/annotations/${e}/measurements.dcm`,r=await this.handlers.file_put(n,i);return this.handlers.note(r===200?`✓ ${n}`:`image: save: ${n}: HTTP ${r}`),r===200}dispose(){this.engine_dispose()}async colormap_cycle(){const e=dh[(dh.indexOf(this.colormap)+1)%dh.length]??"gray";this.colormap_set(e)}async engine_open(e){this.engine=e,this.field.replaceChildren(),this.progressNote=null,this.overlayNote=null,this.probeNote=null,this.layoutPills_paint("single"),this.modeSpan.textContent="",this.colormapPill.textContent=this.colormap.toUpperCase();try{await e.open(this.field)}catch(i){this.stateSpan.textContent="REFUSED",this.handlers.note(`image: ${i instanceof Error?i.message:String(i)}`);return}const s=e.state_get().layout;this.layoutPills_paint(s),this.modeSpan.textContent=s==="single"?"":s.toUpperCase(),e.tool_set(this.tool),this.toolPills_paint(),this.progress_show(null),this.overlay_fill()}engine_dispose(){this.engine?.dispose(),this.engine=null,this.progressNote=null,this.overlayNote=null,this.probeNote=null,this.field.replaceChildren(),this.stateSpan.textContent=""}retryPill_paint(){const e=this.engine===null?0:this.engine.state_get().refused,s=this.engine?.refused_retry!==void 0;this.retryPill.hidden=!s||e===0,this.retryPill.disabled||(this.retryPill.textContent=`RETRY ${e}`)}async retry_press(){if(!(this.engine?.refused_retry===void 0||this.retryPill.disabled)){this.retryPill.disabled=!0,this.retryPill.textContent="ASKING…";try{await this.engine.refused_retry()}finally{this.retryPill.disabled=!1,this.retryPill_paint()}}}engineHost_get(){return{source:this.handlers.source,readout_set:e=>{this.stateSpan.textContent=e,this.retryPill_paint()},progress_set:e=>this.progress_show(e),note:this.handlers.note,regard:e=>{this.handlers.regard(e),this.overlaySlice_paint()},probe_set:e=>this.probe_show(e)}}probe_show(e){if(e===null){this.probeNote?.remove(),this.probeNote=null;return}if(this.probeNote===null||this.probeNote.parentElement===null){const s=document.createElement("div");s.className="image-probe-note",this.field.appendChild(s),this.probeNote=s}this.probeNote.textContent=e}overlaySlice_paint(){const e=this.overlayNote?.querySelector(".image-overlay-slice")??null;if(e===null||this.engine===null)return;const s=this.engine.state_get();e.textContent=s.slices>1?`SLICE ${Math.max(1,s.slice)} OF ${s.slices}`:"",e.hidden=s.slices<=1}progress_show(e){if(e===null){this.progressNote?.remove(),this.progressNote=null;return}if(this.progressNote===null||this.progressNote.parentElement===null){const o=document.createElement("div");o.className="image-working",o.innerHTML='<span class="image-working-label"></span><span class="image-working-track"><span class="image-working-fill"></span></span><span class="image-working-count"></span>',this.field.appendChild(o),this.progressNote=o}const s=this.progressNote;s.classList.remove("image-working-failed");const i=e.total>0,n=i?Math.min(1,e.done/e.total):0;s.querySelector(".image-working-label").textContent=e.label,s.querySelector(".image-working-count").textContent=i?`${e.done} / ${e.total} · ${Math.round(n*100)}%`:"";const r=s.querySelector(".image-working-fill");r.classList.toggle("image-working-pacing",!i),r.style.width=i?`${Math.round(n*100)}%`:""}async overlay_set(e){if(this.overlay=e,this.overlayPill.textContent=e?"OVERLAY ON":"OVERLAY OFF",this.overlayPill.classList.toggle("rail-off",!e),!e){this.overlay_hide();return}await this.overlay_fill()}overlay_hide(){this.overlayNote?.remove(),this.overlayNote=null}async overlay_fill(){if(!this.overlay||this.series===null)return;const e=this.series.files[0]??this.series.path,s=await this.handlers.tags_read(e);if(s===null){this.handlers.note(`image: overlay: ${e}: no header to read`);return}this.overlayLines=l$.flatMap(i=>{const r=(s.constant.find(o=>o.name===i.tag)?.value??"").trim();return r===""?[]:[i.label===""?r:`${i.label} ${r}`]}),this.overlay_paint()}overlay_paint(){if(!this.overlay||this.overlayLines.length===0)return;this.overlay_hide();const e=document.createElement("div");e.className="image-overlay-note";const s=document.createElement("span");s.className="image-overlay-slice",e.appendChild(s);for(const i of this.overlayLines){const n=document.createElement("span");n.textContent=i,e.appendChild(n)}this.field.appendChild(e),this.overlayNote=e,this.overlaySlice_paint()}toolPills_paint(){const e=new Set(this.engine?.toolsOffered_get()??Rb),s=this.engine!==null?this.engine.state_get().primaryTool:this.tool;for(const[i,n]of this.toolPills){const r=e.has(i);n.classList.toggle("rail-na",!r),n.classList.toggle("rail-off",r&&i!==s),n.disabled=!r}}focusMark_paint(e){this.focusMark.hidden=!e,this.pane.classList.toggle("image-field-focused",e)}}function di(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`image pane: missing ${e}`);return s}const E1=["patient","study","series","image","equipment","meta","private","other","varying"],u$=new Set(["meta","private"]),av="••••";class f${pane;title;modeSpan;redactBlock;listing;handlers;redact=!0;model=null;groups=[];constructor(e,s){this.handlers=s,this.pane=e,this.title=Zc(e,".pane-title"),this.modeSpan=Zc(e,".pane-mode"),this.redactBlock=Zc(e,".tags-redact"),this.redactBlock.addEventListener("click",()=>this.redact_set(!this.redact));const i=Zc(e,".tags-panel");this.listing=new Ir({mount:i,traits:this.groupTraits_declare(),key:n=>n.group,chrome:{root:e,prefix:"tags"},caps:"root",row:{className:()=>"tags-group-row",groupClassName:n=>`tags-group tags-group-${n.group}`,decorate:n=>{n.title="fold this group open or shut (it keeps its place)"}},child:sa(n=>n.rows,{traits:this.tagTraits_declare(),key:n=>n.key,activatable:n=>n.items.length>0,row:{className:n=>`tags-row${n.phi?" tags-phi":""}`,groupClassName:()=>"tags-sequence",decorate:(n,r)=>{n.title=r.items.length>0?`${r.name}: fold the sequence open or shut`:`${r.tag} ${r.name}`}},child:sa(n=>n.items,{traits:this.itemTraits_declare(),key:n=>n.key,row:{className:()=>"tags-item-row",groupClassName:()=>"tags-item"},child:sa(n=>n.rows,{traits:this.tagTraits_declare(),key:n=>n.key,activatable:()=>!1,row:{className:n=>`tags-row tags-row-deep${n.phi?" tags-phi":""}`}})})}),state:n=>this.stateLine_compose(n),empty:()=>_$("NO TAGS")}),this.redactBlock_paint(),this.listing.rows_set([],{field:"tags"})}model_show(e){this.model=e,this.title.textContent=`TAGS ${m$(e)}`,this.pane.dataset.modality=g$(e),this.groups=p$(e),this.listing.rows_set([{key:e.path,rows:this.groups}],{field:e.path}),this.listing.open_set(0,this.groups.map(s=>s.group).filter(s=>!u$.has(s))),this.modeSpan.textContent=e.subject==="folder"?"FOLDER":""}path_get(){return this.model?.path??null}redact_get(){return this.redact}redact_set(e){this.redact=e,this.redactBlock_paint(),this.model!==null&&this.listing.rows_set([{key:this.model.path,rows:this.groups}],{field:this.model.path})}filter_set(e){if(e===null){this.listing.filter_toggle(!1);return}this.listing.filter_toggle(!0),this.listing.filter_set(e)}stateLine_compose(e){const s=this.groups.reduce((n,r)=>n+r.rows.length,0),i=[];return this.model!==null&&this.model.subject==="folder"&&(i.push(this.model.read===this.model.of?`${this.model.read} FILES`:`${this.model.read} OF ${this.model.of} FILES`),this.model.refused.length>0&&i.push(`REFUSED ${this.model.refused.length}`)),i.push(e.filter!==""?e.filter:`${s} TAGS`),this.redact&&i.push("REDACTED"),i.join(" · ")}redactBlock_paint(){this.redactBlock.textContent=this.redact?"REDACT ON":"REDACT OFF",this.redactBlock.classList.toggle("rail-off",!this.redact),this.pane.classList.toggle("tags-redacted",this.redact)}value_cell(e){const s=document.createElement("span");if(s.className="tags-value",e.phi&&this.redact)return s.textContent=av,s.title="identifying value, redacted; the REDACT block on the frame reveals it",s;if(s.textContent=e.value,e.decoded!==void 0){const i=document.createElement("span");i.className="tags-decoded",i.textContent=` ${e.decoded}`,s.appendChild(i)}if(e.distinct!==void 0){const i=document.createElement("span");i.className="tags-decoded",i.textContent=` (${e.distinct} distinct)`,s.appendChild(i)}return s}groupTraits_declare(){return[nf(()=>!0),{key:"group",label:"GROUP",className:"tags-group-name",width:"minmax(12em, 1fr)",cell:e=>e.group.toUpperCase(),compare:e=>E1.indexOf(e.group)},{key:"count",label:"TAGS",className:"tags-group-count",width:"5em",cell:e=>String(e.rows.length),compare:e=>e.rows.length}]}tagTraits_declare(){return[nf(e=>e.items.length>0),{key:"tag",label:"TAG",className:"tags-tag",width:"7em",cell:e=>e.tag,compare:e=>e.tag},{key:"name",label:"NAME",className:"tags-name",width:"minmax(8em, 1.4fr)",cell:e=>e.name,compare:e=>e.name.toLowerCase()},{key:"vr",label:"VR",className:"tags-vr",width:"2.4em",cell:e=>e.vr,compare:e=>e.vr},{key:"value",label:"VALUE",className:"tags-value-cell",width:"minmax(6em, 2fr)",cell:e=>this.value_cell(e),compare:e=>(e.phi&&this.redact?av:`${e.value} ${e.decoded??""}`).toLowerCase()}]}itemTraits_declare(){return[nf(()=>!0),{key:"item",label:"ITEM",className:"tags-item-name",width:"minmax(12em, 1fr)",cell:e=>`ITEM ${e.index}`,compare:e=>e.index},{key:"count",label:"TAGS",className:"tags-group-count",width:"5em",cell:e=>String(e.rows.length),compare:e=>e.rows.length}]}}function nf(t){return{key:"fold",label:"",className:"tags-fold",capped:!1,width:"1.4em",cell:e=>{const s=document.createElement("span");return s.className=t(e)?"tags-fold":"tags-fold tags-fold-none",s}}}function p$(t){const e=new Map;for(const s of t.constant){const i=s.group;e.has(i)||e.set(i,[]),e.get(i)?.push(A1(s,`${i}/${s.tag}`))}return t.varying.length>0&&e.set("varying",t.varying.map(s=>({tag:s.tag,name:s.name,vr:s.vr,value:s.distinct===1?s.first:`${s.first} .. ${s.last}`,phi:s.phi,items:[],distinct:s.distinct,key:`varying/${s.tag}`}))),E1.filter(s=>e.has(s)).map(s=>({group:s,rows:e.get(s)??[]}))}function A1(t,e){return{tag:t.tag,name:t.name,vr:t.vr,value:t.value,...t.decoded!==void 0?{decoded:t.decoded}:{},phi:t.phi,items:(t.items??[]).map((s,i)=>({index:i+1,key:`${e}/${i+1}`,rows:s.map(n=>A1(n,`${e}/${i+1}/${n.tag}`))})),key:e}}function m$(t){const e=t.path.replace(/\/$/,"").split("/").pop()??t.path;if(t.subject==="folder")return e.length>24?`${e.slice(0,22)}…`:e;const s=/^(\d+)-/.exec(e)?.[1];return s!==void 0?`INSTANCE ${Number(s)}`:e.length>24?`${e.slice(0,22)}…`:e}function g$(t){const e=(t.constant.find(s=>s.name==="Modality")?.value??"").toUpperCase();return e==="MR"||e==="CT"||e==="PT"?e:"OT"}function _$(t){const e=document.createElement("div");return e.className="tags-note",e.textContent=t,e}function Zc(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`tags pane: missing ${e}`);return s}function b$(t,e){const s=qi("tpl-pane-image"),i=new d$(s,{source:{url_resolve:n=>t.vfsUrl_build(n)},note:n=>t.terminal().line_note(n),regard:n=>t.subjects().regard_write(e,{address:n,modelKind:"dicom.instance"}),file_put:async(n,r)=>{try{return(await fetch(t.vfsUrl_build(n),{method:"POST",body:r})).status}catch{return 0}},tags_read:n=>o_(t,n),tags_open:()=>{t.terminal().line_note(T1(t,e))}});return t.panels().set("image",e,i),{id:e,kind:"image",mount:s,dispose:()=>{i.dispose(),t.panels().delete(e),t.subjects().pane_leave(e)}}}function M$(t,e){const s=qi("tpl-pane-tags"),i=new f$(s,{note:n=>t.terminal().line_note(n)});return t.panels().set("tags",e,i),{id:e,kind:"tags",mount:s,dispose:()=>{t.panels().delete(e),t.subjects().pane_leave(e)}}}async function o_(t,e){try{const s=await t.client().line_execute(`dcm tags "${e}"`,{silent:!0,observe:!1});for(const i of s.envelopes){if(i.model?.kind!==Qo.tags)continue;const n=cz.safeParse(i.model.data);if(n.success)return n.data}}catch{}return null}function v$(t,e,s){const i=t.panels().get("tags",e);i===void 0||i.path_get()===s||o_(t,s).then(n=>{if(n===null){t.terminal().line_note(`tags: ${s}: not a readable DICOM file`);return}t.panels().get("tags",e)?.model_show(n)})}function T1(t,e){const s=new Set(t.layout().panes_shown()),i=t.subjects().group_resolve(e);for(const r of t.panels().ids("tags"))if(s.has(r)&&t.subjects().group_resolve(r)===i)return t.layout().focus_set(r),"image tags";if(!s.has(e))return"image tags: the image pane is not on stage";const n=t.instance_spawn("tags",e);return t.layout().leaf_split(e,t.desktop().replayPlace_get()?.dir??"col",n.id,t.desktop().replayPlace_get()?.before??!1)?(t.birth_record(n.id,e,t.desktop().replayPlace_get()?.dir??"col",t.desktop().replayPlace_get()?.before??!1),"image tags"):(As(n.id),t.layout().mount_remove(n.id),"image tags: could not open beside the image pane")}async function cm(t,e){try{const s=await t.client().line_execute(`dcm series "${e}"`,{silent:!0,observe:!1});for(const i of s.envelopes){if(i.model?.kind!==Qo.series)continue;const n=hz.safeParse(i.model.data);if(n.success)return n.data}}catch{}return null}async function I1(t,e){try{const s=await t.client().line_execute(`ls "${e}"`,{silent:!0,observe:!1});for(const i of s.envelopes){if(i.model?.kind!=="fs.listing")continue;const n=i.model.data,r=(Array.isArray(n)?n[0]:n)??{},o=(r.path??e).replace(/\/$/,"");return(r.items??[]).filter(a=>a.type==="dir").map(a=>`${o}/${a.name}`)}}catch{}return[]}function D1(t,e,s){const i=l=>{s!==void 0&&t.subjects().regard_write(l,s)};if(e!==null&&t.panels().has("image",e))return i(e),t.panels().get("image",e)??null;const n=new Set(t.layout().panes_shown());if(s!==void 0){for(const[l,c]of t.panels().entries("image"))if(n.has(l)&&t.subjects().regard_get(l)?.address===s.address)return i(l),c}const r=e!==null?t.subjects().group_resolve(e):null;for(const[l,c]of t.panels().entries("image"))if(n.has(l)&&r!==null&&t.subjects().group_resolve(l)===r)return c;const o=e!==null&&n.has(e)?e:t.errandHost_find();if(o===null)return null;const a=t.instance_spawn("image",e??void 0);return t.layout().leaf_split(o,t.desktop().replayPlace_get()?.dir??"col",a.id,t.desktop().replayPlace_get()?.before??!1)?(t.birth_record(a.id,o,t.desktop().replayPlace_get()?.dir??"col",t.desktop().replayPlace_get()?.before??!1),i(a.id),t.panels().get("image",a.id)??null):(As(a.id),t.layout().mount_remove(a.id),null)}async function w$(t,e,s,i={},n){t.launcher_yield();const r=e!==null?void 0:sp.test(s)?{address:s,modelKind:"image.volume"}:{address:$h.test(s)?s.slice(0,s.lastIndexOf("/")):s.replace(/\/$/,""),modelKind:"dicom.series"},o=D1(t,e,r);if(o===null)return"image: no pane to open beside";const a=t.panels().idOf("image",o);if(a!==null&&n?.(a),sp.test(s))return o.opening_show(s),o.volume_show(s),`image ${s}`;const l=$h.test(s),c=l?s.slice(0,s.lastIndexOf("/")):s.replace(/\/$/,"");o.opening_show(c);let h=await cm(t,c),d=[];if(h===null&&!l){const p=(await I1(t,c)).slice(0,32);for(const f of p){const _=await cm(t,f);if(_!==null){d=p.map(g=>({path:g,label:g.split("/").pop()??g})),h=_;break}}}if(h===null)return o.opening_fail(s,"NOT A READABLE SERIES"),`image: ${s}: not a readable DICOM series, study, or volume`;const u=l?Math.max(1,h.files.indexOf(s)+1):1;return o.series_show(h,{siblings:d,startAt:u,...i.force===!0?{force:!0}:{}}),`image ${h.path}${d.length>1?` (1 of ${d.length} series)`:""}`}function y$(t){return{imageInstance_build:e=>b$(t,e),tagsInstance_build:e=>M$(t,e),tags_ask:e=>o_(t,e),tagsPane_follow:(e,s)=>v$(t,e,s),tagsPane_open:e=>T1(t,e),series_ask:e=>cm(t,e),subfolders_ask:e=>I1(t,e),imagePane_resolve:(e,s)=>D1(t,e,s),image_open:(e,s,i={},n)=>w$(t,e,s,i,n)}}function z$(t){return{primaries:[t.panes.dag_build("dag",!0),t.panes.universe_build("universe"),{id:"pacs",kind:"pacs",mount:t.pacsMount}],domains:["dag","pacs"],presets:[["pacs",()=>({pane:"pacs"})],["dag",()=>({pane:"dag"})],["universe",()=>({pane:"universe"})]],factories:[["dag",e=>t.panes.dag_build(e,!1)],["universe",t.panes.universe_build],["image",t.dicom.imageInstance_build],["tags",t.dicom.tagsInstance_build],["gather",t.gather_build]]}}function S$(t){return async()=>{const e=await t.ask("proc feeds");let s=[];for(const d of e.envelopes){const u=d.model;if(u===void 0||u.kind!==Kf)continue;const p=qf.safeParse(u.data);p.success&&(s=p.data.feeds)}const n=s.length===0&&e.envelopes.some(d=>d.status==="error")?"INDEX WARMING":`${s.length} FEEDS`,r=s.filter(d=>/error/i.test(d.status)).length,o=s.filter(d=>/running|scheduled|created|started/i.test(d.status)).length,a={key:"universe",name:"UNIVERSE",hue:"--honey",numeral:"",figures:[{text:n}],rows:[],verb:"SEE THE SPACE",about:hn.universe,enter:()=>t.universe_show()},l={key:"analyses",name:"ANALYSES",hue:"--october-sunset",numeral:"3",figures:[{text:n},...o>0?[{text:`${o} RUNNING`}]:[],...r>0?[{text:`${r} ERRORED`,errored:!0,open:()=>t.runs_show("status:error")}]:[]],rows:s.slice(0,6).map(d=>({text:`${d.id} ${d.title}`,errored:/error/i.test(d.status),open:()=>t.feed_enter(d.id)})),verb:"OPEN THE ROSTER",about:hn.analyses,enter:()=>t.runs_show()},c=t.pacs_query(),h={key:"pacs",name:"PACS",hue:"--daybreak",numeral:"4",figures:[{text:c===""?"NO ANSWER":"ANSWERED"}],rows:c===""?[{text:"pacs query PatientID:…",open:()=>t.line_offer("pacs query PatientID:")},{text:"pacs query AccessionNumber:…",open:()=>t.line_offer("pacs query AccessionNumber:")}]:[{text:c.slice(0,48)}],verb:"ASK A PACS",about:hn.pacs,enter:()=>t.pacs_open()};return{lead:{tile:l,weight:s.length},afterFiles:[h],afterPanes:[a],about:{files:{text:"Your ChRIS home: uploads, results and what others shared with you."}}}}}const x$=["expired","failed","error"];function lv(t,e,s){for(const i of t.envelopes){if(i.model?.kind!==e)continue;const n=s(i.model.data);if(n.success&&n.data!==void 0)return n.data}return null}function O$(t){return t===null?"REGION":t.includes(":")?t.slice(t.indexOf(":")+1):t}function E$(t){return t.limit.replace(new RegExp(`^(standard-)?${t.family.toLowerCase()}-`),"").replace(/-count$/,"")}function A$(t){const e=t.available===null?`${t.value} PERMITTED`:`${t.available} / ${t.value} FREE`;return`${t.family.toUpperCase()} ${O$(t.zone)} ${E$(t)} ${e}`}function cv(t,e){return`${e==="USD"?"$":`${e} `}${t.toFixed(2)}`}function T$(t){return async()=>{const[e,s]=await Promise.all([t.ask("domain status"),t.ask("capacity")]),i=lv(e,mz,u=>bz.safeParse(u)),n=i?.domains??[];i!==null&&t.names_seen?.(n.map(u=>u.name));const r=u=>u.steps.some(p=>x$.includes(p.state)),o=n.filter(r).length,a=n.filter(u=>u.cost!==void 0&&u.cost!==null),l=a.reduce((u,p)=>u+(p.cost?.hourly??0),0),c={key:"domains",name:"DOMAINS",hue:"--october-sunset",numeral:"",figures:[{text:n.length===0?"NONE":`${n.length} DOMAIN${n.length===1?"":"S"}`},...o>0?[{text:`${o} NEED${o===1?"S":""} A LOOK`,errored:!0}]:[],...a.length>0?[{text:`${cv(l,a[0]?.cost?.currency??"USD")}/H`}]:[]],rows:n.slice(0,6).map(u=>({text:`${u.name} ${u.lastDone??"NOTHING DONE"}${u.cost!==void 0&&u.cost!==null?` ${cv(u.cost.hourly,u.cost.currency)}/h`:""} ${u.cluster??""}`.trimEnd(),errored:r(u),open:()=>t.domain_open(u.name)})),verb:"OPEN THE CONTROLLER",about:hn.domains,enter:()=>t.domain_open("")},h=lv(s,Hk,u=>qk.safeParse(u)),d={key:"capacity",name:"CAPACITY",hue:"--honey",numeral:"",figures:h===null?[{text:"NO FAMILY"}]:[{text:h.region.toUpperCase()}],rows:h===null?[{text:"capacity E5",open:()=>t.line_run("capacity E5")}]:h.rows.slice(0,6).map(u=>({text:A$(u),errored:u.available===0,open:()=>t.line_run(`capacity ${u.family}`)})),verb:"READ CAPACITY",about:hn.capacity,enter:()=>t.line_run("capacity")};return{lead:{tile:c,weight:n.length},afterFiles:[d],afterPanes:[],about:{files:{text:"Your home: the Trusted Domains this session knows, each a folder of its spec, settings, state and steps."}}}}}const gl=new Set([""]);function I$(t){const e=new Set(["",...t]);if(e.size===gl.size&&[...e].every(s=>gl.has(s)))return!1;gl.clear();for(const s of e)gl.add(s);return!0}function D$(t){return{subjects:{domain:gl},views:{},claims:{},listings:{},chords:[],lines:[{after:"view",line:"domain [<name>] (the TD controller takes the screen; every other domain line is the session's)"}],run:(e,s)=>{if(s.subject==="domain")return t().controller_open(s.words[0]??"")}}}function C$(t){return t>=6e4?`${Math.max(1,Math.round(t/6e4))} MIN`:`${Math.max(1,Math.round(t/1e3))} S`}function wi(t){return t.toLocaleString("en-US")}class R${mount;counts=null;context=null;msPerPage=null;walkSamples=new Map;clock;acts;state=void 0;constructor(e,s=()=>Date.now(),i={}){this.mount=e,this.clock=s,this.acts=i,this.render()}state_show(e){this.state=e,this.render()}pace_show(e){this.msPerPage=e,this.render()}eta_compute(e,s,i){const n=this.clock(),r=this.walkSamples.get(e);let o=r?.rowsPerMs??null;r!==void 0&&s>r.loaded&&n>r.at&&(o=(s-r.loaded)/(n-r.at)),(r===void 0||s!==r.loaded)&&this.walkSamples.set(e,{loaded:s,at:n,rowsPerMs:o});const a=Math.max(0,i-s);return i<=0?null:o!==null&&o>0?a/o:this.msPerPage!==null&&this.msPerPage>0?Math.ceil(a/100/4)*this.msPerPage:null}counts_show(e){this.counts=e,this.render()}promptContext_show(e){this.context=e,e.procIndex!==void 0&&(this.counts={jobs:e.procIndex.jobs,feeds:e.procIndex.feeds}),this.render()}rows_compose(){const e=[],s=this.context?.procWarmup,i=this.context?.warmupFailures??[],n=s!==void 0&&s.sweeping!==!1,r=this.counts!==null?`${wi(this.counts.jobs)} JOBS · ${wi(this.counts.feeds)} FEEDS`:"";if(i.length>0)e.push({label:"INDEX",bar:null,value:`${r}${r?" · ":""}FAILED: ${i.map(l=>l.label.toUpperCase()).join(" ")}`,title:i.map(l=>`${l.label}: ${l.message}`).join(`
4348
4348
  `),degraded:!0});else if(n&&s!==void 0){const l=(s.state??"cold").toUpperCase();e.push({label:"INDEX",bar:{loaded:s.loaded,total:s.total??0,state:s.state==="failed"?"failed":"running"},value:`SWEEP ${wi(s.loaded)} / ${s.total!==void 0?wi(s.total):"?"} · ${l}`,title:"The global topology sweep: every plugin instance CUBE holds, walked page by page.",degraded:s.state==="failed"})}else e.push({label:"INDEX",bar:null,value:r?`${r} · CURRENT`:"CURRENT",title:"Nothing is moving: the process index is whole and current.",degraded:!1});if(this.state!==void 0){const l=this.state;e.push({label:"RUNNING",bar:null,value:`${wi(l.running)} IN ${wi(l.runningFeeds)} FEEDS · SCHEDULED ${wi(l.scheduled)}`,title:"Jobs running and waiting across every feed the index holds, from the roster's own counters.",degraded:!1,verb:this.acts.errored_open!==void 0?{label:`ERRORED ${wi(l.errored)} IN ${wi(l.erroredFeeds)} FEEDS`,title:"Open the runs roster filtered to the feeds with errored jobs.",act:this.acts.errored_open}:null})}const o=s?.feeds??(s?.feed!==void 0?[s.feed]:[]);for(const l of Array.from(this.walkSamples.keys()))o.some(c=>c.id===l)||this.walkSamples.delete(l);for(const l of o){const c=l.total>0?wi(l.total):"?";if(l.failed!==void 0)e.push({label:`FEED ${l.id}`,bar:{loaded:l.loaded,total:l.total,state:"failed"},value:`FAILED AT ${wi(l.loaded)} / ${c} · ${l.failed.toUpperCase()}`,title:"The walk stopped; the next visit to the feed starts it again.",degraded:!0});else{const h=this.eta_compute(l.id,l.loaded,l.total);e.push({label:`FEED ${l.id}`,bar:{loaded:l.loaded,total:l.total,state:"running"},value:`INDEXING ${wi(l.loaded)} / ${c}${h!==null?` · ETA ${C$(h)}`:""}`,title:"A feed is being indexed on its first visit; it opens when the walk lands.",degraded:!1})}}s?.roster!==void 0&&e.push({label:"ROSTER",bar:null,value:s.roster==="full"?"FULL WALK · every feed the identity can see":"DELTA · feeds newer than the roster knows",title:"The roster is being brought up to date; the listing answered from the cache and refreshes when arrivals land.",degraded:!1});const a=s?.arrived??[];return a.length>0&&e.push({label:"ARRIVED",bar:null,value:a.length<=3?a.map(l=>`FEED ${l}`).join(" · "):`${a.length} FEEDS`,title:"Feeds the roster gained: created here, or shared with this identity.",degraded:!1}),e}render(){const e=this.rows_compose();this.mount.replaceChildren();for(const s of e){const i=document.createElement("div");i.className="index-row telemetry-row",i.classList.toggle("status-degraded",s.degraded),i.title=s.title;const n=document.createElement("span");if(n.className="telemetry-label",n.textContent=s.label,i.appendChild(n),s.bar!==null){const o=document.createElement("span");o.className=`index-bar listing-progress listing-progress-${s.bar.state}`;const a=document.createElement("span");a.className="listing-progress-fill";const l=s.bar.total>0?Math.min(100,Math.round(s.bar.loaded/s.bar.total*100)):0;a.style.width=`${l}%`,o.appendChild(a),i.appendChild(o)}const r=document.createElement("span");if(r.className="telemetry-value",r.textContent=s.value,i.appendChild(r),s.verb!==void 0&&s.verb!==null){const o=document.createElement("button");o.type="button",o.className="index-verb pacs-capsule",o.textContent=s.verb.label,o.title=s.verb.title,o.addEventListener("click",s.verb.act),i.appendChild(o)}this.mount.appendChild(i)}}}function k$(t,e){const s=new R$(t,()=>Date.now(),{errored_open:()=>e.runs_show("status:error")});return{promptContext_take:i=>{s.promptContext_show(i),e.dag_primary().promptContext_observe(i);for(const n of e.universes())n.promptContext_observe(i)},telemetry_take:(i,n)=>{s.counts_show(i),n?.state!==void 0&&s.state_show(n.state),n?.cube!==void 0&&s.pace_show(n.cube.msPerPage)},progress_take:i=>{for(const n of e.dag_instances())n.progress_observe(i);e.pacs().progress_observe(i)}}}class N${container;title;handlers;currentAddress=null;constructor(e,s,i){this.container=e,this.title=s,this.handlers=i,this.awaiting_render()}regard_show(e){if(this.currentAddress=e.address,this.title.textContent=`VIEWER — ${e.address}`.toUpperCase(),this.handlers.path_isImage(e.address)){this.container.replaceChildren();const s=document.createElement("img");s.className="files-image",s.src=this.handlers.imageUrl_build(e.address),s.alt=e.address,this.container.appendChild(s);return}this.handlers.content_fetch(e.address).then(s=>{if(this.currentAddress!==e.address)return;if(this.container.replaceChildren(),s.trim().length===0){const n=document.createElement("p");n.className="files-empty",n.textContent=`NO PREVIEW — ${e.address.toUpperCase()}`,this.container.appendChild(n);return}const i=document.createElement("pre");i.className="files-content",i.textContent=s,this.container.appendChild(i)})}awaiting_render(){this.container.replaceChildren();const e=document.createElement("p");e.className="files-empty",e.textContent="NO REGARD — INDICATE A FILE OR NODE IN THIS PANE’S GROUP",this.container.appendChild(e)}}class B${groups=new Map;membership=new Map;writeObserver=null;writeObserver_set(e){this.writeObserver=e}pane_join(e,s){this.pane_leave(e),this.membership.set(e,s),this.groups.has(s)||this.groups.set(s,{value:null,subscribers:new Map,viewers:new Set})}pane_leave(e){const s=this.membership.get(e);if(s===void 0)return;this.membership.delete(e);const i=this.groups.get(s);if(i!==void 0){i.subscribers.delete(e),i.viewers.delete(e);for(const n of this.membership.values())if(n===s)return;this.groups.delete(s)}}group_resolve(e){const s=this.membership.get(e);return s!==void 0?s:(this.pane_join(e,e),e)}viewer_mark(e){this.groups.get(this.group_resolve(e))?.viewers.add(e)}groupHasViewer(e){const s=this.groups.get(this.group_resolve(e));return s!==void 0&&s.viewers.size>0}regard_write(e,s){const i=this.group_resolve(e),n=this.groups.get(i),r={...s,paneId:e};n.value=r;for(const o of n.subscribers.values())o(r);this.writeObserver?.(r,i)}regard_subscribe(e,s){const i=this.groups.get(this.group_resolve(e));i.subscribers.set(e,s),i.value!==null&&s(i.value)}regard_get(e){return this.groups.get(this.group_resolve(e))?.value??null}}const rf=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],G$=new Set(["done","error","unconfirmed","stalled","timeout"]),P$={shell:"`!` runs on its host",pipes:"pipes run on its host",files:"upload/download reach its disk",tasks:"jobs may change the cloud and bill"};function L$(t){return t.length===0?"":`Calypso was started with --host-control: ${t.map(e=>P$[e]??e).join("; ")}.`}function W$(t,e){const s=`${e.operation}:${e.itemId??""}`;if(e.phase==="complete"||e.phase==="failed"){const i=`${e.operation}:`;for(const n of[...t])(n===s||n.startsWith(i))&&t.delete(n);return}if(e.itemId!==void 0&&e.status!==void 0&&G$.has(e.status)){t.delete(s);return}t.add(s)}const F$=100;class U${fields;buildShown=!1;running=new Set;activityTimer=null;activityFrame=0;constructor(e){this.fields={identity:sr(e,"status-identity"),jobs:sr(e,"status-jobs"),activity:sr(e,"status-activity"),latency:sr(e,"status-latency"),mismatch:sr(e,"status-mismatch"),lamp:sr(e,"status-lamp"),host:sr(e,"status-host"),questions:sr(e,"status-questions")}}attach_show(e){if(e.protocolVersion!==Bf){this.fields.mismatch.textContent=`WIRE V${e.protocolVersion} ≠ V${Bf}`,this.fields.mismatch.title="This surface and the daemon speak different contract versions. Some messages may be dropped.",this.hostControl_show(e.hostControl??[]);return}this.fields.mismatch.textContent="",this.fields.mismatch.title=e.stack!==void 0?`chell ${e.stack.chell} · calypso ${e.stack.calypso} · build ${e.stack.build}`:"",this.hostControl_show(e.hostControl??[])}build_show(e,s=""){this.fields.mismatch.textContent!==""&&!this.buildShown||(this.buildShown=e!==null,this.fields.mismatch.textContent=e??"",this.fields.mismatch.title=s)}hostControl_show(e){this.fields.host.textContent=e.length>0?`HOST ${e.join(" ")}`:"",this.fields.host.title=L$(e)}questions_show(e){this.fields.questions.textContent=e.length>0?`? ${e.length} WAITING`:"",this.fields.questions.title=e.map(s=>`surface ${s.surface.slice(0,6)} asks "${s.message.trim()}" (${Math.round(s.sinceMs/1e3)} s); its command is paused until answered there`).join(`
4349
4349
  `)}promptContext_show(e){const s=e.uri.replace(/^https?:\/\//,"");this.fields.identity.textContent=`${e.user}@${s}`.toUpperCase();const i=e.procWarmup,n=[];if(i!==void 0&&i.sweeping!==!1){const a=i.total!==void 0?`/${i.total}`:"",l=i.state!==void 0?` ${i.state.toUpperCase()}`:"";n.push(`JOBS ${i.loaded}${a}${l}`)}const r=i?.feeds??(i?.feed!==void 0?[i.feed]:[]);for(const a of r){const l=a.total>0?`/${a.total}`:"";n.push(a.failed!==void 0?`FEED ${a.id} FAILED ${a.loaded}${l}`:`FEED ${a.id} ${a.loaded}${l}`)}i?.roster!==void 0&&n.push(i.roster==="full"?"ROSTER WALK":"ROSTER DELTA"),i?.arrived!==void 0&&i.arrived.length>0&&n.push(i.arrived.length<=2?`+FEED ${i.arrived.join(" ")}`:`+${i.arrived.length} FEEDS`);const o=e.warmupFailures??[];o.length>0&&n.push(`WARM-UP FAILED: ${o.map(a=>a.label.toUpperCase()).join(" ")}`),this.fields.jobs.textContent=n.join(" · "),this.fields.jobs.classList.toggle("status-degraded",o.length>0),this.fields.jobs.title=o.length>0?o.map(a=>`${a.label}: ${a.message}`).join(`
4350
4350
  `):r.length>0?"A feed is being indexed on its first visit; it opens when the walk completes.":"",this.fields.latency.textContent=e.lastCommandDurationMs>0?`${e.lastCommandDurationMs}MS`:""}progress_observe(e){W$(this.running,e),this.activity_paint()}activity_clear(){this.running.clear(),this.activity_paint()}connection_show(e){this.fields.lamp.textContent=e?"ONLINE":"OFFLINE",this.fields.lamp.classList.toggle("lamp-online",e),this.fields.lamp.classList.toggle("lamp-offline",!e),e||this.activity_clear()}activity_paint(){if(this.running.size===0){this.activityTimer!==null&&(clearInterval(this.activityTimer),this.activityTimer=null),this.fields.activity.textContent="";return}const e=()=>{const s=rf[this.activityFrame]??rf[0];this.fields.activity.textContent=`${s} ${this.running.size} RUNNING`};e(),this.activityTimer===null&&(this.activityTimer=window.setInterval(()=>{this.activityFrame=(this.activityFrame+1)%rf.length,e()},F$))}}function sr(t,e){const s=t.getElementById(e);if(s===null)throw new Error(`status bar: no element with id '${e}'`);return s}const $$=3e3;class j${mount;clock;lane=void 0;cube=void 0;beatAt=null;constructor(e,s=()=>Date.now()){this.mount=e,this.clock=s,this.render()}telemetry_show(e={}){this.beatAt=this.clock(),e.lane!==void 0&&(this.lane=e.lane),e.cube!==void 0&&(this.cube=e.cube),this.render()}tick(){this.render()}rows_compose(){const e=[],s=this.lane;if(s===void 0)e.push({label:"LANE",value:"—",title:"The daemon has not said what holds its lane (an older daemon).",degraded:!1});else if(s.running===null)e.push({label:"LANE",value:s.waiting>0?`IDLE · ${s.waiting} WAITING`:"IDLE",title:"The serialized command lane: nothing is executing.",degraded:!1});else{const r=(s.running.sinceMs/1e3).toFixed(1);e.push({label:"LANE",value:`${s.running.line} · ${r} S${s.waiting>0?` · ${s.waiting} WAITING`:""}`,title:`The command holding the lane${s.running.surface?`, from surface ${s.running.surface}`:""}; every other command waits behind it.`,degraded:s.running.sinceMs>=1e4})}const i=s?.questions??[];if(i.length>0){const r=i.reduce((o,a)=>o.sinceMs>=a.sinceMs?o:a);e.push({label:"ASKING",value:`${i.length} · ${r.message.trim()} · ${(r.sinceMs/1e3).toFixed(0)} S`,title:"Questions open in the session. A command waiting on one has stepped out of the lane; it resumes when answered on the surface that asked.",degraded:!1})}if(this.beatAt===null)e.push({label:"BEAT",value:"NONE YET",title:"No telemetry heartbeat has landed.",degraded:!1});else{const r=Math.max(0,this.clock()-this.beatAt);e.push({label:"BEAT",value:`${(r/1e3).toFixed(1)} S AGO`,title:"The age of the last telemetry heartbeat; the daemon beats once a second while a surface is attached.",degraded:r>=$$})}const n=this.cube;if(n===void 0)e.push({label:"CUBE",value:"NO PAGE TIMED",title:"CUBE's pace is known once a page of a list has been fetched.",degraded:!1});else{const r=n.msPerPage>0?Math.round(6e4/n.msPerPage):0;e.push({label:"CUBE",value:`${(n.msPerPage/1e3).toFixed(1)} S/PAGE · ${r} PAGES/MIN`,title:`The median of the last ${n.samples} page fetches (100 rows each).`,degraded:!1})}return e}render(){const e=this.rows_compose();this.mount.replaceChildren();for(const s of e){const i=document.createElement("div");i.className="lane-row telemetry-row",i.classList.toggle("status-degraded",s.degraded),i.title=s.title;const n=document.createElement("span");n.className="telemetry-label",n.textContent=s.label;const r=document.createElement("span");r.className="telemetry-value",r.textContent=s.value,i.append(n,r),this.mount.appendChild(i)}}}const H$=[2,3,3,2,2,11,2,2],V$=4,hv=300,q$=2600,K$=650;class Y${wrapper;cells=[];bootedAt=Date.now();telemetry={jobsLoaded:0,jobsTotal:0,feeds:0,lastLatencyMs:0,latencySumMs:0,lastExitCode:0,commandsRun:0,opsActive:0,opsDone:0,opsFailed:0,itemsCurrent:0,itemsTotal:0,connected:0};activeOperations=new Set;telemetryRows=[];constructor(e){if(this.wrapper=e,e===null){window.setInterval(()=>this.beat_paint(),hv);return}const s=this.narrowSources_list(),i=this.wideSources_list();let n=0,r=0;for(const o of H$){const a=document.createElement("div");a.className="data-column";for(let l=1;l<=V$;l++){const c=document.createElement("div");c.className=`dc-row-${l}`;let h;o>=6?(h=i[r%i.length],r++):(h=s[n%s.length],n++);const d={element:c,width:o,source:h??(()=>0)};c.textContent=dv(d.source(),o),a.appendChild(c),this.cells.push(d)}e.appendChild(a)}window.setInterval(()=>this.beat_paint(),hv),this.sweep_start()}promptContext_observe(e){const s=e.procWarmup;s!==void 0&&(this.telemetry.jobsLoaded=s.loaded,this.telemetry.jobsTotal=s.total??s.loaded);const i=e.procIndex;i!==void 0&&(s===void 0&&(this.telemetry.jobsLoaded=i.jobs,this.telemetry.jobsTotal=i.jobs),this.telemetry.feeds=i.feeds),e.lastCommandDurationMs>0&&(this.telemetry.lastLatencyMs=e.lastCommandDurationMs,this.telemetry.latencySumMs+=e.lastCommandDurationMs,this.telemetry.commandsRun++),this.telemetry.lastExitCode=e.lastExitCode}progress_observe(e){const s=`${e.operation}:${e.itemId??""}`;if(e.phase==="complete"||e.phase==="failed"){const i=`${e.operation}:`;for(const n of[...this.activeOperations])(n===s||n.startsWith(i))&&this.activeOperations.delete(n);e.status==="error"||e.phase==="failed"?this.telemetry.opsFailed++:this.telemetry.opsDone++}else e.itemId!==void 0&&e.status!==void 0&&["done","error","unconfirmed","stalled","timeout"].includes(e.status)?this.activeOperations.delete(s):this.activeOperations.add(s);this.telemetry.opsActive=this.activeOperations.size,e.current!==void 0&&(this.telemetry.itemsCurrent=e.current),e.total!==void 0&&(this.telemetry.itemsTotal=e.total)}index_observe(e){this.telemetry.jobsLoaded=e.jobs,this.telemetry.jobsTotal=e.jobs,this.telemetry.feeds=e.feeds}connection_show(e){this.telemetry.connected=e?1:0,this.wrapper?.classList.toggle("dc-stale",!e)}telemetryPanel_bind(e){const s=this.telemetry,i=[["LINK",()=>s.connected===1?"ONLINE":"OFFLINE"],["JOBS INDEXED",()=>`${s.jobsLoaded} / ${s.jobsTotal}`],["FEEDS VISIBLE",()=>String(s.feeds)],["OPS ACTIVE",()=>String(s.opsActive)],["OPS DONE",()=>String(s.opsDone)],["OPS FAILED",()=>String(s.opsFailed)],["ITEMS",()=>`${s.itemsCurrent} / ${s.itemsTotal}`],["LAST COMMAND",()=>`${s.lastLatencyMs} MS`],["LATENCY SUM",()=>`${s.latencySumMs} MS`],["COMMANDS RUN",()=>String(s.commandsRun)],["LAST EXIT",()=>String(s.lastExitCode)],["UPTIME",()=>`${this.uptimeSeconds_get()} S`]];for(const[n,r]of i){const o=document.createElement("div");o.className="telemetry-row";const a=document.createElement("span");a.className="telemetry-label",a.textContent=n;const l=document.createElement("span");l.className="telemetry-value",l.textContent=r(),o.append(a,l),e.appendChild(o),this.telemetryRows.push({element:l,source:r})}}narrowSources_list(){const e=this.telemetry;return[()=>e.jobsLoaded,()=>e.feeds,()=>e.lastLatencyMs,()=>e.opsActive,()=>e.opsDone,()=>e.jobsTotal,()=>e.itemsCurrent,()=>e.itemsTotal,()=>e.opsFailed,()=>e.commandsRun,()=>e.lastExitCode,()=>new Date().getSeconds(),()=>this.uptimeSeconds_get()]}wideSources_list(){return[()=>Math.floor(Date.now()/1e3),()=>this.uptimeSeconds_get(),()=>this.telemetry.latencySumMs,()=>X$()]}uptimeSeconds_get(){return Math.floor((Date.now()-this.bootedAt)/1e3)}beat_paint(){for(const e of this.cells){const s=dv(e.source(),e.width);e.element.textContent!==s&&(e.element.textContent=s)}for(const e of this.telemetryRows){const s=e.source();e.element.textContent!==s&&(e.element.textContent=s)}}sweep_start(){if(this.wrapper===null)return;const e=Array.from(this.wrapper.querySelectorAll(".data-column"));window.setInterval(()=>{const s=e[Math.floor(Math.random()*e.length)];s!==void 0&&(s.classList.add("dc-sweep"),window.setTimeout(()=>s.classList.remove("dc-sweep"),K$))},q$)}}function dv(t,e){const s=String(Math.max(0,Math.floor(t)));return s.length>e?s.slice(s.length-e):s.padStart(e,"0")}function X$(){const t=new Date;return t.getHours()*1e4+t.getMinutes()*100+t.getSeconds()}const Z$=2e4;class J${scene;nameplate;command_run;names=[];cursor=0;timer=null;seen=new Map;constructor(e,s,i){this.nameplate=s,this.command_run=i,this.scene=new Gd(e,{},{ambient:!0}),new MutationObserver(()=>this.scene.palette_refresh()).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),new MutationObserver(()=>{window.setTimeout(()=>this.scene.size_fit(),60)}).observe(document.body,{attributes:!0,attributeFilter:["data-header"]}),window.addEventListener("resize",()=>this.scene.size_fit())}names_set(e){this.names=e,this.cursor=0,this.timer!==null&&(window.clearInterval(this.timer),this.timer=null),e.length!==0&&(this.next_request(),e.length>1&&(this.timer=window.setInterval(()=>this.next_request(),Z$)))}envelope_observe(e){if(e.model?.kind!==br.pipelineDiagram)return;const s=_g.safeParse(e.model.data);if(!s.success)return;const i=s.data;this.seen.set(i.name,i),this.model_stage(i)}model_stage(e){this.nameplate.textContent=e.name,this.scene.graph_set({nodes:e.nodes.map(s=>({id:s.id,label:s.label,parentIds:s.parentIds,joinParentIds:s.joinParentIds}))}),this.scene.size_fit()}next_request(){const e=this.names[this.cursor%this.names.length];if(this.cursor++,e===void 0)return;const s=this.seen.get(e);if(s!==void 0){this.model_stage(s);return}this.command_run(`pipeline diagram ${e}`)}}function Q$(t,e){t.line_execute("ls /bin",{silent:!0,observe:!1}).then(s=>{const r=(s.envelopes.find(o=>o.model?.kind==="fs.listing")?.model?.data??[]).flatMap(o=>o.items).filter(o=>o.type==="pipeline").map(o=>o.name);e.names_set(r)})}const uv=new Set(["layout","slice","series","wl","colormap","save","tags","load","guard","ghost","state"]);function ej(t,e,s,i,n){if(s==="layout")return qr(t,e,".dag-strategy",i.toUpperCase())?`layout ${i}`:"dag layout ranked|molecule";if(s==="projection")return qr(t,e,".dag-projection",i.toUpperCase())?`projection ${i}`:"dag projection 2d|3d";if(s==="scale")return qr(t,e,".dag-scale",i.toUpperCase())?`scale ${i}`:"dag scale time|size";if(s==="hue")return qr(t,e,".dag-hue",i.toUpperCase())?`hue ${i}`:"dag hue status|compute";const r=(o,a,l,c)=>{const h=i.toLowerCase();return h==="on"||h==="off"?qr(t,e,o,h==="on"?l:c)?`${a} ${h}`:`dag ${a}: no mode frame`:h!==""?`dag ${a} on|off`:Rn(t,e,o)?`${a} toggled`:`dag ${a}: no mode frame`};if(s==="pulse")return r(".dag-pulse","pulse","PULSE ON","PULSE OFF");if(s==="census")return r(".dag-census","census","CENSUS","SHAPE");if(s==="gravity")return r(".dag-gravity","gravity","GRAVITY ON","GRAVITY OFF");if(s==="draw")return qr(t,e,".dag-draw",i.toUpperCase())?`draw ${i}`:"dag draw spheres|stars";if(s==="select")return i===""?"dag select <feed or job>":t.dag_jump(e,i)?`selecting ${i}`:"dag select: no RUNS pane (view runs)";if(s==="enter")return i===""?"dag enter <job>":t.dag_jump(e,i,!0)?`entering ${i}`:"dag enter: no RUNS pane (view runs)";if(s==="refresh")return fh(t,e,"REFRESH")?"refreshing":"dag refresh: no DAG pane";if(s==="physics"){const o=i,a=t.paneMount_get(e),l=a?.querySelector(".pane-dag")??a;if(l===null)return"dag physics: no DAG pane";if(o==="reset")return l.dispatchEvent(new CustomEvent("argus:dag-physics",{detail:"reset"})),"physics reset";const c=(n[2]??"on").toLowerCase()!=="off";return["charge","link","collide","gravity"].includes(o)?(l.dispatchEvent(new CustomEvent("argus:dag-physics",{detail:{term:o,on:c}})),`physics ${o} ${c?"on":"off"}`):`dag physics: unknown term '${o}' (charge|link|collide|gravity|reset)`}return`dag: unknown verb '${s}' (layout|projection|scale|hue|draw|pulse|census|gravity|select|enter|physics|refresh)`}function tj(t,e,s){return s==="enter"?fh(t,e,"ENTER NODE")?"entering node":"node enter: no DAG drawer":s==="back"?fh(t,e,"BACK")?"node back":"node back: no DAG drawer":s==="immerse"?t.node_immerse(e)?"immersing":"node immerse: nothing indicated":s==="clear"?fh(t,e,"CLEAR DETAIL")?"detail cleared":"node clear: no DAG drawer":`node: unknown verb '${s}' (enter|immerse|back|clear)`}function sj(t){return{subjects:{runs:null,node:null,dag:null,universe:null,pacs:new Set(["sort","filter"]),tags:new Set(["redact","filter"]),image:uv},views:{runs:{button:"gutter-runs",primary:"dag"},pacs:{button:"gutter-tools",primary:"pacs"}},claims:{runs:".empty-go-dag",pacs:".empty-go-pacs"},listings:{runs:{selector:".pane-dag",named:"DAG"},pacs:{selector:"#pacs-workspace",named:"PACS"}},chords:[{after:"1",key:"2",topic:"claim",selector:".empty-go-dag",does:"claim an empty pane as RUNS"},{after:"1",key:"3",topic:"claim",selector:".empty-go-pacs",does:"claim an empty pane as PACS"}],lines:[{after:"view",line:"runs enter <feedId> · sort <col> [asc|desc] · filter <text>|off"},{after:"view",line:"node enter · immerse · back · clear (the indicated node)"},{after:"view",line:"dag [@id] layout ranked|molecule · projection 2d|3d · scale time|size · hue status|compute · draw spheres|stars · pulse [on|off] · census [on|off] · gravity [on|off] · select <feed or job> · enter <job> · physics charge|link|collide|gravity on|off · physics reset · refresh"},{after:"file",line:"pacs sort <col> [asc|desc] · filter <text>|off (the results listing; every other pacs verb is the session's)"},{after:"file",line:"image [@id] [--force] <path> · layout single|mpr|3d|slab · slice <n> · series <n> · wl <lo> <hi> · wl preset <name> · colormap gray|hot|jet|cool · save · tags · load · guard <bytes>|off · ghost <0..1>|off · state"},{after:"file",line:"tags [@id] redact on|off · filter <text>|off (the pane that follows an image pane's slice)"}],run:(e,s,i)=>{const n=t(),{subject:r,words:o}=s,a=(o[0]??"").toLowerCase(),l=(o[1]??"").toLowerCase();if(r==="runs"){if(a==="enter"){const h=parseInt(l.replace(/^feed_/,""),10);return Number.isNaN(h)?"runs enter <feedId>":(n.feed_enter(h),`entering feed_${h}`)}return`runs: unknown verb '${a}' (enter)`}if(!["dag","image","tags","universe","node"].includes(r))return;const c=i();if(c===null)return`${r}: no target pane (nothing focused?)`;if(r==="dag")return ej(n,c,a,l,o);if(r==="image"){const h=o.filter(d=>d!=="--force");return uv.has((h[0]??"").toLowerCase())?n.image_control(c,a,o.slice(1)):null}return r==="tags"?n.tags_control(c,a,o.slice(1)):r==="universe"?n.universe_control(c,a,o.slice(1)):tj(n,c,a)}}}function Wl(t,e){if("pane"in t)return t.pane===e?[]:null;const s=Wl(t.first,e);if(s!==null)return[{node:t,side:"first"},...s];const i=Wl(t.second,e);return i!==null?[{node:t,side:"second"},...i]:null}function Fl(t,e,s){if(t===e)return s;if("pane"in t)return null;const i=Fl(t.first,e,s);if(i!==null)return{...t,first:i};const n=Fl(t.second,e,s);return n!==null?{...t,second:n}:null}function fv(t,e,s){const i=Wl(t,e);if(i===null||i.length===0)return"lone";const n=ki[s].axis,r=ki[s].place==="after"?"first":"second",o=i[i.length-1];let a=null;for(let d=i.length-1;d>=0;d-=1){const u=i[d];if(u.node.dir===n&&u.side===r){a=u.side==="first"?u.node.second:u.node.first;break}}if(a===null){if(o.node.dir===n)return"edge";a=o.side==="first"?o.node.second:o.node.first}const l=od(t,e);if(l===null)return"lone";const c={pane:e};return Fl(l,a,r==="first"?{dir:n,ratio:.5,first:a,second:c}:{dir:n,ratio:.5,first:c,second:a})??"edge"}const pv="argus-layout";class ij{root;mounts;presets=new Map;prefs={};activePreset="";tree=null;focusedPane=null;renderObserver=null;previousFocus=null;constructor(e,s){this.root=e,this.mounts=s;try{const i=window.localStorage.getItem(pv);this.prefs=i!==null?JSON.parse(i):{}}catch{this.prefs={}}}renderObserver_set(e){this.renderObserver=e}preset_register(e,s){this.presets.set(e,s)}mount_register(e,s){this.mounts.set(e,s)}mount_remove(e){this.mounts.delete(e),this.focusedPane===e&&(this.focusedPane=null)}leaf_split(e,s,i,n=!1){if(this.tree===null)return!1;const r=rd(this.tree,e,{dir:s,ratio:.5,first:n?{pane:i}:{pane:e},second:n?{pane:e}:{pane:i}});return r===null?!1:(this.tree=r,this.focus_move(i),this.render(),!0)}leaf_move(e,s){if(this.tree===null)return"lone";const i=fv(this.tree,e,s);return typeof i=="string"?i:(this.tree=i,this.focus_move(e),this.render(),!0)}focus_move(e){this.focusedPane!==null&&this.focusedPane!==e&&(this.previousFocus=this.focusedPane),this.focusedPane=e}focus_last(){const e=this.previousFocus;return e===null||!this.panes_shown().includes(e)?null:(this.focus_set(e),e)}leaf_flip(e){if(this.tree===null)return!1;const s=Wl(this.tree,e);if(s===null||s.length===0)return!1;const i=s[s.length-1],n={...i.node,dir:i.node.dir==="col"?"row":"col"},r=Fl(this.tree,i.node,n);return r===null?!1:(this.tree=r,this.render(),!0)}leaf_resize(e,s,i=.05){if(this.tree===null)return!1;const n=Wl(this.tree,e);if(n===null||n.length===0)return!1;const r=ki[s].axis;for(let o=n.length-1;o>=0;o-=1){const a=n[o];if(a.node.dir!==r)continue;const l=ki[s].place==="after",c=Math.min(.85,Math.max(.15,a.node.ratio+(l?i:-i))),h={...a.node,ratio:c},d=Fl(this.tree,a.node,h);return d===null?!1:(this.tree=d,this.ratio_remember(n.slice(0,o).map(u=>u.side==="first"?"0":"1").join(""),c),this.render(),!0)}return!1}move_possible(e,s){return this.tree!==null&&typeof fv(this.tree,e,s)!="string"}leaf_replace(e,s){if(this.tree===null)return!1;const i=rd(this.tree,e,{pane:s});return i===null?!1:(this.tree=i,this.focusedPane===e&&(this.focusedPane=s),this.render(),!0)}leaf_close(e){if(this.tree===null||"pane"in this.tree)return!1;const s=od(this.tree,e);return s===null?!1:(this.tree=s,this.focusedPane===e&&(this.focusedPane=null),this.render(),!0)}focused_get(){return this.focusedPane}savedPreset_get(){return this.prefs.preset!==void 0&&this.presets.has(this.prefs.preset)?this.prefs.preset:null}activePreset_get(){return this.activePreset}preset_has(e){return this.presets.has(e)}preset_apply(e){const s=this.presets.get(e);s!==void 0&&(this.activePreset=e,this.prefs.preset=e,this.prefs_save(),this.tree=this.ratios_restore(s(),e,""),this.render(),this.root.classList.remove("layout-arrive"),this.root.offsetWidth,this.root.classList.add("layout-arrive"))}tree_get(){return this.tree===null?null:JSON.parse(JSON.stringify(this.tree))}tree_set(e){this.tree=this.ratios_restore(e,this.activePreset,""),this.render()}panes_shown(){const e=[],s=i=>{if(i!==null){if("pane"in i){e.push(i.pane);return}s(i.first),s(i.second)}};return s(this.tree),e}render(){if(this.tree!==null){for(const e of this.mounts.values())e.remove();this.root.replaceChildren(this.node_render(this.tree,"")),this.focus_reconcile(),this.renderObserver?.()}}focus_reconcile(){const e=this.panes_shown();if(this.focusedPane!==null&&e.includes(this.focusedPane))return;const s=e[0];if(s===void 0)return;const i=this.focusedPane;this.focusedPane=null,this.focus_set(s),i!==null&&(this.previousFocus=i)}node_render(e,s){if("pane"in e){const a=document.createElement("div");a.className="layout-leaf",a.dataset.leaf=e.pane;const l=this.mounts.get(e.pane);return l!==void 0&&(a.appendChild(l),l.style.display="",a.addEventListener("mousedown",()=>this.focus_set(e.pane),{capture:!0}),e.pane===this.focusedPane&&a.classList.add("pane-focused")),a}const i=document.createElement("div");i.className=`layout-split layout-${e.dir}`;const n=this.node_render(e.first,`${s}0`),r=this.node_render(e.second,`${s}1`);n.style.flex=`${e.ratio} 1 0`,r.style.flex=`${1-e.ratio} 1 0`;const o=document.createElement("div");return o.className="layout-divider",this.divider_wire(o,i,e,n,r,s),i.append(n,o,r),i}divider_wire(e,s,i,n,r,o){let a=!1;e.addEventListener("mousedown",l=>{a=!0,l.preventDefault()}),window.addEventListener("mousemove",l=>{if(!a)return;const c=s.getBoundingClientRect(),h=i.dir==="col"?(l.clientX-c.left)/c.width:(l.clientY-c.top)/c.height;i.ratio=Math.min(.85,Math.max(.15,h)),n.style.flex=`${i.ratio} 1 0`,r.style.flex=`${1-i.ratio} 1 0`}),window.addEventListener("mouseup",()=>{a&&(a=!1,this.ratio_remember(o,i.ratio),this.renderObserver?.())})}focus_set(e){if(this.focusedPane===e)return;this.focusedPane!==null&&(this.previousFocus=this.focusedPane),this.focusedPane=e,document.body.dataset.focus=e;for(const i of this.root.querySelectorAll(".layout-leaf"))i.classList.remove("pane-focused");this.mounts.get(e)?.parentElement?.classList.add("pane-focused")}ratios_restore(e,s,i){if("pane"in e)return e;const n=this.prefs.ratios?.[`${s}:${i}`];return{...e,ratio:n??e.ratio,first:this.ratios_restore(e.first,s,`${i}0`),second:this.ratios_restore(e.second,s,`${i}1`)}}ratio_remember(e,s){this.prefs.ratios={...this.prefs.ratios??{},[`${this.activePreset}:${e}`]:s},this.prefs_save()}prefs_save(){try{window.localStorage.setItem(pv,JSON.stringify(this.prefs))}catch{}}}function rd(t,e,s){if("pane"in t)return t.pane===e?s:null;const i=rd(t.first,e,s);if(i!==null)return{...t,first:i};const n=rd(t.second,e,s);return n!==null?{...t,second:n}:null}function od(t,e){if("pane"in t)return null;if("pane"in t.first&&t.first.pane===e)return t.second;if("pane"in t.second&&t.second.pane===e)return t.first;const s=od(t.first,e);if(s!==null)return{...t,first:s};const i=od(t.second,e);return i!==null?{...t,second:i}:null}const nj=4e3;function rj(t){const e=new WeakMap,s=(a,l)=>{const c=t.paneInstance_get(a)?.mount.querySelector(".pane-state")??null;if(c===null)return;const h=e.get(c);h!==void 0&&clearTimeout(h);const d={text:c.textContent??"",className:c.className};ys(c,"note",l),e.set(c,setTimeout(()=>{e.delete(c),c.textContent===l&&(c.className=d.className,c.textContent=d.text)},nj))};return{bar_note:s,move:(a,l)=>{const c=t.layout.leaf_move(a,l);return c==="lone"?"pane move: the only pane on stage":c==="edge"?`pane move ${l}: already ${ki[l].edge}`:(s(a,`MOVED ${l.toUpperCase()}`),t.sound("audio3"),`moved ${l}`)},flip:a=>t.layout.leaf_flip(a)?(s(a,"FLIPPED"),t.sound("audio3"),"flipped"):"pane flip: the only pane on stage",resize:(a,l,c)=>t.layout.leaf_resize(a,l,c)?`resized ${ki[l].focusWord}`:`pane resize ${ki[l].focusWord}: no boundary that way`,chordKeys_format:(a,l)=>{const c=pn.filter(h=>h.selector===a&&h.move===!0===l).map(h=>h.key);return c.length===0?"":` [keys ${c.join(" ")}]`}}}const oj={image:"viewer",view:"viewer",dir:"files",fs:"files",tags:"tags",empty:"pane",domain:"dag",catalogue:"catalogue",graph:"dag",gather:"gather",edit:"editor"},of=240;function aj(t,e){const{layout:s,panels:i,paneInstance_get:n,dormant:r}=t,o=new Map;let a=!1,l=null;const c=y=>n(y)?.kind??null,h=(y,b,v,z,x)=>{o.set(y,{parent:b,dir:v,before:z,...x!==void 0?{binding:x}:{}})},d=y=>{if(y==="pacs")return"⊞";if(y==="dag")return"⋔";const b=c(y);return b==="image"?"▣":b==="tags"?"≣":b==="edit"?"✎":"▤"},u=y=>{if(y.length===0)return;const b=[];for(const I of y){const E=n(I)?.mount;if(E===void 0)continue;const O=E.getBoundingClientRect();O.width>0&&O.height>0&&b.push({id:I,left:O.left,top:O.top,width:O.width,height:O.height})}if(b.length===0)return;const v=Math.min(...b.map(I=>I.left)),z=Math.min(...b.map(I=>I.top)),x=Math.max(...b.map(I=>I.left+I.width))-v,M=Math.max(...b.map(I=>I.top+I.height))-z;if(x<=0||M<=0)return;const S=of/x,T=Math.max(40,Math.min(260,Math.round(M*S)));try{const I=document.createElement("canvas");I.width=of,I.height=T;const E=I.getContext("2d");if(E===null)return;const R=getComputedStyle(document.documentElement).getPropertyValue("--harvestgold").trim()||"#c9a15a";E.fillStyle="#05070a",E.fillRect(0,0,of,T);for(const C of b){const k=Math.round((C.left-v)*S),B=Math.round((C.top-z)*S),L=Math.max(6,Math.round(C.width*S)),F=Math.max(6,Math.round(C.height*S)),ee=n(C.id)?.mount.querySelector("canvas");if(ee!=null&&ee.width>0){const X=Math.min(L/ee.width,F/ee.height),he=Math.round(ee.width*X),Oe=Math.round(ee.height*X);E.fillStyle="#000",E.fillRect(k,B,L,F),E.drawImage(ee,k+Math.round((L-he)/2),B+Math.round((F-Oe)/2),he,Oe)}else E.fillStyle="rgba(255,255,255,0.05)",E.fillRect(k,B,L,F),E.fillStyle=R,E.font=`${Math.max(9,Math.min(28,Math.round(Math.min(L,F)*.5)))}px serif`,E.textAlign="center",E.textBaseline="middle",E.fillText(d(C.id),k+L/2,B+F/2+1);E.strokeStyle="rgba(255,255,255,0.22)",E.lineWidth=1,E.strokeRect(k+.5,B+.5,L-1,F-1)}return I.toDataURL("image/png")}catch{return}},p=(y,b,v)=>{const z=c(y),x=o.get(y),M={dir:x?.dir??"col",side:aB(x?.before??!1)};if(rv(y)){const T=b==="dag"?"runs":b,I=b==="pacs"?e.pacsQuery_get():null,E=b==="dag"?i.get("dag","dag"):void 0,O=E!==void 0&&E.graph_isShown()?E.feed_get():null,R=O!==null&&E!==void 0?E.view_lines():[],C=O!==null?E?.feedTitle_get():void 0;return{action:{op:"domain",domain:T,...I!==null?{query:I}:{},...O!==null?{feed:O}:{},...R.length>0?{view:R}:{}},...C!==void 0?{label:C}:{}}}if(x?.binding==="fs"||x?.binding==="view"||x?.binding==="empty")return{action:{op:x.binding,target:v,...M}};if(z==="image"){const T=i.get("image",y),I=T?.state_get()??null;if(T===void 0||I===null||I.path===null)return null;const E=[];I.layout!=="single"&&E.push(`image layout ${I.layout}`),I.colormap!==void 0&&I.colormap!=="gray"&&E.push(`image colormap ${I.colormap}`),I.voi!==void 0&&I.voi!==null&&E.push(`image wl ${I.voi.lower} ${I.voi.upper}`),I.slice>1&&E.push(`image slice ${I.slice}`),I.ghost!==void 0&&I.ghost!==null&&I.layout==="slab"&&E.push(`image ghost ${I.ghost}`);const O=T.series_get(),R=[O?.seriesDescription??"",O?.modality??""].filter(C=>C!=="");return{action:{op:"image",path:I.path,target:v,...M,...E.length>0?{view:E}:{}},anchor:I.path,...R.length>0?{label:R.join(" · ")}:{}}}const S=e.catalogue_find(y);if(S!==void 0){const T=i.get("files",y)?.commandLine_get()??"";return{action:{op:"catalogue",input:S.input,target:v,...M,...S.feed!==null?{feed:S.feed}:{},...S.node!==null?{node:S.node}:{},...T!==""?{line:T}:{}},label:`PROCESS ${S.input.split("/").filter(Boolean).pop()??S.input}`}}if(z==="files"){const T=i.get("files",y)?.path_current()??null;return typeof T!="string"||T.length===0?null:{action:{op:"dir",path:T,target:v,...M}}}if(z==="gather"){const T=i.get("gather",y);if(T===void 0)return null;const I=[...T.entries_get()],E=T.name_get(),O=T.feed_get();return{action:{op:"gather",series:I,target:v,...M,...E!==null?{name:E}:{},...O!==null?{feed:O.feedId,root:{instance:O.rootInstanceId,path:O.path}}:{}},label:E??`GATHER · ${I.length} series`}}if(z==="dag"){const T=i.get("dag",y)?.feed_get()??null;return T===null?null:{action:{op:"graph",feed:T,target:v,...M}}}if(z==="tags")return{action:{op:"tags",target:v,...M}};if(z==="edit"){const T=i.get("edit",y)?.path_get()??null;return T===null?null:{action:{op:"edit",path:T,target:v,...M},label:`EDIT ${T.split("/").pop()??T}`}}return null},f=()=>{if(a)return;const y=new Set(s.panes_shown()),b=s.activePreset_get();if(b==="panes"||b==="launcher")return;const v=Sh().map(F=>F.id).filter(F=>y.has(F)),z=new Map;let x,M;const S=[];for(const F of v){const ee=z.get(o.get(F)?.parent??"")??0,X=p(F,b,ee);X!==null&&(z.set(F,S.length),S.push(X.action),X.anchor!==void 0?x===void 0&&(x=X.anchor,X.label!==void 0&&(M=X.label)):X.label!==void 0&&M===void 0&&(M=X.label))}const T=S.filter(F=>F.op!=="domain"||F.feed!==void 0);if(T.length===0)return;const I=u(v),E=F=>{if("pane"in F){const he=z.get(F.pane);return he===void 0?null:{leaf:he}}const ee=E(F.first),X=E(F.second);return ee===null?X:X===null?ee:{dir:F.dir,ratio:F.ratio,first:ee,second:X}},O=s.tree_get(),R=O===null?null:E(O),C=[...new Set(T.map(F=>oj[F.op]??"pane"))];let k,B,L;if(x!==void 0)k=x,B=M??x.split("/").pop()??x,L={address:x,modelKind:"dicom.series"};else{const F=T.map(he=>he.path).find(he=>he!==void 0),ee=T.map(he=>he.path??(he.input!==void 0?`catalogue:${he.input}`:he.series!==void 0?`gather:${he.series.map(Oe=>Oe.seriesUID).join(",")}`:he.feed!==void 0?`feed:${he.feed}`:he.op)).sort().join("|"),X=b==="dag"?"RUNS":b.toUpperCase();k=`${b}:${ee}`,B=M!==void 0&&M!==""?M:F!==void 0?F.split("/").pop()??F:`${X} · ${T.length+1} panes`,L={address:k,modelKind:"argus.desktop"}}r.add({id:k,label:B,regard:L,members:C,actions:S,...R===null?{}:{shape:R},...I===void 0?{}:{thumbnail:I},lastTouched:Date.now()})},_=()=>{const y=new Set(s.panes_shown());for(const b of Sh())y.has(b.id)||rv(b.id)||b.id==="panes"||b.id==="launcher"||b.id==="universe"||(As(b.id),s.mount_remove(b.id));e.stage_relight()},g=y=>{f(),s.preset_apply(y),_()},m=(y,b)=>{const v=S=>Sh().filter(T=>s.panes_shown().includes(T.id)&&c(T.id)===S).map(T=>T.id),z={dir:y.dir??"col",before:y.side==="before"},x=S=>{l=z;try{return S()}finally{l=null}},M=(S,T)=>v(S).find(I=>!T.has(I))??null;if(y.op==="domain"){const S=y.domain==="runs"?"dag":y.domain==="pacs"?"pacs":"files";if(g(S),y.query!==void 0&&t.terminal.line_run(y.query),y.feed!==void 0){const T=y.feed,I=y.view??[],E=i.get("dag","dag");if(E?.feed_enter(T),I.length>0&&E!==void 0){const O=R=>{if(E.graph_isShown()&&E.feed_get()===T){for(const C of I)t.terminal.line_run(C);return}R>0&&window.setTimeout(()=>O(R-1),250)};O(240)}}return S}if(b!==null&&s.focus_set(b),y.op==="image"&&y.path!==void 0){let S=null;const T=y.path,I=x(()=>e.image_open(null,T,{},R=>{S=R})),E=y.view,O=S;return E!==void 0&&E.length>0&&O!==null&&I.then(()=>{for(const R of E)s.focus_set(O),t.terminal.line_run(R)}).catch(()=>{}),S}if(y.op==="dir"&&y.path!==void 0){const S=new Set(v("files")),T=y.path;return x(()=>e.dir_open(T)),M("files",S)}if(y.op==="tags"){const S=new Set(v("tags"));return x(()=>t.terminal.line_run("image tags")),M("tags",S)}if(y.op==="catalogue"&&y.input!==void 0){const S=()=>e.catalogueIds().filter(O=>s.panes_shown().includes(O)),T=new Set(S()),I=y.input;x(()=>e.process_open(b??"files",{input:I,feed:y.feed??null,node:y.node??null}));const E=S().find(O=>!T.has(O))??null;return E!==null&&y.line!==void 0&&i.get("files",E)?.commandLine_set(y.line),E}if(y.op==="gather"&&y.series!==void 0){const S=[...y.series],T=x(()=>e.gather_open(S,b??"pacs"));return T!==null&&y.name!==void 0&&i.get("gather",T)?.name_set(y.name),T}if(y.op==="graph"&&y.feed!==void 0){const S=new Set(v("dag")),T=y.feed;return x(()=>e.feed_open(b??"files",T)),M("dag",S)}if(y.op==="edit"&&y.path!==void 0){const S=y.path;return x(()=>e.edit_open(S))}return y.op==="fs"||y.op==="view"||y.op==="empty"?b===null?null:e.pillPane_spawn(b,y.op,z.dir,z.before):null};return{birth_record:h,replayPlace_get:()=>l,replaying:()=>a,strip_capture:u,capture:f,orphans_dispose:_,domain_enter:g,restore:async y=>{const b=r.get(y);if(!(b===void 0||b.actions===void 0)){r.dismiss(y),a=!0;try{const v=[];for(const z of b.actions){const x=v[z.target??0]??null;v.push(m(z,x))}if(b.shape!==void 0){const z=M=>{if("leaf"in M){const I=v[M.leaf]??null;return I===null?null:{pane:I}}const S=z(M.first),T=z(M.second);return S===null?T:T===null?S:{dir:M.dir,ratio:M.ratio,first:S,second:T}},x=z(b.shape);x!==null&&!("pane"in x)&&s.tree_set(x)}}finally{a=!1,e.stage_relight()}}}}}const lj=2200;function cj(t){return/\x1b\[/.test(t)?In(t):ti(t).replace(/(&quot;[^&]*&quot;)/g,'<span class="man-str">$1</span>').replace(/(^|\s)(--?[a-zA-Z][\w-]*)/g,'$1<span class="man-flag">$2</span>').replace(/^(\s{0,2})([A-Za-z_ ]+):(\s)/gm,'$1<span class="man-key">$2:</span>$3').replace(/^([A-Z][A-Z ]{2,})$/gm,'<span class="man-head">$1</span>')}function hj(t,e,s,i){if(t===void 0)return[];const n=t.arguments??[],r=[{label:"NODE",value:`${t.label} · @${t.id}`},{label:"PLUGIN",value:t.pluginName},...t.pluginVersion!==void 0?[{label:"VERSION",value:t.pluginVersion}]:[]];if(e){const o=OB(t.label,t.id,i);r.push(...n.length===0?[{label:"ARGUMENTS",value:"none — this node runs on the plugin's defaults"}]:n.map(a=>({label:a.name,value:String(a.value??""),...s?{edit:{flag:`--${o}.${a.name}`,type:typeof a.value=="boolean"?"boolean":"string",placeholder:String(a.value??"")}}:{}})))}else r.push({label:"ARGUMENTS",value:n.length===0?"none":`${n.length} — open the node to read them`});return r}function dj(t,e,s){const i=[{label:"PLUGIN",value:t.name},{label:"VERSION",value:t.version},{label:"TYPE",value:t.type.toUpperCase()}],n=t.parameters;if(!e)return i.push({label:"PARAMETERS",value:n.length===0?"none":`${n.length} — open the node to read them`}),i;if(n.length===0)return i.push({label:"PARAMETERS",value:"none — this plugin takes no arguments"}),i;for(const r of n){const o=[r.type];r.optional||o.push("required");const a=r.default===void 0||r.default===null?"":String(r.default);a!==""&&o.push(`default ${a}`);const l=o.join(" · ");i.push({label:r.flag,value:r.help===void 0?l:`${l} — ${r.help}`,...s?{edit:{flag:r.flag,type:r.type,placeholder:a}}:{}})}return i}function mv(t,e,s,i){t.replaceChildren(),t.classList.toggle("dag-facts-immersed",s);for(const{label:n,value:r,edit:o}of e){const a=document.createElement("div");a.className="telemetry-row";const l=document.createElement("span");if(l.className="telemetry-label",l.textContent=n,a.appendChild(l),o===void 0||i===null){const c=document.createElement("span");c.className="telemetry-value",c.textContent=r,a.appendChild(c)}else{const c=zB(i.line_get(),o.flag),h=document.createElement("input");h.className="telemetry-input",h.spellcheck=!1,h.autocomplete="off",h.title=`${o.flag} — ${r}`,o.type==="boolean"?(h.type="checkbox",h.checked=c===!0,h.addEventListener("change",()=>{i.line_set(b0(i.line_get(),o.flag,h.checked?!0:null))})):(h.type="text",h.placeholder=o.placeholder,h.value=c===null||c===!0?"":c,h.addEventListener("input",()=>{i.line_set(b0(i.line_get(),o.flag,h.value))}));const d=document.createElement("span");d.className="telemetry-hint",d.textContent=r,a.append(h,d)}t.appendChild(a)}}function uj(t,e,s,i){const n=t.closest(".files-body"),r=n?.querySelector(".diagram-strategy")??null,o=n?.querySelector(".diagram-projection")??null,a=n?.querySelector(".diagram-pulse")??null,l=i===void 0?null:n?.querySelector(".diagram-run")??null,c=()=>i?.(),h=()=>{const f=[];e.strategy_get()!=="ranked"&&f.push("MOLECULE"),e.projection_get()!=="3d"&&f.push("2D"),s.mode_annunciate(f.join(" · "))},d=()=>{e.strategy_set(e.strategy_get()==="ranked"?"molecule":"ranked"),r!==null&&(r.textContent=e.strategy_get().toUpperCase()),h()},u=()=>{e.projection_set(e.projection_get()==="3d"?"2d":"3d"),o!==null&&(o.textContent=e.projection_get().toUpperCase()),h()},p=()=>{e.wave_start(),a?.classList.add("pulse-running"),window.setTimeout(()=>a?.classList.remove("pulse-running"),lj)};return r!==null&&(r.textContent=e.strategy_get().toUpperCase()),o!==null&&(o.textContent=e.projection_get().toUpperCase()),r?.addEventListener("click",d),o?.addEventListener("click",u),a?.addEventListener("click",p),l?.addEventListener("click",c),h(),()=>{r?.removeEventListener("click",d),o?.removeEventListener("click",u),a?.removeEventListener("click",p),l?.removeEventListener("click",c),a?.classList.remove("pulse-running")}}function fj(t,e){let s=null;const i=(c,h,d,u)=>{let p=null,f=null;const _=c.contentHtml_show(h,"",{diagram:!0,release:()=>{s=null,f?.(),f=null,c.mode_annunciate(""),p?.dispose(),p=null}});_!==null&&d().then(g=>{if(!_.isConnected)return;if(g===null||g.nodes.length===0){_.textContent="NOTHING TO DRAW FOR THIS ENTRY",_.classList.add("files-diagram-empty");return}g.text!==""&&c.contentText_set(g.text);const m=document.createElement("div");m.className="dag-facts",Mi(m),_.appendChild(m);const w=new Gd(_,{select:v=>g.facts_show(m,v.id,!1,u),activate:v=>y(v),deselect:()=>m.replaceChildren()},{}),y=v=>{w.flight_into(v.id,()=>{s={scene:w,facts:m},g.facts_show(m,v.id,!0,u)})};p=w,w.graph_set({nodes:g.nodes},{wave:!1}),w.size_fit(),f=uj(_,w,c,u===null?void 0:u.run);const b=g.nodes.length===1?g.nodes[0]:void 0;b!==void 0&&y(b)})},n=async c=>{const h=/_id(\d+)$/.exec(c)?.[1]??c.replace(/^.*\//,""),[d,u]=await Promise.all([t.client.line_execute(`cat "${c}"`,{silent:!0,observe:!1}),t.client.line_execute(`pipeline diagram ${h}`,{silent:!0,observe:!1})]),p=d.envelopes.map(f=>f.rendered).join(`
4351
4351
  `);for(const f of u.envelopes){if(f.model?.kind!==br.pipelineDiagram)continue;const _=_g.safeParse(f.model.data);if(!_.success)continue;const g=new Map(_.data.nodes.map(m=>[m.id,m]));return{text:cj(p),nodes:_.data.nodes.map(m=>({id:m.id,label:m.label,parentIds:m.parentIds,joinParentIds:m.joinParentIds})),facts_show:(m,w,y,b)=>{const v=_.data.nodes.map(z=>z.label);mv(m,hj(g.get(w),y,b!==null,v),y,b)}}}return null},r=async c=>{const h=c.replace(/^.*\//,""),d=await t.client.line_execute(`plugin info "${h}"`,{silent:!0,observe:!1});for(const u of d.envelopes){if(u.model?.kind!==tk)continue;const p=ek.safeParse(u.model.data);if(!p.success)continue;const f=p.data;return{text:"",nodes:[{id:h,label:f.name,parentIds:[],joinParentIds:[]}],facts_show:(_,g,m,w)=>{mv(_,dj(f,m,w!==null),m,w)}}}return null},o=(c,h,d,u)=>{const p=e.catalogue_find(c);if(p===void 0)return null;const f=d.replace(/^.*\//,"");return eS(h.commandLine_get())!==f&&h.commandLine_set(Zz(p.input,f)),{line_get:()=>h.commandLine_get(),line_set:_=>h.commandLine_set(_),run:()=>e.run_press(c,f,u)}};return{entry_show:(c,h,d,u)=>{i(h,d,()=>u==="plugin"?r(d):n(d),o(c,h,d,u))},dive_leave:()=>{const c=s;return c===null?!1:(s=null,c.scene.flight_back(()=>{c.facts.classList.remove("dag-facts-immersed"),c.facts.replaceChildren()}),!0)}}}function pj(t,e){const{panels:s,paneInstance_get:i,subjects:n}=t,r=new Map,o=p=>s.get("dag",p)??s.get("universe",p),a=(p,f)=>{const _=r.get(p);if(_===void 0){f?.();return}r.delete(p),_.element.classList.remove("node-overlay-open");const g=()=>{_.element.remove(),f?.()},m=o(p);m!==void 0?m.flight_back(g):g()},l=(p,f,_,g,m)=>{if(m.kind==="dir"){const w=f.replace(/\/+$/,"");if(m.path!==w&&!m.path.startsWith(`${w}/`)){a(p),t.sound("audio3");return}const y=m.path.startsWith("/proc/jobs/")?(m.path.split("/").pop()??"").match(/_(\d+)$/):null;if(y!==null){const v=parseInt(y[1]??"",10);a(p,()=>{o(p)?.node_flyTo(v)!==!0&&c(p,m.path)});return}const b=_.path_current();b!==null&&g.push(b),e.rootedListing_show(p,_,m.path);return}if(n.regard_write(p,{address:m.path,modelKind:"fs.file"}),!n.groupHasViewer(p)){if(e.imagery_is(m.path)){e.image_open(p,m.path).then(w=>t.terminal.line_note(w));return}if(Od(m.path)){_.contentImage_show(m.path,e.vfsUrl_build(m.path));return}e.fileText_fetch(m.path).then(w=>{if(!w.ok){_.contentRefused_show(m.path,w.text);return}e.tableFile_is(m.path)?_.contentTable_show(m.path,w.text):_.content_show(m.path,w.text)})}},c=(p,f)=>{const g=i(p)?.mount?.querySelector(".dag-canvas, .universe-canvas")??null,m=r.get(p);if(m!==void 0&&!m.element.isConnected&&r.delete(p),g===null||r.has(p)){t.terminal.line_note(`dag: ${f}: ${g===null?"this pane has no scene to fly in":"a node is already open here"} — flew back out`),o(p)?.flight_back(()=>{});return}const w=document.createElement("div");w.className="node-overlay",w.setAttribute("aria-label",`inside ${f}`);const y=e.filesBody_stamp();y.classList.add("node-overlay-body");const b=document.createElement("button");b.type="button",b.className="strategy-pill node-overlay-exit",b.title="leave the node (Esc)",b.textContent="EXIT NODE",y.querySelector(".mode-frame")?.prepend(b),w.append(y);const v=y.querySelector(".files-panel");if(v===null)throw new Error("pane template is missing .files-panel");const z=[],x=new jz(v,M=>l(p,f,x,z,M),e.previewProvider);x.rowVerbs_declare((M,S)=>e.rowVerbs_build(p,M,S),(M,S)=>{n.regard_write(p,{address:S,modelKind:"fs.file"})}),r.set(p,{element:w,panel:x,history:z}),x.ceiling_set(f,"EXIT NODE"),b.addEventListener("click",()=>{a(p),t.sound("audio3")}),g.appendChild(w),window.requestAnimationFrame(()=>w.classList.add("node-overlay-open")),e.rootedListing_show(p,x,f)};return{open:c,close:a,back:p=>{const f=r.get(p),_=f?.history.pop();f!==void 0&&_!==void 0&&e.rootedListing_show(p,f.panel,_)},escape:()=>{const p=[...r.keys()].pop();if(p===void 0)return!1;const f=r.get(p);return f!==void 0&&f.panel.content_isShown()?f.panel.listing_restore():a(p),!0},dispose:p=>{r.get(p)?.element.remove(),r.delete(p)}}}async function a_(t,e,s){if(t.ask_isOpen()){const o=t.ask_note(s.message),a=await id(e,s);return o(s.kind==="secret"&&a!==null?"••••••":a),a}const i=id(e,s).then(o=>({from:"pane",answer:o})),n=t.ask_open({message:s.message,kind:s.kind==="choose"?"text":s.kind,focus:!1,...s.suggest===void 0?{}:{suggest:s.suggest}}).then(o=>({from:"console",answer:o})),r=await Promise.race([i,n]);return r.from==="console"?m1():t.ask_settle(r.answer),r.answer}function mj(t,e){const{panels:s,paneInstance_get:i}=t;let n=null,r=null;const o=()=>{const{layout:u}=t,p=u.tree_get();if(p===null)return null;const f=[],_=m=>{if("pane"in m){f.push(m.pane);return}_(m.first),_(m.second)};_(p);const g=u.focused_get();return g!==null&&f.includes(g)?g:f[0]??null};return{errandHost_find:o,errand_open:async u=>{const{layout:p,terminal:f}=t,_=o();if(_===null)return null;const g=e.instance_spawn("files"),m=e.replayPlace_get();if(!p.leaf_split(_,m?.dir??"col",g.id,m?.before??!1))return As(g.id),p.mount_remove(g.id),null;e.birth_record(g.id,_,m?.dir??"col",m?.before??!1);const w=s.get("files",g.id),y=u.path?.anchor??"~";w!==void 0&&e.rootedListing_show(g.id,w,y);const b=g.mount.querySelector(".files-body");if(b===null)return As(g.id),p.mount_remove(g.id),null;const v=document.createElement("div");v.className="errand-bar",b.insertBefore(v,b.firstChild);const z=document.createElement("span");z.className="errand-caption",z.textContent=u.message.trim();const x=document.createElement("input");x.className="errand-path",x.spellcheck=!1;const M=document.createElement("button");M.className="pacs-capsule errand-commit",M.textContent=u.commit??"USE THIS",v.append(z,x,M);const S=()=>{const E=w?.path_current()??y,O=u.path?.suggest;x.value=u.path?.wantsDirectory===!0||O===void 0?E:`${E.replace(/\/$/,"")}/${O}`};S();let T=!1;x.addEventListener("input",()=>{T=!0});const I=()=>{T||S()};return g.mount.addEventListener("click",I),f.question_set(!0),new Promise(E=>{const O=R=>{g.mount.removeEventListener("click",I),f.question_set(!1),n=null,p.leaf_close(g.id),As(g.id),p.mount_remove(g.id),E(R)};n=()=>O(null),M.addEventListener("click",()=>O(x.value.trim()===""?null:x.value.trim())),x.addEventListener("keydown",R=>{R.key==="Enter"&&O(x.value.trim()===""?null:x.value.trim())})})},errand_abandon:()=>n===null?!1:(n(),!0),verbLine_run:(u,p)=>{r=u,t.terminal.line_run(p)},askingPane_take:()=>{const u=r;return r=null,u},askOnPane_await:async(u,p)=>{const{terminal:f}=t,_=i(u)?.mount;if(_===void 0){const g=e.questionSheet_ask?.(p)??null;return g!==null?g:(e.console_expose(),f.ask_open({message:p.message,kind:p.kind==="choose"?"text":p.kind,...p.suggest===void 0?{}:{suggest:p.suggest}}))}return a_(f,_,p)}}}class gj{members=new Map;title=null;landed=null;watchers=new Set;watch(e){return this.watchers.add(e),()=>{this.watchers.delete(e)}}changed(){for(const e of[...this.watchers])e()}members_get(){return[...this.members.values()]}size(){return this.members.size}has(e){return this.members.has(e)}state_adopt(e,s,i){const n=JSON.stringify({members:e,name:s,feed:i}),r=JSON.stringify({members:[...this.members.values()],name:this.title,feed:this.landed});if(n!==r){this.members.clear();for(const o of e)this.members.set(o.seriesUID,o);this.title=s,this.landed=i,this.changed()}}name_get(){return this.title}feed_get(){return this.landed}}function gv(t){return(t.kind??"series")==="series"?void 0:t.vfsPath}const af="cohort";function _j(t){return/[",\n\r]/.test(t)?`"${t.split('"').join('""')}"`:t}function bj(t){const e=document.createElement("p");return e.className="files-empty",e.textContent=t,e}class _v{handlers;title;cohort;greeted=!1;listing;cohortActions;seriesActions;constructor(e,s,i,n){this.handlers=i,this.cohort=n,n.watch(()=>{this.unsaved=!0,this.render()}),this.title=e.querySelector(".gather-title"),this.cohortActions=this.cohortActions_declare(),this.seriesActions=this.seriesActions_declare(),this.listing=new Ir({mount:s,traits:this.cohortTraits_declare(),key:r=>r.key,chrome:{root:e,prefix:"gather"},control:"fold",actions:{of:()=>this.cohortActions},row:{className:()=>"gather-cohort-row",groupClassName:()=>"gather-cohort",decorate:r=>{r.title="the cohort: click for its verbs, the fold cell folds its series"}},child:sa(()=>[...this.cohort.members_get()].map(r=>({entry:r})),{traits:this.seriesTraits_declare(),key:r=>r.entry.seriesUID,address:r=>r.entry.vfsPath,actions:{of:()=>this.seriesActions},row:{className:()=>"gather-series",decorate:(r,o)=>{r.dataset.seriesuid=o.entry.seriesUID}}}),state:r=>this.stateLine_compose(r),empty:()=>bj("NOTHING GATHERED")}),this.pullBlock=e.querySelector(".gather-pull"),this.pullBlock?.addEventListener("click",()=>this.cohort_pull()),this.emptyBlock=e.querySelector(".gather-remove"),this.emptyBlock?.addEventListener("click",()=>{this.cohort_clear()}),this.processBlock=e.querySelector(".gather-process"),this.processBlock?.addEventListener("click",()=>{this.cohort_process()}),this.render()}pullBlock=null;emptyBlock=null;unsaved=!1;processBlock=null;async cohort_clear(){if(this.cohort.size()!==0){if(this.unsaved){const e=await this.handlers.confirm_ask(`Save the cohort first? (${this.cohort.size()} ${this.cohort.size()===1?"member":"members"}, unsaved)`);if(e===null||e==="y"&&!await this.manifest_save())return}await this.handlers.verb_send("gather clear")}}away(){return[...this.cohort.members_get()].filter(e=>e.folderPath===void 0&&e.series?.pulled!==!0)}cohort_pull(){const e=this.away();if(e.length===0)return;const s=e.map(i=>`"${i.vfsPath}"`).join(" ");this.handlers.command_show(`pull ${s}`)}render_now(){this.render()}has(e){return this.cohort.has(e)}entries_get(){return[...this.cohort.members_get()]}name_get(){return this.cohort.name_get()}feed_get(){return this.cohort.feed_get()}async name_set(e){e===null||e===this.cohort.name_get()||await this.handlers.verb_send(`gather name ${Ji(e)}`)}member_remove(e){this.handlers.verb_send(`gather remove ${Ji(e.vfsPath)}`)}render(){if(this.title!==null&&(this.title.textContent=this.cohort.name_get()===null?"GATHER":`GATHER · ${this.cohort.name_get()??""}`.toUpperCase()),this.listing.rows_set([{key:"gather",rows:[{key:af}]}],{field:"gather"}),this.cohort.size()>0&&this.listing.open_set(0,[af]),this.pullBlock!==null){const e=this.away().length;this.pullBlock.hidden=e===0,this.pullBlock.textContent=`PULL ${e}`}this.emptyBlock!==null&&(this.emptyBlock.hidden=this.cohort.size()===0,this.emptyBlock.textContent=`CLEAR ${this.cohort.size()}`),this.processBlock!==null&&(this.processBlock.hidden=this.cohort.size()===0),this.greeted||(this.greeted=!0,this.listing.row_indicate(af))}cohortTraits_declare(){return[{key:"fold",label:"",className:"pacs-fold",capped:!1,width:"5.2em",cell:()=>{const e=document.createElement("span");return e.className="pacs-fold",e}},{key:"name",label:"COHORT",className:"gather-cohort-name",width:"1fr",cell:()=>this.cohort.name_get()??"(unnamed — SAVE names it)"},{key:"series",label:"SERIES",className:"gather-cohort-count",width:"6em",cell:()=>String(this.series_count()),compare:()=>this.series_count()},{key:"patients",label:"PATIENTS",className:"gather-cohort-patients",width:"7em",cell:()=>String(this.patients_count()),compare:()=>this.patients_count()},{key:"feed",label:"FEED",className:"gather-cohort-feed",width:"7em",cell:()=>{if(this.cohort.feed_get()===null)return"—";const e=document.createElement("button");e.className="gather-feed listing-capsule listing-action-selected",e.textContent=`FEED ${this.cohort.feed_get()?.feedId??0}`,e.title="open the feed's graph beside the cohort";const s=this.cohort.feed_get()?.feedId??0;return e.addEventListener("click",i=>{i.stopPropagation(),this.handlers.feed_open(s)}),e},compare:()=>this.cohort.feed_get()?.feedId??-1}]}seriesTraits_declare(){const e=cS(n=>n.entry.series??{seriesUID:n.entry.seriesUID,description:n.entry.description??n.entry.vfsPath??"",modality:n.entry.modality,...n.entry.files===void 0?{}:{fileCount:n.entry.files},...n.entry.folderPath===void 0?{}:{pulled:!0,folderPath:n.entry.folderPath}},NB),s={key:"patient",label:"MRN",className:"gather-series-patient",width:"8em",cell:n=>n.entry.patient||"—"},i={key:"study",label:"STUDY",className:"gather-series-study",width:"14em",cell:n=>n.entry.study??"—"};return[...e.slice(0,1),i,s,...e.slice(1)]}cohortActions_declare(){const e=()=>({count:this.cohort.size(),feed:this.cohort.feed_get()?.feedId??null}),s={save:()=>{this.manifest_save()},export:()=>{this.cohort_export()},feed:()=>{this.feed_ensure()},process:()=>{this.cohort_process()},dismiss:()=>this.handlers.dismiss()};return rS.rules.map(i=>({label:i.label(e()),offered:()=>i.offered(e()),run:()=>s[i.name]?.()}))}seriesActions_declare(){const e=i=>({folderKnown:(i.entry.kind??"series")!=="series"||i.entry.folderPath!==void 0,imagery:(i.entry.kind??"series")==="series"||i.entry.imagery===!0,pullable:(i.entry.kind??"series")==="series"&&i.entry.folderPath===void 0&&i.entry.series?.pulled!==!0&&i.entry.vfsPath!==""}),s={remove:i=>this.member_remove(i.entry),pull:i=>this.handlers.command_show(`pull "${i.entry.vfsPath}"`),image:i=>{const n=i.entry.folderPath??gv(i.entry);n!==void 0&&this.handlers.image_open(n)},process:i=>{const n=i.entry.folderPath??gv(i.entry);if(n!==void 0){this.handlers.process_open(n);return}this.handlers.note(`gather: ${i.entry.description||i.entry.seriesUID} is not in CUBE yet — PULL it first, then PROCESS it.`)}};return nS.rules.map(i=>({label:i.label({folderKnown:!0,pullable:!0}),offered:n=>i.offered(e(n)),run:n=>s[i.name]?.(n)}))}patients_count(){return new Set(this.cohort.members_get().filter(e=>(e.kind??"series")==="series").map(e=>e.patient)).size}series_count(){return this.cohort.members_get().filter(e=>(e.kind??"series")==="series").length}stateLine_compose(e){const s=this.cohort.members_get(),i=s.filter(a=>(a.kind??"series")!=="series").length,n=s.length-i,r=[];(n>0||i===0)&&r.push(`${n} SERIES`),i>0&&r.push(`${i} ${i===1?"PLACE":"PLACES"}`),i===0&&r.push(`${this.patients_count()} PATIENTS`);const o=[r.join(" · ")];return e.filter!==""&&o.push(e.filter),o.join(" · ")}async name_ensure(){if(this.cohort.name_get()!==null)return this.cohort.name_get();const s=(await this.handlers.name_ask(`gather-${new Date().toISOString().slice(0,10)}`)??"").trim();return s===""?null:(await this.handlers.verb_send(`gather name ${Ji(s)}`),s)}async manifest_save(){if(this.cohort.size()===0)return!1;const e=await this.name_ensure();if(e===null)return!1;const s=JSON.stringify({name:e,gatheredAt:new Date().toISOString(),series:[...this.cohort.members_get()].map(i=>({seriesUID:i.seriesUID,description:i.description,modality:i.modality,patient:i.patient,vfsPath:i.vfsPath}))});return this.handlers.command_run("mkdir -p ~/gather"),this.handlers.command_show(`touch --withContents '${s}' ~/gather/${e}.json`),this.unsaved=!1,!0}async cohort_export(){if(this.cohort.size()===0)return;const e=await this.name_ensure();if(e===null)return;const s=[["patient","series","modality","seriesUID","path"].join(","),...[...this.cohort.members_get()].map(i=>[i.patient,i.description,i.modality,i.seriesUID,i.vfsPath].map(_j).join(","))];this.handlers.command_run("mkdir -p ~/gather"),this.handlers.command_show(`touch --withContents '${s.join(`
4352
4352
  `)}' ~/gather/${e}.csv`)}async feed_ensure(){const e=this.cohort.feed_get();return e!==null?e:this.cohort.size()===0||await this.name_ensure()===null?null:(await this.handlers.verb_send("gather feed",!0),this.cohort.feed_get())}async cohort_process(){const e=await this.feed_ensure();e!==null&&this.handlers.cohort_process({input:e.path,feed:e.feedId,node:e.rootInstanceId})}}const bv="gather.cohort";function Mj(t){return{kind:t.kind??"series",seriesUID:t.seriesUID??t.vfsPath,description:t.description??t.vfsPath.split("/").filter(Boolean).pop()??t.vfsPath,modality:t.modality??"—",patient:t.patient??"",vfsPath:t.vfsPath,...t.study===void 0?{}:{study:t.study},...t.imagery===void 0?{}:{imagery:t.imagery},...t.folderPath===void 0?{}:{folderPath:t.folderPath},...t.files===void 0?{}:{files:t.files}}}function vj(t,e){const{panels:s,subjects:i}=t,n=new gj;let r=null,o=!1;const a=b=>{if(b===null||typeof b!="object")return;const v=b,z=Array.isArray(v.series)?v.series.filter(M=>typeof M?.vfsPath=="string").map(Mj):[],x=v.feed;r===null&&z.length>0&&(r=f()),n.state_adopt(z,typeof v.name=="string"?v.name:null,x??null),p(),e.stage_relight()},l=b=>{for(const v of b.envelopes)v.model?.kind===bv&&a(v.model.data)},c=async(b,v=!1)=>{const{terminal:z,client:x}=t;z.line_echo(b);let M;try{M=await x.line_execute(b,{silent:!0,operator:!0})}catch(S){z.output_write("err",`\x1B[31m${S instanceof Error?S.message:String(S)}\x1B[0m
4353
- `);return}(v||M.envelopes.some(S=>S.status==="error"))&&z.outcome_write(M),l(M)},h=[],d=b=>{const v=h.length===0;for(const z of b)z.vfsPath!==""&&!h.includes(z.vfsPath)&&h.push(z.vfsPath);!v||h.length===0||queueMicrotask(()=>{const z=h.splice(0);z.length>0&&c(`gather add ${z.map(Ji).join(" ")}`)})},u=(b,v,z)=>({command_run:x=>{t.client.line_execute(x,{silent:!0})},command_show:x=>t.terminal.line_run(x),note:x=>t.terminal.line_note(x),image_open:x=>{e.image_open(b(),x).then(M=>t.terminal.line_note(M))},process_open:x=>e.process_open(b(),{input:x,feed:null,node:null}),...v,...z,verb_send:c,cohort_process:x=>e.process_open(b(),x),feed_open:x=>e.feed_open(b(),x)}),p=()=>{const b=document.querySelector("#header-gather-pill");b!==null&&b.classList.toggle("panel-gather-empty",(r?.entries_get().length??0)===0)},f=()=>{const b=e.element_require("header-gather"),v=()=>e.errandHost_find()??"pacs",z=x=>a_(t.terminal,e.element_require("header-gather"),x);return new _v(b,e.pane_find(b,".gather-rows"),u(v,{name_ask:x=>z({message:"Cohort name: ",kind:"text",suggest:x,commit:"NAME IT"}),confirm_ask:async x=>{const M=await z({message:x,kind:"confirm"});return M==="y"||M==="n"?M:null}},{dismiss:()=>{document.body.dataset.header="away",o=!0,p()}}),n)};return{cohort:n,instance_build:b=>{const v=e.template_stamp("tpl-pane-gather"),z=new _v(v,e.pane_find(v,".gather-rows"),u(()=>b,{name_ask:x=>e.askOnPane_await(b,{message:"Cohort name: ",kind:"text",suggest:x,commit:"NAME IT"}),confirm_ask:async x=>{const M=await e.askOnPane_await(b,{message:x,kind:"confirm"});return M==="y"||M==="n"?M:null}},{dismiss:()=>{t.layout.leaf_close(b)||e.home_apply(),e.orphans_dispose(),e.stage_relight()}}),n);return s.set("gather",b,z),{id:b,kind:"gather",mount:v,dispose:()=>{s.delete(b),i.pane_leave(b)}}},has:b=>n.has(b),gather:b=>{r===null&&(r=f()),d(b);const v=document.body.dataset.header==="away";(!o||!v)&&(document.body.dataset.header="gather",o=!1),p()},open:(b,v="pacs")=>{const{layout:z}=t,x=new Set(z.panes_shown());let M=s.ids("gather").find(S=>x.has(S))??null;if(M===null){const S=x.has(v)?v:e.errandHost_find()??v,T=e.instance_spawn("gather","pacs"),I=e.replayPlace_get();if(!z.leaf_split(S,I?.dir??"row",T.id,I?.before??!1))return As(T.id),z.mount_remove(T.id),null;e.birth_record(T.id,S,I?.dir??"row",I?.before??!1),M=T.id}return s.get("gather",M)===void 0?null:(d(b),M)},stage:()=>{const{layout:b}=t,v=new Set(b.panes_shown()),z=s.ids("gather").find(x=>v.has(x))??null;if(z!==null)b.focus_set(z);else{const x=e.errandHost_find()??"pacs",M=e.instance_spawn("gather","pacs");if(!b.leaf_split(x,"col",M.id,!1)){As(M.id),b.mount_remove(M.id);return}e.birth_record(M.id,x,"col",!1),s.get("gather",M.id)?.render_now()}document.body.dataset.header="away",o=!0},annunciate:p,restore:async()=>{try{l(await t.client.line_execute("gather",{silent:!0,observe:!1}))}catch{}},envelope_observe:b=>{b.model?.kind===bv&&a(b.model.data)}}}class wj{mount;handlers;titleSpan;stateSpan;fieldSection;savePill;revertPill;focusMark;field=null;path=null;original="";saving=!1;fieldBuild=null;constructor(e,s){this.mount=e,this.handlers=s,this.titleSpan=e.querySelector(".pane-title"),this.stateSpan=e.querySelector(".pane-state"),this.fieldSection=this.element_require(".edit-field"),this.savePill=this.element_require(".edit-save"),this.revertPill=this.element_require(".edit-revert"),this.focusMark=e.querySelector(".edit-focus"),this.savePill.addEventListener("click",()=>{this.save()}),this.revertPill.addEventListener("click",()=>this.revert()),e.addEventListener("keydown",i=>{(i.ctrlKey||i.metaKey)&&!i.altKey&&i.key.toLowerCase()==="s"&&(i.preventDefault(),i.stopPropagation(),this.save())},{capture:!0}),this.fieldSection.addEventListener("mousedown",()=>this.focusMark_set(!0)),this.fieldSection.addEventListener("focusin",()=>this.focusMark_set(!0)),this.fieldSection.addEventListener("focusout",i=>{(!(i.relatedTarget instanceof Node)||!this.fieldSection.contains(i.relatedTarget))&&this.focusMark_set(!1)}),this.controls_sync()}opening_show(e){this.path=e,this.title_set(e),ys(this.stateSpan,"wait","OPENING")}async content_show(e){this.path=e.path,this.original=e.content,this.title_set(e.path),this.fieldBuild??=this.field_build(e);const s=await this.fieldBuild;s!==null&&(s.text_get()!==this.original&&s.text_set(this.original),this.controls_sync(),s.focus(),this.focusMark_set(!0))}async field_build(e){let s;try{s=await lm(()=>import("./field-Dry3W437.js").then(i=>i.Q),[],import.meta.url)}catch(i){if(!r_(i))throw i;return ys(this.stateSpan,"stale",nd),this.handlers.note(`edit: ${nd.toLowerCase()} — the editor's code is of an older build than the server has`),null}return this.field=await s.editField_create(this.fieldSection,e.content,e.extension,()=>this.controls_sync()),this.field}opening_fail(e){ys(this.stateSpan,"refused",`NOT OPENED · ${e.toUpperCase()}`)}async save(){if(this.field===null||this.path===null||this.saving)return!1;const e=this.field.text_get();if(e===this.original)return!0;this.saving=!0,this.controls_sync();let s=!1;try{s=await this.handlers.save(this.path,e)}finally{this.saving=!1}return s&&(this.original=e),this.controls_sync(),s||ys(this.stateSpan,"refused","NOT SAVED · THE CONSOLE SAYS WHY"),s}revert(){this.field===null||!this.dirty_is()||(this.field.text_set(this.original),this.controls_sync())}dirty_is(){return this.field!==null&&this.field.text_get()!==this.original}path_get(){return this.path}field_release(){return this.field===null||!this.field.hasFocus()?!1:(this.field.blur(),this.focusMark_set(!1),!0)}dispose(){this.field?.destroy(),this.field=null}controls_sync(){const e=this.dirty_is();this.savePill.disabled=!e||this.saving,this.revertPill.disabled=!e||this.saving,this.mount.dataset.dirty=e?"yes":"no",this.field!==null&&(this.saving?ys(this.stateSpan,"wait","SAVING"):e?ys(this.stateSpan,"note","DIRTY"):ys(this.stateSpan,"settled","SAVED"))}title_set(e){this.titleSpan!==null&&(this.titleSpan.textContent=`EDIT ${e.split("/").pop()??e}`.toUpperCase()),this.mount.title=e}focusMark_set(e){this.focusMark!==null&&(this.focusMark.hidden=!e)}element_require(e){const s=this.mount.querySelector(e);if(s===null)throw new Error(`edit pane: no ${e} in its template`);return s}}function yj(t,e){const{layout:s,panels:i,subjects:n}=t,r=async(d,u)=>{const p=await ra(t,M1(d,u));return p&&e.saved?.(d),p},o=d=>{const u=e.template_stamp("tpl-pane-edit"),p=new wj(u,{save:r,note:f=>t.terminal.line_note(f)});return i.set("edit",d,p),{id:d,kind:"edit",mount:u,dispose:()=>{p.dispose(),i.delete(d),n.pane_leave(d)}}},a=d=>{const u=new Set(s.panes_shown());for(const[p,f]of i.entries("edit"))if(u.has(p)&&f.path_get()===d)return p;return null},l=()=>{e.launcher_yield();const d=new Set(s.panes_shown()),u=s.focused_get(),p=u!==null&&d.has(u)?u:e.errandHost_find();if(p===null)return null;const f=e.instance_spawn("edit"),_=e.replayPlace_get();return s.leaf_split(p,_?.dir??"col",f.id,_?.before??!1)?(e.birth_record(f.id,p,_?.dir??"col",_?.before??!1),f.id):(As(f.id),s.mount_remove(f.id),null)};return{instance_build:o,edit_receive:d=>{const u=d.path??"";if(u==="")throw new Error("the editor pane needs the file it edits, and the request named none");const p=a(u)??l();if(p===null)return!1;const f=i.get("edit",p);return f===void 0?!1:(s.focus_set(p),f.dirty_is()?(t.terminal.line_note(`edit: ${u}: its pane has unsaved changes; they stand (REVERT reads the file again)`),!0):(f.content_show({path:u,content:d.content,extension:d.extension??ez(u)}),!0))},edit_open:(d,u={})=>{const p=a(d)??l();if(p===null)return null;const f=i.get("edit",p);if(f===void 0)return null;s.focus_set(p),f.dirty_is()||f.opening_show(d);const _=v1(d);return u.visible===!0?(t.terminal.line_run(_),p):(t.client.line_execute(_,{silent:!0,observe:!1}).then(g=>{const m=g.envelopes.find(w=>w.status!=="ok");m!==void 0&&f.opening_fail((m.renderedErr??"").replace(/\x1b\[[0-9;]*m/g,"").trim()||"the kernel refused")}).catch(g=>f.opening_fail(g instanceof Error?g.message:String(g))),p)}}}class zj{listing;constructor(e){const s=e.querySelector(".help-panel");if(s===null)throw new Error("help pane: no .help-panel in its template");this.listing=new Ir({mount:s,traits:this.traits_declare(),key:i=>i.key,chrome:{root:e,prefix:"help"},caps:"root",activatable:()=>!1,row:{className:i=>`help-row help-${i.topic}`}}),this.render()}traits_declare(){return[{key:"name",label:"KEY · VERB",className:"help-key",width:"minmax(9em, 12em)",cell:e=>e.name},{key:"does",label:"DOES",className:"help-does",width:"minmax(16em, 1fr)",cell:e=>e.does}]}render(){const e=o=>{const a=document.createElement("header");return a.className="files-path help-block-head",a.textContent=o,a},s=pn.map(o=>({key:`k:${o.key}`,name:o.key,does:o.does,topic:o.topic})),i=ma.map((o,a)=>{const l=o.indexOf(" ");return{key:`v:${a}`,name:l<0?o:o.slice(0,l),does:l<0?"":o.slice(l+1).trim(),topic:"verb"}}),n=[{key:"g:games",name:"help games",does:"the /usr/games shelf — fortune, cal, weather and their kin, by category (type it in the console)",topic:"verb"}],r=[{key:"n:notes",name:"notes",does:"what the installed releases changed (notes pane opens it as a listing; the dashboard's WHAT'S NEW block too)",topic:"verb"}];this.listing.rows_set([{key:"keys",header:e("KEYS — Ctrl-B opens the focused pane's drawer; then one key presses one of its verbs"),rows:s},{key:"verbs",header:e("VERBS — the console language; the long form is docs/argus-lang.adoc"),rows:i},{key:"games",header:e("GAMES — the small pleasures, kept apart from the tools as BSD kept them"),rows:n},{key:"notes",header:e("NOTES — what changed, release by release"),rows:r}],{field:"help"})}}function Sj(t,e){const{layout:s,panels:i,subjects:n}=t;return{instance_build:a=>{const l=e.template_stamp("tpl-pane-help");return i.set("help",a,new zj(l)),{id:a,kind:"help",mount:l,dispose:()=>{i.delete(a),n.pane_leave(a)}}},open:()=>{const a=i.ids("help").find(d=>s.panes_shown().includes(d));if(a!==void 0)return s.focus_set(a),"help: on stage";const l=e.launcher_active();e.launcher_yield();const c=s.focused_get()??"files",h=e.instance_spawn("help");return l&&s.leaf_replace("files",h.id)?(s.focus_set(h.id),"help: the keys and the verbs, as a pane (help keys, help verbs print them here)"):s.leaf_split(c,"col",h.id,!1)?(e.birth_record(h.id,c,"col",!1),"help: the keys and the verbs, as a pane (help keys, help verbs print them here)"):(As(h.id),s.mount_remove(h.id),"help: could not open a pane")}}}const lf=["___________________ _-_ ","\\__(==========/_=_/ ____.---'---`---.____"," \\_ \\ \\----._________.----/"," \\ \\ / / `-_-' "," __,--`.`-'..'-_ "," /____ || "," `--.____,-' "];function xj(){const t=lf[0].length;let e=Number.NaN,s=0;return{title:"SL",tick:60,step:i=>{Number.isNaN(e)&&(e=-t),e+=1,s+=1,e>i.cols+6&&(e=-t)},draw:(i,n)=>{const r=Math.max(0,Math.floor((i.rows-lf.length)/2));lf.forEach((a,l)=>i.text(Math.round(e),r+l,a,n.lit));const o=s%2===0?"-~=":"-=~";i.text(Math.round(e)-o.length,r+1,o,n.cool)}}}const Mv="ハミヒーウシナモニサワツオリアホテマケメエカキムユラセネスタヌヘ0123456789Z:・.=*+-<>¦|";function Oj(){const t=new Map;let e=0;return{title:"CMATRIX",tick:50,step:(s,i)=>{e+=1;for(let n=0;n<s.cols;n++){const r=t.get(n);if(r===void 0){i()<.02&&t.set(n,{row:-1,speed:1+Math.floor(i()*2),length:4+Math.floor(i()*12),glyphs:[]});continue}e%r.speed===0&&(r.row+=1,r.glyphs.unshift(Mv[Math.floor(i()*Mv.length)]),r.glyphs.length>r.length&&r.glyphs.pop(),r.row-r.length>s.rows&&t.delete(n))}},draw:(s,i)=>{for(const[n,r]of t)r.glyphs.forEach((o,a)=>{const l=a===0?"#ffffff":a<r.length/2?i.lit:i.dim;s.put(n,r.row-a,o,l)})}}}function Ej(){const t=[];return{title:"RAIN",tick:70,step:(e,s)=>{s()<.9&&t.push({col:Math.floor(s()*e.cols),row:0,splash:0});for(const i of t)i.row<e.rows-1?i.row+=1:i.splash+=1;for(let i=t.length-1;i>=0;i--)t[i].splash>3&&t.splice(i,1)},draw:(e,s)=>{for(const i of t){if(i.splash===0){e.put(i.col,i.row,"|",s.cool);continue}const n=["o","O","( )"][i.splash-1];e.text(i.col-(n.length>>1),e.rows-1,n,s.dim)}}}}function Aj(){const t=[],e=[];let s=0;return{title:"ASCIIQUARIUM",tick:90,step:(i,n)=>{if(s+=1,t.length<Math.max(3,i.cols/12)&&n()<.08){const r=n()<.5;t.push({col:r?-4:i.cols+1,row:2+Math.floor(n()*Math.max(1,i.rows-5)),right:r,speed:1+Math.floor(n()*2),hue:Math.floor(n()*3)})}for(const r of t)s%r.speed===0&&(r.col+=r.right?1:-1);for(let r=t.length-1;r>=0;r--){const o=t[r];(o.col<-5||o.col>i.cols+2)&&t.splice(r,1)}if(n()<.3){const r=t[Math.floor(n()*t.length)];r!==void 0&&e.push({col:r.col+(r.right?4:-1),row:r.row-1})}for(const r of e)r.row-=1;for(let r=e.length-1;r>=0;r--)e[r].row<1&&e.splice(r,1)},draw:(i,n)=>{const r=(s%4<2?"~^":"^~").repeat(i.cols>>1);i.text(0,0,r,n.cool);const o=[n.lit,n.cool,n.warn];for(const a of t)i.text(a.col,a.row,a.right?"><>":"<><",o[a.hue]);for(const a of e)i.put(a.col,a.row,a.row%2===0?"o":".",n.dim);for(let a=2;a<i.cols;a+=7){const l=(s>>2)%2===0?0:1;for(let c=0;c<3;c++)i.put(a+(c+l)%2,i.rows-2-c,c%2===0?"(":")",n.dim)}i.text(0,i.rows-1,"^".repeat(i.cols),n.dim)}}}const vv=[[[0,0],[1,0],[2,0],[3,0]],[[0,0],[1,0],[0,1],[1,1]],[[1,0],[0,1],[1,1],[2,1]],[[0,0],[1,0],[1,1],[2,1]],[[1,0],[2,0],[0,1],[1,1]],[[0,0],[0,1],[1,1],[2,1]],[[2,0],[0,1],[1,1],[2,1]]],so=10,co=20;function Tj(){return{well:Array.from({length:co},()=>Array(so).fill(0)),piece:null,score:0,lines:0,over:!1}}function l_(t,e){return e.cells.every(([s,i])=>{const n=e.x+s,r=e.y+i;return n>=0&&n<so&&r<co&&(r<0||t[r][n]===0)})}function cf(t){const e=Math.max(...t.cells.flat())+1;return{...t,cells:t.cells.map(([s,i])=>[e-1-i,s])}}function Ij(t,e){const s=Math.floor(e()*vv.length),i={cells:vv[s].map(n=>[n[0],n[1]]),x:3,y:0,kind:s+1};if(!l_(t.well,i)){t.over=!0;return}t.piece=i}function Dj(t){const e=t.piece;if(e===null)return;e.cells.some(([,n])=>e.y+n<0)&&(t.over=!0);for(const[n,r]of e.cells){const o=e.y+r;o>=0&&(t.well[o][e.x+n]=e.kind)}const s=t.well.filter(n=>n.some(r=>r===0)),i=co-s.length;for(;s.length<co;)s.unshift(Array(so).fill(0));t.well=s,t.lines+=i,t.score+=[0,100,300,500,800][i]??800,t.piece=null}function hm(t,e){if(t.over)return;if(t.piece===null){Ij(t,e);return}const s={...t.piece,y:t.piece.y+1};l_(t.well,s)?t.piece=s:Dj(t)}function Cj(t,e,s){if(t.over||t.piece===null)return!1;const i=t.piece,n=r=>l_(t.well,r)?(t.piece=r,!0):!1;switch(e){case"ArrowLeft":case"h":case"a":return n({...i,x:i.x-1}),!0;case"ArrowRight":case"l":case"d":return n({...i,x:i.x+1}),!0;case"ArrowUp":case"k":case"w":return n(cf(i))||n({...cf(i),x:i.x-1})||n({...cf(i),x:i.x+1}),!0;case"ArrowDown":case"j":case"s":return hm(t,s),!0;case" ":{for(;t.piece!==null;)hm(t,s);return!0}default:return!1}}function Rj(){const t=Tj();let e=Math.random;return{title:"TETRIS",tick:500,step:(s,i)=>{e=i,hm(t,i)},draw:(s,i)=>{const n=Math.max(0,Math.floor((s.cols-(so*2+2))/2)),r=Math.max(0,Math.floor((s.rows-co-1)/2)),o=["",i.cool,i.lit,i.warn,i.dim,i.lit,i.cool,i.warn];for(let a=0;a<co;a++){s.put(n,r+a,"|",i.dim),s.put(n+so*2+1,r+a,"|",i.dim);for(let l=0;l<so;l++){const c=t.well[a][l];c!==0&&s.text(n+1+l*2,r+a,"[]",o[c])}}if(s.text(n,r+co,"+"+"-".repeat(so*2)+"+",i.dim),t.piece!==null)for(const[a,l]of t.piece.cells){const c=t.piece.y+l;c>=0&&s.text(n+1+(t.piece.x+a)*2,r+c,"[]",o[t.piece.kind])}t.over&&s.text(n+2,r+9," GAME OVER ",i.warn)},key:s=>Cj(t,s,e),status:()=>`${t.score} · ${t.lines} lines${t.over?" · OVER":""}`,over:()=>t.over}}function kj(t,e,s){const i=t>>1,n=e>>1,r={body:[[i,n],[i-1,n],[i-2,n]],food:[0,0],heading:"right",next:"right",score:0,over:!1,cols:t,rows:e};return C1(r,s),r}function C1(t,e){for(let s=0;s<1e3;s++){const i=[Math.floor(e()*t.cols),Math.floor(e()*t.rows)];if(!t.body.some(([n,r])=>n===i[0]&&r===i[1])){t.food=i;return}}}const Nj={up:"down",down:"up",left:"right",right:"left"};function Bj(t,e){Nj[e]!==t.heading&&(t.next=e)}function Gj(t,e){if(t.over)return;t.heading=t.next;const[s,i]=t.body[0],n=t.heading==="up"?[s,i-1]:t.heading==="down"?[s,i+1]:t.heading==="left"?[s-1,i]:[s+1,i],r=n[0]<0||n[1]<0||n[0]>=t.cols||n[1]>=t.rows,o=t.body.some(([a,l])=>a===n[0]&&l===n[1]);if(r||o){t.over=!0;return}t.body.unshift(n),n[0]===t.food[0]&&n[1]===t.food[1]?(t.score+=10,C1(t,e)):t.body.pop()}const Pj={ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",ArrowDown:"down",k:"up",w:"up",j:"down",s:"down",h:"left",a:"left",l:"right",d:"right"};function Lj(){let t=null;return{title:"SNAKE",tick:140,step:(e,s)=>{t===null&&(t=kj(Math.max(8,e.cols>>1),Math.max(6,e.rows-1),s)),Gj(t,s)},draw:(e,s)=>{t!==null&&(e.text(0,t.rows,"-".repeat(t.cols*2),s.dim),e.text(t.food[0]*2,t.food[1],"**",s.warn),t.body.forEach(([i,n],r)=>e.text(i*2,n,r===0?"@@":"oo",r===0?s.lit:s.cool)),t.over&&e.text(Math.max(0,t.cols-6),t.rows>>1," GAME OVER ",s.warn))},key:e=>{const s=Pj[e];return s===void 0||t===null?!1:(Bj(t,s),!0)},status:()=>t===null?"":`${t.score}${t.over?" · OVER":""}`,over:()=>t?.over??!1}}const R1={sl:xj,cmatrix:Oj,rain:Ej,aquarium:Aj,tetris:Rj,snake:Lj};function Wj(t){return t in R1}const Fj=8,Uj=26,hf=1.8,$j=100,wv=24;function yv(t,e){let s=Math.floor(t/$j);return e/(s*hf)<wv&&(s=Math.floor(e/wv/hf)),s=Math.max(Fj,Math.min(Uj,s)),{w:s,h:Math.round(s*hf)}}class jj{pane;field;canvas;state;focusMark;pausePill;program=null;name=null;paused=!1;timer=null;frame=null;observer;constructor(e){this.pane=e,this.field=el(e,".games-field"),this.canvas=el(e,".games-canvas"),this.state=e.querySelector(".pane-state"),this.focusMark=el(e,".games-focus"),this.pausePill=el(e,".games-pause"),this.field.tabIndex=0,this.pausePill.addEventListener("click",()=>this.pause_toggle()),el(e,".games-restart").addEventListener("click",()=>{this.name!==null&&this.program_run(this.name)}),this.field.addEventListener("mousedown",()=>{this.field.focus(),this.focusMark_paint(!0)}),this.field.addEventListener("focusin",()=>this.focusMark_paint(!0)),this.field.addEventListener("focusout",s=>{(!(s.relatedTarget instanceof Node)||!this.field.contains(s.relatedTarget))&&this.focusMark_paint(!1)}),this.field.addEventListener("keydown",s=>this.key_handle(s)),this.observer=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>this.draw()),this.observer?.observe(this.field)}program_run(e){this.name=e,this.program=R1[e](),this.paused=!1,this.pausePill.textContent="PAUSE",this.clock_start(),this.program.key!==void 0&&(this.field.focus(),this.focusMark_paint(!0)),this.draw()}program_name(){return this.name}paused_is(){return this.paused}pause_toggle(){this.program!==null&&(this.paused=!this.paused,this.pausePill.textContent=this.paused?"RESUME":"PAUSE",this.paused?this.clock_stop():this.clock_start(),this.state_paint())}field_hasFocus(){return document.activeElement instanceof Node&&this.field.contains(document.activeElement)}field_release(){return this.field_hasFocus()?(document.activeElement.blur(),this.focusMark_paint(!1),!0):!1}dispose(){this.clock_stop(),this.observer?.disconnect()}key_handle(e){if(e.key==="Escape"){this.field_release(),e.stopPropagation();return}if(this.program!==null){if(e.key===" "&&this.program.key===void 0){this.pause_toggle(),e.preventDefault(),e.stopPropagation();return}this.program.key?.(e.key)===!0&&(e.preventDefault(),this.draw()),e.stopPropagation()}}clock_start(){this.clock_stop();const e=this.program;e!==null&&(this.timer=setInterval(()=>{this.field.offsetParent!==null&&(e.step(this.size_measure(),Math.random),this.draw(),e.over?.()===!0&&this.clock_stop())},e.tick))}clock_stop(){this.timer!==null&&clearInterval(this.timer),this.timer=null}size_measure(){const e=this.field.getBoundingClientRect(),s=yv(e.width,e.height);return{cols:Math.max(10,Math.floor(e.width/s.w)),rows:Math.max(6,Math.floor(e.height/s.h))}}palette_read(){const e=getComputedStyle(this.pane),s=(i,n)=>e.getPropertyValue(i).trim()||n;return{lit:s("--harvestgold","#ffcc66"),dim:s("--butter","#ffff99"),warn:s("--tomato","#ff7766"),cool:s("--daybreak","#55aaff")}}draw(){this.frame===null&&(this.frame=requestAnimationFrame(()=>{this.frame=null,this.paint()}))}paint(){const e=this.program,s=this.canvas.getContext("2d");if(e===null||s===null)return;const i=this.field.getBoundingClientRect(),n=window.devicePixelRatio||1;(this.canvas.width!==Math.floor(i.width*n)||this.canvas.height!==Math.floor(i.height*n))&&(this.canvas.width=Math.floor(i.width*n),this.canvas.height=Math.floor(i.height*n)),s.setTransform(n,0,0,n,0,0),s.clearRect(0,0,i.width,i.height);const r=yv(i.width,i.height);s.font=`${r.h-2}px 'Share Tech Mono', monospace`,s.textBaseline="top";const o=this.size_measure(),a=(c,h,d,u)=>{c<0||h<0||c>=o.cols||h>=o.rows||(s.fillStyle=u,s.fillText(d,c*r.w,h*r.h))},l={cols:o.cols,rows:o.rows,put:a,text:(c,h,d,u)=>{[...d].forEach((p,f)=>{p!==" "&&a(c+f,h,p,u)})}};e.draw(l,this.palette_read()),this.state_paint()}state_paint(){if(this.state===null||this.program===null)return;const e=this.program.status?.()??"";this.state.textContent=[this.program.title,e,this.paused?"PAUSED":""].filter(s=>s!=="").join(" · ")}focusMark_paint(e){this.focusMark.hidden=!e,this.pane.classList.toggle("games-field-focused",e)}}function el(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`games pane: missing ${e}`);return s}function Hj(t,e){const{layout:s,panels:i,subjects:n}=t;return{instance_build:a=>{const l=e.template_stamp("tpl-pane-games"),c=new jj(l);return i.set("games",a,c),{id:a,kind:"games",mount:l,dispose:()=>{c.dispose(),i.delete(a),n.pane_leave(a)}}},show:a=>{const l=typeof a=="object"&&a!==null?a.program:void 0;if(typeof l!="string"||!Wj(l))return`games: no program named ${String(l)}`;const c=i.ids("games").find(f=>s.panes_shown().includes(f));if(c!==void 0)return s.focus_set(c),i.get("games",c)?.program_run(l),`games: ${l} on the GAMES pane`;const h=e.launcher_active();e.launcher_yield();const d=s.focused_get()??"files",u=e.instance_spawn("games");return(h?s.leaf_replace("files",u.id):s.leaf_split(d,"col",u.id,!1))?(h?s.focus_set(u.id):e.birth_record(u.id,d,"col",!1),i.get("games",u.id)?.program_run(l),`games: ${l} in a GAMES pane (Esc gives the keyboard back; its PAUSE and RESTART pills on the frame)`):(As(u.id),s.mount_remove(u.id),"games: could not open a pane")}}}function st(t,e){const s=document.createElementNS("http://www.w3.org/2000/svg",t);for(const[i,n]of Object.entries(e))s.setAttribute(i,String(n));return s}const fr=["cruiser","raptor","talon","warbird"],Vj={ship:'<g fill="currentColor"><ellipse cx="12" cy="6.5" rx="9" ry="4"/><rect x="9.5" y="9.5" width="5" height="6" rx="1"/><rect x="3" y="14" width="5" height="8" rx="2.2"/><rect x="16" y="14" width="5" height="8" rx="2.2"/><rect x="7" y="16" width="10" height="2.2" rx="1"/></g>',"klingon-cruiser":'<g fill="currentColor"><circle cx="12" cy="4" r="2.6"/><rect x="11" y="5.5" width="2" height="8.5"/><path d="M12 12.5 L22 20.5 L22.5 22.5 L17 19.2 L12 18 L7 19.2 L1.5 22.5 L2 20.5 Z"/><rect x="8.5" y="18.5" width="7" height="3.2" rx="1.2"/></g>',"klingon-raptor":'<path fill="currentColor" d="M12 1.5 L14 6.5 L22.5 10.5 L21.5 18 L19.5 12.5 L15 13.5 L14 20 L12 17 L10 20 L9 13.5 L4.5 12.5 L2.5 18 L1.5 10.5 L10 6.5 Z"/>',"klingon-talon":'<g fill="currentColor"><path d="M12 1.5 L13.6 11 L21.5 4.5 L19 15 L12 22 L5 15 L2.5 4.5 L10.4 11 Z"/><circle cx="12" cy="13.5" r="1.6" fill="#000"/></g>',"klingon-warbird":'<g fill="currentColor"><rect x="8.5" y="2" width="7" height="3.2" rx="1.6"/><rect x="11.1" y="4.5" width="1.8" height="7"/><path d="M1.5 13 Q12 6 22.5 13 L22 20 Q17 15.5 14 17 L12 22 L10 17 Q7 15.5 2 20 Z"/></g>',base:'<g fill="currentColor"><path d="M12 1.5 L17 12 L12 22.5 L7 12 Z"/><rect x="1.5" y="10.8" width="21" height="2.4" rx="1.2"/><circle cx="12" cy="12" r="3" fill="#000"/></g>',inhabited:'<circle cx="12" cy="12" r="7.5" fill="currentColor"/><path d="M4.5 12 Q12 15.5 19.5 12" fill="none" stroke="#000" stroke-width="1.6"/><path d="M5.5 8.5 Q12 11 18.5 8.5" fill="none" stroke="#000" stroke-width="1.2" opacity="0.6"/>',star:'<g stroke="currentColor" stroke-width="1.8" stroke-linecap="round" fill="none"><path d="M12 2 V22 M2 12 H22 M4.9 4.9 L19.1 19.1 M19.1 4.9 L4.9 19.1"/></g><circle cx="12" cy="12" r="2.6" fill="currentColor"/>',hole:'<g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"><path d="M12 12 m0 -2.5 a2.5 2.5 0 1 1 -2.5 2.5"/><path d="M12 12 m0 -6 a6 6 0 1 1 -6 6"/><path d="M12 12 m0 -9.5 a9.5 9.5 0 1 1 -9.5 9.5" opacity="0.5"/></g>',supernova:'<g fill="currentColor"><path d="M10 8.536 A4 4 0 0 1 14 8.536 L17.5 2.474 A11 11 0 0 0 6.5 2.474 Z"/><path d="M10 8.536 A4 4 0 0 1 14 8.536 L17.5 2.474 A11 11 0 0 0 6.5 2.474 Z" transform="rotate(120 12 12)"/><path d="M10 8.536 A4 4 0 0 1 14 8.536 L17.5 2.474 A11 11 0 0 0 6.5 2.474 Z" transform="rotate(240 12 12)"/><circle cx="12" cy="12" r="2.4"/></g>'},Al="tm-";function k1(t,e=null){return t==="klingon"?`${Al}klingon-${e!==null&&fr.includes(e)?e:fr[0]}`:`${Al}${t}`}function qj(){if(document.getElementById(`${Al}ship`)!==null)return null;const t=st("svg",{class:"tm-defs",width:0,height:0,"aria-hidden":"true"}),e=st("defs",{});for(const[i,n]of Object.entries(Vj)){const r=st("symbol",{id:`${Al}${i}`,viewBox:"0 0 24 24"});r.innerHTML=n,e.append(r)}const s=(i,n)=>{const r=st("radialGradient",{id:`${Al}${i}`});for(const[o,a,l]of n){const c=st("stop",{offset:o});c.setAttribute("style",`stop-color: ${a}; stop-opacity: ${l}`),r.append(c)}return r};return e.append(s("halo",[[0,"var(--butter)",.9],[.35,"var(--harvestgold)",.5],[1,"var(--harvestgold)",0]]),s("halo-nova",[[0,"var(--butter)",.9],[.3,"var(--pumpkin-pie)",.6],[1,"var(--pumpkin-pie)",0]]),s("halo-mars",[[0,"var(--butter)",.8],[.3,"var(--mars)",.6],[1,"var(--mars)",0]]),s("photon-core",[[0,"#fff",1],[.35,"#ffd27a",1],[1,"#ff6a1a",1]]),s("photon-halo",[[0,"#ff6a1a",.55],[1,"#ff6a1a",0]])),t.append(e),t}function c_(t,e,s=null,i=0){const n=st("g",{class:`tm-mark tm-mark-${t}`});return n.append(st("use",{href:`#${k1(t,s)}`,x:-e.size/2,y:-e.size/2,width:e.size,height:e.size,class:"tm-symbol"})),N1(n,e.cx,e.cy,i),n}function N1(t,e,s,i=0){t.setAttribute("transform",i===0?`translate(${e} ${s})`:`translate(${e} ${s}) rotate(${i})`)}function h_(t,e=null){const s=st("svg",{viewBox:"0 0 24 24",class:`tm-icon tm-icon-${t}`,"aria-hidden":"true"});return s.append(st("use",{href:`#${k1(t,e)}`})),s}const Jc={ship:"E",klingon:"K",base:"#",inhabited:"@",star:"*",hole:" ",supernova:"///"},Kj=[{kind:"ship",name:"ENTERPRISE"},{kind:"klingon",name:"KLINGON"},{kind:"base",name:"STARBASE"},{kind:"inhabited",name:"INHABITED"},{kind:"star",name:"STAR"},{kind:"hole",name:"BLACK HOLE"},{kind:"supernova",name:"SUPERNOVA"}],Yj=/^Klingon at (\d+),(\d+) moves to (\d+),(\d+)/,Xj=/^Klingon at (\d+),(\d+) escapes to quadrant/,Zj=/\*\*\* Klingon at (\d+),(\d+) destroyed \*\*\*/;class Tl{marks=new Map;mark_find(e){return this.marks.get(Tl.key_format(e))??null}line_hear(e){const s=Yj.exec(e);if(s!==null){const n=`${s[1]},${s[2]}`,r=this.marks.get(n);return this.marks.delete(n),r!==void 0&&this.marks.set(`${s[3]},${s[4]}`,r),!0}const i=Xj.exec(e)??Zj.exec(e);return i!==null?(this.marks.delete(`${i[1]},${i[2]}`),!0):!1}reconcile(e,s={}){s.reset===!0&&this.marks.clear();const i=new Set(e.map(n=>Tl.key_format(n)));for(const n of[...this.marks.keys()])i.has(n)||this.marks.delete(n);e.forEach((n,r)=>{const o=Tl.key_format(n);if(s.byOrder===!0){this.marks.set(o,fr[r%fr.length]);return}this.marks.has(o)||this.marks.set(o,this.leastWorn_get())})}clear(){this.marks.clear()}leastWorn_get(){const e=new Map(fr.map(i=>[i,0]));for(const i of this.marks.values())e.set(i,(e.get(i)??0)+1);let s=fr[0];for(const i of fr)(e.get(i)??0)<(e.get(s)??0)&&(s=i);return s}static key_format(e){return`${e.x},${e.y}`}}function Jj(t,e,s,i){const n=Math.max(0,Math.min(100,100*t/Math.max(1,e)));return i?{className:"tb-ring tb-ring-docked",width:.09,percent:n}:s?{className:`tb-ring ${n>60?"tb-ring-full":n>30?"tb-ring-mid":"tb-ring-low"}`,width:.025+.085*n/100,percent:n}:{className:"tb-ring tb-ring-down",width:.02,percent:n}}function q(t,e,s){const i=document.createElement(t);return i.className=e,s!==void 0&&(i.textContent=s),i}function Os(t,e,s){const i=q("button",`tb-pill ${t}`,e);return i.type="button",i.addEventListener("click",s),i}const Qj=16;class B1{constructor(e,s,i){this.onCommit=i,this.size=e;const n=e/2;this.root=q("div","tb-wheel");const r=st("svg",{width:e,height:e,viewBox:`0 0 ${e} ${e}`,role:"img","aria-label":s});r.classList.add("tb-wheel-face"),r.append(st("circle",{cx:n,cy:n,r:n-4,class:"tb-wheel-rim"})),r.append(st("circle",{cx:n,cy:n,r:(n-4)*.66,class:"tb-wheel-ring"})),r.append(st("circle",{cx:n,cy:n,r:(n-4)*.33,class:"tb-wheel-ring"}));for(let l=0;l<36;l++){const c=l*Math.PI/18,h=l%3===0,d=n-4-(h?12:7);r.append(st("line",{x1:n+d*Math.sin(c),y1:n-d*Math.cos(c),x2:n+(n-4)*Math.sin(c),y2:n-(n-4)*Math.cos(c),class:h?"tb-wheel-tick-major":"tb-wheel-tick"}))}for(const l of[0,90,180,270]){const c=l*Math.PI/180,h=st("text",{x:n+(n-26)*Math.sin(c),y:n-(n-26)*Math.cos(c)+4,"text-anchor":"middle",class:"tb-wheel-label"});h.textContent=String(l),r.append(h)}this.wedge=st("path",{d:"",class:"tb-wheel-wedge"}),r.append(this.wedge),this.marks=st("g",{class:"tb-wheel-marks"}),r.append(this.marks),this.needle=st("line",{x1:n,y1:n,x2:n,y2:14,class:"tb-wheel-needle"}),r.append(this.needle),r.append(st("circle",{cx:n,cy:n,r:6,class:"tb-wheel-hub"})),this.root.append(r);const o=q("div","tb-wheel-row");this.readout=q("span","tb-wheel-readout","0°"),this.commit=Os("tb-commit","SET COURSE",()=>this.onCommit(Math.round(this.degrees))),o.append(this.readout,this.commit),this.root.append(o);const a=l=>{const c=r.getBoundingClientRect(),h=l.clientX-c.left-c.width/2,d=l.clientY-c.top-c.height/2;this.degrees_set((Math.atan2(h,-d)*180/Math.PI+360)%360)};r.addEventListener("pointerdown",l=>{r.setPointerCapture(l.pointerId),a(l)}),r.addEventListener("pointermove",l=>{l.buttons!==0&&a(l)})}onCommit;root;needle;marks;wedge;readout;commit;degrees=0;wedgeHalf=null;size;degrees_set(e){this.degrees=e;const s=this.size/2,i=e*Math.PI/180;this.needle.setAttribute("x2",String(s+(s-14)*Math.sin(i))),this.needle.setAttribute("y2",String(s-(s-14)*Math.cos(i))),this.readout.textContent=`${Math.round(e)}°`,this.wedge_draw()}degrees_get(){return this.degrees}wedge_set(e){this.wedgeHalf=e,this.wedge_draw()}wedge_draw(){if(this.wedgeHalf===null){this.wedge.setAttribute("d","");return}const e=this.size/2,s=e-14,i=(this.degrees-this.wedgeHalf)*Math.PI/180,n=(this.degrees+this.wedgeHalf)*Math.PI/180,r=e+s*Math.sin(i),o=e-s*Math.cos(i),a=e+s*Math.sin(n),l=e-s*Math.cos(n);this.wedge.setAttribute("d",`M ${e} ${e} L ${r} ${o} A ${s} ${s} 0 0 1 ${a} ${l} Z`)}marks_set(e){this.marks.replaceChildren();const s=this.size/2;for(const i of e){const n=i.bearing*Math.PI/180,r=(s-4)*.8,o=s+r*Math.sin(n),a=s-r*Math.cos(n),l=i.kind==="klingon"?i.bearing+180:0,c=c_(i.kind,{cx:o,cy:a,size:Qj},i.variant??null,l);c.classList.add("tb-wheel-mark",`tb-wheel-mark-${i.kind}`);const h=st("title",{});h.textContent=i.label,c.append(h),this.marks.append(c)}}lit_set(e,s="SET COURSE"){this.root.classList.toggle("tb-lit",e),this.commit.disabled=!e,this.commit.textContent=s}}class xr{constructor(e,s,i,n){this.digits=i,this.onCommit=n,this.root=q("div","tb-slider");const r=q("label","tb-slider-label",s);r.htmlFor=e,this.input=document.createElement("input"),this.input.type="range",this.input.id=e,this.input.className="tb-slider-input",this.input.addEventListener("input",()=>{this.shown_refresh(),this.onInput?.(this.value_get())});const o=q("div","tb-slider-column");this.ticks=q("div","tb-slider-ticks"),this.note=q("span","tb-slider-note"),o.append(this.input,this.ticks,this.note),this.shown=q("span","tb-slider-readout","—"),this.commit=Os("tb-commit","SET",()=>this.onCommit(this.value_get())),this.root.append(r,o,this.shown,this.commit)}digits;onCommit;root;input;shown;commit;note;ticks;onInput=null;range_set(e,s,i,n=0){const r=e.min??0,o=e.max??1;this.input.min=String(r),this.input.max=String(o),this.input.step=String(e.step??1),this.input.value=String(Math.min(o,Math.max(r,s))),this.note.textContent=i,this.ticks.replaceChildren();for(let a=0;a<n;a++){const l=r+(o-r)*a/Math.max(1,n-1);this.ticks.append(q("span","tb-slider-tick",Number.isInteger(l)?String(l):l.toFixed(1)))}this.shown_refresh()}input_listen(e){this.onInput=e}note_set(e){this.note.textContent=e}value_get(){return Number(this.input.value)}value_set(e){this.input.value=String(e),this.shown_refresh()}lit_set(e,s="SET"){this.root.classList.toggle("tb-lit",e),this.input.disabled=!e,this.commit.disabled=!e,this.commit.textContent=s}lit_is(){return this.root.classList.contains("tb-lit")}shown_refresh(){this.shown.textContent=this.value_get().toFixed(this.digits)}}class Qc{root;buttons=[];note;constructor(e,s,i){this.root=q("div","tb-pillrow"),e!==""&&this.root.append(q("span","tb-slider-label",e));const n=q("div","tb-slider-column"),r=q("div","tb-pills");for(const o of s){const a=Os("tb-choice",o.label,()=>i(o.line,o.label));a.dataset.line=o.line,this.buttons.push(a),r.append(a)}this.note=q("span","tb-slider-note",""),n.append(r,this.note),this.root.append(n)}note_set(e){this.note.textContent=e}lit_set(e){this.root.classList.toggle("tb-lit",e);for(const s of this.buttons)s.disabled=!e}}const e6=[[/Klingon attack:/,"incoming"],[/^HIT: \d+ units/,"hit"],[/CRITICAL HIT/,"hit"],[/\*\*\* Klingon at \d+,\d+ destroyed \*\*\*/,"explosion"],[/\*\*\*\*\* .* destroyed \*\*\*\*\*/,"explosion"],[/Starbase at \d+,\d+ destroyed/,"explosion"],[/Inhabited starsystem .* destroyed/,"explosion"],[/^Torpedo track/,"torpedo"],[/^Phaser bank \d+ fires:/,"phaser"],[/^Phasers locked on target/,"phaser"],[/^Starbase in \d+,\d+ responds/,"hail"],[/^Password verified; self destruct sequence continues/,"destruct"]];function t6(t){const e=[];for(const[s,i]of e6)s.test(t)&&!e.includes(i)&&e.push(i);return e}function s6(t,e){const s=[];if(t!==null&&t.condition.name!==e.condition.name)switch(e.condition.name){case"RED":s.push("redalert");break;case"YELLOW":s.push("yellowalert");break;case"DOCKED":s.push("dock");break;default:s.push("green");break}return t!==null&&(t.position.quadrant.x!==e.position.quadrant.x||t.position.quadrant.y!==e.position.quadrant.y)&&s.push("sensor"),s}function i6(t){switch(t){case"abandon":return"transporter";case"destruct":return"destruct";case"computer":return"thinking";default:return null}}function n6(t,e){return t!=="distance"?null:e==="impulse"?"impulse":e==="move"||e==="ram"?"warp":null}function gr(t,e){return e==="computer"&&t==="MOVE"?"MOVE (COMPUTER)":e==="commit"?/^SET COURSE/.test(t)?"SET COURSE":"SLIDER SET":e==="choice"&&/^\d+°$/.test(t)?"BURST ANGLE":/^CANCEL/.test(t)?"CANCEL":t}const Ss=10,Ul=8,r6="*",o6="#",G1="E",a6="Q",l6="K",c6="@",P1=" ",h6=7,d6=64,u6=63,f6=0,p6=1,m6=2,g6=3,_6=[{name:"warp drive",person:"Scotty"},{name:"S.R. scanners",person:"Scotty"},{name:"L.R. scanners",person:"Scotty"},{name:"phasers",person:"Sulu"},{name:"photon tubes",person:"Sulu"},{name:"impulse engines",person:"Scotty"},{name:"shield control",person:"Sulu"},{name:"computer",person:"Spock"},{name:"subspace radio",person:"Uhura"},{name:"life support",person:"Scotty"},{name:"navigation system",person:"Chekov"},{name:"cloaking device",person:"Scotty"},{name:"transporter",person:"Scotty"},{name:"shuttlecraft",person:"Scotty"},{name:"*ERR 14*",person:"Nobody"},{name:"*ERR 15*",person:"Nobody"}],b6=["GREEN","DOCKED","YELLOW","RED"];function xh(t,e){return(Math.atan2(e.y-t.y,-(e.x-t.x))*180/Math.PI+360)%360}function ad(t,e){return Math.hypot(e.x-t.x,e.y-t.y)}function M6(t){switch(t){case G1:case a6:return"ship";case l6:return"klingon";case o6:return"base";case r6:return"star";case c6:return"inhabited";case P1:return"hole";default:return"empty"}}function v6(t){const e=new Map;for(const s of t)(s.evcode&u6)!==h6||(s.evcode&d6)!==0||e.set(s.systemname,s.date);return _6.map((s,i)=>({index:i,name:s.name,person:s.person,repairAt:e.get(i)??null})).filter(s=>!s.name.startsWith("*"))}function w6(t){const e=t.Etc.nkling;switch(t.Ship.cond){case g6:return e===1?"1 Klingon in this quadrant":`${e} Klingons in this quadrant`;case m6:return t.Ship.energy<t.Param.energylow?"energy low":"Klingons near";case p6:return"docked at a starbase";case f6:default:return"all clear"}}function y6(t){const{Ship:e,Now:s,Game:i,Param:n,Etc:r,Sect:o,Quad:a}=t,l={x:e.quadx,y:e.quady},c={x:e.sectx,y:e.secty},h=[];for(let m=0;m<Ss;m++){const w=[];for(let y=0;y<Ss;y++){const b=o[m]?.[y]??P1;w.push({x:m,y,kind:M6(b),glyph:b})}h.push(w)}const d=r.klingon.slice(0,r.nkling).map(m=>({x:m.x,y:m.y,bearing:xh(c,m),range:ad(c,m),power:m.power,mark:null})).sort((m,w)=>m.range-w.range),u=s.base.slice(0,s.bases).map(m=>({x:m.x,y:m.y}));let p=null;for(const m of u){const w=ad(l,m);(p===null||w<p.range)&&(p={at:m,range:w,here:w===0})}const f=[];for(let m=0;m<Ul;m++){const w=[];for(let y=0;y<Ul;y++){const v=a[m]?.[y]?.scanned??-1,z=v<0?null:v>=1e3?"///":String(v).padStart(3,"0");w.push({x:m,y,here:m===l.x&&y===l.y,code:z,supernova:v>=1e3,klingons:v<0||v>=1e3?0:Math.floor(v/100),bases:v<0||v>=1e3?0:Math.floor(v%100/10)})}f.push(w)}const _=v6(t.Event),g=_.filter(m=>m.repairAt!==null).sort((m,w)=>(m.repairAt??0)-(w.repairAt??0));return{condition:{name:b6[e.cond]??"GREEN",why:w6(t)},ship:{shipName:e.shipname,energy:e.energy,energyMax:n.energy,shield:e.shield,shieldMax:n.shield,shieldsUp:e.shldup!==0,cloaked:e.cloaked!==0,torpedoes:e.torped,torpedoesMax:n.torped,reserves:e.reserves,reservesMax:n.reserves,crew:e.crew,warp:e.warp},mission:{stardate:s.date,timeLeft:s.time,klingonsLeft:s.klings,klingonsStart:n.klings,killed:i.killk,captives:i.captives,starbases:s.bases},position:{quadrant:l,sector:c},sectors:h,klingons:d,bases:u,nearestBase:p,chart:f,devices:_,damaged:g,game:{killk:i.killk,killb:i.killb,kills:i.kills,killinhab:i.killinhab,helps:i.helps,captives:i.captives,deaths:i.deaths,killed:i.killed!==0,skill:i.skill,won:t.Move.endgame>0,abandoned:e.ship!==G1},param:{warptime:n.warptime,dockfac:n.dockfac,klingpwr:n.klingpwr,date:n.date}}}const z6=["novice","fair","good","expert","commodore","impossible"];function L1(t){const{game:e,mission:s,param:i}=t,n=[];n.push({label:`${e.killk} Klingons killed`,points:Math.trunc(i.klingpwr/4)*e.killk});const r=Math.max(1,s.stardate-i.date),o=e.killk/r;return n.push({label:`kill rate ${o.toFixed(2)} Klingons/stardate`,points:Math.trunc(400*o)}),n.push({label:`penalty for ${s.klingonsLeft} Klingons remaining`,points:Math.trunc(-400*s.klingonsLeft/(e.killk+1))}),e.won&&n.push({label:`bonus for winning a ${z6[e.skill-1]??""} game`,points:100*e.skill}),e.killed&&n.push({label:"penalty for getting killed",points:-500}),n.push({label:`${e.killb} starbases killed`,points:-100*e.killb}),n.push({label:`${e.helps} calls for help`,points:-100*e.helps}),n.push({label:`${e.kills} stars destroyed`,points:-5*e.kills}),n.push({label:`${e.killinhab} inhabited starsystems destroyed`,points:-150*e.killinhab}),e.abandoned&&n.push({label:"penalty for abandoning ship",points:-200}),n.push({label:`${e.captives} Klingons captured`,points:3*e.captives}),n.push({label:`${e.deaths} casualties`,points:-e.deaths}),{items:n,total:n.reduce((a,l)=>a+l.points,0)}}function zv(t,e){const{quadrant:s,sector:i}=t.position,n=s.x+i.x/Ss-(e.quadrant.x+e.sector.x/Ss),r=e.quadrant.y+e.sector.y/Ss-(s.y+i.y/Ss);let o=Math.atan2(r,n);return o<0&&(o+=2*Math.PI),{course:Math.trunc(o*180/Math.PI+.5)%360,distance:Math.hypot(n,r)}}function S6(t,e,s){const{quadrant:i,sector:n}=t.position,r=e*Math.PI/180,o=Math.min(Ul*Ss-1,Math.max(0,Math.round(i.x*Ss+n.x-Math.cos(r)*s*Ss))),a=Math.min(Ul*Ss-1,Math.max(0,Math.round(i.y*Ss+n.y+Math.sin(r)*s*Ss)));return{quadrant:{x:Math.trunc(o/Ss),y:Math.trunc(a/Ss)},sector:{x:o%Ss,y:a%Ss}}}function W1(t,e,s){const i=Math.trunc((t+.05)*e*e*e);return{stardates:s*t/(e*e),units:i,unitsShielded:2*i}}function x6(t){return{stardates:t/.095,units:Math.trunc(20+100*t)}}function F1(t){return Math.trunc(Math.pow(.9,t*10)*98+.5)}function Sv(t,e){if(t.repairAt===null)return null;const s=t.repairAt-e.mission.stardate,i=e.condition.name==="DOCKED",n=i?1/e.param.dockfac:1,r=i?1:e.param.dockfac;return{inFlight:s*n+.005,docked:s*r+.005}}function U1(t,e){const s=[],i=(d,u)=>`${d>0?"+":d<0?"−":""}${Math.abs(d).toFixed(u)}`,n=e.mission.stardate-t.mission.stardate;Math.abs(n)>=.005&&s.push({label:"STARDATE",change:i(n,2),bad:!1});const r=e.ship.energy-t.ship.energy;r!==0&&s.push({label:"ENERGY",change:i(r,0),bad:r<0});const o=e.ship.shield-t.ship.shield;o!==0&&s.push({label:"SHIELDS",change:i(o,0),bad:o<0});const a=e.ship.torpedoes-t.ship.torpedoes;a!==0&&s.push({label:"TORPEDOES",change:i(a,0),bad:!1});const l=e.mission.klingonsLeft-t.mission.klingonsLeft;l!==0&&s.push({label:"KLINGONS",change:`${i(l,0)} · ${e.mission.klingonsLeft} LEFT`,bad:l>0});const c=e.damaged.filter(d=>!t.damaged.some(u=>u.index===d.index));c.length>0&&s.push({label:"DAMAGE",change:c.map(d=>d.name.toUpperCase()).join(" · "),bad:!0});const h=t.damaged.filter(d=>!e.damaged.some(u=>u.index===d.index));return h.length>0&&s.push({label:"REPAIRED",change:h.map(d=>d.name.toUpperCase()).join(" · "),bad:!1}),t.condition.name!==e.condition.name&&s.push({label:"CONDITION",change:e.condition.name,bad:e.condition.name==="RED"}),s}const O6=[["return to continue","return"],["What length game","length"],["What skill game","skill"],["Enter password verification","password-verify"],["Enter a password","password"],["Enter tournament code","tournament"],["Command","command"],["Torpedo course","torpedo-course"],["Course","course"],["course","bank-course"],["Distance","distance"],["distance","computer-distance"],["Warp factor","warp-factor"],["warp factor","computer-warp"],["How long","how-long"],["Manual or automatic","manual-automatic"],["Units to fire","units"],["units","bank-units"],["spread","spread"],["Do you want a burst","burst"],["burst angle","burst-angle"],["Up or down","up-down"],["Request","request"],["Quadrant","quadrant"],["q-y","quadrant-y"],["Sector","sector"],["s-y","sector-y"],["range","range"],["direction","direction"],["status report","status-report"],["Another game","another"]];function E6(t){const e=t.replace(/[:.\s]+$/,"");if(e==="")return"return";for(const[s,i]of O6)if(e.endsWith(s))return i;return/wise$|certain that is wise$|Shall we cancel our rest period$/.test(e)?"yes-no":"unknown"}const Pd=[{id:"move",label:"MOVE",station:"helm",line:"m",asks:["course","distance"]},{id:"ram",label:"RAM",station:"helm",line:"ram",asks:["course","distance"]},{id:"warp",label:"WARP",station:"helm",line:"w",asks:["warp-factor"]},{id:"impulse",label:"IMPULSE",station:"helm",line:"i",asks:["course","distance"]},{id:"dock",label:"DOCK",station:"helm",line:"do",asks:[]},{id:"undock",label:"UNDOCK",station:"helm",line:"u",asks:[]},{id:"rest",label:"REST",station:"helm",line:"r",asks:["how-long"]},{id:"phasers",label:"PHASERS",station:"tactical",line:"p",asks:["manual-automatic","units"]},{id:"torpedo",label:"TORPEDO",station:"tactical",line:"t",asks:["torpedo-course","burst","burst-angle"]},{id:"shields",label:"SHIELDS",station:"tactical",line:"sh",asks:["up-down"]},{id:"cloak",label:"CLOAK",station:"tactical",line:"cl",asks:["up-down"]},{id:"capture",label:"CAPTURE",station:"tactical",line:"ca",asks:[]},{id:"visual",label:"VISUAL",station:"tactical",line:"v",asks:["direction"]},{id:"computer",label:"COMPUTER",station:"ship",line:"c",asks:["request"]},{id:"help",label:"CALL STARBASE",station:"ship",line:"help",asks:[]},{id:"dump",label:"DUMP",station:"ship",line:"dump",asks:[]},{id:"credits",label:"CREDITS",station:"ship",line:"cr",asks:[]},{id:"abandon",label:"ABANDON",station:"ship",line:"abandon",asks:[],grave:!0},{id:"destruct",label:"DESTRUCT",station:"ship",line:"destruct",asks:["password-verify"],grave:!0},{id:"terminate",label:"TERMINATE",station:"ship",line:"terminate",asks:[],grave:!0}];function xs(t,e){switch(t){case"return":return{kind:"auto"};case"length":return{kind:"pills",choices:[{label:"SHORT",line:"s"},{label:"MEDIUM",line:"m"},{label:"LONG",line:"l"},{label:"RESTART",line:"restart"}]};case"skill":return{kind:"pills",choices:[{label:"NOVICE",line:"n"},{label:"FAIR",line:"f"},{label:"GOOD",line:"g"},{label:"EXPERT",line:"e"},{label:"COMMODORE",line:"c"},{label:"IMPOSSIBLE",line:"i"}]};case"password":case"tournament":case"password-verify":return{kind:"auto"};case"course":case"torpedo-course":case"direction":case"bank-course":return{kind:"wheel",min:0,max:360,step:1,commit:"SET COURSE",cancel:"-1"};case"distance":return{kind:"slider",min:0,max:15,step:.1,commit:"ENGAGE",cancel:"-1"};case"computer-distance":case"range":return{kind:"slider",min:0,max:15,step:.1,commit:"SET"};case"warp-factor":return{kind:"slider",min:1,max:10,step:.1,commit:"SET WARP",cancel:"-1"};case"computer-warp":return{kind:"slider",min:1,max:10,step:.1,commit:"SET"};case"how-long":return{kind:"slider",min:0,max:Math.max(.1,e?.mission.timeLeft??15),step:.1,commit:"REST",cancel:"0"};case"manual-automatic":return{kind:"pills",choices:[{label:"MANUAL",line:"m"},{label:"AUTOMATIC",line:"a"}]};case"units":return{kind:"slider",min:0,max:Math.max(10,e?.ship.energy??5e3),step:10,commit:"FIRE",cancel:"0"};case"bank-units":return{kind:"slider",min:0,max:Math.max(10,e?.ship.energy??5e3),step:10,commit:"SET",cancel:"0"};case"spread":return{kind:"slider",min:0,max:1,step:.05,commit:"SET"};case"burst":case"status-report":case"another":case"yes-no":return{kind:"yesno",choices:[{label:"YES",line:"y"},{label:"NO",line:"n"}]};case"burst-angle":return{kind:"pills",choices:[1,2,3,5,8,10,12,15].map(s=>({label:`${s}°`,line:String(s)})),cancel:"0"};case"up-down":return{kind:"pills",choices:[{label:"UP",line:"u"},{label:"DOWN",line:"d"}]};case"request":return{kind:"pills",choices:[{label:"CHART",line:"ch"},{label:"TRAJECTORY",line:"t"},{label:"COURSE",line:"c"},{label:"MOVE",line:"m"},{label:"SCORE",line:"s"},{label:"PHASER EFFECT",line:"p"},{label:"WARP COST",line:"w"},{label:"IMPULSE COST",line:"i"},{label:"DISTRESS LIST",line:"d"}]};case"quadrant":case"quadrant-y":return{kind:"slider",min:0,max:Ul-1,step:1,commit:"SET"};case"sector":case"sector-y":return{kind:"slider",min:0,max:Ss-1,step:1,commit:"SET"};default:return{kind:"text"}}}function A6(){return`argus${Math.floor(Math.random()*9e3+1e3)}`}class T6{constructor(e){this.hooks=e}hooks;open=null;lastCommand=null;password=A6();ended=!1;ask(e){const s=E6(e);return s==="return"?Promise.resolve(""):s==="password"||s==="tournament"||s==="password-verify"?Promise.resolve(this.password):(s==="command"&&(this.lastCommand=null),new Promise(i=>{this.open={question:{prompt:e,question:s,command:this.lastCommand},answer:i},this.hooks.question_changed(this.open.question)}))}question_get(){return this.open?.question??null}answer(e){if(this.open===null)return!1;const{answer:s}=this.open;return this.open=null,this.hooks.question_changed(null),s(e),!0}command_send(e){return this.open?.question.question!=="command"?!1:(this.lastCommand=e,this.answer(e.line))}abandon(){if(this.open===null)return!1;const{answer:e}=this.open;return this.open=null,this.hooks.question_changed(null),e(null),!0}text_take(e){this.hooks.text_written(e)}event_take(e,s){e==="games.trek.state"&&typeof s=="object"&&s!==null&&this.hooks.state_shown(s)}end(e){this.ended||(this.ended=!0,this.open=null,this.hooks.ended(e))}ended_is(){return this.ended}}const Un={torpedoPoint:140,sector:170,burst:800,beam:900,rescan:350,flare:900,tail:300},I6=[[/^Torpedo track(?:, torpedo number \d+)?:/,()=>({kind:"torpedo-head"})],[/^\s*(\d+\.\d)\s+(\d+\.\d)\s*$/,t=>({kind:"torpedo-point",at:{x:Number(t[1]),y:Number(t[2])}})],[/^Torpedo missed|^Torpedo disappears into a black hole/,()=>({kind:"torpedo-end"})],[/\*\*\* Klingon at (\d+),(\d+) destroyed \*\*\*/,t=>({kind:"kill",at:ui(t,1)})],[/^Starbase at (\d+),(\d+) destroyed/,t=>({kind:"kill",at:ui(t,1)})],[/^Inhabited starsystem .* at (\d+),(\d+) destroyed/,t=>({kind:"kill",at:ui(t,1)})],[/^Unknown object . at (\d+),(\d+) destroyed/,t=>({kind:"kill",at:ui(t,1)})],[/Star at (\d+),(\d+) gone nova/,t=>({kind:"nova",at:ui(t,1)})],[/^Photon tubes misfire/,()=>({kind:"misfire"})],[/^(\d+) unit hit on Klingon at (\d+),(\d+)/,t=>({kind:"phaser",at:ui(t,2)})],[/^HIT: (\d+) units(?: from (\d+),(\d+))?(?:, shields absorb (\d+)%)?/,t=>({kind:"incoming",hit:Number(t[1]),from:t[2]===void 0?null:ui(t,2),absorb:t[4]===void 0?0:Number(t[4])})],[/^Klingon at (\d+),(\d+) moves to (\d+),(\d+)/,t=>({kind:"klingon-move",from:ui(t,1),to:ui(t,3)})],[/^Klingon at (\d+),(\d+) escapes to quadrant (\d+),(\d+)/,t=>({kind:"klingon-escape",from:ui(t,1),quadrant:ui(t,3)})],[/RED ALERT: supernova occurring at (\d+),(\d+)/,t=>({kind:"supernova",at:ui(t,1)})],[/^\s*in quadrant (\d+),(\d+)\.\s+Caution is advised/,t=>({kind:"supernova-report",quadrant:ui(t,1)})]];function ui(t,e){return{x:Number(t[e]),y:Number(t[e+1])}}function D6(t){for(const[e,s]of I6){const i=e.exec(t);if(i!==null)return s(i)}return null}class C6{constructor(e=R6){this.reduced=e}reduced;frames=[];running=!1;skipping=!1;waiting=new Set;played={};push(e){this.frames.push(e),this.pump()}skip(){if(!(this.frames.length===0&&!this.running)){this.skipping=!0;for(const e of this.waiting)e();this.waiting.clear()}}busy_is(){return this.running||this.frames.length>0}pending_count(){return this.frames.length}skipping_is(){return this.skipping}async settle(){for(;this.busy_is();)await new Promise(e=>{setTimeout(e,1)})}wait(e){return this.skipping||e<=0?Promise.resolve():new Promise(s=>{const i=setTimeout(()=>{this.waiting.delete(n),s()},e),n=()=>{clearTimeout(i),s()};this.waiting.add(n)})}async tween(e,s){const i=xv();for(;!this.skipping;){const n=Math.min(1,(xv()-i)/Math.max(1,e));if(s(n),n>=1)return;await k6(this)}s(1)}async pump(){if(!this.running){this.running=!0;try{for(;this.frames.length>0;){const e=this.frames.shift();this.played[e.kind]=(this.played[e.kind]??0)+1;const s=this.skipping||this.reduced();try{await e.run(s)}catch{}}}finally{this.running=!1,this.skipping=!1}}}}function R6(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function xv(){return typeof performance=="object"?performance.now():Date.now()}function k6(t){return typeof requestAnimationFrame=="function"?new Promise(e=>{requestAnimationFrame(()=>e())}):t.wait(16)}function ya(t){return[t.y+.5,t.x+.5]}function $1(t,e){return(Math.atan2(e.y-t.y,-(e.x-t.x))*180/Math.PI+360)%360}function N6(t,e,s=10){const i={x:t.quadrant.x*s+t.sector.x,y:t.quadrant.y*s+t.sector.y},n={x:e.quadrant.x*s+e.sector.x,y:e.quadrant.y*s+e.sector.y},r={x:n.x-i.x,y:n.y-i.y},o=(p,f,_)=>{let g=_?1/0:-1/0;for(const m of["x","y"]){if(r[m]===0)continue;const w=p[m]*s-.5,y=p[m]*s+s-.5,b=(w-f[m])/r[m],v=(y-f[m])/r[m];_?g=Math.min(g,Math.max(b,v)):g=Math.max(g,Math.min(b,v))}return Number.isFinite(g)?Math.max(0,Math.min(1,g)):_?1:0},a=o(t.quadrant,i,!0),l=o(e.quadrant,i,!1),c=.7,h={x:i.x+r.x*a-t.quadrant.x*s,y:i.y+r.y*a-t.quadrant.y*s},d={x:i.x+r.x*l-e.quadrant.x*s,y:i.y+r.y*l-e.quadrant.y*s},u=Math.hypot(r.x,r.y)||1;return{exit:{x:h.x+r.x/u*c,y:h.y+r.y/u*c},entry:{x:d.x-r.x/u*c,y:d.y-r.y/u*c}}}function Ld(t,e=""){const s=st("g",{class:`tb-motion ${e}`.trim()});return t.append(s),s}const B6=.7;async function tl(t,e,s,i,n,r={},o=!1){if(o)return;const a=Ld(t,"tb-motion-slide"),[l,c]=ya(i),[h,d]=ya(n),u=r.hostile===!0?" tb-hostile":"";a.append(st("line",{class:`tb-track${u}`,x1:l,y1:c,x2:h,y2:d}));const p=st("line",{class:`tb-pulse tb-pulse-wide${u}`,x1:l,y1:c,x2:l,y2:c}),f=st("line",{class:`tb-pulse tb-pulse-core${u}`,x1:l,y1:c,x2:l,y2:c}),_=r.heading??$1(i,n),g=c_(s.kind,{cx:l,cy:c,size:B6},s.variant,_);g.classList.add(`tb-sector-${s.kind}`),a.append(p,f,g);const m=Math.max(1,Math.hypot(n.x-i.x,n.y-i.y));await e.tween(m*Un.sector,w=>{const y=l+(h-l)*w,b=c+(d-c)*w,v=Math.max(0,w-.12),z=l+(h-l)*v,x=c+(d-c)*v;for(const M of[p,f])M.setAttribute("x1",String(z)),M.setAttribute("y1",String(x)),M.setAttribute("x2",String(y)),M.setAttribute("y2",String(b));N1(g,y,b,_)}),a.remove()}async function Ov(t,e,s,i,n,r=!1){if(r)return;const o=Ld(t,"tb-motion-beam"),[a,l]=ya(s),[c,h]=ya(i),d=n?" tb-hostile":"";o.append(st("line",{class:`tb-beam${d}`,x1:a,y1:l,x2:c,y2:h}),st("line",{class:`tb-beam tb-beam-core${d}`,x1:a,y1:l,x2:c,y2:h})),await e.wait(Un.beam),o.remove()}async function eh(t,e,s,i,n=!1){if(n)return;const r=Ld(t,`tb-motion-burst tb-burst tb-burst-${i}`),[o,a]=ya(s),l=i==="misfire"?Un.burst*.6:i==="supernova"?Un.burst*1.6:Un.burst;r.style.setProperty("--tb-ms",`${l}ms`),r.append(st("circle",{class:"tb-burst-halo",cx:o,cy:a,r:.1}));const c=st("g",{class:"tb-burst-spikes"}),h=i==="nova"||i==="supernova"?12:8,d=i==="misfire"?.6:i==="supernova"?1.8:i==="nova"?1.1:.95;for(let u=0;u<h;u++){const p=u/h*Math.PI*2+(h===8?Math.PI/8:0);c.append(st("line",{class:"tb-burst-spike",x1:o+Math.cos(p)*.12,y1:a+Math.sin(p)*.12,x2:o+Math.cos(p)*d,y2:a+Math.sin(p)*d}))}r.append(c,st("circle",{class:"tb-burst-core",cx:o,cy:a,r:.04})),await e.wait(l),r.remove()}async function G6(t,e,s=!1){if(s)return;const i=t.querySelector(".tb-ring");if(i===null)return;const n=st("circle",{class:"tb-motion tb-ring-flare",cx:i.getAttribute("cx")??0,cy:i.getAttribute("cy")??0,r:.46});t.append(n),await e.wait(Un.flare),n.remove()}class P6{layer;tail;photon;points=[];constructor(e,s){this.layer=Ld(e,"tb-motion-torpedo"),this.tail=st("g",{class:"tb-tail"}),this.photon=st("g",{class:"tb-photon"}),this.photon.append(st("circle",{class:"tb-photon-halo",cx:0,cy:0,r:.34}));const i=st("g",{class:"tb-photon-pulses"});for(let o=0;o<10;o++){const a=st("g",{transform:`rotate(${o*36})`});a.append(st("rect",{x:.08,y:-.016,width:.2+o%3*.05,height:.032,rx:.006})),i.append(a)}this.photon.append(i,st("circle",{class:"tb-photon-core",cx:0,cy:0,r:.12})),this.layer.append(this.tail,this.photon);const[n,r]=ya(s);this.points.push([n,r]),this.photon.setAttribute("transform",`translate(${n} ${r})`)}async point_reach(e,s,i=!1){const[n,r]=[s.y,s.x];this.points.push([n,r]),this.photon.setAttribute("transform",`translate(${n} ${r})`),this.tail.replaceChildren();const o=this.points.slice(-4);for(let a=1;a<o.length;a++){const[l,c]=o[a-1],[h,d]=o[a];this.tail.append(st("line",{class:"tb-tail-segment",x1:l,y1:c,x2:h,y2:d,"stroke-width":.03+.03*a,opacity:.25+.25*a}))}i||await e.wait(Un.torpedoPoint)}async end(e,s=!1){this.photon.remove(),s||await e.wait(Un.tail),this.layer.remove()}}function Ev(t,e){t.classList.toggle("tb-rescan",e)}function L6(t,e){t.classList.remove("tb-bloom","tb-bloom-hostile"),t.offsetWidth,t.classList.add("tb-bloom"),e&&t.classList.add("tb-bloom-hostile"),t.addEventListener("animationend",()=>t.classList.remove("tb-bloom","tb-bloom-hostile"),{once:!0})}function gi(t,e){return t!==null&&e.includes(t.question)}function Wd(t,e){const s=q("div","tb-station-head"),i=q("span","tb-station-step",""),n=Os("tb-grave tb-cancel","CANCEL",()=>{e.answer_send(n.dataset.line??"","CANCEL")});return n.hidden=!0,s.append(q("span","tb-station-name",t),i,q("span","tb-station-fill"),n),{root:s,step:i,cancel:n}}function Fd(t,e,s,i){const n=s?.command??null,r=n!==null&&n.station===e&&s!==null&&s.question!=="command";t.step.textContent=r&&n!==null&&s!==null?`${n.label} · ${s.question.replace(/-/g," ").toUpperCase()}`:s?.question==="command"?"READY":"";const o=r?i?.cancel:void 0;t.cancel.hidden=o===void 0,t.cancel.dataset.line=o??"",t.cancel.textContent=n===null?"CANCEL":`CANCEL ${n.label}`}function d_(t,e){const s=Os(`tb-command${t.grave===!0?" tb-grave":""}`,t.label,()=>{e.command_send(t)});return s.dataset.command=t.id,s}function j1(t,e){const s=q("div","tb-pills tb-command-pills"),i=new Map;for(const n of Pd.filter(r=>r.station===t)){const r=d_(n,e);i.set(n.id,r),s.append(r)}return{root:s,pills:i}}function Ud(t,e){for(const[s,i]of t)i.disabled=e?.question!=="command",i.classList.toggle("tb-pill-on",e?.command?.id===s)}function H1(t,e){const s=Os("tb-target","",e);return s.append(h_("klingon",t.mark),document.createTextNode(`${t.x},${t.y}`)),s.title=`Klingon at ${t.x},${t.y}`,s}function dm(t,e){const s=q("span",t,e.supernova?"":e.code??"");return e.supernova&&s.append(h_("supernova")),s}function um(t){return`quadrant ${t.x},${t.y}${t.supernova?" · supernova":t.code===null?" · unscanned":""}`}function V1(t){const e=t.klingons.map(s=>({bearing:s.bearing,kind:"klingon",label:`Klingon at ${s.x},${s.y} · ${s.range.toFixed(1)} · ${Math.round(s.bearing)}°`,variant:s.mark}));for(const s of t.sectors)for(const i of s){if(i.kind!=="base")continue;const n=i.x-t.position.sector.x,r=i.y-t.position.sector.y;e.push({bearing:(Math.atan2(r,-n)*180/Math.PI+360)%360,kind:"base",label:`starbase at ${i.x},${i.y}`})}return e}class Av{root;wheel;distance;warp;rest;head;pills;readout=null;constructor(e,s,i){this.root=q("div","tb-station tb-station-helm"),this.head=Wd("HELM",e);const n=j1("helm",e);this.pills=n.pills;const r=q("div","tb-controls");this.wheel=new B1(s,"course wheel",a=>e.answer_send(String(a),"SET COURSE"));const o=q("div","tb-sliders");this.distance=new xr(`${i}-distance`,"DISTANCE",1,a=>e.answer_send(a.toFixed(1),"SLIDER SET")),this.warp=new xr(`${i}-warp`,"WARP FACTOR",1,a=>e.answer_send(a.toFixed(1),"SLIDER SET")),this.rest=new xr(`${i}-rest`,"REST",1,a=>e.answer_send(a.toFixed(1),"SLIDER SET")),this.distance.input_listen(()=>this.arrival_note()),o.append(this.distance.root,this.warp.root,this.rest.root),r.append(this.wheel.root,o),this.root.append(this.head.root,n.root,r)}state_show(e){const s=this.readout===null;this.readout=e,this.wheel.marks_set(V1(e)),this.warp.range_set(xs("warp-factor",e),e.ship.warp,"THE SHIP NOW · ABOVE 6 THE ENGINES MAY BURN",10),this.distance.range_set(xs("distance",e),s?1:this.distance.value_get(),"QUADRANTS · 0.1 IS ONE SECTOR",6),this.rest.range_set(xs("how-long",e),0,`STARDATES · ${e.mission.timeLeft.toFixed(1)} LEFT · REPAIRS RUN WHILE TIME PASSES`,2)}question_show(e){Ud(this.pills,e);const s=e===null?null:xs(e.question,this.readout);Fd(this.head,"helm",e,s),this.wheel.lit_set(gi(e,["course","direction"]),"SET COURSE"),this.distance.lit_set(gi(e,["distance"]),"ENGAGE"),this.warp.lit_set(gi(e,["warp-factor"]),"SET WARP"),this.rest.lit_set(gi(e,["how-long"]),"REST"),e?.question==="distance"&&this.arrival_note()}arrival_note(){if(this.readout===null)return;const e=this.distance.value_get(),s=S6(this.readout,this.wheel.degrees_get(),e),i=W1(e,this.readout.ship.warp,this.readout.param.warptime);this.distance.note_set(`ARRIVES ${s.quadrant.x},${s.quadrant.y} / ${s.sector.x},${s.sector.y} · ${i.stardates.toFixed(2)} STARDATES AT WARP ${this.readout.ship.warp.toFixed(1)} · ${i.units} UNITS`)}}class Tv{constructor(e,s,i){this.host=e,this.root=q("div","tb-station tb-station-tactical"),this.head=Wd("TACTICAL",e);const n=j1("tactical",e);this.pills=n.pills;const r=q("div","tb-controls");this.wheel=new B1(s,"firing course wheel",l=>e.answer_send(String(l),"SET COURSE"));const o=q("div","tb-sliders");this.burst=new Qc("BURST",xs("burst",null).choices??[],(l,c)=>e.answer_send(l,gr(c,"choice"))),this.burstAngle=new Qc("BURST ANGLE",xs("burst-angle",null).choices??[],(l,c)=>{this.wheel.wedge_set(Number(l)),e.answer_send(l,gr(c,"choice"))}),this.manual=new Qc("PHASERS",xs("manual-automatic",null).choices??[],(l,c)=>e.answer_send(l,gr(c,"choice"))),this.units=new xr(`${i}-units`,"UNITS",0,l=>e.answer_send(String(Math.round(l)),"SLIDER SET")),this.spread=new xr(`${i}-spread`,"SPREAD",2,l=>e.answer_send(l.toFixed(2),"SLIDER SET")),this.upDown=new Qc("SHIELDS",xs("up-down",null).choices??[],(l,c)=>e.answer_send(l,gr(c,"choice")));const a=q("div","tb-fire-row");this.fire=Os("tb-fire","FIRE",()=>e.answer_send("0",null)),this.targets=q("div","tb-targets"),a.append(this.fire,this.targets),o.append(this.burst.root,this.burstAngle.root,this.manual.root,this.units.root,this.spread.root,this.upDown.root,a),r.append(this.wheel.root,o),this.root.append(this.head.root,n.root,r)}host;root;wheel;units;spread;head;pills;burst;burstAngle;manual;upDown;fire;targets;readout=null;state_show(e){this.readout=e,this.wheel.marks_set(V1(e)),this.wheel.wedge_set(null),e.klingons[0]!==void 0&&this.wheel.degrees_set(e.klingons[0].bearing),this.units.range_set(xs("units",e),Math.min(e.ship.energy,Math.round(e.ship.energy/100)*10),`UP TO THE ${e.ship.energy} FREE`,6),this.spread.range_set(xs("spread",e),.5,"MANUAL PHASERS ONLY",3),this.burst.note_set(`${e.ship.torpedoes} TORPEDOES · A BURST FIRES 3`),this.upDown.note_set(`${e.ship.shieldsUp?"UP":"DOWN"} · ${e.ship.shield} OF ${e.ship.shieldMax} · REFILLS AT A STARBASE`);const s=this.pills.get("phasers");s!==void 0&&(s.classList.toggle("tb-barred",e.ship.shieldsUp),s.title=e.ship.shieldsUp?"Shields are up: phasers cannot fire through them. SHIELDS, then DOWN, first.":""),this.targets_draw(e)}question_show(e){Ud(this.pills,e);const s=e===null?null:xs(e.question,this.readout);Fd(this.head,"tactical",e,s),this.wheel.lit_set(gi(e,["torpedo-course","bank-course"]),"SET COURSE"),this.burst.lit_set(gi(e,["burst"])),this.burstAngle.lit_set(gi(e,["burst-angle"])),this.manual.lit_set(gi(e,["manual-automatic"])),this.units.lit_set(gi(e,["units","bank-units"]),e?.question==="units"?"FIRE":"SET BANK"),this.spread.lit_set(gi(e,["spread"])),this.upDown.lit_set(gi(e,["up-down"])),this.fire.disabled=!gi(e,["bank-units"]),this.fire.textContent="FIRE THE BANKS SET"}targets_draw(e){if(this.targets.replaceChildren(),e.klingons.length===0){this.targets.append(q("span","tb-note","NO KLINGONS IN THIS QUADRANT"));return}for(const s of["TARGET","RANGE","BEARING","PHASER HIT"])this.targets.append(q("span","tb-target-head",s));for(const s of e.klingons){const i=H1(s,()=>{this.host.voice.cue("scanner"),this.host.course_set(s.bearing,s.range/10)});this.targets.append(i,q("span","tb-target-cell",s.range.toFixed(1)),q("span","tb-target-cell",`${Math.round(s.bearing)}°`),q("span","tb-target-cell",`${F1(s.range/10)}%`))}}}class W6{root;rest;head;pills;damage;systems;since;inThatTime;readout=null;constructor(e){this.root=q("div","tb-view-body tb-view-engineering");const s=q("section","tb-panel tb-damage");s.append(q("span","tb-title","DAMAGE CONTROL"),q("span","tb-note","THE C'S REPORT · ALWAYS ON")),this.damage=q("div","tb-dc"),s.append(this.damage,q("span","tb-note","REPAIR TIMES IN STARDATES · REPAIRS RUN WHILE TIME PASSES · DOCKED, FASTER BY THE DOCK FACTOR"));const i=q("section","tb-panel tb-systems-section");i.append(q("span","tb-title","SHIP"),q("span","tb-note","ENERGY, SHIELDS, RESERVES")),this.systems=q("div","tb-systems"),i.append(this.systems,q("span","tb-title","SINCE THE LAST COMMAND")),this.since=q("div","tb-head-grid tb-since-grid"),i.append(this.since,q("span","tb-note","SHIELDS ARE UP OR DOWN IN TREK(6): THEIR ENERGY IS A READOUT, REFILLED AT A STARBASE"));const n=q("section","tb-panel tb-station tb-station-time");this.head=Wd("REST",e);const r=q("div","tb-pills tb-command-pills");this.pills=new Map;for(const o of["rest","dock","undock"]){const a=Pd.find(c=>c.id===o);if(a===void 0)continue;const l=d_(a,e);this.pills.set(o,l),r.append(l)}this.rest=new xr("tbe-rest","HOW LONG",1,o=>e.answer_send(o.toFixed(1),"SLIDER SET")),this.rest.input_listen(()=>this.inThatTime_note()),this.inThatTime=q("div","tb-in-that-time"),n.append(this.head.root,r,this.rest.root,q("span","tb-title","IN THAT TIME"),this.inThatTime),this.root.append(s,i,n)}state_show(e,s){this.readout=e,this.damage_draw(e),this.systems_draw(e),this.since.replaceChildren();const i=s===null?[]:U1(s,e);i.length===0&&this.since.append(q("span","tb-head-label","—"),q("span","tb-head-value","NOTHING MOVED"));for(const n of i)this.since.append(q("span","tb-head-label",n.label),q("span",`tb-head-value ${n.bad?"tb-bad":"tb-good"}`,n.change));this.rest.range_set(xs("how-long",e),this.rest.value_get(),`STARDATES · ${e.mission.timeLeft.toFixed(1)} LEFT`,4),this.inThatTime_note()}question_show(e){Ud(this.pills,e);const s=e===null?null:xs(e.question,this.readout),i=e!==null&&(e.command===null||["rest","dock","undock"].includes(e.command.id))?e:null;Fd(this.head,"helm",i,s),this.rest.lit_set(gi(e,["how-long"]),"REST")}damage_draw(e){this.damage.replaceChildren();for(const i of["DEVICE","","IN FLIGHT","DOCKED",""])this.damage.append(q("span","tb-dc-head",i));const s=Math.max(1,...e.damaged.map(i=>(i.repairAt??0)-e.mission.stardate));for(const i of e.devices){const n=Sv(i,e),r=q("div","tb-bar-track"),o=q("div",`tb-bar-fill${n===null?" tb-bar-ok":" tb-bar-down"}`);o.style.width=n===null?"100%":`${Math.max(4,Math.min(100,Math.round(100*((i.repairAt??0)-e.mission.stardate)/s)))}%`,r.append(o),this.damage.append(q("span",`tb-dc-name${n===null?"":" tb-bad"}`,i.name.toUpperCase()),r,q("span","tb-dc-time",n===null?"—":n.inFlight.toFixed(2)),q("span","tb-dc-time",n===null?"—":n.docked.toFixed(2)),q("span",`tb-dc-state${n===null?" tb-good":" tb-bad"}`,n===null?"OK":"DOWN"))}}systems_draw(e){const{ship:s}=e;this.systems.replaceChildren();const i=(l,c,h,d,u)=>{const p=q("div","tb-bar-track"),f=q("div",`tb-bar-fill${u?" tb-bar-down":" tb-bar-ok"}`);f.style.width=`${Math.max(0,Math.min(100,Math.round(100*c/Math.max(1,h))))}%`,p.append(f),this.systems.append(q("span","tb-dc-name",l),p,q("span","tb-dc-time tb-sys-value",d))};i("ENERGY",s.energy,s.energyMax,`${s.energy} / ${s.energyMax}`,s.energy<s.energyMax/4),i("SHIELDS",s.shield,s.shieldMax,`${s.shieldsUp?"UP":"DOWN"} · ${s.shield} / ${s.shieldMax}`,s.shield<s.shieldMax/4),i("LIFE SUPPORT",s.reserves,s.reservesMax,`RESERVES ${s.reserves.toFixed(1)} / ${s.reservesMax.toFixed(1)}`,s.reserves<s.reservesMax/4);const n=q("div","tb-pips");for(let l=0;l<s.torpedoesMax;l++)n.append(q("span",`tb-pip${l<s.torpedoes?" tb-pip-on":""}`));this.systems.append(q("span","tb-dc-name","TORPEDOES"),n,q("span","tb-dc-time tb-sys-value",`${s.torpedoes} / ${s.torpedoesMax}`));const r=(l,c)=>{this.systems.append(q("span","tb-dc-name",l),q("span","tb-sys-text",c))};r("CREW",`${s.crew}${e.mission.captives>0?` · ${e.mission.captives} CAPTIVE`:" · BRIG EMPTY"}`);const o=e.damaged.some(l=>/warp/i.test(l.name));r("WARP",`${s.warp.toFixed(1)} · ENGINES ${o?"DOWN":"OK"}`);const a=e.damaged.some(l=>/cloak/i.test(l.name));r("CLOAK",`${s.cloaked?"ON":"OFF"} · DEVICE ${a?"DOWN":"OK"}`)}inThatTime_note(){if(this.readout===null)return;const e=this.rest.value_get();this.inThatTime.replaceChildren();const s=this.readout.damaged.filter(n=>(Sv(n,this.readout)?.inFlight??1/0)<=e).map(n=>n.name.toUpperCase());this.inThatTime.append(q("span","tb-head-value tb-good",s.length===0?e>0?"NO REPAIR COMPLETES":"—":`${s.join(" · ")} REPAIRED`));const i=this.readout.klingons.length;i>0&&this.inThatTime.append(q("span","tb-head-value tb-bad",`${i} KLINGON${i===1?"":"S"} IN THE QUADRANT WILL FIRE · SPOCK MAY ASK TO CANCEL`))}}const Iv=[{label:"CHART",line:"ch",asks:[]},{label:"TRAJECTORY",line:"t",asks:[]},{label:"COURSE",line:"c",asks:["quadrant","quadrant-y","sector","sector-y"]},{label:"MOVE",line:"m",asks:["quadrant","quadrant-y","sector","sector-y"]},{label:"SCORE",line:"s",asks:[]},{label:"PHASER EFFECT",line:"p",asks:["range"]},{label:"WARP COST",line:"w",asks:["computer-distance","computer-warp"]},{label:"IMPULSE COST",line:"i",asks:["computer-distance"]},{label:"DISTRESS LIST",line:"d",asks:[]}];class F6{constructor(e){this.host=e,this.root=q("div","tb-view-body tb-view-computer");const s=q("section","tb-panel tb-chart-section");s.append(q("span","tb-title","GALAXY · WHAT THE SHIP HAS SEEN"),q("span","tb-note","PRESS A QUADRANT: THE COURSE PANEL AIMS AT IT · HUNDREDS KLINGONS, TENS BASES, ONES STARS")),this.chart=q("div","tb-chart-big"),s.append(this.chart);const i=q("section","tb-station tb-station-computer");this.head=Wd("COMPUTER",e);const n=q("div","tb-pills tb-command-pills");for(const d of Iv){const u=Os("tb-command tb-request",d.label,()=>this.request_send(d));u.dataset.request=d.line,this.requestPills.push(u),n.append(u)}const r=q("div","tb-computer-panels"),o=q("div","tb-panel");o.append(q("span","tb-title","COURSE AND DISTANCE")),this.courseGrid=q("div","tb-head-grid");const a=q("div","tb-pills");a.append(Os("tb-commit tb-send-helm","SEND TO HELM",()=>this.helm_send()),Os("tb-commit tb-move-now","MOVE THERE NOW",()=>this.request_send(Iv[3]))),o.append(this.courseGrid,a);const l=q("div","tb-panel");l.append(q("span","tb-title","WARP COST")),this.wcDistance=new xr("tbc-distance","DISTANCE",2,()=>{}),this.wcWarp=new xr("tbc-warp","WARP FACTOR",1,()=>{}),this.wcDistance.root.classList.add("tb-local"),this.wcWarp.root.classList.add("tb-local"),this.wcDistance.input_listen(()=>this.costs_note()),this.wcWarp.input_listen(()=>{this.warpTouched=!0,this.costs_note()}),this.wcResult=q("div","tb-head-grid"),l.append(this.wcDistance.root,this.wcWarp.root,this.wcResult);const c=q("div","tb-panel");c.append(q("span","tb-title","TRAJECTORY · KLINGONS HERE")),this.trajectory=q("div","tb-targets"),c.append(this.trajectory,q("span","tb-title","SCORE SO FAR")),this.score=q("div","tb-score"),c.append(this.score);const h=q("div","tb-panel tb-answer-panel");h.append(q("span","tb-title","THE COMPUTER ANSWERS")),this.answer=q("pre","tb-computer-answer","—"),h.append(this.answer),r.append(o,l,c,h),i.append(this.head.root,n,r),this.root.append(s,i)}host;root;head;chart;requestPills=[];courseGrid;wcDistance;wcWarp;wcResult;trajectory;score;answer;readout=null;target=null;open=null;warpTouched=!1;state_show(e){this.readout=e,this.target===null&&(this.target={quadrant:{...e.position.quadrant},sector:{...e.position.sector}}),this.chart_draw(e),this.wcWarp.range_set(xs("computer-warp",e),this.warpTouched?this.wcWarp.value_get():e.ship.warp,"THE SHIP'S NOW",4),this.wcDistance.range_set(xs("computer-distance",e),this.wcDistance.value_get(),"QUADRANTS · FILLED FROM THE COURSE",4),this.wcDistance.lit_set(!0,""),this.wcWarp.lit_set(!0,""),this.course_note(),this.trajectory_draw(e),this.score_draw(e)}question_show(e){this.open=e;const s=e===null?null:xs(e.question,this.readout);Fd(this.head,"ship",e,s);const i=e?.question==="command"||e?.question==="request";for(const n of this.requestPills)n.disabled=!i}answer_take(e){if(e===null){this.answer.textContent="";return}this.answer.textContent=`${this.answer.textContent??""}${e}`.replace(/^\s*\n/,"")}sector_set(e){this.readout!==null&&(this.target={quadrant:this.target?.quadrant??{...this.readout.position.quadrant},sector:{x:e.x,y:e.y}},this.course_note())}request_send(e){const s=e.asks.map(n=>[n,this.plannedAnswer_derive(n)]);if(this.open?.question==="request"){this.host.plan_set(s),this.answer_take(null),this.host.answer_send(e.line,gr(e.label,"computer")),this.host.voice.cue("thinking");return}const i=Pd.find(n=>n.id==="computer");if(i===void 0||this.open?.question!=="command"){this.host.voice.cue("deny");return}this.host.plan_set([["request",e.line],...s]),this.answer_take(null),this.host.voice.pill(gr(e.label,"computer")),this.host.command_send(i)}plannedAnswer_derive(e){const s=this.target,i=this.readout?.klingons[0];switch(e){case"quadrant":return String(s?.quadrant.x??0);case"quadrant-y":return String(s?.quadrant.y??0);case"sector":return String(s?.sector.x??0);case"sector-y":return String(s?.sector.y??0);case"range":return(i===void 0?this.wcDistance.value_get():i.range/10).toFixed(2);case"computer-distance":return this.wcDistance.value_get().toFixed(2);case"computer-warp":return this.wcWarp.value_get().toFixed(1);default:return""}}helm_send(){if(this.readout===null||this.target===null)return;const e=zv(this.readout,this.target);this.host.voice.pill("SEND TO HELM"),this.host.course_set(e.course,Math.round(e.distance*10)/10)}chart_draw(e){this.chart.replaceChildren(),this.chart.append(q("span","tb-srs-corner",""));for(let s=0;s<(e.chart[0]?.length??0);s++)this.chart.append(q("span","tb-srs-axis",String(s)));for(const s of e.chart){this.chart.append(q("span","tb-srs-axis",String(s[0]?.x??"")));for(const i of s)this.chart.append(this.quadrantButton_make(i))}}quadrantButton_make(e){const s=this.target?.quadrant.x===e.x&&this.target.quadrant.y===e.y,i=Os(`tb-cq${e.here?" tb-here":""}${e.klingons>0?" tb-hostile":""}${e.bases>0?" tb-based":""}${e.code===null?" tb-unscanned":""}${s?" tb-pressed":""}`,"",()=>{this.readout!==null&&(this.target={quadrant:{x:e.x,y:e.y},sector:this.target?.sector??{...this.readout.position.sector}},this.host.voice.cue("scanner"),this.chart_draw(this.readout),this.course_note())});return i.dataset.x=String(e.x),i.dataset.y=String(e.y),i.append(dm("tb-cq-code",e),q("span","tb-cq-at",`${e.x},${e.y}`)),i.title=um(e),i}course_note(){if(this.readout===null||this.target===null)return;const{position:e}=this.readout,s=zv(this.readout,this.target);this.courseGrid.replaceChildren(q("span","tb-head-label","FROM"),q("span","tb-head-value",`QUADRANT ${e.quadrant.x},${e.quadrant.y} · SECTOR ${e.sector.x},${e.sector.y}`),q("span","tb-head-label","TO"),q("span","tb-head-value",`QUADRANT ${this.target.quadrant.x},${this.target.quadrant.y} · SECTOR ${this.target.sector.x},${this.target.sector.y}`),q("span","tb-head-label","COURSE"),q("span","tb-head-value tb-course-value",`${s.course}°`),q("span","tb-head-label","DISTANCE"),q("span","tb-head-value tb-distance-value",s.distance.toFixed(2))),this.wcDistance.value_set(Math.round(s.distance*100)/100),this.costs_note()}costs_note(){if(this.readout===null)return;const e=this.wcDistance.value_get(),s=W1(e,this.wcWarp.value_get(),this.readout.param.warptime),i=x6(e);this.wcResult.replaceChildren(q("span","tb-head-label","TIME"),q("span","tb-head-value",`${s.stardates.toFixed(2)} STARDATES`),q("span","tb-head-label","ENERGY"),q("span","tb-head-value",`${s.units} UNITS · ${s.unitsShielded} WITH SHIELDS UP`),q("span","tb-head-label","AT IMPULSE"),q("span","tb-head-value",`${i.stardates.toFixed(2)} STARDATES · ${i.units} UNITS`))}trajectory_draw(e){if(this.trajectory.replaceChildren(),e.klingons.length===0){this.trajectory.append(q("span","tb-note","NO KLINGONS IN THIS QUADRANT"));return}for(const s of["AT","COURSE","RANGE","PHASER HIT"])this.trajectory.append(q("span","tb-target-head",s));for(const s of e.klingons)this.trajectory.append(H1(s,()=>{this.host.voice.cue("scanner"),this.host.course_set(s.bearing,s.range/10)}),q("span","tb-target-cell",`${Math.round(s.bearing)}°`),q("span","tb-target-cell",s.range.toFixed(1)),q("span","tb-target-cell",`${F1(s.range/10)}%`))}score_draw(e){const s=L1(e);this.score.replaceChildren();for(const i of s.items.filter(n=>n.points!==0||/killed|remaining/.test(n.label)))this.score.append(q("span","tb-score-label",i.label.toUpperCase()),q("span",`tb-score-points${i.points<0?" tb-bad":" tb-good"}`,`${i.points>0?"+":""}${i.points}`));this.score.append(q("span","tb-score-label tb-score-total","TOTAL"),q("span","tb-score-points tb-score-total",String(s.total)))}}const U6=["bridge","helm","tactical","engineering","computer"],$6=400,j6="-0.6 -0.6 10.6 10.6",H6=.7,V6=/^S\.R\. scanners$/i,q6=/^L\.R\. scanners$/i,K6={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]},Y6=["length","skill","request","quadrant","quadrant-y","sector","sector-y","range","computer-distance","computer-warp","status-report","another","yes-no","unknown"];class X6{constructor(e,s){this.hooks=e,this.harness=new T6({question_changed:d=>{this.partial_flush(),this.question_show(d)},text_written:d=>this.text_take(d),state_shown:d=>this.state_show(d),ended:()=>{this.leaving||this.hooks.voice.cue("gameover")}}),this.root=q("section","trek-bridge"),this.root.id="trek-bridge",this.root.dataset.view="bridge",this.root.setAttribute("aria-label","trek: the bridge");const i={},n=qj();n!==null&&this.root.append(n);const r=this.gutter_build(i,s),[o,a]=this.frame_build(),l=this.header_build(i),c=this.body_build(i);this.strip_build(i);const h=this.log_build(i);this.leaveAsk_build(i),this.root.append(r,o,l,a,c,i.ask,h,i.leaveAsk),this.parts=i,this.question_show(null)}hooks;root;harness;readout=null;previous=null;view="bridge";nextDistance=null;plan=new Map;answering=!1;computerRunning=!1;leaving=!1;tracker=new Tl;heading=0;pressedSector=null;scanDue=!1;fold=null;frames=new C6;shown=null;torpedo=null;trackPrinting=!1;partial="";lrsBloom=null;parts;stationHost_get(){return{answer_send:(e,s)=>this.answer_send(e,s),command_send:e=>this.command_send(e),plan_set:e=>{for(const[s,i]of e)this.plan.set(s,i)},course_set:(e,s)=>this.course_set(e,s),voice:this.hooks.voice}}gutter_build(e,s){const i=q("aside","tb-gutter"),n=q("div","tb-block");n.append(q("span","tb-block-name","TREK"),q("span","tb-block-sub","ARGUS · BSD TREK")),e.seed=q("div","tb-seed",s===null?"RANDOM GALAXY":`SEED ${s}`);const r=q("nav","tb-views");r.setAttribute("aria-label","views"),e.views=new Map;for(const c of U6){const h=Os(`tb-view tb-view-${c}`,c.toUpperCase(),()=>this.view_set(c));h.classList.remove("tb-pill"),h.dataset.view=c,e.views.set(c,h),r.append(h)}const o=Os("tb-leave","LEAVE BRIDGE",()=>this.leave_ask());o.classList.remove("tb-pill");const a=q("div","tb-gutter-top");a.append(n,e.seed,q("div","tb-gutter-fill"));const l=q("div","tb-gutter-body");return l.append(q("div","tb-gutter-cap"),r,q("div","tb-gutter-fill"),o),i.append(a,l),i}frame_build(){const e=q("div","tb-bar tb-bar-top");for(const i of["tb-bar-a","tb-bar-b","tb-bar-c","tb-bar-d"])e.append(q("span",i));const s=q("div","tb-bar tb-bar-body");for(const i of["tb-bar-a","tb-bar-b","tb-bar-c"])s.append(q("span",i));return[e,s]}header_build(e){const s=q("header","tb-header"),i=q("section","tb-head-condition"),n=q("div","tb-condition");n.append(q("span","tb-condition-label","CONDITION")),e.condition=q("span","tb-condition-name","—"),n.append(e.condition),e.conditionWhy=q("div","tb-condition-why",""),i.append(n,e.conditionWhy);const r=p=>{const f=q("section","tb-head-section");f.append(q("span","tb-head-title",p));const _=q("div","tb-head-grid");return f.append(_),[f,_]},[o,a]=r("SHIP"),[l,c]=r("MISSION"),[h,d]=r("POSITION"),u=q("div","tb-head-grid tb-head-since");return l.append(q("span","tb-head-title","SINCE LAST COMMAND"),u),e.ship=a,e.mission=c,e.position=d,e.since=u,s.append(i,o,l,h),s}body_build(e){const s=this.stationHost_get(),i=q("main","tb-body");i.dataset.view="bridge",e.body=i;const n=q("section","tb-scans");n.append(q("span","tb-title","LONG RANGE")),e.lrs=q("div","tb-lrs"),n.append(e.lrs,q("span","tb-title","GALAXY · WHAT THE SHIP HAS SEEN")),e.chart=q("div","tb-chart"),n.append(e.chart);const r=q("section","tb-srs-section");e.srsTitle=q("span","tb-title","SHORT RANGE"),r.append(e.srsTitle),e.scan=st("svg",{class:"tb-scan",viewBox:j6,role:"grid","aria-label":"short range scan"}),e.scan.addEventListener("keydown",l=>this.scan_key(l)),e.legend=this.legend_build(),r.append(e.scan,q("span","tb-note","PRESS A SECTOR: ITS COURSE AND DISTANCE FILL IN"),e.legend),e.shipPills=new Map;const o=q("div","tb-pills tb-ship-pills");o.append(q("span","tb-slider-label","SHIP"));for(const l of Pd.filter(c=>c.station==="ship")){const c=d_(l,s);e.shipPills.set(l.id,c),o.append(c)}r.append(o);const a=q("section","tb-stations");return e.helm=new Av(s,150,"tb"),e.tactical=new Tv(s,150,"tb"),a.append(e.helm.root,e.tactical.root),e.helmView=new Av(s,260,"tbh"),e.helmView.root.classList.add("tb-view-body","tb-view-helm"),e.tacticalView=new Tv(s,260,"tbt"),e.tacticalView.root.classList.add("tb-view-body","tb-view-tactical"),e.engineeringView=new W6(s),e.computerView=new F6(s),i.append(n,r,a,e.helmView.root,e.tacticalView.root,e.engineeringView.root,e.computerView.root),i}legend_build(){const e=q("div","tb-legend");for(const s of Kj){const i=q("span",`tb-legend-item tb-legend-${s.kind}`),n=s.kind==="klingon"?fr:[null];for(const r of n)i.append(h_(s.kind,r));i.append(q("span","tb-legend-glyph",Jc[s.kind].trim()===""?"␠":Jc[s.kind]),q("span","tb-legend-name",s.name)),e.append(i)}return e}strip_build(e){e.ask=q("div","tb-ask"),e.ask.hidden=!0,e.ask.setAttribute("role","dialog"),e.askText=q("span","tb-ask-text",""),e.askPills=q("div","tb-pills"),e.askInput=document.createElement("input"),e.askInput.type="text",e.askInput.className="tb-ask-input",e.askInput.setAttribute("aria-label","the answer");const s=e.askInput;e.askSend=Os("tb-commit","ANSWER",()=>this.answer_send(s.value,"ANSWER")),s.addEventListener("keydown",i=>{i.key==="Enter"&&this.answer_send(s.value,"ANSWER")}),e.ask.append(q("span","tb-ask-label","THE GAME ASKS"),e.askText,e.askPills,e.askInput,e.askSend)}log_build(e){const s=q("footer","tb-log-section"),i=q("div","tb-log-head");return i.append(q("span","tb-title","SHIP'S LOG"),q("span","tb-note","READ ONLY")),e.log=q("div","tb-log"),e.log.setAttribute("aria-live","polite"),s.append(i,e.log),s}leaveAsk_build(e){e.leaveAsk=q("div","tb-leave-ask"),e.leaveAsk.hidden=!0,e.leaveAsk.setAttribute("role","dialog");const s=e.leaveAsk,i=Os("tb-grave","LEAVE · THE GAME ENDS",()=>{this.leaving=!0,this.hooks.voice.cue("close"),this.hooks.leave()}),n=Os("","STAY",()=>{s.hidden=!0});e.leaveAsk.append(q("span","tb-ask-label","LEAVE THE BRIDGE?"),q("span","tb-ask-text","The game ends where it stands; dump first to keep it."),i,n)}harness_get(){return this.harness}leave_ask(){this.frames.skip(),this.parts.leaveAsk.hidden&&this.hooks.voice.pill("LEAVE BRIDGE"),this.parts.leaveAsk.hidden=!1}frames_get(){return{played:{...this.frames.played},pending:this.frames.pending_count(),busy:this.frames.busy_is()}}frames_settle(){return this.frames.settle()}leaveAsk_isOpen(){return!this.parts.leaveAsk.hidden}leaveAsk_close(){this.parts.leaveAsk.hidden=!0}view_get(){return this.view}view_set(e){this.frames.skip(),this.view=e,this.root.dataset.view=e,this.parts.body.dataset.view=e;for(const[s,i]of this.parts.views)i.classList.toggle("tb-view-on",s===e);this.hooks.voice.pill(gr(e.toUpperCase(),"view"))}readout_get(){return this.readout}command_send(e){if(this.frames.skip(),!this.harness.command_send(e))return this.hooks.voice.cue("deny"),!1;const s=i6(e.id);return s===null?this.hooks.voice.pill(gr(e.label,"command")):this.hooks.voice.cue(s),this.nextDistance=null,this.computerRunning=e.id==="computer",this.computerRunning&&this.parts.computerView.answer_take(null),this.log_write(`Command: ${e.line}
4353
+ `);return}(v||M.envelopes.some(S=>S.status==="error"))&&z.outcome_write(M),l(M)},h=[],d=b=>{const v=h.length===0;for(const z of b)z.vfsPath!==""&&!h.includes(z.vfsPath)&&h.push(z.vfsPath);!v||h.length===0||queueMicrotask(()=>{const z=h.splice(0);z.length>0&&c(`gather add ${z.map(Ji).join(" ")}`)})},u=(b,v,z)=>({command_run:x=>{t.client.line_execute(x,{silent:!0})},command_show:x=>t.terminal.line_run(x),note:x=>t.terminal.line_note(x),image_open:x=>{e.image_open(b(),x).then(M=>t.terminal.line_note(M))},process_open:x=>e.process_open(b(),{input:x,feed:null,node:null}),...v,...z,verb_send:c,cohort_process:x=>e.process_open(b(),x),feed_open:x=>e.feed_open(b(),x)}),p=()=>{const b=document.querySelector("#header-gather-pill");b!==null&&b.classList.toggle("panel-gather-empty",(r?.entries_get().length??0)===0)},f=()=>{const b=e.element_require("header-gather"),v=()=>e.errandHost_find()??"pacs",z=x=>a_(t.terminal,e.element_require("header-gather"),x);return new _v(b,e.pane_find(b,".gather-rows"),u(v,{name_ask:x=>z({message:"Cohort name: ",kind:"text",suggest:x,commit:"NAME IT"}),confirm_ask:async x=>{const M=await z({message:x,kind:"confirm"});return M==="y"||M==="n"?M:null}},{dismiss:()=>{document.body.dataset.header="away",o=!0,p()}}),n)};return{cohort:n,instance_build:b=>{const v=e.template_stamp("tpl-pane-gather"),z=new _v(v,e.pane_find(v,".gather-rows"),u(()=>b,{name_ask:x=>e.askOnPane_await(b,{message:"Cohort name: ",kind:"text",suggest:x,commit:"NAME IT"}),confirm_ask:async x=>{const M=await e.askOnPane_await(b,{message:x,kind:"confirm"});return M==="y"||M==="n"?M:null}},{dismiss:()=>{t.layout.leaf_close(b)||e.home_apply(),e.orphans_dispose(),e.stage_relight()}}),n);return s.set("gather",b,z),{id:b,kind:"gather",mount:v,dispose:()=>{s.delete(b),i.pane_leave(b)}}},has:b=>n.has(b),gather:b=>{r===null&&(r=f()),d(b);const v=document.body.dataset.header==="away";(!o||!v)&&(document.body.dataset.header="gather",o=!1),p()},open:(b,v="pacs")=>{const{layout:z}=t,x=new Set(z.panes_shown());let M=s.ids("gather").find(S=>x.has(S))??null;if(M===null){const S=x.has(v)?v:e.errandHost_find()??v,T=e.instance_spawn("gather","pacs"),I=e.replayPlace_get();if(!z.leaf_split(S,I?.dir??"row",T.id,I?.before??!1))return As(T.id),z.mount_remove(T.id),null;e.birth_record(T.id,S,I?.dir??"row",I?.before??!1),M=T.id}return s.get("gather",M)===void 0?null:(d(b),M)},stage:()=>{const{layout:b}=t,v=new Set(b.panes_shown()),z=s.ids("gather").find(x=>v.has(x))??null;if(z!==null)b.focus_set(z);else{const x=e.errandHost_find()??"pacs",M=e.instance_spawn("gather","pacs");if(!b.leaf_split(x,"col",M.id,!1)){As(M.id),b.mount_remove(M.id);return}e.birth_record(M.id,x,"col",!1),s.get("gather",M.id)?.render_now()}document.body.dataset.header="away",o=!0},annunciate:p,restore:async()=>{try{l(await t.client.line_execute("gather",{silent:!0,observe:!1}))}catch{}},envelope_observe:b=>{b.model?.kind===bv&&a(b.model.data)}}}class wj{mount;handlers;titleSpan;stateSpan;fieldSection;savePill;revertPill;focusMark;field=null;path=null;original="";saving=!1;fieldBuild=null;constructor(e,s){this.mount=e,this.handlers=s,this.titleSpan=e.querySelector(".pane-title"),this.stateSpan=e.querySelector(".pane-state"),this.fieldSection=this.element_require(".edit-field"),this.savePill=this.element_require(".edit-save"),this.revertPill=this.element_require(".edit-revert"),this.focusMark=e.querySelector(".edit-focus"),this.savePill.addEventListener("click",()=>{this.save()}),this.revertPill.addEventListener("click",()=>this.revert()),e.addEventListener("keydown",i=>{(i.ctrlKey||i.metaKey)&&!i.altKey&&i.key.toLowerCase()==="s"&&(i.preventDefault(),i.stopPropagation(),this.save())},{capture:!0}),this.fieldSection.addEventListener("mousedown",()=>this.focusMark_set(!0)),this.fieldSection.addEventListener("focusin",()=>this.focusMark_set(!0)),this.fieldSection.addEventListener("focusout",i=>{(!(i.relatedTarget instanceof Node)||!this.fieldSection.contains(i.relatedTarget))&&this.focusMark_set(!1)}),this.controls_sync()}opening_show(e){this.path=e,this.title_set(e),ys(this.stateSpan,"wait","OPENING")}async content_show(e){this.path=e.path,this.original=e.content,this.title_set(e.path),this.fieldBuild??=this.field_build(e);const s=await this.fieldBuild;s!==null&&(s.text_get()!==this.original&&s.text_set(this.original),this.controls_sync(),s.focus(),this.focusMark_set(!0))}async field_build(e){let s;try{s=await lm(()=>import("./field-jqfvruDC.js").then(i=>i.Q),[],import.meta.url)}catch(i){if(!r_(i))throw i;return ys(this.stateSpan,"stale",nd),this.handlers.note(`edit: ${nd.toLowerCase()} — the editor's code is of an older build than the server has`),null}return this.field=await s.editField_create(this.fieldSection,e.content,e.extension,()=>this.controls_sync()),this.field}opening_fail(e){ys(this.stateSpan,"refused",`NOT OPENED · ${e.toUpperCase()}`)}async save(){if(this.field===null||this.path===null||this.saving)return!1;const e=this.field.text_get();if(e===this.original)return!0;this.saving=!0,this.controls_sync();let s=!1;try{s=await this.handlers.save(this.path,e)}finally{this.saving=!1}return s&&(this.original=e),this.controls_sync(),s||ys(this.stateSpan,"refused","NOT SAVED · THE CONSOLE SAYS WHY"),s}revert(){this.field===null||!this.dirty_is()||(this.field.text_set(this.original),this.controls_sync())}dirty_is(){return this.field!==null&&this.field.text_get()!==this.original}path_get(){return this.path}field_release(){return this.field===null||!this.field.hasFocus()?!1:(this.field.blur(),this.focusMark_set(!1),!0)}dispose(){this.field?.destroy(),this.field=null}controls_sync(){const e=this.dirty_is();this.savePill.disabled=!e||this.saving,this.revertPill.disabled=!e||this.saving,this.mount.dataset.dirty=e?"yes":"no",this.field!==null&&(this.saving?ys(this.stateSpan,"wait","SAVING"):e?ys(this.stateSpan,"note","DIRTY"):ys(this.stateSpan,"settled","SAVED"))}title_set(e){this.titleSpan!==null&&(this.titleSpan.textContent=`EDIT ${e.split("/").pop()??e}`.toUpperCase()),this.mount.title=e}focusMark_set(e){this.focusMark!==null&&(this.focusMark.hidden=!e)}element_require(e){const s=this.mount.querySelector(e);if(s===null)throw new Error(`edit pane: no ${e} in its template`);return s}}function yj(t,e){const{layout:s,panels:i,subjects:n}=t,r=async(d,u)=>{const p=await ra(t,M1(d,u));return p&&e.saved?.(d),p},o=d=>{const u=e.template_stamp("tpl-pane-edit"),p=new wj(u,{save:r,note:f=>t.terminal.line_note(f)});return i.set("edit",d,p),{id:d,kind:"edit",mount:u,dispose:()=>{p.dispose(),i.delete(d),n.pane_leave(d)}}},a=d=>{const u=new Set(s.panes_shown());for(const[p,f]of i.entries("edit"))if(u.has(p)&&f.path_get()===d)return p;return null},l=()=>{e.launcher_yield();const d=new Set(s.panes_shown()),u=s.focused_get(),p=u!==null&&d.has(u)?u:e.errandHost_find();if(p===null)return null;const f=e.instance_spawn("edit"),_=e.replayPlace_get();return s.leaf_split(p,_?.dir??"col",f.id,_?.before??!1)?(e.birth_record(f.id,p,_?.dir??"col",_?.before??!1),f.id):(As(f.id),s.mount_remove(f.id),null)};return{instance_build:o,edit_receive:d=>{const u=d.path??"";if(u==="")throw new Error("the editor pane needs the file it edits, and the request named none");const p=a(u)??l();if(p===null)return!1;const f=i.get("edit",p);return f===void 0?!1:(s.focus_set(p),f.dirty_is()?(t.terminal.line_note(`edit: ${u}: its pane has unsaved changes; they stand (REVERT reads the file again)`),!0):(f.content_show({path:u,content:d.content,extension:d.extension??ez(u)}),!0))},edit_open:(d,u={})=>{const p=a(d)??l();if(p===null)return null;const f=i.get("edit",p);if(f===void 0)return null;s.focus_set(p),f.dirty_is()||f.opening_show(d);const _=v1(d);return u.visible===!0?(t.terminal.line_run(_),p):(t.client.line_execute(_,{silent:!0,observe:!1}).then(g=>{const m=g.envelopes.find(w=>w.status!=="ok");m!==void 0&&f.opening_fail((m.renderedErr??"").replace(/\x1b\[[0-9;]*m/g,"").trim()||"the kernel refused")}).catch(g=>f.opening_fail(g instanceof Error?g.message:String(g))),p)}}}class zj{listing;constructor(e){const s=e.querySelector(".help-panel");if(s===null)throw new Error("help pane: no .help-panel in its template");this.listing=new Ir({mount:s,traits:this.traits_declare(),key:i=>i.key,chrome:{root:e,prefix:"help"},caps:"root",activatable:()=>!1,row:{className:i=>`help-row help-${i.topic}`}}),this.render()}traits_declare(){return[{key:"name",label:"KEY · VERB",className:"help-key",width:"minmax(9em, 12em)",cell:e=>e.name},{key:"does",label:"DOES",className:"help-does",width:"minmax(16em, 1fr)",cell:e=>e.does}]}render(){const e=o=>{const a=document.createElement("header");return a.className="files-path help-block-head",a.textContent=o,a},s=pn.map(o=>({key:`k:${o.key}`,name:o.key,does:o.does,topic:o.topic})),i=ma.map((o,a)=>{const l=o.indexOf(" ");return{key:`v:${a}`,name:l<0?o:o.slice(0,l),does:l<0?"":o.slice(l+1).trim(),topic:"verb"}}),n=[{key:"g:games",name:"help games",does:"the /usr/games shelf — fortune, cal, weather and their kin, by category (type it in the console)",topic:"verb"}],r=[{key:"n:notes",name:"notes",does:"what the installed releases changed (notes pane opens it as a listing; the dashboard's WHAT'S NEW block too)",topic:"verb"}];this.listing.rows_set([{key:"keys",header:e("KEYS — Ctrl-B opens the focused pane's drawer; then one key presses one of its verbs"),rows:s},{key:"verbs",header:e("VERBS — the console language; the long form is docs/argus-lang.adoc"),rows:i},{key:"games",header:e("GAMES — the small pleasures, kept apart from the tools as BSD kept them"),rows:n},{key:"notes",header:e("NOTES — what changed, release by release"),rows:r}],{field:"help"})}}function Sj(t,e){const{layout:s,panels:i,subjects:n}=t;return{instance_build:a=>{const l=e.template_stamp("tpl-pane-help");return i.set("help",a,new zj(l)),{id:a,kind:"help",mount:l,dispose:()=>{i.delete(a),n.pane_leave(a)}}},open:()=>{const a=i.ids("help").find(d=>s.panes_shown().includes(d));if(a!==void 0)return s.focus_set(a),"help: on stage";const l=e.launcher_active();e.launcher_yield();const c=s.focused_get()??"files",h=e.instance_spawn("help");return l&&s.leaf_replace("files",h.id)?(s.focus_set(h.id),"help: the keys and the verbs, as a pane (help keys, help verbs print them here)"):s.leaf_split(c,"col",h.id,!1)?(e.birth_record(h.id,c,"col",!1),"help: the keys and the verbs, as a pane (help keys, help verbs print them here)"):(As(h.id),s.mount_remove(h.id),"help: could not open a pane")}}}const lf=["___________________ _-_ ","\\__(==========/_=_/ ____.---'---`---.____"," \\_ \\ \\----._________.----/"," \\ \\ / / `-_-' "," __,--`.`-'..'-_ "," /____ || "," `--.____,-' "];function xj(){const t=lf[0].length;let e=Number.NaN,s=0;return{title:"SL",tick:60,step:i=>{Number.isNaN(e)&&(e=-t),e+=1,s+=1,e>i.cols+6&&(e=-t)},draw:(i,n)=>{const r=Math.max(0,Math.floor((i.rows-lf.length)/2));lf.forEach((a,l)=>i.text(Math.round(e),r+l,a,n.lit));const o=s%2===0?"-~=":"-=~";i.text(Math.round(e)-o.length,r+1,o,n.cool)}}}const Mv="ハミヒーウシナモニサワツオリアホテマケメエカキムユラセネスタヌヘ0123456789Z:・.=*+-<>¦|";function Oj(){const t=new Map;let e=0;return{title:"CMATRIX",tick:50,step:(s,i)=>{e+=1;for(let n=0;n<s.cols;n++){const r=t.get(n);if(r===void 0){i()<.02&&t.set(n,{row:-1,speed:1+Math.floor(i()*2),length:4+Math.floor(i()*12),glyphs:[]});continue}e%r.speed===0&&(r.row+=1,r.glyphs.unshift(Mv[Math.floor(i()*Mv.length)]),r.glyphs.length>r.length&&r.glyphs.pop(),r.row-r.length>s.rows&&t.delete(n))}},draw:(s,i)=>{for(const[n,r]of t)r.glyphs.forEach((o,a)=>{const l=a===0?"#ffffff":a<r.length/2?i.lit:i.dim;s.put(n,r.row-a,o,l)})}}}function Ej(){const t=[];return{title:"RAIN",tick:70,step:(e,s)=>{s()<.9&&t.push({col:Math.floor(s()*e.cols),row:0,splash:0});for(const i of t)i.row<e.rows-1?i.row+=1:i.splash+=1;for(let i=t.length-1;i>=0;i--)t[i].splash>3&&t.splice(i,1)},draw:(e,s)=>{for(const i of t){if(i.splash===0){e.put(i.col,i.row,"|",s.cool);continue}const n=["o","O","( )"][i.splash-1];e.text(i.col-(n.length>>1),e.rows-1,n,s.dim)}}}}function Aj(){const t=[],e=[];let s=0;return{title:"ASCIIQUARIUM",tick:90,step:(i,n)=>{if(s+=1,t.length<Math.max(3,i.cols/12)&&n()<.08){const r=n()<.5;t.push({col:r?-4:i.cols+1,row:2+Math.floor(n()*Math.max(1,i.rows-5)),right:r,speed:1+Math.floor(n()*2),hue:Math.floor(n()*3)})}for(const r of t)s%r.speed===0&&(r.col+=r.right?1:-1);for(let r=t.length-1;r>=0;r--){const o=t[r];(o.col<-5||o.col>i.cols+2)&&t.splice(r,1)}if(n()<.3){const r=t[Math.floor(n()*t.length)];r!==void 0&&e.push({col:r.col+(r.right?4:-1),row:r.row-1})}for(const r of e)r.row-=1;for(let r=e.length-1;r>=0;r--)e[r].row<1&&e.splice(r,1)},draw:(i,n)=>{const r=(s%4<2?"~^":"^~").repeat(i.cols>>1);i.text(0,0,r,n.cool);const o=[n.lit,n.cool,n.warn];for(const a of t)i.text(a.col,a.row,a.right?"><>":"<><",o[a.hue]);for(const a of e)i.put(a.col,a.row,a.row%2===0?"o":".",n.dim);for(let a=2;a<i.cols;a+=7){const l=(s>>2)%2===0?0:1;for(let c=0;c<3;c++)i.put(a+(c+l)%2,i.rows-2-c,c%2===0?"(":")",n.dim)}i.text(0,i.rows-1,"^".repeat(i.cols),n.dim)}}}const vv=[[[0,0],[1,0],[2,0],[3,0]],[[0,0],[1,0],[0,1],[1,1]],[[1,0],[0,1],[1,1],[2,1]],[[0,0],[1,0],[1,1],[2,1]],[[1,0],[2,0],[0,1],[1,1]],[[0,0],[0,1],[1,1],[2,1]],[[2,0],[0,1],[1,1],[2,1]]],so=10,co=20;function Tj(){return{well:Array.from({length:co},()=>Array(so).fill(0)),piece:null,score:0,lines:0,over:!1}}function l_(t,e){return e.cells.every(([s,i])=>{const n=e.x+s,r=e.y+i;return n>=0&&n<so&&r<co&&(r<0||t[r][n]===0)})}function cf(t){const e=Math.max(...t.cells.flat())+1;return{...t,cells:t.cells.map(([s,i])=>[e-1-i,s])}}function Ij(t,e){const s=Math.floor(e()*vv.length),i={cells:vv[s].map(n=>[n[0],n[1]]),x:3,y:0,kind:s+1};if(!l_(t.well,i)){t.over=!0;return}t.piece=i}function Dj(t){const e=t.piece;if(e===null)return;e.cells.some(([,n])=>e.y+n<0)&&(t.over=!0);for(const[n,r]of e.cells){const o=e.y+r;o>=0&&(t.well[o][e.x+n]=e.kind)}const s=t.well.filter(n=>n.some(r=>r===0)),i=co-s.length;for(;s.length<co;)s.unshift(Array(so).fill(0));t.well=s,t.lines+=i,t.score+=[0,100,300,500,800][i]??800,t.piece=null}function hm(t,e){if(t.over)return;if(t.piece===null){Ij(t,e);return}const s={...t.piece,y:t.piece.y+1};l_(t.well,s)?t.piece=s:Dj(t)}function Cj(t,e,s){if(t.over||t.piece===null)return!1;const i=t.piece,n=r=>l_(t.well,r)?(t.piece=r,!0):!1;switch(e){case"ArrowLeft":case"h":case"a":return n({...i,x:i.x-1}),!0;case"ArrowRight":case"l":case"d":return n({...i,x:i.x+1}),!0;case"ArrowUp":case"k":case"w":return n(cf(i))||n({...cf(i),x:i.x-1})||n({...cf(i),x:i.x+1}),!0;case"ArrowDown":case"j":case"s":return hm(t,s),!0;case" ":{for(;t.piece!==null;)hm(t,s);return!0}default:return!1}}function Rj(){const t=Tj();let e=Math.random;return{title:"TETRIS",tick:500,step:(s,i)=>{e=i,hm(t,i)},draw:(s,i)=>{const n=Math.max(0,Math.floor((s.cols-(so*2+2))/2)),r=Math.max(0,Math.floor((s.rows-co-1)/2)),o=["",i.cool,i.lit,i.warn,i.dim,i.lit,i.cool,i.warn];for(let a=0;a<co;a++){s.put(n,r+a,"|",i.dim),s.put(n+so*2+1,r+a,"|",i.dim);for(let l=0;l<so;l++){const c=t.well[a][l];c!==0&&s.text(n+1+l*2,r+a,"[]",o[c])}}if(s.text(n,r+co,"+"+"-".repeat(so*2)+"+",i.dim),t.piece!==null)for(const[a,l]of t.piece.cells){const c=t.piece.y+l;c>=0&&s.text(n+1+(t.piece.x+a)*2,r+c,"[]",o[t.piece.kind])}t.over&&s.text(n+2,r+9," GAME OVER ",i.warn)},key:s=>Cj(t,s,e),status:()=>`${t.score} · ${t.lines} lines${t.over?" · OVER":""}`,over:()=>t.over}}function kj(t,e,s){const i=t>>1,n=e>>1,r={body:[[i,n],[i-1,n],[i-2,n]],food:[0,0],heading:"right",next:"right",score:0,over:!1,cols:t,rows:e};return C1(r,s),r}function C1(t,e){for(let s=0;s<1e3;s++){const i=[Math.floor(e()*t.cols),Math.floor(e()*t.rows)];if(!t.body.some(([n,r])=>n===i[0]&&r===i[1])){t.food=i;return}}}const Nj={up:"down",down:"up",left:"right",right:"left"};function Bj(t,e){Nj[e]!==t.heading&&(t.next=e)}function Gj(t,e){if(t.over)return;t.heading=t.next;const[s,i]=t.body[0],n=t.heading==="up"?[s,i-1]:t.heading==="down"?[s,i+1]:t.heading==="left"?[s-1,i]:[s+1,i],r=n[0]<0||n[1]<0||n[0]>=t.cols||n[1]>=t.rows,o=t.body.some(([a,l])=>a===n[0]&&l===n[1]);if(r||o){t.over=!0;return}t.body.unshift(n),n[0]===t.food[0]&&n[1]===t.food[1]?(t.score+=10,C1(t,e)):t.body.pop()}const Pj={ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",ArrowDown:"down",k:"up",w:"up",j:"down",s:"down",h:"left",a:"left",l:"right",d:"right"};function Lj(){let t=null;return{title:"SNAKE",tick:140,step:(e,s)=>{t===null&&(t=kj(Math.max(8,e.cols>>1),Math.max(6,e.rows-1),s)),Gj(t,s)},draw:(e,s)=>{t!==null&&(e.text(0,t.rows,"-".repeat(t.cols*2),s.dim),e.text(t.food[0]*2,t.food[1],"**",s.warn),t.body.forEach(([i,n],r)=>e.text(i*2,n,r===0?"@@":"oo",r===0?s.lit:s.cool)),t.over&&e.text(Math.max(0,t.cols-6),t.rows>>1," GAME OVER ",s.warn))},key:e=>{const s=Pj[e];return s===void 0||t===null?!1:(Bj(t,s),!0)},status:()=>t===null?"":`${t.score}${t.over?" · OVER":""}`,over:()=>t?.over??!1}}const R1={sl:xj,cmatrix:Oj,rain:Ej,aquarium:Aj,tetris:Rj,snake:Lj};function Wj(t){return t in R1}const Fj=8,Uj=26,hf=1.8,$j=100,wv=24;function yv(t,e){let s=Math.floor(t/$j);return e/(s*hf)<wv&&(s=Math.floor(e/wv/hf)),s=Math.max(Fj,Math.min(Uj,s)),{w:s,h:Math.round(s*hf)}}class jj{pane;field;canvas;state;focusMark;pausePill;program=null;name=null;paused=!1;timer=null;frame=null;observer;constructor(e){this.pane=e,this.field=el(e,".games-field"),this.canvas=el(e,".games-canvas"),this.state=e.querySelector(".pane-state"),this.focusMark=el(e,".games-focus"),this.pausePill=el(e,".games-pause"),this.field.tabIndex=0,this.pausePill.addEventListener("click",()=>this.pause_toggle()),el(e,".games-restart").addEventListener("click",()=>{this.name!==null&&this.program_run(this.name)}),this.field.addEventListener("mousedown",()=>{this.field.focus(),this.focusMark_paint(!0)}),this.field.addEventListener("focusin",()=>this.focusMark_paint(!0)),this.field.addEventListener("focusout",s=>{(!(s.relatedTarget instanceof Node)||!this.field.contains(s.relatedTarget))&&this.focusMark_paint(!1)}),this.field.addEventListener("keydown",s=>this.key_handle(s)),this.observer=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>this.draw()),this.observer?.observe(this.field)}program_run(e){this.name=e,this.program=R1[e](),this.paused=!1,this.pausePill.textContent="PAUSE",this.clock_start(),this.program.key!==void 0&&(this.field.focus(),this.focusMark_paint(!0)),this.draw()}program_name(){return this.name}paused_is(){return this.paused}pause_toggle(){this.program!==null&&(this.paused=!this.paused,this.pausePill.textContent=this.paused?"RESUME":"PAUSE",this.paused?this.clock_stop():this.clock_start(),this.state_paint())}field_hasFocus(){return document.activeElement instanceof Node&&this.field.contains(document.activeElement)}field_release(){return this.field_hasFocus()?(document.activeElement.blur(),this.focusMark_paint(!1),!0):!1}dispose(){this.clock_stop(),this.observer?.disconnect()}key_handle(e){if(e.key==="Escape"){this.field_release(),e.stopPropagation();return}if(this.program!==null){if(e.key===" "&&this.program.key===void 0){this.pause_toggle(),e.preventDefault(),e.stopPropagation();return}this.program.key?.(e.key)===!0&&(e.preventDefault(),this.draw()),e.stopPropagation()}}clock_start(){this.clock_stop();const e=this.program;e!==null&&(this.timer=setInterval(()=>{this.field.offsetParent!==null&&(e.step(this.size_measure(),Math.random),this.draw(),e.over?.()===!0&&this.clock_stop())},e.tick))}clock_stop(){this.timer!==null&&clearInterval(this.timer),this.timer=null}size_measure(){const e=this.field.getBoundingClientRect(),s=yv(e.width,e.height);return{cols:Math.max(10,Math.floor(e.width/s.w)),rows:Math.max(6,Math.floor(e.height/s.h))}}palette_read(){const e=getComputedStyle(this.pane),s=(i,n)=>e.getPropertyValue(i).trim()||n;return{lit:s("--harvestgold","#ffcc66"),dim:s("--butter","#ffff99"),warn:s("--tomato","#ff7766"),cool:s("--daybreak","#55aaff")}}draw(){this.frame===null&&(this.frame=requestAnimationFrame(()=>{this.frame=null,this.paint()}))}paint(){const e=this.program,s=this.canvas.getContext("2d");if(e===null||s===null)return;const i=this.field.getBoundingClientRect(),n=window.devicePixelRatio||1;(this.canvas.width!==Math.floor(i.width*n)||this.canvas.height!==Math.floor(i.height*n))&&(this.canvas.width=Math.floor(i.width*n),this.canvas.height=Math.floor(i.height*n)),s.setTransform(n,0,0,n,0,0),s.clearRect(0,0,i.width,i.height);const r=yv(i.width,i.height);s.font=`${r.h-2}px 'Share Tech Mono', monospace`,s.textBaseline="top";const o=this.size_measure(),a=(c,h,d,u)=>{c<0||h<0||c>=o.cols||h>=o.rows||(s.fillStyle=u,s.fillText(d,c*r.w,h*r.h))},l={cols:o.cols,rows:o.rows,put:a,text:(c,h,d,u)=>{[...d].forEach((p,f)=>{p!==" "&&a(c+f,h,p,u)})}};e.draw(l,this.palette_read()),this.state_paint()}state_paint(){if(this.state===null||this.program===null)return;const e=this.program.status?.()??"";this.state.textContent=[this.program.title,e,this.paused?"PAUSED":""].filter(s=>s!=="").join(" · ")}focusMark_paint(e){this.focusMark.hidden=!e,this.pane.classList.toggle("games-field-focused",e)}}function el(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`games pane: missing ${e}`);return s}function Hj(t,e){const{layout:s,panels:i,subjects:n}=t;return{instance_build:a=>{const l=e.template_stamp("tpl-pane-games"),c=new jj(l);return i.set("games",a,c),{id:a,kind:"games",mount:l,dispose:()=>{c.dispose(),i.delete(a),n.pane_leave(a)}}},show:a=>{const l=typeof a=="object"&&a!==null?a.program:void 0;if(typeof l!="string"||!Wj(l))return`games: no program named ${String(l)}`;const c=i.ids("games").find(f=>s.panes_shown().includes(f));if(c!==void 0)return s.focus_set(c),i.get("games",c)?.program_run(l),`games: ${l} on the GAMES pane`;const h=e.launcher_active();e.launcher_yield();const d=s.focused_get()??"files",u=e.instance_spawn("games");return(h?s.leaf_replace("files",u.id):s.leaf_split(d,"col",u.id,!1))?(h?s.focus_set(u.id):e.birth_record(u.id,d,"col",!1),i.get("games",u.id)?.program_run(l),`games: ${l} in a GAMES pane (Esc gives the keyboard back; its PAUSE and RESTART pills on the frame)`):(As(u.id),s.mount_remove(u.id),"games: could not open a pane")}}}function st(t,e){const s=document.createElementNS("http://www.w3.org/2000/svg",t);for(const[i,n]of Object.entries(e))s.setAttribute(i,String(n));return s}const fr=["cruiser","raptor","talon","warbird"],Vj={ship:'<g fill="currentColor"><ellipse cx="12" cy="6.5" rx="9" ry="4"/><rect x="9.5" y="9.5" width="5" height="6" rx="1"/><rect x="3" y="14" width="5" height="8" rx="2.2"/><rect x="16" y="14" width="5" height="8" rx="2.2"/><rect x="7" y="16" width="10" height="2.2" rx="1"/></g>',"klingon-cruiser":'<g fill="currentColor"><circle cx="12" cy="4" r="2.6"/><rect x="11" y="5.5" width="2" height="8.5"/><path d="M12 12.5 L22 20.5 L22.5 22.5 L17 19.2 L12 18 L7 19.2 L1.5 22.5 L2 20.5 Z"/><rect x="8.5" y="18.5" width="7" height="3.2" rx="1.2"/></g>',"klingon-raptor":'<path fill="currentColor" d="M12 1.5 L14 6.5 L22.5 10.5 L21.5 18 L19.5 12.5 L15 13.5 L14 20 L12 17 L10 20 L9 13.5 L4.5 12.5 L2.5 18 L1.5 10.5 L10 6.5 Z"/>',"klingon-talon":'<g fill="currentColor"><path d="M12 1.5 L13.6 11 L21.5 4.5 L19 15 L12 22 L5 15 L2.5 4.5 L10.4 11 Z"/><circle cx="12" cy="13.5" r="1.6" fill="#000"/></g>',"klingon-warbird":'<g fill="currentColor"><rect x="8.5" y="2" width="7" height="3.2" rx="1.6"/><rect x="11.1" y="4.5" width="1.8" height="7"/><path d="M1.5 13 Q12 6 22.5 13 L22 20 Q17 15.5 14 17 L12 22 L10 17 Q7 15.5 2 20 Z"/></g>',base:'<g fill="currentColor"><path d="M12 1.5 L17 12 L12 22.5 L7 12 Z"/><rect x="1.5" y="10.8" width="21" height="2.4" rx="1.2"/><circle cx="12" cy="12" r="3" fill="#000"/></g>',inhabited:'<circle cx="12" cy="12" r="7.5" fill="currentColor"/><path d="M4.5 12 Q12 15.5 19.5 12" fill="none" stroke="#000" stroke-width="1.6"/><path d="M5.5 8.5 Q12 11 18.5 8.5" fill="none" stroke="#000" stroke-width="1.2" opacity="0.6"/>',star:'<g stroke="currentColor" stroke-width="1.8" stroke-linecap="round" fill="none"><path d="M12 2 V22 M2 12 H22 M4.9 4.9 L19.1 19.1 M19.1 4.9 L4.9 19.1"/></g><circle cx="12" cy="12" r="2.6" fill="currentColor"/>',hole:'<g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"><path d="M12 12 m0 -2.5 a2.5 2.5 0 1 1 -2.5 2.5"/><path d="M12 12 m0 -6 a6 6 0 1 1 -6 6"/><path d="M12 12 m0 -9.5 a9.5 9.5 0 1 1 -9.5 9.5" opacity="0.5"/></g>',supernova:'<g fill="currentColor"><path d="M10 8.536 A4 4 0 0 1 14 8.536 L17.5 2.474 A11 11 0 0 0 6.5 2.474 Z"/><path d="M10 8.536 A4 4 0 0 1 14 8.536 L17.5 2.474 A11 11 0 0 0 6.5 2.474 Z" transform="rotate(120 12 12)"/><path d="M10 8.536 A4 4 0 0 1 14 8.536 L17.5 2.474 A11 11 0 0 0 6.5 2.474 Z" transform="rotate(240 12 12)"/><circle cx="12" cy="12" r="2.4"/></g>'},Al="tm-";function k1(t,e=null){return t==="klingon"?`${Al}klingon-${e!==null&&fr.includes(e)?e:fr[0]}`:`${Al}${t}`}function qj(){if(document.getElementById(`${Al}ship`)!==null)return null;const t=st("svg",{class:"tm-defs",width:0,height:0,"aria-hidden":"true"}),e=st("defs",{});for(const[i,n]of Object.entries(Vj)){const r=st("symbol",{id:`${Al}${i}`,viewBox:"0 0 24 24"});r.innerHTML=n,e.append(r)}const s=(i,n)=>{const r=st("radialGradient",{id:`${Al}${i}`});for(const[o,a,l]of n){const c=st("stop",{offset:o});c.setAttribute("style",`stop-color: ${a}; stop-opacity: ${l}`),r.append(c)}return r};return e.append(s("halo",[[0,"var(--butter)",.9],[.35,"var(--harvestgold)",.5],[1,"var(--harvestgold)",0]]),s("halo-nova",[[0,"var(--butter)",.9],[.3,"var(--pumpkin-pie)",.6],[1,"var(--pumpkin-pie)",0]]),s("halo-mars",[[0,"var(--butter)",.8],[.3,"var(--mars)",.6],[1,"var(--mars)",0]]),s("photon-core",[[0,"#fff",1],[.35,"#ffd27a",1],[1,"#ff6a1a",1]]),s("photon-halo",[[0,"#ff6a1a",.55],[1,"#ff6a1a",0]])),t.append(e),t}function c_(t,e,s=null,i=0){const n=st("g",{class:`tm-mark tm-mark-${t}`});return n.append(st("use",{href:`#${k1(t,s)}`,x:-e.size/2,y:-e.size/2,width:e.size,height:e.size,class:"tm-symbol"})),N1(n,e.cx,e.cy,i),n}function N1(t,e,s,i=0){t.setAttribute("transform",i===0?`translate(${e} ${s})`:`translate(${e} ${s}) rotate(${i})`)}function h_(t,e=null){const s=st("svg",{viewBox:"0 0 24 24",class:`tm-icon tm-icon-${t}`,"aria-hidden":"true"});return s.append(st("use",{href:`#${k1(t,e)}`})),s}const Jc={ship:"E",klingon:"K",base:"#",inhabited:"@",star:"*",hole:" ",supernova:"///"},Kj=[{kind:"ship",name:"ENTERPRISE"},{kind:"klingon",name:"KLINGON"},{kind:"base",name:"STARBASE"},{kind:"inhabited",name:"INHABITED"},{kind:"star",name:"STAR"},{kind:"hole",name:"BLACK HOLE"},{kind:"supernova",name:"SUPERNOVA"}],Yj=/^Klingon at (\d+),(\d+) moves to (\d+),(\d+)/,Xj=/^Klingon at (\d+),(\d+) escapes to quadrant/,Zj=/\*\*\* Klingon at (\d+),(\d+) destroyed \*\*\*/;class Tl{marks=new Map;mark_find(e){return this.marks.get(Tl.key_format(e))??null}line_hear(e){const s=Yj.exec(e);if(s!==null){const n=`${s[1]},${s[2]}`,r=this.marks.get(n);return this.marks.delete(n),r!==void 0&&this.marks.set(`${s[3]},${s[4]}`,r),!0}const i=Xj.exec(e)??Zj.exec(e);return i!==null?(this.marks.delete(`${i[1]},${i[2]}`),!0):!1}reconcile(e,s={}){s.reset===!0&&this.marks.clear();const i=new Set(e.map(n=>Tl.key_format(n)));for(const n of[...this.marks.keys()])i.has(n)||this.marks.delete(n);e.forEach((n,r)=>{const o=Tl.key_format(n);if(s.byOrder===!0){this.marks.set(o,fr[r%fr.length]);return}this.marks.has(o)||this.marks.set(o,this.leastWorn_get())})}clear(){this.marks.clear()}leastWorn_get(){const e=new Map(fr.map(i=>[i,0]));for(const i of this.marks.values())e.set(i,(e.get(i)??0)+1);let s=fr[0];for(const i of fr)(e.get(i)??0)<(e.get(s)??0)&&(s=i);return s}static key_format(e){return`${e.x},${e.y}`}}function Jj(t,e,s,i){const n=Math.max(0,Math.min(100,100*t/Math.max(1,e)));return i?{className:"tb-ring tb-ring-docked",width:.09,percent:n}:s?{className:`tb-ring ${n>60?"tb-ring-full":n>30?"tb-ring-mid":"tb-ring-low"}`,width:.025+.085*n/100,percent:n}:{className:"tb-ring tb-ring-down",width:.02,percent:n}}function q(t,e,s){const i=document.createElement(t);return i.className=e,s!==void 0&&(i.textContent=s),i}function Os(t,e,s){const i=q("button",`tb-pill ${t}`,e);return i.type="button",i.addEventListener("click",s),i}const Qj=16;class B1{constructor(e,s,i){this.onCommit=i,this.size=e;const n=e/2;this.root=q("div","tb-wheel");const r=st("svg",{width:e,height:e,viewBox:`0 0 ${e} ${e}`,role:"img","aria-label":s});r.classList.add("tb-wheel-face"),r.append(st("circle",{cx:n,cy:n,r:n-4,class:"tb-wheel-rim"})),r.append(st("circle",{cx:n,cy:n,r:(n-4)*.66,class:"tb-wheel-ring"})),r.append(st("circle",{cx:n,cy:n,r:(n-4)*.33,class:"tb-wheel-ring"}));for(let l=0;l<36;l++){const c=l*Math.PI/18,h=l%3===0,d=n-4-(h?12:7);r.append(st("line",{x1:n+d*Math.sin(c),y1:n-d*Math.cos(c),x2:n+(n-4)*Math.sin(c),y2:n-(n-4)*Math.cos(c),class:h?"tb-wheel-tick-major":"tb-wheel-tick"}))}for(const l of[0,90,180,270]){const c=l*Math.PI/180,h=st("text",{x:n+(n-26)*Math.sin(c),y:n-(n-26)*Math.cos(c)+4,"text-anchor":"middle",class:"tb-wheel-label"});h.textContent=String(l),r.append(h)}this.wedge=st("path",{d:"",class:"tb-wheel-wedge"}),r.append(this.wedge),this.marks=st("g",{class:"tb-wheel-marks"}),r.append(this.marks),this.needle=st("line",{x1:n,y1:n,x2:n,y2:14,class:"tb-wheel-needle"}),r.append(this.needle),r.append(st("circle",{cx:n,cy:n,r:6,class:"tb-wheel-hub"})),this.root.append(r);const o=q("div","tb-wheel-row");this.readout=q("span","tb-wheel-readout","0°"),this.commit=Os("tb-commit","SET COURSE",()=>this.onCommit(Math.round(this.degrees))),o.append(this.readout,this.commit),this.root.append(o);const a=l=>{const c=r.getBoundingClientRect(),h=l.clientX-c.left-c.width/2,d=l.clientY-c.top-c.height/2;this.degrees_set((Math.atan2(h,-d)*180/Math.PI+360)%360)};r.addEventListener("pointerdown",l=>{r.setPointerCapture(l.pointerId),a(l)}),r.addEventListener("pointermove",l=>{l.buttons!==0&&a(l)})}onCommit;root;needle;marks;wedge;readout;commit;degrees=0;wedgeHalf=null;size;degrees_set(e){this.degrees=e;const s=this.size/2,i=e*Math.PI/180;this.needle.setAttribute("x2",String(s+(s-14)*Math.sin(i))),this.needle.setAttribute("y2",String(s-(s-14)*Math.cos(i))),this.readout.textContent=`${Math.round(e)}°`,this.wedge_draw()}degrees_get(){return this.degrees}wedge_set(e){this.wedgeHalf=e,this.wedge_draw()}wedge_draw(){if(this.wedgeHalf===null){this.wedge.setAttribute("d","");return}const e=this.size/2,s=e-14,i=(this.degrees-this.wedgeHalf)*Math.PI/180,n=(this.degrees+this.wedgeHalf)*Math.PI/180,r=e+s*Math.sin(i),o=e-s*Math.cos(i),a=e+s*Math.sin(n),l=e-s*Math.cos(n);this.wedge.setAttribute("d",`M ${e} ${e} L ${r} ${o} A ${s} ${s} 0 0 1 ${a} ${l} Z`)}marks_set(e){this.marks.replaceChildren();const s=this.size/2;for(const i of e){const n=i.bearing*Math.PI/180,r=(s-4)*.8,o=s+r*Math.sin(n),a=s-r*Math.cos(n),l=i.kind==="klingon"?i.bearing+180:0,c=c_(i.kind,{cx:o,cy:a,size:Qj},i.variant??null,l);c.classList.add("tb-wheel-mark",`tb-wheel-mark-${i.kind}`);const h=st("title",{});h.textContent=i.label,c.append(h),this.marks.append(c)}}lit_set(e,s="SET COURSE"){this.root.classList.toggle("tb-lit",e),this.commit.disabled=!e,this.commit.textContent=s}}class xr{constructor(e,s,i,n){this.digits=i,this.onCommit=n,this.root=q("div","tb-slider");const r=q("label","tb-slider-label",s);r.htmlFor=e,this.input=document.createElement("input"),this.input.type="range",this.input.id=e,this.input.className="tb-slider-input",this.input.addEventListener("input",()=>{this.shown_refresh(),this.onInput?.(this.value_get())});const o=q("div","tb-slider-column");this.ticks=q("div","tb-slider-ticks"),this.note=q("span","tb-slider-note"),o.append(this.input,this.ticks,this.note),this.shown=q("span","tb-slider-readout","—"),this.commit=Os("tb-commit","SET",()=>this.onCommit(this.value_get())),this.root.append(r,o,this.shown,this.commit)}digits;onCommit;root;input;shown;commit;note;ticks;onInput=null;range_set(e,s,i,n=0){const r=e.min??0,o=e.max??1;this.input.min=String(r),this.input.max=String(o),this.input.step=String(e.step??1),this.input.value=String(Math.min(o,Math.max(r,s))),this.note.textContent=i,this.ticks.replaceChildren();for(let a=0;a<n;a++){const l=r+(o-r)*a/Math.max(1,n-1);this.ticks.append(q("span","tb-slider-tick",Number.isInteger(l)?String(l):l.toFixed(1)))}this.shown_refresh()}input_listen(e){this.onInput=e}note_set(e){this.note.textContent=e}value_get(){return Number(this.input.value)}value_set(e){this.input.value=String(e),this.shown_refresh()}lit_set(e,s="SET"){this.root.classList.toggle("tb-lit",e),this.input.disabled=!e,this.commit.disabled=!e,this.commit.textContent=s}lit_is(){return this.root.classList.contains("tb-lit")}shown_refresh(){this.shown.textContent=this.value_get().toFixed(this.digits)}}class Qc{root;buttons=[];note;constructor(e,s,i){this.root=q("div","tb-pillrow"),e!==""&&this.root.append(q("span","tb-slider-label",e));const n=q("div","tb-slider-column"),r=q("div","tb-pills");for(const o of s){const a=Os("tb-choice",o.label,()=>i(o.line,o.label));a.dataset.line=o.line,this.buttons.push(a),r.append(a)}this.note=q("span","tb-slider-note",""),n.append(r,this.note),this.root.append(n)}note_set(e){this.note.textContent=e}lit_set(e){this.root.classList.toggle("tb-lit",e);for(const s of this.buttons)s.disabled=!e}}const e6=[[/Klingon attack:/,"incoming"],[/^HIT: \d+ units/,"hit"],[/CRITICAL HIT/,"hit"],[/\*\*\* Klingon at \d+,\d+ destroyed \*\*\*/,"explosion"],[/\*\*\*\*\* .* destroyed \*\*\*\*\*/,"explosion"],[/Starbase at \d+,\d+ destroyed/,"explosion"],[/Inhabited starsystem .* destroyed/,"explosion"],[/^Torpedo track/,"torpedo"],[/^Phaser bank \d+ fires:/,"phaser"],[/^Phasers locked on target/,"phaser"],[/^Starbase in \d+,\d+ responds/,"hail"],[/^Password verified; self destruct sequence continues/,"destruct"]];function t6(t){const e=[];for(const[s,i]of e6)s.test(t)&&!e.includes(i)&&e.push(i);return e}function s6(t,e){const s=[];if(t!==null&&t.condition.name!==e.condition.name)switch(e.condition.name){case"RED":s.push("redalert");break;case"YELLOW":s.push("yellowalert");break;case"DOCKED":s.push("dock");break;default:s.push("green");break}return t!==null&&(t.position.quadrant.x!==e.position.quadrant.x||t.position.quadrant.y!==e.position.quadrant.y)&&s.push("sensor"),s}function i6(t){switch(t){case"abandon":return"transporter";case"destruct":return"destruct";case"computer":return"thinking";default:return null}}function n6(t,e){return t!=="distance"?null:e==="impulse"?"impulse":e==="move"||e==="ram"?"warp":null}function gr(t,e){return e==="computer"&&t==="MOVE"?"MOVE (COMPUTER)":e==="commit"?/^SET COURSE/.test(t)?"SET COURSE":"SLIDER SET":e==="choice"&&/^\d+°$/.test(t)?"BURST ANGLE":/^CANCEL/.test(t)?"CANCEL":t}const Ss=10,Ul=8,r6="*",o6="#",G1="E",a6="Q",l6="K",c6="@",P1=" ",h6=7,d6=64,u6=63,f6=0,p6=1,m6=2,g6=3,_6=[{name:"warp drive",person:"Scotty"},{name:"S.R. scanners",person:"Scotty"},{name:"L.R. scanners",person:"Scotty"},{name:"phasers",person:"Sulu"},{name:"photon tubes",person:"Sulu"},{name:"impulse engines",person:"Scotty"},{name:"shield control",person:"Sulu"},{name:"computer",person:"Spock"},{name:"subspace radio",person:"Uhura"},{name:"life support",person:"Scotty"},{name:"navigation system",person:"Chekov"},{name:"cloaking device",person:"Scotty"},{name:"transporter",person:"Scotty"},{name:"shuttlecraft",person:"Scotty"},{name:"*ERR 14*",person:"Nobody"},{name:"*ERR 15*",person:"Nobody"}],b6=["GREEN","DOCKED","YELLOW","RED"];function xh(t,e){return(Math.atan2(e.y-t.y,-(e.x-t.x))*180/Math.PI+360)%360}function ad(t,e){return Math.hypot(e.x-t.x,e.y-t.y)}function M6(t){switch(t){case G1:case a6:return"ship";case l6:return"klingon";case o6:return"base";case r6:return"star";case c6:return"inhabited";case P1:return"hole";default:return"empty"}}function v6(t){const e=new Map;for(const s of t)(s.evcode&u6)!==h6||(s.evcode&d6)!==0||e.set(s.systemname,s.date);return _6.map((s,i)=>({index:i,name:s.name,person:s.person,repairAt:e.get(i)??null})).filter(s=>!s.name.startsWith("*"))}function w6(t){const e=t.Etc.nkling;switch(t.Ship.cond){case g6:return e===1?"1 Klingon in this quadrant":`${e} Klingons in this quadrant`;case m6:return t.Ship.energy<t.Param.energylow?"energy low":"Klingons near";case p6:return"docked at a starbase";case f6:default:return"all clear"}}function y6(t){const{Ship:e,Now:s,Game:i,Param:n,Etc:r,Sect:o,Quad:a}=t,l={x:e.quadx,y:e.quady},c={x:e.sectx,y:e.secty},h=[];for(let m=0;m<Ss;m++){const w=[];for(let y=0;y<Ss;y++){const b=o[m]?.[y]??P1;w.push({x:m,y,kind:M6(b),glyph:b})}h.push(w)}const d=r.klingon.slice(0,r.nkling).map(m=>({x:m.x,y:m.y,bearing:xh(c,m),range:ad(c,m),power:m.power,mark:null})).sort((m,w)=>m.range-w.range),u=s.base.slice(0,s.bases).map(m=>({x:m.x,y:m.y}));let p=null;for(const m of u){const w=ad(l,m);(p===null||w<p.range)&&(p={at:m,range:w,here:w===0})}const f=[];for(let m=0;m<Ul;m++){const w=[];for(let y=0;y<Ul;y++){const v=a[m]?.[y]?.scanned??-1,z=v<0?null:v>=1e3?"///":String(v).padStart(3,"0");w.push({x:m,y,here:m===l.x&&y===l.y,code:z,supernova:v>=1e3,klingons:v<0||v>=1e3?0:Math.floor(v/100),bases:v<0||v>=1e3?0:Math.floor(v%100/10)})}f.push(w)}const _=v6(t.Event),g=_.filter(m=>m.repairAt!==null).sort((m,w)=>(m.repairAt??0)-(w.repairAt??0));return{condition:{name:b6[e.cond]??"GREEN",why:w6(t)},ship:{shipName:e.shipname,energy:e.energy,energyMax:n.energy,shield:e.shield,shieldMax:n.shield,shieldsUp:e.shldup!==0,cloaked:e.cloaked!==0,torpedoes:e.torped,torpedoesMax:n.torped,reserves:e.reserves,reservesMax:n.reserves,crew:e.crew,warp:e.warp},mission:{stardate:s.date,timeLeft:s.time,klingonsLeft:s.klings,klingonsStart:n.klings,killed:i.killk,captives:i.captives,starbases:s.bases},position:{quadrant:l,sector:c},sectors:h,klingons:d,bases:u,nearestBase:p,chart:f,devices:_,damaged:g,game:{killk:i.killk,killb:i.killb,kills:i.kills,killinhab:i.killinhab,helps:i.helps,captives:i.captives,deaths:i.deaths,killed:i.killed!==0,skill:i.skill,won:t.Move.endgame>0,abandoned:e.ship!==G1},param:{warptime:n.warptime,dockfac:n.dockfac,klingpwr:n.klingpwr,date:n.date}}}const z6=["novice","fair","good","expert","commodore","impossible"];function L1(t){const{game:e,mission:s,param:i}=t,n=[];n.push({label:`${e.killk} Klingons killed`,points:Math.trunc(i.klingpwr/4)*e.killk});const r=Math.max(1,s.stardate-i.date),o=e.killk/r;return n.push({label:`kill rate ${o.toFixed(2)} Klingons/stardate`,points:Math.trunc(400*o)}),n.push({label:`penalty for ${s.klingonsLeft} Klingons remaining`,points:Math.trunc(-400*s.klingonsLeft/(e.killk+1))}),e.won&&n.push({label:`bonus for winning a ${z6[e.skill-1]??""} game`,points:100*e.skill}),e.killed&&n.push({label:"penalty for getting killed",points:-500}),n.push({label:`${e.killb} starbases killed`,points:-100*e.killb}),n.push({label:`${e.helps} calls for help`,points:-100*e.helps}),n.push({label:`${e.kills} stars destroyed`,points:-5*e.kills}),n.push({label:`${e.killinhab} inhabited starsystems destroyed`,points:-150*e.killinhab}),e.abandoned&&n.push({label:"penalty for abandoning ship",points:-200}),n.push({label:`${e.captives} Klingons captured`,points:3*e.captives}),n.push({label:`${e.deaths} casualties`,points:-e.deaths}),{items:n,total:n.reduce((a,l)=>a+l.points,0)}}function zv(t,e){const{quadrant:s,sector:i}=t.position,n=s.x+i.x/Ss-(e.quadrant.x+e.sector.x/Ss),r=e.quadrant.y+e.sector.y/Ss-(s.y+i.y/Ss);let o=Math.atan2(r,n);return o<0&&(o+=2*Math.PI),{course:Math.trunc(o*180/Math.PI+.5)%360,distance:Math.hypot(n,r)}}function S6(t,e,s){const{quadrant:i,sector:n}=t.position,r=e*Math.PI/180,o=Math.min(Ul*Ss-1,Math.max(0,Math.round(i.x*Ss+n.x-Math.cos(r)*s*Ss))),a=Math.min(Ul*Ss-1,Math.max(0,Math.round(i.y*Ss+n.y+Math.sin(r)*s*Ss)));return{quadrant:{x:Math.trunc(o/Ss),y:Math.trunc(a/Ss)},sector:{x:o%Ss,y:a%Ss}}}function W1(t,e,s){const i=Math.trunc((t+.05)*e*e*e);return{stardates:s*t/(e*e),units:i,unitsShielded:2*i}}function x6(t){return{stardates:t/.095,units:Math.trunc(20+100*t)}}function F1(t){return Math.trunc(Math.pow(.9,t*10)*98+.5)}function Sv(t,e){if(t.repairAt===null)return null;const s=t.repairAt-e.mission.stardate,i=e.condition.name==="DOCKED",n=i?1/e.param.dockfac:1,r=i?1:e.param.dockfac;return{inFlight:s*n+.005,docked:s*r+.005}}function U1(t,e){const s=[],i=(d,u)=>`${d>0?"+":d<0?"−":""}${Math.abs(d).toFixed(u)}`,n=e.mission.stardate-t.mission.stardate;Math.abs(n)>=.005&&s.push({label:"STARDATE",change:i(n,2),bad:!1});const r=e.ship.energy-t.ship.energy;r!==0&&s.push({label:"ENERGY",change:i(r,0),bad:r<0});const o=e.ship.shield-t.ship.shield;o!==0&&s.push({label:"SHIELDS",change:i(o,0),bad:o<0});const a=e.ship.torpedoes-t.ship.torpedoes;a!==0&&s.push({label:"TORPEDOES",change:i(a,0),bad:!1});const l=e.mission.klingonsLeft-t.mission.klingonsLeft;l!==0&&s.push({label:"KLINGONS",change:`${i(l,0)} · ${e.mission.klingonsLeft} LEFT`,bad:l>0});const c=e.damaged.filter(d=>!t.damaged.some(u=>u.index===d.index));c.length>0&&s.push({label:"DAMAGE",change:c.map(d=>d.name.toUpperCase()).join(" · "),bad:!0});const h=t.damaged.filter(d=>!e.damaged.some(u=>u.index===d.index));return h.length>0&&s.push({label:"REPAIRED",change:h.map(d=>d.name.toUpperCase()).join(" · "),bad:!1}),t.condition.name!==e.condition.name&&s.push({label:"CONDITION",change:e.condition.name,bad:e.condition.name==="RED"}),s}const O6=[["return to continue","return"],["What length game","length"],["What skill game","skill"],["Enter password verification","password-verify"],["Enter a password","password"],["Enter tournament code","tournament"],["Command","command"],["Torpedo course","torpedo-course"],["Course","course"],["course","bank-course"],["Distance","distance"],["distance","computer-distance"],["Warp factor","warp-factor"],["warp factor","computer-warp"],["How long","how-long"],["Manual or automatic","manual-automatic"],["Units to fire","units"],["units","bank-units"],["spread","spread"],["Do you want a burst","burst"],["burst angle","burst-angle"],["Up or down","up-down"],["Request","request"],["Quadrant","quadrant"],["q-y","quadrant-y"],["Sector","sector"],["s-y","sector-y"],["range","range"],["direction","direction"],["status report","status-report"],["Another game","another"]];function E6(t){const e=t.replace(/[:.\s]+$/,"");if(e==="")return"return";for(const[s,i]of O6)if(e.endsWith(s))return i;return/wise$|certain that is wise$|Shall we cancel our rest period$/.test(e)?"yes-no":"unknown"}const Pd=[{id:"move",label:"MOVE",station:"helm",line:"m",asks:["course","distance"]},{id:"ram",label:"RAM",station:"helm",line:"ram",asks:["course","distance"]},{id:"warp",label:"WARP",station:"helm",line:"w",asks:["warp-factor"]},{id:"impulse",label:"IMPULSE",station:"helm",line:"i",asks:["course","distance"]},{id:"dock",label:"DOCK",station:"helm",line:"do",asks:[]},{id:"undock",label:"UNDOCK",station:"helm",line:"u",asks:[]},{id:"rest",label:"REST",station:"helm",line:"r",asks:["how-long"]},{id:"phasers",label:"PHASERS",station:"tactical",line:"p",asks:["manual-automatic","units"]},{id:"torpedo",label:"TORPEDO",station:"tactical",line:"t",asks:["torpedo-course","burst","burst-angle"]},{id:"shields",label:"SHIELDS",station:"tactical",line:"sh",asks:["up-down"]},{id:"cloak",label:"CLOAK",station:"tactical",line:"cl",asks:["up-down"]},{id:"capture",label:"CAPTURE",station:"tactical",line:"ca",asks:[]},{id:"visual",label:"VISUAL",station:"tactical",line:"v",asks:["direction"]},{id:"computer",label:"COMPUTER",station:"ship",line:"c",asks:["request"]},{id:"help",label:"CALL STARBASE",station:"ship",line:"help",asks:[]},{id:"dump",label:"DUMP",station:"ship",line:"dump",asks:[]},{id:"credits",label:"CREDITS",station:"ship",line:"cr",asks:[]},{id:"abandon",label:"ABANDON",station:"ship",line:"abandon",asks:[],grave:!0},{id:"destruct",label:"DESTRUCT",station:"ship",line:"destruct",asks:["password-verify"],grave:!0},{id:"terminate",label:"TERMINATE",station:"ship",line:"terminate",asks:[],grave:!0}];function xs(t,e){switch(t){case"return":return{kind:"auto"};case"length":return{kind:"pills",choices:[{label:"SHORT",line:"s"},{label:"MEDIUM",line:"m"},{label:"LONG",line:"l"},{label:"RESTART",line:"restart"}]};case"skill":return{kind:"pills",choices:[{label:"NOVICE",line:"n"},{label:"FAIR",line:"f"},{label:"GOOD",line:"g"},{label:"EXPERT",line:"e"},{label:"COMMODORE",line:"c"},{label:"IMPOSSIBLE",line:"i"}]};case"password":case"tournament":case"password-verify":return{kind:"auto"};case"course":case"torpedo-course":case"direction":case"bank-course":return{kind:"wheel",min:0,max:360,step:1,commit:"SET COURSE",cancel:"-1"};case"distance":return{kind:"slider",min:0,max:15,step:.1,commit:"ENGAGE",cancel:"-1"};case"computer-distance":case"range":return{kind:"slider",min:0,max:15,step:.1,commit:"SET"};case"warp-factor":return{kind:"slider",min:1,max:10,step:.1,commit:"SET WARP",cancel:"-1"};case"computer-warp":return{kind:"slider",min:1,max:10,step:.1,commit:"SET"};case"how-long":return{kind:"slider",min:0,max:Math.max(.1,e?.mission.timeLeft??15),step:.1,commit:"REST",cancel:"0"};case"manual-automatic":return{kind:"pills",choices:[{label:"MANUAL",line:"m"},{label:"AUTOMATIC",line:"a"}]};case"units":return{kind:"slider",min:0,max:Math.max(10,e?.ship.energy??5e3),step:10,commit:"FIRE",cancel:"0"};case"bank-units":return{kind:"slider",min:0,max:Math.max(10,e?.ship.energy??5e3),step:10,commit:"SET",cancel:"0"};case"spread":return{kind:"slider",min:0,max:1,step:.05,commit:"SET"};case"burst":case"status-report":case"another":case"yes-no":return{kind:"yesno",choices:[{label:"YES",line:"y"},{label:"NO",line:"n"}]};case"burst-angle":return{kind:"pills",choices:[1,2,3,5,8,10,12,15].map(s=>({label:`${s}°`,line:String(s)})),cancel:"0"};case"up-down":return{kind:"pills",choices:[{label:"UP",line:"u"},{label:"DOWN",line:"d"}]};case"request":return{kind:"pills",choices:[{label:"CHART",line:"ch"},{label:"TRAJECTORY",line:"t"},{label:"COURSE",line:"c"},{label:"MOVE",line:"m"},{label:"SCORE",line:"s"},{label:"PHASER EFFECT",line:"p"},{label:"WARP COST",line:"w"},{label:"IMPULSE COST",line:"i"},{label:"DISTRESS LIST",line:"d"}]};case"quadrant":case"quadrant-y":return{kind:"slider",min:0,max:Ul-1,step:1,commit:"SET"};case"sector":case"sector-y":return{kind:"slider",min:0,max:Ss-1,step:1,commit:"SET"};default:return{kind:"text"}}}function A6(){return`argus${Math.floor(Math.random()*9e3+1e3)}`}class T6{constructor(e){this.hooks=e}hooks;open=null;lastCommand=null;password=A6();ended=!1;ask(e){const s=E6(e);return s==="return"?Promise.resolve(""):s==="password"||s==="tournament"||s==="password-verify"?Promise.resolve(this.password):(s==="command"&&(this.lastCommand=null),new Promise(i=>{this.open={question:{prompt:e,question:s,command:this.lastCommand},answer:i},this.hooks.question_changed(this.open.question)}))}question_get(){return this.open?.question??null}answer(e){if(this.open===null)return!1;const{answer:s}=this.open;return this.open=null,this.hooks.question_changed(null),s(e),!0}command_send(e){return this.open?.question.question!=="command"?!1:(this.lastCommand=e,this.answer(e.line))}abandon(){if(this.open===null)return!1;const{answer:e}=this.open;return this.open=null,this.hooks.question_changed(null),e(null),!0}text_take(e){this.hooks.text_written(e)}event_take(e,s){e==="games.trek.state"&&typeof s=="object"&&s!==null&&this.hooks.state_shown(s)}end(e){this.ended||(this.ended=!0,this.open=null,this.hooks.ended(e))}ended_is(){return this.ended}}const Un={torpedoPoint:140,sector:170,burst:800,beam:900,rescan:350,flare:900,tail:300},I6=[[/^Torpedo track(?:, torpedo number \d+)?:/,()=>({kind:"torpedo-head"})],[/^\s*(\d+\.\d)\s+(\d+\.\d)\s*$/,t=>({kind:"torpedo-point",at:{x:Number(t[1]),y:Number(t[2])}})],[/^Torpedo missed|^Torpedo disappears into a black hole/,()=>({kind:"torpedo-end"})],[/\*\*\* Klingon at (\d+),(\d+) destroyed \*\*\*/,t=>({kind:"kill",at:ui(t,1)})],[/^Starbase at (\d+),(\d+) destroyed/,t=>({kind:"kill",at:ui(t,1)})],[/^Inhabited starsystem .* at (\d+),(\d+) destroyed/,t=>({kind:"kill",at:ui(t,1)})],[/^Unknown object . at (\d+),(\d+) destroyed/,t=>({kind:"kill",at:ui(t,1)})],[/Star at (\d+),(\d+) gone nova/,t=>({kind:"nova",at:ui(t,1)})],[/^Photon tubes misfire/,()=>({kind:"misfire"})],[/^(\d+) unit hit on Klingon at (\d+),(\d+)/,t=>({kind:"phaser",at:ui(t,2)})],[/^HIT: (\d+) units(?: from (\d+),(\d+))?(?:, shields absorb (\d+)%)?/,t=>({kind:"incoming",hit:Number(t[1]),from:t[2]===void 0?null:ui(t,2),absorb:t[4]===void 0?0:Number(t[4])})],[/^Klingon at (\d+),(\d+) moves to (\d+),(\d+)/,t=>({kind:"klingon-move",from:ui(t,1),to:ui(t,3)})],[/^Klingon at (\d+),(\d+) escapes to quadrant (\d+),(\d+)/,t=>({kind:"klingon-escape",from:ui(t,1),quadrant:ui(t,3)})],[/RED ALERT: supernova occurring at (\d+),(\d+)/,t=>({kind:"supernova",at:ui(t,1)})],[/^\s*in quadrant (\d+),(\d+)\.\s+Caution is advised/,t=>({kind:"supernova-report",quadrant:ui(t,1)})]];function ui(t,e){return{x:Number(t[e]),y:Number(t[e+1])}}function D6(t){for(const[e,s]of I6){const i=e.exec(t);if(i!==null)return s(i)}return null}class C6{constructor(e=R6){this.reduced=e}reduced;frames=[];running=!1;skipping=!1;waiting=new Set;played={};push(e){this.frames.push(e),this.pump()}skip(){if(!(this.frames.length===0&&!this.running)){this.skipping=!0;for(const e of this.waiting)e();this.waiting.clear()}}busy_is(){return this.running||this.frames.length>0}pending_count(){return this.frames.length}skipping_is(){return this.skipping}async settle(){for(;this.busy_is();)await new Promise(e=>{setTimeout(e,1)})}wait(e){return this.skipping||e<=0?Promise.resolve():new Promise(s=>{const i=setTimeout(()=>{this.waiting.delete(n),s()},e),n=()=>{clearTimeout(i),s()};this.waiting.add(n)})}async tween(e,s){const i=xv();for(;!this.skipping;){const n=Math.min(1,(xv()-i)/Math.max(1,e));if(s(n),n>=1)return;await k6(this)}s(1)}async pump(){if(!this.running){this.running=!0;try{for(;this.frames.length>0;){const e=this.frames.shift();this.played[e.kind]=(this.played[e.kind]??0)+1;const s=this.skipping||this.reduced();try{await e.run(s)}catch{}}}finally{this.running=!1,this.skipping=!1}}}}function R6(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function xv(){return typeof performance=="object"?performance.now():Date.now()}function k6(t){return typeof requestAnimationFrame=="function"?new Promise(e=>{requestAnimationFrame(()=>e())}):t.wait(16)}function ya(t){return[t.y+.5,t.x+.5]}function $1(t,e){return(Math.atan2(e.y-t.y,-(e.x-t.x))*180/Math.PI+360)%360}function N6(t,e,s=10){const i={x:t.quadrant.x*s+t.sector.x,y:t.quadrant.y*s+t.sector.y},n={x:e.quadrant.x*s+e.sector.x,y:e.quadrant.y*s+e.sector.y},r={x:n.x-i.x,y:n.y-i.y},o=(p,f,_)=>{let g=_?1/0:-1/0;for(const m of["x","y"]){if(r[m]===0)continue;const w=p[m]*s-.5,y=p[m]*s+s-.5,b=(w-f[m])/r[m],v=(y-f[m])/r[m];_?g=Math.min(g,Math.max(b,v)):g=Math.max(g,Math.min(b,v))}return Number.isFinite(g)?Math.max(0,Math.min(1,g)):_?1:0},a=o(t.quadrant,i,!0),l=o(e.quadrant,i,!1),c=.7,h={x:i.x+r.x*a-t.quadrant.x*s,y:i.y+r.y*a-t.quadrant.y*s},d={x:i.x+r.x*l-e.quadrant.x*s,y:i.y+r.y*l-e.quadrant.y*s},u=Math.hypot(r.x,r.y)||1;return{exit:{x:h.x+r.x/u*c,y:h.y+r.y/u*c},entry:{x:d.x-r.x/u*c,y:d.y-r.y/u*c}}}function Ld(t,e=""){const s=st("g",{class:`tb-motion ${e}`.trim()});return t.append(s),s}const B6=.7;async function tl(t,e,s,i,n,r={},o=!1){if(o)return;const a=Ld(t,"tb-motion-slide"),[l,c]=ya(i),[h,d]=ya(n),u=r.hostile===!0?" tb-hostile":"";a.append(st("line",{class:`tb-track${u}`,x1:l,y1:c,x2:h,y2:d}));const p=st("line",{class:`tb-pulse tb-pulse-wide${u}`,x1:l,y1:c,x2:l,y2:c}),f=st("line",{class:`tb-pulse tb-pulse-core${u}`,x1:l,y1:c,x2:l,y2:c}),_=r.heading??$1(i,n),g=c_(s.kind,{cx:l,cy:c,size:B6},s.variant,_);g.classList.add(`tb-sector-${s.kind}`),a.append(p,f,g);const m=Math.max(1,Math.hypot(n.x-i.x,n.y-i.y));await e.tween(m*Un.sector,w=>{const y=l+(h-l)*w,b=c+(d-c)*w,v=Math.max(0,w-.12),z=l+(h-l)*v,x=c+(d-c)*v;for(const M of[p,f])M.setAttribute("x1",String(z)),M.setAttribute("y1",String(x)),M.setAttribute("x2",String(y)),M.setAttribute("y2",String(b));N1(g,y,b,_)}),a.remove()}async function Ov(t,e,s,i,n,r=!1){if(r)return;const o=Ld(t,"tb-motion-beam"),[a,l]=ya(s),[c,h]=ya(i),d=n?" tb-hostile":"";o.append(st("line",{class:`tb-beam${d}`,x1:a,y1:l,x2:c,y2:h}),st("line",{class:`tb-beam tb-beam-core${d}`,x1:a,y1:l,x2:c,y2:h})),await e.wait(Un.beam),o.remove()}async function eh(t,e,s,i,n=!1){if(n)return;const r=Ld(t,`tb-motion-burst tb-burst tb-burst-${i}`),[o,a]=ya(s),l=i==="misfire"?Un.burst*.6:i==="supernova"?Un.burst*1.6:Un.burst;r.style.setProperty("--tb-ms",`${l}ms`),r.append(st("circle",{class:"tb-burst-halo",cx:o,cy:a,r:.1}));const c=st("g",{class:"tb-burst-spikes"}),h=i==="nova"||i==="supernova"?12:8,d=i==="misfire"?.6:i==="supernova"?1.8:i==="nova"?1.1:.95;for(let u=0;u<h;u++){const p=u/h*Math.PI*2+(h===8?Math.PI/8:0);c.append(st("line",{class:"tb-burst-spike",x1:o+Math.cos(p)*.12,y1:a+Math.sin(p)*.12,x2:o+Math.cos(p)*d,y2:a+Math.sin(p)*d}))}r.append(c,st("circle",{class:"tb-burst-core",cx:o,cy:a,r:.04})),await e.wait(l),r.remove()}async function G6(t,e,s=!1){if(s)return;const i=t.querySelector(".tb-ring");if(i===null)return;const n=st("circle",{class:"tb-motion tb-ring-flare",cx:i.getAttribute("cx")??0,cy:i.getAttribute("cy")??0,r:.46});t.append(n),await e.wait(Un.flare),n.remove()}class P6{layer;tail;photon;points=[];constructor(e,s){this.layer=Ld(e,"tb-motion-torpedo"),this.tail=st("g",{class:"tb-tail"}),this.photon=st("g",{class:"tb-photon"}),this.photon.append(st("circle",{class:"tb-photon-halo",cx:0,cy:0,r:.34}));const i=st("g",{class:"tb-photon-pulses"});for(let o=0;o<10;o++){const a=st("g",{transform:`rotate(${o*36})`});a.append(st("rect",{x:.08,y:-.016,width:.2+o%3*.05,height:.032,rx:.006})),i.append(a)}this.photon.append(i,st("circle",{class:"tb-photon-core",cx:0,cy:0,r:.12})),this.layer.append(this.tail,this.photon);const[n,r]=ya(s);this.points.push([n,r]),this.photon.setAttribute("transform",`translate(${n} ${r})`)}async point_reach(e,s,i=!1){const[n,r]=[s.y,s.x];this.points.push([n,r]),this.photon.setAttribute("transform",`translate(${n} ${r})`),this.tail.replaceChildren();const o=this.points.slice(-4);for(let a=1;a<o.length;a++){const[l,c]=o[a-1],[h,d]=o[a];this.tail.append(st("line",{class:"tb-tail-segment",x1:l,y1:c,x2:h,y2:d,"stroke-width":.03+.03*a,opacity:.25+.25*a}))}i||await e.wait(Un.torpedoPoint)}async end(e,s=!1){this.photon.remove(),s||await e.wait(Un.tail),this.layer.remove()}}function Ev(t,e){t.classList.toggle("tb-rescan",e)}function L6(t,e){t.classList.remove("tb-bloom","tb-bloom-hostile"),t.offsetWidth,t.classList.add("tb-bloom"),e&&t.classList.add("tb-bloom-hostile"),t.addEventListener("animationend",()=>t.classList.remove("tb-bloom","tb-bloom-hostile"),{once:!0})}function gi(t,e){return t!==null&&e.includes(t.question)}function Wd(t,e){const s=q("div","tb-station-head"),i=q("span","tb-station-step",""),n=Os("tb-grave tb-cancel","CANCEL",()=>{e.answer_send(n.dataset.line??"","CANCEL")});return n.hidden=!0,s.append(q("span","tb-station-name",t),i,q("span","tb-station-fill"),n),{root:s,step:i,cancel:n}}function Fd(t,e,s,i){const n=s?.command??null,r=n!==null&&n.station===e&&s!==null&&s.question!=="command";t.step.textContent=r&&n!==null&&s!==null?`${n.label} · ${s.question.replace(/-/g," ").toUpperCase()}`:s?.question==="command"?"READY":"";const o=r?i?.cancel:void 0;t.cancel.hidden=o===void 0,t.cancel.dataset.line=o??"",t.cancel.textContent=n===null?"CANCEL":`CANCEL ${n.label}`}function d_(t,e){const s=Os(`tb-command${t.grave===!0?" tb-grave":""}`,t.label,()=>{e.command_send(t)});return s.dataset.command=t.id,s}function j1(t,e){const s=q("div","tb-pills tb-command-pills"),i=new Map;for(const n of Pd.filter(r=>r.station===t)){const r=d_(n,e);i.set(n.id,r),s.append(r)}return{root:s,pills:i}}function Ud(t,e){for(const[s,i]of t)i.disabled=e?.question!=="command",i.classList.toggle("tb-pill-on",e?.command?.id===s)}function H1(t,e){const s=Os("tb-target","",e);return s.append(h_("klingon",t.mark),document.createTextNode(`${t.x},${t.y}`)),s.title=`Klingon at ${t.x},${t.y}`,s}function dm(t,e){const s=q("span",t,e.supernova?"":e.code??"");return e.supernova&&s.append(h_("supernova")),s}function um(t){return`quadrant ${t.x},${t.y}${t.supernova?" · supernova":t.code===null?" · unscanned":""}`}function V1(t){const e=t.klingons.map(s=>({bearing:s.bearing,kind:"klingon",label:`Klingon at ${s.x},${s.y} · ${s.range.toFixed(1)} · ${Math.round(s.bearing)}°`,variant:s.mark}));for(const s of t.sectors)for(const i of s){if(i.kind!=="base")continue;const n=i.x-t.position.sector.x,r=i.y-t.position.sector.y;e.push({bearing:(Math.atan2(r,-n)*180/Math.PI+360)%360,kind:"base",label:`starbase at ${i.x},${i.y}`})}return e}class Av{root;wheel;distance;warp;rest;head;pills;readout=null;constructor(e,s,i){this.root=q("div","tb-station tb-station-helm"),this.head=Wd("HELM",e);const n=j1("helm",e);this.pills=n.pills;const r=q("div","tb-controls");this.wheel=new B1(s,"course wheel",a=>e.answer_send(String(a),"SET COURSE"));const o=q("div","tb-sliders");this.distance=new xr(`${i}-distance`,"DISTANCE",1,a=>e.answer_send(a.toFixed(1),"SLIDER SET")),this.warp=new xr(`${i}-warp`,"WARP FACTOR",1,a=>e.answer_send(a.toFixed(1),"SLIDER SET")),this.rest=new xr(`${i}-rest`,"REST",1,a=>e.answer_send(a.toFixed(1),"SLIDER SET")),this.distance.input_listen(()=>this.arrival_note()),o.append(this.distance.root,this.warp.root,this.rest.root),r.append(this.wheel.root,o),this.root.append(this.head.root,n.root,r)}state_show(e){const s=this.readout===null;this.readout=e,this.wheel.marks_set(V1(e)),this.warp.range_set(xs("warp-factor",e),e.ship.warp,"THE SHIP NOW · ABOVE 6 THE ENGINES MAY BURN",10),this.distance.range_set(xs("distance",e),s?1:this.distance.value_get(),"QUADRANTS · 0.1 IS ONE SECTOR",6),this.rest.range_set(xs("how-long",e),0,`STARDATES · ${e.mission.timeLeft.toFixed(1)} LEFT · REPAIRS RUN WHILE TIME PASSES`,2)}question_show(e){Ud(this.pills,e);const s=e===null?null:xs(e.question,this.readout);Fd(this.head,"helm",e,s),this.wheel.lit_set(gi(e,["course","direction"]),"SET COURSE"),this.distance.lit_set(gi(e,["distance"]),"ENGAGE"),this.warp.lit_set(gi(e,["warp-factor"]),"SET WARP"),this.rest.lit_set(gi(e,["how-long"]),"REST"),e?.question==="distance"&&this.arrival_note()}arrival_note(){if(this.readout===null)return;const e=this.distance.value_get(),s=S6(this.readout,this.wheel.degrees_get(),e),i=W1(e,this.readout.ship.warp,this.readout.param.warptime);this.distance.note_set(`ARRIVES ${s.quadrant.x},${s.quadrant.y} / ${s.sector.x},${s.sector.y} · ${i.stardates.toFixed(2)} STARDATES AT WARP ${this.readout.ship.warp.toFixed(1)} · ${i.units} UNITS`)}}class Tv{constructor(e,s,i){this.host=e,this.root=q("div","tb-station tb-station-tactical"),this.head=Wd("TACTICAL",e);const n=j1("tactical",e);this.pills=n.pills;const r=q("div","tb-controls");this.wheel=new B1(s,"firing course wheel",l=>e.answer_send(String(l),"SET COURSE"));const o=q("div","tb-sliders");this.burst=new Qc("BURST",xs("burst",null).choices??[],(l,c)=>e.answer_send(l,gr(c,"choice"))),this.burstAngle=new Qc("BURST ANGLE",xs("burst-angle",null).choices??[],(l,c)=>{this.wheel.wedge_set(Number(l)),e.answer_send(l,gr(c,"choice"))}),this.manual=new Qc("PHASERS",xs("manual-automatic",null).choices??[],(l,c)=>e.answer_send(l,gr(c,"choice"))),this.units=new xr(`${i}-units`,"UNITS",0,l=>e.answer_send(String(Math.round(l)),"SLIDER SET")),this.spread=new xr(`${i}-spread`,"SPREAD",2,l=>e.answer_send(l.toFixed(2),"SLIDER SET")),this.upDown=new Qc("SHIELDS",xs("up-down",null).choices??[],(l,c)=>e.answer_send(l,gr(c,"choice")));const a=q("div","tb-fire-row");this.fire=Os("tb-fire","FIRE",()=>e.answer_send("0",null)),this.targets=q("div","tb-targets"),a.append(this.fire,this.targets),o.append(this.burst.root,this.burstAngle.root,this.manual.root,this.units.root,this.spread.root,this.upDown.root,a),r.append(this.wheel.root,o),this.root.append(this.head.root,n.root,r)}host;root;wheel;units;spread;head;pills;burst;burstAngle;manual;upDown;fire;targets;readout=null;state_show(e){this.readout=e,this.wheel.marks_set(V1(e)),this.wheel.wedge_set(null),e.klingons[0]!==void 0&&this.wheel.degrees_set(e.klingons[0].bearing),this.units.range_set(xs("units",e),Math.min(e.ship.energy,Math.round(e.ship.energy/100)*10),`UP TO THE ${e.ship.energy} FREE`,6),this.spread.range_set(xs("spread",e),.5,"MANUAL PHASERS ONLY",3),this.burst.note_set(`${e.ship.torpedoes} TORPEDOES · A BURST FIRES 3`),this.upDown.note_set(`${e.ship.shieldsUp?"UP":"DOWN"} · ${e.ship.shield} OF ${e.ship.shieldMax} · REFILLS AT A STARBASE`);const s=this.pills.get("phasers");s!==void 0&&(s.classList.toggle("tb-barred",e.ship.shieldsUp),s.title=e.ship.shieldsUp?"Shields are up: phasers cannot fire through them. SHIELDS, then DOWN, first.":""),this.targets_draw(e)}question_show(e){Ud(this.pills,e);const s=e===null?null:xs(e.question,this.readout);Fd(this.head,"tactical",e,s),this.wheel.lit_set(gi(e,["torpedo-course","bank-course"]),"SET COURSE"),this.burst.lit_set(gi(e,["burst"])),this.burstAngle.lit_set(gi(e,["burst-angle"])),this.manual.lit_set(gi(e,["manual-automatic"])),this.units.lit_set(gi(e,["units","bank-units"]),e?.question==="units"?"FIRE":"SET BANK"),this.spread.lit_set(gi(e,["spread"])),this.upDown.lit_set(gi(e,["up-down"])),this.fire.disabled=!gi(e,["bank-units"]),this.fire.textContent="FIRE THE BANKS SET"}targets_draw(e){if(this.targets.replaceChildren(),e.klingons.length===0){this.targets.append(q("span","tb-note","NO KLINGONS IN THIS QUADRANT"));return}for(const s of["TARGET","RANGE","BEARING","PHASER HIT"])this.targets.append(q("span","tb-target-head",s));for(const s of e.klingons){const i=H1(s,()=>{this.host.voice.cue("scanner"),this.host.course_set(s.bearing,s.range/10)});this.targets.append(i,q("span","tb-target-cell",s.range.toFixed(1)),q("span","tb-target-cell",`${Math.round(s.bearing)}°`),q("span","tb-target-cell",`${F1(s.range/10)}%`))}}}class W6{root;rest;head;pills;damage;systems;since;inThatTime;readout=null;constructor(e){this.root=q("div","tb-view-body tb-view-engineering");const s=q("section","tb-panel tb-damage");s.append(q("span","tb-title","DAMAGE CONTROL"),q("span","tb-note","THE C'S REPORT · ALWAYS ON")),this.damage=q("div","tb-dc"),s.append(this.damage,q("span","tb-note","REPAIR TIMES IN STARDATES · REPAIRS RUN WHILE TIME PASSES · DOCKED, FASTER BY THE DOCK FACTOR"));const i=q("section","tb-panel tb-systems-section");i.append(q("span","tb-title","SHIP"),q("span","tb-note","ENERGY, SHIELDS, RESERVES")),this.systems=q("div","tb-systems"),i.append(this.systems,q("span","tb-title","SINCE THE LAST COMMAND")),this.since=q("div","tb-head-grid tb-since-grid"),i.append(this.since,q("span","tb-note","SHIELDS ARE UP OR DOWN IN TREK(6): THEIR ENERGY IS A READOUT, REFILLED AT A STARBASE"));const n=q("section","tb-panel tb-station tb-station-time");this.head=Wd("REST",e);const r=q("div","tb-pills tb-command-pills");this.pills=new Map;for(const o of["rest","dock","undock"]){const a=Pd.find(c=>c.id===o);if(a===void 0)continue;const l=d_(a,e);this.pills.set(o,l),r.append(l)}this.rest=new xr("tbe-rest","HOW LONG",1,o=>e.answer_send(o.toFixed(1),"SLIDER SET")),this.rest.input_listen(()=>this.inThatTime_note()),this.inThatTime=q("div","tb-in-that-time"),n.append(this.head.root,r,this.rest.root,q("span","tb-title","IN THAT TIME"),this.inThatTime),this.root.append(s,i,n)}state_show(e,s){this.readout=e,this.damage_draw(e),this.systems_draw(e),this.since.replaceChildren();const i=s===null?[]:U1(s,e);i.length===0&&this.since.append(q("span","tb-head-label","—"),q("span","tb-head-value","NOTHING MOVED"));for(const n of i)this.since.append(q("span","tb-head-label",n.label),q("span",`tb-head-value ${n.bad?"tb-bad":"tb-good"}`,n.change));this.rest.range_set(xs("how-long",e),this.rest.value_get(),`STARDATES · ${e.mission.timeLeft.toFixed(1)} LEFT`,4),this.inThatTime_note()}question_show(e){Ud(this.pills,e);const s=e===null?null:xs(e.question,this.readout),i=e!==null&&(e.command===null||["rest","dock","undock"].includes(e.command.id))?e:null;Fd(this.head,"helm",i,s),this.rest.lit_set(gi(e,["how-long"]),"REST")}damage_draw(e){this.damage.replaceChildren();for(const i of["DEVICE","","IN FLIGHT","DOCKED",""])this.damage.append(q("span","tb-dc-head",i));const s=Math.max(1,...e.damaged.map(i=>(i.repairAt??0)-e.mission.stardate));for(const i of e.devices){const n=Sv(i,e),r=q("div","tb-bar-track"),o=q("div",`tb-bar-fill${n===null?" tb-bar-ok":" tb-bar-down"}`);o.style.width=n===null?"100%":`${Math.max(4,Math.min(100,Math.round(100*((i.repairAt??0)-e.mission.stardate)/s)))}%`,r.append(o),this.damage.append(q("span",`tb-dc-name${n===null?"":" tb-bad"}`,i.name.toUpperCase()),r,q("span","tb-dc-time",n===null?"—":n.inFlight.toFixed(2)),q("span","tb-dc-time",n===null?"—":n.docked.toFixed(2)),q("span",`tb-dc-state${n===null?" tb-good":" tb-bad"}`,n===null?"OK":"DOWN"))}}systems_draw(e){const{ship:s}=e;this.systems.replaceChildren();const i=(l,c,h,d,u)=>{const p=q("div","tb-bar-track"),f=q("div",`tb-bar-fill${u?" tb-bar-down":" tb-bar-ok"}`);f.style.width=`${Math.max(0,Math.min(100,Math.round(100*c/Math.max(1,h))))}%`,p.append(f),this.systems.append(q("span","tb-dc-name",l),p,q("span","tb-dc-time tb-sys-value",d))};i("ENERGY",s.energy,s.energyMax,`${s.energy} / ${s.energyMax}`,s.energy<s.energyMax/4),i("SHIELDS",s.shield,s.shieldMax,`${s.shieldsUp?"UP":"DOWN"} · ${s.shield} / ${s.shieldMax}`,s.shield<s.shieldMax/4),i("LIFE SUPPORT",s.reserves,s.reservesMax,`RESERVES ${s.reserves.toFixed(1)} / ${s.reservesMax.toFixed(1)}`,s.reserves<s.reservesMax/4);const n=q("div","tb-pips");for(let l=0;l<s.torpedoesMax;l++)n.append(q("span",`tb-pip${l<s.torpedoes?" tb-pip-on":""}`));this.systems.append(q("span","tb-dc-name","TORPEDOES"),n,q("span","tb-dc-time tb-sys-value",`${s.torpedoes} / ${s.torpedoesMax}`));const r=(l,c)=>{this.systems.append(q("span","tb-dc-name",l),q("span","tb-sys-text",c))};r("CREW",`${s.crew}${e.mission.captives>0?` · ${e.mission.captives} CAPTIVE`:" · BRIG EMPTY"}`);const o=e.damaged.some(l=>/warp/i.test(l.name));r("WARP",`${s.warp.toFixed(1)} · ENGINES ${o?"DOWN":"OK"}`);const a=e.damaged.some(l=>/cloak/i.test(l.name));r("CLOAK",`${s.cloaked?"ON":"OFF"} · DEVICE ${a?"DOWN":"OK"}`)}inThatTime_note(){if(this.readout===null)return;const e=this.rest.value_get();this.inThatTime.replaceChildren();const s=this.readout.damaged.filter(n=>(Sv(n,this.readout)?.inFlight??1/0)<=e).map(n=>n.name.toUpperCase());this.inThatTime.append(q("span","tb-head-value tb-good",s.length===0?e>0?"NO REPAIR COMPLETES":"—":`${s.join(" · ")} REPAIRED`));const i=this.readout.klingons.length;i>0&&this.inThatTime.append(q("span","tb-head-value tb-bad",`${i} KLINGON${i===1?"":"S"} IN THE QUADRANT WILL FIRE · SPOCK MAY ASK TO CANCEL`))}}const Iv=[{label:"CHART",line:"ch",asks:[]},{label:"TRAJECTORY",line:"t",asks:[]},{label:"COURSE",line:"c",asks:["quadrant","quadrant-y","sector","sector-y"]},{label:"MOVE",line:"m",asks:["quadrant","quadrant-y","sector","sector-y"]},{label:"SCORE",line:"s",asks:[]},{label:"PHASER EFFECT",line:"p",asks:["range"]},{label:"WARP COST",line:"w",asks:["computer-distance","computer-warp"]},{label:"IMPULSE COST",line:"i",asks:["computer-distance"]},{label:"DISTRESS LIST",line:"d",asks:[]}];class F6{constructor(e){this.host=e,this.root=q("div","tb-view-body tb-view-computer");const s=q("section","tb-panel tb-chart-section");s.append(q("span","tb-title","GALAXY · WHAT THE SHIP HAS SEEN"),q("span","tb-note","PRESS A QUADRANT: THE COURSE PANEL AIMS AT IT · HUNDREDS KLINGONS, TENS BASES, ONES STARS")),this.chart=q("div","tb-chart-big"),s.append(this.chart);const i=q("section","tb-station tb-station-computer");this.head=Wd("COMPUTER",e);const n=q("div","tb-pills tb-command-pills");for(const d of Iv){const u=Os("tb-command tb-request",d.label,()=>this.request_send(d));u.dataset.request=d.line,this.requestPills.push(u),n.append(u)}const r=q("div","tb-computer-panels"),o=q("div","tb-panel");o.append(q("span","tb-title","COURSE AND DISTANCE")),this.courseGrid=q("div","tb-head-grid");const a=q("div","tb-pills");a.append(Os("tb-commit tb-send-helm","SEND TO HELM",()=>this.helm_send()),Os("tb-commit tb-move-now","MOVE THERE NOW",()=>this.request_send(Iv[3]))),o.append(this.courseGrid,a);const l=q("div","tb-panel");l.append(q("span","tb-title","WARP COST")),this.wcDistance=new xr("tbc-distance","DISTANCE",2,()=>{}),this.wcWarp=new xr("tbc-warp","WARP FACTOR",1,()=>{}),this.wcDistance.root.classList.add("tb-local"),this.wcWarp.root.classList.add("tb-local"),this.wcDistance.input_listen(()=>this.costs_note()),this.wcWarp.input_listen(()=>{this.warpTouched=!0,this.costs_note()}),this.wcResult=q("div","tb-head-grid"),l.append(this.wcDistance.root,this.wcWarp.root,this.wcResult);const c=q("div","tb-panel");c.append(q("span","tb-title","TRAJECTORY · KLINGONS HERE")),this.trajectory=q("div","tb-targets"),c.append(this.trajectory,q("span","tb-title","SCORE SO FAR")),this.score=q("div","tb-score"),c.append(this.score);const h=q("div","tb-panel tb-answer-panel");h.append(q("span","tb-title","THE COMPUTER ANSWERS")),this.answer=q("pre","tb-computer-answer","—"),h.append(this.answer),r.append(o,l,c,h),i.append(this.head.root,n,r),this.root.append(s,i)}host;root;head;chart;requestPills=[];courseGrid;wcDistance;wcWarp;wcResult;trajectory;score;answer;readout=null;target=null;open=null;warpTouched=!1;state_show(e){this.readout=e,this.target===null&&(this.target={quadrant:{...e.position.quadrant},sector:{...e.position.sector}}),this.chart_draw(e),this.wcWarp.range_set(xs("computer-warp",e),this.warpTouched?this.wcWarp.value_get():e.ship.warp,"THE SHIP'S NOW",4),this.wcDistance.range_set(xs("computer-distance",e),this.wcDistance.value_get(),"QUADRANTS · FILLED FROM THE COURSE",4),this.wcDistance.lit_set(!0,""),this.wcWarp.lit_set(!0,""),this.course_note(),this.trajectory_draw(e),this.score_draw(e)}question_show(e){this.open=e;const s=e===null?null:xs(e.question,this.readout);Fd(this.head,"ship",e,s);const i=e?.question==="command"||e?.question==="request";for(const n of this.requestPills)n.disabled=!i}answer_take(e){if(e===null){this.answer.textContent="";return}this.answer.textContent=`${this.answer.textContent??""}${e}`.replace(/^\s*\n/,"")}sector_set(e){this.readout!==null&&(this.target={quadrant:this.target?.quadrant??{...this.readout.position.quadrant},sector:{x:e.x,y:e.y}},this.course_note())}request_send(e){const s=e.asks.map(n=>[n,this.plannedAnswer_derive(n)]);if(this.open?.question==="request"){this.host.plan_set(s),this.answer_take(null),this.host.answer_send(e.line,gr(e.label,"computer")),this.host.voice.cue("thinking");return}const i=Pd.find(n=>n.id==="computer");if(i===void 0||this.open?.question!=="command"){this.host.voice.cue("deny");return}this.host.plan_set([["request",e.line],...s]),this.answer_take(null),this.host.voice.pill(gr(e.label,"computer")),this.host.command_send(i)}plannedAnswer_derive(e){const s=this.target,i=this.readout?.klingons[0];switch(e){case"quadrant":return String(s?.quadrant.x??0);case"quadrant-y":return String(s?.quadrant.y??0);case"sector":return String(s?.sector.x??0);case"sector-y":return String(s?.sector.y??0);case"range":return(i===void 0?this.wcDistance.value_get():i.range/10).toFixed(2);case"computer-distance":return this.wcDistance.value_get().toFixed(2);case"computer-warp":return this.wcWarp.value_get().toFixed(1);default:return""}}helm_send(){if(this.readout===null||this.target===null)return;const e=zv(this.readout,this.target);this.host.voice.pill("SEND TO HELM"),this.host.course_set(e.course,Math.round(e.distance*10)/10)}chart_draw(e){this.chart.replaceChildren(),this.chart.append(q("span","tb-srs-corner",""));for(let s=0;s<(e.chart[0]?.length??0);s++)this.chart.append(q("span","tb-srs-axis",String(s)));for(const s of e.chart){this.chart.append(q("span","tb-srs-axis",String(s[0]?.x??"")));for(const i of s)this.chart.append(this.quadrantButton_make(i))}}quadrantButton_make(e){const s=this.target?.quadrant.x===e.x&&this.target.quadrant.y===e.y,i=Os(`tb-cq${e.here?" tb-here":""}${e.klingons>0?" tb-hostile":""}${e.bases>0?" tb-based":""}${e.code===null?" tb-unscanned":""}${s?" tb-pressed":""}`,"",()=>{this.readout!==null&&(this.target={quadrant:{x:e.x,y:e.y},sector:this.target?.sector??{...this.readout.position.sector}},this.host.voice.cue("scanner"),this.chart_draw(this.readout),this.course_note())});return i.dataset.x=String(e.x),i.dataset.y=String(e.y),i.append(dm("tb-cq-code",e),q("span","tb-cq-at",`${e.x},${e.y}`)),i.title=um(e),i}course_note(){if(this.readout===null||this.target===null)return;const{position:e}=this.readout,s=zv(this.readout,this.target);this.courseGrid.replaceChildren(q("span","tb-head-label","FROM"),q("span","tb-head-value",`QUADRANT ${e.quadrant.x},${e.quadrant.y} · SECTOR ${e.sector.x},${e.sector.y}`),q("span","tb-head-label","TO"),q("span","tb-head-value",`QUADRANT ${this.target.quadrant.x},${this.target.quadrant.y} · SECTOR ${this.target.sector.x},${this.target.sector.y}`),q("span","tb-head-label","COURSE"),q("span","tb-head-value tb-course-value",`${s.course}°`),q("span","tb-head-label","DISTANCE"),q("span","tb-head-value tb-distance-value",s.distance.toFixed(2))),this.wcDistance.value_set(Math.round(s.distance*100)/100),this.costs_note()}costs_note(){if(this.readout===null)return;const e=this.wcDistance.value_get(),s=W1(e,this.wcWarp.value_get(),this.readout.param.warptime),i=x6(e);this.wcResult.replaceChildren(q("span","tb-head-label","TIME"),q("span","tb-head-value",`${s.stardates.toFixed(2)} STARDATES`),q("span","tb-head-label","ENERGY"),q("span","tb-head-value",`${s.units} UNITS · ${s.unitsShielded} WITH SHIELDS UP`),q("span","tb-head-label","AT IMPULSE"),q("span","tb-head-value",`${i.stardates.toFixed(2)} STARDATES · ${i.units} UNITS`))}trajectory_draw(e){if(this.trajectory.replaceChildren(),e.klingons.length===0){this.trajectory.append(q("span","tb-note","NO KLINGONS IN THIS QUADRANT"));return}for(const s of["AT","COURSE","RANGE","PHASER HIT"])this.trajectory.append(q("span","tb-target-head",s));for(const s of e.klingons)this.trajectory.append(H1(s,()=>{this.host.voice.cue("scanner"),this.host.course_set(s.bearing,s.range/10)}),q("span","tb-target-cell",`${Math.round(s.bearing)}°`),q("span","tb-target-cell",s.range.toFixed(1)),q("span","tb-target-cell",`${F1(s.range/10)}%`))}score_draw(e){const s=L1(e);this.score.replaceChildren();for(const i of s.items.filter(n=>n.points!==0||/killed|remaining/.test(n.label)))this.score.append(q("span","tb-score-label",i.label.toUpperCase()),q("span",`tb-score-points${i.points<0?" tb-bad":" tb-good"}`,`${i.points>0?"+":""}${i.points}`));this.score.append(q("span","tb-score-label tb-score-total","TOTAL"),q("span","tb-score-points tb-score-total",String(s.total)))}}const U6=["bridge","helm","tactical","engineering","computer"],$6=400,j6="-0.6 -0.6 10.6 10.6",H6=.7,V6=/^S\.R\. scanners$/i,q6=/^L\.R\. scanners$/i,K6={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]},Y6=["length","skill","request","quadrant","quadrant-y","sector","sector-y","range","computer-distance","computer-warp","status-report","another","yes-no","unknown"];class X6{constructor(e,s){this.hooks=e,this.harness=new T6({question_changed:d=>{this.partial_flush(),this.question_show(d)},text_written:d=>this.text_take(d),state_shown:d=>this.state_show(d),ended:()=>{this.leaving||this.hooks.voice.cue("gameover")}}),this.root=q("section","trek-bridge"),this.root.id="trek-bridge",this.root.dataset.view="bridge",this.root.setAttribute("aria-label","trek: the bridge");const i={},n=qj();n!==null&&this.root.append(n);const r=this.gutter_build(i,s),[o,a]=this.frame_build(),l=this.header_build(i),c=this.body_build(i);this.strip_build(i);const h=this.log_build(i);this.leaveAsk_build(i),this.root.append(r,o,l,a,c,i.ask,h,i.leaveAsk),this.parts=i,this.question_show(null)}hooks;root;harness;readout=null;previous=null;view="bridge";nextDistance=null;plan=new Map;answering=!1;computerRunning=!1;leaving=!1;tracker=new Tl;heading=0;pressedSector=null;scanDue=!1;fold=null;frames=new C6;shown=null;torpedo=null;trackPrinting=!1;partial="";lrsBloom=null;parts;stationHost_get(){return{answer_send:(e,s)=>this.answer_send(e,s),command_send:e=>this.command_send(e),plan_set:e=>{for(const[s,i]of e)this.plan.set(s,i)},course_set:(e,s)=>this.course_set(e,s),voice:this.hooks.voice}}gutter_build(e,s){const i=q("aside","tb-gutter"),n=q("div","tb-block");n.append(q("span","tb-block-name","TREK"),q("span","tb-block-sub","ARGUS · BSD TREK")),e.seed=q("div","tb-seed",s===null?"RANDOM GALAXY":`SEED ${s}`);const r=q("nav","tb-views");r.setAttribute("aria-label","views"),e.views=new Map;for(const c of U6){const h=Os(`tb-view tb-view-${c}`,c.toUpperCase(),()=>this.view_set(c));h.classList.remove("tb-pill"),h.dataset.view=c,e.views.set(c,h),r.append(h)}const o=Os("tb-leave","LEAVE BRIDGE",()=>this.leave_ask());o.classList.remove("tb-pill");const a=q("div","tb-gutter-top");a.append(n,e.seed,q("div","tb-gutter-fill"));const l=q("div","tb-gutter-body");return l.append(q("div","tb-gutter-cap"),r,q("div","tb-gutter-fill"),o),i.append(a,l),i}frame_build(){const e=q("div","tb-bar tb-bar-top");for(const i of["tb-bar-a","tb-bar-b","tb-bar-c","tb-bar-d"])e.append(q("span",i));const s=q("div","tb-bar tb-bar-body");for(const i of["tb-bar-a","tb-bar-b","tb-bar-c"])s.append(q("span",i));return[e,s]}header_build(e){const s=q("header","tb-header"),i=q("section","tb-head-condition"),n=q("div","tb-condition");n.append(q("span","tb-condition-label","CONDITION")),e.condition=q("span","tb-condition-name","—"),n.append(e.condition),e.conditionWhy=q("div","tb-condition-why",""),i.append(n,e.conditionWhy);const r=p=>{const f=q("section","tb-head-section");f.append(q("span","tb-head-title",p));const _=q("div","tb-head-grid");return f.append(_),[f,_]},[o,a]=r("SHIP"),[l,c]=r("MISSION"),[h,d]=r("POSITION"),u=q("div","tb-head-grid tb-head-since");return l.append(q("span","tb-head-title","SINCE LAST COMMAND"),u),e.ship=a,e.mission=c,e.position=d,e.since=u,s.append(i,o,l,h),s}body_build(e){const s=this.stationHost_get(),i=q("main","tb-body");i.dataset.view="bridge",e.body=i;const n=q("section","tb-scans");n.append(q("span","tb-title","LONG RANGE")),e.lrs=q("div","tb-lrs"),n.append(e.lrs,q("span","tb-title","GALAXY · WHAT THE SHIP HAS SEEN")),e.chart=q("div","tb-chart"),n.append(e.chart);const r=q("section","tb-srs-section");e.srsTitle=q("span","tb-title","SHORT RANGE"),r.append(e.srsTitle),e.scan=st("svg",{class:"tb-scan",viewBox:j6,role:"grid","aria-label":"short range scan"}),e.scan.addEventListener("keydown",l=>this.scan_key(l)),e.legend=this.legend_build(),r.append(e.scan,q("span","tb-note","PRESS A SECTOR: ITS COURSE AND DISTANCE FILL IN"),e.legend),e.shipPills=new Map;const o=q("div","tb-pills tb-ship-pills");o.append(q("span","tb-slider-label","SHIP"));for(const l of Pd.filter(c=>c.station==="ship")){const c=d_(l,s);e.shipPills.set(l.id,c),o.append(c)}r.append(o);const a=q("section","tb-stations");return e.helm=new Av(s,150,"tb"),e.tactical=new Tv(s,150,"tb"),a.append(e.helm.root,e.tactical.root),e.helmView=new Av(s,260,"tbh"),e.helmView.root.classList.add("tb-view-body","tb-view-helm"),e.tacticalView=new Tv(s,260,"tbt"),e.tacticalView.root.classList.add("tb-view-body","tb-view-tactical"),e.engineeringView=new W6(s),e.computerView=new F6(s),i.append(n,r,a,e.helmView.root,e.tacticalView.root,e.engineeringView.root,e.computerView.root),i}legend_build(){const e=q("div","tb-legend");for(const s of Kj){const i=q("span",`tb-legend-item tb-legend-${s.kind}`),n=s.kind==="klingon"?fr:[null];for(const r of n)i.append(h_(s.kind,r));i.append(q("span","tb-legend-glyph",Jc[s.kind].trim()===""?"␠":Jc[s.kind]),q("span","tb-legend-name",s.name)),e.append(i)}return e}strip_build(e){e.ask=q("div","tb-ask"),e.ask.hidden=!0,e.ask.setAttribute("role","dialog"),e.askText=q("span","tb-ask-text",""),e.askPills=q("div","tb-pills"),e.askInput=document.createElement("input"),e.askInput.type="text",e.askInput.className="tb-ask-input",e.askInput.setAttribute("aria-label","the answer");const s=e.askInput;e.askSend=Os("tb-commit","ANSWER",()=>this.answer_send(s.value,"ANSWER")),s.addEventListener("keydown",i=>{i.key==="Enter"&&this.answer_send(s.value,"ANSWER")}),e.ask.append(q("span","tb-ask-label","THE GAME ASKS"),e.askText,e.askPills,e.askInput,e.askSend)}log_build(e){const s=q("footer","tb-log-section"),i=q("div","tb-log-head");return i.append(q("span","tb-title","SHIP'S LOG"),q("span","tb-note","READ ONLY")),e.log=q("div","tb-log"),e.log.setAttribute("aria-live","polite"),s.append(i,e.log),s}leaveAsk_build(e){e.leaveAsk=q("div","tb-leave-ask"),e.leaveAsk.hidden=!0,e.leaveAsk.setAttribute("role","dialog");const s=e.leaveAsk,i=Os("tb-grave","LEAVE · THE GAME ENDS",()=>{this.leaving=!0,this.hooks.voice.cue("close"),this.hooks.leave()}),n=Os("","STAY",()=>{s.hidden=!0});e.leaveAsk.append(q("span","tb-ask-label","LEAVE THE BRIDGE?"),q("span","tb-ask-text","The game ends where it stands; dump first to keep it."),i,n)}harness_get(){return this.harness}leave_ask(){this.frames.skip(),this.parts.leaveAsk.hidden&&this.hooks.voice.pill("LEAVE BRIDGE"),this.parts.leaveAsk.hidden=!1}frames_get(){return{played:{...this.frames.played},pending:this.frames.pending_count(),busy:this.frames.busy_is()}}frames_settle(){return this.frames.settle()}leaveAsk_isOpen(){return!this.parts.leaveAsk.hidden}leaveAsk_close(){this.parts.leaveAsk.hidden=!0}view_get(){return this.view}view_set(e){this.frames.skip(),this.view=e,this.root.dataset.view=e,this.parts.body.dataset.view=e;for(const[s,i]of this.parts.views)i.classList.toggle("tb-view-on",s===e);this.hooks.voice.pill(gr(e.toUpperCase(),"view"))}readout_get(){return this.readout}command_send(e){if(this.frames.skip(),!this.harness.command_send(e))return this.hooks.voice.cue("deny"),!1;const s=i6(e.id);return s===null?this.hooks.voice.pill(gr(e.label,"command")):this.hooks.voice.cue(s),this.nextDistance=null,this.computerRunning=e.id==="computer",this.computerRunning&&this.parts.computerView.answer_take(null),this.log_write(`Command: ${e.line}
4354
4354
  `,!0),!0}answer_send(e,s){const i=this.harness.question_get();if(!this.harness.answer(e)){this.hooks.voice.cue("deny");return}const n=i===null?null:n6(i.question,i.command?.id??null);n!==null?this.hooks.voice.cue(n):s!==null&&this.hooks.voice.pill(s);const r=i===null?"":i.prompt.trim();this.log_write(`${r===""?"":`${r} `}${e}
4355
4355
  `,!0),i?.question==="course"&&Number.isFinite(Number(e))&&(this.heading=(Number(e)%360+360)%360,this.shown!==null&&this.srs_draw(this.shown))}course_set(e,s){const{parts:i}=this;for(const n of[i.helm,i.helmView,i.tactical,i.tacticalView])n.wheel.degrees_set(e);s!==null&&(i.helm.distance.value_set(s),i.helmView.distance.value_set(s),this.nextDistance=s)}state_show(e){this.previous=this.readout;const s=y6(e);this.readout=s;const{parts:i}=this,n=this.previous===null||this.previous.position.quadrant.x!==s.position.quadrant.x||this.previous.position.quadrant.y!==s.position.quadrant.y;this.tracker.reconcile(s.klingons,{reset:n,byOrder:!this.device_isOk(s,V6)});for(const r of s.klingons)r.mark=this.tracker.mark_find(r);n&&(this.pressedSector=null),n&&this.device_isOk(s,q6)&&(this.scanDue=!0),i.condition.textContent=s.condition.name,i.condition.parentElement?.setAttribute("data-condition",s.condition.name.toLowerCase()),i.conditionWhy.textContent=s.condition.why.toUpperCase(),this.header_draw(s);for(const r of[i.helm,i.helmView,i.tactical,i.tacticalView,i.computerView])r.state_show(s);i.engineeringView.state_show(s,this.previous),this.partial_flush(),this.frames.push(this.stateFrame_make(s,this.previous)),this.question_show(this.harness.question_get())}stateFrame_make(e,s){return{kind:"state",run:async i=>{const n=this.parts.scan;await this.torpedo_end(!0);const r=this.shown,o=r!==null&&(r.position.quadrant.x!==e.position.quadrant.x||r.position.quadrant.y!==e.position.quadrant.y),a=r!==null&&(o||r.position.sector.x!==e.position.sector.x||r.position.sector.y!==e.position.sector.y);if(a&&r!==null){const c={x:r.position.quadrant.x*10+r.position.sector.x,y:r.position.quadrant.y*10+r.position.sector.y},h={x:e.position.quadrant.x*10+e.position.sector.x,y:e.position.quadrant.y*10+e.position.sector.y};this.heading=Math.round($1(c,h))}const l={kind:"ship",variant:null};if(a&&!i&&r!==null&&!o)this.srs_draw(r,!1),await tl(n,this.frames,l,r.position.sector,e.position.sector,{heading:this.heading});else if(a&&!i&&r!==null&&o){const{exit:c,entry:h}=N6(r.position,e.position);this.srs_draw(r,!1),await tl(n,this.frames,l,r.position.sector,c,{heading:this.heading}),Ev(n,!0),this.shown=Dv(e),this.srs_draw(this.shown,!1),this.lrs_draw(this.shown,!0),this.chart_draw(this.shown),await this.frames.wait(Un.rescan),Ev(n,!1),await tl(n,this.frames,l,h,e.position.sector,{heading:this.heading})}this.shown=Dv(e),this.srs_draw(this.shown),this.lrs_draw(this.shown,o&&i),this.chart_draw(this.shown);for(const c of s6(s,e))this.hooks.voice.cue(c);this.standingOrder_try()}}}header_draw(e){const{parts:s}=this,i=(o,a)=>{o.replaceChildren();for(const[l,c,h]of a)o.append(q("span","tb-head-label",l),q("span",`tb-head-value${h===void 0?"":` ${h}`}`,c))},n=(o,a)=>`${Math.max(0,Math.min(100,Math.round(100*o/Math.max(1,a))))}`;i(s.ship,[["ENERGY",`${e.ship.energy} / ${e.ship.energyMax}`],["SHIELDS",`${e.ship.shieldsUp?"UP":"DOWN"} · ${e.ship.shield} (${n(e.ship.shield,e.ship.shieldMax)}%)`],["TORPEDOES",`${e.ship.torpedoes} / ${e.ship.torpedoesMax}`],["WARP",`${e.ship.warp.toFixed(1)}${e.ship.cloaked?" · CLOAKED":""}`]]),i(s.mission,[["STARDATE",e.mission.stardate.toFixed(2)],["TIME LEFT",e.mission.timeLeft.toFixed(2)],["KLINGONS",`${e.mission.klingonsLeft} LEFT · ${e.mission.killed} KILLED${e.mission.captives>0?` · ${e.mission.captives} CAPTIVE`:""}`],["STARBASES",e.nearestBase===null?`${e.mission.starbases}`:`${e.mission.starbases} · NEAREST ${e.nearestBase.at.x},${e.nearestBase.at.y}${e.nearestBase.here?" HERE":""}`]]),i(s.position,[["QUADRANT",`${e.position.quadrant.x},${e.position.quadrant.y}`],["SECTOR",`${e.position.sector.x},${e.position.sector.y}`],["CREW",`${e.ship.crew}`],["LIFE SUPPORT",`${e.ship.reserves.toFixed(1)} / ${e.ship.reservesMax.toFixed(1)}`],["SCORE",`${L1(e).total}`]]);const r=this.previous===null?[]:U1(this.previous,e);i(s.since,r.length===0?[["—","NOTHING MOVED"]]:r.map(o=>[o.label,o.change,o.bad?"tb-bad":"tb-good"]))}srs_draw(e,s=!0){const{parts:i}=this;i.srsTitle.textContent=`SHORT RANGE · QUADRANT ${e.position.quadrant.x},${e.position.quadrant.y}`;const n=i.scan,r=[...n.querySelectorAll(":scope > .tb-motion")];n.replaceChildren();const o=e.sectors[0]?.length??0;for(let c=0;c<o;c++)n.append(this.axis_make(String(c),c+.5,-.3));for(const c of e.sectors)n.append(this.axis_make(String(c[0]?.x??""),-.3,(c[0]?.x??0)+.5));const a=e.position.sector,l=this.pressedSector??a;for(const c of e.sectors)for(const h of c)n.append(this.sector_make(h,e,a,l,s));if(s){const c=Jj(e.ship.shield,e.ship.shieldMax,e.ship.shieldsUp,e.condition.name==="DOCKED"),h=st("circle",{class:c.className,cx:a.y+.5,cy:a.x+.5,r:.46,"stroke-width":c.width});h.dataset.percent=String(Math.round(c.percent)),n.append(h)}n.append(...r)}axis_make(e,s,i){const n=st("text",{class:"tb-scan-axis",x:s,y:i});return n.textContent=e,n}sector_make(e,s,i,n,r=!0){const o=xh(i,e),a=ad(i,e),l=this.pressedSector?.x===e.x&&this.pressedSector.y===e.y,c=st("g",{class:`tb-sector tb-sector-${e.kind}${l?" tb-pressed":""}`,role:"button",tabindex:n.x===e.x&&n.y===e.y?0:-1});c.dataset.x=String(e.x),c.dataset.y=String(e.y);const h=st("title",{}),d=e.kind==="empty"?"·":Jc[e.kind];if(h.textContent=e.kind==="ship"?`the ship · ${e.x},${e.y}`:`${e.x},${e.y} ${d.trim()===""?"black hole":d} · course ${Math.round(o)}° · ${(a/10).toFixed(1)}`,c.append(h,st("rect",{class:"tb-cell",x:e.y+.04,y:e.x+.04,width:.92,height:.92,rx:.16})),e.kind==="empty"||e.kind==="ship"&&!r)c.append(st("circle",{class:"tb-cell-dot",cx:e.y+.5,cy:e.x+.5,r:.03}));else{const p=e.kind,f=p==="klingon"?s.klingons.find(m=>m.x===e.x&&m.y===e.y):void 0,_=p==="ship"?this.heading:p==="klingon"?xh(e,i):0,g=c_(p,{cx:e.y+.5,cy:e.x+.5,size:H6},f?.mark??null,_);p==="star"&&g.style.setProperty("--tb-breathe",`-${(e.x*7+e.y*3)%11*.33}s`),c.append(g)}const u=()=>this.sector_press(e,o,a);return c.addEventListener("click",u),c.addEventListener("keydown",p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),u())}),c}scan_key(e){const s=K6[e.key],i=e.target?.closest(".tb-sector")??null;if(s===void 0||i===null)return;const n=Number(i.dataset.x)+s[0],r=Number(i.dataset.y)+s[1],o=this.parts.scan.querySelector(`.tb-sector[data-x="${n}"][data-y="${r}"]`);o!==null&&(e.preventDefault(),i.setAttribute("tabindex","-1"),o.setAttribute("tabindex","0"),o.focus())}sector_press(e,s,i){this.hooks.voice.cue("scanner"),this.course_set(s,Math.round(i)/10),this.parts.computerView.sector_set(e),this.pressedSector={x:e.x,y:e.y};for(const n of this.parts.scan.querySelectorAll(".tb-sector")){const r=n.dataset.x===String(e.x)&&n.dataset.y===String(e.y);n.classList.toggle("tb-pressed",r),n.setAttribute("tabindex",r?"0":"-1")}}device_isOk(e,s){const i=e.devices.find(n=>s.test(n.name));return i===void 0||i.repairAt===null}lrs_draw(e,s=!1){const{parts:i}=this;i.lrs.replaceChildren();const{quadrant:n}=e.position,r=this.lrsBloom;this.lrsBloom=null;for(let o=-1;o<=1;o++)for(let a=-1;a<=1;a++){const l=e.chart[n.x+o]?.[n.y+a];if(l===void 0){const h=q("div","tb-lrs-cell tb-lrs-edge");h.append(q("span","tb-lrs-code","—"),q("span","tb-lrs-at","EDGE")),h.title="outside the galaxy",i.lrs.append(h);continue}const c=q("div",`tb-lrs-cell${l.here?" tb-here":""}${l.klingons>0?" tb-hostile":""}${l.code===null?" tb-unscanned":""}${l.supernova?" tb-supernova":""}`);c.append(dm("tb-lrs-code",l),q("span","tb-lrs-at",`${l.x},${l.y}`)),c.title=um(l),c.dataset.x=String(l.x),c.dataset.y=String(l.y),i.lrs.append(c),(s&&l.here||r!==null&&r.at.x===l.x&&r.at.y===l.y)&&L6(c,r!==null&&!l.here&&r.hostile)}}chart_draw(e){const{parts:s}=this;s.chart.replaceChildren();for(const i of e.chart)for(const n of i){const r=dm(`tb-quadrant${n.here?" tb-here":""}${n.klingons>0?" tb-hostile":""}${n.bases>0?" tb-based":""}${n.code===null?" tb-unscanned":""}${n.supernova?" tb-supernova":""}`,n);r.title=um(n),s.chart.append(r)}}question_show(e){const{parts:s}=this;if(e?.question==="command"&&(this.plan.clear(),this.computerRunning=!1,this.fold_close(),this.standingOrder_try()))return;const i=e===null?void 0:this.plan.get(e.question);if(i!==void 0&&e!==null&&!this.answering){this.plan.delete(e.question),this.answering=!0;try{this.answer_send(i,null)}finally{this.answering=!1}return}Ud(s.shipPills,e);for(const n of[s.helm,s.helmView,s.tactical,s.tacticalView,s.engineeringView,s.computerView])n.question_show(e);e?.question==="distance"&&this.nextDistance!==null&&(s.helm.distance.value_set(this.nextDistance),s.helmView.distance.value_set(this.nextDistance)),this.strip_show(e),this.lit_reveal()}lit_reveal(){const e=[...this.parts.body.querySelectorAll(".tb-lit")].find(s=>s.getClientRects().length>0);e!==void 0&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}strip_show(e){const{parts:s}=this,i=e?.question??null,n=i===null?null:xs(i,this.readout),r=n!==null&&i!==null&&i!=="command"&&(n.kind==="yesno"||n.kind==="text"||Y6.includes(i));if(s.ask.hidden=!r,!r||n===null||e===null)return;s.askText.textContent=e.prompt.replace(/[:\s]+$/,"").trim(),s.askPills.replaceChildren();for(const a of n.choices??[])s.askPills.append(Os("tb-choice",a.label,()=>this.answer_send(a.line,a.label)));const o=n.kind==="text"||n.kind==="slider";s.askInput.hidden=!o,s.askSend.hidden=!o,o&&(s.askInput.value="",s.askInput.focus())}standingOrder_try(){if(!this.scanDue||this.answering||this.harness.question_get()?.question!=="command")return!1;this.scanDue=!1;const e=this.readout?.position.quadrant;return this.fold_open(`LONG RANGE SCAN · STANDING ORDER${e===void 0?"":` · QUADRANT ${e.x},${e.y}`}`),this.harness.answer("l")?(this.log_write(`Command: l
4356
4356
  `,!0),!0):(this.fold_close(),!1)}fold_open(e){this.frames.push({kind:"fold",run:()=>{const s=q("details","tb-log-fold");s.append(q("summary","tb-log-fold-head",e)),this.parts.log.append(s),this.fold=s}})}fold_close(){this.frames.push({kind:"fold",run:()=>{this.fold=null}})}text_take(e){const s=e.replace(/\x1b\[[0-9;]*m/g,"").replace(/\x07/g,"");this.computerRunning&&this.parts.computerView.answer_take(s);const i=(this.partial+s).split(`
@@ -4363,7 +4363,7 @@ ${f instanceof Error?f.message:String(f)}`}}if(s!==null)return s.domain_choose(d
4363
4363
  `)}finally{i=!1}await a()},size_read:l,stop:()=>t.client.stop_send(),leave:c,voice:{pill:p=>Ci.pill_play(p),cue:p=>Ci.cue_play(p)}});return s=u,document.body.append(u.root),document.body.dataset.takeover="controller",Ci.preload(),Ci.cue_play("open"),a().then(()=>u.domain_choose(d)),`domain: the TD controller takes the screen${d===""?"":` on ${d}`} (Esc or LEAVE gives it back)`},active_is:()=>s!==null,running_is:()=>s!==null&&i,ask:d=>s===null?Promise.resolve(null):s.ask_take(d.message,d.kind),output_take:d=>{s?.output_take(d)},event_take:(d,u)=>{if(d!==Uk||s===null)return;o.events++;const p=_z.safeParse(u);if(!p.success){o.lastError=p.error.message;return}s.domain_take(p.data)},names_get:()=>[...n]}}function vH(t){return`${t.date??"undated"} · ${t.entries.map(e=>`${e.package} ${e.version}`).join(" · ")}`}function wH(t,e){return t.releases.map(s=>{const i=s.merge??s.date??"undated",n=[];for(const r of s.entries)r.changes.forEach((o,a)=>{const l=`${i}:${r.package}:${a}`,c=o.body!=="";n.push({key:l,tag:r.package,text:o.headline,body:!1,more:c,internal:o.internal,of:l}),c&&e.has(l)&&n.push({key:`${l}:body`,tag:"",text:o.body,body:!0,more:!1,internal:o.internal,of:l})});return{key:i,title:vH(s),rows:n}})}class yH{constructor(e,s){this.hooks=s;const i=e.querySelector(".notes-panel");if(i===null)throw new Error("notes pane: no .notes-panel in its template");this.state=e.querySelector(".pane-state"),this.sincePill=e.querySelector(".notes-since"),this.internalPill=e.querySelector(".notes-internal"),this.listing=new Ir({mount:i,traits:this.traits_declare(),key:n=>n.key,chrome:{root:e,prefix:"notes"},caps:"root",activatable:n=>n.more,activate:n=>this.unfold_toggle(n.of),row:{className:n=>`notes-row${n.body?" notes-row-body":""}${n.internal?" notes-row-internal":""}${n.more?" notes-row-more":""}`}}),this.sincePill?.addEventListener("click",()=>{this.since_cycle()}),this.internalPill?.addEventListener("click",()=>{this.internal_toggle()}),this.pills_paint()}hooks;listing;state;sincePill;internalPill;model=null;unfolded=new Set;ask={since:1,all:!1};traits_declare(){return[{key:"tag",label:"PACKAGE",className:"notes-tag",width:"minmax(5em, 7em)",cell:e=>e.tag},{key:"text",label:"CHANGE",className:"notes-text",width:"minmax(16em, 1fr)",cell:e=>e.more&&!e.body?`${e.text} ▸`:e.text}]}model_show(e){this.model=e,this.ask={since:e.releases.length>1?e.releases.length>=e.total?"all":e.releases.length:1,all:e.all},this.render()}releases_shown(){return this.model?.releases.length??0}unfolded_is(e){return this.unfolded.has(e)}unfold_toggle(e){this.unfolded.has(e)?this.unfolded.delete(e):this.unfolded.add(e),this.render()}async since_cycle(){const e=this.ask.since===1?5:this.ask.since===5?"all":1;await this.ask_again({...this.ask,since:e})}async internal_toggle(){await this.ask_again({...this.ask,all:!this.ask.all})}async ask_again(e){const s=e.since==="all"?"9999":String(e.since),i=await this.hooks.ask(`notes --since ${s}${e.all?" --all":""}`);i!==null&&(this.ask=e,this.model_show(i))}pills_paint(){this.sincePill!==null&&(this.sincePill.textContent=this.ask.since==="all"?"ALL RELEASES":this.ask.since===1?"LATEST RELEASE":`LAST ${this.ask.since} RELEASES`),this.internalPill!==null&&(this.internalPill.textContent=this.ask.all?"INTERNAL ON":"INTERNAL OFF",this.internalPill.classList.toggle("rail-off",!this.ask.all))}render(){const e=this.model;if(e===null)return;const s=n=>{const r=document.createElement("header");return r.className="files-path notes-block-head",r.textContent=n,r},i=wH(e,this.unfolded).map(n=>({key:n.key,header:s(n.title),rows:n.rows}));if(this.listing.rows_set(i,{field:"notes"}),this.state!==null){const n=Object.entries(e.installed).map(([r,o])=>`${r} ${o}`).join(" · ");this.state.textContent=`${e.source.toUpperCase()} · ${n}`}this.pills_paint()}}function zH(t){for(const e of t.envelopes){if(e.model?.kind!==Mk)continue;const s=zk.safeParse(e.model.data);if(s.success)return s.data}return null}function SH(t,e){const{layout:s,panels:i,subjects:n}=t,r=async c=>zH(await e.ask(c)),o=c=>{const h=e.template_stamp("tpl-pane-notes");return i.set("notes",c,new yH(h,{ask:r})),{id:c,kind:"notes",mount:h,dispose:()=>{i.delete(c),n.pane_leave(c)}}},a=c=>{r("notes").then(h=>{h!==null&&i.get("notes",c)?.model_show(h)})};return{instance_build:o,open:()=>{const c=i.ids("notes").find(f=>s.panes_shown().includes(f));if(c!==void 0)return s.focus_set(c),a(c),"notes: on stage";const h=e.launcher_active();e.launcher_yield();const d=s.focused_get()??"files",u=e.instance_spawn("notes");return(h?s.leaf_replace("files",u.id):s.leaf_split(d,"col",u.id,!1))?(h?s.focus_set(u.id):e.birth_record(u.id,d,"col",!1),a(u.id),"notes: what the installed releases changed, as a pane (notes in the console prints it)"):(As(u.id),s.mount_remove(u.id),"notes: could not open a pane")},latest:()=>r("notes")}}function Uv(t){return[...t.querySelectorAll(".mode-frame button")].filter(e=>!e.disabled&&!e.hidden&&e.offsetParent!==null)}function xH(t){return[...t.querySelectorAll(".listing-row")].filter(e=>e.offsetParent!==null)}function OH(t,e,s){if(e===0)return null;switch(s){case"ArrowDown":return t<0?0:Math.min(e-1,t+1);case"ArrowUp":return t<0?e-1:Math.max(0,t-1);case"Home":return 0;case"End":return e-1;default:return null}}function EH(t,e){const{layout:s,panels:i,paneInstance_get:n}=t,r=[()=>e.palette_isOpen()?(e.palette_close(),"claimed"):"passed",()=>t.terminal.ask_abandon()?"claimed":"passed",()=>m1()?"claimed":"passed",()=>e.errand_abandon()?"claimed":"passed",()=>{const f=document.activeElement;return!(f instanceof HTMLInputElement||f instanceof HTMLTextAreaElement)||f.closest(".workspace-pane")===null||f.closest("#terminal")!==null?"passed":(f.blur(),"claimed")},()=>i.values("image").some(f=>f.field_release())?"claimed":"passed",()=>i.values("edit").some(f=>f.field_release())?"claimed":"passed",()=>i.values("games").some(f=>f.field_release())?"claimed":"passed",()=>{if(t.terminal.ask_isOpen())return"passed";let f=!1;for(const _ of i.values("files"))_.select_isOn()&&(_.select_toggle(!1),f=!0);return f?"claimed":"passed"},()=>{const f=e.drawers_close(),_=e.modeFrames_close();return f||_?"claimed":"passed"},()=>document.body.dataset.zoom!==void 0?"yielded":"passed",()=>e.dive_leave()?"claimed":"passed",()=>e.overlay_escape()?"claimed":"passed",()=>{const f=i.entries("dag").find(([,_])=>_.inside_isHeld());return f===void 0?"passed":(f[1].flight_back(()=>{}),"claimed")},()=>{const f=s.focused_get(),_=i.entries("files").filter(([,g])=>g.content_isShown()).sort(([g],[m])=>g===f?-1:m===f?1:0)[0];return _===void 0?"passed":(_[1].listing_restore(),"claimed")},()=>i.values("dag").some(f=>f.nav_pop())?"claimed":"passed"],o=f=>{if(document.body.dataset.zoom!=="launcher")for(const _ of r){const g=_();if(g==="yielded")return;if(g==="claimed"){f.stopImmediatePropagation(),_!==r[0]&&t.sound("audio3");return}}},a=(f,_)=>{const g=()=>{f.preventDefault(),f.stopImmediatePropagation()},m=oB(f.key);if(f.ctrlKey&&!f.metaKey&&!f.altKey&&m!==null){const v=s.focused_get();return v!==null&&e.verbs.resize(v,m,.05),g(),!0}if(f.ctrlKey||f.metaKey||f.altKey)return!1;const w=v=>(e.drawers_close(),v(),g(),!0);if(m!==null)return w(()=>{l(),Vz(e.host(),ki[m].focusWord)!==null&&t.sound("audio3")});switch(f.key){case"o":case"O":{const v=s.panes_shown(),z=v.indexOf(s.focused_get()??""),x=v[(z+(f.key==="o"?1:v.length-1))%v.length];return w(()=>{l(),x!==void 0&&(s.focus_set(x),t.sound("audio3"))})}case"?":return w(()=>t.terminal.line_run("argus keys"));case";":return w(()=>{l(),s.focus_last()!==null&&t.sound("audio3")});case"q":return w(()=>{for(const v of s.panes_shown())e.verbs.bar_note(v,`@${v}`)});case" ":{const v=s.focused_get();return w(()=>{v!==null&&e.verbs.flip(v)})}case"!":{const v=s.focused_get();return w(()=>{v!==null&&s.panes_shown().length>1&&(e.stage_alone(v),e.verbs.bar_note(v,"ALONE ON STAGE"),t.sound("audio3"))})}case"w":return w(()=>e.element_require("gutter-panes").click());case"r":return w(()=>{l();const v=c();v!==null&&h(v)});case"&":return w(()=>t.terminal.line_run("pane close all"));case"[":return w(()=>{const v=document.querySelector(".argus-output");v!==null&&(v.tabIndex=-1,v.focus())})}const y=pn.find(v=>v.key===f.key&&v.selector!==null);if(y===void 0||y.selector===null)return!1;y.move===!0&&_.querySelector('.drawer-mode[data-mode="move"]')?.click();const b=_.querySelector(y.selector);return b===null||b.disabled?y.move===!0&&_.querySelector('.drawer-mode[data-mode="split"]')?.click():b.click(),g(),!0},l=()=>{const f=document.activeElement;f instanceof HTMLElement&&f.closest("#drawer")!==null&&f.blur(),e.console_release()},c=()=>{const f=document.body.dataset.zoom;if(f==="console"||f==="launcher")return null;const _=f!==void 0?f:s.focused_get();if(_===null)return null;const g=n(_)?.mount??null;return g?.closest(".workspace-pane")??g},h=f=>{f.classList.contains("workspace-pane")&&(f.dataset.modes="open");let _=0;const g=()=>{_+=1;const m=document.activeElement;!(m instanceof HTMLButtonElement&&m.closest(".mode-frame")!==null&&f.contains(m))&&(m===null||m===document.body)&&Uv(f)[0]?.focus(),_<30&&window.requestAnimationFrame(g)};return g(),t.sound("audio3"),!0},d=f=>{if(f.ctrlKey||f.metaKey||f.altKey||f.shiftKey)return!1;const _=c();if(_===null)return!1;const g=()=>(f.preventDefault(),f.stopImmediatePropagation(),!0),m=document.activeElement;if(m instanceof HTMLButtonElement&&m.closest(".mode-frame")!==null&&_.contains(m)){const x=Uv(_),M=x.indexOf(m);return f.key==="ArrowLeft"?(m.blur(),g()):f.key==="ArrowDown"||f.key==="ArrowUp"?(x[f.key==="ArrowDown"?Math.min(x.length-1,M+1):Math.max(0,M-1)]?.focus(),g()):!1}if(m!==null&&m!==document.body&&!m.classList.contains("listing-row"))return!1;const w=xH(_);if(w.length===0)return!1;const y=w.findIndex(x=>x.classList.contains("listing-cursor")),b=y>=0?y:w.findIndex(x=>x.classList.contains("listing-indicated"));if(f.key==="ArrowRight")return h(_)&&g();if(f.key==="Enter"){const x=w[b];if(x===void 0)return!1;if(x.classList.contains("listing-indicated")){const M=x.querySelector(".listing-control");M!==null?M.click():x.dispatchEvent(new MouseEvent("dblclick",{bubbles:!0,cancelable:!0}))}else x.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0}));return g()}const v=OH(b,w.length,f.key);if(v===null)return!1;for(const x of w)x.classList.remove("listing-cursor");const z=w[v];return z?.classList.add("listing-cursor"),z?.scrollIntoView({block:"nearest"}),g()},u=f=>{const _=document.querySelector(".pane-drawer:not([hidden])")!==null;if(f.key===":"&&_){e.drawers_close(),e.palette_open(),f.preventDefault(),f.stopImmediatePropagation();return}if(!(f.key==="b"&&f.ctrlKey&&!f.altKey&&!f.metaKey))return;if(f.preventDefault(),_){e.drawers_close(),e.palette_open();return}const g=document.body.dataset.zoom,m=g==="console"||g===void 0&&e.consoleFocused(),w=g!==void 0&&g!=="console"?g:s.focused_get()??"files",y=m?e.element_require("console-drawer"):n(w)?.mount?.querySelector(".pane-drawer")??null;y!==null&&(y.hidden=!y.hidden,y.hidden||y.querySelector("button")?.focus(),t.sound("audio3"))},p=f=>{if(f.key==="Escape"){o(f);return}const _=document.querySelector(".pane-drawer:not([hidden])"),g=f.target instanceof HTMLInputElement||f.target instanceof HTMLTextAreaElement||f.target instanceof HTMLElement&&f.target.isContentEditable;_!==null&&!g&&a(f,_)||_===null&&!g&&!e.palette_isOpen()&&d(f)||u(f)};return window.addEventListener("keydown",p,{capture:!0}),()=>window.removeEventListener("keydown",p,{capture:!0})}function AH(t,e){const{layout:s,panels:i,subjects:n}=t,r=(l,c,h)=>{h.addEventListener("click",_=>{_.target instanceof Element&&_.target.closest("button")!==null||(c.hidden=!c.hidden,c.hidden||c.querySelector("button")?.focus(),t.sound("audio3"))});const d=c.querySelector(".drawer-zoom");d!==null&&(d.dataset.pane=l),h.addEventListener("dblclick",_=>{_.target instanceof Element&&_.target.closest("button")!==null||(window.getSelection()?.removeAllRanges(),d?.click())});for(const _ of c.querySelectorAll(".drawer-bind"))_.addEventListener("click",()=>{for(const g of c.querySelectorAll(".drawer-bind"))g.classList.remove("drawer-bind-selected");_.classList.add("drawer-bind-selected"),t.sound("audio3")});const u=[...c.querySelectorAll("[data-split]")],p=_=>nB(_.dataset.split,_.dataset.place)??"right",f=_=>{c.dataset.mode=_;for(const g of c.querySelectorAll(".drawer-mode"))g.classList.toggle("drawer-mode-selected",g.dataset.mode===_);for(const g of u){const m=p(g);g.disabled=_==="move"&&!s.move_possible(l,m);const w=xi(m);g.title=_==="move"?`this pane moves ${m}${e.verbs.chordKeys_format(w,!0)}`:`new pane opens ${m}${e.verbs.chordKeys_format(w,!1)}`}};for(const _ of c.querySelectorAll(".drawer-mode"))_.addEventListener("click",()=>{const g=_.dataset.mode==="move"?"move":"split";f(g==="move"&&c.dataset.mode==="move"?"split":g),t.sound("audio3")});for(const _ of u)_.addEventListener("click",()=>{if(c.dataset.mode==="move"){e.verbs.move(l,p(_)),f("split"),c.hidden=!0;return}const g=_.dataset.split==="row"?"row":"col",m=_.dataset.place==="before",w=c.querySelector(".drawer-bind-selected")?.dataset.bind??"unlinked",y=w==="viewer"?"view":w==="fs"?"fs":"empty";e.pillPane_spawn(l,y,g,m)!==null&&(c.hidden=!0,t.sound("audio3"))});for(const _ of new Set(pn.filter(g=>g.selector!==null&&g.move!==!0).map(g=>g.selector??""))){const g=c.querySelector(_);g!==null&&!g.title.includes("[keys ")&&(g.title=`${g.title}${e.verbs.chordKeys_format(_,!1)}`)}c.querySelector(".drawer-close")?.addEventListener("click",()=>{if(l==="dag"){e.dag_dismiss(),e.home_apply();return}s.leaf_close(l)||e.home_apply(),e.orphans_dispose(),t.sound("audio3")})},o=(l,c,h)=>{const{browser:d}=e,u=c.querySelector(".drawer-binding");if(u!==null){const g=document.createElement("span");g.className="drawer-label drawer-label-cwd",g.textContent="CWD",u.appendChild(g);const m=(w,y,b)=>{const v=document.createElement("button");v.className="pacs-capsule drawer-cwdbind",v.dataset.follow=y?"on":"off",v.textContent=w,v.title=b,v.addEventListener("click",()=>{d.follows(l)!==y&&d.follow_set(l,y),t.sound("audio3")}),u.appendChild(v)};m("FOLLOW CWD",!0,"bind this browser to the session cwd (the console's browser)"),m("ROOT HERE",!1,"unbind from the cwd: this browser keeps its own place"),d.cwdBind_sync_register(l,()=>{const w=d.follows(l);for(const y of u.querySelectorAll(".drawer-cwdbind"))y.classList.toggle("drawer-bind-selected",y.dataset.follow==="on"===w)}),d.cwdBind_sync(l)}const p=()=>i.get("files",l);h.querySelector(".files-home")?.addEventListener("click",()=>{if(d.follows(l)){t.terminal.line_run("cd ~");return}const g=p();g!==void 0&&d.rooted_walk(l,g,"~")}),h.querySelector(".files-back")?.addEventListener("click",()=>{if(d.follows(l)){t.terminal.line_run("cd -");return}const g=p();g!==void 0&&d.rooted_back(l,g)});const f=()=>p()?.path_current()??null;h.querySelector(".files-mkdir")?.addEventListener("click",()=>{const g=f();g!==null&&d.directory_make(l,g)}),h.querySelector(".files-refresh")?.addEventListener("click",()=>{const g=f();g!==null&&d.listing_refresh(l,g)});const _=h.querySelector(".files-upload-input");h.querySelector(".files-upload")?.addEventListener("click",()=>{f()!==null&&_?.click()}),_?.addEventListener("change",()=>{const g=f(),m=_.files;g===null||m===null||m.length===0||(d.files_deliver(l,g,Array.from(m)),_.value="")})},a=(l,c)=>{const h=d=>d.modelKind==="fs.file"?d.address.replace(/\/[^/]*$/,"")||"/":d.address;c("ENTER NODE","move the session into the indicated node (its data directory)",()=>{const d=n.regard_get(l),u=i.get("dag",l)?.feed_get()??null,p=d===null?u===null?null:`/proc/jobs/feed_${u}`:h(d);p!==null&&t.terminal.line_run(`cd "${p}"`)}),c("PROCESS NODE","run an executable on the indicated node's output (a catalogue opens beside)",()=>{const d=n.regard_get(l),u=i.get("dag",l)?.feed_get()??null;if(d===null||u===null)return;const p=h(d),f=am(p)??(/_(\d+)\/?$/.exec(p)===null?null:parseInt(/_(\d+)\/?$/.exec(p)?.[1]??"",10));f!==null&&e.process_open(l,{input:p.replace(/\/data\/?$/,"")+"/data",feed:u,node:f})}),c("ENTER FEED","move the session into the feed on stage (or the one picked in the roster)",()=>{const d=i.get("dag",l)?.feed_get()??null;d!==null&&t.terminal.line_run(`cd "/proc/jobs/feed_${d}"`)}),c("BACK","return to the previous listing inside the node",()=>e.overlay_back(l)),c("CLEAR DETAIL","dismiss the node facts (a click on empty space does too)",()=>{i.get("dag",l)?.detail_clear()}),c("REFRESH","revisit the feed now (a watch keeps sampling it while it runs)",()=>{i.get("dag",l)?.refresh()})};return(l,c,h)=>{const d=h.querySelector(".pane-drawer"),u=h.querySelector(".pane-handle");if(d===null||u===null)return;r(l,d,u);const p=d.querySelector(".drawer-children");if(p===null)return;const f=(_,g,m)=>{const w=document.createElement("button");w.className="pacs-capsule drawer-child",w.textContent=_,w.title=g,w.addEventListener("click",()=>{m(),d.hidden=!0,t.sound("audio3")}),p.appendChild(w)};(c==="files"||c==="catalogue")&&o(l,d,h),c==="dag"&&a(l,f)}}async function TH(t,e){if(!Vl(window.location.search))return`${t}: this page did not come through a porter, so there is no other session to switch to`;const s=Dl(window.location.pathname,"switch");let i;try{i=await(await fetch(s,{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},body:JSON.stringify(t==="stratus"?{to:t,cloud:"oci",spend:e}:{to:t})})).json()}catch(r){return`${t}: the porter did not answer (${r instanceof Error?r.message:String(r)})`}if(i.error!==void 0||i.key===void 0)return`${t}: ${i.error??"the porter refused"}`;const n=s.slice(0,-6);return window.location.assign(i.state==="starting"?`${n}greet/${i.key}`:`${n}s/${i.key}/?door`),t==="stratus"?`switching to your stratus session${e?" (may spend)":" (read-only)"}…`:"switching to your ChRIS session…"}function IH(t,e){const{layout:s,panels:i,paneInstance_get:n,subjects:r}=t,o=d=>n(d)?.kind??null,a=(d,u)=>{const p=new Set(s.panes_shown()),f=r.group_resolve(u),_=i.entries(d).filter(([g])=>p.has(g));return i.get(d,u)??_.find(([g])=>r.group_resolve(g)===f)?.[1]??(_.length===1?_[0]?.[1]:void 0)},l=async(d,u,p)=>{if(u==="state"){const f=d.state_get();if(f===null)return"image state: no image on the field";const _=(f.viewports??[]).map(g=>`${g.id.replace(/^.*-/,"")} scale=${g.scale.toFixed(3)} focus=${g.focus.map(m=>m.toFixed(2)).join(",")} voi=${g.voi===null?"-":`${g.voi.lower.toFixed(1)}..${g.voi.upper.toFixed(1)}`}`).join(" | ");return`image: layout=${f.layout} tool=${f.tool} primary=${f.primaryTool??"-"} slice=${f.slice}/${f.slices} refused=${f.refused} annotations=${f.annotations} filled=${f.filled}
4364
4364
  viewports: ${_||"(none)"}`}if(u==="layout"){const f=p[0]??"";return $2.includes(f)?await d.layout_set(f)?`image layout ${f}`:d.state_get()?.waiting===f?`image layout ${f}: waiting for LOAD`:`image layout ${f}: not offered`:"image layout single|mpr|3d|slab"}if(u==="slice"){const f=Number(p[0]);return!Number.isInteger(f)||f<1?"image slice <n>":d.slice_set(f)?`image slice ${f}`:`image slice ${f}: not offered`}if(u==="series"){const f=Number(p[0]),_=d.siblings_get();if(_.length===0)return"image series: this pane holds one series, not a study";const g=_[f-1];if(g===void 0)return`image series <1..${_.length}>: ${_.map((w,y)=>`${y+1} ${w.label}`).join(" · ")}`;const m=await e.series_ask(g.path);return m===null?`image series ${f}: ${g.path}: not a readable DICOM series`:(d.series_show(m,{siblings:[..._]}),`image series ${f} ${g.label}`)}if(u==="wl"){if((p[0]??"").toLowerCase()==="preset"){const g=p[1]??"";return g===""?"image wl preset <brain|bone|lung|soft|liver>":d.wlPreset_set(g)?`image wl preset ${g}`:`image wl preset ${g}: none for this modality`}const f=Number(p[0]),_=Number(p[1]);return!Number.isFinite(f)||!Number.isFinite(_)||f>=_?"image wl <lower> <upper> | image wl preset <name>":d.wl_set(f,_)?`image wl ${f} ${_}`:"image wl: not offered"}if(u==="colormap"){const f=(p[0]??"").toLowerCase();return dh.includes(f)?d.colormap_set(f)?`image colormap ${f}`:`image colormap ${f}: not offered`:"image colormap gray|hot|jet|cool"}if(u==="save")return await d.annotations_save()?"image save":"image save: nothing saved (the console says why)";if(u==="load")return await d.load_press()?"image load":"image load: nothing was waiting";if(u==="guard"){if((p[0]??"").toLowerCase()==="off")return d.guard_set(null),"image guard off";const _=Number(p[0]);return!Number.isFinite(_)||_<0?`image guard <bytes>|off (now ${d.guard_get()===null?"off":d.guard_get()})`:(d.guard_set(_),`image guard ${_}`)}if(u==="ghost"){const _=(p[0]??"").toLowerCase()==="off"?null:Number(p[0]);return _!==null&&(!Number.isFinite(_)||_<0||_>1)?"image ghost <0..1>|off (SLAB layout)":d.ghost_set(_)?`image ghost ${_===null?"off":_}`:"image ghost: SLAB layout only"}if(u==="tags"){const f=i.idOf("image",d);return f===null?"image tags: no image pane":e.tagsPane_open(f)}return"image <path> · layout single|mpr|3d · slice <n> · series <n> · wl <lo> <hi> | wl preset <name> · colormap <name> · save"},c=(d,u,p)=>{if(u==="redact"){const f=(p[0]??"").toLowerCase();return f!=="on"&&f!=="off"?"tags redact on|off":(d.redact_set(f==="on"),`tags redact ${f}`)}if(u==="filter"){const f=p.join(" ");return f===""||f.toLowerCase()==="off"?(d.filter_set(null),"tags filter off"):(d.filter_set(f),`tags filter ${f}`)}return"tags redact on|off · filter <text>|off"},h=()=>{const d=s.tree_get();if(d===null)return"# empty desktop";const u=[],p=v=>"pane"in v?v.pane:p(v.first),f=p(d),_=o(f);u.push(`view ${_==="dag"?"runs":_==="pacs"?"pacs":"files"}`);let g=1;const m=(v,z)=>{const x=o(v);x==="dag"&&v!==f&&u.push(`pane %${z} claim runs`),x==="files"&&v!==f&&r.group_resolve(v)===v&&u.push(`pane %${z} claim files`);const M=x==="files"?i.get("files",v)?.path_current()??null:null;M!==null&&u.push(`file %${z} open ${M}`);const S=x==="dag"?i.get("dag",v):void 0;if(S!==void 0&&S.graph_isShown())for(const T of S.view_lines())u.push(T.replace(/^dag /,`dag %${z} `));else if(x==="dag"){const T=n(v)?.mount,I=T?.querySelector(".dag-strategy")?.textContent?.toLowerCase()??"ranked",E=T?.querySelector(".dag-projection")?.textContent?.toLowerCase()??"3d",O=T?.querySelector(".dag-hue")?.textContent?.toLowerCase()??"status";I!=="ranked"&&u.push(`dag %${z} layout ${I}`),E!=="3d"&&u.push(`dag %${z} projection ${E}`),O!=="status"&&u.push(`dag %${z} hue ${O}`)}},w=(v,z)=>{if("pane"in v){m(v.pane,z);return}const x=p(v.second),M=o(x),S=M==="view"?"viewer":M==="files"&&r.group_resolve(x)!==x?"fs":"unlinked";u.push(`pane %${z} bind ${S}`),u.push(`pane %${z} split ${v.dir==="col"?"right":"below"}`);const T=++g;w(v.first,z),w(v.second,T)};w(d,g);const y=document.body.dataset.header;return y!==void 0&&u.push(`header ${y}`),document.getElementById("drawer")?.classList.contains("drawer-closed")&&u.push("console close"),u.join(`
4365
4365
  `)};return{focused_get:()=>{const d=document.body.dataset.zoom;return d!==void 0&&d!=="console"?d:s.focused_get()??s.panes_shown()[0]??null},focus_set:d=>n(d)===void 0?!1:(s.focus_set(d),!0),panes_shown:()=>s.panes_shown(),pane_move:e.verbs.move,pane_flip:e.verbs.flip,pane_resize:e.verbs.resize,help_open:e.help_open,notes_open:e.notes_open,focus_last:()=>{const d=s.focus_last();return d!==null&&t.sound("audio3"),d===null?null:`focused ${d}`},paneRect_get:d=>document.querySelector(`.layout-leaf[data-leaf="${d}"]`)?.getBoundingClientRect()??null,paneMount_get:d=>n(d)?.mount??null,paneKind_get:o,paneLinked_get:d=>r.group_resolve(d)!==d,feed_enter:e.feed_enter,consoleZoom_toggle:e.consoleZoom_toggle,launcher_enter:e.launcher_enter,trek_open:e.trek_open,session_switch:TH,stage_keep:e.stage_keep,viewModes_hold:UU,identity_get:e.identity_get,dag_jump:(d,u,p=!1)=>{const f=i.get("dag",d)??i.values("dag")[0];return f===void 0?!1:(f.target_jumpTo(u,p),!0)},node_immerse:d=>{const p=r.regard_get(d)?.address.match(/_(\d+)(?:\/data)?\/?$/)??null;return p===null?!1:i.get("dag",d)?.node_flyTo(parseInt(p[1]??"",10))??!1},files_open:e.files_open,file_download:d=>{const u=r.regard_get(d);return u===null||u.modelKind!=="fs.file"?!1:(e.file_save(u.address),!0)},image_open:(d,u,p)=>e.image_open(d,u,p??{}),image_control:async(d,u,p)=>{const f=a("image",d);return f===void 0?`image ${u}: no image pane on stage for '${d}'`:l(f,u,p)},universe_control:(d,u,p)=>{const f=new Set(s.panes_shown()),_=(d!==null?i.get("universe",d):void 0)??i.entries("universe").find(([g])=>f.has(g))?.[1];return _===void 0?"universe: no universe pane on stage (press the dashboard tile)":_.control(u,p)},tags_control:(d,u,p)=>{const f=a("tags",d);return f===void 0?`tags ${u}: no tags pane on stage for '${d}'`:c(f,u,p)},file_delete:d=>{const u=r.regard_get(d);return u===null||u.modelKind!=="fs.file"?!1:(t.terminal.line_run(`rm "${u.address}"`),!0)},session_run:async d=>{try{return(await t.client.line_execute(d,{silent:!0,observe:!1})).envelopes.map(p=>p.renderedErr??p.rendered).join(`
4366
- `)}catch(u){return u instanceof Error?u.message:String(u)}},desktop_serialize:h}}function DH(t,e,s){if(s===!0)return"daemon-older";if(e===void 0)return null;const i=e.surface;return s===!1?i!==void 0&&t.built<i.built?"argus-older":null:i===void 0?"daemon-older":i.git===t.git&&i.built===t.built?null:t.built>=i.built?"daemon-older":"argus-older"}const u_={"daemon-older":{readout:"CALYPSO DAEMON OUT OF DATE",before:"The calypso daemon has been updated and should be restarted; some controls may not work until then. ",cure:"Restart the calypso daemon",after:"."},"argus-older":{readout:"ARGUS OUT OF DATE",before:"ARGUS is older than the calypso daemon. ",cure:"Refresh",after:" to load the new ARGUS."}};function Y1(t){const e=u_[t];return`${e.before}${e.cure}${e.after}`}async function CH(t){try{const e=t??(typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):void 0);if(e===void 0)return null;const s=await e("notes.json",{cache:"no-store"});if(!s.ok)return null;const i=await s.json(),r=i.releases?.[0]?.changes?.find(o=>o.internal!==!0)?.headline;return typeof r!="string"||typeof i.version!="string"?null:{version:i.version,headline:r}}catch{return null}}const $v=96;function RH(t){const e=t.headline.length>$v?`${t.headline.slice(0,$v-1).trimEnd()}…`:t.headline;return`argus ${t.version} · ${e} — WHAT'S NEW after restart`}function kH(t,e,s,i,n=document.body,r){n.querySelector(".build-mismatch")?.remove();const o=s.surface!==void 0?`ARGUS ${s.surface.git} built ${s.surface.built}Z`:"an ARGUS too old to say its build";i(`argus: ${Y1(t)}`);const a=s.surface!==void 0&&s.surface.git===e.git&&s.surface.built===e.built;i(a?`argus: the calypso daemon's own code on disk has changed since it started (ARGUS ${e.git} built ${e.built}Z)`:`argus: ARGUS ${e.git} built ${e.built}Z · calypso daemon started with ${o}`);const l=u_[t],c=document.createElement("div");c.className="stale-page build-mismatch",c.dataset.mismatch=t,c.setAttribute("role","alert");const h=document.createElement("span");h.className="stale-page-words";let d=document.createTextNode(l.cure);if(t==="argus-older"){const p=document.createElement("button");p.type="button",p.className="stale-page-reload",p.textContent=l.cure,p.title="reload this tab to load the new ARGUS",p.addEventListener("click",()=>{window.location.reload()}),d=p}else if(r!==void 0){const p=document.createElement("button");p.type="button",p.className="stale-page-reload build-mismatch-restart",p.textContent=l.cure,p.title="restart the calypso daemon (asks first; you stay logged in)",p.addEventListener("click",r),d=p}h.append(document.createTextNode(l.before),d,document.createTextNode(l.after));const u=document.createElement("button");u.type="button",u.className="build-mismatch-dismiss",u.textContent="×",u.title="dismiss (the status strip keeps saying it)",u.addEventListener("click",()=>{c.remove()}),c.append(h,u),n.appendChild(c),t==="daemon-older"&&CH().then(p=>{if(p===null||!c.isConnected)return;const f=document.createElement("span");f.className="build-mismatch-news",f.textContent=RH(p),h.appendChild(f)})}function NH(t,e,s,i=document.body){const n={git:"89d24509",built:"2026-10-24 19:48"};let r=[],o,a=null;const l=h=>{r!==null?r.push(h):e(h)},c=h=>{if(o===void 0)return;const d=DH(n,o,h);if(d!==a){if(a=d,d===null){t.build_show(null),i.querySelector(".build-mismatch")?.remove();return}t.build_show(u_[d].readout,Y1(d)),kH(d,n,o,l,i,Vl(window.location.search)?s:void 0)}};return{attach_take:h=>{o=h.stack,c(h.stale)},stale_take:h=>c(h),release:()=>{const h=r??[];r=null;for(const d of h)e(d)}}}function BH(t=document.getElementById("door-pill")){t===null||!Vl(window.location.search)||(t.hidden=!1,t.addEventListener("click",()=>{const e=Dl(window.location.pathname,"logout"),s=Dl(window.location.pathname,"login");fetch(e,{method:"POST",headers:{accept:"application/json"}}).catch(()=>{}).then(()=>{window.location.assign(s)})}))}const GH="Restart the calypso daemon? You'll stay logged in; the page reloads when the new daemon is up.";function PH(t){const e=[];t.running!==null&&e.push(`the running command: ${t.running}`);for(const r of t.unsaved)e.push(`an unsaved edit in ${r}`);const s=t.others.filter(r=>r.kind==="browser").length,i=t.others.length-s,n=[];return s>0&&n.push(s===1?"1 other browser":`${s} other browsers`),i>0&&n.push(i===1?"1 chell":`${i} chells`),n.length>0&&e.push(`${n.join(" and ")}, which will be disconnected`),e}function LH(t){return t==="restart"?"The calypso daemon is restarting (asked from another browser or surface). Following it…":t==="end"?"The calypso daemon was ended by an administrator.":"The calypso daemon stopped."}function WH(t,e){const s=document.createElement("div");s.className="stale-page restart-question",s.setAttribute("role","alertdialog");const i=document.createElement("div");i.className="stale-page-words";const n=document.createElement("div");if(n.textContent=GH,i.append(n),t.length>0){const h=document.createElement("ul");h.className="restart-cuts";const d=document.createElement("li");d.className="restart-cuts-lead",d.textContent="This will cut off:",h.append(d);for(const u of t){const p=document.createElement("li");p.textContent=u,h.append(p)}i.append(h)}const r=document.createElement("button");r.type="button",r.className="restart-yes",r.textContent="YES";const o=document.createElement("button");o.type="button",o.className="restart-no",o.textContent="NO";let a=!1;const l=h=>{a||(a=!0,s.remove(),e(h))};r.addEventListener("click",()=>l(!0)),o.addEventListener("click",()=>l(!1)),s.addEventListener("keydown",h=>{h.key!=="Enter"&&h.key!=="Escape"||(h.preventDefault(),h.stopPropagation(),l(h.key==="Enter"))});const c=document.createElement("div");return c.className="restart-answers",c.append(r,o),s.append(i,c),s}function FH(t,e=document.body){const s=Vl(window.location.search);let i=null,n=null,r=[],o=!1;const a=u=>{e.querySelector(".restart-said")?.remove();const p=document.createElement("div");p.className="stale-page restart-said",p.setAttribute("role","alert"),p.textContent=u,e.appendChild(p)},l=u=>{window.location.assign(`${Dl(window.location.pathname,"greet")}/${encodeURIComponent(u)}`)},c=async()=>{o=!0,a("Restarting the calypso daemon…");try{const u=await fetch(Dl(window.location.pathname,"restart"),{method:"POST",headers:{accept:"application/json"}}),p=await u.json();if(!u.ok||p.key===void 0)throw new Error(p.error??`the door answered ${u.status}`);l(p.key)}catch(u){o=!1,a(`The calypso daemon could not be restarted: ${u instanceof Error?u.message:String(u)}`)}},h=()=>{if(!s||e.querySelector(".restart-question")!==null)return;const u={running:n,unsaved:t.unsaved(),others:r.filter(f=>f.id!==i)},p=WH(PH(u),f=>{f&&c()});e.querySelector(".build-mismatch")?.remove(),e.appendChild(p),p.querySelector(".restart-yes")?.focus()},d=document.getElementById("restart-pill");return d!==null&&s&&(d.hidden=!1,d.addEventListener("click",h)),{ask:h,attach_take:u=>{i=u.surface??null},telemetry_take:u=>{u?.lane!==void 0&&(n=u.lane.running?.line??null),u?.surfaces!==void 0&&(r=u.surfaces)},closing_take:u=>{if(o||(a(LH(u)),u!=="restart"||!s))return;const p=window.location.pathname.split("/").filter(f=>f.length>0).at(-1);p!==void 0&&setTimeout(()=>l(p),1200)}}}function UH(t,e,s,i){t.line_execute(`motd ${s}`,{silent:!0,observe:!1}).then(n=>{const r=n.envelopes.filter(o=>o.status==="ok").map(o=>o.rendered).join("").trimEnd();r.length>0&&e.greeting_write(r.split(`
4366
+ `)}catch(u){return u instanceof Error?u.message:String(u)}},desktop_serialize:h}}function DH(t,e,s){if(s===!0)return"daemon-older";if(e===void 0)return null;const i=e.surface;return s===!1?i!==void 0&&t.built<i.built?"argus-older":null:i===void 0?"daemon-older":i.git===t.git&&i.built===t.built?null:t.built>=i.built?"daemon-older":"argus-older"}const u_={"daemon-older":{readout:"CALYPSO DAEMON OUT OF DATE",before:"The calypso daemon has been updated and should be restarted; some controls may not work until then. ",cure:"Restart the calypso daemon",after:"."},"argus-older":{readout:"ARGUS OUT OF DATE",before:"ARGUS is older than the calypso daemon. ",cure:"Refresh",after:" to load the new ARGUS."}};function Y1(t){const e=u_[t];return`${e.before}${e.cure}${e.after}`}async function CH(t){try{const e=t??(typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):void 0);if(e===void 0)return null;const s=await e("notes.json",{cache:"no-store"});if(!s.ok)return null;const i=await s.json(),r=i.releases?.[0]?.changes?.find(o=>o.internal!==!0)?.headline;return typeof r!="string"||typeof i.version!="string"?null:{version:i.version,headline:r}}catch{return null}}const $v=96;function RH(t){const e=t.headline.length>$v?`${t.headline.slice(0,$v-1).trimEnd()}…`:t.headline;return`argus ${t.version} · ${e} — WHAT'S NEW after restart`}function kH(t,e,s,i,n=document.body,r){n.querySelector(".build-mismatch")?.remove();const o=s.surface!==void 0?`ARGUS ${s.surface.git} built ${s.surface.built}Z`:"an ARGUS too old to say its build";i(`argus: ${Y1(t)}`);const a=s.surface!==void 0&&s.surface.git===e.git&&s.surface.built===e.built;i(a?`argus: the calypso daemon's own code on disk has changed since it started (ARGUS ${e.git} built ${e.built}Z)`:`argus: ARGUS ${e.git} built ${e.built}Z · calypso daemon started with ${o}`);const l=u_[t],c=document.createElement("div");c.className="stale-page build-mismatch",c.dataset.mismatch=t,c.setAttribute("role","alert");const h=document.createElement("span");h.className="stale-page-words";let d=document.createTextNode(l.cure);if(t==="argus-older"){const p=document.createElement("button");p.type="button",p.className="stale-page-reload",p.textContent=l.cure,p.title="reload this tab to load the new ARGUS",p.addEventListener("click",()=>{window.location.reload()}),d=p}else if(r!==void 0){const p=document.createElement("button");p.type="button",p.className="stale-page-reload build-mismatch-restart",p.textContent=l.cure,p.title="restart the calypso daemon (asks first; you stay logged in)",p.addEventListener("click",r),d=p}h.append(document.createTextNode(l.before),d,document.createTextNode(l.after));const u=document.createElement("button");u.type="button",u.className="build-mismatch-dismiss",u.textContent="×",u.title="dismiss (the status strip keeps saying it)",u.addEventListener("click",()=>{c.remove()}),c.append(h,u),n.appendChild(c),t==="daemon-older"&&CH().then(p=>{if(p===null||!c.isConnected)return;const f=document.createElement("span");f.className="build-mismatch-news",f.textContent=RH(p),h.appendChild(f)})}function NH(t,e,s,i=document.body){const n={git:"79ee8a07",built:"2026-10-25 02:44"};let r=[],o,a=null;const l=h=>{r!==null?r.push(h):e(h)},c=h=>{if(o===void 0)return;const d=DH(n,o,h);if(d!==a){if(a=d,d===null){t.build_show(null),i.querySelector(".build-mismatch")?.remove();return}t.build_show(u_[d].readout,Y1(d)),kH(d,n,o,l,i,Vl(window.location.search)?s:void 0)}};return{attach_take:h=>{o=h.stack,c(h.stale)},stale_take:h=>c(h),release:()=>{const h=r??[];r=null;for(const d of h)e(d)}}}function BH(t=document.getElementById("door-pill")){t===null||!Vl(window.location.search)||(t.hidden=!1,t.addEventListener("click",()=>{const e=Dl(window.location.pathname,"logout"),s=Dl(window.location.pathname,"login");fetch(e,{method:"POST",headers:{accept:"application/json"}}).catch(()=>{}).then(()=>{window.location.assign(s)})}))}const GH="Restart the calypso daemon? You'll stay logged in; the page reloads when the new daemon is up.";function PH(t){const e=[];t.running!==null&&e.push(`the running command: ${t.running}`);for(const r of t.unsaved)e.push(`an unsaved edit in ${r}`);const s=t.others.filter(r=>r.kind==="browser").length,i=t.others.length-s,n=[];return s>0&&n.push(s===1?"1 other browser":`${s} other browsers`),i>0&&n.push(i===1?"1 chell":`${i} chells`),n.length>0&&e.push(`${n.join(" and ")}, which will be disconnected`),e}function LH(t){return t==="restart"?"The calypso daemon is restarting (asked from another browser or surface). Following it…":t==="end"?"The calypso daemon was ended by an administrator.":"The calypso daemon stopped."}function WH(t,e){const s=document.createElement("div");s.className="stale-page restart-question",s.setAttribute("role","alertdialog");const i=document.createElement("div");i.className="stale-page-words";const n=document.createElement("div");if(n.textContent=GH,i.append(n),t.length>0){const h=document.createElement("ul");h.className="restart-cuts";const d=document.createElement("li");d.className="restart-cuts-lead",d.textContent="This will cut off:",h.append(d);for(const u of t){const p=document.createElement("li");p.textContent=u,h.append(p)}i.append(h)}const r=document.createElement("button");r.type="button",r.className="restart-yes",r.textContent="YES";const o=document.createElement("button");o.type="button",o.className="restart-no",o.textContent="NO";let a=!1;const l=h=>{a||(a=!0,s.remove(),e(h))};r.addEventListener("click",()=>l(!0)),o.addEventListener("click",()=>l(!1)),s.addEventListener("keydown",h=>{h.key!=="Enter"&&h.key!=="Escape"||(h.preventDefault(),h.stopPropagation(),l(h.key==="Enter"))});const c=document.createElement("div");return c.className="restart-answers",c.append(r,o),s.append(i,c),s}function FH(t,e=document.body){const s=Vl(window.location.search);let i=null,n=null,r=[],o=!1;const a=u=>{e.querySelector(".restart-said")?.remove();const p=document.createElement("div");p.className="stale-page restart-said",p.setAttribute("role","alert"),p.textContent=u,e.appendChild(p)},l=u=>{window.location.assign(`${Dl(window.location.pathname,"greet")}/${encodeURIComponent(u)}`)},c=async()=>{o=!0,a("Restarting the calypso daemon…");try{const u=await fetch(Dl(window.location.pathname,"restart"),{method:"POST",headers:{accept:"application/json"}}),p=await u.json();if(!u.ok||p.key===void 0)throw new Error(p.error??`the door answered ${u.status}`);l(p.key)}catch(u){o=!1,a(`The calypso daemon could not be restarted: ${u instanceof Error?u.message:String(u)}`)}},h=()=>{if(!s||e.querySelector(".restart-question")!==null)return;const u={running:n,unsaved:t.unsaved(),others:r.filter(f=>f.id!==i)},p=WH(PH(u),f=>{f&&c()});e.querySelector(".build-mismatch")?.remove(),e.appendChild(p),p.querySelector(".restart-yes")?.focus()},d=document.getElementById("restart-pill");return d!==null&&s&&(d.hidden=!1,d.addEventListener("click",h)),{ask:h,attach_take:u=>{i=u.surface??null},telemetry_take:u=>{u?.lane!==void 0&&(n=u.lane.running?.line??null),u?.surfaces!==void 0&&(r=u.surfaces)},closing_take:u=>{if(o||(a(LH(u)),u!=="restart"||!s))return;const p=window.location.pathname.split("/").filter(f=>f.length>0).at(-1);p!==void 0&&setTimeout(()=>l(p),1200)}}}function UH(t,e,s,i){t.line_execute(`motd ${s}`,{silent:!0,observe:!1}).then(n=>{const r=n.envelopes.filter(o=>o.status==="ok").map(o=>o.rendered).join("").trimEnd();r.length>0&&e.greeting_write(r.split(`
4367
4367
  `))}).catch(()=>{}).finally(i)}var X1=Object.defineProperty,$H=Object.getOwnPropertyDescriptor,jH=(t,e)=>{for(var s in e)X1(t,s,{get:e[s],enumerable:!0})},es=(t,e,s,i)=>{for(var n=i>1?void 0:i?$H(e,s):e,r=t.length-1,o;r>=0;r--)(o=t[r])&&(n=(i?o(e,s,n):o(n))||n);return i&&n&&X1(e,s,n),n},Re=(t,e)=>(s,i)=>e(s,i,t),jv="Terminal input",fm={get:()=>jv,set:t=>jv=t},Hv="Too much output to announce, navigate to rows manually to read",pm={get:()=>Hv,set:t=>Hv=t};function HH(t){return t.replace(/\r?\n/g,"\r")}function VH(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function qH(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function KH(t,e,s,i){if(t.stopPropagation(),t.clipboardData){let n=t.clipboardData.getData("text/plain");Z1(n,e,s,i)}}function Z1(t,e,s,i){t=HH(t),t=VH(t,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function J1(t,e,s){let i=s.getBoundingClientRect(),n=t.clientX-i.left-10,r=t.clientY-i.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${n}px`,e.style.top=`${r}px`,e.style.zIndex="1000",e.focus()}function Vv(t,e,s,i,n){J1(t,e,s),n&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function dr(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function $d(t,e=0,s=t.length){let i="";for(let n=e;n<s;++n){let r=t[n];r>65535?(r-=65536,i+=String.fromCharCode((r>>10)+55296)+String.fromCharCode(r%1024+56320)):i+=String.fromCharCode(r)}return i}var YH=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let i=0,n=0;if(this._interim){let r=t.charCodeAt(n++);56320<=r&&r<=57343?e[i++]=(this._interim-55296)*1024+r-56320+65536:(e[i++]=this._interim,e[i++]=r),this._interim=0}for(let r=n;r<s;++r){let o=t.charCodeAt(r);if(55296<=o&&o<=56319){if(++r>=s)return this._interim=o,i;let a=t.charCodeAt(r);56320<=a&&a<=57343?e[i++]=(o-55296)*1024+a-56320+65536:(e[i++]=o,e[i++]=a);continue}o!==65279&&(e[i++]=o)}return i}},XH=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let s=t.length;if(!s)return 0;let i=0,n,r,o,a,l=0,c=0;if(this.interim[0]){let u=!1,p=this.interim[0];p&=(p&224)===192?31:(p&240)===224?15:7;let f=0,_;for(;(_=this.interim[++f]&63)&&f<4;)p<<=6,p|=_;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,m=g-f;for(;c<m;){if(c>=s)return 0;if(_=t[c++],(_&192)!==128){c--,u=!0;break}else this.interim[f++]=_,p<<=6,p|=_&63}u||(g===2?p<128?c--:e[i++]=p:g===3?p<2048||p>=55296&&p<=57343||p===65279||(e[i++]=p):p<65536||p>1114111||(e[i++]=p)),this.interim.fill(0)}let h=s-4,d=c;for(;d<s;){for(;d<h&&!((n=t[d])&128)&&!((r=t[d+1])&128)&&!((o=t[d+2])&128)&&!((a=t[d+3])&128);)e[i++]=n,e[i++]=r,e[i++]=o,e[i++]=a,d+=4;if(n=t[d++],n<128)e[i++]=n;else if((n&224)===192){if(d>=s)return this.interim[0]=n,i;if(r=t[d++],(r&192)!==128){d--;continue}if(l=(n&31)<<6|r&63,l<128){d--;continue}e[i++]=l}else if((n&240)===224){if(d>=s)return this.interim[0]=n,i;if(r=t[d++],(r&192)!==128){d--;continue}if(d>=s)return this.interim[0]=n,this.interim[1]=r,i;if(o=t[d++],(o&192)!==128){d--;continue}if(l=(n&15)<<12|(r&63)<<6|o&63,l<2048||l>=55296&&l<=57343||l===65279)continue;e[i++]=l}else if((n&248)===240){if(d>=s)return this.interim[0]=n,i;if(r=t[d++],(r&192)!==128){d--;continue}if(d>=s)return this.interim[0]=n,this.interim[1]=r,i;if(o=t[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=n,this.interim[1]=r,this.interim[2]=o,i;if(a=t[d++],(a&192)!==128){d--;continue}if(l=(n&7)<<18|(r&63)<<12|(o&63)<<6|a&63,l<65536||l>1114111)continue;e[i++]=l}}return i}},Q1="",_r=" ",Xl=class ex{constructor(){this.fg=0,this.bg=0,this.extended=new ld}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new ex;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ld=class tx{constructor(e=0,s=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new tx(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ni=class sx extends Xl{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ld,this.combinedData=""}static fromCharData(e){let s=new sx;return s.setFromCharData(e),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?dr(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let s=!1;if(e[1].length>2)s=!0;else if(e[1].length===2){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let n=e[1].charCodeAt(1);56320<=n&&n<=57343?this.content=(i-55296)*1024+n-56320+65536|e[2]<<22:s=!0}else s=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;s&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},qv="di$target",mm="di$dependencies",pf=new Map;function ZH(t){return t[mm]||[]}function zs(t){if(pf.has(t))return pf.get(t);let e=function(s,i,n){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");JH(e,s,n)};return e._id=t,pf.set(t,e),e}function JH(t,e,s){e[qv]===e?e[mm].push({id:t,index:s}):(e[mm]=[{id:t,index:s}],e[qv]=e)}var Zs=zs("BufferService"),ix=zs("CoreMouseService"),zo=zs("CoreService"),QH=zs("CharsetService"),f_=zs("InstantiationService"),nx=zs("LogService"),Js=zs("OptionsService"),rx=zs("OscLinkService"),e9=zs("UnicodeService"),Zl=zs("DecorationService"),gm=class{constructor(t,e,s){this._bufferService=t,this._optionsService=e,this._oscLinkService=s}provideLinks(t,e){let s=this._bufferService.buffer.lines.get(t-1);if(!s){e(void 0);return}let i=[],n=this._optionsService.rawOptions.linkHandler,r=new Ni,o=s.getTrimmedLength(),a=-1,l=-1,c=!1;for(let h=0;h<o;h++)if(!(l===-1&&!s.hasContent(h))){if(s.loadCell(h,r),r.hasExtendedAttrs()&&r.extended.urlId)if(l===-1){l=h,a=r.extended.urlId;continue}else c=r.extended.urlId!==a;else l!==-1&&(c=!0);if(c||l!==-1&&h===o-1){let d=this._oscLinkService.getLinkData(a)?.uri;if(d){let u={start:{x:l+1,y:t},end:{x:h+(!c&&h===o-1?1:0),y:t}},p=!1;if(!n?.allowNonHttpProtocols)try{let f=new URL(d);["http:","https:"].includes(f.protocol)||(p=!0)}catch{p=!0}p||i.push({text:d,range:u,activate:(f,_)=>n?n.activate(f,_,u):t9(f,_),hover:(f,_)=>n?.hover?.(f,_,u),leave:(f,_)=>n?.leave?.(f,_,u)})}c=!1,r.hasExtendedAttrs()&&r.extended.urlId?(l=h,a=r.extended.urlId):(l=-1,a=-1)}}e(i)}};gm=es([Re(0,Zs),Re(1,Js),Re(2,rx)],gm);function t9(t,e){if(confirm(`Do you want to navigate to ${e}?
4368
4368
 
4369
4369
  WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var jd=zs("CharSizeService"),Kn=zs("CoreBrowserService"),p_=zs("MouseService"),Yn=zs("RenderService"),s9=zs("SelectionService"),ox=zs("CharacterJoinerService"),Oa=zs("ThemeService"),ax=zs("LinkProviderService"),i9=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?Kv.isErrorNoTelemetry(t)?new Kv(t.message+`
@@ -4387,9 +4387,9 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
4387
4387
  `).slice(2).join(`
4388
4388
  `))}},bq=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},Mq=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},vq=0,Tf=class{constructor(t){this.value=t,this.id=vq++}},wq=2,yq,ar=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new gq(t?.onListenerError??Af,this._options?.leakWarningThreshold??mq):void 0,this._perfMon=this._options?._profName?new pq(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(t,e,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let o=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(o);let a=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],l=new Mq(`${o}. HINT: Stack shows most frequent listener (${a[1]}-times)`,a[0]);return(this._options?.onListenerError||Af)(l),pd.None}if(this._disposed)return pd.None;e&&(t=t.bind(e));let i=new Tf(t),n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=_q.create(),n=this._leakageMon.check(i.stack,this._size+1)),this._listeners?this._listeners instanceof Tf?(this._deliveryQueue??=new zq,this._listeners=[this._listeners,i]):this._listeners.push(i):(this._options?.onWillAddFirstListener?.(this),this._listeners=i,this._options?.onDidAddFirstListener?.(this)),this._size++;let r=Ux(()=>{n?.(),this._removeListener(i)});return s instanceof z_?s.add(r):Array.isArray(s)&&s.push(r),r},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let e=this._listeners,s=e.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,e[s]=void 0;let i=this._deliveryQueue.current===this;if(this._size*wq<=e.length){let n=0;for(let r=0;r<e.length;r++)e[r]?e[n++]=e[r]:i&&(this._deliveryQueue.end--,n<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=n}}_deliver(t,e){if(!t)return;let s=this._options?.onListenerError||Af;if(!s){t.value(e);return}try{t.value(e)}catch(i){s(i)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Tf)this._deliver(this._listeners,t);else{let e=this._deliveryQueue;e.enqueue(this,t,this._listeners.length),this._deliverQueue(e)}this._perfMon?.stop()}hasListeners(){return this._size>0}},zq=class{constructor(){this.i=-1,this.end=0}enqueue(t,e,s){this.i=0,this.end=s,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},md=class Rh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ar,this.onChange=this._onChange.event;let e=new iq;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!==0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,s,i=!1){return(e&16777215)<<3|(s&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let s=0,i=0,n=e.length;for(let r=0;r<n;++r){let o=e.charCodeAt(r);if(55296<=o&&o<=56319){if(++r>=n)return s+this.wcwidth(o);let c=e.charCodeAt(r);56320<=c&&c<=57343?o=(o-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let a=this.charProperties(o,i),l=Rh.extractWidth(a);Rh.extractShouldJoin(a)&&(l-=Rh.extractWidth(i)),s+=l,i=a}return s}charProperties(e,s){return this._activeProvider.charProperties(e,s)}},If=[[768,879],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1541],[1552,1562],[1564,1564],[1611,1631],[1648,1648],[1750,1757],[1759,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2045,2045],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2259,2306],[2362,2362],[2364,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2558,2558],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2641,2641],[2672,2673],[2677,2677],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2810,2815],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[2902,2902],[2914,2915],[2946,2946],[3008,3008],[3021,3021],[3072,3072],[3076,3076],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3170,3171],[3201,3201],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3328,3329],[3387,3388],[3393,3396],[3405,3405],[3426,3427],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3981,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4151],[4153,4154],[4157,4158],[4184,4185],[4190,4192],[4209,4212],[4226,4226],[4229,4230],[4237,4237],[4253,4253],[4448,4607],[4957,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6158],[6277,6278],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6683,6683],[6742,6742],[6744,6750],[6752,6752],[6754,6754],[6757,6764],[6771,6780],[6783,6783],[6832,6846],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7040,7041],[7074,7077],[7080,7081],[7083,7085],[7142,7142],[7144,7145],[7149,7149],[7151,7153],[7212,7219],[7222,7223],[7376,7378],[7380,7392],[7394,7400],[7405,7405],[7412,7412],[7416,7417],[7616,7673],[7675,7679],[8203,8207],[8234,8238],[8288,8292],[8294,8303],[8400,8432],[11503,11505],[11647,11647],[11744,11775],[12330,12333],[12441,12442],[42607,42610],[42612,42621],[42654,42655],[42736,42737],[43010,43010],[43014,43014],[43019,43019],[43045,43046],[43204,43205],[43232,43249],[43263,43263],[43302,43309],[43335,43345],[43392,43394],[43443,43443],[43446,43449],[43452,43453],[43493,43493],[43561,43566],[43569,43570],[43573,43574],[43587,43587],[43596,43596],[43644,43644],[43696,43696],[43698,43700],[43703,43704],[43710,43711],[43713,43713],[43756,43757],[43766,43766],[44005,44005],[44008,44008],[44013,44013],[64286,64286],[65024,65039],[65056,65071],[65279,65279],[65529,65531]],Sq=[[66045,66045],[66272,66272],[66422,66426],[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[68325,68326],[68900,68903],[69446,69456],[69633,69633],[69688,69702],[69759,69761],[69811,69814],[69817,69818],[69821,69821],[69837,69837],[69888,69890],[69927,69931],[69933,69940],[70003,70003],[70016,70017],[70070,70078],[70089,70092],[70191,70193],[70196,70196],[70198,70199],[70206,70206],[70367,70367],[70371,70378],[70400,70401],[70459,70460],[70464,70464],[70502,70508],[70512,70516],[70712,70719],[70722,70724],[70726,70726],[70750,70750],[70835,70840],[70842,70842],[70847,70848],[70850,70851],[71090,71093],[71100,71101],[71103,71104],[71132,71133],[71219,71226],[71229,71229],[71231,71232],[71339,71339],[71341,71341],[71344,71349],[71351,71351],[71453,71455],[71458,71461],[71463,71467],[71727,71735],[71737,71738],[72148,72151],[72154,72155],[72160,72160],[72193,72202],[72243,72248],[72251,72254],[72263,72263],[72273,72278],[72281,72283],[72330,72342],[72344,72345],[72752,72758],[72760,72765],[72767,72767],[72850,72871],[72874,72880],[72882,72883],[72885,72886],[73009,73014],[73018,73018],[73020,73021],[73023,73029],[73031,73031],[73104,73105],[73109,73109],[73111,73111],[73459,73460],[78896,78904],[92912,92916],[92976,92982],[94031,94031],[94095,94098],[113821,113822],[113824,113827],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[121344,121398],[121403,121452],[121461,121461],[121476,121476],[121499,121503],[121505,121519],[122880,122886],[122888,122904],[122907,122913],[122915,122916],[122918,122922],[123184,123190],[123628,123631],[125136,125142],[125252,125258],[917505,917505],[917536,917631],[917760,917999]],Df=[[4352,4447],[8986,8987],[9001,9002],[9193,9196],[9200,9200],[9203,9203],[9725,9726],[9748,9749],[9800,9811],[9855,9855],[9875,9875],[9889,9889],[9898,9899],[9917,9918],[9924,9925],[9934,9934],[9940,9940],[9962,9962],[9970,9971],[9973,9973],[9978,9978],[9981,9981],[9989,9989],[9994,9995],[10024,10024],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10133,10135],[10160,10160],[10175,10175],[11035,11036],[11088,11088],[11093,11093],[11904,11929],[11931,12019],[12032,12245],[12272,12283],[12288,12329],[12334,12350],[12353,12438],[12443,12543],[12549,12591],[12593,12686],[12688,12730],[12736,12771],[12784,12830],[12832,12871],[12880,19903],[19968,42124],[42128,42182],[43360,43388],[44032,55203],[63744,64255],[65040,65049],[65072,65106],[65108,65126],[65128,65131],[65281,65376],[65504,65510]],xq=[[94176,94179],[94208,100343],[100352,101106],[110592,110878],[110928,110930],[110948,110951],[110960,111355],[126980,126980],[127183,127183],[127374,127374],[127377,127386],[127488,127490],[127504,127547],[127552,127560],[127568,127569],[127584,127589],[127744,127776],[127789,127797],[127799,127868],[127870,127891],[127904,127946],[127951,127955],[127968,127984],[127988,127988],[127992,128062],[128064,128064],[128066,128252],[128255,128317],[128331,128334],[128336,128359],[128378,128378],[128405,128406],[128420,128420],[128507,128591],[128640,128709],[128716,128716],[128720,128722],[128725,128725],[128747,128748],[128756,128762],[128992,129003],[129293,129393],[129395,129398],[129402,129442],[129445,129450],[129454,129482],[129485,129535],[129648,129651],[129656,129658],[129664,129666],[129680,129685],[131072,196605],[196608,262141]],Tn;function Lw(t,e){let s=0,i=e.length-1,n;if(t<e[0][0]||t>e[i][1])return!1;for(;i>=s;)if(n=s+i>>1,t>e[n][1])s=n+1;else if(t<e[n][0])i=n-1;else return!0;return!1}var Oq=class{constructor(){if(this.version="11",!Tn){Tn=new Uint8Array(65536),Tn.fill(1),Tn[0]=0,Tn.fill(0,1,32),Tn.fill(0,127,160);for(let t=0;t<If.length;++t)Tn.fill(0,If[t][0],If[t][1]+1);for(let t=0;t<Df.length;++t)Tn.fill(2,Df[t][0],Df[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?Tn[t]:Lw(t,Sq)?0:Lw(t,xq)?2:1}charProperties(t,e){let s=this.wcwidth(t),i=s===0&&e!==0;if(i){let n=md.extractWidth(e);n===0?i=!1:n>s&&(s=n)}return md.createPropertyValue(0,s,i)}},Eq=class{activate(t){t.unicode.register(new Oq)}dispose(){}};var Aq=class{constructor(t,e,s,i={}){this._terminal=t,this._regex=e,this._handler=s,this._options=i}provideLinks(t,e){let s=Iq.computeLink(t,this._regex,this._terminal,this._handler);e(this._addCallbacks(s))}_addCallbacks(t){return t.map(e=>(e.leave=this._options.leave,e.hover=(s,i)=>{if(this._options.hover){let{range:n}=e;this._options.hover(s,i,n)}},e))}};function Tq(t){try{let e=new URL(t),s=e.password&&e.username?`${e.protocol}//${e.username}:${e.password}@${e.host}`:e.username?`${e.protocol}//${e.username}@${e.host}`:`${e.protocol}//${e.host}`;return t.toLocaleLowerCase().startsWith(s.toLocaleLowerCase())}catch{return!1}}var Iq=class kh{static computeLink(e,s,i,n){let r=new RegExp(s.source,(s.flags||"")+"g"),[o,a]=kh._getWindowedLineStrings(e-1,i),l=o.join(""),c,h=[];for(;c=r.exec(l);){let d=c[0];if(!Tq(d))continue;let[u,p]=kh._mapStrIdx(i,a,0,c.index),[f,_]=kh._mapStrIdx(i,u,p,d.length);if(u===-1||p===-1||f===-1||_===-1)continue;let g={start:{x:p+1,y:u+1},end:{x:_,y:f+1}};h.push({range:g,text:d,activate:n})}return h}static _getWindowedLineStrings(e,s){let i,n=e,r=e,o=0,a="",l=[];if(i=s.buffer.active.getLine(e)){let c=i.translateToString(!0);if(i.isWrapped&&c[0]!==" "){for(o=0;(i=s.buffer.active.getLine(--n))&&o<2048&&(a=i.translateToString(!0),o+=a.length,l.push(a),!(!i.isWrapped||a.indexOf(" ")!==-1)););l.reverse()}for(l.push(c),o=0;(i=s.buffer.active.getLine(++r))&&i.isWrapped&&o<2048&&(a=i.translateToString(!0),o+=a.length,l.push(a),a.indexOf(" ")===-1););}return[l,n]}static _mapStrIdx(e,s,i,n){let r=e.buffer.active,o=r.getNullCell(),a=i;for(;n;){let l=r.getLine(s);if(!l)return[-1,-1];for(let c=a;c<l.length;++c){l.getCell(c,o);let h=o.getChars();if(o.getWidth()&&(n-=h.length||1,c===l.length-1&&h==="")){let d=r.getLine(s+1);d&&d.isWrapped&&(d.getCell(0,o),o.getWidth()===2&&(n+=1))}if(n<0)return[s,c]}s++,a=0}return[s,a]}},Dq=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Cq(t,e){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}var Rq=class{constructor(t=Cq,e={}){this._handler=t,this._options=e}activate(t){this._terminal=t;let e=this._options,s=e.urlRegex||Dq;this._linkProvider=this._terminal.registerLinkProvider(new Aq(this._terminal,s,this._handler,e))}dispose(){this._linkProvider?.dispose()}};const kq=6677;function Nq(t){const e=/^state=(idle|busy|asking|playing)$/.exec(t.trim());return e===null?null:e[1]}const eg="argus.terminalId",Bq="'JetBrainsMono NF Mono', 'MesloLGS NF', monospace",Gq=[{label:"ESC",data:"\x1B"},{label:"TAB",data:" "},{label:"CTRL",data:"ctrl"},{label:"←",data:"\x1B[D"},{label:"↑",data:"\x1B[A"},{label:"↓",data:"\x1B[B"},{label:"→",data:"\x1B[C"}];function Pq(t){const[e,s,i,n,r,o,a,l,c,h,d,u,p,f,_,g]=Qk;return{background:"#000000",foreground:t,cursor:t,cursorAccent:"#000000",selectionBackground:"#44556680",black:e,red:s,green:i,yellow:n,blue:r,magenta:o,cyan:a,white:l,brightBlack:c,brightRed:h,brightGreen:d,brightYellow:u,brightBlue:p,brightMagenta:f,brightCyan:_,brightWhite:g}}function Lq(t){if(t.length!==1)return t;const e=t.toUpperCase().charCodeAt(0);return e>=64&&e<=95?String.fromCharCode(e-64):t}function Wq(){try{return sessionStorage.getItem(eg)??void 0}catch{return}}function Ww(t){try{t===null?sessionStorage.removeItem(eg):sessionStorage.setItem(eg,t)}catch{}}class Fq{constructor(e,s,i,n=()=>{}){this.mount=e,this.wire=s,this.refused=i,this.state=n;const r=getComputedStyle(e).color||"#ffaa44";this.term=new ZV({fontFamily:Bq,fontSize:Math.max(10,Math.floor(parseFloat(getComputedStyle(e).fontSize)||13)),theme:Pq(r),cursorBlink:!0,scrollback:5e3,allowProposedApi:!0}),this.term.loadAddon(this.fit),this.term.loadAddon(new Rq),this.term.loadAddon(new Eq),this.term.unicode.activeVersion="11";const o=document.createElement("div");o.className="argus-xterm",e.appendChild(o),this.term.open(o),this.keyRow_build(),this.term.onData(a=>this.keys_send(a)),this.term.onLineFeed(()=>{this.feeds++}),this.term.parser.registerOscHandler(kq,a=>{const l=Nq(a);return l!==null&&this.state(l),!0}),this.term.onResize(({cols:a,rows:l})=>{this.terminalId!==null&&this.wire.resize(this.terminalId,a,l)}),this.observer=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>this.size_fit()),this.observer?.observe(e),this.size_fit(),this.wire.open(this.term.cols,this.term.rows,Wq())}mount;wire;refused;state;term;fit=new eq;terminalId=null;ended=!1;ctrlHeld=!1;resizeFrame=null;feeds=0;observer;size_fit(){this.resizeFrame===null&&(this.resizeFrame=requestAnimationFrame(()=>{if(this.resizeFrame=null,this.mount.offsetParent!==null)try{this.fit.fit()}catch{}}))}terminalId_get(){return this.terminalId}focus(){this.term.focus()}opened(e,s,i){if(i!==void 0){this.refused(i);return}this.terminalId=e,this.ended=!1,Ww(e),s!==""&&this.term.write(s),this.wire.resize(e,this.term.cols,this.term.rows)}data(e,s){e===this.terminalId&&this.term.write(s)}exited(e,s){e===this.terminalId&&(this.ended=!0,this.terminalId=null,Ww(null),this.term.write(`\r
4389
4389
  \x1B[90m[the console's shell exited${s===0?"":` (${s})`}; press a key for a new one]\x1B[0m\r
4390
- `))}offer(e){this.terminalId!==null&&this.wire.input(this.terminalId,`${e}`),this.focus()}buffer_lines(){const e=this.term.buffer.active,s=[];for(let i=0;i<e.length;i++){const n=e.getLine(i),r=n?.translateToString(!0)??"";n?.isWrapped===!0&&s.length>0?s[s.length-1]+=r:s.push(r)}for(;s.length>0&&s[s.length-1]==="";)s.pop();return s}mark(){return this.feeds}lines_since(e){const s=this.buffer_lines(),i=Math.max(0,this.feeds-e)+1;return s.slice(Math.max(0,s.length-i))}type(e){this.keys_send(e)}dispose(){this.observer?.disconnect(),this.term.dispose()}keys_send(e){if(this.ended){this.ended=!1,this.term.reset(),this.wire.open(this.term.cols,this.term.rows);return}if(this.terminalId===null)return;let s=e;this.ctrlHeld&&(s=Lq(e),this.ctrlHeld=!1,this.mount.querySelector(".argus-xterm-key.held")?.classList.remove("held")),this.wire.input(this.terminalId,s)}keyRow_build(){const e=document.createElement("div");e.className="argus-xterm-keys";for(const s of Gq){const i=document.createElement("button");i.type="button",i.className="argus-xterm-key",i.textContent=s.label,i.addEventListener("pointerdown",n=>{n.preventDefault(),s.data==="ctrl"?(this.ctrlHeld=!this.ctrlHeld,i.classList.toggle("held",this.ctrlHeld)):this.keys_send(s.data),this.focus()}),e.appendChild(i)}this.mount.appendChild(e)}}const Uq="argus.consoleMode",$q="console: the transcript, deprecated: this host offers no pseudo-terminal (node-pty did not build). Install python, make and g++ and reinstall for the terminal console.";function jq(){try{localStorage.removeItem(Uq)}catch{}}function Hq(t){const{client:e,terminal:s,offered:i}=t,n=document.getElementById("terminal");let r=null,o="transcript";const a=l=>{if(n!==null)if(l==="terminal"&&i){if(n.classList.add("console-terminal"),r===null){const h=document.createElement("div");h.className="argus-terminal-mount",n.appendChild(h),r=new Fq(h,{open:(d,u,p)=>e.terminal_open(d,u,p),input:(d,u)=>e.terminal_input(d,u),resize:(d,u,p)=>e.terminal_resize(d,u,p)},d=>{a("transcript"),s.line_note(`console: ${d}`)},d=>{n.dataset.terminalState=d}),n.dataset.terminalState="busy",t.screen_set(r)}const c=r;e.mirror_set(!0),s.delegate_set({note:h=>e.note_send(h),offer:h=>c.offer(h),focus:()=>c.focus(),fit:()=>c.size_fit()}),c.size_fit(),o="terminal"}else n.classList.remove("console-terminal"),e.mirror_set(!1),s.delegate_set(null),o="transcript"};return jq(),a(i?"terminal":"transcript"),i||s.line_note($q),Object.assign(globalThis,{__argusConsole:{mode:()=>o,state:()=>n?.dataset.terminalState??"busy",type:l=>r?.type(l),lines:()=>r?.buffer_lines()??[],mark:()=>r?.mark()??0,since:l=>r?.lines_since(l)??[]}}),{terminal_is:()=>o==="terminal",question_sheet:async l=>{document.querySelector(".question-sheet")?.remove();const c=document.createElement("div");c.className="share-sheet question-sheet",c.setAttribute("role","dialog");const h=document.createElement("div");h.className="share-head",h.textContent="THE SESSION ASKS",c.appendChild(h),document.body.appendChild(c);try{return await a_(s,c,l)}finally{c.remove()}}}}const Vq=new Set(["busy","asking","playing"]);function qq(t,e=()=>null){const s=document.querySelector(".console-stop"),i=document.getElementById("terminal");if(s===null||i===null)return;const n=()=>{const o=i.classList.contains("console-terminal")?Vq.has(i.dataset.terminalState??""):i.dataset.busy==="true";s.hidden=!o};new MutationObserver(n).observe(i,{attributes:!0,attributeFilter:["data-busy","data-terminal-state","class"]}),n(),s.addEventListener("click",()=>{const r=i.classList.contains("console-terminal")?e():null;r!==null&&t.terminal_input(r,""),t.stop_send()})}let Xr=()=>{};function Fw(){Xr(document.body.dataset.zoom==="console"?null:"console")}const Kq=mO(),Yq=_O(),Xq=new URL("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNDAgMjkwIj4KPGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJnIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjQwIiB5MT0iMCIgeDI9IjIwMCIgeTI9IjIyNCI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wL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ZiIgbGV0dGVyLXNwYWNpbmc9IjQiPk9DSSBURDwvdGV4dD4KPC9zdmc+",import.meta.url).href,Zq=`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" fill="#000"/><rect x="6" y="14" width="52" height="36" rx="18" fill="#20bdef"/><rect x="34" y="14" width="24" height="36" fill="#20bdef"/></svg>')}`;function Uw(t){for(const e of document.querySelectorAll('link[rel="icon"], link[rel="apple-touch-icon"]'))e.href=t}const Jq="ARGUS",$w="argus-audio",Qq=.4;let lr=!1;const eK={audio1:{file:"press",cue:"press"},audio2:{file:"arrive",cue:"ack"},audio3:{file:"retreat",cue:"close"},audio4:{file:"refuse",cue:"deny"}},Yx=new Set;function tK(){fetch("sounds/index.json").then(t=>t.ok?t.json():Promise.resolve(null)).then(t=>{const e=typeof t=="object"&&t!==null?t.files:void 0;if(Array.isArray(e))for(const s of e)typeof s=="string"&&Yx.add(s.replace(/\.[a-z0-9]+$/,""))}).catch(()=>{})}function Ii(t){if(lr)return;const e=eK[t];if(e!==void 0&&!Yx.has(e.file)){Ci.cue_play(e.cue);return}const s=document.getElementById(t);s instanceof HTMLAudioElement&&(s.currentTime=0,s.volume=Qq,s.play().catch(()=>{}))}function sK(){const t=Qe("head-menu-pill"),e=s=>{s?document.body.dataset.headMenu="open":delete document.body.dataset.headMenu,t.setAttribute("aria-expanded",String(s))};t.addEventListener("click",s=>{s.stopPropagation(),e(document.body.dataset.headMenu!=="open")}),document.addEventListener("click",s=>{if(document.body.dataset.headMenu!=="open")return;s.target instanceof Element&&s.target.closest("#header-dag-info")!==null||e(!1)})}function iK(){const t=Qe("audio-pill");try{lr=window.localStorage.getItem($w)==="off"}catch{lr=!1}const e=()=>{t.classList.toggle("audio-off",lr),Ci.muted_set(lr)};e(),tK(),t.addEventListener("click",()=>{lr=!lr;try{window.localStorage.setItem($w,lr?"off":"on")}catch{}e(),Ii("audio2")})}function nK(){return bO(window.location)}let Cf=null,gd=0;function S_(t,e){const s=()=>{e.dataset.zoom!==void 0||e.dataset.header==="away"||(gd=Math.ceil(t.offsetTop+t.offsetHeight),e.style.setProperty("--zoom-header-height",`${gd}px`))};s(),Cf===null&&(Cf=new ResizeObserver(s),Cf.observe(t))}const jw=120,rK=96;function oK(t,e,s,i){let n="";const r=h=>{h?(n=t.style.height,t.style.height=""):n!==""&&(t.style.height=n),t.classList.toggle("drawer-closed",h),Ii("audio3"),h||(i.size_fit(),i.focus_take())};s.addEventListener("click",()=>r(!t.classList.contains("drawer-closed")));let o=0,a=0,l=!1;e.addEventListener("pointerdown",h=>{l=!0,o=h.clientY,a=t.getBoundingClientRect().height,t.classList.add("drawer-dragging"),e.setPointerCapture(h.pointerId),h.preventDefault()}),e.addEventListener("pointermove",h=>{if(!l)return;const d=Math.max(jw,window.innerHeight-rK),u=a+(h.clientY-o),p=Math.min(Math.max(jw,u),d);t.style.height=`${p}px`,i.size_fit()});const c=()=>{l=!1,t.classList.remove("drawer-dragging")};return e.addEventListener("pointerup",c),e.addEventListener("pointercancel",c),r}function aK(t){const e=document.body,s=document.querySelector(".wrap:not(#gap)");let i;const n=r=>{for(const o of document.querySelectorAll(".pane-zoomed, .pane-zoomed-path"))o.classList.remove("pane-zoomed","pane-zoomed-path");if(r===null)delete e.dataset.zoom,i!==void 0&&(e.dataset.header=i,i=void 0);else{window.scrollTo(0,0),e.dataset.header==="away"?(i="away",delete e.dataset.header,gd>0&&e.style.setProperty("--zoom-header-height",`${gd}px`)):s!==null&&S_(s,e),e.dataset.zoom=r;const a=zh(r)?.mount?.parentElement??null;a?.classList.add("pane-zoomed");let l=a?.parentElement??null;for(;l!==null&&l.id!=="layout-root";)l.classList.add("pane-zoomed-path"),l=l.parentElement}for(const o of document.querySelectorAll(".drawer-zoom"))o.textContent=r!==null&&o.dataset.pane===r?"RESTORE":"ZOOM";Ii("audio3")};return Qe("header-restore").addEventListener("click",()=>{e.dataset.zoom!==void 0&&n(null)}),document.addEventListener("click",r=>{const o=r.target;if(!(o instanceof Element))return;const a=o.closest("[data-pane]");if(a===null)return;const l=a.dataset.pane??"";l!==""&&n(e.dataset.zoom===l?null:l)}),window.addEventListener("keydown",r=>{r.key==="Escape"&&e.dataset.zoom!==void 0&&(n(null),r.stopImmediatePropagation())}),Qe("drawer").addEventListener("transitionend",r=>{r.propertyName==="height"&&t.size_fit()}),n}function lK(){const t=new Y$(document.getElementById("data-cascade")),e=document.getElementById("header-telemetry");return e!==null&&t.telemetryPanel_bind(e),t}const Rf=96,cK=220,Hw="argus.headerBand.height",hK=52;function dK(){const t=document.documentElement,e=document.getElementById("header-strip"),s=document.querySelector(".wrap:not(#gap)");if(e===null||s===null)return;const i=h=>{const d=Math.max(Rf,window.innerHeight-cK),u=Math.min(Math.max(Rf,h),d);t.style.setProperty("--header-band-h",`${u}px`);try{window.localStorage.setItem(Hw,String(u))}catch{}},n=(()=>{try{return window.localStorage.getItem(Hw)}catch{return null}})();n!==null&&Number.isFinite(Number(n))&&i(Number(n));const r=()=>{const h=s.getBoundingClientRect();e.style.top=`${Math.max(0,h.bottom-hK)}px`};r(),window.addEventListener("resize",r),new MutationObserver(r).observe(document.body,{attributes:!0,attributeFilter:["data-header"]}),window.setInterval(r,500);let o=!1,a=0,l=0;e.addEventListener("pointerdown",h=>{const d=document.querySelector(".header-face");o=!0,a=h.clientY,l=d===null?Rf:d.getBoundingClientRect().height,e.setPointerCapture(h.pointerId),h.preventDefault()}),e.addEventListener("pointermove",h=>{o&&(i(l+(h.clientY-a)),r())});const c=()=>{o=!1,r()};e.addEventListener("pointerup",c),e.addEventListener("pointercancel",c)}let x_=null;function uK(t){const e=t.querySelector(".gather-rows");if(e===null)return;const s=Mi(e,{rows:".listing-row",label:i=>`+${i} MORE · ON STAGE`,press:()=>{x_?.()},className:"strategy-pill gather-more",mount:t});s.title="the whole cohort as a pane on the main panel"}function Vw(t){Mi(t,{rows:".strategy-pill, .listing-action, .holder-mark",className:"frame-more"})}function fK(){const t=e=>{for(const s of e.querySelectorAll(".mode-frame:not([data-more])"))Vw(s)};new MutationObserver(e=>{for(const s of e)for(const i of s.addedNodes)i instanceof HTMLElement&&(i.matches(".mode-frame")&&i.dataset.more===void 0&&Vw(i),t(i))}).observe(document.body,{childList:!0,subtree:!0}),t(document)}function qw(t){const e=t?.text;if(typeof e!="string"||e.length===0||typeof window.speechSynthesis>"u")return;const s=new SpeechSynthesisUtterance(e);s.rate=1,window.speechSynthesis.speak(s)}function pK(){const t=document.body,e=document.querySelector(".wrap:not(#gap)"),s=r=>{t.dataset.header===r?(e!==null&&S_(e,t),t.dataset.header="away"):t.dataset.header=r};document.querySelector(".panel-1")?.addEventListener("click",()=>s("stats")),document.querySelector(".panel-2")?.addEventListener("click",()=>s("dag")),document.querySelector(".panel-gather")?.addEventListener("click",()=>s("gather"));const i=document.querySelector(".header-gather-field");i?.querySelector(".gather-stage")?.addEventListener("click",r=>{r.stopPropagation(),x_?.()}),i!==null&&uK(i),fK();const n=()=>{t.dataset.zoom===void 0&&(delete t.dataset.header,Ii("audio3"))};Qe("header-restore").addEventListener("click",n),window.addEventListener("keydown",r=>{r.key==="Escape"&&t.dataset.header==="away"&&t.dataset.zoom===void 0&&t.dataset.gutter!=="away"&&n()})}const Zo=[{key:"lower-decks",label:"LOWER DECKS"},{key:"gold",label:"CERRITOS GOLD"},{key:"medical",label:"MEDICAL"},{key:"nemesis",label:"NEMESIS"},{key:"pharos",label:"PHAROS"}],Xx="argus-landing",mK=15e3;function Kw(){try{return(window.localStorage.getItem(Xx)??"launcher")==="launcher"}catch{return!0}}function gK(t){try{window.localStorage.setItem(Xx,t?"launcher":"last")}catch{}}const Yw="argus-theme",_K="argus-lcars",bK="medical",MK={sickbay:"medical"};function vK(){const t=Qe("theme-pill"),e=Math.max(Zo.findIndex(r=>r.key===bK),0);let s=e;try{const r=window.localStorage.getItem(Yw)??window.localStorage.getItem(_K),o=r===null?null:MK[r]??r,a=Zo.findIndex(l=>l.key===o);s=a>=0?a:e}catch{s=e}const i=document.documentElement,n=()=>{const r=Zo[s]??Zo[0];r.key==="lower-decks"?delete i.dataset.theme:i.dataset.theme=r.key,t.textContent=r.label};n(),t.addEventListener("click",()=>{s=(s+1)%Zo.length,n();try{window.localStorage.setItem(Yw,Zo[s]?.key??"lower-decks")}catch{}Ii("audio2")})}function wK(t){const e=document.getElementById("about-rows");if(e===null)return;e.replaceChildren();const i={...Xk(t)==="chris"?{cumin:t.stack?.cumin,salsa:t.stack?.salsa,chili:t.stack?.chili}:{},brasa:t.stack?.brasa,calypso:t.stack?.calypso,chell:t.stack?.chell},n=[];for(const[r,o]of Object.entries(i))o!==void 0&&n.push([r.toUpperCase(),o]);n.push(["MENU","0.30.0"],["ARGUS","89d24509 · 2026-10-24 19:48Z"],["WIRE",`V${t.protocolVersion}`]),t.stack?.build!==void 0&&n.push(["BUILD",t.stack.build]);for(const[r,o]of n){const a=document.createElement("div");a.className="telemetry-row";const l=document.createElement("span");l.className="telemetry-label",l.textContent=r;const c=document.createElement("span");c.className="telemetry-value",c.textContent=o,c.title=o,a.append(l,c),e.appendChild(a)}}function yK(){for(const t of document.querySelectorAll(".left-frame button, .left-frame-top button"))t.addEventListener("click",()=>Ii("audio2"))}let Jo=null;async function zK(t){let e=null;const s=await vO(t),i=s==="chris";document.body.dataset.composition=s;const n=new U$(document),r=i?k$(Qe("index-instrument"),{dag_primary:()=>At,dag_instances:()=>a.values("dag"),universes:()=>a.values("universe"),pacs:()=>A,runs_show:D=>N(D)}):{promptContext_take:()=>{},telemetry_take:()=>{},progress_take:()=>{}},o=new j$(Qe("lane-instrument"));window.setInterval(()=>o.tick(),500);const a=new s$;i&&m0(sj(()=>Z)),s==="stratus"&&m0(D$(()=>({...Z,controller_open:D=>Wi.open(D)})));const l=new B$;l.writeObserver_set((D,j)=>{gt.regard_send({address:D.address,...D.modelKind!==void 0?{modelKind:D.modelKind}:{},groupId:j,paneId:D.paneId}),Y()});const c={get layout(){return $},panels:a,paneInstance_get:zh,subjects:l,get dormant(){return oe},sound:Ii,get terminal(){return Ce},get client(){return gt}},h=fj(c,{catalogue_find:D=>T.get(D),run_press:(D,j,le)=>{he(D,j,le)}}),d=h.entry_show,u=D=>sg(D,t),p=Y5(c,{vfsUrl_build:u,downloadUrl_build:D=>wO(D,t),image_open:(D,j)=>k(D,j),process_open:(D,j)=>B(D,j),run_press:(D,j,le)=>{he(D,j,le)},cohort_gather:D=>ie(D),verbLine_run:(D,j)=>Et(D,j),askOnPane_await:(D,j)=>P(D,j),binEntry_show:d,catalogue_find:D=>T.get(D),promptUser:()=>M,template_stamp:qi,pane_find:Ks}),{previewProvider:f,fileText_fetch:_,file_save:g,rootedListing_show:m,listing_refresh:w,directory_make:y,files_deliver:b,filesBody_stamp:v,rowVerbs_build:z}=p,x=p.instance_build;let M=null,S=null;const T=new Map,{imageInstance_build:I,tagsInstance_build:E,tagsPane_follow:O,tagsPane_open:R,series_ask:C,image_open:k}=y$({client:()=>gt,terminal:()=>Ce,panels:()=>a,subjects:()=>l,layout:()=>$,desktop:()=>re,instance_spawn:(D,j)=>Ie(D,j),errandHost_find:()=>V(),launcher_yield:()=>_e(),birth_record:(D,j,le,xe,Ge)=>ge(D,j,le,xe,Ge),vfsUrl_build:D=>u(D)}),B=(D,j)=>{_e();const le=new Set($.panes_shown());for(const[ft,li]of T)if(le.has(ft)&&li.input===j.input){$.focus_set(ft);return}const xe=le.has(D)?D:V()??D,Ge=Ie("catalogue",D);if(!$.leaf_split(xe,re.replayPlace_get()?.dir??"col",Ge.id,re.replayPlace_get()?.before??!1)){As(Ge.id),$.mount_remove(Ge.id);return}ge(Ge.id,xe,re.replayPlace_get()?.dir??"col",re.replayPlace_get()?.before??!1),T.set(Ge.id,j);const mt=a.get("files",Ge.id);mt!==void 0&&(mt.binding_set({input:j.input,place:j.feed===null?"new feed":`feed ${j.feed}${j.node===null?"":` · node ${j.node}`}`}),mt.feedOpen_declare(ft=>X(Ge.id,ft)),m(Ge.id,mt,"/bin"),ee(mt),$.focus_set(Ge.id))},L=5,F=40,ee=D=>{gt.line_execute(`plugininstance list --limit ${F} --fields id,plugin_name,plugin_version,owner_username`,{silent:!0,observe:!1}).then(le=>{const xe=[];for(const Ge of le.envelopes)if(!(Ge.model?.kind!=="plugininstance.list"||!Array.isArray(Ge.model.data)))for(const mt of Ge.model.data){if(typeof mt.pluginName!="string"||typeof mt.pluginVersion!="string"||M!==null&&typeof mt.owner=="string"&&mt.owner!==M||mt.pluginName==="pl-dircopy")continue;const ft=`${mt.pluginName}-v${mt.pluginVersion}`;if(xe.includes(ft)||xe.push(ft),xe.length>=L)break}D.recent_set(xe.length===0?null:xe)}).catch(()=>{})},X=(D,j)=>{_e();const le=new Set($.panes_shown());for(const[mt,ft]of a.entries("dag"))if(mt!=="dag"&&le.has(mt)&&ft.feed_get()===j){$.focus_set(mt);return}const xe=le.has(D)?D:V()??D,Ge=Ie("dag",D);if(!$.leaf_split(xe,re.replayPlace_get()?.dir??"col",Ge.id,re.replayPlace_get()?.before??!1)){As(Ge.id),$.mount_remove(Ge.id);return}ge(Ge.id,xe,re.replayPlace_get()?.dir??"col",re.replayPlace_get()?.before??!1),a.get("dag",Ge.id)?.feed_enter(j)},he=async(D,j,le)=>{const xe=T.get(D),Ge=a.get("files",D);if(xe===void 0||Ge===void 0)return;const mt=$s=>{Ce.output_write("err",`\x1B[31m${$s}\x1B[0m
4390
+ `))}offer(e){this.terminalId!==null&&this.wire.input(this.terminalId,`${e}`),this.focus()}buffer_lines(){const e=this.term.buffer.active,s=[];for(let i=0;i<e.length;i++){const n=e.getLine(i),r=n?.translateToString(!0)??"";n?.isWrapped===!0&&s.length>0?s[s.length-1]+=r:s.push(r)}for(;s.length>0&&s[s.length-1]==="";)s.pop();return s}mark(){return this.feeds}lines_since(e){const s=this.buffer_lines(),i=Math.max(0,this.feeds-e)+1;return s.slice(Math.max(0,s.length-i))}type(e){this.keys_send(e)}dispose(){this.observer?.disconnect(),this.term.dispose()}keys_send(e){if(this.ended){this.ended=!1,this.term.reset(),this.wire.open(this.term.cols,this.term.rows);return}if(this.terminalId===null)return;let s=e;this.ctrlHeld&&(s=Lq(e),this.ctrlHeld=!1,this.mount.querySelector(".argus-xterm-key.held")?.classList.remove("held")),this.wire.input(this.terminalId,s)}keyRow_build(){const e=document.createElement("div");e.className="argus-xterm-keys";for(const s of Gq){const i=document.createElement("button");i.type="button",i.className="argus-xterm-key",i.textContent=s.label,i.addEventListener("pointerdown",n=>{n.preventDefault(),s.data==="ctrl"?(this.ctrlHeld=!this.ctrlHeld,i.classList.toggle("held",this.ctrlHeld)):this.keys_send(s.data),this.focus()}),e.appendChild(i)}this.mount.appendChild(e)}}const Uq="argus.consoleMode",$q="console: the transcript, deprecated: this host offers no pseudo-terminal (node-pty did not build). Install python, make and g++ and reinstall for the terminal console.";function jq(){try{localStorage.removeItem(Uq)}catch{}}function Hq(t){const{client:e,terminal:s,offered:i}=t,n=document.getElementById("terminal");let r=null,o="transcript";const a=l=>{if(n!==null)if(l==="terminal"&&i){if(n.classList.add("console-terminal"),r===null){const h=document.createElement("div");h.className="argus-terminal-mount",n.appendChild(h),r=new Fq(h,{open:(d,u,p)=>e.terminal_open(d,u,p),input:(d,u)=>e.terminal_input(d,u),resize:(d,u,p)=>e.terminal_resize(d,u,p)},d=>{a("transcript"),s.line_note(`console: ${d}`)},d=>{n.dataset.terminalState=d}),n.dataset.terminalState="busy",t.screen_set(r)}const c=r;e.mirror_set(!0),s.delegate_set({note:h=>e.note_send(h),offer:h=>c.offer(h),focus:()=>c.focus(),fit:()=>c.size_fit()}),c.size_fit(),o="terminal"}else n.classList.remove("console-terminal"),e.mirror_set(!1),s.delegate_set(null),o="transcript"};return jq(),a(i?"terminal":"transcript"),i||s.line_note($q),Object.assign(globalThis,{__argusConsole:{mode:()=>o,state:()=>n?.dataset.terminalState??"busy",type:l=>r?.type(l),lines:()=>r?.buffer_lines()??[],mark:()=>r?.mark()??0,since:l=>r?.lines_since(l)??[]}}),{terminal_is:()=>o==="terminal",question_sheet:async l=>{document.querySelector(".question-sheet")?.remove();const c=document.createElement("div");c.className="share-sheet question-sheet",c.setAttribute("role","dialog");const h=document.createElement("div");h.className="share-head",h.textContent="THE SESSION ASKS",c.appendChild(h),document.body.appendChild(c);try{return await a_(s,c,l)}finally{c.remove()}}}}const Vq=new Set(["busy","asking","playing"]);function qq(t,e=()=>null){const s=document.querySelector(".console-stop"),i=document.getElementById("terminal");if(s===null||i===null)return;const n=()=>{const o=i.classList.contains("console-terminal")?Vq.has(i.dataset.terminalState??""):i.dataset.busy==="true";s.hidden=!o};new MutationObserver(n).observe(i,{attributes:!0,attributeFilter:["data-busy","data-terminal-state","class"]}),n(),s.addEventListener("click",()=>{const r=i.classList.contains("console-terminal")?e():null;r!==null&&t.terminal_input(r,""),t.stop_send()})}let Xr=()=>{};function Fw(){Xr(document.body.dataset.zoom==="console"?null:"console")}const Kq=mO(),Yq=_O(),Xq=new URL("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNDAgMjkwIj4KPGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJnIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjQwIiB5MT0iMCIgeDI9IjIwMCIgeTI9IjIyNCI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjMmE2M2JmIi8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjN2FkM2YxIi8+PC9saW5lYXJHcmFkaWVudD4KPHJhZGlhbEdyYWRpZW50IGlkPSJoIj48c3RvcCBvZmZzZXQ9IjAiIHN0b3AtY29sb3I9IiM3YWQzZjEiIHN0b3Atb3BhY2l0eT0iMC40NSIvPjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzdhZDNmMSIgc3RvcC1vcGFjaXR5PSIwIi8+PC9yYWRpYWxHcmFkaWVudD48L2RlZnM+Cj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0iMTEyLjAiIHI9IjQuNSIvPjxjaXJjbGUgY3g9IjEyMC4wIiBjeT0iMTcyLjUiIHI9IjQuNSIvPjxjaXJjbGUgY3g9IjgwLjQiIGN5PSIxMTIuMCIgcj0iNC41Ii8+PGNpcmNsZSBjeD0iMTMxLjQiIGN5PSI4NC42IiByPSIzLjUiLz48Y2lyY2xlIGN4PSIxNDcuNCIgY3k9IjEwMC42IiByPSIzLjUiLz48Y2lyY2xlIGN4PSIxNDcuNCIgY3k9IjEyMy40IiByPSIzLjUiLz48Y2lyY2xlIGN4PSIxMzEuNCIgY3k9IjEzOS40IiByPSIzLjUiLz48Y2lyY2xlIGN4PSIxMDguNiIgY3k9IjEzOS40IiByPSIzLjUiLz48Y2lyY2xlIGN4PSI5Mi42IiBjeT0iMTIzLjQiIHI9IjMuNSIvPjxjaXJjbGUgY3g9IjkyLjYiIGN5PSIxMDAuNiIgcj0iMy41Ii8+PGNpcmNsZSBjeD0iMTA4LjYiIGN5PSI4NC42IiByPSIzLjUiLz48L2c+Cjx0ZXh0IHg9IjEyMCIgeT0iMjY4IiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBmb250LWZhbWlseT0iTW9udHNlcnJhdCxIZWx2ZXRpY2EsQXJpYWwsc2Fucy1zZXJpZiIgZm9udC13ZWlnaHQ9IjcwMCIgZm9udC1zaXplPSIzOCIgZmlsbD0iIzJhNjNiZiIgbGV0dGVyLXNwYWNpbmc9IjQiPk9DSSBURDwvdGV4dD4KPC9zdmc+",import.meta.url).href,Zq=`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" fill="#000"/><rect x="6" y="14" width="52" height="36" rx="18" fill="#20bdef"/><rect x="34" y="14" width="24" height="36" fill="#20bdef"/></svg>')}`;function Uw(t){for(const e of document.querySelectorAll('link[rel="icon"], link[rel="apple-touch-icon"]'))e.href=t}const Jq="ARGUS",$w="argus-audio",Qq=.4;let lr=!1;const eK={audio1:{file:"press",cue:"press"},audio2:{file:"arrive",cue:"ack"},audio3:{file:"retreat",cue:"close"},audio4:{file:"refuse",cue:"deny"}},Yx=new Set;function tK(){fetch("sounds/index.json").then(t=>t.ok?t.json():Promise.resolve(null)).then(t=>{const e=typeof t=="object"&&t!==null?t.files:void 0;if(Array.isArray(e))for(const s of e)typeof s=="string"&&Yx.add(s.replace(/\.[a-z0-9]+$/,""))}).catch(()=>{})}function Ii(t){if(lr)return;const e=eK[t];if(e!==void 0&&!Yx.has(e.file)){Ci.cue_play(e.cue);return}const s=document.getElementById(t);s instanceof HTMLAudioElement&&(s.currentTime=0,s.volume=Qq,s.play().catch(()=>{}))}function sK(){const t=Qe("head-menu-pill"),e=s=>{s?document.body.dataset.headMenu="open":delete document.body.dataset.headMenu,t.setAttribute("aria-expanded",String(s))};t.addEventListener("click",s=>{s.stopPropagation(),e(document.body.dataset.headMenu!=="open")}),document.addEventListener("click",s=>{if(document.body.dataset.headMenu!=="open")return;s.target instanceof Element&&s.target.closest("#header-dag-info")!==null||e(!1)})}function iK(){const t=Qe("audio-pill");try{lr=window.localStorage.getItem($w)==="off"}catch{lr=!1}const e=()=>{t.classList.toggle("audio-off",lr),Ci.muted_set(lr)};e(),tK(),t.addEventListener("click",()=>{lr=!lr;try{window.localStorage.setItem($w,lr?"off":"on")}catch{}e(),Ii("audio2")})}function nK(){return bO(window.location)}let Cf=null,gd=0;function S_(t,e){const s=()=>{e.dataset.zoom!==void 0||e.dataset.header==="away"||(gd=Math.ceil(t.offsetTop+t.offsetHeight),e.style.setProperty("--zoom-header-height",`${gd}px`))};s(),Cf===null&&(Cf=new ResizeObserver(s),Cf.observe(t))}const jw=120,rK=96;function oK(t,e,s,i){let n="";const r=h=>{h?(n=t.style.height,t.style.height=""):n!==""&&(t.style.height=n),t.classList.toggle("drawer-closed",h),Ii("audio3"),h||(i.size_fit(),i.focus_take())};s.addEventListener("click",()=>r(!t.classList.contains("drawer-closed")));let o=0,a=0,l=!1;e.addEventListener("pointerdown",h=>{l=!0,o=h.clientY,a=t.getBoundingClientRect().height,t.classList.add("drawer-dragging"),e.setPointerCapture(h.pointerId),h.preventDefault()}),e.addEventListener("pointermove",h=>{if(!l)return;const d=Math.max(jw,window.innerHeight-rK),u=a+(h.clientY-o),p=Math.min(Math.max(jw,u),d);t.style.height=`${p}px`,i.size_fit()});const c=()=>{l=!1,t.classList.remove("drawer-dragging")};return e.addEventListener("pointerup",c),e.addEventListener("pointercancel",c),r}function aK(t){const e=document.body,s=document.querySelector(".wrap:not(#gap)");let i;const n=r=>{for(const o of document.querySelectorAll(".pane-zoomed, .pane-zoomed-path"))o.classList.remove("pane-zoomed","pane-zoomed-path");if(r===null)delete e.dataset.zoom,i!==void 0&&(e.dataset.header=i,i=void 0);else{window.scrollTo(0,0),e.dataset.header==="away"?(i="away",delete e.dataset.header,gd>0&&e.style.setProperty("--zoom-header-height",`${gd}px`)):s!==null&&S_(s,e),e.dataset.zoom=r;const a=zh(r)?.mount?.parentElement??null;a?.classList.add("pane-zoomed");let l=a?.parentElement??null;for(;l!==null&&l.id!=="layout-root";)l.classList.add("pane-zoomed-path"),l=l.parentElement}for(const o of document.querySelectorAll(".drawer-zoom"))o.textContent=r!==null&&o.dataset.pane===r?"RESTORE":"ZOOM";Ii("audio3")};return Qe("header-restore").addEventListener("click",()=>{e.dataset.zoom!==void 0&&n(null)}),document.addEventListener("click",r=>{const o=r.target;if(!(o instanceof Element))return;const a=o.closest("[data-pane]");if(a===null)return;const l=a.dataset.pane??"";l!==""&&n(e.dataset.zoom===l?null:l)}),window.addEventListener("keydown",r=>{r.key==="Escape"&&e.dataset.zoom!==void 0&&(n(null),r.stopImmediatePropagation())}),Qe("drawer").addEventListener("transitionend",r=>{r.propertyName==="height"&&t.size_fit()}),n}function lK(){const t=new Y$(document.getElementById("data-cascade")),e=document.getElementById("header-telemetry");return e!==null&&t.telemetryPanel_bind(e),t}const Rf=96,cK=220,Hw="argus.headerBand.height",hK=52;function dK(){const t=document.documentElement,e=document.getElementById("header-strip"),s=document.querySelector(".wrap:not(#gap)");if(e===null||s===null)return;const i=h=>{const d=Math.max(Rf,window.innerHeight-cK),u=Math.min(Math.max(Rf,h),d);t.style.setProperty("--header-band-h",`${u}px`);try{window.localStorage.setItem(Hw,String(u))}catch{}},n=(()=>{try{return window.localStorage.getItem(Hw)}catch{return null}})();n!==null&&Number.isFinite(Number(n))&&i(Number(n));const r=()=>{const h=s.getBoundingClientRect();e.style.top=`${Math.max(0,h.bottom-hK)}px`};r(),window.addEventListener("resize",r),new MutationObserver(r).observe(document.body,{attributes:!0,attributeFilter:["data-header"]}),window.setInterval(r,500);let o=!1,a=0,l=0;e.addEventListener("pointerdown",h=>{const d=document.querySelector(".header-face");o=!0,a=h.clientY,l=d===null?Rf:d.getBoundingClientRect().height,e.setPointerCapture(h.pointerId),h.preventDefault()}),e.addEventListener("pointermove",h=>{o&&(i(l+(h.clientY-a)),r())});const c=()=>{o=!1,r()};e.addEventListener("pointerup",c),e.addEventListener("pointercancel",c)}let x_=null;function uK(t){const e=t.querySelector(".gather-rows");if(e===null)return;const s=Mi(e,{rows:".listing-row",label:i=>`+${i} MORE · ON STAGE`,press:()=>{x_?.()},className:"strategy-pill gather-more",mount:t});s.title="the whole cohort as a pane on the main panel"}function Vw(t){Mi(t,{rows:".strategy-pill, .listing-action, .holder-mark",className:"frame-more"})}function fK(){const t=e=>{for(const s of e.querySelectorAll(".mode-frame:not([data-more])"))Vw(s)};new MutationObserver(e=>{for(const s of e)for(const i of s.addedNodes)i instanceof HTMLElement&&(i.matches(".mode-frame")&&i.dataset.more===void 0&&Vw(i),t(i))}).observe(document.body,{childList:!0,subtree:!0}),t(document)}function qw(t){const e=t?.text;if(typeof e!="string"||e.length===0||typeof window.speechSynthesis>"u")return;const s=new SpeechSynthesisUtterance(e);s.rate=1,window.speechSynthesis.speak(s)}function pK(){const t=document.body,e=document.querySelector(".wrap:not(#gap)"),s=r=>{t.dataset.header===r?(e!==null&&S_(e,t),t.dataset.header="away"):t.dataset.header=r};document.querySelector(".panel-1")?.addEventListener("click",()=>s("stats")),document.querySelector(".panel-2")?.addEventListener("click",()=>s("dag")),document.querySelector(".panel-gather")?.addEventListener("click",()=>s("gather"));const i=document.querySelector(".header-gather-field");i?.querySelector(".gather-stage")?.addEventListener("click",r=>{r.stopPropagation(),x_?.()}),i!==null&&uK(i),fK();const n=()=>{t.dataset.zoom===void 0&&(delete t.dataset.header,Ii("audio3"))};Qe("header-restore").addEventListener("click",n),window.addEventListener("keydown",r=>{r.key==="Escape"&&t.dataset.header==="away"&&t.dataset.zoom===void 0&&t.dataset.gutter!=="away"&&n()})}const Zo=[{key:"lower-decks",label:"LOWER DECKS"},{key:"gold",label:"CERRITOS GOLD"},{key:"medical",label:"MEDICAL"},{key:"nemesis",label:"NEMESIS"},{key:"pharos",label:"PHAROS"}],Xx="argus-landing",mK=15e3;function Kw(){try{return(window.localStorage.getItem(Xx)??"launcher")==="launcher"}catch{return!0}}function gK(t){try{window.localStorage.setItem(Xx,t?"launcher":"last")}catch{}}const Yw="argus-theme",_K="argus-lcars",bK="medical",MK={sickbay:"medical"};function vK(){const t=Qe("theme-pill"),e=Math.max(Zo.findIndex(r=>r.key===bK),0);let s=e;try{const r=window.localStorage.getItem(Yw)??window.localStorage.getItem(_K),o=r===null?null:MK[r]??r,a=Zo.findIndex(l=>l.key===o);s=a>=0?a:e}catch{s=e}const i=document.documentElement,n=()=>{const r=Zo[s]??Zo[0];r.key==="lower-decks"?delete i.dataset.theme:i.dataset.theme=r.key,t.textContent=r.label};n(),t.addEventListener("click",()=>{s=(s+1)%Zo.length,n();try{window.localStorage.setItem(Yw,Zo[s]?.key??"lower-decks")}catch{}Ii("audio2")})}function wK(t){const e=document.getElementById("about-rows");if(e===null)return;e.replaceChildren();const i={...Xk(t)==="chris"?{cumin:t.stack?.cumin,salsa:t.stack?.salsa,chili:t.stack?.chili}:{},brasa:t.stack?.brasa,calypso:t.stack?.calypso,chell:t.stack?.chell},n=[];for(const[r,o]of Object.entries(i))o!==void 0&&n.push([r.toUpperCase(),o]);n.push(["MENU","0.30.0"],["ARGUS","79ee8a07 · 2026-10-25 02:44Z"],["WIRE",`V${t.protocolVersion}`]),t.stack?.build!==void 0&&n.push(["BUILD",t.stack.build]);for(const[r,o]of n){const a=document.createElement("div");a.className="telemetry-row";const l=document.createElement("span");l.className="telemetry-label",l.textContent=r;const c=document.createElement("span");c.className="telemetry-value",c.textContent=o,c.title=o,a.append(l,c),e.appendChild(a)}}function yK(){for(const t of document.querySelectorAll(".left-frame button, .left-frame-top button"))t.addEventListener("click",()=>Ii("audio2"))}let Jo=null;async function zK(t){let e=null;const s=await vO(t),i=s==="chris";document.body.dataset.composition=s;const n=new U$(document),r=i?k$(Qe("index-instrument"),{dag_primary:()=>At,dag_instances:()=>a.values("dag"),universes:()=>a.values("universe"),pacs:()=>A,runs_show:D=>N(D)}):{promptContext_take:()=>{},telemetry_take:()=>{},progress_take:()=>{}},o=new j$(Qe("lane-instrument"));window.setInterval(()=>o.tick(),500);const a=new s$;i&&m0(sj(()=>Z)),s==="stratus"&&m0(D$(()=>({...Z,controller_open:D=>Wi.open(D)})));const l=new B$;l.writeObserver_set((D,j)=>{gt.regard_send({address:D.address,...D.modelKind!==void 0?{modelKind:D.modelKind}:{},groupId:j,paneId:D.paneId}),Y()});const c={get layout(){return $},panels:a,paneInstance_get:zh,subjects:l,get dormant(){return oe},sound:Ii,get terminal(){return Ce},get client(){return gt}},h=fj(c,{catalogue_find:D=>T.get(D),run_press:(D,j,le)=>{he(D,j,le)}}),d=h.entry_show,u=D=>sg(D,t),p=Y5(c,{vfsUrl_build:u,downloadUrl_build:D=>wO(D,t),image_open:(D,j)=>k(D,j),process_open:(D,j)=>B(D,j),run_press:(D,j,le)=>{he(D,j,le)},cohort_gather:D=>ie(D),verbLine_run:(D,j)=>Et(D,j),askOnPane_await:(D,j)=>P(D,j),binEntry_show:d,catalogue_find:D=>T.get(D),promptUser:()=>M,template_stamp:qi,pane_find:Ks}),{previewProvider:f,fileText_fetch:_,file_save:g,rootedListing_show:m,listing_refresh:w,directory_make:y,files_deliver:b,filesBody_stamp:v,rowVerbs_build:z}=p,x=p.instance_build;let M=null,S=null;const T=new Map,{imageInstance_build:I,tagsInstance_build:E,tagsPane_follow:O,tagsPane_open:R,series_ask:C,image_open:k}=y$({client:()=>gt,terminal:()=>Ce,panels:()=>a,subjects:()=>l,layout:()=>$,desktop:()=>re,instance_spawn:(D,j)=>Ie(D,j),errandHost_find:()=>V(),launcher_yield:()=>_e(),birth_record:(D,j,le,xe,Ge)=>ge(D,j,le,xe,Ge),vfsUrl_build:D=>u(D)}),B=(D,j)=>{_e();const le=new Set($.panes_shown());for(const[ft,li]of T)if(le.has(ft)&&li.input===j.input){$.focus_set(ft);return}const xe=le.has(D)?D:V()??D,Ge=Ie("catalogue",D);if(!$.leaf_split(xe,re.replayPlace_get()?.dir??"col",Ge.id,re.replayPlace_get()?.before??!1)){As(Ge.id),$.mount_remove(Ge.id);return}ge(Ge.id,xe,re.replayPlace_get()?.dir??"col",re.replayPlace_get()?.before??!1),T.set(Ge.id,j);const mt=a.get("files",Ge.id);mt!==void 0&&(mt.binding_set({input:j.input,place:j.feed===null?"new feed":`feed ${j.feed}${j.node===null?"":` · node ${j.node}`}`}),mt.feedOpen_declare(ft=>X(Ge.id,ft)),m(Ge.id,mt,"/bin"),ee(mt),$.focus_set(Ge.id))},L=5,F=40,ee=D=>{gt.line_execute(`plugininstance list --limit ${F} --fields id,plugin_name,plugin_version,owner_username`,{silent:!0,observe:!1}).then(le=>{const xe=[];for(const Ge of le.envelopes)if(!(Ge.model?.kind!=="plugininstance.list"||!Array.isArray(Ge.model.data)))for(const mt of Ge.model.data){if(typeof mt.pluginName!="string"||typeof mt.pluginVersion!="string"||M!==null&&typeof mt.owner=="string"&&mt.owner!==M||mt.pluginName==="pl-dircopy")continue;const ft=`${mt.pluginName}-v${mt.pluginVersion}`;if(xe.includes(ft)||xe.push(ft),xe.length>=L)break}D.recent_set(xe.length===0?null:xe)}).catch(()=>{})},X=(D,j)=>{_e();const le=new Set($.panes_shown());for(const[mt,ft]of a.entries("dag"))if(mt!=="dag"&&le.has(mt)&&ft.feed_get()===j){$.focus_set(mt);return}const xe=le.has(D)?D:V()??D,Ge=Ie("dag",D);if(!$.leaf_split(xe,re.replayPlace_get()?.dir??"col",Ge.id,re.replayPlace_get()?.before??!1)){As(Ge.id),$.mount_remove(Ge.id);return}ge(Ge.id,xe,re.replayPlace_get()?.dir??"col",re.replayPlace_get()?.before??!1),a.get("dag",Ge.id)?.feed_enter(j)},he=async(D,j,le)=>{const xe=T.get(D),Ge=a.get("files",D);if(xe===void 0||Ge===void 0)return;const mt=$s=>{Ce.output_write("err",`\x1B[31m${$s}\x1B[0m
4391
4391
  `);const Yd=Ge.indicated_get();Yd!==null&&Ge.rowReadout_show(Yd,$s.toUpperCase().slice(0,80))};if(le==="pipeline"&&xe.node===null){mt(`${j}: a pipeline runs on a node — PROCESS a node of a feed`);return}let ft=Ge.commandLine_get();if((ft===""||eS(ft)!==j)&&(ft=Zz(xe.input,j)),xe.feed===null&&!SB(ft)){const $s=xe.input.split("/").filter(Boolean).pop()??"feed",R_=(await P(D,{message:"Feed title: ",kind:"text",suggest:$s,commit:"RUN"})??"").trim();if(R_==="")return;ft=xB(ft,R_)}Ge.commandLine_set(ft),Ce.line_echo(ft);let li;try{li=await gt.line_execute(ft,{silent:!0})}catch($s){mt($s instanceof Error?$s.message:String($s));return}Ce.outcome_write(li),li.envelopes.some($s=>$s.model?.kind==="fs.cwd")&&gt.line_execute("ls",{silent:!0});const tc=li.envelopes.find($s=>$s.model?.kind==="run.scheduled"||$s.model?.kind==="pipeline.scheduled")?.model?.data;if(typeof tc?.feedId=="number"){Ge.run_show(tc.feedId);return}const D_=li.envelopes.map($s=>$s.renderedErr??"").join(" ").replace(/\x1b\[[0-9;]*m/g,"").trim().split(`
4392
- `)[0]??"",C_=Ge.indicated_get();C_!==null&&Ge.rowReadout_show(C_,D_===""?"NOT SCHEDULED":D_.toUpperCase().slice(0,80))},Oe=D=>{_e();const j=new Set($.panes_shown());for(const[ft]of a.entries("files"))if(j.has(ft)&&l.regard_get(ft)?.address===D){$.focus_set(ft);return}let le;for(const[ft,li]of a.entries("image"))if(j.has(ft)&&(l.regard_get(ft)?.address===D||li.state_get()?.path===D)){le=ft;break}const xe=V();if(xe===null)return;const Ge=Ie("files",le);if(!$.leaf_split(xe,re.replayPlace_get()?.dir??"col",Ge.id,re.replayPlace_get()?.before??!1)){As(Ge.id),$.mount_remove(Ge.id);return}ge(Ge.id,xe,re.replayPlace_get()?.dir??"col",re.replayPlace_get()?.before??!1),le===void 0&&l.regard_write(Ge.id,{address:D,modelKind:"dicom.series"});const mt=a.get("files",Ge.id);mt!==void 0&&m(Ge.id,mt,D)},De=vj(c,{image_open:(D,j)=>k(D,j),process_open:(D,j)=>B(D,j),feed_open:(D,j)=>X(D,j),askOnPane_await:(D,j)=>P(D,j),errandHost_find:()=>V(),instance_spawn:(D,j)=>Ie(D,j),birth_record:(D,j,le,xe)=>ge(D,j,le,xe),replayPlace_get:()=>re.replayPlace_get(),stage_relight:()=>Y(),home_apply:()=>Ue(),orphans_dispose:()=>we(),template_stamp:qi,pane_find:Ks,element_require:Qe}),ke=De.instance_build,ie=De.gather,ae=De.open,fe=D=>{const j=qi("tpl-pane-view");Mi(Ks(j,".view-body"));const le=new N$(Ks(j,".view-body"),Ks(j,".view-title"),{content_fetch:async xe=>(await _(xe)).text,imageUrl_build:u,path_isImage:Od});return a.set("view",D,le),{id:D,kind:"view",mount:j,dispose:()=>{a.delete(D),l.pane_leave(D)}}},Fe=pj(c,{filesBody_stamp:v,rootedListing_show:m,rowVerbs_build:z,image_open:(D,j)=>k(D,j),imagery_is:S1,tableFile_is:D=>z1.test(D),vfsUrl_build:u,fileText_fetch:_,previewProvider:f}),Ze=Fe.open;Fe.close;const Ve=N5(c,{askOnPane_await:(D,j)=>P(D,j),promptUser:()=>M,changed:()=>{for(const D of a.values("dag"))D.roster_ask(),D.marks_refresh(),D.indicated_refresh()}}),yt=J5({client:()=>gt,terminal:()=>Ce,panels:()=>a,subjects:()=>l,context:()=>c,feedVerbs:()=>Ve,nodeOverlay:()=>Fe,nodeOverlay_open:(D,j)=>Ze(D,j),process_open:(D,j)=>B(D,j),promptUser:()=>M,runs_show:()=>N(),dag_primary:()=>At,binEntry_show:(D,j,le,xe)=>d(D,j,le,xe),dag_summon:()=>$e()}),Ne=x("files",!0);Yc(Ne);const wt=z$({panes:yt,dicom:{imageInstance_build:I,tagsInstance_build:E},gather_build:ke,pacsMount:Qe("pacs-workspace")}),ut=i?wt:{primaries:[],domains:[],presets:[],factories:[]};for(const D of ut.primaries)Yc(D);for(const D of ut.domains)Q5(D);const ct=qi("tpl-pane-launcher");Yc({id:"launcher",kind:"launcher",mount:ct});const Pt=qi("tpl-pane-panes");Yc({id:"panes",kind:"panes",mount:Pt});const ts=a.get("files","files"),At=a.get("dag","dag"),ns=new J$(Qe("pipeline-cycler"),Qe("pipeline-cycler-name"),D=>{gt.line_execute(D,{silent:!0})});let Nt=null;const $t=mj(c,{instance_spawn:(D,j)=>Ie(D,j),birth_record:(D,j,le,xe)=>ge(D,j,le,xe),replayPlace_get:()=>re.replayPlace_get(),rootedListing_show:m,console_expose:()=>Nt?.(!1),questionSheet_ask:D=>e!==null&&e.terminal_is()?e.question_sheet(D):null}),{errandHost_find:V,errand_open:Cs,verbLine_run:Et,askOnPane_await:P}=$t;Mi(Qe("pacs-workspace"),{rows:".listing-row"});const A=new BB(Qe("pacs-workspace"),{command_run:D=>{const j=/^(pacs query|pull )/.test(D);j&&Ce.line_echo(D),gt.line_execute(D,{silent:!0,operator:j}).then(le=>{for(const xe of le.envelopes)A.envelope_observe(xe)})},command_show:D=>{Ce.line_run(D)},note:D=>Ce.line_note(D),image_open:D=>{k(null,D).then(j=>Ce.line_note(j))},dir_open:D=>Oe(D),process_open:D=>B("pacs",{input:D,feed:null,node:null}),gather_add:D=>ie([D]),gathered_is:D=>De.has(D),workspace_close:()=>Ue()}),Y=()=>{const D=new Set($.panes_shown()),j=new Map;for(const le of Sh()){if(!D.has(le.id))continue;const xe=l.regard_get(le.id)?.address;if(xe===void 0)continue;const Ge=te(le.id);if(Ge!=="image"&&Ge!=="files")continue;const mt=xe.replace(/\/$/,""),ft=j.get(mt)??{viewer:!1,browser:!1};Ge==="image"?ft.viewer=!0:ft.browser=!0,j.set(mt,ft)}A.stage_lit(j)},$=new ij(Qe("layout-root"),new Map([...ut.primaries.map(D=>[D.id,D.mount]),["files",Ne.mount],["launcher",ct],["panes",Pt]]));let ne=!1;const me=()=>ne?{dir:"col",ratio:.45,first:{pane:"files"},second:{pane:"dag"}}:{pane:"files"};$.preset_register("files",me);for(const[D,j]of ut.presets)$.preset_register(D,j);$.preset_register("panes",()=>({pane:"panes"})),$.preset_register("launcher",()=>({pane:"launcher"})),$.renderObserver_set(()=>{document.body.dataset.zoom==="launcher"&&!$.panes_shown().includes("launcher")&&Xr(null),window.requestAnimationFrame(()=>{for(const D of a.values("dag"))D.size_fit()})});const ve=(D,j,le,xe)=>{const Ge=j==="view"?Ie("view",D):j==="fs"?Ie("files",D):Ie("empty");if(!$.leaf_split(D,le,Ge.id,xe))return As(Ge.id),$.mount_remove(Ge.id),null;if(ge(Ge.id,D,le,xe,j),j==="fs"){const mt=li=>{const Kd=a.get("files",Ge.id);if(Kd===void 0)return;const tc=li.modelKind==="fs.file"?li.address.replace(/\/[^/]*$/,"")||"/":li.address;m(Ge.id,Kd,tc)};l.regard_subscribe(Ge.id,mt);const ft=l.regard_get(D);ft!==null&&mt(ft)}return Ge.id},oe=new sO(Xw,Zw());Object.assign(globalThis,{__argusDormant:{list:()=>oe.list(),get:D=>oe.get(D),dismiss:D=>oe.dismiss(D)}});const re=aj(c,{image_open:k,dir_open:Oe,process_open:B,gather_open:ae,feed_open:X,edit_open:D=>Ra.edit_open(D),pillPane_spawn:ve,pacsQuery_get:()=>A.query_get(),catalogue_find:D=>T.get(D),catalogueIds:()=>[...T.keys()],stage_relight:()=>Y()}),{birth_record:ge,domain_enter:Pe,orphans_dispose:we}=re,ye=re.capture,Ye=re.restore,Ue=()=>{Pe("files"),At.size_fit()},it=()=>{Pe("launcher"),Ee.render(),$.focus_set("launcher"),Xr("launcher")},H=(D=!1)=>{if(document.body.dataset.zoom!=="launcher"||(Xr(null),!D))return;const j=document.querySelector(".wrap:not(#gap)");j!==null&&S_(j,document.body),document.body.dataset.header="away",Nt?.(!0)},_e=()=>{H(),$.activePreset_get()==="launcher"&&(ne=!1,Ue())};let de=!1;const ze=vB({ask:D=>gt.line_execute(D,{silent:!0,observe:!1}),home_open:()=>{ne=!1,Ue(),$.focus_set("files")},home_cd:D=>{ne=!1,Ue(),Ce.line_run(`cd "${D}"`)},desktops:()=>oe.list(),desktop_restore:D=>{Ye(D)},panes_open:()=>{Pe("panes"),pe.render(),$.focus_set("panes")},keys_open:()=>{Lr()},notes_open:()=>{So.open()},notes_latest:()=>So.latest(),daemon_stale:()=>de,console_open:()=>Qe("gutter-console").click(),...i?{contribution:S$({ask:D=>gt.line_execute(D,{silent:!0,observe:!1}),universe_show:()=>K(),runs_show:D=>N(D),feed_enter:D=>{N(),a.get("dag","dag")?.feed_enter(D)},line_offer:D=>Ce.line_offer(D),pacs_query:()=>A.query_get()??"",pacs_open:()=>{Pe("pacs"),$.focus_set("pacs")}})}:{},...s!=="stratus"?{}:{contribution:T$({ask:D=>gt.line_execute(D,{silent:!0,observe:!1}),domain_open:D=>{Wi.open(D)},home_open:()=>{ne=!1,Ue(),$.focus_set("files")},line_run:D=>{Qe("gutter-console").click(),Ce.line_run(D)},names_seen:D=>Ca(D)})}}),Ee=new tB(ct,{tiles:ze,leave:()=>H(!0),startHere_get:Kw,startHere_set:gK});setInterval(()=>{$.activePreset_get()==="launcher"&&(!ct.isConnected||document.visibilityState!=="visible"||Ee.render())},mK),Mi(Ks(Pt,".panes-body"),{rows:".panes-card"});const pe=new hO(Pt,{list:()=>oe.list(),restore:D=>{Ye(D)},dismiss:D=>{oe.dismiss(D)}}),$e=()=>{const D=$.activePreset_get();if(D==="pacs"||D==="dag"||D==="launcher"){ne=!0;return}ne&&D==="files"||(ne=!0,Ue())},Ie=(D,j)=>{const le=t$(D);return l.pane_join(le.id,j!==void 0?l.group_resolve(j):le.id),D==="tags"&&l.regard_subscribe(le.id,xe=>{xe.modelKind==="dicom.instance"&&O(le.id,xe.address)}),D==="view"&&(l.viewer_mark(le.id),l.regard_subscribe(le.id,xe=>{xe.modelKind!=="dicom.instance"&&a.get("view",le.id)?.regard_show(xe)})),$.mount_register(le.id,le.mount),Br(le.id,D,le.mount),le},{bar_note:jt,move:It,flip:oi,resize:ai,chordKeys_format:qd}=rj(c),Br=AH(c,{verbs:{move:It,chordKeys_format:qd},browser:p,pillPane_spawn:ve,process_open:(D,j)=>B(D,j),overlay_back:D=>Fe.back(D),home_apply:()=>Ue(),orphans_dispose:()=>we(),dag_dismiss:()=>{ne=!1}});Br("files","files",Ne.mount);for(const D of ut.primaries)Br(D.id,D.kind,D.mount);Br("launcher","launcher",ct),Br("panes","panes",Pt);let Gr=!1;const Pi=D=>{Gr=D};for(const D of["click","focusin"])document.addEventListener(D,j=>{j.target instanceof Element&&(j.target.closest("#drawer")!==null?Gr=!0:j.target.closest("#layout-root")!==null&&(Gr=!1))});const ec=()=>{let D=!1;for(const j of document.querySelectorAll(".pane-drawer:not([hidden])"))j.hidden=!0,D=!0;return D},Aa=()=>{let D=!1;for(const j of document.querySelectorAll('.workspace-pane[data-modes="open"], [data-frame-host][data-modes="open"]'))delete j.dataset.modes,D=!0;return A.serverStrip_isOpen()&&(A.serverStrip_close(),D=!0),D};document.addEventListener("click",D=>{if(!(D.target instanceof Element)||D.target.closest(".mode-frame")!==null&&D.target.closest(".mode-fill")===null||D.target.closest("#pacs-server-strip")!==null||D.target.closest("#pacs-f-server")!==null||D.target.closest(".listing-framed .listing-row, .ask-bar")!==null)return;const j=D.target.closest(".mode-strip"),le=j?.closest(".workspace-pane, [data-frame-host]")??null,xe=le?.dataset.modes==="open",Ge=Aa();if(j!==null&&le!==null&&!xe){le.dataset.modes="open",Ii("audio3");return}Ge&&Ii("audio3")}),EH(c,{palette_isOpen:()=>!J.hidden,palette_open:()=>We(),palette_close:()=>Le(),errand_abandon:()=>$t.errand_abandon(),dive_leave:()=>h.dive_leave(),overlay_escape:()=>Fe.escape(),drawers_close:ec,modeFrames_close:Aa,consoleFocused:()=>Gr,console_release:()=>Pi(!1),verbs:{bar_note:jt,flip:oi,resize:ai},host:()=>Z,stage_alone:D=>{ye(),$.tree_set({pane:D}),we()},element_require:Qe});const Li=new FB,Qi=(D,j)=>{const le=Ie(j);return $.leaf_replace(D,le.id),As(D),$.mount_remove(D),le};Li.claim_add("fs.listing","files"),i&&UB(Li,{dag_target:()=>{const D=$.focused_get();return D!==null&&a.has("dag",D)?a.get("dag",D):At},dags:()=>[At,...a.values("dag")],universes:()=>a.values("universe"),pacs:()=>A,pacs_present:()=>{$.preset_apply("pacs"),we()},image_open:(D,j)=>{k($.focused_get(),D,j?{force:!0}:{}).then(le=>Ce.line_note(le))},pane_replace:(D,j)=>Qi(D,j).id,dag_get:D=>a.get("dag",D),image_get:D=>a.get("image",D),tags_get:D=>a.get("tags",D)});const Ta=(D,j,le)=>{const xe=Li.claimer_get(j);if(xe!==void 0){xe(D,le);return}const Ge=Qi(D,j),mt=a.get("files",Ge.id);for(const ft of le)mt?.envelope_observe(ft)},Pr={instance_spawn:Ie,birth_record:ge,launcher_yield:_e,launcher_active:()=>$.activePreset_get()==="launcher",template_stamp:qi},Ia=Sj(c,Pr),Lr=Ia.open,Da=Hj(c,Pr),Fs=nH(c);function Ca(D){I$(D)&&c.client.claims_send(p0())}const Wi=MH(c,D=>Ca(D)),So=SH(c,{...Pr,ask:D=>gt.line_execute(D,{silent:!0})}),Ra=yj(c,{...Pr,replayPlace_get:re.replayPlace_get,errandHost_find:V,saved:()=>{for(const D of a.values("dag"))D.marks_refresh()}});En("files",D=>x(D,!1)),En("catalogue",D=>x(D,!1,!0)),En("view",fe),En("help",Ia.instance_build),En("games",Da.instance_build),En("notes",So.instance_build),En("edit",Ra.instance_build);for(const[D,j]of ut.factories)En(D,j);En("empty",D=>{const j=qi("tpl-pane-empty");return new LB(j,{execute:le=>gt.line_execute(le,{silent:!0,observe:!1}),claim:(le,xe)=>Ta(D,le,xe),claimKind_find:le=>Li.claimKind_find(le)}),{id:D,kind:"empty",mount:j}});const ka=D=>{D?document.body.dataset.gutter="away":delete document.body.dataset.gutter,Ii("audio3")},Wr=(D,j)=>{if($.activePreset_get()===D&&$.panes_shown().includes(D)){ka(!0);return}document.body.dataset.gutter==="away"&&delete document.body.dataset.gutter,j()};Qe("gutter-restore").addEventListener("click",()=>ka(!1)),window.addEventListener("keydown",D=>{D.key==="Escape"&&document.body.dataset.gutter==="away"&&document.body.dataset.zoom===void 0&&ka(!1)}),Qe("gutter-files").addEventListener("click",()=>{Wr("files",()=>{ne=!1,Ue(),$.focus_set("files"),Pi(!1)})});const N=(D="")=>{Pe("dag"),At.stage_returned(),At.list_reset(),At.roster_filter(D),At.feedsChooser_request(),$.focus_set("dag"),Pi(!1)},K=()=>{Pe("universe");const D=a.get("universe","universe");D!==void 0&&!D.shown_get()&&D.request(),D?.stage_returned(),$.focus_set("universe"),Pi(!1)};Qe("gutter-runs").addEventListener("click",()=>Wr("dag",()=>N())),Qe("gutter-console").addEventListener("click",()=>{Qe("drawer").classList.contains("drawer-closed")&&Qe("drawer-toggle").click(),Ce.focus_take(),Pi(!0)}),Qe("gutter-tools").addEventListener("click",()=>{Wr("pacs",()=>{Pe("pacs"),$.focus_set("pacs"),Pi(!1)})}),Qe("gutter-dashboard").addEventListener("click",()=>{Wr("launcher",it)}),Qe("gutter-panes").addEventListener("click",()=>{Wr("panes",()=>{Pe("panes"),pe.render(),$.focus_set("panes"),Pi(!1)})});const te=D=>zh(D)?.kind??null,Z=IH(c,{verbs:{move:It,flip:oi,resize:ai},help_open:Lr,notes_open:So.open,launcher_enter:it,trek_open:D=>Fs.active_is()?"trek: the bridge is already up":(Fs.open(D),"trek: the bridge takes the screen (Esc or LEAVE BRIDGE gives it back)"),identity_get:()=>S,consoleZoom_toggle:Fw,feed_enter:D=>At.feed_enter(D),file_save:g,stage_keep:()=>ye(),files_open:(D,j)=>{const le=a.get("files",D);return le===void 0?!1:(p.follow_set(D,!1),m(D,le,j),!0)},image_open:(D,j,le)=>k(D,j,le),series_ask:C,tagsPane_open:R}),J=Qe("lang-palette"),Me=Qe("lang-input"),Be=Qe("lang-result"),Se=Qe("lang-pill"),We=()=>{ec(),J.hidden=!1,Se.classList.add("lang-live"),Be.textContent="",Me.value="",Me.focus(),Ii("audio3")},Le=()=>{J.hidden=!0,Se.classList.remove("lang-live"),Be.textContent=""};Se.addEventListener("click",()=>{J.hidden?We():Le()});const nt=["pane","view","runs","node","dag","file","pacs","header","console","back","desktop","argus","help","notes"],ot={pane:["split","zoom","close","bind","claim","focus","flip","resize"],resize:["left","right","up","down"],help:["keys","verbs"],notes:["pane"],focus:["left","right","up","down","last"],view:["files","runs","pacs"],runs:["enter","sort","filter"],node:["enter","immerse","back","clear"],dag:["layout","projection","scale","hue","draw","pulse","census","gravity","select","enter","physics","refresh"],draw:["spheres","stars"],pulse:["on","off"],census:["on","off"],gravity:["on","off"],physics:["charge","link","collide","gravity","reset"],file:["home","back","download","delete","sort","filter","follow","root","list","cards","preview"],pacs:["sort","filter","connect","disconnect","list","query","pull","status"],header:["stats","dag","away","restore"],console:["open","close","toggle","zoom","height"],desktop:["save","load","show","list","delete","clear","share"],split:["left","right","above","below"],bind:["unlinked","fs","viewer"],claim:["files","runs","pacs"],layout:["ranked","molecule"],projection:["2d","3d"],scale:["time","size"],hue:["status","compute"],argus:["verbs"]};if(Me.addEventListener("keydown",D=>{if(D.key==="Escape"){D.stopPropagation(),Le();return}if(D.key==="Tab"){D.preventDefault();const j=Me.value.split(/\s+/),le=j[j.length-1]??"",xe=j.length<=1?"":j[j.length-2]??"",mt=(j.length<=1?nt:ot[xe]??ot[j[0]??""]??[]).find(ft=>ft.startsWith(le.toLowerCase()));mt!==void 0&&(j[j.length-1]=mt,Me.value=`${j.join(" ")} `);return}if(D.key==="Enter"){const j=Me.value.trim();if(j.length===0){Le();return}ph(Z,j).then(le=>{le!==null&&(Fs.active_is()||Wi.active_is())?(Ce.output_write("data",`: ${j}
4392
+ `)[0]??"",C_=Ge.indicated_get();C_!==null&&Ge.rowReadout_show(C_,D_===""?"NOT SCHEDULED":D_.toUpperCase().slice(0,80))},Oe=D=>{_e();const j=new Set($.panes_shown());for(const[ft]of a.entries("files"))if(j.has(ft)&&l.regard_get(ft)?.address===D){$.focus_set(ft);return}let le;for(const[ft,li]of a.entries("image"))if(j.has(ft)&&(l.regard_get(ft)?.address===D||li.state_get()?.path===D)){le=ft;break}const xe=V();if(xe===null)return;const Ge=Ie("files",le);if(!$.leaf_split(xe,re.replayPlace_get()?.dir??"col",Ge.id,re.replayPlace_get()?.before??!1)){As(Ge.id),$.mount_remove(Ge.id);return}ge(Ge.id,xe,re.replayPlace_get()?.dir??"col",re.replayPlace_get()?.before??!1),le===void 0&&l.regard_write(Ge.id,{address:D,modelKind:"dicom.series"});const mt=a.get("files",Ge.id);mt!==void 0&&m(Ge.id,mt,D)},De=vj(c,{image_open:(D,j)=>k(D,j),process_open:(D,j)=>B(D,j),feed_open:(D,j)=>X(D,j),askOnPane_await:(D,j)=>P(D,j),errandHost_find:()=>V(),instance_spawn:(D,j)=>Ie(D,j),birth_record:(D,j,le,xe)=>ge(D,j,le,xe),replayPlace_get:()=>re.replayPlace_get(),stage_relight:()=>Y(),home_apply:()=>Ue(),orphans_dispose:()=>we(),template_stamp:qi,pane_find:Ks,element_require:Qe}),ke=De.instance_build,ie=De.gather,ae=De.open,fe=D=>{const j=qi("tpl-pane-view");Mi(Ks(j,".view-body"));const le=new N$(Ks(j,".view-body"),Ks(j,".view-title"),{content_fetch:async xe=>(await _(xe)).text,imageUrl_build:u,path_isImage:Od});return a.set("view",D,le),{id:D,kind:"view",mount:j,dispose:()=>{a.delete(D),l.pane_leave(D)}}},Fe=pj(c,{filesBody_stamp:v,rootedListing_show:m,rowVerbs_build:z,image_open:(D,j)=>k(D,j),imagery_is:S1,tableFile_is:D=>z1.test(D),vfsUrl_build:u,fileText_fetch:_,previewProvider:f}),Ze=Fe.open;Fe.close;const Ve=N5(c,{askOnPane_await:(D,j)=>P(D,j),promptUser:()=>M,changed:()=>{for(const D of a.values("dag"))D.roster_ask(),D.marks_refresh(),D.indicated_refresh()}}),yt=J5({client:()=>gt,terminal:()=>Ce,panels:()=>a,subjects:()=>l,context:()=>c,feedVerbs:()=>Ve,nodeOverlay:()=>Fe,nodeOverlay_open:(D,j)=>Ze(D,j),process_open:(D,j)=>B(D,j),promptUser:()=>M,runs_show:()=>N(),dag_primary:()=>At,binEntry_show:(D,j,le,xe)=>d(D,j,le,xe),dag_summon:()=>$e()}),Ne=x("files",!0);Yc(Ne);const wt=z$({panes:yt,dicom:{imageInstance_build:I,tagsInstance_build:E},gather_build:ke,pacsMount:Qe("pacs-workspace")}),ut=i?wt:{primaries:[],domains:[],presets:[],factories:[]};for(const D of ut.primaries)Yc(D);for(const D of ut.domains)Q5(D);const ct=qi("tpl-pane-launcher");Yc({id:"launcher",kind:"launcher",mount:ct});const Pt=qi("tpl-pane-panes");Yc({id:"panes",kind:"panes",mount:Pt});const ts=a.get("files","files"),At=a.get("dag","dag"),ns=new J$(Qe("pipeline-cycler"),Qe("pipeline-cycler-name"),D=>{gt.line_execute(D,{silent:!0})});let Nt=null;const $t=mj(c,{instance_spawn:(D,j)=>Ie(D,j),birth_record:(D,j,le,xe)=>ge(D,j,le,xe),replayPlace_get:()=>re.replayPlace_get(),rootedListing_show:m,console_expose:()=>Nt?.(!1),questionSheet_ask:D=>e!==null&&e.terminal_is()?e.question_sheet(D):null}),{errandHost_find:V,errand_open:Cs,verbLine_run:Et,askOnPane_await:P}=$t;Mi(Qe("pacs-workspace"),{rows:".listing-row"});const A=new BB(Qe("pacs-workspace"),{command_run:D=>{const j=/^(pacs query|pull )/.test(D);j&&Ce.line_echo(D),gt.line_execute(D,{silent:!0,operator:j}).then(le=>{for(const xe of le.envelopes)A.envelope_observe(xe)})},command_show:D=>{Ce.line_run(D)},note:D=>Ce.line_note(D),image_open:D=>{k(null,D).then(j=>Ce.line_note(j))},dir_open:D=>Oe(D),process_open:D=>B("pacs",{input:D,feed:null,node:null}),gather_add:D=>ie([D]),gathered_is:D=>De.has(D),workspace_close:()=>Ue()}),Y=()=>{const D=new Set($.panes_shown()),j=new Map;for(const le of Sh()){if(!D.has(le.id))continue;const xe=l.regard_get(le.id)?.address;if(xe===void 0)continue;const Ge=te(le.id);if(Ge!=="image"&&Ge!=="files")continue;const mt=xe.replace(/\/$/,""),ft=j.get(mt)??{viewer:!1,browser:!1};Ge==="image"?ft.viewer=!0:ft.browser=!0,j.set(mt,ft)}A.stage_lit(j)},$=new ij(Qe("layout-root"),new Map([...ut.primaries.map(D=>[D.id,D.mount]),["files",Ne.mount],["launcher",ct],["panes",Pt]]));let ne=!1;const me=()=>ne?{dir:"col",ratio:.45,first:{pane:"files"},second:{pane:"dag"}}:{pane:"files"};$.preset_register("files",me);for(const[D,j]of ut.presets)$.preset_register(D,j);$.preset_register("panes",()=>({pane:"panes"})),$.preset_register("launcher",()=>({pane:"launcher"})),$.renderObserver_set(()=>{document.body.dataset.zoom==="launcher"&&!$.panes_shown().includes("launcher")&&Xr(null),window.requestAnimationFrame(()=>{for(const D of a.values("dag"))D.size_fit()})});const ve=(D,j,le,xe)=>{const Ge=j==="view"?Ie("view",D):j==="fs"?Ie("files",D):Ie("empty");if(!$.leaf_split(D,le,Ge.id,xe))return As(Ge.id),$.mount_remove(Ge.id),null;if(ge(Ge.id,D,le,xe,j),j==="fs"){const mt=li=>{const Kd=a.get("files",Ge.id);if(Kd===void 0)return;const tc=li.modelKind==="fs.file"?li.address.replace(/\/[^/]*$/,"")||"/":li.address;m(Ge.id,Kd,tc)};l.regard_subscribe(Ge.id,mt);const ft=l.regard_get(D);ft!==null&&mt(ft)}return Ge.id},oe=new sO(Xw,Zw());Object.assign(globalThis,{__argusDormant:{list:()=>oe.list(),get:D=>oe.get(D),dismiss:D=>oe.dismiss(D)}});const re=aj(c,{image_open:k,dir_open:Oe,process_open:B,gather_open:ae,feed_open:X,edit_open:D=>Ra.edit_open(D),pillPane_spawn:ve,pacsQuery_get:()=>A.query_get(),catalogue_find:D=>T.get(D),catalogueIds:()=>[...T.keys()],stage_relight:()=>Y()}),{birth_record:ge,domain_enter:Pe,orphans_dispose:we}=re,ye=re.capture,Ye=re.restore,Ue=()=>{Pe("files"),At.size_fit()},it=()=>{Pe("launcher"),Ee.render(),$.focus_set("launcher"),Xr("launcher")},H=(D=!1)=>{if(document.body.dataset.zoom!=="launcher"||(Xr(null),!D))return;const j=document.querySelector(".wrap:not(#gap)");j!==null&&S_(j,document.body),document.body.dataset.header="away",Nt?.(!0)},_e=()=>{H(),$.activePreset_get()==="launcher"&&(ne=!1,Ue())};let de=!1;const ze=vB({ask:D=>gt.line_execute(D,{silent:!0,observe:!1}),home_open:()=>{ne=!1,Ue(),$.focus_set("files")},home_cd:D=>{ne=!1,Ue(),Ce.line_run(`cd "${D}"`)},desktops:()=>oe.list(),desktop_restore:D=>{Ye(D)},panes_open:()=>{Pe("panes"),pe.render(),$.focus_set("panes")},keys_open:()=>{Lr()},notes_open:()=>{So.open()},notes_latest:()=>So.latest(),daemon_stale:()=>de,console_open:()=>Qe("gutter-console").click(),...i?{contribution:S$({ask:D=>gt.line_execute(D,{silent:!0,observe:!1}),universe_show:()=>K(),runs_show:D=>N(D),feed_enter:D=>{N(),a.get("dag","dag")?.feed_enter(D)},line_offer:D=>Ce.line_offer(D),pacs_query:()=>A.query_get()??"",pacs_open:()=>{Pe("pacs"),$.focus_set("pacs")}})}:{},...s!=="stratus"?{}:{contribution:T$({ask:D=>gt.line_execute(D,{silent:!0,observe:!1}),domain_open:D=>{Wi.open(D)},home_open:()=>{ne=!1,Ue(),$.focus_set("files")},line_run:D=>{Qe("gutter-console").click(),Ce.line_run(D)},names_seen:D=>Ca(D)})}}),Ee=new tB(ct,{tiles:ze,leave:()=>H(!0),startHere_get:Kw,startHere_set:gK});setInterval(()=>{$.activePreset_get()==="launcher"&&(!ct.isConnected||document.visibilityState!=="visible"||Ee.render())},mK),Mi(Ks(Pt,".panes-body"),{rows:".panes-card"});const pe=new hO(Pt,{list:()=>oe.list(),restore:D=>{Ye(D)},dismiss:D=>{oe.dismiss(D)}}),$e=()=>{const D=$.activePreset_get();if(D==="pacs"||D==="dag"||D==="launcher"){ne=!0;return}ne&&D==="files"||(ne=!0,Ue())},Ie=(D,j)=>{const le=t$(D);return l.pane_join(le.id,j!==void 0?l.group_resolve(j):le.id),D==="tags"&&l.regard_subscribe(le.id,xe=>{xe.modelKind==="dicom.instance"&&O(le.id,xe.address)}),D==="view"&&(l.viewer_mark(le.id),l.regard_subscribe(le.id,xe=>{xe.modelKind!=="dicom.instance"&&a.get("view",le.id)?.regard_show(xe)})),$.mount_register(le.id,le.mount),Br(le.id,D,le.mount),le},{bar_note:jt,move:It,flip:oi,resize:ai,chordKeys_format:qd}=rj(c),Br=AH(c,{verbs:{move:It,chordKeys_format:qd},browser:p,pillPane_spawn:ve,process_open:(D,j)=>B(D,j),overlay_back:D=>Fe.back(D),home_apply:()=>Ue(),orphans_dispose:()=>we(),dag_dismiss:()=>{ne=!1}});Br("files","files",Ne.mount);for(const D of ut.primaries)Br(D.id,D.kind,D.mount);Br("launcher","launcher",ct),Br("panes","panes",Pt);let Gr=!1;const Pi=D=>{Gr=D};for(const D of["click","focusin"])document.addEventListener(D,j=>{j.target instanceof Element&&(j.target.closest("#drawer")!==null?Gr=!0:j.target.closest("#layout-root")!==null&&(Gr=!1))});const ec=()=>{let D=!1;for(const j of document.querySelectorAll(".pane-drawer:not([hidden])"))j.hidden=!0,D=!0;return D},Aa=()=>{let D=!1;for(const j of document.querySelectorAll('.workspace-pane[data-modes="open"], [data-frame-host][data-modes="open"]'))delete j.dataset.modes,D=!0;return A.serverStrip_isOpen()&&(A.serverStrip_close(),D=!0),D};document.addEventListener("click",D=>{if(!(D.target instanceof Element)||D.target.closest(".mode-frame")!==null&&D.target.closest(".mode-fill")===null||D.target.closest("#pacs-server-strip")!==null||D.target.closest("#pacs-f-server")!==null||D.target.closest(".listing-framed .listing-row, .ask-bar")!==null)return;const j=D.target.closest(".mode-strip"),le=j?.closest(".workspace-pane, [data-frame-host]")??null,xe=le?.dataset.modes==="open",Ge=Aa();if(j!==null&&le!==null&&!xe){le.dataset.modes="open",Ii("audio3");return}Ge&&Ii("audio3")}),EH(c,{palette_isOpen:()=>!J.hidden,palette_open:()=>We(),palette_close:()=>Le(),errand_abandon:()=>$t.errand_abandon(),dive_leave:()=>h.dive_leave(),overlay_escape:()=>Fe.escape(),drawers_close:ec,modeFrames_close:Aa,consoleFocused:()=>Gr,console_release:()=>Pi(!1),verbs:{bar_note:jt,flip:oi,resize:ai},host:()=>Z,stage_alone:D=>{ye(),$.tree_set({pane:D}),we()},element_require:Qe});const Li=new FB,Qi=(D,j)=>{const le=Ie(j);return $.leaf_replace(D,le.id),As(D),$.mount_remove(D),le};Li.claim_add("fs.listing","files"),i&&UB(Li,{dag_target:()=>{const D=$.focused_get();return D!==null&&a.has("dag",D)?a.get("dag",D):At},dags:()=>[At,...a.values("dag")],universes:()=>a.values("universe"),pacs:()=>A,pacs_present:()=>{$.preset_apply("pacs"),we()},image_open:(D,j)=>{k($.focused_get(),D,j?{force:!0}:{}).then(le=>Ce.line_note(le))},pane_replace:(D,j)=>Qi(D,j).id,cohort_adopt:D=>De.envelope_observe(D),dag_get:D=>a.get("dag",D),image_get:D=>a.get("image",D),tags_get:D=>a.get("tags",D)});const Ta=(D,j,le)=>{const xe=Li.claimer_get(j);if(xe!==void 0){xe(D,le);return}const Ge=Qi(D,j),mt=a.get("files",Ge.id);for(const ft of le)mt?.envelope_observe(ft)},Pr={instance_spawn:Ie,birth_record:ge,launcher_yield:_e,launcher_active:()=>$.activePreset_get()==="launcher",template_stamp:qi},Ia=Sj(c,Pr),Lr=Ia.open,Da=Hj(c,Pr),Fs=nH(c);function Ca(D){I$(D)&&c.client.claims_send(p0())}const Wi=MH(c,D=>Ca(D)),So=SH(c,{...Pr,ask:D=>gt.line_execute(D,{silent:!0})}),Ra=yj(c,{...Pr,replayPlace_get:re.replayPlace_get,errandHost_find:V,saved:()=>{for(const D of a.values("dag"))D.marks_refresh()}});En("files",D=>x(D,!1)),En("catalogue",D=>x(D,!1,!0)),En("view",fe),En("help",Ia.instance_build),En("games",Da.instance_build),En("notes",So.instance_build),En("edit",Ra.instance_build);for(const[D,j]of ut.factories)En(D,j);En("empty",D=>{const j=qi("tpl-pane-empty");return new LB(j,{execute:le=>gt.line_execute(le,{silent:!0,observe:!1}),claim:(le,xe)=>Ta(D,le,xe),claimKind_find:le=>Li.claimKind_find(le)}),{id:D,kind:"empty",mount:j}});const ka=D=>{D?document.body.dataset.gutter="away":delete document.body.dataset.gutter,Ii("audio3")},Wr=(D,j)=>{if($.activePreset_get()===D&&$.panes_shown().includes(D)){ka(!0);return}document.body.dataset.gutter==="away"&&delete document.body.dataset.gutter,j()};Qe("gutter-restore").addEventListener("click",()=>ka(!1)),window.addEventListener("keydown",D=>{D.key==="Escape"&&document.body.dataset.gutter==="away"&&document.body.dataset.zoom===void 0&&ka(!1)}),Qe("gutter-files").addEventListener("click",()=>{Wr("files",()=>{ne=!1,Ue(),$.focus_set("files"),Pi(!1)})});const N=(D="")=>{Pe("dag"),At.stage_returned(),At.list_reset(),At.roster_filter(D),At.feedsChooser_request(),$.focus_set("dag"),Pi(!1)},K=()=>{Pe("universe");const D=a.get("universe","universe");D!==void 0&&!D.shown_get()&&D.request(),D?.stage_returned(),$.focus_set("universe"),Pi(!1)};Qe("gutter-runs").addEventListener("click",()=>Wr("dag",()=>N())),Qe("gutter-console").addEventListener("click",()=>{Qe("drawer").classList.contains("drawer-closed")&&Qe("drawer-toggle").click(),Ce.focus_take(),Pi(!0)}),Qe("gutter-tools").addEventListener("click",()=>{Wr("pacs",()=>{Pe("pacs"),$.focus_set("pacs"),Pi(!1)})}),Qe("gutter-dashboard").addEventListener("click",()=>{Wr("launcher",it)}),Qe("gutter-panes").addEventListener("click",()=>{Wr("panes",()=>{Pe("panes"),pe.render(),$.focus_set("panes"),Pi(!1)})});const te=D=>zh(D)?.kind??null,Z=IH(c,{verbs:{move:It,flip:oi,resize:ai},help_open:Lr,notes_open:So.open,launcher_enter:it,trek_open:D=>Fs.active_is()?"trek: the bridge is already up":(Fs.open(D),"trek: the bridge takes the screen (Esc or LEAVE BRIDGE gives it back)"),identity_get:()=>S,consoleZoom_toggle:Fw,feed_enter:D=>At.feed_enter(D),file_save:g,stage_keep:()=>ye(),files_open:(D,j)=>{const le=a.get("files",D);return le===void 0?!1:(p.follow_set(D,!1),m(D,le,j),!0)},image_open:(D,j,le)=>k(D,j,le),series_ask:C,tagsPane_open:R}),J=Qe("lang-palette"),Me=Qe("lang-input"),Be=Qe("lang-result"),Se=Qe("lang-pill"),We=()=>{ec(),J.hidden=!1,Se.classList.add("lang-live"),Be.textContent="",Me.value="",Me.focus(),Ii("audio3")},Le=()=>{J.hidden=!0,Se.classList.remove("lang-live"),Be.textContent=""};Se.addEventListener("click",()=>{J.hidden?We():Le()});const nt=["pane","view","runs","node","dag","file","pacs","header","console","back","desktop","argus","help","notes"],ot={pane:["split","zoom","close","bind","claim","focus","flip","resize"],resize:["left","right","up","down"],help:["keys","verbs"],notes:["pane"],focus:["left","right","up","down","last"],view:["files","runs","pacs"],runs:["enter","sort","filter"],node:["enter","immerse","back","clear"],dag:["layout","projection","scale","hue","draw","pulse","census","gravity","select","enter","physics","refresh"],draw:["spheres","stars"],pulse:["on","off"],census:["on","off"],gravity:["on","off"],physics:["charge","link","collide","gravity","reset"],file:["home","back","download","delete","sort","filter","follow","root","list","cards","preview"],pacs:["sort","filter","connect","disconnect","list","query","pull","status"],header:["stats","dag","away","restore"],console:["open","close","toggle","zoom","height"],desktop:["save","load","show","list","delete","clear","share"],split:["left","right","above","below"],bind:["unlinked","fs","viewer"],claim:["files","runs","pacs"],layout:["ranked","molecule"],projection:["2d","3d"],scale:["time","size"],hue:["status","compute"],argus:["verbs"]};if(Me.addEventListener("keydown",D=>{if(D.key==="Escape"){D.stopPropagation(),Le();return}if(D.key==="Tab"){D.preventDefault();const j=Me.value.split(/\s+/),le=j[j.length-1]??"",xe=j.length<=1?"":j[j.length-2]??"",mt=(j.length<=1?nt:ot[xe]??ot[j[0]??""]??[]).find(ft=>ft.startsWith(le.toLowerCase()));mt!==void 0&&(j[j.length-1]=mt,Me.value=`${j.join(" ")} `);return}if(D.key==="Enter"){const j=Me.value.trim();if(j.length===0){Le();return}ph(Z,j).then(le=>{le!==null&&(Fs.active_is()||Wi.active_is())?(Ce.output_write("data",`: ${j}
4393
4393
  ${le}
4394
4394
  `),Le()):le!==null?(Be.textContent=le,Ce.output_write("data",`: ${j}
4395
4395
  ${le}