@fnndsc/argus 0.44.0 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{Settings-CA_Y9_tD.js → Settings-Cc5lCv3O.js} +1 -1
- package/dist/assets/{Texture-CiCQeubr.js → Texture-B157rLuy.js} +1 -1
- package/dist/assets/{addVolumesToViewports-DMbI2RL0.js → addVolumesToViewports-CrkezNA_.js} +1 -1
- package/dist/assets/{asciidoc-CY89DR7y.js → asciidoc-BTHUh6YB.js} +1 -1
- package/dist/assets/{cornerstoneEngine-DOq401ca.js → cornerstoneEngine-PEP4UIJ7.js} +2 -2
- package/dist/assets/{documentEngines-DVCBo-Z6.js → documentEngines-CCoYPxPZ.js} +1 -1
- package/dist/assets/{field-DLtY8hYm.js → field-BKHyiJnc.js} +1 -1
- package/dist/assets/{index-CewxfqE7.js → index-5tdg5ONM.js} +1 -1
- package/dist/assets/{index-D9307TXO.js → index-B556a1Up.js} +1 -1
- package/dist/assets/{index-CH0i1dT3.js → index-BcJvzcDh.js} +1 -1
- package/dist/assets/{index-BQPxeCl8.js → index-BkhlBeUL.js} +1 -1
- package/dist/assets/{index-CPY1fYxX.js → index-BmKitoqU.js} +1 -1
- package/dist/assets/{index-BuNudOlE.js → index-CEJn4PwZ.js} +14 -14
- package/dist/assets/{index-DAPJ1asE.js → index-CTPSv9v3.js} +1 -1
- package/dist/assets/{index-BtxxK29d.js → index-CnXoUzHG.js} +1 -1
- package/dist/assets/{index-Da39IMz6.css → index-CyvB3PsH.css} +1 -1
- package/dist/assets/{index-dGoK1HyL.js → index-D3hO2zdO.js} +1 -1
- package/dist/assets/{index-CRipsi7X.js → index-DRCPd-p9.js} +1 -1
- package/dist/assets/{index-BQltAD7K.js → index-DtiTE7yb.js} +1 -1
- package/dist/assets/{index-DTiNKN3t.js → index-mz7dxXsI.js} +1 -1
- package/dist/assets/{index-D6nj2sGK.js → index-nVrqO_1B.js} +1 -1
- package/dist/assets/{index-DBDbe82G.js → index-tAIm7_30.js} +1 -1
- package/dist/assets/{niivueEngine-GirHHMsU.js → niivueEngine-BCKasqoA.js} +2 -2
- package/dist/assets/{slabScene-DZaFF3AA.js → slabScene-BczGoxx5.js} +1 -1
- package/dist/assets/{syntax-1x8StFCS.js → syntax-CGla7mM6.js} +3 -3
- package/dist/build.json +1 -1
- package/dist/index.html +2 -2
- package/dist/notes.json +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./cornerstoneEngine-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./cornerstoneEngine-PEP4UIJ7.js","./refusal-DOpm8I8L.js","./_commonjsHelpers-CE1G-McA.js","./__vite-browser-external-D7Ct-6yo.js","./niivueEngine-BCKasqoA.js","./field-BKHyiJnc.js","./syntax-CGla7mM6.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 hO=450,W_=12;function Oo(t,e,s=Date.now()){const i=Number(t.dataset.edgeAt??0);return t.dataset.edge===e&&s-i<hO?!1:(delete t.dataset.edge,t.offsetWidth,t.dataset.edge=e,t.dataset.edgeAt=String(s),!0)}function dO(t,e){return e?"▲ TOP":`▼ ${t} MORE`}function uO(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 fO(t){const e=parseFloat(getComputedStyle(t).lineHeight)||16;return Math.max(0,Math.ceil((t.scrollHeight-t.scrollTop-t.clientHeight)/e))}function ii(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??dO,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?uO(t,e.rows):fO(t),h=i(c,n());s.textContent!==h&&(s.textContent=h)}finally{o=!1}}};return t.addEventListener("scroll",a,{passive:!0}),pO(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 pO(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()?Oo(t,"top"):e()&&Oo(t,"bottom"))}),t.addEventListener("wheel",o=>{!s()||o.deltaY===0||(o.deltaY<0&&i()?Oo(t,"top"):o.deltaY>0&&e()&&Oo(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>W_&&i()?(Oo(t,"top"),r=null):r-a>W_&&e()&&(Oo(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 Xi(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 Ys(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`pane template is missing ${e}`);return s}const ry=24,Wf="argus.dormant";class mO{constructor(e=ry,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(Wf,JSON.stringify([...this.groups.values()]))}catch{}}rehydrate(){if(this.store!==void 0)try{const e=this.store.getItem(Wf);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 oy(){try{const t=globalThis.localStorage;return t===void 0?void 0:(t.getItem(Wf),t)}catch{return}}function gO(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 ay(t,e){return`${t.replace(/\/+$/,"")}/#${encodeURI(e)}`}const _O=2500;function ly(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),og(e,t);const n=r=>{r.stopPropagation(),cy(e)};return s.addEventListener("click",n),i.addEventListener("click",n),e}function og(t,e){const s=ay(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 cy(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"))},_O),n}const bO="desktop clear";function hy(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",bO,...e].join(`
|
|
4
4
|
`)}const F_=2500;function MO(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),ii(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")},F_)};return r.addEventListener("click",()=>{h()}),o.addEventListener("click",()=>{const d=vO(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"},F_)})}),a.addEventListener("click",()=>s.remove()),s.addEventListener("keydown",d=>{d.key==="Escape"&&s.remove()}),h(),a.focus(),s}const Ff="view=";function vO(t,e){return`${t.replace(/\/+$/,"")}/#${Ff}${encodeURIComponent(e)}`}function wO(t){if(!t.startsWith(`#${Ff}`))return null;try{const e=decodeURIComponent(t.slice(Ff.length+1));return e.trim()===""?null:e}catch{return null}}function yO(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),ii(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 zO{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 SO(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 SO(t){return[...new Set(t)]}const xO="G1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtChtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzE7MW0gG1swbRtbMzg7MjswOzE7Mm0gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjswOzE7MW0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjsxOzI7Mm0gG1swbRtbMzg7MjswOzE7MW0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbQobWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDsxOzFtIBtbMG0bWzM4OzI7MTsyOzNtIBtbMG0bWzM4OzI7MTsyOzNtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7NTsxMDsxNG0gG1swbRtbMzg7Mjs5OzE4OzI0bSAbWzBtG1szODsyOzU7MTA7MTNtIBtbMG0bWzM4OzI7MTQ7Mjc7MzdtIBtbMG0bWzM4OzI7Mzs3OzltIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MTsyOzJtIBtbMG0bWzM4OzI7MTsyOzNtIBtbMG0bWzM4OzI7MTsyOzJtIBtbMG0bWzM4OzI7MDsxOzFtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsybSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzk7MTc7MjRtIBtbMG0bWzM4OzI7MjM7NDU7NjJtLhtbMG0bWzM4OzI7NDE7Nzk7MTA5bTobWzBtG1szODsyOzU5OzExMzsxNTVtPRtbMG0bWzM4OzI7NzU7MTQ0OzE5NW0rG1swbRtbMzg7Mjs3NjsxNDQ7MTkzbSsbWzBtG1szODsyOzE0OzI3OzM3bSAbWzBtG1szODsyOzc1OzE0MjsxODltKxtbMG0bWzM4OzI7Nzc7MTQ1OzE5Mm0rG1swbRtbMzg7Mjs2NzsxMjY7MTY1bT0bWzBtG1szODsyOzU1OzEwMjsxMzRtLRtbMG0bWzM4OzI7NDE7Nzc7MTAwbTobWzBtG1szODsyOzI3OzUxOzY2bS4bWzBtG1szODsyOzE0OzI3OzM1bSAbWzBtG1szODsyOzQ7ODsxMW0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsxOzI7Mm0gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjswOzE7MW0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbQobWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDsxOzJtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7Mjs1OzhtIBtbMG0bWzM4OzI7MTQ7Mjc7MzltIBtbMG0bWzM4OzI7Mjk7NTc7ODFtOhtbMG0bWzM4OzI7NDU7ODk7MTI3bS0bWzBtG1szODsyOzYxOzEyMDsxNzBtPRtbMG0bWzM4OzI7NzU7MTQ1OzIwM20rG1swbRtbMzg7Mjs3OTsxNTM7MjExbSsbWzBtG1szODsyOzgwOzE1NDsyMTJtKxtbMG0bWzM4OzI7ODE7MTU2OzIxM20rG1swbRtbMzg7Mjs4MjsxNTg7MjEzbSsbWzBtG1szODsyOzg0OzE1OTsyMTRtKxtbMG0bWzM4OzI7Mzg7NzI7OTdtOhtbMG0bWzM4OzI7MzQ7NjU7ODZtOhtbMG0bWzM4OzI7ODc7MTY0OzIxNm0rG1swbRtbMzg7Mjs4OTsxNjY7MjE3bSsbWzBtG1szODsyOzkwOzE2NzsyMThtKxtbMG0bWzM4OzI7OTE7MTY5OzIxOW0rG1swbRtbMzg7Mjs5MjsxNzE7MjE5bSobWzBtG1szODsyOzkyOzE3MjsyMTltKhtbMG0bWzM4OzI7ODU7MTU3OzIwMG0rG1swbRtbMzg7Mjs3NDsxMzc7MTcybT0bWzBtG1szODsyOzYyOzExMzsxNDFtLRtbMG0bWzM4OzI7NDY7ODQ7MTA1bTobWzBtG1szODsyOzMxOzU3OzcxbTobWzBtG1szODsyOzE3OzMxOzM4bS4bWzBtG1szODsyOzY7MTA7MTNtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzIxOzQzOzY1bS4bWzBtG1szODsyOzM4Ozc2OzExM206G1swbRtbMzg7Mjs0OTs5OTsxNDVtLRtbMG0bWzM4OzI7NjI7MTI0OzE4MW09G1swbRtbMzg7Mjs3MzsxNDQ7MjA4bSsbWzBtG1szODsyOzc0OzE0NjsyMDhtKxtbMG0bWzM4OzI7NzU7MTQ3OzIwOW0rG1swbRtbMzg7Mjs3NjsxNDk7MjEwbSsbWzBtG1szODsyOzc4OzE1MTsyMTFtKxtbMG0bWzM4OzI7Nzg7MTUxOzIwOG0rG1swbRtbMzg7Mjs3ODsxNTE7MjA4bSsbWzBtG1szODsyOzgwOzE1NDsyMTBtKxtbMG0bWzM4OzI7ODE7MTU2OzIxMG0rG1swbRtbMzg7Mjs4MzsxNTc7MjEybSsbWzBtG1szODsyOzc4OzE0OTsxOThtKxtbMG0bWzM4OzI7MTE7MjI7MjltIBtbMG0bWzM4OzI7NzY7MTQ0OzE5MG0rG1swbRtbMzg7Mjs4ODsxNjY7MjE3bSsbWzBtG1szODsyOzg3OzE2MjsyMTJtKxtbMG0bWzM4OzI7ODk7MTY2OzIxNW0rG1swbRtbMzg7Mjs5MDsxNjg7MjE2bSsbWzBtG1szODsyOzkzOzE3MzsyMjBtKhtbMG0bWzM4OzI7OTQ7MTc0OzIyMW0qG1swbRtbMzg7Mjs5NjsxNzY7MjIxbSobWzBtG1szODsyOzk3OzE3ODsyMjJtKhtbMG0bWzM4OzI7OTg7MTc5OzIyM20qG1swbRtbMzg7Mjs5OTsxODE7MjI0bSobWzBtG1szODsyOzEwMTsxODM7MjI0bSobWzBtG1szODsyOzkzOzE2ODsyMDVtKxtbMG0bWzM4OzI7ODE7MTQ4OzE3OW0rG1swbRtbMzg7Mjs2ODsxMjM7MTQ4bT0bWzBtG1szODsyOzUxOzkzOzExMm0tG1swbRtbMzg7MjszNDs2MTs3M206G1swbRtbMzg7MjsyMjs0MDs0N20uG1swbRtbMzg7Mjs5OzE2OzE5bSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtChtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzI7M20gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsyOzU7OG0gG1swbRtbMzg7MjszNzs3NjsxMTVtOhtbMG0bWzM4OzI7Mjg7NTg7ODhtOhtbMG0bWzM4OzI7Mjg7NTY7ODRtOhtbMG0bWzM4OzI7NTM7MTA2OzE1OG0tG1swbRtbMzg7Mjs3MDsxNDE7MjA2bT0bWzBtG1szODsyOzcxOzE0MjsyMDdtKxtbMG0bWzM4OzI7NzM7MTQ0OzIwOG0rG1swbRtbMzg7Mjs3MTsxNDE7MjAybSsbWzBtG1szODsyOzczOzE0NDsyMDRtKxtbMG0bWzM4OzI7NzU7MTQ3OzIwOG0rG1swbRtbMzg7Mjs3NzsxNDk7MjA5bSsbWzBtG1szODsyOzc4OzE1MTsyMDltKxtbMG0bWzM4OzI7Nzk7MTUyOzIxMG0rG1swbRtbMzg7Mjs4MDsxNTU7MjEybSsbWzBtG1szODsyOzgyOzE1ODsyMTNtKxtbMG0bWzM4OzI7ODE7MTU1OzIwOW0rG1swbRtbMzg7Mjs4NTsxNjE7MjE1bSsbWzBtG1szODsyOzQyOzgwOzEwN206G1swbRtbMzg7MjsyODs1Mzs3MG0uG1swbRtbMzg7Mjs3NDsxNDA7MTgzbT0bWzBtG1szODsyOzkwOzE2NzsyMThtKxtbMG0bWzM4OzI7OTA7MTY4OzIxOG0rG1swbRtbMzg7Mjs5MDsxNjg7MjE1bSsbWzBtG1szODsyOzkxOzE3MDsyMTdtKhtbMG0bWzM4OzI7OTI7MTcxOzIxOG0qG1swbRtbMzg7Mjs5NDsxNzM7MjE4bSobWzBtG1szODsyOzk1OzE3NTsyMThtKhtbMG0bWzM4OzI7OTY7MTc2OzIxOW0qG1swbRtbMzg7Mjs5NzsxNzg7MjIxbSobWzBtG1szODsyOzEwMTsxODM7MjI0bSobWzBtG1szODsyOzEwMjsxODQ7MjI1bSobWzBtG1szODsyOzEwMzsxODY7MjI2bSobWzBtG1szODsyOzEwNDsxODg7MjI2bSobWzBtG1szODsyOzEwNTsxODk7MjI3bSobWzBtG1szODsyOzEwNzsxOTE7MjI4bSobWzBtG1szODsyOzk4OzE3NjsyMDltKhtbMG0bWzM4OzI7MjM7NDI7NTBtLhtbMG0bWzM4OzI7NzsxMzsxNm0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzE7MW0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbQobWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDsyOzNtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MTE7MjM7MzVtIBtbMG0bWzM4OzI7NTE7MTA2OzE2M20tG1swbRtbMzg7Mjs2NTsxMzQ7MjAzbT0bWzBtG1szODsyOzY3OzEzNjsyMDRtPRtbMG0bWzM4OzI7NTM7MTA5OzE2Mm0tG1swbRtbMzg7MjsyOTs1OTs4N206G1swbRtbMzg7MjsyMzs0Nzs2OG0uG1swbRtbMzg7Mjs0Mzs4NzsxMjdtLRtbMG0bWzM4OzI7Njk7MTM3OzE5OW09G1swbRtbMzg7Mjs3NDsxNDY7MjA4bSsbWzBtG1szODsyOzc1OzE0NzsyMDltKxtbMG0bWzM4OzI7NzQ7MTQ2OzIwNm0rG1swbRtbMzg7Mjs3ODsxNTE7MjExbSsbWzBtG1szODsyOzc5OzE1MzsyMTFtKxtbMG0bWzM4OzI7ODA7MTU0OzIxMm0rG1swbRtbMzg7Mjs4MTsxNTY7MjEzbSsbWzBtG1szODsyOzgwOzE1NDsyMDhtKxtbMG0bWzM4OzI7ODQ7MTU5OzIxNG0rG1swbRtbMzg7Mjs4MzsxNTc7MjA5bSsbWzBtG1szODsyOzE0OzI2OzM1bSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzQzOzgxOzEwNm06G1swbRtbMzg7Mjs5MTsxNjk7MjE5bSsbWzBtG1szODsyOzkyOzE3MTsyMTltKhtbMG0bWzM4OzI7OTM7MTczOzIyMG0qG1swbRtbMzg7Mjs5NDsxNzQ7MjIxbSobWzBtG1szODsyOzk2OzE3NjsyMjFtKhtbMG0bWzM4OzI7OTU7MTc1OzIxOW0qG1swbRtbMzg7Mjs5NjsxNzY7MjIwbSobWzBtG1szODsyOzk4OzE4MDsyMjNtKhtbMG0bWzM4OzI7MTAwOzE4MjsyMjNtKhtbMG0bWzM4OzI7MTAxOzE4MjsyMjNtKhtbMG0bWzM4OzI7MTAxOzE4MzsyMjJtKhtbMG0bWzM4OzI7MTAwOzE4MTsyMThtKhtbMG0bWzM4OzI7MTA1OzE4OTsyMjdtKhtbMG0bWzM4OzI7ODc7MTU2OzE4Nm0rG1swbRtbMzg7MjsxODszMjszOG0uG1swbRtbMzg7Mjs3NTsxMzQ7MTU4bT0bWzBtG1szODsyOzM3OzY1Ozc3bTobWzBtG1szODsyOzQ3Ozg0Ozk4bTobWzBtG1szODsyOzE1OzI3OzMybSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzE7MzszbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtChtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsyMTs0NTs3MG0uG1swbRtbMzg7Mjs1OTsxMjM7MTkwbT0bWzBtG1szODsyOzY0OzEzMzsyMDNtPRtbMG0bWzM4OzI7NjM7MTMxOzE5OW09G1swbRtbMzg7Mjs2NjsxMzQ7MjAxbT0bWzBtG1szODsyOzY4OzEzODsyMDVtPRtbMG0bWzM4OzI7Njk7MTM5OzIwNm09G1swbRtbMzg7Mjs2MDsxMjI7MTc5bT0bWzBtG1szODsyOzM2OzcyOzEwNW06G1swbRtbMzg7MjsyNDs0ODs2OW0uG1swbRtbMzg7Mjs0MDs3OTsxMTNtOhtbMG0bWzM4OzI7Njc7MTMyOzE4OG09G1swbRtbMzg7Mjs3NjsxNDk7MjEwbSsbWzBtG1szODsyOzc2OzE0ODsyMDdtKxtbMG0bWzM4OzI7Njg7MTMyOzE4Mm09G1swbRtbMzg7Mjs2ODsxMzI7MTgybT0bWzBtG1szODsyOzc4OzE1MDsyMDVtKxtbMG0bWzM4OzI7ODI7MTU4OzIxM20rG1swbRtbMzg7Mjs3NzsxNDY7MTk3bSsbWzBtG1szODsyOzQyOzc5OzEwNm06G1swbRtbMzg7Mjs0Ozg7MTFtIBtbMG0bWzM4OzI7MTszOzRtIBtbMG0bWzM4OzI7NTsxMDsxM20gG1swbRtbMzg7MjsyNjs1MDs2NG0uG1swbRtbMzg7MjszODs3MTs5Mm06G1swbRtbMzg7Mjs0Nzs4NzsxMTJtLRtbMG0bWzM4OzI7NjM7MTE4OzE1MG09G1swbRtbMzg7Mjs4MTsxNTA7MTkxbSsbWzBtG1szODsyOzk2OzE3NjsyMjFtKhtbMG0bWzM4OzI7OTc7MTc4OzIyMm0qG1swbRtbMzg7Mjs5ODsxNzk7MjIzbSobWzBtG1szODsyOzk5OzE4MTsyMjRtKhtbMG0bWzM4OzI7MTAxOzE4MzsyMjRtKhtbMG0bWzM4OzI7MTAyOzE4NDsyMjVtKhtbMG0bWzM4OzI7MTAzOzE4NjsyMjZtKhtbMG0bWzM4OzI7MTA0OzE4ODsyMjdtKhtbMG0bWzM4OzI7Nzc7MTM5OzE2N209G1swbRtbMzg7MjsxNzszMTszN20uG1swbRtbMzg7Mjs3OTsxNDA7MTY3bT0bWzBtG1szODsyOzEwOTsxOTU7MjI5bSobWzBtG1szODsyOzQxOzczOzg2bTobWzBtG1szODsyOzYxOzEwOTsxMjdtLRtbMG0bWzM4OzI7MTAxOzE3NzsyMDZtKhtbMG0bWzM4OzI7MjA7MzY7NDFtLhtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MTszOzNtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzQ7ODsxNG0gG1swbRtbMzg7MjszODs4MTsxMjdtOhtbMG0bWzM4OzI7NjI7MTI5OzIwMW09G1swbRtbMzg7Mjs2MzsxMzE7MjAybT0bWzBtG1szODsyOzYzOzEzMDsyMDBtPRtbMG0bWzM4OzI7NjQ7MTMyOzIwMG09G1swbRtbMzg7Mjs2NTsxMzM7MjAwbT0bWzBtG1szODsyOzY2OzEzNTsyMDBtPRtbMG0bWzM4OzI7Njc7MTM1OzIwMG09G1swbRtbMzg7Mjs3MDsxNDE7MjA2bT0bWzBtG1szODsyOzcxOzE0MjsyMDdtKxtbMG0bWzM4OzI7NjY7MTMyOzE5MG09G1swbRtbMzg7Mjs0Mjs4MzsxMThtOhtbMG0bWzM4OzI7MjY7NTE7NzNtLhtbMG0bWzM4OzI7MzA7NjA7ODVtOhtbMG0bWzM4OzI7MTI7MjQ7MzNtIBtbMG0bWzM4OzI7MTsyOzRtIBtbMG0bWzM4OzI7MTsyOzNtIBtbMG0bWzM4OzI7MTA7MTk7MjZtIBtbMG0bWzM4OzI7MzI7NjE7ODNtOhtbMG0bWzM4OzI7Mjg7NTQ7NzNtLhtbMG0bWzM4OzI7NDg7OTE7MTIybS0bWzBtG1szODsyOzgwOzE1MzsyMDNtKxtbMG0bWzM4OzI7MjU7NDc7NjNtLhtbMG0bWzM4OzI7NDg7OTE7MTE5bS0bWzBtG1szODsyOzkwOzE2NzsyMThtKxtbMG0bWzM4OzI7ODI7MTUzOzE5OG0rG1swbRtbMzg7Mjs2ODsxMjc7MTYzbT0bWzBtG1szODsyOzUyOzk4OzEyNW0tG1swbRtbMzg7Mjs0MTs3Nzs5N206G1swbRtbMzg7MjszOTs3Mjs5MW06G1swbRtbMzg7Mjs0ODs4ODsxMTBtLRtbMG0bWzM4OzI7NjQ7MTE3OzE0Nm09G1swbRtbMzg7Mjs4MzsxNTI7MTg4bSsbWzBtG1szODsyOzEwMTsxODM7MjI0bSobWzBtG1szODsyOzEwMDsxODA7MjIwbSobWzBtG1szODsyOzg4OzE1OTsxOTRtKxtbMG0bWzM4OzI7Njg7MTI0OzE1MG09G1swbRtbMzg7MjsyNjs0Njs1Nm0uG1swbRtbMzg7Mjs5MTsxNjQ7MTk1bSsbWzBtG1szODsyOzEwODsxOTI7MjI5bSobWzBtG1szODsyOzEwODsxOTM7MjI3bSobWzBtG1szODsyOzY3OzExOTsxNDBtPRtbMG0bWzM4OzI7Mzc7NjY7NzdtOhtbMG0bWzM4OzI7MTEzOzE5OTsyMzFtKhtbMG0bWzM4OzI7MTA1OzE4NjsyMTVtKhtbMG0bWzM4OzI7MzU7NjI7NzFtOhtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MTsyOzJtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzEzOzI3OzQzbSAbWzBtG1szODsyOzM1Ozc1OzExOG06G1swbRtbMzg7Mjs0Mzs5MTsxNDFtLRtbMG0bWzM4OzI7NTY7MTE2OzE3OW09G1swbRtbMzg7Mjs2NDsxMzI7MjAzbT0bWzBtG1szODsyOzY1OzEzNDsyMDNtPRtbMG0bWzM4OzI7Njc7MTM2OzIwNG09G1swbRtbMzg7Mjs2ODsxMzg7MjA1bT0bWzBtG1szODsyOzY5OzEzOTsyMDZtPRtbMG0bWzM4OzI7NzA7MTQxOzIwNm09G1swbRtbMzg7Mjs3MTsxNDI7MjA3bSsbWzBtG1szODsyOzczOzE0NDsyMDhtKxtbMG0bWzM4OzI7NzQ7MTQ2OzIwOG0rG1swbRtbMzg7Mjs1MjsxMDI7MTQ1bS0bWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzQ4OzkxOzEyM20tG1swbRtbMzg7Mjs4NTsxNjE7MjE1bSsbWzBtG1szODsyOzg2OzE2MzsyMTZtKxtbMG0bWzM4OzI7MzM7NjM7ODNtOhtbMG0bWzM4OzI7NDY7ODc7MTE0bS0bWzBtG1szODsyOzg4OzE2MzsyMTNtKxtbMG0bWzM4OzI7OTE7MTY5OzIxOW0rG1swbRtbMzg7Mjs5MjsxNzE7MjE5bSobWzBtG1szODsyOzkzOzE3MzsyMjBtKhtbMG0bWzM4OzI7OTQ7MTc0OzIyMW0qG1swbRtbMzg7Mjs4OTsxNjQ7MjA2bSsbWzBtG1szODsyOzc0OzEzNjsxNzBtPRtbMG0bWzM4OzI7NTc7MTA0OzEzMG0tG1swbRtbMzg7Mjs0NDs4MDsxMDBtOhtbMG0bWzM4OzI7Mzc7Njg7ODNtOhtbMG0bWzM4OzI7MTg7MzM7NDFtLhtbMG0bWzM4OzI7Mzs2OzdtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7NTU7OTk7MTE5bS0bWzBtG1szODsyOzk4OzE3NjsyMTBtKhtbMG0bWzM4OzI7OTk7MTc3OzIxMW0qG1swbRtbMzg7MjsxMDg7MTk0OzIyOG0qG1swbRtbMzg7Mjs2NTsxMTY7MTM3bT0bWzBtG1szODsyOzE2OzI4OzMzbSAbWzBtG1szODsyOzg0OzE0OTsxNzNtKxtbMG0bWzM4OzI7MTE0OzIwMTsyMzJtIxtbMG0bWzM4OzI7MTE1OzIwMzsyMzNtIxtbMG0bWzM4OzI7NTU7OTc7MTExbS0bWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtChtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MW0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsxMTsyNDszOG0gG1swbRtbMzg7Mjs0Mzs5MTsxNDRtLRtbMG0bWzM4OzI7MzM7Njg7MTA3bTobWzBtG1szODsyOzI2OzU1Ozg1bS4bWzBtG1szODsyOzI2OzU1Ozg1bS4bWzBtG1szODsyOzM1OzczOzExMG06G1swbRtbMzg7Mjs0Mjs4NjsxMzBtLRtbMG0bWzM4OzI7MjM7NDc7NjltLhtbMG0bWzM4OzI7MjQ7NDg7NzFtLhtbMG0bWzM4OzI7NDk7OTk7MTQ1bS0bWzBtG1szODsyOzUwOzEwMTsxNDdtLRtbMG0bWzM4OzI7NDI7ODM7MTE5bTobWzBtG1szODsyOzM1OzcwOzEwMW06G1swbRtbMzg7MjsyMDs0MDs1N20uG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsxOzI7NG0gG1swbRtbMzg7MjswOzE7MW0gG1swbRtbMzg7MjswOzE7MW0gG1swbRtbMzg7MjswOzE7MW0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjszMDs1Nzs3OG06G1swbRtbMzg7Mjs4MzsxNTc7MjA5bSsbWzBtG1szODsyOzg2OzE2MzsyMTZtKxtbMG0bWzM4OzI7NDA7NzU7OTltOhtbMG0bWzM4OzI7NDM7ODA7MTA1bTobWzBtG1szODsyOzkwOzE2NzsyMThtKxtbMG0bWzM4OzI7ODk7MTY1OzIxNG0rG1swbRtbMzg7Mjs5MTsxNjk7MjE3bSsbWzBtG1szODsyOzkxOzE3MDsyMTdtKhtbMG0bWzM4OzI7OTM7MTcyOzIxOW0qG1swbRtbMzg7Mjs5NjsxNzY7MjIxbSobWzBtG1szODsyOzk3OzE3ODsyMjJtKhtbMG0bWzM4OzI7OTg7MTc5OzIyM20qG1swbRtbMzg7MjsxMDA7MTgxOzIyNG0qG1swbRtbMzg7Mjs4NTsxNTU7MTg5bSsbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzM7NTs3bSAbWzBtG1szODsyOzM4OzY5OzgzbTobWzBtG1szODsyOzQ5Ozg3OzEwNG0tG1swbRtbMzg7Mjs0Nzs4NDs5OW06G1swbRtbMzg7MjszNTs2Mzs3NG06G1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7Mjs1Mjs5MzsxMDdtLRtbMG0bWzM4OzI7ODg7MTU2OzE4MG0rG1swbRtbMzg7MjsxMDU7MTg1OzIxMm0qG1swbRtbMzg7Mjs2NDsxMTI7MTI3bS0bWzBtG1szODsyOzU7ODsxMG0gG1swbRtbMzg7MjsxOzM7M20gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbQobWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDsxOzJtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7Mzk7ODM7MTMxbTobWzBtG1szODsyOzYyOzEyOTsyMDFtPRtbMG0bWzM4OzI7NjM7MTMxOzIwMm09G1swbRtbMzg7Mjs1NzsxMjA7MTgzbT0bWzBtG1szODsyOzQ3Ozk2OzE0NW0tG1swbRtbMzg7MjswOzI7M20gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjszOzc7MTFtIBtbMG0bWzM4OzI7NDE7ODI7MTIwbTobWzBtG1szODsyOzUwOzk5OzE0NG0tG1swbRtbMzg7Mjs1OTsxMTc7MTY4bT0bWzBtG1szODsyOzY4OzEzNDsxOTBtPRtbMG0bWzM4OzI7Mzc7NzM7MTAybTobWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzQ7NzsxMG0gG1swbRtbMzg7MjszMjs2Mjs4NG06G1swbRtbMzg7Mjs0Mjs3OTsxMDdtOhtbMG0bWzM4OzI7MzE7NTk7ODBtOhtbMG0bWzM4OzI7NDQ7ODQ7MTExbTobWzBtG1szODsyOzE4OzM1OzQ2bS4bWzBtG1szODsyOzEyOzIzOzMwbSAbWzBtG1szODsyOzYwOzExMjsxNDdtLRtbMG0bWzM4OzI7OTE7MTY5OzIxOW0rG1swbRtbMzg7Mjs5MDsxNjc7MjE0bSsbWzBtG1szODsyOzkyOzE3MjsyMTltKhtbMG0bWzM4OzI7OTQ7MTc0OzIyMW0qG1swbRtbMzg7Mjs5NTsxNzU7MjIwbSobWzBtG1szODsyOzk1OzE3NDsyMTdtKhtbMG0bWzM4OzI7OTg7MTc5OzIyM20qG1swbRtbMzg7Mjs5NzsxNzY7MjE3bSobWzBtG1szODsyOzM1OzY0Ozc5bTobWzBtG1szODsyOzQ2Ozg0OzEwM206G1swbRtbMzg7Mjs3NzsxNDA7MTcwbT0bWzBtG1szODsyOzg3OzE1ODsxOTBtKxtbMG0bWzM4OzI7MTA1OzE4OTsyMjdtKhtbMG0bWzM4OzI7MTA3OzE5MTsyMjhtKhtbMG0bWzM4OzI7MTA4OzE5MzsyMjltKhtbMG0bWzM4OzI7OTE7MTYyOzE5Mm0rG1swbRtbMzg7MjszMTs1Njs2NW0uG1swbRtbMzg7MjszOzY7N20gG1swbRtbMzg7MjsyNzs0OTs1N20uG1swbRtbMzg7Mjs2NjsxMTc7MTM1bT0bWzBtG1szODsyOzU4OzEwMzsxMThtLRtbMG0bWzM4OzI7NTA7ODg7MTAwbS0bWzBtG1szODsyOzYzOzExMTsxMjZtLRtbMG0bWzM4OzI7MjQ7NDQ7NDltLhtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDsxOzFtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzQ7ODsxM20gG1swbRtbMzg7Mjs1NTsxMTU7MTc5bT0bWzBtG1szODsyOzYyOzEyOTsxOTltPRtbMG0bWzM4OzI7NjQ7MTMzOzIwM209G1swbRtbMzg7Mjs2NTsxMzQ7MjAzbT0bWzBtG1szODsyOzUyOzEwNjsxNjBtLRtbMG0bWzM4OzI7MTc7MzU7NTJtLhtbMG0bWzM4OzI7MTE7MjM7MzNtIBtbMG0bWzM4OzI7NTY7MTEzOzE2Nm09G1swbRtbMzg7Mjs3MTsxNDI7MjA3bSsbWzBtG1szODsyOzczOzE0NDsyMDhtKxtbMG0bWzM4OzI7NzQ7MTQ2OzIwOG0rG1swbRtbMzg7Mjs3NTsxNDg7MjA5bSsbWzBtG1szODsyOzMxOzYxOzg3bTobWzBtG1szODsyOzM0OzY2OzkybTobWzBtG1szODsyOzYxOzExODsxNjRtPRtbMG0bWzM4OzI7NTk7MTE0OzE1N209G1swbRtbMzg7Mjs3MjsxNDA7MTkxbT0bWzBtG1szODsyOzgyOzE1ODsyMTNtKxtbMG0bWzM4OzI7ODQ7MTU5OzIxNG0rG1swbRtbMzg7Mjs3OTsxNDk7MTk5bSsbWzBtG1szODsyOzExOzIyOzI5bSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzgyOzE1MjsxOTdtKxtbMG0bWzM4OzI7OTI7MTcxOzIxOW0qG1swbRtbMzg7Mjs5MzsxNzM7MjIwbSobWzBtG1szODsyOzkzOzE3MjsyMTltKhtbMG0bWzM4OzI7OTY7MTc2OzIyMW0qG1swbRtbMzg7Mjs5NzsxNzg7MjIybSobWzBtG1szODsyOzg4OzE2MDsyMDBtKxtbMG0bWzM4OzI7MjM7NDM7NTNtLhtbMG0bWzM4OzI7NTI7OTQ7MTE1bS0bWzBtG1szODsyOzEwMjsxODQ7MjI1bSobWzBtG1szODsyOzEwMzsxODY7MjI2bSobWzBtG1szODsyOzEwNDsxODg7MjI2bSobWzBtG1szODsyOzEwNDsxODc7MjI1bSobWzBtG1szODsyOzEwNjsxODk7MjI2bSobWzBtG1szODsyOzEwODsxOTM7MjI5bSobWzBtG1szODsyOzEwOTsxOTQ7MjI5bSobWzBtG1szODsyOzExMTsxOTY7MjMwbSobWzBtG1szODsyOzM1OzYyOzczbTobWzBtG1szODsyOzY4OzEyMTsxNDFtPRtbMG0bWzM4OzI7MTE0OzIwMTsyMzJtIxtbMG0bWzM4OzI7MTE1OzIwMzsyMzNtIxtbMG0bWzM4OzI7MTE2OzIwNDsyMzRtIxtbMG0bWzM4OzI7Nzg7MTM2OzE1NW09G1swbRtbMzg7MjszMzs1ODs2Nm06G1swbRtbMzg7MjsyMTszNjs0MW0uG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbQobWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDsxOzJtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MjI7NDc7NzNtLhtbMG0bWzM4OzI7NjM7MTMxOzIwMm09G1swbRtbMzg7Mjs2MjsxMzA7MTk5bT0bWzBtG1szODsyOzYzOzEzMDsxOThtPRtbMG0bWzM4OzI7Njc7MTM2OzIwNG09G1swbRtbMzg7Mjs0ODs5NzsxNDZtLRtbMG0bWzM4OzI7MTk7NDA7NThtLhtbMG0bWzM4OzI7NzA7MTQxOzIwNm09G1swbRtbMzg7Mjs2OTsxMzg7MjAybT0bWzBtG1szODsyOzcwOzE0MDsyMDJtPRtbMG0bWzM4OzI7NzQ7MTQ2OzIwOG0rG1swbRtbMzg7MjszNTs3MDs5OW06G1swbRtbMzg7MjsyMjs0NDs2MW0uG1swbRtbMzg7Mjs3ODsxNTE7MjExbSsbWzBtG1szODsyOzc5OzE1MzsyMTFtKxtbMG0bWzM4OzI7ODA7MTU0OzIxMm0rG1swbRtbMzg7Mjs4MTsxNTY7MjEzbSsbWzBtG1szODsyOzgxOzE1NjsyMTBtKxtbMG0bWzM4OzI7ODI7MTU1OzIwOW0rG1swbRtbMzg7Mjs4NTsxNjE7MjE1bSsbWzBtG1szODsyOzc0OzE0MDsxODZtPRtbMG0bWzM4OzI7MjU7NDc7NjJtLhtbMG0bWzM4OzI7MTQ7Mjc7MzVtIBtbMG0bWzM4OzI7NDg7ODk7MTE3bS0bWzBtG1szODsyOzMxOzU4Ozc0bTobWzBtG1szODsyOzQ4Ozg5OzExNW0tG1swbRtbMzg7Mjs4MzsxNTQ7MTk2bSsbWzBtG1szODsyOzk0OzE3NDsyMjFtKhtbMG0bWzM4OzI7OTQ7MTczOzIxN20qG1swbRtbMzg7Mjs3OTsxNDU7MTgxbSsbWzBtG1szODsyOzIwOzM3OzQ3bS4bWzBtG1szODsyOzY1OzExNzsxNDVtPRtbMG0bWzM4OzI7MTAxOzE4MzsyMjRtKhtbMG0bWzM4OzI7MTAwOzE4MTsyMjFtKhtbMG0bWzM4OzI7MTAxOzE4MzsyMjNtKhtbMG0bWzM4OzI7MTAzOzE4NjsyMjRtKhtbMG0bWzM4OzI7MTA1OzE4OTsyMjdtKhtbMG0bWzM4OzI7MTA3OzE5MTsyMjhtKhtbMG0bWzM4OzI7MTA4OzE5MzsyMjltKhtbMG0bWzM4OzI7MTA2OzE4OTsyMjNtKhtbMG0bWzM4OzI7MTExOzE5NjsyMzBtKhtbMG0bWzM4OzI7NjU7MTE2OzEzNm09G1swbRtbMzg7Mjs0MDs3Mjs4M206G1swbRtbMzg7MjsxMTQ7MjAxOzIzMm0jG1swbRtbMzg7Mjs5NzsxNzE7MTk3bSobWzBtG1szODsyOzQxOzczOzg0bTobWzBtG1szODsyOzM5OzY5Ozc4bTobWzBtG1szODsyOzEwNTsxODM7MjA3bSobWzBtG1szODsyOzcwOzEyMjsxMzhtPRtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MTszOzNtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsybSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzQ2Ozk3OzE0OW0tG1swbRtbMzg7Mjs2NDsxMzI7MjAzbT0bWzBtG1szODsyOzYyOzEyOTsxOTZtPRtbMG0bWzM4OzI7NjY7MTM0OzIwMW09G1swbRtbMzg7Mjs1NDsxMDk7MTYzbS0bWzBtG1szODsyOzEzOzI2OzM5bSAbWzBtG1szODsyOzY5OzEzOTsyMDNtPRtbMG0bWzM4OzI7Njk7MTM5OzIwM209G1swbRtbMzg7Mjs3MzsxNDQ7MjA4bSsbWzBtG1szODsyOzQ1Ozg5OzEyN20tG1swbRtbMzg7MjsxNjszMTs0NG0uG1swbRtbMzg7Mjs3NDsxNDY7MjA1bSsbWzBtG1szODsyOzc3OzE0OTsyMDhtKxtbMG0bWzM4OzI7Nzc7MTUwOzIwN20rG1swbRtbMzg7Mjs3OTsxNTI7MjA5bSsbWzBtG1szODsyOzgwOzE1NDsyMTFtKxtbMG0bWzM4OzI7ODI7MTU4OzIxM20rG1swbRtbMzg7Mjs4NDsxNTk7MjE0bSsbWzBtG1szODsyOzgzOzE1ODsyMTFtKxtbMG0bWzM4OzI7ODY7MTYzOzIxNm0rG1swbRtbMzg7Mjs1ODsxMDk7MTQ0bS0bWzBtG1szODsyOzI4OzUzOzY4bS4bWzBtG1szODsyOzkwOzE2NzsyMThtKxtbMG0bWzM4OzI7ODU7MTU4OzIwNW0rG1swbRtbMzg7Mjs1NTsxMDM7MTMybS0bWzBtG1szODsyOzI3OzUwOzY0bS4bWzBtG1szODsyOzI1OzQ3OzYwbS4bWzBtG1szODsyOzE2OzI5OzM3bS4bWzBtG1szODsyOzQ7ODsxMW0gG1swbRtbMzg7Mjs2ODsxMjQ7MTU0bT0bWzBtG1szODsyOzk5OzE4MTsyMjRtKhtbMG0bWzM4OzI7OTc7MTc2OzIxNm0qG1swbRtbMzg7MjsxMDE7MTgzOzIyNG0qG1swbRtbMzg7MjsxMDM7MTg2OzIyNm0qG1swbRtbMzg7MjsxMDQ7MTg4OzIyNm0qG1swbRtbMzg7MjsxMDU7MTg5OzIyN20qG1swbRtbMzg7MjsxMDc7MTkxOzIyOG0qG1swbRtbMzg7MjsxMDg7MTkzOzIyOW0qG1swbRtbMzg7MjsxMDc7MTkxOzIyNm0qG1swbRtbMzg7MjsxMDY7MTg5OzIyMW0qG1swbRtbMzg7Mjs1Njs5OTsxMTZtLRtbMG0bWzM4OzI7MTI7MjE7MjVtIBtbMG0bWzM4OzI7NTY7MTAwOzExNW0tG1swbRtbMzg7MjszMjs1Nzs2NW06G1swbRtbMzg7Mjs3NjsxMzQ7MTU0bT0bWzBtG1szODsyOzExNzsyMDY7MjM0bSMbWzBtG1szODsyOzExOTsyMDg7MjM1bSMbWzBtG1szODsyOzg1OzE0OTsxNjhtKxtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDsxOzFtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzEwOzIxOzMzbSAbWzBtG1szODsyOzYwOzEyNjsxOTNtPRtbMG0bWzM4OzI7NjU7MTM0OzIwM209G1swbRtbMzg7Mjs2NzsxMzY7MjA0bT0bWzBtG1szODsyOzYxOzEyMzsxODRtPRtbMG0bWzM4OzI7MTE7MjM7MzVtIBtbMG0bWzM4OzI7NjQ7MTI5OzE4OW09G1swbRtbMzg7Mjs3MTsxNDM7MjA3bSsbWzBtG1szODsyOzUzOzEwNTsxNTFtLRtbMG0bWzM4OzI7MTE7MjI7MzFtIBtbMG0bWzM4OzI7Njg7MTM0OzE5MW09G1swbRtbMzg7Mjs3NjsxNDk7MjEwbSsbWzBtG1szODsyOzc3OzE0OTsyMDltKxtbMG0bWzM4OzI7Nzk7MTUzOzIxMW0rG1swbRtbMzg7Mjs4MDsxNTQ7MjEybSsbWzBtG1szODsyOzgxOzE1NjsyMTNtKxtbMG0bWzM4OzI7ODI7MTU4OzIxM20rG1swbRtbMzg7Mjs4NDsxNTk7MjE0bSsbWzBtG1szODsyOzg0OzE1OTsyMTJtKxtbMG0bWzM4OzI7ODU7MTYxOzIxNG0rG1swbRtbMzg7Mjs1NjsxMDY7MTQwbS0bWzBtG1szODsyOzI0OzQ1OzU5bS4bWzBtG1szODsyOzg4OzE2NDsyMTRtKxtbMG0bWzM4OzI7ODk7MTY2OzIxNW0rG1swbRtbMzg7Mjs5MjsxNzE7MjE5bSobWzBtG1szODsyOzcxOzEzMTsxNjhtPRtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7NDY7ODQ7MTA1bTobWzBtG1szODsyOzk4OzE3OTsyMjJtKhtbMG0bWzM4OzI7MTAxOzE4MzsyMjRtKhtbMG0bWzM4OzI7MTAyOzE4NDsyMjVtKhtbMG0bWzM4OzI7MTAxOzE4MzsyMjNtKhtbMG0bWzM4OzI7MTAzOzE4NzsyMjVtKhtbMG0bWzM4OzI7MTA0OzE4ODsyMjZtKhtbMG0bWzM4OzI7MTA2OzE5MDsyMjdtKhtbMG0bWzM4OzI7MTA1OzE4NzsyMjNtKhtbMG0bWzM4OzI7MTA5OzE5NDsyMjltKhtbMG0bWzM4OzI7ODQ7MTQ5OzE3NW0rG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7Mjs2OTsxMjE7MTM5bT0bWzBtG1szODsyOzExNjsyMDQ7MjM0bSMbWzBtG1szODsyOzExNDsxOTk7MjI2bSobWzBtG1szODsyOzExODsyMDc7MjM0bSMbWzBtG1szODsyOzEwNDsxODE7MjA1bSobWzBtG1szODsyOzI7NTs1bSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtChtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsxMDsyMjszM20gG1swbRtbMzg7Mjs0Mjs4NzsxMzJtLRtbMG0bWzM4OzI7Njc7MTM2OzIwNG09G1swbRtbMzg7Mjs2ODsxMzg7MjA1bT0bWzBtG1szODsyOzExOzIzOzM1bSAbWzBtG1szODsyOzYyOzEyNTsxODNtPRtbMG0bWzM4OzI7NjE7MTIyOzE3OG09G1swbRtbMzg7Mjs5OzE4OzI1bSAbWzBtG1szODsyOzYxOzEyMTsxNzJtPRtbMG0bWzM4OzI7NzU7MTQ3OzIwOW0rG1swbRtbMzg7Mjs3NTsxNDc7MjA3bSsbWzBtG1szODsyOzc4OzE1MTsyMTFtKxtbMG0bWzM4OzI7Nzk7MTUzOzIxMW0rG1swbRtbMzg7Mjs4MDsxNTQ7MjEybSsbWzBtG1szODsyOzgxOzE1NjsyMTNtKxtbMG0bWzM4OzI7ODI7MTU4OzIxM20rG1swbRtbMzg7Mjs4NDsxNTk7MjE0bSsbWzBtG1szODsyOzg0OzE1OTsyMTJtKxtbMG0bWzM4OzI7ODY7MTYzOzIxNm0rG1swbRtbMzg7Mjs2MDsxMTM7MTQ5bS0bWzBtG1szODsyOzIyOzQyOzU1bS4bWzBtG1szODsyOzg5OzE2NjsyMTdtKxtbMG0bWzM4OzI7ODk7MTY2OzIxNW0rG1swbRtbMzg7Mjs5MjsxNzE7MjE5bSobWzBtG1szODsyOzQyOzc4OzEwMG06G1swbRtbMzg7MjsyOTs1Mzs2N20uG1swbRtbMzg7Mjs1Mzs5NzsxMjJtLRtbMG0bWzM4OzI7NjU7MTIwOzE0OW09G1swbRtbMzg7Mjs0Nzs4NzsxMDhtLRtbMG0bWzM4OzI7MzQ7NjI7NzdtOhtbMG0bWzM4OzI7NjE7MTExOzEzNm0tG1swbRtbMzg7Mjs5NjsxNzM7MjExbSobWzBtG1szODsyOzEwMzsxODY7MjI2bSobWzBtG1szODsyOzEwNDsxODg7MjI2bSobWzBtG1szODsyOzEwNTsxODk7MjI3bSobWzBtG1szODsyOzEwNzsxOTE7MjI4bSobWzBtG1szODsyOzEwODsxOTI7MjI5bSobWzBtG1szODsyOzEwMzsxODQ7MjE4bSobWzBtG1szODsyOzQyOzc2Ozg5bTobWzBtG1szODsyOzI1OzQ1OzUybS4bWzBtG1szODsyOzc7MTQ7MTZtIBtbMG0bWzM4OzI7Mzg7Njc7NzhtOhtbMG0bWzM4OzI7MTAyOzE4MDsyMDdtKhtbMG0bWzM4OzI7MTE0OzIwMDsyMzBtKhtbMG0bWzM4OzI7MTE3OzIwNDsyMzJtIxtbMG0bWzM4OzI7MTE4OzIwNzsyMzRtIxtbMG0bWzM4OzI7MTE1OzIwMDsyMjZtKhtbMG0bWzM4OzI7MTQ7MjU7MjhtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDsxOzFtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzE1OzMyOzQ4bS4bWzBtG1szODsyOzUxOzEwNDsxNTVtLRtbMG0bWzM4OzI7MTg7Mzc7NTVtLhtbMG0bWzM4OzI7NDU7OTE7MTMzbS0bWzBtG1szODsyOzE1OzMxOzQ2bS4bWzBtG1szODsyOzUwOzEwMDsxNDRtLRtbMG0bWzM4OzI7NzQ7MTQ2OzIwOG0rG1swbRtbMzg7Mjs3MzsxNDQ7MjA1bSsbWzBtG1szODsyOzc2OzE0OTsyMTBtKxtbMG0bWzM4OzI7Nzg7MTUxOzIxMW0rG1swbRtbMzg7Mjs3OTsxNTM7MjExbSsbWzBtG1szODsyOzgwOzE1NDsyMTJtKxtbMG0bWzM4OzI7ODE7MTU2OzIxM20rG1swbRtbMzg7Mjs4MjsxNTg7MjEzbSsbWzBtG1szODsyOzg0OzE1OTsyMTRtKxtbMG0bWzM4OzI7ODQ7MTU5OzIxMm0rG1swbRtbMzg7Mjs4NjsxNjM7MjE2bSsbWzBtG1szODsyOzYyOzExNzsxNTRtPRtbMG0bWzM4OzI7MjA7Mzc7NDltLhtbMG0bWzM4OzI7OTA7MTY3OzIxOG0rG1swbRtbMzg7Mjs5MDsxNjg7MjE4bSsbWzBtG1szODsyOzMyOzU5Ozc2bTobWzBtG1szODsyOzM0OzYzOzgxbTobWzBtG1szODsyOzk0OzE3NDsyMjFtKhtbMG0bWzM4OzI7OTY7MTc2OzIyMW0qG1swbRtbMzg7Mjs5NzsxNzg7MjIybSobWzBtG1szODsyOzk4OzE3OTsyMjNtKhtbMG0bWzM4OzI7ODc7MTU5OzE5N20rG1swbRtbMzg7Mjs1Mzs5NzsxMTltLRtbMG0bWzM4OzI7MzQ7NjE7NzVtOhtbMG0bWzM4OzI7NTI7OTU7MTE2bS0bWzBtG1szODsyOzkzOzE2ODsyMDNtKxtbMG0bWzM4OzI7OTc7MTc0OzIxMG0qG1swbRtbMzg7Mjs5NTsxNzA7MjAzbSsbWzBtG1szODsyOzgwOzE0MzsxNzBtKxtbMG0bWzM4OzI7MjY7NDc7NTVtLhtbMG0bWzM4OzI7NTk7MTA2OzEyNW0tG1swbRtbMzg7MjsxMTI7MTk4OzIzMW0qG1swbRtbMzg7MjszMDs1NDs2M20uG1swbRtbMzg7Mjs4MDsxNDI7MTY0bT0bWzBtG1szODsyOzExNTsyMDM7MjMzbSMbWzBtG1szODsyOzExMzsxOTk7MjI4bSobWzBtG1szODsyOzExNjsyMDM7MjMxbSMbWzBtG1szODsyOzExOTsyMDg7MjM1bSMbWzBtG1szODsyOzEyMDsyMDk7MjM2bSMbWzBtG1szODsyOzM3OzY0OzcybTobWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzE7MjsybSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtChtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzE7MW0gG1swbRtbMzg7MjswOzE7Mm0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7Mjs1OzEwOzE1bSAbWzBtG1szODsyOzM7Njs5bSAbWzBtG1szODsyOzQ1OzkyOzEzM20tG1swbRtbMzg7Mjs3MzsxNDQ7MjA4bSsbWzBtG1szODsyOzc0OzE0NjsyMDhtKxtbMG0bWzM4OzI7NzQ7MTQ2OzIwOG0rG1swbRtbMzg7Mjs3NDsxNDY7MjA2bSsbWzBtG1szODsyOzc3OzE0OTsyMDltKxtbMG0bWzM4OzI7Nzg7MTUyOzIxMG0rG1swbRtbMzg7Mjs3OTsxNTM7MjExbSsbWzBtG1szODsyOzgwOzE1NDsyMTFtKxtbMG0bWzM4OzI7ODE7MTU2OzIxMW0rG1swbRtbMzg7Mjs4MzsxNTc7MjExbSsbWzBtG1szODsyOzgzOzE1NzsyMDltKxtbMG0bWzM4OzI7ODU7MTYyOzIxNW0rG1swbRtbMzg7Mjs2OTsxMzE7MTcybT0bWzBtG1szODsyOzIyOzQxOzU0bS4bWzBtG1szODsyOzg1OzE1OTsyMDdtKxtbMG0bWzM4OzI7MjM7NDQ7NTdtLhtbMG0bWzM4OzI7NDM7ODE7MTAzbTobWzBtG1szODsyOzkzOzE3MjsyMjBtKhtbMG0bWzM4OzI7OTM7MTcyOzIxOW0qG1swbRtbMzg7Mjs5NDsxNzM7MjE3bSobWzBtG1szODsyOzk1OzE3NTsyMTltKhtbMG0bWzM4OzI7OTY7MTc2OzIyMG0qG1swbRtbMzg7Mjs5OTsxODE7MjI0bSobWzBtG1szODsyOzEwMTsxODM7MjI0bSobWzBtG1szODsyOzk2OzE3MzsyMTFtKhtbMG0bWzM4OzI7NjQ7MTE2OzE0MW09G1swbRtbMzg7MjsyMzs0Mjs1MW0uG1swbRtbMzg7Mjs5OzE3OzIwbSAbWzBtG1szODsyOzU7OTsxMW0gG1swbRtbMzg7Mjs1OzEwOzEybSAbWzBtG1szODsyOzk3OzE3MjsyMDNtKhtbMG0bWzM4OzI7MTEwOzE5NjsyMzBtKhtbMG0bWzM4OzI7MTEyOzE5ODsyMzFtKhtbMG0bWzM4OzI7NDM7NzY7ODhtOhtbMG0bWzM4OzI7NjE7MTA3OzEyNG0tG1swbRtbMzg7MjsxMTU7MjAyOzIzM20jG1swbRtbMzg7MjsxMTY7MjA0OzIzNG0jG1swbRtbMzg7MjsxMTg7MjA2OzIzNG0jG1swbRtbMzg7MjsxMDk7MTkxOzIxNm0qG1swbRtbMzg7Mjs3NjsxMzI7MTQ5bT0bWzBtG1szODsyOzE4OzMzOzM3bS4bWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtChtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzE7Mm0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsxNzszNDs1MG0uG1swbRtbMzg7MjszNzs3NDsxMDdtOhtbMG0bWzM4OzI7NjE7MTIxOzE3Mm09G1swbRtbMzg7Mjs3NTsxNDc7MjA5bSsbWzBtG1szODsyOzc2OzE0OTsyMTBtKxtbMG0bWzM4OzI7Nzg7MTUxOzIxMW0rG1swbRtbMzg7Mjs3OTsxNTM7MjExbSsbWzBtG1szODsyOzgwOzE1NDsyMTJtKxtbMG0bWzM4OzI7ODE7MTU2OzIxM20rG1swbRtbMzg7Mjs4MjsxNTg7MjEzbSsbWzBtG1szODsyOzg0OzE1OTsyMTRtKxtbMG0bWzM4OzI7ODU7MTYxOzIxNW0rG1swbRtbMzg7Mjs4NjsxNjM7MjE2bSsbWzBtG1szODsyOzQ2Ozg4OzExNm0tG1swbRtbMzg7MjsxMjsyMzszMG0gG1swbRtbMzg7MjsxOTszNzs0OG0uG1swbRtbMzg7Mjs1NDsxMDI7MTMybS0bWzBtG1szODsyOzkyOzE3MTsyMTltKhtbMG0bWzM4OzI7OTA7MTY4OzIxM20rG1swbRtbMzg7Mjs5MzsxNzI7MjE5bSobWzBtG1szODsyOzk2OzE3NjsyMjFtKhtbMG0bWzM4OzI7OTY7MTc3OzIyMW0qG1swbRtbMzg7Mjs5NzsxNzg7MjIybSobWzBtG1szODsyOzk3OzE3ODsyMjFtKhtbMG0bWzM4OzI7OTg7MTc4OzIxOG0qG1swbRtbMzg7MjsxMDI7MTg0OzIyNW0qG1swbRtbMzg7MjsxMDM7MTg2OzIyNm0qG1swbRtbMzg7MjsxOTszNjs0M20uG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsxMDsxODsyMW0gG1swbRtbMzg7Mjs1NDs5NzsxMTRtLRtbMG0bWzM4OzI7Nzg7MTM5OzE2M209G1swbRtbMzg7MjsxMDg7MTkxOzIyM20qG1swbRtbMzg7Mjs1MDs5MDsxMDVtLRtbMG0bWzM4OzI7Mzg7Njg7NzhtOhtbMG0bWzM4OzI7MTA3OzE4OTsyMThtKhtbMG0bWzM4OzI7ODU7MTUwOzE3Mm0rG1swbRtbMzg7Mjs0Njs4MDs5MW06G1swbRtbMzg7MjsxMTsxOTsyMm0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbQobWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDsxOzJtIBtbMG0bWzM4OzI7MTc7MzQ7NDltLhtbMG0bWzM4OzI7NDI7ODI7MTE2bTobWzBtG1szODsyOzY2OzEyOTsxODFtPRtbMG0bWzM4OzI7Nzg7MTUxOzIwOG0rG1swbRtbMzg7Mjs3NjsxNDY7MjAybSsbWzBtG1szODsyOzcxOzEzODsxODhtPRtbMG0bWzM4OzI7NjY7MTI4OzE3NG09G1swbRtbMzg7Mjs1OTsxMTQ7MTU0bT0bWzBtG1szODsyOzUzOzEwMTsxMzVtLRtbMG0bWzM4OzI7MzI7NjA7ODBtOhtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7NjM7MTE4OzE1Mm09G1swbRtbMzg7Mjs5MjsxNzE7MjE5bSobWzBtG1szODsyOzkzOzE3MzsyMjBtKhtbMG0bWzM4OzI7OTQ7MTc0OzIyMW0qG1swbRtbMzg7Mjs5NTsxNzQ7MjE5bSobWzBtG1szODsyOzk3OzE3ODsyMjJtKhtbMG0bWzM4OzI7OTg7MTc5OzIyM20qG1swbRtbMzg7Mjs5OTsxODE7MjI0bSobWzBtG1szODsyOzEwMTsxODM7MjI0bSobWzBtG1szODsyOzY3OzEyMTsxNDltPRtbMG0bWzM4OzI7Mjc7NTA7NjFtLhtbMG0bWzM4OzI7NTc7MTA0OzEyNm0tG1swbRtbMzg7Mjs4MDsxNDU7MTc0bSsbWzBtG1szODsyOzc2OzEzNzsxNjNtPRtbMG0bWzM4OzI7OTk7MTc3OzIxMG0qG1swbRtbMzg7Mjs4MDsxNDM7MTY4bT0bWzBtG1szODsyOzU1Ozk4OzExNW0tG1swbRtbMzg7MjsyMjs0MDs0Nm0uG1swbRtbMzg7Mjs0Ozc7OW0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7Mjs5OzE2OzE5bSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzE7MjsybSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtChtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzE7MW0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzE7MW0gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsyOzQ7NW0gG1swbRtbMzg7MjsxMjsyMzszMm0gG1swbRtbMzg7Mjs3OzE1OzIwbSAbWzBtG1szODsyOzM7Njs4bSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzE7MTsybSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzEzOzI1OzMybSAbWzBtG1szODsyOzM3OzY4Ozg5bTobWzBtG1szODsyOzM5OzczOzkzbTobWzBtG1szODsyOzYwOzExMTsxNDJtLRtbMG0bWzM4OzI7ODU7MTU3OzIwMG0rG1swbRtbMzg7Mjs5NjsxNzY7MjIxbSobWzBtG1szODsyOzkyOzE2OTsyMTFtKxtbMG0bWzM4OzI7OTU7MTc0OzIxN20qG1swbRtbMzg7Mjs4MTsxNDY7MTgxbSsbWzBtG1szODsyOzMyOzU5OzcybTobWzBtG1szODsyOzQwOzcyOzg4bTobWzBtG1szODsyOzg4OzE1OTsxOTRtKxtbMG0bWzM4OzI7MTA0OzE4ODsyMjZtKhtbMG0bWzM4OzI7MTA1OzE4OTsyMjdtKhtbMG0bWzM4OzI7MTA3OzE5MTsyMjhtKhtbMG0bWzM4OzI7MTA4OzE5MzsyMjltKhtbMG0bWzM4OzI7MTA5OzE5NDsyMjltKhtbMG0bWzM4OzI7MTEwOzE5NjsyMzBtKhtbMG0bWzM4OzI7NTg7MTAzOzEyMW0tG1swbRtbMzg7MjsxOzM7M20gG1swbRtbMzg7MjsxOzI7Mm0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsxOzM7M20gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbQobWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDsxOzJtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDsxOzFtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDsxOzJtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MTszOzVtIBtbMG0bWzM4OzI7MTsyOzNtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDsxOzFtIBtbMG0bWzM4OzI7NTsxMDsxM20gG1swbRtbMzg7Mjs3NDsxMzk7MTgwbT0bWzBtG1szODsyOzc2OzE0MjsxODJtPRtbMG0bWzM4OzI7NTI7OTc7MTIzbS0bWzBtG1szODsyOzM1OzY2Ozg0bTobWzBtG1szODsyOzI4OzUxOzY1bS4bWzBtG1szODsyOzEyOzIyOzI3bSAbWzBtG1szODsyOzE0OzI1OzMybSAbWzBtG1szODsyOzE5OzM1OzQzbS4bWzBtG1szODsyOzc3OzEzOTsxNzFtPRtbMG0bWzM4OzI7MTAyOzE4NDsyMjVtKhtbMG0bWzM4OzI7MTAzOzE4NjsyMjZtKhtbMG0bWzM4OzI7MTAyOzE4NTsyMjJtKhtbMG0bWzM4OzI7MTAzOzE4NjsyMjRtKhtbMG0bWzM4OzI7MTA1OzE4ODsyMjRtKhtbMG0bWzM4OzI7MTA2OzE4OTsyMjVtKhtbMG0bWzM4OzI7MTA2OzE4OTsyMjNtKhtbMG0bWzM4OzI7MTA2OzE4OTsyMjJtKhtbMG0bWzM4OzI7MTEyOzE5ODsyMzFtKhtbMG0bWzM4OzI7NzU7MTMyOzE1NG09G1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsxOzM7M20gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbQobWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7Mjs0OzVtIBtbMG0bWzM4OzI7OTsxODsyNW0gG1swbRtbMzg7Mjs2OzEyOzE2bSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzU7MTA7MTRtIBtbMG0bWzM4OzI7NDs4OzExbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MTsybSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzU7MTE7MTVtIBtbMG0bWzM4OzI7NjsxMjsxNm0gG1swbRtbMzg7Mjs2OzEyOzE2bSAbWzBtG1szODsyOzY7MTI7MTZtIBtbMG0bWzM4OzI7NTsxMDsxNG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7Mjs1OzEwOzE0bSAbWzBtG1szODsyOzU7MTA7MTRtIBtbMG0bWzM4OzI7MDsxOzFtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7ODsxNTsyMW0gG1swbRtbMzg7MjsxMTsyMjszMG0gG1swbRtbMzg7Mjs0Ozc7MTBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDsxOzFtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MTc7MzI7NDFtLhtbMG0bWzM4OzI7OTI7MTcxOzIxOW0qG1swbRtbMzg7Mjs5MzsxNzM7MjIwbSobWzBtG1szODsyOzkyOzE2ODsyMTRtKxtbMG0bWzM4OzI7OTsxNzsyMW0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsyMTszODs0N20uG1swbRtbMzg7Mjs5NzsxNzc7MjE2bSobWzBtG1szODsyOzEwMjsxODQ7MjI1bSobWzBtG1szODsyOzEwMzsxODY7MjI2bSobWzBtG1szODsyOzEwNDsxODg7MjI2bSobWzBtG1szODsyOzEwNDsxODc7MjI1bSobWzBtG1szODsyOzEwNzsxOTE7MjI4bSobWzBtG1szODsyOzEwODsxOTM7MjI5bSobWzBtG1szODsyOzEwOTsxOTQ7MjI5bSobWzBtG1szODsyOzExMDsxOTY7MjMwbSobWzBtG1szODsyOzEwMjsxODA7MjExbSobWzBtG1szODsyOzYyOzExMDsxMjhtLRtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MTsyOzJtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzM7Njs4bSAbWzBtG1szODsyOzQ0Ozg2OzExOG0tG1swbRtbMzg7Mjs3NDsxNDM7MTk2bSsbWzBtG1szODsyOzc1OzE0NTsxOTltKxtbMG0bWzM4OzI7NzY7MTQ4OzIwMm0rG1swbRtbMzg7Mjs2NTsxMjc7MTc0bT0bWzBtG1szODsyOzI0OzQ2OzY0bS4bWzBtG1szODsyOzE7Mzs0bSAbWzBtG1szODsyOzcyOzE0MDsxOTJtPRtbMG0bWzM4OzI7NjE7MTE4OzE2Mm09G1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7Mjs3OzE1OzIwbSAbWzBtG1szODsyOzcyOzE0MTsxOTJtPRtbMG0bWzM4OzI7NzQ7MTQ1OzE5OG0rG1swbRtbMzg7Mjs3NDsxNDU7MTk4bSsbWzBtG1szODsyOzc0OzE0NTsxOThtKxtbMG0bWzM4OzI7NzQ7MTQ1OzE5OG0rG1swbRtbMzg7Mjs2ODsxMzM7MTgybT0bWzBtG1szODsyOzM2OzcwOzk2bTobWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzE7Mjs0bSAbWzBtG1szODsyOzY2OzEyODsxNzVtPRtbMG0bWzM4OzI7Njk7MTMzOzE4Mm09G1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjsxNDsyNzszOG0gG1swbRtbMzg7Mjs1ODsxMTQ7MTU2bT0bWzBtG1szODsyOzcxOzEzODsxODltPRtbMG0bWzM4OzI7NzM7MTQxOzE5M209G1swbRtbMzg7Mjs3NzsxNDk7MjA0bSsbWzBtG1szODsyOzU2OzEwOTsxNDltLRtbMG0bWzM4OzI7ODsxNjsyMm0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7Mjs0Nzs4ODsxMTNtLRtbMG0bWzM4OzI7OTM7MTcyOzIyMG0qG1swbRtbMzg7Mjs5NDsxNzI7MjE5bSobWzBtG1szODsyOzg3OzE2MDsyMDFtKxtbMG0bWzM4OzI7NjM7MTE1OzE0NG09G1swbRtbMzg7MjsyOTs1NDs2OG0uG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7Mjs3OzE0OzE3bSAbWzBtG1szODsyOzM3OzY3OzgybTobWzBtG1szODsyOzcyOzEzMTsxNTltPRtbMG0bWzM4OzI7OTk7MTgwOzIxN20qG1swbRtbMzg7MjsxMDU7MTg5OzIyN20qG1swbRtbMzg7Mjs5OTsxNzg7MjEybSobWzBtG1szODsyOzgwOzE0NDsxNzFtKxtbMG0bWzM4OzI7NTQ7OTc7MTE0bS0bWzBtG1szODsyOzI4OzUwOzU5bS4bWzBtG1szODsyOzc7MTM7MTZtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsybSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzQ3OzkyOzEyNm0tG1swbRtbMzg7Mjs4MDsxNTU7MjEybSsbWzBtG1szODsyOzQ2Ozg5OzEyM20tG1swbRtbMzg7MjsxMTsyMTsyOW0gG1swbRtbMzg7MjsyMzs0NDs2MW0uG1swbRtbMzg7Mjs1MjsxMDA7MTM4bS0bWzBtG1szODsyOzI3OzUyOzcybS4bWzBtG1szODsyOzI7NTs3bSAbWzBtG1szODsyOzc5OzE1NDsyMTFtKxtbMG0bWzM4OzI7NjY7MTI4OzE3Nm09G1swbRtbMzg7MjsxMTsyMzszMW0gG1swbRtbMzg7MjsyMTs0MTs1N20uG1swbRtbMzg7MjsxMjsyMzszMm0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7Mjs3OzE1OzIwbSAbWzBtG1szODsyOzgwOzE1NTsyMTJtKxtbMG0bWzM4OzI7Njg7MTMyOzE4MW09G1swbRtbMzg7Mjs2OzEzOzE4bSAbWzBtG1szODsyOzY7MTM7MThtIBtbMG0bWzM4OzI7MTI7MjM7MzJtIBtbMG0bWzM4OzI7NzI7MTM5OzE5MW09G1swbRtbMzg7Mjs4MDsxNTU7MjEybSsbWzBtG1szODsyOzEyOzI0OzM0bSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzczOzE0MTsxOTNtPRtbMG0bWzM4OzI7NzU7MTQ3OzIwMW0rG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7Mjs0OTs5NjsxMzFtLRtbMG0bWzM4OzI7ODA7MTU1OzIxMm0rG1swbRtbMzg7Mjs0ODs5NDsxMjhtLRtbMG0bWzM4OzI7MTQ7Mjc7MzdtIBtbMG0bWzM4OzI7Mjk7NTc7NzhtOhtbMG0bWzM4OzI7Mzc7NzM7MTAwbTobWzBtG1szODsyOzk7MTg7MjRtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MTsyOzJtIBtbMG0bWzM4OzI7Mjs1OzZtIBtbMG0bWzM4OzI7Nzg7MTQ1OzE4NG0rG1swbRtbMzg7Mjs5MzsxNzM7MjIwbSobWzBtG1szODsyOzk2OzE3NjsyMjFtKhtbMG0bWzM4OzI7OTc7MTc4OzIyMm0qG1swbRtbMzg7Mjs5MjsxNjk7MjEwbSsbWzBtG1szODsyOzExOzIwOzI1bSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzE0OzI1OzMxbSAbWzBtG1szODsyOzI4OzUxOzYxbS4bWzBtG1szODsyOzk7MTY7MTltIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzI7NTs3bSAbWzBtG1szODsyOzc0OzE0MzsxOTZtKxtbMG0bWzM4OzI7NzY7MTQ4OzIwMm0rG1swbRtbMzg7MjsyOzU7N20gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7Mjs0Ozk7MTNtIBtbMG0bWzM4OzI7NzQ7MTQ0OzE5N20rG1swbRtbMzg7Mjs3NzsxNTA7MjA1bSsbWzBtG1szODsyOzY2OzEyODsxNzVtPRtbMG0bWzM4OzI7NzM7MTQyOzE5NG0rG1swbRtbMzg7Mjs3ODsxNTI7MjA4bSsbWzBtG1szODsyOzM2OzcxOzk3bTobWzBtG1szODsyOzQ7ODsxMW0gG1swbRtbMzg7Mjs3ODsxNTI7MjA4bSsbWzBtG1szODsyOzc0OzE0NDsxOTdtKxtbMG0bWzM4OzI7NTA7OTc7MTMzbS0bWzBtG1szODsyOzQ5Ozk1OzEzMG0tG1swbRtbMzg7Mjs0Nzs5MTsxMjRtLRtbMG0bWzM4OzI7NzQ7MTQ1OzE5OG0rG1swbRtbMzg7Mjs2NDsxMjQ7MTcwbT0bWzBtG1szODsyOzU7MTA7MTRtIBtbMG0bWzM4OzI7MDsxOzJtIBtbMG0bWzM4OzI7NzA7MTM3OzE4N209G1swbRtbMzg7Mjs3MzsxNDI7MTk0bSsbWzBtG1szODsyOzE7Mzs0bSAbWzBtG1szODsyOzc7MTQ7MTltIBtbMG0bWzM4OzI7NDg7OTM7MTI4bS0bWzBtG1szODsyOzcyOzE0MDsxOTJtPRtbMG0bWzM4OzI7NzQ7MTQ0OzE5N20rG1swbRtbMzg7Mjs2MDsxMTc7MTYwbT0bWzBtG1szODsyOzMxOzYwOzgzbTobWzBtG1szODsyOzI7NTs3bSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzE7MjsybSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzIyOzQyOzUzbS4bWzBtG1szODsyOzk0OzE3NDsyMjFtKhtbMG0bWzM4OzI7OTM7MTcxOzIxNG0qG1swbRtbMzg7Mjs5MjsxNzA7MjEybSsbWzBtG1szODsyOzk3OzE3ODsyMjJtKhtbMG0bWzM4OzI7Njk7MTI3OzE1OG09G1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsyOzQ7NW0gG1swbRtbMzg7MjsxOzI7Mm0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzE7MW0gG1swbRtbMzg7MjsxOzM7M20gG1swbRtbMzg7MjsxOzI7Mm0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbQobWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MTsyOzNtIBtbMG0bWzM4OzI7NjY7MTI4OzE3NW09G1swbRtbMzg7Mjs4MDsxNTU7MjEybSsbWzBtG1szODsyOzE5OzM3OzUxbS4bWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsybSAbWzBtG1szODsyOzE5OzM3OzUxbS4bWzBtG1szODsyOzEwOzIwOzI3bSAbWzBtG1szODsyOzM7Nzs5bSAbWzBtG1szODsyOzc1OzE0NjsyMDBtKxtbMG0bWzM4OzI7Njk7MTM1OzE4NW09G1swbRtbMzg7MjsyOzU7N20gG1swbRtbMzg7MjsxMDsxOTsyNm0gG1swbRtbMzg7Mjs3OTsxNTM7MjA5bSsbWzBtG1szODsyOzYxOzExOTsxNjJtPRtbMG0bWzM4OzI7NTsxMDsxNW0gG1swbRtbMzg7Mjs3NzsxNTA7MjA2bSsbWzBtG1szODsyOzc0OzE0MzsxOTZtKxtbMG0bWzM4OzI7NDc7OTE7MTI1bS0bWzBtG1szODsyOzU3OzExMTsxNTJtLRtbMG0bWzM4OzI7ODA7MTU1OzIxMm0rG1swbRtbMzg7Mjs2ODsxMzM7MTgybT0bWzBtG1szODsyOzI7NDs2bSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzE7Mzs1bSAbWzBtG1szODsyOzY5OzEzNDsxODRtPRtbMG0bWzM4OzI7NzE7MTM5OzE5MG09G1swbRtbMzg7MjsyOzQ7Nm0gG1swbRtbMzg7MjsxNTszMDs0MW0uG1swbRtbMzg7MjsyNDs0Njs2NG0uG1swbRtbMzg7Mjs2OzEyOzE2bSAbWzBtG1szODsyOzEzOzI2OzM2bSAbWzBtG1szODsyOzQ0Ozg1OzExN20tG1swbRtbMzg7Mjs4MDsxNTU7MjEybSsbWzBtG1szODsyOzU2OzEwODsxNDhtLRtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDsxOzJtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MTsyOzNtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7NTU7MTAxOzEyOW0tG1swbRtbMzg7Mjs5NjsxNzY7MjIxbSobWzBtG1szODsyOzk3OzE3ODsyMjJtKhtbMG0bWzM4OzI7OTg7MTc5OzIyM20qG1swbRtbMzg7MjsxMDA7MTgxOzIyNG0qG1swbRtbMzg7Mjs0OTs4ODsxMDhtLRtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MTsyOzJtIBtbMG0bWzM4OzI7MDsxOzFtIBtbMG0bWzM4OzI7MTsyOzJtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsybSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzIyOzQzOzU5bS4bWzBtG1szODsyOzc1OzE0NTsxOTltKxtbMG0bWzM4OzI7ODA7MTU1OzIxMm0rG1swbRtbMzg7Mjs1NjsxMTA7MTUwbS0bWzBtG1szODsyOzY4OzEzMTsxODBtPRtbMG0bWzM4OzI7ODA7MTU1OzIxMm0rG1swbRtbMzg7MjszNzs3MzsxMDBtOhtbMG0bWzM4OzI7MTszOzRtIBtbMG0bWzM4OzI7ODA7MTU1OzIxMm0rG1swbRtbMzg7Mjs2OTsxMzU7MTg1bT0bWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzY7MTI7MTZtIBtbMG0bWzM4OzI7ODA7MTU1OzIxMm0rG1swbRtbMzg7Mjs2NDsxMjQ7MTcwbT0bWzBtG1szODsyOzU7MTA7MTVtIBtbMG0bWzM4OzI7ODA7MTU1OzIxMm0rG1swbRtbMzg7Mjs2OTsxMzQ7MTg0bT0bWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzQ5Ozk2OzEzMW0tG1swbRtbMzg7Mjs4MDsxNTU7MjEybSsbWzBtG1szODsyOzQ1Ozg4OzEyMG0tG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjsxOzM7NW0gG1swbRtbMzg7Mjs3NjsxNDc7MjAybSsbWzBtG1szODsyOzc5OzE1MzsyMDltKxtbMG0bWzM4OzI7MDsxOzJtIBtbMG0bWzM4OzI7NDI7ODI7MTEzbTobWzBtG1szODsyOzgwOzE1NTsyMTJtKxtbMG0bWzM4OzI7Njg7MTMzOzE4Mm09G1swbRtbMzg7Mjs0OTs5NTsxMzBtLRtbMG0bWzM4OzI7NTk7MTE1OzE1N209G1swbRtbMzg7Mjs4MDsxNTU7MjEybSsbWzBtG1szODsyOzQyOzgyOzExM206G1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzE7Mm0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7Mjs0Ozg7MTBtIBtbMG0bWzM4OzI7MzY7NjY7ODNtOhtbMG0bWzM4OzI7MzY7Njc7ODRtOhtbMG0bWzM4OzI7MzY7Njc7ODNtOhtbMG0bWzM4OzI7Mzc7Njg7ODRtOhtbMG0bWzM4OzI7MzQ7NjM7NzdtOhtbMG0bWzM4OzI7MDsxOzFtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzk7MTg7MjVtIBtbMG0bWzM4OzI7MzM7NjQ7ODhtOhtbMG0bWzM4OzI7NDY7ODk7MTIzbS0bWzBtG1szODsyOzQwOzc3OzEwNm06G1swbRtbMzg7MjsxNzszMzs0NW0uG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsxOzM7NG0gG1swbRtbMzg7MjszNDs2Njs5MW06G1swbRtbMzg7MjsyOTs1Nzs3OG06G1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjszOzY7OG0gG1swbRtbMzg7MjszNTs2ODs5M206G1swbRtbMzg7MjsyNjs1Mjs3MW0uG1swbRtbMzg7MjsyOzQ7Nm0gG1swbRtbMzg7MjszNTs2OTs5NG06G1swbRtbMzg7MjsyOTs1Nzs3OG06G1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjswOzE7MW0gG1swbRtbMzg7MjsyOzQ7NW0gG1swbRtbMzg7MjszMzs2NTs4OW06G1swbRtbMzg7MjszNzs3MTs5OG06G1swbRtbMzg7Mjs0Ozc7MTBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MzE7NjA7ODNtOhtbMG0bWzM4OzI7MzI7NjI7ODVtOhtbMG0bWzM4OzI7MDsxOzJtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MTU7Mjk7MzltLhtbMG0bWzM4OzI7Mzk7NzY7MTA0bTobWzBtG1szODsyOzQ4OzkzOzEyOG0tG1swbRtbMzg7Mjs0Mjs4MjsxMTJtOhtbMG0bWzM4OzI7MTk7Mzc7NTFtLhtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzE7MjsybSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtChtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzE7MW0gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjswOzE7Mm0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjswOzE7Mm0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjswOzE7Mm0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjswOzE7Mm0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzE7MW0gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjsxOzI7M20gG1swbRtbMzg7MjswOzE7Mm0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbQobWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtCg==",OO=/\x1b\[[0-9;]*m/g,U_="\x1B[0m",$_="\x1B[7m",dy=atob(xO).trimEnd().split(`
|
|
@@ -58,7 +58,7 @@ ${s.join(`
|
|
|
58
58
|
|
|
59
59
|
`)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()};let o;const a=Nl,l=!Li.jitless,h=l&&YO.value,d=e.catchall;let u;t._zod.parse=(p,f)=>{u??(u=i.value);const _=p.value;return a(_)?l&&h&&f?.async===!1&&f.jitless!==!0?(o||(o=r(e.shape)),p=o(p,f),d?By([],_,p,f,u,t,f?.abortEarly===!0):p):s(p,f):(p.issues.push({expected:"object",code:"invalid_type",input:_,inst:t}),p)}});function eb(t,e,s,i){for(const r of t)if(r.issues.length===0)return e.value=r.value,e;const n=t.filter(r=>!Qi(r));return n.length===1?(e.value=n[0].value,n[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:s,errors:t.map(r=>r.issues.map(o=>Ir(o,i,wn())))}),e)}const Gy=le("$ZodUnion",(t,e)=>{Ut.init(t,e),bt(t,"optin",i=>i.def.options.some(n=>n._zod.optin==="defaulted")?"defaulted":i.def.options.some(n=>n._zod.optin!==void 0)?"optional":void 0),bt(t,"optout",i=>i.def.options.some(n=>n._zod.optout==="optional")?"optional":void 0),bt(t,"values",i=>{if(i.def.options.every(n=>n._zod.values))return new Set(i.def.options.flatMap(n=>Array.from(n._zod.values)))}),bt(t,"pattern",i=>{if(i.def.options.every(n=>n._zod.pattern)){const n=i.def.options.map(r=>r._zod.pattern);return new RegExp(`^(${n.map(r=>lg(r.source)).join("|")})$`)}});const s=e.options.length===1?e.options[0]._zod.run:null;t._zod.parse=(i,n)=>{if(s)return s(i,n);let r=!1;const o=[];for(const a of e.options){const l=a._zod.run({value:i.value,issues:[]},n);if(l instanceof Promise)o.push(l),r=!0;else{if(l.issues.length===0)return l;o.push(l)}}return r?Promise.all(o).then(a=>eb(a,i,t,n)):eb(o,i,t,n)}});function mT(t){const e=new Map;for(const s of t.options){const i=s._zod.propValues?.[t.discriminator];if(!i||i.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const n of i)if(e.has(n)){if(n!==void 0)throw new Error(`Duplicate discriminator value "${String(n)}"`);e.set(n,null)}else e.set(n,s)}return e}const gT=le("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,Gy.init(t,e);const s=t._zod.parse;bt(t,"propValues",n=>{const r={};let o=0;for(const a of n.def.options){const l=a._zod.propValues;if(!l||Object.keys(l).length===0)throw new Error(`Invalid discriminated union option at index "${n.def.options.indexOf(a)}"`);l[n.def.discriminator]?.has(void 0)&&o++;for(const[c,h]of Object.entries(l)){Object.prototype.hasOwnProperty.call(r,c)||Yn(r,c,new Set);for(const d of h)r[c].add(d)}}return!n.def.unionFallback&&o>1&&r[n.def.discriminator]?.delete(void 0),r}),e.options.forEach((n,r)=>{const o=cg(n._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,e.discriminator))throw new Error(`Invalid discriminated union option at index "${r}"`)});const i=yd(()=>mT(e));t._zod.parse=(n,r)=>{const o=n.value;if(!Nl(o))return n.issues.push({code:"invalid_type",expected:"object",input:o,inst:t}),n;const a=o?.[e.discriminator],l=i.value.get(a);return l&&(a!==void 0||r.direction!=="backward")?l._zod.run(n,r):e.unionFallback||r.direction==="backward"?s(n,r):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,options:Array.from(i.value.keys()).filter(c=>i.value.get(c)!==null),input:o,path:[e.discriminator],inst:t}),n)}}),_T=le("$ZodIntersection",(t,e)=>{Ut.init(t,e),t._zod.parse=(s,i)=>{const n=s.value,r=e.left._zod.run({value:n,issues:[]},i),o=e.right._zod.run({value:n,issues:[]},i);return r instanceof Promise||o instanceof Promise?Promise.all([r,o]).then(([l,c])=>tb(s,l,c)):tb(s,r,o)}});function qf(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(la(t)&&la(e)){const s=Object.keys(e),i=Object.keys(t).filter(r=>s.indexOf(r)!==-1),n={...t,...e};Object.prototype.hasOwnProperty.call(n,"__proto__")&&delete n.__proto__;for(const r of i){if(r==="__proto__")continue;const o=qf(t[r],e[r]);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n[r]=o.data}return{valid:!0,data:n}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const s=[];for(let i=0;i<t.length;i++){const n=t[i],r=e[i],o=qf(n,r);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};s.push(o.data)}return{valid:!0,data:s}}return{valid:!1,mergeErrorPath:[]}}function tb(t,e,s){const i=new Map;let n;const r=new Map,o=(c,h)=>{let d;if(c.code==="unrecognized_keys"&&!c.path?.length)n??(n=c),d=c.keys;else if(c.code==="invalid_key"&&c.origin==="record"&&c.path?.length===1){const u=String(c.path[0]);r.has(u)||r.set(u,c),d=[u]}else return!1;for(const u of d)i.has(u)||i.set(u,{}),i.get(u)[h]=!0;return!0};for(const c of e.issues)o(c,"l")||t.issues.push(c);for(const c of s.issues)o(c,"r")||t.issues.push(c);const a=[...i].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(a.length){const c=n?a.filter(h=>n.keys.includes(h)):[];c.length&&t.issues.push({...n,keys:c});for(const h of a)!c.includes(h)&&r.has(h)&&t.issues.push(r.get(h))}const l=qf(e.value,s.value);if(!l.valid){if(Qi(t))return t;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(l.mergeErrorPath)}`)}return t.value=l.data,t}const bT=le("$ZodTuple",(t,e)=>{Ut.init(t,e);const s=e.items,i=Li.memoizer;i?.attach(t),t._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({input:o,inst:t,expected:"tuple",code:"invalid_type"}),n;n.value=i?i.alloc(t,n,[],r):[];const a=[],l=sb(s,"optin"),c=sb(s,"optout");if(!e.rest){if(o.length<l)return n.issues.push({code:"too_small",minimum:l,inclusive:!0,input:o,inst:t,origin:"array"}),n;o.length>s.length&&n.issues.push({code:"too_big",maximum:s.length,inclusive:!0,input:o,inst:t,origin:"array"})}const h=new Array(s.length),d=e.rest?r?.abortEarly:void 0;let u=!1;for(let p=0;p<s.length;p++){const f=s[p]._zod.run({value:o[p],issues:[]},r);f instanceof Promise?a.push(f.then(_=>{h[p]=_})):(h[p]=f,d&&!u&&f.issues.length&&(u=Qi(f)))}if(e.rest&&!u){let p=s.length-1;const f=o.slice(s.length);let _=n.issues.length;for(const g of f){if(d&&n.issues.length!==_){if(Qi(n,_))break;_=n.issues.length}p++;const m=e.rest._zod.run({value:g,issues:[]},r);m instanceof Promise?a.push(m.then(v=>ib(v,n,p))):ib(m,n,p)}}return a.length?Promise.all(a).then(()=>nb(h,n,s,o,c)):nb(h,n,s,o,c)}});function sb(t,e){for(let s=t.length-1;s>=0;s--)if(!(e==="optin"?t[s]._zod.optin!==void 0:t[s]._zod.optout==="optional"))return s+1;return 0}function ib(t,e,s){t.issues.length&&e.issues.push(...br(s,t.issues)),e.value[s]=t.value}function nb(t,e,s,i,n){for(let r=0;r<s.length;r++){const o=t[r],a=r<i.length;if(!a&&r>=n&&s[r]._zod.optin==="optional"){e.value.length=r;break}if(o.issues.length){if(!a&&r>=n){e.value.length=r;break}e.issues.push(...br(r,o.issues))}e.value[r]=o.value}for(let r=e.value.length-1;r>=i.length&&(s[r]._zod.optout==="optional"&&e.value[r]===void 0);r--)e.value.length=r;return e}const MT=le("$ZodRecord",(t,e)=>{Ut.init(t,e);const s=Li.memoizer;s?.attach(t),t._zod.parse=(i,n)=>{const r=i.value;if(!la(r))return i.issues.push({expected:"record",code:"invalid_type",input:r,inst:t}),i;const o=[],a=e.keyType._zod.values;if(a&&!e.partial){i.value=s?s.alloc(t,i,{},n):{};const l=new Set;for(const h of a)if(typeof h=="string"||typeof h=="number"||typeof h=="symbol"){if(l.add(typeof h=="number"?h.toString():h),h==="__proto__")continue;const d=e.keyType._zod.run({value:h,issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(f=>Ir(f,n,wn())),input:h,path:[h],inst:t});continue}const u=d.value;if(u==="__proto__")continue;const p=e.valueType._zod.run({value:r[h],issues:[]},n);p instanceof Promise?o.push(p.then(f=>{f.issues.length&&i.issues.push(...br(h,f.issues)),i.value[u]=f.value})):(p.issues.length&&i.issues.push(...br(h,p.issues)),i.value[u]=p.value)}let c;for(const h in r)if(!l.has(h))if(e.mode==="loose"){if(h==="__proto__")continue;i.value[h]=r[h]}else c=c??[],c.push(h);c&&c.length>0&&i.issues.push({code:"unrecognized_keys",input:r,inst:t,keys:c,continue:!0})}else{i.value=s?s.alloc(t,i,{},n):{};let l;for(const c of Reflect.ownKeys(r)){if(c==="__proto__"||!Object.prototype.propertyIsEnumerable.call(r,c))continue;let h=e.keyType._zod.run({value:c,issues:[]},n);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&gg.test(c)&&h.issues.length){const f=e.keyType._zod.run({value:Number(c),issues:[]},n);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(h=f)}if(h.issues.length){e.mode==="loose"?i.value[c]=r[c]:a?(l=l??[],l.push(c)):i.issues.push({code:"invalid_key",origin:"record",issues:h.issues.map(f=>Ir(f,n,wn())),input:c,path:[c],inst:t});continue}const u=h.value;if(u==="__proto__")continue;const p=e.valueType._zod.run({value:r[c],issues:[]},n);p instanceof Promise?o.push(p.then(f=>{f.issues.length&&i.issues.push(...br(c,f.issues)),i.value[u]=f.value})):(p.issues.length&&i.issues.push(...br(c,p.issues)),i.value[u]=p.value)}l&&l.length>0&&i.issues.push({code:"unrecognized_keys",input:r,inst:t,keys:l,continue:!0})}return o.length?Promise.all(o).then(()=>i):i}}),vT=le("$ZodEnum",(t,e)=>{Ut.init(t,e);const s=$f(e.entries),i=new Set(s);t._zod.values=i,bt(t,"pattern",n=>{const r=$f(n.def.entries).filter(o=>XO.has(typeof o));return new RegExp(r.length?`^(${r.map(o=>ca(o.toString())).join("|")})$`:"^[^\\s\\S]$")}),t._zod.parse=(n,r)=>{const o=n.value;return i.has(o)||n.issues.push({code:"invalid_value",values:s,input:o,inst:t}),n}}),wT=le("$ZodLiteral",(t,e)=>{Ut.init(t,e);const s=new Set(e.values);t._zod.values=s,bt(t,"pattern",i=>{const n=i.def.values;return new RegExp(n.length?`^(${n.map(r=>typeof r=="string"?ca(r):r?ca(r.toString()):String(r)).join("|")})$`:"^[^\\s\\S]$")}),t._zod.parse=(i,n)=>{const r=i.value;return s.has(r)||i.issues.push({code:"invalid_value",values:e.values,input:r,inst:t}),i}}),yT=le("$ZodTransform",(t,e)=>{Ut.init(t,e),t._zod.optin="optional",Li.memoizer?.guard(t),t._zod.parse=(s,i)=>{if(i.direction==="backward")throw new yy(t.constructor.name);const n=e.transform(s.value,s);if(i.async)return(n instanceof Promise?n:Promise.resolve(n)).then(o=>(s.value=o,s));if(n instanceof Promise)throw new ro;return s.value=n,s}});function rb(t,e){return t.value=e.issues.length?void 0:e.value,t}const Py=le("$ZodOptional",(t,e)=>{Ut.init(t,e),bt(t,"optin",s=>s.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),t._zod.optout="optional",bt(t,"values",s=>{const i=s.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),bt(t,"pattern",s=>{const i=s.def.innerType._zod.pattern;return i?new RegExp(`^(${lg(i.source)})?$`):void 0}),t._zod.parse=(s,i)=>{if(s.value===void 0){if(e.innerType._zod.optin!=="defaulted")return s;const n=e.innerType._zod.run({value:s.value,issues:[]},i);return n instanceof Promise?n.then(r=>rb(s,r)):rb(s,n)}return e.innerType._zod.run(s,i)}}),zT=le("$ZodExactOptional",(t,e)=>{Py.init(t,e),bt(t,"values",s=>s.def.innerType._zod.values),bt(t,"pattern",s=>s.def.innerType._zod.pattern),t._zod.parse=(s,i)=>e.innerType._zod.run(s,i)}),ST=le("$ZodNullable",(t,e)=>{Ut.init(t,e),bt(t,"optin",s=>s.def.innerType._zod.optin),bt(t,"optout",s=>s.def.innerType._zod.optout),bt(t,"pattern",s=>{const i=s.def.innerType._zod.pattern;return i?new RegExp(`^(${lg(i.source)}|null)$`):void 0}),bt(t,"values",s=>s.def.innerType._zod.values?new Set([...s.def.innerType._zod.values,null]):void 0),t._zod.parse=(s,i)=>s.value===null?s:e.innerType._zod.run(s,i)}),xT=le("$ZodDefault",(t,e)=>{Ut.init(t,e),t._zod.optin="defaulted",bt(t,"values",s=>s.def.innerType._zod.values),t._zod.parse=(s,i)=>{if(i.direction==="backward")return e.innerType._zod.run(s,i);if(s.value===void 0)return s.value=e.defaultValue,s;const n=e.innerType._zod.run(s,i);return n instanceof Promise?n.then(r=>ob(r,e)):ob(n,e)}});function ob(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const OT=le("$ZodPrefault",(t,e)=>{Ut.init(t,e),t._zod.optin="defaulted",bt(t,"values",s=>s.def.innerType._zod.values),t._zod.parse=(s,i)=>(i.direction==="backward"||s.value===void 0&&(s.value=e.defaultValue),e.innerType._zod.run(s,i))}),ET=le("$ZodNonOptional",(t,e)=>{Ut.init(t,e),bt(t,"values",s=>{const i=s.def.innerType._zod.values;return i?new Set([...i].filter(n=>n!==void 0)):void 0}),t._zod.parse=(s,i)=>{const n=e.innerType._zod.run(s,i);return n instanceof Promise?n.then(r=>ab(r,t)):ab(n,t)}});function ab(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}function lb(t,e,s,i){return e.issues.length?(t.value=s.catchValue({...e,value:t.value,error:{issues:e.issues.map(n=>Ir(n,i,wn()))},input:t.value}),t):(t.value=e.value,e.memo&&(t.memo=!0),t)}const AT=le("$ZodCatch",(t,e)=>{Ut.init(t,e),bt(t,"optin",s=>s.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),bt(t,"optout",s=>s.def.innerType._zod.optout),bt(t,"values",s=>s.def.innerType._zod.values),t._zod.parse=(s,i)=>{if(i.direction==="backward")return e.innerType._zod.run(s,i);const n=e.innerType._zod.run({value:s.value,issues:[]},i);return n instanceof Promise?n.then(r=>lb(s,r,e,i)):lb(s,n,e,i)}}),TT=le("$ZodPipe",(t,e)=>{Ut.init(t,e),bt(t,"values",s=>s.def.in._zod.values),bt(t,"optin",s=>s.def.in._zod.optin),bt(t,"optout",s=>s.def.out._zod.optout),bt(t,"propValues",s=>s.def.in._zod.propValues),t._zod.parse=(s,i)=>{if(i.direction==="backward"){const r=e.out._zod.run(s,i);return r instanceof Promise?r.then(o=>rc(o,e.in,i)):rc(r,e.in,i)}const n=e.in._zod.run(s,i);return n instanceof Promise?n.then(r=>rc(r,e.out,i)):rc(n,e.out,i)}});function rc(t,e,s){return t.issues.some(i=>i.code!=="unrecognized_keys")?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},s)}const DT=le("$ZodReadonly",(t,e)=>{Ut.init(t,e),bt(t,"propValues",s=>s.def.innerType._zod.propValues),bt(t,"values",s=>s.def.innerType._zod.values),bt(t,"optin",s=>s.def.innerType?._zod?.optin),bt(t,"optout",s=>s.def.innerType?._zod?.optout),t._zod.parse=(s,i)=>{if(i.direction==="backward")return e.innerType._zod.run(s,i);const n=e.innerType._zod.run(s,i);return n instanceof Promise?n.then(cb):cb(n)}});function cb(t){return t.memo||(t.value=Object.freeze(t.value)),t}const IT=le("$ZodLazy",(t,e)=>{Ut.init(t,e),HO(t._zod,"innerType",()=>{const s=e;return s._cachedInner||(s._cachedInner=e.getter()),s._cachedInner}),bt(t,"pattern",s=>s.innerType?._zod?.pattern),bt(t,"propValues",s=>s.innerType?._zod?.propValues),bt(t,"optin",s=>s.innerType?._zod?.optin??void 0),bt(t,"optout",s=>s.innerType?._zod?.optout??void 0),t._zod.parse=(s,i)=>t._zod.innerType._zod.run(s,i)}),CT=le("$ZodCustom",(t,e)=>{oi.init(t,e),Ut.init(t,e),t._zod.parse=(s,i)=>s,t._zod.check=s=>{const i=s.value,n=e.fn(i);if(n instanceof Promise)return n.then(r=>hb(r,s,i,t));hb(n,s,i,t)}});function hb(t,e,s,i){if(!t){const n={code:"custom",input:s,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(n.params=i._zod.def.params),e.issues.push(Bl(n))}}class RT extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Kf="~memo",db=[];function Ly(t){return t!==null&&typeof t=="object"}function iu(t){return t.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const Wy=new WeakMap,dl=0,dh=1,xl=2;function uh(t,e,s){const i=Wy.get(t);if(i!==void 0)return i?xl:dl;if(e.has(t))return xl;e.add(t);let n=dl;const r=h=>{if(n!==xl&&h?._zod){const d=uh(h,e);d>n&&(n=d)}},o=(h,d)=>{let u=dl;for(const p of Reflect.ownKeys(h)){const f=Object.getOwnPropertyDescriptor(h,p);if(!f.enumerable)continue;const _=f.get?dh:f.value?._zod?uh(f.value,e):dl;_>u&&(u=_)}return u},a=h=>{h>n&&(n=h)},l=t._zod.def;switch(l.type){case"object":{const h=cg(l);a(h?o(h):dh),r(l.catchall);break}case"array":r(l.element);break;case"tuple":for(const h of l.items)r(h);r(l.rest);break;case"record":case"map":r(l.keyType),r(l.valueType);break;case"set":r(l.valueType);break;case"union":for(const h of l.options)r(h);break;case"intersection":r(l.left),r(l.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":r(l.innerType);break;case"pipe":r(l.in),r(l.out);break;case"function":r(l.input),r(l.output);break;case"lazy":{const h=l._cachedInner??void 0;a(h?uh(h,e):dh);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const h in l){const d=Object.getOwnPropertyDescriptor(l,h);if(!d||d.get)continue;const u=d.value;if(!(!u||typeof u!="object")){if(u._zod)r(u);else if(Array.isArray(u))for(const p of u)r(p)}}}return e.delete(t),kT(t,n)}function kT(t,e){return e!==dh&&Wy.set(t,e===xl),e}function NT(t,e){let s=t.buckets.get(e);return s||(s=new WeakMap,t.buckets.set(e,s)),s}let oc;const ac=[],BT={alloc(t,e,s){const i=oc;if(!i)return s;oc=void 0;const n={value:s,issues:null};return i.set(e.value,n),ac.push(n),s},guard(t){var e;(e=t._zod).deferred??(e.deferred=[]),t._zod.deferred.push(()=>{const s=t._zod.parse,i=(n,r)=>{if(r.direction!=="backward"&&PT(r,n.value))throw new RT;return s(n,r)};t._zod.parse=i,t._zod.run===s&&(t._zod.run=i)})},attach(t){var e;let s,i=!1,n,r;(e=t._zod).deferred??(e.deferred=[]),t._zod.deferred.push(()=>{const o=t._zod.parse,a=(l,c)=>{if(s===void 0){const m=uh(t,new Set);if(m===dl)return t._zod.parse=o,t._zod.run===a&&(t._zod.run=o),o(l,c);m===xl||i?s=!0:i=!0}const h=l.value;if(!Ly(h))return o(l,c);let d=c[Kf];d||(d={buckets:new WeakMap,backEdges:void 0},c[Kf]=d);let u;n===c?u=r:(u=NT(d,t),n=c,r=u);const p=u.get(h);if(p)return l.value=p.value,p.issues?p.issues.length&&l.issues.push(...iu(p.issues)):(l.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(p.value)),l;oc=u;const f=ac.length,_=o(l,c);oc=void 0;const g=ac.length>f?ac.pop():void 0;return _ instanceof Promise?_.then(m=>(g&&(g.issues=m.issues.length?iu(m.issues):db),m)):(g&&(g.issues=_.issues.length?iu(_.issues):db),_)};t._zod.parse=a,t._zod.run===o&&(t._zod.run=a)})}};function GT(){return BT}function PT(t,e){const s=t[Kf]?.backEdges;return s!==void 0&&Ly(e)&&s.has(e)}const LT=()=>{const t={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function e(r){return t[r]??null}const s={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function n(r,o){return r==="number"&&typeof o=="number"&&!Number.isFinite(o)?String(o):i[r]??r}return r=>{switch(r.code){case"invalid_type":{const o=n(r.expected),a=aE(r.input),l=n(a,r.input);return`Invalid input: expected ${o}, received ${l}`}case"invalid_value":return r.values.length===1?`Invalid input: expected ${_y(r.values[0])}`:`Invalid option: expected one of ${j_(r.values,"|")}`;case"too_big":{const o=r.exact?"exactly ":r.inclusive?"<=":"<",a=e(r.origin);return a?`Too big: expected ${r.origin??"value"} to have ${o}${r.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${r.origin??"value"} to be ${o}${r.maximum.toString()}`}case"too_small":{const o=r.exact?"exactly ":r.inclusive?">=":">",a=e(r.origin);return a?`Too small: expected ${r.origin} to have ${o}${r.minimum.toString()} ${a.unit}`:`Too small: expected ${r.origin} to be ${o}${r.minimum.toString()}`}case"invalid_format":{const o=r;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${s[o.format]??r.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${r.divisor}`;case"unrecognized_keys":return`Unrecognized key${r.keys.length>1?"s":""}: ${j_(r.keys,", ")}`;case"invalid_key":return`Invalid key in ${r.origin}`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`Invalid discriminator value. Expected ${r.options.map(a=>`'${a}'`).join(" | ")}`:r.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${r.origin}`;default:return"Invalid input"}}};function WT(){return{localeError:LT()}}var ub;class FT{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...s){const i=s[0];return this._map.set(e,i),i&&typeof i=="object"&&"id"in i&&this._idmap.set(i.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const s=this._map.get(e);return s&&typeof s=="object"&&"id"in s&&this._idmap.delete(s.id),this._map.delete(e),this}get(e){const s=e._zod.parent;if(s){const i={...this.get(s)??{}};delete i.id;const n={...i,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function UT(){return new FT}(ub=globalThis).__zod_globalRegistry??(ub.__zod_globalRegistry=UT());const ul=globalThis.__zod_globalRegistry;function Fy(t){return t.checks&&(t.checks=[...t.checks]),t}function $T(t,e){return new t(Fy({type:"string",...Ve(e)}))}function jT(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...Ve(e)})}function HT(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...Ve(e)})}function VT(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...Ve(e)})}function qT(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ve(e)})}function KT(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ve(e)})}function YT(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ve(e)})}function XT(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Ve(e)})}function ZT(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...Ve(e)})}function JT(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ve(e)})}function QT(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...Ve(e)})}function eD(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ve(e)})}function tD(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...Ve(e)})}function sD(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...Ve(e)})}function iD(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ve(e)})}function nD(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ve(e)})}function rD(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ve(e)})}function oD(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ve(e)})}function aD(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ve(e)})}function lD(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...Ve(e)})}function cD(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...Ve(e)})}function hD(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...Ve(e)})}function dD(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...Ve(e)})}function uD(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ve(e)})}function fD(t,e){return new t({type:"string",format:"date",check:"string_format",...Ve(e)})}function pD(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...Ve(e)})}function mD(t,e){return new t({type:"string",format:"duration",check:"string_format",...Ve(e)})}function gD(t,e){return new t(Fy({type:"number",checks:[],...Ve(e)}))}function _D(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Ve(e)})}function bD(t,e){return new t({type:"boolean",...Ve(e)})}function MD(t){return new t({type:"unknown"})}function vD(t,e){return new t({type:"never",...Ve(e)})}function fb(t,e){return new xy({check:"less_than",...Ve(e),value:t,inclusive:!1})}function nu(t,e){return new xy({check:"less_than",...Ve(e),value:t,inclusive:!0})}function pb(t,e){return new Oy({check:"greater_than",...Ve(e),value:t,inclusive:!1})}function ru(t,e){return new Oy({check:"greater_than",...Ve(e),value:t,inclusive:!0})}function mb(t,e){return new uA({check:"multiple_of",...Ve(e),value:t})}function Uy(t,e){return new pA({check:"max_length",...Ve(e),maximum:t})}function Uh(t,e){return new mA({check:"min_length",...Ve(e),minimum:t})}function $y(t,e){return new gA({check:"length_equals",...Ve(e),length:t})}function wD(t,e){return new _A({check:"string_format",format:"regex",...Ve(e),pattern:t})}function yD(t){return new bA({check:"string_format",format:"lowercase",...Ve(t)})}function zD(t){return new MA({check:"string_format",format:"uppercase",...Ve(t)})}function SD(t,e){return new vA({check:"string_format",format:"includes",...Ve(e),includes:t})}function xD(t,e){return new wA({check:"string_format",format:"starts_with",...Ve(e),prefix:t})}function OD(t,e){return new yA({check:"string_format",format:"ends_with",...Ve(e),suffix:t})}function Oa(t){return new zA({check:"overwrite",tx:t})}function ED(t){return Oa(e=>e.normalize(t))}function AD(){return Oa(t=>t.trim())}function TD(){return Oa(t=>t.toLowerCase())}function DD(){return Oa(t=>t.toUpperCase())}function ID(){return Oa(t=>KO(t))}function CD(t,e,s){return new t({type:"array",element:e,...Ve(s)})}function RD(t,e,s){return new t({type:"custom",check:"custom",fn:e,...Ve(s)})}function kD(t,e){const s=ND(i=>(i.addIssue=n=>{if(typeof n=="string")i.issues.push(Bl(n,i.value,s._zod.def));else{const r=n;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),"input"in r||(r.input=i.value),r.inst??(r.inst=s),r.continue??(r.continue=!s._zod.def.abort),i.issues.push(Bl(r))}},t(i.value,i)),e);return s}function ND(t,e){const s=new oi({check:"custom",...Ve(e)});return s._zod.check=t,s}function Ol(t,...e){for(const s of e)for(const i of Reflect.ownKeys(s))Object.prototype.propertyIsEnumerable.call(s,i)&&Yn(t,i,s[i]);return t}function jy(t){let e=t?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??ul,target:e,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:t?.cycles??"ref",reused:t?.reused??"inline",intersections:[],deferred:[],external:t?.external??void 0}}function Rr(t,e,s,i,n){const r=typeof e.unrepresentable=="function"?e.unrepresentable({zodSchema:t,path:i.path,message:n}):e.unrepresentable;if(r==="any")return!1;if(r===void 0||r==="throw")throw new Error(n);return Object.assign(s,r),!0}function Jt(t,e,s={path:[],schemaPath:[]}){var i;const n=t._zod.def,r=e.seen.get(t);if(r)return r.count++,s.schemaPath.includes(t)&&(r.cycle=s.path),r.schema;const o={schema:{},count:1,cycle:void 0,path:s.path};e.seen.set(t,o),e.sharedDefsExtractedFor=void 0,e.sharedEmitDoneFor=void 0;const a=t._zod.toJSONSchema?.();if(a)o.schema=a;else{const h={...s,schemaPath:[...s.schemaPath,t],path:s.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,h);else{const u=o.schema,p=e.processors[n.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);p(t,e,u,h)}const d=t._zod.parent;d&&(o.ref||(o.ref=d),Jt(d,e,h),e.seen.get(d).isParent=!0)}const l=e.metadataRegistry.get(t);return l&&Ol(o.schema,l),e.io==="input"&&Vs(t)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&"_prefault"in o.schema&&((i=o.schema).default??(i.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(t).schema}function gb(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function Hy(t,e){const s=t.seen.get(e);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");if(t.external&&t.sharedDefsExtractedFor===t.external)return;const i=new Map;for(const o of t.seen.entries()){const a=t.metadataRegistry.get(o[0])?.id;if(a){const l=i.get(a);if(l&&l!==o[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}const n=o=>{const a=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const d=t.external.registry.get(o[0])?.id,u=t.external.uri??(f=>f);if(d)return{ref:u(d)};const p=o[1].defId??o[1].schema.id??`schema${t.counter++}`;return o[1].defId=p,{defId:p,ref:`${u("__shared")}#/${a}/${gb(p)}`}}const l="#",c=`${l}/${a}/`;if(o[1]===s&&!o[1].schema.id)return{ref:l};const h=o[1].schema.id??`__schema${t.counter++}`;return{defId:h,ref:c+gb(h)}},r=o=>{if(o[1].schema.$ref)return;const a=o[1],{ref:l,defId:c}=n(o);a.def={...a.schema},c&&(a.defId=c);const h=a.schema;for(const d in h)delete h[d];h.$ref=l};if(t.cycles==="throw")for(const o of t.seen.entries()){const a=o[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
60
60
|
|
|
61
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const o of t.seen.entries()){const a=o[1];if(e===o[0]){r(o);continue}if(t.external){const c=t.external.registry.get(o[0])?.id;if(e!==o[0]&&c){r(o);continue}}if(t.metadataRegistry.get(o[0])?.id){r(o);continue}if(a.cycle){r(o);continue}a.count>1&&t.reused==="ref"&&r(o)}t.external&&(t.sharedDefsExtractedFor=t.external)}function Vy(t){const e=t.anyOf;if(!Array.isArray(e)||e.length===0||t.type!==void 0)return;const s=[];for(const i of e){if(!i||typeof i!="object")return;Vy(i);const n=Object.keys(i);if(n.length!==1||n[0]!=="type")return;const r=i.type;for(const o of Array.isArray(r)?r:[r]){if(typeof o!="string")return;s.includes(o)||s.push(o)}}delete t.anyOf,t.type=s.length===1?s[0]:s}const qy=new Set(["type","properties","required","additionalProperties"]),_b=["oneOf","anyOf"];function bb(t){const e=t.additionalProperties;return e===void 0||e===!1||typeof e!="object"||e===null?null:Object.keys(e).length?e:null}function Yf(t){const e=[];for(const r of t){if(typeof r!="object"||r.type!=="object")return null;for(const o in r)if(!qy.has(o))return null;e.push(r)}const s={},i=new Set;for(const r of e){for(const o in r.properties){if(Object.prototype.hasOwnProperty.call(s,o))continue;const a=[];for(const c of e){const h=c.properties?.[o]??bb(c);h!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(h))||a.push(h))}const l=a.length===1?a[0]:Yf(a)??{allOf:a};Yn(s,o,l)}for(const o of r.required??[])i.add(o)}const n={type:"object",properties:s};if(i.size&&(n.required=[...i]),e.every(r=>r.additionalProperties===!1))n.additionalProperties=!1;else{const r=[];for(const o of e){const a=bb(o);a&&!r.some(l=>JSON.stringify(l)===JSON.stringify(a))&&r.push(a)}r.length===1?n.additionalProperties=r[0]:r.length>1&&(n.additionalProperties={allOf:r})}return n}function BD(t){const e=t.allOf;if(!Array.isArray(e)||e.length<2)return;for(const n of qy)if(n in t)return;const s=e.filter(n=>_b.some(r=>Array.isArray(n[r])));let i=null;if(!s.length)i=Yf(e);else{const n=s[0],r=_b.find(l=>Array.isArray(n[l]));if(Object.keys(n).length!==1)return;const o=e.filter(l=>l!==n),a=n[r].map(l=>Yf([...o,l]));if(a.some(l=>!l))return;i={[r]:a}}i&&(delete t.allOf,Ol(t,i))}function Ky(t,e){const s=t.seen.get(e);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=a=>{const l=t.seen.get(a);if(l.ref===null)return;const c=l.def??l.schema,h={...c},d=l.ref;if(l.ref=null,d){i(d);const p=t.seen.get(d),f=p.schema;if(f.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(f)):Ol(c,f),Ol(c,h),a._zod.parent===d)for(const g in c)g==="$ref"||g==="allOf"||g in h||delete c[g];if(f.$ref&&p.def)for(const g in c)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(c[g])===JSON.stringify(p.def[g])&&delete c[g]}const u=a._zod.parent;if(u&&u!==d){i(u);const p=t.seen.get(u);if(p?.schema.$ref&&(c.$ref=p.schema.$ref,p.def))for(const f in c)f==="$ref"||f==="allOf"||f in p.def&&JSON.stringify(c[f])===JSON.stringify(p.def[f])&&delete c[f]}t.override({zodSchema:a,jsonSchema:c,path:l.path??[]})};if(!t.external||t.sharedEmitDoneFor!==t.external){for(const a of[...t.seen.entries()].reverse())i(a[0]);if(t.target!=="openapi-3.0")for(const a of t.seen.entries())Vy(a[1].def??a[1].schema);for(const a of t.deferred)a();if(t.intersections.length){const a=new Map;for(const l of t.seen.values())for(const c of[l.schema,l.def]){const h=c?.allOf;if(!Array.isArray(h))continue;const d=a.get(h);d?d.push(c):a.set(h,[c])}for(const l of t.intersections)for(const c of a.get(l)??[])BD(c)}}const n={};if(t.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){const a=t.external.registry.get(e)?.id;if(!a)throw new Error("Schema is missing an `id` property");n.$id=t.external.uri(a)}Ol(n,s.defId?s.schema:s.def??s.schema);const r=t.metadataRegistry.get(e)?.id;r!==void 0&&n.id===r&&delete n.id;const o=t.external?.defs??{};if(!t.external||t.sharedEmitDoneFor!==t.external)for(const a of t.seen.entries()){const l=a[1];l.def&&l.defId&&(l.def.id===l.defId&&delete l.def.id,Yn(o,l.defId,l.def))}t.external&&(t.sharedEmitDoneFor=t.external),t.external||Object.keys(o).length>0&&(t.target==="draft-2020-12"?n.$defs=o:n.definitions=o);try{const a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,"~standard",{value:{...e["~standard"],jsonSchema:{input:$h(e,"input",t.processors),output:$h(e,"output",t.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Vs(t,e){const s=e??{seen:new Set};if(s.seen.has(t))return!1;s.seen.add(t);const i=t._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Vs(i.element,s);if(i.type==="set")return Vs(i.valueType,s);if(i.type==="lazy")return Vs(i.getter(),s);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return Vs(i.innerType,s);if(i.type==="intersection")return Vs(i.left,s)||Vs(i.right,s);if(i.type==="record"||i.type==="map")return Vs(i.keyType,s)||Vs(i.valueType,s);if(i.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:Vs(i.in,s)||Vs(i.out,s);if(i.type==="object"){for(const n in i.shape)if(Vs(i.shape[n],s))return!0;return!1}if(i.type==="union"){for(const n of i.options)if(Vs(n,s))return!0;return!1}if(i.type==="tuple"){for(const n of i.items)if(Vs(n,s))return!0;return!!(i.rest&&Vs(i.rest,s))}return!1}const GD=(t,e={})=>s=>{const i=jy({...s,processors:e});return Jt(t,i),Hy(i,t),Ky(i,t)},$h=(t,e,s={})=>i=>{const{libraryOptions:n,target:r}=i??{},o=jy({...n??{},target:r,io:e,processors:s});return Jt(t,o),Hy(o,t),Ky(o,t)},ha=(t,e,s)=>{(t[e]===void 0||s>t[e])&&(t[e]=s)},da=(t,e,s)=>{(t[e]===void 0||s<t[e])&&(t[e]=s)},Mb=(t,e)=>{ha(t,"minimum",e),da(t,"maximum",e)},Yy=(t,e)=>{t.multipleOf??(t.multipleOf=[]),t.multipleOf.includes(e)||t.multipleOf.push(e)},Xy=(t,e)=>{t.patterns??(t.patterns=new Set),t.patterns.add(e)},Zy=(t,e)=>{t.mime=t.mime?t.mime.filter(s=>e.includes(s)):[...e]},Jy=(t,e)=>{t.format=e,e.includes("int")&&(t.isInt=!0)},vb=(t,e)=>ha(t,"minimum",e.minimum),wb=(t,e)=>da(t,"maximum",e.maximum),yb=t=>(e,s)=>{Jy(e,s.format);const[i,n]=t[s.format];ha(e,"minimum",i),da(e,"maximum",n)},PD={greater_than:(t,e)=>ha(t,e.inclusive?"minimum":"exclusiveMinimum",e.value),less_than:(t,e)=>da(t,e.inclusive?"maximum":"exclusiveMaximum",e.value),multiple_of:(t,e)=>Yy(t,e.value),number_format:yb(by),bigint_format:yb(JO),min_length:vb,max_length:wb,length_equals:(t,e)=>Mb(t,e.length),min_size:vb,max_size:wb,size_equals:(t,e)=>Mb(t,e.size),string_format:(t,e)=>{Jy(t,e.format),e.pattern&&Xy(t,e.pattern),(e.format==="base64"||e.format==="base64url")&&(t.contentEncoding=e.format),(e.local||e.precision===-1)&&(t.laxFormat=!0)},mime_type:(t,e)=>Zy(t,e.mime)};function Bi(t){const e={},s=t._zod.def,i=t._zod.traits.has("$ZodCheck")?[t,...s.checks??[]]:s.checks??[];for(const r of i)PD[r._zod.def.check]?.(e,r._zod.def);const n=t._zod.bag;n.minimum!==void 0&&ha(e,"minimum",n.minimum),n.exclusiveMinimum!==void 0&&ha(e,"exclusiveMinimum",n.exclusiveMinimum),n.maximum!==void 0&&da(e,"maximum",n.maximum),n.exclusiveMaximum!==void 0&&da(e,"exclusiveMaximum",n.exclusiveMaximum),n.multipleOf!==void 0&&Yy(e,n.multipleOf),n.format!==void 0&&(e.format??(e.format=n.format),n.format.includes("int")&&(e.isInt=!0)),n.mime&&Zy(e,n.mime);for(const r of n.patterns??[])Xy(e,r);return e}const LD={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},WD=new Map([[Ry,QE],[Mg,eA]]),Qy=t=>WD.get(t)??t,FD=(t,e,s,i)=>{const n=s;n.type="string";const{minimum:r,maximum:o,format:a,patterns:l,contentEncoding:c,laxFormat:h}=Bi(t);if(typeof r=="number"&&(n.minLength=r),typeof o=="number"&&(n.maxLength=o),a&&(n.format=LD[a]??a,n.format===""&&delete n.format,(a==="time"||h)&&delete n.format),c&&(n.contentEncoding=c),l&&l.size>0){const d=[...l].map(Qy);d.length===1?n.pattern=d[0].source:d.length>1&&(n.allOf=[...d.map(u=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:u.source}))])}},UD=(t,e,s,i)=>{const n=s,{minimum:r,maximum:o,multipleOf:a,exclusiveMaximum:l,exclusiveMinimum:c,isInt:h}=Bi(t);n.type=h?"integer":"number";const d=typeof c=="number"&&c>=(r??Number.NEGATIVE_INFINITY),u=typeof l=="number"&&l<=(o??Number.POSITIVE_INFINITY),p=e.target==="draft-04"||e.target==="openapi-3.0";if(d?p?(n.minimum=c,n.exclusiveMinimum=!0):n.exclusiveMinimum=c:typeof r=="number"&&(n.minimum=r),u?p?(n.maximum=l,n.exclusiveMaximum=!0):n.exclusiveMaximum=l:typeof o=="number"&&(n.maximum=o),a){const f=new Set;for(const m of a)Number.isFinite(m)&&m!==0?f.add(Math.abs(m)):Rr(t,e,n,i,`A multipleOf divisor of ${m} cannot be represented in JSON Schema`);const[_,...g]=f;_!==void 0&&(n.multipleOf=_),g.length&&(n.allOf=[...n.allOf??[],...g.map(m=>({multipleOf:m}))])}},$D=(t,e,s,i)=>{s.type="boolean"},jD=(t,e,s,i)=>{s.not={}},HD=(t,e,s,i)=>{},VD=(t,e,s,i)=>{const n=t._zod.def,r=$f(n.entries);if(r.length===0){s.not={};return}r.every(o=>typeof o=="number")&&(s.type="number"),r.every(o=>typeof o=="string")&&(s.type="string"),s.enum=r},qD=(t,e,s,i)=>{const n=t._zod.def;if(n.values.length===0){s.not={};return}const r=[];for(const o of n.values)if(o===void 0){if(Rr(t,e,s,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o=="bigint"){if(Rr(t,e,s,i,"BigInt literals cannot be represented in JSON Schema"))return;r.push(Number(o))}else r.push(o);if(r.length!==0)if(r.length===1){const o=r[0];s.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?s.enum=[o]:s.const=o}else r.every(o=>typeof o=="number")&&(s.type="number"),r.every(o=>typeof o=="string")&&(s.type="string"),r.every(o=>typeof o=="boolean")&&(s.type="boolean"),r.every(o=>o===null)&&(s.type="null"),s.enum=r},KD=(t,e,s,i)=>{Rr(t,e,s,i,"Custom types cannot be represented in JSON Schema")},YD=(t,e,s,i)=>{Rr(t,e,s,i,"Transforms cannot be represented in JSON Schema")},XD=(t,e,s,i)=>{const n=s,r=t._zod.def,{minimum:o,maximum:a}=Bi(t);typeof o=="number"&&(n.minItems=o),typeof a=="number"&&(n.maxItems=a),n.type="array",n.items=Jt(r.element,e,{...i,path:[...i.path,"items"]})};function Gl(t){const e=t._zod.def;return e.type==="pipe"&&e.in._zod.traits.has("$ZodTransform")?Gl(e.out):e.type==="catch"?Gl(e.innerType):t._zod.optin}const ZD=(t,e,s,i)=>{const n=s,r=t._zod.def,o=r.shape;if(Object.getOwnPropertySymbols(o).length&&Rr(t,e,n,i,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(const c in o)Yn(n.properties,c,Jt(o[c],e,{...i,path:[...i.path,"properties",c]}));const l=[];for(const c of Object.keys(o)){const h=r.shape[c];(e.io==="input"?Gl(h)===void 0:h._zod.optout===void 0)&&l.push(c)}l.length>0&&(n.required=l),r.catchall?._zod.def.type==="never"?n.additionalProperties=!1:r.catchall?r.catchall&&(n.additionalProperties=Jt(r.catchall,e,{...i,path:[...i.path,"additionalProperties"]})):e.io==="output"&&(n.additionalProperties=!1)},JD=(t,e,s,i)=>{const n=t._zod.def,r=n.inclusive===!1,o=n.options.map((a,l)=>Jt(a,e,{...i,path:[...i.path,r?"oneOf":"anyOf",l]}));r?s.oneOf=o:s.anyOf=o},QD=(t,e,s,i)=>{const n=t._zod.def,r=Jt(n.left,e,{...i,path:[...i.path,"allOf",0]}),o=Jt(n.right,e,{...i,path:[...i.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1,l=[...a(r)?r.allOf:[r],...a(o)?o.allOf:[o]];s.allOf=l,e.intersections.push(l)},eI=(t,e,s,i)=>{const n=s,r=t._zod.def;n.type="array";const o=e.target==="draft-2020-12"?"prefixItems":"items",a=e.target==="draft-2020-12"||e.target==="openapi-3.0"?"items":"additionalItems",l=r.items.map((_,g)=>Jt(_,e,{...i,path:[...i.path,o,g]})),c=r.rest?Jt(r.rest,e,{...i,path:[...i.path,a,...e.target==="openapi-3.0"?[r.items.length]:[]]}):null;let h=r.items.length;for(;h>0;){const _=r.items[h-1];if(!(e.io==="input"?Gl(_)!==void 0:_._zod.optout==="optional"))break;h--}const d=r.items.length,u=!r.rest;e.target==="draft-2020-12"?(n.prefixItems=l,u?n.items=!1:c&&(n.items=c),h>0&&(n.minItems=h),u&&(n.maxItems=d)):e.target==="openapi-3.0"?(n.items={anyOf:l},c&&n.items.anyOf.push(c),h>0&&(n.minItems=h),u&&(n.maxItems=d)):(n.items=l,u?n.additionalItems=!1:c&&(n.additionalItems=c),h>0&&(n.minItems=h),u&&(n.maxItems=d));const{minimum:p,maximum:f}=Bi(t);typeof p=="number"&&(n.minItems=p),typeof f=="number"&&(n.maxItems=f)};function Xf(t,e,s){if(e.$ref){if(s.has(e))return e;s.add(e);const f=t.get(e)?.def;if(!f)return e;const _=Xf(t,f,s);return _===f?e:_}for(const f of["anyOf","oneOf"]){const _=e[f];if(!Array.isArray(_))continue;const g=_.map(m=>Xf(t,m,s));g.some((m,v)=>m!==_[v])&&(e={...e,[f]:g})}const i=Array.isArray(e.type)?e.type:[e.type],n=!i.includes("string")&&i.some(f=>f==="number"||f==="integer"),r=e.enum??(e.const!==void 0?[e.const]:void 0);if(!n&&!r?.some(f=>typeof f=="number"))return e;const{minimum:o,maximum:a,exclusiveMinimum:l,exclusiveMaximum:c,multipleOf:h,format:d,id:u,...p}=e;return p.enum?p.enum=p.enum.map(f=>typeof f=="number"?String(f):f):typeof p.const=="number"&&(p.const=String(p.const)),n&&(p.type="string",r||(p.pattern=(i.includes("number")?gg:lA).source)),p}const Zf=new WeakMap;function tI(t){const e=new Map;for(const i of t.seen.values())i.def&&!e.has(i.schema)&&e.set(i.schema,i);const s=new Map;for(const i of Zf.get(t)??[]){const n=t.seen.get(i),r=(n?.def??n?.schema)?.propertyNames;if(!r||r===!0||s.has(r))continue;const o=Xf(e,r,new Set);o!==r&&s.set(r,o)}if(s.size)for(const i of t.seen.values())for(const n of[i.schema,i.def]){const r=n&&s.get(n.propertyNames);r&&(n.propertyNames=r)}}const sI=(t,e,s,i)=>{const n=s,r=t._zod.def;n.type="object";const o=r.keyType,a=Bi(o).patterns;if(r.mode==="loose"&&a&&a.size>0){const h=Jt(r.valueType,e,{...i,path:[...i.path,"patternProperties","*"]});n.patternProperties={};for(const d of a)Yn(n.patternProperties,Qy(d).source,h)}else{if(e.target==="draft-07"||e.target==="draft-2020-12"){n.propertyNames=Jt(r.keyType,e,{...i,path:[...i.path,"propertyNames"]});let h=Zf.get(e);h||(h=[],Zf.set(e,h),e.deferred.push(()=>tI(e))),h.push(t)}n.additionalProperties=Jt(r.valueType,e,{...i,path:[...i.path,"additionalProperties"]})}const l=o._zod.values,c=e.io==="input"&&Gl(r.valueType)!==void 0;if(l&&!r.partial&&!c){const h=[...l].filter(d=>typeof d=="string"||typeof d=="number");h.length>0&&(n.required=h.map(String))}},iI=(t,e,s,i)=>{const n=t._zod.def,r=Jt(n.innerType,e,i),o=e.seen.get(t);e.target==="openapi-3.0"?(o.ref=n.innerType,s.nullable=!0):s.anyOf=[r,{type:"null"}]},nI=(t,e,s,i)=>{const n=t._zod.def;Jt(n.innerType,e,i);const r=e.seen.get(t);r.ref=n.innerType},vg=Symbol();function ez(t,e,s,i,n){let r=!1;const o=JSON.stringify(t,(a,l)=>typeof l!="bigint"?l:(r=!0,null));return r?(Rr(e,s,i,n,"BigInt defaults cannot be represented in JSON Schema"),vg):JSON.parse(o)}const rI=(t,e,s,i)=>{const n=t._zod.def;Jt(n.innerType,e,i);const r=e.seen.get(t);r.ref=n.innerType;const o=ez(n.defaultValue,t,e,s,i);o!==vg&&(s.default=o)},oI=(t,e,s,i)=>{const n=t._zod.def;Jt(n.innerType,e,i);const r=e.seen.get(t);if(r.ref=n.innerType,e.io!=="input")return;const o=ez(n.defaultValue,t,e,s,i);o!==vg&&(s._prefault=o)},aI=(t,e,s,i)=>{const n=t._zod.def;Jt(n.innerType,e,i);const r=e.seen.get(t);r.ref=n.innerType;let o;try{o=n.catchValue(void 0)}catch{Rr(t,e,s,i,"Dynamic catch values are not supported in JSON Schema");return}s.default=o},lI=(t,e,s,i)=>{const n=t._zod.def,r=n.in._zod.traits.has("$ZodTransform"),o=e.io==="input"?r?n.out:n.in:n.out;Jt(o,e,i);const a=e.seen.get(t);a.ref=o},cI=(t,e,s,i)=>{const n=t._zod.def;Jt(n.innerType,e,i);const r=e.seen.get(t);r.ref=n.innerType,s.readOnly=!0},tz=(t,e,s,i)=>{const n=t._zod.def;Jt(n.innerType,e,i);const r=e.seen.get(t);r.ref=n.innerType},hI=(t,e,s,i)=>{const n=t._zod.innerType;Jt(n,e,i);const r=e.seen.get(t);r.ref=n},zb=new WeakSet([Object.prototype,Error.prototype]);function lc(t,e,s){Object.defineProperty(t,e,{configurable:!0,enumerable:!1,get(){const i=s(this);return Object.defineProperty(this,e,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,e,{value:i,configurable:!0,writable:!0})}})}const dI=(t,e)=>{vE.init(t,e),t.name="ZodError";const s=Object.getPrototypeOf(t);zb.has(s)||(zb.add(s),lc(s,"format",i=>n=>zE(i,n)),lc(s,"flatten",i=>n=>yE(i,n)),lc(s,"addIssue",i=>n=>{i.issues.push(n),i.message=JSON.stringify(i.issues,jf,2)}),lc(s,"addIssues",i=>n=>{i.issues.push(...n),i.message=JSON.stringify(i.issues,jf,2)}),Object.defineProperty(s,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Wi=le("ZodError",dI,void 0,{Parent:Error}),uI=ug(Wi),fI=fg(Wi),pI=pg(Wi),mI=mg(Wi),gI=TE(Wi),_I=DE(Wi),bI=IE(Wi),MI=CE(Wi),vI=RE(Wi),wI=kE(Wi),yI=NE(Wi),zI=BE(Wi);function SI(){Li.localeError||wn(WT())}function Xl(){Li.memoizer||wn({memoizer:GT()})}const jt=le("ZodType",(t,e)=>(SI(),Ut.init(t,e),t.def=e,t.type=e.type,t),{check(...t){const e=this.def;return this.clone(wi(e,{checks:[...e.checks??[],...t.map(s=>typeof s=="function"?{_zod:{check:s,def:{check:"custom"},onattach:[]}}:s)]}),{parent:!0})},with(...t){return this.check(...t)},clone(t,e){return Pr(this,t,e)},brand(){return this},register(t,e){return t.add(this,e),this},refine(t,e){return this.check(SC(t,e))},superRefine(t,e){return this.check(xC(t,e))},overwrite(t){return this.check(Oa(t))},optional(){return Ob(this)},exactOptional(){return cC(this)},nullable(){return Eb(this)},nullish(){return Ob(Eb(this))},nonoptional(t){return mC(this,t)},array(){return je(this)},or(t){return tC([this,t])},and(t){return nC(this,t)},transform(t){return Ab(this,lC(t))},default(t){return uC(this,t)},prefault(t){return pC(this,t)},catch(t){return _C(this,t)},pipe(t){return Ab(this,t)},readonly(){return vC(this)},describe(t){const e=this.clone();return ul.add(e,{description:t}),e},meta(...t){if(t.length===0)return ul.get(this);const e=this.clone();return ul.add(e,t[0]),e},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(t,...e){return e.length===0?t(this):t(this,...e)},get"~standard"(){return vy(this,"~standard",{...Ay(this),jsonSchema:{input:$h(this,"input"),output:$h(this,"output")}})},set"~standard"(t){Cr(this,"~standard",t)},parse:function t(e,s){return uI(this,e,s,{callee:t})},parseAsync:async function t(e,s){return await fI(this,e,s,{callee:t})},safeParse(t,e){return pI(this,t,e)},async safeParseAsync(t,e){return mI(this,t,e)},get spa(){return this?.safeParseAsync},set spa(t){Cr(this,"spa",t)},validate(t,e){return OE(this,t,e)},validateAsync(t,e){return AE(this,t,e)},encode:function t(e,s){return gI(this,e,s,{callee:t})},decode:function t(e,s){return _I(this,e,s,{callee:t})},encodeAsync:async function t(e,s){return await bI(this,e,s,{callee:t})},decodeAsync:async function t(e,s){return await MI(this,e,s,{callee:t})},safeEncode(t,e){return vI(this,t,e)},safeDecode(t,e){return wI(this,t,e)},async safeEncodeAsync(t,e){return yI(this,t,e)},async safeDecodeAsync(t,e){return zI(this,t,e)},toJSONSchema(t){return GD(this,{})(t)},get description(){return ul.get(this)?.description},get _def(){return this._zod.def}}),sz=le("_ZodString",(t,e)=>{bg.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>FD(t,s,i)},wy({format:t=>Bi(t).format??null,minLength:t=>Bi(t).minimum??null,maxLength:t=>Bi(t).maximum??null},{regex(...t){return this.check(wD(...t))},includes(...t){return this.check(SD(...t))},startsWith(...t){return this.check(xD(...t))},endsWith(...t){return this.check(OD(...t))},min(...t){return this.check(Uh(...t))},max(...t){return this.check(Uy(...t))},length(...t){return this.check($y(...t))},nonempty(...t){return this.check(Uh(1,...t))},lowercase(t){return this.check(yD(t))},uppercase(t){return this.check(zD(t))},trim(){return this.check(AD())},normalize(...t){return this.check(ED(...t))},toLowerCase(){return this.check(TD())},toUpperCase(){return this.check(DD())},slugify(){return this.check(ID())}})),xI=le("ZodString",(t,e)=>{bg.init(t,e),sz.init(t,e)},{email(t){return this.check(jT(DI,t))},url(t){return this.check(XT(CI,t))},jwt(t){return this.check(dD(qI,t))},emoji(t){return this.check(ZT(RI,t))},guid(t){return this.check(HT(II,t))},uuid(t){return this.check(VT(cc,t))},uuidv4(t){return this.check(qT(cc,t))},uuidv6(t){return this.check(KT(cc,t))},uuidv7(t){return this.check(YT(cc,t))},nanoid(t){return this.check(JT(kI,t))},cuid(t){return this.check(QT(NI,t))},cuid2(t){return this.check(eD(BI,t))},ulid(t){return this.check(tD(GI,t))},base64(t){return this.check(lD(jI,t))},base64url(t){return this.check(cD(HI,t))},xid(t){return this.check(sD(PI,t))},ksuid(t){return this.check(iD(LI,t))},ipv4(t){return this.check(nD(WI,t))},ipv6(t){return this.check(rD(FI,t))},cidrv4(t){return this.check(oD(UI,t))},cidrv6(t){return this.check(aD($I,t))},e164(t){return this.check(hD(VI,t))},datetime(t){return this.check(uD(OI,t))},date(t){return this.check(fD(EI,t))},time(t){return this.check(pD(AI,t))},duration(t){return this.check(mD(TI,t))}});function G(t){return $T(xI,t)}const es=le("ZodStringFormat",(t,e)=>{Kt.init(t,e),sz.init(t,e)}),OI=le("ZodISODateTime",(t,e)=>{$A.init(t,e),es.init(t,e)}),EI=le("ZodISODate",(t,e)=>{jA.init(t,e),es.init(t,e)}),AI=le("ZodISOTime",(t,e)=>{HA.init(t,e),es.init(t,e)}),TI=le("ZodISODuration",(t,e)=>{VA.init(t,e),es.init(t,e)}),DI=le("ZodEmail",(t,e)=>{TA.init(t,e),es.init(t,e)}),II=le("ZodGUID",(t,e)=>{EA.init(t,e),es.init(t,e)}),cc=le("ZodUUID",(t,e)=>{AA.init(t,e),es.init(t,e)}),CI=le("ZodURL",(t,e)=>{NA.init(t,e),es.init(t,e)}),RI=le("ZodEmoji",(t,e)=>{BA.init(t,e),es.init(t,e)}),kI=le("ZodNanoID",(t,e)=>{GA.init(t,e),es.init(t,e)}),NI=le("ZodCUID",(t,e)=>{PA.init(t,e),es.init(t,e)}),BI=le("ZodCUID2",(t,e)=>{LA.init(t,e),es.init(t,e)}),GI=le("ZodULID",(t,e)=>{WA.init(t,e),es.init(t,e)}),PI=le("ZodXID",(t,e)=>{FA.init(t,e),es.init(t,e)}),LI=le("ZodKSUID",(t,e)=>{UA.init(t,e),es.init(t,e)}),WI=le("ZodIPv4",(t,e)=>{qA.init(t,e),es.init(t,e)}),FI=le("ZodIPv6",(t,e)=>{YA.init(t,e),es.init(t,e)}),UI=le("ZodCIDRv4",(t,e)=>{XA.init(t,e),es.init(t,e)}),$I=le("ZodCIDRv6",(t,e)=>{JA.init(t,e),es.init(t,e)}),jI=le("ZodBase64",(t,e)=>{QA.init(t,e),es.init(t,e)}),HI=le("ZodBase64URL",(t,e)=>{tT.init(t,e),es.init(t,e)}),VI=le("ZodE164",(t,e)=>{sT.init(t,e),es.init(t,e)}),qI=le("ZodJWT",(t,e)=>{nT.init(t,e),es.init(t,e)}),iz=le("ZodNumber",(t,e)=>{ky.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>UD(t,s,i,n),t.isFinite=!0},wy({minValue:t=>{const{minimum:e,exclusiveMinimum:s}=Bi(t);return Math.max(e??Number.NEGATIVE_INFINITY,s??Number.NEGATIVE_INFINITY)},maxValue:t=>{const{maximum:e,exclusiveMaximum:s}=Bi(t);return Math.min(e??Number.POSITIVE_INFINITY,s??Number.POSITIVE_INFINITY)},isInt:t=>{const{isInt:e,multipleOf:s}=Bi(t);return!!e||!!s?.some(Number.isSafeInteger)},format:t=>Bi(t).format??null},{gt(t,e){return this.check(pb(t,e))},gte(t,e){return this.check(ru(t,e))},min(t,e){return this.check(ru(t,e))},lt(t,e){return this.check(fb(t,e))},lte(t,e){return this.check(nu(t,e))},max(t,e){return this.check(nu(t,e))},int(t){return this.check(Sb(t))},safe(t){return this.check(Sb(t))},positive(t){return this.check(pb(0,t))},nonnegative(t){return this.check(ru(0,t))},negative(t){return this.check(fb(0,t))},nonpositive(t){return this.check(nu(0,t))},multipleOf(t,e){return this.check(mb(t,e))},step(t,e){return this.check(mb(t,e))},finite(){return this}}));function Q(t){return gD(iz,t)}const KI=le("ZodNumberFormat",(t,e)=>{rT.init(t,e),iz.init(t,e)});function Sb(t){return _D(KI,t)}const YI=le("ZodBoolean",(t,e)=>{oT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>$D(t,s,i)});function wt(t){return bD(YI,t)}const XI=le("ZodUnknown",(t,e)=>{aT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>HD()});function ua(){return MD(XI)}const ZI=le("ZodNever",(t,e)=>{lT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>jD(t,s,i)});function JI(t){return vD(ZI,t)}const QI=le("ZodArray",(t,e)=>{Xl(),dT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>XD(t,s,i,n),t.element=e.element},{min(t,e){return this.check(Uh(t,e))},nonempty(t){return this.check(Uh(1,t))},max(t,e){return this.check(Uy(t,e))},length(t,e){return this.check($y(t,e))},unwrap(){return this.element}});function je(t,e){return CD(QI,t,e)}const eC=le("ZodObject",(t,e)=>{Xl(),pT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>ZD(t,s,i,n),uE(t,"shape",s=>s._zod.def.shape,!1)},{keyof(){return kt(Object.keys(this._zod.def.shape))},catchall(t){return this.clone(wi(this._zod.def,{catchall:t}))},passthrough(){return this.clone(wi(this._zod.def,{catchall:ua()}))},loose(){return this.clone(wi(this._zod.def,{catchall:ua()}))},strict(){return this.clone(wi(this._zod.def,{catchall:JI()}))},strip(){return this.clone(wi(this._zod.def,{catchall:void 0}))},extend(t){return tE(this,t)},safeExtend(t){return sE(this,t)},merge(t){return iE(this,t)},pick(t){return QO(this,t)},omit(t){return eE(this,t)},partial(...t){return V_(wg,this,t[0])},exactPartial(...t){return V_(az,this,t[0],"exactPartial")},required(...t){return nE(lz,this,t[0])}});function se(t,e){const s={type:"object",shape:t??{},...Ve(e)};return new eC(s)}const nz=le("ZodUnion",(t,e)=>{Gy.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>JD(t,s,i,n),t.options=e.options});function tC(t,e){return new nz({type:"union",options:t,...Ve(e)})}const sC=le("ZodDiscriminatedUnion",(t,e)=>{nz.init(t,e),gT.init(t,e)});function rz(t,e,s){return new sC({type:"union",options:e,discriminator:t,...Ve(s)})}const iC=le("ZodIntersection",(t,e)=>{_T.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>QD(t,s,i,n)});function nC(t,e){return new iC({type:"intersection",left:t,right:e})}const rC=le("ZodTuple",(t,e)=>{Xl(),bT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>eI(t,s,i,n)},{rest(t){return this.clone({...this._zod.def,rest:t})},partial(){const t=this._zod.def;if(t.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...t,items:t.items.map(e=>new wg({type:"optional",innerType:e}))})}});function oz(t,e,s){const i=e instanceof Ut,n=i?s:e,r=i?e:null;return new rC({type:"tuple",items:t,rest:r,...Ve(n)})}const xb=le("ZodRecord",(t,e)=>{Xl(),MT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>sI(t,s,i,n),t.keyType=e.keyType,t.valueType=e.valueType});function jh(t,e,s){return!e||!e._zod?new xb({type:"record",keyType:G(),valueType:t,...Ve(e)}):new xb({type:"record",keyType:t,valueType:e,...Ve(s)})}const Jf=le("ZodEnum",(t,e)=>{vT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(i,n,r)=>VD(t,i,n),t.enum=e.entries,t.options=[...t._zod.values];const s=new Set(Object.keys(e.entries));t.extract=(i,n)=>{const r={};for(const o of i)if(s.has(o))r[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Jf({...e,checks:[],...Ve(n),entries:r})},t.exclude=(i,n)=>{const r={...e.entries};for(const o of i)if(s.has(o))delete r[o];else throw new Error(`Key ${o} not found in enum`);return new Jf({...e,checks:[],...Ve(n),entries:r})}});function kt(t,e){const s=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new Jf({type:"enum",entries:s,...Ve(e)})}const oC=le("ZodLiteral",(t,e)=>{wT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>qD(t,s,i,n),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function Xe(t,e){return new oC({type:"literal",values:Array.isArray(t)?t:[t],...Ve(e)})}const aC=le("ZodTransform",(t,e)=>{Xl(),yT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>YD(t,s,i,n),t._zod.parse=(s,i)=>{if(i.direction==="backward")throw new yy(t.constructor.name);s.addIssue=r=>{if(typeof r=="string")s.issues.push(Bl(r,s.value,e));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=s.value),o.inst??(o.inst=t),s.issues.push(Bl(o))}};const n=e.transform(s.value,s);return n instanceof Promise?n.then(r=>(s.value=r,s)):(s.value=n,s)}});function lC(t){return new aC({type:"transform",transform:t})}const wg=le("ZodOptional",(t,e)=>{Py.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>tz(t,s,i,n),t.unwrap=()=>t._zod.def.innerType});function Ob(t){return new wg({type:"optional",innerType:t})}const az=le("ZodExactOptional",(t,e)=>{zT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>tz(t,s,i,n),t.unwrap=()=>t._zod.def.innerType});function cC(t){return new az({type:"optional",innerType:t})}const hC=le("ZodNullable",(t,e)=>{ST.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>iI(t,s,i,n),t.unwrap=()=>t._zod.def.innerType});function Eb(t){return new hC({type:"nullable",innerType:t})}const dC=le("ZodDefault",(t,e)=>{xT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>rI(t,s,i,n),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function uC(t,e){return new dC({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():gy(e)}})}const fC=le("ZodPrefault",(t,e)=>{OT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>oI(t,s,i,n),t.unwrap=()=>t._zod.def.innerType});function pC(t,e){return new fC({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():gy(e)}})}const lz=le("ZodNonOptional",(t,e)=>{ET.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>nI(t,s,i,n),t.unwrap=()=>t._zod.def.innerType});function mC(t,e){return new lz({type:"nonoptional",innerType:t,...Ve(e)})}const gC=le("ZodCatch",(t,e)=>{AT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>aI(t,s,i,n),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function _C(t,e){return new gC({type:"catch",innerType:t,catchValue:typeof e=="function"?e:pE(e)})}const bC=le("ZodPipe",(t,e)=>{TT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>lI(t,s,i,n),t.in=e.in,t.out=e.out});function Ab(t,e){return new bC({type:"pipe",in:t,out:e})}const MC=le("ZodReadonly",(t,e)=>{DT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>cI(t,s,i,n),t.unwrap=()=>t._zod.def.innerType});function vC(t){return new MC({type:"readonly",innerType:t})}const wC=le("ZodLazy",(t,e)=>{IT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>hI(t,s,i,n),t.unwrap=()=>t._zod.def.getter()});function yC(t){return new wC({type:"lazy",getter:t})}const zC=le("ZodCustom",(t,e)=>{CT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>KD(t,s,i,n)});function SC(t,e={}){return RD(zC,t,e)}function xC(t,e){return kD(t,e)}se({name:G(),type:G(),size:Q(),owner:G(),date:G(),target:G().optional(),version:G().optional(),title:G().optional(),tags:je(G()).optional(),id:Q().optional(),status:G().optional()}).passthrough();const OC=new Set([".dcm",".png",".jpg",".jpeg",".gif",".bmp",".webp",".ico",".pdf",".zip",".tar",".gz",".bz2",".xz",".7z",".exe",".dll",".so",".bin",".mp3",".mp4",".avi",".wav",".nii",".mgz"]),EC=1024*1024;function yg(t){const e=t.split("/").pop()??t,s=e.lastIndexOf(".");return s>0?e.slice(s).toLowerCase():""}function AC(t){return!OC.has(yg(t))}const TC=kt(["ok","error"]),DC=se({type:kt(["error","warning"]),message:G()}),IC=se({kind:G(),data:ua()}),CC=se({input:G(),proposed:G(),validated:wt(),executed:G().optional()}),cz=se({status:TC,rendered:G(),renderedErr:G().optional(),model:IC.optional(),errors:je(DC).optional(),trace:CC.optional()}),RC=kt(["data","err","status"]),kC=se({shellCommands:wt(),hiddenInput:wt().optional(),color:wt().optional(),fileDelivery:wt().optional(),localFilesystem:wt().optional(),claims:je(se({subject:G(),verbs:je(G()).optional()})).optional(),terminal:G().optional()}),NC=se({type:Xe("attach"),protocolVersion:Q().int(),token:G(),session:G().optional(),capabilities:kC.optional()}),BC=se({type:Xe("execute"),id:G(),line:G(),instrument:wt().optional(),mirrored:wt().optional()}),GC=se({type:Xe("cancel"),id:G()}),PC=se({type:Xe("stop")}),LC=se({type:Xe("complete"),id:G(),prefix:G()}),WC=se({type:Xe("promptAnswer"),promptId:G(),answer:G()}),FC=se({type:Xe("promptError"),promptId:G(),reason:G()}),UC=se({type:Xe("pipeResult"),pipeId:G(),output:G()}),$C=se({type:Xe("pipeError"),pipeId:G(),reason:G()}),jC=se({type:Xe("shellResult"),shellId:G(),exitCode:Q().int()}),HC=se({type:Xe("shellError"),shellId:G(),reason:G()}),VC=se({type:Xe("editResult"),editId:G(),content:G(),changed:wt(),opened:wt().optional()}),qC=se({type:Xe("editError"),editId:G(),reason:G()}),KC=se({type:Xe("deliverResult"),deliverId:G(),location:G(),bytes:Q().nonnegative()}),YC=se({type:Xe("deliverError"),deliverId:G(),reason:G()}),XC=se({address:G(),modelKind:G().optional(),groupId:G(),paneId:G()}),hz=se({type:Xe("regard"),regard:XC}),ZC=se({type:Xe("watch"),subject:G()}),JC=se({type:Xe("unwatch"),subject:G()}),QC=se({type:Xe("terminalOpen"),terminalId:G().optional(),cols:Q().int(),rows:Q().int()}),eR=se({type:Xe("terminalInput"),terminalId:G(),data:G()}),tR=se({type:Xe("terminalResize"),terminalId:G(),cols:Q().int(),rows:Q().int()}),sR=se({type:Xe("terminalClose"),terminalId:G()}),iR=se({type:Xe("surfaceLineResult"),lineId:G(),rendered:G(),status:kt(["ok","error"])}),nR=se({type:Xe("surfaceLineError"),lineId:G(),reason:G()}),rR=se({type:Xe("surfaceClaims"),claims:je(se({subject:G(),verbs:je(G()).optional()}))}),oR=se({type:Xe("note"),text:G()}),aR=["live","settled","stale"],lR=kt(aR),cR=se({type:Xe("stale"),stale:wt()}),hR=["restart","end","stop"],dR=se({type:Xe("closing"),cause:kt(hR)}),uR=se({type:Xe("watched"),subject:G(),state:lR}),fR=se({type:Xe("numbered"),id:Q(),source:G(),rows:Q(),handles:je(se({kind:G(),ordinal:Q(),address:G()}))});rz("type",[NC,BC,GC,PC,LC,WC,FC,UC,$C,jC,HC,VC,qC,KC,YC,hz,ZC,JC,QC,eR,tR,sR,iR,nR,oR,rR]);const pR=se({type:Xe("attached"),session:G(),surface:G().optional(),backend:G().optional(),protocolVersion:Q().int(),stack:se({chell:G(),calypso:G(),build:G(),surface:se({git:G(),built:G()}).optional(),brasa:G().optional(),chili:G().optional(),salsa:G().optional(),cumin:G().optional()}).optional(),hostControl:je(G()).optional(),stale:wt().optional(),terminals:wt().optional()}),mR=se({type:Xe("result"),id:G(),envelopes:je(cz)}),gR=se({type:Xe("complete"),id:G(),prefix:G(),candidates:je(G())}),_R=se({type:Xe("event"),id:G(),kind:G(),data:ua()}),bR=se({type:Xe("output"),id:G(),channel:RC,chunk:G()}),MR=kt(GO).catch("task"),vR=kt(PO).catch(void 0),wR=kt(LO).catch("working"),yR=kt(WO).catch(void 0),zR=kt(FO).catch("unknown"),SR=se({type:Xe("progress"),id:G(),operation:MR,kind:vR.optional(),phase:wR,label:G().optional(),itemId:G().optional(),current:Q().nonnegative().optional(),total:Q().nonnegative().optional(),percent:Q().min(0).max(100).optional(),unit:yR.optional(),status:zR.optional(),path:G().optional(),reason:G().optional()}),xR=se({type:Xe("session"),surface:G(),envelope:cz,terminal:G().optional()}),OR=se({type:Xe("error"),id:G().optional(),reason:G()}),ER=["text","secret","confirm","path"],AR=kt(ER).catch("text"),TR=se({anchor:G().optional(),wantsDirectory:wt(),suggest:G().optional()}),DR=se({type:Xe("prompt"),promptId:G(),message:G(),hidden:wt(),wants:AR.optional(),path:TR.optional(),commit:G().optional()});function IR(t){return t.wants!==void 0?t.wants:t.hidden===!0?"secret":"text"}const CR=["leader","place","identity","path","work","note","alert"],RR=se({key:G(),label:G(),value:G(),tone:kt(CR)}),kR=se({user:G(),uri:G(),cwd:G(),pacsserver:G().nullable(),physicalMode:wt(),lastExitCode:Q(),lastCommandDurationMs:Q(),procWarmup:se({loaded:Q(),total:Q().optional(),restored:wt().optional(),state:kt(NO).optional(),sweeping:wt().optional(),feed:se({id:Q(),loaded:Q(),total:Q(),failed:G().optional()}).optional(),feeds:je(se({id:Q(),loaded:Q(),total:Q(),failed:G().optional()})).optional(),arrived:je(Q()).optional(),landed:je(se({id:Q(),title:G().default(""),jobs:Q(),status:G(),chain:je(G()),groups:je(se({plugin:G(),count:Q(),errored:Q().default(0),status:G(),parent:Q().nullable()})).default([])})).optional(),roster:kt(["delta","full"]).optional()}).optional(),procIndex:se({jobs:Q(),feeds:Q()}).optional(),warmupFailures:je(se({label:G(),message:G()})).optional(),questions:Q().optional(),segments:je(RR).optional()}),NR=se({type:Xe("promptline"),context:kR}),BR=se({type:Xe("pipe"),pipeId:G(),command:G(),input:G()}),GR=se({type:Xe("shell"),shellId:G(),command:G()}),PR=se({type:Xe("edit"),editId:G(),content:G(),extension:G().optional(),path:G().optional()}),LR=se({type:Xe("deliver"),deliverId:G(),path:G(),filename:G(),destination:G().optional(),size:Q().nonnegative().optional(),contentType:G().optional()}),WR=se({type:Xe("telemetry"),index:se({jobs:Q(),feeds:Q()}),lane:se({running:se({line:G(),sinceMs:Q(),surface:G()}).nullable(),waiting:Q(),questions:je(se({surface:G(),message:G(),sinceMs:Q()})).optional(),joblets:je(se({number:Q(),line:G(),waiting:wt()})).optional()}).optional(),surfaces:je(se({id:G(),kind:kt(["chell","browser"])})).optional(),cube:se({msPerPage:Q(),samples:Q()}).optional(),state:se({running:Q(),runningFeeds:Q(),scheduled:Q(),errored:Q(),erroredFeeds:Q()}).optional()}),FR=se({type:Xe("terminalOpened"),terminalId:G(),replay:G(),refused:G().optional()}),UR=se({type:Xe("terminalData"),terminalId:G(),data:G()}),$R=se({type:Xe("terminalExit"),terminalId:G(),code:Q().int()}),jR=se({type:Xe("surfaceLine"),lineId:G(),line:G(),terminal:G().optional()}),HR=se({type:Xe("consoleNote"),text:G()}),dz=rz("type",[pR,mR,gR,bR,SR,_R,xR,OR,DR,NR,WR,BR,GR,PR,LR,hz,uR,cR,dR,fR,FR,UR,$R,jR,HR]);new Set(dz.options.map(t=>t.shape.type.value));function VR(t){return t.issues.map(e=>{const s=e.path.map(String).join(".");return s?`${s}: ${e.message}`:e.message}).join("; ")}function qR(t,e){const s=t.safeParse(e);return s.success?{ok:!0,value:s.data}:{ok:!1,error:VR(s.error)}}function KR(t){return qR(dz,t)}const uz=se({id:G(),label:G(),parentIds:je(G()),joinParentIds:je(G())}),YR=se({name:G(),value:ua()}),XR=uz.extend({pluginName:G(),pluginVersion:G().optional(),arguments:je(YR).optional()}),zg=se({name:G(),pipelineId:Q().optional(),nodes:je(XR)}),ZR=["created","waiting","scheduled","started","registeringFiles","finishedSuccessfully","finishedWithError","cancelled","unknown"],fz=kt(ZR).catch("unknown"),JR=se({count:Q(),done:Q(),error:Q(),running:Q(),other:Q(),anomalies:je(se({id:G(),status:fz})).optional()}),QR=se({computeSeconds:Q().optional(),dataBytes:Q().optional()}),ek=uz.extend({instanceId:Q(),pluginName:G(),pluginVersion:G().optional(),status:fz,vfsPath:G(),metrics:QR.optional(),tally:JR.optional(),computeResource:G().optional()}),Sg=se({feedId:Q(),feedName:G(),nodes:je(ek)}),tk=se({feedId:Q(),loaded:Q(),total:Q(),failed:G().optional()}),yr={pipelineDiagram:"pipeline.diagram",feedDag:"feed.dag",feedIndexing:"feed.indexing"},sk=se({id:Q(),title:G(),owner:G(),status:G(),createdAt:G(),new:wt().optional(),sizeBytes:Q().optional(),wallSeconds:Q().optional(),jobsDone:Q().optional(),jobsTotal:Q().optional(),jobsErrored:Q().optional(),tags:je(G()).optional()}),Qf=se({feeds:je(sk)}),ep="feed.list",ik=se({target:G(),choices:je(se({kind:kt(["feed","node"]),feedId:Q(),nodeId:Q().optional(),name:G(),title:G()}))}),nk="proc.jump",rk=se({plugin:G(),count:Q(),errored:Q().default(0),status:G(),parent:Q().nullable()}),ok=se({format:kt(["dicom","nifti","mgz","jpeg","png","other","unknown"]),modality:G().optional(),seriesDescription:G().optional(),reason:G().optional(),sourceFeed:Q().optional()}),ak=se({id:Q(),title:G().default(""),jobs:Q(),status:G(),chain:je(G()),groups:je(rk).default([]),createdAt:G().default(""),data:ok.optional()}),lk=se({feeds:je(ak),whole:wt()}),ck="proc.universe",hk=se({name:G(),positions:jh(G(),oz([Q(),Q(),Q()])).nullable(),writtenAt:G().nullable(),laying:se({nodes:Q(),fraction:Q()}).nullable().optional()}),dk="proc.layout",uk=se({name:G(),type:G(),optional:wt(),default:ua().optional(),help:G().optional(),flag:G()}),fk=se({id:Q().optional(),name:G(),version:G(),type:G(),title:G().optional(),description:G().optional(),authors:G().optional(),documentation:G().optional(),category:G().optional(),parameters:je(uk),command:G().optional()}),pk="plugin.info",mk=se({seriesUID:G(),description:G(),modality:G(),fileCount:Q().optional(),vfsPath:G().optional(),pulled:wt().optional(),pulledFiles:Q().optional(),folderPath:G().optional()}),gk=se({studyUID:G().optional(),server:G().optional(),vfsPath:G().optional(),description:G(),patientName:G(),patientId:G(),date:G(),modalities:G(),accession:G(),series:je(mk)}),pz=se({replayed:wt(),answeredAt:G()}),_k=["found","none","unasked"],bk=kt(_k).catch("unasked"),Mk=se({patientId:G(),server:G().optional(),patientName:G().optional(),status:bk,studyCount:Q(),seriesCount:Q(),queryId:Q().optional(),provenance:pz.optional(),error:G().optional()}),vk=se({queryId:Q(),vfsPath:G(),pacsName:G(),expression:G(),studies:je(gk),provenance:pz.optional(),patients:je(Mk).optional()}),wk=se({id:Q(),identifier:G(),active:wt()}),yk=se({servers:je(wk)}),zk="pacs.servers",Sk="pacs.query";function xk(t){return`pacs:patient:${t.server??"-"}:${t.patientId}`}const Ok=["patient","study","series","image","equipment","meta","private","other"],mz=kt(Ok).catch("other"),gz=yC(()=>se({tag:G(),name:G(),vr:G(),value:G(),group:mz,phi:wt(),decoded:G().optional(),items:je(je(gz)).optional()})),Ek=se({tag:G(),name:G(),vr:G(),group:mz,phi:wt(),distinct:Q(),first:G(),last:G(),values:je(se({path:G(),value:G().nullable()}))}),_z=se({path:G(),subject:kt(["file","folder"]),read:Q(),of:Q(),refused:je(G()),constant:je(gz),varying:je(Ek)}),Ak=se({rows:Q(),columns:Q(),pixelSpacing:oz([Q(),Q()]).optional(),sliceThickness:Q().optional(),spacingBetweenSlices:Q().optional()}),bz=se({path:G(),seriesInstanceUID:G().optional(),studyInstanceUID:G().optional(),modality:G(),seriesDescription:G(),seriesNumber:Q().optional(),instances:Q(),frames:Q(),order:kt(["filename","unknown"]),geometry:Ak.optional(),transferSyntax:se({uid:G(),name:G().optional()}).optional(),bytes:Q(),header:G(),files:je(G()),annotations:je(G())}),ea={tags:"dicom.tags",series:"dicom.series"},Tk=se({path:G(),target:kt(["series","volume"]),force:wt().optional(),startAt:Q().int().positive().optional()}),Dk={view:"image.view"},Ik=se({state:kt(["cold","warming","current"]),loaded:Q(),total:Q()});se({user:G(),surface:G(),feeds:se({total:Q(),own:Q(),shared:Q(),public:Q()}),jobs:se({total:Q(),finished:Q(),errored:Q(),cancelled:Q(),running:Q(),scheduled:Q()}),failureRate:Q().nullable(),index:Ik,fortune:G()});const Ck="session.notes",Rk=se({package:G(),headline:G(),body:G(),internal:wt()}),kk=se({package:G(),version:G(),bump:kt(["major","minor","patch"]),changes:je(Rk)}),Nk=se({date:G().nullable(),merge:G().nullable(),entries:je(kk)}),Bk=se({source:Xe("daemon"),installed:jh(G(),G()),releases:je(Nk),total:Q(),all:wt()});function Ws(t){return t.groups.map(e=>`${e.parent??"r"}:${e.plugin}`).join(">")}function zr(t,e){return`feed:${t}:${e}`}function Mz(t){return`shape:${t}`}function Pl(t){return Math.log2(Math.max(1,t)+1)}function xg(t){if(!(t.errored<=0||t.count<=0))return Math.min(1,t.errored/t.count)}function Od(t,e="jobs"){const s=[],i=new Set,n=[...t].sort((o,a)=>o.id-a.id),r=new Map;for(const o of n){if(o.groups.length===0)continue;const a=Ws(o);r.set(a,(r.get(a)??0)+1)}for(const o of n){if(o.groups.length===0)continue;const a=Ws(o),l=Mz(a);i.has(a)||(i.add(a),s.push({id:l,label:Ed(a),parentIds:[],joinParentIds:[],ghost:!0,halo:!0,metric:1,count:r.get(a)??1})),o.groups.forEach((c,h)=>{const d=xg(c);s.push({id:zr(o.id,h),label:c.plugin,parentIds:[c.parent===null?l:zr(o.id,c.parent)],joinParentIds:[],status:c.status,metric:e==="jobs"?Pl(c.count):1,...c.count>1?{count:c.count}:{},...d!==void 0?{share:d}:{}})})}return{nodes:s}}const tp="plugin:";function Gk(t){return`${tp}${t}`}function sp(t){return t.startsWith(tp)?t.slice(tp.length):null}function Og(t,e="jobs"){const s=[],i=new Map,n=[...t].sort((r,o)=>r.id-o.id);for(const r of n)if(r.groups.length!==0){for(const o of new Set(r.groups.map(a=>a.plugin)))i.set(o,(i.get(o)??0)+1);r.groups.forEach((o,a)=>{const l=xg(o);s.push({id:zr(r.id,a),label:o.plugin,parentIds:o.parent===null?[]:[zr(r.id,o.parent)],joinParentIds:[],status:o.status,metric:e==="jobs"?Pl(o.count):1,attrs:{plugin:o.plugin},...o.count>1?{count:o.count}:{},...l!==void 0?{share:l}:{}})})}for(const[r,o]of[...i].sort((a,l)=>a[0]<l[0]?-1:1))s.push({id:Gk(r),label:r,parentIds:[],joinParentIds:[],metric:1+Math.log(o),hue:"#e8f4ff",ring:!0,attrs:{kind:"star",plugin:r}});return{nodes:s}}function Tb(t,e="jobs"){const s=new Map;for(const n of t){const r=n.createdAt===void 0?Number.NaN:Date.parse(n.createdAt);Number.isFinite(r)&&s.set(n.id,r)}return{nodes:Og(t,e).nodes.filter(n=>n.attrs?.kind!=="star").map(n=>{const r=s.get(Number(n.id.split(":")[1]));return r===void 0?n:{...n,attrs:{...n.attrs,createdAt:r}}})}}function Ed(t){const e=[];for(const s of t.split(">")){const i=s.slice(s.indexOf(":")+1);i.length>0&&!e.includes(i)&&e.push(i)}return e.join(" > ")}const Pk=.5,Lk=5,Wk=.02,ip="data:",Fk={dicom:"DICOM",nifti:"NIfTI",mgz:"MGZ",jpeg:"JPEG",png:"PNG",other:"OTHER",unknown:"UNREADABLE",unread:"NOT YET READ"};function Uk(t){const e=t.toUpperCase().replace(/[_\-.,/\\()[\]:;+]+/g," ").split(/\s+/).filter(s=>s.length>0).filter(s=>!/^\d+$/.test(s)).filter(s=>!/^\d+X\d+$/.test(s)).filter(s=>!/^FOV\d*$/.test(s)).filter(s=>!/^\d+(\.\d+)?(MM|CM)$/.test(s));return[...new Set(e)]}function $k(t,e){if(t.length===0||e.length===0)return 0;const s=new Set(t);return e.filter(n=>s.has(n)).length/Math.min(t.length,e.length)}function vz(t){const e=new Map;for(const r of t)e.set(r,(e.get(r)??0)+1);const s=[...e.keys()].sort((r,o)=>(e.get(o)??0)-(e.get(r)??0)||(r<o?-1:1)),i=[],n=new Map;for(const r of s){const o=Uk(r),a=o.length===0?void 0:i.find(l=>$k(l.words,o)>=Pk);if(a!==void 0){n.set(r,a.name);continue}i.push({name:r,words:o}),n.set(r,r)}return n}function wz(t,e){const s=t.data?.format??"unread",i=[{key:s,label:Fk[s]??s.toUpperCase()}];if(s!=="dicom")return i;const n=t.data?.modality??"NO MODALITY";i.push({key:`${s}/${n}`,label:n});const r=t.data?.seriesDescription,o=r===void 0?"NO DESCRIPTION":e.get(r)??r;return i.push({key:`${s}/${n}/${o}`,label:o}),i}function ou(t){return`${ip}${t}`}function np(t){return t.startsWith(ip)?t.slice(ip.length):null}function Db(t,e="jobs"){const s=[...t].filter(h=>h.groups.length>0).sort((h,d)=>h.id-d.id),i=vz(s.map(h=>h.data?.seriesDescription).filter(h=>h!==void 0)),n=new Map,r=[];for(const h of s){const d=wz(h,i);let u=null;for(const f of d){const _=n.get(f.key);_===void 0?n.set(f.key,{label:f.label,feeds:1,parent:u}):_.feeds+=1,u=f.key}const p=ou(u);h.groups.forEach((f,_)=>{const g=xg(f);r.push({id:zr(h.id,_),label:f.plugin,parentIds:[f.parent===null?p:zr(h.id,f.parent)],joinParentIds:[],status:f.status,metric:e==="jobs"?Pl(f.count):1,...f.count>1?{count:f.count}:{},...g!==void 0?{share:g}:{}})})}const o=new Map;for(const h of s){const d=h.groups.findIndex(u=>u.parent===null);d>=0&&o.set(h.id,zr(h.id,d))}const a=new Map(r.map(h=>[h.id,h]));for(const h of s){const d=h.data?.sourceFeed,u=d===void 0||d===h.id?void 0:o.get(d),p=o.get(h.id);if(u===void 0||p===void 0)continue;const f=a.get(p);f!==void 0&&(f.joinParentIds=[...f.joinParentIds,u],f.joinFaint=!0)}const l=(h,d)=>h.split("/").length<3||d>=Math.max(Lk,Wk*s.length);return{graph:{nodes:[...[...n].map(([h,d])=>({id:ou(h),label:d.label,parentIds:d.parent===null?[]:[ou(d.parent)],joinParentIds:[],ghost:!0,halo:!0,metric:1,count:d.feeds,...l(h,d.feeds)?{caption:`${d.label} · ${d.feeds.toLocaleString("en-US")}`}:{}})),...r]},hubs:new Map([...n].map(([h,d])=>[h,{label:d.label,feeds:d.feeds}]))}}function jk(t,e){const s=np(t);if(s===null)return null;const i=s.split("/"),n=i.map((o,a)=>e.get(i.slice(0,a+1).join("/"))?.label??i[a]??""),r=e.get(s)?.feeds??0;return`${n.join(" · ")} · ${r.toLocaleString("en-US")} feed${r===1?"":"s"}`}const rp=12,Hk=240;function Vk(t){return t<=Hk?rp:void 0}function op(t,e){return`fold:${t}:${e}`}function yz(t){const e=t.match(/^fold:(.+):\d+$/);return e===null?null:e[1]}function qk(t){const e=t.match(/^feed:(\d+):/);if(e!==null)return`feed:${e[1]}`;const s=yz(t);return s===null?null:`fold:${s}`}const Kk=se({at:Q(),method:G(),family:G(),path:G(),status:Q(),ms:Q()}),Yk=se({family:G(),count:Q(),ms:Q()});se({since:G(),total:Q(),ms:Q(),families:je(Yk),last:je(Kk)});const zz="stratus.domains",Xk=se({folder:G(),state:G(),name:G().optional(),evidence:G().optional(),started:G().nullable().optional(),ended:G().nullable().optional()}),Zk=["SIZING","STOPPED","ASKING","BUILDING","UP","SERVING","FAILED","GONE"],Ib=se({count:Q(),vcpu:Q(),ramGib:Q(),bootGib:Q(),bootTier:G()}),Sz=se({family:G(),controlPlane:Ib,workers:Ib,chris:se({dataGib:Q(),databaseGib:Q(),queueGib:Q()})}),Jk=se({action:G(),kind:G(),count:Q(),names:je(G())}),Qk=se({create:Q(),replace:Q(),change:Q(),drift:Q(),destroy:Q(),groups:je(Jk),at:G().nullable()}),e2=se({name:G(),ok:wt().nullable(),detail:G(),how:G()}),xz=se({name:G(),path:G(),cluster:G().nullable(),lastDone:G().nullable(),steps:je(Xk),resources:jh(G(),Q()).nullable(),cost:se({hourly:Q(),soFar:Q(),currency:G()}).nullable().optional(),condition:kt(Zk).optional(),billing:wt().optional(),origin:kt(["built","adopted","checkout","found"]).optional(),protected:wt().optional(),refused:jh(G(),G()).optional(),region:G().nullable().optional(),compartment:G().nullable().optional(),gone:G().nullable().optional(),spec:Sz.nullable().optional(),next:G().nullable().optional(),billingStep:G().optional(),running:se({job:G(),step:G().nullable(),since:G().nullable()}).nullable().optional(),plan:Qk.nullable().optional(),verify:se({at:G().nullable(),checks:je(e2)}).nullable().optional(),asking:G().nullable().optional()}),Oz=se({domains:je(xz)}),t2="stratus.domain.state",s2="stratus.domain.size",i2=se({region:G(),family:G(),families:je(G()),vcpuPerCore:Q(),cores:se({min:Q(),max:Q()}).nullable(),memoryGib:se({min:Q(),max:Q()}).nullable(),zones:je(se({zone:G(),coresFree:Q().nullable(),memoryFree:Q().nullable()})),price:se({vcpuHour:Q(),gibHour:Q(),currency:G()}).nullable(),services:se({volumeGibMonth:Q(),vpuGibMonth:Q(),balancerHour:Q(),balancerMbpsHour:Q()}).nullable(),start:Sz,baseDomain:G().nullable(),dnsZones:je(G()).optional()}),Ez="stratus.capacity",n2=se({family:G(),limit:G(),zone:G().nullable(),value:Q(),used:Q().nullable(),available:Q().nullable()}),Az=se({region:G(),rows:je(n2)}),Tz=/^\d+-.*-[0-9a-f]{7}$/,Cb="/SERVICES/PACS/",r2=4;function au(t,e){if(Tz.test(e))return!0;if(!t.startsWith(Cb))return!1;const s=t.slice(Cb.length).replace(/\/+$/,"");return s!==""&&s.split("/").length===r2}const o2="daemon";function a2(t){return t.backend??"chris"}class Eg{socket;handlers;token;pending=new Map;pendingCompletions=new Map;silentIds=new Set;nextId=0;mirroring=!1;constructor(e,s,i){this.socket=e,this.handlers=s,this.token=i,this.socket.onmessage=n=>this.message_handle(String(n.data)),this.socket.onclose=()=>this.handlers.close_handle?.()}static session_attach(e,s,i){return new Promise((n,r)=>{const o=new WebSocket(e);o.onerror=()=>r(new Error(`cannot reach the daemon at ${e}`)),o.onopen=()=>{o.send(JSON.stringify({type:"attach",protocolVersion:Uf,token:s,capabilities:{shellCommands:!1,color:!0,hiddenInput:!0,fileDelivery:!0,localFilesystem:!1}}))},o.onmessage=a=>{const l=Rb(String(a.data));if(!l){r(new Error("invalid attach response")),o.close();return}if(l.type==="error"){r(new Error(l.reason)),o.close();return}if(l.type!=="attached"){r(new Error(`unexpected attach response: ${l.type}`)),o.close();return}const c=new Eg(o,i,s);n({client:c,attach:{session:l.session,protocolVersion:l.protocolVersion,...l.stack!==void 0?{stack:l.stack}:{},...l.hostControl!==void 0?{hostControl:l.hostControl}:{},...l.stale!==void 0?{stale:l.stale}:{},...l.terminals!==void 0?{terminals:l.terminals}:{},...l.surface!==void 0?{surface:l.surface}:{},...l.backend!==void 0?{backend:l.backend}:{}}})}})}line_execute(e,s){const i=`argus-${this.nextId++}`;return s?.silent===!0&&this.silentIds.add(i),new Promise((n,r)=>{this.pending.set(i,{resolve:n,reject:r,liveChannels:new Set,observed:s?.observe!==!1}),this.socket.send(JSON.stringify({type:"execute",id:i,line:e,...s?.silent===!0&&s.operator!==!0?{instrument:!0}:{},...this.mirroring&&s?.silent!==!0?{mirrored:!0}:{}}))})}mirror_set(e){this.mirroring=e}terminal_open(e,s,i){this.socket.send(JSON.stringify({type:"terminalOpen",cols:e,rows:s,...i===void 0?{}:{terminalId:i}}))}terminal_input(e,s){this.socket.send(JSON.stringify({type:"terminalInput",terminalId:e,data:s}))}terminal_resize(e,s,i){this.socket.send(JSON.stringify({type:"terminalResize",terminalId:e,cols:s,rows:i}))}line_complete(e){const s=`argus-c-${this.nextId++}`;return new Promise((i,n)=>{this.pendingCompletions.set(s,{resolve:i,reject:n}),this.socket.send(JSON.stringify({type:"complete",id:s,prefix:e}))})}terminalMessage_handle(e){e.type==="terminalOpened"?this.handlers.terminalOpened_receive?.(e.terminalId,e.replay,e.refused):e.type==="terminalData"?this.handlers.terminalData_receive?.(e.terminalId,e.data):this.handlers.terminalExit_receive?.(e.terminalId,e.code)}surfaceLine_handle(e,s,i){const n=this.handlers.surfaceLine_receive;if(n===void 0){this.socket.send(JSON.stringify({type:"surfaceLineError",lineId:e,reason:"this surface runs no lines of its own"}));return}n(s,i).then(r=>{this.socket.send(JSON.stringify({type:"surfaceLineResult",lineId:e,rendered:r.rendered,status:r.status}))},r=>{this.socket.send(JSON.stringify({type:"surfaceLineError",lineId:e,reason:r instanceof Error?r.message:String(r)}))})}claims_send(e){this.socket.send(JSON.stringify({type:"surfaceClaims",claims:e}))}note_send(e){this.socket.send(JSON.stringify({type:"note",text:e}))}stop_send(){this.socket.send(JSON.stringify({type:"stop"}))}regard_send(e){this.socket.send(JSON.stringify({type:"regard",regard:e}))}watch_send(e){this.socket.send(JSON.stringify({type:"watch",subject:e}))}unwatch_send(e){this.socket.send(JSON.stringify({type:"unwatch",subject:e}))}connection_close(){this.socket.close()}message_handle(e){const s=Rb(e);if(l2(s?.type??`refused:${c2(e)}`),!!s)switch(s.type){case"result":{this.silentIds.delete(s.id);const i=this.pending.get(s.id);if(i&&(this.pending.delete(s.id),i.resolve({envelopes:s.envelopes,liveChannels:i.liveChannels})),i===void 0||i.observed)for(const n of s.envelopes)this.handlers.envelope_observe?.(n);break}case"complete":{const i=this.pendingCompletions.get(s.id);i&&(this.pendingCompletions.delete(s.id),i.resolve({candidates:s.candidates,prefix:s.prefix}));break}case"output":{(s.channel==="data"||s.channel==="err")&&this.pending.get(s.id)?.liveChannels.add(s.channel),this.silentIds.has(s.id)||this.handlers.output_receive?.(s.channel,s.chunk);break}case"progress":{this.handlers.progress_receive?.(s);break}case"event":{this.handlers.event_receive?.(s.id,s.kind,s.data);break}case"session":{if(s.surface===o2){this.handlers.ambient_receive?.(s.envelope);break}this.handlers.session_receive?.(s.surface,s.envelope,s.terminal),this.handlers.envelope_observe?.(s.envelope);break}case"watched":{this.handlers.watched_receive?.(s.subject,s.state);break}case"stale":this.handlers.stale_receive?.(s.stale);break;case"surfaceLine":this.surfaceLine_handle(s.lineId,s.line,s.terminal);break;case"terminalOpened":case"terminalData":case"terminalExit":this.terminalMessage_handle(s);break;case"closing":this.handlers.closing_receive?.(s.cause);break;case"numbered":{this.handlers.numbered_receive?.({id:s.id,source:s.source,rows:s.rows,handles:s.handles});break}case"promptline":this.handlers.promptline_receive?.(s.context);break;case"telemetry":this.handlers.telemetry_receive?.(s.index,{lane:s.lane,cube:s.cube,state:s.state,surfaces:s.surfaces});break;case"regard":this.handlers.regard_receive?.(s.regard);break;case"error":{if(s.id!==void 0){const i=this.pending.get(s.id);i&&(this.pending.delete(s.id),i.reject(new Error(s.reason)));const n=this.pendingCompletions.get(s.id);n&&(this.pendingCompletions.delete(s.id),n.reject(new Error(s.reason)))}break}case"prompt":{const i=this.handlers.ask_receive;if(i===void 0){this.reply_send({type:"promptError",promptId:s.promptId,reason:"this surface has no way to ask"});break}const n=s.promptId;i({message:s.message,kind:IR(s),...s.path?.suggest===void 0?{}:{suggest:s.path.suggest},...s.path===void 0?{}:{path:s.path},...s.commit===void 0?{}:{commit:s.commit}}).then(r=>{if(r===null){this.reply_send({type:"promptError",promptId:n,reason:"the operator abandoned the question"});return}this.reply_send({type:"promptAnswer",promptId:n,answer:r})}).catch(r=>{const o=r instanceof Error?r.message:"the question could not be answered";this.reply_send({type:"promptError",promptId:n,reason:o})});break}case"pipe":{this.reply_send({type:"pipeError",pipeId:s.pipeId,reason:"the argus surface cannot run pipeline segments"});break}case"shell":{this.reply_send({type:"shellError",shellId:s.shellId,reason:"the argus surface cannot run shell commands"});break}case"edit":{this.edit_run(s);break}case"deliver":{this.deliver_run(s);break}}}edit_run(e){const s=this.handlers.edit_receive;let i=!1,n="the argus surface cannot open an editor";if(s!==void 0)try{i=s({content:e.content,...e.path===void 0?{}:{path:e.path},...e.extension===void 0?{}:{extension:e.extension}}),n="the editor pane did not open"}catch(r){n=r instanceof Error?r.message:String(r)}if(i){this.reply_send({type:"editResult",editId:e.editId,content:e.content,changed:!1,opened:!0});return}this.reply_send({type:"editError",editId:e.editId,reason:n})}async deliver_run(e){try{const s=ag(e.path,this.token),i=await fetch(s);if(!i.ok)throw new Error(`calypso refused to serve this file (HTTP ${i.status})`);const n=await i.blob(),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=e.filename,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(r),0),this.reply_send({type:"deliverResult",deliverId:e.deliverId,location:e.filename,bytes:n.size})}catch(s){const i=s instanceof Error?s.message:String(s);this.reply_send({type:"deliverError",deliverId:e.deliverId,reason:i})}}reply_send(e){this.socket.send(JSON.stringify(e))}}const ap={};typeof window<"u"&&(window.__argusWire=ap);function l2(t){ap[t]=(ap[t]??0)+1}function c2(t){try{const e=JSON.parse(t).type;return typeof e=="string"?e:"?"}catch{return"?"}}function Rb(t){try{const e=KR(JSON.parse(t));return e.ok&&e.value!==void 0?e.value:null}catch{return null}}const Zi=["#000000","#f24444","#33cc66","#ffaa44","#5599ff","#cc88ff","#44cccc","#ffeecc","#777777","#ff6666","#66ee99","#ffcc66","#77bbff","#dd99ff","#66dddd","#ffffff"],h2=Zi,d2={yellow:Zi[3],white:Zi[7],cyan:Zi[6],green:Zi[2],magenta:Zi[5]};function Dz(){return{fg:null,bg:null,bold:!1,dim:!1,italic:!1,inverse:!1,underline:!1}}function u2(t){if(t<16)return Zi[t]??"#ffeecc";if(t<232){const s=t-16,i=[0,95,135,175,215,255],n=i[Math.floor(s/36)%6]??0,r=i[Math.floor(s/6)%6]??0,o=i[s%6]??0;return`#${(n<<16|r<<8|o).toString(16).padStart(6,"0")}`}const e=8+(t-232)*10;return`#${(e<<16|e<<8|e).toString(16).padStart(6,"0")}`}function f2(t,e){for(let s=0;s<e.length;s++){const i=e[s]??0;if(i===0)Object.assign(t,Dz());else if(i===1)t.bold=!0;else if(i===2)t.dim=!0;else if(i===3)t.italic=!0;else if(i===4)t.underline=!0;else if(i===7)t.inverse=!0;else if(i===27)t.inverse=!1;else if(i===22)t.bold=!1,t.dim=!1;else if(i===23)t.italic=!1;else if(i===24)t.underline=!1;else if(i>=30&&i<=37)t.fg=Zi[i-30]??null;else if(i>=90&&i<=97)t.fg=Zi[i-90+8]??null;else if(i===39)t.fg=null;else if(i>=40&&i<=47)t.bg=Zi[i-40]??null;else if(i>=100&&i<=107)t.bg=Zi[i-100+8]??null;else if(i===49)t.bg=null;else if(i===38||i===48){const n=e[s+1]??0;let r=null;if(n===5)r=u2(e[s+2]??0),s+=2;else if(n===2){const o=e[s+2]??0,a=e[s+3]??0,l=e[s+4]??0;r=`#${(o<<16|a<<8|l).toString(16).padStart(6,"0")}`,s+=4}i===38?t.fg=r:t.bg=r}}}function p2(t){const e=[],s=t.inverse?t.bg??"#000":t.fg,i=t.inverse?t.fg??"var(--daybreak)":t.bg;return s!==null&&e.push(`color:${s}`),i!==null&&e.push(`background-color:${i}`),t.bold&&e.push("font-weight:bold"),t.dim&&e.push("opacity:0.55"),t.italic&&e.push("font-style:italic"),t.underline&&e.push("text-decoration:underline"),e.join(";")}function si(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}const lu=/\x1b(?:\[([0-?]*)[ -/]*([@-~])|\][^\x07\x1b]*(?:\x07|\x1b\\)|[@-Z\\-_])/g;function Cn(t){const e=Dz();let s="",i=0;const n=o=>{if(o.length===0)return;const a=p2(e),l=si(o.replace(/\r/g,""));s+=a.length>0?`<span style="${a}">${l}</span>`:l};lu.lastIndex=0;let r=lu.exec(t);for(;r!==null;){if(n(t.slice(i,r.index)),i=r.index+r[0].length,r[2]==="m"){const o=(r[1]??"").split(/[;:]/).map(a=>a.length>0?Number(a):0);f2(e,o)}r=lu.exec(t)}return n(t.slice(i)),s}function m2(t){for(const[e,s]of Object.entries(d2))t.style.setProperty(`--console-${e}`,s)}const g2=3e3,_2=28;function b2(t,e){if(t===null)return'<span class="dim">argus</span>';const s=t.segments??[],i=s.length>0?M2(s,e):w2(t,e);return i.push(...y2(t,e)),z2(i,e)}function M2(t,e){const s={cloud:e.glyphs.cloud,tenancy:e.glyphs.cube,region:e.glyphs.globe,user:e.glyphs.user,domain:e.glyphs.sitemap,cwd:e.glyphs.folder},i={leader:e.palette.host,place:e.palette.pacs,identity:e.palette.user,path:e.palette.dir,work:e.palette.duration,note:e.palette.time,alert:e.palette.status};return t.map(n=>{const r=s[n.key],o=n.tone==="identity"?v2(n.value):n.value;return{text:r!==void 0?`${r} ${o}`:o,color:i[n.tone],...o!==n.value?{title:n.value}:{}}})}function v2(t){return t.length<=_2?t:`…${t.slice(-27)}`}function w2(t,e){const s=t.uri.replace(/^https?:\/\//,"").replace(/\/api\/v1\/?$/,""),i=`/home/${t.user}`,n=t.cwd.startsWith(i)?`~${t.cwd.slice(i.length)}`:t.cwd,r=[];if(t.pacsserver!==null&&t.pacsserver.length>0&&r.push({text:`${e.glyphs.database} ${t.pacsserver}`,color:e.palette.pacs}),r.push({text:`${e.glyphs.cube} ${s}`,color:e.palette.host},{text:`${e.glyphs.user} ${t.user}`,color:e.palette.user},{text:`${e.glyphs.folder} ${n}`,color:e.palette.dir}),t.procWarmup!==void 0){const o=BO(t.procWarmup),a=e.procStates[o];r.push({text:`${a.icon} ${a.label}: ${S2(t.procWarmup.loaded,t.procWarmup.total??0)}`,color:a.color})}return r}function y2(t,e){const s=[];if(t.physicalMode&&s.push({text:`${e.glyphs.microscope} PHYSICAL`,color:e.palette.physical}),t.lastCommandDurationMs>=g2){const i=Math.floor(t.lastCommandDurationMs/1e3);s.push({text:`${e.glyphs.bolt} ${i}s`,color:e.palette.duration})}return t.lastExitCode!==0&&s.push({text:`${e.glyphs.error} ${t.lastExitCode}`,color:e.palette.status}),s}function z2(t,e){let s="";for(let i=0;i<t.length;i++){const n=t[i];if(n===void 0)continue;const r=n.title!==void 0?` title="${si(n.title)}"`:"";s+=`<span style="color:${n.color.fg};background-color:${n.color.bg}"${r}> ${si(n.text)} </span>`;const o=t[i+1];s+=o!==void 0?`<span style="color:${n.color.bg};background-color:${o.color.bg}">${e.glyphs.powerline}</span>`:`<span style="color:${n.color.bg}">${e.glyphs.powerline}</span>`}return s}function S2(t,e){if(e<=0)return`${t}/?`;const s=Math.min(99,Math.floor(t/e*100));return`${t}/${e} ${s}%`}const x2={pacs:{bg:"#875FFF",fg:"#FFFFFF"},host:{bg:"#00AFFF",fg:"#001018"},user:{bg:"#00D787",fg:"#00140C"},dir:{bg:"#FFD75F",fg:"#201800"},physical:{bg:"#FF5F5F",fg:"#1B0000"},duration:{bg:"#FF8700",fg:"#201000"},status:{bg:"#FF005F",fg:"#FFFFFF"},time:{bg:"#5F5F87",fg:"#FFFFFF"}},O2={cold:{icon:"",label:"proc cold",color:{bg:"#FF8700",fg:"#201000"}},cached:{icon:"",label:"proc cached, refreshing",color:{bg:"#5F5F87",fg:"#FFFFFF"}},failed:{icon:"",label:"proc failed",color:{bg:"#FF005F",fg:"#FFFFFF"}}},E2={powerline:"",cube:"",database:"",user:"",folder:"",microscope:"",bolt:"",error:"",cloud:"",globe:"",sitemap:""},A2=200;class T2{output;clear(){this.output.replaceChildren()}splashGreeting=null;progressRegion;promptBar;inputGlyph;input;submit;complete;promptContext=null;busy=!0;delegate=null;mirrorPending="";container;pendingAsk=null;queuedLines=[];questionOpen=!1;history=[];historyIndex=0;streamBlock=null;streamPendingElement=null;streamPendingText="";streamPendingChannel="data";constructor(e,s,i){this.submit=s,this.complete=i,this.container=e,e.innerHTML=`
|
|
61
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const o of t.seen.entries()){const a=o[1];if(e===o[0]){r(o);continue}if(t.external){const c=t.external.registry.get(o[0])?.id;if(e!==o[0]&&c){r(o);continue}}if(t.metadataRegistry.get(o[0])?.id){r(o);continue}if(a.cycle){r(o);continue}a.count>1&&t.reused==="ref"&&r(o)}t.external&&(t.sharedDefsExtractedFor=t.external)}function Vy(t){const e=t.anyOf;if(!Array.isArray(e)||e.length===0||t.type!==void 0)return;const s=[];for(const i of e){if(!i||typeof i!="object")return;Vy(i);const n=Object.keys(i);if(n.length!==1||n[0]!=="type")return;const r=i.type;for(const o of Array.isArray(r)?r:[r]){if(typeof o!="string")return;s.includes(o)||s.push(o)}}delete t.anyOf,t.type=s.length===1?s[0]:s}const qy=new Set(["type","properties","required","additionalProperties"]),_b=["oneOf","anyOf"];function bb(t){const e=t.additionalProperties;return e===void 0||e===!1||typeof e!="object"||e===null?null:Object.keys(e).length?e:null}function Yf(t){const e=[];for(const r of t){if(typeof r!="object"||r.type!=="object")return null;for(const o in r)if(!qy.has(o))return null;e.push(r)}const s={},i=new Set;for(const r of e){for(const o in r.properties){if(Object.prototype.hasOwnProperty.call(s,o))continue;const a=[];for(const c of e){const h=c.properties?.[o]??bb(c);h!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(h))||a.push(h))}const l=a.length===1?a[0]:Yf(a)??{allOf:a};Yn(s,o,l)}for(const o of r.required??[])i.add(o)}const n={type:"object",properties:s};if(i.size&&(n.required=[...i]),e.every(r=>r.additionalProperties===!1))n.additionalProperties=!1;else{const r=[];for(const o of e){const a=bb(o);a&&!r.some(l=>JSON.stringify(l)===JSON.stringify(a))&&r.push(a)}r.length===1?n.additionalProperties=r[0]:r.length>1&&(n.additionalProperties={allOf:r})}return n}function BD(t){const e=t.allOf;if(!Array.isArray(e)||e.length<2)return;for(const n of qy)if(n in t)return;const s=e.filter(n=>_b.some(r=>Array.isArray(n[r])));let i=null;if(!s.length)i=Yf(e);else{const n=s[0],r=_b.find(l=>Array.isArray(n[l]));if(Object.keys(n).length!==1)return;const o=e.filter(l=>l!==n),a=n[r].map(l=>Yf([...o,l]));if(a.some(l=>!l))return;i={[r]:a}}i&&(delete t.allOf,Ol(t,i))}function Ky(t,e){const s=t.seen.get(e);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=a=>{const l=t.seen.get(a);if(l.ref===null)return;const c=l.def??l.schema,h={...c},d=l.ref;if(l.ref=null,d){i(d);const p=t.seen.get(d),f=p.schema;if(f.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(f)):Ol(c,f),Ol(c,h),a._zod.parent===d)for(const g in c)g==="$ref"||g==="allOf"||g in h||delete c[g];if(f.$ref&&p.def)for(const g in c)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(c[g])===JSON.stringify(p.def[g])&&delete c[g]}const u=a._zod.parent;if(u&&u!==d){i(u);const p=t.seen.get(u);if(p?.schema.$ref&&(c.$ref=p.schema.$ref,p.def))for(const f in c)f==="$ref"||f==="allOf"||f in p.def&&JSON.stringify(c[f])===JSON.stringify(p.def[f])&&delete c[f]}t.override({zodSchema:a,jsonSchema:c,path:l.path??[]})};if(!t.external||t.sharedEmitDoneFor!==t.external){for(const a of[...t.seen.entries()].reverse())i(a[0]);if(t.target!=="openapi-3.0")for(const a of t.seen.entries())Vy(a[1].def??a[1].schema);for(const a of t.deferred)a();if(t.intersections.length){const a=new Map;for(const l of t.seen.values())for(const c of[l.schema,l.def]){const h=c?.allOf;if(!Array.isArray(h))continue;const d=a.get(h);d?d.push(c):a.set(h,[c])}for(const l of t.intersections)for(const c of a.get(l)??[])BD(c)}}const n={};if(t.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){const a=t.external.registry.get(e)?.id;if(!a)throw new Error("Schema is missing an `id` property");n.$id=t.external.uri(a)}Ol(n,s.defId?s.schema:s.def??s.schema);const r=t.metadataRegistry.get(e)?.id;r!==void 0&&n.id===r&&delete n.id;const o=t.external?.defs??{};if(!t.external||t.sharedEmitDoneFor!==t.external)for(const a of t.seen.entries()){const l=a[1];l.def&&l.defId&&(l.def.id===l.defId&&delete l.def.id,Yn(o,l.defId,l.def))}t.external&&(t.sharedEmitDoneFor=t.external),t.external||Object.keys(o).length>0&&(t.target==="draft-2020-12"?n.$defs=o:n.definitions=o);try{const a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,"~standard",{value:{...e["~standard"],jsonSchema:{input:$h(e,"input",t.processors),output:$h(e,"output",t.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Vs(t,e){const s=e??{seen:new Set};if(s.seen.has(t))return!1;s.seen.add(t);const i=t._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Vs(i.element,s);if(i.type==="set")return Vs(i.valueType,s);if(i.type==="lazy")return Vs(i.getter(),s);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return Vs(i.innerType,s);if(i.type==="intersection")return Vs(i.left,s)||Vs(i.right,s);if(i.type==="record"||i.type==="map")return Vs(i.keyType,s)||Vs(i.valueType,s);if(i.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:Vs(i.in,s)||Vs(i.out,s);if(i.type==="object"){for(const n in i.shape)if(Vs(i.shape[n],s))return!0;return!1}if(i.type==="union"){for(const n of i.options)if(Vs(n,s))return!0;return!1}if(i.type==="tuple"){for(const n of i.items)if(Vs(n,s))return!0;return!!(i.rest&&Vs(i.rest,s))}return!1}const GD=(t,e={})=>s=>{const i=jy({...s,processors:e});return Jt(t,i),Hy(i,t),Ky(i,t)},$h=(t,e,s={})=>i=>{const{libraryOptions:n,target:r}=i??{},o=jy({...n??{},target:r,io:e,processors:s});return Jt(t,o),Hy(o,t),Ky(o,t)},ha=(t,e,s)=>{(t[e]===void 0||s>t[e])&&(t[e]=s)},da=(t,e,s)=>{(t[e]===void 0||s<t[e])&&(t[e]=s)},Mb=(t,e)=>{ha(t,"minimum",e),da(t,"maximum",e)},Yy=(t,e)=>{t.multipleOf??(t.multipleOf=[]),t.multipleOf.includes(e)||t.multipleOf.push(e)},Xy=(t,e)=>{t.patterns??(t.patterns=new Set),t.patterns.add(e)},Zy=(t,e)=>{t.mime=t.mime?t.mime.filter(s=>e.includes(s)):[...e]},Jy=(t,e)=>{t.format=e,e.includes("int")&&(t.isInt=!0)},vb=(t,e)=>ha(t,"minimum",e.minimum),wb=(t,e)=>da(t,"maximum",e.maximum),yb=t=>(e,s)=>{Jy(e,s.format);const[i,n]=t[s.format];ha(e,"minimum",i),da(e,"maximum",n)},PD={greater_than:(t,e)=>ha(t,e.inclusive?"minimum":"exclusiveMinimum",e.value),less_than:(t,e)=>da(t,e.inclusive?"maximum":"exclusiveMaximum",e.value),multiple_of:(t,e)=>Yy(t,e.value),number_format:yb(by),bigint_format:yb(JO),min_length:vb,max_length:wb,length_equals:(t,e)=>Mb(t,e.length),min_size:vb,max_size:wb,size_equals:(t,e)=>Mb(t,e.size),string_format:(t,e)=>{Jy(t,e.format),e.pattern&&Xy(t,e.pattern),(e.format==="base64"||e.format==="base64url")&&(t.contentEncoding=e.format),(e.local||e.precision===-1)&&(t.laxFormat=!0)},mime_type:(t,e)=>Zy(t,e.mime)};function Bi(t){const e={},s=t._zod.def,i=t._zod.traits.has("$ZodCheck")?[t,...s.checks??[]]:s.checks??[];for(const r of i)PD[r._zod.def.check]?.(e,r._zod.def);const n=t._zod.bag;n.minimum!==void 0&&ha(e,"minimum",n.minimum),n.exclusiveMinimum!==void 0&&ha(e,"exclusiveMinimum",n.exclusiveMinimum),n.maximum!==void 0&&da(e,"maximum",n.maximum),n.exclusiveMaximum!==void 0&&da(e,"exclusiveMaximum",n.exclusiveMaximum),n.multipleOf!==void 0&&Yy(e,n.multipleOf),n.format!==void 0&&(e.format??(e.format=n.format),n.format.includes("int")&&(e.isInt=!0)),n.mime&&Zy(e,n.mime);for(const r of n.patterns??[])Xy(e,r);return e}const LD={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},WD=new Map([[Ry,QE],[Mg,eA]]),Qy=t=>WD.get(t)??t,FD=(t,e,s,i)=>{const n=s;n.type="string";const{minimum:r,maximum:o,format:a,patterns:l,contentEncoding:c,laxFormat:h}=Bi(t);if(typeof r=="number"&&(n.minLength=r),typeof o=="number"&&(n.maxLength=o),a&&(n.format=LD[a]??a,n.format===""&&delete n.format,(a==="time"||h)&&delete n.format),c&&(n.contentEncoding=c),l&&l.size>0){const d=[...l].map(Qy);d.length===1?n.pattern=d[0].source:d.length>1&&(n.allOf=[...d.map(u=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:u.source}))])}},UD=(t,e,s,i)=>{const n=s,{minimum:r,maximum:o,multipleOf:a,exclusiveMaximum:l,exclusiveMinimum:c,isInt:h}=Bi(t);n.type=h?"integer":"number";const d=typeof c=="number"&&c>=(r??Number.NEGATIVE_INFINITY),u=typeof l=="number"&&l<=(o??Number.POSITIVE_INFINITY),p=e.target==="draft-04"||e.target==="openapi-3.0";if(d?p?(n.minimum=c,n.exclusiveMinimum=!0):n.exclusiveMinimum=c:typeof r=="number"&&(n.minimum=r),u?p?(n.maximum=l,n.exclusiveMaximum=!0):n.exclusiveMaximum=l:typeof o=="number"&&(n.maximum=o),a){const f=new Set;for(const m of a)Number.isFinite(m)&&m!==0?f.add(Math.abs(m)):Rr(t,e,n,i,`A multipleOf divisor of ${m} cannot be represented in JSON Schema`);const[_,...g]=f;_!==void 0&&(n.multipleOf=_),g.length&&(n.allOf=[...n.allOf??[],...g.map(m=>({multipleOf:m}))])}},$D=(t,e,s,i)=>{s.type="boolean"},jD=(t,e,s,i)=>{s.not={}},HD=(t,e,s,i)=>{},VD=(t,e,s,i)=>{const n=t._zod.def,r=$f(n.entries);if(r.length===0){s.not={};return}r.every(o=>typeof o=="number")&&(s.type="number"),r.every(o=>typeof o=="string")&&(s.type="string"),s.enum=r},qD=(t,e,s,i)=>{const n=t._zod.def;if(n.values.length===0){s.not={};return}const r=[];for(const o of n.values)if(o===void 0){if(Rr(t,e,s,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o=="bigint"){if(Rr(t,e,s,i,"BigInt literals cannot be represented in JSON Schema"))return;r.push(Number(o))}else r.push(o);if(r.length!==0)if(r.length===1){const o=r[0];s.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?s.enum=[o]:s.const=o}else r.every(o=>typeof o=="number")&&(s.type="number"),r.every(o=>typeof o=="string")&&(s.type="string"),r.every(o=>typeof o=="boolean")&&(s.type="boolean"),r.every(o=>o===null)&&(s.type="null"),s.enum=r},KD=(t,e,s,i)=>{Rr(t,e,s,i,"Custom types cannot be represented in JSON Schema")},YD=(t,e,s,i)=>{Rr(t,e,s,i,"Transforms cannot be represented in JSON Schema")},XD=(t,e,s,i)=>{const n=s,r=t._zod.def,{minimum:o,maximum:a}=Bi(t);typeof o=="number"&&(n.minItems=o),typeof a=="number"&&(n.maxItems=a),n.type="array",n.items=Jt(r.element,e,{...i,path:[...i.path,"items"]})};function Gl(t){const e=t._zod.def;return e.type==="pipe"&&e.in._zod.traits.has("$ZodTransform")?Gl(e.out):e.type==="catch"?Gl(e.innerType):t._zod.optin}const ZD=(t,e,s,i)=>{const n=s,r=t._zod.def,o=r.shape;if(Object.getOwnPropertySymbols(o).length&&Rr(t,e,n,i,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(const c in o)Yn(n.properties,c,Jt(o[c],e,{...i,path:[...i.path,"properties",c]}));const l=[];for(const c of Object.keys(o)){const h=r.shape[c];(e.io==="input"?Gl(h)===void 0:h._zod.optout===void 0)&&l.push(c)}l.length>0&&(n.required=l),r.catchall?._zod.def.type==="never"?n.additionalProperties=!1:r.catchall?r.catchall&&(n.additionalProperties=Jt(r.catchall,e,{...i,path:[...i.path,"additionalProperties"]})):e.io==="output"&&(n.additionalProperties=!1)},JD=(t,e,s,i)=>{const n=t._zod.def,r=n.inclusive===!1,o=n.options.map((a,l)=>Jt(a,e,{...i,path:[...i.path,r?"oneOf":"anyOf",l]}));r?s.oneOf=o:s.anyOf=o},QD=(t,e,s,i)=>{const n=t._zod.def,r=Jt(n.left,e,{...i,path:[...i.path,"allOf",0]}),o=Jt(n.right,e,{...i,path:[...i.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1,l=[...a(r)?r.allOf:[r],...a(o)?o.allOf:[o]];s.allOf=l,e.intersections.push(l)},eI=(t,e,s,i)=>{const n=s,r=t._zod.def;n.type="array";const o=e.target==="draft-2020-12"?"prefixItems":"items",a=e.target==="draft-2020-12"||e.target==="openapi-3.0"?"items":"additionalItems",l=r.items.map((_,g)=>Jt(_,e,{...i,path:[...i.path,o,g]})),c=r.rest?Jt(r.rest,e,{...i,path:[...i.path,a,...e.target==="openapi-3.0"?[r.items.length]:[]]}):null;let h=r.items.length;for(;h>0;){const _=r.items[h-1];if(!(e.io==="input"?Gl(_)!==void 0:_._zod.optout==="optional"))break;h--}const d=r.items.length,u=!r.rest;e.target==="draft-2020-12"?(n.prefixItems=l,u?n.items=!1:c&&(n.items=c),h>0&&(n.minItems=h),u&&(n.maxItems=d)):e.target==="openapi-3.0"?(n.items={anyOf:l},c&&n.items.anyOf.push(c),h>0&&(n.minItems=h),u&&(n.maxItems=d)):(n.items=l,u?n.additionalItems=!1:c&&(n.additionalItems=c),h>0&&(n.minItems=h),u&&(n.maxItems=d));const{minimum:p,maximum:f}=Bi(t);typeof p=="number"&&(n.minItems=p),typeof f=="number"&&(n.maxItems=f)};function Xf(t,e,s){if(e.$ref){if(s.has(e))return e;s.add(e);const f=t.get(e)?.def;if(!f)return e;const _=Xf(t,f,s);return _===f?e:_}for(const f of["anyOf","oneOf"]){const _=e[f];if(!Array.isArray(_))continue;const g=_.map(m=>Xf(t,m,s));g.some((m,v)=>m!==_[v])&&(e={...e,[f]:g})}const i=Array.isArray(e.type)?e.type:[e.type],n=!i.includes("string")&&i.some(f=>f==="number"||f==="integer"),r=e.enum??(e.const!==void 0?[e.const]:void 0);if(!n&&!r?.some(f=>typeof f=="number"))return e;const{minimum:o,maximum:a,exclusiveMinimum:l,exclusiveMaximum:c,multipleOf:h,format:d,id:u,...p}=e;return p.enum?p.enum=p.enum.map(f=>typeof f=="number"?String(f):f):typeof p.const=="number"&&(p.const=String(p.const)),n&&(p.type="string",r||(p.pattern=(i.includes("number")?gg:lA).source)),p}const Zf=new WeakMap;function tI(t){const e=new Map;for(const i of t.seen.values())i.def&&!e.has(i.schema)&&e.set(i.schema,i);const s=new Map;for(const i of Zf.get(t)??[]){const n=t.seen.get(i),r=(n?.def??n?.schema)?.propertyNames;if(!r||r===!0||s.has(r))continue;const o=Xf(e,r,new Set);o!==r&&s.set(r,o)}if(s.size)for(const i of t.seen.values())for(const n of[i.schema,i.def]){const r=n&&s.get(n.propertyNames);r&&(n.propertyNames=r)}}const sI=(t,e,s,i)=>{const n=s,r=t._zod.def;n.type="object";const o=r.keyType,a=Bi(o).patterns;if(r.mode==="loose"&&a&&a.size>0){const h=Jt(r.valueType,e,{...i,path:[...i.path,"patternProperties","*"]});n.patternProperties={};for(const d of a)Yn(n.patternProperties,Qy(d).source,h)}else{if(e.target==="draft-07"||e.target==="draft-2020-12"){n.propertyNames=Jt(r.keyType,e,{...i,path:[...i.path,"propertyNames"]});let h=Zf.get(e);h||(h=[],Zf.set(e,h),e.deferred.push(()=>tI(e))),h.push(t)}n.additionalProperties=Jt(r.valueType,e,{...i,path:[...i.path,"additionalProperties"]})}const l=o._zod.values,c=e.io==="input"&&Gl(r.valueType)!==void 0;if(l&&!r.partial&&!c){const h=[...l].filter(d=>typeof d=="string"||typeof d=="number");h.length>0&&(n.required=h.map(String))}},iI=(t,e,s,i)=>{const n=t._zod.def,r=Jt(n.innerType,e,i),o=e.seen.get(t);e.target==="openapi-3.0"?(o.ref=n.innerType,s.nullable=!0):s.anyOf=[r,{type:"null"}]},nI=(t,e,s,i)=>{const n=t._zod.def;Jt(n.innerType,e,i);const r=e.seen.get(t);r.ref=n.innerType},vg=Symbol();function ez(t,e,s,i,n){let r=!1;const o=JSON.stringify(t,(a,l)=>typeof l!="bigint"?l:(r=!0,null));return r?(Rr(e,s,i,n,"BigInt defaults cannot be represented in JSON Schema"),vg):JSON.parse(o)}const rI=(t,e,s,i)=>{const n=t._zod.def;Jt(n.innerType,e,i);const r=e.seen.get(t);r.ref=n.innerType;const o=ez(n.defaultValue,t,e,s,i);o!==vg&&(s.default=o)},oI=(t,e,s,i)=>{const n=t._zod.def;Jt(n.innerType,e,i);const r=e.seen.get(t);if(r.ref=n.innerType,e.io!=="input")return;const o=ez(n.defaultValue,t,e,s,i);o!==vg&&(s._prefault=o)},aI=(t,e,s,i)=>{const n=t._zod.def;Jt(n.innerType,e,i);const r=e.seen.get(t);r.ref=n.innerType;let o;try{o=n.catchValue(void 0)}catch{Rr(t,e,s,i,"Dynamic catch values are not supported in JSON Schema");return}s.default=o},lI=(t,e,s,i)=>{const n=t._zod.def,r=n.in._zod.traits.has("$ZodTransform"),o=e.io==="input"?r?n.out:n.in:n.out;Jt(o,e,i);const a=e.seen.get(t);a.ref=o},cI=(t,e,s,i)=>{const n=t._zod.def;Jt(n.innerType,e,i);const r=e.seen.get(t);r.ref=n.innerType,s.readOnly=!0},tz=(t,e,s,i)=>{const n=t._zod.def;Jt(n.innerType,e,i);const r=e.seen.get(t);r.ref=n.innerType},hI=(t,e,s,i)=>{const n=t._zod.innerType;Jt(n,e,i);const r=e.seen.get(t);r.ref=n},zb=new WeakSet([Object.prototype,Error.prototype]);function lc(t,e,s){Object.defineProperty(t,e,{configurable:!0,enumerable:!1,get(){const i=s(this);return Object.defineProperty(this,e,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,e,{value:i,configurable:!0,writable:!0})}})}const dI=(t,e)=>{vE.init(t,e),t.name="ZodError";const s=Object.getPrototypeOf(t);zb.has(s)||(zb.add(s),lc(s,"format",i=>n=>zE(i,n)),lc(s,"flatten",i=>n=>yE(i,n)),lc(s,"addIssue",i=>n=>{i.issues.push(n),i.message=JSON.stringify(i.issues,jf,2)}),lc(s,"addIssues",i=>n=>{i.issues.push(...n),i.message=JSON.stringify(i.issues,jf,2)}),Object.defineProperty(s,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Wi=le("ZodError",dI,void 0,{Parent:Error}),uI=ug(Wi),fI=fg(Wi),pI=pg(Wi),mI=mg(Wi),gI=TE(Wi),_I=DE(Wi),bI=IE(Wi),MI=CE(Wi),vI=RE(Wi),wI=kE(Wi),yI=NE(Wi),zI=BE(Wi);function SI(){Li.localeError||wn(WT())}function Xl(){Li.memoizer||wn({memoizer:GT()})}const jt=le("ZodType",(t,e)=>(SI(),Ut.init(t,e),t.def=e,t.type=e.type,t),{check(...t){const e=this.def;return this.clone(wi(e,{checks:[...e.checks??[],...t.map(s=>typeof s=="function"?{_zod:{check:s,def:{check:"custom"},onattach:[]}}:s)]}),{parent:!0})},with(...t){return this.check(...t)},clone(t,e){return Pr(this,t,e)},brand(){return this},register(t,e){return t.add(this,e),this},refine(t,e){return this.check(SC(t,e))},superRefine(t,e){return this.check(xC(t,e))},overwrite(t){return this.check(Oa(t))},optional(){return Ob(this)},exactOptional(){return cC(this)},nullable(){return Eb(this)},nullish(){return Ob(Eb(this))},nonoptional(t){return mC(this,t)},array(){return je(this)},or(t){return tC([this,t])},and(t){return nC(this,t)},transform(t){return Ab(this,lC(t))},default(t){return uC(this,t)},prefault(t){return pC(this,t)},catch(t){return _C(this,t)},pipe(t){return Ab(this,t)},readonly(){return vC(this)},describe(t){const e=this.clone();return ul.add(e,{description:t}),e},meta(...t){if(t.length===0)return ul.get(this);const e=this.clone();return ul.add(e,t[0]),e},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(t,...e){return e.length===0?t(this):t(this,...e)},get"~standard"(){return vy(this,"~standard",{...Ay(this),jsonSchema:{input:$h(this,"input"),output:$h(this,"output")}})},set"~standard"(t){Cr(this,"~standard",t)},parse:function t(e,s){return uI(this,e,s,{callee:t})},parseAsync:async function t(e,s){return await fI(this,e,s,{callee:t})},safeParse(t,e){return pI(this,t,e)},async safeParseAsync(t,e){return mI(this,t,e)},get spa(){return this?.safeParseAsync},set spa(t){Cr(this,"spa",t)},validate(t,e){return OE(this,t,e)},validateAsync(t,e){return AE(this,t,e)},encode:function t(e,s){return gI(this,e,s,{callee:t})},decode:function t(e,s){return _I(this,e,s,{callee:t})},encodeAsync:async function t(e,s){return await bI(this,e,s,{callee:t})},decodeAsync:async function t(e,s){return await MI(this,e,s,{callee:t})},safeEncode(t,e){return vI(this,t,e)},safeDecode(t,e){return wI(this,t,e)},async safeEncodeAsync(t,e){return yI(this,t,e)},async safeDecodeAsync(t,e){return zI(this,t,e)},toJSONSchema(t){return GD(this,{})(t)},get description(){return ul.get(this)?.description},get _def(){return this._zod.def}}),sz=le("_ZodString",(t,e)=>{bg.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>FD(t,s,i)},wy({format:t=>Bi(t).format??null,minLength:t=>Bi(t).minimum??null,maxLength:t=>Bi(t).maximum??null},{regex(...t){return this.check(wD(...t))},includes(...t){return this.check(SD(...t))},startsWith(...t){return this.check(xD(...t))},endsWith(...t){return this.check(OD(...t))},min(...t){return this.check(Uh(...t))},max(...t){return this.check(Uy(...t))},length(...t){return this.check($y(...t))},nonempty(...t){return this.check(Uh(1,...t))},lowercase(t){return this.check(yD(t))},uppercase(t){return this.check(zD(t))},trim(){return this.check(AD())},normalize(...t){return this.check(ED(...t))},toLowerCase(){return this.check(TD())},toUpperCase(){return this.check(DD())},slugify(){return this.check(ID())}})),xI=le("ZodString",(t,e)=>{bg.init(t,e),sz.init(t,e)},{email(t){return this.check(jT(DI,t))},url(t){return this.check(XT(CI,t))},jwt(t){return this.check(dD(qI,t))},emoji(t){return this.check(ZT(RI,t))},guid(t){return this.check(HT(II,t))},uuid(t){return this.check(VT(cc,t))},uuidv4(t){return this.check(qT(cc,t))},uuidv6(t){return this.check(KT(cc,t))},uuidv7(t){return this.check(YT(cc,t))},nanoid(t){return this.check(JT(kI,t))},cuid(t){return this.check(QT(NI,t))},cuid2(t){return this.check(eD(BI,t))},ulid(t){return this.check(tD(GI,t))},base64(t){return this.check(lD(jI,t))},base64url(t){return this.check(cD(HI,t))},xid(t){return this.check(sD(PI,t))},ksuid(t){return this.check(iD(LI,t))},ipv4(t){return this.check(nD(WI,t))},ipv6(t){return this.check(rD(FI,t))},cidrv4(t){return this.check(oD(UI,t))},cidrv6(t){return this.check(aD($I,t))},e164(t){return this.check(hD(VI,t))},datetime(t){return this.check(uD(OI,t))},date(t){return this.check(fD(EI,t))},time(t){return this.check(pD(AI,t))},duration(t){return this.check(mD(TI,t))}});function G(t){return $T(xI,t)}const es=le("ZodStringFormat",(t,e)=>{Kt.init(t,e),sz.init(t,e)}),OI=le("ZodISODateTime",(t,e)=>{$A.init(t,e),es.init(t,e)}),EI=le("ZodISODate",(t,e)=>{jA.init(t,e),es.init(t,e)}),AI=le("ZodISOTime",(t,e)=>{HA.init(t,e),es.init(t,e)}),TI=le("ZodISODuration",(t,e)=>{VA.init(t,e),es.init(t,e)}),DI=le("ZodEmail",(t,e)=>{TA.init(t,e),es.init(t,e)}),II=le("ZodGUID",(t,e)=>{EA.init(t,e),es.init(t,e)}),cc=le("ZodUUID",(t,e)=>{AA.init(t,e),es.init(t,e)}),CI=le("ZodURL",(t,e)=>{NA.init(t,e),es.init(t,e)}),RI=le("ZodEmoji",(t,e)=>{BA.init(t,e),es.init(t,e)}),kI=le("ZodNanoID",(t,e)=>{GA.init(t,e),es.init(t,e)}),NI=le("ZodCUID",(t,e)=>{PA.init(t,e),es.init(t,e)}),BI=le("ZodCUID2",(t,e)=>{LA.init(t,e),es.init(t,e)}),GI=le("ZodULID",(t,e)=>{WA.init(t,e),es.init(t,e)}),PI=le("ZodXID",(t,e)=>{FA.init(t,e),es.init(t,e)}),LI=le("ZodKSUID",(t,e)=>{UA.init(t,e),es.init(t,e)}),WI=le("ZodIPv4",(t,e)=>{qA.init(t,e),es.init(t,e)}),FI=le("ZodIPv6",(t,e)=>{YA.init(t,e),es.init(t,e)}),UI=le("ZodCIDRv4",(t,e)=>{XA.init(t,e),es.init(t,e)}),$I=le("ZodCIDRv6",(t,e)=>{JA.init(t,e),es.init(t,e)}),jI=le("ZodBase64",(t,e)=>{QA.init(t,e),es.init(t,e)}),HI=le("ZodBase64URL",(t,e)=>{tT.init(t,e),es.init(t,e)}),VI=le("ZodE164",(t,e)=>{sT.init(t,e),es.init(t,e)}),qI=le("ZodJWT",(t,e)=>{nT.init(t,e),es.init(t,e)}),iz=le("ZodNumber",(t,e)=>{ky.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>UD(t,s,i,n),t.isFinite=!0},wy({minValue:t=>{const{minimum:e,exclusiveMinimum:s}=Bi(t);return Math.max(e??Number.NEGATIVE_INFINITY,s??Number.NEGATIVE_INFINITY)},maxValue:t=>{const{maximum:e,exclusiveMaximum:s}=Bi(t);return Math.min(e??Number.POSITIVE_INFINITY,s??Number.POSITIVE_INFINITY)},isInt:t=>{const{isInt:e,multipleOf:s}=Bi(t);return!!e||!!s?.some(Number.isSafeInteger)},format:t=>Bi(t).format??null},{gt(t,e){return this.check(pb(t,e))},gte(t,e){return this.check(ru(t,e))},min(t,e){return this.check(ru(t,e))},lt(t,e){return this.check(fb(t,e))},lte(t,e){return this.check(nu(t,e))},max(t,e){return this.check(nu(t,e))},int(t){return this.check(Sb(t))},safe(t){return this.check(Sb(t))},positive(t){return this.check(pb(0,t))},nonnegative(t){return this.check(ru(0,t))},negative(t){return this.check(fb(0,t))},nonpositive(t){return this.check(nu(0,t))},multipleOf(t,e){return this.check(mb(t,e))},step(t,e){return this.check(mb(t,e))},finite(){return this}}));function Q(t){return gD(iz,t)}const KI=le("ZodNumberFormat",(t,e)=>{rT.init(t,e),iz.init(t,e)});function Sb(t){return _D(KI,t)}const YI=le("ZodBoolean",(t,e)=>{oT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>$D(t,s,i)});function wt(t){return bD(YI,t)}const XI=le("ZodUnknown",(t,e)=>{aT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>HD()});function ua(){return MD(XI)}const ZI=le("ZodNever",(t,e)=>{lT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>jD(t,s,i)});function JI(t){return vD(ZI,t)}const QI=le("ZodArray",(t,e)=>{Xl(),dT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>XD(t,s,i,n),t.element=e.element},{min(t,e){return this.check(Uh(t,e))},nonempty(t){return this.check(Uh(1,t))},max(t,e){return this.check(Uy(t,e))},length(t,e){return this.check($y(t,e))},unwrap(){return this.element}});function je(t,e){return CD(QI,t,e)}const eC=le("ZodObject",(t,e)=>{Xl(),pT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>ZD(t,s,i,n),uE(t,"shape",s=>s._zod.def.shape,!1)},{keyof(){return kt(Object.keys(this._zod.def.shape))},catchall(t){return this.clone(wi(this._zod.def,{catchall:t}))},passthrough(){return this.clone(wi(this._zod.def,{catchall:ua()}))},loose(){return this.clone(wi(this._zod.def,{catchall:ua()}))},strict(){return this.clone(wi(this._zod.def,{catchall:JI()}))},strip(){return this.clone(wi(this._zod.def,{catchall:void 0}))},extend(t){return tE(this,t)},safeExtend(t){return sE(this,t)},merge(t){return iE(this,t)},pick(t){return QO(this,t)},omit(t){return eE(this,t)},partial(...t){return V_(wg,this,t[0])},exactPartial(...t){return V_(az,this,t[0],"exactPartial")},required(...t){return nE(lz,this,t[0])}});function se(t,e){const s={type:"object",shape:t??{},...Ve(e)};return new eC(s)}const nz=le("ZodUnion",(t,e)=>{Gy.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>JD(t,s,i,n),t.options=e.options});function tC(t,e){return new nz({type:"union",options:t,...Ve(e)})}const sC=le("ZodDiscriminatedUnion",(t,e)=>{nz.init(t,e),gT.init(t,e)});function rz(t,e,s){return new sC({type:"union",options:e,discriminator:t,...Ve(s)})}const iC=le("ZodIntersection",(t,e)=>{_T.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>QD(t,s,i,n)});function nC(t,e){return new iC({type:"intersection",left:t,right:e})}const rC=le("ZodTuple",(t,e)=>{Xl(),bT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>eI(t,s,i,n)},{rest(t){return this.clone({...this._zod.def,rest:t})},partial(){const t=this._zod.def;if(t.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...t,items:t.items.map(e=>new wg({type:"optional",innerType:e}))})}});function oz(t,e,s){const i=e instanceof Ut,n=i?s:e,r=i?e:null;return new rC({type:"tuple",items:t,rest:r,...Ve(n)})}const xb=le("ZodRecord",(t,e)=>{Xl(),MT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>sI(t,s,i,n),t.keyType=e.keyType,t.valueType=e.valueType});function jh(t,e,s){return!e||!e._zod?new xb({type:"record",keyType:G(),valueType:t,...Ve(e)}):new xb({type:"record",keyType:t,valueType:e,...Ve(s)})}const Jf=le("ZodEnum",(t,e)=>{vT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(i,n,r)=>VD(t,i,n),t.enum=e.entries,t.options=[...t._zod.values];const s=new Set(Object.keys(e.entries));t.extract=(i,n)=>{const r={};for(const o of i)if(s.has(o))r[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Jf({...e,checks:[],...Ve(n),entries:r})},t.exclude=(i,n)=>{const r={...e.entries};for(const o of i)if(s.has(o))delete r[o];else throw new Error(`Key ${o} not found in enum`);return new Jf({...e,checks:[],...Ve(n),entries:r})}});function kt(t,e){const s=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new Jf({type:"enum",entries:s,...Ve(e)})}const oC=le("ZodLiteral",(t,e)=>{wT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>qD(t,s,i,n),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function Xe(t,e){return new oC({type:"literal",values:Array.isArray(t)?t:[t],...Ve(e)})}const aC=le("ZodTransform",(t,e)=>{Xl(),yT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>YD(t,s,i,n),t._zod.parse=(s,i)=>{if(i.direction==="backward")throw new yy(t.constructor.name);s.addIssue=r=>{if(typeof r=="string")s.issues.push(Bl(r,s.value,e));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=s.value),o.inst??(o.inst=t),s.issues.push(Bl(o))}};const n=e.transform(s.value,s);return n instanceof Promise?n.then(r=>(s.value=r,s)):(s.value=n,s)}});function lC(t){return new aC({type:"transform",transform:t})}const wg=le("ZodOptional",(t,e)=>{Py.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>tz(t,s,i,n),t.unwrap=()=>t._zod.def.innerType});function Ob(t){return new wg({type:"optional",innerType:t})}const az=le("ZodExactOptional",(t,e)=>{zT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>tz(t,s,i,n),t.unwrap=()=>t._zod.def.innerType});function cC(t){return new az({type:"optional",innerType:t})}const hC=le("ZodNullable",(t,e)=>{ST.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>iI(t,s,i,n),t.unwrap=()=>t._zod.def.innerType});function Eb(t){return new hC({type:"nullable",innerType:t})}const dC=le("ZodDefault",(t,e)=>{xT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>rI(t,s,i,n),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function uC(t,e){return new dC({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():gy(e)}})}const fC=le("ZodPrefault",(t,e)=>{OT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>oI(t,s,i,n),t.unwrap=()=>t._zod.def.innerType});function pC(t,e){return new fC({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():gy(e)}})}const lz=le("ZodNonOptional",(t,e)=>{ET.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>nI(t,s,i,n),t.unwrap=()=>t._zod.def.innerType});function mC(t,e){return new lz({type:"nonoptional",innerType:t,...Ve(e)})}const gC=le("ZodCatch",(t,e)=>{AT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>aI(t,s,i,n),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function _C(t,e){return new gC({type:"catch",innerType:t,catchValue:typeof e=="function"?e:pE(e)})}const bC=le("ZodPipe",(t,e)=>{TT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>lI(t,s,i,n),t.in=e.in,t.out=e.out});function Ab(t,e){return new bC({type:"pipe",in:t,out:e})}const MC=le("ZodReadonly",(t,e)=>{DT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>cI(t,s,i,n),t.unwrap=()=>t._zod.def.innerType});function vC(t){return new MC({type:"readonly",innerType:t})}const wC=le("ZodLazy",(t,e)=>{IT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>hI(t,s,i,n),t.unwrap=()=>t._zod.def.getter()});function yC(t){return new wC({type:"lazy",getter:t})}const zC=le("ZodCustom",(t,e)=>{CT.init(t,e),jt.init(t,e),t._zod.processJSONSchema=(s,i,n)=>KD(t,s,i,n)});function SC(t,e={}){return RD(zC,t,e)}function xC(t,e){return kD(t,e)}se({name:G(),type:G(),size:Q(),owner:G(),date:G(),target:G().optional(),version:G().optional(),title:G().optional(),tags:je(G()).optional(),id:Q().optional(),status:G().optional()}).passthrough();const OC=new Set([".dcm",".png",".jpg",".jpeg",".gif",".bmp",".webp",".ico",".pdf",".zip",".tar",".gz",".bz2",".xz",".7z",".exe",".dll",".so",".bin",".mp3",".mp4",".avi",".wav",".nii",".mgz"]),EC=1024*1024;function yg(t){const e=t.split("/").pop()??t,s=e.lastIndexOf(".");return s>0?e.slice(s).toLowerCase():""}function AC(t){return!OC.has(yg(t))}const TC=kt(["ok","error"]),DC=se({type:kt(["error","warning"]),message:G()}),IC=se({kind:G(),data:ua()}),CC=se({input:G(),proposed:G(),validated:wt(),executed:G().optional()}),cz=se({status:TC,rendered:G(),renderedErr:G().optional(),model:IC.optional(),errors:je(DC).optional(),trace:CC.optional()}),RC=kt(["data","err","status"]),kC=se({shellCommands:wt(),hiddenInput:wt().optional(),color:wt().optional(),fileDelivery:wt().optional(),localFilesystem:wt().optional(),claims:je(se({subject:G(),verbs:je(G()).optional()})).optional(),terminal:G().optional()}),NC=se({type:Xe("attach"),protocolVersion:Q().int(),token:G(),session:G().optional(),capabilities:kC.optional()}),BC=se({type:Xe("execute"),id:G(),line:G(),instrument:wt().optional(),mirrored:wt().optional()}),GC=se({type:Xe("cancel"),id:G()}),PC=se({type:Xe("stop")}),LC=se({type:Xe("complete"),id:G(),prefix:G()}),WC=se({type:Xe("promptAnswer"),promptId:G(),answer:G()}),FC=se({type:Xe("promptError"),promptId:G(),reason:G()}),UC=se({type:Xe("pipeResult"),pipeId:G(),output:G()}),$C=se({type:Xe("pipeError"),pipeId:G(),reason:G()}),jC=se({type:Xe("shellResult"),shellId:G(),exitCode:Q().int()}),HC=se({type:Xe("shellError"),shellId:G(),reason:G()}),VC=se({type:Xe("editResult"),editId:G(),content:G(),changed:wt(),opened:wt().optional()}),qC=se({type:Xe("editError"),editId:G(),reason:G()}),KC=se({type:Xe("deliverResult"),deliverId:G(),location:G(),bytes:Q().nonnegative()}),YC=se({type:Xe("deliverError"),deliverId:G(),reason:G()}),XC=se({address:G(),modelKind:G().optional(),groupId:G(),paneId:G()}),hz=se({type:Xe("regard"),regard:XC}),ZC=se({type:Xe("watch"),subject:G()}),JC=se({type:Xe("unwatch"),subject:G()}),QC=se({type:Xe("terminalOpen"),terminalId:G().optional(),cols:Q().int(),rows:Q().int()}),eR=se({type:Xe("terminalInput"),terminalId:G(),data:G()}),tR=se({type:Xe("terminalResize"),terminalId:G(),cols:Q().int(),rows:Q().int()}),sR=se({type:Xe("terminalClose"),terminalId:G()}),iR=se({type:Xe("surfaceLineResult"),lineId:G(),rendered:G(),status:kt(["ok","error"])}),nR=se({type:Xe("surfaceLineError"),lineId:G(),reason:G()}),rR=se({type:Xe("surfaceClaims"),claims:je(se({subject:G(),verbs:je(G()).optional()}))}),oR=se({type:Xe("note"),text:G()}),aR=["live","settled","stale"],lR=kt(aR),cR=se({type:Xe("stale"),stale:wt()}),hR=["restart","end","stop"],dR=se({type:Xe("closing"),cause:kt(hR)}),uR=se({type:Xe("watched"),subject:G(),state:lR}),fR=se({type:Xe("numbered"),id:Q(),source:G(),rows:Q(),handles:je(se({kind:G(),ordinal:Q(),address:G()}))});rz("type",[NC,BC,GC,PC,LC,WC,FC,UC,$C,jC,HC,VC,qC,KC,YC,hz,ZC,JC,QC,eR,tR,sR,iR,nR,oR,rR]);const pR=se({type:Xe("attached"),session:G(),surface:G().optional(),backend:G().optional(),protocolVersion:Q().int(),stack:se({chell:G(),calypso:G(),build:G(),surface:se({git:G(),built:G()}).optional(),brasa:G().optional(),chili:G().optional(),salsa:G().optional(),cumin:G().optional()}).optional(),hostControl:je(G()).optional(),stale:wt().optional(),terminals:wt().optional()}),mR=se({type:Xe("result"),id:G(),envelopes:je(cz)}),gR=se({type:Xe("complete"),id:G(),prefix:G(),candidates:je(G())}),_R=se({type:Xe("event"),id:G(),kind:G(),data:ua()}),bR=se({type:Xe("output"),id:G(),channel:RC,chunk:G()}),MR=kt(GO).catch("task"),vR=kt(PO).catch(void 0),wR=kt(LO).catch("working"),yR=kt(WO).catch(void 0),zR=kt(FO).catch("unknown"),SR=se({type:Xe("progress"),id:G(),operation:MR,kind:vR.optional(),phase:wR,label:G().optional(),itemId:G().optional(),current:Q().nonnegative().optional(),total:Q().nonnegative().optional(),percent:Q().min(0).max(100).optional(),unit:yR.optional(),status:zR.optional(),path:G().optional(),reason:G().optional()}),xR=se({type:Xe("session"),surface:G(),envelope:cz,terminal:G().optional()}),OR=se({type:Xe("error"),id:G().optional(),reason:G()}),ER=["text","secret","confirm","path"],AR=kt(ER).catch("text"),TR=se({anchor:G().optional(),wantsDirectory:wt(),suggest:G().optional()}),DR=se({type:Xe("prompt"),promptId:G(),message:G(),hidden:wt(),wants:AR.optional(),path:TR.optional(),commit:G().optional()});function IR(t){return t.wants!==void 0?t.wants:t.hidden===!0?"secret":"text"}const CR=["leader","place","identity","path","work","note","alert"],RR=se({key:G(),label:G(),value:G(),tone:kt(CR)}),kR=se({user:G(),uri:G(),cwd:G(),pacsserver:G().nullable(),physicalMode:wt(),lastExitCode:Q(),lastCommandDurationMs:Q(),procWarmup:se({loaded:Q(),total:Q().optional(),restored:wt().optional(),state:kt(NO).optional(),sweeping:wt().optional(),feed:se({id:Q(),loaded:Q(),total:Q(),failed:G().optional()}).optional(),feeds:je(se({id:Q(),loaded:Q(),total:Q(),failed:G().optional()})).optional(),arrived:je(Q()).optional(),landed:je(se({id:Q(),title:G().default(""),jobs:Q(),status:G(),chain:je(G()),groups:je(se({plugin:G(),count:Q(),errored:Q().default(0),status:G(),parent:Q().nullable()})).default([])})).optional(),roster:kt(["delta","full"]).optional()}).optional(),procIndex:se({jobs:Q(),feeds:Q()}).optional(),warmupFailures:je(se({label:G(),message:G()})).optional(),questions:Q().optional(),segments:je(RR).optional()}),NR=se({type:Xe("promptline"),context:kR}),BR=se({type:Xe("pipe"),pipeId:G(),command:G(),input:G()}),GR=se({type:Xe("shell"),shellId:G(),command:G()}),PR=se({type:Xe("edit"),editId:G(),content:G(),extension:G().optional(),path:G().optional()}),LR=se({type:Xe("deliver"),deliverId:G(),path:G(),filename:G(),destination:G().optional(),size:Q().nonnegative().optional(),contentType:G().optional()}),WR=se({type:Xe("telemetry"),index:se({jobs:Q(),feeds:Q()}),lane:se({running:se({line:G(),sinceMs:Q(),surface:G()}).nullable(),waiting:Q(),questions:je(se({surface:G(),message:G(),sinceMs:Q()})).optional(),joblets:je(se({number:Q(),line:G(),waiting:wt()})).optional()}).optional(),surfaces:je(se({id:G(),kind:kt(["chell","browser"])})).optional(),cube:se({msPerPage:Q(),samples:Q()}).optional(),state:se({running:Q(),runningFeeds:Q(),scheduled:Q(),errored:Q(),erroredFeeds:Q()}).optional()}),FR=se({type:Xe("terminalOpened"),terminalId:G(),replay:G(),refused:G().optional()}),UR=se({type:Xe("terminalData"),terminalId:G(),data:G()}),$R=se({type:Xe("terminalExit"),terminalId:G(),code:Q().int()}),jR=se({type:Xe("surfaceLine"),lineId:G(),line:G(),terminal:G().optional()}),HR=se({type:Xe("consoleNote"),text:G()}),dz=rz("type",[pR,mR,gR,bR,SR,_R,xR,OR,DR,NR,WR,BR,GR,PR,LR,hz,uR,cR,dR,fR,FR,UR,$R,jR,HR]);new Set(dz.options.map(t=>t.shape.type.value));function VR(t){return t.issues.map(e=>{const s=e.path.map(String).join(".");return s?`${s}: ${e.message}`:e.message}).join("; ")}function qR(t,e){const s=t.safeParse(e);return s.success?{ok:!0,value:s.data}:{ok:!1,error:VR(s.error)}}function KR(t){return qR(dz,t)}const uz=se({id:G(),label:G(),parentIds:je(G()),joinParentIds:je(G())}),YR=se({name:G(),value:ua()}),XR=uz.extend({pluginName:G(),pluginVersion:G().optional(),arguments:je(YR).optional()}),zg=se({name:G(),pipelineId:Q().optional(),nodes:je(XR)}),ZR=["created","waiting","scheduled","started","registeringFiles","finishedSuccessfully","finishedWithError","cancelled","unknown"],fz=kt(ZR).catch("unknown"),JR=se({count:Q(),done:Q(),error:Q(),running:Q(),other:Q(),anomalies:je(se({id:G(),status:fz})).optional()}),QR=se({computeSeconds:Q().optional(),dataBytes:Q().optional()}),ek=uz.extend({instanceId:Q(),pluginName:G(),pluginVersion:G().optional(),status:fz,vfsPath:G(),metrics:QR.optional(),tally:JR.optional(),computeResource:G().optional()}),Sg=se({feedId:Q(),feedName:G(),nodes:je(ek)}),tk=se({feedId:Q(),loaded:Q(),total:Q(),failed:G().optional()}),yr={pipelineDiagram:"pipeline.diagram",feedDag:"feed.dag",feedIndexing:"feed.indexing"},sk=se({id:Q(),title:G(),owner:G(),status:G(),createdAt:G(),new:wt().optional(),sizeBytes:Q().optional(),wallSeconds:Q().optional(),jobsDone:Q().optional(),jobsTotal:Q().optional(),jobsErrored:Q().optional(),tags:je(G()).optional()}),Qf=se({feeds:je(sk)}),ep="feed.list",ik=se({target:G(),choices:je(se({kind:kt(["feed","node"]),feedId:Q(),nodeId:Q().optional(),name:G(),title:G()}))}),nk="proc.jump",rk=se({plugin:G(),count:Q(),errored:Q().default(0),status:G(),parent:Q().nullable()}),ok=se({format:kt(["dicom","nifti","mgz","jpeg","png","other","unknown"]),modality:G().optional(),seriesDescription:G().optional(),reason:G().optional(),sourceFeed:Q().optional()}),ak=se({id:Q(),title:G().default(""),jobs:Q(),status:G(),chain:je(G()),groups:je(rk).default([]),createdAt:G().default(""),data:ok.optional()}),lk=se({feeds:je(ak),whole:wt()}),ck="proc.universe",hk=se({name:G(),positions:jh(G(),oz([Q(),Q(),Q()])).nullable(),writtenAt:G().nullable(),laying:se({nodes:Q(),fraction:Q()}).nullable().optional()}),dk="proc.layout",uk=se({name:G(),type:G(),optional:wt(),default:ua().optional(),help:G().optional(),flag:G()}),fk=se({id:Q().optional(),name:G(),version:G(),type:G(),title:G().optional(),description:G().optional(),authors:G().optional(),documentation:G().optional(),category:G().optional(),parameters:je(uk),command:G().optional()}),pk="plugin.info",mk=se({seriesUID:G(),description:G(),modality:G(),fileCount:Q().optional(),vfsPath:G().optional(),pulled:wt().optional(),pulledFiles:Q().optional(),folderPath:G().optional()}),gk=se({studyUID:G().optional(),server:G().optional(),vfsPath:G().optional(),description:G(),patientName:G(),patientId:G(),date:G(),modalities:G(),accession:G(),series:je(mk)}),pz=se({replayed:wt(),answeredAt:G()}),_k=["found","none","unasked"],bk=kt(_k).catch("unasked"),Mk=se({patientId:G(),server:G().optional(),patientName:G().optional(),status:bk,studyCount:Q(),seriesCount:Q(),queryId:Q().optional(),provenance:pz.optional(),error:G().optional()}),vk=se({queryId:Q(),vfsPath:G(),pacsName:G(),expression:G(),studies:je(gk),provenance:pz.optional(),patients:je(Mk).optional()}),wk=se({id:Q(),identifier:G(),active:wt()}),yk=se({servers:je(wk)}),zk="pacs.servers",Sk="pacs.query";function xk(t){return`pacs:patient:${t.server??"-"}:${t.patientId}`}const Ok=["patient","study","series","image","equipment","meta","private","other"],mz=kt(Ok).catch("other"),gz=yC(()=>se({tag:G(),name:G(),vr:G(),value:G(),group:mz,phi:wt(),decoded:G().optional(),items:je(je(gz)).optional()})),Ek=se({tag:G(),name:G(),vr:G(),group:mz,phi:wt(),distinct:Q(),first:G(),last:G(),values:je(se({path:G(),value:G().nullable()}))}),_z=se({path:G(),subject:kt(["file","folder"]),read:Q(),of:Q(),refused:je(G()),constant:je(gz),varying:je(Ek)}),Ak=se({rows:Q(),columns:Q(),pixelSpacing:oz([Q(),Q()]).optional(),sliceThickness:Q().optional(),spacingBetweenSlices:Q().optional()}),bz=se({path:G(),seriesInstanceUID:G().optional(),studyInstanceUID:G().optional(),modality:G(),seriesDescription:G(),seriesNumber:Q().optional(),instances:Q(),frames:Q(),order:kt(["filename","unknown"]),geometry:Ak.optional(),transferSyntax:se({uid:G(),name:G().optional()}).optional(),bytes:Q(),header:G(),files:je(G()),annotations:je(G())}),ea={tags:"dicom.tags",series:"dicom.series"},Tk=se({path:G(),target:kt(["series","volume"]),force:wt().optional(),startAt:Q().int().positive().optional()}),Dk={view:"image.view"},Ik=se({state:kt(["cold","warming","current"]),loaded:Q(),total:Q()});se({user:G(),surface:G(),feeds:se({total:Q(),own:Q(),shared:Q(),public:Q()}),jobs:se({total:Q(),finished:Q(),errored:Q(),cancelled:Q(),running:Q(),scheduled:Q()}),failureRate:Q().nullable(),index:Ik,fortune:G()});const Ck="session.notes",Rk=se({package:G(),headline:G(),body:G(),internal:wt()}),kk=se({package:G(),version:G(),bump:kt(["major","minor","patch"]),changes:je(Rk)}),Nk=se({date:G().nullable(),merge:G().nullable(),entries:je(kk)}),Bk=se({source:Xe("daemon"),installed:jh(G(),G()),releases:je(Nk),total:Q(),all:wt()});function Ws(t){return t.groups.map(e=>`${e.parent??"r"}:${e.plugin}`).join(">")}function zr(t,e){return`feed:${t}:${e}`}function Mz(t){return`shape:${t}`}function Pl(t){return Math.log2(Math.max(1,t)+1)}function xg(t){if(!(t.errored<=0||t.count<=0))return Math.min(1,t.errored/t.count)}function Od(t,e="jobs"){const s=[],i=new Set,n=[...t].sort((o,a)=>o.id-a.id),r=new Map;for(const o of n){if(o.groups.length===0)continue;const a=Ws(o);r.set(a,(r.get(a)??0)+1)}for(const o of n){if(o.groups.length===0)continue;const a=Ws(o),l=Mz(a);i.has(a)||(i.add(a),s.push({id:l,label:Ed(a),parentIds:[],joinParentIds:[],ghost:!0,halo:!0,metric:1,count:r.get(a)??1})),o.groups.forEach((c,h)=>{const d=xg(c);s.push({id:zr(o.id,h),label:c.plugin,parentIds:[c.parent===null?l:zr(o.id,c.parent)],joinParentIds:[],status:c.status,metric:e==="jobs"?Pl(c.count):1,...c.count>1?{count:c.count}:{},...d!==void 0?{share:d}:{}})})}return{nodes:s}}const tp="plugin:";function Gk(t){return`${tp}${t}`}function sp(t){return t.startsWith(tp)?t.slice(tp.length):null}function Og(t,e="jobs"){const s=[],i=new Map,n=[...t].sort((r,o)=>r.id-o.id);for(const r of n)if(r.groups.length!==0){for(const o of new Set(r.groups.map(a=>a.plugin)))i.set(o,(i.get(o)??0)+1);r.groups.forEach((o,a)=>{const l=xg(o);s.push({id:zr(r.id,a),label:o.plugin,parentIds:o.parent===null?[]:[zr(r.id,o.parent)],joinParentIds:[],status:o.status,metric:e==="jobs"?Pl(o.count):1,attrs:{plugin:o.plugin},...o.count>1?{count:o.count}:{},...l!==void 0?{share:l}:{}})})}for(const[r,o]of[...i].sort((a,l)=>a[0]<l[0]?-1:1))s.push({id:Gk(r),label:r,parentIds:[],joinParentIds:[],metric:1+Math.log(o),hue:"#e8f4ff",ring:!0,attrs:{kind:"star",plugin:r}});return{nodes:s}}function Tb(t,e="jobs"){const s=new Map;for(const n of t){const r=n.createdAt===void 0?Number.NaN:Date.parse(n.createdAt);Number.isFinite(r)&&s.set(n.id,r)}return{nodes:Og(t,e).nodes.filter(n=>n.attrs?.kind!=="star").map(n=>{const r=s.get(Number(n.id.split(":")[1]));return r===void 0?n:{...n,attrs:{...n.attrs,createdAt:r}}})}}function Ed(t){const e=[];for(const s of t.split(">")){const i=s.slice(s.indexOf(":")+1);i.length>0&&!e.includes(i)&&e.push(i)}return e.join(" > ")}const Pk=.5,Lk=5,Wk=.02,ip="data:",Fk={dicom:"DICOM",nifti:"NIfTI",mgz:"MGZ",jpeg:"JPEG",png:"PNG",other:"OTHER",unknown:"UNREADABLE",unread:"NOT YET READ"};function Uk(t){const e=t.toUpperCase().replace(/[_\-.,/\\()[\]:;+]+/g," ").split(/\s+/).filter(s=>s.length>0).filter(s=>!/^\d+$/.test(s)).filter(s=>!/^\d+X\d+$/.test(s)).filter(s=>!/^FOV\d*$/.test(s)).filter(s=>!/^\d+(\.\d+)?(MM|CM)$/.test(s));return[...new Set(e)]}function $k(t,e){if(t.length===0||e.length===0)return 0;const s=new Set(t);return e.filter(n=>s.has(n)).length/Math.min(t.length,e.length)}function vz(t){const e=new Map;for(const r of t)e.set(r,(e.get(r)??0)+1);const s=[...e.keys()].sort((r,o)=>(e.get(o)??0)-(e.get(r)??0)||(r<o?-1:1)),i=[],n=new Map;for(const r of s){const o=Uk(r),a=o.length===0?void 0:i.find(l=>$k(l.words,o)>=Pk);if(a!==void 0){n.set(r,a.name);continue}i.push({name:r,words:o}),n.set(r,r)}return n}function wz(t,e){const s=t.data?.format??"unread",i=[{key:s,label:Fk[s]??s.toUpperCase()}];if(s!=="dicom")return i;const n=t.data?.modality??"NO MODALITY";i.push({key:`${s}/${n}`,label:n});const r=t.data?.seriesDescription,o=r===void 0?"NO DESCRIPTION":e.get(r)??r;return i.push({key:`${s}/${n}/${o}`,label:o}),i}function ou(t){return`${ip}${t}`}function np(t){return t.startsWith(ip)?t.slice(ip.length):null}function Db(t,e="jobs"){const s=[...t].filter(h=>h.groups.length>0).sort((h,d)=>h.id-d.id),i=vz(s.map(h=>h.data?.seriesDescription).filter(h=>h!==void 0)),n=new Map,r=[];for(const h of s){const d=wz(h,i);let u=null;for(const f of d){const _=n.get(f.key);_===void 0?n.set(f.key,{label:f.label,feeds:1,parent:u}):_.feeds+=1,u=f.key}const p=ou(u);h.groups.forEach((f,_)=>{const g=xg(f);r.push({id:zr(h.id,_),label:f.plugin,parentIds:[f.parent===null?p:zr(h.id,f.parent)],joinParentIds:[],status:f.status,metric:e==="jobs"?Pl(f.count):1,...f.count>1?{count:f.count}:{},...g!==void 0?{share:g}:{}})})}const o=new Map;for(const h of s){const d=h.groups.findIndex(u=>u.parent===null);d>=0&&o.set(h.id,zr(h.id,d))}const a=new Map(r.map(h=>[h.id,h]));for(const h of s){const d=h.data?.sourceFeed,u=d===void 0||d===h.id?void 0:o.get(d),p=o.get(h.id);if(u===void 0||p===void 0)continue;const f=a.get(p);f!==void 0&&(f.joinParentIds=[...f.joinParentIds,u],f.joinFaint=!0)}const l=(h,d)=>h.split("/").length<3||d>=Math.max(Lk,Wk*s.length);return{graph:{nodes:[...[...n].map(([h,d])=>({id:ou(h),label:d.label,parentIds:d.parent===null?[]:[ou(d.parent)],joinParentIds:[],ghost:!0,halo:!0,metric:1,count:d.feeds,...l(h,d.feeds)?{caption:`${d.label} · ${d.feeds.toLocaleString("en-US")}`}:{}})),...r]},hubs:new Map([...n].map(([h,d])=>[h,{label:d.label,feeds:d.feeds}]))}}function jk(t,e){const s=np(t);if(s===null)return null;const i=s.split("/"),n=i.map((o,a)=>e.get(i.slice(0,a+1).join("/"))?.label??i[a]??""),r=e.get(s)?.feeds??0;return`${n.join(" · ")} · ${r.toLocaleString("en-US")} feed${r===1?"":"s"}`}const rp=12,Hk=240;function Vk(t){return t<=Hk?rp:void 0}function op(t,e){return`fold:${t}:${e}`}function yz(t){const e=t.match(/^fold:(.+):\d+$/);return e===null?null:e[1]}function qk(t){const e=t.match(/^feed:(\d+):/);if(e!==null)return`feed:${e[1]}`;const s=yz(t);return s===null?null:`fold:${s}`}const Kk=se({at:Q(),method:G(),family:G(),path:G(),status:Q(),ms:Q()}),Yk=se({family:G(),count:Q(),ms:Q()});se({since:G(),total:Q(),ms:Q(),families:je(Yk),last:je(Kk)});const zz="stratus.clusters",Xk=se({folder:G(),state:G(),name:G().optional(),evidence:G().optional(),started:G().nullable().optional(),ended:G().nullable().optional()}),Zk=["SIZING","STOPPED","ASKING","BUILDING","UP","SERVING","FAILED","GONE"],Ib=se({count:Q(),vcpu:Q(),ramGib:Q(),bootGib:Q(),bootTier:G()}),Sz=se({family:G(),controlPlane:Ib,workers:Ib,chris:se({dataGib:Q(),databaseGib:Q(),queueGib:Q()})}),Jk=se({action:G(),kind:G(),count:Q(),names:je(G())}),Qk=se({create:Q(),replace:Q(),change:Q(),drift:Q(),destroy:Q(),groups:je(Jk),at:G().nullable()}),e2=se({name:G(),ok:wt().nullable(),detail:G(),how:G()}),xz=se({name:G(),path:G(),cluster:G().nullable(),lastDone:G().nullable(),steps:je(Xk),resources:jh(G(),Q()).nullable(),cost:se({hourly:Q(),soFar:Q(),currency:G()}).nullable().optional(),condition:kt(Zk).optional(),billing:wt().optional(),origin:kt(["built","adopted","checkout","found"]).optional(),protected:wt().optional(),refused:jh(G(),G()).optional(),region:G().nullable().optional(),compartment:G().nullable().optional(),gone:G().nullable().optional(),spec:Sz.nullable().optional(),next:G().nullable().optional(),billingStep:G().optional(),running:se({job:G(),step:G().nullable(),since:G().nullable()}).nullable().optional(),plan:Qk.nullable().optional(),verify:se({at:G().nullable(),checks:je(e2)}).nullable().optional(),asking:G().nullable().optional()}),Oz=se({clusters:je(xz)}),t2="stratus.cluster.state",s2="stratus.cluster.size",i2=se({region:G(),family:G(),families:je(G()),vcpuPerCore:Q(),cores:se({min:Q(),max:Q()}).nullable(),memoryGib:se({min:Q(),max:Q()}).nullable(),zones:je(se({zone:G(),coresFree:Q().nullable(),memoryFree:Q().nullable()})),price:se({vcpuHour:Q(),gibHour:Q(),currency:G()}).nullable(),services:se({volumeGibMonth:Q(),vpuGibMonth:Q(),balancerHour:Q(),balancerMbpsHour:Q()}).nullable(),start:Sz,baseDomain:G().nullable(),dnsZones:je(G()).optional()}),Ez="stratus.capacity",n2=se({family:G(),limit:G(),zone:G().nullable(),value:Q(),used:Q().nullable(),available:Q().nullable()}),Az=se({region:G(),rows:je(n2)}),Tz=/^\d+-.*-[0-9a-f]{7}$/,Cb="/SERVICES/PACS/",r2=4;function au(t,e){if(Tz.test(e))return!0;if(!t.startsWith(Cb))return!1;const s=t.slice(Cb.length).replace(/\/+$/,"");return s!==""&&s.split("/").length===r2}const o2="daemon";function a2(t){return t.backend??"chris"}class Eg{socket;handlers;token;pending=new Map;pendingCompletions=new Map;silentIds=new Set;nextId=0;mirroring=!1;constructor(e,s,i){this.socket=e,this.handlers=s,this.token=i,this.socket.onmessage=n=>this.message_handle(String(n.data)),this.socket.onclose=()=>this.handlers.close_handle?.()}static session_attach(e,s,i){return new Promise((n,r)=>{const o=new WebSocket(e);o.onerror=()=>r(new Error(`cannot reach the daemon at ${e}`)),o.onopen=()=>{o.send(JSON.stringify({type:"attach",protocolVersion:Uf,token:s,capabilities:{shellCommands:!1,color:!0,hiddenInput:!0,fileDelivery:!0,localFilesystem:!1}}))},o.onmessage=a=>{const l=Rb(String(a.data));if(!l){r(new Error("invalid attach response")),o.close();return}if(l.type==="error"){r(new Error(l.reason)),o.close();return}if(l.type!=="attached"){r(new Error(`unexpected attach response: ${l.type}`)),o.close();return}const c=new Eg(o,i,s);n({client:c,attach:{session:l.session,protocolVersion:l.protocolVersion,...l.stack!==void 0?{stack:l.stack}:{},...l.hostControl!==void 0?{hostControl:l.hostControl}:{},...l.stale!==void 0?{stale:l.stale}:{},...l.terminals!==void 0?{terminals:l.terminals}:{},...l.surface!==void 0?{surface:l.surface}:{},...l.backend!==void 0?{backend:l.backend}:{}}})}})}line_execute(e,s){const i=`argus-${this.nextId++}`;return s?.silent===!0&&this.silentIds.add(i),new Promise((n,r)=>{this.pending.set(i,{resolve:n,reject:r,liveChannels:new Set,observed:s?.observe!==!1}),this.socket.send(JSON.stringify({type:"execute",id:i,line:e,...s?.silent===!0&&s.operator!==!0?{instrument:!0}:{},...this.mirroring&&s?.silent!==!0?{mirrored:!0}:{}}))})}mirror_set(e){this.mirroring=e}terminal_open(e,s,i){this.socket.send(JSON.stringify({type:"terminalOpen",cols:e,rows:s,...i===void 0?{}:{terminalId:i}}))}terminal_input(e,s){this.socket.send(JSON.stringify({type:"terminalInput",terminalId:e,data:s}))}terminal_resize(e,s,i){this.socket.send(JSON.stringify({type:"terminalResize",terminalId:e,cols:s,rows:i}))}line_complete(e){const s=`argus-c-${this.nextId++}`;return new Promise((i,n)=>{this.pendingCompletions.set(s,{resolve:i,reject:n}),this.socket.send(JSON.stringify({type:"complete",id:s,prefix:e}))})}terminalMessage_handle(e){e.type==="terminalOpened"?this.handlers.terminalOpened_receive?.(e.terminalId,e.replay,e.refused):e.type==="terminalData"?this.handlers.terminalData_receive?.(e.terminalId,e.data):this.handlers.terminalExit_receive?.(e.terminalId,e.code)}surfaceLine_handle(e,s,i){const n=this.handlers.surfaceLine_receive;if(n===void 0){this.socket.send(JSON.stringify({type:"surfaceLineError",lineId:e,reason:"this surface runs no lines of its own"}));return}n(s,i).then(r=>{this.socket.send(JSON.stringify({type:"surfaceLineResult",lineId:e,rendered:r.rendered,status:r.status}))},r=>{this.socket.send(JSON.stringify({type:"surfaceLineError",lineId:e,reason:r instanceof Error?r.message:String(r)}))})}claims_send(e){this.socket.send(JSON.stringify({type:"surfaceClaims",claims:e}))}note_send(e){this.socket.send(JSON.stringify({type:"note",text:e}))}stop_send(){this.socket.send(JSON.stringify({type:"stop"}))}regard_send(e){this.socket.send(JSON.stringify({type:"regard",regard:e}))}watch_send(e){this.socket.send(JSON.stringify({type:"watch",subject:e}))}unwatch_send(e){this.socket.send(JSON.stringify({type:"unwatch",subject:e}))}connection_close(){this.socket.close()}message_handle(e){const s=Rb(e);if(l2(s?.type??`refused:${c2(e)}`),!!s)switch(s.type){case"result":{this.silentIds.delete(s.id);const i=this.pending.get(s.id);if(i&&(this.pending.delete(s.id),i.resolve({envelopes:s.envelopes,liveChannels:i.liveChannels})),i===void 0||i.observed)for(const n of s.envelopes)this.handlers.envelope_observe?.(n);break}case"complete":{const i=this.pendingCompletions.get(s.id);i&&(this.pendingCompletions.delete(s.id),i.resolve({candidates:s.candidates,prefix:s.prefix}));break}case"output":{(s.channel==="data"||s.channel==="err")&&this.pending.get(s.id)?.liveChannels.add(s.channel),this.silentIds.has(s.id)||this.handlers.output_receive?.(s.channel,s.chunk);break}case"progress":{this.handlers.progress_receive?.(s);break}case"event":{this.handlers.event_receive?.(s.id,s.kind,s.data);break}case"session":{if(s.surface===o2){this.handlers.ambient_receive?.(s.envelope);break}this.handlers.session_receive?.(s.surface,s.envelope,s.terminal),this.handlers.envelope_observe?.(s.envelope);break}case"watched":{this.handlers.watched_receive?.(s.subject,s.state);break}case"stale":this.handlers.stale_receive?.(s.stale);break;case"surfaceLine":this.surfaceLine_handle(s.lineId,s.line,s.terminal);break;case"terminalOpened":case"terminalData":case"terminalExit":this.terminalMessage_handle(s);break;case"closing":this.handlers.closing_receive?.(s.cause);break;case"numbered":{this.handlers.numbered_receive?.({id:s.id,source:s.source,rows:s.rows,handles:s.handles});break}case"promptline":this.handlers.promptline_receive?.(s.context);break;case"telemetry":this.handlers.telemetry_receive?.(s.index,{lane:s.lane,cube:s.cube,state:s.state,surfaces:s.surfaces});break;case"regard":this.handlers.regard_receive?.(s.regard);break;case"error":{if(s.id!==void 0){const i=this.pending.get(s.id);i&&(this.pending.delete(s.id),i.reject(new Error(s.reason)));const n=this.pendingCompletions.get(s.id);n&&(this.pendingCompletions.delete(s.id),n.reject(new Error(s.reason)))}break}case"prompt":{const i=this.handlers.ask_receive;if(i===void 0){this.reply_send({type:"promptError",promptId:s.promptId,reason:"this surface has no way to ask"});break}const n=s.promptId;i({message:s.message,kind:IR(s),...s.path?.suggest===void 0?{}:{suggest:s.path.suggest},...s.path===void 0?{}:{path:s.path},...s.commit===void 0?{}:{commit:s.commit}}).then(r=>{if(r===null){this.reply_send({type:"promptError",promptId:n,reason:"the operator abandoned the question"});return}this.reply_send({type:"promptAnswer",promptId:n,answer:r})}).catch(r=>{const o=r instanceof Error?r.message:"the question could not be answered";this.reply_send({type:"promptError",promptId:n,reason:o})});break}case"pipe":{this.reply_send({type:"pipeError",pipeId:s.pipeId,reason:"the argus surface cannot run pipeline segments"});break}case"shell":{this.reply_send({type:"shellError",shellId:s.shellId,reason:"the argus surface cannot run shell commands"});break}case"edit":{this.edit_run(s);break}case"deliver":{this.deliver_run(s);break}}}edit_run(e){const s=this.handlers.edit_receive;let i=!1,n="the argus surface cannot open an editor";if(s!==void 0)try{i=s({content:e.content,...e.path===void 0?{}:{path:e.path},...e.extension===void 0?{}:{extension:e.extension}}),n="the editor pane did not open"}catch(r){n=r instanceof Error?r.message:String(r)}if(i){this.reply_send({type:"editResult",editId:e.editId,content:e.content,changed:!1,opened:!0});return}this.reply_send({type:"editError",editId:e.editId,reason:n})}async deliver_run(e){try{const s=ag(e.path,this.token),i=await fetch(s);if(!i.ok)throw new Error(`calypso refused to serve this file (HTTP ${i.status})`);const n=await i.blob(),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=e.filename,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(r),0),this.reply_send({type:"deliverResult",deliverId:e.deliverId,location:e.filename,bytes:n.size})}catch(s){const i=s instanceof Error?s.message:String(s);this.reply_send({type:"deliverError",deliverId:e.deliverId,reason:i})}}reply_send(e){this.socket.send(JSON.stringify(e))}}const ap={};typeof window<"u"&&(window.__argusWire=ap);function l2(t){ap[t]=(ap[t]??0)+1}function c2(t){try{const e=JSON.parse(t).type;return typeof e=="string"?e:"?"}catch{return"?"}}function Rb(t){try{const e=KR(JSON.parse(t));return e.ok&&e.value!==void 0?e.value:null}catch{return null}}const Zi=["#000000","#f24444","#33cc66","#ffaa44","#5599ff","#cc88ff","#44cccc","#ffeecc","#777777","#ff6666","#66ee99","#ffcc66","#77bbff","#dd99ff","#66dddd","#ffffff"],h2=Zi,d2={yellow:Zi[3],white:Zi[7],cyan:Zi[6],green:Zi[2],magenta:Zi[5]};function Dz(){return{fg:null,bg:null,bold:!1,dim:!1,italic:!1,inverse:!1,underline:!1}}function u2(t){if(t<16)return Zi[t]??"#ffeecc";if(t<232){const s=t-16,i=[0,95,135,175,215,255],n=i[Math.floor(s/36)%6]??0,r=i[Math.floor(s/6)%6]??0,o=i[s%6]??0;return`#${(n<<16|r<<8|o).toString(16).padStart(6,"0")}`}const e=8+(t-232)*10;return`#${(e<<16|e<<8|e).toString(16).padStart(6,"0")}`}function f2(t,e){for(let s=0;s<e.length;s++){const i=e[s]??0;if(i===0)Object.assign(t,Dz());else if(i===1)t.bold=!0;else if(i===2)t.dim=!0;else if(i===3)t.italic=!0;else if(i===4)t.underline=!0;else if(i===7)t.inverse=!0;else if(i===27)t.inverse=!1;else if(i===22)t.bold=!1,t.dim=!1;else if(i===23)t.italic=!1;else if(i===24)t.underline=!1;else if(i>=30&&i<=37)t.fg=Zi[i-30]??null;else if(i>=90&&i<=97)t.fg=Zi[i-90+8]??null;else if(i===39)t.fg=null;else if(i>=40&&i<=47)t.bg=Zi[i-40]??null;else if(i>=100&&i<=107)t.bg=Zi[i-100+8]??null;else if(i===49)t.bg=null;else if(i===38||i===48){const n=e[s+1]??0;let r=null;if(n===5)r=u2(e[s+2]??0),s+=2;else if(n===2){const o=e[s+2]??0,a=e[s+3]??0,l=e[s+4]??0;r=`#${(o<<16|a<<8|l).toString(16).padStart(6,"0")}`,s+=4}i===38?t.fg=r:t.bg=r}}}function p2(t){const e=[],s=t.inverse?t.bg??"#000":t.fg,i=t.inverse?t.fg??"var(--daybreak)":t.bg;return s!==null&&e.push(`color:${s}`),i!==null&&e.push(`background-color:${i}`),t.bold&&e.push("font-weight:bold"),t.dim&&e.push("opacity:0.55"),t.italic&&e.push("font-style:italic"),t.underline&&e.push("text-decoration:underline"),e.join(";")}function si(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}const lu=/\x1b(?:\[([0-?]*)[ -/]*([@-~])|\][^\x07\x1b]*(?:\x07|\x1b\\)|[@-Z\\-_])/g;function Cn(t){const e=Dz();let s="",i=0;const n=o=>{if(o.length===0)return;const a=p2(e),l=si(o.replace(/\r/g,""));s+=a.length>0?`<span style="${a}">${l}</span>`:l};lu.lastIndex=0;let r=lu.exec(t);for(;r!==null;){if(n(t.slice(i,r.index)),i=r.index+r[0].length,r[2]==="m"){const o=(r[1]??"").split(/[;:]/).map(a=>a.length>0?Number(a):0);f2(e,o)}r=lu.exec(t)}return n(t.slice(i)),s}function m2(t){for(const[e,s]of Object.entries(d2))t.style.setProperty(`--console-${e}`,s)}const g2=3e3,_2=28;function b2(t,e){if(t===null)return'<span class="dim">argus</span>';const s=t.segments??[],i=s.length>0?M2(s,e):w2(t,e);return i.push(...y2(t,e)),z2(i,e)}function M2(t,e){const s={cloud:e.glyphs.cloud,tenancy:e.glyphs.cube,region:e.glyphs.globe,user:e.glyphs.user,cluster:e.glyphs.sitemap,cwd:e.glyphs.folder},i={leader:e.palette.host,place:e.palette.pacs,identity:e.palette.user,path:e.palette.dir,work:e.palette.duration,note:e.palette.time,alert:e.palette.status};return t.map(n=>{const r=s[n.key],o=n.tone==="identity"?v2(n.value):n.value;return{text:r!==void 0?`${r} ${o}`:o,color:i[n.tone],...o!==n.value?{title:n.value}:{}}})}function v2(t){return t.length<=_2?t:`…${t.slice(-27)}`}function w2(t,e){const s=t.uri.replace(/^https?:\/\//,"").replace(/\/api\/v1\/?$/,""),i=`/home/${t.user}`,n=t.cwd.startsWith(i)?`~${t.cwd.slice(i.length)}`:t.cwd,r=[];if(t.pacsserver!==null&&t.pacsserver.length>0&&r.push({text:`${e.glyphs.database} ${t.pacsserver}`,color:e.palette.pacs}),r.push({text:`${e.glyphs.cube} ${s}`,color:e.palette.host},{text:`${e.glyphs.user} ${t.user}`,color:e.palette.user},{text:`${e.glyphs.folder} ${n}`,color:e.palette.dir}),t.procWarmup!==void 0){const o=BO(t.procWarmup),a=e.procStates[o];r.push({text:`${a.icon} ${a.label}: ${S2(t.procWarmup.loaded,t.procWarmup.total??0)}`,color:a.color})}return r}function y2(t,e){const s=[];if(t.physicalMode&&s.push({text:`${e.glyphs.microscope} PHYSICAL`,color:e.palette.physical}),t.lastCommandDurationMs>=g2){const i=Math.floor(t.lastCommandDurationMs/1e3);s.push({text:`${e.glyphs.bolt} ${i}s`,color:e.palette.duration})}return t.lastExitCode!==0&&s.push({text:`${e.glyphs.error} ${t.lastExitCode}`,color:e.palette.status}),s}function z2(t,e){let s="";for(let i=0;i<t.length;i++){const n=t[i];if(n===void 0)continue;const r=n.title!==void 0?` title="${si(n.title)}"`:"";s+=`<span style="color:${n.color.fg};background-color:${n.color.bg}"${r}> ${si(n.text)} </span>`;const o=t[i+1];s+=o!==void 0?`<span style="color:${n.color.bg};background-color:${o.color.bg}">${e.glyphs.powerline}</span>`:`<span style="color:${n.color.bg}">${e.glyphs.powerline}</span>`}return s}function S2(t,e){if(e<=0)return`${t}/?`;const s=Math.min(99,Math.floor(t/e*100));return`${t}/${e} ${s}%`}const x2={pacs:{bg:"#875FFF",fg:"#FFFFFF"},host:{bg:"#00AFFF",fg:"#001018"},user:{bg:"#00D787",fg:"#00140C"},dir:{bg:"#FFD75F",fg:"#201800"},physical:{bg:"#FF5F5F",fg:"#1B0000"},duration:{bg:"#FF8700",fg:"#201000"},status:{bg:"#FF005F",fg:"#FFFFFF"},time:{bg:"#5F5F87",fg:"#FFFFFF"}},O2={cold:{icon:"",label:"proc cold",color:{bg:"#FF8700",fg:"#201000"}},cached:{icon:"",label:"proc cached, refreshing",color:{bg:"#5F5F87",fg:"#FFFFFF"}},failed:{icon:"",label:"proc failed",color:{bg:"#FF005F",fg:"#FFFFFF"}}},E2={powerline:"",cube:"",database:"",user:"",folder:"",microscope:"",bolt:"",error:"",cloud:"",globe:"",sitemap:""},A2=200;class T2{output;clear(){this.output.replaceChildren()}splashGreeting=null;progressRegion;promptBar;inputGlyph;input;submit;complete;promptContext=null;busy=!0;delegate=null;mirrorPending="";container;pendingAsk=null;queuedLines=[];questionOpen=!1;history=[];historyIndex=0;streamBlock=null;streamPendingElement=null;streamPendingText="";streamPendingChannel="data";constructor(e,s,i){this.submit=s,this.complete=i,this.container=e,e.innerHTML=`
|
|
62
62
|
<div class="argus-screen">
|
|
63
63
|
<div class="argus-output"></div>
|
|
64
64
|
<div class="argus-progress"></div>
|
|
@@ -87,9 +87,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
87
87
|
<span class="argus-progress-label"></span>
|
|
88
88
|
<span class="argus-progress-elapsed"></span>`,this.region.appendChild(n);const r={element:n,labelElement:n.querySelector(".argus-progress-label"),barFill:n.querySelector(".argus-progress-fill"),startedAt:performance.now()};return this.rows.set(e,r),r}row_paint(e,s){const i=s.label??s.operation,n=s.current!==void 0&&s.total!==void 0&&s.total>0?` ${Nb(s.current,s.unit)}/${Nb(s.total,s.unit)}`:"";if(e.labelElement.innerHTML=`${kb(i)}<span class="argus-progress-counts">${kb(n)}</span>`,e.barFill!==null){const r=s.percent??(s.current!==void 0&&s.total!==void 0&&s.total>0?s.current/s.total*100:0);e.barFill.style.width=`${Math.max(0,Math.min(100,r))}%`}}row_remove(e){const s=this.rows.get(e);s!==void 0&&(s.element.remove(),this.rows.delete(e),this.rows.size===0&&this.elapsedTimer!==null&&(clearInterval(this.elapsedTimer),this.elapsedTimer=null))}elapsed_ensure(){this.elapsedTimer===null&&(this.elapsed_paint(),this.elapsedTimer=window.setInterval(()=>this.elapsed_paint(),I2))}elapsed_paint(){const e=performance.now();for(const s of this.rows.values()){const i=s.element.querySelector(".argus-progress-elapsed");i!==null&&(i.textContent=`${((e-s.startedAt)/1e3).toFixed(1)}s`)}}}function Ag(t){return/\dfr\b/.test(t)}function Bb(t){const e=t.trim().match(/^minmax\(\s*([^,]+?)\s*,/);return e!==null?(e[1]??"3em").trim():"3em"}const Hh="argus.columns";function cu(){try{const t=globalThis.localStorage;return t===void 0?null:(t.getItem(`${Hh}.probe`),t)}catch{return null}}function R2(t,e,s){const i=new Map;if(t===null)return i;for(const n of s)try{const r=t.getItem(`${Hh}.${e}.${n}`),o=r===null?Number.NaN:Number(r);Number.isFinite(o)&&o>0&&i.set(n,Math.round(o))}catch{}return i}function k2(t,e,s,i){if(t!==null)try{i===null?t.removeItem(`${Hh}.${e}.${s}`):t.setItem(`${Hh}.${e}.${s}`,String(Math.round(i)))}catch{}}function N2(t){const e=getComputedStyle(t);return t.getBoundingClientRect().width+(Number.parseFloat(e.marginLeft)||0)+(Number.parseFloat(e.marginRight)||0)}function B2(t,e,s,i=0,n=!1){if(n&&!t.expanse){const c=s>=0?s:Math.min(0,Math.max(t.floor-t.width,s));return c===0?{left:null,right:null,moved:c}:{left:Math.round(t.width+c),right:null,moved:c}}let r,o;const a=c=>s>=0?Math.max(0,Math.min(o,c)):Math.min(0,Math.max(r,c));if(e===null){r=t.floor-t.width,o=i;const c=a(s);return{left:Math.round(t.width+c),right:null,moved:c}}if(t.expanse){r=t.floor-t.width,o=e.width-e.floor;const c=a(s);return c===0?{left:null,right:null,moved:c}:{left:null,right:Math.round(e.width-c),moved:c}}if(e.expanse){r=t.floor-t.width,o=e.width-e.floor;const c=a(s);return{left:Math.round(t.width+c),right:null,moved:c}}r=t.floor-t.width,o=e.width-e.floor;const l=a(s);return l===0?{left:null,right:null,moved:l}:{left:Math.round(t.width+l),right:Math.round(e.width-l),moved:l}}const G2="roster-grip";function P2(t,e){for(const s of t.querySelectorAll(`.${G2}`)){if(s.dataset.wired==="1")continue;s.dataset.wired="1";const i=s.closest(".roster-cap");if(i===null)continue;s.addEventListener("click",r=>{r.stopPropagation()});const n=()=>{let r=i.nextElementSibling;for(;r!==null&&!r.classList.contains("roster-cap");)r=r.nextElementSibling;if(!(r instanceof HTMLElement))return null;const o=e.key_read(r);return o===null?null:{cap:r,key:o}};s.addEventListener("dblclick",r=>{r.stopPropagation();const o=e.key_read(i),a=n();o!==null&&e.reset(o),a!==null&&e.reset(a.key)}),s.addEventListener("pointerdown",r=>{const o=e.key_read(i);if(o===null||r.button!==0)return;r.preventDefault(),r.stopPropagation();try{s.setPointerCapture(r.pointerId)}catch{}const a=r.clientX,l=(g,m)=>{const v=N2(g),y=e.floor_measure(m);return{width:v,floor:y,expanse:e.expanse_is(m)&&v>y+1}},c=l(i,o),h=n(),d=h===null?null:l(h.cap,h.key);if(c.expanse&&d===null)return;const u=e.expanseSlack(),p=t.scrollWidth>t.clientWidth+1;t.classList.add("roster-sizing");const f=g=>{const m=B2(c,d,g.clientX-a,u,p);m.left!==null&&e.size(o,m.left),m.right!==null&&h!==null&&e.size(h.key,m.right)},_=()=>{t.classList.remove("roster-sizing"),window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",_),window.removeEventListener("pointercancel",_)};window.addEventListener("pointermove",f),window.addEventListener("pointerup",_),window.addEventListener("pointercancel",_)})}}function Gb(t,e){const s=t.trim().match(/^([\d.]+)\s*(px|em|rem)$/);if(s===null)return 0;const i=Number(s[1]);if(s[2]==="px")return i;const n=s[2]==="rem"?document.documentElement:e,r=Number.parseFloat(getComputedStyle(n).fontSize)||16;return i*r}class L2{root;capsRows=[];strip;input;columns;value_of;onChange;leadingCells;terms;state={sortKey:null,sortDir:"asc",filter:""};changeQueued=!1;change_emit(){this.changeQueued||(this.changeQueued=!0,window.requestAnimationFrame(()=>{this.changeQueued=!1,this.onChange()}))}host_prepare(e){this.root.parentElement!==e&&e.prepend(this.root);for(const s of[...e.children])s!==this.root&&s.remove()}shown=0;total=0;constructor(e,s,i,n,r=0,o=!0,a=[]){this.terms=a,this.columns=e,this.value_of=s,this.onChange=i,n!==void 0&&(this.state={...this.state,sortKey:n.key,sortDir:n.dir}),this.leadingCells=r,this.root=document.createElement("div"),this.root.className="roster-order",this.strip=document.createElement("div"),this.strip.className="roster-filter",this.strip.hidden=!0;const l=document.createElement("span");l.className="roster-filter-glyph",l.textContent="FILTER :",this.input=document.createElement("input"),this.input.className="roster-filter-input",this.input.placeholder="text, or column:text (e.g. owner:<user> status:error)",this.input.setAttribute("autocomplete","off"),this.input.addEventListener("input",()=>this.filter_set(this.input.value,!1)),this.input.addEventListener("keydown",c=>{c.key==="Escape"&&(c.stopPropagation(),this.strip_toggle(!1))}),this.strip.append(l,this.input),o&&this.root.appendChild(this.caps_mint()),this.root.appendChild(this.strip),this.caps_paint()}caps_mint(){const e=document.createElement("div");e.className="roster-caps";for(let s=0;s<this.leadingCells;s++)e.appendChild(document.createElement("span"));for(const s of this.columns){const i=document.createElement("button");if(i.className="roster-cap",i.dataset.key=s.key,i.title=`sort by ${s.label.toLowerCase()} (again to reverse)`,i.addEventListener("click",()=>this.sort_toggle(s.key)),s!==this.columns[this.columns.length-1]){const n=document.createElement("span");n.className="roster-grip",n.title="drag to size the column; press twice to give it back",i.appendChild(n)}e.appendChild(i)}return this.capsRows.push(e),this.caps_paint(),e}state_get(){return{...this.state}}sort_toggle(e){this.state.sortKey===e?this.sort_set(e,this.state.sortDir==="asc"?"desc":"asc"):this.sort_set(e,"asc")}sort_set(e,s){this.columns.some(i=>i.key===e)&&(this.state={...this.state,sortKey:e,sortDir:s},this.caps_paint(),this.change_emit())}onFilter=null;filterChange_observe(e){this.onFilter=e}filterText_get(){return this.state.filter}filter_set(e,s=!0){this.state={...this.state,filter:e},this.onFilter?.(e),s&&(this.input.value=e),e.length>0&&this.strip.hidden&&(this.strip.hidden=!1,this.onStrip?.()),this.change_emit()}strip_toggle(e){const s=e??this.strip.hidden;this.strip.hidden=!s,s?this.input.focus():this.state.filter.length>0&&this.filter_set(""),this.onStrip?.()}strip_isOpen(){return!this.strip.hidden}onStrip=null;stripChange_observe(e){this.onStrip=e}matches(e){return this.terms_parse().every(s=>{const i=s.key===null?void 0:this.terms.find(r=>r.key===s.key);return(i!==void 0?i.value(e).toLowerCase():s.key!==null?String(this.value_of(e,s.key)).toLowerCase():[...this.columns.map(r=>String(this.value_of(e,r.key))),...this.terms.map(r=>r.value(e))].join(" ").toLowerCase()).includes(s.text)})}sorted(e){const s=[...e],i=this.state.sortKey;if(i===null)return s;const n=this.state.sortDir==="asc"?1:-1;return s.sort((r,o)=>{const a=this.value_of(r,i),l=this.value_of(o,i);return typeof a=="number"&&typeof l=="number"?(a-l)*n:String(a).localeCompare(String(l),void 0,{numeric:!0,sensitivity:"base"})*n}),s}counts_set(e,s){this.shown=e,this.total=s}terms_parse(){return this.state.filter.toLowerCase().split(/\s+/).filter(e=>e.length>0).map(e=>{const s=e.indexOf(":");if(s>0){const i=e.slice(0,s);if(this.columns.some(n=>n.key===i)||this.terms.some(n=>n.key===i))return{key:i,text:e.slice(s+1)}}return{key:null,text:e}})}apply(e){const s=this.sorted(e.filter(i=>this.matches(i)));return this.shown=s.length,this.total=e.length,s}summary(){const e=[];return this.state.filter.length>0&&e.push(`FILTERED ${this.shown}/${this.total}`),e.join(" · ")}caps_paint(){const e=this.capsRows.filter(s=>s.parentElement===null||s.isConnected);this.capsRows.length=0,this.capsRows.push(...e);for(const s of this.capsRows)for(const i of s.querySelectorAll(".roster-cap")){const n=i.dataset.key??"",r=this.columns.find(l=>l.key===n),o=n===this.state.sortKey;i.classList.toggle("roster-active",o);let a=i.querySelector(".roster-cap-words");a===null&&(a=document.createElement("span"),a.className="roster-cap-words",i.prepend(a)),a.textContent=`${r?.label??n}${o?this.state.sortDir==="asc"?" ▲":" ▼":""}`}}}const W2=["state-live","state-settled","state-stale","state-wait","state-note","state-refused"];function Es(t,e,s){t!==null&&(t.classList.remove(...W2),e!==null&&t.classList.add(`state-${e}`),s!==void 0&&(t.textContent=s))}function ta(t,e){t?.classList.remove(`state-${e}`)}function F2(t,e,s){t?.classList.toggle(`state-${e}`,s)}class U2{container;order;field=null;constructor(e,s){this.container=e,this.order=s}field_open(){this.order.host_prepare(this.container);const e=document.createElement("div");return e.className="listing-field",this.container.appendChild(e),this.field=e,ii(e,{rows:".listing-row"}),e}field_get(){return this.field}}function $2(t){return t.map(e=>({key:e.key,label:e.label}))}function j2(t){const e=new Map(t.map(s=>[s.key,s]));return(s,i)=>{const n=e.get(i);if(n===void 0)return"";if(n.compare!==void 0)return n.compare(s);const r=n.cell(s);return r instanceof Node?r.textContent??"":r==null?"":String(r)}}function H2(t,e,s){const i=document.createElement("div");i.className=s.className(t);for(const n of s.leading?.(t)??[])i.appendChild(n);for(const n of e){const r=n.cell(t);if(r instanceof Node){i.appendChild(r);continue}const o=document.createElement("span");o.className=n.className,o.textContent=r==null?"":String(r),i.appendChild(o)}return s.decorate?.(i,t),i}function hc(t){let e=0,s=0,i=!1;for(const n of t)e+=n.done,s+=n.total,i=i||n.failed===!0;return{done:e,total:s,...i?{failed:!0}:{}}}function Vh(t){const e=document.createElement("span");if(e.className="listing-progress",t===null||t.total===0)return e.classList.add("listing-progress-idle"),e.title=t===null?"no work":"nothing scheduled yet",e;const s=t.failed===!0,i=t.done>=t.total,n=s&&t.succeeded!==void 0?t.succeeded:t.done,r=Math.min(1,Math.max(0,n/t.total));e.classList.add(s?"listing-progress-failed":i?"listing-progress-done":"listing-progress-running"),e.title=s&&t.succeeded!==void 0?`${t.succeeded}/${t.total} succeeded — errored`:`${t.done}/${t.total}`;const o=document.createElement("span");return o.className="listing-progress-fill",o.style.width=`${Math.round(r*100)}%`,e.appendChild(o),e}function fh(t,e){const s=document.createElement("span");s.className="listing-actions";for(const i of e){if(i.offered!==void 0&&!i.offered(t))continue;const n=document.createElement("button");n.className="listing-action",n.textContent=i.label,i.disabled?.(t)===!0&&(n.disabled=!0),i.selected?.(t)===!0&&n.classList.add("listing-action-selected"),n.addEventListener("click",r=>{r.stopPropagation(),i.run(t)}),s.appendChild(n)}return s}function V2(t,e){return t.mode==="fold"&&t.open.has(e)}function q2(t,e){return t.mode!=="fold"||t.open.delete(e)?!1:(t.open.add(e),!0)}function Pb(t){const e=t.trim();if(/^(auto|min-content|max-content)$/.test(e)||/^fit-content\(/.test(e))return!1;const s=/^minmax\(\s*([^,]+?)\s*,\s*([^)]+?)\s*\)$/.exec(e);if(s!==null){const i=s[1]??"";return/^(?:[1-9]\d*|0*\.\d*[1-9]\d*|[1-9]\d*\.\d+)(px|em|rem|ch|vw|vh|%)$/.test(i)}return/^(?:\d+\.?\d*|\.\d+)(px|em|rem|ch|vw|vh|%|fr)$/.test(e)}function K2(t){let e=0;for(const s of t){if(s.capped!==!1)break;e+=1}return e}function ia(t,e){return{level_visit(s){return s(t,e)}}}function dc(t,e,s){const i=[];let n=!1;for(const r of t){if(r.width===void 0||r.width.trim()==="")throw new Error(`listing trait '${r.key}' declares no width`);if(!Pb(r.width))throw new Error(`listing trait '${r.key}' declares a content-sized track '${r.width.trim()}': a row is its own grid, so a track sized to its content sizes per row and jogs every column after it`);if(r.capped===!1){if(n)throw new Error(`uncapped listing trait '${r.key}' must lead the traits`)}else n=!0;const o=s?.get(r.key);o===void 0?i.push(r.width.trim()):i.push(Ag(r.width)?`minmax(${o}px, 1fr)`:`${o}px`)}if(e!==void 0){if(e.width===void 0||e.width.trim()==="")throw new Error("listing actions on the row declare no track; declare a width, or a row zone for the verbs to ride");if(!Pb(e.width))throw new Error(`listing actions declare a content-sized track '${e.width.trim()}'`);i.push(e.width.trim())}return i.join(" ")}let El=new Map,ph=new Map;function Y2(t){if(El=new Map,ph=new Map,t!==null)for(const e of t.handles)El.has(e.address)||El.set(e.address,e),ph.set(e.kind,Math.max(ph.get(e.kind)??0,`${e.ordinal}`.length));Cz()}function Iz(t){const e=Math.max(3,ph.get(t.kind)??0);return`${t.kind}${`${t.ordinal}`.padStart(e,"0")}`}function Cz(){const t=new Map;for(const e of document.querySelectorAll(".listing-index")){const s=e.closest(".listing-row"),i=s?.parentElement??null;if(s===null||i===null)continue;if(s.classList.contains("listing-lead")){e.textContent="",e.classList.remove("numbered");continue}const r=i.classList.contains("listing-rows")&&i.parentElement?.classList.contains("listing-block")===!0?i.closest(".listing-field")??i:i,o=t.get(r);o===void 0?t.set(r,[s]):o.push(s)}for(const e of t.values()){const s=`${Math.max(e.length,1)}`.length;e.forEach((i,n)=>{const r=i.querySelector(".listing-index");if(r===null)return;const o=r.dataset.address,a=o===void 0?void 0:El.get(o);r.textContent=a===void 0?`${n+1}`.padStart(s,"0"):Iz(a),r.classList.toggle("numbered",a!==void 0)})}}function X2(t){return{key:"index",label:"",className:"listing-index-cell",width:"5.2rem",capped:!1,cell:e=>{const s=document.createElement("span");s.className="listing-index";const i=t?.(e);i!==void 0&&(s.dataset.address=i);const n=i===void 0?void 0:El.get(i);return n!==void 0&&(s.textContent=Iz(n),s.classList.add("numbered")),s}}}class Tg{declaration;host;select;order;template;child;expansion;rowsByKey=new Map;dataByKey=new Map;cellsByKey=new Map;leadKeys=new Set;indicated=null;depth;constructor(e,s,i,n,r=0){e={...e,traits:[X2(e.address),...e.traits]},this.declaration=e,this.host=s,this.select=n,this.depth=r,this.template=dc(e.traits,this.trackActions_get(),this.sized);const o=e.traits.filter(a=>a.capped!==!1);if(this.order=new L2($2(o),j2(e.traits),()=>this.host.repaint(),e.defaultSort,K2(e.traits),i,e.terms??[]),this.expansion={mode:e.child===void 0?"replace":"fold",open:new Set},this.child=e.child===void 0?null:this.childSeat_build(e.child),this.child!==null){const a=this.child;this.order.filterChange_observe(l=>a.filter_set(l))}}childSeat_build(e){return e.level_visit((s,i)=>{const n=new Tg(i,this.host,!1,null,this.depth+1);return{filter_set:r=>n.filter_set(r),sort_set:(r,o)=>n.sort_set(r,o),survives:r=>n.anyMatch(s(r)),render:(r,o,a)=>{const l=document.createElement("div");l.className="listing-level",l.dataset.depth=String(this.depth+1),l.style.setProperty("--roster-cols",n.template),l.appendChild(n.order.caps_mint()),n.rows_draw(s(r),[],l,a),o.appendChild(l)},forget:()=>n.forget(),open_set:(r,o)=>n.open_set(r,o),open_clear:()=>n.open_clear(),template_select:r=>n.template_select(r)}})}actions_set(e){this.declaration={...this.declaration,...e===null?{actions:void 0}:{actions:e}},this.template=dc(this.traits_shown(),this.trackActions_get(),this.sized)}shed=new Set;traits_shown(){return this.shed.size===0?this.declaration.traits:this.declaration.traits.filter(e=>!this.shed.has(e.key))}shed_set(e){this.shed.clear();for(const s of e)this.shed.add(s);this.template=dc(this.traits_shown(),this.trackActions_get(),this.sized)}shedOrder(){return this.declaration.traits.filter(e=>e.shed!==void 0).sort((e,s)=>e.shed-s.shed).map(e=>e.key)}label_find(e){return this.declaration.traits.find(s=>s.key===e)?.label??e}sized=new Map;column_size(e,s){s===null?this.sized.delete(e):this.sized.set(e,s),this.template=dc(this.traits_shown(),this.trackActions_get(),this.sized)}track_find(e){return this.declaration.traits.find(s=>s.key===e)?.width??null}traitKeys(){return this.declaration.traits.map(e=>e.key)}expanse_find(){const e=this.declaration.traits.find(s=>Ag(s.width??""));return e===void 0?null:{key:e.key,width:e.width??""}}trackActions_get(){return this.host.framed()?void 0:this.declaration.actions}filter_set(e){this.order.filter_set(e,!1)}sort_set(e,s){this.order.sort_set(e,s),this.child?.sort_set(e,s)}open_set(e,s){if(e===0){if(this.expansion.open.clear(),this.expansion.mode==="fold")for(const i of s)this.expansion.open.add(i);return}this.child?.open_set(e-1,s)}open_clear(){this.expansion.open.clear(),this.child?.open_clear()}template_select(e){if(e===0)return this.template;if(this.child===null)throw new Error(`no listing level at depth ${this.depth+e}`);return this.child.template_select(e-1)}anyMatch(e){return e.some(s=>this.order.matches(s)||(this.child?.survives(s)??!1))}filter_isEmpty(){return this.order.state_get().filter.length===0}rows_keep(e,s){const i=s?[...e]:e.filter(n=>this.order.matches(n)||(this.child?.survives(n)??!1));return this.order.sorted(i)}forget(){this.rowsByKey.clear(),this.dataByKey.clear(),this.cellsByKey.clear(),this.leadKeys.clear(),this.indicated=null,this.child?.forget()}rows_draw(e,s,i,n){for(const o of s)i.appendChild(this.row_build(o,!0));const r=this.rows_keep(e,n);for(const o of r){const a=this.row_build(o,!1);if(this.child===null){i.appendChild(a);continue}const l=this.declaration.key(o),c=this.order.filterText_get()!==""&&!this.order.matches(o)&&(this.child?.survives(o)??!1),h=V2(this.expansion,l)||c,d=document.createElement("div"),u=this.declaration.row?.groupClassName?.(o);d.className=`listing-group${h?" listing-open":""}${u===void 0||u===""?"":` ${u}`}`,d.appendChild(a),h&&(a.classList.add("listing-open"),this.child.render(o,d,n||this.order.matches(o))),i.appendChild(d)}return r.length}row_build(e,s){const i=this.declaration,n=i.key(e),r=this.host.framed(),o=H2(e,this.traits_shown(),{className:h=>{const d=i.row?.className?.(h);return d===void 0||d===""?"listing-row":`listing-row ${d}`},decorate:(h,d)=>{if(h.dataset.key=n,i.actions!==void 0&&!r){const u=document.createElement("span");u.className="listing-actions",!s&&i.actions.always===!0&&u.replaceChildren(...fh(d,i.actions.of(d)).childNodes),h.appendChild(u),this.cellsByKey.set(n,u)}i.row?.decorate?.(h,d)}});if(this.rowsByKey.set(n,o),this.dataByKey.set(n,e),s&&(this.leadKeys.add(n),o.classList.add("listing-lead")),i.activatable?.(e)===!1)return o;o.classList.add("listing-activatable");const a=i.actions!==void 0&&i.actions.always!==!0&&i.actions.of(e).length>0,l=!s&&this.child!==null,c=this.controlCell_find(o);return o.addEventListener("click",h=>{if(!(!s&&this.select!==null&&this.select(n,e))){if(c!==null&&h.target instanceof Node&&c.contains(h.target)){l||this.row_indicate(null),this.row_activate(e,n,s);return}if(!a){this.row_activate(e,n,s);return}this.row_indicate(n),l&&c===null&&this.row_activate(e,n,!1)}}),a&&!l&&o.addEventListener("dblclick",()=>{this.row_indicate(null),this.row_activate(e,n,s)}),o}controlCell_find(e){const s=this.declaration.control;if(s===void 0)return null;const i=this.declaration.traits.findIndex(r=>r.key===s);if(i<0)throw new Error(`listing level declares control '${s}', which names no trait`);const n=e.children[i];return n instanceof HTMLElement?(n.classList.add("listing-control"),n):null}row_activate(e,s,i){if(!i&&this.child!==null){q2(this.expansion,s),this.host.repaint(),this.declaration.activate?.(e);return}this.host.activating_is(s)||(this.host.activation_begin(s,this.rowsByKey.get(s)??null,J2(s)),this.declaration.activate?.(e))}row_indicate(e,s=!1){const i=this.host.framed();if(this.indication_drop(),e===null){this.host.indication_release(this);return}const n=this.dataByKey.get(e),r=this.rowsByKey.get(e);if(n===void 0||r===void 0){this.host.indication_release(this);return}this.indicated=e,r.classList.add("listing-indicated");const o=this.declaration.actions?.of(n)??[];if(this.host.indication_claim({level:this,key:e,drop:()=>this.indication_drop(),restore:()=>this.rowsByKey.has(e)?(this.row_indicate(e,!0),!0):!1}),i)this.host.zoneVerbs_set([...fh(n,o).childNodes]);else{const a=this.cellsByKey.get(e);a!==void 0&&o.length>0&&a.replaceChildren(...fh(n,o).childNodes)}s||this.declaration.indicated?.(n)}indication_drop(){this.indicated!==null&&(this.cellsByKey.get(this.indicated)?.replaceChildren(),this.rowsByKey.get(this.indicated)?.classList.remove("listing-indicated"),this.indicated=null)}indicated_get(){return this.indicated}readout_show(e,s){if(this.indicated!==e)return;if(this.host.framed()){this.host.zoneReadout_set(s);return}const i=this.cellsByKey.get(e);if(i===void 0)return;const n=document.createElement("span");n.className="listing-readout",n.append(s),i.querySelector(".listing-readout")?.remove(),i.appendChild(n)}row_element(e){return this.rowsByKey.get(e)??null}keysOnStage_list(){return[...this.rowsByKey.keys()].filter(e=>!this.leadKeys.has(e))}}class Vn{declaration;level;host;gridHost;stateSpan;activating=null;filterBlock;selectBlock;zone;wired=!1;zonePane_get(){return this.zone?.closest(".workspace-pane, [data-frame-host]")??null}zoneOpened=!1;claim=null;blocks=[];field=null;painter=null;selecting=!1;selection=new Map;repaintQueued=!1;constructor(e){if(this.declaration=e,this.gridHost=e.gridHost??e.mount,this.zone=e.rowZone??Z2(e.mount,e.chrome?.prefix),e.selection!==void 0&&this.zone===null)throw new Error("a listing that selects declares a row zone: a selection's verbs ride the frame");this.level=new Tg(e,{repaint:()=>this.repaint_queue(),framed:()=>this.zone!==null,activating_is:i=>this.activating?.key===i,activation_begin:(i,n,r)=>this.activation_begin(i,n,r),zoneVerbs_set:i=>this.zoneVerbs_set(i),zoneReadout_set:i=>this.zoneReadout_set(i),indication_claim:i=>{this.claim!==null&&this.claim.level!==i.level&&this.claim.drop(),this.claim=i},indication_release:i=>{this.claim===null||this.claim.level!==i||(this.claim=null,this.zoneVerbs_set([]))}},e.caps!=="each",e.selection===void 0?null:(i,n)=>this.selection_gather(i,n)),this.host=new U2(e.mount,this.level.order),this.gridHost.style.setProperty("--roster-cols",this.level.template),this.zone!==null&&(this.zone.classList.add("listing-zone"),this.zone.hidden=!0,e.mount.classList.add("listing-framed"),this.zone_wire());const s=e.chrome;this.stateSpan=s?.root.querySelector(".pane-state")??null,this.filterBlock=s?.root.querySelector(`.${s.prefix}-filter`)??null,this.selectBlock=s?.root.querySelector(`.${s.prefix}-select`)??null,this.filterBlock?.classList.add("rail-off"),this.filterBlock?.addEventListener("click",()=>this.filter_toggle()),s?.root.querySelector(`.${s.prefix}-refresh`)?.addEventListener("click",()=>this.declaration.refresh?.()),this.columns_wire(s),this.level.order.stripChange_observe(()=>this.filterBlock_sync()),this.selectBlock?.addEventListener("click",()=>this.select_toggle()),s?.root.addEventListener("argus:roster",i=>{const n=i.detail;n.op==="sort"?this.level.sort_set(n.key,n.dir??"asc"):n.text===""?this.level.order.strip_toggle(!1):this.level.order.filter_set(n.text)}),this.filterBlock_sync()}rows_set(e,s){this.field!==null&&s.field!==this.field&&(this.selection.clear(),this.claim?.drop(),this.claim=null),this.field=s.field,this.blocks=e,this.activation_settle(),this.render(),this.grips_ensure()}activation_begin(e,s,i){this.activating?.element?.classList.remove("listing-activating"),this.activating={key:e,element:s},s?.classList.add("listing-activating"),Es(this.stateSpan,"wait",`OPENING ${i}`)}activation_settle(){this.activating!==null&&(this.activating.element?.classList.remove("listing-activating"),this.activating=null,ta(this.stateSpan,"wait"))}activation_refuse(e){this.activating!==null&&(this.activation_settle(),Es(this.stateSpan,"refused",e.toUpperCase()))}activating_get(){return this.activating?.key??null}repaint_queue(){this.repaintQueued||(this.repaintQueued=!0,window.requestAnimationFrame(()=>{this.repaintQueued=!1,this.render()}))}render(){this.level.forget();const e=this.host.field_open(),s=this.level.filter_isEmpty();let i=0,n=0;const r=this.blocks.reduce((o,a)=>o+a.rows.length,0);this.blocks.length>0&&r===0&&this.declaration.empty!==void 0&&e.appendChild(this.declaration.empty());for(const o of this.blocks){const a=document.createElement("section");if(a.className="listing-block",a.dataset.key=o.key,o.header!==void 0&&a.appendChild(o.header),this.declaration.caps==="each"&&a.appendChild(this.level.order.caps_mint()),n+=o.rows.length,this.painter!==null){const l=this.level.rows_keep(o.rows,s);i+=l.length,this.painter({...o,rows:l},a)}else{const l=document.createElement("div");l.className="listing-rows",i+=this.level.rows_draw(o.rows,o.lead??[],l,s),a.appendChild(l)}e.appendChild(a)}!s&&r>0&&i===0&&this.declaration.filteredEmpty!==void 0&&e.appendChild(this.declaration.filteredEmpty(this.level.order.filterText_get())),this.level.order.counts_set(i,n),Cz(),this.claim!==null&&!this.claim.restore()&&(this.claim=null,this.zoneVerbs_set([])),this.selection_render(),this.state_render(),this.shed_fit()}shedObserver=null;shedWidth=-1;shed_fit(e=!1){const s=this.level.shedOrder();if(s.length===0)return;this.shedObserver===null&&typeof ResizeObserver<"u"&&(this.shedObserver=new ResizeObserver(()=>this.shed_fit()),this.shedObserver.observe(this.gridHost));const i=this.declaration.mount.querySelector(".roster-order .roster-caps")??this.declaration.mount.querySelector(".roster-caps");if(i===null||i.clientWidth===0)return;const n=i.clientWidth;if(!e&&n===this.shedWidth){for(const c of i.querySelectorAll(".roster-cap"))c.hidden=this.level.shed.has(c.dataset.key??"");return}this.shedWidth=n;const r=[...this.level.shed].join(","),o=c=>{this.level.shed_set(c),this.gridHost.style.setProperty("--roster-cols",this.level.template);for(const h of i.querySelectorAll(".roster-cap"))h.hidden=this.level.shed.has(h.dataset.key??"");return i.scrollWidth<=i.clientWidth+1};let a=[],l=o(a);for(const c of s){if(l)break;a=[...a,c],l=o(a)}a.join(",")!==r&&(this.columnsBlock_paint(),this.field!==null&&this.render())}row_indicate(e){if(e===null){this.claim?.drop();const s=this.claim;this.claim=null,s!==null&&this.zoneVerbs_set([]);return}this.level.row_indicate(e)}indicated_get(){return this.claim?.key??null}indication_refresh(){this.claim!==null&&(this.claim.restore()||(this.claim=null,this.zoneVerbs_set([])))}readout_show(e,s){this.level.readout_show(e,s)}row_element(e){return this.level.row_element(e)}template_get(e=0){return this.level.template_select(e)}field_get(){return this.host.field_get()}open_set(e,s){this.level.open_set(e,s),this.field!==null&&this.render()}open_clear(){this.level.open_clear()}painter_set(e){this.painter=e}actions_declare(e){this.level.actions_set(e),this.gridHost.style.setProperty("--roster-cols",this.level.template),this.field!==null&&this.render()}columnsBlock=null;columnsPrefix=null;columns_wire(e){if(this.columnsPrefix=e?.prefix??null,this.columnsBlock=e?.root.querySelector(`.${e.prefix}-columns`)??null,this.columnsBlock?.addEventListener("click",()=>this.columns_reset()),this.columnsPrefix!==null){for(const[s,i]of R2(cu(),this.columnsPrefix,this.level.traitKeys()))this.level.column_size(s,i);this.gridHost.style.setProperty("--roster-cols",this.level.template)}this.columnsBlock_paint(),this.grips_ensure()}grips_ensure(){const e=this.declaration.mount.querySelector(".roster-order .roster-caps");if(e===null)return;const s=cu();P2(e,{key_read:i=>i.dataset.key??null,expanse_is:i=>Ag(this.level.track_find(i)??""),floor_measure:i=>Gb(Bb(this.level.track_find(i)??"3em"),e),expanseSlack:()=>{const i=this.level.expanse_find(),n=i===null?null:e.querySelector(`.roster-cap[data-key="${i.key}"]`);return n===null||i===null?0:Math.max(0,n.getBoundingClientRect().width-Gb(Bb(i.width),e))},size:(i,n)=>this.column_size(i,n,s),reset:i=>this.column_size(i,null,s)})}column_size(e,s,i){this.level.column_size(e,s),this.gridHost.style.setProperty("--roster-cols",this.level.template),this.columnsPrefix!==null&&k2(i,this.columnsPrefix,e,s),this.columnsBlock_paint()}columns_reset(){const e=cu();for(const s of[...this.level.sized.keys()])this.column_size(s,null,e)}columns_sized(){return[...this.level.sized.keys()]}columnsBlock_paint(){if(this.columnsBlock===null)return;const e=this.level.sized.size>0,s=[...this.level.shed].map(i=>this.level.label_find(i));this.columnsBlock.textContent=`COLUMNS${e?" · SIZED":""}${s.length>0?` · ${s.length} HIDDEN`:""}`,this.columnsBlock.classList.toggle("rail-off",!e&&s.length===0),this.columnsBlock.title=`${e?"columns sized by hand; press to give them all back":"drag a cap's edge to size its column; a double-press gives one back"}${s.length>0?`. Hidden for want of room: ${s.join(", ")} (a wider pane brings them back)`:""}`}filter_toggle(e){this.level.order.strip_toggle(e)}filter_set(e){this.level.order.filter_set(e)}filterText_get(){return this.level.order.filterText_get()}filterBlock_sync(){if(this.filterBlock===null)return;const e=this.level.order.strip_isOpen();this.filterBlock.textContent=e?"FILTER ON":"FILTER OFF",this.filterBlock.classList.toggle("rail-off",!e)}select_toggle(e){this.declaration.selection!==void 0&&(this.selecting=e??!this.selecting,this.zoneOpened=!1,this.claim!==null&&this.row_indicate(null),this.declaration.mount.classList.toggle("listing-selecting",this.selecting),this.selectBlock?.classList.toggle("rail-off",!this.selecting),this.selectBlock!==null&&(this.selectBlock.textContent=this.selecting?"SELECT ON":"SELECT OFF"),this.selection_render(),this.state_render())}select_isOn(){return this.selecting}selection_get(){return[...this.selection.keys()]}selection_gather(e,s){return this.selecting?(this.selection.has(e)?this.selection.delete(e):this.selection.set(e,s),this.selection_render(),this.state_render(),!0):!1}selection_render(){for(const i of this.level.keysOnStage_list())this.level.row_element(i)?.classList.toggle("listing-selected",this.selection.has(i));if(this.zone===null)return;if(!this.selecting){this.claim===null&&this.zoneVerbs_set([]);return}const e=[...this.selection.entries()],s=e.length>0?this.declaration.selection?.verbs(e)??[]:[];this.zoneVerbs_set(s.length===0?[]:[...fh(void 0,s).childNodes])}zone_wire(){const e=this.zone,s=this.zonePane_get();if(e===null||s===null||this.wired)return;this.wired=!0,e.closest(".mode-frame")?.addEventListener("click",n=>{n.target instanceof Node&&e.contains(n.target)||(this.zoneOpened=!1)},!0),new MutationObserver(()=>{s.dataset.modes!=="open"&&(this.zoneOpened=!1,this.claim!==null&&this.row_indicate(null))}).observe(s,{attributes:!0,attributeFilter:["data-modes"]})}zoneVerbs_set(e){const s=this.zone;if(s===null)return;s.replaceChildren(...e),s.hidden=e.length===0,this.wired||this.zone_wire();const i=this.zonePane_get();if(i!==null){if(e.length>0){i.dataset.modes!=="open"&&(i.dataset.modes="open",this.zoneOpened=!0);return}this.zoneOpened&&(this.zoneOpened=!1,delete i.dataset.modes)}}zoneReadout_set(e){const s=this.zone;if(s===null)return;s.querySelector(".listing-readout")?.remove();const i=document.createElement("span");i.className="listing-readout",i.append(e),s.appendChild(i),s.hidden=!1}selectionShown_count(){let e=0;for(const s of this.selection.keys())this.level.row_element(s)!==null&&(e+=1);return e}state_refresh(){this.state_render()}state_render(){if(this.stateSpan===null)return;const e={filter:this.level.order.summary(),selecting:this.selecting,selected:this.selection.size,shown:this.selectionShown_count(),shed:this.level.shed.size},s=this.declaration.state!==void 0?this.declaration.state(e):Q2(e);s!==null&&(this.stateSpan.textContent=s)}}function Z2(t,e){const s=t.parentElement?.querySelector(":scope > .mode-frame")??null;if(s===null)return null;const i=document.createElement("span");i.className=e===void 0?"listing-zone":`listing-zone ${e}-row-zone`,i.hidden=!0;const n=s.querySelector(":scope > .mode-fill");return n!==null?s.insertBefore(i,n):s.appendChild(i),i}function J2(t){return t.split("/").filter(e=>e!=="").pop()??t}function Q2(t){const e=[];return t.selecting&&e.push("SELECT"),t.filter!==""&&e.push(t.filter),(t.shed??0)>0&&e.push(`${t.shed} COLUMN${t.shed===1?"":"S"} HIDDEN`),t.selected>0&&e.push(t.shown===t.selected?`${t.selected} SELECTED`:`${t.selected} SELECTED · ${t.shown} SHOWN`),e.join(" · ")}const eN="modulepreload",tN=function(t,e){return new URL(t,e).href},Lb={},Ll=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=tN(h,i),h in Lb)return;Lb[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":eN,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)})},sN=["single","mpr","3d","slab"],Wb=["wl","zoom","pan","length","angle","probe"],mh=["gray","hot","jet","cool"],Rz=[{name:"brain",lower:0,upper:80,modalities:["CT"]},{name:"bone",lower:-500,upper:1300,modalities:["CT"]},{name:"lung",lower:-1400,upper:200,modalities:["CT"]},{name:"soft",lower:-160,upper:240,modalities:["CT"]},{name:"liver",lower:-10,upper:140,modalities:["CT"]}],lp=/\.(nii|nii\.gz|mgz|mgh)$/i,qh=/\.dcm$/i;function iN(t,e){const s=t.toLowerCase();return Rz.find(i=>i.name===s&&(i.modalities.length===0||i.modalities.includes(e.toUpperCase())))}const kr={charge:!0,link:!0,collide:!0,gravity:!1},Pt=.55;function oo(t,e,s){var i,n=1;t==null&&(t=0),e==null&&(e=0),s==null&&(s=0);function r(){var o,a=i.length,l,c=0,h=0,d=0;for(o=0;o<a;++o)l=i[o],c+=l.x||0,h+=l.y||0,d+=l.z||0;for(c=(c/a-t)*n,h=(h/a-e)*n,d=(d/a-s)*n,o=0;o<a;++o)l=i[o],c&&(l.x-=c),h&&(l.y-=h),d&&(l.z-=d)}return r.initialize=function(o){i=o},r.x=function(o){return arguments.length?(t=+o,r):t},r.y=function(o){return arguments.length?(e=+o,r):e},r.z=function(o){return arguments.length?(s=+o,r):s},r.strength=function(o){return arguments.length?(n=+o,r):n},r}function nN(t){const e=+this._x.call(null,t);return kz(this.cover(e),e,t)}function kz(t,e,s){if(isNaN(e))return t;var i,n=t._root,r={data:s},o=t._x0,a=t._x1,l,c,h,d,u;if(!n)return t._root=r,t;for(;n.length;)if((h=e>=(l=(o+a)/2))?o=l:a=l,i=n,!(n=n[d=+h]))return i[d]=r,t;if(c=+t._x.call(null,n.data),e===c)return r.next=n,i?i[d]=r:t._root=r,t;do i=i?i[d]=new Array(2):t._root=new Array(2),(h=e>=(l=(o+a)/2))?o=l:a=l;while((d=+h)==(u=+(c>=l)));return i[u]=n,i[d]=r,t}function rN(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,s=new Float64Array(e);let i=1/0,n=-1/0;for(let r=0,o;r<e;++r)isNaN(o=+this._x.call(null,t[r]))||(s[r]=o,o<i&&(i=o),o>n&&(n=o));if(i>n)return this;this.cover(i).cover(n);for(let r=0;r<e;++r)kz(this,s[r],t[r]);return this}function oN(t){if(isNaN(t=+t))return this;var e=this._x0,s=this._x1;if(isNaN(e))s=(e=Math.floor(t))+1;else{for(var i=s-e||1,n=this._root,r,o;e>t||t>=s;)switch(o=+(t<e),r=new Array(2),r[o]=n,n=r,i*=2,o){case 0:s=e+i;break;case 1:e=s-i;break}this._root&&this._root.length&&(this._root=n)}return this._x0=e,this._x1=s,this}function aN(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function lN(t){return arguments.length?this.cover(+t[0][0]).cover(+t[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function Fn(t,e,s){this.node=t,this.x0=e,this.x1=s}function cN(t,e){var s,i=this._x0,n,r,o=this._x1,a=[],l=this._root,c,h;for(l&&a.push(new Fn(l,i,o)),e==null?e=1/0:(i=t-e,o=t+e);c=a.pop();)if(!(!(l=c.node)||(n=c.x0)>o||(r=c.x1)<i))if(l.length){var d=(n+r)/2;a.push(new Fn(l[1],d,r),new Fn(l[0],n,d)),(h=+(t>=d))&&(c=a[a.length-1],a[a.length-1]=a[a.length-1-h],a[a.length-1-h]=c)}else{var u=Math.abs(t-+this._x.call(null,l.data));u<e&&(e=u,i=t-u,o=t+u,s=l.data)}return s}function hN(t){if(isNaN(l=+this._x.call(null,t)))return this;var e,s=this._root,i,n,r,o=this._x0,a=this._x1,l,c,h,d,u;if(!s)return this;if(s.length)for(;;){if((h=l>=(c=(o+a)/2))?o=c:a=c,e=s,!(s=s[d=+h]))return this;if(!s.length)break;e[d+1&1]&&(i=e,u=d)}for(;s.data!==t;)if(n=s,!(s=s.next))return this;return(r=s.next)&&delete s.next,n?(r?n.next=r:delete n.next,this):e?(r?e[d]=r:delete e[d],(s=e[0]||e[1])&&s===(e[1]||e[0])&&!s.length&&(i?i[u]=s:this._root=s),this):(this._root=r,this)}function dN(t){for(var e=0,s=t.length;e<s;++e)this.remove(t[e]);return this}function uN(){return this._root}function fN(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function pN(t){var e=[],s,i=this._root,n,r,o;for(i&&e.push(new Fn(i,this._x0,this._x1));s=e.pop();)if(!t(i=s.node,r=s.x0,o=s.x1)&&i.length){var a=(r+o)/2;(n=i[1])&&e.push(new Fn(n,a,o)),(n=i[0])&&e.push(new Fn(n,r,a))}return this}function mN(t){var e=[],s=[],i;for(this._root&&e.push(new Fn(this._root,this._x0,this._x1));i=e.pop();){var n=i.node;if(n.length){var r,o=i.x0,a=i.x1,l=(o+a)/2;(r=n[0])&&e.push(new Fn(r,o,l)),(r=n[1])&&e.push(new Fn(r,l,a))}s.push(i)}for(;i=s.pop();)t(i.node,i.x0,i.x1);return this}function gN(t){return t[0]}function _N(t){return arguments.length?(this._x=t,this):this._x}function Dg(t,e){var s=new Ig(e??gN,NaN,NaN);return t==null?s:s.addAll(t)}function Ig(t,e,s){this._x=t,this._x0=e,this._x1=s,this._root=void 0}function Fb(t){for(var e={data:t.data},s=e;t=t.next;)s=s.next={data:t.data};return e}var ai=Dg.prototype=Ig.prototype;ai.copy=function(){var t=new Ig(this._x,this._x0,this._x1),e=this._root,s,i;if(!e)return t;if(!e.length)return t._root=Fb(e),t;for(s=[{source:e,target:t._root=new Array(2)}];e=s.pop();)for(var n=0;n<2;++n)(i=e.source[n])&&(i.length?s.push({source:i,target:e.target[n]=new Array(2)}):e.target[n]=Fb(i));return t};ai.add=nN;ai.addAll=rN;ai.cover=oN;ai.data=aN;ai.extent=lN;ai.find=cN;ai.remove=hN;ai.removeAll=dN;ai.root=uN;ai.size=fN;ai.visit=pN;ai.visitAfter=mN;ai.x=_N;function bN(t){const e=+this._x.call(null,t),s=+this._y.call(null,t);return Nz(this.cover(e,s),e,s,t)}function Nz(t,e,s,i){if(isNaN(e)||isNaN(s))return t;var n,r=t._root,o={data:i},a=t._x0,l=t._y0,c=t._x1,h=t._y1,d,u,p,f,_,g,m,v;if(!r)return t._root=o,t;for(;r.length;)if((_=e>=(d=(a+c)/2))?a=d:c=d,(g=s>=(u=(l+h)/2))?l=u:h=u,n=r,!(r=r[m=g<<1|_]))return n[m]=o,t;if(p=+t._x.call(null,r.data),f=+t._y.call(null,r.data),e===p&&s===f)return o.next=r,n?n[m]=o:t._root=o,t;do n=n?n[m]=new Array(4):t._root=new Array(4),(_=e>=(d=(a+c)/2))?a=d:c=d,(g=s>=(u=(l+h)/2))?l=u:h=u;while((m=g<<1|_)===(v=(f>=u)<<1|p>=d));return n[v]=r,n[m]=o,t}function MN(t){var e,s,i=t.length,n,r,o=new Array(i),a=new Array(i),l=1/0,c=1/0,h=-1/0,d=-1/0;for(s=0;s<i;++s)isNaN(n=+this._x.call(null,e=t[s]))||isNaN(r=+this._y.call(null,e))||(o[s]=n,a[s]=r,n<l&&(l=n),n>h&&(h=n),r<c&&(c=r),r>d&&(d=r));if(l>h||c>d)return this;for(this.cover(l,c).cover(h,d),s=0;s<i;++s)Nz(this,o[s],a[s],t[s]);return this}function vN(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var s=this._x0,i=this._y0,n=this._x1,r=this._y1;if(isNaN(s))n=(s=Math.floor(t))+1,r=(i=Math.floor(e))+1;else{for(var o=n-s||1,a=this._root,l,c;s>t||t>=n||i>e||e>=r;)switch(c=(e<i)<<1|t<s,l=new Array(4),l[c]=a,a=l,o*=2,c){case 0:n=s+o,r=i+o;break;case 1:s=n-o,r=i+o;break;case 2:n=s+o,i=r-o;break;case 3:s=n-o,i=r-o;break}this._root&&this._root.length&&(this._root=a)}return this._x0=s,this._y0=i,this._x1=n,this._y1=r,this}function wN(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function yN(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function Xs(t,e,s,i,n){this.node=t,this.x0=e,this.y0=s,this.x1=i,this.y1=n}function zN(t,e,s){var i,n=this._x0,r=this._y0,o,a,l,c,h=this._x1,d=this._y1,u=[],p=this._root,f,_;for(p&&u.push(new Xs(p,n,r,h,d)),s==null?s=1/0:(n=t-s,r=e-s,h=t+s,d=e+s,s*=s);f=u.pop();)if(!(!(p=f.node)||(o=f.x0)>h||(a=f.y0)>d||(l=f.x1)<n||(c=f.y1)<r))if(p.length){var g=(o+l)/2,m=(a+c)/2;u.push(new Xs(p[3],g,m,l,c),new Xs(p[2],o,m,g,c),new Xs(p[1],g,a,l,m),new Xs(p[0],o,a,g,m)),(_=(e>=m)<<1|t>=g)&&(f=u[u.length-1],u[u.length-1]=u[u.length-1-_],u[u.length-1-_]=f)}else{var v=t-+this._x.call(null,p.data),y=e-+this._y.call(null,p.data),b=v*v+y*y;if(b<s){var w=Math.sqrt(s=b);n=t-w,r=e-w,h=t+w,d=e+w,i=p.data}}return i}function SN(t){if(isNaN(h=+this._x.call(null,t))||isNaN(d=+this._y.call(null,t)))return this;var e,s=this._root,i,n,r,o=this._x0,a=this._y0,l=this._x1,c=this._y1,h,d,u,p,f,_,g,m;if(!s)return this;if(s.length)for(;;){if((f=h>=(u=(o+l)/2))?o=u:l=u,(_=d>=(p=(a+c)/2))?a=p:c=p,e=s,!(s=s[g=_<<1|f]))return this;if(!s.length)break;(e[g+1&3]||e[g+2&3]||e[g+3&3])&&(i=e,m=g)}for(;s.data!==t;)if(n=s,!(s=s.next))return this;return(r=s.next)&&delete s.next,n?(r?n.next=r:delete n.next,this):e?(r?e[g]=r:delete e[g],(s=e[0]||e[1]||e[2]||e[3])&&s===(e[3]||e[2]||e[1]||e[0])&&!s.length&&(i?i[m]=s:this._root=s),this):(this._root=r,this)}function xN(t){for(var e=0,s=t.length;e<s;++e)this.remove(t[e]);return this}function ON(){return this._root}function EN(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function AN(t){var e=[],s,i=this._root,n,r,o,a,l;for(i&&e.push(new Xs(i,this._x0,this._y0,this._x1,this._y1));s=e.pop();)if(!t(i=s.node,r=s.x0,o=s.y0,a=s.x1,l=s.y1)&&i.length){var c=(r+a)/2,h=(o+l)/2;(n=i[3])&&e.push(new Xs(n,c,h,a,l)),(n=i[2])&&e.push(new Xs(n,r,h,c,l)),(n=i[1])&&e.push(new Xs(n,c,o,a,h)),(n=i[0])&&e.push(new Xs(n,r,o,c,h))}return this}function TN(t){var e=[],s=[],i;for(this._root&&e.push(new Xs(this._root,this._x0,this._y0,this._x1,this._y1));i=e.pop();){var n=i.node;if(n.length){var r,o=i.x0,a=i.y0,l=i.x1,c=i.y1,h=(o+l)/2,d=(a+c)/2;(r=n[0])&&e.push(new Xs(r,o,a,h,d)),(r=n[1])&&e.push(new Xs(r,h,a,l,d)),(r=n[2])&&e.push(new Xs(r,o,d,h,c)),(r=n[3])&&e.push(new Xs(r,h,d,l,c))}s.push(i)}for(;i=s.pop();)t(i.node,i.x0,i.y0,i.x1,i.y1);return this}function DN(t){return t[0]}function IN(t){return arguments.length?(this._x=t,this):this._x}function CN(t){return t[1]}function RN(t){return arguments.length?(this._y=t,this):this._y}function Cg(t,e,s){var i=new Rg(e??DN,s??CN,NaN,NaN,NaN,NaN);return t==null?i:i.addAll(t)}function Rg(t,e,s,i,n,r){this._x=t,this._y=e,this._x0=s,this._y0=i,this._x1=n,this._y1=r,this._root=void 0}function Ub(t){for(var e={data:t.data},s=e;t=t.next;)s=s.next={data:t.data};return e}var Js=Cg.prototype=Rg.prototype;Js.copy=function(){var t=new Rg(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,s,i;if(!e)return t;if(!e.length)return t._root=Ub(e),t;for(s=[{source:e,target:t._root=new Array(4)}];e=s.pop();)for(var n=0;n<4;++n)(i=e.source[n])&&(i.length?s.push({source:i,target:e.target[n]=new Array(4)}):e.target[n]=Ub(i));return t};Js.add=bN;Js.addAll=MN;Js.cover=vN;Js.data=wN;Js.extent=yN;Js.find=zN;Js.remove=SN;Js.removeAll=xN;Js.root=ON;Js.size=EN;Js.visit=AN;Js.visitAfter=TN;Js.x=IN;Js.y=RN;function kN(t){const e=+this._x.call(null,t),s=+this._y.call(null,t),i=+this._z.call(null,t);return Bz(this.cover(e,s,i),e,s,i,t)}function Bz(t,e,s,i,n){if(isNaN(e)||isNaN(s)||isNaN(i))return t;var r,o=t._root,a={data:n},l=t._x0,c=t._y0,h=t._z0,d=t._x1,u=t._y1,p=t._z1,f,_,g,m,v,y,b,w,z,x,M;if(!o)return t._root=a,t;for(;o.length;)if((b=e>=(f=(l+d)/2))?l=f:d=f,(w=s>=(_=(c+u)/2))?c=_:u=_,(z=i>=(g=(h+p)/2))?h=g:p=g,r=o,!(o=o[x=z<<2|w<<1|b]))return r[x]=a,t;if(m=+t._x.call(null,o.data),v=+t._y.call(null,o.data),y=+t._z.call(null,o.data),e===m&&s===v&&i===y)return a.next=o,r?r[x]=a:t._root=a,t;do r=r?r[x]=new Array(8):t._root=new Array(8),(b=e>=(f=(l+d)/2))?l=f:d=f,(w=s>=(_=(c+u)/2))?c=_:u=_,(z=i>=(g=(h+p)/2))?h=g:p=g;while((x=z<<2|w<<1|b)===(M=(y>=g)<<2|(v>=_)<<1|m>=f));return r[M]=o,r[x]=a,t}function NN(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,s=new Float64Array(e),i=new Float64Array(e),n=new Float64Array(e);let r=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,h=-1/0;for(let d=0,u,p,f,_;d<e;++d)isNaN(p=+this._x.call(null,u=t[d]))||isNaN(f=+this._y.call(null,u))||isNaN(_=+this._z.call(null,u))||(s[d]=p,i[d]=f,n[d]=_,p<r&&(r=p),p>l&&(l=p),f<o&&(o=f),f>c&&(c=f),_<a&&(a=_),_>h&&(h=_));if(r>l||o>c||a>h)return this;this.cover(r,o,a).cover(l,c,h);for(let d=0;d<e;++d)Bz(this,s[d],i[d],n[d],t[d]);return this}function BN(t,e,s){if(isNaN(t=+t)||isNaN(e=+e)||isNaN(s=+s))return this;var i=this._x0,n=this._y0,r=this._z0,o=this._x1,a=this._y1,l=this._z1;if(isNaN(i))o=(i=Math.floor(t))+1,a=(n=Math.floor(e))+1,l=(r=Math.floor(s))+1;else{for(var c=o-i||1,h=this._root,d,u;i>t||t>=o||n>e||e>=a||r>s||s>=l;)switch(u=(s<r)<<2|(e<n)<<1|t<i,d=new Array(8),d[u]=h,h=d,c*=2,u){case 0:o=i+c,a=n+c,l=r+c;break;case 1:i=o-c,a=n+c,l=r+c;break;case 2:o=i+c,n=a-c,l=r+c;break;case 3:i=o-c,n=a-c,l=r+c;break;case 4:o=i+c,a=n+c,r=l-c;break;case 5:i=o-c,a=n+c,r=l-c;break;case 6:o=i+c,n=a-c,r=l-c;break;case 7:i=o-c,n=a-c,r=l-c;break}this._root&&this._root.length&&(this._root=h)}return this._x0=i,this._y0=n,this._z0=r,this._x1=o,this._y1=a,this._z1=l,this}function GN(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function PN(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function Lt(t,e,s,i,n,r,o){this.node=t,this.x0=e,this.y0=s,this.z0=i,this.x1=n,this.y1=r,this.z1=o}function LN(t,e,s,i){var n,r=this._x0,o=this._y0,a=this._z0,l,c,h,d,u,p,f=this._x1,_=this._y1,g=this._z1,m=[],v=this._root,y,b;for(v&&m.push(new Lt(v,r,o,a,f,_,g)),i==null?i=1/0:(r=t-i,o=e-i,a=s-i,f=t+i,_=e+i,g=s+i,i*=i);y=m.pop();)if(!(!(v=y.node)||(l=y.x0)>f||(c=y.y0)>_||(h=y.z0)>g||(d=y.x1)<r||(u=y.y1)<o||(p=y.z1)<a))if(v.length){var w=(l+d)/2,z=(c+u)/2,x=(h+p)/2;m.push(new Lt(v[7],w,z,x,d,u,p),new Lt(v[6],l,z,x,w,u,p),new Lt(v[5],w,c,x,d,z,p),new Lt(v[4],l,c,x,w,z,p),new Lt(v[3],w,z,h,d,u,x),new Lt(v[2],l,z,h,w,u,x),new Lt(v[1],w,c,h,d,z,x),new Lt(v[0],l,c,h,w,z,x)),(b=(s>=x)<<2|(e>=z)<<1|t>=w)&&(y=m[m.length-1],m[m.length-1]=m[m.length-1-b],m[m.length-1-b]=y)}else{var M=t-+this._x.call(null,v.data),S=e-+this._y.call(null,v.data),T=s-+this._z.call(null,v.data),A=M*M+S*S+T*T;if(A<i){var E=Math.sqrt(i=A);r=t-E,o=e-E,a=s-E,f=t+E,_=e+E,g=s+E,n=v.data}}return n}const WN=(t,e,s,i,n,r)=>Math.sqrt((t-i)**2+(e-n)**2+(s-r)**2);function FN(t,e,s,i){const n=[],r=t-i,o=e-i,a=s-i,l=t+i,c=e+i,h=s+i;return this.visit((d,u,p,f,_,g,m)=>{if(!d.length)do{const v=d.data;WN(t,e,s,this._x(v),this._y(v),this._z(v))<=i&&n.push(v)}while(d=d.next);return u>l||p>c||f>h||_<r||g<o||m<a}),n}function UN(t){if(isNaN(u=+this._x.call(null,t))||isNaN(p=+this._y.call(null,t))||isNaN(f=+this._z.call(null,t)))return this;var e,s=this._root,i,n,r,o=this._x0,a=this._y0,l=this._z0,c=this._x1,h=this._y1,d=this._z1,u,p,f,_,g,m,v,y,b,w,z;if(!s)return this;if(s.length)for(;;){if((v=u>=(_=(o+c)/2))?o=_:c=_,(y=p>=(g=(a+h)/2))?a=g:h=g,(b=f>=(m=(l+d)/2))?l=m:d=m,e=s,!(s=s[w=b<<2|y<<1|v]))return this;if(!s.length)break;(e[w+1&7]||e[w+2&7]||e[w+3&7]||e[w+4&7]||e[w+5&7]||e[w+6&7]||e[w+7&7])&&(i=e,z=w)}for(;s.data!==t;)if(n=s,!(s=s.next))return this;return(r=s.next)&&delete s.next,n?(r?n.next=r:delete n.next,this):e?(r?e[w]=r:delete e[w],(s=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&s===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!s.length&&(i?i[z]=s:this._root=s),this):(this._root=r,this)}function $N(t){for(var e=0,s=t.length;e<s;++e)this.remove(t[e]);return this}function jN(){return this._root}function HN(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function VN(t){var e=[],s,i=this._root,n,r,o,a,l,c,h;for(i&&e.push(new Lt(i,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));s=e.pop();)if(!t(i=s.node,r=s.x0,o=s.y0,a=s.z0,l=s.x1,c=s.y1,h=s.z1)&&i.length){var d=(r+l)/2,u=(o+c)/2,p=(a+h)/2;(n=i[7])&&e.push(new Lt(n,d,u,p,l,c,h)),(n=i[6])&&e.push(new Lt(n,r,u,p,d,c,h)),(n=i[5])&&e.push(new Lt(n,d,o,p,l,u,h)),(n=i[4])&&e.push(new Lt(n,r,o,p,d,u,h)),(n=i[3])&&e.push(new Lt(n,d,u,a,l,c,p)),(n=i[2])&&e.push(new Lt(n,r,u,a,d,c,p)),(n=i[1])&&e.push(new Lt(n,d,o,a,l,u,p)),(n=i[0])&&e.push(new Lt(n,r,o,a,d,u,p))}return this}function qN(t){var e=[],s=[],i;for(this._root&&e.push(new Lt(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));i=e.pop();){var n=i.node;if(n.length){var r,o=i.x0,a=i.y0,l=i.z0,c=i.x1,h=i.y1,d=i.z1,u=(o+c)/2,p=(a+h)/2,f=(l+d)/2;(r=n[0])&&e.push(new Lt(r,o,a,l,u,p,f)),(r=n[1])&&e.push(new Lt(r,u,a,l,c,p,f)),(r=n[2])&&e.push(new Lt(r,o,p,l,u,h,f)),(r=n[3])&&e.push(new Lt(r,u,p,l,c,h,f)),(r=n[4])&&e.push(new Lt(r,o,a,f,u,p,d)),(r=n[5])&&e.push(new Lt(r,u,a,f,c,p,d)),(r=n[6])&&e.push(new Lt(r,o,p,f,u,h,d)),(r=n[7])&&e.push(new Lt(r,u,p,f,c,h,d))}s.push(i)}for(;i=s.pop();)t(i.node,i.x0,i.y0,i.z0,i.x1,i.y1,i.z1);return this}function KN(t){return t[0]}function YN(t){return arguments.length?(this._x=t,this):this._x}function XN(t){return t[1]}function ZN(t){return arguments.length?(this._y=t,this):this._y}function JN(t){return t[2]}function QN(t){return arguments.length?(this._z=t,this):this._z}function kg(t,e,s,i){var n=new Ng(e??KN,s??XN,i??JN,NaN,NaN,NaN,NaN,NaN,NaN);return t==null?n:n.addAll(t)}function Ng(t,e,s,i,n,r,o,a,l){this._x=t,this._y=e,this._z=s,this._x0=i,this._y0=n,this._z0=r,this._x1=o,this._y1=a,this._z1=l,this._root=void 0}function $b(t){for(var e={data:t.data},s=e;t=t.next;)s=s.next={data:t.data};return e}var Ns=kg.prototype=Ng.prototype;Ns.copy=function(){var t=new Ng(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),e=this._root,s,i;if(!e)return t;if(!e.length)return t._root=$b(e),t;for(s=[{source:e,target:t._root=new Array(8)}];e=s.pop();)for(var n=0;n<8;++n)(i=e.source[n])&&(i.length?s.push({source:i,target:e.target[n]=new Array(8)}):e.target[n]=$b(i));return t};Ns.add=kN;Ns.addAll=NN;Ns.cover=BN;Ns.data=GN;Ns.extent=PN;Ns.find=LN;Ns.findAllWithinRadius=FN;Ns.remove=UN;Ns.removeAll=$N;Ns.root=jN;Ns.size=HN;Ns.visit=VN;Ns.visitAfter=qN;Ns.x=YN;Ns.y=ZN;Ns.z=QN;function bs(t){return function(){return t}}function Ii(t){return(t()-.5)*1e-6}function hu(t){return t.x+t.vx}function jb(t){return t.y+t.vy}function e7(t){return t.z+t.vz}function Sr(t){var e,s,i,n,r=1,o=1;typeof t!="function"&&(t=bs(t==null?1:+t));function a(){for(var h,d=e.length,u,p,f,_,g,m,v,y=0;y<o;++y)for(u=(s===1?Dg(e,hu):s===2?Cg(e,hu,jb):s===3?kg(e,hu,jb,e7):null).visitAfter(l),h=0;h<d;++h)p=e[h],m=i[p.index],v=m*m,f=p.x+p.vx,s>1&&(_=p.y+p.vy),s>2&&(g=p.z+p.vz),u.visit(b);function b(w,z,x,M,S,T,A){var E=[z,x,M,S,T,A],O=E[0],R=E[1],C=E[2],k=E[s],B=E[s+1],L=E[s+2],U=w.data,ee=w.r,X=m+ee;if(U){if(U.index>p.index){var ce=f-U.x-U.vx,Oe=s>1?_-U.y-U.vy:0,Ce=s>2?g-U.z-U.vz:0,Ne=ce*ce+Oe*Oe+Ce*Ce;Ne<X*X&&(ce===0&&(ce=Ii(n),Ne+=ce*ce),s>1&&Oe===0&&(Oe=Ii(n),Ne+=Oe*Oe),s>2&&Ce===0&&(Ce=Ii(n),Ne+=Ce*Ce),Ne=(X-(Ne=Math.sqrt(Ne)))/Ne*r,p.vx+=(ce*=Ne)*(X=(ee*=ee)/(v+ee)),s>1&&(p.vy+=(Oe*=Ne)*X),s>2&&(p.vz+=(Ce*=Ne)*X),U.vx-=ce*(X=1-X),s>1&&(U.vy-=Oe*X),s>2&&(U.vz-=Ce*X))}return}return O>f+X||k<f-X||s>1&&(R>_+X||B<_-X)||s>2&&(C>g+X||L<g-X)}}function l(h){if(h.data)return h.r=i[h.data.index];for(var d=h.r=0;d<Math.pow(2,s);++d)h[d]&&h[d].r>h.r&&(h.r=h[d].r)}function c(){if(e){var h,d=e.length,u;for(i=new Array(d),h=0;h<d;++h)u=e[h],i[u.index]=+t(u,h,e)}}return a.initialize=function(h,...d){e=h,n=d.find(u=>typeof u=="function")||Math.random,s=d.find(u=>[1,2,3].includes(u))||2,c()},a.iterations=function(h){return arguments.length?(o=+h,a):o},a.strength=function(h){return arguments.length?(r=+h,a):r},a.radius=function(h){return arguments.length?(t=typeof h=="function"?h:bs(+h),c(),a):t},a}function t7(t){return t.index}function Hb(t,e){var s=t.get(e);if(!s)throw new Error("node not found: "+e);return s}function po(t){var e=t7,s=u,i,n=bs(30),r,o,a,l,c,h,d=1;t==null&&(t=[]);function u(m){return 1/Math.min(l[m.source.index],l[m.target.index])}function p(m){for(var v=0,y=t.length;v<d;++v)for(var b=0,w,z,x,M=0,S=0,T=0,A,E;b<y;++b)w=t[b],z=w.source,x=w.target,M=x.x+x.vx-z.x-z.vx||Ii(h),a>1&&(S=x.y+x.vy-z.y-z.vy||Ii(h)),a>2&&(T=x.z+x.vz-z.z-z.vz||Ii(h)),A=Math.sqrt(M*M+S*S+T*T),A=(A-r[b])/A*m*i[b],M*=A,S*=A,T*=A,x.vx-=M*(E=c[b]),a>1&&(x.vy-=S*E),a>2&&(x.vz-=T*E),z.vx+=M*(E=1-E),a>1&&(z.vy+=S*E),a>2&&(z.vz+=T*E)}function f(){if(o){var m,v=o.length,y=t.length,b=new Map(o.map((z,x)=>[e(z,x,o),z])),w;for(m=0,l=new Array(v);m<y;++m)w=t[m],w.index=m,typeof w.source!="object"&&(w.source=Hb(b,w.source)),typeof w.target!="object"&&(w.target=Hb(b,w.target)),l[w.source.index]=(l[w.source.index]||0)+1,l[w.target.index]=(l[w.target.index]||0)+1;for(m=0,c=new Array(y);m<y;++m)w=t[m],c[m]=l[w.source.index]/(l[w.source.index]+l[w.target.index]);i=new Array(y),_(),r=new Array(y),g()}}function _(){if(o)for(var m=0,v=t.length;m<v;++m)i[m]=+s(t[m],m,t)}function g(){if(o)for(var m=0,v=t.length;m<v;++m)r[m]=+n(t[m],m,t)}return p.initialize=function(m,...v){o=m,h=v.find(y=>typeof y=="function")||Math.random,a=v.find(y=>[1,2,3].includes(y))||2,f()},p.links=function(m){return arguments.length?(t=m,f(),p):t},p.id=function(m){return arguments.length?(e=m,p):e},p.iterations=function(m){return arguments.length?(d=+m,p):d},p.strength=function(m){return arguments.length?(s=typeof m=="function"?m:bs(+m),_(),p):s},p.distance=function(m){return arguments.length?(n=typeof m=="function"?m:bs(+m),g(),p):n},p}var s7={value:()=>{}};function Gz(){for(var t=0,e=arguments.length,s={},i;t<e;++t){if(!(i=arguments[t]+"")||i in s||/[\s.]/.test(i))throw new Error("illegal type: "+i);s[i]=[]}return new gh(s)}function gh(t){this._=t}function i7(t,e){return t.trim().split(/^|\s+/).map(function(s){var i="",n=s.indexOf(".");if(n>=0&&(i=s.slice(n+1),s=s.slice(0,n)),s&&!e.hasOwnProperty(s))throw new Error("unknown type: "+s);return{type:s,name:i}})}gh.prototype=Gz.prototype={constructor:gh,on:function(t,e){var s=this._,i=i7(t+"",s),n,r=-1,o=i.length;if(arguments.length<2){for(;++r<o;)if((n=(t=i[r]).type)&&(n=n7(s[n],t.name)))return n;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++r<o;)if(n=(t=i[r]).type)s[n]=Vb(s[n],t.name,e);else if(e==null)for(n in s)s[n]=Vb(s[n],t.name,null);return this},copy:function(){var t={},e=this._;for(var s in e)t[s]=e[s].slice();return new gh(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var s=new Array(n),i=0,n,r;i<n;++i)s[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(r=this._[t],i=0,n=r.length;i<n;++i)r[i].value.apply(e,s)},apply:function(t,e,s){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var i=this._[t],n=0,r=i.length;n<r;++n)i[n].value.apply(e,s)}};function n7(t,e){for(var s=0,i=t.length,n;s<i;++s)if((n=t[s]).name===e)return n.value}function Vb(t,e,s){for(var i=0,n=t.length;i<n;++i)if(t[i].name===e){t[i]=s7,t=t.slice(0,i).concat(t.slice(i+1));break}return s!=null&&t.push({name:e,value:s}),t}var fa=0,fl=0,Wa=0,Pz=1e3,Kh,pl,Yh=0,mo=0,Ad=0,Wl=typeof performance=="object"&&performance.now?performance:Date,Lz=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Wz(){return mo||(Lz(r7),mo=Wl.now()+Ad)}function r7(){mo=0}function cp(){this._call=this._time=this._next=null}cp.prototype=Fz.prototype={constructor:cp,restart:function(t,e,s){if(typeof t!="function")throw new TypeError("callback is not a function");s=(s==null?Wz():+s)+(e==null?0:+e),!this._next&&pl!==this&&(pl?pl._next=this:Kh=this,pl=this),this._call=t,this._time=s,hp()},stop:function(){this._call&&(this._call=null,this._time=1/0,hp())}};function Fz(t,e,s){var i=new cp;return i.restart(t,e,s),i}function o7(){Wz(),++fa;for(var t=Kh,e;t;)(e=mo-t._time)>=0&&t._call.call(void 0,e),t=t._next;--fa}function qb(){mo=(Yh=Wl.now())+Ad,fa=fl=0;try{o7()}finally{fa=0,l7(),mo=0}}function a7(){var t=Wl.now(),e=t-Yh;e>Pz&&(Ad-=e,Yh=t)}function l7(){for(var t,e=Kh,s,i=1/0;e;)e._call?(i>e._time&&(i=e._time),t=e,e=e._next):(s=e._next,e._next=null,e=t?t._next=s:Kh=s);pl=t,hp(i)}function hp(t){if(!fa){fl&&(fl=clearTimeout(fl));var e=t-mo;e>24?(t<1/0&&(fl=setTimeout(qb,t-Wl.now()-Ad)),Wa&&(Wa=clearInterval(Wa))):(Wa||(Yh=Wl.now(),Wa=setInterval(a7,Pz)),fa=1,Lz(qb))}}const c7=1664525,h7=1013904223,Kb=4294967296;function d7(){let t=1;return()=>(t=(c7*t+h7)%Kb)/Kb}var Yb=3;function du(t){return t.x}function Xb(t){return t.y}function u7(t){return t.z}var f7=10,p7=Math.PI*(3-Math.sqrt(5)),m7=Math.PI*20/(9+Math.sqrt(221));function xr(t,e){e=e||2;var s=Math.min(Yb,Math.max(1,Math.round(e))),i,n=1,r=.001,o=1-Math.pow(r,1/300),a=0,l=.6,c=new Map,h=Fz(p),d=Gz("tick","end"),u=d7();t==null&&(t=[]);function p(){f(),d.call("tick",i),n<r&&(h.stop(),d.call("end",i))}function f(m){var v,y=t.length,b;m===void 0&&(m=1);for(var w=0;w<m;++w)for(n+=(a-n)*o,c.forEach(function(z){z(n)}),v=0;v<y;++v)b=t[v],b.fx==null?b.x+=b.vx*=l:(b.x=b.fx,b.vx=0),s>1&&(b.fy==null?b.y+=b.vy*=l:(b.y=b.fy,b.vy=0)),s>2&&(b.fz==null?b.z+=b.vz*=l:(b.z=b.fz,b.vz=0));return i}function _(){for(var m=0,v=t.length,y;m<v;++m){if(y=t[m],y.index=m,y.fx!=null&&(y.x=y.fx),y.fy!=null&&(y.y=y.fy),y.fz!=null&&(y.z=y.fz),isNaN(y.x)||s>1&&isNaN(y.y)||s>2&&isNaN(y.z)){var b=f7*(s>2?Math.cbrt(.5+m):s>1?Math.sqrt(.5+m):m),w=m*p7,z=m*m7;s===1?y.x=b:s===2?(y.x=b*Math.cos(w),y.y=b*Math.sin(w)):(y.x=b*Math.sin(w)*Math.cos(z),y.y=b*Math.cos(w),y.z=b*Math.sin(w)*Math.sin(z))}(isNaN(y.vx)||s>1&&isNaN(y.vy)||s>2&&isNaN(y.vz))&&(y.vx=0,s>1&&(y.vy=0),s>2&&(y.vz=0))}}function g(m){return m.initialize&&m.initialize(t,u,s),m}return _(),i={tick:f,restart:function(){return h.restart(p),i},stop:function(){return h.stop(),i},numDimensions:function(m){return arguments.length?(s=Math.min(Yb,Math.max(1,Math.round(m))),c.forEach(g),i):s},nodes:function(m){return arguments.length?(t=m,_(),c.forEach(g),i):t},alpha:function(m){return arguments.length?(n=+m,i):n},alphaMin:function(m){return arguments.length?(r=+m,i):r},alphaDecay:function(m){return arguments.length?(o=+m,i):+o},alphaTarget:function(m){return arguments.length?(a=+m,i):a},velocityDecay:function(m){return arguments.length?(l=1-m,i):1-l},randomSource:function(m){return arguments.length?(u=m,c.forEach(g),i):u},force:function(m,v){return arguments.length>1?(v==null?c.delete(m):c.set(m,g(v)),i):c.get(m)},find:function(){var m=Array.prototype.slice.call(arguments),v=m.shift()||0,y=(s>1?m.shift():null)||0,b=(s>2?m.shift():null)||0,w=m.shift()||1/0,z=0,x=t.length,M,S,T,A,E,O;for(w*=w,z=0;z<x;++z)E=t[z],M=v-E.x,S=y-(E.y||0),T=b-(E.z||0),A=M*M+S*S+T*T,A<w&&(O=E,w=A);return O},on:function(m,v){return arguments.length>1?(d.on(m,v),i):d.on(m)}}}function Or(){var t,e,s,i,n,r=bs(-30),o,a=1,l=1/0,c=.81;function h(f){var _,g=t.length,m=(e===1?Dg(t,du):e===2?Cg(t,du,Xb):e===3?kg(t,du,Xb,u7):null).visitAfter(u);for(n=f,_=0;_<g;++_)s=t[_],m.visit(p)}function d(){if(t){var f,_=t.length,g;for(o=new Array(_),f=0;f<_;++f)g=t[f],o[g.index]=+r(g,f,t)}}function u(f){var _=0,g,m,v=0,y,b,w,z,x=f.length;if(x){for(y=b=w=z=0;z<x;++z)(g=f[z])&&(m=Math.abs(g.value))&&(_+=g.value,v+=m,y+=m*(g.x||0),b+=m*(g.y||0),w+=m*(g.z||0));_*=Math.sqrt(4/x),f.x=y/v,e>1&&(f.y=b/v),e>2&&(f.z=w/v)}else{g=f,g.x=g.data.x,e>1&&(g.y=g.data.y),e>2&&(g.z=g.data.z);do _+=o[g.data.index];while(g=g.next)}f.value=_}function p(f,_,g,m,v){if(!f.value)return!0;var y=[g,m,v][e-1],b=f.x-s.x,w=e>1?f.y-s.y:0,z=e>2?f.z-s.z:0,x=y-_,M=b*b+w*w+z*z;if(x*x/c<M)return M<l&&(b===0&&(b=Ii(i),M+=b*b),e>1&&w===0&&(w=Ii(i),M+=w*w),e>2&&z===0&&(z=Ii(i),M+=z*z),M<a&&(M=Math.sqrt(a*M)),s.vx+=b*f.value*n/M,e>1&&(s.vy+=w*f.value*n/M),e>2&&(s.vz+=z*f.value*n/M)),!0;if(f.length||M>=l)return;(f.data!==s||f.next)&&(b===0&&(b=Ii(i),M+=b*b),e>1&&w===0&&(w=Ii(i),M+=w*w),e>2&&z===0&&(z=Ii(i),M+=z*z),M<a&&(M=Math.sqrt(a*M)));do f.data!==s&&(x=o[f.data.index]*n/M,s.vx+=b*x,e>1&&(s.vy+=w*x),e>2&&(s.vz+=z*x));while(f=f.next)}return h.initialize=function(f,..._){t=f,i=_.find(g=>typeof g=="function")||Math.random,e=_.find(g=>[1,2,3].includes(g))||2,d()},h.strength=function(f){return arguments.length?(r=typeof f=="function"?f:bs(+f),d(),h):r},h.distanceMin=function(f){return arguments.length?(a=f*f,h):Math.sqrt(a)},h.distanceMax=function(f){return arguments.length?(l=f*f,h):Math.sqrt(l)},h.theta=function(f){return arguments.length?(c=f*f,h):Math.sqrt(c)},h}function Bg(t){var e=bs(.1),s,i,n;typeof t!="function"&&(t=bs(t==null?0:+t));function r(a){for(var l=0,c=s.length,h;l<c;++l)h=s[l],h.vx+=(n[l]-h.x)*i[l]*a}function o(){if(s){var a,l=s.length;for(i=new Array(l),n=new Array(l),a=0;a<l;++a)i[a]=isNaN(n[a]=+t(s[a],a,s))?0:+e(s[a],a,s)}}return r.initialize=function(a){s=a,o()},r.strength=function(a){return arguments.length?(e=typeof a=="function"?a:bs(+a),o(),r):e},r.x=function(a){return arguments.length?(t=typeof a=="function"?a:bs(+a),o(),r):t},r}function Gg(t){var e=bs(.1),s,i,n;typeof t!="function"&&(t=bs(t==null?0:+t));function r(a){for(var l=0,c=s.length,h;l<c;++l)h=s[l],h.vy+=(n[l]-h.y)*i[l]*a}function o(){if(s){var a,l=s.length;for(i=new Array(l),n=new Array(l),a=0;a<l;++a)i[a]=isNaN(n[a]=+t(s[a],a,s))?0:+e(s[a],a,s)}}return r.initialize=function(a){s=a,o()},r.strength=function(a){return arguments.length?(e=typeof a=="function"?a:bs(+a),o(),r):e},r.y=function(a){return arguments.length?(t=typeof a=="function"?a:bs(+a),o(),r):t},r}function Pg(t){var e=bs(.1),s,i,n;typeof t!="function"&&(t=bs(t==null?0:+t));function r(a){for(var l=0,c=s.length,h;l<c;++l)h=s[l],h.vz+=(n[l]-h.z)*i[l]*a}function o(){if(s){var a,l=s.length;for(i=new Array(l),n=new Array(l),a=0;a<l;++a)i[a]=isNaN(n[a]=+t(s[a],a,s))?0:+e(s[a],a,s)}}return r.initialize=function(a){s=a,o()},r.strength=function(a){return arguments.length?(e=typeof a=="function"?a:bs(+a),o(),r):e},r.z=function(a){return arguments.length?(t=typeof a=="function"?a:bs(+a),o(),r):t},r}function g7(t){let e=2166136261;for(let s=0;s<t.length;s++)e^=t.charCodeAt(s),e=Math.imul(e,16777619);return e>>>0}function _7(t){let e=t>>>0;return()=>(e=Math.imul(e,1664525)+1013904223>>>0,e/4294967296)}function pa(t){return _7(g7(t))}const qi=.55,b7=12,M7=60,uu=60;function v7(t){const e=new Map(t.map((s,i)=>[s.id,i]));return t.map(s=>`${s.parents.map(n=>e.get(n)??-1).join(".")}:${s.radius.toFixed(2)}`).join("|")}function w7(t,e,s){const[i,n,r]=t,o=i*Math.cos(e)+r*Math.sin(e),a=-i*Math.sin(e)+r*Math.cos(e),l=n*Math.cos(s)-a*Math.sin(s),c=n*Math.sin(s)+a*Math.cos(s);return[o,l,c]}function y7(t,e,s){const i=f=>Math.hypot(f[0],f[1],f[2]),n=i(e),r=i(s);if(n<1e-9||r<1e-9)return t;const o=[e[0]/n,e[1]/n,e[2]/n],a=[s[0]/r,s[1]/r,s[2]/r],l=[o[1]*a[2]-o[2]*a[1],o[2]*a[0]-o[0]*a[2],o[0]*a[1]-o[1]*a[0]],c=i(l),h=o[0]*a[0]+o[1]*a[1]+o[2]*a[2];if(c<1e-9)return h>0?t:[-t[0],-t[1],-t[2]];const d=[l[0]/c,l[1]/c,l[2]/c],u=d[0]*t[0]+d[1]*t[1]+d[2]*t[2],p=[d[1]*t[2]-d[2]*t[1],d[2]*t[0]-d[0]*t[2],d[0]*t[1]-d[1]*t[0]];return[t[0]*h+p[0]*c+d[0]*u*(1-h),t[1]*h+p[1]*c+d[1]*u*(1-h),t[2]*h+p[2]*c+d[2]*u*(1-h)]}function Zb(t,e,s){if(e.length===0)return t;let i=0;for(const n of e)i+=s.get(n.id.slice(6))??qi;return i/=e.length,Math.max(t+2,Math.sqrt(e.length)*i*1.6)}function fu(t,e,s){const i=e<=1?0:1-2*(t+.5)/e,n=Math.sqrt(Math.max(0,1-i*i)),r=t*Math.PI*(3-Math.sqrt(5));return[Math.cos(r)*n*s,i*s,Math.sin(r)*n*s]}function Lg(t,e,s=()=>{},i="clumps",n=pa){const r=new Map(t.map(O=>[O.id,O])),o=new Map,a=[];for(const O of t)O.group===null?a.push(O):o.set(O.group,[...o.get(O.group)??[],O]);const l=new Map,c=new Map,h=new Map,d=new Set;let u=0;const p=Math.max(1,o.size),f=new Map;for(const[O,R]of o){const C=R.filter(X=>X.seed!==void 0),k=[0,0,0];for(const X of C)k[0]+=X.seed[0],k[1]+=X.seed[1],k[2]+=X.seed[2];C.length>0&&(k[0]/=C.length,k[1]/=C.length,k[2]/=C.length,h.set(O,k)),R.every(X=>X.frozen===!0&&X.seed!==void 0)&&d.add(O);const B=new Map,L=C.length===0?v7(R):null,U=L===null?void 0:f.get(L);if(C.length===R.length)for(const X of R)B.set(X.id,[X.seed[0]-k[0],X.seed[1]-k[1],X.seed[2]-k[2]]);else if(U!==void 0){const X=n(O),ce=X()*Math.PI*2,Oe=(X()-.5)*Math.PI;R.forEach((Ce,Ne)=>{B.set(Ce.id,w7(U[Ne]??[0,0,0],ce,Oe))})}else{const X=R.map(ae=>{const ue={id:ae.id,r:ae.radius};return ae.seed!==void 0&&(ue.x=ae.seed[0]-k[0],ue.y=ae.seed[1]-k[1],ue.z=ae.seed[2]-k[2],ae.frozen===!0&&(ue.fx=ue.x,ue.fy=ue.y,ue.fz=ue.z)),ue}),ce=new Set(R.map(ae=>ae.id)),Oe=[];for(const ae of R)for(const ue of ae.parents)ce.has(ue)&&Oe.push({source:ue,target:ae.id});const Ce=new Map(R.map(ae=>[ae.id,ae.radius])),Ne=xr(X,3).force("link",po(Oe).id(ae=>ae.id).distance(e.link?ae=>(Ce.get(ae.source.id)??qi)+(Ce.get(ae.target.id)??qi)+1.4:2.2)).force("charge",Or().strength(ae=>e.charge?-6*(ae.r/qi)**2:-6).distanceMax(b7)).force("center",oo(0,0,0)).stop();e.collide&&Ne.force("collide",Sr().radius(ae=>ae.r*1.2));for(let ae=0;ae<M7;ae++)Ne.tick();const ie=[0,0,0];for(const ae of X)ie[0]+=ae.x??0,ie[1]+=ae.y??0,ie[2]+=ae.z??0;ie[0]/=X.length,ie[1]/=X.length,ie[2]/=X.length;for(const ae of X)B.set(ae.id,[(ae.x??0)-ie[0],(ae.y??0)-ie[1],(ae.z??0)-ie[2]]);L!==null&&f.set(L,R.map(ae=>B.get(ae.id)??[0,0,0]))}let ee=qi;for(const X of R){const ce=B.get(X.id)??[0,0,0];l.set(X.id,ce),ee=Math.max(ee,Math.hypot(ce[0],ce[1],ce[2])+X.radius)}c.set(O,ee),u+=1,u%50===0&&s(.3*(u/p))}s(.3);const _=O=>{const R=r.get(O);return R!==void 0&&R.group!==null?`group:${R.group}`:O},g=[],m=new Map;let v=!1;for(const[O]of o){const R=`group:${O}`,C=c.get(O)??qi,k={id:R,r:C},B=h.get(O);B!==void 0&&(k.x=B[0],k.y=B[1],k.z=B[2],d.has(O)&&(k.fx=B[0],k.fy=B[1],k.fz=B[2],v=!0)),m.set(R,C),g.push(k)}for(const O of a){const R={id:O.id,r:O.radius};O.seed!==void 0&&(R.x=O.seed[0],R.y=O.seed[1],R.z=O.seed[2],O.frozen===!0&&(R.fx=O.seed[0],R.fy=O.seed[1],R.fz=O.seed[2],v=!0)),m.set(O.id,O.radius),g.push(R)}const y=new Set,b=[];for(const O of t)for(const R of O.parents){if(!r.has(R))continue;const C=_(R),k=_(O.id);if(C===k)continue;const B=`${C}\0${k}`;y.has(B)||(y.add(B),b.push({source:C,target:k}))}const w=new Map;for(const O of b)if(O.source.startsWith("group:")!==O.target.startsWith("group:")){const R=O.source.startsWith("group:")?O.source:O.target,C=O.source.startsWith("group:")?O.target:O.source;w.has(R)||w.set(R,C)}const z=new Map;for(const O of g){const R=w.get(O.id);R!==void 0&&z.set(R,[...z.get(R)??[],O])}const x=g.reduce((O,R)=>O+R.r*R.r,0),M=g.filter(O=>!O.id.startsWith("group:"));M.forEach((O,R)=>{if(O.x!==void 0)return;const[C,k,B]=fu(R,M.length,Math.sqrt(x)*1.2+10);O.x=C,O.y=k,O.z=B});for(const[O,R]of z){const C=g.find(B=>B.id===O),k=Math.sqrt(R.reduce((B,L)=>B+L.r*L.r,0))*1.4+2;R.forEach((B,L)=>{if(B.x!==void 0)return;const[U,ee,X]=fu(L,R.length,k);B.x=(C?.x??0)+U,B.y=(C?.y??0)+ee,B.z=(C?.z??0)+X})}const S=new Set;if(i==="spokes"){const O=C=>{const k=o.get(C)??[],B=new Set(k.map(U=>U.id)),L=k.find(U=>U.parents.some(ee=>!B.has(ee)))??k[0];return L===void 0?[0,0,0]:l.get(L.id)??[0,0,0]},R=[];for(const C of g){if(C.id.startsWith("group:")&&w.has(C.id)){S.add(C.id);continue}if(C.id.startsWith("group:"))R.push(C);else{const k=z.get(C.id)??[];let B=C.r;const L=Zb(C.r,k,c);for(const U of k){const ee=U.id.slice(6),X=O(ee);B=Math.max(B,L+Math.hypot(X[0],X[1],X[2])+2*(c.get(ee)??qi))}R.push({id:C.id,r:B,x:C.x,y:C.y,z:C.z,...C.fx!==void 0?{fx:C.fx,fy:C.fy,fz:C.fz}:{}})}}if(!R.every(C=>C.fx!==void 0)){const C=xr(R,3).force("charge",Or().strength(k=>-1.5*k.r)).force("collide",Sr().radius(k=>k.r*.9)).stop();v||C.force("center",oo(0,0,0));for(let k=0;k<uu;k++)C.tick(),k%5===0&&s(.3+.7*(k/uu))}for(const C of R){const k=g.find(B=>B.id===C.id);k!==void 0&&k!==C&&(k.x=C.x,k.y=C.y,k.z=C.z)}for(const C of g){if(C.id.startsWith("group:")||!z.has(C.id))continue;const k=z.get(C.id)??[],B=Zb(C.r,k,c);k.forEach((L,U)=>{if(L.fx!==void 0||h.has(L.id.slice(6)))return;const ee=O(L.id.slice(6)),X=fu(U,k.length,1),ce=.35+.65*(U*.6180339887%1),Oe=C.r+1.4+B*ce+Math.hypot(ee[0],ee[1],ee[2]);L.x=(C.x??0)+X[0]*Oe,L.y=(C.y??0)+X[1]*Oe,L.z=(C.z??0)+X[2]*Oe})}}if(!g.every(O=>O.fx!==void 0)&&i!=="spokes"){const O=xr(g,3).force("link",po(b).id(k=>k.id).distance(e.link?k=>(m.get(k.source.id)??qi)+(m.get(k.target.id)??qi)+1.4:2.2)).stop(),R=Or().strength(k=>e.charge?-6*(k.r/qi)**2:-6);if(e.reach!==void 0&&R.distanceMax(e.reach),O.force("charge",R),v||O.force("center",oo(0,0,0)),e.collide&&O.force("collide",Sr().radius(k=>k.r*1.05)),e.gravity){const k=B=>Math.min(1,(B.r/qi)**2*.08);O.force("gx",Bg(0).strength(k)).force("gy",Gg(0).strength(k)).force("gz",Pg(0).strength(k))}const C=uu;for(let k=0;k<C;k++)O.tick(),k%5===0&&s(.3+.7*(k/C))}const A=new Map(g.map(O=>[O.id,O]));if(i==="spokes")for(const[O,R]of o){if(R.some(Ce=>Ce.seed!==void 0))continue;const C=`group:${O}`,k=A.get(C),B=w.get(C),L=B===void 0?void 0:A.get(B);if(k===void 0||L===void 0)continue;const U=[(k.x??0)-(L.x??0),(k.y??0)-(L.y??0),(k.z??0)-(L.z??0)],ee=new Set(R.map(Ce=>Ce.id)),X=R.find(Ce=>Ce.parents.some(Ne=>!ee.has(Ne)))??R[0],ce=l.get(X.id)??[0,0,0],Oe=[-ce[0],-ce[1],-ce[2]];for(const Ce of R){const Ne=l.get(Ce.id)??[0,0,0];l.set(Ce.id,y7(Ne,Oe,U))}}const E={};for(const O of t){const R=A.get(_(O.id)),C=[R?.x??0,R?.y??0,R?.z??0],k=O.group===null?[0,0,0]:l.get(O.id)??[0,0,0];E[O.id]=[C[0]+k[0],C[1]+k[1],C[2]+k[2]]}return s(1),E}const Jb=80;function Uz(t,e,s=()=>{},i=pa){const n=t.some(u=>u.seed===void 0),r=n?Lg(t,e,u=>s(.05*u),"spokes",i):{};s(.05);const o=t.map(u=>{const p=u.seed??r[u.id],f={id:u.id,r:u.radius};return p!==void 0&&(f.x=p[0],f.y=p[1],f.z=p[2],u.frozen===!0&&u.seed!==void 0&&(f.fx=p[0],f.fy=p[1],f.fz=p[2])),f}),a=new Set(t.map(u=>u.id)),l=[];for(const u of t)for(const p of u.parents)a.has(p)&&l.push({source:p,target:u.id});const c=new Map(t.map(u=>[u.id,u.radius])),h=o.some(u=>u.fx!==void 0);if(!o.every(u=>u.fx!==void 0)){const u=xr(o,3).force("link",po(l).id(f=>f.id).distance(e.link?f=>(c.get(f.source.id)??Pt)+(c.get(f.target.id)??Pt)+1.4:2.2)).stop(),p=Or().strength(f=>e.charge?-6*(f.r/Pt)**2:-6);if(e.reach!==void 0&&p.distanceMax(e.reach),u.force("charge",p),h||u.force("center",oo(0,0,0)),e.collide&&u.force("collide",Sr().radius(f=>f.r*1.2)),e.gravity){const f=_=>(_.r/Pt)**2*.08;u.force("gx",Bg(0).strength(f)).force("gy",Gg(0).strength(f)).force("gz",Pg(0).strength(f))}n&&u.alpha(.6);for(let f=0;f<Jb;f++)u.tick(),f%2===0&&s(.05+.95*(f/Jb))}const d={};for(const u of o)d[u.id]=[u.x??0,u.y??0,u.z??0];return s(1),d}function $z(t){const e=new Map;for(const s of t)for(const i of s.parents)e.set(i,(e.get(i)??0)+1),e.set(s.id,(e.get(s.id)??0)+1);return t.map(s=>s.metric??e.get(s.id)??1)}function jz(t){const e=$z(t),s=Math.max(...e,1);return new Map(t.map((i,n)=>[i.id,Pt*(.5+(e[n]??1)/s*1.2)]))}function Hz(t,e=3,s=new Map,i=kr,n=new Set){const r=[];for(const v of t)for(const y of v.parents)r.push({source:y,target:v.id});const o=$z(t),a=Math.max(...o,1),l=o.map(v=>Pt*(.5+v/a*1.2)),c=new Map(t.map((v,y)=>[v.id,l[y]??Pt])),h=t.map(v=>{const y=s.get(v.id);return y===void 0?{id:v.id}:n.has(v.id)?{id:v.id,x:y[0],y:y[1],z:y[2],fx:y[0],fy:y[1],fz:y[2]}:{id:v.id,x:y[0],y:y[1],z:y[2]}}),d=v=>n.has(v.id)&&v.fx!==void 0;let u=h,p=r;if(n.size>0){const v=new Set(h.filter(w=>!d(w)).map(w=>w.id));p=r.filter(w=>v.has(w.source)||v.has(w.target));const y=new Set(v);for(const w of p)y.add(w.source),y.add(w.target);u=h.filter(w=>y.has(w.id));const b=new Set(u.map(w=>w.id));p=p.filter(w=>b.has(w.source)&&b.has(w.target))}const f=Or().strength(i.charge?v=>n.has(v.id)?0:-6*((c.get(v.id)??Pt)/Pt)**2:v=>n.has(v.id)?0:-6);i.reach!==void 0&&f.distanceMax(i.reach);const _=xr(u,e).force("link",po(p).id(v=>v.id).distance(i.link?v=>(c.get(v.source.id)??Pt)+(c.get(v.target.id)??Pt)+1.4:2.2)).force("charge",f).stop();if(n.size===0&&_.force("center",e===2?oo(0,0):oo(0,0,0)),i.collide&&_.force("collide",Sr().radius(v=>(c.get(v.id)??Pt)*1.2)),i.gravity){const v=y=>((c.get(y.id)??Pt)/Pt)**2*.08;_.force("gx",Bg(0).strength(v)).force("gy",Gg(0).strength(v)),e===3&&_.force("gz",Pg(0).strength(v))}const g=u.length===0?0:s.size>0?90:150;let m=0;return{total:g,moving:u.length,step:v=>{for(let y=0;y<v&&m<g;y++,m++)_.tick()},place:()=>t.map((v,y)=>{const b=h[y];return{id:v.id,position:[b?.x??0,b?.y??0,b?.z??0],radius:l[y]??Pt}})}}function z7(t,e=3,s=new Map,i=kr,n=new Set){const r=Hz(t,e,s,i,n);return r.step(r.total),r.place()}function S7(t,e,s=new Map,i=new Set){const n=jz(t.map(r=>{const o={id:r.id,parents:[...r.parentIds,...r.joinParentIds]};return r.metric!==void 0&&(o.metric=r.metric),o}));return t.map(r=>{const o=s.get(r.id);return{id:r.id,parents:[...r.parentIds,...r.joinParentIds],radius:n.get(r.id)??Pt,group:r.ghost===!0?null:e(r),...r.attrs===void 0?{}:{attrs:r.attrs},...o===void 0?{}:{seed:o},...i.has(r.id)?{frozen:!0}:{}}})}const Qb=160,e0=120,t0=5,x7=.9,s0=.3,O7=.9;function Vz(t,e){const s=new Map;for(const[i,n]of t)s.set(i,e===0||n/e>O7?0:Math.log(e/Math.max(1,n)));return s}function E7(t,e,s=()=>{}){const i=M=>typeof M.attrs?.plugin=="string"?M.attrs.plugin:null,n=M=>M.attrs?.kind==="star"&&i(M)!==null,r=t.filter(n),o=new Map(r.map(M=>[i(M),M])),a=t.filter(M=>!n(M)),l=new Map;for(const M of a){const S=i(M);M.group===null||S===null||!o.has(S)||l.set(M.group,(l.get(M.group)??new Set).add(S))}const c=new Map;for(const M of l.values())for(const S of M)c.set(S,(c.get(S)??0)+1);const h=Vz(c,l.size),d=Math.max(1e-9,...h.values()),u=new Map;for(const M of l.values()){const S=[...M].sort();for(let T=0;T<S.length;T++)for(let A=T+1;A<S.length;A++){const E=`${S[T]}\0${S[A]}`;u.set(E,(u.get(E)??0)+1)}}const p=Math.max(6,Math.sqrt(r.length)*4,Math.sqrt(a.length)*1.6),f=r.map(M=>i0(M,p,pa(`star:${M.id}`))),_=[];for(const[M,S]of u){const[T,A]=M.split("\0"),E=Math.min(c.get(T)??1,c.get(A)??1);_.push({source:o.get(T).id,target:o.get(A).id,share:S/Math.max(1,E)})}if(f.length>0&&f.some(M=>M.fx===void 0)){const M=xr(f,3).force("link",po(_).id(S=>S.id).distance(S=>p*(1.1-Number(S.share))).strength(S=>.05+.6*Number(S.share))).force("charge",Or().strength(-30).distanceMax(p*3)).force("collide",Sr().radius(S=>S.r*3)).force("center",oo(0,0,0)).stop();for(let S=0;S<Qb;S++)M.tick(),S%4===0&&s(.4*(S/Qb))}const g=new Map(f.map(M=>[M.id,[M.x??0,M.y??0,M.z??0]]));s(.4);const m=[...f.map(M=>({...M,fx:M.x??0,fy:M.y??0,fz:M.z??0})),...a.map(M=>{const S=i(M),T=S===null?void 0:o.get(S),A=T===void 0?void 0:g.get(T.id);return i0(M,2,pa(`stage:${M.id}`),A)})],v=new Set(t.map(M=>M.id)),y=new Map(t.map(M=>[M.id,M.radius])),b=[];for(const M of a){for(const O of M.parents)v.has(O)&&b.push({source:O,target:M.id,strength:1,length:(y.get(O)??Pt)+M.radius+1.4});const S=i(M),T=S===null?void 0:o.get(S),A=S===null?0:h.get(S)??0,E=M.group===null?1:Math.max(1,l.get(M.group)?.size??1);if(T!==void 0&&A>0){const O=A/d,R=(s0+(x7-s0)*O)/Math.sqrt(E);b.push({source:T.id,target:M.id,strength:R,length:T.radius+M.radius+1})}}const w=xr(m,3).force("link",po(b).id(M=>M.id).distance(M=>Number(M.length)).strength(M=>Number(M.strength))).stop();if(e.charge){const M=Or().strength(S=>-6*(S.r/Pt)**2);M.distanceMax(Math.min(e.reach??t0,t0)),w.force("charge",M)}e.collide&&w.force("collide",Sr().radius(M=>M.r*1.2));const z=m.some(M=>M.fx===void 0);for(let M=0;z&&M<e0;M++)w.tick(),M%4===0&&s(.4+.6*(M/e0));const x={};for(const M of m)x[M.id]=[M.x??0,M.y??0,M.z??0];return s(1),x}function i0(t,e,s,i=[0,0,0]){const n={id:t.id,r:t.radius},r=t.seed??[i[0]+(s()-.5)*2*e,i[1]+(s()-.5)*2*e,i[2]+(s()-.5)*2*e];return n.x=r[0],n.y=r[1],n.z=r[2],t.frozen===!0&&t.seed!==void 0&&(n.fx=r[0],n.fy=r[1],n.fz=r[2]),n}const ma=.4,A7=400,Eo=.35,T7=.01,D7=3;function n0(t,e,s){let i=0,n=0;for(const r of new Set([...t,...e])){const o=s.get(r)??0;n+=o,t.has(r)&&e.has(r)&&(i+=o)}return n===0?0:i/n}const r0=1.4,I7=Math.PI/3;function C7(t,e){const s=new Map,i=new Map(t.map(h=>[h.id,h])),n=new Map,r=[];for(const h of t){const d=h.parents.find(u=>i.has(u));d===void 0?r.push(h):n.set(d,[...n.get(d)??[],h])}const o=new Map,a=[];r.forEach((h,d)=>{const u=ao(e),p=d===0?0:h.radius*2+r0;s.set(h.id,[u[0]*p,u[1]*p,u[2]*p]),o.set(h.id,u),a.push(h)});for(let h=a.shift();h!==void 0;h=a.shift()){const d=s.get(h.id),u=o.get(h.id);for(const p of n.get(h.id)??[]){if(s.has(p.id))continue;const f=e()*I7,_=R7(u,e),g=qz([u[0]*Math.cos(f)+_[0]*Math.sin(f),u[1]*Math.cos(f)+_[1]*Math.sin(f),u[2]*Math.cos(f)+_[2]*Math.sin(f)]),m=h.radius+p.radius+r0;s.set(p.id,[d[0]+g[0]*m,d[1]+g[1]*m,d[2]+g[2]*m]),o.set(p.id,g),a.push(p)}}for(const h of t)s.has(h.id)||s.set(h.id,[0,0,0]);const l=[0,0,0];for(const h of s.values())l[0]+=h[0]/s.size,l[1]+=h[1]/s.size,l[2]+=h[2]/s.size;let c=Pt;for(const h of t){const d=s.get(h.id),u=[d[0]-l[0],d[1]-l[1],d[2]-l[2]];s.set(h.id,u),c=Math.max(c,Math.hypot(u[0],u[1],u[2])+h.radius)}return{local:s,radius:c}}function qz(t){const e=Math.max(1e-9,Math.hypot(t[0],t[1],t[2]));return[t[0]/e,t[1]/e,t[2]/e]}function R7(t,e){const s=Math.abs(t[0])<.9?[1,0,0]:[0,1,0],i=qz([t[1]*s[2]-t[2]*s[1],t[2]*s[0]-t[0]*s[2],t[0]*s[1]-t[1]*s[0]]),n=[t[1]*i[2]-t[2]*i[1],t[2]*i[0]-t[0]*i[2],t[0]*i[1]-t[1]*i[0]],r=e()*Math.PI*2;return[i[0]*Math.cos(r)+n[0]*Math.sin(r),i[1]*Math.cos(r)+n[1]*Math.sin(r),i[2]*Math.cos(r)+n[2]*Math.sin(r)]}function ao(t){const e=t()*2-1,s=t()*Math.PI*2,i=Math.sqrt(1-e*e);return[i*Math.cos(s),i*Math.sin(s),e]}class k7{size;cells=new Map;constructor(e){this.size=e}key(e){return`${Math.floor(e[0]/this.size)},${Math.floor(e[1]/this.size)},${Math.floor(e[2]/this.size)}`}add(e){const s=this.key(e.centre);this.cells.set(s,[...this.cells.get(s)??[],e])}touching(e,s){const i=[],[n,r,o]=[Math.floor(e[0]/this.size),Math.floor(e[1]/this.size),Math.floor(e[2]/this.size)];for(let a=-1;a<=1;a++)for(let l=-1;l<=1;l++)for(let c=-1;c<=1;c++)for(const h of this.cells.get(`${n+a},${r+l},${o+c}`)??[]){const d=s+h.particle.radius+ma;Math.hypot(e[0]-h.centre[0],e[1]-h.centre[1],e[2]-h.centre[2])<d&&i.push(h)}return i}}function o0(t,e,s,i){let n=[e[0]-t.centre[0],e[1]-t.centre[1],e[2]-t.centre[2]];const r=Math.hypot(n[0],n[1],n[2]);n=r<1e-9?ao(i):[n[0]/r,n[1]/r,n[2]/r];const o=s+t.particle.radius+ma;return[t.centre[0]+n[0]*o,t.centre[1]+n[1]*o,t.centre[2]+n[2]*o]}function N7(t,e,s=()=>{}){const i={},n={};if(t.length>0&&t.every(f=>f.frozen===!0&&f.seed!==void 0)){for(const f of t)i[f.id]=f.seed;return s(1),{positions:i,arrival:n}}const r=new Map;for(const f of t){if(f.group===null){i[f.id]=[0,0,0];continue}r.set(f.group,[...r.get(f.group)??[],f])}const o=[...r].map(([f,_])=>{const g=new Set;let m=Number.POSITIVE_INFINITY;for(const b of _){const w=b.attrs?.plugin;typeof w=="string"&&g.add(w);const z=b.attrs?.createdAt;typeof z=="number"&&z<m&&(m=z)}if(_.every(b=>b.frozen===!0&&b.seed!==void 0)){const b=_.map(M=>M.seed),w=[0,1,2].map(M=>b.reduce((S,T)=>S+T[M],0)/b.length),z=new Map;let x=Pt;for(const M of _){const S=M.seed,T=[S[0]-w[0],S[1]-w[1],S[2]-w[2]];z.set(M.id,T),x=Math.max(x,Math.hypot(T[0],T[1],T[2])+M.radius)}return{key:f,nodes:_,plugins:g,created:m,local:z,radius:x,held:!0,centre:w}}const{local:v,radius:y}=C7(_,pa(`turn:${f}`));return{key:f,nodes:_,plugins:g,created:m,local:v,radius:y,held:!1}});o.sort((f,_)=>f.created-_.created||(f.key<_.key?-1:f.key>_.key?1:0));const a=new Map;for(const f of o)for(const _ of f.plugins)a.set(_,(a.get(_)??0)+1);const l=Vz(a,o.length),c=Math.max(Pt,...o.map(f=>f.radius)),h=new k7(2*c+ma),d=[];let u=0;const p=(f,_,g)=>{const m={particle:f,centre:g};d.push(m),h.add(m),u=Math.max(u,Math.hypot(g[0],g[1],g[2])+f.radius);for(const v of f.nodes){const y=f.local.get(v.id)??[0,0,0];i[v.id]=f.held&&v.seed!==void 0?v.seed:[g[0]+y[0],g[1]+y[1],g[2]+y[2]],n[v.id]=_}};return o.forEach((f,_)=>{f.held&&f.centre!==void 0&&p(f,_,f.centre)}),o.forEach((f,_)=>{if(f.held)return;const g=pa(`accrete:${f.key}`);let m;if(d.length===0)m=[0,0,0];else{let v=d[d.length-1],y=-1;for(const S of d){const T=n0(f.plugins,S.particle.plugins,l);T>=y&&(v=S,y=T)}const b=u+D7*f.radius+c,w=Math.max(.5,f.radius*.5),z=ao(g);let x=[z[0]*b,z[1]*b,z[2]*b],M=null;for(let S=0;S<A7&&M===null;S++){const T=ao(g),A=[v.centre[0]-x[0],v.centre[1]-x[1],v.centre[2]-x[2]],E=Math.max(1e-9,Math.hypot(A[0],A[1],A[2])),O=[T[0]*(1-Eo)+A[0]/E*Eo,T[1]*(1-Eo)+A[1]/E*Eo,T[2]*(1-Eo)+A[2]/E*Eo],R=[x[0]+O[0]*w,x[1]+O[1]*w,x[2]+O[2]*w],C=h.touching(R,f.radius);if(C.length===0){if(Math.hypot(R[0],R[1],R[2])>b*2){const L=ao(g);x=[L[0]*b,L[1]*b,L[2]*b]}else x=R;continue}let k=C[0],B=-1;for(const L of C){const U=n0(f.plugins,L.particle.plugins,l);U>B&&(k=L,B=U)}if(g()<Math.max(T7,B)&&(M=o0(k,x,f.radius,g),h.touching(M,f.radius-1e-6).some(L=>L!==k&&Kz(M,f.radius,L))&&(M=null)),M===null){const L=o0(k,x,f.radius,g),U=[L[0]-k.centre[0],L[1]-k.centre[1],L[2]-k.centre[2]],ee=Math.max(1e-9,Math.hypot(U[0],U[1],U[2]));x=[L[0]+U[0]/ee*w,L[1]+U[1]/ee*w,L[2]+U[2]/ee*w]}}m=M??B7(v,f.radius,h,g)}p(f,_,m),_%8===0&&s(_/Math.max(1,o.length))}),s(1),{positions:i,arrival:n}}function Kz(t,e,s){return Math.hypot(t[0]-s.centre[0],t[1]-s.centre[1],t[2]-s.centre[2])<e+s.particle.radius+ma*.5}function B7(t,e,s,i){for(let o=0;o<8;o++)for(let a=0;a<24;a++){const l=ao(i),c=e+t.particle.radius+ma+o*e,h=[t.centre[0]+l[0]*c,t.centre[1]+l[1]*c,t.centre[2]+l[2]*c];if(!s.touching(h,e).some(d=>Kz(h,e,d)))return h}const n=ao(i),r=e+t.particle.radius+ma+8*e;return[t.centre[0]+n[0]*r,t.centre[1]+n[1]*r,t.centre[2]+n[2]*r]}function Yz(t){const e=new Map(t.map(f=>[f.id,f])),s=new Map,i=(f,_)=>{const g=s.get(f.id);if(g!==void 0)return g;if(_.has(f.id)||f.parentIds.length===0)return s.set(f.id,0),0;_.add(f.id);let m=0;for(const v of f.parentIds){const y=e.get(v);y&&(m=Math.max(m,i(y,_)+1))}return s.set(f.id,m),m};for(const f of t)i(f,new Set);const n=new Map,r=[],o=(f,_)=>f.id.localeCompare(_.id,void 0,{numeric:!0});for(const f of t){const _=f.parentIds.find(m=>e.has(m));if(_===void 0){r.push(f);continue}const g=n.get(_)??[];g.push(f),n.set(_,g)}r.sort(o);for(const f of n.values())f.sort(o);const a=new Map;let l=0;const c=new Set,h=f=>{c.add(f.id);const _=(n.get(f.id)??[]).filter(y=>!c.has(y.id));if(_.length===0){const y=l++;return a.set(f.id,y),[y,y]}let g=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY;for(const y of _){const[b,w]=h(y);g=Math.min(g,b),m=Math.max(m,w)}const v=(g+m)/2;return a.set(f.id,v),[g,m]};for(const f of r)h(f);for(const f of t)a.has(f.id)||h(f);const d=Math.max(...Array.from(s.values()),0)+1,u=Math.max(l-1,0);return{placements:t.map(f=>({id:f.id,x:a.get(f.id)??0,tier:s.get(f.id)??0})),width:u,tierCount:d}}const G7=2.6,P7=2;function Wg(t){const e=t.map(r=>r.metric??0),s=Math.max(...e,0),i=Yz(t),n=new Map(i.placements.map(r=>[r.id,r]));return t.map(r=>{const o=n.get(r.id),a=((o?.x??0)-i.width/2)*P7,l=((i.tierCount-1)/2-(o?.tier??0))*G7,c=r.metric??0,h=s>0?.55+c/s*1:1,d=[a,l,0];return{id:r.id,position:d,radius:Pt*h}})}const L7=.02;function W7(t){const e=new Map(t.nodes.map(a=>[a.id,a])),s=[],i=new Map;for(const a of t.edges){const l=e.get(a.from),c=e.get(a.to);l===void 0||c===void 0||l.halo||c.halo||(s.push({source:a.from,target:a.to}),i.set(a.from,[...i.get(a.from)??[],a.to]),i.set(a.to,[...i.get(a.to)??[],a.from]))}const n=new Set([t.grabbed]),r=[t.grabbed];for(;r.length>0;){const a=r.pop();for(const l of i.get(a)??[])n.has(l)||e.get(l)?.dim===!0||(n.add(l),r.push(l))}const o=s.filter(a=>n.has(a.source)&&n.has(a.target));return{ids:n,links:o}}class F7{nodes;grabbed;sim;constructor(e){const{ids:s,links:i}=W7(e),n=new Map(e.nodes.map(a=>[a.id,a.radius])),r=a=>n.get(a)??e.baseRadius,o=new Map(e.nodes.map(a=>[a.id,a.position]));this.nodes=[...s].filter(a=>o.has(a)).map(a=>{const[l,c,h]=o.get(a);return{id:a,x:l,y:c,z:h}}),this.sim=xr(this.nodes,e.dimensions).force("link",po(i).id(a=>a.id).distance(a=>r(a.source.id)+r(a.target.id)+1.4)).force("charge",Or().strength(a=>-6*(r(a.id)/e.baseRadius)**2).distanceMax(12)).force("collide",Sr().radius(a=>r(a.id)*1.2)).alpha(.25).alphaTarget(.08).stop(),this.grabbed=this.nodes.find(a=>a.id===e.grabbed),this.grabbed!==void 0&&(this.grabbed.fx=this.grabbed.x,this.grabbed.fy=this.grabbed.y,this.grabbed.fz=this.grabbed.z)}pin(e){this.grabbed!==void 0&&([this.grabbed.fx,this.grabbed.fy,this.grabbed.fz]=e)}release(){this.grabbed!==void 0&&(this.grabbed.fx=null,this.grabbed.fy=null,this.grabbed.fz=null),this.sim.alphaTarget(0)}step(e){return!e&&this.sim.alpha()<=L7?!1:(this.sim.tick(),!0)}positions(){return this.nodes.map(e=>({id:e.id,position:[e.x,e.y,e.z]}))}}function Td(t){const e={id:t.id,parents:t.parents,radius:t.radius,group:t.group};return t.seed!==void 0&&(e.seed=t.seed),t.frozen!==void 0&&(e.frozen=t.frozen),e}function Xz(t){const e=t.attrs?.metric;return typeof e=="number"?e:void 0}function Zz(t){const e={};for(const s of t)e[s.id]=s.position;return e}const U7={id:"galaxy",label:"GALAXY",needs:[],run:(t,e)=>({positions:Uz(t.nodes.map(Td),t.physics,e)})},$7={id:"spokes",label:"SPOKES",needs:[],run:(t,e)=>({positions:Lg(t.nodes.map(Td),t.physics,e,"spokes")})},j7={id:"clumps",label:"CLUMPS",needs:[],run:(t,e)=>({positions:Lg(t.nodes.map(Td),t.physics,e,"clumps")})},H7={id:"ranked",label:"RANKED",needs:[],run:(t,e)=>{const s=t.nodes.map(n=>{const r={id:n.id,parentIds:n.parents},o=Xz(n);return o!==void 0&&(r.metric=o),r}),i=Zz(Wg(s));return e(1),{positions:i}}},V7={id:"molecule",label:"MOLECULE",needs:[],run:(t,e)=>{const s=t.nodes.map(o=>{const a={id:o.id,parents:o.parents},l=Xz(o);return l!==void 0&&(a.metric=l),a}),i=new Map,n=new Set;for(const o of t.nodes)o.seed!==void 0&&i.set(o.id,o.seed),o.frozen===!0&&n.add(o.id);const r=Zz(z7(s,3,i,t.physics,n));return e(1),{positions:r}}},q7={id:"constellations",label:"CONSTELLATIONS",needs:["plugin"],run:(t,e)=>({positions:E7(t.nodes,t.physics,e)})},K7={id:"hubs",label:"HUBS",needs:[],run:(t,e)=>({positions:Uz(t.nodes.map(Td),t.physics,e)})},Y7={id:"accretion",label:"ACCRETION",needs:["plugin"],run:(t,e)=>N7(t.nodes,t.physics,e)},X7=[U7,$7,j7,q7,K7,Y7,H7,V7];function Z7(t){return X7.find(e=>e.id===t)}function J7(t,e){const s=[];let i="",n=[],r=!1,o=0,a=!1;const l=()=>{n.push(i),i="",a=!0},c=()=>{s.push(n),n=[],a=!1};for(;o<t.length;){const h=t[o];if(r){if(h==='"'){if(t[o+1]==='"'){i+='"',o+=2;continue}r=!1,o+=1;continue}i+=h,o+=1;continue}if(h==='"'&&i===""){r=!0,o+=1;continue}if(h===e){l(),o+=1;continue}if(h==="\r"&&t[o+1]===`
|
|
89
89
|
`){l(),c(),o+=2;continue}if(h===`
|
|
90
|
-
`||h==="\r"){l(),c(),o+=1;continue}i+=h,o+=1}return(i!==""||a||n.length>0)&&(l(),c()),s}function Q7(t){if(t.length===0)return!1;const e=new Set;for(const s of t){const i=s.trim();if(i===""||e.has(i.toLowerCase())||i!==""&&Number.isFinite(Number(i)))return!1;e.add(i.toLowerCase())}return!0}function eB(t,e){const s=/\.tsv$/i.test(e)?" ":",",i=J7(t,s);if(i.length===0)return{caps:[],rows:[],headed:!1};const n=i[0],r=Q7(n),o=r?i.slice(1):i,a=i.reduce((h,d)=>Math.max(h,d.length),0),l=r?Array.from({length:a},(h,d)=>(n[d]??`COLUMN ${d+1}`).trim()):Array.from({length:a},(h,d)=>`COLUMN ${d+1}`),c=o.map(h=>Array.from({length:a},(d,u)=>h[u]??""));return{caps:l,rows:c,headed:r}}const a0=/\.json$/i,tB=4*1024*1024,pu=/("(?:\\.|[^"\\])*")(\s*:)?|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|\b(true|false|null)\b/g;function l0(t){if(t.length>tB)return null;let e;try{e=JSON.parse(t)}catch{return null}const s=JSON.stringify(e,null,2),i=document.createDocumentFragment();let n=0;pu.lastIndex=0;for(let r=pu.exec(s);r!==null;r=pu.exec(s)){r.index>n&&i.append(s.slice(n,r.index));const o=document.createElement("span"),[a,l,c,h,d]=r;l!==void 0?(o.className=c!==void 0?"json-key":"json-string",o.textContent=l,i.append(o),c!==void 0&&i.append(c)):h!==void 0?(o.className="json-number",o.textContent=h,i.append(o)):(o.className="json-literal",o.textContent=d??a,i.append(o)),n=r.index+a.length}return n<s.length&&i.append(s.slice(n)),i}const sB=/\.(?:md|markdown|adoc|asciidoc|asc)$/i,iB=2*1024*1024,c0="doc-";function Jz(t){return sB.test(t)}function nB(t){const e=new Map;for(const s of Array.from(t.querySelectorAll("h1, h2, h3, h4, h5, h6"))){if(s.id!=="")continue;const i=(s.textContent??"").trim().toLowerCase().replace(/[^\p{L}\p{N}\s_-]/gu,"").replace(/\s/g,"-"),n=e.get(i)??0;e.set(i,n+1),s.id=n===0?i:`${i}-${n}`}}function rB(t){for(const e of Array.from(t.querySelectorAll("[id]")))e.id=`${c0}${e.id}`;for(const e of Array.from(t.querySelectorAll("a[href]"))){const s=e.getAttribute("href")??"";s.startsWith("#")?e.setAttribute("href",`#${c0}${s.slice(1)}`):/^(?:https?:|mailto:)/i.test(s)?(e.target="_blank",e.rel="noopener noreferrer"):(e.removeAttribute("href"),e.classList.add("doc-link-local"),e.title=s)}for(const e of Array.from(t.querySelectorAll("img"))){const s=document.createElement("span");s.className="doc-image",s.textContent=`[image: ${e.alt!==""?e.alt:e.getAttribute("src")??""}]`,e.replaceWith(s)}t.addEventListener("click",e=>{const s=e.target?.closest('a[href^="#"]')??null;if(s===null)return;e.preventDefault(),t.querySelector(`[id="${CSS.escape((s.getAttribute("href")??"").slice(1))}"]`)?.scrollIntoView({block:"start",behavior:"smooth"})})}async function Qz(t,e){if(e.length>iB)return null;const{documentHtml_build:s}=await Ll(async()=>{const{documentHtml_build:r}=await import("./documentEngines-
|
|
90
|
+
`||h==="\r"){l(),c(),o+=1;continue}i+=h,o+=1}return(i!==""||a||n.length>0)&&(l(),c()),s}function Q7(t){if(t.length===0)return!1;const e=new Set;for(const s of t){const i=s.trim();if(i===""||e.has(i.toLowerCase())||i!==""&&Number.isFinite(Number(i)))return!1;e.add(i.toLowerCase())}return!0}function eB(t,e){const s=/\.tsv$/i.test(e)?" ":",",i=J7(t,s);if(i.length===0)return{caps:[],rows:[],headed:!1};const n=i[0],r=Q7(n),o=r?i.slice(1):i,a=i.reduce((h,d)=>Math.max(h,d.length),0),l=r?Array.from({length:a},(h,d)=>(n[d]??`COLUMN ${d+1}`).trim()):Array.from({length:a},(h,d)=>`COLUMN ${d+1}`),c=o.map(h=>Array.from({length:a},(d,u)=>h[u]??""));return{caps:l,rows:c,headed:r}}const a0=/\.json$/i,tB=4*1024*1024,pu=/("(?:\\.|[^"\\])*")(\s*:)?|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|\b(true|false|null)\b/g;function l0(t){if(t.length>tB)return null;let e;try{e=JSON.parse(t)}catch{return null}const s=JSON.stringify(e,null,2),i=document.createDocumentFragment();let n=0;pu.lastIndex=0;for(let r=pu.exec(s);r!==null;r=pu.exec(s)){r.index>n&&i.append(s.slice(n,r.index));const o=document.createElement("span"),[a,l,c,h,d]=r;l!==void 0?(o.className=c!==void 0?"json-key":"json-string",o.textContent=l,i.append(o),c!==void 0&&i.append(c)):h!==void 0?(o.className="json-number",o.textContent=h,i.append(o)):(o.className="json-literal",o.textContent=d??a,i.append(o)),n=r.index+a.length}return n<s.length&&i.append(s.slice(n)),i}const sB=/\.(?:md|markdown|adoc|asciidoc|asc)$/i,iB=2*1024*1024,c0="doc-";function Jz(t){return sB.test(t)}function nB(t){const e=new Map;for(const s of Array.from(t.querySelectorAll("h1, h2, h3, h4, h5, h6"))){if(s.id!=="")continue;const i=(s.textContent??"").trim().toLowerCase().replace(/[^\p{L}\p{N}\s_-]/gu,"").replace(/\s/g,"-"),n=e.get(i)??0;e.set(i,n+1),s.id=n===0?i:`${i}-${n}`}}function rB(t){for(const e of Array.from(t.querySelectorAll("[id]")))e.id=`${c0}${e.id}`;for(const e of Array.from(t.querySelectorAll("a[href]"))){const s=e.getAttribute("href")??"";s.startsWith("#")?e.setAttribute("href",`#${c0}${s.slice(1)}`):/^(?:https?:|mailto:)/i.test(s)?(e.target="_blank",e.rel="noopener noreferrer"):(e.removeAttribute("href"),e.classList.add("doc-link-local"),e.title=s)}for(const e of Array.from(t.querySelectorAll("img"))){const s=document.createElement("span");s.className="doc-image",s.textContent=`[image: ${e.alt!==""?e.alt:e.getAttribute("src")??""}]`,e.replaceWith(s)}t.addEventListener("click",e=>{const s=e.target?.closest('a[href^="#"]')??null;if(s===null)return;e.preventDefault(),t.querySelector(`[id="${CSS.escape((s.getAttribute("href")??"").slice(1))}"]`)?.scrollIntoView({block:"start",behavior:"smooth"})})}async function Qz(t,e){if(e.length>iB)return null;const{documentHtml_build:s}=await Ll(async()=>{const{documentHtml_build:r}=await import("./documentEngines-CCoYPxPZ.js");return{documentHtml_build:r}},[],import.meta.url),i=/\.(?:md|markdown)$/i.test(t)?"markdown":"asciidoc",n=document.createElement("article");return n.className=`doc-rendered doc-${i}`,n.innerHTML=await s(e,i),i==="markdown"&&nB(n),rB(n),n}function oB(t){return t.model?.kind==="fs.listing"&&Array.isArray(t.model.data)&&t.model.data.length>0}function eS(t){const e=(t.renderedErr??t.rendered??"").replace(/\x1b\[[0-9;]*m/g,"").split(`
|
|
91
91
|
`).map(i=>i.trim()).filter(i=>i.length>0).join(" · "),s=[...t.errors??[]].reverse().find(i=>i.type==="error")?.message?.replace(/^\[[^\]]*\]\s*\|\s*/,"")??"";return e||s||"refused"}function h0(t){return/-v(\d+(?:\.\d+)*)$/.exec(t)?.[1]??""}const d0="",aB="/bin",u0="/bin/recent",uc={dir:"",file:"",link:"",plugin:"",pipeline:"",vfs:"",job:""},mu=["list","cards","preview"],lB=5e3,cB=new Set(["png","jpg","jpeg","gif","svg","webp","bmp"]),hB=new Set(["txt","md","adoc","rst","json","csv","tsv","log","yaml","yml","toml","ini","cfg","xml","html","py","sh","ts","js","mjs","r","c","h","cpp","java","go","rs","sql","tex","bib"]),f0=160,p0=100,fc=10,dB=30,uB=256*1024,fB=4e3,pB=12*1024*1024,mB=400;function Dd(t){return cB.has(tS(t))}function tS(t){const e=t.split("/").pop()??"",s=e.lastIndexOf(".");return s>0?e.slice(s+1).toLowerCase():""}function gB(t){if(t.includes("\0"))return!0;const e=(t.match(/\uFFFD/g)??[]).length;return e>0&&e/t.length>.02}const _B=80;function m0(t,e){if(t===null)return[];const s=document.createElement("button");return s.className="files-close-pill files-download-pill",s.textContent="DOWNLOAD",s.title="save this file to your disk",s.addEventListener("click",()=>t.download(e)),[s]}function g0(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("viewBox",`0 0 ${f0} ${p0}`),s.setAttribute("preserveAspectRatio","xMidYMid meet");const i=Yz(t),n=Math.max(i.width,1),r=Math.max(i.tierCount-1,1),o=new Map;for(const a of i.placements)o.set(a.id,{x:fc+a.x/n*(f0-2*fc),y:fc+a.tier/r*(p0-2*fc)});for(const a of t){const l=o.get(a.id);if(l)for(const c of a.parentIds){const h=o.get(c);if(!h)continue;const d=document.createElementNS(e,"line");d.setAttribute("x1",String(h.x)),d.setAttribute("y1",String(h.y)),d.setAttribute("x2",String(l.x)),d.setAttribute("y2",String(l.y)),d.setAttribute("stroke","currentColor"),d.setAttribute("stroke-width","1"),d.setAttribute("opacity","0.6"),s.appendChild(d)}}for(const[,a]of o){const l=document.createElementNS(e,"circle");l.setAttribute("cx",String(a.x)),l.setAttribute("cy",String(a.y)),l.setAttribute("r",t.length>dB?"2.2":"4"),l.setAttribute("fill","currentColor"),s.appendChild(l)}return s}function pc(t){return t.type==="dir"||t.type==="vfs"||t.type==="link"||t.type==="job"?"dir":t.type==="file"?"file":t.type==="plugin"||t.type==="pipeline"?t.type:null}class sS{container;recent=null;activate;listing;lastListings=[];contentShown=!1;denied=new Set;following=!1;viewMode="list";viewPill;modeSpan;preview;catalogue;runStrip=null;feedOpen=null;headCache=new Map;thumbObserver=null;frameTopObserver=null;stale=!1;home=null;ceiling=null;stateSpan;indicate=null;selectionVerbs=null;constructor(e,s,i=null,n={}){this.container=e,this.activate=s,this.preview=i,this.catalogue=n.catalogue===!0,this.catalogue&&e.parentElement?.classList.add("files-catalogue");const r=e.closest(".pane-files")??e.parentElement;this.viewPill=e.parentElement?.querySelector(".files-view")??null,this.modeSpan=e.closest(".pane-files")?.querySelector(".pane-mode")??null,this.stateSpan=r?.querySelector(".pane-state")??null,this.viewPill?.addEventListener("click",()=>{this.view_set(mu[(mu.indexOf(this.viewMode)+1)%mu.length]??"list")});const o=e.parentElement?.querySelector(":scope > .mode-frame")!==null;this.listing=new Vn({mount:e,traits:this.traits_declare(),key:a=>a.home===!0?"~":a.path,address:a=>a.path,chrome:r===null?void 0:{root:r,prefix:"files"},control:"control",activate:a=>this.row_activate(a),activatable:a=>a.updir||pc(a.entry)!==null,indicated:a=>this.indicate?.(a.entry,a.path),row:{className:a=>`files-row files-type-${a.entry.type}${a.home===!0?" files-lead-home":a.updir?" files-lead-up":""}${!a.updir&&this.denied.has(a.path)?" files-denied":""}`,decorate:(a,l)=>{a.dataset.path=l.path,!l.updir&&this.denied.has(l.path)&&(a.title="listed but not readable — CUBE refused this identity access to the contents")}},...o?{selection:{verbs:a=>this.selectionVerbs?.(a.map(([l,c])=>[l,c.entry]))??[]}}:{},state:a=>this.stateLine_compose(a),defaultSort:{key:"name",dir:"asc"}}),this.empty_render()}traits_declare(){return this.catalogue?this.catalogueTraits_declare():this.browserTraits_declare()}browserTraits_declare(){return[{key:"control",label:"",className:"files-control",capped:!1,width:"2.4em",cell:e=>{const s=document.createElement("span"),i=e.updir?"dir":e.entry.type,n=e.updir||pc(e.entry)!==null;return s.className=`files-control files-glyph files-glyph-${i}${n?" files-capsule":""}`,s.textContent=e.home===!0?d0:!e.updir&&this.denied.has(e.path)?"⃠":uc[i],s}},{key:"name",label:"NAME",className:"files-name",width:"minmax(12em, 1fr)",cell:e=>{const s=document.createElement("span");if(s.className="files-name",s.textContent=e.home===!0?"~":e.entry.name,e.home===!0){const i=document.createElement("span");i.className="files-target",i.textContent=e.path,s.appendChild(i),s.title=`home: ${e.path}`}if(!e.updir&&e.entry.type==="link"&&e.entry.target!==void 0){const i=document.createElement("span");i.className="files-target",i.textContent=`→ ${e.entry.target}`,s.appendChild(i),s.title=e.entry.target}return s},compare:e=>e.entry.name},{key:"type",shed:2,label:"TYPE",className:"files-type",width:"6em",cell:e=>e.updir?"":e.entry.type},{key:"size",label:"SIZE",className:"files-size",width:"6em",cell:e=>e.updir||e.entry.type==="dir"?"":M0(e.entry.size),compare:e=>e.entry.size},{key:"date",shed:3,label:"DATE",className:"files-date",width:"7em",cell:e=>e.updir?"":e.entry.date.slice(0,10),compare:e=>e.entry.date},{key:"owner",shed:1,label:"OWNER",className:"files-owner",width:"10em",cell:e=>e.updir?"":e.entry.owner}]}row_activate(e){if(e.updir){this.activate({kind:"dir",path:e.path});return}const s=pc(e.entry);s!==null&&this.activate({kind:s,path:e.path})}listing_fail(e){const s=e.trim().split(`
|
|
92
|
-
`)[0]?.slice(0,120)??"";Es(this.stateSpan,"refused",`COULD NOT LIST${s===""?"":` · ${s.toUpperCase()}`}`);const i=this.lastListings.length===0?this.container.querySelector(".files-empty"):null;i!==null&&(i.textContent=`COULD NOT LIST — ${s}`)}envelope_observe(e){if(e.status==="error"&&!oB(e)){this.listing.activation_refuse(eS(e));return}if(e.model?.kind!=="fs.listing")return;const s=_0(e.model.data);if(s===null||s.length===0)return;this.lastListings=s;const i=s[0]?.path??"";this.container.closest(".workspace-pane")?.classList.toggle("files-projection",/^\/(proc|net|etc|usr)(\/|$)/.test(i)),!this.contentShown&&this.listings_render(s)}ambient_observe(e){if(e.model?.kind!=="fs.listing")return;const s=_0(e.model.data);if(s===null||this.lastListings.length===0)return;let i=!1;const n=this.lastListings.map(r=>{const o=s.find(a=>a.path===r.path);return o===void 0?r:(i=!0,o)});if(i){if(this.contentShown){this.lastListings=n;return}this.listings_render(n)}}contentTable_show(e,s){const i=eB(s,e);if(i.caps.length===0){this.content_show(e,s);return}const n=i.rows.slice(0,lB),r=i.rows.length>n.length;this.contentRelease?.(),this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren(),this.diagram_declare(!1);const o=document.createElement("section");o.className="files-content-view files-table-view";const a=document.createElement("header");a.className="files-path files-content-header";const l=document.createElement("span");l.textContent=e;const c=document.createElement("span");c.className="pane-state",a.append(l,c);const h=document.createElement("div");h.className="files-table-field";const d=document.createElement("span");d.className="field-rule";const u=document.createElement("button");u.className="mode-strip",u.title="display modes";const p=document.createElement("span");p.className="mode-elbow";const f=document.createElement("aside");f.className="mode-frame";const _=document.createElement("button");_.className="strategy-pill csv-filter rail-off",_.textContent="FILTER OFF",_.title="filter the table";const g=document.createElement("button");g.className="strategy-pill csv-raw",g.textContent="RAW",g.title="the bytes as written",g.addEventListener("click",()=>this.content_show(e,s));const m=document.createElement("button");m.className="strategy-pill csv-close",m.textContent="CLOSE",m.title="leave the table; the listing beneath returns",m.addEventListener("click",()=>this.listing_restore());const v=document.createElement("span");v.className="mode-fill",f.append(_,g,v);const y=this.preview;if(y!==null){const x=document.createElement("button");x.className="strategy-pill csv-download",x.textContent="DOWNLOAD",x.title="save this file to your disk",x.addEventListener("click",()=>y.download(e)),f.append(x)}f.append(m);const b=document.createElement("div");b.className="files-table-rows",h.append(d,u,p,f,b),o.append(a,h),this.container.appendChild(o);const w=i.caps.map((x,M)=>({key:`c${M}`,label:x.toUpperCase(),className:"files-table-cell",cell:S=>S.cells[M]??"",width:"minmax(6em, 1fr)"}));new Vn({mount:b,traits:w,key:x=>String(x.index),chrome:{root:o,prefix:"csv"},state:x=>{const M=[];return x.filter!==""?M.push(`${x.filter} ROWS`):M.push(r?`SHOWING ${n.length} OF ${i.rows.length} ROWS`:`${i.rows.length} ROWS`),i.headed||M.push("NO HEADER: COLUMNS NUMBERED"),M.join(" · ")},empty:()=>{const x=document.createElement("div");return x.className="files-note",x.textContent="NO ROWS",x}}).rows_set([{key:e,rows:n.map((x,M)=>({index:M,cells:x}))}],{field:e}),this.contentRelease=()=>{b.replaceChildren()}}content_show(e,s,i=!1,n=!1){this.diagram_declare(!1),this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren();const r=document.createElement("header");r.className="files-path files-content-header";const o=document.createElement("span");o.textContent=e;const a=document.createElement("button");a.className="files-close-pill",a.textContent="CLOSE",a.addEventListener("click",()=>this.listing_restore());const l=document.createElement("pre");l.className="files-content";const c=i||!a0.test(e)?null:l0(s),h=[];if(c!==null||i&&a0.test(e)&&l0(s)!==null){const u=document.createElement("button");u.className="files-close-pill",u.textContent=c!==null?"RAW":"PRETTY",u.addEventListener("click",()=>this.content_show(e,s,c!==null)),h.push(u)}const d=Jz(e);if(d){const u=document.createElement("button");u.className="files-close-pill files-render-pill",u.textContent=n?"SOURCE":"RENDERED",u.title=n?"the document as written":"the document as its page",u.addEventListener("click",()=>this.content_show(e,s,!1,!n)),h.push(u)}if(r.append(o,...m0(this.preview,e),...h,a),c!==null?(l.classList.add("files-json"),l.append(c)):l.textContent=s,this.container.append(r,l),ii(l),c===null){if(d&&n){Qz(e,s).then(u=>{u===null||!l.isConnected||(u.classList.add("files-content"),l.replaceWith(u),ii(u))}).catch(()=>{});return}Ll(async()=>{const{sourceSpans_build:u}=await import("./syntax-1x8StFCS.js").then(p=>p.ao);return{sourceSpans_build:u}},[],import.meta.url).then(({sourceSpans_build:u})=>u(s,yg(e))).then(u=>{if(u===null||!l.isConnected)return;const p=l.querySelector(":scope > .more-chip");l.replaceChildren(u),p!==null&&l.append(p),l.classList.add("files-source")}).catch(()=>{})}}contentRefused_show(e,s){this.diagram_declare(!1),this.denied.add(e),this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren();const i=document.createElement("header");i.className="files-path files-content-header files-content-refused";const n=document.createElement("span");n.textContent=e;const r=document.createElement("button");r.className="files-close-pill",r.textContent="CLOSE",r.addEventListener("click",()=>this.listing_restore()),i.append(n,r);const o=document.createElement("div");o.className="files-refused";const a=document.createElement("p");a.className="files-refused-lede",a.textContent="READ REFUSED";const l=document.createElement("pre");l.className="files-refused-said",l.textContent=s,o.append(a,l),this.container.append(i,o)}contentImage_show(e,s){this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren();const i=document.createElement("header");i.className="files-path files-content-header";const n=document.createElement("span");n.textContent=e;const r=document.createElement("button");r.className="files-close-pill",r.textContent="CLOSE",r.addEventListener("click",()=>this.listing_restore()),i.append(n,...m0(this.preview,e),r);const o=document.createElement("img");o.className="files-image",o.src=s,o.alt=e,this.container.append(i,o)}rowVerbs_declare(e,s){this.indicate=s??null,this.listing.actions_declare({of:i=>i.updir?[]:e(i.entry,i.path).map(n=>({label:n.label,run:()=>n.run(i.entry),...n.offered!==void 0?{offered:()=>n.offered(i.entry)}:{},...n.disabled!==void 0?{disabled:()=>n.disabled(i.entry)}:{}}))})}catalogueTraits_declare(){return[...this.browserTraits_declare().filter(i=>i.key==="control"||i.key==="name"),{key:"type",label:"TYPE",className:"files-type",width:"6em",cell:i=>i.updir?"":i.entry.type},{key:"version",label:"VERSION",className:"files-version",width:"7em",cell:i=>i.updir?"":h0(i.entry.name),compare:i=>h0(i.entry.name)}]}catalogue_is(){return this.catalogue}binding_set(e){if(this.runStrip===null){const i=document.createElement("div");i.className="files-run-strip";const n=document.createElement("span");n.className="files-binding";const r=document.createElement("input");r.className="files-command",r.spellcheck=!1,r.autocomplete="off",r.placeholder="the line RUN will run",i.append(n,r),this.container.parentElement?.insertBefore(i,this.container),this.runStrip=i;const o=this.container.closest(".pane-files")?.querySelector(".pane-title");o!=null&&(o.textContent="CATALOGUE")}const s=this.runStrip.querySelector(".files-binding");s!==null&&(s.textContent=`INPUT ${e.input} → ${e.place}`),this.frameTop_track()}commandLine_get(){return this.runStrip?.querySelector(".files-command")?.value.trim()??""}commandLine_set(e){const s=this.runStrip?.querySelector(".files-command")??null;s!==null&&(s.value=e)}indicated_get(){return this.listing.indicated_get()}feedOpen_declare(e){this.feedOpen=e}run_show(e){if(this.runStrip===null)return;this.runStrip.querySelector(".files-feed")?.remove();const s=document.createElement("button");s.className="files-feed listing-capsule listing-action-selected",s.textContent=`FEED ${e}`,s.title="open this run's graph beside the catalogue",s.addEventListener("click",()=>this.feedOpen?.(e)),this.runStrip.appendChild(s)}row_indicate(e){this.listing.row_indicate(e)}rowReadout_show(e,s){this.listing.readout_show(e,s)}selectionVerbs_declare(e){this.selectionVerbs=e}select_toggle(e){this.listing.select_toggle(e)}select_isOn(){return this.listing.select_isOn()}selection_get(){return this.listing.selection_get()}path_current(){return this.lastListings[0]?.path??null}content_isShown(){return this.contentShown}contentRelease=null;contentHtml_show(e,s,i={}){this.contentRelease?.(),this.contentRelease=i.release??null,this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren();const n=document.createElement("section");n.className="files-content-view";const r=document.createElement("header");r.className="files-path files-content-header";const o=document.createElement("span");o.textContent=e;const a=document.createElement("button");if(a.className="files-close-pill",a.textContent="CLOSE",a.addEventListener("click",()=>this.listing_restore()),r.append(o,a),n.appendChild(r),s!==""){const c=document.createElement("pre");c.className="files-content",c.innerHTML=s,n.appendChild(c)}let l=null;return i.diagram===!0&&(l=document.createElement("div"),l.className="files-diagram",n.appendChild(l)),this.diagram_declare(i.diagram===!0),this.container.appendChild(n),l}contentText_set(e){const s=this.container.querySelector(".files-content-view");if(s===null)return;const i=s.querySelector(".files-content"),n=i??document.createElement("pre");n.className="files-content",n.innerHTML=e,i===null&&s.querySelector(".files-content-header")?.after(n)}recent_set(e){this.recent=e===null?null:[...e],this.lastListings.length>0&&!this.contentShown&&this.listings_render(this.lastListings)}listing_restore(){this.contentRelease?.(),this.contentRelease=null,this.lastListings.length>0?this.listings_render(this.lastListings):this.empty_render()}empty_render(){this.diagram_declare(!1),this.container.replaceChildren();const e=document.createElement("p");e.className="files-empty",e.textContent="AWAITING LISTING — TYPE ls IN THE CONSOLE",this.container.appendChild(e)}listings_render(e){this.diagram_declare(!1),this.contentShown=!1,this.container.parentElement?.classList.remove("content-view"),this.lastListings=e,this.thumbObserver?.disconnect(),this.thumbObserver=null,this.stale=e.some(n=>n.fresh===!1),F2(this.stateSpan,"stale",this.stale),this.listing.painter_set(this.viewMode==="list"?null:(n,r)=>this.cards_paint(n,r));const s=e.map(n=>this.block_build(n)),i=e.find(n=>n.path===aB);if(this.recent!==null&&this.recent.length>0&&i!==void 0){const n=this.recentBlock_build(i);n!==null&&s.unshift(n)}this.listing.rows_set(s,{field:e[0]?.path??""}),this.frameTop_track()}crumbs_build(e){const s=document.createElement("header");s.className="files-path files-crumbs";const i=[],n=this.home;let r;n!==null&&(e===n||e.startsWith(`${n}/`))?(i.push({label:"~",path:n}),r=e.slice(n.length)):(i.push({label:"/",path:"/"}),r=e);let o=i[0]?.path??"/";for(const a of r.split("/").filter(l=>l.length>0))o=o==="/"?`/${a}`:`${o}/${a}`,i.push({label:a,path:o});return i.forEach((a,l)=>{l>0&&i[l-1]?.label!=="/"&&s.append("/");const c=l===i.length-1,h=document.createElement(c?"span":"button");h.className=c?"files-crumb files-crumb-here":"files-crumb",h.textContent=a.label,h.dataset.path=a.path,c||(h.title=`go to ${a.path}`,h.addEventListener("click",d=>{d.stopPropagation(),this.activate({kind:"dir",path:a.path})})),s.appendChild(h)}),this.catalogue||s.appendChild(ly(e)),s}link_copy(e){const s=b0(e),n=[...this.container.querySelectorAll(".files-crumbs")].filter(r=>r.querySelector(".files-crumb-here")?.dataset.path===s||r.querySelector(".files-crumb-here")?.dataset.path===e).map(r=>r.querySelector(".link-line")).filter(r=>r!==null)[0];return n===void 0?null:(og(n,e),cy(n))}ceiling_set(e,s=".."){this.ceiling=e===null?null:{path:e.replace(/\/+$/,"")||"/",word:s}}home_set(e){e!==this.home&&(this.home=e,!this.contentShown&&this.lastListings.length>0&&this.listings_render(this.lastListings))}block_build(e){const s=this.crumbs_build(e.path),i=e.items.map(r=>({entry:r,path:mc(e.path,r.name),updir:!1})),n=[];if(!this.catalogue&&this.home!==null&&e.path!==this.home&&n.push({entry:{name:"~",type:"dir",size:0,owner:"",date:""},path:this.home,updir:!0,home:!0}),e.path!=="/"){const r=this.ceiling!==null&&this.ceiling.path===e.path?this.ceiling.word:"..";n.push({entry:{name:r,type:"dir",size:0,owner:"",date:""},path:b0(e.path),updir:!0})}return{key:e.path,header:s,lead:n,rows:i}}recentBlock_build(e){const s=new Map(e.items.map(r=>[r.name,r])),i=[];for(const r of this.recent??[]){const o=s.get(r);o!==void 0&&i.push({entry:o,path:mc(u0,r),updir:!1})}if(i.length===0)return null;const n=document.createElement("header");return n.className="files-path files-recent",n.textContent="RECENT",{key:u0,header:n,lead:[],rows:i}}cards_paint(e,s){const i=this.viewMode==="preview",n=document.createElement("div");n.className=i?"files-cards files-previews":"files-cards";for(const o of e.lead??[]){const a=document.createElement("article");a.className=o.home===!0?"files-card files-card-up files-card-home files-activatable":"files-card files-card-up files-activatable",a.textContent=o.home===!0?`${d0} ~`:"▴ ..",a.addEventListener("click",()=>this.activate({kind:"dir",path:o.path})),n.appendChild(a)}const r=e.key;for(const o of e.rows)n.appendChild(this.card_build(r,o.entry,i));s.appendChild(n)}frameTop_track(){const e=this.container.parentElement,s=this.container.querySelector(".roster-order"),i=this.container.querySelector(".files-path");if(this.frameTopObserver?.disconnect(),this.frameTopObserver=null,e===null)return;if(s===null||i===null){e.style.removeProperty("--mode-frame-top"),e.style.removeProperty("--roster-frame-h");return}const n=()=>{const r=e.getBoundingClientRect().top,o=Math.ceil(s.getBoundingClientRect().bottom-r);e.style.setProperty("--roster-frame-h",`${o}px`),e.style.setProperty("--mode-frame-top",`${Math.ceil(i.getBoundingClientRect().bottom-r)}px`)};n(),this.frameTopObserver=new ResizeObserver(n),this.frameTopObserver.observe(s),this.frameTopObserver.observe(i)}follow_set(e){this.following=e,this.listing.state_refresh()}follow_get(){return this.following}view_set(e){this.viewMode=e,this.viewPill!==null&&(this.viewPill.textContent=e.toUpperCase()),this.modeSpan!==null&&(this.modeSpan.textContent=e==="list"?"":e.toUpperCase()),this.lastListings.length>0&&!this.contentShown&&this.listings_render(this.lastListings)}view_get(){return this.viewMode}body_get(){return this.container.closest(".files-body")}diagram_declare(e){this.body_get()?.classList.toggle("diagram-shown",e),e||this.mode_annunciate(this.viewMode==="list"?"":this.viewMode.toUpperCase())}mode_annunciate(e){this.modeSpan!==null&&(this.modeSpan.textContent=e)}stateLine_compose(e){const s=[];return this.following&&s.push("CWD"),e.selecting&&s.push("SELECT"),s.push(this.stale?"STALE":e.filter),e.selected>0&&s.push(e.shown===e.selected?`${e.selected} SELECTED`:`${e.selected} SELECTED · ${e.shown} SHOWN`),s.filter(i=>i!=="").join(" · ")}card_build(e,s,i=!1){const n=document.createElement("article");n.className=`files-card files-type-${s.type}`,i&&n.appendChild(this.thumb_build(mc(e,s.name),s));const r=document.createElement("div");r.className="files-card-head";const o=document.createElement("span");o.className="files-card-badge",o.textContent=s.type.toUpperCase();const a=document.createElement("span");a.className="files-card-size",a.textContent=s.type==="dir"||s.size===0?"":M0(s.size),r.append(o,a);const l=document.createElement("div");l.className="files-card-title",l.textContent=s.name;const c=document.createElement("div");c.className="files-card-meta";const h=document.createElement("span");h.textContent=s.owner;const d=document.createElement("span");if(d.textContent=s.date.slice(0,10),c.append(h,d),n.append(r,l,c),s.type==="link"&&s.target!==void 0){const f=document.createElement("div");f.className="files-card-target",f.textContent=`→ ${s.target}`,f.title=s.target,n.appendChild(f)}const u=mc(e,s.name),p=pc(s);return p!==null&&(n.classList.add("files-activatable"),n.addEventListener("click",()=>this.activate({kind:p,path:u}))),n}thumb_build(e,s){const i=document.createElement("div");i.className="files-card-thumb";const n=()=>{i.textContent=uc[s.type]};if(Tz.test(s.name)||qh.test(s.name)){i.classList.add("thumb-series");const d=document.createElement("span");d.className="thumb-series-mark",d.textContent="DCM";const u=/^\d+-(.*)-[0-9a-f]{7}$/.exec(s.name)?.[1];if(i.replaceChildren(d),u!==void 0){const p=document.createElement("span");p.className="thumb-series-text",p.textContent=u.replace(/_/g," "),i.appendChild(p)}return i}if(this.preview===null||!(s.type==="file"||s.type==="plugin"||s.type==="pipeline"))return n(),i;if(s.type==="plugin")return i.replaceChildren(g0([{id:e,parentIds:[]}])),i;if(s.type==="pipeline"){const d=this.preview;i.classList.add("thumb-wait"),i.textContent=uc[s.type];const u=()=>{d.pipelineGlimpse(e).then(p=>{if(i.classList.remove("thumb-wait"),p===null||p.length===0){n();return}if(p.length>_B){i.textContent=`${p.length} NODES`,i.classList.add("thumb-count");return}i.replaceChildren(g0(p))}).catch(()=>{i.classList.remove("thumb-wait"),n()})};return this.thumbObserver_get().observe(i),i.addEventListener("files:thumb-seen",u,{once:!0}),i}const r=this.headCache.get(e);if(r!==void 0){const d=document.createElement("pre");return d.textContent=r,i.appendChild(d),i}const o=Dd(e)&&s.size<=pB,a=tS(e),l=(a===""||hB.has(a))&&s.size<=uB;if(!o&&!l)return n(),i;i.classList.add("thumb-wait"),i.textContent=uc.file;const c=this.preview,h=()=>{if(o){const d=document.createElement("img");d.alt=s.name,d.addEventListener("load",()=>{i.classList.remove("thumb-wait")}),d.addEventListener("error",()=>{i.classList.remove("thumb-wait"),n()}),d.src=c.imageUrl(e),i.replaceChildren(d);return}c.textHead(e,fB).then(d=>{if(this.headCache.size>=mB&&this.headCache.clear(),this.headCache.set(e,d),i.classList.remove("thumb-wait"),d.trim()===""||gB(d)){n();return}const u=document.createElement("pre");u.textContent=d,i.replaceChildren(u)}).catch(()=>{i.classList.remove("thumb-wait"),n()})};return this.thumbObserver_get().observe(i),i.addEventListener("files:thumb-seen",h,{once:!0}),i}thumbObserver_get(){return this.thumbObserver===null&&(this.thumbObserver=new IntersectionObserver(e=>{for(const s of e)s.isIntersecting&&(this.thumbObserver?.unobserve(s.target),s.target.dispatchEvent(new CustomEvent("files:thumb-seen")))},{root:this.container,rootMargin:"25%"})),this.thumbObserver}filter_toggle(e){this.listing.filter_toggle(e)}}function _0(t){if(!Array.isArray(t))return null;for(const e of t){if(typeof e!="object"||e===null)return null;const s=e;if(typeof s.path!="string"||!Array.isArray(s.items))return null}return t}function mc(t,e){return t.endsWith("/")?`${t}${e}`:`${t}/${e}`}function b0(t){const e=t.endsWith("/")?t.slice(0,-1):t,s=e.lastIndexOf("/");return s<=0?"/":e.slice(0,s)}function M0(t){if(t<1024)return String(t);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]}`}class bB{grid;startHere;host;paintId=0;constructor(e,s){this.host=s,this.grid=e.querySelector(".launcher-grid"),ii(this.grid,{rows:".launcher-tile",mount:this.grid.parentElement??this.grid});const i=e.querySelector(".launcher-body");i!==null&&ii(i,{rows:".launcher-tile",scrolls:()=>/auto|scroll/.test(getComputedStyle(i).overflowY)}),this.startHere=e.querySelector(".launcher-start"),this.startHere.addEventListener("click",()=>{this.host.startHere_set(!this.host.startHere_get()),this.startHere_render()}),this.startHere_render()}render(){const e=++this.paintId;this.host.tiles().then(s=>{e!==this.paintId||!this.grid.isConnected||(this.grid.replaceChildren(...s.map((i,n)=>this.tile_build(i,n===0||i.wide===!0))),this.startHere_render())}).catch(()=>{e!==this.paintId||!this.grid.isConnected||this.grid.replaceChildren()})}numeral_press(e){const s=this.grid.querySelector(`[data-numeral="${e}"]`);return s===null?!1:(s.click(),!0)}startHere_render(){const e=this.host.startHere_get();this.startHere.textContent=e?"START HERE · ON":"START HERE · OFF",this.startHere.classList.toggle("pacs-capsule-off",!e)}tile_build(e,s){const i=document.createElement("button");i.className=`launcher-tile${s?" launcher-tile-wide":""}`,i.style.setProperty("--tile-hue",`var(${e.hue})`),i.dataset.numeral=e.numeral,i.title=e.verb,i.addEventListener("click",h=>{h.target instanceof Element&&h.target.closest(".launcher-row, .launcher-figure")!==null||(this.host.leave?.(),e.enter())});const n=document.createElement("span");n.className="launcher-head";const r=document.createElement("span");r.className="launcher-name",r.textContent=e.name;const o=document.createElement("span");o.className="launcher-numeral",o.textContent=e.numeral,n.append(r);for(const h of e.figures){const d=document.createElement(h.open===void 0?"span":"button");if(d.className=`launcher-figure${h.errored===!0?" launcher-figure-errored":""}`,d.textContent=h.text,h.open!==void 0){const u=h.open;d.addEventListener("click",p=>{p.stopPropagation(),this.host.leave?.(),u()})}n.appendChild(d)}n.appendChild(o);const a=document.createElement("span");a.className="launcher-rule";const l=document.createElement("span");l.className="launcher-rows";for(const h of e.rows){const d=document.createElement(h.open===void 0?"span":"button");d.className=`launcher-row${h.arrived===!0?" launcher-row-arrived":""}`;const u=document.createElement("span");u.className=`launcher-dot${h.errored===!0?" launcher-dot-errored":""}`;const p=document.createElement("span");if(p.className="launcher-row-text",p.textContent=h.text,d.append(u,p),h.open!==void 0){const f=h.open,_=document.createElement("span");_.className="launcher-go",_.textContent="›",d.appendChild(_),d.addEventListener("click",g=>{g.stopPropagation(),this.host.leave?.(),f()})}l.appendChild(d)}const c=document.createElement("span");return c.className="launcher-verb",c.textContent=e.verb,i.append(n,a),e.about!==void 0&&i.appendChild(MB(e.about)),i.append(l,c),i}}function MB(t){const e=document.createElement("span");e.className="launcher-about";const s=document.createElement("span");if(s.className="launcher-about-text",s.textContent=t.text,e.appendChild(s),t.list!==void 0&&t.list.length>0){const i=document.createElement("span");i.className="launcher-about-list";for(const n of t.list){const r=document.createElement("span");r.className="launcher-about-item",r.textContent=n,i.appendChild(r)}e.appendChild(i)}if(t.tail!==void 0){const i=document.createElement("span");i.className="launcher-about-text",i.textContent=t.tail,e.appendChild(i)}return e}const Gi={left:{axis:"col",place:"before",focusWord:"left",arrow:"ArrowLeft",edge:"leftmost"},right:{axis:"col",place:"after",focusWord:"right",arrow:"ArrowRight",edge:"rightmost"},above:{axis:"row",place:"before",focusWord:"up",arrow:"ArrowUp",edge:"topmost"},below:{axis:"row",place:"after",focusWord:"down",arrow:"ArrowDown",edge:"bottommost"}},iS=["left","right","above","below"];function v0(t){return t==="left"||t==="right"||t==="above"||t==="below"}function vB(t,e){return t==="row"?e?"above":"below":e?"left":"right"}function wB(t,e){return t!=="row"&&t!=="col"||e!=="before"&&e!=="after"?null:vB(t,e==="before")}function yB(t){return iS.find(e=>Gi[e].focusWord===t)??null}function zB(t){return iS.find(e=>Gi[e].arrow===t)??null}function SB(t){return t?"before":"after"}function Ai(t){return`[data-split="${Gi[t].axis}"][data-place="${Gi[t].place}"]`}const xB=["read look only: the tenancy, its Trusted Domains, their cost; nothing outside this host changes","manage act as well: build, tear down and spend, each after its own lock and the name typed back"];function OB(t){document.querySelector(".share-sheet")?.remove();const e=document.createElement("div");e.className="share-sheet cloud-ask",e.setAttribute("role","dialog");const s=document.createElement("div");s.className="share-head",s.textContent=`CLOUD MANAGEMENT · ${t.toUpperCase()} · ENTER TO READ, OR TO MANAGE?`;const i=document.createElement("pre");i.className="share-script",i.textContent=xB.join(`
|
|
92
|
+
`)[0]?.slice(0,120)??"";Es(this.stateSpan,"refused",`COULD NOT LIST${s===""?"":` · ${s.toUpperCase()}`}`);const i=this.lastListings.length===0?this.container.querySelector(".files-empty"):null;i!==null&&(i.textContent=`COULD NOT LIST — ${s}`)}envelope_observe(e){if(e.status==="error"&&!oB(e)){this.listing.activation_refuse(eS(e));return}if(e.model?.kind!=="fs.listing")return;const s=_0(e.model.data);if(s===null||s.length===0)return;this.lastListings=s;const i=s[0]?.path??"";this.container.closest(".workspace-pane")?.classList.toggle("files-projection",/^\/(proc|net|etc|usr)(\/|$)/.test(i)),!this.contentShown&&this.listings_render(s)}ambient_observe(e){if(e.model?.kind!=="fs.listing")return;const s=_0(e.model.data);if(s===null||this.lastListings.length===0)return;let i=!1;const n=this.lastListings.map(r=>{const o=s.find(a=>a.path===r.path);return o===void 0?r:(i=!0,o)});if(i){if(this.contentShown){this.lastListings=n;return}this.listings_render(n)}}contentTable_show(e,s){const i=eB(s,e);if(i.caps.length===0){this.content_show(e,s);return}const n=i.rows.slice(0,lB),r=i.rows.length>n.length;this.contentRelease?.(),this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren(),this.diagram_declare(!1);const o=document.createElement("section");o.className="files-content-view files-table-view";const a=document.createElement("header");a.className="files-path files-content-header";const l=document.createElement("span");l.textContent=e;const c=document.createElement("span");c.className="pane-state",a.append(l,c);const h=document.createElement("div");h.className="files-table-field";const d=document.createElement("span");d.className="field-rule";const u=document.createElement("button");u.className="mode-strip",u.title="display modes";const p=document.createElement("span");p.className="mode-elbow";const f=document.createElement("aside");f.className="mode-frame";const _=document.createElement("button");_.className="strategy-pill csv-filter rail-off",_.textContent="FILTER OFF",_.title="filter the table";const g=document.createElement("button");g.className="strategy-pill csv-raw",g.textContent="RAW",g.title="the bytes as written",g.addEventListener("click",()=>this.content_show(e,s));const m=document.createElement("button");m.className="strategy-pill csv-close",m.textContent="CLOSE",m.title="leave the table; the listing beneath returns",m.addEventListener("click",()=>this.listing_restore());const v=document.createElement("span");v.className="mode-fill",f.append(_,g,v);const y=this.preview;if(y!==null){const x=document.createElement("button");x.className="strategy-pill csv-download",x.textContent="DOWNLOAD",x.title="save this file to your disk",x.addEventListener("click",()=>y.download(e)),f.append(x)}f.append(m);const b=document.createElement("div");b.className="files-table-rows",h.append(d,u,p,f,b),o.append(a,h),this.container.appendChild(o);const w=i.caps.map((x,M)=>({key:`c${M}`,label:x.toUpperCase(),className:"files-table-cell",cell:S=>S.cells[M]??"",width:"minmax(6em, 1fr)"}));new Vn({mount:b,traits:w,key:x=>String(x.index),chrome:{root:o,prefix:"csv"},state:x=>{const M=[];return x.filter!==""?M.push(`${x.filter} ROWS`):M.push(r?`SHOWING ${n.length} OF ${i.rows.length} ROWS`:`${i.rows.length} ROWS`),i.headed||M.push("NO HEADER: COLUMNS NUMBERED"),M.join(" · ")},empty:()=>{const x=document.createElement("div");return x.className="files-note",x.textContent="NO ROWS",x}}).rows_set([{key:e,rows:n.map((x,M)=>({index:M,cells:x}))}],{field:e}),this.contentRelease=()=>{b.replaceChildren()}}content_show(e,s,i=!1,n=!1){this.diagram_declare(!1),this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren();const r=document.createElement("header");r.className="files-path files-content-header";const o=document.createElement("span");o.textContent=e;const a=document.createElement("button");a.className="files-close-pill",a.textContent="CLOSE",a.addEventListener("click",()=>this.listing_restore());const l=document.createElement("pre");l.className="files-content";const c=i||!a0.test(e)?null:l0(s),h=[];if(c!==null||i&&a0.test(e)&&l0(s)!==null){const u=document.createElement("button");u.className="files-close-pill",u.textContent=c!==null?"RAW":"PRETTY",u.addEventListener("click",()=>this.content_show(e,s,c!==null)),h.push(u)}const d=Jz(e);if(d){const u=document.createElement("button");u.className="files-close-pill files-render-pill",u.textContent=n?"SOURCE":"RENDERED",u.title=n?"the document as written":"the document as its page",u.addEventListener("click",()=>this.content_show(e,s,!1,!n)),h.push(u)}if(r.append(o,...m0(this.preview,e),...h,a),c!==null?(l.classList.add("files-json"),l.append(c)):l.textContent=s,this.container.append(r,l),ii(l),c===null){if(d&&n){Qz(e,s).then(u=>{u===null||!l.isConnected||(u.classList.add("files-content"),l.replaceWith(u),ii(u))}).catch(()=>{});return}Ll(async()=>{const{sourceSpans_build:u}=await import("./syntax-CGla7mM6.js").then(p=>p.ao);return{sourceSpans_build:u}},[],import.meta.url).then(({sourceSpans_build:u})=>u(s,yg(e))).then(u=>{if(u===null||!l.isConnected)return;const p=l.querySelector(":scope > .more-chip");l.replaceChildren(u),p!==null&&l.append(p),l.classList.add("files-source")}).catch(()=>{})}}contentRefused_show(e,s){this.diagram_declare(!1),this.denied.add(e),this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren();const i=document.createElement("header");i.className="files-path files-content-header files-content-refused";const n=document.createElement("span");n.textContent=e;const r=document.createElement("button");r.className="files-close-pill",r.textContent="CLOSE",r.addEventListener("click",()=>this.listing_restore()),i.append(n,r);const o=document.createElement("div");o.className="files-refused";const a=document.createElement("p");a.className="files-refused-lede",a.textContent="READ REFUSED";const l=document.createElement("pre");l.className="files-refused-said",l.textContent=s,o.append(a,l),this.container.append(i,o)}contentImage_show(e,s){this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren();const i=document.createElement("header");i.className="files-path files-content-header";const n=document.createElement("span");n.textContent=e;const r=document.createElement("button");r.className="files-close-pill",r.textContent="CLOSE",r.addEventListener("click",()=>this.listing_restore()),i.append(n,...m0(this.preview,e),r);const o=document.createElement("img");o.className="files-image",o.src=s,o.alt=e,this.container.append(i,o)}rowVerbs_declare(e,s){this.indicate=s??null,this.listing.actions_declare({of:i=>i.updir?[]:e(i.entry,i.path).map(n=>({label:n.label,run:()=>n.run(i.entry),...n.offered!==void 0?{offered:()=>n.offered(i.entry)}:{},...n.disabled!==void 0?{disabled:()=>n.disabled(i.entry)}:{}}))})}catalogueTraits_declare(){return[...this.browserTraits_declare().filter(i=>i.key==="control"||i.key==="name"),{key:"type",label:"TYPE",className:"files-type",width:"6em",cell:i=>i.updir?"":i.entry.type},{key:"version",label:"VERSION",className:"files-version",width:"7em",cell:i=>i.updir?"":h0(i.entry.name),compare:i=>h0(i.entry.name)}]}catalogue_is(){return this.catalogue}binding_set(e){if(this.runStrip===null){const i=document.createElement("div");i.className="files-run-strip";const n=document.createElement("span");n.className="files-binding";const r=document.createElement("input");r.className="files-command",r.spellcheck=!1,r.autocomplete="off",r.placeholder="the line RUN will run",i.append(n,r),this.container.parentElement?.insertBefore(i,this.container),this.runStrip=i;const o=this.container.closest(".pane-files")?.querySelector(".pane-title");o!=null&&(o.textContent="CATALOGUE")}const s=this.runStrip.querySelector(".files-binding");s!==null&&(s.textContent=`INPUT ${e.input} → ${e.place}`),this.frameTop_track()}commandLine_get(){return this.runStrip?.querySelector(".files-command")?.value.trim()??""}commandLine_set(e){const s=this.runStrip?.querySelector(".files-command")??null;s!==null&&(s.value=e)}indicated_get(){return this.listing.indicated_get()}feedOpen_declare(e){this.feedOpen=e}run_show(e){if(this.runStrip===null)return;this.runStrip.querySelector(".files-feed")?.remove();const s=document.createElement("button");s.className="files-feed listing-capsule listing-action-selected",s.textContent=`FEED ${e}`,s.title="open this run's graph beside the catalogue",s.addEventListener("click",()=>this.feedOpen?.(e)),this.runStrip.appendChild(s)}row_indicate(e){this.listing.row_indicate(e)}rowReadout_show(e,s){this.listing.readout_show(e,s)}selectionVerbs_declare(e){this.selectionVerbs=e}select_toggle(e){this.listing.select_toggle(e)}select_isOn(){return this.listing.select_isOn()}selection_get(){return this.listing.selection_get()}path_current(){return this.lastListings[0]?.path??null}content_isShown(){return this.contentShown}contentRelease=null;contentHtml_show(e,s,i={}){this.contentRelease?.(),this.contentRelease=i.release??null,this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren();const n=document.createElement("section");n.className="files-content-view";const r=document.createElement("header");r.className="files-path files-content-header";const o=document.createElement("span");o.textContent=e;const a=document.createElement("button");if(a.className="files-close-pill",a.textContent="CLOSE",a.addEventListener("click",()=>this.listing_restore()),r.append(o,a),n.appendChild(r),s!==""){const c=document.createElement("pre");c.className="files-content",c.innerHTML=s,n.appendChild(c)}let l=null;return i.diagram===!0&&(l=document.createElement("div"),l.className="files-diagram",n.appendChild(l)),this.diagram_declare(i.diagram===!0),this.container.appendChild(n),l}contentText_set(e){const s=this.container.querySelector(".files-content-view");if(s===null)return;const i=s.querySelector(".files-content"),n=i??document.createElement("pre");n.className="files-content",n.innerHTML=e,i===null&&s.querySelector(".files-content-header")?.after(n)}recent_set(e){this.recent=e===null?null:[...e],this.lastListings.length>0&&!this.contentShown&&this.listings_render(this.lastListings)}listing_restore(){this.contentRelease?.(),this.contentRelease=null,this.lastListings.length>0?this.listings_render(this.lastListings):this.empty_render()}empty_render(){this.diagram_declare(!1),this.container.replaceChildren();const e=document.createElement("p");e.className="files-empty",e.textContent="AWAITING LISTING — TYPE ls IN THE CONSOLE",this.container.appendChild(e)}listings_render(e){this.diagram_declare(!1),this.contentShown=!1,this.container.parentElement?.classList.remove("content-view"),this.lastListings=e,this.thumbObserver?.disconnect(),this.thumbObserver=null,this.stale=e.some(n=>n.fresh===!1),F2(this.stateSpan,"stale",this.stale),this.listing.painter_set(this.viewMode==="list"?null:(n,r)=>this.cards_paint(n,r));const s=e.map(n=>this.block_build(n)),i=e.find(n=>n.path===aB);if(this.recent!==null&&this.recent.length>0&&i!==void 0){const n=this.recentBlock_build(i);n!==null&&s.unshift(n)}this.listing.rows_set(s,{field:e[0]?.path??""}),this.frameTop_track()}crumbs_build(e){const s=document.createElement("header");s.className="files-path files-crumbs";const i=[],n=this.home;let r;n!==null&&(e===n||e.startsWith(`${n}/`))?(i.push({label:"~",path:n}),r=e.slice(n.length)):(i.push({label:"/",path:"/"}),r=e);let o=i[0]?.path??"/";for(const a of r.split("/").filter(l=>l.length>0))o=o==="/"?`/${a}`:`${o}/${a}`,i.push({label:a,path:o});return i.forEach((a,l)=>{l>0&&i[l-1]?.label!=="/"&&s.append("/");const c=l===i.length-1,h=document.createElement(c?"span":"button");h.className=c?"files-crumb files-crumb-here":"files-crumb",h.textContent=a.label,h.dataset.path=a.path,c||(h.title=`go to ${a.path}`,h.addEventListener("click",d=>{d.stopPropagation(),this.activate({kind:"dir",path:a.path})})),s.appendChild(h)}),this.catalogue||s.appendChild(ly(e)),s}link_copy(e){const s=b0(e),n=[...this.container.querySelectorAll(".files-crumbs")].filter(r=>r.querySelector(".files-crumb-here")?.dataset.path===s||r.querySelector(".files-crumb-here")?.dataset.path===e).map(r=>r.querySelector(".link-line")).filter(r=>r!==null)[0];return n===void 0?null:(og(n,e),cy(n))}ceiling_set(e,s=".."){this.ceiling=e===null?null:{path:e.replace(/\/+$/,"")||"/",word:s}}home_set(e){e!==this.home&&(this.home=e,!this.contentShown&&this.lastListings.length>0&&this.listings_render(this.lastListings))}block_build(e){const s=this.crumbs_build(e.path),i=e.items.map(r=>({entry:r,path:mc(e.path,r.name),updir:!1})),n=[];if(!this.catalogue&&this.home!==null&&e.path!==this.home&&n.push({entry:{name:"~",type:"dir",size:0,owner:"",date:""},path:this.home,updir:!0,home:!0}),e.path!=="/"){const r=this.ceiling!==null&&this.ceiling.path===e.path?this.ceiling.word:"..";n.push({entry:{name:r,type:"dir",size:0,owner:"",date:""},path:b0(e.path),updir:!0})}return{key:e.path,header:s,lead:n,rows:i}}recentBlock_build(e){const s=new Map(e.items.map(r=>[r.name,r])),i=[];for(const r of this.recent??[]){const o=s.get(r);o!==void 0&&i.push({entry:o,path:mc(u0,r),updir:!1})}if(i.length===0)return null;const n=document.createElement("header");return n.className="files-path files-recent",n.textContent="RECENT",{key:u0,header:n,lead:[],rows:i}}cards_paint(e,s){const i=this.viewMode==="preview",n=document.createElement("div");n.className=i?"files-cards files-previews":"files-cards";for(const o of e.lead??[]){const a=document.createElement("article");a.className=o.home===!0?"files-card files-card-up files-card-home files-activatable":"files-card files-card-up files-activatable",a.textContent=o.home===!0?`${d0} ~`:"▴ ..",a.addEventListener("click",()=>this.activate({kind:"dir",path:o.path})),n.appendChild(a)}const r=e.key;for(const o of e.rows)n.appendChild(this.card_build(r,o.entry,i));s.appendChild(n)}frameTop_track(){const e=this.container.parentElement,s=this.container.querySelector(".roster-order"),i=this.container.querySelector(".files-path");if(this.frameTopObserver?.disconnect(),this.frameTopObserver=null,e===null)return;if(s===null||i===null){e.style.removeProperty("--mode-frame-top"),e.style.removeProperty("--roster-frame-h");return}const n=()=>{const r=e.getBoundingClientRect().top,o=Math.ceil(s.getBoundingClientRect().bottom-r);e.style.setProperty("--roster-frame-h",`${o}px`),e.style.setProperty("--mode-frame-top",`${Math.ceil(i.getBoundingClientRect().bottom-r)}px`)};n(),this.frameTopObserver=new ResizeObserver(n),this.frameTopObserver.observe(s),this.frameTopObserver.observe(i)}follow_set(e){this.following=e,this.listing.state_refresh()}follow_get(){return this.following}view_set(e){this.viewMode=e,this.viewPill!==null&&(this.viewPill.textContent=e.toUpperCase()),this.modeSpan!==null&&(this.modeSpan.textContent=e==="list"?"":e.toUpperCase()),this.lastListings.length>0&&!this.contentShown&&this.listings_render(this.lastListings)}view_get(){return this.viewMode}body_get(){return this.container.closest(".files-body")}diagram_declare(e){this.body_get()?.classList.toggle("diagram-shown",e),e||this.mode_annunciate(this.viewMode==="list"?"":this.viewMode.toUpperCase())}mode_annunciate(e){this.modeSpan!==null&&(this.modeSpan.textContent=e)}stateLine_compose(e){const s=[];return this.following&&s.push("CWD"),e.selecting&&s.push("SELECT"),s.push(this.stale?"STALE":e.filter),e.selected>0&&s.push(e.shown===e.selected?`${e.selected} SELECTED`:`${e.selected} SELECTED · ${e.shown} SHOWN`),s.filter(i=>i!=="").join(" · ")}card_build(e,s,i=!1){const n=document.createElement("article");n.className=`files-card files-type-${s.type}`,i&&n.appendChild(this.thumb_build(mc(e,s.name),s));const r=document.createElement("div");r.className="files-card-head";const o=document.createElement("span");o.className="files-card-badge",o.textContent=s.type.toUpperCase();const a=document.createElement("span");a.className="files-card-size",a.textContent=s.type==="dir"||s.size===0?"":M0(s.size),r.append(o,a);const l=document.createElement("div");l.className="files-card-title",l.textContent=s.name;const c=document.createElement("div");c.className="files-card-meta";const h=document.createElement("span");h.textContent=s.owner;const d=document.createElement("span");if(d.textContent=s.date.slice(0,10),c.append(h,d),n.append(r,l,c),s.type==="link"&&s.target!==void 0){const f=document.createElement("div");f.className="files-card-target",f.textContent=`→ ${s.target}`,f.title=s.target,n.appendChild(f)}const u=mc(e,s.name),p=pc(s);return p!==null&&(n.classList.add("files-activatable"),n.addEventListener("click",()=>this.activate({kind:p,path:u}))),n}thumb_build(e,s){const i=document.createElement("div");i.className="files-card-thumb";const n=()=>{i.textContent=uc[s.type]};if(Tz.test(s.name)||qh.test(s.name)){i.classList.add("thumb-series");const d=document.createElement("span");d.className="thumb-series-mark",d.textContent="DCM";const u=/^\d+-(.*)-[0-9a-f]{7}$/.exec(s.name)?.[1];if(i.replaceChildren(d),u!==void 0){const p=document.createElement("span");p.className="thumb-series-text",p.textContent=u.replace(/_/g," "),i.appendChild(p)}return i}if(this.preview===null||!(s.type==="file"||s.type==="plugin"||s.type==="pipeline"))return n(),i;if(s.type==="plugin")return i.replaceChildren(g0([{id:e,parentIds:[]}])),i;if(s.type==="pipeline"){const d=this.preview;i.classList.add("thumb-wait"),i.textContent=uc[s.type];const u=()=>{d.pipelineGlimpse(e).then(p=>{if(i.classList.remove("thumb-wait"),p===null||p.length===0){n();return}if(p.length>_B){i.textContent=`${p.length} NODES`,i.classList.add("thumb-count");return}i.replaceChildren(g0(p))}).catch(()=>{i.classList.remove("thumb-wait"),n()})};return this.thumbObserver_get().observe(i),i.addEventListener("files:thumb-seen",u,{once:!0}),i}const r=this.headCache.get(e);if(r!==void 0){const d=document.createElement("pre");return d.textContent=r,i.appendChild(d),i}const o=Dd(e)&&s.size<=pB,a=tS(e),l=(a===""||hB.has(a))&&s.size<=uB;if(!o&&!l)return n(),i;i.classList.add("thumb-wait"),i.textContent=uc.file;const c=this.preview,h=()=>{if(o){const d=document.createElement("img");d.alt=s.name,d.addEventListener("load",()=>{i.classList.remove("thumb-wait")}),d.addEventListener("error",()=>{i.classList.remove("thumb-wait"),n()}),d.src=c.imageUrl(e),i.replaceChildren(d);return}c.textHead(e,fB).then(d=>{if(this.headCache.size>=mB&&this.headCache.clear(),this.headCache.set(e,d),i.classList.remove("thumb-wait"),d.trim()===""||gB(d)){n();return}const u=document.createElement("pre");u.textContent=d,i.replaceChildren(u)}).catch(()=>{i.classList.remove("thumb-wait"),n()})};return this.thumbObserver_get().observe(i),i.addEventListener("files:thumb-seen",h,{once:!0}),i}thumbObserver_get(){return this.thumbObserver===null&&(this.thumbObserver=new IntersectionObserver(e=>{for(const s of e)s.isIntersecting&&(this.thumbObserver?.unobserve(s.target),s.target.dispatchEvent(new CustomEvent("files:thumb-seen")))},{root:this.container,rootMargin:"25%"})),this.thumbObserver}filter_toggle(e){this.listing.filter_toggle(e)}}function _0(t){if(!Array.isArray(t))return null;for(const e of t){if(typeof e!="object"||e===null)return null;const s=e;if(typeof s.path!="string"||!Array.isArray(s.items))return null}return t}function mc(t,e){return t.endsWith("/")?`${t}${e}`:`${t}/${e}`}function b0(t){const e=t.endsWith("/")?t.slice(0,-1):t,s=e.lastIndexOf("/");return s<=0?"/":e.slice(0,s)}function M0(t){if(t<1024)return String(t);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]}`}class bB{grid;startHere;host;paintId=0;constructor(e,s){this.host=s,this.grid=e.querySelector(".launcher-grid"),ii(this.grid,{rows:".launcher-tile",mount:this.grid.parentElement??this.grid});const i=e.querySelector(".launcher-body");i!==null&&ii(i,{rows:".launcher-tile",scrolls:()=>/auto|scroll/.test(getComputedStyle(i).overflowY)}),this.startHere=e.querySelector(".launcher-start"),this.startHere.addEventListener("click",()=>{this.host.startHere_set(!this.host.startHere_get()),this.startHere_render()}),this.startHere_render()}render(){const e=++this.paintId;this.host.tiles().then(s=>{e!==this.paintId||!this.grid.isConnected||(this.grid.replaceChildren(...s.map((i,n)=>this.tile_build(i,n===0||i.wide===!0))),this.startHere_render())}).catch(()=>{e!==this.paintId||!this.grid.isConnected||this.grid.replaceChildren()})}numeral_press(e){const s=this.grid.querySelector(`[data-numeral="${e}"]`);return s===null?!1:(s.click(),!0)}startHere_render(){const e=this.host.startHere_get();this.startHere.textContent=e?"START HERE · ON":"START HERE · OFF",this.startHere.classList.toggle("pacs-capsule-off",!e)}tile_build(e,s){const i=document.createElement("button");i.className=`launcher-tile${s?" launcher-tile-wide":""}`,i.style.setProperty("--tile-hue",`var(${e.hue})`),i.dataset.numeral=e.numeral,i.title=e.verb,i.addEventListener("click",h=>{h.target instanceof Element&&h.target.closest(".launcher-row, .launcher-figure")!==null||(this.host.leave?.(),e.enter())});const n=document.createElement("span");n.className="launcher-head";const r=document.createElement("span");r.className="launcher-name",r.textContent=e.name;const o=document.createElement("span");o.className="launcher-numeral",o.textContent=e.numeral,n.append(r);for(const h of e.figures){const d=document.createElement(h.open===void 0?"span":"button");if(d.className=`launcher-figure${h.errored===!0?" launcher-figure-errored":""}`,d.textContent=h.text,h.open!==void 0){const u=h.open;d.addEventListener("click",p=>{p.stopPropagation(),this.host.leave?.(),u()})}n.appendChild(d)}n.appendChild(o);const a=document.createElement("span");a.className="launcher-rule";const l=document.createElement("span");l.className="launcher-rows";for(const h of e.rows){const d=document.createElement(h.open===void 0?"span":"button");d.className=`launcher-row${h.arrived===!0?" launcher-row-arrived":""}`;const u=document.createElement("span");u.className=`launcher-dot${h.errored===!0?" launcher-dot-errored":""}`;const p=document.createElement("span");if(p.className="launcher-row-text",p.textContent=h.text,d.append(u,p),h.open!==void 0){const f=h.open,_=document.createElement("span");_.className="launcher-go",_.textContent="›",d.appendChild(_),d.addEventListener("click",g=>{g.stopPropagation(),this.host.leave?.(),f()})}l.appendChild(d)}const c=document.createElement("span");return c.className="launcher-verb",c.textContent=e.verb,i.append(n,a),e.about!==void 0&&i.appendChild(MB(e.about)),i.append(l,c),i}}function MB(t){const e=document.createElement("span");e.className="launcher-about";const s=document.createElement("span");if(s.className="launcher-about-text",s.textContent=t.text,e.appendChild(s),t.list!==void 0&&t.list.length>0){const i=document.createElement("span");i.className="launcher-about-list";for(const n of t.list){const r=document.createElement("span");r.className="launcher-about-item",r.textContent=n,i.appendChild(r)}e.appendChild(i)}if(t.tail!==void 0){const i=document.createElement("span");i.className="launcher-about-text",i.textContent=t.tail,e.appendChild(i)}return e}const Gi={left:{axis:"col",place:"before",focusWord:"left",arrow:"ArrowLeft",edge:"leftmost"},right:{axis:"col",place:"after",focusWord:"right",arrow:"ArrowRight",edge:"rightmost"},above:{axis:"row",place:"before",focusWord:"up",arrow:"ArrowUp",edge:"topmost"},below:{axis:"row",place:"after",focusWord:"down",arrow:"ArrowDown",edge:"bottommost"}},iS=["left","right","above","below"];function v0(t){return t==="left"||t==="right"||t==="above"||t==="below"}function vB(t,e){return t==="row"?e?"above":"below":e?"left":"right"}function wB(t,e){return t!=="row"&&t!=="col"||e!=="before"&&e!=="after"?null:vB(t,e==="before")}function yB(t){return iS.find(e=>Gi[e].focusWord===t)??null}function zB(t){return iS.find(e=>Gi[e].arrow===t)??null}function SB(t){return t?"before":"after"}function Ai(t){return`[data-split="${Gi[t].axis}"][data-place="${Gi[t].place}"]`}const xB=["read look only: the tenancy, what is built in it, its cost; nothing outside this host changes","manage act as well: build, tear down and spend, each after its own lock and the name typed back"];function OB(t){document.querySelector(".share-sheet")?.remove();const e=document.createElement("div");e.className="share-sheet cloud-ask",e.setAttribute("role","dialog");const s=document.createElement("div");s.className="share-head",s.textContent=`CLOUD MANAGEMENT · ${t.toUpperCase()} · ENTER TO READ, OR TO MANAGE?`;const i=document.createElement("pre");i.className="share-script",i.textContent=xB.join(`
|
|
93
93
|
`);const n=(c,h)=>{const d=document.createElement("button");return d.type="button",d.className=h,d.textContent=c,d},r=n("READ","share-copy cloud-read"),o=n("MANAGE","share-copy cloud-manage"),a=n("NOT NOW","share-close"),l=document.createElement("div");return l.className="share-pills",l.append(r,o,a),e.append(s,i,l),document.body.appendChild(e),r.focus(),new Promise(c=>{const h=d=>{e.remove(),c(d)};r.addEventListener("click",()=>h("read")),o.addEventListener("click",()=>h("manage")),a.addEventListener("click",()=>h(null)),e.addEventListener("keydown",d=>{const u=d.key.toLowerCase();u==="escape"?h(null):u==="r"?h("read"):u==="m"&&h("manage")})})}const Id=new Set(["pane","view","file","header","console","back","desktop","dashboard","help","notes","launcher","attach","argus","trek","stratus","chris","capacity"]),EB=new Set(Id),Fg={help:new Set(["pane","keys","verbs"]),notes:new Set(["pane"]),capacity:new Set(["pane"]),file:new Set(["home","back","download","delete","follow","root","open","list","cards","preview","sort","filter"]),trek:new Set(["","--seed"])};let Bn=null,fn=null;const Ao="argus.desktop.",w0="~/.config/argus/desktops";function y0(){return[...Id].sort().map(t=>{const e=Fg[t];return e===void 0?{subject:t}:{subject:t,verbs:[...e].sort()}})}function AB(t){const e=t.trim().split(/\s+/),s=(e[0]??"").toLowerCase();if(!Id.has(s))return null;const i=Fg[s];if(i!==void 0&&!i.has((e[1]??"").toLowerCase()))return null;let n=null,r=e.slice(1);return(r[0]?.startsWith("@")||r[0]?.startsWith("%"))&&(n=r[0],r=r.slice(1)),{subject:s,target:n,words:r}}function gu(t,e){if(e===null)return t.focused_get();if(e.startsWith("@"))return e.slice(1);const s=parseInt(e.slice(1),10);return fn===null?null:fn[s-1]??null}function TB(t,e,s){return e!==null&&s.includes(t.paneKind_get(e)??"")?e:t.panes_shown().find(i=>s.includes(t.paneKind_get(i)??""))??null}function Nn(t,e,s){const n=t.paneMount_get(e)?.querySelector(s)??null;return n===null?!1:(n.click(),!0)}function _h(t,e,s){const i=t.paneMount_get(e);if(i===null)return!1;for(const n of i.querySelectorAll(".drawer-child"))if(n.textContent?.trim().toUpperCase()===s)return n.click(),!0;return!1}function DB(t,e,s){return Nn(t,e,`.drawer-cwdbind[data-follow="${s?"on":"off"}"]`)}function Kr(t,e,s,i){const r=t.paneMount_get(e)?.querySelector(s)??null;if(r===null)return!1;for(let o=0;o<4;o++){if(r.textContent?.trim().toUpperCase()===i)return!0;r.click()}return r.textContent?.trim().toUpperCase()===i}function nS(t,e){const s=t.focused_get(),i=s!==null?t.paneRect_get(s):null;if(i===null)return null;const n=i.x+i.width/2,r=i.y+i.height/2;let o=null;for(const a of t.panes_shown()){if(a===s)continue;const l=t.paneRect_get(a);if(l===null)continue;const c=l.x+l.width/2-n,h=l.y+l.height/2-r,d=e==="left"?-c:e==="right"?c:e==="up"?-h:h;if(d<=1)continue;const u=Math.abs(e==="left"||e==="right"?h:c),p=d+u*2;(o===null||p<o.score)&&(o={id:a,score:p})}return o===null?null:(t.focus_set(o.id),o.id)}const _n=[{key:"%",topic:"pane",selector:Ai("right"),does:"split right (tmux)"},{key:'"',topic:"pane",selector:Ai("below"),does:"split below (tmux)"},{key:"h",topic:"pane",selector:Ai("left"),does:"split left"},{key:"j",topic:"pane",selector:Ai("below"),does:"split below"},{key:"k",topic:"pane",selector:Ai("above"),does:"split above"},{key:"l",topic:"pane",selector:Ai("right"),does:"split right"},{key:"H",topic:"pane",selector:Ai("left"),does:"move this pane left",move:!0},{key:"J",topic:"pane",selector:Ai("below"),does:"move this pane below",move:!0},{key:"K",topic:"pane",selector:Ai("above"),does:"move this pane above",move:!0},{key:"L",topic:"pane",selector:Ai("right"),does:"move this pane right",move:!0},{key:"m",topic:"pane",selector:'.drawer-mode[data-mode="move"]',does:"arm MOVE (then a direction)"},{key:"z",topic:"pane",selector:".drawer-zoom",does:"zoom (tmux), or double-click the pane's header"},{key:"x",topic:"pane",selector:".drawer-close",does:"close (tmux)"},{key:"u",topic:"binding",selector:'.drawer-bind[data-bind="unlinked"]',does:"the next split is unlinked"},{key:"f",topic:"binding",selector:'.drawer-bind[data-bind="fs"]',does:"the next split is a linked filesystem"},{key:"v",topic:"binding",selector:'.drawer-bind[data-bind="viewer"]',does:"the next split is a linked viewer"},{key:"1",topic:"claim",selector:".empty-go-files",does:"claim an empty pane as FILES"},{key:"o",topic:"focus",selector:null,does:"focus the next pane (tmux)"},{key:";",topic:"focus",selector:null,does:"focus the last pane (tmux)"},{key:"q",topic:"focus",selector:null,does:"show every pane's @id on its bar (tmux)"},{key:"Space",topic:"pane",selector:null,does:"flip this pane's split: beside becomes above (tmux next layout)"},{key:"!",topic:"pane",selector:null,does:"break this pane out: alone on stage, the rest a PANES card (tmux)"},{key:"Ctrl-←↑↓→",topic:"pane",selector:null,does:"move the boundary beside this pane a step (tmux)"},{key:"w",topic:"stage",selector:null,does:"PANES, the desktops (tmux window chooser)"},{key:"r",topic:"focus",selector:null,does:"the keys into this pane's frame: Tab or ↑↓ walk its verbs, Enter presses, ← or Esc leaves"},{key:"&",topic:"pane",selector:null,does:"close every pane on the stage (tmux kill-window)"},{key:"[",topic:"console",selector:null,does:"the console's scrollback takes the keys (tmux)"},{key:"O",topic:"focus",selector:null,does:"focus the previous pane"},{key:"←↑↓→",topic:"focus",selector:null,does:"focus the pane in that direction (tmux)"},{key:":",topic:"console",selector:null,does:"the command line (tmux)"},{key:"?",topic:"console",selector:null,does:"this table"}];function rS(t){let e=0;for(const s of t.panes_shown())Nn(t,s,".drawer-close")&&(e+=1);return`closed ${e} pane${e===1?"":"s"}`}function oS(){return["prefix chords — Ctrl-B opens the focused pane's drawer; one key then presses one capsule",..._n.map(t=>` ${t.key.padEnd(6)} ${t.does}`)," Tab walks the verbs; Enter fires; Esc closes the drawer","in a pane holding a listing, no prefix needed:"," ↑↓ move the row cursor (Home/End: first/last)"," Enter indicates the row (its verbs ride the frame); Enter again goes (opens, enters, folds open)"," → the keys into the frame, as Ctrl-B r"].join(`
|
|
94
94
|
`)}const ga=[],IB=[{subject:"pane",line:()=>"pane [@id|%n] split left|right|above|below · zoom · close · close all · bind unlinked|fs|viewer"},{subject:"pane claim",line:()=>`pane [@id|%n] claim ${["files",...Object.keys(Bn?.claims??{})].join("|")} · focus left|right|up|down|@id|last · flip · resize left|right|up|down [percent]`},{subject:"view",line:()=>`${`view ${["files",...Object.keys(Bn?.views??{})].join("|")}`.padEnd(28)}(the gutter givens, workspace scope)`},{subject:"file",line:()=>"file [@id] home|back|download|delete · follow · root · list|cards|preview · sort <col> [asc|desc] · filter <text>|off"},{subject:"header",line:()=>"header stats|dag|away|restore"}],CB=["console open|close|toggle|zoom|height <px>","back (contextual back — exactly Esc)","desktop save|load|show|list|delete [name] · load <ChRIS file> · clear · share","attach [--reveal] (how to reach THIS session from a terminal or another browser)","stratus oci [read|manage] (through a porter: your cloud session, on your filed credentials; bare, it asks which)","chris (through a porter: back to your ChRIS session)","argus verbs (this table; the long form is docs/argus-lang.adoc)","argus keys (the prefix chords: one key, one drawer verb)","help pane|keys|verbs (the KEYS pane on the stage; keys and verbs print the tables here; bare help is the session's)","notes pane (what the installed releases changed, as a pane; bare notes prints it here)","capacity pane [<family>] (what the region has free for a family, as a pane; bare capacity prints it here)","trek [--seed <n>] (the bridge takes the screen: BSD trek played from its controls; --credits, --help and --version are the session's)"],RB=new Set(["--credits","--help","-h","--version","-V"]);function aS(t){const e=t.trim().split(/\s+/);return e[0]!=="trek"?!1:!e.slice(1).some(s=>RB.has(s))}function lS(){const t=[];for(const e of IB){t.push(e.line());for(const s of Bn?.lines??[])s.after===e.subject&&t.push(s.line)}t.push(...CB),ga.splice(0,ga.length,...t)}function z0(t){Bn=t;for(const[e,s]of Object.entries(t.subjects))Id.add(e),s!==null&&(Fg[e]=s);for(const e of t.chords){const s=_n.findIndex(r=>r.key===e.after),{after:i,...n}=e;_n.splice(s===-1?_n.length:s+1+t.chords.filter(r=>r.after===e.after&&t.chords.indexOf(r)<t.chords.indexOf(e)).length,0,n)}lS()}lS();function kB(t,e){const s=new URL(window.location.href),i=s.searchParams.get("token")??"",n=i===""?"":e?i:"•".repeat(8),r=i===""?s.origin+s.pathname:`${s.origin}${s.pathname}?token=${n}`,o=t.identity_get(),a=/^(127\.|\[?::1\]?$|localhost$)/.test(s.hostname),l=["attach — this session, from anywhere that can reach it"];return o!==null&&o!==""&&l.push(` identity ${o}`),l.push(""),l.push(" this machine chell --remote"),l.push(` another machine chell --remote --attach "${r}"`),l.push(` another browser ${r}`),l.push(""),a&&(l.push(" bound to loopback — another machine cannot reach this session;"),l.push(" relaunch the daemon with CALYPSO_BIND=0.0.0.0 to change that")),i===""?(l.push(" this page carries no token: it was opened without one, and a"),l.push(" second surface cannot attach with what is on screen")):e?l.push(" revealed — anyone who reads this line holds the session"):(l.push(" the token is masked — `attach --reveal` prints it. It is a bearer"),l.push(" credential with no expiry: treat the line like a password")),l.join(`
|
|
95
95
|
`)}async function bh(t,e){const s=AB(e);if(s===null)return null;const{subject:i,words:n}=s,r=(n[0]??"").toLowerCase(),o=(n[1]??"").toLowerCase();if(i==="argus")return r==="keys"?oS():ga.join(`
|
|
@@ -102,7 +102,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
102
102
|
`)[0]})`}if(e==="delete")return window.localStorage.removeItem(Ao+s),`deleted '${s}' (local; a CFS copy, if any, is yours to rm)`;if(e==="load"){if(s.includes("/")){const n=await t.session_run(`cat ${s}`);if(n.trim()===""||/No such|cannot|error/i.test(n.split(`
|
|
103
103
|
`)[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}
|
|
104
104
|
${await dp(t,n,o?null:s)}`}let i=window.localStorage.getItem(Ao+s);if(i===null){const n=await t.session_run(`cat ${w0}/${s}.desk`);n.trim().length>0&&!n.includes("No such")&&!n.toLowerCase().includes("error")&&(i=n)}return i===null?`(no desktop '${s}')`:`loaded '${s}'
|
|
105
|
-
${await dp(t,i,null)}`}return"desktop save|load|show|list|delete [name] · load <ChRIS file> · clear · share"}const Ji={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 in this tenancy, found by their tag: each one's condition or last finished build step, its address and what it costs per hour. One with a step gone wrong shows in red; one torn down reads GONE until what is left of it is removed. Opening the tile, or a Trusted 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."},cloud:{text:"Your cloud session: the tenancy and its Trusted Domains. Entering asks which way in:",list:["READ: look only; nothing outside this host changes","MANAGE: build, tear down and spend, each after its own lock and the name typed back"],tail:"Which it is stays fixed for that session; enter again to change it."},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 LB(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??Ji.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:Ji.panes,enter:()=>t.panes_open()},h={key:"help",name:"KEYS",hue:"--butter",numeral:"",figures:[{text:`${_n.length} KEYS`},{text:`${ga.length} VERBS`}],rows:_n.slice(0,5).map(m=>({text:`${m.key.padEnd(6)} ${m.does}`,open:()=>t.keys_open()})),verb:"OPEN THE KEYS",about:Ji.keys,enter:()=>t.keys_open()},d=s?.releases[0],u=d?.entries.flatMap(m=>m.changes.filter(v=>!v.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:Ji.notes,enter:()=>t.notes_open()},f={key:"console",name:"CONSOLE",hue:"--daybreak",numeral:"5",figures:[],rows:[],verb:"OPEN THE CONSOLE",about:Ji.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 Cd(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 cS(t,e){return`cd "${t}"; ${e}`}function FB(t){return/^[A-Za-z0-9_./:@+=,-]+$/.test(t)?t:`"${t.replace(/(["\\])/g,"\\$1")}"`}function hS(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 x0(t){return t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/\\(["\\])/g,"$1"):t}function dS(t){return t.startsWith("-")&&t!=="-"&&!/^-\d/.test(t)}function UB(t,e){const s=hS(Cd(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||dS(r)?!0:x0(r)}if(n.startsWith(`${e}=`))return x0(n.slice(e.length+1))}return null}function O0(t,e,s){const i=Cd(t),n=hS(i.args),r=[];let o=!1;const a=s===null||s===""?[]:s===!0?[e]:[e,FB(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&&!dS(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 $B(t){return/\bfeed_title=/.test(Cd(t).tail)}function jB(t,e){return`${t} -- feed_title="${e.replace(/(["\\])/g,"\\$1")}"`}function uS(t){return Cd(t).head.replace(/^.*;\s*/,"").trim()}function HB(t,e,s){return/^[A-Za-z0-9_-]+$/.test(t)&&s.filter(n=>n===t).length===1?t:`@${e}`}const fS={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}}]},pS={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]}}]},mS={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}}]},ml={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}}]},Jr={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}}]},gS={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}}]},_S={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 Ur(t){return{listing:t.listing,visit(e){return e(t)}}}Ur(fS),Ur(pS),Ur(mS),Ur(ml),Ur(Jr),Ur(_S),Ur(gS);function hn(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 To={fold:"5.2em",patient:"13em",mrn:"7.5em"};function VB(t){return{inCube:t.pulled===!0,folderKnown:t.folderPath!==void 0,addressable:t.vfsPath!==void 0}}function E0(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 Sn(t){const e=VB(t),s=i=>hn(Jr,i).offered(e);return{gather:s("gather"),image:s("image"),dir:s("dir"),pull:s("pull")}}function qB(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 A0=[{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"}],gc={running:"RETRIEVING",done:"✓ PULLED",error:"✗ ERROR",unconfirmed:"? UNCONFIRMED",stalled:"STALLED",queued:"QUEUED",idle:"NOT RETRIEVED"},KB="--fresh",T0="--anon",YB=/\s*--anon\b/,XB=["pacs-f-name","pacs-f-mrn","pacs-f-accession","pacs-f-date"],D0=/\s*--fresh\b/;function I0(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 Xh=new Map;function bS(t,e){const s=Xh.get(t)??new Set;s.add(e),Xh.set(t,s)}const MS=new Map;function vS(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=gc.idle,t.append(Vh({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=gc[e.status]??e.status.toUpperCase();return}const i=e.total!==void 0?` ${e.current??0}/${e.total}`:"",n=ZB(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"?gc.queued:`${gc.running}${i}`,t.append(r,s)}function ZB(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 JB(t,e){return t.pulled===!0&&e.status!=="done"&&e.status!=="running"&&e.status!=="queued"}function QB(t,e){const s=Xh.get(t);if(s!==void 0){for(const i of[...s]){if(!i.isConnected){s.delete(i);continue}e(i)}s.size===0&&Xh.delete(t)}}function eG(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",bS(t.seriesUID,e);const n=MS.get(t.seriesUID);return n!==void 0&&vS(e,n),e}function wS(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 tG{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=_c(e,"#pacs-command"),this.results=Ki(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 Vn({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?xk(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:ia(i=>i.studies.map((n,r)=>({study:n,key:C0(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:ia(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:()=>k0("NO STUDIES FOUND")}),e.style.setProperty("--roster-cols",this.listing.template_get(1)),this.listing.rows_set([],{field:"pacs"});for(const{id:i}of A0){const n=_c(e,`#${i}`);n.addEventListener("input",()=>this.command_regenerate()),n.addEventListener("keydown",r=>{r.key==="Enter"&&(r.preventDefault(),this.query_run())})}this.serverCell=Ki(e,"#pacs-f-server"),this.serverStrip=Ki(e,"#pacs-server-strip"),this.serverCell.addEventListener("click",()=>this.serverStrip_toggle()),this.serverCell_sync(),this.provenance=Ki(e,"#pacs-provenance"),this.anonPill=Ki(e,"#pacs-anon"),this.revealPill=Ki(e,"#pacs-reveal"),this.anonPill.addEventListener("click",()=>this.anon_set(!this.anon)),this.revealPill.addEventListener("click",()=>this.reveal_set(!this.revealed)),this.run=Ki(e,"#pacs-run"),this.run.addEventListener("click",()=>this.query_run(this.replayed)),this.command.addEventListener("keydown",i=>{i.key==="Enter"&&this.query_run()}),Ki(e,"#pacs-export").addEventListener("click",()=>this.answer_export()),Ki(e,"#pacs-gather-shown").addEventListener("click",()=>this.shown_gather()),Ki(e,"#pacs-pull-shown").addEventListener("click",()=>this.shown_pull())}patientTraits_declare(){return[{key:"fold",label:"",className:"pacs-fold",capped:!1,width:To.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:To.patient,cell:e=>e.patient.patientName||"(unknown)"},{key:"mrn",label:"MRN",className:"pacs-patient-mrn",width:To.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?"—":I0(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 hc(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(Vh(hc(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:To.fold,cell:()=>{const e=document.createElement("span");return e.className="pacs-fold",e}},{key:"patient",label:"PATIENT",className:"pacs-study-patient",width:To.patient,cell:e=>e.study.patientName||"(unknown)"},{key:"mrn",label:"MRN",className:"pacs-study-mrn",width:To.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:hn(ml,"pullStudy").label({addressable:!0,allInCube:!1}),offered:e=>hn(ml,"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:hn(ml,"gather").label({addressable:!0,allInCube:!1,anyInCube:!0}),offered:e=>e.study.series.some(s=>Sn(s).gather),run:e=>{const s=e.study.series.filter(n=>Sn(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:hn(ml,"process").label({addressable:!0,allInCube:!0}),offered:e=>E0(e.study)!==null,run:e=>{const s=E0(e.study);s!==null&&this.handlers.process_open(s)}}]}studyProgress_compute(e){return hc(e.study.series.map(s=>this.seriesProgress.get(s.seriesUID)??{done:0,total:0}))}traits_declare(){return wS(e=>e.series,e=>this.badge_build(e))}actions_declare(){return[{label:hn(Jr,"gather").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>Sn(e.series).gather,selected:e=>this.handlers.gathered_is(e.series.seriesUID),run:e=>this.gather_note(e.study,e.series)},{label:hn(Jr,"image").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>Sn(e.series).image,selected:e=>e.series.folderPath!==void 0&&(this.litFolders.get(R0(e.series.folderPath))?.viewer??!1),run:e=>{e.series.folderPath!==void 0&&this.handlers.image_open(e.series.folderPath)}},{label:hn(Jr,"dir").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>Sn(e.series).dir,selected:e=>e.series.folderPath!==void 0&&(this.litFolders.get(R0(e.series.folderPath))?.browser??!1),run:e=>{e.series.folderPath!==void 0&&this.handlers.dir_open(e.series.folderPath)}},{label:hn(Jr,"process").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>Sn(e.series).image,run:e=>{e.series.folderPath!==void 0&&this.handlers.process_open(e.series.folderPath)}},{label:hn(Jr,"pull").label({inCube:!1,folderKnown:!1,addressable:!0}),offered:e=>Sn(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 A0){const o=_c(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?` ${T0}`:"";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()} ${T0}`.trim():this.command.value.replace(YB,"").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 XB)_c(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(k0("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&&!D0.test(this.command.value)&&(this.command.value=`${this.command.value.trim()} ${KB}`);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(D0,"").trimEnd();return}const s=e?.answeredAt??"",i=I0(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===zk){const n=yk.safeParse(e.model.data);n.success&&this.servers_take(n.data.servers);return}if(e.model?.kind!==Sk)return;const i=vk.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&&qB(this.model,e.itemId,e.current??e.total,e.path)&&this.results_repaint()}badgeState_set(e,s){this.badgeStates.set(e,s),MS.set(e,s),this.seriesProgress.set(e,iG(s,this.seriesProgress.get(e))),QB(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 bS(e.seriesUID,s),this.badge_paint(s,this.badgeStates.get(e.seriesUID)??{status:"idle"}),s}badge_paint(e,s){vS(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,[C0(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&&JB(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,sG(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(Vh(hc(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})=>Sn(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=>Sn(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 C0(t,e){return t.studyUID??`study-${e}`}function R0(t){return t.replace(/\/$/,"")}function sG(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 iG(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 Ki(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`PACS workspace is missing '${e}'`);return s}function _c(t,e){const s=Ki(t,e);if(!(s instanceof HTMLInputElement))throw new Error(`'${e}' is not an input`);return s}function k0(t){const e=document.createElement("p");return e.className="files-empty",e.textContent=t,e}class nG{result;handlers;constructor(e,s){this.handlers=s,this.result=Fa(e,".empty-result"),ii(this.result);const i=Fa(e,".empty-prompt");i.addEventListener("keydown",n=>{n.key==="Enter"&&i.value.trim().length>0&&(this.line_run(i.value.trim()),i.value="")}),Fa(e,".empty-go-files").addEventListener("click",()=>{this.line_run("ls .")}),Fa(e,".empty-go-dag").addEventListener("click",()=>{this.line_run("proc feeds")}),Fa(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
|
+
${await dp(t,i,null)}`}return"desktop save|load|show|list|delete [name] · load <ChRIS file> · clear · share"}const Ji={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."},clusters:{text:"The OpenShift clusters in this tenancy, found by their tag: each one's condition or last finished build step, its address and what it costs per hour. One with a step gone wrong shows in red; one torn down reads GONE until what is left of it is removed. Opening the tile, or a cluster on it, opens the 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 clusters use, zone by zone: the cores and memory a new cluster 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."},cloud:{text:"Your cloud session: the tenancy and what is built in it. Entering asks which way in:",list:["READ: look only; nothing outside this host changes","MANAGE: build, tear down and spend, each after its own lock and the name typed back"],tail:"Which it is stays fixed for that session; enter again to change it."},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 LB(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??Ji.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:Ji.panes,enter:()=>t.panes_open()},h={key:"help",name:"KEYS",hue:"--butter",numeral:"",figures:[{text:`${_n.length} KEYS`},{text:`${ga.length} VERBS`}],rows:_n.slice(0,5).map(m=>({text:`${m.key.padEnd(6)} ${m.does}`,open:()=>t.keys_open()})),verb:"OPEN THE KEYS",about:Ji.keys,enter:()=>t.keys_open()},d=s?.releases[0],u=d?.entries.flatMap(m=>m.changes.filter(v=>!v.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:Ji.notes,enter:()=>t.notes_open()},f={key:"console",name:"CONSOLE",hue:"--daybreak",numeral:"5",figures:[],rows:[],verb:"OPEN THE CONSOLE",about:Ji.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 Cd(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 cS(t,e){return`cd "${t}"; ${e}`}function FB(t){return/^[A-Za-z0-9_./:@+=,-]+$/.test(t)?t:`"${t.replace(/(["\\])/g,"\\$1")}"`}function hS(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 x0(t){return t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/\\(["\\])/g,"$1"):t}function dS(t){return t.startsWith("-")&&t!=="-"&&!/^-\d/.test(t)}function UB(t,e){const s=hS(Cd(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||dS(r)?!0:x0(r)}if(n.startsWith(`${e}=`))return x0(n.slice(e.length+1))}return null}function O0(t,e,s){const i=Cd(t),n=hS(i.args),r=[];let o=!1;const a=s===null||s===""?[]:s===!0?[e]:[e,FB(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&&!dS(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 $B(t){return/\bfeed_title=/.test(Cd(t).tail)}function jB(t,e){return`${t} -- feed_title="${e.replace(/(["\\])/g,"\\$1")}"`}function uS(t){return Cd(t).head.replace(/^.*;\s*/,"").trim()}function HB(t,e,s){return/^[A-Za-z0-9_-]+$/.test(t)&&s.filter(n=>n===t).length===1?t:`@${e}`}const fS={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}}]},pS={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]}}]},mS={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}}]},ml={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}}]},Jr={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}}]},gS={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}}]},_S={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 Ur(t){return{listing:t.listing,visit(e){return e(t)}}}Ur(fS),Ur(pS),Ur(mS),Ur(ml),Ur(Jr),Ur(_S),Ur(gS);function hn(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 To={fold:"5.2em",patient:"13em",mrn:"7.5em"};function VB(t){return{inCube:t.pulled===!0,folderKnown:t.folderPath!==void 0,addressable:t.vfsPath!==void 0}}function E0(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 Sn(t){const e=VB(t),s=i=>hn(Jr,i).offered(e);return{gather:s("gather"),image:s("image"),dir:s("dir"),pull:s("pull")}}function qB(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 A0=[{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"}],gc={running:"RETRIEVING",done:"✓ PULLED",error:"✗ ERROR",unconfirmed:"? UNCONFIRMED",stalled:"STALLED",queued:"QUEUED",idle:"NOT RETRIEVED"},KB="--fresh",T0="--anon",YB=/\s*--anon\b/,XB=["pacs-f-name","pacs-f-mrn","pacs-f-accession","pacs-f-date"],D0=/\s*--fresh\b/;function I0(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 Xh=new Map;function bS(t,e){const s=Xh.get(t)??new Set;s.add(e),Xh.set(t,s)}const MS=new Map;function vS(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=gc.idle,t.append(Vh({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=gc[e.status]??e.status.toUpperCase();return}const i=e.total!==void 0?` ${e.current??0}/${e.total}`:"",n=ZB(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"?gc.queued:`${gc.running}${i}`,t.append(r,s)}function ZB(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 JB(t,e){return t.pulled===!0&&e.status!=="done"&&e.status!=="running"&&e.status!=="queued"}function QB(t,e){const s=Xh.get(t);if(s!==void 0){for(const i of[...s]){if(!i.isConnected){s.delete(i);continue}e(i)}s.size===0&&Xh.delete(t)}}function eG(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",bS(t.seriesUID,e);const n=MS.get(t.seriesUID);return n!==void 0&&vS(e,n),e}function wS(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 tG{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=_c(e,"#pacs-command"),this.results=Ki(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 Vn({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?xk(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:ia(i=>i.studies.map((n,r)=>({study:n,key:C0(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:ia(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:()=>k0("NO STUDIES FOUND")}),e.style.setProperty("--roster-cols",this.listing.template_get(1)),this.listing.rows_set([],{field:"pacs"});for(const{id:i}of A0){const n=_c(e,`#${i}`);n.addEventListener("input",()=>this.command_regenerate()),n.addEventListener("keydown",r=>{r.key==="Enter"&&(r.preventDefault(),this.query_run())})}this.serverCell=Ki(e,"#pacs-f-server"),this.serverStrip=Ki(e,"#pacs-server-strip"),this.serverCell.addEventListener("click",()=>this.serverStrip_toggle()),this.serverCell_sync(),this.provenance=Ki(e,"#pacs-provenance"),this.anonPill=Ki(e,"#pacs-anon"),this.revealPill=Ki(e,"#pacs-reveal"),this.anonPill.addEventListener("click",()=>this.anon_set(!this.anon)),this.revealPill.addEventListener("click",()=>this.reveal_set(!this.revealed)),this.run=Ki(e,"#pacs-run"),this.run.addEventListener("click",()=>this.query_run(this.replayed)),this.command.addEventListener("keydown",i=>{i.key==="Enter"&&this.query_run()}),Ki(e,"#pacs-export").addEventListener("click",()=>this.answer_export()),Ki(e,"#pacs-gather-shown").addEventListener("click",()=>this.shown_gather()),Ki(e,"#pacs-pull-shown").addEventListener("click",()=>this.shown_pull())}patientTraits_declare(){return[{key:"fold",label:"",className:"pacs-fold",capped:!1,width:To.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:To.patient,cell:e=>e.patient.patientName||"(unknown)"},{key:"mrn",label:"MRN",className:"pacs-patient-mrn",width:To.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?"—":I0(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 hc(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(Vh(hc(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:To.fold,cell:()=>{const e=document.createElement("span");return e.className="pacs-fold",e}},{key:"patient",label:"PATIENT",className:"pacs-study-patient",width:To.patient,cell:e=>e.study.patientName||"(unknown)"},{key:"mrn",label:"MRN",className:"pacs-study-mrn",width:To.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:hn(ml,"pullStudy").label({addressable:!0,allInCube:!1}),offered:e=>hn(ml,"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:hn(ml,"gather").label({addressable:!0,allInCube:!1,anyInCube:!0}),offered:e=>e.study.series.some(s=>Sn(s).gather),run:e=>{const s=e.study.series.filter(n=>Sn(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:hn(ml,"process").label({addressable:!0,allInCube:!0}),offered:e=>E0(e.study)!==null,run:e=>{const s=E0(e.study);s!==null&&this.handlers.process_open(s)}}]}studyProgress_compute(e){return hc(e.study.series.map(s=>this.seriesProgress.get(s.seriesUID)??{done:0,total:0}))}traits_declare(){return wS(e=>e.series,e=>this.badge_build(e))}actions_declare(){return[{label:hn(Jr,"gather").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>Sn(e.series).gather,selected:e=>this.handlers.gathered_is(e.series.seriesUID),run:e=>this.gather_note(e.study,e.series)},{label:hn(Jr,"image").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>Sn(e.series).image,selected:e=>e.series.folderPath!==void 0&&(this.litFolders.get(R0(e.series.folderPath))?.viewer??!1),run:e=>{e.series.folderPath!==void 0&&this.handlers.image_open(e.series.folderPath)}},{label:hn(Jr,"dir").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>Sn(e.series).dir,selected:e=>e.series.folderPath!==void 0&&(this.litFolders.get(R0(e.series.folderPath))?.browser??!1),run:e=>{e.series.folderPath!==void 0&&this.handlers.dir_open(e.series.folderPath)}},{label:hn(Jr,"process").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>Sn(e.series).image,run:e=>{e.series.folderPath!==void 0&&this.handlers.process_open(e.series.folderPath)}},{label:hn(Jr,"pull").label({inCube:!1,folderKnown:!1,addressable:!0}),offered:e=>Sn(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 A0){const o=_c(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?` ${T0}`:"";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()} ${T0}`.trim():this.command.value.replace(YB,"").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 XB)_c(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(k0("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&&!D0.test(this.command.value)&&(this.command.value=`${this.command.value.trim()} ${KB}`);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(D0,"").trimEnd();return}const s=e?.answeredAt??"",i=I0(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===zk){const n=yk.safeParse(e.model.data);n.success&&this.servers_take(n.data.servers);return}if(e.model?.kind!==Sk)return;const i=vk.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&&qB(this.model,e.itemId,e.current??e.total,e.path)&&this.results_repaint()}badgeState_set(e,s){this.badgeStates.set(e,s),MS.set(e,s),this.seriesProgress.set(e,iG(s,this.seriesProgress.get(e))),QB(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 bS(e.seriesUID,s),this.badge_paint(s,this.badgeStates.get(e.seriesUID)??{status:"idle"}),s}badge_paint(e,s){vS(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,[C0(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&&JB(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,sG(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(Vh(hc(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})=>Sn(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=>Sn(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 C0(t,e){return t.studyUID??`study-${e}`}function R0(t){return t.replace(/\/$/,"")}function sG(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 iG(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 Ki(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`PACS workspace is missing '${e}'`);return s}function _c(t,e){const s=Ki(t,e);if(!(s instanceof HTMLInputElement))throw new Error(`'${e}' is not an input`);return s}function k0(t){const e=document.createElement("p");return e.className="files-empty",e.textContent=t,e}class nG{result;handlers;constructor(e,s){this.handlers=s,this.result=Fa(e,".empty-result"),ii(this.result);const i=Fa(e,".empty-prompt");i.addEventListener("keydown",n=>{n.key==="Enter"&&i.value.trim().length>0&&(this.line_run(i.value.trim()),i.value="")}),Fa(e,".empty-go-files").addEventListener("click",()=>{this.line_run("ls .")}),Fa(e,".empty-go-dag").addEventListener("click",()=>{this.line_run("proc feeds")}),Fa(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(`
|
|
106
106
|
`);this.result.textContent=rG(i)||"(no output)"}}function Fa(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`empty pane template is missing ${e}`);return s}function rG(t){return t.replace(/\x1b\[[0-9;:]*[A-Za-z]/g,"")}class oG{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 aG(t,e){t.route_add("console",[Dk.view],i=>{const n=Tk.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",yr.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=Sg.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(ea.series,"image",(i,n)=>{const r=e.image_get(e.pane_replace(i,"image"));for(const o of n){if(o.model?.kind!==ea.series)continue;const a=bz.safeParse(o.model.data);a.success&&r?.series_show(a.data)}}),t.claim_add(ea.tags,"tags",(i,n)=>{const r=e.tags_get(e.pane_replace(i,"tags"));for(const o of n){if(o.model?.kind!==ea.tags)continue;const a=_z.safeParse(o.model.data);a.success&&r?.model_show(a.data)}})}const Ug="185",lG=0,N0=1,cG=2,Mh=1,hG=2,gl=3,Nr=0,ni=1,Gn=2,Un=0,lo=1,Br=2,B0=3,G0=4,dG=5,Qr=100,uG=101,fG=102,pG=103,mG=104,gG=200,_G=201,bG=202,MG=203,up=204,fp=205,vG=206,wG=207,yG=208,zG=209,SG=210,xG=211,OG=212,EG=213,AG=214,pp=0,mp=1,gp=2,_a=3,_p=4,bp=5,Mp=6,vp=7,yS=0,TG=1,DG=2,bn=0,zS=1,SS=2,xS=3,OS=4,ES=5,AS=6,TS=7,DS=300,go=301,ba=302,_u=303,bu=304,Rd=306,wp=1e3,Pn=1001,yp=1002,ks=1003,IG=1004,bc=1005,Fs=1006,Mu=1007,to=1008,yi=1009,IS=1010,CS=1011,Fl=1012,$g=1013,yn=1014,en=1015,qn=1016,jg=1017,Hg=1018,Ul=1020,RS=35902,kS=35899,NS=1021,BS=1022,tn=1023,Kn=1026,so=1027,Vg=1028,qg=1029,_o=1030,Kg=1031,Yg=1033,vh=33776,wh=33777,yh=33778,zh=33779,zp=35840,Sp=35841,xp=35842,Op=35843,Ep=36196,Ap=37492,Tp=37496,Dp=37488,Ip=37489,Zh=37490,Cp=37491,Rp=37808,kp=37809,Np=37810,Bp=37811,Gp=37812,Pp=37813,Lp=37814,Wp=37815,Fp=37816,Up=37817,$p=37818,jp=37819,Hp=37820,Vp=37821,qp=36492,Kp=36494,Yp=36495,Xp=36283,Zp=36284,Jh=36285,Jp=36286,CG=3200,Qp=0,RG=1,gr="",Ti="srgb",Qh="srgb-linear",ed="linear",Rt="srgb",Do=7680,P0=519,kG=512,NG=513,BG=514,Xg=515,GG=516,PG=517,Zg=518,LG=519,em=35044,L0="300 es",mn=2e3,$l=2001;function WG(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function td(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function FG(){const t=td("canvas");return t.style.display="block",t}const W0={};function sd(...t){const e="THREE."+t.shift();console.log(e,...t)}function GS(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 et(...t){t=GS(t);const e="THREE."+t.shift();{const s=t[0];s&&s.isStackTrace?console.warn(s.getError(e)):console.warn(e,...t)}}function mt(...t){t=GS(t);const e="THREE."+t.shift();{const s=t[0];s&&s.isStackTrace?console.error(s.getError(e)):console.error(e,...t)}}function na(...t){const e=t.join(" ");e in W0||(W0[e]=!0,et(...t))}function UG(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 $G={[pp]:mp,[gp]:Mp,[_p]:vp,[_a]:bp,[mp]:pp,[Mp]:gp,[vp]:_p,[bp]:_a};class vo{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 Gs=["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"],vu=Math.PI/180,tm=180/Math.PI;function Er(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Gs[t&255]+Gs[t>>8&255]+Gs[t>>16&255]+Gs[t>>24&255]+"-"+Gs[e&255]+Gs[e>>8&255]+"-"+Gs[e>>16&15|64]+Gs[e>>24&255]+"-"+Gs[s&63|128]+Gs[s>>8&255]+"-"+Gs[s>>16&255]+Gs[s>>24&255]+Gs[i&255]+Gs[i>>8&255]+Gs[i>>16&255]+Gs[i>>24&255]).toLowerCase()}function _t(t,e,s){return Math.max(e,Math.min(s,t))}function jG(t,e){return(t%e+e)%e}function wu(t,e,s){return(1-s)*t+s*e}function pn(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 Bt(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 C_=class C_{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=_t(this.x,e.x,s.x),this.y=_t(this.y,e.y,s.y),this}clampScalar(e,s){return this.x=_t(this.x,e,s),this.y=_t(this.y,e,s),this}clampLength(e,s){const i=this.length();return this.divideScalar(i||1).multiplyScalar(_t(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(_t(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}};C_.prototype.isVector2=!0;let st=C_;class wo{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 v=Math.acos(g),y=Math.sin(v);m=Math.sin(m*v)/y,a=Math.sin(a*v)/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 v=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=v,c*=v,h*=v,d*=v}}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:et("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(_t(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 R_=class R_{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(F0.setFromEuler(e))}applyAxisAngle(e,s){return this.applyQuaternion(F0.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=_t(this.x,e.x,s.x),this.y=_t(this.y,e.y,s.y),this.z=_t(this.z,e.z,s.z),this}clampScalar(e,s){return this.x=_t(this.x,e,s),this.y=_t(this.y,e,s),this.z=_t(this.z,e,s),this}clampLength(e,s){const i=this.length();return this.divideScalar(i||1).multiplyScalar(_t(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 yu.copy(this).projectOnVector(e),this.sub(yu)}reflect(e){return this.sub(yu.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(_t(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}};R_.prototype.isVector3=!0;let F=R_;const yu=new F,F0=new wo,k_=class k_{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],v=n[1],y=n[4],b=n[7],w=n[2],z=n[5],x=n[8];return r[0]=o*_+a*v+l*w,r[3]=o*g+a*y+l*z,r[6]=o*m+a*b+l*x,r[1]=c*_+h*v+d*w,r[4]=c*g+h*y+d*z,r[7]=c*m+h*b+d*x,r[2]=u*_+p*v+f*w,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 na("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(zu.makeScale(e,s)),this}rotate(e){return na("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(zu.makeRotation(-e)),this}translate(e,s){return na("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(zu.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)}};k_.prototype.isMatrix3=!0;let rt=k_;const zu=new rt,U0=new rt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),$0=new rt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function HG(){const t={enabled:!0,workingColorSpace:Qh,spaces:{},convert:function(n,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===Rt&&(n.r=$n(n.r),n.g=$n(n.g),n.b=$n(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===Rt&&(n.r=ra(n.r),n.g=ra(n.g),n.b=ra(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===gr?ed: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 na("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(n,r)},toWorkingColorSpace:function(n,r){return na("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({[Qh]:{primaries:e,whitePoint:i,transfer:ed,toXYZ:U0,fromXYZ:$0,luminanceCoefficients:s,workingColorSpaceConfig:{unpackColorSpace:Ti},outputColorSpaceConfig:{drawingBufferColorSpace:Ti}},[Ti]:{primaries:e,whitePoint:i,transfer:Rt,toXYZ:U0,fromXYZ:$0,luminanceCoefficients:s,outputColorSpaceConfig:{drawingBufferColorSpace:Ti}}}),t}const gt=HG();function $n(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function ra(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Io;class VG{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=td("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=td("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]=$n(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($n(s[i]/255)*255):s[i]=$n(s[i]);return{data:s,width:e.width,height:e.height}}else return et("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let qG=0;class Jg{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:qG++}),this.uuid=Er(),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(Su(n[o].image)):r.push(Su(n[o]))}else r=Su(n);i.url=r}return s||(e.images[this.uuid]=i),i}}function Su(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?VG.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(et("Texture: Unable to serialize Texture."),{})}let KG=0;const xu=new F;class Us extends vo{constructor(e=Us.DEFAULT_IMAGE,s=Us.DEFAULT_MAPPING,i=Pn,n=Pn,r=Fs,o=to,a=tn,l=yi,c=Us.DEFAULT_ANISOTROPY,h=gr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:KG++}),this.uuid=Er(),this.name="",this.source=new Jg(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 st(0,0),this.repeat=new st(1,1),this.center=new st(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(xu).x}get height(){return this.source.getSize(xu).y}get depth(){return this.source.getSize(xu).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){et(`Texture.setValues(): parameter '${s}' has value of undefined.`);continue}const n=this[s];if(n===void 0){et(`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!==DS)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case wp:e.x=e.x-Math.floor(e.x);break;case Pn:e.x=e.x<0?0:1;break;case yp: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 wp:e.y=e.y-Math.floor(e.y);break;case Pn:e.y=e.y<0?0:1;break;case yp: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++}}Us.DEFAULT_IMAGE=null;Us.DEFAULT_MAPPING=DS;Us.DEFAULT_ANISOTROPY=1;const N_=class N_{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,w=(m+1)/2,z=(h+u)/4,x=(d+_)/4,M=(f+g)/4;return y>b&&y>w?y<.01?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(y),n=z/i,r=x/i):b>w?b<.01?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(b),i=z/n,r=M/n):w<.01?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(w),i=x/r,n=M/r),this.set(i,n,r,s),this}let v=Math.sqrt((g-f)*(g-f)+(d-_)*(d-_)+(u-h)*(u-h));return Math.abs(v)<.001&&(v=1),this.x=(g-f)/v,this.y=(d-_)/v,this.z=(u-h)/v,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=_t(this.x,e.x,s.x),this.y=_t(this.y,e.y,s.y),this.z=_t(this.z,e.z,s.z),this.w=_t(this.w,e.w,s.w),this}clampScalar(e,s){return this.x=_t(this.x,e,s),this.y=_t(this.y,e,s),this.z=_t(this.z,e,s),this.w=_t(this.w,e,s),this}clampLength(e,s){const i=this.length();return this.divideScalar(i||1).multiplyScalar(_t(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}};N_.prototype.isVector4=!0;let Zt=N_;class YG extends vo{constructor(e=1,s=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Fs,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 Zt(0,0,e,s),this.scissorTest=!1,this.viewport=new Zt(0,0,e,s),this.textures=[];const n={width:e,height:s,depth:i.depth},r=new Us(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:Fs,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 Jg(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 Mn extends YG{constructor(e=1,s=1,i={}){super(e,s,i),this.isWebGLRenderTarget=!0}}class PS extends Us{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=ks,this.minFilter=ks,this.wrapR=Pn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class XG extends Us{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=ks,this.minFilter=ks,this.wrapR=Pn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const wd=class wd{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 wd().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/Co.setFromMatrixColumn(e,0).length(),r=1/Co.setFromMatrixColumn(e,1).length(),o=1/Co.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(ZG,e,JG)}lookAt(e,s,i){const n=this.elements;return ui.subVectors(e,s),ui.lengthSq()===0&&(ui.z=1),ui.normalize(),er.crossVectors(i,ui),er.lengthSq()===0&&(Math.abs(i.z)===1?ui.x+=1e-4:ui.z+=1e-4,ui.normalize(),er.crossVectors(i,ui)),er.normalize(),Mc.crossVectors(ui,er),n[0]=er.x,n[4]=Mc.x,n[8]=ui.x,n[1]=er.y,n[5]=Mc.y,n[9]=ui.y,n[2]=er.z,n[6]=Mc.z,n[10]=ui.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],v=i[3],y=i[7],b=i[11],w=i[15],z=n[0],x=n[4],M=n[8],S=n[12],T=n[1],A=n[5],E=n[9],O=n[13],R=n[2],C=n[6],k=n[10],B=n[14],L=n[3],U=n[7],ee=n[11],X=n[15];return r[0]=o*z+a*T+l*R+c*L,r[4]=o*x+a*A+l*C+c*U,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*A+u*C+p*U,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+_*A+g*C+m*U,r[10]=f*M+_*E+g*k+m*ee,r[14]=f*S+_*O+g*B+m*X,r[3]=v*z+y*T+b*R+w*L,r[7]=v*x+y*A+b*C+w*U,r[11]=v*M+y*E+b*k+w*ee,r[15]=v*S+y*O+b*B+w*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],v=l*p-c*u,y=a*p-c*d,b=a*u-l*d,w=o*p-c*h,z=o*u-l*h,x=o*d-a*h;return s*(_*v-g*y+m*b)-i*(f*v-g*w+m*z)+n*(f*y-_*w+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],v=s*a-i*o,y=s*l-n*o,b=s*c-r*o,w=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,A=d*g-u*_,E=d*m-p*_,O=u*m-p*g,R=v*O-y*E+b*A+w*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*A)*C,e[1]=(n*E-i*O-r*A)*C,e[2]=(_*x-g*z+m*w)*C,e[3]=(u*z-d*x-p*w)*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*v)*C,e[11]=(d*b-h*z-p*v)*C,e[12]=(a*S-o*A-l*M)*C,e[13]=(s*A-i*S+n*M)*C,e[14]=(_*y-f*w-g*v)*C,e[15]=(h*w-d*y+u*v)*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,v=l*c,y=l*h,b=l*d,w=i.x,z=i.y,x=i.z;return n[0]=(1-(_+m))*w,n[1]=(p+b)*w,n[2]=(f-y)*w,n[3]=0,n[4]=(p-b)*z,n[5]=(1-(u+m))*z,n[6]=(g+v)*z,n[7]=0,n[8]=(f+y)*x,n[9]=(g-v)*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=Co.set(n[0],n[1],n[2]).length();const a=Co.set(n[4],n[5],n[6]).length(),l=Co.set(n[8],n[9],n[10]).length();r<0&&(o=-o),ji.copy(this);const c=1/o,h=1/a,d=1/l;return ji.elements[0]*=c,ji.elements[1]*=c,ji.elements[2]*=c,ji.elements[4]*=h,ji.elements[5]*=h,ji.elements[6]*=h,ji.elements[8]*=d,ji.elements[9]*=d,ji.elements[10]*=d,s.setFromRotationMatrix(ji),i.x=o,i.y=a,i.z=l,this}makePerspective(e,s,i,n,r,o,a=mn,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===mn)f=-(o+r)/(o-r),_=-2*o*r/(o-r);else if(a===$l)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=mn,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===mn)f=-2/(o-r),_=-(o+r)/(o-r);else if(a===$l)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}};wd.prototype.isMatrix4=!0;let zt=wd;const Co=new F,ji=new zt,ZG=new F(0,0,0),JG=new F(1,1,1),er=new F,Mc=new F,ui=new F,j0=new zt,H0=new wo;class Gr{constructor(e=0,s=0,i=0,n=Gr.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(_t(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(-_t(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(_t(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(-_t(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(_t(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(-_t(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:et("Euler: .setFromRotationMatrix() encountered an unknown order: "+s)}return this._order=s,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,s,i){return j0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(j0,s,i)}setFromVector3(e,s=this._order){return this.set(e.x,e.y,e.z,s)}reorder(e){return H0.setFromEuler(this),this.setFromQuaternion(H0,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}}Gr.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 QG=0;const V0=new F,Ro=new wo,xn=new zt,vc=new F,Ua=new F,eP=new F,tP=new wo,q0=new F(1,0,0),K0=new F(0,1,0),Y0=new F(0,0,1),X0={type:"added"},sP={type:"removed"},ko={type:"childadded",child:null},Ou={type:"childremoved",child:null};class Qt extends vo{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:QG++}),this.uuid=Er(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Qt.DEFAULT_UP.clone();const e=new F,s=new Gr,i=new wo,n=new F(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 zt},normalMatrix:{value:new rt}}),this.matrix=new zt,this.matrixWorld=new zt,this.matrixAutoUpdate=Qt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Qt.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 Ro.setFromAxisAngle(e,s),this.quaternion.multiply(Ro),this}rotateOnWorldAxis(e,s){return Ro.setFromAxisAngle(e,s),this.quaternion.premultiply(Ro),this}rotateX(e){return this.rotateOnAxis(q0,e)}rotateY(e){return this.rotateOnAxis(K0,e)}rotateZ(e){return this.rotateOnAxis(Y0,e)}translateOnAxis(e,s){return V0.copy(e).applyQuaternion(this.quaternion),this.position.add(V0.multiplyScalar(s)),this}translateX(e){return this.translateOnAxis(q0,e)}translateY(e){return this.translateOnAxis(K0,e)}translateZ(e){return this.translateOnAxis(Y0,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(xn.copy(this.matrixWorld).invert())}lookAt(e,s,i){e.isVector3?vc.copy(e):vc.set(e,s,i);const n=this.parent;this.updateWorldMatrix(!0,!1),Ua.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?xn.lookAt(Ua,vc,this.up):xn.lookAt(vc,Ua,this.up),this.quaternion.setFromRotationMatrix(xn),n&&(xn.extractRotation(n.matrixWorld),Ro.setFromRotationMatrix(xn),this.quaternion.premultiply(Ro.invert()))}add(e){if(arguments.length>1){for(let s=0;s<arguments.length;s++)this.add(arguments[s]);return this}return e===this?(mt("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(X0),ko.child=e,this.dispatchEvent(ko),ko.child=null):mt("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(sP),Ou.child=e,this.dispatchEvent(Ou),Ou.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),xn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),xn.multiply(e.parent.matrixWorld)),e.applyMatrix4(xn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(X0),ko.child=e,this.dispatchEvent(ko),ko.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(Ua,e,eP),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ua,tP,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}}Qt.DEFAULT_UP=new F(0,1,0);Qt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Qt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class _l extends Qt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const iP={type:"move"};class Eu{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new _l,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 _l,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new F,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new F),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new _l,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new F,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new F,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(iP)))}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 _l;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[s.jointName]=i,e.add(i)}return e.joints[s.jointName]}}const LS={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},tr={h:0,s:0,l:0},wc={h:0,s:0,l:0};function Au(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=Ti){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,gt.colorSpaceToWorking(this,s),this}setRGB(e,s,i,n=gt.workingColorSpace){return this.r=e,this.g=s,this.b=i,gt.colorSpaceToWorking(this,n),this}setHSL(e,s,i,n=gt.workingColorSpace){if(e=jG(e,1),s=_t(s,0,1),i=_t(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=Au(o,r,e+1/3),this.g=Au(o,r,e),this.b=Au(o,r,e-1/3)}return gt.colorSpaceToWorking(this,n),this}setStyle(e,s=Ti){function i(r){r!==void 0&&parseFloat(r)<1&&et("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:et("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);et("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,s);return this}setColorName(e,s=Ti){const i=LS[e.toLowerCase()];return i!==void 0?this.setHex(i,s):et("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=$n(e.r),this.g=$n(e.g),this.b=$n(e.b),this}copyLinearToSRGB(e){return this.r=ra(e.r),this.g=ra(e.g),this.b=ra(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ti){return gt.workingToColorSpace(Ps.copy(this),e),Math.round(_t(Ps.r*255,0,255))*65536+Math.round(_t(Ps.g*255,0,255))*256+Math.round(_t(Ps.b*255,0,255))}getHexString(e=Ti){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,s=gt.workingColorSpace){gt.workingToColorSpace(Ps.copy(this),s);const i=Ps.r,n=Ps.g,r=Ps.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=gt.workingColorSpace){return gt.workingToColorSpace(Ps.copy(this),s),e.r=Ps.r,e.g=Ps.g,e.b=Ps.b,e}getStyle(e=Ti){gt.workingToColorSpace(Ps.copy(this),e);const s=Ps.r,i=Ps.g,n=Ps.b;return e!==Ti?`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(tr),this.setHSL(tr.h+e,tr.s+s,tr.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(tr),e.getHSL(wc);const i=wu(tr.h,wc.h,s),n=wu(tr.s,wc.s,s),r=wu(tr.l,wc.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 Ps=new Ke;Ke.NAMES=LS;class nP extends Qt{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 Gr,this.environmentIntensity=1,this.environmentRotation=new Gr,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 Hi=new F,On=new F,Tu=new F,En=new F,No=new F,Bo=new F,Z0=new F,Du=new F,Iu=new F,Cu=new F,Ru=new Zt,ku=new Zt,Nu=new Zt;class ki{constructor(e=new F,s=new F,i=new F){this.a=e,this.b=s,this.c=i}static getNormal(e,s,i,n){n.subVectors(i,s),Hi.subVectors(e,s),n.cross(Hi);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){Hi.subVectors(n,s),On.subVectors(i,s),Tu.subVectors(e,s);const o=Hi.dot(Hi),a=Hi.dot(On),l=Hi.dot(Tu),c=On.dot(On),h=On.dot(Tu),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,En)===null?!1:En.x>=0&&En.y>=0&&En.x+En.y<=1}static getInterpolation(e,s,i,n,r,o,a,l){return this.getBarycoord(e,s,i,n,En)===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,En.x),l.addScaledVector(o,En.y),l.addScaledVector(a,En.z),l)}static getInterpolatedAttribute(e,s,i,n,r,o){return Ru.setScalar(0),ku.setScalar(0),Nu.setScalar(0),Ru.fromBufferAttribute(e,s),ku.fromBufferAttribute(e,i),Nu.fromBufferAttribute(e,n),o.setScalar(0),o.addScaledVector(Ru,r.x),o.addScaledVector(ku,r.y),o.addScaledVector(Nu,r.z),o}static isFrontFacing(e,s,i,n){return Hi.subVectors(i,s),On.subVectors(e,s),Hi.cross(On).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 Hi.subVectors(this.c,this.b),On.subVectors(this.a,this.b),Hi.cross(On).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ki.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,s){return ki.getBarycoord(e,this.a,this.b,this.c,s)}getInterpolation(e,s,i,n,r){return ki.getInterpolation(e,this.a,this.b,this.c,s,i,n,r)}containsPoint(e){return ki.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ki.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;No.subVectors(n,i),Bo.subVectors(r,i),Du.subVectors(e,i);const l=No.dot(Du),c=Bo.dot(Du);if(l<=0&&c<=0)return s.copy(i);Iu.subVectors(e,n);const h=No.dot(Iu),d=Bo.dot(Iu);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(No,o);Cu.subVectors(e,r);const p=No.dot(Cu),f=Bo.dot(Cu);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(Bo,a);const g=h*f-p*d;if(g<=0&&d-h>=0&&p-f>=0)return Z0.subVectors(r,n),a=(d-h)/(d-h+(p-f)),s.copy(n).addScaledVector(Z0,a);const m=1/(g+_+u);return o=_*m,a=u*m,s.copy(i).addScaledVector(No,o).addScaledVector(Bo,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class yo{constructor(e=new F(1/0,1/0,1/0),s=new F(-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(Vi.fromArray(e,s));return this}setFromBufferAttribute(e){this.makeEmpty();for(let s=0,i=e.count;s<i;s++)this.expandByPoint(Vi.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=Vi.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,Vi):Vi.fromBufferAttribute(r,o),Vi.applyMatrix4(e.matrixWorld),this.expandByPoint(Vi);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),yc.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),yc.copy(i.boundingBox)),yc.applyMatrix4(e.matrixWorld),this.union(yc)}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,Vi),Vi.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($a),zc.subVectors(this.max,$a),Go.subVectors(e.a,$a),Po.subVectors(e.b,$a),Lo.subVectors(e.c,$a),sr.subVectors(Po,Go),ir.subVectors(Lo,Po),$r.subVectors(Go,Lo);let s=[0,-sr.z,sr.y,0,-ir.z,ir.y,0,-$r.z,$r.y,sr.z,0,-sr.x,ir.z,0,-ir.x,$r.z,0,-$r.x,-sr.y,sr.x,0,-ir.y,ir.x,0,-$r.y,$r.x,0];return!Bu(s,Go,Po,Lo,zc)||(s=[1,0,0,0,1,0,0,0,1],!Bu(s,Go,Po,Lo,zc))?!1:(Sc.crossVectors(sr,ir),s=[Sc.x,Sc.y,Sc.z],Bu(s,Go,Po,Lo,zc))}clampPoint(e,s){return s.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Vi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Vi).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:(An[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),An[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),An[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),An[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),An[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),An[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),An[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),An[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(An),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 An=[new F,new F,new F,new F,new F,new F,new F,new F],Vi=new F,yc=new yo,Go=new F,Po=new F,Lo=new F,sr=new F,ir=new F,$r=new F,$a=new F,zc=new F,Sc=new F,jr=new F;function Bu(t,e,s,i,n){for(let r=0,o=t.length-3;r<=o;r+=3){jr.fromArray(t,r);const a=n.x*Math.abs(jr.x)+n.y*Math.abs(jr.y)+n.z*Math.abs(jr.z),l=e.dot(jr),c=s.dot(jr),h=i.dot(jr);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const hs=new F,xc=new st;let rP=0;class Cs extends vo{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:rP++}),this.name="",this.array=e,this.itemSize=s,this.count=e!==void 0?e.length/s:0,this.normalized=i,this.usage=em,this.updateRanges=[],this.gpuType=en,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++)xc.fromBufferAttribute(this,s),xc.applyMatrix3(e),this.setXY(s,xc.x,xc.y);else if(this.itemSize===3)for(let s=0,i=this.count;s<i;s++)hs.fromBufferAttribute(this,s),hs.applyMatrix3(e),this.setXYZ(s,hs.x,hs.y,hs.z);return this}applyMatrix4(e){for(let s=0,i=this.count;s<i;s++)hs.fromBufferAttribute(this,s),hs.applyMatrix4(e),this.setXYZ(s,hs.x,hs.y,hs.z);return this}applyNormalMatrix(e){for(let s=0,i=this.count;s<i;s++)hs.fromBufferAttribute(this,s),hs.applyNormalMatrix(e),this.setXYZ(s,hs.x,hs.y,hs.z);return this}transformDirection(e){for(let s=0,i=this.count;s<i;s++)hs.fromBufferAttribute(this,s),hs.transformDirection(e),this.setXYZ(s,hs.x,hs.y,hs.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=pn(i,this.array)),i}setComponent(e,s,i){return this.normalized&&(i=Bt(i,this.array)),this.array[e*this.itemSize+s]=i,this}getX(e){let s=this.array[e*this.itemSize];return this.normalized&&(s=pn(s,this.array)),s}setX(e,s){return this.normalized&&(s=Bt(s,this.array)),this.array[e*this.itemSize]=s,this}getY(e){let s=this.array[e*this.itemSize+1];return this.normalized&&(s=pn(s,this.array)),s}setY(e,s){return this.normalized&&(s=Bt(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=pn(s,this.array)),s}setZ(e,s){return this.normalized&&(s=Bt(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=pn(s,this.array)),s}setW(e,s){return this.normalized&&(s=Bt(s,this.array)),this.array[e*this.itemSize+3]=s,this}setXY(e,s,i){return e*=this.itemSize,this.normalized&&(s=Bt(s,this.array),i=Bt(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=Bt(s,this.array),i=Bt(i,this.array),n=Bt(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=Bt(s,this.array),i=Bt(i,this.array),n=Bt(n,this.array),r=Bt(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!==em&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class WS extends Cs{constructor(e,s,i){super(new Uint16Array(e),s,i)}}class FS extends Cs{constructor(e,s,i){super(new Uint32Array(e),s,i)}}class It extends Cs{constructor(e,s,i){super(new Float32Array(e),s,i)}}const oP=new yo,ja=new F,Gu=new F;class zo{constructor(e=new F,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):oP.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;ja.subVectors(e,this.center);const s=ja.lengthSq();if(s>this.radius*this.radius){const i=Math.sqrt(s),n=(i-this.radius)*.5;this.center.addScaledVector(ja,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):(Gu.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ja.copy(e.center).add(Gu)),this.expandByPoint(ja.copy(e.center).sub(Gu))),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 aP=0;const Si=new zt,Pu=new Qt,Wo=new F,fi=new yo,Ha=new yo,ys=new F;class fs extends vo{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:aP++}),this.uuid=Er(),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)?FS:WS)(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 Si.makeRotationFromQuaternion(e),this.applyMatrix4(Si),this}rotateX(e){return Si.makeRotationX(e),this.applyMatrix4(Si),this}rotateY(e){return Si.makeRotationY(e),this.applyMatrix4(Si),this}rotateZ(e){return Si.makeRotationZ(e),this.applyMatrix4(Si),this}translate(e,s,i){return Si.makeTranslation(e,s,i),this.applyMatrix4(Si),this}scale(e,s,i){return Si.makeScale(e,s,i),this.applyMatrix4(Si),this}lookAt(e){return Pu.lookAt(e),Pu.updateMatrix(),this.applyMatrix4(Pu.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Wo).negate(),this.translate(Wo.x,Wo.y,Wo.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 It(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&&et("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 yo);const e=this.attributes.position,s=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){mt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new F(-1/0,-1/0,-1/0),new F(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];fi.setFromBufferAttribute(r),this.morphTargetsRelative?(ys.addVectors(this.boundingBox.min,fi.min),this.boundingBox.expandByPoint(ys),ys.addVectors(this.boundingBox.max,fi.max),this.boundingBox.expandByPoint(ys)):(this.boundingBox.expandByPoint(fi.min),this.boundingBox.expandByPoint(fi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&mt('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 zo);const e=this.attributes.position,s=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){mt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new F,1/0);return}if(e){const i=this.boundingSphere.center;if(fi.setFromBufferAttribute(e),s)for(let r=0,o=s.length;r<o;r++){const a=s[r];Ha.setFromBufferAttribute(a),this.morphTargetsRelative?(ys.addVectors(fi.min,Ha.min),fi.expandByPoint(ys),ys.addVectors(fi.max,Ha.max),fi.expandByPoint(ys)):(fi.expandByPoint(Ha.min),fi.expandByPoint(Ha.max))}fi.getCenter(i);let n=0;for(let r=0,o=e.count;r<o;r++)ys.fromBufferAttribute(e,r),n=Math.max(n,i.distanceToSquared(ys));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++)ys.fromBufferAttribute(a,c),l&&(Wo.fromBufferAttribute(e,c),ys.add(Wo)),n=Math.max(n,i.distanceToSquared(ys))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&mt('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){mt("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 Cs(new Float32Array(4*i.count),4),this.setAttribute("tangent",o));const a=[],l=[];for(let M=0;M<i.count;M++)a[M]=new F,l[M]=new F;const c=new F,h=new F,d=new F,u=new st,p=new st,f=new st,_=new F,g=new F;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 A=1/(p.x*f.y-f.x*p.y);isFinite(A)&&(_.copy(h).multiplyScalar(f.y).addScaledVector(d,-p.y).multiplyScalar(A),g.copy(d).multiplyScalar(p.x).addScaledVector(h,-f.x).multiplyScalar(A),a[M].add(_),a[S].add(_),a[T].add(_),l[M].add(g),l[S].add(g),l[T].add(g))}let v=this.groups;v.length===0&&(v=[{start:0,count:e.count}]);for(let M=0,S=v.length;M<S;++M){const T=v[M],A=T.start,E=T.count;for(let O=A,R=A+E;O<R;O+=3)m(e.getX(O+0),e.getX(O+1),e.getX(O+2))}const y=new F,b=new F,w=new F,z=new F;function x(M){w.fromBufferAttribute(n,M),z.copy(w);const S=a[M];y.copy(S),y.sub(w.multiplyScalar(w.dot(S))).normalize(),b.crossVectors(z,S);const A=b.dot(l[M])<0?-1:1;o.setXYZW(M,y.x,y.y,y.z,A)}for(let M=0,S=v.length;M<S;++M){const T=v[M],A=T.start,E=T.count;for(let O=A,R=A+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 Cs(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 F,r=new F,o=new F,a=new F,l=new F,c=new F,h=new F,d=new F;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++)ys.fromBufferAttribute(e,s),ys.normalize(),e.setXYZ(s,ys.x,ys.y,ys.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 Cs(u,h,d)}if(this.index===null)return et("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const s=new fs,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 lP{constructor(e,s){this.isInterleavedBuffer=!0,this.array=e,this.stride=s,this.count=e!==void 0?e.length/s:0,this.usage=em,this.updateRanges=[],this.version=0,this.uuid=Er()}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=Er()),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=Er()),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 Hs=new F;class id{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++)Hs.fromBufferAttribute(this,s),Hs.applyMatrix4(e),this.setXYZ(s,Hs.x,Hs.y,Hs.z);return this}applyNormalMatrix(e){for(let s=0,i=this.count;s<i;s++)Hs.fromBufferAttribute(this,s),Hs.applyNormalMatrix(e),this.setXYZ(s,Hs.x,Hs.y,Hs.z);return this}transformDirection(e){for(let s=0,i=this.count;s<i;s++)Hs.fromBufferAttribute(this,s),Hs.transformDirection(e),this.setXYZ(s,Hs.x,Hs.y,Hs.z);return this}getComponent(e,s){let i=this.array[e*this.data.stride+this.offset+s];return this.normalized&&(i=pn(i,this.array)),i}setComponent(e,s,i){return this.normalized&&(i=Bt(i,this.array)),this.data.array[e*this.data.stride+this.offset+s]=i,this}setX(e,s){return this.normalized&&(s=Bt(s,this.array)),this.data.array[e*this.data.stride+this.offset]=s,this}setY(e,s){return this.normalized&&(s=Bt(s,this.array)),this.data.array[e*this.data.stride+this.offset+1]=s,this}setZ(e,s){return this.normalized&&(s=Bt(s,this.array)),this.data.array[e*this.data.stride+this.offset+2]=s,this}setW(e,s){return this.normalized&&(s=Bt(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=pn(s,this.array)),s}getY(e){let s=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(s=pn(s,this.array)),s}getZ(e){let s=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(s=pn(s,this.array)),s}getW(e){let s=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(s=pn(s,this.array)),s}setXY(e,s,i){return e=e*this.data.stride+this.offset,this.normalized&&(s=Bt(s,this.array),i=Bt(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=Bt(s,this.array),i=Bt(i,this.array),n=Bt(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=Bt(s,this.array),i=Bt(i,this.array),n=Bt(n,this.array),r=Bt(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){sd("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 Cs(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 id(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){sd("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 cP=0;class Xn extends vo{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:cP++}),this.uuid=Er(),this.name="",this.type="Material",this.blending=lo,this.side=Nr,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=up,this.blendDst=fp,this.blendEquation=Qr,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ke(0,0,0),this.blendAlpha=0,this.depthFunc=_a,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=P0,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Do,this.stencilZFail=Do,this.stencilZPass=Do,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){et(`Material: parameter '${s}' has value of undefined.`);continue}const n=this[s];if(n===void 0){et(`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!==lo&&(i.blending=this.blending),this.side!==Nr&&(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!==up&&(i.blendSrc=this.blendSrc),this.blendDst!==fp&&(i.blendDst=this.blendDst),this.blendEquation!==Qr&&(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!==_a&&(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!==P0&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Do&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Do&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Do&&(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 st().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 st().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 Zl extends Xn{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 Fo;const Va=new F,Uo=new F,$o=new F,jo=new st,qa=new st,US=new zt,Oc=new F,Ka=new F,Ec=new F,J0=new st,Lu=new st,Q0=new st;class kd extends Qt{constructor(e=new Zl){if(super(),this.isSprite=!0,this.type="Sprite",Fo===void 0){Fo=new fs;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 lP(s,5);Fo.setIndex([0,1,2,0,2,3]),Fo.setAttribute("position",new id(i,3,0,!1)),Fo.setAttribute("uv",new id(i,2,3,!1))}this.geometry=Fo,this.material=e,this.center=new st(.5,.5),this.count=1}raycast(e,s){e.camera===null&&mt('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Uo.setFromMatrixScale(this.matrixWorld),US.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),$o.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Uo.multiplyScalar(-$o.z);const i=this.material.rotation;let n,r;i!==0&&(r=Math.cos(i),n=Math.sin(i));const o=this.center;Ac(Oc.set(-.5,-.5,0),$o,o,Uo,n,r),Ac(Ka.set(.5,-.5,0),$o,o,Uo,n,r),Ac(Ec.set(.5,.5,0),$o,o,Uo,n,r),J0.set(0,0),Lu.set(1,0),Q0.set(1,1);let a=e.ray.intersectTriangle(Oc,Ka,Ec,!1,Va);if(a===null&&(Ac(Ka.set(-.5,.5,0),$o,o,Uo,n,r),Lu.set(0,1),a=e.ray.intersectTriangle(Oc,Ec,Ka,!1,Va),a===null))return;const l=e.ray.origin.distanceTo(Va);l<e.near||l>e.far||s.push({distance:l,point:Va.clone(),uv:ki.getInterpolation(Va,Oc,Ka,Ec,J0,Lu,Q0,new st),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 Ac(t,e,s,i,n,r){jo.subVectors(t,s).addScalar(.5).multiply(i),n!==void 0?(qa.x=r*jo.x-n*jo.y,qa.y=n*jo.x+r*jo.y):qa.copy(jo),t.copy(e),t.x+=qa.x,t.y+=qa.y,t.applyMatrix4(US)}const Tn=new F,Wu=new F,Tc=new F,nr=new F,Fu=new F,Dc=new F,Uu=new F;class Nd{constructor(e=new F,s=new F(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,Tn)),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=Tn.subVectors(e,this.origin).dot(this.direction);return s<0?this.origin.distanceToSquared(e):(Tn.copy(this.origin).addScaledVector(this.direction,s),Tn.distanceToSquared(e))}distanceSqToSegment(e,s,i,n){Wu.copy(e).add(s).multiplyScalar(.5),Tc.copy(s).sub(e).normalize(),nr.copy(this.origin).sub(Wu);const r=e.distanceTo(s)*.5,o=-this.direction.dot(Tc),a=nr.dot(this.direction),l=-nr.dot(Tc),c=nr.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(Wu).addScaledVector(Tc,u),p}intersectSphere(e,s){Tn.subVectors(e.center,this.origin);const i=Tn.dot(this.direction),n=Tn.dot(Tn)-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,Tn)!==null}intersectTriangle(e,s,i,n,r){Fu.subVectors(s,e),Dc.subVectors(i,e),Uu.crossVectors(Fu,Dc);let o=this.direction.dot(Uu),a;if(o>0){if(n)return null;a=1}else if(o<0)a=-1,o=-o;else return null;nr.subVectors(this.origin,e);const l=a*this.direction.dot(Dc.crossVectors(nr,Dc));if(l<0)return null;const c=a*this.direction.dot(Fu.cross(nr));if(c<0||l+c>o)return null;const h=-a*nr.dot(Uu);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 e_ extends Xn{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 Gr,this.combine=yS,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 eM=new zt,Hr=new Nd,Ic=new zo,tM=new F,Cc=new F,Rc=new F,kc=new F,$u=new F,Nc=new F,sM=new F,Bc=new F;class ri extends Qt{constructor(e=new fs,s=new e_){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){Nc.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const h=a[l],d=r[l];h!==0&&($u.fromBufferAttribute(d,e),o?Nc.addScaledVector($u,h):Nc.addScaledVector($u.sub(s),h))}s.add(Nc)}return s}raycast(e,s){const i=this.geometry,n=this.material,r=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Ic.copy(i.boundingSphere),Ic.applyMatrix4(r),Hr.copy(e.ray).recast(e.near),!(Ic.containsPoint(Hr.origin)===!1&&(Hr.intersectSphere(Ic,tM)===null||Hr.origin.distanceToSquared(tM)>(e.far-e.near)**2))&&(eM.copy(r).invert(),Hr.copy(e.ray).applyMatrix4(eM),!(i.boundingBox!==null&&Hr.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,s,Hr)))}_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],v=Math.max(g.start,p.start),y=Math.min(a.count,Math.min(g.start+g.count,p.start+p.count));for(let b=v,w=y;b<w;b+=3){const z=a.getX(b),x=a.getX(b+1),M=a.getX(b+2);n=Gc(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 v=a.getX(g),y=a.getX(g+1),b=a.getX(g+2);n=Gc(this,o,e,i,c,h,d,v,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],v=Math.max(g.start,p.start),y=Math.min(l.count,Math.min(g.start+g.count,p.start+p.count));for(let b=v,w=y;b<w;b+=3){const z=b,x=b+1,M=b+2;n=Gc(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 v=g,y=g+1,b=g+2;n=Gc(this,o,e,i,c,h,d,v,y,b),n&&(n.faceIndex=Math.floor(g/3),s.push(n))}}}}function hP(t,e,s,i,n,r,o,a){let l;if(e.side===ni?l=i.intersectTriangle(o,r,n,!0,a):l=i.intersectTriangle(n,r,o,e.side===Nr,a),l===null)return null;Bc.copy(a),Bc.applyMatrix4(t.matrixWorld);const c=s.ray.origin.distanceTo(Bc);return c<s.near||c>s.far?null:{distance:c,point:Bc.clone(),object:t}}function Gc(t,e,s,i,n,r,o,a,l,c){t.getVertexPosition(a,Cc),t.getVertexPosition(l,Rc),t.getVertexPosition(c,kc);const h=hP(t,e,s,i,Cc,Rc,kc,sM);if(h){const d=new F;ki.getBarycoord(sM,Cc,Rc,kc,d),n&&(h.uv=ki.getInterpolatedAttribute(n,a,l,c,d,new st)),r&&(h.uv1=ki.getInterpolatedAttribute(r,a,l,c,d,new st)),o&&(h.normal=ki.getInterpolatedAttribute(o,a,l,c,d,new F),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const u={a,b:l,c,normal:new F,materialIndex:0};ki.getNormal(Cc,Rc,kc,u.normal),h.face=u,h.barycoord=d}return h}class $S extends Us{constructor(e=null,s=1,i=1,n,r,o,a,l,c=ks,h=ks,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 Ar extends Cs{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 Ho=new zt,iM=new zt,Pc=[],nM=new yo,dP=new zt,Ya=new ri,Xa=new zo;class t_ extends ri{constructor(e,s,i){super(e,s),this.isInstancedMesh=!0,this.instanceMatrix=new Ar(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,dP)}computeBoundingBox(){const e=this.geometry,s=this.count;this.boundingBox===null&&(this.boundingBox=new yo),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<s;i++)this.getMatrixAt(i,Ho),nM.copy(e.boundingBox).applyMatrix4(Ho),this.boundingBox.union(nM)}computeBoundingSphere(){const e=this.geometry,s=this.count;this.boundingSphere===null&&(this.boundingSphere=new zo),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<s;i++)this.getMatrixAt(i,Ho),Xa.copy(e.boundingSphere).applyMatrix4(Ho),this.boundingSphere.union(Xa)}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(Ya.geometry=this.geometry,Ya.material=this.material,Ya.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Xa.copy(this.boundingSphere),Xa.applyMatrix4(i),e.ray.intersectsSphere(Xa)!==!1))for(let r=0;r<n;r++){this.getMatrixAt(r,Ho),iM.multiplyMatrices(i,Ho),Ya.matrixWorld=iM,Ya.raycast(e,Pc);for(let o=0,a=Pc.length;o<a;o++){const l=Pc[o];l.instanceId=r,l.object=this,s.push(l)}Pc.length=0}}setColorAt(e,s){return this.instanceColor===null&&(this.instanceColor=new Ar(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 $S(new Float32Array(n*this.count),n,this.count,Vg,en));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 ju=new F,uP=new F,fP=new rt;class fr{constructor(e=new F(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=ju.subVectors(i,s).cross(uP.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(ju),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||fP.getNormalMatrix(e),n=this.coplanarPoint(ju).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 Vr=new zo,pP=new st(.5,.5),Lc=new F;class s_{constructor(e=new fr,s=new fr,i=new fr,n=new fr,r=new fr,o=new fr){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=mn,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],v=r[12],y=r[13],b=r[14],w=r[15];if(n[0].setComponents(c-o,p-h,m-f,w-v).normalize(),n[1].setComponents(c+o,p+h,m+f,w+v).normalize(),n[2].setComponents(c+a,p+d,m+_,w+y).normalize(),n[3].setComponents(c-a,p-d,m-_,w-y).normalize(),i)n[4].setComponents(l,u,g,b).normalize(),n[5].setComponents(c-l,p-u,m-g,w-b).normalize();else if(n[4].setComponents(c-l,p-u,m-g,w-b).normalize(),s===mn)n[5].setComponents(c+l,p+u,m+g,w+b).normalize();else if(s===$l)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(),Vr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const s=e.geometry;s.boundingSphere===null&&s.computeBoundingSphere(),Vr.copy(s.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Vr)}intersectsSprite(e){Vr.center.set(0,0,0);const s=pP.distanceTo(e.center);return Vr.radius=.7071067811865476+s,Vr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Vr)}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(Lc.x=n.normal.x>0?e.max.x:e.min.x,Lc.y=n.normal.y>0?e.max.y:e.min.y,Lc.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(Lc)<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 Bd extends Xn{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 nd=new F,rd=new F,rM=new zt,Za=new Nd,Wc=new zo,Hu=new F,oM=new F;class sm extends Qt{constructor(e=new fs,s=new Bd){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++)nd.fromBufferAttribute(s,n-1),rd.fromBufferAttribute(s,n),i[n]=i[n-1],i[n]+=nd.distanceTo(rd);e.setAttribute("lineDistance",new It(i,1))}else et("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(),Wc.copy(i.boundingSphere),Wc.applyMatrix4(n),Wc.radius+=r,e.ray.intersectsSphere(Wc)===!1)return;rM.copy(n).invert(),Za.copy(e.ray).applyMatrix4(rM);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(_),v=h.getX(_+1),y=Fc(this,e,Za,l,m,v,_);y&&s.push(y)}if(this.isLineLoop){const _=h.getX(f-1),g=h.getX(p),m=Fc(this,e,Za,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=Fc(this,e,Za,l,_,_+1,_);m&&s.push(m)}if(this.isLineLoop){const _=Fc(this,e,Za,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 Fc(t,e,s,i,n,r,o){const a=t.geometry.attributes.position;if(nd.fromBufferAttribute(a,n),rd.fromBufferAttribute(a,r),s.distanceSqToSegment(nd,rd,Hu,oM)>i)return;Hu.applyMatrix4(t.matrixWorld);const c=e.ray.origin.distanceTo(Hu);if(!(c<e.near||c>e.far))return{distance:c,point:oM.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const aM=new F,lM=new F;class im extends sm{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)aM.fromBufferAttribute(s,n),lM.fromBufferAttribute(s,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+aM.distanceTo(lM);e.setAttribute("lineDistance",new It(i,1))}else et("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class mP extends Xn{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 cM=new zt,nm=new Nd,Uc=new zo,$c=new F;class gP extends Qt{constructor(e=new fs,s=new mP){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(),Uc.copy(i.boundingSphere),Uc.applyMatrix4(n),Uc.radius+=r,e.ray.intersectsSphere(Uc)===!1)return;cM.copy(n).invert(),nm.copy(e.ray).applyMatrix4(cM);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);$c.fromBufferAttribute(d,g),hM($c,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++)$c.fromBufferAttribute(d,f),hM($c,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 hM(t,e,s,i,n,r,o){const a=nm.distanceSqToPoint(t);if(a<s){const l=new F;nm.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 jS extends Us{constructor(e=[],s=go,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 HS extends Us{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 Ma extends Us{constructor(e,s,i=yn,n,r,o,a=ks,l=ks,c,h=Kn,d=1){if(h!==Kn&&h!==so)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 Jg(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 _P extends Ma{constructor(e,s=yn,i=go,n,r,o=ks,a=ks,l,c=Kn){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 VS extends Us{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Jl extends fs{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 It(c,3)),this.setAttribute("normal",new It(h,3)),this.setAttribute("uv",new It(d,2));function f(_,g,m,v,y,b,w,z,x,M,S){const T=b/x,A=w/M,E=b/2,O=w/2,R=z/2,C=x+1,k=M+1;let B=0,L=0;const U=new F;for(let ee=0;ee<k;ee++){const X=ee*A-O;for(let ce=0;ce<C;ce++){const Oe=ce*T-E;U[_]=Oe*v,U[g]=X*y,U[m]=R,c.push(U.x,U.y,U.z),U[_]=0,U[g]=0,U[m]=z>0?1:-1,h.push(U.x,U.y,U.z),d.push(ce/x),d.push(1-ee/M),B+=1}}for(let ee=0;ee<M;ee++)for(let X=0;X<x;X++){const ce=u+X+C*ee,Oe=u+X+C*(ee+1),Ce=u+(X+1)+C*(ee+1),Ne=u+(X+1)+C*ee;l.push(ce,Oe,Ne),l.push(Oe,Ce,Ne),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 Jl(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class i_ extends fs{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 F,h=new st;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 It(o,3)),this.setAttribute("normal",new It(a,3)),this.setAttribute("uv",new It(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i_(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class n_ extends fs{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;v(),o===!1&&(e>0&&y(!0),s>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new It(d,3)),this.setAttribute("normal",new It(u,3)),this.setAttribute("uv",new It(p,2));function v(){const b=new F,w=new F;let z=0;const x=(s-e)/i;for(let M=0;M<=r;M++){const S=[],T=M/r,A=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);w.x=A*C,w.y=-T*i+g,w.z=A*k,d.push(w.x,w.y,w.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],A=_[S+1][M],E=_[S+1][M+1],O=_[S][M+1];(e>0||S!==0)&&(h.push(T,A,O),z+=3),(s>0||S!==r-1)&&(h.push(A,E,O),z+=3)}c.addGroup(m,z,0),m+=z}function y(b){const w=f,z=new st,x=new F;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 A=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=w+E,R=A+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 n_(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class r_ extends fs{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 It(r,3)),this.setAttribute("normal",new It(r.slice(),3)),this.setAttribute("uv",new It(o,2)),n===0?this.computeVertexNormals():this.normalizeNormals();function a(v){const y=new F,b=new F,w=new F;for(let z=0;z<s.length;z+=3)p(s[z+0],y),p(s[z+1],b),p(s[z+2],w),l(y,b,w,v)}function l(v,y,b,w){const z=w+1,x=[];for(let M=0;M<=z;M++){x[M]=[];const S=v.clone().lerp(b,M/z),T=y.clone().lerp(b,M/z),A=z-M;for(let E=0;E<=A;E++)E===0&&M===z?x[M][E]=S:x[M][E]=S.clone().lerp(T,E/A)}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(v){const y=new F;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(v),r[b+0]=y.x,r[b+1]=y.y,r[b+2]=y.z}function h(){const v=new F;for(let y=0;y<r.length;y+=3){v.x=r[y+0],v.y=r[y+1],v.z=r[y+2];const b=g(v)/2/Math.PI+.5,w=m(v)/Math.PI+.5;o.push(b,1-w)}f(),d()}function d(){for(let v=0;v<o.length;v+=6){const y=o[v+0],b=o[v+2],w=o[v+4],z=Math.max(y,b,w),x=Math.min(y,b,w);z>.9&&x<.1&&(y<.2&&(o[v+0]+=1),b<.2&&(o[v+2]+=1),w<.2&&(o[v+4]+=1))}}function u(v){r.push(v.x,v.y,v.z)}function p(v,y){const b=v*3;y.x=e[b+0],y.y=e[b+1],y.z=e[b+2]}function f(){const v=new F,y=new F,b=new F,w=new F,z=new st,x=new st,M=new st;for(let S=0,T=0;S<r.length;S+=9,T+=6){v.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]),w.copy(v).add(y).add(b).divideScalar(3);const A=g(w);_(z,T+0,v,A),_(x,T+2,y,A),_(M,T+4,b,A)}}function _(v,y,b,w){w<0&&v.x===1&&(o[y]=v.x-1),b.x===0&&b.z===0&&(o[y]=w/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function m(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r_(e.vertices,e.indices,e.radius,e.detail)}}class o_ extends r_{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 o_(e.radius,e.detail)}}class Gd extends fs{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 v=m*u-o;for(let y=0;y<c;y++){const b=y*d-r;f.push(b,-v,0),_.push(0,0,1),g.push(y/a),g.push(1-m/l)}}for(let m=0;m<l;m++)for(let v=0;v<a;v++){const y=v+c*m,b=v+c*(m+1),w=v+1+c*(m+1),z=v+1+c*m;p.push(y,b,z),p.push(b,w,z)}this.setIndex(p),this.setAttribute("position",new It(f,3)),this.setAttribute("normal",new It(_,3)),this.setAttribute("uv",new It(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Gd(e.width,e.height,e.widthSegments,e.heightSegments)}}class Pd extends fs{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 F,u=new F,p=[],f=[],_=[],g=[];for(let m=0;m<=i;m++){const v=[],y=m/i,b=o+y*a,w=e*Math.cos(b),z=Math.sqrt(e*e-w*w);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=w,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),v.push(c++)}h.push(v)}for(let m=0;m<i;m++)for(let v=0;v<s;v++){const y=h[m][v+1],b=h[m][v],w=h[m+1][v],z=h[m+1][v+1];(m!==0||o>0)&&p.push(y,b,z),(m!==i-1||l<Math.PI)&&p.push(b,w,z)}this.setIndex(p),this.setAttribute("position",new It(f,3)),this.setAttribute("normal",new It(_,3)),this.setAttribute("uv",new It(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Pd(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function va(t){const e={};for(const s in t){e[s]={};for(const i in t[s]){const n=t[s][i];if(dM(n))n.isRenderTargetTexture?(et("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(dM(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 Ks(t){const e={};for(let s=0;s<t.length;s++){const i=va(t[s]);for(const n in i)e[n]=i[n]}return e}function dM(t){return t&&(t.isColor||t.isMatrix3||t.isMatrix4||t.isVector2||t.isVector3||t.isVector4||t.isTexture||t.isQuaternion)}function bP(t){const e=[];for(let s=0;s<t.length;s++)e.push(t[s].clone());return e}function qS(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:gt.workingColorSpace}const MP={clone:va,merge:Ks};var vP=`void main() {
|
|
107
107
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
108
108
|
}`,wP=`void main() {
|
|
@@ -4345,26 +4345,26 @@ void main() {
|
|
|
4345
4345
|
`),!1}return s.outcome_write(n),n.envelopes.length>0&&n.envelopes.every(r=>r.status==="ok")}function V5(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 q5(t,e){return t.split(`
|
|
4346
4346
|
`).map(s=>s.trim().split(":")).filter(s=>s.length>=4&&(s[3]??"").split(",").includes(e)).map(s=>s[0]??"").filter(s=>s!=="")}function K5(t){return/^(u|user|g|group|o|other):/.test(t)?t:`u:${t}:r`}function Y5(t,e){return e.kind==="public"?`setfacl -m o::- feed_${t}`:`setfacl -x ${e.kind==="user"?"u":"g"}:${sn(e.name)} feed_${t}`}function Xc(t){return t.kind==="public"?"PUBLIC":t.kind==="group"?`group ${t.name}`:t.name}function X5(t,e){const s={silent:!0,observe:!1},i=async c=>{try{return V5(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 q5(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 ${Xc(d)}? `})==="y"&&await oa(t,Y5(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=Xc(f);const g=document.createElement("span");g.className="holder-mark-name",g.textContent=Xc(f),_.append(g);const m=document.createElement("span");m.className="holder-mark-x",m.title=`stop sharing with ${Xc(f)} (asks first)`,m.textContent="×",m.addEventListener("click",v=>{v.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 oa(t,`setfacl -m ${K5(_)} 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 oa(t,I1(`/proc/jobs/feed_${h}/title`,u))&&e.changed(h)}}}function Z5(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 J5(t,e,s){const i=`setfattr -n tag -v ${sn(e)} feed_${t}`;return s.includes(e)?[i]:[`mkdir ${sn(`/proc/tags/${e}`)}`,i]}function Q5(t,e){const s=async()=>{try{return Z5(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 J5(o,p,c))if(f=await oa(t,_),!f)break;if(!f)return;l.add(p),e.tags_changed(o)}},tag_remove:async(r,o)=>{const a=await oa(t,`setfattr -x tag -v ${sn(o)} feed_${r}`);return a&&e.tags_changed(r),a}}}function e$(t,e){return{tags:Q5(t,{askOnPane_await:e.askOnPane_await,tags_changed:e.changed}),access:X5(t,e)}}function t$(t){for(const e of t.envelopes){if(e.model?.kind!=="fs.xattr")continue;return e.model.data[0]?.tags??[]}return[]}function R1(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 mS.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?[]:t$(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 s$=256*1024*1024;function i$(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 lv(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 cv(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 k1(){return`dl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}async function n$(t,e,s=fetch,i=k1()){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=lv(r);if(o!==null)return{ok:!1,reason:o};const a=i$(r.headers.get("content-disposition"),e),l=Number(r.headers.get("content-length")??NaN);if(!Number.isFinite(l)||l>s$)return cv(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=lv(c);if(h!==null)return{ok:!1,reason:h};const d=await c.blob(),u=URL.createObjectURL(d);return cv(u,a),setTimeout(()=>URL.revokeObjectURL(u),6e4),{ok:!0,name:a,bytes:d.size,streamed:!1}}const r$=1e3,o$=5e3,a$=3,l$=2e4;function sl(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 Zc(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 c$(t,e){switch(t.phase){case"opening":return`WAITING FOR CUBE · ${Zc(t.elapsedMs)}`;case"ready":return"CUBE ANSWERED · HANDING TO THE BROWSER";case"streaming":{if(t.bytes===0)return`WAITING FOR CUBE'S FIRST BYTE · ${Zc(t.elapsedMs)}`;const s=[t.size!==void 0?`${sl(t.bytes)} OF ${sl(t.size)}`:sl(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(`${sl(e)}/S`),t.size!==void 0&&s.push(`${Zc(1e3*(t.size-t.bytes)/e)} LEFT`)),s.join(" · ")}case"done":return`DONE · ${sl(t.bytes)} IN ${Zc(t.elapsedMs)}`;case"failed":return`FAILED · ${t.reason??"the session did not say why"}`;case"cancelled":return"CANCELLED"}}function hv(t){return t==="done"||t==="failed"||t==="cancelled"}function dv(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 h$(){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 d$(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),h$().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(_,l$)},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 v=!1,y=0;const b=x=>{n.dataset.phase=x.phase;const M=c$(x,x.phase==="streaming"?m(x.bytes):null);l.textContent=v&&!hv(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)}%`,hv(x.phase)&&g()},w=async x=>{const M=new AbortController,S=setTimeout(()=>M.abort(),o$);try{const T=await i(dv(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 w("progress");if(!u){if(x===null)y+=1,y>=a$&&(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()},r$))}};return c.addEventListener("click",()=>{if(u){_();return}c.disabled=!0,v=!0,l.textContent="CANCELLING",w("cancel").then(x=>{c.disabled=!1,!u&&(x===null?(v=!1,l.textContent="THE CANCEL GOT NO ANSWER FROM THE SESSION · PRESS CANCEL AGAIN"):x==="unknown"?(v=!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(dv(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 N1=/\.(csv|tsv)$/i;function uv(t){return t.replace(/\x1b\[[0-9;:]*[A-Za-z]/g,"")}function B1(t){return lp.test(t)||qh.test(t)}function fm(t){const e=/_(\d+)\/data\/?$/.exec(t);return e===null?null:parseInt(e[1]??"",10)}function Dl(t){const e=t.match(/\/(?:feeds|jobs)\/feed_(\d+)(?:\/|$)/);return e===null?null:Number(e[1])}function u$(t){return/^\/(proc|net|etc|usr)(\/|$)/.test(t)}function f$(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 p$(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),A=k1(),E=S.split("/").filter(R=>R.length>0).pop()??S,O=d$(E,T,A);t.terminal.line_note(`download: asking the session for ${E}`),n$(T,S,fetch,A).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:uv(T.envelopes.map(O=>O.rendered).join(`
|
|
4347
4347
|
`))};const E=T.envelopes.flatMap(O=>(O.errors??[]).map(R=>R.message)).concat(T.envelopes.map(O=>O.renderedErr??"")).map(O=>uv(O).trim()).filter(O=>O!=="").join(`
|
|
4348
|
-
`);return{ok:!1,text:E===""?"the session refused this read and said nothing further":E}}),c=async(S,T)=>{const A=await fetch(e.vfsUrl_build(S));if(!A.ok||A.body===null)return(await l(S)).text.slice(0,T);const E=A.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(/^.*\//,""),A=await t.client.line_execute(`pipeline diagram ${T}`,{silent:!0,observe:!1});for(const E of A.envelopes){if(E.model?.kind!==yr.pipelineDiagram)continue;const O=zg.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,A)=>{const E=A==="~"?"ls ~":`ls "${A}"`;t.client.line_execute(E,{silent:!0,observe:!1}).then(O=>{for(const R of O.envelopes)T.envelope_observe(R);if(A!=="~"&&T.path_current()!==A.replace(/\/+$/,"")){const R=O.envelopes.find(k=>k.status==="error"),C=R!==void 0?eS(R):"the session answered no listing";T.listing_fail(C),t.terminal.line_note(`files: ${A}: ${C}`)}},O=>{const R=O instanceof Error?O.message:String(O);T.listing_fail(R),t.terminal.line_note(`files: ${A}: ${R}`)})},p=(S,T,A)=>{const E=T.path_current();E!==null&&n.get(S)?.push(E),u(S,T,A)},f=(S,T)=>{const A=n.get(S)?.pop();A!==void 0&&u(S,T,A)},_=S=>{o.get(S)?.()},g=(S,T)=>{r.set(S,T),_(S);const A=s.get("files",S);A?.follow_set(T),T&&A!==void 0&&t.client.line_execute("ls",{silent:!0,observe:!1}).then(E=>{for(const O of E.envelopes)A.envelope_observe(O)})},m=(S,T)=>{const A=s.get("files",S);A!==void 0&&(r.get(S)===!0?t.terminal.line_run("ls"):u(S,A,T))},v=(S,T)=>{e.askOnPane_await(S,{message:`New directory in ${T}: `,kind:"text",commit:"MAKE IT"}).then(A=>{const E=(A??"").trim();E!==""&&(t.terminal.line_run(`mkdir "${T}/${E}"`),m(S,T))})},y=async(S,T,A)=>{for(const E of A){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,A)=>{if(A.kind==="dir"){r.get(S)===!0?t.terminal.line_run(`cd "${A.path}"`):p(S,T,A.path);return}if(A.kind==="plugin"||A.kind==="pipeline"){e.binEntry_show(S,T,A.path,A.kind);return}if(B1(A.path)){e.image_open(S,A.path).then(E=>t.terminal.line_note(E));return}if(i.regard_write(S,{address:A.path,modelKind:"fs.file"}),!i.groupHasViewer(S)){if(Dd(A.path)){T.contentImage_show(A.path,e.vfsUrl_build(A.path));return}l(A.path).then(E=>{if(!E.ok){T.contentRefused_show(A.path,E.text);return}N1.test(A.path)?T.contentTable_show(A.path,E.text):T.content_show(A.path,E.text)})}},w=()=>{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,A)=>{const E=`"${A}"`,O=T.type==="dir"||T.type==="vfs"||T.type==="job",R=Dl(A),C={kind:T.type==="plugin"||T.type==="pipeline"?"catalogue":O&&au(A,T.name)?"seriesFolder":T.type==="file"?"file":"directory",feed:R,node:R===null?null:fm(A),bound:e.catalogue_find(S)!==void 0,projection:u$(A),editable:T.type==="file"&&AC(A)},k={image:()=>{e.image_open(S,A).then(B=>t.terminal.line_note(B))},download:()=>a(A),link:()=>{const B=ay(window.location.origin,A);(s.get("files",S)?.link_copy(A)??navigator.clipboard.writeText(B).then(()=>!0,()=>!1)).then(U=>t.terminal.line_note(U?`link copied: ${B}`:`link (copy it): ${B}`))},process:()=>e.process_open(S,{input:A,feed:R,node:R===null?null:fm(A)}),gather:()=>e.cohort_gather([{kind:O?"dir":"file",seriesUID:A,description:T.name,imagery:au(A,T.name),modality:au(A,T.name)?"MR":"—",patient:e.promptUser()??"",vfsPath:A,folderPath:A}]),run:()=>e.run_press(S,T.name,T.type==="pipeline"?"pipeline":"plugin"),edit:()=>{const B=C1(A),L=H5(T.name,T.size,EC);if(L===null){e.verbLine_run(S,B);return}e.askOnPane_await(S,{kind:"confirm",message:L}).then(U=>{U==="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 fS.rules.filter(B=>B.offered(C)).map(B=>({label:B.label(C),run:()=>k[B.name]?.()}))},x=(S,T)=>{const A=T.map(([k])=>k),E=A.map(k=>`"${k}"`).join(" "),O=[];for(const k of A){const B=Dl(k);B!==null&&!O.includes(B)&&O.push(B)}const R={count:A.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 pS.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:v,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:w,rowVerbs_build:z,instance_build:(S,T,A=!1)=>{const E=e.template_stamp("tpl-pane-files"),O=new sS(e.pane_find(E,".files-panel"),C=>b(S,O,C),d,{catalogue:A});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"}),Dl(k)!==null&&t.client.line_execute(`getfacl "${k}"`,{silent:!0,observe:!1}).then(B=>{O.rowReadout_show(k,f$(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 m$(t,e){const s=Xi("tpl-pane-universe"),i=new j5({canvas:Ys(s,".universe-canvas"),title:Ys(s,".universe-title"),state:s.querySelector(".pane-state"),empty:Ys(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}))(R1(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!==yr.feedDag)continue;const a=Sg.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=Dl(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)},oy());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 g$(t,e,s){const i=Xi("tpl-pane-dag"),n=new b5(Ys(i,".dag-canvas"),Ys(i,".dag-title"),Ys(i,".dag-facts"),Ys(i,".dag-empty"),Ys(i,".dag-strategy"),Ys(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=Dl(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"})},...R1(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 _$(t){return{universe_build:e=>m$(t,e),dag_build:(e,s)=>g$(t,e,s)}}const G1=new Set(["files"]);function b$(t){G1.add(t)}function fv(t){return G1.has(t)}const P1=new Map,ya=new Map;let M$=0;function an(t,e){P1.set(t,e)}function v$(t){const e=P1.get(t);if(e===void 0)throw new Error(`no pane factory registered for kind '${t}'`);const s=e(`${t}-${M$++}`);return ya.set(s.id,s),s}function Jc(t){ya.set(t.id,t)}function Eh(t){return ya.get(t)}function Ah(){return[...ya.values()]}function As(t){const e=ya.get(t);e!==void 0&&(ya.delete(t),e.dispose?.(),e.mount.remove())}class w${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 y$=/Failed to fetch dynamically imported module|error loading dynamically imported module|Importing a module script failed/i;function d_(t){const e=t instanceof Error?t.message:String(t??"");return y$.test(e)}const aa={before:"ARGUS has been updated in the background — ",refresh:"refresh",after:" this page"},z$=`${aa.before}${aa.refresh}${aa.after}`,ld="ARGUS UPDATED IN THE BACKGROUND · REFRESH THIS PAGE";function S$(t,e=document.body){let s=!1;const i=()=>{if(s)return;s=!0,t(`argus: ${z$} (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=aa.refresh,o.title="load the argus the server has now",o.addEventListener("click",()=>{window.location.reload()}),r.append(document.createTextNode(aa.before),o,document.createTextNode(aa.after)),n.append(r),e.appendChild(n)};window.addEventListener("vite:preloadError",()=>{i()}),window.addEventListener("unhandledrejection",n=>{d_(n.reason)&&i()})}const x$=[{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"}],O$=256*1024*1024;function Qc(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 E$(t){const e=t.toUpperCase();return e==="MR"||e==="CT"||e==="PT"?e:"OT"}class A${pane;field;title;modeSpan;stateSpan;layoutPills=new Map;overlayPill;colormapPill;savePill;loadPill;retryPill;presetPill;focusMark;guardBytes=O$;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=pi(e,".image-field"),this.title=pi(e,".pane-title"),this.modeSpan=pi(e,".pane-mode"),this.stateSpan=pi(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=pi(e,".image-overlay"),this.overlayPill.addEventListener("click",()=>{this.overlay_set(!this.overlay)}),this.colormapPill=pi(e,".image-colormap"),this.savePill=pi(e,".image-save"),this.loadPill=pi(e,".image-load"),this.retryPill=pi(e,".image-retry"),this.presetPill=pi(e,".image-preset"),this.focusMark=pi(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()),pi(e,".image-tags").addEventListener("click",()=>this.handlers.tags_open());for(const i of Wb){const n=pi(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=E$(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(()=>Ll(()=>import("./cornerstoneEngine-DOq401ca.js").then(o=>o.b2),__vite__mapDeps([0,1,2,3]),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 ${Qc(e.bytes)} · LOAD FOR STACK`,this.handlers.note(`image: ${Qc(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(()=>Ll(()=>import("./niivueEngine-GirHHMsU.js"),__vite__mapDeps([4,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(!d_(s))throw s}return Es(this.stateSpan,"stale",ld),this.handlers.note(`image: ${ld.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 ${Qc(this.series?.bytes??0)} · LOAD FOR ${e.toUpperCase()}`,this.handlers.note(`image: ${Qc(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 Rz.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=iN(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=mh[(mh.indexOf(this.colormap)+1)%mh.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=x$.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()??Wb),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 pi(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`image pane: missing ${e}`);return s}const L1=["patient","study","series","image","equipment","meta","private","other","varying"],T$=new Set(["meta","private"]),pv="••••";class D${pane;title;modeSpan;redactBlock;listing;handlers;redact=!0;model=null;groups=[];constructor(e,s){this.handlers=s,this.pane=e,this.title=eh(e,".pane-title"),this.modeSpan=eh(e,".pane-mode"),this.redactBlock=eh(e,".tags-redact"),this.redactBlock.addEventListener("click",()=>this.redact_set(!this.redact));const i=eh(e,".tags-panel");this.listing=new Vn({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:ia(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:ia(n=>n.items,{traits:this.itemTraits_declare(),key:n=>n.key,row:{className:()=>"tags-item-row",groupClassName:()=>"tags-item"},child:ia(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:()=>k$("NO TAGS")}),this.redactBlock_paint(),this.listing.rows_set([],{field:"tags"})}model_show(e){this.model=e,this.title.textContent=`TAGS ${C$(e)}`,this.pane.dataset.modality=R$(e),this.groups=I$(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=>!T$.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=pv,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[lf(()=>!0),{key:"group",label:"GROUP",className:"tags-group-name",width:"minmax(12em, 1fr)",cell:e=>e.group.toUpperCase(),compare:e=>L1.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[lf(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?pv:`${e.value} ${e.decoded??""}`).toLowerCase()}]}itemTraits_declare(){return[lf(()=>!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 lf(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 I$(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(W1(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}`}))),L1.filter(s=>e.has(s)).map(s=>({group:s,rows:e.get(s)??[]}))}function W1(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=>W1(n,`${e}/${i+1}/${n.tag}`))})),key:e}}function C$(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 R$(t){const e=(t.constant.find(s=>s.name==="Modality")?.value??"").toUpperCase();return e==="MR"||e==="CT"||e==="PT"?e:"OT"}function k$(t){const e=document.createElement("div");return e.className="tags-note",e.textContent=t,e}function eh(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`tags pane: missing ${e}`);return s}function N$(t,e){const s=Xi("tpl-pane-image"),i=new A$(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=>u_(t,n),tags_open:()=>{t.terminal().line_note(F1(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 B$(t,e){const s=Xi("tpl-pane-tags"),i=new D$(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 u_(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!==ea.tags)continue;const n=_z.safeParse(i.model.data);if(n.success)return n.data}}catch{}return null}function G$(t,e,s){const i=t.panels().get("tags",e);i===void 0||i.path_get()===s||u_(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 F1(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 pm(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!==ea.series)continue;const n=bz.safeParse(i.model.data);if(n.success)return n.data}}catch{}return null}async function U1(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 $1(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 P$(t,e,s,i={},n){t.launcher_yield();const r=e!==null?void 0:lp.test(s)?{address:s,modelKind:"image.volume"}:{address:qh.test(s)?s.slice(0,s.lastIndexOf("/")):s.replace(/\/$/,""),modelKind:"dicom.series"},o=$1(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),lp.test(s))return o.opening_show(s),o.volume_show(s),`image ${s}`;const l=qh.test(s),c=l?s.slice(0,s.lastIndexOf("/")):s.replace(/\/$/,"");o.opening_show(c);let h=await pm(t,c),d=[];if(h===null&&!l){const p=(await U1(t,c)).slice(0,32);for(const f of p){const _=await pm(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 L$(t){return{imageInstance_build:e=>N$(t,e),tagsInstance_build:e=>B$(t,e),tags_ask:e=>u_(t,e),tagsPane_follow:(e,s)=>G$(t,e,s),tagsPane_open:e=>F1(t,e),series_ask:e=>pm(t,e),subfolders_ask:e=>U1(t,e),imagePane_resolve:(e,s)=>$1(t,e,s),image_open:(e,s,i={},n)=>P$(t,e,s,i,n)}}function W$(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 F$(t){return async()=>{const e=await t.ask("proc feeds");let s=[];for(const u of e.envelopes){const p=u.model;if(p===void 0||p.kind!==ep)continue;const f=Qf.safeParse(p.data);f.success&&(s=f.data.feeds)}const n=s.length===0&&e.envelopes.some(u=>u.status==="error")?"INDEX WARMING":`${s.length} FEEDS`,r=s.filter(u=>/error/i.test(u.status)).length,o=s.filter(u=>/running|scheduled|created|started/i.test(u.status)).length,a={key:"universe",name:"UNIVERSE",hue:"--honey",numeral:"",figures:[{text:n}],rows:[],verb:"SEE THE SPACE",about:Ji.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(u=>({text:`${u.id} ${u.title}`,errored:/error/i.test(u.status),open:()=>t.feed_enter(u.id)})),verb:"OPEN THE ROSTER",about:Ji.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:Ji.pacs,enter:()=>t.pacs_open()},d=t.cloud_enter===null?null:{key:"cloud",name:"CLOUD",hue:"--daybreak",numeral:"",figures:[{text:"OCI"}],rows:[{text:"READ · look only",open:t.cloud_enter},{text:"MANAGE · build, tear down, spend",open:t.cloud_enter}],verb:"ENTER CLOUD MANAGEMENT",about:Ji.cloud,enter:t.cloud_enter};return{lead:{tile:l,weight:s.length},afterFiles:[h],afterPanes:d===null?[a]:[a,d],about:{files:{text:"Your ChRIS home: uploads, results and what others shared with you."}}}}}const U$=1500;function $$(t,e){return new Promise(s=>{const i=setTimeout(()=>s(null),e);t.then(n=>{clearTimeout(i),s(n)},()=>{clearTimeout(i),s(null)})})}const j$=["expired","failed","error"];function mv(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 H$(t){return t===null?"REGION":t.includes(":")?t.slice(t.indexOf(":")+1):t}function V$(t){return t.limit.replace(new RegExp(`^(standard-)?${t.family.toLowerCase()}-`),"").replace(/-count$/,"")}function q$(t){const e=t.available===null?`${t.value} PERMITTED`:`${t.available} / ${t.value} FREE`;return`${t.family.toUpperCase()} ${H$(t.zone)} ${V$(t)} ${e}`}function gv(t,e){return`${e==="USD"?"$":`${e} `}${t.toFixed(2)}`}function K$(t){let e=null,s=!1;const i=()=>{if(e!==null)return e;const n=t.ask("capacity");e=n;const r=()=>{e===n&&(e=null),s&&(s=!1,t.repaint?.())};return n.then(r,r),n};return async()=>{const[n,r]=await Promise.all([t.ask("domain status"),$$(i(),t.capacityGraceMs??U$)]),o=r===null;o&&(s=!0);const a=mv(n,zz,v=>Oz.safeParse(v)),l=a?.domains??[];a!==null&&t.names_seen?.(l.map(v=>v.name));const c=v=>v.steps.some(y=>j$.includes(y.state)),h=l.filter(c).length,d=l.filter(v=>v.cost!==void 0&&v.cost!==null),u=d.reduce((v,y)=>v+(y.cost?.hourly??0),0),p=l.filter(v=>v.condition==="GONE").length,f=l.length-p,_={key:"domains",name:"TRUSTED DOMAINS",hue:"--october-sunset",numeral:"",figures:[{text:f===0?"NONE":`${f} TRUSTED DOMAIN${f===1?"":"S"}`},...p>0?[{text:`${p} GONE`}]:[],...h>0?[{text:`${h} NEED${h===1?"S":""} A LOOK`,errored:!0}]:[],...d.length>0?[{text:`${gv(u,d[0]?.cost?.currency??"USD")}/H`}]:[]],rows:l.slice(0,6).map(v=>({text:`${v.name} ${v.condition==="GONE"?"GONE":v.origin==="found"?`${v.condition??"FOUND"} · NOT ADOPTED`:v.lastDone??"NOTHING DONE"}${v.cost!==void 0&&v.cost!==null?` ${gv(v.cost.hourly,v.cost.currency)}/h`:""} ${v.cluster??""}`.trimEnd(),errored:c(v),open:()=>t.domain_open(v.name)})),verb:"OPEN THE CONTROLLER",about:Ji.domains,enter:()=>t.domain_open("")},g=r===null?null:mv(r,Ez,v=>Az.safeParse(v)),m={key:"capacity",name:"CAPACITY",hue:"--honey",numeral:"",figures:g===null?[{text:o?"READING":"NOT READ"}]:[{text:g.region.toUpperCase()}],rows:g===null?[{text:"capacity",open:()=>t.capacity_open("")}]:g.rows.slice(0,6).map(v=>({text:q$(v),errored:v.available===0,open:()=>t.capacity_open(v.family)})),verb:"OPEN CAPACITY",about:Ji.capacity,enter:()=>t.capacity_open("")};return{lead:{tile:_,weight:l.length},afterFiles:[m],afterPanes:[],about:{files:{text:"Your home: the Trusted Domains this session knows, each a folder of its spec, settings, state and steps."}}}}}const Ml=new Set([""]);function Y$(t){const e=new Set(["",...t]);if(e.size===Ml.size&&[...e].every(s=>Ml.has(s)))return!1;Ml.clear();for(const s of e)Ml.add(s);return!0}function X$(t){return{subjects:{domain:Ml},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 Z$(t){return t>=6e4?`${Math.max(1,Math.round(t/6e4))} MIN`:`${Math.max(1,Math.round(t/1e3))} S`}function xi(t){return t.toLocaleString("en-US")}class J${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?`${xi(this.counts.jobs)} JOBS · ${xi(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
|
+
`);return{ok:!1,text:E===""?"the session refused this read and said nothing further":E}}),c=async(S,T)=>{const A=await fetch(e.vfsUrl_build(S));if(!A.ok||A.body===null)return(await l(S)).text.slice(0,T);const E=A.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(/^.*\//,""),A=await t.client.line_execute(`pipeline diagram ${T}`,{silent:!0,observe:!1});for(const E of A.envelopes){if(E.model?.kind!==yr.pipelineDiagram)continue;const O=zg.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,A)=>{const E=A==="~"?"ls ~":`ls "${A}"`;t.client.line_execute(E,{silent:!0,observe:!1}).then(O=>{for(const R of O.envelopes)T.envelope_observe(R);if(A!=="~"&&T.path_current()!==A.replace(/\/+$/,"")){const R=O.envelopes.find(k=>k.status==="error"),C=R!==void 0?eS(R):"the session answered no listing";T.listing_fail(C),t.terminal.line_note(`files: ${A}: ${C}`)}},O=>{const R=O instanceof Error?O.message:String(O);T.listing_fail(R),t.terminal.line_note(`files: ${A}: ${R}`)})},p=(S,T,A)=>{const E=T.path_current();E!==null&&n.get(S)?.push(E),u(S,T,A)},f=(S,T)=>{const A=n.get(S)?.pop();A!==void 0&&u(S,T,A)},_=S=>{o.get(S)?.()},g=(S,T)=>{r.set(S,T),_(S);const A=s.get("files",S);A?.follow_set(T),T&&A!==void 0&&t.client.line_execute("ls",{silent:!0,observe:!1}).then(E=>{for(const O of E.envelopes)A.envelope_observe(O)})},m=(S,T)=>{const A=s.get("files",S);A!==void 0&&(r.get(S)===!0?t.terminal.line_run("ls"):u(S,A,T))},v=(S,T)=>{e.askOnPane_await(S,{message:`New directory in ${T}: `,kind:"text",commit:"MAKE IT"}).then(A=>{const E=(A??"").trim();E!==""&&(t.terminal.line_run(`mkdir "${T}/${E}"`),m(S,T))})},y=async(S,T,A)=>{for(const E of A){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,A)=>{if(A.kind==="dir"){r.get(S)===!0?t.terminal.line_run(`cd "${A.path}"`):p(S,T,A.path);return}if(A.kind==="plugin"||A.kind==="pipeline"){e.binEntry_show(S,T,A.path,A.kind);return}if(B1(A.path)){e.image_open(S,A.path).then(E=>t.terminal.line_note(E));return}if(i.regard_write(S,{address:A.path,modelKind:"fs.file"}),!i.groupHasViewer(S)){if(Dd(A.path)){T.contentImage_show(A.path,e.vfsUrl_build(A.path));return}l(A.path).then(E=>{if(!E.ok){T.contentRefused_show(A.path,E.text);return}N1.test(A.path)?T.contentTable_show(A.path,E.text):T.content_show(A.path,E.text)})}},w=()=>{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,A)=>{const E=`"${A}"`,O=T.type==="dir"||T.type==="vfs"||T.type==="job",R=Dl(A),C={kind:T.type==="plugin"||T.type==="pipeline"?"catalogue":O&&au(A,T.name)?"seriesFolder":T.type==="file"?"file":"directory",feed:R,node:R===null?null:fm(A),bound:e.catalogue_find(S)!==void 0,projection:u$(A),editable:T.type==="file"&&AC(A)},k={image:()=>{e.image_open(S,A).then(B=>t.terminal.line_note(B))},download:()=>a(A),link:()=>{const B=ay(window.location.origin,A);(s.get("files",S)?.link_copy(A)??navigator.clipboard.writeText(B).then(()=>!0,()=>!1)).then(U=>t.terminal.line_note(U?`link copied: ${B}`:`link (copy it): ${B}`))},process:()=>e.process_open(S,{input:A,feed:R,node:R===null?null:fm(A)}),gather:()=>e.cohort_gather([{kind:O?"dir":"file",seriesUID:A,description:T.name,imagery:au(A,T.name),modality:au(A,T.name)?"MR":"—",patient:e.promptUser()??"",vfsPath:A,folderPath:A}]),run:()=>e.run_press(S,T.name,T.type==="pipeline"?"pipeline":"plugin"),edit:()=>{const B=C1(A),L=H5(T.name,T.size,EC);if(L===null){e.verbLine_run(S,B);return}e.askOnPane_await(S,{kind:"confirm",message:L}).then(U=>{U==="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 fS.rules.filter(B=>B.offered(C)).map(B=>({label:B.label(C),run:()=>k[B.name]?.()}))},x=(S,T)=>{const A=T.map(([k])=>k),E=A.map(k=>`"${k}"`).join(" "),O=[];for(const k of A){const B=Dl(k);B!==null&&!O.includes(B)&&O.push(B)}const R={count:A.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 pS.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:v,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:w,rowVerbs_build:z,instance_build:(S,T,A=!1)=>{const E=e.template_stamp("tpl-pane-files"),O=new sS(e.pane_find(E,".files-panel"),C=>b(S,O,C),d,{catalogue:A});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"}),Dl(k)!==null&&t.client.line_execute(`getfacl "${k}"`,{silent:!0,observe:!1}).then(B=>{O.rowReadout_show(k,f$(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 m$(t,e){const s=Xi("tpl-pane-universe"),i=new j5({canvas:Ys(s,".universe-canvas"),title:Ys(s,".universe-title"),state:s.querySelector(".pane-state"),empty:Ys(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}))(R1(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!==yr.feedDag)continue;const a=Sg.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=Dl(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)},oy());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 g$(t,e,s){const i=Xi("tpl-pane-dag"),n=new b5(Ys(i,".dag-canvas"),Ys(i,".dag-title"),Ys(i,".dag-facts"),Ys(i,".dag-empty"),Ys(i,".dag-strategy"),Ys(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=Dl(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"})},...R1(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 _$(t){return{universe_build:e=>m$(t,e),dag_build:(e,s)=>g$(t,e,s)}}const G1=new Set(["files"]);function b$(t){G1.add(t)}function fv(t){return G1.has(t)}const P1=new Map,ya=new Map;let M$=0;function an(t,e){P1.set(t,e)}function v$(t){const e=P1.get(t);if(e===void 0)throw new Error(`no pane factory registered for kind '${t}'`);const s=e(`${t}-${M$++}`);return ya.set(s.id,s),s}function Jc(t){ya.set(t.id,t)}function Eh(t){return ya.get(t)}function Ah(){return[...ya.values()]}function As(t){const e=ya.get(t);e!==void 0&&(ya.delete(t),e.dispose?.(),e.mount.remove())}class w${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 y$=/Failed to fetch dynamically imported module|error loading dynamically imported module|Importing a module script failed/i;function d_(t){const e=t instanceof Error?t.message:String(t??"");return y$.test(e)}const aa={before:"ARGUS has been updated in the background — ",refresh:"refresh",after:" this page"},z$=`${aa.before}${aa.refresh}${aa.after}`,ld="ARGUS UPDATED IN THE BACKGROUND · REFRESH THIS PAGE";function S$(t,e=document.body){let s=!1;const i=()=>{if(s)return;s=!0,t(`argus: ${z$} (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=aa.refresh,o.title="load the argus the server has now",o.addEventListener("click",()=>{window.location.reload()}),r.append(document.createTextNode(aa.before),o,document.createTextNode(aa.after)),n.append(r),e.appendChild(n)};window.addEventListener("vite:preloadError",()=>{i()}),window.addEventListener("unhandledrejection",n=>{d_(n.reason)&&i()})}const x$=[{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"}],O$=256*1024*1024;function Qc(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 E$(t){const e=t.toUpperCase();return e==="MR"||e==="CT"||e==="PT"?e:"OT"}class A${pane;field;title;modeSpan;stateSpan;layoutPills=new Map;overlayPill;colormapPill;savePill;loadPill;retryPill;presetPill;focusMark;guardBytes=O$;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=pi(e,".image-field"),this.title=pi(e,".pane-title"),this.modeSpan=pi(e,".pane-mode"),this.stateSpan=pi(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=pi(e,".image-overlay"),this.overlayPill.addEventListener("click",()=>{this.overlay_set(!this.overlay)}),this.colormapPill=pi(e,".image-colormap"),this.savePill=pi(e,".image-save"),this.loadPill=pi(e,".image-load"),this.retryPill=pi(e,".image-retry"),this.presetPill=pi(e,".image-preset"),this.focusMark=pi(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()),pi(e,".image-tags").addEventListener("click",()=>this.handlers.tags_open());for(const i of Wb){const n=pi(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=E$(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(()=>Ll(()=>import("./cornerstoneEngine-PEP4UIJ7.js").then(o=>o.b2),__vite__mapDeps([0,1,2,3]),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 ${Qc(e.bytes)} · LOAD FOR STACK`,this.handlers.note(`image: ${Qc(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(()=>Ll(()=>import("./niivueEngine-BCKasqoA.js"),__vite__mapDeps([4,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(!d_(s))throw s}return Es(this.stateSpan,"stale",ld),this.handlers.note(`image: ${ld.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 ${Qc(this.series?.bytes??0)} · LOAD FOR ${e.toUpperCase()}`,this.handlers.note(`image: ${Qc(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 Rz.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=iN(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=mh[(mh.indexOf(this.colormap)+1)%mh.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=x$.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()??Wb),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 pi(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`image pane: missing ${e}`);return s}const L1=["patient","study","series","image","equipment","meta","private","other","varying"],T$=new Set(["meta","private"]),pv="••••";class D${pane;title;modeSpan;redactBlock;listing;handlers;redact=!0;model=null;groups=[];constructor(e,s){this.handlers=s,this.pane=e,this.title=eh(e,".pane-title"),this.modeSpan=eh(e,".pane-mode"),this.redactBlock=eh(e,".tags-redact"),this.redactBlock.addEventListener("click",()=>this.redact_set(!this.redact));const i=eh(e,".tags-panel");this.listing=new Vn({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:ia(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:ia(n=>n.items,{traits:this.itemTraits_declare(),key:n=>n.key,row:{className:()=>"tags-item-row",groupClassName:()=>"tags-item"},child:ia(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:()=>k$("NO TAGS")}),this.redactBlock_paint(),this.listing.rows_set([],{field:"tags"})}model_show(e){this.model=e,this.title.textContent=`TAGS ${C$(e)}`,this.pane.dataset.modality=R$(e),this.groups=I$(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=>!T$.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=pv,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[lf(()=>!0),{key:"group",label:"GROUP",className:"tags-group-name",width:"minmax(12em, 1fr)",cell:e=>e.group.toUpperCase(),compare:e=>L1.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[lf(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?pv:`${e.value} ${e.decoded??""}`).toLowerCase()}]}itemTraits_declare(){return[lf(()=>!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 lf(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 I$(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(W1(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}`}))),L1.filter(s=>e.has(s)).map(s=>({group:s,rows:e.get(s)??[]}))}function W1(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=>W1(n,`${e}/${i+1}/${n.tag}`))})),key:e}}function C$(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 R$(t){const e=(t.constant.find(s=>s.name==="Modality")?.value??"").toUpperCase();return e==="MR"||e==="CT"||e==="PT"?e:"OT"}function k$(t){const e=document.createElement("div");return e.className="tags-note",e.textContent=t,e}function eh(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`tags pane: missing ${e}`);return s}function N$(t,e){const s=Xi("tpl-pane-image"),i=new A$(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=>u_(t,n),tags_open:()=>{t.terminal().line_note(F1(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 B$(t,e){const s=Xi("tpl-pane-tags"),i=new D$(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 u_(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!==ea.tags)continue;const n=_z.safeParse(i.model.data);if(n.success)return n.data}}catch{}return null}function G$(t,e,s){const i=t.panels().get("tags",e);i===void 0||i.path_get()===s||u_(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 F1(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 pm(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!==ea.series)continue;const n=bz.safeParse(i.model.data);if(n.success)return n.data}}catch{}return null}async function U1(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 $1(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 P$(t,e,s,i={},n){t.launcher_yield();const r=e!==null?void 0:lp.test(s)?{address:s,modelKind:"image.volume"}:{address:qh.test(s)?s.slice(0,s.lastIndexOf("/")):s.replace(/\/$/,""),modelKind:"dicom.series"},o=$1(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),lp.test(s))return o.opening_show(s),o.volume_show(s),`image ${s}`;const l=qh.test(s),c=l?s.slice(0,s.lastIndexOf("/")):s.replace(/\/$/,"");o.opening_show(c);let h=await pm(t,c),d=[];if(h===null&&!l){const p=(await U1(t,c)).slice(0,32);for(const f of p){const _=await pm(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 L$(t){return{imageInstance_build:e=>N$(t,e),tagsInstance_build:e=>B$(t,e),tags_ask:e=>u_(t,e),tagsPane_follow:(e,s)=>G$(t,e,s),tagsPane_open:e=>F1(t,e),series_ask:e=>pm(t,e),subfolders_ask:e=>U1(t,e),imagePane_resolve:(e,s)=>$1(t,e,s),image_open:(e,s,i={},n)=>P$(t,e,s,i,n)}}function W$(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 F$(t){return async()=>{const e=await t.ask("proc feeds");let s=[];for(const u of e.envelopes){const p=u.model;if(p===void 0||p.kind!==ep)continue;const f=Qf.safeParse(p.data);f.success&&(s=f.data.feeds)}const n=s.length===0&&e.envelopes.some(u=>u.status==="error")?"INDEX WARMING":`${s.length} FEEDS`,r=s.filter(u=>/error/i.test(u.status)).length,o=s.filter(u=>/running|scheduled|created|started/i.test(u.status)).length,a={key:"universe",name:"UNIVERSE",hue:"--honey",numeral:"",figures:[{text:n}],rows:[],verb:"SEE THE SPACE",about:Ji.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(u=>({text:`${u.id} ${u.title}`,errored:/error/i.test(u.status),open:()=>t.feed_enter(u.id)})),verb:"OPEN THE ROSTER",about:Ji.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:Ji.pacs,enter:()=>t.pacs_open()},d=t.cloud_enter===null?null:{key:"cloud",name:"CLOUD",hue:"--daybreak",numeral:"",figures:[{text:"OCI"}],rows:[{text:"READ · look only",open:t.cloud_enter},{text:"MANAGE · build, tear down, spend",open:t.cloud_enter}],verb:"ENTER CLOUD MANAGEMENT",about:Ji.cloud,enter:t.cloud_enter};return{lead:{tile:l,weight:s.length},afterFiles:[h],afterPanes:d===null?[a]:[a,d],about:{files:{text:"Your ChRIS home: uploads, results and what others shared with you."}}}}}const U$=1500;function $$(t,e){return new Promise(s=>{const i=setTimeout(()=>s(null),e);t.then(n=>{clearTimeout(i),s(n)},()=>{clearTimeout(i),s(null)})})}const j$=["expired","failed","error"];function mv(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 H$(t){return t===null?"REGION":t.includes(":")?t.slice(t.indexOf(":")+1):t}function V$(t){return t.limit.replace(new RegExp(`^(standard-)?${t.family.toLowerCase()}-`),"").replace(/-count$/,"")}function q$(t){const e=t.available===null?`${t.value} PERMITTED`:`${t.available} / ${t.value} FREE`;return`${t.family.toUpperCase()} ${H$(t.zone)} ${V$(t)} ${e}`}function gv(t,e){return`${e==="USD"?"$":`${e} `}${t.toFixed(2)}`}function K$(t){let e=null,s=!1;const i=()=>{if(e!==null)return e;const n=t.ask("capacity");e=n;const r=()=>{e===n&&(e=null),s&&(s=!1,t.repaint?.())};return n.then(r,r),n};return async()=>{const[n,r]=await Promise.all([t.ask("cluster status"),$$(i(),t.capacityGraceMs??U$)]),o=r===null;o&&(s=!0);const a=mv(n,zz,v=>Oz.safeParse(v)),l=a?.clusters??[];a!==null&&t.names_seen?.(l.map(v=>v.name));const c=v=>v.steps.some(y=>j$.includes(y.state)),h=l.filter(c).length,d=l.filter(v=>v.cost!==void 0&&v.cost!==null),u=d.reduce((v,y)=>v+(y.cost?.hourly??0),0),p=l.filter(v=>v.condition==="GONE").length,f=l.length-p,_={key:"clusters",name:"OPENSHIFT",hue:"--october-sunset",numeral:"",figures:[{text:f===0?"NONE":`${f} CLUSTER${f===1?"":"S"}`},...p>0?[{text:`${p} GONE`}]:[],...h>0?[{text:`${h} NEED${h===1?"S":""} A LOOK`,errored:!0}]:[],...d.length>0?[{text:`${gv(u,d[0]?.cost?.currency??"USD")}/H`}]:[]],rows:l.slice(0,6).map(v=>({text:`${v.name} ${v.condition==="GONE"?"GONE":v.origin==="found"?`${v.condition??"FOUND"} · NOT ADOPTED`:v.lastDone??"NOTHING DONE"}${v.cost!==void 0&&v.cost!==null?` ${gv(v.cost.hourly,v.cost.currency)}/h`:""} ${v.cluster??""}`.trimEnd(),errored:c(v),open:()=>t.cluster_open(v.name)})),verb:"OPEN THE CONTROLLER",about:Ji.clusters,enter:()=>t.cluster_open("")},g=r===null?null:mv(r,Ez,v=>Az.safeParse(v)),m={key:"capacity",name:"CAPACITY",hue:"--honey",numeral:"",figures:g===null?[{text:o?"READING":"NOT READ"}]:[{text:g.region.toUpperCase()}],rows:g===null?[{text:"capacity",open:()=>t.capacity_open("")}]:g.rows.slice(0,6).map(v=>({text:q$(v),errored:v.available===0,open:()=>t.capacity_open(v.family)})),verb:"OPEN CAPACITY",about:Ji.capacity,enter:()=>t.capacity_open("")};return{lead:{tile:_,weight:l.length},afterFiles:[m],afterPanes:[],about:{files:{text:"Your home: the clusters this session knows, each a folder of its spec, settings, state and steps."}}}}}const Ml=new Set([""]);function Y$(t){const e=new Set(["",...t]);if(e.size===Ml.size&&[...e].every(s=>Ml.has(s)))return!1;Ml.clear();for(const s of e)Ml.add(s);return!0}function X$(t){return{subjects:{cluster:Ml},views:{},claims:{},listings:{},chords:[],lines:[{after:"view",line:"cluster [<name>] (the TD controller takes the screen; every other cluster line is the session's)"}],run:(e,s)=>{if(s.subject==="cluster")return t().controller_open(s.words[0]??"")}}}function Z$(t){return t>=6e4?`${Math.max(1,Math.round(t/6e4))} MIN`:`${Math.max(1,Math.round(t/1e3))} S`}function xi(t){return t.toLocaleString("en-US")}class J${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?`${xi(this.counts.jobs)} JOBS · ${xi(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(`
|
|
4349
4349
|
`),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 ${xi(s.loaded)} / ${s.total!==void 0?xi(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:`${xi(l.running)} IN ${xi(l.runningFeeds)} FEEDS · SCHEDULED ${xi(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 ${xi(l.errored)} IN ${xi(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?xi(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 ${xi(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 ${xi(l.loaded)} / ${c}${h!==null?` · ETA ${Z$(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 Q$(t,e){const s=new J$(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 ej{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),Jz(e.address)&&Qz(e.address,s).then(n=>{n===null||this.currentAddress!==e.address||!i.isConnected||i.replaceWith(n)}).catch(()=>{})})}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 tj{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 cf=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],sj=new Set(["done","error","unconfirmed","stalled","timeout"]),ij={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 nj(t){return t.length===0?"":`Calypso was started with --host-control: ${t.map(e=>ij[e]??e).join("; ")}.`}function rj(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&&sj.has(e.status)){t.delete(s);return}t.add(s)}const oj=100;class aj{fields;buildShown=!1;running=new Set;activityTimer=null;activityFrame=0;constructor(e){this.fields={identity:or(e,"status-identity"),jobs:or(e,"status-jobs"),activity:or(e,"status-activity"),latency:or(e,"status-latency"),mismatch:or(e,"status-mismatch"),lamp:or(e,"status-lamp"),host:or(e,"status-host"),questions:or(e,"status-questions")}}attach_show(e){if(e.protocolVersion!==Uf){this.fields.mismatch.textContent=`WIRE V${e.protocolVersion} ≠ V${Uf}`,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=nj(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(`
|
|
4350
4350
|
`)}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(`
|
|
4351
4351
|
`):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){rj(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=cf[this.activityFrame]??cf[0];this.fields.activity.textContent=`${s} ${this.running.size} RUNNING`};e(),this.activityTimer===null&&(this.activityTimer=window.setInterval(()=>{this.activityFrame=(this.activityFrame+1)%cf.length,e()},oj))}}function or(t,e){const s=t.getElementById(e);if(s===null)throw new Error(`status bar: no element with id '${e}'`);return s}const lj=3e3;class cj{mount;clock;line_send;lane=void 0;cube=void 0;beatAt=null;constructor(e,s=()=>Date.now(),i){this.mount=e,this.clock=s,this.line_send=i,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})}for(const r of s?.joblets??[])e.push({label:`%${r.number}`,value:`${r.line} · ${r.waiting?`WAITING · FG %${r.number} TO ANSWER`:"RUNNING"}`,title:`Joblet %${r.number}, run in the background: its log is /proc/joblets/${r.number}/log.`,degraded:r.waiting,stop:`kill %${r.number}`});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>=lj})}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");if(r.className="telemetry-value",r.textContent=s.value,i.append(n,r),s.stop!==void 0&&this.line_send!==void 0){const o=document.createElement("button");o.type="button",o.className="lane-stop",o.textContent="STOP",o.title=s.stop;const a=this.line_send,l=s.stop;o.addEventListener("click",()=>a(l)),i.appendChild(o)}this.mount.appendChild(i)}}}const hj=[2,3,3,2,2,11,2,2],dj=4,_v=300,uj=2600,fj=650;class pj{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(),_v);return}const s=this.narrowSources_list(),i=this.wideSources_list();let n=0,r=0;for(const o of hj){const a=document.createElement("div");a.className="data-column";for(let l=1;l<=dj;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=bv(d.source(),o),a.appendChild(c),this.cells.push(d)}e.appendChild(a)}window.setInterval(()=>this.beat_paint(),_v),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,()=>mj()]}uptimeSeconds_get(){return Math.floor((Date.now()-this.bootedAt)/1e3)}beat_paint(){for(const e of this.cells){const s=bv(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"),fj))},uj)}}function bv(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 mj(){const t=new Date;return t.getHours()*1e4+t.getMinutes()*100+t.getSeconds()}const gj=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 Fd(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(),gj)))}envelope_observe(e){if(e.model?.kind!==yr.pipelineDiagram)return;const s=zg.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 bj(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 Mv=new Set(["layout","slice","series","wl","colormap","save","tags","load","guard","ghost","state"]);function Mj(t,e,s,i,n){if(s==="layout")return Kr(t,e,".dag-strategy",i.toUpperCase())?`layout ${i}`:"dag layout ranked|molecule";if(s==="projection")return Kr(t,e,".dag-projection",i.toUpperCase())?`projection ${i}`:"dag projection 2d|3d";if(s==="scale")return Kr(t,e,".dag-scale",i.toUpperCase())?`scale ${i}`:"dag scale time|size";if(s==="hue")return Kr(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"?Kr(t,e,o,h==="on"?l:c)?`${a} ${h}`:`dag ${a}: no mode frame`:h!==""?`dag ${a} on|off`:Nn(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 Kr(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 _h(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 vj(t,e,s){return s==="enter"?_h(t,e,"ENTER NODE")?"entering node":"node enter: no DAG drawer":s==="back"?_h(t,e,"BACK")?"node back":"node back: no DAG drawer":s==="immerse"?t.node_immerse(e)?"immersing":"node immerse: nothing indicated":s==="clear"?_h(t,e,"CLEAR DETAIL")?"detail cleared":"node clear: no DAG drawer":`node: unknown verb '${s}' (enter|immerse|back|clear)`}function wj(t){return{subjects:{runs:null,node:null,dag:null,universe:null,pacs:new Set(["sort","filter"]),tags:new Set(["redact","filter"]),image:Mv},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 Mj(n,c,a,l,o);if(r==="image"){const h=o.filter(d=>d!=="--force");return Mv.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)):vj(n,c,a)}}}function jl(t,e){if("pane"in t)return t.pane===e?[]:null;const s=jl(t.first,e);if(s!==null)return[{node:t,side:"first"},...s];const i=jl(t.second,e);return i!==null?[{node:t,side:"second"},...i]:null}function Hl(t,e,s){if(t===e)return s;if("pane"in t)return null;const i=Hl(t.first,e,s);if(i!==null)return{...t,first:i};const n=Hl(t.second,e,s);return n!==null?{...t,second:n}:null}function vv(t,e,s){const i=jl(t,e);if(i===null||i.length===0)return"lone";const n=Gi[s].axis,r=Gi[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=hd(t,e);if(l===null)return"lone";const c={pane:e};return Hl(l,a,r==="first"?{dir:n,ratio:.5,first:a,second:c}:{dir:n,ratio:.5,first:c,second:a})??"edge"}const wv="argus-layout";class yj{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(wv);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=cd(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=vv(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=jl(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=Hl(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=jl(this.tree,e);if(n===null||n.length===0)return!1;const r=Gi[s].axis;for(let o=n.length-1;o>=0;o-=1){const a=n[o];if(a.node.dir!==r)continue;const l=Gi[s].place==="after",c=Math.min(.85,Math.max(.15,a.node.ratio+(l?i:-i))),h={...a.node,ratio:c},d=Hl(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 vv(this.tree,e,s)!="string"}leaf_replace(e,s){if(this.tree===null)return!1;const i=cd(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=hd(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(wv,JSON.stringify(this.prefs))}catch{}}}function cd(t,e,s){if("pane"in t)return t.pane===e?s:null;const i=cd(t.first,e,s);if(i!==null)return{...t,first:i};const n=cd(t.second,e,s);return n!==null?{...t,second:n}:null}function hd(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=hd(t.first,e);if(s!==null)return{...t,first:s};const i=hd(t.second,e);return i!==null?{...t,second:i}:null}const zj=4e3;function Sj(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};Es(c,"note",l),e.set(c,setTimeout(()=>{e.delete(c),c.textContent===l&&(c.className=d.className,c.textContent=d.text)},zj))};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 ${Gi[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 ${Gi[l].focusWord}`:`pane resize ${Gi[l].focusWord}: no boundary that way`,chordKeys_format:(a,l)=>{const c=_n.filter(h=>h.selector===a&&h.move===!0===l).map(h=>h.key);return c.length===0?"":` [keys ${c.join(" ")}]`}}}const xj={image:"viewer",view:"viewer",dir:"files",fs:"files",tags:"tags",empty:"pane",domain:"dag",catalogue:"catalogue",graph:"dag",gather:"gather",edit:"editor"},hf=240;function Oj(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,w,z,x)=>{o.set(y,{parent:b,dir:w,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 A of y){const E=n(A)?.mount;if(E===void 0)continue;const O=E.getBoundingClientRect();O.width>0&&O.height>0&&b.push({id:A,left:O.left,top:O.top,width:O.width,height:O.height})}if(b.length===0)return;const w=Math.min(...b.map(A=>A.left)),z=Math.min(...b.map(A=>A.top)),x=Math.max(...b.map(A=>A.left+A.width))-w,M=Math.max(...b.map(A=>A.top+A.height))-z;if(x<=0||M<=0)return;const S=hf/x,T=Math.max(40,Math.min(260,Math.round(M*S)));try{const A=document.createElement("canvas");A.width=hf,A.height=T;const E=A.getContext("2d");if(E===null)return;const R=getComputedStyle(document.documentElement).getPropertyValue("--harvestgold").trim()||"#c9a15a";E.fillStyle="#05070a",E.fillRect(0,0,hf,T);for(const C of b){const k=Math.round((C.left-w)*S),B=Math.round((C.top-z)*S),L=Math.max(6,Math.round(C.width*S)),U=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,U/ee.height),ce=Math.round(ee.width*X),Oe=Math.round(ee.height*X);E.fillStyle="#000",E.fillRect(k,B,L,U),E.drawImage(ee,k+Math.round((L-ce)/2),B+Math.round((U-Oe)/2),ce,Oe)}else E.fillStyle="rgba(255,255,255,0.05)",E.fillRect(k,B,L,U),E.fillStyle=R,E.font=`${Math.max(9,Math.min(28,Math.round(Math.min(L,U)*.5)))}px serif`,E.textAlign="center",E.textBaseline="middle",E.fillText(d(C.id),k+L/2,B+U/2+1);E.strokeStyle="rgba(255,255,255,0.22)",E.lineWidth=1,E.strokeRect(k+.5,B+.5,L-1,U-1)}return A.toDataURL("image/png")}catch{return}},p=(y,b,w)=>{const z=c(y),x=o.get(y),M={dir:x?.dir??"col",side:SB(x?.before??!1)};if(fv(y)){const T=b==="dag"?"runs":b,A=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,...A!==null?{query:A}:{},...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:w,...M}};if(z==="image"){const T=i.get("image",y),A=T?.state_get()??null;if(T===void 0||A===null||A.path===null)return null;const E=[];A.layout!=="single"&&E.push(`image layout ${A.layout}`),A.colormap!==void 0&&A.colormap!=="gray"&&E.push(`image colormap ${A.colormap}`),A.voi!==void 0&&A.voi!==null&&E.push(`image wl ${A.voi.lower} ${A.voi.upper}`),A.slice>1&&E.push(`image slice ${A.slice}`),A.ghost!==void 0&&A.ghost!==null&&A.layout==="slab"&&E.push(`image ghost ${A.ghost}`);const O=T.series_get(),R=[O?.seriesDescription??"",O?.modality??""].filter(C=>C!=="");return{action:{op:"image",path:A.path,target:w,...M,...E.length>0?{view:E}:{}},anchor:A.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:w,...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:w,...M}}}if(z==="gather"){const T=i.get("gather",y);if(T===void 0)return null;const A=[...T.entries_get()],E=T.name_get(),O=T.feed_get();return{action:{op:"gather",series:A,target:w,...M,...E!==null?{name:E}:{},...O!==null?{feed:O.feedId,root:{instance:O.rootInstanceId,path:O.path}}:{}},label:E??`GATHER · ${A.length} series`}}if(z==="dag"){const T=i.get("dag",y)?.feed_get()??null;return T===null?null:{action:{op:"graph",feed:T,target:w,...M}}}if(z==="tags")return{action:{op:"tags",target:w,...M}};if(z==="edit"){const T=i.get("edit",y)?.path_get()??null;return T===null?null:{action:{op:"edit",path:T,target:w,...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 w=Ah().map(U=>U.id).filter(U=>y.has(U)),z=new Map;let x,M;const S=[];for(const U of w){const ee=z.get(o.get(U)?.parent??"")??0,X=p(U,b,ee);X!==null&&(z.set(U,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(U=>U.op!=="domain"||U.feed!==void 0);if(T.length===0)return;const A=u(w),E=U=>{if("pane"in U){const ce=z.get(U.pane);return ce===void 0?null:{leaf:ce}}const ee=E(U.first),X=E(U.second);return ee===null?X:X===null?ee:{dir:U.dir,ratio:U.ratio,first:ee,second:X}},O=s.tree_get(),R=O===null?null:E(O),C=[...new Set(T.map(U=>xj[U.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 U=T.map(ce=>ce.path).find(ce=>ce!==void 0),ee=T.map(ce=>ce.path??(ce.input!==void 0?`catalogue:${ce.input}`:ce.series!==void 0?`gather:${ce.series.map(Oe=>Oe.seriesUID).join(",")}`:ce.feed!==void 0?`feed:${ce.feed}`:ce.op)).sort().join("|"),X=b==="dag"?"RUNS":b.toUpperCase();k=`${b}:${ee}`,B=M!==void 0&&M!==""?M:U!==void 0?U.split("/").pop()??U:`${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},...A===void 0?{}:{thumbnail:A},lastTouched:Date.now()})},_=()=>{const y=new Set(s.panes_shown());for(const b of Ah())y.has(b.id)||fv(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 w=S=>Ah().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)=>w(S).find(A=>!T.has(A))??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,A=y.view??[],E=i.get("dag","dag");if(E?.feed_enter(T),A.length>0&&E!==void 0){const O=R=>{if(E.graph_isShown()&&E.feed_get()===T){for(const C of A)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,A=x(()=>e.image_open(null,T,{},R=>{S=R})),E=y.view,O=S;return E!==void 0&&E.length>0&&O!==null&&A.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(w("files")),T=y.path;return x(()=>e.dir_open(T)),M("files",S)}if(y.op==="tags"){const S=new Set(w("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()),A=y.input;x(()=>e.process_open(b??"files",{input:A,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(w("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 w=[];for(const z of b.actions){const x=w[z.target??0]??null;w.push(m(z,x))}if(b.shape!==void 0){const z=M=>{if("leaf"in M){const A=w[M.leaf]??null;return A===null?null:{pane:A}}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 Ej=2200;function Aj(t){return/\x1b\[/.test(t)?Cn(t):si(t).replace(/("[^&]*")/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 Tj(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=HB(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 yv(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=UB(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(O0(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(O0(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 Ij(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"),Ej)};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 Cj(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",ii(m),_.appendChild(m);const v=new Fd(_,{select:w=>g.facts_show(m,w.id,!1,u),activate:w=>y(w),deselect:()=>m.replaceChildren()},{}),y=w=>{v.flight_into(w.id,()=>{s={scene:v,facts:m},g.facts_show(m,w.id,!0,u)})};p=v,v.graph_set({nodes:g.nodes},{wave:!1}),v.size_fit(),f=Ij(_,v,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(`
|
|
4352
4352
|
`);for(const f of u.envelopes){if(f.model?.kind!==yr.pipelineDiagram)continue;const _=zg.safeParse(f.model.data);if(!_.success)continue;const g=new Map(_.data.nodes.map(m=>[m.id,m]));return{text:Aj(p),nodes:_.data.nodes.map(m=>({id:m.id,label:m.label,parentIds:m.parentIds,joinParentIds:m.joinParentIds})),facts_show:(m,v,y,b)=>{const w=_.data.nodes.map(z=>z.label);yv(m,Tj(g.get(v),y,b!==null,w),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!==pk)continue;const p=fk.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,v)=>{yv(_,Dj(f,m,v!==null),m,v)}}}return null},o=(c,h,d,u)=>{const p=e.catalogue_find(c);if(p===void 0)return null;const f=d.replace(/^.*\//,"");return uS(h.commandLine_get())!==f&&h.commandLine_set(cS(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 Rj(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 v=f.replace(/\/+$/,"");if(m.path!==v&&!m.path.startsWith(`${v}/`)){a(p),t.sound("audio3");return}const y=m.path.startsWith("/proc/jobs/")?(m.path.split("/").pop()??"").match(/_(\d+)$/):null;if(y!==null){const w=parseInt(y[1]??"",10);a(p,()=>{o(p)?.node_flyTo(w)!==!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(v=>t.terminal.line_note(v));return}if(Dd(m.path)){_.contentImage_show(m.path,e.vfsUrl_build(m.path));return}e.fileText_fetch(m.path).then(v=>{if(!v.ok){_.contentRefused_show(m.path,v.text);return}e.tableFile_is(m.path)?_.contentTable_show(m.path,v.text):_.content_show(m.path,v.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 v=document.createElement("div");v.className="node-overlay",v.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),v.append(y);const w=y.querySelector(".files-panel");if(w===null)throw new Error("pane template is missing .files-panel");const z=[],x=new sS(w,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:v,panel:x,history:z}),x.ceiling_set(f,"EXIT NODE"),b.addEventListener("click",()=>{a(p),t.sound("audio3")}),g.appendChild(v),window.requestAnimationFrame(()=>v.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 f_(t,e,s){if(t.ask_isOpen()){const o=t.ask_note(s.message),a=await ad(e,s);return o(s.kind==="secret"&&a!==null?"••••••":a),a}const i=ad(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"?E1():t.ask_settle(r.answer),r.answer}function kj(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 v=s.get("files",g.id),y=u.path?.anchor??"~";v!==void 0&&e.rootedListing_show(g.id,v,y);const b=g.mount.querySelector(".files-body");if(b===null)return As(g.id),p.mount_remove(g.id),null;const w=document.createElement("div");w.className="errand-bar",b.insertBefore(w,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",w.append(z,x,M);const S=()=>{const E=v?.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 A=()=>{T||S()};return g.mount.addEventListener("click",A),f.question_set(!0),new Promise(E=>{const O=R=>{g.mount.removeEventListener("click",A),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 f_(f,_,p)}}}class Nj{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 zv(t){return(t.kind??"series")==="series"?void 0:t.vfsPath}const df="cohort";function Bj(t){return/[",\n\r]/.test(t)?`"${t.split('"').join('""')}"`:t}function Gj(t){const e=document.createElement("p");return e.className="files-empty",e.textContent=t,e}class Sv{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 Vn({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:ia(()=>[...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:()=>Gj("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 ${sn(e)}`)}member_remove(e){this.handlers.verb_send(`gather remove ${sn(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:df}]}],{field:"gather"}),this.cohort.size()>0&&this.listing.open_set(0,[df]),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(df))}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=wS(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}},eG),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 _S.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??zv(i.entry);n!==void 0&&this.handlers.image_open(n)},process:i=>{const n=i.entry.folderPath??zv(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 gS.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 ${sn(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(Bj).join(","))];this.handlers.command_run("mkdir -p ~/gather"),this.handlers.command_show(`touch --withContents '${s.join(`
|
|
4353
4353
|
`)}' ~/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 xv="gather.cohort";function Pj(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 Lj(t,e){const{panels:s,subjects:i}=t,n=new Nj;let r=null,o=!1;const a=b=>{if(b===null||typeof b!="object")return;const w=b,z=Array.isArray(w.series)?w.series.filter(M=>typeof M?.vfsPath=="string").map(Pj):[],x=w.feed;r===null&&z.length>0&&(r=f()),n.state_adopt(z,typeof w.name=="string"?w.name:null,x??null),p(),e.stage_relight()},l=b=>{for(const w of b.envelopes)w.model?.kind===xv&&a(w.model.data)},c=async(b,w=!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
|
|
4354
|
-
`);return}(w||M.envelopes.some(S=>S.status==="error"))&&z.outcome_write(M),l(M)},h=[],d=b=>{const w=h.length===0;for(const z of b)z.vfsPath!==""&&!h.includes(z.vfsPath)&&h.push(z.vfsPath);!w||h.length===0||queueMicrotask(()=>{const z=h.splice(0);z.length>0&&c(`gather add ${z.map(sn).join(" ")}`)})},u=(b,w,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}),...w,...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"),w=()=>e.errandHost_find()??"pacs",z=x=>f_(t.terminal,e.element_require("header-gather"),x);return new Sv(b,e.pane_find(b,".gather-rows"),u(w,{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 w=e.template_stamp("tpl-pane-gather"),z=new Sv(w,e.pane_find(w,".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:w,dispose:()=>{s.delete(b),i.pane_leave(b)}}},has:b=>n.has(b),gather:b=>{r===null&&(r=f()),d(b);const w=document.body.dataset.header==="away";(!o||!w)&&(document.body.dataset.header="gather",o=!1),p()},open:(b,w="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(w)?w:e.errandHost_find()??w,T=e.instance_spawn("gather","pacs"),A=e.replayPlace_get();if(!z.leaf_split(S,A?.dir??"row",T.id,A?.before??!1))return As(T.id),z.mount_remove(T.id),null;e.birth_record(T.id,S,A?.dir??"row",A?.before??!1),M=T.id}return s.get("gather",M)===void 0?null:(d(b),M)},stage:()=>{const{layout:b}=t,w=new Set(b.panes_shown()),z=s.ids("gather").find(x=>w.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===xv&&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),Es(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 Ll(()=>import("./field-DLtY8hYm.js"),__vite__mapDeps([5,6]),import.meta.url)}catch(i){if(!d_(i))throw i;return Es(this.stateSpan,"stale",ld),this.handlers.note(`edit: ${ld.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){Es(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||Es(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?Es(this.stateSpan,"wait","SAVING"):e?Es(this.stateSpan,"note","DIRTY"):Es(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 Fj(t,e){const{layout:s,panels:i,subjects:n}=t,r=async(d,u)=>{const p=await oa(t,I1(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??yg(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 _=C1(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(v=>v.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 Uj{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 Vn({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=_n.map(o=>({key:`k:${o.key}`,name:o.key,does:o.does,topic:o.topic})),i=ga.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 $j(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 Uj(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 uf=["___________________ _-_ ","\\__(==========/_=_/ ____.---'---`---.____"," \\_ \\ \\----._________.----/"," \\ \\ / / `-_-' "," __,--`.`-'..'-_ "," /____ || "," `--.____,-' "];function jj(){const t=uf[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-uf.length)/2));uf.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 Ov="ハミヒーウシナモニサワツオリアホテマケメエカキムユラセネスタヌヘ0123456789Z:・.=*+-<>¦|";function Hj(){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(Ov[Math.floor(i()*Ov.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 Vj(){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 qj(){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 Ev=[[[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]]],io=10,ho=20;function Kj(){return{well:Array.from({length:ho},()=>Array(io).fill(0)),piece:null,score:0,lines:0,over:!1}}function p_(t,e){return e.cells.every(([s,i])=>{const n=e.x+s,r=e.y+i;return n>=0&&n<io&&r<ho&&(r<0||t[r][n]===0)})}function ff(t){const e=Math.max(...t.cells.flat())+1;return{...t,cells:t.cells.map(([s,i])=>[e-1-i,s])}}function Yj(t,e){const s=Math.floor(e()*Ev.length),i={cells:Ev[s].map(n=>[n[0],n[1]]),x:3,y:0,kind:s+1};if(!p_(t.well,i)){t.over=!0;return}t.piece=i}function Xj(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=ho-s.length;for(;s.length<ho;)s.unshift(Array(io).fill(0));t.well=s,t.lines+=i,t.score+=[0,100,300,500,800][i]??800,t.piece=null}function mm(t,e){if(t.over)return;if(t.piece===null){Yj(t,e);return}const s={...t.piece,y:t.piece.y+1};p_(t.well,s)?t.piece=s:Xj(t)}function Zj(t,e,s){if(t.over||t.piece===null)return!1;const i=t.piece,n=r=>p_(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(ff(i))||n({...ff(i),x:i.x-1})||n({...ff(i),x:i.x+1}),!0;case"ArrowDown":case"j":case"s":return mm(t,s),!0;case" ":{for(;t.piece!==null;)mm(t,s);return!0}default:return!1}}function Jj(){const t=Kj();let e=Math.random;return{title:"TETRIS",tick:500,step:(s,i)=>{e=i,mm(t,i)},draw:(s,i)=>{const n=Math.max(0,Math.floor((s.cols-(io*2+2))/2)),r=Math.max(0,Math.floor((s.rows-ho-1)/2)),o=["",i.cool,i.lit,i.warn,i.dim,i.lit,i.cool,i.warn];for(let a=0;a<ho;a++){s.put(n,r+a,"|",i.dim),s.put(n+io*2+1,r+a,"|",i.dim);for(let l=0;l<io;l++){const c=t.well[a][l];c!==0&&s.text(n+1+l*2,r+a,"[]",o[c])}}if(s.text(n,r+ho,"+"+"-".repeat(io*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=>Zj(t,s,e),status:()=>`${t.score} · ${t.lines} lines${t.over?" · OVER":""}`,over:()=>t.over}}function Qj(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 j1(r,s),r}function j1(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 e6={up:"down",down:"up",left:"right",right:"left"};function t6(t,e){e6[e]!==t.heading&&(t.next=e)}function s6(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,j1(t,e)):t.body.pop()}const i6={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 n6(){let t=null;return{title:"SNAKE",tick:140,step:(e,s)=>{t===null&&(t=Qj(Math.max(8,e.cols>>1),Math.max(6,e.rows-1),s)),s6(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=i6[e];return s===void 0||t===null?!1:(t6(t,s),!0)},status:()=>t===null?"":`${t.score}${t.over?" · OVER":""}`,over:()=>t?.over??!1}}const H1={sl:jj,cmatrix:Hj,rain:Vj,aquarium:qj,tetris:Jj,snake:n6};function r6(t){return t in H1}const o6=8,a6=26,pf=1.8,l6=100,Av=24;function Tv(t,e){let s=Math.floor(t/l6);return e/(s*pf)<Av&&(s=Math.floor(e/Av/pf)),s=Math.max(o6,Math.min(a6,s)),{w:s,h:Math.round(s*pf)}}class c6{pane;field;canvas;state;focusMark;pausePill;program=null;name=null;paused=!1;timer=null;frame=null;observer;constructor(e){this.pane=e,this.field=il(e,".games-field"),this.canvas=il(e,".games-canvas"),this.state=e.querySelector(".pane-state"),this.focusMark=il(e,".games-focus"),this.pausePill=il(e,".games-pause"),this.field.tabIndex=0,this.pausePill.addEventListener("click",()=>this.pause_toggle()),il(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=H1[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=Tv(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=Tv(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 il(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`games pane: missing ${e}`);return s}function h6(t,e){const{layout:s,panels:i,subjects:n}=t;return{instance_build:a=>{const l=e.template_stamp("tpl-pane-games"),c=new c6(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"||!r6(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 it(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 _r=["cruiser","raptor","talon","warbird"],d6={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>'},Il="tm-";function V1(t,e=null){return t==="klingon"?`${Il}klingon-${e!==null&&_r.includes(e)?e:_r[0]}`:`${Il}${t}`}function u6(){if(document.getElementById(`${Il}ship`)!==null)return null;const t=it("svg",{class:"tm-defs",width:0,height:0,"aria-hidden":"true"}),e=it("defs",{});for(const[i,n]of Object.entries(d6)){const r=it("symbol",{id:`${Il}${i}`,viewBox:"0 0 24 24"});r.innerHTML=n,e.append(r)}const s=(i,n)=>{const r=it("radialGradient",{id:`${Il}${i}`});for(const[o,a,l]of n){const c=it("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 m_(t,e,s=null,i=0){const n=it("g",{class:`tm-mark tm-mark-${t}`});return n.append(it("use",{href:`#${V1(t,s)}`,x:-e.size/2,y:-e.size/2,width:e.size,height:e.size,class:"tm-symbol"})),q1(n,e.cx,e.cy,i),n}function q1(t,e,s,i=0){t.setAttribute("transform",i===0?`translate(${e} ${s})`:`translate(${e} ${s}) rotate(${i})`)}function g_(t,e=null){const s=it("svg",{viewBox:"0 0 24 24",class:`tm-icon tm-icon-${t}`,"aria-hidden":"true"});return s.append(it("use",{href:`#${V1(t,e)}`})),s}const th={ship:"E",klingon:"K",base:"#",inhabited:"@",star:"*",hole:" ",supernova:"///"},f6=[{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"}],p6=/^Klingon at (\d+),(\d+) moves to (\d+),(\d+)/,m6=/^Klingon at (\d+),(\d+) escapes to quadrant/,g6=/\*\*\* Klingon at (\d+),(\d+) destroyed \*\*\*/;class Cl{marks=new Map;mark_find(e){return this.marks.get(Cl.key_format(e))??null}line_hear(e){const s=p6.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=m6.exec(e)??g6.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=>Cl.key_format(n)));for(const n of[...this.marks.keys()])i.has(n)||this.marks.delete(n);e.forEach((n,r)=>{const o=Cl.key_format(n);if(s.byOrder===!0){this.marks.set(o,_r[r%_r.length]);return}this.marks.has(o)||this.marks.set(o,this.leastWorn_get())})}clear(){this.marks.clear()}leastWorn_get(){const e=new Map(_r.map(i=>[i,0]));for(const i of this.marks.values())e.set(i,(e.get(i)??0)+1);let s=_r[0];for(const i of _r)(e.get(i)??0)<(e.get(s)??0)&&(s=i);return s}static key_format(e){return`${e.x},${e.y}`}}function _6(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 Y(t,e,s){const i=document.createElement(t);return i.className=e,s!==void 0&&(i.textContent=s),i}function Zs(t,e,s){const i=Y("button",`tb-pill ${t}`,e);return i.type="button",i.addEventListener("click",s),i}const b6=16;class K1{constructor(e,s,i){this.onCommit=i,this.size=e;const n=e/2;this.root=Y("div","tb-wheel");const r=it("svg",{width:e,height:e,viewBox:`0 0 ${e} ${e}`,role:"img","aria-label":s});r.classList.add("tb-wheel-face"),r.append(it("circle",{cx:n,cy:n,r:n-4,class:"tb-wheel-rim"})),r.append(it("circle",{cx:n,cy:n,r:(n-4)*.66,class:"tb-wheel-ring"})),r.append(it("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(it("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=it("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=it("path",{d:"",class:"tb-wheel-wedge"}),r.append(this.wedge),this.marks=it("g",{class:"tb-wheel-marks"}),r.append(this.marks),this.needle=it("line",{x1:n,y1:n,x2:n,y2:14,class:"tb-wheel-needle"}),r.append(this.needle),r.append(it("circle",{cx:n,cy:n,r:6,class:"tb-wheel-hub"})),this.root.append(r);const o=Y("div","tb-wheel-row");this.readout=Y("span","tb-wheel-readout","0°"),this.commit=Zs("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=m_(i.kind,{cx:o,cy:a,size:b6},i.variant??null,l);c.classList.add("tb-wheel-mark",`tb-wheel-mark-${i.kind}`);const h=it("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 Tr{constructor(e,s,i,n){this.digits=i,this.onCommit=n,this.root=Y("div","tb-slider");const r=Y("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=Y("div","tb-slider-column");this.ticks=Y("div","tb-slider-ticks"),this.note=Y("span","tb-slider-note"),o.append(this.input,this.ticks,this.note),this.shown=Y("span","tb-slider-readout","—"),this.commit=Zs("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(Y("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 sh{root;buttons=[];note;constructor(e,s,i){this.root=Y("div","tb-pillrow"),e!==""&&this.root.append(Y("span","tb-slider-label",e));const n=Y("div","tb-slider-column"),r=Y("div","tb-pills");for(const o of s){const a=Zs("tb-choice",o.label,()=>i(o.line,o.label));a.dataset.line=o.line,this.buttons.push(a),r.append(a)}this.note=Y("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 M6=["panel-3","panel-4","panel-5","panel-6"];function Ot(t,e,s){const i=document.createElement(t);return e!==""&&(i.className=e),s!==void 0&&(i.textContent=s),i}function Dv(t,e){const s=Ot("div",e===""?"bar-panel":`bar-panel ${e}`);for(let i=t;i<t+5;i++)s.append(Ot("div",`bar-${i}`));return s}function Iv(t,e){const s=Ot("div","lcars-terminal-header-bar files-header-bar"),i=Ot("div","lcars-bar-horizontal"),n=Ot("span","lcars-title",t),r=Ot("span","lcars-terminal-status",e);return i.append(n,r),s.append(i,Ot("div","lcars-bar-end bar-punctuation")),{strip:s,title:n,note:r}}function Y1(t,e,s){const i=Ot("section",`takeover ${t.className}`);i.id=t.id;const n=Ot("div","takeover-gutter-head"),r=Ot("button","panel-1 takeover-brand");if(r.type="button",r.setAttribute("aria-label",t.brand.name),t.brand.mark){const S=Ot("span","brand-mark brand-mark-td");S.setAttribute("aria-hidden","true"),r.append(S)}const o=Ot("span","takeover-brand-words");o.append(Ot("span","takeover-brand-name",t.brand.name),Ot("span","takeover-brand-sub",t.brand.sub)),r.append(o);const a=Ot("div","panel-2 takeover-seat");n.append(r,a);const l=Ot("div","takeover-head"),c=Ot("div","takeover-face");l.append(Ot("div","banner",t.banner),c,Dv(1,"first-bar-panel"));const h=Ot("div","takeover-top");h.append(n,l);const d=Ot("nav","takeover-gutter");d.setAttribute("aria-label",t.labels.views);const u=Ot("div",""),p=new Map;t.views.forEach((S,T)=>{const A=M6[T]??"panel-view",E=Ot("button",`${A}${S.destroy===!0?" takeover-view-destroy":""}`,S.label);E.type="button",E.dataset.view=S.key,E.addEventListener("click",()=>e(S.key)),p.set(S.key,E),u.append(E)}),u.append(Ot("div","panel-spacer"));const f=Ot("div",""),_=Ot("button",`panel-7${t.leave.destroy===!0?" takeover-view-destroy":""}`,t.leave.label);_.type="button",_.addEventListener("click",s),f.append(_),d.append(u,f);const g=Ot("div","takeover-main"),m=Ot("main","takeover-stage"),v=Iv(t.stage.title,t.stage.note),y=Ot("div","takeover-body"),b=Ot("div","takeover-aside"),w=Iv(t.log.title,t.log.note),z=Ot("section","takeover-log");z.setAttribute("aria-label",t.labels.log),m.append(v.strip,y,b,w.strip,z),g.append(Dv(6,""),m);const x=Ot("div","takeover-wrap");x.append(d,g),i.append(h,x);const M=S=>{for(const[T,A]of p){const E=T===S;A.classList.toggle("takeover-view-on",E),A.setAttribute("aria-current",E?"page":"false")}i.dataset.firstLit=S===t.views[0]?.key?"true":"false"};return{root:i,seat:a,face:c,views:p,leave:_,stageTitle:v.title,stageNote:v.note,body:y,aside:b,logTitle:w.title,logNote:w.note,log:z,view_mark:M}}const v6=[[/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 w6(t){const e=[];for(const[s,i]of v6)s.test(t)&&!e.includes(i)&&e.push(i);return e}function y6(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 z6(t){switch(t){case"abandon":return"transporter";case"destruct":return"destruct";case"computer":return"thinking";default:return null}}function S6(t,e){return t!=="distance"?null:e==="impulse"?"impulse":e==="move"||e==="ram"?"warp":null}function vr(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 Ds=10,Vl=8,x6="*",O6="#",X1="E",E6="Q",A6="K",T6="@",Z1=" ",D6=7,I6=64,C6=63,R6=0,k6=1,N6=2,B6=3,G6=[{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"}],P6=["GREEN","DOCKED","YELLOW","RED"];function Th(t,e){return(Math.atan2(e.y-t.y,-(e.x-t.x))*180/Math.PI+360)%360}function dd(t,e){return Math.hypot(e.x-t.x,e.y-t.y)}function L6(t){switch(t){case X1:case E6:return"ship";case A6:return"klingon";case O6:return"base";case x6:return"star";case T6:return"inhabited";case Z1:return"hole";default:return"empty"}}function W6(t){const e=new Map;for(const s of t)(s.evcode&C6)!==D6||(s.evcode&I6)!==0||e.set(s.systemname,s.date);return G6.map((s,i)=>({index:i,name:s.name,person:s.person,repairAt:e.get(i)??null})).filter(s=>!s.name.startsWith("*"))}function F6(t){const e=t.Etc.nkling;switch(t.Ship.cond){case B6:return e===1?"1 Klingon in this quadrant":`${e} Klingons in this quadrant`;case N6:return t.Ship.energy<t.Param.energylow?"energy low":"Klingons near";case k6:return"docked at a starbase";case R6:default:return"all clear"}}function U6(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<Ds;m++){const v=[];for(let y=0;y<Ds;y++){const b=o[m]?.[y]??Z1;v.push({x:m,y,kind:L6(b),glyph:b})}h.push(v)}const d=r.klingon.slice(0,r.nkling).map(m=>({x:m.x,y:m.y,bearing:Th(c,m),range:dd(c,m),power:m.power,mark:null})).sort((m,v)=>m.range-v.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 v=dd(l,m);(p===null||v<p.range)&&(p={at:m,range:v,here:v===0})}const f=[];for(let m=0;m<Vl;m++){const v=[];for(let y=0;y<Vl;y++){const w=a[m]?.[y]?.scanned??-1,z=w<0?null:w>=1e3?"///":String(w).padStart(3,"0");v.push({x:m,y,here:m===l.x&&y===l.y,code:z,supernova:w>=1e3,klingons:w<0||w>=1e3?0:Math.floor(w/100),bases:w<0||w>=1e3?0:Math.floor(w%100/10)})}f.push(v)}const _=W6(t.Event),g=_.filter(m=>m.repairAt!==null).sort((m,v)=>(m.repairAt??0)-(v.repairAt??0));return{condition:{name:P6[e.cond]??"GREEN",why:F6(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!==X1},param:{warptime:n.warptime,dockfac:n.dockfac,klingpwr:n.klingpwr,date:n.date}}}const $6=["novice","fair","good","expert","commodore","impossible"];function J1(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 ${$6[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 Cv(t,e){const{quadrant:s,sector:i}=t.position,n=s.x+i.x/Ds-(e.quadrant.x+e.sector.x/Ds),r=e.quadrant.y+e.sector.y/Ds-(s.y+i.y/Ds);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 j6(t,e,s){const{quadrant:i,sector:n}=t.position,r=e*Math.PI/180,o=Math.min(Vl*Ds-1,Math.max(0,Math.round(i.x*Ds+n.x-Math.cos(r)*s*Ds))),a=Math.min(Vl*Ds-1,Math.max(0,Math.round(i.y*Ds+n.y+Math.sin(r)*s*Ds)));return{quadrant:{x:Math.trunc(o/Ds),y:Math.trunc(a/Ds)},sector:{x:o%Ds,y:a%Ds}}}function Q1(t,e,s){const i=Math.trunc((t+.05)*e*e*e);return{stardates:s*t/(e*e),units:i,unitsShielded:2*i}}function H6(t){return{stardates:t/.095,units:Math.trunc(20+100*t)}}function ex(t){return Math.trunc(Math.pow(.9,t*10)*98+.5)}function Rv(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 tx(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 V6=[["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 q6(t){const e=t.replace(/[:.\s]+$/,"");if(e==="")return"return";for(const[s,i]of V6)if(e.endsWith(s))return i;return/wise$|certain that is wise$|Shall we cancel our rest period$/.test(e)?"yes-no":"unknown"}const Ud=[{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 Is(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:Vl-1,step:1,commit:"SET"};case"sector":case"sector-y":return{kind:"slider",min:0,max:Ds-1,step:1,commit:"SET"};default:return{kind:"text"}}}function K6(){return`argus${Math.floor(Math.random()*9e3+1e3)}`}class Y6{constructor(e){this.hooks=e}hooks;open=null;lastCommand=null;password=K6();ended=!1;ask(e){const s=q6(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 jn={torpedoPoint:140,sector:170,burst:800,beam:900,rescan:350,flare:900,tail:300},X6=[[/^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:mi(t,1)})],[/^Starbase at (\d+),(\d+) destroyed/,t=>({kind:"kill",at:mi(t,1)})],[/^Inhabited starsystem .* at (\d+),(\d+) destroyed/,t=>({kind:"kill",at:mi(t,1)})],[/^Unknown object . at (\d+),(\d+) destroyed/,t=>({kind:"kill",at:mi(t,1)})],[/Star at (\d+),(\d+) gone nova/,t=>({kind:"nova",at:mi(t,1)})],[/^Photon tubes misfire/,()=>({kind:"misfire"})],[/^(\d+) unit hit on Klingon at (\d+),(\d+)/,t=>({kind:"phaser",at:mi(t,2)})],[/^HIT: (\d+) units(?: from (\d+),(\d+))?(?:, shields absorb (\d+)%)?/,t=>({kind:"incoming",hit:Number(t[1]),from:t[2]===void 0?null:mi(t,2),absorb:t[4]===void 0?0:Number(t[4])})],[/^Klingon at (\d+),(\d+) moves to (\d+),(\d+)/,t=>({kind:"klingon-move",from:mi(t,1),to:mi(t,3)})],[/^Klingon at (\d+),(\d+) escapes to quadrant (\d+),(\d+)/,t=>({kind:"klingon-escape",from:mi(t,1),quadrant:mi(t,3)})],[/RED ALERT: supernova occurring at (\d+),(\d+)/,t=>({kind:"supernova",at:mi(t,1)})],[/^\s*in quadrant (\d+),(\d+)\.\s+Caution is advised/,t=>({kind:"supernova-report",quadrant:mi(t,1)})]];function mi(t,e){return{x:Number(t[e]),y:Number(t[e+1])}}function Z6(t){for(const[e,s]of X6){const i=e.exec(t);if(i!==null)return s(i)}return null}class J6{constructor(e=Q6){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=kv();for(;!this.skipping;){const n=Math.min(1,(kv()-i)/Math.max(1,e));if(s(n),n>=1)return;await eH(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 Q6(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function kv(){return typeof performance=="object"?performance.now():Date.now()}function eH(t){return typeof requestAnimationFrame=="function"?new Promise(e=>{requestAnimationFrame(()=>e())}):t.wait(16)}function za(t){return[t.y+.5,t.x+.5]}function sx(t,e){return(Math.atan2(e.y-t.y,-(e.x-t.x))*180/Math.PI+360)%360}function tH(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 v=p[m]*s-.5,y=p[m]*s+s-.5,b=(v-f[m])/r[m],w=(y-f[m])/r[m];_?g=Math.min(g,Math.max(b,w)):g=Math.max(g,Math.min(b,w))}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 $d(t,e=""){const s=it("g",{class:`tb-motion ${e}`.trim()});return t.append(s),s}const sH=.7;async function nl(t,e,s,i,n,r={},o=!1){if(o)return;const a=$d(t,"tb-motion-slide"),[l,c]=za(i),[h,d]=za(n),u=r.hostile===!0?" tb-hostile":"";a.append(it("line",{class:`tb-track${u}`,x1:l,y1:c,x2:h,y2:d}));const p=it("line",{class:`tb-pulse tb-pulse-wide${u}`,x1:l,y1:c,x2:l,y2:c}),f=it("line",{class:`tb-pulse tb-pulse-core${u}`,x1:l,y1:c,x2:l,y2:c}),_=r.heading??sx(i,n),g=m_(s.kind,{cx:l,cy:c,size:sH},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*jn.sector,v=>{const y=l+(h-l)*v,b=c+(d-c)*v,w=Math.max(0,v-.12),z=l+(h-l)*w,x=c+(d-c)*w;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));q1(g,y,b,_)}),a.remove()}async function Nv(t,e,s,i,n,r=!1){if(r)return;const o=$d(t,"tb-motion-beam"),[a,l]=za(s),[c,h]=za(i),d=n?" tb-hostile":"";o.append(it("line",{class:`tb-beam${d}`,x1:a,y1:l,x2:c,y2:h}),it("line",{class:`tb-beam tb-beam-core${d}`,x1:a,y1:l,x2:c,y2:h})),await e.wait(jn.beam),o.remove()}async function ih(t,e,s,i,n=!1){if(n)return;const r=$d(t,`tb-motion-burst tb-burst tb-burst-${i}`),[o,a]=za(s),l=i==="misfire"?jn.burst*.6:i==="supernova"?jn.burst*1.6:jn.burst;r.style.setProperty("--tb-ms",`${l}ms`),r.append(it("circle",{class:"tb-burst-halo",cx:o,cy:a,r:.1}));const c=it("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(it("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,it("circle",{class:"tb-burst-core",cx:o,cy:a,r:.04})),await e.wait(l),r.remove()}async function iH(t,e,s=!1){if(s)return;const i=t.querySelector(".tb-ring");if(i===null)return;const n=it("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(jn.flare),n.remove()}class nH{layer;tail;photon;points=[];constructor(e,s){this.layer=$d(e,"tb-motion-torpedo"),this.tail=it("g",{class:"tb-tail"}),this.photon=it("g",{class:"tb-photon"}),this.photon.append(it("circle",{class:"tb-photon-halo",cx:0,cy:0,r:.34}));const i=it("g",{class:"tb-photon-pulses"});for(let o=0;o<10;o++){const a=it("g",{transform:`rotate(${o*36})`});a.append(it("rect",{x:.08,y:-.016,width:.2+o%3*.05,height:.032,rx:.006})),i.append(a)}this.photon.append(i,it("circle",{class:"tb-photon-core",cx:0,cy:0,r:.12})),this.layer.append(this.tail,this.photon);const[n,r]=za(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(it("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(jn.torpedoPoint)}async end(e,s=!1){this.photon.remove(),s||await e.wait(jn.tail),this.layer.remove()}}function Bv(t,e){t.classList.toggle("tb-rescan",e)}function rH(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 vi(t,e){return t!==null&&e.includes(t.question)}function jd(t,e){const s=Y("div","tb-station-head"),i=Y("span","tb-station-step",""),n=Zs("tb-grave tb-cancel","CANCEL",()=>{e.answer_send(n.dataset.line??"","CANCEL")});return n.hidden=!0,s.append(Y("span","tb-station-name",t),i,Y("span","tb-station-fill"),n),{root:s,step:i,cancel:n}}function Hd(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 __(t,e){const s=Zs(`tb-command${t.grave===!0?" tb-grave":""}`,t.label,()=>{e.command_send(t)});return s.dataset.command=t.id,s}function ix(t,e){const s=Y("div","tb-pills tb-command-pills"),i=new Map;for(const n of Ud.filter(r=>r.station===t)){const r=__(n,e);i.set(n.id,r),s.append(r)}return{root:s,pills:i}}function Vd(t,e){for(const[s,i]of t)i.disabled=e?.question!=="command",i.classList.toggle("tb-pill-on",e?.command?.id===s)}function nx(t,e){const s=Zs("tb-target","",e);return s.append(g_("klingon",t.mark),document.createTextNode(`${t.x},${t.y}`)),s.title=`Klingon at ${t.x},${t.y}`,s}function gm(t,e){const s=Y("span",t,e.supernova?"":e.code??"");return e.supernova&&s.append(g_("supernova")),s}function _m(t){return`quadrant ${t.x},${t.y}${t.supernova?" · supernova":t.code===null?" · unscanned":""}`}function rx(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 Gv{root;wheel;distance;warp;rest;head;pills;readout=null;constructor(e,s,i){this.root=Y("div","tb-station tb-station-helm"),this.head=jd("HELM",e);const n=ix("helm",e);this.pills=n.pills;const r=Y("div","tb-controls");this.wheel=new K1(s,"course wheel",a=>e.answer_send(String(a),"SET COURSE"));const o=Y("div","tb-sliders");this.distance=new Tr(`${i}-distance`,"DISTANCE",1,a=>e.answer_send(a.toFixed(1),"SLIDER SET")),this.warp=new Tr(`${i}-warp`,"WARP FACTOR",1,a=>e.answer_send(a.toFixed(1),"SLIDER SET")),this.rest=new Tr(`${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(rx(e)),this.warp.range_set(Is("warp-factor",e),e.ship.warp,"THE SHIP NOW · ABOVE 6 THE ENGINES MAY BURN",10),this.distance.range_set(Is("distance",e),s?1:this.distance.value_get(),"QUADRANTS · 0.1 IS ONE SECTOR",6),this.rest.range_set(Is("how-long",e),0,`STARDATES · ${e.mission.timeLeft.toFixed(1)} LEFT · REPAIRS RUN WHILE TIME PASSES`,2)}question_show(e){Vd(this.pills,e);const s=e===null?null:Is(e.question,this.readout);Hd(this.head,"helm",e,s),this.wheel.lit_set(vi(e,["course","direction"]),"SET COURSE"),this.distance.lit_set(vi(e,["distance"]),"ENGAGE"),this.warp.lit_set(vi(e,["warp-factor"]),"SET WARP"),this.rest.lit_set(vi(e,["how-long"]),"REST"),e?.question==="distance"&&this.arrival_note()}arrival_note(){if(this.readout===null)return;const e=this.distance.value_get(),s=j6(this.readout,this.wheel.degrees_get(),e),i=Q1(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 Pv{constructor(e,s,i){this.host=e,this.root=Y("div","tb-station tb-station-tactical"),this.head=jd("TACTICAL",e);const n=ix("tactical",e);this.pills=n.pills;const r=Y("div","tb-controls");this.wheel=new K1(s,"firing course wheel",l=>e.answer_send(String(l),"SET COURSE"));const o=Y("div","tb-sliders");this.burst=new sh("BURST",Is("burst",null).choices??[],(l,c)=>e.answer_send(l,vr(c,"choice"))),this.burstAngle=new sh("BURST ANGLE",Is("burst-angle",null).choices??[],(l,c)=>{this.wheel.wedge_set(Number(l)),e.answer_send(l,vr(c,"choice"))}),this.manual=new sh("PHASERS",Is("manual-automatic",null).choices??[],(l,c)=>e.answer_send(l,vr(c,"choice"))),this.units=new Tr(`${i}-units`,"UNITS",0,l=>e.answer_send(String(Math.round(l)),"SLIDER SET")),this.spread=new Tr(`${i}-spread`,"SPREAD",2,l=>e.answer_send(l.toFixed(2),"SLIDER SET")),this.upDown=new sh("SHIELDS",Is("up-down",null).choices??[],(l,c)=>e.answer_send(l,vr(c,"choice")));const a=Y("div","tb-fire-row");this.fire=Zs("tb-fire","FIRE",()=>e.answer_send("0",null)),this.targets=Y("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(rx(e)),this.wheel.wedge_set(null),e.klingons[0]!==void 0&&this.wheel.degrees_set(e.klingons[0].bearing),this.units.range_set(Is("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(Is("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){Vd(this.pills,e);const s=e===null?null:Is(e.question,this.readout);Hd(this.head,"tactical",e,s),this.wheel.lit_set(vi(e,["torpedo-course","bank-course"]),"SET COURSE"),this.burst.lit_set(vi(e,["burst"])),this.burstAngle.lit_set(vi(e,["burst-angle"])),this.manual.lit_set(vi(e,["manual-automatic"])),this.units.lit_set(vi(e,["units","bank-units"]),e?.question==="units"?"FIRE":"SET BANK"),this.spread.lit_set(vi(e,["spread"])),this.upDown.lit_set(vi(e,["up-down"])),this.fire.disabled=!vi(e,["bank-units"]),this.fire.textContent="FIRE THE BANKS SET"}targets_draw(e){if(this.targets.replaceChildren(),e.klingons.length===0){this.targets.append(Y("span","tb-note","NO KLINGONS IN THIS QUADRANT"));return}for(const s of["TARGET","RANGE","BEARING","PHASER HIT"])this.targets.append(Y("span","tb-target-head",s));for(const s of e.klingons){const i=nx(s,()=>{this.host.voice.cue("scanner"),this.host.course_set(s.bearing,s.range/10)});this.targets.append(i,Y("span","tb-target-cell",s.range.toFixed(1)),Y("span","tb-target-cell",`${Math.round(s.bearing)}°`),Y("span","tb-target-cell",`${ex(s.range/10)}%`))}}}class oH{root;rest;head;pills;damage;systems;since;inThatTime;readout=null;constructor(e){this.root=Y("div","tb-view-body tb-view-engineering");const s=Y("section","tb-panel tb-damage");s.append(Y("span","tb-title","DAMAGE CONTROL"),Y("span","tb-note","THE C'S REPORT · ALWAYS ON")),this.damage=Y("div","tb-dc"),s.append(this.damage,Y("span","tb-note","REPAIR TIMES IN STARDATES · REPAIRS RUN WHILE TIME PASSES · DOCKED, FASTER BY THE DOCK FACTOR"));const i=Y("section","tb-panel tb-systems-section");i.append(Y("span","tb-title","SHIP"),Y("span","tb-note","ENERGY, SHIELDS, RESERVES")),this.systems=Y("div","tb-systems"),i.append(this.systems,Y("span","tb-title","SINCE THE LAST COMMAND")),this.since=Y("div","tb-head-grid tb-since-grid"),i.append(this.since,Y("span","tb-note","SHIELDS ARE UP OR DOWN IN TREK(6): THEIR ENERGY IS A READOUT, REFILLED AT A STARBASE"));const n=Y("section","tb-panel tb-station tb-station-time");this.head=jd("REST",e);const r=Y("div","tb-pills tb-command-pills");this.pills=new Map;for(const o of["rest","dock","undock"]){const a=Ud.find(c=>c.id===o);if(a===void 0)continue;const l=__(a,e);this.pills.set(o,l),r.append(l)}this.rest=new Tr("tbe-rest","HOW LONG",1,o=>e.answer_send(o.toFixed(1),"SLIDER SET")),this.rest.input_listen(()=>this.inThatTime_note()),this.inThatTime=Y("div","tb-in-that-time"),n.append(this.head.root,r,this.rest.root,Y("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?[]:tx(s,e);i.length===0&&this.since.append(Y("span","tb-head-label","—"),Y("span","tb-head-value","NOTHING MOVED"));for(const n of i)this.since.append(Y("span","tb-head-label",n.label),Y("span",`tb-head-value ${n.bad?"tb-bad":"tb-good"}`,n.change));this.rest.range_set(Is("how-long",e),this.rest.value_get(),`STARDATES · ${e.mission.timeLeft.toFixed(1)} LEFT`,4),this.inThatTime_note()}question_show(e){Vd(this.pills,e);const s=e===null?null:Is(e.question,this.readout),i=e!==null&&(e.command===null||["rest","dock","undock"].includes(e.command.id))?e:null;Hd(this.head,"helm",i,s),this.rest.lit_set(vi(e,["how-long"]),"REST")}damage_draw(e){this.damage.replaceChildren();for(const i of["DEVICE","","IN FLIGHT","DOCKED",""])this.damage.append(Y("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=Rv(i,e),r=Y("div","tb-bar-track"),o=Y("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(Y("span",`tb-dc-name${n===null?"":" tb-bad"}`,i.name.toUpperCase()),r,Y("span","tb-dc-time",n===null?"—":n.inFlight.toFixed(2)),Y("span","tb-dc-time",n===null?"—":n.docked.toFixed(2)),Y("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=Y("div","tb-bar-track"),f=Y("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(Y("span","tb-dc-name",l),p,Y("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=Y("div","tb-pips");for(let l=0;l<s.torpedoesMax;l++)n.append(Y("span",`tb-pip${l<s.torpedoes?" tb-pip-on":""}`));this.systems.append(Y("span","tb-dc-name","TORPEDOES"),n,Y("span","tb-dc-time tb-sys-value",`${s.torpedoes} / ${s.torpedoesMax}`));const r=(l,c)=>{this.systems.append(Y("span","tb-dc-name",l),Y("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=>(Rv(n,this.readout)?.inFlight??1/0)<=e).map(n=>n.name.toUpperCase());this.inThatTime.append(Y("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(Y("span","tb-head-value tb-bad",`${i} KLINGON${i===1?"":"S"} IN THE QUADRANT WILL FIRE · SPOCK MAY ASK TO CANCEL`))}}const Lv=[{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 aH{constructor(e){this.host=e,this.root=Y("div","tb-view-body tb-view-computer");const s=Y("section","tb-panel tb-chart-section");s.append(Y("span","tb-title","GALAXY · WHAT THE SHIP HAS SEEN"),Y("span","tb-note","PRESS A QUADRANT: THE COURSE PANEL AIMS AT IT · HUNDREDS KLINGONS, TENS BASES, ONES STARS")),this.chart=Y("div","tb-chart-big"),s.append(this.chart);const i=Y("section","tb-station tb-station-computer");this.head=jd("COMPUTER",e);const n=Y("div","tb-pills tb-command-pills");for(const d of Lv){const u=Zs("tb-command tb-request",d.label,()=>this.request_send(d));u.dataset.request=d.line,this.requestPills.push(u),n.append(u)}const r=Y("div","tb-computer-panels"),o=Y("div","tb-panel");o.append(Y("span","tb-title","COURSE AND DISTANCE")),this.courseGrid=Y("div","tb-head-grid");const a=Y("div","tb-pills");a.append(Zs("tb-commit tb-send-helm","SEND TO HELM",()=>this.helm_send()),Zs("tb-commit tb-move-now","MOVE THERE NOW",()=>this.request_send(Lv[3]))),o.append(this.courseGrid,a);const l=Y("div","tb-panel");l.append(Y("span","tb-title","WARP COST")),this.wcDistance=new Tr("tbc-distance","DISTANCE",2,()=>{}),this.wcWarp=new Tr("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=Y("div","tb-head-grid"),l.append(this.wcDistance.root,this.wcWarp.root,this.wcResult);const c=Y("div","tb-panel");c.append(Y("span","tb-title","TRAJECTORY · KLINGONS HERE")),this.trajectory=Y("div","tb-targets"),c.append(this.trajectory,Y("span","tb-title","SCORE SO FAR")),this.score=Y("div","tb-score"),c.append(this.score);const h=Y("div","tb-panel tb-answer-panel");h.append(Y("span","tb-title","THE COMPUTER ANSWERS")),this.answer=Y("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(Is("computer-warp",e),this.warpTouched?this.wcWarp.value_get():e.ship.warp,"THE SHIP'S NOW",4),this.wcDistance.range_set(Is("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:Is(e.question,this.readout);Hd(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,vr(e.label,"computer")),this.host.voice.cue("thinking");return}const i=Ud.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(vr(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=Cv(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(Y("span","tb-srs-corner",""));for(let s=0;s<(e.chart[0]?.length??0);s++)this.chart.append(Y("span","tb-srs-axis",String(s)));for(const s of e.chart){this.chart.append(Y("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=Zs(`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(gm("tb-cq-code",e),Y("span","tb-cq-at",`${e.x},${e.y}`)),i.title=_m(e),i}course_note(){if(this.readout===null||this.target===null)return;const{position:e}=this.readout,s=Cv(this.readout,this.target);this.courseGrid.replaceChildren(Y("span","tb-head-label","FROM"),Y("span","tb-head-value",`QUADRANT ${e.quadrant.x},${e.quadrant.y} · SECTOR ${e.sector.x},${e.sector.y}`),Y("span","tb-head-label","TO"),Y("span","tb-head-value",`QUADRANT ${this.target.quadrant.x},${this.target.quadrant.y} · SECTOR ${this.target.sector.x},${this.target.sector.y}`),Y("span","tb-head-label","COURSE"),Y("span","tb-head-value tb-course-value",`${s.course}°`),Y("span","tb-head-label","DISTANCE"),Y("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=Q1(e,this.wcWarp.value_get(),this.readout.param.warptime),i=H6(e);this.wcResult.replaceChildren(Y("span","tb-head-label","TIME"),Y("span","tb-head-value",`${s.stardates.toFixed(2)} STARDATES`),Y("span","tb-head-label","ENERGY"),Y("span","tb-head-value",`${s.units} UNITS · ${s.unitsShielded} WITH SHIELDS UP`),Y("span","tb-head-label","AT IMPULSE"),Y("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(Y("span","tb-note","NO KLINGONS IN THIS QUADRANT"));return}for(const s of["AT","COURSE","RANGE","PHASER HIT"])this.trajectory.append(Y("span","tb-target-head",s));for(const s of e.klingons)this.trajectory.append(nx(s,()=>{this.host.voice.cue("scanner"),this.host.course_set(s.bearing,s.range/10)}),Y("span","tb-target-cell",`${Math.round(s.bearing)}°`),Y("span","tb-target-cell",s.range.toFixed(1)),Y("span","tb-target-cell",`${ex(s.range/10)}%`))}score_draw(e){const s=J1(e);this.score.replaceChildren();for(const i of s.items.filter(n=>n.points!==0||/killed|remaining/.test(n.label)))this.score.append(Y("span","tb-score-label",i.label.toUpperCase()),Y("span",`tb-score-points${i.points<0?" tb-bad":" tb-good"}`,`${i.points>0?"+":""}${i.points}`));this.score.append(Y("span","tb-score-label tb-score-total","TOTAL"),Y("span","tb-score-points tb-score-total",String(s.total)))}}const mf=["bridge","helm","tactical","engineering","computer"],lH=400,cH="-0.6 -0.6 10.6 10.6",hH=.7,dH=/^S\.R\. scanners$/i,uH=/^L\.R\. scanners$/i,fH={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]},pH=["length","skill","request","quadrant","quadrant-y","sector","sector-y","range","computer-distance","computer-warp","status-report","another","yes-no","unknown"];class mH{constructor(e,s){this.hooks=e,this.harness=new Y6({question_changed:r=>{this.partial_flush(),this.question_show(r)},text_written:r=>this.text_take(r),state_shown:r=>this.state_show(r),ended:()=>{this.leaving||this.hooks.voice.cue("gameover")}}),this.frame=Y1({id:"trek-bridge",className:"trek-bridge",brand:{name:"TREK",sub:"ARGUS · BSD TREK",mark:!1},banner:"TREK • THE BRIDGE",views:mf.map(r=>({key:r,label:r.toUpperCase()})),leave:{label:"LEAVE BRIDGE",destroy:!0},stage:{title:"THE BRIDGE",note:"BRIDGE"},log:{title:"SHIP'S LOG",note:"READ ONLY"},labels:{views:"views",log:"ship's log"}},r=>{const o=mf.find(a=>a===r);o!==void 0&&this.view_set(o)},()=>this.leave_ask()),this.frame.leave.classList.add("tb-leave"),this.root=this.frame.root,this.root.dataset.view="bridge",this.frame.view_mark("bridge"),this.root.setAttribute("aria-label","trek: the bridge");const i={},n=u6();n!==null&&this.root.append(n),this.gutter_build(i,s),this.frame.face.append(this.header_build(i)),this.frame.body.append(this.body_build(i)),this.strip_build(i),this.frame.aside.append(i.ask),this.frame.log.append(this.log_build(i)),this.leaveAsk_build(i),this.root.append(i.leaveAsk),this.parts=i,this.question_show(null)}hooks;root;frame;harness;readout=null;previous=null;view="bridge";nextDistance=null;plan=new Map;answering=!1;computerRunning=!1;leaving=!1;tracker=new Cl;heading=0;pressedSector=null;scanDue=!1;fold=null;frames=new J6;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){e.seed=Y("div","tb-seed",s===null?"RANDOM GALAXY":`SEED ${s}`),this.frame.seat.append(e.seed),e.views=new Map;for(const i of mf){const n=this.frame.views.get(i);n!==void 0&&(n.classList.add("tb-view",`tb-view-${i}`),e.views.set(i,n))}}header_build(e){const s=Y("header","tb-header"),i=Y("section","tb-head-condition"),n=Y("div","tb-condition");n.append(Y("span","tb-condition-label","CONDITION")),e.condition=Y("span","tb-condition-name","—"),n.append(e.condition),e.conditionWhy=Y("div","tb-condition-why",""),i.append(n,e.conditionWhy);const r=p=>{const f=Y("section","tb-head-section");f.append(Y("span","tb-head-title",p));const _=Y("div","tb-head-grid");return f.append(_),[f,_]},[o,a]=r("SHIP"),[l,c]=r("MISSION"),[h,d]=r("POSITION"),u=Y("div","tb-head-grid tb-head-since");return l.append(Y("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=Y("main","tb-body");i.dataset.view="bridge",e.body=i;const n=Y("section","tb-scans");n.append(Y("span","tb-title","LONG RANGE")),e.lrs=Y("div","tb-lrs"),n.append(e.lrs,Y("span","tb-title","GALAXY · WHAT THE SHIP HAS SEEN")),e.chart=Y("div","tb-chart"),n.append(e.chart);const r=Y("section","tb-srs-section");e.srsTitle=Y("span","tb-title","SHORT RANGE"),r.append(e.srsTitle),e.scan=it("svg",{class:"tb-scan",viewBox:cH,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,Y("span","tb-note","PRESS A SECTOR: ITS COURSE AND DISTANCE FILL IN"),e.legend),e.shipPills=new Map;const o=Y("div","tb-pills tb-ship-pills");o.append(Y("span","tb-slider-label","SHIP"));for(const l of Ud.filter(c=>c.station==="ship")){const c=__(l,s);e.shipPills.set(l.id,c),o.append(c)}r.append(o);const a=Y("section","tb-stations");return e.helm=new Gv(s,150,"tb"),e.tactical=new Pv(s,150,"tb"),a.append(e.helm.root,e.tactical.root),e.helmView=new Gv(s,260,"tbh"),e.helmView.root.classList.add("tb-view-body","tb-view-helm"),e.tacticalView=new Pv(s,260,"tbt"),e.tacticalView.root.classList.add("tb-view-body","tb-view-tactical"),e.engineeringView=new oH(s),e.computerView=new aH(s),i.append(n,r,a,e.helmView.root,e.tacticalView.root,e.engineeringView.root,e.computerView.root),i}legend_build(){const e=Y("div","tb-legend");for(const s of f6){const i=Y("span",`tb-legend-item tb-legend-${s.kind}`),n=s.kind==="klingon"?_r:[null];for(const r of n)i.append(g_(s.kind,r));i.append(Y("span","tb-legend-glyph",th[s.kind].trim()===""?"␠":th[s.kind]),Y("span","tb-legend-name",s.name)),e.append(i)}return e}strip_build(e){e.ask=Y("div","tb-ask"),e.ask.hidden=!0,e.ask.setAttribute("role","dialog"),e.askText=Y("span","tb-ask-text",""),e.askPills=Y("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=Zs("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(Y("span","tb-ask-label","THE GAME ASKS"),e.askText,e.askPills,e.askInput,e.askSend)}log_build(e){const s=Y("footer","tb-log-section");return e.log=Y("div","tb-log"),e.log.setAttribute("aria-live","polite"),s.append(e.log),s}leaveAsk_build(e){e.leaveAsk=Y("div","tb-leave-ask"),e.leaveAsk.hidden=!0,e.leaveAsk.setAttribute("role","dialog");const s=e.leaveAsk,i=Zs("tb-grave","LEAVE · THE GAME ENDS",()=>{this.leaving=!0,this.hooks.voice.cue("close"),this.hooks.leave()}),n=Zs("","STAY",()=>{s.hidden=!0});e.leaveAsk.append(Y("span","tb-ask-label","LEAVE THE BRIDGE?"),Y("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,this.frame.view_mark(e);for(const[s,i]of this.parts.views)i.classList.toggle("tb-view-on",s===e);this.frame.stageNote.textContent=e.toUpperCase(),this.hooks.voice.pill(vr(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=z6(e.id);return s===null?this.hooks.voice.pill(vr(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
|
+
`);return}(w||M.envelopes.some(S=>S.status==="error"))&&z.outcome_write(M),l(M)},h=[],d=b=>{const w=h.length===0;for(const z of b)z.vfsPath!==""&&!h.includes(z.vfsPath)&&h.push(z.vfsPath);!w||h.length===0||queueMicrotask(()=>{const z=h.splice(0);z.length>0&&c(`gather add ${z.map(sn).join(" ")}`)})},u=(b,w,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}),...w,...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"),w=()=>e.errandHost_find()??"pacs",z=x=>f_(t.terminal,e.element_require("header-gather"),x);return new Sv(b,e.pane_find(b,".gather-rows"),u(w,{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 w=e.template_stamp("tpl-pane-gather"),z=new Sv(w,e.pane_find(w,".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:w,dispose:()=>{s.delete(b),i.pane_leave(b)}}},has:b=>n.has(b),gather:b=>{r===null&&(r=f()),d(b);const w=document.body.dataset.header==="away";(!o||!w)&&(document.body.dataset.header="gather",o=!1),p()},open:(b,w="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(w)?w:e.errandHost_find()??w,T=e.instance_spawn("gather","pacs"),A=e.replayPlace_get();if(!z.leaf_split(S,A?.dir??"row",T.id,A?.before??!1))return As(T.id),z.mount_remove(T.id),null;e.birth_record(T.id,S,A?.dir??"row",A?.before??!1),M=T.id}return s.get("gather",M)===void 0?null:(d(b),M)},stage:()=>{const{layout:b}=t,w=new Set(b.panes_shown()),z=s.ids("gather").find(x=>w.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===xv&&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),Es(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 Ll(()=>import("./field-BKHyiJnc.js"),__vite__mapDeps([5,6]),import.meta.url)}catch(i){if(!d_(i))throw i;return Es(this.stateSpan,"stale",ld),this.handlers.note(`edit: ${ld.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){Es(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||Es(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?Es(this.stateSpan,"wait","SAVING"):e?Es(this.stateSpan,"note","DIRTY"):Es(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 Fj(t,e){const{layout:s,panels:i,subjects:n}=t,r=async(d,u)=>{const p=await oa(t,I1(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??yg(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 _=C1(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(v=>v.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 Uj{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 Vn({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=_n.map(o=>({key:`k:${o.key}`,name:o.key,does:o.does,topic:o.topic})),i=ga.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 $j(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 Uj(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 uf=["___________________ _-_ ","\\__(==========/_=_/ ____.---'---`---.____"," \\_ \\ \\----._________.----/"," \\ \\ / / `-_-' "," __,--`.`-'..'-_ "," /____ || "," `--.____,-' "];function jj(){const t=uf[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-uf.length)/2));uf.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 Ov="ハミヒーウシナモニサワツオリアホテマケメエカキムユラセネスタヌヘ0123456789Z:・.=*+-<>¦|";function Hj(){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(Ov[Math.floor(i()*Ov.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 Vj(){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 qj(){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 Ev=[[[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]]],io=10,ho=20;function Kj(){return{well:Array.from({length:ho},()=>Array(io).fill(0)),piece:null,score:0,lines:0,over:!1}}function p_(t,e){return e.cells.every(([s,i])=>{const n=e.x+s,r=e.y+i;return n>=0&&n<io&&r<ho&&(r<0||t[r][n]===0)})}function ff(t){const e=Math.max(...t.cells.flat())+1;return{...t,cells:t.cells.map(([s,i])=>[e-1-i,s])}}function Yj(t,e){const s=Math.floor(e()*Ev.length),i={cells:Ev[s].map(n=>[n[0],n[1]]),x:3,y:0,kind:s+1};if(!p_(t.well,i)){t.over=!0;return}t.piece=i}function Xj(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=ho-s.length;for(;s.length<ho;)s.unshift(Array(io).fill(0));t.well=s,t.lines+=i,t.score+=[0,100,300,500,800][i]??800,t.piece=null}function mm(t,e){if(t.over)return;if(t.piece===null){Yj(t,e);return}const s={...t.piece,y:t.piece.y+1};p_(t.well,s)?t.piece=s:Xj(t)}function Zj(t,e,s){if(t.over||t.piece===null)return!1;const i=t.piece,n=r=>p_(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(ff(i))||n({...ff(i),x:i.x-1})||n({...ff(i),x:i.x+1}),!0;case"ArrowDown":case"j":case"s":return mm(t,s),!0;case" ":{for(;t.piece!==null;)mm(t,s);return!0}default:return!1}}function Jj(){const t=Kj();let e=Math.random;return{title:"TETRIS",tick:500,step:(s,i)=>{e=i,mm(t,i)},draw:(s,i)=>{const n=Math.max(0,Math.floor((s.cols-(io*2+2))/2)),r=Math.max(0,Math.floor((s.rows-ho-1)/2)),o=["",i.cool,i.lit,i.warn,i.dim,i.lit,i.cool,i.warn];for(let a=0;a<ho;a++){s.put(n,r+a,"|",i.dim),s.put(n+io*2+1,r+a,"|",i.dim);for(let l=0;l<io;l++){const c=t.well[a][l];c!==0&&s.text(n+1+l*2,r+a,"[]",o[c])}}if(s.text(n,r+ho,"+"+"-".repeat(io*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=>Zj(t,s,e),status:()=>`${t.score} · ${t.lines} lines${t.over?" · OVER":""}`,over:()=>t.over}}function Qj(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 j1(r,s),r}function j1(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 e6={up:"down",down:"up",left:"right",right:"left"};function t6(t,e){e6[e]!==t.heading&&(t.next=e)}function s6(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,j1(t,e)):t.body.pop()}const i6={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 n6(){let t=null;return{title:"SNAKE",tick:140,step:(e,s)=>{t===null&&(t=Qj(Math.max(8,e.cols>>1),Math.max(6,e.rows-1),s)),s6(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=i6[e];return s===void 0||t===null?!1:(t6(t,s),!0)},status:()=>t===null?"":`${t.score}${t.over?" · OVER":""}`,over:()=>t?.over??!1}}const H1={sl:jj,cmatrix:Hj,rain:Vj,aquarium:qj,tetris:Jj,snake:n6};function r6(t){return t in H1}const o6=8,a6=26,pf=1.8,l6=100,Av=24;function Tv(t,e){let s=Math.floor(t/l6);return e/(s*pf)<Av&&(s=Math.floor(e/Av/pf)),s=Math.max(o6,Math.min(a6,s)),{w:s,h:Math.round(s*pf)}}class c6{pane;field;canvas;state;focusMark;pausePill;program=null;name=null;paused=!1;timer=null;frame=null;observer;constructor(e){this.pane=e,this.field=il(e,".games-field"),this.canvas=il(e,".games-canvas"),this.state=e.querySelector(".pane-state"),this.focusMark=il(e,".games-focus"),this.pausePill=il(e,".games-pause"),this.field.tabIndex=0,this.pausePill.addEventListener("click",()=>this.pause_toggle()),il(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=H1[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=Tv(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=Tv(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 il(t,e){const s=t.querySelector(e);if(s===null)throw new Error(`games pane: missing ${e}`);return s}function h6(t,e){const{layout:s,panels:i,subjects:n}=t;return{instance_build:a=>{const l=e.template_stamp("tpl-pane-games"),c=new c6(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"||!r6(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 it(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 _r=["cruiser","raptor","talon","warbird"],d6={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>'},Il="tm-";function V1(t,e=null){return t==="klingon"?`${Il}klingon-${e!==null&&_r.includes(e)?e:_r[0]}`:`${Il}${t}`}function u6(){if(document.getElementById(`${Il}ship`)!==null)return null;const t=it("svg",{class:"tm-defs",width:0,height:0,"aria-hidden":"true"}),e=it("defs",{});for(const[i,n]of Object.entries(d6)){const r=it("symbol",{id:`${Il}${i}`,viewBox:"0 0 24 24"});r.innerHTML=n,e.append(r)}const s=(i,n)=>{const r=it("radialGradient",{id:`${Il}${i}`});for(const[o,a,l]of n){const c=it("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 m_(t,e,s=null,i=0){const n=it("g",{class:`tm-mark tm-mark-${t}`});return n.append(it("use",{href:`#${V1(t,s)}`,x:-e.size/2,y:-e.size/2,width:e.size,height:e.size,class:"tm-symbol"})),q1(n,e.cx,e.cy,i),n}function q1(t,e,s,i=0){t.setAttribute("transform",i===0?`translate(${e} ${s})`:`translate(${e} ${s}) rotate(${i})`)}function g_(t,e=null){const s=it("svg",{viewBox:"0 0 24 24",class:`tm-icon tm-icon-${t}`,"aria-hidden":"true"});return s.append(it("use",{href:`#${V1(t,e)}`})),s}const th={ship:"E",klingon:"K",base:"#",inhabited:"@",star:"*",hole:" ",supernova:"///"},f6=[{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"}],p6=/^Klingon at (\d+),(\d+) moves to (\d+),(\d+)/,m6=/^Klingon at (\d+),(\d+) escapes to quadrant/,g6=/\*\*\* Klingon at (\d+),(\d+) destroyed \*\*\*/;class Cl{marks=new Map;mark_find(e){return this.marks.get(Cl.key_format(e))??null}line_hear(e){const s=p6.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=m6.exec(e)??g6.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=>Cl.key_format(n)));for(const n of[...this.marks.keys()])i.has(n)||this.marks.delete(n);e.forEach((n,r)=>{const o=Cl.key_format(n);if(s.byOrder===!0){this.marks.set(o,_r[r%_r.length]);return}this.marks.has(o)||this.marks.set(o,this.leastWorn_get())})}clear(){this.marks.clear()}leastWorn_get(){const e=new Map(_r.map(i=>[i,0]));for(const i of this.marks.values())e.set(i,(e.get(i)??0)+1);let s=_r[0];for(const i of _r)(e.get(i)??0)<(e.get(s)??0)&&(s=i);return s}static key_format(e){return`${e.x},${e.y}`}}function _6(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 Y(t,e,s){const i=document.createElement(t);return i.className=e,s!==void 0&&(i.textContent=s),i}function Zs(t,e,s){const i=Y("button",`tb-pill ${t}`,e);return i.type="button",i.addEventListener("click",s),i}const b6=16;class K1{constructor(e,s,i){this.onCommit=i,this.size=e;const n=e/2;this.root=Y("div","tb-wheel");const r=it("svg",{width:e,height:e,viewBox:`0 0 ${e} ${e}`,role:"img","aria-label":s});r.classList.add("tb-wheel-face"),r.append(it("circle",{cx:n,cy:n,r:n-4,class:"tb-wheel-rim"})),r.append(it("circle",{cx:n,cy:n,r:(n-4)*.66,class:"tb-wheel-ring"})),r.append(it("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(it("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=it("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=it("path",{d:"",class:"tb-wheel-wedge"}),r.append(this.wedge),this.marks=it("g",{class:"tb-wheel-marks"}),r.append(this.marks),this.needle=it("line",{x1:n,y1:n,x2:n,y2:14,class:"tb-wheel-needle"}),r.append(this.needle),r.append(it("circle",{cx:n,cy:n,r:6,class:"tb-wheel-hub"})),this.root.append(r);const o=Y("div","tb-wheel-row");this.readout=Y("span","tb-wheel-readout","0°"),this.commit=Zs("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=m_(i.kind,{cx:o,cy:a,size:b6},i.variant??null,l);c.classList.add("tb-wheel-mark",`tb-wheel-mark-${i.kind}`);const h=it("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 Tr{constructor(e,s,i,n){this.digits=i,this.onCommit=n,this.root=Y("div","tb-slider");const r=Y("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=Y("div","tb-slider-column");this.ticks=Y("div","tb-slider-ticks"),this.note=Y("span","tb-slider-note"),o.append(this.input,this.ticks,this.note),this.shown=Y("span","tb-slider-readout","—"),this.commit=Zs("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(Y("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 sh{root;buttons=[];note;constructor(e,s,i){this.root=Y("div","tb-pillrow"),e!==""&&this.root.append(Y("span","tb-slider-label",e));const n=Y("div","tb-slider-column"),r=Y("div","tb-pills");for(const o of s){const a=Zs("tb-choice",o.label,()=>i(o.line,o.label));a.dataset.line=o.line,this.buttons.push(a),r.append(a)}this.note=Y("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 M6=["panel-3","panel-4","panel-5","panel-6"];function Ot(t,e,s){const i=document.createElement(t);return e!==""&&(i.className=e),s!==void 0&&(i.textContent=s),i}function Dv(t,e){const s=Ot("div",e===""?"bar-panel":`bar-panel ${e}`);for(let i=t;i<t+5;i++)s.append(Ot("div",`bar-${i}`));return s}function Iv(t,e){const s=Ot("div","lcars-terminal-header-bar files-header-bar"),i=Ot("div","lcars-bar-horizontal"),n=Ot("span","lcars-title",t),r=Ot("span","lcars-terminal-status",e);return i.append(n,r),s.append(i,Ot("div","lcars-bar-end bar-punctuation")),{strip:s,title:n,note:r}}function Y1(t,e,s){const i=Ot("section",`takeover ${t.className}`);i.id=t.id;const n=Ot("div","takeover-gutter-head"),r=Ot("button","panel-1 takeover-brand");if(r.type="button",r.setAttribute("aria-label",t.brand.name),t.brand.mark){const S=Ot("span","brand-mark brand-mark-td");S.setAttribute("aria-hidden","true"),r.append(S)}const o=Ot("span","takeover-brand-words");o.append(Ot("span","takeover-brand-name",t.brand.name),Ot("span","takeover-brand-sub",t.brand.sub)),r.append(o);const a=Ot("div","panel-2 takeover-seat");n.append(r,a);const l=Ot("div","takeover-head"),c=Ot("div","takeover-face");l.append(Ot("div","banner",t.banner),c,Dv(1,"first-bar-panel"));const h=Ot("div","takeover-top");h.append(n,l);const d=Ot("nav","takeover-gutter");d.setAttribute("aria-label",t.labels.views);const u=Ot("div",""),p=new Map;t.views.forEach((S,T)=>{const A=M6[T]??"panel-view",E=Ot("button",`${A}${S.destroy===!0?" takeover-view-destroy":""}`,S.label);E.type="button",E.dataset.view=S.key,E.addEventListener("click",()=>e(S.key)),p.set(S.key,E),u.append(E)}),u.append(Ot("div","panel-spacer"));const f=Ot("div",""),_=Ot("button",`panel-7${t.leave.destroy===!0?" takeover-view-destroy":""}`,t.leave.label);_.type="button",_.addEventListener("click",s),f.append(_),d.append(u,f);const g=Ot("div","takeover-main"),m=Ot("main","takeover-stage"),v=Iv(t.stage.title,t.stage.note),y=Ot("div","takeover-body"),b=Ot("div","takeover-aside"),w=Iv(t.log.title,t.log.note),z=Ot("section","takeover-log");z.setAttribute("aria-label",t.labels.log),m.append(v.strip,y,b,w.strip,z),g.append(Dv(6,""),m);const x=Ot("div","takeover-wrap");x.append(d,g),i.append(h,x);const M=S=>{for(const[T,A]of p){const E=T===S;A.classList.toggle("takeover-view-on",E),A.setAttribute("aria-current",E?"page":"false")}i.dataset.firstLit=S===t.views[0]?.key?"true":"false"};return{root:i,seat:a,face:c,views:p,leave:_,stageTitle:v.title,stageNote:v.note,body:y,aside:b,logTitle:w.title,logNote:w.note,log:z,view_mark:M}}const v6=[[/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 w6(t){const e=[];for(const[s,i]of v6)s.test(t)&&!e.includes(i)&&e.push(i);return e}function y6(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 z6(t){switch(t){case"abandon":return"transporter";case"destruct":return"destruct";case"computer":return"thinking";default:return null}}function S6(t,e){return t!=="distance"?null:e==="impulse"?"impulse":e==="move"||e==="ram"?"warp":null}function vr(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 Ds=10,Vl=8,x6="*",O6="#",X1="E",E6="Q",A6="K",T6="@",Z1=" ",D6=7,I6=64,C6=63,R6=0,k6=1,N6=2,B6=3,G6=[{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"}],P6=["GREEN","DOCKED","YELLOW","RED"];function Th(t,e){return(Math.atan2(e.y-t.y,-(e.x-t.x))*180/Math.PI+360)%360}function dd(t,e){return Math.hypot(e.x-t.x,e.y-t.y)}function L6(t){switch(t){case X1:case E6:return"ship";case A6:return"klingon";case O6:return"base";case x6:return"star";case T6:return"inhabited";case Z1:return"hole";default:return"empty"}}function W6(t){const e=new Map;for(const s of t)(s.evcode&C6)!==D6||(s.evcode&I6)!==0||e.set(s.systemname,s.date);return G6.map((s,i)=>({index:i,name:s.name,person:s.person,repairAt:e.get(i)??null})).filter(s=>!s.name.startsWith("*"))}function F6(t){const e=t.Etc.nkling;switch(t.Ship.cond){case B6:return e===1?"1 Klingon in this quadrant":`${e} Klingons in this quadrant`;case N6:return t.Ship.energy<t.Param.energylow?"energy low":"Klingons near";case k6:return"docked at a starbase";case R6:default:return"all clear"}}function U6(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<Ds;m++){const v=[];for(let y=0;y<Ds;y++){const b=o[m]?.[y]??Z1;v.push({x:m,y,kind:L6(b),glyph:b})}h.push(v)}const d=r.klingon.slice(0,r.nkling).map(m=>({x:m.x,y:m.y,bearing:Th(c,m),range:dd(c,m),power:m.power,mark:null})).sort((m,v)=>m.range-v.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 v=dd(l,m);(p===null||v<p.range)&&(p={at:m,range:v,here:v===0})}const f=[];for(let m=0;m<Vl;m++){const v=[];for(let y=0;y<Vl;y++){const w=a[m]?.[y]?.scanned??-1,z=w<0?null:w>=1e3?"///":String(w).padStart(3,"0");v.push({x:m,y,here:m===l.x&&y===l.y,code:z,supernova:w>=1e3,klingons:w<0||w>=1e3?0:Math.floor(w/100),bases:w<0||w>=1e3?0:Math.floor(w%100/10)})}f.push(v)}const _=W6(t.Event),g=_.filter(m=>m.repairAt!==null).sort((m,v)=>(m.repairAt??0)-(v.repairAt??0));return{condition:{name:P6[e.cond]??"GREEN",why:F6(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!==X1},param:{warptime:n.warptime,dockfac:n.dockfac,klingpwr:n.klingpwr,date:n.date}}}const $6=["novice","fair","good","expert","commodore","impossible"];function J1(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 ${$6[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 Cv(t,e){const{quadrant:s,sector:i}=t.position,n=s.x+i.x/Ds-(e.quadrant.x+e.sector.x/Ds),r=e.quadrant.y+e.sector.y/Ds-(s.y+i.y/Ds);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 j6(t,e,s){const{quadrant:i,sector:n}=t.position,r=e*Math.PI/180,o=Math.min(Vl*Ds-1,Math.max(0,Math.round(i.x*Ds+n.x-Math.cos(r)*s*Ds))),a=Math.min(Vl*Ds-1,Math.max(0,Math.round(i.y*Ds+n.y+Math.sin(r)*s*Ds)));return{quadrant:{x:Math.trunc(o/Ds),y:Math.trunc(a/Ds)},sector:{x:o%Ds,y:a%Ds}}}function Q1(t,e,s){const i=Math.trunc((t+.05)*e*e*e);return{stardates:s*t/(e*e),units:i,unitsShielded:2*i}}function H6(t){return{stardates:t/.095,units:Math.trunc(20+100*t)}}function ex(t){return Math.trunc(Math.pow(.9,t*10)*98+.5)}function Rv(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 tx(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 V6=[["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 q6(t){const e=t.replace(/[:.\s]+$/,"");if(e==="")return"return";for(const[s,i]of V6)if(e.endsWith(s))return i;return/wise$|certain that is wise$|Shall we cancel our rest period$/.test(e)?"yes-no":"unknown"}const Ud=[{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 Is(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:Vl-1,step:1,commit:"SET"};case"sector":case"sector-y":return{kind:"slider",min:0,max:Ds-1,step:1,commit:"SET"};default:return{kind:"text"}}}function K6(){return`argus${Math.floor(Math.random()*9e3+1e3)}`}class Y6{constructor(e){this.hooks=e}hooks;open=null;lastCommand=null;password=K6();ended=!1;ask(e){const s=q6(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 jn={torpedoPoint:140,sector:170,burst:800,beam:900,rescan:350,flare:900,tail:300},X6=[[/^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:mi(t,1)})],[/^Starbase at (\d+),(\d+) destroyed/,t=>({kind:"kill",at:mi(t,1)})],[/^Inhabited starsystem .* at (\d+),(\d+) destroyed/,t=>({kind:"kill",at:mi(t,1)})],[/^Unknown object . at (\d+),(\d+) destroyed/,t=>({kind:"kill",at:mi(t,1)})],[/Star at (\d+),(\d+) gone nova/,t=>({kind:"nova",at:mi(t,1)})],[/^Photon tubes misfire/,()=>({kind:"misfire"})],[/^(\d+) unit hit on Klingon at (\d+),(\d+)/,t=>({kind:"phaser",at:mi(t,2)})],[/^HIT: (\d+) units(?: from (\d+),(\d+))?(?:, shields absorb (\d+)%)?/,t=>({kind:"incoming",hit:Number(t[1]),from:t[2]===void 0?null:mi(t,2),absorb:t[4]===void 0?0:Number(t[4])})],[/^Klingon at (\d+),(\d+) moves to (\d+),(\d+)/,t=>({kind:"klingon-move",from:mi(t,1),to:mi(t,3)})],[/^Klingon at (\d+),(\d+) escapes to quadrant (\d+),(\d+)/,t=>({kind:"klingon-escape",from:mi(t,1),quadrant:mi(t,3)})],[/RED ALERT: supernova occurring at (\d+),(\d+)/,t=>({kind:"supernova",at:mi(t,1)})],[/^\s*in quadrant (\d+),(\d+)\.\s+Caution is advised/,t=>({kind:"supernova-report",quadrant:mi(t,1)})]];function mi(t,e){return{x:Number(t[e]),y:Number(t[e+1])}}function Z6(t){for(const[e,s]of X6){const i=e.exec(t);if(i!==null)return s(i)}return null}class J6{constructor(e=Q6){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=kv();for(;!this.skipping;){const n=Math.min(1,(kv()-i)/Math.max(1,e));if(s(n),n>=1)return;await eH(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 Q6(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function kv(){return typeof performance=="object"?performance.now():Date.now()}function eH(t){return typeof requestAnimationFrame=="function"?new Promise(e=>{requestAnimationFrame(()=>e())}):t.wait(16)}function za(t){return[t.y+.5,t.x+.5]}function sx(t,e){return(Math.atan2(e.y-t.y,-(e.x-t.x))*180/Math.PI+360)%360}function tH(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 v=p[m]*s-.5,y=p[m]*s+s-.5,b=(v-f[m])/r[m],w=(y-f[m])/r[m];_?g=Math.min(g,Math.max(b,w)):g=Math.max(g,Math.min(b,w))}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 $d(t,e=""){const s=it("g",{class:`tb-motion ${e}`.trim()});return t.append(s),s}const sH=.7;async function nl(t,e,s,i,n,r={},o=!1){if(o)return;const a=$d(t,"tb-motion-slide"),[l,c]=za(i),[h,d]=za(n),u=r.hostile===!0?" tb-hostile":"";a.append(it("line",{class:`tb-track${u}`,x1:l,y1:c,x2:h,y2:d}));const p=it("line",{class:`tb-pulse tb-pulse-wide${u}`,x1:l,y1:c,x2:l,y2:c}),f=it("line",{class:`tb-pulse tb-pulse-core${u}`,x1:l,y1:c,x2:l,y2:c}),_=r.heading??sx(i,n),g=m_(s.kind,{cx:l,cy:c,size:sH},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*jn.sector,v=>{const y=l+(h-l)*v,b=c+(d-c)*v,w=Math.max(0,v-.12),z=l+(h-l)*w,x=c+(d-c)*w;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));q1(g,y,b,_)}),a.remove()}async function Nv(t,e,s,i,n,r=!1){if(r)return;const o=$d(t,"tb-motion-beam"),[a,l]=za(s),[c,h]=za(i),d=n?" tb-hostile":"";o.append(it("line",{class:`tb-beam${d}`,x1:a,y1:l,x2:c,y2:h}),it("line",{class:`tb-beam tb-beam-core${d}`,x1:a,y1:l,x2:c,y2:h})),await e.wait(jn.beam),o.remove()}async function ih(t,e,s,i,n=!1){if(n)return;const r=$d(t,`tb-motion-burst tb-burst tb-burst-${i}`),[o,a]=za(s),l=i==="misfire"?jn.burst*.6:i==="supernova"?jn.burst*1.6:jn.burst;r.style.setProperty("--tb-ms",`${l}ms`),r.append(it("circle",{class:"tb-burst-halo",cx:o,cy:a,r:.1}));const c=it("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(it("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,it("circle",{class:"tb-burst-core",cx:o,cy:a,r:.04})),await e.wait(l),r.remove()}async function iH(t,e,s=!1){if(s)return;const i=t.querySelector(".tb-ring");if(i===null)return;const n=it("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(jn.flare),n.remove()}class nH{layer;tail;photon;points=[];constructor(e,s){this.layer=$d(e,"tb-motion-torpedo"),this.tail=it("g",{class:"tb-tail"}),this.photon=it("g",{class:"tb-photon"}),this.photon.append(it("circle",{class:"tb-photon-halo",cx:0,cy:0,r:.34}));const i=it("g",{class:"tb-photon-pulses"});for(let o=0;o<10;o++){const a=it("g",{transform:`rotate(${o*36})`});a.append(it("rect",{x:.08,y:-.016,width:.2+o%3*.05,height:.032,rx:.006})),i.append(a)}this.photon.append(i,it("circle",{class:"tb-photon-core",cx:0,cy:0,r:.12})),this.layer.append(this.tail,this.photon);const[n,r]=za(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(it("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(jn.torpedoPoint)}async end(e,s=!1){this.photon.remove(),s||await e.wait(jn.tail),this.layer.remove()}}function Bv(t,e){t.classList.toggle("tb-rescan",e)}function rH(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 vi(t,e){return t!==null&&e.includes(t.question)}function jd(t,e){const s=Y("div","tb-station-head"),i=Y("span","tb-station-step",""),n=Zs("tb-grave tb-cancel","CANCEL",()=>{e.answer_send(n.dataset.line??"","CANCEL")});return n.hidden=!0,s.append(Y("span","tb-station-name",t),i,Y("span","tb-station-fill"),n),{root:s,step:i,cancel:n}}function Hd(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 __(t,e){const s=Zs(`tb-command${t.grave===!0?" tb-grave":""}`,t.label,()=>{e.command_send(t)});return s.dataset.command=t.id,s}function ix(t,e){const s=Y("div","tb-pills tb-command-pills"),i=new Map;for(const n of Ud.filter(r=>r.station===t)){const r=__(n,e);i.set(n.id,r),s.append(r)}return{root:s,pills:i}}function Vd(t,e){for(const[s,i]of t)i.disabled=e?.question!=="command",i.classList.toggle("tb-pill-on",e?.command?.id===s)}function nx(t,e){const s=Zs("tb-target","",e);return s.append(g_("klingon",t.mark),document.createTextNode(`${t.x},${t.y}`)),s.title=`Klingon at ${t.x},${t.y}`,s}function gm(t,e){const s=Y("span",t,e.supernova?"":e.code??"");return e.supernova&&s.append(g_("supernova")),s}function _m(t){return`quadrant ${t.x},${t.y}${t.supernova?" · supernova":t.code===null?" · unscanned":""}`}function rx(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 Gv{root;wheel;distance;warp;rest;head;pills;readout=null;constructor(e,s,i){this.root=Y("div","tb-station tb-station-helm"),this.head=jd("HELM",e);const n=ix("helm",e);this.pills=n.pills;const r=Y("div","tb-controls");this.wheel=new K1(s,"course wheel",a=>e.answer_send(String(a),"SET COURSE"));const o=Y("div","tb-sliders");this.distance=new Tr(`${i}-distance`,"DISTANCE",1,a=>e.answer_send(a.toFixed(1),"SLIDER SET")),this.warp=new Tr(`${i}-warp`,"WARP FACTOR",1,a=>e.answer_send(a.toFixed(1),"SLIDER SET")),this.rest=new Tr(`${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(rx(e)),this.warp.range_set(Is("warp-factor",e),e.ship.warp,"THE SHIP NOW · ABOVE 6 THE ENGINES MAY BURN",10),this.distance.range_set(Is("distance",e),s?1:this.distance.value_get(),"QUADRANTS · 0.1 IS ONE SECTOR",6),this.rest.range_set(Is("how-long",e),0,`STARDATES · ${e.mission.timeLeft.toFixed(1)} LEFT · REPAIRS RUN WHILE TIME PASSES`,2)}question_show(e){Vd(this.pills,e);const s=e===null?null:Is(e.question,this.readout);Hd(this.head,"helm",e,s),this.wheel.lit_set(vi(e,["course","direction"]),"SET COURSE"),this.distance.lit_set(vi(e,["distance"]),"ENGAGE"),this.warp.lit_set(vi(e,["warp-factor"]),"SET WARP"),this.rest.lit_set(vi(e,["how-long"]),"REST"),e?.question==="distance"&&this.arrival_note()}arrival_note(){if(this.readout===null)return;const e=this.distance.value_get(),s=j6(this.readout,this.wheel.degrees_get(),e),i=Q1(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 Pv{constructor(e,s,i){this.host=e,this.root=Y("div","tb-station tb-station-tactical"),this.head=jd("TACTICAL",e);const n=ix("tactical",e);this.pills=n.pills;const r=Y("div","tb-controls");this.wheel=new K1(s,"firing course wheel",l=>e.answer_send(String(l),"SET COURSE"));const o=Y("div","tb-sliders");this.burst=new sh("BURST",Is("burst",null).choices??[],(l,c)=>e.answer_send(l,vr(c,"choice"))),this.burstAngle=new sh("BURST ANGLE",Is("burst-angle",null).choices??[],(l,c)=>{this.wheel.wedge_set(Number(l)),e.answer_send(l,vr(c,"choice"))}),this.manual=new sh("PHASERS",Is("manual-automatic",null).choices??[],(l,c)=>e.answer_send(l,vr(c,"choice"))),this.units=new Tr(`${i}-units`,"UNITS",0,l=>e.answer_send(String(Math.round(l)),"SLIDER SET")),this.spread=new Tr(`${i}-spread`,"SPREAD",2,l=>e.answer_send(l.toFixed(2),"SLIDER SET")),this.upDown=new sh("SHIELDS",Is("up-down",null).choices??[],(l,c)=>e.answer_send(l,vr(c,"choice")));const a=Y("div","tb-fire-row");this.fire=Zs("tb-fire","FIRE",()=>e.answer_send("0",null)),this.targets=Y("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(rx(e)),this.wheel.wedge_set(null),e.klingons[0]!==void 0&&this.wheel.degrees_set(e.klingons[0].bearing),this.units.range_set(Is("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(Is("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){Vd(this.pills,e);const s=e===null?null:Is(e.question,this.readout);Hd(this.head,"tactical",e,s),this.wheel.lit_set(vi(e,["torpedo-course","bank-course"]),"SET COURSE"),this.burst.lit_set(vi(e,["burst"])),this.burstAngle.lit_set(vi(e,["burst-angle"])),this.manual.lit_set(vi(e,["manual-automatic"])),this.units.lit_set(vi(e,["units","bank-units"]),e?.question==="units"?"FIRE":"SET BANK"),this.spread.lit_set(vi(e,["spread"])),this.upDown.lit_set(vi(e,["up-down"])),this.fire.disabled=!vi(e,["bank-units"]),this.fire.textContent="FIRE THE BANKS SET"}targets_draw(e){if(this.targets.replaceChildren(),e.klingons.length===0){this.targets.append(Y("span","tb-note","NO KLINGONS IN THIS QUADRANT"));return}for(const s of["TARGET","RANGE","BEARING","PHASER HIT"])this.targets.append(Y("span","tb-target-head",s));for(const s of e.klingons){const i=nx(s,()=>{this.host.voice.cue("scanner"),this.host.course_set(s.bearing,s.range/10)});this.targets.append(i,Y("span","tb-target-cell",s.range.toFixed(1)),Y("span","tb-target-cell",`${Math.round(s.bearing)}°`),Y("span","tb-target-cell",`${ex(s.range/10)}%`))}}}class oH{root;rest;head;pills;damage;systems;since;inThatTime;readout=null;constructor(e){this.root=Y("div","tb-view-body tb-view-engineering");const s=Y("section","tb-panel tb-damage");s.append(Y("span","tb-title","DAMAGE CONTROL"),Y("span","tb-note","THE C'S REPORT · ALWAYS ON")),this.damage=Y("div","tb-dc"),s.append(this.damage,Y("span","tb-note","REPAIR TIMES IN STARDATES · REPAIRS RUN WHILE TIME PASSES · DOCKED, FASTER BY THE DOCK FACTOR"));const i=Y("section","tb-panel tb-systems-section");i.append(Y("span","tb-title","SHIP"),Y("span","tb-note","ENERGY, SHIELDS, RESERVES")),this.systems=Y("div","tb-systems"),i.append(this.systems,Y("span","tb-title","SINCE THE LAST COMMAND")),this.since=Y("div","tb-head-grid tb-since-grid"),i.append(this.since,Y("span","tb-note","SHIELDS ARE UP OR DOWN IN TREK(6): THEIR ENERGY IS A READOUT, REFILLED AT A STARBASE"));const n=Y("section","tb-panel tb-station tb-station-time");this.head=jd("REST",e);const r=Y("div","tb-pills tb-command-pills");this.pills=new Map;for(const o of["rest","dock","undock"]){const a=Ud.find(c=>c.id===o);if(a===void 0)continue;const l=__(a,e);this.pills.set(o,l),r.append(l)}this.rest=new Tr("tbe-rest","HOW LONG",1,o=>e.answer_send(o.toFixed(1),"SLIDER SET")),this.rest.input_listen(()=>this.inThatTime_note()),this.inThatTime=Y("div","tb-in-that-time"),n.append(this.head.root,r,this.rest.root,Y("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?[]:tx(s,e);i.length===0&&this.since.append(Y("span","tb-head-label","—"),Y("span","tb-head-value","NOTHING MOVED"));for(const n of i)this.since.append(Y("span","tb-head-label",n.label),Y("span",`tb-head-value ${n.bad?"tb-bad":"tb-good"}`,n.change));this.rest.range_set(Is("how-long",e),this.rest.value_get(),`STARDATES · ${e.mission.timeLeft.toFixed(1)} LEFT`,4),this.inThatTime_note()}question_show(e){Vd(this.pills,e);const s=e===null?null:Is(e.question,this.readout),i=e!==null&&(e.command===null||["rest","dock","undock"].includes(e.command.id))?e:null;Hd(this.head,"helm",i,s),this.rest.lit_set(vi(e,["how-long"]),"REST")}damage_draw(e){this.damage.replaceChildren();for(const i of["DEVICE","","IN FLIGHT","DOCKED",""])this.damage.append(Y("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=Rv(i,e),r=Y("div","tb-bar-track"),o=Y("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(Y("span",`tb-dc-name${n===null?"":" tb-bad"}`,i.name.toUpperCase()),r,Y("span","tb-dc-time",n===null?"—":n.inFlight.toFixed(2)),Y("span","tb-dc-time",n===null?"—":n.docked.toFixed(2)),Y("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=Y("div","tb-bar-track"),f=Y("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(Y("span","tb-dc-name",l),p,Y("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=Y("div","tb-pips");for(let l=0;l<s.torpedoesMax;l++)n.append(Y("span",`tb-pip${l<s.torpedoes?" tb-pip-on":""}`));this.systems.append(Y("span","tb-dc-name","TORPEDOES"),n,Y("span","tb-dc-time tb-sys-value",`${s.torpedoes} / ${s.torpedoesMax}`));const r=(l,c)=>{this.systems.append(Y("span","tb-dc-name",l),Y("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=>(Rv(n,this.readout)?.inFlight??1/0)<=e).map(n=>n.name.toUpperCase());this.inThatTime.append(Y("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(Y("span","tb-head-value tb-bad",`${i} KLINGON${i===1?"":"S"} IN THE QUADRANT WILL FIRE · SPOCK MAY ASK TO CANCEL`))}}const Lv=[{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 aH{constructor(e){this.host=e,this.root=Y("div","tb-view-body tb-view-computer");const s=Y("section","tb-panel tb-chart-section");s.append(Y("span","tb-title","GALAXY · WHAT THE SHIP HAS SEEN"),Y("span","tb-note","PRESS A QUADRANT: THE COURSE PANEL AIMS AT IT · HUNDREDS KLINGONS, TENS BASES, ONES STARS")),this.chart=Y("div","tb-chart-big"),s.append(this.chart);const i=Y("section","tb-station tb-station-computer");this.head=jd("COMPUTER",e);const n=Y("div","tb-pills tb-command-pills");for(const d of Lv){const u=Zs("tb-command tb-request",d.label,()=>this.request_send(d));u.dataset.request=d.line,this.requestPills.push(u),n.append(u)}const r=Y("div","tb-computer-panels"),o=Y("div","tb-panel");o.append(Y("span","tb-title","COURSE AND DISTANCE")),this.courseGrid=Y("div","tb-head-grid");const a=Y("div","tb-pills");a.append(Zs("tb-commit tb-send-helm","SEND TO HELM",()=>this.helm_send()),Zs("tb-commit tb-move-now","MOVE THERE NOW",()=>this.request_send(Lv[3]))),o.append(this.courseGrid,a);const l=Y("div","tb-panel");l.append(Y("span","tb-title","WARP COST")),this.wcDistance=new Tr("tbc-distance","DISTANCE",2,()=>{}),this.wcWarp=new Tr("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=Y("div","tb-head-grid"),l.append(this.wcDistance.root,this.wcWarp.root,this.wcResult);const c=Y("div","tb-panel");c.append(Y("span","tb-title","TRAJECTORY · KLINGONS HERE")),this.trajectory=Y("div","tb-targets"),c.append(this.trajectory,Y("span","tb-title","SCORE SO FAR")),this.score=Y("div","tb-score"),c.append(this.score);const h=Y("div","tb-panel tb-answer-panel");h.append(Y("span","tb-title","THE COMPUTER ANSWERS")),this.answer=Y("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(Is("computer-warp",e),this.warpTouched?this.wcWarp.value_get():e.ship.warp,"THE SHIP'S NOW",4),this.wcDistance.range_set(Is("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:Is(e.question,this.readout);Hd(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,vr(e.label,"computer")),this.host.voice.cue("thinking");return}const i=Ud.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(vr(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=Cv(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(Y("span","tb-srs-corner",""));for(let s=0;s<(e.chart[0]?.length??0);s++)this.chart.append(Y("span","tb-srs-axis",String(s)));for(const s of e.chart){this.chart.append(Y("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=Zs(`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(gm("tb-cq-code",e),Y("span","tb-cq-at",`${e.x},${e.y}`)),i.title=_m(e),i}course_note(){if(this.readout===null||this.target===null)return;const{position:e}=this.readout,s=Cv(this.readout,this.target);this.courseGrid.replaceChildren(Y("span","tb-head-label","FROM"),Y("span","tb-head-value",`QUADRANT ${e.quadrant.x},${e.quadrant.y} · SECTOR ${e.sector.x},${e.sector.y}`),Y("span","tb-head-label","TO"),Y("span","tb-head-value",`QUADRANT ${this.target.quadrant.x},${this.target.quadrant.y} · SECTOR ${this.target.sector.x},${this.target.sector.y}`),Y("span","tb-head-label","COURSE"),Y("span","tb-head-value tb-course-value",`${s.course}°`),Y("span","tb-head-label","DISTANCE"),Y("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=Q1(e,this.wcWarp.value_get(),this.readout.param.warptime),i=H6(e);this.wcResult.replaceChildren(Y("span","tb-head-label","TIME"),Y("span","tb-head-value",`${s.stardates.toFixed(2)} STARDATES`),Y("span","tb-head-label","ENERGY"),Y("span","tb-head-value",`${s.units} UNITS · ${s.unitsShielded} WITH SHIELDS UP`),Y("span","tb-head-label","AT IMPULSE"),Y("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(Y("span","tb-note","NO KLINGONS IN THIS QUADRANT"));return}for(const s of["AT","COURSE","RANGE","PHASER HIT"])this.trajectory.append(Y("span","tb-target-head",s));for(const s of e.klingons)this.trajectory.append(nx(s,()=>{this.host.voice.cue("scanner"),this.host.course_set(s.bearing,s.range/10)}),Y("span","tb-target-cell",`${Math.round(s.bearing)}°`),Y("span","tb-target-cell",s.range.toFixed(1)),Y("span","tb-target-cell",`${ex(s.range/10)}%`))}score_draw(e){const s=J1(e);this.score.replaceChildren();for(const i of s.items.filter(n=>n.points!==0||/killed|remaining/.test(n.label)))this.score.append(Y("span","tb-score-label",i.label.toUpperCase()),Y("span",`tb-score-points${i.points<0?" tb-bad":" tb-good"}`,`${i.points>0?"+":""}${i.points}`));this.score.append(Y("span","tb-score-label tb-score-total","TOTAL"),Y("span","tb-score-points tb-score-total",String(s.total)))}}const mf=["bridge","helm","tactical","engineering","computer"],lH=400,cH="-0.6 -0.6 10.6 10.6",hH=.7,dH=/^S\.R\. scanners$/i,uH=/^L\.R\. scanners$/i,fH={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]},pH=["length","skill","request","quadrant","quadrant-y","sector","sector-y","range","computer-distance","computer-warp","status-report","another","yes-no","unknown"];class mH{constructor(e,s){this.hooks=e,this.harness=new Y6({question_changed:r=>{this.partial_flush(),this.question_show(r)},text_written:r=>this.text_take(r),state_shown:r=>this.state_show(r),ended:()=>{this.leaving||this.hooks.voice.cue("gameover")}}),this.frame=Y1({id:"trek-bridge",className:"trek-bridge",brand:{name:"TREK",sub:"ARGUS · BSD TREK",mark:!1},banner:"TREK • THE BRIDGE",views:mf.map(r=>({key:r,label:r.toUpperCase()})),leave:{label:"LEAVE BRIDGE",destroy:!0},stage:{title:"THE BRIDGE",note:"BRIDGE"},log:{title:"SHIP'S LOG",note:"READ ONLY"},labels:{views:"views",log:"ship's log"}},r=>{const o=mf.find(a=>a===r);o!==void 0&&this.view_set(o)},()=>this.leave_ask()),this.frame.leave.classList.add("tb-leave"),this.root=this.frame.root,this.root.dataset.view="bridge",this.frame.view_mark("bridge"),this.root.setAttribute("aria-label","trek: the bridge");const i={},n=u6();n!==null&&this.root.append(n),this.gutter_build(i,s),this.frame.face.append(this.header_build(i)),this.frame.body.append(this.body_build(i)),this.strip_build(i),this.frame.aside.append(i.ask),this.frame.log.append(this.log_build(i)),this.leaveAsk_build(i),this.root.append(i.leaveAsk),this.parts=i,this.question_show(null)}hooks;root;frame;harness;readout=null;previous=null;view="bridge";nextDistance=null;plan=new Map;answering=!1;computerRunning=!1;leaving=!1;tracker=new Cl;heading=0;pressedSector=null;scanDue=!1;fold=null;frames=new J6;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){e.seed=Y("div","tb-seed",s===null?"RANDOM GALAXY":`SEED ${s}`),this.frame.seat.append(e.seed),e.views=new Map;for(const i of mf){const n=this.frame.views.get(i);n!==void 0&&(n.classList.add("tb-view",`tb-view-${i}`),e.views.set(i,n))}}header_build(e){const s=Y("header","tb-header"),i=Y("section","tb-head-condition"),n=Y("div","tb-condition");n.append(Y("span","tb-condition-label","CONDITION")),e.condition=Y("span","tb-condition-name","—"),n.append(e.condition),e.conditionWhy=Y("div","tb-condition-why",""),i.append(n,e.conditionWhy);const r=p=>{const f=Y("section","tb-head-section");f.append(Y("span","tb-head-title",p));const _=Y("div","tb-head-grid");return f.append(_),[f,_]},[o,a]=r("SHIP"),[l,c]=r("MISSION"),[h,d]=r("POSITION"),u=Y("div","tb-head-grid tb-head-since");return l.append(Y("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=Y("main","tb-body");i.dataset.view="bridge",e.body=i;const n=Y("section","tb-scans");n.append(Y("span","tb-title","LONG RANGE")),e.lrs=Y("div","tb-lrs"),n.append(e.lrs,Y("span","tb-title","GALAXY · WHAT THE SHIP HAS SEEN")),e.chart=Y("div","tb-chart"),n.append(e.chart);const r=Y("section","tb-srs-section");e.srsTitle=Y("span","tb-title","SHORT RANGE"),r.append(e.srsTitle),e.scan=it("svg",{class:"tb-scan",viewBox:cH,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,Y("span","tb-note","PRESS A SECTOR: ITS COURSE AND DISTANCE FILL IN"),e.legend),e.shipPills=new Map;const o=Y("div","tb-pills tb-ship-pills");o.append(Y("span","tb-slider-label","SHIP"));for(const l of Ud.filter(c=>c.station==="ship")){const c=__(l,s);e.shipPills.set(l.id,c),o.append(c)}r.append(o);const a=Y("section","tb-stations");return e.helm=new Gv(s,150,"tb"),e.tactical=new Pv(s,150,"tb"),a.append(e.helm.root,e.tactical.root),e.helmView=new Gv(s,260,"tbh"),e.helmView.root.classList.add("tb-view-body","tb-view-helm"),e.tacticalView=new Pv(s,260,"tbt"),e.tacticalView.root.classList.add("tb-view-body","tb-view-tactical"),e.engineeringView=new oH(s),e.computerView=new aH(s),i.append(n,r,a,e.helmView.root,e.tacticalView.root,e.engineeringView.root,e.computerView.root),i}legend_build(){const e=Y("div","tb-legend");for(const s of f6){const i=Y("span",`tb-legend-item tb-legend-${s.kind}`),n=s.kind==="klingon"?_r:[null];for(const r of n)i.append(g_(s.kind,r));i.append(Y("span","tb-legend-glyph",th[s.kind].trim()===""?"␠":th[s.kind]),Y("span","tb-legend-name",s.name)),e.append(i)}return e}strip_build(e){e.ask=Y("div","tb-ask"),e.ask.hidden=!0,e.ask.setAttribute("role","dialog"),e.askText=Y("span","tb-ask-text",""),e.askPills=Y("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=Zs("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(Y("span","tb-ask-label","THE GAME ASKS"),e.askText,e.askPills,e.askInput,e.askSend)}log_build(e){const s=Y("footer","tb-log-section");return e.log=Y("div","tb-log"),e.log.setAttribute("aria-live","polite"),s.append(e.log),s}leaveAsk_build(e){e.leaveAsk=Y("div","tb-leave-ask"),e.leaveAsk.hidden=!0,e.leaveAsk.setAttribute("role","dialog");const s=e.leaveAsk,i=Zs("tb-grave","LEAVE · THE GAME ENDS",()=>{this.leaving=!0,this.hooks.voice.cue("close"),this.hooks.leave()}),n=Zs("","STAY",()=>{s.hidden=!0});e.leaveAsk.append(Y("span","tb-ask-label","LEAVE THE BRIDGE?"),Y("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,this.frame.view_mark(e);for(const[s,i]of this.parts.views)i.classList.toggle("tb-view-on",s===e);this.frame.stageNote.textContent=e.toUpperCase(),this.hooks.voice.pill(vr(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=z6(e.id);return s===null?this.hooks.voice.pill(vr(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}
|
|
4355
4355
|
`,!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:S6(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}
|
|
4356
4356
|
`,!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=U6(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,dH)});for(const r of s.klingons)r.mark=this.tracker.mark_find(r);n&&(this.pressedSector=null),n&&this.device_isOk(s,uH)&&(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(sx(c,h))}const l={kind:"ship",variant:null};if(a&&!i&&r!==null&&!o)this.srs_draw(r,!1),await nl(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}=tH(r.position,e.position);this.srs_draw(r,!1),await nl(n,this.frames,l,r.position.sector,c,{heading:this.heading}),Bv(n,!0),this.shown=Wv(e),this.srs_draw(this.shown,!1),this.lrs_draw(this.shown,!0),this.chart_draw(this.shown),await this.frames.wait(jn.rescan),Bv(n,!1),await nl(n,this.frames,l,h,e.position.sector,{heading:this.heading})}this.shown=Wv(e),this.srs_draw(this.shown),this.lrs_draw(this.shown,o&&i),this.chart_draw(this.shown);for(const c of y6(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(Y("span","tb-head-label",l),Y("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",`${J1(e).total}`]]);const r=this.previous===null?[]:tx(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=_6(e.ship.shield,e.ship.shieldMax,e.ship.shieldsUp,e.condition.name==="DOCKED"),h=it("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=it("text",{class:"tb-scan-axis",x:s,y:i});return n.textContent=e,n}sector_make(e,s,i,n,r=!0){const o=Th(i,e),a=dd(i,e),l=this.pressedSector?.x===e.x&&this.pressedSector.y===e.y,c=it("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=it("title",{}),d=e.kind==="empty"?"·":th[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,it("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(it("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"?Th(e,i):0,g=m_(p,{cx:e.y+.5,cy:e.x+.5,size:hH},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=fH[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=Y("div","tb-lrs-cell tb-lrs-edge");h.append(Y("span","tb-lrs-code","—"),Y("span","tb-lrs-at","EDGE")),h.title="outside the galaxy",i.lrs.append(h);continue}const c=Y("div",`tb-lrs-cell${l.here?" tb-here":""}${l.klingons>0?" tb-hostile":""}${l.code===null?" tb-unscanned":""}${l.supernova?" tb-supernova":""}`);c.append(gm("tb-lrs-code",l),Y("span","tb-lrs-at",`${l.x},${l.y}`)),c.title=_m(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)&&rH(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=gm(`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=_m(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}Vd(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:Is(i,this.readout),r=n!==null&&i!==null&&i!=="command"&&(n.kind==="yesno"||n.kind==="text"||pH.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(Zs("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
|
|
4357
4357
|
`,!0),!0):(this.fold_close(),!1)}fold_open(e){this.frames.push({kind:"fold",run:()=>{const s=Y("details","tb-log-fold");s.append(Y("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(`
|
|
4358
4358
|
`);this.partial=i.pop()??"";for(const n of i)this.line_take(n,!1)}partial_flush(){if(this.partial==="")return;const e=this.partial;this.partial="",this.line_take(e,!1)}log_write(e,s=!0){for(const i of e.replace(/\n$/,"").split(`
|
|
4359
4359
|
`))this.line_take(i,s)}line_take(e,s){const i=s?null:Z6(e),n=i?.kind==="torpedo-point";s||this.tracker.line_hear(e),i?.kind==="torpedo-head"?this.trackPrinting=!0:n||(this.trackPrinting=!1);const r=n&&!this.trackPrinting?null:i;this.frames.push({kind:r===null?"line":r.kind,run:async o=>{if(this.log_append(e,s),!s){for(const a of w6(e))this.hooks.voice.cue(a);r!==null&&await this.event_play(r,o)}}})}log_append(e,s=!1){const{parts:i}=this;for((this.fold??i.log).append(Y("div",s?"tb-log-line tb-log-own":"tb-log-line",e));i.log.childElementCount>lH;)i.log.firstElementChild?.remove();i.log.scrollTop=i.log.scrollHeight}async event_play(e,s){const i=this.shown,n=this.parts.scan;if(i!==null)switch(e.kind!=="torpedo-point"&&e.kind!=="torpedo-head"&&await this.torpedo_end(s),e.kind){case"torpedo-head":await this.torpedo_end(!0),this.torpedo=new nH(n,i.position.sector);return;case"torpedo-point":this.torpedo!==null&&await this.torpedo.point_reach(this.frames,e.at,s);return;case"torpedo-end":return;case"kill":await ih(n,this.frames,e.at,"kill",s),this.shown_clear(e.at);return;case"nova":this.hooks.voice.cue("nova"),await ih(n,this.frames,e.at,"nova",s),this.shown_clear(e.at);return;case"misfire":this.hooks.voice.cue("deny"),await ih(n,this.frames,i.position.sector,"misfire",s);return;case"phaser":await Nv(n,this.frames,i.position.sector,e.at,!1,s);return;case"incoming":{this.hooks.voice.cue("shield");const r=iH(n,this.frames,s);e.from!==null&&await Nv(n,this.frames,e.from,i.position.sector,!0,s);const o=Math.trunc(e.hit*e.absorb/100);i.ship.shield=Math.max(0,i.ship.shield-o),this.srs_draw(i),await r;return}case"klingon-move":{this.hooks.voice.cue("klingon-pass");const r=this.tracker.mark_find(e.to)??this.tracker.mark_find(e.from);this.shown_clear(e.from),this.srs_draw(i),await nl(n,this.frames,{kind:"klingon",variant:r},e.from,e.to,{hostile:!0},s),this.shown_put(e.to,"klingon",r);return}case"klingon-escape":{this.hooks.voice.cue("klingon-pass");const r=this.tracker.mark_find(e.from),o={x:Math.sign(e.quadrant.x-i.position.quadrant.x),y:Math.sign(e.quadrant.y-i.position.quadrant.y)},a={x:o.x>0?10.2:o.x<0?-1.2:e.from.x,y:o.y>0?10.2:o.y<0?-1.2:e.from.y};this.shown_clear(e.from),this.srs_draw(i),await nl(n,this.frames,{kind:"klingon",variant:r},e.from,a,{hostile:!0},s),this.lrsBloom={at:e.quadrant,hostile:!0};return}case"supernova":this.hooks.voice.cue("supernova"),await ih(n,this.frames,e.at,"supernova",s);return;case"supernova-report":this.hooks.voice.cue("supernova"),this.lrsBloom={at:e.quadrant,hostile:!0};return;default:return}}async torpedo_end(e){const s=this.torpedo;s!==null&&(this.torpedo=null,await s.end(this.frames,e))}shown_clear(e){const s=this.shown;if(s===null)return;const i=s.sectors[e.x]?.[e.y];i!==void 0&&(i.kind="empty",i.glyph="."),s.klingons=s.klingons.filter(n=>n.x!==e.x||n.y!==e.y),this.srs_draw(s)}shown_put(e,s,i){const n=this.shown;if(n===null)return;const r=n.sectors[e.x]?.[e.y];r!==void 0&&(r.kind=s,r.glyph=th[s]);const o=n.position.sector;n.klingons.push({x:e.x,y:e.y,bearing:Th(o,e),range:dd(o,e),power:0,mark:i}),this.srs_draw(n)}}function Wv(t){return JSON.parse(JSON.stringify(t))}const gH=24.5,_H=.6;function bH(t){const e=t.sampleRate*4,s=t.createBuffer(1,e,t.sampleRate),i=s.getChannelData(0);for(let n=0;n<e;n++)i[n]=(Math.random()*2-1)*1.732;return s}function MH(t,e,s,i,n,r={}){const o=r.rate??1,a=r.pitch??1,l=n.frame/o,c=r.start??0,h=Math.min(n.frames,r.end??n.frames),d=(r.gain??1)*_H/(n.peak||1);let u=0;for(const[g,m,v]of n.tracks){const y=g+m.length-1;if(y<=c||g>=h)continue;const b=Math.max(g,c),w=Math.min(y,h);if(w<=b)continue;const z=Float32Array.from(m.slice(b-g,w-g+1),E=>E*a),x=Float32Array.from([0,...v.slice(b-g,w-g+1).map(E=>E*d),0]),M=i+(b-c)*l,S=(w-b)*l,T=t.createOscillator();T.type="sine",T.frequency.setValueAtTime(z[0]??440,M),z.length>1&&T.frequency.setValueCurveAtTime(z,M,S);const A=t.createGain();A.gain.setValueAtTime(0,M-l),A.gain.setValueCurveAtTime(x,M-l,S+2*l),T.connect(A),A.connect(e),T.start(M-l),T.stop(M+S+l+.01),u++}const p=n.noise.frames,f=Math.max(0,c),_=Math.min(p.length,h);if(_>f+1){const g=t.createBufferSource();g.buffer=s,g.loop=!0,g.loopStart=Math.random()*2;const m=(_-f)*l;n.noise.centres.forEach((v,y)=>{const b=Float32Array.from([0,...p.slice(f,_).map(M=>(M[y]??0)*d*gH),0]);if(b.every(M=>M<1e-6))return;const w=t.createBiquadFilter();w.type="bandpass",w.frequency.setValueAtTime(v*a,i),w.Q.setValueAtTime(n.noise.q,i);const z=t.createBiquadFilter();z.type="bandpass",z.frequency.setValueAtTime(v*a,i),z.Q.setValueAtTime(n.noise.q,i);const x=t.createGain();x.gain.setValueAtTime(0,i-l),x.gain.setValueCurveAtTime(b,i-l,m+2*l),g.connect(w),w.connect(z),z.connect(x),x.connect(e)}),g.start(i-l),g.stop(i+m+l+.01)}return{voices:u,seconds:(h-c)*l}}function vH(t,e){return t.pills[e]??t.cues.press??null}class wH{constructor(e="sound/"){this.base=e}base;context=null;out=null;noise=null;muted=!1;bank=null;models=new Map;lastAt=0;tally={played:0,loaded:0,missing:0,voices:0};tally_get(){return{...this.tally}}muted_set(e){this.muted=e,this.out!==null&&this.context!==null&&this.out.gain.setTargetAtTime(e?0:1,this.context.currentTime,.01)}muted_is(){return this.muted}cue_play(e,s={}){this.muted||this.bank_load().then(i=>{const n=i?.cues[e];n!==void 0&&this.file_play(n,s)})}pill_play(e){this.muted||this.bank_load().then(s=>{const i=s===null?null:vH(s,e);i!==null&&this.file_play(i,{})})}preload(){this.bank_load().then(e=>{if(e!==null)for(const s of new Set([...Object.values(e.cues),...Object.values(e.pills)]))this.model_load(s)})}bank_load(){return this.bank===null&&(this.bank=fetch(`${this.base}bank.json`).then(e=>e.ok?e.json():Promise.reject(new Error(String(e.status)))).catch(()=>null)),this.bank}model_load(e){let s=this.models.get(e);return s===void 0&&(s=fetch(`${this.base}${e}`).then(i=>i.ok?i.json():Promise.reject(new Error(String(i.status)))).then(i=>(this.tally.loaded++,i)).catch(()=>(this.tally.missing++,null)),this.models.set(e,s)),s}context_get(){if(this.context===null){const e=window.AudioContext??window.webkitAudioContext;if(e===void 0)return null;this.context=new e,this.out=this.context.createGain(),this.out.gain.value=this.muted?0:1;const s=this.context.createDynamicsCompressor();s.threshold.value=-12,s.ratio.value=6,this.out.connect(s),s.connect(this.context.destination),this.noise=bH(this.context)}return this.context.state==="suspended"&&this.context.resume(),{context:this.context,out:this.out,noise:this.noise}}file_play(e,s){const i=this.context_get();i!==null&&this.model_load(e).then(n=>{if(n===null||this.muted)return;const r=i.context.currentTime+.02,o=Math.max(r,this.lastAt+.08);this.lastAt=o;try{const a=MH(i.context,i.out,i.noise,o,n,s);this.tally.played++,this.tally.voices+=a.voices}catch{}})}}const Ni=new wH;function yH(t){const e=t.trim().split(/\s+/),s=e.indexOf("--seed");if(s<0)return null;const i=Number(e[s+1]);return Number.isFinite(i)?i:null}function zH(t){let e=null;const s={pill:a=>Ni.pill_play(a),cue:a=>Ni.cue_play(a)},i={events:0,states:0,lastError:null};window.__argusTrek={question:()=>e?.harness_get().question_get()?.question??null,prompt:()=>e?.harness_get().question_get()?.prompt??null,readout:()=>e?.readout_get()??null,view:()=>e?.view_get()??null,heard:()=>({...i,voice:Ni.tally_get()}),frames:()=>e?.frames_get()??null};const n=()=>{e!==null&&(e.root.remove(),e=null,delete document.body.dataset.takeover)},r=()=>{e!==null&&(e.leaveAsk_close(),e.harness_get().abandon()||n())};return window.addEventListener("keydown",a=>{e===null||a.key!=="Escape"||(a.stopImmediatePropagation(),a.preventDefault(),e.leaveAsk_isOpen()?e.leaveAsk_close():e.leave_ask())},!0),{open:async a=>{if(e!==null)return;const l=new mH({voice:s,leave:r},yH(a));e=l,document.body.append(l.root),document.body.dataset.takeover="trek",Ni.preload(),Ni.cue_play("open");try{const h=(await t.client.line_execute(a,{operator:!0})).envelopes.find(d=>d.model?.kind==="games.trek");l.harness_get().end(typeof h?.model?.data?.exit=="number"?(h?.model?.data).exit:0)}catch{l.harness_get().end(1)}finally{e===l&&n()}},active_is:()=>e!==null,ask:a=>e===null?Promise.resolve(null):e.harness_get().ask(a.message),output_take:a=>{e?.harness_get().text_take(a)},event_take:(a,l)=>{i.events++,a==="games.trek.state"&&i.states++;try{e?.harness_get().event_take(a,l)}catch(c){i.lastError=c instanceof Error?`${c.message}
|
|
4360
|
-
${c.stack??""}`:String(c),console.error("trek bridge: could not draw the state",c)}}}}const gf=["overview","size","build","cluster","chris","teardown"],SH=["chris-deploy","chris-seed","smoke"],Dh=730,xH={balanced:10,higher:20,ultra:30},Fv=3,OH=10;function EH(t,e){return t===void 0?e:{...t,...e,resources:e.resources??t.resources,cost:e.cost!==void 0?e.cost:t.cost}}function Rn(t,e,s=2){return`${e==="USD"?"$":`${e} `}${t.toFixed(s)}`}function Uv(t){const e=Math.max(0,Math.round(t/1e3));if(e<60)return`${e}s`;const s=Math.floor(e/60);if(s<60)return`${s}m`;const i=Math.floor(s/60);return i<48?`${i}h ${s%60}m`:`${Math.floor(i/24)}d ${i%24}h`}function $v(t){return t.origin==="found"?t.condition==="GONE"?"FOUND · NOTHING LEFT":"FOUND · NOT ADOPTED":t.origin==="adopted"?"ADOPTED · PLANS ONLY":t.origin==="checkout"?"CHECKOUT · READ ONLY":t.gone!==null&&t.gone!==void 0?"TORN DOWN":"BUILT HERE"}function AH(t){const e=t.billing===!0,s=t.origin==="adopted"?"ADOPTED":t.origin==="checkout"?"READ FROM A CHECKOUT":t.condition==="GONE"?"TORN DOWN":t.condition==="SIZING"?"NOTHING BUILT":t.condition==="STOPPED"?!e&&t.next===t.billingStep?"PLANNED":"NOT FINISHED":t.condition??"";return e?{text:`BILLING · ${s}`,billing:e}:{text:`${s} · NOTHING BILLED`,billing:e}}function _f(t){return t.steps.map((e,s)=>{const i=e.name??e.folder.replace(/^\d+-/,""),n=String(s+1).padStart(2,"0"),r=TH(e.evidence??""),o=i===t.billingStep,a=(l,c)=>({n,name:i,word:l,tone:c,note:r,billFrom:o});return e.state==="done"?a("DONE","done"):e.state==="running"?a("RUNNING","running"):e.state==="failed"?a("FAILED","failed"):e.state==="expired"?a("EXPIRED","expired"):e.state==="unknown"?a("UNKNOWN","unknown"):i===t.next?t.asking!==null&&t.asking!==void 0?a("ASKING","asking"):a("NEXT","next"):a("NOT DONE","later")})}function TH(t){const s=t.match(/^done before adoption \(harbor-oci: [a-z ]+, (.*)\)$/)?.[1]??t;return s.length>60?`${s.slice(0,59)}…`:s}function bf(t){return{done:t.steps.filter(e=>e.state==="done").length,total:t.steps.length}}function jv(t,e){if(t===null)return[{label:"",text:"FIRST READ"}];const s=[];t.condition!==e.condition&&s.push({label:"CONDITION",text:`${t.condition??"?"} → ${e.condition??"?"}`});const i=new Map(t.steps.map(l=>[l.name??l.folder,l.state])),n=e.steps.filter(l=>i.get(l.name??l.folder)!==l.state);for(const l of n.slice(-2))s.push({label:(l.name??l.folder).toUpperCase(),text:`${(i.get(l.name??l.folder)??"NONE").toUpperCase()} → ${l.state.toUpperCase()}`});const r=l=>l.verify===null||l.verify===void 0?null:ox(l.verify.checks);r(t)!==r(e)&&s.push({label:"VERIFY",text:r(e)??"NOT RUN"});const o=l=>l.plan===null||l.plan===void 0?null:ax(l.plan);o(t)!==o(e)&&s.push({label:"PLAN",text:o(e)??"NONE"});const a=l=>l.cost===null||l.cost===void 0?null:Rn(l.cost.hourly,l.cost.currency);return a(t)!==a(e)&&a(t)!==null&&a(e)!==null&&s.push({label:"PER HOUR",text:`${a(t)} → ${a(e)}`}),t.protected!==e.protected&&s.push({label:"LOCK",text:e.protected===!1?"OFF":"ON"}),s.length===0?[{label:"",text:"NO CHANGE"}]:s.slice(0,3)}function ox(t){const e=t.filter(n=>n.ok===!0).length,s=t.filter(n=>n.ok===!1).length,i=t.length-e-s;return`${e} OF ${t.length} PASS${s>0?` · ${s} FAIL`:""}${i>0?` · ${i} NOT RUN`:""}`}function ax(t){const e=t.change+t.replace,s=e>0||t.drift===0?`${e} ~`:"",i=t.drift>0?`${t.drift} ~ TAG DRIFT`:"";return[`${t.create} +`,s,i,`${t.destroy} −`].filter(n=>n!=="").join(" · ")}function Hv(t){const e=t.includes(":")?t.slice(t.indexOf(":")+1):t,s=e.match(/AD-\d+$/i);return s!==null?s[0].toUpperCase():e}function Vv(t,e,s){const i=Math.max(t.zones.length,1),n=[];for(let l=0;l<e.controlPlane.count;l++)n.push({name:`${s}-cp-${l}`,vcpu:e.controlPlane.vcpu,ramGib:e.controlPlane.ramGib,zone:l%i});for(let l=0;l<e.workers.count;l++)n.push({name:`${s}-w-${l}`,vcpu:e.workers.vcpu,ramGib:e.workers.ramGib,zone:l%i});const r=t.zones.map((l,c)=>{const h=n.filter(f=>f.zone===c),d=h.reduce((f,_)=>f+_.vcpu/t.vcpuPerCore,0),u=h.reduce((f,_)=>f+_.ramGib,0),p=l.coresFree!==null&&l.memoryFree!==null;return{zone:l.zone,nodes:h.map(f=>f.name),coresNeeded:d,coresFree:l.coresFree,memoryNeeded:u,memoryFree:l.memoryFree,fits:p?d<=l.coresFree&&u<=l.memoryFree:null,tightest:!1}}),o=l=>l.coresFree===null?1/0:(l.coresFree-l.coresNeeded)/Math.max(l.coresFree,1),a=[...r].filter(l=>l.coresFree!==null).sort((l,c)=>o(l)-o(c))[0];return a!==void 0&&r.length>1&&(a.tightest=!0),r}function qv(t,e){const s=e.controlPlane.count*e.controlPlane.vcpu+e.workers.count*e.workers.vcpu,i=e.controlPlane.count*e.controlPlane.ramGib+e.workers.count*e.workers.ramGib,n=(h,d)=>t.services===null?null:h*(t.services.volumeGibMonth+(xH[d]??10)*t.services.vpuGibMonth)/Dh,r=e.controlPlane.count*e.controlPlane.bootGib+e.workers.count*e.workers.bootGib,o=t.services===null?null:n(e.controlPlane.count*e.controlPlane.bootGib,e.controlPlane.bootTier)+n(e.workers.count*e.workers.bootGib,e.workers.bootTier),a=e.chris.dataGib+e.chris.databaseGib+e.chris.queueGib,l=[{what:`COMPUTE · ${s} vCPU`,hourly:t.price===null?null:s*t.price.vcpuHour},{what:`MEMORY · ${i} GiB`,hourly:t.price===null?null:i*t.price.gibHour},{what:`BOOT VOLUMES · ${r} GiB`,hourly:o},{what:`CHRIS VOLUMES · ${a} GiB`,hourly:n(a,"balanced")},{what:`LOAD BALANCERS · ${Fv}`,hourly:t.services===null?null:Fv*(t.services.balancerHour+OH*t.services.balancerMbpsHour)}],c=l.filter(h=>h.hourly!==null);return{rows:l,hourly:c.length===0?null:c.reduce((h,d)=>h+d.hourly,0),currency:t.price?.currency??"USD"}}function DH(t,e,s,i=null){const n=["domain","new",t];i!==null&&n.push("--base-domain",i);const r=o=>`${o.count}x${o.vcpu}/${o.ramGib}`;return e.family!==s.family&&n.push("--family",e.family),r(e.controlPlane)!==r(s.controlPlane)&&n.push("--plane",r(e.controlPlane)),r(e.workers)!==r(s.workers)&&n.push("--workers",r(e.workers)),e.chris.dataGib!==s.chris.dataGib&&n.push("--data",String(e.chris.dataGib)),e.chris.databaseGib!==s.chris.databaseGib&&n.push("--database",String(e.chris.databaseGib)),e.chris.queueGib!==s.chris.queueGib&&n.push("--queue",String(e.chris.queueGib)),n.join(" ")}function Mf(t){return{family:t.family,controlPlane:{...t.controlPlane},workers:{...t.workers},chris:{...t.chris}}}const IH=/^[a-z]([a-z0-9-]{0,52}[a-z0-9])?$/;function CH(t,e){return t===""?"NAME IT FIRST":IH.test(t)?e.includes(t)?`${t.toUpperCase()} IS TAKEN`:null:"A DNS LABEL: a-z, 0-9 AND -, A LETTER FIRST"}const ps={status:t=>`domain ${t}`,adopt:t=>`domain adopt ${t}`,plan:t=>`domain plan ${t}`,verify:t=>`domain verify ${t}`,spend:t=>`spend ${t}`,build:t=>`domain build ${t}`,kill:t=>`kill ${t}`,follow:t=>`domain build ${t}`,protect:(t,e)=>`domain protect ${t} ${e?"on":"off"}`,teardown:t=>`domain teardown ${t}`,size:t=>t===void 0?"domain size":`domain size --family ${t}`,tenant:t=>`play ~/tenant.mise --param NAME=${t}`};function RH(t){return/\[y\/N\]\s*$/i.test(t.trim())?"yes-no":"typed"}const kH=400,gi="",nh={overview:"OVERVIEW",size:"SIZE",build:"BUILD",cluster:"CLUSTER",chris:"CHRIS",teardown:"TEARDOWN"};function V(t,e,s){const i=document.createElement(t);return i.className=e,s!==void 0&&(i.textContent=s),i}function NH(t){return t.replace(/\x1b\[[0-9;?]*[A-Za-z]/g,"").replace(/\r/g,"")}class BH{constructor(e){this.hooks=e,this.frame=Y1({id:"td-controller",className:"td-controller",brand:{name:"STRATUS",sub:"TD CONTROLLER · OCI",mark:!0},banner:"STRATUS • TD CONTROLLER",views:gf.map(p=>({key:p,label:nh[p],destroy:p==="teardown"})),leave:{label:"LEAVE"},stage:{title:"NEW TRUSTED DOMAIN",note:nh.size},log:{title:"TRUSTED DOMAIN LOG",note:"THE SESSION'S LINES · TYPE BELOW"},labels:{views:"Views",log:"Trusted Domain log"}},p=>{const f=gf.find(_=>_===p);f!==void 0&&(this.hooks.voice.pill(nh[f]),this.view_show(f))},()=>{this.hooks.voice.pill("LEAVE"),this.hooks.leave()}),this.frame.leave.classList.add("tdc-leave"),this.root=this.frame.root,this.root.setAttribute("role","application"),this.root.setAttribute("aria-label","TD controller");const s=this.frame.seat;s.setAttribute("aria-label","Trusted Domains");const i=V("header","tdc-header");this.frame.face.append(i);const n=new Map;for(const p of gf){const f=this.frame.views.get(p);f!==void 0&&(f.classList.add("tdc-view",`tdc-view-${p}`),n.set(p,f))}const r=V("div","tdc-body");this.frame.body.append(r);const o=V("section","tdc-strip");o.setAttribute("aria-label","The engine asks"),o.hidden=!0,this.frame.aside.append(o);const a=V("section","tdc-foot"),l=V("div","tdc-log");l.setAttribute("aria-live","polite");const c=V("div","tdc-prompt"),h=V("label","tdc-prompt-label","stratus ›"),d=V("input","tdc-prompt-input");d.id="tdc-prompt-input",h.setAttribute("for",d.id),d.placeholder="any session line · domain plan · ls domains/ · spend",d.spellcheck=!1,d.autocomplete="off",d.addEventListener("keydown",p=>{if(p.key!=="Enter")return;const f=d.value.trim();f!==""&&(d.value="",this.line_send(f))}),c.append(h,d);const u=V("div","tdc-log-column");u.append(l,c),a.append(u),this.frame.log.append(a),this.parts={pills:s,header:i,views:n,body:r,strip:o,log:l,input:d,promptLabel:h},this.ticker=setInterval(()=>{this.domain_get()?.running&&this.header_draw()},15e3),this.draw()}hooks;root;frame;domains=new Map;current=gi;view="overview";before=null;since=[{label:"",text:"FIRST READ"}];size=null;sizeAsked=!1;levers=null;newName="";zone=null;busy=null;ask=null;partial="";stepLog=[];stepLogLine=null;parts;ticker=null;dispose(){this.ticker!==null&&clearInterval(this.ticker),this.ticker=null,this.ask?.answer(null),this.ask=null}domains_take(e){const s=this.domain_get();this.domains.clear();for(const i of e)this.domains.set(i.name,i);this.current!==gi&&!this.domains.has(this.current)&&(this.current=e[0]?.name??gi),this.cues_play(s,this.domain_get()),this.draw()}domain_take(e){const s=this.domains.get(e.name);this.domains.set(e.name,EH(s,e)),e.name===this.current&&this.cues_play(s??null,this.domain_get()),this.draw()}domain_choose(e){this.current=e!==""&&this.domains.has(e)?e:this.domains.keys().next().value??gi,this.current===gi&&(this.view="size",this.size_need()),this.draw()}domain_get(){return this.domains.get(this.current)??null}view_get(){return this.view}names_get(){return[...this.domains.keys()]}output_take(e){const i=(this.partial+NH(e)).split(`
|
|
4361
|
-
`);this.partial=i.pop()??"";for(const n of i)this.log_add(n,"out")}ask_take(e,s){return this.ask?.answer(null),this.hooks.voice.cue("hail"),new Promise(i=>{this.ask={message:e,kind:s,answer:n=>{this.ask=null,this.strip_draw(),i(n)}},this.log_add(e,"ask"),this.strip_draw()})}asking_is(){return this.ask!==null}async line_send(e){if(this.busy!==null){this.log_add(`the lane is held by: ${this.busy} (STOP FOLLOWING frees it; the build goes on)`,"note");return}this.before=this.domain_get(),this.busy=e,this.log_add(`stratus> ${e}`,"sent"),/^(domain (build|plan)|play) /.test(e)&&(this.stepLog=[],this.stepLogLine=e),this.draw();try{await this.hooks.run(e)}finally{this.partial!==""&&(this.log_add(this.partial,"out"),this.partial=""),this.busy=null;const s=this.domain_get();s!==null&&(this.since=jv(this.before,s)),this.draw()}}since_refresh(){const e=this.domain_get();e!==null&&(this.since=jv(this.before?.name===e.name?this.before:null,e)),this.header_draw()}title_get(){const e=this.domain_get();return e===null?"SIZING · NEW TRUSTED DOMAIN":`${e.condition??"READING"} · ${e.name}`}view_show(e){this.view=e,e==="size"&&this.size_need(),this.draw()}draw(){this.pills_draw(),this.header_draw(),this.frame.view_mark(this.view);for(const[e,s]of this.parts.views)s.classList.toggle("tdc-view-on",e===this.view);this.frame.stageTitle.textContent=this.current===gi?"NEW TRUSTED DOMAIN":this.current.toUpperCase(),this.frame.stageNote.textContent=nh[this.view],this.body_draw(),this.strip_draw(),this.parts.promptLabel.textContent=this.current===gi?"stratus ›":`stratus ~/${this.current} ›`,this.parts.input.disabled=this.busy!==null,this.root.dataset.busy=this.busy===null?"no":"yes",document.title=this.title_get()}pills_draw(){const e=this.parts.pills;e.replaceChildren();for(const s of[...this.domains.keys(),gi]){const i=this.domains.get(s),n=V("button","tdc-domain takeover-seat-pill",s===gi?"+ NEW":s.toUpperCase());n.type="button",n.dataset.condition=i?.condition??"SIZING",i?.billing===!0&&n.classList.add("tdc-billing"),n.setAttribute("aria-current",s===this.current?"true":"false"),n.addEventListener("click",()=>{if(this.hooks.voice.pill(n.textContent??""),s===gi){this.current=gi,this.view_show("size");return}this.current=s,this.view==="size"&&this.levers!==null&&(this.levers=null),this.line_send(ps.status(s))}),e.append(n)}}header_draw(){const e=this.parts.header;e.replaceChildren();const s=this.domain_get();if(e.append(this.condition_make(s)),s===null){e.append(this.headSection_make("TRUSTED DOMAIN",[["NAME",this.newName===""?"[NAME IT ON SIZE]":this.newName],["REGION",this.size?.region??"…"],["ADDRESS",this.size===null?"…":this.zone===null?"NO ZONE · CHOOSE ONE ON SIZE":`${this.newName||"<name>"}.${this.zone}`]]),this.headSection_make("COST · AS SIZED",this.sizedCost_rows()),this.headSection_make("FIT",this.fit_rows()),this.headSection_make("SINCE LAST CHANGE",[["","NOTHING WRITTEN YET"]]));return}const i=s.path.match(/^\/net\/[^/]+\/([^/]+)\//)?.[1]??"?";e.append(this.headSection_make("TRUSTED DOMAIN",[["TENANCY",i],["REGION",s.region??"?"],["ADDRESS",s.cluster??(s.origin==="found"?"NO ZONE KNOWN":"?")]]),this.headSection_make("COST",this.cost_rows(s),s.billing===!0?0:-1),this.headSection_make("BUILD",this.build_rows(s)),this.since_make())}condition_make(e){const s=V("section","tdc-head-condition");s.setAttribute("aria-label","Condition");const i=V("div","tdc-condition"),n=e?.condition??"SIZING";i.dataset.condition=n,i.append(V("span","tdc-condition-label","CONDITION"),V("span","tdc-condition-name",n));const r=e===null?{text:"NOTHING BUILT · NOTHING BILLED",billing:!1}:AH(e),o=V("div",`tdc-condition-why${r.billing?" tdc-bill":""}`,r.text),a=V("div","tdc-chips");if(e!==null){const l=bf(e);a.append(V("span","tdc-chip",`${l.done} OF ${l.total} DONE${e.origin==="found"?" · FROM THE CLOUD":""}`),V("span","tdc-chip tdc-chip-class",$v(e))),e.origin==="found"&&e.condition==="GONE"||a.append(this.lock_make(e))}else a.append(V("span","tdc-chip","NO SPEC YET"));return s.append(i,o,a),s}lock_make(e){const s=e.protected!==!1,i=V("span",`tdc-chip tdc-lock${s?" tdc-lock-on":" tdc-lock-off"}`);return i.append(this.lockIcon_make(s),document.createTextNode(s?"PROTECTED":"UNLOCKED")),i.title=s?`teardown refused until: domain protect ${e.name} off`:"teardown may run; it still asks for the name typed back",i}lockIcon_make(e){const s="http://www.w3.org/2000/svg",i=document.createElementNS(s,"svg");i.setAttribute("viewBox","0 0 16 16"),i.setAttribute("width","12"),i.setAttribute("height","12"),i.setAttribute("aria-hidden","true");const n=document.createElementNS(s,"path");n.setAttribute("d",e?"M4.5 7V5a3.5 3.5 0 0 1 7 0v2":"M4.5 7V5a3.5 3.5 0 0 1 6.8-1.2"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.8");const r=document.createElementNS(s,"rect");for(const[o,a]of[["x","3"],["y","7"],["width","10"],["height","7"],["rx","1.5"],["fill","currentColor"]])r.setAttribute(o,a);return i.append(n,r),i}headSection_make(e,s,i=-1){const n=V("section","tdc-head-section");n.setAttribute("aria-label",e),n.append(V("span","tdc-head-title",e));const r=V("div","tdc-head-grid");return s.forEach(([o,a],l)=>{r.append(V("span",`tdc-head-label${l===i?" tdc-head-label-bill":""}`,o),V("span","tdc-head-value",a))}),n.append(r),n}since_make(){const e=V("section","tdc-head-section");e.setAttribute("aria-label","Since the last command"),e.append(V("span","tdc-head-title","SINCE LAST COMMAND"));const s=V("div","tdc-since");for(const i of this.since)s.append(V("span","tdc-since-label",i.label),V("span","tdc-since-value",i.text));return e.append(s),e}cost_rows(e){if(e.cost===null||e.cost===void 0)return[["PER HOUR",e.billing===!0?"NOT PRICED":"0"],["SO FAR","—"],["A MONTH","—"]];const{hourly:s,soFar:i,currency:n}=e.cost;return[["PER HOUR",`${Rn(s,n)} · EST`],["SO FAR",Rn(i,n)],["A MONTH",`${Rn(s*Dh,n,0)} · AT THIS RATE`]]}build_rows(e){const s=e.lastDone===null?"nothing":e.lastDone.replace(/^\d+-/,""),i=e.running===null||e.running===void 0?"nothing":`${e.running.step??"between steps"}${e.running.since!==null?` · ${Uv(Date.now()-Date.parse(e.running.since))}`:""}`,n=e.plan===null||e.plan===void 0?"none kept":ax(e.plan);return[["LAST DONE",s],["RUNNING",i],["LAST PLAN",n]]}sizedCost_rows(){if(this.size===null||this.levers===null)return[["PER HOUR","…"],["A MONTH","…"],["SO FAR","0"]];const e=qv(this.size,this.levers);return[["PER HOUR",e.hourly===null?"NOT PRICED":`${Rn(e.hourly,e.currency)} · EST`],["A MONTH",e.hourly===null?"—":`${Rn(e.hourly*Dh,e.currency,0)} · EST`],["SO FAR","0"]]}fit_rows(){if(this.size===null||this.levers===null)return[["ZONES","…"]];const e=Vv(this.size,this.levers,this.newName||"new"),s=e.filter(n=>n.fits===!0).length,i=e.find(n=>n.tightest);return[["ZONES",`${s} OF ${e.length} FIT`],["TIGHTEST",i===void 0?"—":Hv(i.zone)],["FAMILY",this.levers.family]]}body_draw(){const e=this.parts.body;e.replaceChildren(),e.dataset.view=this.view;const s=this.domain_get();if(this.view==="size"){e.append(...this.size_make(s));return}if(s===null){e.append(this.empty_make("NO TRUSTED DOMAIN CHOSEN","Press + NEW and size one on SIZE, or a Trusted Domain's pill above."));return}const i={overview:()=>this.overview_make(s),build:()=>this.build_make(s),cluster:()=>this.cluster_make(s),chris:()=>this.chris_make(s),teardown:()=>this.teardown_make(s)};e.append(...i[this.view]());const n=e.querySelector(".tdc-steplog");n!==null&&(n.scrollTop=n.scrollHeight)}empty_make(e,s){const i=V("section","tdc-empty");return i.append(V("span","tdc-section-title",e),V("p","tdc-prose",s)),i}section_make(e,s="",i){const n=V("section",`tdc-section ${s}`.trim());n.setAttribute("aria-label",e);const r=V("div","tdc-section-head");return r.append(V("span","tdc-section-title",e)),i!==void 0&&r.append(V("span","tdc-section-aside",i)),n.append(r),n}pairs_make(e,s=""){const i=V("div",`tdc-pairs ${s}`.trim());for(const[n,r]of e)i.append(V("span","tdc-pair-label",n),V("span","tdc-pair-value",r));return i}linePill_make(e,s,i="plain",n){const r=V("button",`tdc-pill tdc-pill-${i}`,n===void 0?e:`${e} · REFUSED`);return r.type="button",r.title=n===void 0?`sends: ${s}`:`refused: ${n}`,r.disabled=n!==void 0||this.busy!==null,r.addEventListener("click",()=>{this.hooks.voice.pill(e),this.line_send(s)}),r}spec_make(e,s=!1){if(e==null)return[V("p","tdc-prose",s?"No spec here: ADOPT reads the spec its stack says.":"No spec kept: a domain read from a checkout says its spec in its own files (cat spec.yaml).")];const i=n=>`${n.count} × ${n.vcpu} vCPU · ${n.ramGib} GiB · ${n.bootGib} GiB ${n.bootTier.toUpperCase()}`;return[this.pairs_make([["FAMILY",e.family],["CONTROL PLANE",i(e.controlPlane)],["WORKERS",e.workers.count===0?"0 · COMPACT, PLANE SCHEDULABLE":i(e.workers)]])]}chrisSpec_make(e){return e==null?V("p","tdc-prose","—"):this.pairs_make([["DATA",`${e.chris.dataGib} GiB · GROWS, NEVER SHRINKS`],["DATABASE · QUEUE",`${e.chris.databaseGib} GiB · ${e.chris.queueGib} GiB · FIXED`]])}classNote_make(e){const s=V("div",`tdc-note tdc-note-${e.origin??"built"}`),i=$v(e);return s.append(V("span","tdc-note-title",i)),e.origin==="adopted"?(s.append(V("span","tdc-prose","Built by harbor-oci. Its installer ids and its Terraform state are kept by stratus; it is planned against, never built on.")),s.append(V("span","tdc-prose tdc-quiet",`build refused: ${e.refused?.build??"adopted"}`))):e.origin==="found"&&e.condition==="GONE"?(s.append(V("span","tdc-prose",`Torn down, or never built: nothing of it lives, and its stack holds nothing. What is left carries its tag: ${this.leftovers_words(e)}. REMOVE WHAT IS LEFT takes those away, after the name typed back; no adoption first.`)),s.append(this.linePill_make("REMOVE WHAT IS LEFT",ps.teardown(e.name),"destroy",e.refused?.teardown))):e.origin==="found"?(s.append(V("span","tdc-prose","Found in the tenancy by its tag. What is shown is what the cloud says of it: its address and spec from its stack, its condition from what lives in its compartment. ADOPT keeps it here, which is what PLAN, VERIFY, BUILD and TEAR DOWN wait on; its kubeconfig and CUBE token are then copied by hand.")),s.append(this.linePill_make("ADOPT",ps.adopt(e.name)))):e.origin==="checkout"?s.append(V("span","tdc-prose","Read from a harbor-oci checkout. Adopting it keeps it here: domain adopt <name> --from <checkout>.")):e.gone!==null&&e.gone!==void 0?s.append(V("span","tdc-prose",`Torn down ${e.gone.slice(0,16).replace("T"," ")}. Its spec and its record are kept.`)):s.append(V("span","tdc-prose",e.protected!==!1?"Built by this daemon, and protected: teardown is refused until the lock is lifted, as a line of its own.":"Built by this daemon. The lock is off: teardown may run, and still asks for the name typed back.")),s}overview_make(e){const s=this.section_make("SPEC · THE CLUSTER","tdc-col-spec");s.append(this.classNote_make(e),...this.spec_make(e.spec,e.origin==="found"),V("span","tdc-section-title tdc-gap","SPEC · CHRIS ON IT"),this.chrisSpec_make(e.spec));const i=this.section_make(e.origin==="found"?"STEPS · AS FAR AS THE CLOUD ATTESTS THEM":"STEPS · THE MACHINE, THEN CHRIS","tdc-col-steps","PRESS A STEP · BUILD OPENS ON IT"),n=V("div","tdc-step-grid");for(const l of _f(e)){const c=V("button",`tdc-step tdc-step-${l.tone}${l.billFrom?" tdc-step-billfrom":""}`);c.type="button",c.setAttribute("aria-label",`${l.name}, ${l.word}`),c.title=l.note,c.append(V("span","tdc-step-n",l.n),V("span","tdc-step-name",l.name),V("span","tdc-step-note",l.note),V("span","tdc-step-word",l.word)),c.addEventListener("click",()=>{this.hooks.voice.pill(l.name),this.view_show("build")}),n.append(c)}i.append(n,V("div","tdc-billing-line",`BILLING STARTS AT ${(e.billingStep??"infra-apply").toUpperCase()} · EVERY STEP AFTER IT RUNS ON PAID MACHINES`));const r=V("div","tdc-commands");r.append(V("span","tdc-commands-label","TRUSTED DOMAIN"),this.linePill_make("PLAN",ps.plan(e.name),"plain",e.refused?.plan),this.linePill_make("VERIFY",ps.verify(e.name),"plain",e.refused?.verify),this.linePill_make("SPEND",ps.spend(e.name)),V("span","tdc-flex"),this.linePill_make("BUILD",ps.build(e.name),"bill",e.refused?.build)),i.append(r);const o=this.section_make("THE CLUSTER AT A GLANCE","tdc-col-glance"),a=e.verify===null||e.verify===void 0?this.verifyUnkept_render(e):`${ox(e.verify.checks)} · ${(e.verify.at??"").slice(0,16).replace("T"," ")}`;return o.append(this.pairs_make([["ADDRESS",e.cluster??"?"],["VERIFY",a],["RUNNING",e.running===null||e.running===void 0?"nothing":e.running.step??"between steps"]])),o.append(V("span","tdc-section-title tdc-gap","IN ITS COMPARTMENT")),o.append(this.resources_make(e)),o.append(V("p","tdc-prose tdc-quiet","Nodes per zone and projects come with the cluster in the tree (cluster/).")),[s,i,o]}verifyUnkept_render(e){const s=e.steps.find(i=>i.name==="verify");return s!==void 0&&s.state!=="not done"?`${(s.evidence??s.state).toUpperCase()} · CHECKS NOT KEPT`:"NOT RUN"}resources_make(e){if(e.resources===null)return V("p","tdc-prose tdc-quiet","not counted");const s=Object.entries(e.resources).filter(([,i])=>i>0).map(([i,n])=>[i.toUpperCase(),String(n)]);return s.length===0?V("p","tdc-prose","nothing live"):this.pairs_make(s,"tdc-pairs-narrow")}strip_make(e){const s=this.section_make("STEPS","tdc-col-strip");for(const i of _f(e)){i.billFrom&&s.append(V("div","tdc-billing-from","BILLING FROM HERE"));const n=V("div",`tdc-strip-step tdc-step-${i.tone}`);n.setAttribute("aria-label",`${i.name}, ${i.word}`),n.title=i.note,n.append(V("span","tdc-strip-name",i.name),V("span","tdc-strip-word",i.word)),s.append(n)}return s}build_make(e){const s=V("div","tdc-col-middle"),i=e.running;if(i!=null){const c=this.section_make(`RUNNING · ${(i.step??"between steps").toUpperCase()}`,"tdc-running",`/proc/steps/${i.job}`);c.append(this.pairs_make([["SINCE",i.since===null?"?":`${i.since.slice(11,16)} · ${Uv(Date.now()-Date.parse(i.since))}`],["THE TASK","goes on with every surface closed, and after a daemon restart"]]));const h=V("div","tdc-commands"),d=this.busy!==null&&this.busy.startsWith(`domain build ${e.name}`),u=V("button","tdc-pill tdc-pill-destroy","KILL");u.type="button",u.title=`stops following, then sends: ${ps.kill(i.job)}`,u.addEventListener("click",()=>{this.hooks.voice.pill("KILL"),this.kill_send(i.job)});const p=d?V("button","tdc-pill tdc-pill-quiet","STOP FOLLOWING"):this.linePill_make("FOLLOW",ps.follow(e.name),"quiet");d&&(p.type="button",p.title="Ctrl-C: stops following; the build goes on",p.addEventListener("click",()=>{this.hooks.voice.pill("STOP FOLLOWING"),this.hooks.stop()})),h.append(u,V("span","tdc-commands-label","ASKS THE STEP TO STOP · NEVER FORCES"),V("span","tdc-flex"),p),c.append(h),s.append(c)}const n=this.section_make("THE PLAN","tdc-plan",e.plan?.at?`MADE ${e.plan.at.slice(0,16).replace("T"," ")}`:void 0);if(e.plan===null||e.plan===void 0)n.append(V("p","tdc-prose",e.origin==="adopted"?"No plan kept here. PLAN, under the tasks tier, plans against the adopted state; an apply is refused.":"No plan yet. BUILD makes it at infra-plan, and nothing it makes bills."));else{const c=V("div","tdc-plan-counts"),h=(p,f,_,g)=>{const m=V("div",`tdc-plan-count tdc-plan-${_}`);return m.append(V("span","tdc-plan-count-label",p),V("span","tdc-plan-count-value",String(f))),g!==void 0&&m.append(V("span","tdc-plan-count-note",g)),m};c.append(h("TO CREATE",e.plan.create,"create"),h("TO CHANGE",e.plan.change+e.plan.replace+e.plan.drift,"change",e.plan.drift>0?`${e.plan.drift} ORACLE-TAGS DRIFT · ${e.plan.change+e.plan.replace} REAL`:void 0),h("TO DESTROY",e.plan.destroy,"destroy"));const d=V("div","tdc-plan-rows"),u={create:"+",change:"~",drift:"~",replace:"±",destroy:"−"};for(const p of e.plan.groups.slice(0,14))d.append(V("span",`tdc-plan-mark tdc-plan-${p.action}`,u[p.action]??"?"),V("span","tdc-plan-kind",`${p.kind}${p.action==="drift"?" · tag drift":p.action==="replace"?" · replaced":""}`),V("span","tdc-plan-n",String(p.count)),V("span","tdc-plan-names",p.names.slice(0,4).join(" · ")+(p.names.length>4?` … ${p.names.length-4} more`:"")));n.append(c,d)}const r=V("div","tdc-commands");r.append(this.linePill_make("PLAN",ps.plan(e.name),"plain",e.refused?.plan),V("span","tdc-flex"),this.linePill_make("BUILD · THROUGH RUN",ps.build(e.name),"bill",e.refused?.build)),n.append(r),s.append(n);const o=this.section_make("THE STEP'S LOG","tdc-col-steplog",this.stepLogLine??(i?`/proc/steps/${i.job}/log`:void 0)),a=V("div","tdc-steplog"),l=this.stepLog.slice(-60);l.length===0&&a.append(V("span","tdc-quiet",i?`following shows it here (FOLLOW, or: cat /proc/steps/${i.job}/log)`:"nothing run from here yet"));for(const c of l)a.append(V("span","tdc-steplog-line",c));return o.append(a),[this.strip_make(e),s,o]}cluster_make(e){const s=this.section_make("VERIFY · TEN CHECKS","tdc-col-wide",e.verify?.at?`LAST RUN ${e.verify.at.slice(0,16).replace("T"," ")}`:"NOT RUN HERE");if(e.verify===null||e.verify===void 0)s.append(V("p","tdc-prose",`${this.verifyUnkept_render(e)}. VERIFY runs the checks through the cluster's kubeconfig, which stays on the host, and keeps them.`));else{const o=V("div","tdc-checks");for(const a of e.verify.checks){const l=a.ok===!0?"pass":a.ok===!1?"fail":"skip";o.append(V("span",`tdc-check-mark tdc-check-${l}`,a.ok===!0?"✓":a.ok===!1?"✗":"–"),V("span","tdc-check-name",a.name),V("span","tdc-check-detail",a.detail),V("span",`tdc-check-how${a.how==="writes"?" tdc-bill":""}`,a.how.toUpperCase()))}s.append(o)}const i=V("div","tdc-note tdc-note-bill");i.append(V("span","tdc-note-title","ONE CHECK WRITES"),V("span","tdc-prose","The block-volume probe makes a claim and a pod, writes, reads back and removes both: it runs only under the tasks tier; without it verify says so and runs the other nine."));const n=V("div","tdc-commands");n.append(this.linePill_make("VERIFY",ps.verify(e.name),"plain",e.refused?.verify)),s.append(i,n);const r=this.section_make("IN ITS COMPARTMENT","tdc-col-side");return r.append(this.resources_make(e),V("span","tdc-section-title tdc-gap","ACCESS"),this.pairs_make([["KUBECONFIG","ON THE HOST · NEVER SHOWN HERE"],["KUBEADMIN","ON THE HOST · NEVER SHOWN HERE"]]),V("p","tdc-prose tdc-quiet","Nodes per zone and the cluster's projects come with the cluster in the tree (cluster/).")),[s,r]}chris_make(e){const s=this.section_make("STORAGE · THE SPEC'S CHRIS HALF","tdc-col-spec");s.append(this.chrisSpec_make(e.spec),V("p","tdc-prose tdc-bill","DATA grows with a new spec and a plan; it never shrinks. DATABASE and QUEUE are fixed from the first deploy."));const i=this.section_make("THE APPLICATION'S STEPS","tdc-col-steps"),n=_f(e).filter(c=>SH.includes(c.name));for(const c of n){const h=V("div",`tdc-chris-step tdc-step-${c.tone}`),d=V("div","tdc-chris-step-head");d.append(V("span","tdc-chris-step-name",c.name.toUpperCase()),V("span","tdc-chris-step-word",c.word)),h.append(d,V("span","tdc-prose",c.note===""?"—":c.note)),i.append(h)}const r=V("div","tdc-commands"),o=V("button","tdc-pill tdc-pill-plain","SMOKE AGAIN · LATER");o.type="button",o.disabled=!0,o.title="the build runs the smoke journey once, as its last step; running it again is a line of its own, not written yet",r.append(o),i.append(r);const a=this.section_make("THE CUBE","tdc-col-glance"),l=V("button","tdc-pill tdc-pill-plain","ATTACH · LATER");return l.type="button",l.disabled=!0,l.title="domain attach starts the domain session; it comes after the ChRIS steps",a.append(this.pairs_make([["SIGN-IN","THE TRUSTED DOMAIN'S OWN"],["CUBE",e.steps.some(c=>c.name==="chris-deploy"&&c.state==="done")?`cube.apps.${e.cluster??""}`:"NOT DEPLOYED"]]),V("p","tdc-prose","ATTACH starts the domain session: a second daemon on the ChRIS backend, signed in through the domain's own sign-in. This session never holds the CUBE token; that one never holds a cloud key."),l),[s,i,a]}leftovers_words(e){const s=Object.entries(e.resources??{}).filter(([,n])=>n>0).map(([n,r])=>`${r} ${n}`),i=[];return e.compartment!==null&&e.compartment!==void 0&&i.push(`its compartment${s.length>0?` (holding ${s.join(", ")})`:" (empty)"}`),i.push("its stack, when one stands"),i.join(" and ")}teardown_make(e){const s=e.origin==="found"&&e.condition==="GONE",i=this.section_make(s?"WHAT IS LEFT · AND GOES":"WHAT GOES · IN THIS ORDER","tdc-col-wide","ONLY WHAT THIS TRUSTED DOMAIN MADE"),n=s?[["the stack itself","emptied by an earlier teardown; it carried the tag, so the domain was found again"],["its compartment and the image bucket","when stratus made them (domains/<name>); another's keeps itself and loses the tag"]]:[["the stack's resources","a destroy job on the domain's Resource Manager stack"],["the DNS records","api, api-int and *.apps in the zone"],["the image and its link","the discovery ISO and its pre-authenticated request"],["the cluster's volumes","the block volumes the CSI driver made for its claims, found through the cluster, and any left in the compartment with the attribution tag"],["the installer's records","the cluster and the infra-env at Red Hat"],["the stack itself","it carried the tag; left, the domain would be found again"],["its compartment and the image bucket","when stratus made them (domains/<name>); another's keeps itself and loses the tag"]],r=V("div","tdc-teardown-rows");for(const[d,u]of n)r.append(V("span","tdc-destroy-mark","−"),V("span","tdc-teardown-what",d),V("span","tdc-teardown-how",u));i.append(r,V("p","tdc-prose tdc-quiet","Nothing else is touched: the zone, the tag namespace and what other Trusted Domains made stay. The engine counts the stack and the volumes when the line runs, and asks for the name typed back."));const o=this.section_make("THE GUARD","tdc-col-side"),a=e.refused?.teardown,l=a!==void 0&&a.startsWith("protected");if(a!==void 0&&!l){const d=V("div","tdc-note tdc-note-refused");return d.append(V("span","tdc-note-title","REFUSED BY NAME"),V("span","tdc-mono",`domain teardown: ${e.name}: Operation not permitted: ${a}`)),o.append(d),[i,o]}if(s){const d=V("div","tdc-note tdc-note-found");d.append(V("span","tdc-note-title","NOTHING TO PROTECT"),V("span","tdc-prose",`Nothing of ${e.name} lives and its stack holds nothing, so there is no lock. The engine still asks for the name typed back.`));const u=V("div","tdc-commands");return u.append(V("span","tdc-flex"),this.linePill_make("REMOVE WHAT IS LEFT",ps.teardown(e.name),"destroy")),d.append(u),o.append(d),[i,o]}const c=V("div",`tdc-note ${e.protected!==!1?"tdc-note-locked":"tdc-note-refused"}`);c.append(V("span","tdc-note-title",e.protected!==!1?"PROTECTED":"UNLOCKED"),V("span","tdc-prose",e.protected!==!1?"A domain is born protected. Lifting the lock is a line of its own, so no single slip or replayed line removes a tenant.":"The lock is off. TEAR DOWN sends the line; the engine lists what goes and asks for the name typed back."));const h=V("div","tdc-commands");return e.protected!==!1?h.append(this.linePill_make("LIFT THE LOCK",ps.protect(e.name,!1),"quiet")):h.append(this.linePill_make("LOCK AGAIN",ps.protect(e.name,!0),"quiet"),V("span","tdc-flex"),this.linePill_make("TEAR DOWN",ps.teardown(e.name),"destroy",e.refused?.teardown)),c.append(h),o.append(c),[i,o]}async size_need(e){if(this.sizeAsked&&e===void 0)return;this.sizeAsked=!0;const s=await this.hooks.size_read(e);if(s===null)return;this.size=s,(this.zone===null||!(s.dnsZones??[this.zone]).includes(this.zone))&&(this.zone=s.baseDomain);const i=this.levers;this.levers=i===null?Mf(s.start):{...i,family:s.family},this.draw()}zones_make(e){const s=V("div","tdc-families tdc-zones");s.append(V("span","tdc-pair-label","ZONE"));const i=e.dnsZones??(e.baseDomain===null?[]:[e.baseDomain]);i.length===0&&s.append(V("span","tdc-quiet","THE TENANCY HOLDS NO DNS ZONE"));for(const n of i){const r=V("button",`tdc-family${n===this.zone?" tdc-family-on":""}`,n);r.type="button",r.addEventListener("click",()=>{this.hooks.voice.pill("ZONE"),this.zone=n,this.draw()}),s.append(r)}return s}size_make(e){const s=e!==null;s&&e?.spec!==null&&e?.spec!==void 0&&(this.levers===null||this.current!==gi)&&(this.levers=Mf(e.spec));const i=this.section_make(s?`THE SPEC OF ${e?.name.toUpperCase()}`:"A NEW TRUSTED DOMAIN","tdc-col-levers");if(this.size===null||this.levers===null)return i.append(V("p","tdc-prose tdc-quiet","reading what a domain is sized against: domain size")),[i];const n=this.levers,r=this.size;if(s)i.append(V("p","tdc-prose tdc-quiet","A domain's spec is written once, by domain new. These are its sizes, against the region now; + NEW sizes another."));else{const f=V("div","tdc-name-row"),_=V("label","tdc-pair-label","NAME"),g=V("input","tdc-name-input");g.id="tdc-new-name",_.setAttribute("for",g.id),g.value=this.newName,g.placeholder="a DNS label, as quay",g.spellcheck=!1,g.addEventListener("input",()=>{this.newName=g.value.trim(),this.sized_redraw()}),f.append(_,g),i.append(f)}const o=V("div","tdc-families");o.append(V("span","tdc-pair-label","FAMILY"));const a=[...new Set([n.family,"E5","E4","E6","A1"].filter(f=>r.families.includes(f)))];for(const f of a){const _=V("button",`tdc-family${f===n.family?" tdc-family-on":""}`,f);_.type="button",_.disabled=s,_.addEventListener("click",()=>{this.hooks.voice.pill(f),this.levers!==null&&(this.levers.family=f),this.size_need(f)}),o.append(_)}i.append(o),s||i.append(this.zones_make(r));const l=(f,_,g,m,v,y,b,w)=>{const z=V("div","tdc-slider"),x=V("label","tdc-slider-label",_),M=V("input","tdc-slider-input");M.type="range",M.id=`tdc-${f}`,x.setAttribute("for",M.id),M.min=String(g),M.max=String(m),M.step=String(v),M.value=String(y()),M.disabled=s||g===m;const S=V("span","tdc-slider-value",String(y()));M.addEventListener("input",()=>{b(Number(M.value)),S.textContent=M.value,this.sized_redraw()});const T=V("div","tdc-slider-track"),A=V("div","tdc-slider-ends");return A.append(V("span","",String(g)),V("span","tdc-slider-note",w??""),V("span","",String(m))),T.append(M,A),z.append(x,T,S),z},c=r.cores===null?64:Math.min(r.cores.max*r.vcpuPerCore,128),h=r.memoryGib===null?512:Math.min(r.memoryGib.max,1024),d=(f,_)=>{const g=V("div","tdc-lever-group");return g.append(V("span","tdc-section-title",f),..._),g};i.append(d("CONTROL PLANE",[l("pc","NODES",3,3,1,()=>n.controlPlane.count,()=>{},"ONE PER ZONE · FIXED"),l("pv","vCPU EACH",4,c,2,()=>n.controlPlane.vcpu,f=>{n.controlPlane.vcpu=f}),l("pr","GiB EACH",16,h,4,()=>n.controlPlane.ramGib,f=>{n.controlPlane.ramGib=f})]),d("WORKERS",[l("wc","NODES",0,12,1,()=>n.workers.count,f=>{n.workers.count=f},"0 · COMPACT"),l("wv","vCPU EACH",4,c,2,()=>n.workers.vcpu,f=>{n.workers.vcpu=f}),l("wr","GiB EACH",16,h,8,()=>n.workers.ramGib,f=>{n.workers.ramGib=f})]),d("CHRIS",[l("cd","DATA GiB",20,2e3,10,()=>n.chris.dataGib,f=>{n.chris.dataGib=f},"GROWS LATER · NEVER SHRINKS"),l("cb","DATABASE GiB",5,200,5,()=>n.chris.databaseGib,f=>{n.chris.databaseGib=f},"FIXED AFTER THE FIRST DEPLOY")]));const u=this.section_make(`FIT · ${n.family} PER ZONE, AS SIZED`,"tdc-col-fit",`FROM ${r.region} · READ ONCE`),p=this.section_make("COST · PER HOUR, FROM THE PRICE LIST","tdc-col-cost");return this.fit_fill(u),this.cost_fill(p,!s),[i,u,p]}sized_redraw(){const e=this.parts.body.querySelector(".tdc-col-fit"),s=this.parts.body.querySelector(".tdc-col-cost");e!==null&&this.fit_fill(e),s!==null&&this.cost_fill(s,this.current===gi),this.header_draw()}fit_fill(e){if(e.querySelectorAll(".tdc-zone").forEach(s=>s.remove()),!(this.size===null||this.levers===null))for(const s of Vv(this.size,this.levers,this.newName||this.current||"new")){const i=V("div",`tdc-zone${s.fits===!1?" tdc-zone-bad":s.tightest?" tdc-zone-tight":""}`),n=V("div","tdc-zone-head");n.append(V("span","tdc-zone-name",Hv(s.zone)),V("span","tdc-zone-verdict",s.fits===null?"NOT SAID":s.fits?s.tightest?"FITS · TIGHTEST":"FITS":"DOES NOT FIT"));const r=(o,a,l)=>{const c=V("div","tdc-zone-bar"),h=V("div","tdc-zone-track"),d=V("div","tdc-zone-take");return d.style.width=a===null||a<=0?"0%":`${Math.min(100,o/a*100)}%`,h.append(d),c.append(V("span","tdc-zone-unit",l),h,V("span","tdc-zone-text",`${o} OF ${a??"?"}`)),c};i.append(n,r(s.coresNeeded,s.coresFree,"CORES"),r(s.memoryNeeded,s.memoryFree,"GiB"),V("span","tdc-zone-nodes",s.nodes.join(" · ")||"nothing placed")),e.append(i)}}cost_fill(e,s){if(e.querySelectorAll(".tdc-cost-rows, .tdc-commit").forEach(r=>r.remove()),this.size===null||this.levers===null)return;const i=qv(this.size,this.levers),n=V("div","tdc-cost-rows");for(const r of i.rows)n.append(V("span","tdc-pair-label",r.what),V("span","tdc-cost-rate",r.hourly===null?"NOT PRICED":Rn(r.hourly,i.currency,3)));if(n.append(V("span","tdc-pair-label tdc-bill","TOTAL · EST"),V("span","tdc-cost-rate tdc-bill",i.hourly===null?"—":`${Rn(i.hourly,i.currency)} · ${Rn(i.hourly*Dh,i.currency,0)} A MONTH`)),e.append(n),s){const r=V("div","tdc-commit");e.append(r),this.commit_fill(r)}}commit_fill(e){if(this.size===null||this.levers===null)return;e.replaceChildren();const s=CH(this.newName,this.names_get())??(this.zone===null?"NO ZONE":null),i=DH(this.newName||"<name>",this.levers,this.size.start,this.zone!==this.size.baseDomain?this.zone:null),n=ps.tenant(this.newName||"<name>");e.append(V("span","tdc-section-title","THE LINES COMMIT SENDS"),V("div","tdc-mono tdc-commit-line",i),V("div","tdc-mono tdc-commit-line",n),V("p","tdc-prose tdc-quiet","The first writes the spec. The second plays the tenant: the build through the install, which asks before billing, then verify. A NO leaves the spec written and nothing made."));const r=V("div","tdc-commands"),o=V("button","tdc-pill tdc-pill-plain",s===null?"COMMIT":`COMMIT · ${s}`);o.type="button",o.disabled=s!==null||this.busy!==null,o.addEventListener("click",()=>{this.hooks.voice.pill("COMMIT");const l=this.newName;this.line_send(i).then(async()=>{this.domains.has(l)&&(this.current=l,this.newName="",this.view="build",this.draw(),await this.line_send(ps.tenant(l)))})});const a=V("button","tdc-pill tdc-pill-quiet","RESET");a.type="button",a.addEventListener("click",()=>{this.hooks.voice.pill("RESET"),this.size!==null&&(this.levers=Mf(this.size.start)),this.draw()}),r.append(o,V("span","tdc-flex"),a),e.append(r)}strip_draw(){const e=this.parts.strip;if(e.replaceChildren(),e.hidden=this.ask===null,this.ask===null)return;const s=this.ask,i=/destroy/i.test(s.message),n=/billing starts/i.test(s.message);e.dataset.tone=i?"destroy":n?"bill":"plain";const r=V("div","tdc-strip-words");if(r.append(V("span","tdc-strip-title","THE ENGINE ASKS"),V("span","tdc-strip-text",s.message)),e.append(r),RH(s.message)==="yes-no"){const u=V("button",`tdc-pill ${n?"tdc-pill-bill":"tdc-pill-plain"}`,n?"YES · BILL":"YES");u.type="button",u.addEventListener("click",()=>{this.hooks.voice.pill("YES"),this.log_add("y","answer"),s.answer("y")});const p=V("button","tdc-pill tdc-pill-quiet","NO");p.type="button",p.addEventListener("click",()=>{this.hooks.voice.pill("NO"),this.log_add("n","answer"),s.answer("n")}),e.append(u,p);return}const o=V("input","tdc-strip-input");o.id="tdc-strip-input",o.type=s.kind==="secret"?"password":"text",o.autocomplete="off",o.spellcheck=!1;const a=V("label","tdc-pair-label",i?"NAME":"ANSWER");a.setAttribute("for",o.id);const l=V("button",`tdc-pill ${i?"tdc-pill-destroy":"tdc-pill-plain"}`,i?"DESTROY":"SEND");l.type="button";const c=this.current;i&&(l.disabled=!0,o.addEventListener("input",()=>{l.disabled=o.value.trim()!==c}));const h=()=>{l.disabled||(this.hooks.voice.pill(l.textContent??""),this.log_add(s.kind==="secret"?"(hidden)":o.value,"answer"),s.answer(o.value))};l.addEventListener("click",h),o.addEventListener("keydown",u=>{u.key==="Enter"&&h()});const d=V("button","tdc-pill tdc-pill-quiet","NO");d.type="button",d.addEventListener("click",()=>{this.hooks.voice.pill("NO"),this.log_add("(declined)","answer"),s.answer("")}),e.append(a,o,l,d),queueMicrotask(()=>o.focus())}log_add(e,s){const i=V("span",`tdc-log-line tdc-log-${s}`,e);for(this.parts.log.append(i);this.parts.log.childElementCount>kH;)this.parts.log.firstElementChild?.remove();if(this.parts.log.scrollTop=this.parts.log.scrollHeight,s==="out"&&this.stepLogLine!==null&&this.busy===this.stepLogLine&&(this.stepLog.push(e),this.view==="build")){const n=this.parts.body.querySelector(".tdc-steplog");if(n!==null){for(n.querySelector(".tdc-quiet")?.remove(),n.append(V("span","tdc-steplog-line",e));n.childElementCount>60;)n.firstElementChild?.remove();n.scrollTop=n.scrollHeight}}}async kill_send(e){if(this.busy!==null){this.hooks.stop();for(let s=0;s<50&&this.busy!==null;s++)await new Promise(i=>{setTimeout(i,100)})}await this.line_send(ps.kill(e))}cues_play(e,s){if(e===null||s===null||e.name!==s.name)return;if(e.condition!=="FAILED"&&s.condition==="FAILED"){this.hooks.voice.cue("redalert");return}const i=bf(e).done;bf(s).done>i&&this.hooks.voice.cue("ack")}}const Kv=1250;function Yv(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 GH(t,e){let s=null,i=!1,n=[],r=document.title;const o={events:0,reads:0,lastError:null};window.__argusController={view:()=>s?.view_get()??null,domain:()=>s?.domain_get()??null,asking:()=>s?.asking_is()??!1,heard:()=>({...o})};const a=async()=>{try{const d=await t.client.line_execute("domain status",{silent:!0,observe:!1}),u=Yv(d,zz,p=>Oz.safeParse(p));if(o.reads++,u===null)return;n=u.domains.map(p=>p.name),e(n),s?.domains_take(u.domains),s?.since_refresh()}catch(d){o.lastError=d instanceof Error?d.message:String(d)}},l=async d=>{try{const u=await t.client.line_execute(d===void 0?"domain size":`domain size --family ${d}`,{silent:!0,observe:!1});return Yv(u,s2,p=>i2.safeParse(p))}catch{return null}},c=()=>{s!==null&&(s.dispose(),s.root.remove(),s=null,delete document.body.dataset.takeover,document.title=r,Ni.cue_play("close"))};return window.addEventListener("keydown",d=>{s===null||d.key!=="Escape"||(d.stopImmediatePropagation(),d.preventDefault(),c())},!0),{open:async d=>{if(window.innerWidth<Kv){const p=`domain: the TD controller needs a screen at least ${Kv} px wide; this one is ${window.innerWidth}, so the line runs as text`;try{const f=await t.client.line_execute(d===""?"domain status":`domain ${d}`,{silent:!0,observe:!1});return[p,...f.envelopes.map(_=>`${_.rendered??""}${_.renderedErr??""}`.trimEnd())].join(`
|
|
4360
|
+
${c.stack??""}`:String(c),console.error("trek bridge: could not draw the state",c)}}}}const gf=["overview","size","build","cluster","chris","teardown"],SH=["chris-deploy","chris-seed","smoke"],Dh=730,xH={balanced:10,higher:20,ultra:30},Fv=3,OH=10;function EH(t,e){return t===void 0?e:{...t,...e,resources:e.resources??t.resources,cost:e.cost!==void 0?e.cost:t.cost}}function Rn(t,e,s=2){return`${e==="USD"?"$":`${e} `}${t.toFixed(s)}`}function Uv(t){const e=Math.max(0,Math.round(t/1e3));if(e<60)return`${e}s`;const s=Math.floor(e/60);if(s<60)return`${s}m`;const i=Math.floor(s/60);return i<48?`${i}h ${s%60}m`:`${Math.floor(i/24)}d ${i%24}h`}function $v(t){return t.origin==="found"?t.condition==="GONE"?"FOUND · NOTHING LEFT":"FOUND · NOT ADOPTED":t.origin==="adopted"?"ADOPTED · PLANS ONLY":t.origin==="checkout"?"CHECKOUT · READ ONLY":t.gone!==null&&t.gone!==void 0?"TORN DOWN":"BUILT HERE"}function AH(t){const e=t.billing===!0,s=t.origin==="adopted"?"ADOPTED":t.origin==="checkout"?"READ FROM A CHECKOUT":t.condition==="GONE"?"TORN DOWN":t.condition==="SIZING"?"NOTHING BUILT":t.condition==="STOPPED"?!e&&t.next===t.billingStep?"PLANNED":"NOT FINISHED":t.condition??"";return e?{text:`BILLING · ${s}`,billing:e}:{text:`${s} · NOTHING BILLED`,billing:e}}function _f(t){return t.steps.map((e,s)=>{const i=e.name??e.folder.replace(/^\d+-/,""),n=String(s+1).padStart(2,"0"),r=TH(e.evidence??""),o=i===t.billingStep,a=(l,c)=>({n,name:i,word:l,tone:c,note:r,billFrom:o});return e.state==="done"?a("DONE","done"):e.state==="running"?a("RUNNING","running"):e.state==="failed"?a("FAILED","failed"):e.state==="expired"?a("EXPIRED","expired"):e.state==="unknown"?a("UNKNOWN","unknown"):i===t.next?t.asking!==null&&t.asking!==void 0?a("ASKING","asking"):a("NEXT","next"):a("NOT DONE","later")})}function TH(t){const s=t.match(/^done before adoption \(harbor-oci: [a-z ]+, (.*)\)$/)?.[1]??t;return s.length>60?`${s.slice(0,59)}…`:s}function bf(t){return{done:t.steps.filter(e=>e.state==="done").length,total:t.steps.length}}function jv(t,e){if(t===null)return[{label:"",text:"FIRST READ"}];const s=[];t.condition!==e.condition&&s.push({label:"CONDITION",text:`${t.condition??"?"} → ${e.condition??"?"}`});const i=new Map(t.steps.map(l=>[l.name??l.folder,l.state])),n=e.steps.filter(l=>i.get(l.name??l.folder)!==l.state);for(const l of n.slice(-2))s.push({label:(l.name??l.folder).toUpperCase(),text:`${(i.get(l.name??l.folder)??"NONE").toUpperCase()} → ${l.state.toUpperCase()}`});const r=l=>l.verify===null||l.verify===void 0?null:ox(l.verify.checks);r(t)!==r(e)&&s.push({label:"VERIFY",text:r(e)??"NOT RUN"});const o=l=>l.plan===null||l.plan===void 0?null:ax(l.plan);o(t)!==o(e)&&s.push({label:"PLAN",text:o(e)??"NONE"});const a=l=>l.cost===null||l.cost===void 0?null:Rn(l.cost.hourly,l.cost.currency);return a(t)!==a(e)&&a(t)!==null&&a(e)!==null&&s.push({label:"PER HOUR",text:`${a(t)} → ${a(e)}`}),t.protected!==e.protected&&s.push({label:"LOCK",text:e.protected===!1?"OFF":"ON"}),s.length===0?[{label:"",text:"NO CHANGE"}]:s.slice(0,3)}function ox(t){const e=t.filter(n=>n.ok===!0).length,s=t.filter(n=>n.ok===!1).length,i=t.length-e-s;return`${e} OF ${t.length} PASS${s>0?` · ${s} FAIL`:""}${i>0?` · ${i} NOT RUN`:""}`}function ax(t){const e=t.change+t.replace,s=e>0||t.drift===0?`${e} ~`:"",i=t.drift>0?`${t.drift} ~ TAG DRIFT`:"";return[`${t.create} +`,s,i,`${t.destroy} −`].filter(n=>n!=="").join(" · ")}function Hv(t){const e=t.includes(":")?t.slice(t.indexOf(":")+1):t,s=e.match(/AD-\d+$/i);return s!==null?s[0].toUpperCase():e}function Vv(t,e,s){const i=Math.max(t.zones.length,1),n=[];for(let l=0;l<e.controlPlane.count;l++)n.push({name:`${s}-cp-${l}`,vcpu:e.controlPlane.vcpu,ramGib:e.controlPlane.ramGib,zone:l%i});for(let l=0;l<e.workers.count;l++)n.push({name:`${s}-w-${l}`,vcpu:e.workers.vcpu,ramGib:e.workers.ramGib,zone:l%i});const r=t.zones.map((l,c)=>{const h=n.filter(f=>f.zone===c),d=h.reduce((f,_)=>f+_.vcpu/t.vcpuPerCore,0),u=h.reduce((f,_)=>f+_.ramGib,0),p=l.coresFree!==null&&l.memoryFree!==null;return{zone:l.zone,nodes:h.map(f=>f.name),coresNeeded:d,coresFree:l.coresFree,memoryNeeded:u,memoryFree:l.memoryFree,fits:p?d<=l.coresFree&&u<=l.memoryFree:null,tightest:!1}}),o=l=>l.coresFree===null?1/0:(l.coresFree-l.coresNeeded)/Math.max(l.coresFree,1),a=[...r].filter(l=>l.coresFree!==null).sort((l,c)=>o(l)-o(c))[0];return a!==void 0&&r.length>1&&(a.tightest=!0),r}function qv(t,e){const s=e.controlPlane.count*e.controlPlane.vcpu+e.workers.count*e.workers.vcpu,i=e.controlPlane.count*e.controlPlane.ramGib+e.workers.count*e.workers.ramGib,n=(h,d)=>t.services===null?null:h*(t.services.volumeGibMonth+(xH[d]??10)*t.services.vpuGibMonth)/Dh,r=e.controlPlane.count*e.controlPlane.bootGib+e.workers.count*e.workers.bootGib,o=t.services===null?null:n(e.controlPlane.count*e.controlPlane.bootGib,e.controlPlane.bootTier)+n(e.workers.count*e.workers.bootGib,e.workers.bootTier),a=e.chris.dataGib+e.chris.databaseGib+e.chris.queueGib,l=[{what:`COMPUTE · ${s} vCPU`,hourly:t.price===null?null:s*t.price.vcpuHour},{what:`MEMORY · ${i} GiB`,hourly:t.price===null?null:i*t.price.gibHour},{what:`BOOT VOLUMES · ${r} GiB`,hourly:o},{what:`CHRIS VOLUMES · ${a} GiB`,hourly:n(a,"balanced")},{what:`LOAD BALANCERS · ${Fv}`,hourly:t.services===null?null:Fv*(t.services.balancerHour+OH*t.services.balancerMbpsHour)}],c=l.filter(h=>h.hourly!==null);return{rows:l,hourly:c.length===0?null:c.reduce((h,d)=>h+d.hourly,0),currency:t.price?.currency??"USD"}}function DH(t,e,s,i=null){const n=["cluster","new",t];i!==null&&n.push("--base-domain",i);const r=o=>`${o.count}x${o.vcpu}/${o.ramGib}`;return e.family!==s.family&&n.push("--family",e.family),r(e.controlPlane)!==r(s.controlPlane)&&n.push("--plane",r(e.controlPlane)),r(e.workers)!==r(s.workers)&&n.push("--workers",r(e.workers)),e.chris.dataGib!==s.chris.dataGib&&n.push("--data",String(e.chris.dataGib)),e.chris.databaseGib!==s.chris.databaseGib&&n.push("--database",String(e.chris.databaseGib)),e.chris.queueGib!==s.chris.queueGib&&n.push("--queue",String(e.chris.queueGib)),n.join(" ")}function Mf(t){return{family:t.family,controlPlane:{...t.controlPlane},workers:{...t.workers},chris:{...t.chris}}}const IH=/^[a-z]([a-z0-9-]{0,52}[a-z0-9])?$/;function CH(t,e){return t===""?"NAME IT FIRST":IH.test(t)?e.includes(t)?`${t.toUpperCase()} IS TAKEN`:null:"A DNS LABEL: a-z, 0-9 AND -, A LETTER FIRST"}const ps={status:t=>`cluster ${t}`,adopt:t=>`cluster adopt ${t}`,plan:t=>`cluster plan ${t}`,verify:t=>`cluster verify ${t}`,spend:t=>`spend ${t}`,build:t=>`cluster build ${t}`,kill:t=>`kill ${t}`,follow:t=>`cluster build ${t}`,protect:(t,e)=>`cluster protect ${t} ${e?"on":"off"}`,teardown:t=>`cluster teardown ${t}`,size:t=>t===void 0?"cluster size":`cluster size --family ${t}`,tenant:t=>`play ~/tenant.mise --param NAME=${t}`};function RH(t){return/\[y\/N\]\s*$/i.test(t.trim())?"yes-no":"typed"}const kH=400,gi="",nh={overview:"OVERVIEW",size:"SIZE",build:"BUILD",cluster:"CLUSTER",chris:"CHRIS",teardown:"TEARDOWN"};function V(t,e,s){const i=document.createElement(t);return i.className=e,s!==void 0&&(i.textContent=s),i}function NH(t){return t.replace(/\x1b\[[0-9;?]*[A-Za-z]/g,"").replace(/\r/g,"")}class BH{constructor(e){this.hooks=e,this.frame=Y1({id:"td-controller",className:"td-controller",brand:{name:"STRATUS",sub:"TD CONTROLLER · OCI",mark:!0},banner:"STRATUS • TD CONTROLLER",views:gf.map(p=>({key:p,label:nh[p],destroy:p==="teardown"})),leave:{label:"LEAVE"},stage:{title:"NEW TRUSTED DOMAIN",note:nh.size},log:{title:"TRUSTED DOMAIN LOG",note:"THE SESSION'S LINES · TYPE BELOW"},labels:{views:"Views",log:"Cluster log"}},p=>{const f=gf.find(_=>_===p);f!==void 0&&(this.hooks.voice.pill(nh[f]),this.view_show(f))},()=>{this.hooks.voice.pill("LEAVE"),this.hooks.leave()}),this.frame.leave.classList.add("tdc-leave"),this.root=this.frame.root,this.root.setAttribute("role","application"),this.root.setAttribute("aria-label","TD controller");const s=this.frame.seat;s.setAttribute("aria-label","Clusters");const i=V("header","tdc-header");this.frame.face.append(i);const n=new Map;for(const p of gf){const f=this.frame.views.get(p);f!==void 0&&(f.classList.add("tdc-view",`tdc-view-${p}`),n.set(p,f))}const r=V("div","tdc-body");this.frame.body.append(r);const o=V("section","tdc-strip");o.setAttribute("aria-label","The engine asks"),o.hidden=!0,this.frame.aside.append(o);const a=V("section","tdc-foot"),l=V("div","tdc-log");l.setAttribute("aria-live","polite");const c=V("div","tdc-prompt"),h=V("label","tdc-prompt-label","stratus ›"),d=V("input","tdc-prompt-input");d.id="tdc-prompt-input",h.setAttribute("for",d.id),d.placeholder="any session line · cluster plan · ls clusters/ · spend",d.spellcheck=!1,d.autocomplete="off",d.addEventListener("keydown",p=>{if(p.key!=="Enter")return;const f=d.value.trim();f!==""&&(d.value="",this.line_send(f))}),c.append(h,d);const u=V("div","tdc-log-column");u.append(l,c),a.append(u),this.frame.log.append(a),this.parts={pills:s,header:i,views:n,body:r,strip:o,log:l,input:d,promptLabel:h},this.ticker=setInterval(()=>{this.cluster_get()?.running&&this.header_draw()},15e3),this.draw()}hooks;root;frame;clusters=new Map;current=gi;view="overview";before=null;since=[{label:"",text:"FIRST READ"}];size=null;sizeAsked=!1;levers=null;newName="";zone=null;busy=null;ask=null;partial="";stepLog=[];stepLogLine=null;parts;ticker=null;dispose(){this.ticker!==null&&clearInterval(this.ticker),this.ticker=null,this.ask?.answer(null),this.ask=null}clusters_take(e){const s=this.cluster_get();this.clusters.clear();for(const i of e)this.clusters.set(i.name,i);this.current!==gi&&!this.clusters.has(this.current)&&(this.current=e[0]?.name??gi),this.cues_play(s,this.cluster_get()),this.draw()}cluster_take(e){const s=this.clusters.get(e.name);this.clusters.set(e.name,EH(s,e)),e.name===this.current&&this.cues_play(s??null,this.cluster_get()),this.draw()}cluster_choose(e){this.current=e!==""&&this.clusters.has(e)?e:this.clusters.keys().next().value??gi,this.current===gi&&(this.view="size",this.size_need()),this.draw()}cluster_get(){return this.clusters.get(this.current)??null}view_get(){return this.view}names_get(){return[...this.clusters.keys()]}output_take(e){const i=(this.partial+NH(e)).split(`
|
|
4361
|
+
`);this.partial=i.pop()??"";for(const n of i)this.log_add(n,"out")}ask_take(e,s){return this.ask?.answer(null),this.hooks.voice.cue("hail"),new Promise(i=>{this.ask={message:e,kind:s,answer:n=>{this.ask=null,this.strip_draw(),i(n)}},this.log_add(e,"ask"),this.strip_draw()})}asking_is(){return this.ask!==null}async line_send(e){if(this.busy!==null){this.log_add(`the lane is held by: ${this.busy} (STOP FOLLOWING frees it; the build goes on)`,"note");return}this.before=this.cluster_get(),this.busy=e,this.log_add(`stratus> ${e}`,"sent"),/^(cluster (build|plan)|play) /.test(e)&&(this.stepLog=[],this.stepLogLine=e),this.draw();try{await this.hooks.run(e)}finally{this.partial!==""&&(this.log_add(this.partial,"out"),this.partial=""),this.busy=null;const s=this.cluster_get();s!==null&&(this.since=jv(this.before,s)),this.draw()}}since_refresh(){const e=this.cluster_get();e!==null&&(this.since=jv(this.before?.name===e.name?this.before:null,e)),this.header_draw()}title_get(){const e=this.cluster_get();return e===null?"SIZING · NEW TRUSTED DOMAIN":`${e.condition??"READING"} · ${e.name}`}view_show(e){this.view=e,e==="size"&&this.size_need(),this.draw()}draw(){this.pills_draw(),this.header_draw(),this.frame.view_mark(this.view);for(const[e,s]of this.parts.views)s.classList.toggle("tdc-view-on",e===this.view);this.frame.stageTitle.textContent=this.current===gi?"NEW TRUSTED DOMAIN":this.current.toUpperCase(),this.frame.stageNote.textContent=nh[this.view],this.body_draw(),this.strip_draw(),this.parts.promptLabel.textContent=this.current===gi?"stratus ›":`stratus ~/${this.current} ›`,this.parts.input.disabled=this.busy!==null,this.root.dataset.busy=this.busy===null?"no":"yes",document.title=this.title_get()}pills_draw(){const e=this.parts.pills;e.replaceChildren();for(const s of[...this.clusters.keys(),gi]){const i=this.clusters.get(s),n=V("button","tdc-cluster takeover-seat-pill",s===gi?"+ NEW":s.toUpperCase());n.type="button",n.dataset.condition=i?.condition??"SIZING",i?.billing===!0&&n.classList.add("tdc-billing"),n.setAttribute("aria-current",s===this.current?"true":"false"),n.addEventListener("click",()=>{if(this.hooks.voice.pill(n.textContent??""),s===gi){this.current=gi,this.view_show("size");return}this.current=s,this.view==="size"&&this.levers!==null&&(this.levers=null),this.line_send(ps.status(s))}),e.append(n)}}header_draw(){const e=this.parts.header;e.replaceChildren();const s=this.cluster_get();if(e.append(this.condition_make(s)),s===null){e.append(this.headSection_make("TRUSTED DOMAIN",[["NAME",this.newName===""?"[NAME IT ON SIZE]":this.newName],["REGION",this.size?.region??"…"],["ADDRESS",this.size===null?"…":this.zone===null?"NO ZONE · CHOOSE ONE ON SIZE":`${this.newName||"<name>"}.${this.zone}`]]),this.headSection_make("COST · AS SIZED",this.sizedCost_rows()),this.headSection_make("FIT",this.fit_rows()),this.headSection_make("SINCE LAST CHANGE",[["","NOTHING WRITTEN YET"]]));return}const i=s.path.match(/^\/net\/[^/]+\/([^/]+)\//)?.[1]??"?";e.append(this.headSection_make("TRUSTED DOMAIN",[["TENANCY",i],["REGION",s.region??"?"],["ADDRESS",s.cluster??(s.origin==="found"?"NO ZONE KNOWN":"?")]]),this.headSection_make("COST",this.cost_rows(s),s.billing===!0?0:-1),this.headSection_make("BUILD",this.build_rows(s)),this.since_make())}condition_make(e){const s=V("section","tdc-head-condition");s.setAttribute("aria-label","Condition");const i=V("div","tdc-condition"),n=e?.condition??"SIZING";i.dataset.condition=n,i.append(V("span","tdc-condition-label","CONDITION"),V("span","tdc-condition-name",n));const r=e===null?{text:"NOTHING BUILT · NOTHING BILLED",billing:!1}:AH(e),o=V("div",`tdc-condition-why${r.billing?" tdc-bill":""}`,r.text),a=V("div","tdc-chips");if(e!==null){const l=bf(e);a.append(V("span","tdc-chip",`${l.done} OF ${l.total} DONE${e.origin==="found"?" · FROM THE CLOUD":""}`),V("span","tdc-chip tdc-chip-class",$v(e))),e.origin==="found"&&e.condition==="GONE"||a.append(this.lock_make(e))}else a.append(V("span","tdc-chip","NO SPEC YET"));return s.append(i,o,a),s}lock_make(e){const s=e.protected!==!1,i=V("span",`tdc-chip tdc-lock${s?" tdc-lock-on":" tdc-lock-off"}`);return i.append(this.lockIcon_make(s),document.createTextNode(s?"PROTECTED":"UNLOCKED")),i.title=s?`teardown refused until: cluster protect ${e.name} off`:"teardown may run; it still asks for the name typed back",i}lockIcon_make(e){const s="http://www.w3.org/2000/svg",i=document.createElementNS(s,"svg");i.setAttribute("viewBox","0 0 16 16"),i.setAttribute("width","12"),i.setAttribute("height","12"),i.setAttribute("aria-hidden","true");const n=document.createElementNS(s,"path");n.setAttribute("d",e?"M4.5 7V5a3.5 3.5 0 0 1 7 0v2":"M4.5 7V5a3.5 3.5 0 0 1 6.8-1.2"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.8");const r=document.createElementNS(s,"rect");for(const[o,a]of[["x","3"],["y","7"],["width","10"],["height","7"],["rx","1.5"],["fill","currentColor"]])r.setAttribute(o,a);return i.append(n,r),i}headSection_make(e,s,i=-1){const n=V("section","tdc-head-section");n.setAttribute("aria-label",e),n.append(V("span","tdc-head-title",e));const r=V("div","tdc-head-grid");return s.forEach(([o,a],l)=>{r.append(V("span",`tdc-head-label${l===i?" tdc-head-label-bill":""}`,o),V("span","tdc-head-value",a))}),n.append(r),n}since_make(){const e=V("section","tdc-head-section");e.setAttribute("aria-label","Since the last command"),e.append(V("span","tdc-head-title","SINCE LAST COMMAND"));const s=V("div","tdc-since");for(const i of this.since)s.append(V("span","tdc-since-label",i.label),V("span","tdc-since-value",i.text));return e.append(s),e}cost_rows(e){if(e.cost===null||e.cost===void 0)return[["PER HOUR",e.billing===!0?"NOT PRICED":"0"],["SO FAR","—"],["A MONTH","—"]];const{hourly:s,soFar:i,currency:n}=e.cost;return[["PER HOUR",`${Rn(s,n)} · EST`],["SO FAR",Rn(i,n)],["A MONTH",`${Rn(s*Dh,n,0)} · AT THIS RATE`]]}build_rows(e){const s=e.lastDone===null?"nothing":e.lastDone.replace(/^\d+-/,""),i=e.running===null||e.running===void 0?"nothing":`${e.running.step??"between steps"}${e.running.since!==null?` · ${Uv(Date.now()-Date.parse(e.running.since))}`:""}`,n=e.plan===null||e.plan===void 0?"none kept":ax(e.plan);return[["LAST DONE",s],["RUNNING",i],["LAST PLAN",n]]}sizedCost_rows(){if(this.size===null||this.levers===null)return[["PER HOUR","…"],["A MONTH","…"],["SO FAR","0"]];const e=qv(this.size,this.levers);return[["PER HOUR",e.hourly===null?"NOT PRICED":`${Rn(e.hourly,e.currency)} · EST`],["A MONTH",e.hourly===null?"—":`${Rn(e.hourly*Dh,e.currency,0)} · EST`],["SO FAR","0"]]}fit_rows(){if(this.size===null||this.levers===null)return[["ZONES","…"]];const e=Vv(this.size,this.levers,this.newName||"new"),s=e.filter(n=>n.fits===!0).length,i=e.find(n=>n.tightest);return[["ZONES",`${s} OF ${e.length} FIT`],["TIGHTEST",i===void 0?"—":Hv(i.zone)],["FAMILY",this.levers.family]]}body_draw(){const e=this.parts.body;e.replaceChildren(),e.dataset.view=this.view;const s=this.cluster_get();if(this.view==="size"){e.append(...this.size_make(s));return}if(s===null){e.append(this.empty_make("NO CLUSTER CHOSEN","Press + NEW and size one on SIZE, or a cluster's pill above."));return}const i={overview:()=>this.overview_make(s),build:()=>this.build_make(s),cluster:()=>this.cluster_make(s),chris:()=>this.chris_make(s),teardown:()=>this.teardown_make(s)};e.append(...i[this.view]());const n=e.querySelector(".tdc-steplog");n!==null&&(n.scrollTop=n.scrollHeight)}empty_make(e,s){const i=V("section","tdc-empty");return i.append(V("span","tdc-section-title",e),V("p","tdc-prose",s)),i}section_make(e,s="",i){const n=V("section",`tdc-section ${s}`.trim());n.setAttribute("aria-label",e);const r=V("div","tdc-section-head");return r.append(V("span","tdc-section-title",e)),i!==void 0&&r.append(V("span","tdc-section-aside",i)),n.append(r),n}pairs_make(e,s=""){const i=V("div",`tdc-pairs ${s}`.trim());for(const[n,r]of e)i.append(V("span","tdc-pair-label",n),V("span","tdc-pair-value",r));return i}linePill_make(e,s,i="plain",n){const r=V("button",`tdc-pill tdc-pill-${i}`,n===void 0?e:`${e} · REFUSED`);return r.type="button",r.title=n===void 0?`sends: ${s}`:`refused: ${n}`,r.disabled=n!==void 0||this.busy!==null,r.addEventListener("click",()=>{this.hooks.voice.pill(e),this.line_send(s)}),r}spec_make(e,s=!1){if(e==null)return[V("p","tdc-prose",s?"No spec here: ADOPT reads the spec its stack says.":"No spec kept: a cluster read from a checkout says its spec in its own files (cat spec.yaml).")];const i=n=>`${n.count} × ${n.vcpu} vCPU · ${n.ramGib} GiB · ${n.bootGib} GiB ${n.bootTier.toUpperCase()}`;return[this.pairs_make([["FAMILY",e.family],["CONTROL PLANE",i(e.controlPlane)],["WORKERS",e.workers.count===0?"0 · COMPACT, PLANE SCHEDULABLE":i(e.workers)]])]}chrisSpec_make(e){return e==null?V("p","tdc-prose","—"):this.pairs_make([["DATA",`${e.chris.dataGib} GiB · GROWS, NEVER SHRINKS`],["DATABASE · QUEUE",`${e.chris.databaseGib} GiB · ${e.chris.queueGib} GiB · FIXED`]])}classNote_make(e){const s=V("div",`tdc-note tdc-note-${e.origin??"built"}`),i=$v(e);return s.append(V("span","tdc-note-title",i)),e.origin==="adopted"?(s.append(V("span","tdc-prose","Built by harbor-oci. Its installer ids and its Terraform state are kept by stratus; it is planned against, never built on.")),s.append(V("span","tdc-prose tdc-quiet",`build refused: ${e.refused?.build??"adopted"}`))):e.origin==="found"&&e.condition==="GONE"?(s.append(V("span","tdc-prose",`Torn down, or never built: nothing of it lives, and its stack holds nothing. What is left carries its tag: ${this.leftovers_words(e)}. REMOVE WHAT IS LEFT takes those away, after the name typed back; no adoption first.`)),s.append(this.linePill_make("REMOVE WHAT IS LEFT",ps.teardown(e.name),"destroy",e.refused?.teardown))):e.origin==="found"?(s.append(V("span","tdc-prose","Found in the tenancy by its tag. What is shown is what the cloud says of it: its address and spec from its stack, its condition from what lives in its compartment. ADOPT keeps it here, which is what PLAN, VERIFY, BUILD and TEAR DOWN wait on; its kubeconfig and CUBE token are then copied by hand.")),s.append(this.linePill_make("ADOPT",ps.adopt(e.name)))):e.origin==="checkout"?s.append(V("span","tdc-prose","Read from a harbor-oci checkout. Adopting it keeps it here: cluster adopt <name> --from <checkout>.")):e.gone!==null&&e.gone!==void 0?s.append(V("span","tdc-prose",`Torn down ${e.gone.slice(0,16).replace("T"," ")}. Its spec and its record are kept.`)):s.append(V("span","tdc-prose",e.protected!==!1?"Built by this daemon, and protected: teardown is refused until the lock is lifted, as a line of its own.":"Built by this daemon. The lock is off: teardown may run, and still asks for the name typed back.")),s}overview_make(e){const s=this.section_make("SPEC · THE CLUSTER","tdc-col-spec");s.append(this.classNote_make(e),...this.spec_make(e.spec,e.origin==="found"),V("span","tdc-section-title tdc-gap","SPEC · CHRIS ON IT"),this.chrisSpec_make(e.spec));const i=this.section_make(e.origin==="found"?"STEPS · AS FAR AS THE CLOUD ATTESTS THEM":"STEPS · THE MACHINE, THEN CHRIS","tdc-col-steps","PRESS A STEP · BUILD OPENS ON IT"),n=V("div","tdc-step-grid");for(const l of _f(e)){const c=V("button",`tdc-step tdc-step-${l.tone}${l.billFrom?" tdc-step-billfrom":""}`);c.type="button",c.setAttribute("aria-label",`${l.name}, ${l.word}`),c.title=l.note,c.append(V("span","tdc-step-n",l.n),V("span","tdc-step-name",l.name),V("span","tdc-step-note",l.note),V("span","tdc-step-word",l.word)),c.addEventListener("click",()=>{this.hooks.voice.pill(l.name),this.view_show("build")}),n.append(c)}i.append(n,V("div","tdc-billing-line",`BILLING STARTS AT ${(e.billingStep??"infra-apply").toUpperCase()} · EVERY STEP AFTER IT RUNS ON PAID MACHINES`));const r=V("div","tdc-commands");r.append(V("span","tdc-commands-label","CLUSTER"),this.linePill_make("PLAN",ps.plan(e.name),"plain",e.refused?.plan),this.linePill_make("VERIFY",ps.verify(e.name),"plain",e.refused?.verify),this.linePill_make("SPEND",ps.spend(e.name)),V("span","tdc-flex"),this.linePill_make("BUILD",ps.build(e.name),"bill",e.refused?.build)),i.append(r);const o=this.section_make("THE CLUSTER AT A GLANCE","tdc-col-glance"),a=e.verify===null||e.verify===void 0?this.verifyUnkept_render(e):`${ox(e.verify.checks)} · ${(e.verify.at??"").slice(0,16).replace("T"," ")}`;return o.append(this.pairs_make([["ADDRESS",e.cluster??"?"],["VERIFY",a],["RUNNING",e.running===null||e.running===void 0?"nothing":e.running.step??"between steps"]])),o.append(V("span","tdc-section-title tdc-gap","IN ITS COMPARTMENT")),o.append(this.resources_make(e)),o.append(V("p","tdc-prose tdc-quiet","Nodes per zone and projects come with the cluster in the tree (cluster/).")),[s,i,o]}verifyUnkept_render(e){const s=e.steps.find(i=>i.name==="verify");return s!==void 0&&s.state!=="not done"?`${(s.evidence??s.state).toUpperCase()} · CHECKS NOT KEPT`:"NOT RUN"}resources_make(e){if(e.resources===null)return V("p","tdc-prose tdc-quiet","not counted");const s=Object.entries(e.resources).filter(([,i])=>i>0).map(([i,n])=>[i.toUpperCase(),String(n)]);return s.length===0?V("p","tdc-prose","nothing live"):this.pairs_make(s,"tdc-pairs-narrow")}strip_make(e){const s=this.section_make("STEPS","tdc-col-strip");for(const i of _f(e)){i.billFrom&&s.append(V("div","tdc-billing-from","BILLING FROM HERE"));const n=V("div",`tdc-strip-step tdc-step-${i.tone}`);n.setAttribute("aria-label",`${i.name}, ${i.word}`),n.title=i.note,n.append(V("span","tdc-strip-name",i.name),V("span","tdc-strip-word",i.word)),s.append(n)}return s}build_make(e){const s=V("div","tdc-col-middle"),i=e.running;if(i!=null){const c=this.section_make(`RUNNING · ${(i.step??"between steps").toUpperCase()}`,"tdc-running",`/proc/steps/${i.job}`);c.append(this.pairs_make([["SINCE",i.since===null?"?":`${i.since.slice(11,16)} · ${Uv(Date.now()-Date.parse(i.since))}`],["THE TASK","goes on with every surface closed, and after a daemon restart"]]));const h=V("div","tdc-commands"),d=this.busy!==null&&this.busy.startsWith(`cluster build ${e.name}`),u=V("button","tdc-pill tdc-pill-destroy","KILL");u.type="button",u.title=`stops following, then sends: ${ps.kill(i.job)}`,u.addEventListener("click",()=>{this.hooks.voice.pill("KILL"),this.kill_send(i.job)});const p=d?V("button","tdc-pill tdc-pill-quiet","STOP FOLLOWING"):this.linePill_make("FOLLOW",ps.follow(e.name),"quiet");d&&(p.type="button",p.title="Ctrl-C: stops following; the build goes on",p.addEventListener("click",()=>{this.hooks.voice.pill("STOP FOLLOWING"),this.hooks.stop()})),h.append(u,V("span","tdc-commands-label","ASKS THE STEP TO STOP · NEVER FORCES"),V("span","tdc-flex"),p),c.append(h),s.append(c)}const n=this.section_make("THE PLAN","tdc-plan",e.plan?.at?`MADE ${e.plan.at.slice(0,16).replace("T"," ")}`:void 0);if(e.plan===null||e.plan===void 0)n.append(V("p","tdc-prose",e.origin==="adopted"?"No plan kept here. PLAN, under the tasks tier, plans against the adopted state; an apply is refused.":"No plan yet. BUILD makes it at infra-plan, and nothing it makes bills."));else{const c=V("div","tdc-plan-counts"),h=(p,f,_,g)=>{const m=V("div",`tdc-plan-count tdc-plan-${_}`);return m.append(V("span","tdc-plan-count-label",p),V("span","tdc-plan-count-value",String(f))),g!==void 0&&m.append(V("span","tdc-plan-count-note",g)),m};c.append(h("TO CREATE",e.plan.create,"create"),h("TO CHANGE",e.plan.change+e.plan.replace+e.plan.drift,"change",e.plan.drift>0?`${e.plan.drift} ORACLE-TAGS DRIFT · ${e.plan.change+e.plan.replace} REAL`:void 0),h("TO DESTROY",e.plan.destroy,"destroy"));const d=V("div","tdc-plan-rows"),u={create:"+",change:"~",drift:"~",replace:"±",destroy:"−"};for(const p of e.plan.groups.slice(0,14))d.append(V("span",`tdc-plan-mark tdc-plan-${p.action}`,u[p.action]??"?"),V("span","tdc-plan-kind",`${p.kind}${p.action==="drift"?" · tag drift":p.action==="replace"?" · replaced":""}`),V("span","tdc-plan-n",String(p.count)),V("span","tdc-plan-names",p.names.slice(0,4).join(" · ")+(p.names.length>4?` … ${p.names.length-4} more`:"")));n.append(c,d)}const r=V("div","tdc-commands");r.append(this.linePill_make("PLAN",ps.plan(e.name),"plain",e.refused?.plan),V("span","tdc-flex"),this.linePill_make("BUILD · THROUGH RUN",ps.build(e.name),"bill",e.refused?.build)),n.append(r),s.append(n);const o=this.section_make("THE STEP'S LOG","tdc-col-steplog",this.stepLogLine??(i?`/proc/steps/${i.job}/log`:void 0)),a=V("div","tdc-steplog"),l=this.stepLog.slice(-60);l.length===0&&a.append(V("span","tdc-quiet",i?`following shows it here (FOLLOW, or: cat /proc/steps/${i.job}/log)`:"nothing run from here yet"));for(const c of l)a.append(V("span","tdc-steplog-line",c));return o.append(a),[this.strip_make(e),s,o]}cluster_make(e){const s=this.section_make("VERIFY · TEN CHECKS","tdc-col-wide",e.verify?.at?`LAST RUN ${e.verify.at.slice(0,16).replace("T"," ")}`:"NOT RUN HERE");if(e.verify===null||e.verify===void 0)s.append(V("p","tdc-prose",`${this.verifyUnkept_render(e)}. VERIFY runs the checks through the cluster's kubeconfig, which stays on the host, and keeps them.`));else{const o=V("div","tdc-checks");for(const a of e.verify.checks){const l=a.ok===!0?"pass":a.ok===!1?"fail":"skip";o.append(V("span",`tdc-check-mark tdc-check-${l}`,a.ok===!0?"✓":a.ok===!1?"✗":"–"),V("span","tdc-check-name",a.name),V("span","tdc-check-detail",a.detail),V("span",`tdc-check-how${a.how==="writes"?" tdc-bill":""}`,a.how.toUpperCase()))}s.append(o)}const i=V("div","tdc-note tdc-note-bill");i.append(V("span","tdc-note-title","ONE CHECK WRITES"),V("span","tdc-prose","The block-volume probe makes a claim and a pod, writes, reads back and removes both: it runs only under the tasks tier; without it verify says so and runs the other nine."));const n=V("div","tdc-commands");n.append(this.linePill_make("VERIFY",ps.verify(e.name),"plain",e.refused?.verify)),s.append(i,n);const r=this.section_make("IN ITS COMPARTMENT","tdc-col-side");return r.append(this.resources_make(e),V("span","tdc-section-title tdc-gap","ACCESS"),this.pairs_make([["KUBECONFIG","ON THE HOST · NEVER SHOWN HERE"],["KUBEADMIN","ON THE HOST · NEVER SHOWN HERE"]]),V("p","tdc-prose tdc-quiet","Nodes per zone and the cluster's projects come with the cluster in the tree (cluster/).")),[s,r]}chris_make(e){const s=this.section_make("STORAGE · THE SPEC'S CHRIS HALF","tdc-col-spec");s.append(this.chrisSpec_make(e.spec),V("p","tdc-prose tdc-bill","DATA grows with a new spec and a plan; it never shrinks. DATABASE and QUEUE are fixed from the first deploy."));const i=this.section_make("THE APPLICATION'S STEPS","tdc-col-steps"),n=_f(e).filter(c=>SH.includes(c.name));for(const c of n){const h=V("div",`tdc-chris-step tdc-step-${c.tone}`),d=V("div","tdc-chris-step-head");d.append(V("span","tdc-chris-step-name",c.name.toUpperCase()),V("span","tdc-chris-step-word",c.word)),h.append(d,V("span","tdc-prose",c.note===""?"—":c.note)),i.append(h)}const r=V("div","tdc-commands"),o=V("button","tdc-pill tdc-pill-plain","SMOKE AGAIN · LATER");o.type="button",o.disabled=!0,o.title="the build runs the smoke journey once, as its last step; running it again is a line of its own, not written yet",r.append(o),i.append(r);const a=this.section_make("THE CUBE","tdc-col-glance"),l=V("button","tdc-pill tdc-pill-plain","ATTACH · LATER");return l.type="button",l.disabled=!0,l.title="cluster attach starts the cluster session; it comes after the ChRIS steps",a.append(this.pairs_make([["SIGN-IN","THE TRUSTED DOMAIN'S OWN"],["CUBE",e.steps.some(c=>c.name==="chris-deploy"&&c.state==="done")?`cube.apps.${e.cluster??""}`:"NOT DEPLOYED"]]),V("p","tdc-prose","ATTACH starts the cluster session: a second daemon on the ChRIS backend, signed in through the cluster's own sign-in. This session never holds the CUBE token; that one never holds a cloud key."),l),[s,i,a]}leftovers_words(e){const s=Object.entries(e.resources??{}).filter(([,n])=>n>0).map(([n,r])=>`${r} ${n}`),i=[];return e.compartment!==null&&e.compartment!==void 0&&i.push(`its compartment${s.length>0?` (holding ${s.join(", ")})`:" (empty)"}`),i.push("its stack, when one stands"),i.join(" and ")}teardown_make(e){const s=e.origin==="found"&&e.condition==="GONE",i=this.section_make(s?"WHAT IS LEFT · AND GOES":"WHAT GOES · IN THIS ORDER","tdc-col-wide","ONLY WHAT THIS TRUSTED DOMAIN MADE"),n=s?[["the stack itself","emptied by an earlier teardown; it carried the tag, so the cluster was found again"],["its compartment and the image bucket","when stratus made them (clusters/<name>); another's keeps itself and loses the tag"]]:[["the stack's resources","a destroy job on the cluster's Resource Manager stack"],["the DNS records","api, api-int and *.apps in the zone"],["the image and its link","the discovery ISO and its pre-authenticated request"],["the cluster's volumes","the block volumes the CSI driver made for its claims, found through the cluster, and any left in the compartment with the attribution tag"],["the installer's records","the cluster and the infra-env at Red Hat"],["the stack itself","it carried the tag; left, the cluster would be found again"],["its compartment and the image bucket","when stratus made them (clusters/<name>); another's keeps itself and loses the tag"]],r=V("div","tdc-teardown-rows");for(const[d,u]of n)r.append(V("span","tdc-destroy-mark","−"),V("span","tdc-teardown-what",d),V("span","tdc-teardown-how",u));i.append(r,V("p","tdc-prose tdc-quiet","Nothing else is touched: the zone, the tag namespace and what other clusters made stay. The engine counts the stack and the volumes when the line runs, and asks for the name typed back."));const o=this.section_make("THE GUARD","tdc-col-side"),a=e.refused?.teardown,l=a!==void 0&&a.startsWith("protected");if(a!==void 0&&!l){const d=V("div","tdc-note tdc-note-refused");return d.append(V("span","tdc-note-title","REFUSED BY NAME"),V("span","tdc-mono",`cluster teardown: ${e.name}: Operation not permitted: ${a}`)),o.append(d),[i,o]}if(s){const d=V("div","tdc-note tdc-note-found");d.append(V("span","tdc-note-title","NOTHING TO PROTECT"),V("span","tdc-prose",`Nothing of ${e.name} lives and its stack holds nothing, so there is no lock. The engine still asks for the name typed back.`));const u=V("div","tdc-commands");return u.append(V("span","tdc-flex"),this.linePill_make("REMOVE WHAT IS LEFT",ps.teardown(e.name),"destroy")),d.append(u),o.append(d),[i,o]}const c=V("div",`tdc-note ${e.protected!==!1?"tdc-note-locked":"tdc-note-refused"}`);c.append(V("span","tdc-note-title",e.protected!==!1?"PROTECTED":"UNLOCKED"),V("span","tdc-prose",e.protected!==!1?"A cluster is born protected. Lifting the lock is a line of its own, so no single slip or replayed line removes a tenant.":"The lock is off. TEAR DOWN sends the line; the engine lists what goes and asks for the name typed back."));const h=V("div","tdc-commands");return e.protected!==!1?h.append(this.linePill_make("LIFT THE LOCK",ps.protect(e.name,!1),"quiet")):h.append(this.linePill_make("LOCK AGAIN",ps.protect(e.name,!0),"quiet"),V("span","tdc-flex"),this.linePill_make("TEAR DOWN",ps.teardown(e.name),"destroy",e.refused?.teardown)),c.append(h),o.append(c),[i,o]}async size_need(e){if(this.sizeAsked&&e===void 0)return;this.sizeAsked=!0;const s=await this.hooks.size_read(e);if(s===null)return;this.size=s,(this.zone===null||!(s.dnsZones??[this.zone]).includes(this.zone))&&(this.zone=s.baseDomain);const i=this.levers;this.levers=i===null?Mf(s.start):{...i,family:s.family},this.draw()}zones_make(e){const s=V("div","tdc-families tdc-zones");s.append(V("span","tdc-pair-label","ZONE"));const i=e.dnsZones??(e.baseDomain===null?[]:[e.baseDomain]);i.length===0&&s.append(V("span","tdc-quiet","THE TENANCY HOLDS NO DNS ZONE"));for(const n of i){const r=V("button",`tdc-family${n===this.zone?" tdc-family-on":""}`,n);r.type="button",r.addEventListener("click",()=>{this.hooks.voice.pill("ZONE"),this.zone=n,this.draw()}),s.append(r)}return s}size_make(e){const s=e!==null;s&&e?.spec!==null&&e?.spec!==void 0&&(this.levers===null||this.current!==gi)&&(this.levers=Mf(e.spec));const i=this.section_make(s?`THE SPEC OF ${e?.name.toUpperCase()}`:"A NEW TRUSTED DOMAIN","tdc-col-levers");if(this.size===null||this.levers===null)return i.append(V("p","tdc-prose tdc-quiet","reading what a cluster is sized against: cluster size")),[i];const n=this.levers,r=this.size;if(s)i.append(V("p","tdc-prose tdc-quiet","A cluster's spec is written once, by cluster new. These are its sizes, against the region now; + NEW sizes another."));else{const f=V("div","tdc-name-row"),_=V("label","tdc-pair-label","NAME"),g=V("input","tdc-name-input");g.id="tdc-new-name",_.setAttribute("for",g.id),g.value=this.newName,g.placeholder="a DNS label, as quay",g.spellcheck=!1,g.addEventListener("input",()=>{this.newName=g.value.trim(),this.sized_redraw()}),f.append(_,g),i.append(f)}const o=V("div","tdc-families");o.append(V("span","tdc-pair-label","FAMILY"));const a=[...new Set([n.family,"E5","E4","E6","A1"].filter(f=>r.families.includes(f)))];for(const f of a){const _=V("button",`tdc-family${f===n.family?" tdc-family-on":""}`,f);_.type="button",_.disabled=s,_.addEventListener("click",()=>{this.hooks.voice.pill(f),this.levers!==null&&(this.levers.family=f),this.size_need(f)}),o.append(_)}i.append(o),s||i.append(this.zones_make(r));const l=(f,_,g,m,v,y,b,w)=>{const z=V("div","tdc-slider"),x=V("label","tdc-slider-label",_),M=V("input","tdc-slider-input");M.type="range",M.id=`tdc-${f}`,x.setAttribute("for",M.id),M.min=String(g),M.max=String(m),M.step=String(v),M.value=String(y()),M.disabled=s||g===m;const S=V("span","tdc-slider-value",String(y()));M.addEventListener("input",()=>{b(Number(M.value)),S.textContent=M.value,this.sized_redraw()});const T=V("div","tdc-slider-track"),A=V("div","tdc-slider-ends");return A.append(V("span","",String(g)),V("span","tdc-slider-note",w??""),V("span","",String(m))),T.append(M,A),z.append(x,T,S),z},c=r.cores===null?64:Math.min(r.cores.max*r.vcpuPerCore,128),h=r.memoryGib===null?512:Math.min(r.memoryGib.max,1024),d=(f,_)=>{const g=V("div","tdc-lever-group");return g.append(V("span","tdc-section-title",f),..._),g};i.append(d("CONTROL PLANE",[l("pc","NODES",3,3,1,()=>n.controlPlane.count,()=>{},"ONE PER ZONE · FIXED"),l("pv","vCPU EACH",4,c,2,()=>n.controlPlane.vcpu,f=>{n.controlPlane.vcpu=f}),l("pr","GiB EACH",16,h,4,()=>n.controlPlane.ramGib,f=>{n.controlPlane.ramGib=f})]),d("WORKERS",[l("wc","NODES",0,12,1,()=>n.workers.count,f=>{n.workers.count=f},"0 · COMPACT"),l("wv","vCPU EACH",4,c,2,()=>n.workers.vcpu,f=>{n.workers.vcpu=f}),l("wr","GiB EACH",16,h,8,()=>n.workers.ramGib,f=>{n.workers.ramGib=f})]),d("CHRIS",[l("cd","DATA GiB",20,2e3,10,()=>n.chris.dataGib,f=>{n.chris.dataGib=f},"GROWS LATER · NEVER SHRINKS"),l("cb","DATABASE GiB",5,200,5,()=>n.chris.databaseGib,f=>{n.chris.databaseGib=f},"FIXED AFTER THE FIRST DEPLOY")]));const u=this.section_make(`FIT · ${n.family} PER ZONE, AS SIZED`,"tdc-col-fit",`FROM ${r.region} · READ ONCE`),p=this.section_make("COST · PER HOUR, FROM THE PRICE LIST","tdc-col-cost");return this.fit_fill(u),this.cost_fill(p,!s),[i,u,p]}sized_redraw(){const e=this.parts.body.querySelector(".tdc-col-fit"),s=this.parts.body.querySelector(".tdc-col-cost");e!==null&&this.fit_fill(e),s!==null&&this.cost_fill(s,this.current===gi),this.header_draw()}fit_fill(e){if(e.querySelectorAll(".tdc-zone").forEach(s=>s.remove()),!(this.size===null||this.levers===null))for(const s of Vv(this.size,this.levers,this.newName||this.current||"new")){const i=V("div",`tdc-zone${s.fits===!1?" tdc-zone-bad":s.tightest?" tdc-zone-tight":""}`),n=V("div","tdc-zone-head");n.append(V("span","tdc-zone-name",Hv(s.zone)),V("span","tdc-zone-verdict",s.fits===null?"NOT SAID":s.fits?s.tightest?"FITS · TIGHTEST":"FITS":"DOES NOT FIT"));const r=(o,a,l)=>{const c=V("div","tdc-zone-bar"),h=V("div","tdc-zone-track"),d=V("div","tdc-zone-take");return d.style.width=a===null||a<=0?"0%":`${Math.min(100,o/a*100)}%`,h.append(d),c.append(V("span","tdc-zone-unit",l),h,V("span","tdc-zone-text",`${o} OF ${a??"?"}`)),c};i.append(n,r(s.coresNeeded,s.coresFree,"CORES"),r(s.memoryNeeded,s.memoryFree,"GiB"),V("span","tdc-zone-nodes",s.nodes.join(" · ")||"nothing placed")),e.append(i)}}cost_fill(e,s){if(e.querySelectorAll(".tdc-cost-rows, .tdc-commit").forEach(r=>r.remove()),this.size===null||this.levers===null)return;const i=qv(this.size,this.levers),n=V("div","tdc-cost-rows");for(const r of i.rows)n.append(V("span","tdc-pair-label",r.what),V("span","tdc-cost-rate",r.hourly===null?"NOT PRICED":Rn(r.hourly,i.currency,3)));if(n.append(V("span","tdc-pair-label tdc-bill","TOTAL · EST"),V("span","tdc-cost-rate tdc-bill",i.hourly===null?"—":`${Rn(i.hourly,i.currency)} · ${Rn(i.hourly*Dh,i.currency,0)} A MONTH`)),e.append(n),s){const r=V("div","tdc-commit");e.append(r),this.commit_fill(r)}}commit_fill(e){if(this.size===null||this.levers===null)return;e.replaceChildren();const s=CH(this.newName,this.names_get())??(this.zone===null?"NO ZONE":null),i=DH(this.newName||"<name>",this.levers,this.size.start,this.zone!==this.size.baseDomain?this.zone:null),n=ps.tenant(this.newName||"<name>");e.append(V("span","tdc-section-title","THE LINES COMMIT SENDS"),V("div","tdc-mono tdc-commit-line",i),V("div","tdc-mono tdc-commit-line",n),V("p","tdc-prose tdc-quiet","The first writes the spec. The second plays the tenant: the build through the install, which asks before billing, then verify. A NO leaves the spec written and nothing made."));const r=V("div","tdc-commands"),o=V("button","tdc-pill tdc-pill-plain",s===null?"COMMIT":`COMMIT · ${s}`);o.type="button",o.disabled=s!==null||this.busy!==null,o.addEventListener("click",()=>{this.hooks.voice.pill("COMMIT");const l=this.newName;this.line_send(i).then(async()=>{this.clusters.has(l)&&(this.current=l,this.newName="",this.view="build",this.draw(),await this.line_send(ps.tenant(l)))})});const a=V("button","tdc-pill tdc-pill-quiet","RESET");a.type="button",a.addEventListener("click",()=>{this.hooks.voice.pill("RESET"),this.size!==null&&(this.levers=Mf(this.size.start)),this.draw()}),r.append(o,V("span","tdc-flex"),a),e.append(r)}strip_draw(){const e=this.parts.strip;if(e.replaceChildren(),e.hidden=this.ask===null,this.ask===null)return;const s=this.ask,i=/destroy/i.test(s.message),n=/billing starts/i.test(s.message);e.dataset.tone=i?"destroy":n?"bill":"plain";const r=V("div","tdc-strip-words");if(r.append(V("span","tdc-strip-title","THE ENGINE ASKS"),V("span","tdc-strip-text",s.message)),e.append(r),RH(s.message)==="yes-no"){const u=V("button",`tdc-pill ${n?"tdc-pill-bill":"tdc-pill-plain"}`,n?"YES · BILL":"YES");u.type="button",u.addEventListener("click",()=>{this.hooks.voice.pill("YES"),this.log_add("y","answer"),s.answer("y")});const p=V("button","tdc-pill tdc-pill-quiet","NO");p.type="button",p.addEventListener("click",()=>{this.hooks.voice.pill("NO"),this.log_add("n","answer"),s.answer("n")}),e.append(u,p);return}const o=V("input","tdc-strip-input");o.id="tdc-strip-input",o.type=s.kind==="secret"?"password":"text",o.autocomplete="off",o.spellcheck=!1;const a=V("label","tdc-pair-label",i?"NAME":"ANSWER");a.setAttribute("for",o.id);const l=V("button",`tdc-pill ${i?"tdc-pill-destroy":"tdc-pill-plain"}`,i?"DESTROY":"SEND");l.type="button";const c=this.current;i&&(l.disabled=!0,o.addEventListener("input",()=>{l.disabled=o.value.trim()!==c}));const h=()=>{l.disabled||(this.hooks.voice.pill(l.textContent??""),this.log_add(s.kind==="secret"?"(hidden)":o.value,"answer"),s.answer(o.value))};l.addEventListener("click",h),o.addEventListener("keydown",u=>{u.key==="Enter"&&h()});const d=V("button","tdc-pill tdc-pill-quiet","NO");d.type="button",d.addEventListener("click",()=>{this.hooks.voice.pill("NO"),this.log_add("(declined)","answer"),s.answer("")}),e.append(a,o,l,d),queueMicrotask(()=>o.focus())}log_add(e,s){const i=V("span",`tdc-log-line tdc-log-${s}`,e);for(this.parts.log.append(i);this.parts.log.childElementCount>kH;)this.parts.log.firstElementChild?.remove();if(this.parts.log.scrollTop=this.parts.log.scrollHeight,s==="out"&&this.stepLogLine!==null&&this.busy===this.stepLogLine&&(this.stepLog.push(e),this.view==="build")){const n=this.parts.body.querySelector(".tdc-steplog");if(n!==null){for(n.querySelector(".tdc-quiet")?.remove(),n.append(V("span","tdc-steplog-line",e));n.childElementCount>60;)n.firstElementChild?.remove();n.scrollTop=n.scrollHeight}}}async kill_send(e){if(this.busy!==null){this.hooks.stop();for(let s=0;s<50&&this.busy!==null;s++)await new Promise(i=>{setTimeout(i,100)})}await this.line_send(ps.kill(e))}cues_play(e,s){if(e===null||s===null||e.name!==s.name)return;if(e.condition!=="FAILED"&&s.condition==="FAILED"){this.hooks.voice.cue("redalert");return}const i=bf(e).done;bf(s).done>i&&this.hooks.voice.cue("ack")}}const Kv=1250;function Yv(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 GH(t,e){let s=null,i=!1,n=[],r=document.title;const o={events:0,reads:0,lastError:null};window.__argusController={view:()=>s?.view_get()??null,cluster:()=>s?.cluster_get()??null,asking:()=>s?.asking_is()??!1,heard:()=>({...o})};const a=async()=>{try{const d=await t.client.line_execute("cluster status",{silent:!0,observe:!1}),u=Yv(d,zz,p=>Oz.safeParse(p));if(o.reads++,u===null)return;n=u.clusters.map(p=>p.name),e(n),s?.clusters_take(u.clusters),s?.since_refresh()}catch(d){o.lastError=d instanceof Error?d.message:String(d)}},l=async d=>{try{const u=await t.client.line_execute(d===void 0?"cluster size":`cluster size --family ${d}`,{silent:!0,observe:!1});return Yv(u,s2,p=>i2.safeParse(p))}catch{return null}},c=()=>{s!==null&&(s.dispose(),s.root.remove(),s=null,delete document.body.dataset.takeover,document.title=r,Ni.cue_play("close"))};return window.addEventListener("keydown",d=>{s===null||d.key!=="Escape"||(d.stopImmediatePropagation(),d.preventDefault(),c())},!0),{open:async d=>{if(window.innerWidth<Kv){const p=`cluster: the controller needs a screen at least ${Kv} px wide; this one is ${window.innerWidth}, so the line runs as text`;try{const f=await t.client.line_execute(d===""?"cluster status":`cluster ${d}`,{silent:!0,observe:!1});return[p,...f.envelopes.map(_=>`${_.rendered??""}${_.renderedErr??""}`.trimEnd())].join(`
|
|
4362
4362
|
`)}catch(f){return`${p}
|
|
4363
|
-
${f instanceof Error?f.message:String(f)}`}}if(s!==null)return s.
|
|
4364
|
-
`)}finally{i=!1}await a()},size_read:l,stop:()=>t.client.stop_send(),leave:c,voice:{pill:p=>Ni.pill_play(p),cue:p=>Ni.cue_play(p)}});return s=u,document.body.append(u.root),document.body.dataset.takeover="controller",Ni.preload(),Ni.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!==t2||s===null)return;o.events++;const p=xz.safeParse(u);if(!p.success){o.lastError=p.error.message;return}s.domain_take(p.data)},names_get:()=>[...n]}}function PH(t){return`${t.date??"undated"} · ${t.entries.map(e=>`${e.package} ${e.version}`).join(" · ")}`}function LH(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:PH(s),rows:n}})}class WH{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 Vn({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=LH(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 FH(t){for(const e of t.envelopes){if(e.model?.kind!==Ck)continue;const s=Bk.safeParse(e.model.data);if(s.success)return s.data}return null}function UH(t,e){const{layout:s,panels:i,subjects:n}=t,r=async c=>FH(await e.ask(c)),o=c=>{const h=e.template_stamp("tpl-pane-notes");return i.set("notes",c,new WH(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 $H(t){if(t===null)return"REGION";const e=t.indexOf(":");return(e===-1?t:t.slice(e+1)).toUpperCase()}function Xv(t){return t===null?"—":String(t)}function jH(t){const e=new Map;for(const s of t.rows){const i=e.get(s.family)??[];i.push({key:`${s.family}:${s.limit}:${s.zone??"region"}`,family:s.family,limit:s.limit,zone:$H(s.zone),value:s.value,used:s.used,available:s.available}),e.set(s.family,i)}return[...e.entries()].map(([s,i])=>({key:s,title:`${s} · ${t.region}`,rows:i}))}class HH{constructor(e,s){this.hooks=s;const i=e.querySelector(".capacity-panel");if(i===null)throw new Error("capacity pane: no .capacity-panel in its template");this.state=e.querySelector(".pane-state"),this.listing=new Vn({mount:i,traits:this.traits_declare(),key:n=>n.key,chrome:{root:e,prefix:"capacity"},caps:"root",activatable:()=>!1,row:{className:n=>`capacity-row${n.available===0?" capacity-row-full":""}`}})}hooks;listing;state;model=null;traits_declare(){return[{key:"family",label:"FAMILY",className:"capacity-family",width:"minmax(4em, 5em)",cell:e=>e.family},{key:"limit",label:"LIMIT",className:"capacity-limit",width:"minmax(10em, 16em)",cell:e=>e.limit},{key:"zone",label:"ZONE",className:"capacity-zone",width:"minmax(8em, 1fr)",cell:e=>e.zone},{key:"used",label:"USED",className:"capacity-num",width:"6em",cell:e=>Xv(e.used),compare:e=>e.used??-1},{key:"available",label:"FREE",className:"capacity-num",width:"6em",cell:e=>Xv(e.available),compare:e=>e.available??-1},{key:"value",label:"OF",className:"capacity-num",width:"6em",cell:e=>String(e.value),compare:e=>e.value}]}model_show(e){this.model=e,this.render()}families_shown(){return this.model===null?[]:[...new Set(this.model.rows.map(e=>e.family))]}async family_ask(e){const s=await this.hooks.ask(e===""?"capacity":`capacity ${e}`);s!==null&&this.model_show(s)}render(){const e=this.model;if(e===null)return;const s=n=>{const r=document.createElement("header");return r.className="files-path capacity-block-head",r.textContent=n,r},i=jH(e).map(n=>({key:n.key,header:s(n.title),rows:n.rows}));this.listing.rows_set(i,{field:"capacity"}),this.state!==null&&(this.state.textContent=`${e.region.toUpperCase()} · ${this.families_shown().join(" · ")||"NO FAMILY"}`)}}function VH(t){for(const e of t.envelopes){if(e.model?.kind!==Ez)continue;const s=Az.safeParse(e.model.data);if(s.success)return s.data}return null}function qH(t,e){const{layout:s,panels:i,subjects:n}=t,r=async c=>VH(await e.ask(c)),o=c=>{const h=e.template_stamp("tpl-pane-capacity");return i.set("capacity",c,new HH(h,{ask:r})),{id:c,kind:"capacity",mount:h,dispose:()=>{i.delete(c),n.pane_leave(c)}}},a=(c,h)=>{i.get("capacity",c)?.family_ask(h)};return{instance_build:o,open:c=>{const h=c===""?"every family the region offers":c,d=i.ids("capacity").find(g=>s.panes_shown().includes(g));if(d!==void 0)return s.focus_set(d),a(d,c),`capacity: on stage, reading ${h}`;const u=e.launcher_active();e.launcher_yield();const p=s.focused_get()??"files",f=e.instance_spawn("capacity");return(u?s.leaf_replace("files",f.id):s.leaf_split(p,"col",f.id,!1))?(u?s.focus_set(f.id):e.birth_record(f.id,p,"col",!1),a(f.id,c),`capacity: what the region has free for ${h}, as a pane (capacity in the console prints it)`):(As(f.id),s.mount_remove(f.id),"capacity: could not open a pane")}}}function Zv(t){return[...t.querySelectorAll(".mode-frame button")].filter(e=>!e.disabled&&!e.hidden&&e.offsetParent!==null)}function KH(t){return[...t.querySelectorAll(".listing-row")].filter(e=>e.offsetParent!==null)}function YH(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 XH(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",()=>E1()?"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=zB(f.key);if(f.ctrlKey&&!f.metaKey&&!f.altKey&&m!==null){const w=s.focused_get();return w!==null&&e.verbs.resize(w,m,.05),g(),!0}if(f.ctrlKey||f.metaKey||f.altKey)return!1;const v=w=>(e.drawers_close(),w(),g(),!0);if(m!==null)return v(()=>{l(),nS(e.host(),Gi[m].focusWord)!==null&&t.sound("audio3")});switch(f.key){case"o":case"O":{const w=s.panes_shown(),z=w.indexOf(s.focused_get()??""),x=w[(z+(f.key==="o"?1:w.length-1))%w.length];return v(()=>{l(),x!==void 0&&(s.focus_set(x),t.sound("audio3"))})}case"?":return v(()=>t.terminal.line_run("argus keys"));case";":return v(()=>{l(),s.focus_last()!==null&&t.sound("audio3")});case"q":return v(()=>{for(const w of s.panes_shown())e.verbs.bar_note(w,`@${w}`)});case" ":{const w=s.focused_get();return v(()=>{w!==null&&e.verbs.flip(w)})}case"!":{const w=s.focused_get();return v(()=>{w!==null&&s.panes_shown().length>1&&(e.stage_alone(w),e.verbs.bar_note(w,"ALONE ON STAGE"),t.sound("audio3"))})}case"w":return v(()=>e.element_require("gutter-panes").click());case"r":return v(()=>{l();const w=c();w!==null&&h(w)});case"&":return v(()=>t.terminal.line_run("pane close all"));case"[":return v(()=>{const w=document.querySelector(".argus-output");w!==null&&(w.tabIndex=-1,w.focus())})}const y=_n.find(w=>w.key===f.key&&w.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)&&Zv(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=Zv(_),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 v=KH(_);if(v.length===0)return!1;const y=v.findIndex(x=>x.classList.contains("listing-cursor")),b=y>=0?y:v.findIndex(x=>x.classList.contains("listing-indicated"));if(f.key==="ArrowRight")return h(_)&&g();if(f.key==="Enter"){const x=v[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 w=YH(b,v.length,f.key);if(w===null)return!1;for(const x of v)x.classList.remove("listing-cursor");const z=v[w];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(),v=g!==void 0&&g!=="console"?g:s.focused_get()??"files",y=m?e.element_require("console-drawer"):n(v)?.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 ZH(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=_=>wB(_.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 v=Ai(m);g.title=_==="move"?`this pane moves ${m}${e.verbs.chordKeys_format(v,!0)}`:`new pane opens ${m}${e.verbs.chordKeys_format(v,!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",v=c.querySelector(".drawer-bind-selected")?.dataset.bind??"unlinked",y=v==="viewer"?"view":v==="fs"?"fs":"empty";e.pillPane_spawn(l,y,g,m)!==null&&(c.hidden=!0,t.sound("audio3"))});for(const _ of new Set(_n.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=(v,y,b)=>{const w=document.createElement("button");w.className="pacs-capsule drawer-cwdbind",w.dataset.follow=y?"on":"off",w.textContent=v,w.title=b,w.addEventListener("click",()=>{d.follows(l)!==y&&d.follow_set(l,y),t.sound("audio3")}),u.appendChild(w)};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 v=d.follows(l);for(const y of u.querySelectorAll(".drawer-cwdbind"))y.classList.toggle("drawer-bind-selected",y.dataset.follow==="on"===v)}),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=fm(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 v=document.createElement("button");v.className="pacs-capsule drawer-child",v.textContent=_,v.title=g,v.addEventListener("click",()=>{m(),d.hidden=!0,t.sound("audio3")}),p.appendChild(v)};(c==="files"||c==="catalogue")&&o(l,d,h),c==="dag"&&a(l,f)}}async function JH(t,e){if(!xa(window.location.search))return`${t}: this page did not come through a porter, so there is no other session to switch to`;const s=kl(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?" (to manage: build, tear down, spend)":" (to read)"}…`:"switching to your ChRIS session…"}function QH(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}
|
|
4363
|
+
${f instanceof Error?f.message:String(f)}`}}if(s!==null)return s.cluster_choose(d),`cluster: the controller is up${d===""?"":`, on ${d}`}`;r=document.title;const u=new BH({run:async p=>{i=!0;try{await t.client.line_execute(p,{operator:!0})}catch(f){u.output_take(`${f instanceof Error?f.message:String(f)}
|
|
4364
|
+
`)}finally{i=!1}await a()},size_read:l,stop:()=>t.client.stop_send(),leave:c,voice:{pill:p=>Ni.pill_play(p),cue:p=>Ni.cue_play(p)}});return s=u,document.body.append(u.root),document.body.dataset.takeover="controller",Ni.preload(),Ni.cue_play("open"),a().then(()=>u.cluster_choose(d)),`cluster: 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!==t2||s===null)return;o.events++;const p=xz.safeParse(u);if(!p.success){o.lastError=p.error.message;return}s.cluster_take(p.data)},names_get:()=>[...n]}}function PH(t){return`${t.date??"undated"} · ${t.entries.map(e=>`${e.package} ${e.version}`).join(" · ")}`}function LH(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:PH(s),rows:n}})}class WH{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 Vn({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=LH(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 FH(t){for(const e of t.envelopes){if(e.model?.kind!==Ck)continue;const s=Bk.safeParse(e.model.data);if(s.success)return s.data}return null}function UH(t,e){const{layout:s,panels:i,subjects:n}=t,r=async c=>FH(await e.ask(c)),o=c=>{const h=e.template_stamp("tpl-pane-notes");return i.set("notes",c,new WH(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 $H(t){if(t===null)return"REGION";const e=t.indexOf(":");return(e===-1?t:t.slice(e+1)).toUpperCase()}function Xv(t){return t===null?"—":String(t)}function jH(t){const e=new Map;for(const s of t.rows){const i=e.get(s.family)??[];i.push({key:`${s.family}:${s.limit}:${s.zone??"region"}`,family:s.family,limit:s.limit,zone:$H(s.zone),value:s.value,used:s.used,available:s.available}),e.set(s.family,i)}return[...e.entries()].map(([s,i])=>({key:s,title:`${s} · ${t.region}`,rows:i}))}class HH{constructor(e,s){this.hooks=s;const i=e.querySelector(".capacity-panel");if(i===null)throw new Error("capacity pane: no .capacity-panel in its template");this.state=e.querySelector(".pane-state"),this.listing=new Vn({mount:i,traits:this.traits_declare(),key:n=>n.key,chrome:{root:e,prefix:"capacity"},caps:"root",activatable:()=>!1,row:{className:n=>`capacity-row${n.available===0?" capacity-row-full":""}`}})}hooks;listing;state;model=null;traits_declare(){return[{key:"family",label:"FAMILY",className:"capacity-family",width:"minmax(4em, 5em)",cell:e=>e.family},{key:"limit",label:"LIMIT",className:"capacity-limit",width:"minmax(10em, 16em)",cell:e=>e.limit},{key:"zone",label:"ZONE",className:"capacity-zone",width:"minmax(8em, 1fr)",cell:e=>e.zone},{key:"used",label:"USED",className:"capacity-num",width:"6em",cell:e=>Xv(e.used),compare:e=>e.used??-1},{key:"available",label:"FREE",className:"capacity-num",width:"6em",cell:e=>Xv(e.available),compare:e=>e.available??-1},{key:"value",label:"OF",className:"capacity-num",width:"6em",cell:e=>String(e.value),compare:e=>e.value}]}model_show(e){this.model=e,this.render()}families_shown(){return this.model===null?[]:[...new Set(this.model.rows.map(e=>e.family))]}async family_ask(e){const s=await this.hooks.ask(e===""?"capacity":`capacity ${e}`);s!==null&&this.model_show(s)}render(){const e=this.model;if(e===null)return;const s=n=>{const r=document.createElement("header");return r.className="files-path capacity-block-head",r.textContent=n,r},i=jH(e).map(n=>({key:n.key,header:s(n.title),rows:n.rows}));this.listing.rows_set(i,{field:"capacity"}),this.state!==null&&(this.state.textContent=`${e.region.toUpperCase()} · ${this.families_shown().join(" · ")||"NO FAMILY"}`)}}function VH(t){for(const e of t.envelopes){if(e.model?.kind!==Ez)continue;const s=Az.safeParse(e.model.data);if(s.success)return s.data}return null}function qH(t,e){const{layout:s,panels:i,subjects:n}=t,r=async c=>VH(await e.ask(c)),o=c=>{const h=e.template_stamp("tpl-pane-capacity");return i.set("capacity",c,new HH(h,{ask:r})),{id:c,kind:"capacity",mount:h,dispose:()=>{i.delete(c),n.pane_leave(c)}}},a=(c,h)=>{i.get("capacity",c)?.family_ask(h)};return{instance_build:o,open:c=>{const h=c===""?"every family the region offers":c,d=i.ids("capacity").find(g=>s.panes_shown().includes(g));if(d!==void 0)return s.focus_set(d),a(d,c),`capacity: on stage, reading ${h}`;const u=e.launcher_active();e.launcher_yield();const p=s.focused_get()??"files",f=e.instance_spawn("capacity");return(u?s.leaf_replace("files",f.id):s.leaf_split(p,"col",f.id,!1))?(u?s.focus_set(f.id):e.birth_record(f.id,p,"col",!1),a(f.id,c),`capacity: what the region has free for ${h}, as a pane (capacity in the console prints it)`):(As(f.id),s.mount_remove(f.id),"capacity: could not open a pane")}}}function Zv(t){return[...t.querySelectorAll(".mode-frame button")].filter(e=>!e.disabled&&!e.hidden&&e.offsetParent!==null)}function KH(t){return[...t.querySelectorAll(".listing-row")].filter(e=>e.offsetParent!==null)}function YH(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 XH(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",()=>E1()?"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=zB(f.key);if(f.ctrlKey&&!f.metaKey&&!f.altKey&&m!==null){const w=s.focused_get();return w!==null&&e.verbs.resize(w,m,.05),g(),!0}if(f.ctrlKey||f.metaKey||f.altKey)return!1;const v=w=>(e.drawers_close(),w(),g(),!0);if(m!==null)return v(()=>{l(),nS(e.host(),Gi[m].focusWord)!==null&&t.sound("audio3")});switch(f.key){case"o":case"O":{const w=s.panes_shown(),z=w.indexOf(s.focused_get()??""),x=w[(z+(f.key==="o"?1:w.length-1))%w.length];return v(()=>{l(),x!==void 0&&(s.focus_set(x),t.sound("audio3"))})}case"?":return v(()=>t.terminal.line_run("argus keys"));case";":return v(()=>{l(),s.focus_last()!==null&&t.sound("audio3")});case"q":return v(()=>{for(const w of s.panes_shown())e.verbs.bar_note(w,`@${w}`)});case" ":{const w=s.focused_get();return v(()=>{w!==null&&e.verbs.flip(w)})}case"!":{const w=s.focused_get();return v(()=>{w!==null&&s.panes_shown().length>1&&(e.stage_alone(w),e.verbs.bar_note(w,"ALONE ON STAGE"),t.sound("audio3"))})}case"w":return v(()=>e.element_require("gutter-panes").click());case"r":return v(()=>{l();const w=c();w!==null&&h(w)});case"&":return v(()=>t.terminal.line_run("pane close all"));case"[":return v(()=>{const w=document.querySelector(".argus-output");w!==null&&(w.tabIndex=-1,w.focus())})}const y=_n.find(w=>w.key===f.key&&w.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)&&Zv(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=Zv(_),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 v=KH(_);if(v.length===0)return!1;const y=v.findIndex(x=>x.classList.contains("listing-cursor")),b=y>=0?y:v.findIndex(x=>x.classList.contains("listing-indicated"));if(f.key==="ArrowRight")return h(_)&&g();if(f.key==="Enter"){const x=v[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 w=YH(b,v.length,f.key);if(w===null)return!1;for(const x of v)x.classList.remove("listing-cursor");const z=v[w];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(),v=g!==void 0&&g!=="console"?g:s.focused_get()??"files",y=m?e.element_require("console-drawer"):n(v)?.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 ZH(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=_=>wB(_.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 v=Ai(m);g.title=_==="move"?`this pane moves ${m}${e.verbs.chordKeys_format(v,!0)}`:`new pane opens ${m}${e.verbs.chordKeys_format(v,!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",v=c.querySelector(".drawer-bind-selected")?.dataset.bind??"unlinked",y=v==="viewer"?"view":v==="fs"?"fs":"empty";e.pillPane_spawn(l,y,g,m)!==null&&(c.hidden=!0,t.sound("audio3"))});for(const _ of new Set(_n.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=(v,y,b)=>{const w=document.createElement("button");w.className="pacs-capsule drawer-cwdbind",w.dataset.follow=y?"on":"off",w.textContent=v,w.title=b,w.addEventListener("click",()=>{d.follows(l)!==y&&d.follow_set(l,y),t.sound("audio3")}),u.appendChild(w)};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 v=d.follows(l);for(const y of u.querySelectorAll(".drawer-cwdbind"))y.classList.toggle("drawer-bind-selected",y.dataset.follow==="on"===v)}),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=fm(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 v=document.createElement("button");v.className="pacs-capsule drawer-child",v.textContent=_,v.title=g,v.addEventListener("click",()=>{m(),d.hidden=!0,t.sound("audio3")}),p.appendChild(v)};(c==="files"||c==="catalogue")&&o(l,d,h),c==="dag"&&a(l,f)}}async function JH(t,e){if(!xa(window.location.search))return`${t}: this page did not come through a porter, so there is no other session to switch to`;const s=kl(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?" (to manage: build, tear down, spend)":" (to read)"}…`:"switching to your ChRIS session…"}function QH(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}
|
|
4365
4365
|
viewports: ${_||"(none)"}`}if(u==="layout"){const f=p[0]??"";return sN.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((v,y)=>`${y+1} ${v.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 mh.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=w=>"pane"in w?w.pane:p(w.first),f=p(d),_=o(f);u.push(`view ${_==="dag"?"runs":_==="pacs"?"pacs":"files"}`);let g=1;const m=(w,z)=>{const x=o(w);x==="dag"&&w!==f&&u.push(`pane %${z} claim runs`),x==="files"&&w!==f&&r.group_resolve(w)===w&&u.push(`pane %${z} claim files`);const M=x==="files"?i.get("files",w)?.path_current()??null:null;M!==null&&u.push(`file %${z} open ${M}`);const S=x==="dag"?i.get("dag",w):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(w)?.mount,A=T?.querySelector(".dag-strategy")?.textContent?.toLowerCase()??"ranked",E=T?.querySelector(".dag-projection")?.textContent?.toLowerCase()??"3d",O=T?.querySelector(".dag-hue")?.textContent?.toLowerCase()??"status";A!=="ranked"&&u.push(`dag %${z} layout ${A}`),E!=="3d"&&u.push(`dag %${z} projection ${E}`),O!=="status"&&u.push(`dag %${z} hue ${O}`)}},v=(w,z)=>{if("pane"in w){m(w.pane,z);return}const x=p(w.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 ${w.dir==="col"?"right":"below"}`);const T=++g;v(w.first,z),v(w.second,T)};v(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(`
|
|
4366
4366
|
`)};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,capacity_open:e.capacity_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:JH,stage_keep:e.stage_keep,viewModes_hold:a5,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(`
|
|
4367
|
-
`)}catch(u){return u instanceof Error?u.message:String(u)}},desktop_serialize:h}}function e9(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 b_={"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 lx(t){const e=b_[t];return`${e.before}${e.cure}${e.after}`}async function t9(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 Jv=96;function s9(t){const e=t.headline.length>Jv?`${t.headline.slice(0,Jv-1).trimEnd()}…`:t.headline;return`argus ${t.version} · ${e} — WHAT'S NEW after restart`}function i9(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: ${lx(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=b_[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"&&t9().then(p=>{if(p===null||!c.isConnected)return;const f=document.createElement("span");f.className="build-mismatch-news",f.textContent=s9(p),h.appendChild(f)})}function n9(t,e,s,i=document.body){const n={git:"
|
|
4367
|
+
`)}catch(u){return u instanceof Error?u.message:String(u)}},desktop_serialize:h}}function e9(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 b_={"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 lx(t){const e=b_[t];return`${e.before}${e.cure}${e.after}`}async function t9(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 Jv=96;function s9(t){const e=t.headline.length>Jv?`${t.headline.slice(0,Jv-1).trimEnd()}…`:t.headline;return`argus ${t.version} · ${e} — WHAT'S NEW after restart`}function i9(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: ${lx(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=b_[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"&&t9().then(p=>{if(p===null||!c.isConnected)return;const f=document.createElement("span");f.className="build-mismatch-news",f.textContent=s9(p),h.appendChild(f)})}function n9(t,e,s,i=document.body){const n={git:"a863f341",built:"2026-11-02 01:51"};let r=[],o,a=null;const l=h=>{r!==null?r.push(h):e(h)},c=h=>{if(o===void 0)return;const d=e9(n,o,h);if(d!==a){if(a=d,d===null){t.build_show(null),i.querySelector(".build-mismatch")?.remove();return}t.build_show(b_[d].readout,lx(d)),i9(d,n,o,l,i,xa(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 r9(t=document.getElementById("door-pill")){t===null||!xa(window.location.search)||(t.hidden=!1,t.addEventListener("click",()=>{const e=kl(window.location.pathname,"logout"),s=kl(window.location.pathname,"login");fetch(e,{method:"POST",headers:{accept:"application/json"}}).catch(()=>{}).then(()=>{window.location.assign(s)})}))}const o9="Restart the calypso daemon? You'll stay logged in; the page reloads when the new daemon is up.";function a9(t){const e=[];t.running!==null&&e.push(`the running command: ${t.running}`);for(const r of t.joblets??[])e.push(`joblet %${r.number}: ${r.line} (ended; its log is kept)`);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 l9(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 c9(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=o9,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 h9(t,e=document.body){const s=xa(window.location.search);let i=null,n=null,r=[],o=[],a=!1;const l=p=>{e.querySelector(".restart-said")?.remove();const f=document.createElement("div");f.className="stale-page restart-said",f.setAttribute("role","alert"),f.textContent=p,e.appendChild(f)},c=p=>{window.location.assign(`${kl(window.location.pathname,"greet")}/${encodeURIComponent(p)}`)},h=async()=>{a=!0,l("Restarting the calypso daemon…");try{const p=await fetch(kl(window.location.pathname,"restart"),{method:"POST",headers:{accept:"application/json"}}),f=await p.json();if(!p.ok||f.key===void 0)throw new Error(f.error??`the door answered ${p.status}`);c(f.key)}catch(p){a=!1,l(`The calypso daemon could not be restarted: ${p instanceof Error?p.message:String(p)}`)}},d=()=>{if(!s||e.querySelector(".restart-question")!==null)return;const p={running:n,unsaved:t.unsaved(),others:o.filter(_=>_.id!==i),joblets:r},f=c9(a9(p),_=>{_&&h()});e.querySelector(".build-mismatch")?.remove(),e.appendChild(f),f.querySelector(".restart-yes")?.focus()},u=document.getElementById("restart-pill");return u!==null&&s&&(u.hidden=!1,u.addEventListener("click",d)),{ask:d,attach_take:p=>{i=p.surface??null},telemetry_take:p=>{p?.lane!==void 0&&(n=p.lane.running?.line??null),p?.lane?.joblets!==void 0&&(r=p.lane.joblets),p?.surfaces!==void 0&&(o=p.surfaces)},closing_take:p=>{if(a||(l(l9(p)),p!=="restart"||!s))return;const f=window.location.pathname.split("/").filter(_=>_.length>0).at(-1);f!==void 0&&setTimeout(()=>c(f),1200)}}}function d9(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(`
|
|
4368
4368
|
`))}).catch(()=>{}).finally(i)}var cx=Object.defineProperty,u9=Object.getOwnPropertyDescriptor,f9=(t,e)=>{for(var s in e)cx(t,s,{get:e[s],enumerable:!0})},ss=(t,e,s,i)=>{for(var n=i>1?void 0:i?u9(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&&cx(e,s,n),n},ke=(t,e)=>(s,i)=>e(s,i,t),Qv="Terminal input",bm={get:()=>Qv,set:t=>Qv=t},ew="Too much output to announce, navigate to rows manually to read",Mm={get:()=>ew,set:t=>ew=t};function p9(t){return t.replace(/\r?\n/g,"\r")}function m9(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function g9(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function _9(t,e,s,i){if(t.stopPropagation(),t.clipboardData){let n=t.clipboardData.getData("text/plain");hx(n,e,s,i)}}function hx(t,e,s,i){t=p9(t),t=m9(t,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function dx(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 tw(t,e,s,i,n){dx(t,e,s),n&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function mr(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function qd(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 b9=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}},M9=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}},ux="",wr=" ",Ql=class fx{constructor(){this.fg=0,this.bg=0,this.extended=new ud}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 fx;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}},ud=class px{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 px(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Pi=class mx extends Ql{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ud,this.combinedData=""}static fromCharData(e){let s=new mx;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?mr(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()]}},sw="di$target",vm="di$dependencies",vf=new Map;function v9(t){return t[vm]||[]}function Ts(t){if(vf.has(t))return vf.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");w9(e,s,n)};return e._id=t,vf.set(t,e),e}function w9(t,e,s){e[sw]===e?e[vm].push({id:t,index:s}):(e[vm]=[{id:t,index:s}],e[sw]=e)}var Qs=Ts("BufferService"),gx=Ts("CoreMouseService"),So=Ts("CoreService"),y9=Ts("CharsetService"),M_=Ts("InstantiationService"),_x=Ts("LogService"),ei=Ts("OptionsService"),bx=Ts("OscLinkService"),z9=Ts("UnicodeService"),ec=Ts("DecorationService"),wm=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 Pi,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):S9(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)}};wm=ss([ke(0,Qs),ke(1,ei),ke(2,bx)],wm);function S9(t,e){if(confirm(`Do you want to navigate to ${e}?
|
|
4369
4369
|
|
|
4370
4370
|
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 Kd=Ts("CharSizeService"),Zn=Ts("CoreBrowserService"),v_=Ts("MouseService"),Jn=Ts("RenderService"),x9=Ts("SelectionService"),Mx=Ts("CharacterJoinerService"),Aa=Ts("ThemeService"),vx=Ts("LinkProviderService"),O9=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?iw.isErrorNoTelemetry(t)?new iw(t.message+`
|
|
@@ -4388,9 +4388,9 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
|
|
|
4388
4388
|
`).slice(2).join(`
|
|
4389
4389
|
`))}},Fq=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},Uq=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},$q=0,Nf=class{constructor(t){this.value=t,this.id=$q++}},jq=2,Hq,dr=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new Lq(t?.onListenerError??kf,this._options?.leakWarningThreshold??Pq):void 0,this._perfMon=this._options?._profName?new Gq(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 Uq(`${o}. HINT: Stack shows most frequent listener (${a[1]}-times)`,a[0]);return(this._options?.onListenerError||kf)(l),bd.None}if(this._disposed)return bd.None;e&&(t=t.bind(e));let i=new Nf(t),n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=Wq.create(),n=this._leakageMon.check(i.stack,this._size+1)),this._listeners?this._listeners instanceof Nf?(this._deliveryQueue??=new Vq,this._listeners=[this._listeners,i]):this._listeners.push(i):(this._options?.onWillAddFirstListener?.(this),this._listeners=i,this._options?.onDidAddFirstListener?.(this)),this._size++;let r=tO(()=>{n?.(),this._removeListener(i)});return s instanceof T_?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*jq<=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||kf;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 Nf)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}},Vq=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 Gh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new dr,this.onChange=this._onChange.event;let e=new Oq;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=Gh.extractWidth(a);Gh.extractShouldJoin(a)&&(l-=Gh.extractWidth(i)),s+=l,i=a}return s}charProperties(e,s){return this._activeProvider.charProperties(e,s)}},Bf=[[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]],qq=[[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]],Gf=[[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]],Kq=[[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]],In;function Kw(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 Yq=class{constructor(){if(this.version="11",!In){In=new Uint8Array(65536),In.fill(1),In[0]=0,In.fill(0,1,32),In.fill(0,127,160);for(let t=0;t<Bf.length;++t)In.fill(0,Bf[t][0],Bf[t][1]+1);for(let t=0;t<Gf.length;++t)In.fill(2,Gf[t][0],Gf[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?In[t]:Kw(t,qq)?0:Kw(t,Kq)?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)}},Xq=class{activate(t){t.unicode.register(new Yq)}dispose(){}};var Zq=class{constructor(t,e,s,i={}){this._terminal=t,this._regex=e,this._handler=s,this._options=i}provideLinks(t,e){let s=Qq.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 Jq(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 Qq=class Ph{static computeLink(e,s,i,n){let r=new RegExp(s.source,(s.flags||"")+"g"),[o,a]=Ph._getWindowedLineStrings(e-1,i),l=o.join(""),c,h=[];for(;c=r.exec(l);){let d=c[0];if(!Jq(d))continue;let[u,p]=Ph._mapStrIdx(i,a,0,c.index),[f,_]=Ph._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]}},eK=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function tK(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 sK=class{constructor(t=tK,e={}){this._handler=t,this._options=e}activate(t){this._terminal=t;let e=this._options,s=e.urlRegex||eK;this._linkProvider=this._terminal.registerLinkProvider(new Zq(this._terminal,s,this._handler,e))}dispose(){this._linkProvider?.dispose()}};const iK=6677;function nK(t){const e=/^state=(idle|busy|asking|playing)$/.exec(t.trim());return e===null?null:e[1]}const rg="argus.terminalId",rK="'JetBrainsMono NF Mono', 'MesloLGS NF', monospace",oK=[{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 aK(t){const[e,s,i,n,r,o,a,l,c,h,d,u,p,f,_,g]=h2;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 lK(t){if(t.length!==1)return t;const e=t.toUpperCase().charCodeAt(0);return e>=64&&e<=95?String.fromCharCode(e-64):t}function cK(){try{return sessionStorage.getItem(rg)??void 0}catch{return}}function Yw(t){try{t===null?sessionStorage.removeItem(rg):sessionStorage.setItem(rg,t)}catch{}}class hK{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 vq({fontFamily:rK,fontSize:Math.max(10,Math.floor(parseFloat(getComputedStyle(e).fontSize)||13)),theme:aK(r),cursorBlink:!0,scrollback:5e3,allowProposedApi:!0}),this.term.loadAddon(this.fit),this.term.loadAddon(new sK),this.term.loadAddon(new Xq),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(iK,a=>{const l=nK(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,cK())}mount;wire;refused;state;term;fit=new zq;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,Yw(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,Yw(null),this.term.write(`\r
|
|
4390
4390
|
\x1B[90m[the console's shell exited${s===0?"":` (${s})`}; press a key for a new one]\x1B[0m\r
|
|
4391
|
-
`))}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=lK(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 oK){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 dK="argus.consoleMode",uK="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 fK(){try{localStorage.removeItem(dK)}catch{}}function pK(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 hK(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 fK(),a(i?"terminal":"transcript"),i||s.line_note(uK),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 f_(s,c,l)}finally{c.remove()}}}}const mK=new Set(["busy","asking","playing"]);function gK(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")?mK.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 Zr=()=>{};function Xw(){Zr(document.body.dataset.zoom==="console"?null:"console")}const _K=AO(),bK=DO(),MK=new URL("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNDAgMjkwIj4KPGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJnIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjQwIiB5MT0iMCIgeDI9IjIwMCIgeTI9IjIyNCI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjMmE2M2JmIi8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjN2FkM2YxIi8+PC9saW5lYXJHcmFkaWVudD4KPHJhZGlhbEdyYWRpZW50IGlkPSJoIj48c3RvcCBvZmZzZXQ9IjAiIHN0b3AtY29sb3I9IiM3YWQzZjEiIHN0b3Atb3BhY2l0eT0iMC40NSIvPjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzdhZDNmMSIgc3RvcC1vcGFjaXR5PSIwIi8+PC9yYWRpYWxHcmFkaWVudD48L2RlZnM+CjxjaXJjbGUgY3g9IjEyMCIgY3k9IjExMiIgcj0iMTA0IiBmaWxsPSJ1cmwoI2gpIi8+PHJlY3QgeD0iMjIuMCIgeT0iNDguMCIgd2lkdGg9IjE5NiIgaGVpZ2h0PSIxMjgiIHJ4PSI2NC4wIiBmaWxsPSJub25lIiBzdHJva2U9IiNjNzQ2MzQiIHN0cm9rZS13aWR0aD0iMTYiLz48bGluZSB4MT0iMTIwIiB5MT0iMTEyIiB4Mj0iMjE0IiB5Mj0iMjIiIHN0cm9rZT0iIzdhZDNmMSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtZGFzaGFycmF5PSIyIDUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgb3BhY2l0eT0iMC44Ii8+PGxpbmUgeDE9IjEyMCIgeTE9IjExMiIgeDI9IjI2IiB5Mj0iMjAyIiBzdHJva2U9IiM3YWQzZjEiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWRhc2hhcnJheT0iMiA1IiBzdHJva2UtbGluZWNhcD0icm91bmQiIG9wYWNpdHk9IjAuOCIvPjxwYXRoIGQ9Ik0yMTQsMC4wIEwyMTguNSwxNy41IEwyMzAuMCwyMiBMMjE4LjUsMjYuNSBMMjE0LDQ0LjAgTDIwOS41LDI2LjUgTDE5OC4wLDIyIEwyMDkuNSwxNy41WiIgZmlsbD0idXJsKCNnKSIvPjxwYXRoIGQ9Ik0yNiwxODguOCBMMjguNywxOTkuMyBMMzUuNiwyMDIgTDI4LjcsMjA0LjcgTDI2LDIxNS4yIEwyMy4zLDIwNC43IEwxNi40LDIwMiBMMjMuMywxOTkuM1oiIGZpbGw9InVybCgjZykiLz48cG9seWdvbiBwb2ludHM9IjEyMC4wLDExMi4wIDEwOC42LDg0LjYgMTIwLjAsMi4wIiBmaWxsPSJ1cmwoI2cpIi8+PHBvbHlnb24gcG9pbnRzPSIxMjAuMCwxMTIuMCAxMjAuMCwyLjAgMTMxLjQsODQuNiIgZmlsbD0idXJsKCNnKSIgZmlsbC1vcGFjaXR5PSIwLjciLz48cG9seWdvbiBwb2ludHM9IjEyMC4wLDExMi4wIDEzMS40LDg0LjYgMTUxLjEsODAuOSIgZmlsbD0idXJsKCNnKSIvPjxwb2x5Z29uIHBvaW50cz0iMTIwLjAsMTEyLjAgMTUxLjEsODAuOSAxNDcuNCwxMDAuNiIgZmlsbD0idXJsKCNnKSIgZmlsbC1vcGFjaXR5PSIwLjciLz48cG9seWdvbiBwb2ludHM9IjEyMC4wLDExMi4wIDE0Ny40LDEwMC42IDE5Mi4wLDExMi4wIiBmaWxsPSJ1cmwoI2cpIi8+PHBvbHlnb24gcG9pbnRzPSIxMjAuMCwxMTIuMCAxOTIuMCwxMTIuMCAxNDcuNCwxMjMuNCIgZmlsbD0idXJsKCNnKSIgZmlsbC1vcGFjaXR5PSIwLjciLz48cG9seWdvbiBwb2ludHM9IjEyMC4wLDExMi4wIDE0Ny40LDEyMy40IDE1MS4xLDE0My4xIiBmaWxsPSJ1cmwoI2cpIi8+PHBvbHlnb24gcG9pbnRzPSIxMjAuMCwxMTIuMCAxNTEuMSwxNDMuMSAxMzEuNCwxMzkuNCIgZmlsbD0idXJsKCNnKSIgZmlsbC1vcGFjaXR5PSIwLjciLz48cG9seWdvbiBwb2ludHM9IjEyMC4wLDExMi4wIDEzMS40LDEzOS40IDEyMC4wLDIyMi4wIiBmaWxsPSJ1cmwoI2cpIi8+PHBvbHlnb24gcG9pbnRzPSIxMjAuMCwxMTIuMCAxMjAuMCwyMjIuMCAxMDguNiwxMzkuNCIgZmlsbD0idXJsKCNnKSIgZmlsbC1vcGFjaXR5PSIwLjciLz48cG9seWdvbiBwb2ludHM9IjEyMC4wLDExMi4wIDEwOC42LDEzOS40IDg4LjksMTQzLjEiIGZpbGw9InVybCgjZykiLz48cG9seWdvbiBwb2ludHM9IjEyMC4wLDExMi4wIDg4LjksMTQzLjEgOTIuNiwxMjMuNCIgZmlsbD0idXJsKCNnKSIgZmlsbC1vcGFjaXR5PSIwLjciLz48cG9seWdvbiBwb2ludHM9IjEyMC4wLDExMi4wIDkyLjYsMTIzLjQgNDguMCwxMTIuMCIgZmlsbD0idXJsKCNnKSIvPjxwb2x5Z29uIHBvaW50cz0iMTIwLjAsMTEyLjAgNDguMCwxMTIuMCA5Mi42LDEwMC42IiBmaWxsPSJ1cmwoI2cpIiBmaWxsLW9wYWNpdHk9IjAuNyIvPjxwb2x5Z29uIHBvaW50cz0iMTIwLjAsMTEyLjAgOTIuNiwxMDAuNiA4OC45LDgwLjkiIGZpbGw9InVybCgjZykiLz48cG9seWdvbiBwb2ludHM9IjEyMC4wLDExMi4wIDg4LjksODAuOSAxMDguNiw4NC42IiBmaWxsPSJ1cmwoI2cpIiBmaWxsLW9wYWNpdHk9IjAuNyIvPgo8ZyBzdHJva2U9IiNmZmYiIHN0cm9rZS13aWR0aD0iMyIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBmaWxsPSJub25lIj48bGluZSB4MT0iMTIwIiB5MT0iMTEyIiB4Mj0iMTIwLjAiIHkyPSIxNy40Ii8+PGxpbmUgeDE9IjEyMCIgeTE9IjExMiIgeDI9IjE4MS45IiB5Mj0iMTEyLjAiLz48bGluZSB4MT0iMTIwIiB5MT0iMTEyIiB4Mj0iMTIwLjAiIHkyPSIyMDYuNiIvPjxsaW5lIHgxPSIxMjAiIHkxPSIxMTIiIHgyPSI1OC4xIiB5Mj0iMTEyLjAiLz48cG9seWdvbiBwb2ludHM9IjEzMS40LDg0LjYgMTQ3LjQsMTAwLjYgMTQ3LjQsMTIzLjQgMTMxLjQsMTM5LjQgMTA4LjYsMTM5LjQgOTIuNiwxMjMuNCA5Mi42LDEwMC42IDEwOC42LDg0LjYiLz48L2c+CjxnIGZpbGw9IiNmZmYiPjxjaXJjbGUgY3g9IjEyMCIgY3k9IjExMiIgcj0iMTAiLz48Y2lyY2xlIGN4PSIxMjAuMCIgY3k9IjUxLjUiIHI9IjQuNSIvPjxjaXJjbGUgY3g9IjE1OS42IiBjeT0iMTEyLjAiIHI9IjQuNSIvPjxjaXJjbGUgY3g9IjEyMC4wIiBjeT0iMTcyLjUiIHI9IjQuNSIvPjxjaXJjbGUgY3g9IjgwLjQiIGN5PSIxMTIuMCIgcj0iNC41Ii8+PGNpcmNsZSBjeD0iMTMxLjQiIGN5PSI4NC42IiByPSIzLjUiLz48Y2lyY2xlIGN4PSIxNDcuNCIgY3k9IjEwMC42IiByPSIzLjUiLz48Y2lyY2xlIGN4PSIxNDcuNCIgY3k9IjEyMy40IiByPSIzLjUiLz48Y2lyY2xlIGN4PSIxMzEuNCIgY3k9IjEzOS40IiByPSIzLjUiLz48Y2lyY2xlIGN4PSIxMDguNiIgY3k9IjEzOS40IiByPSIzLjUiLz48Y2lyY2xlIGN4PSI5Mi42IiBjeT0iMTIzLjQiIHI9IjMuNSIvPjxjaXJjbGUgY3g9IjkyLjYiIGN5PSIxMDAuNiIgcj0iMy41Ii8+PGNpcmNsZSBjeD0iMTA4LjYiIGN5PSI4NC42IiByPSIzLjUiLz48L2c+Cjx0ZXh0IHg9IjEyMCIgeT0iMjY4IiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBmb250LWZhbWlseT0iTW9udHNlcnJhdCxIZWx2ZXRpY2EsQXJpYWwsc2Fucy1zZXJpZiIgZm9udC13ZWlnaHQ9IjcwMCIgZm9udC1zaXplPSIzOCIgZmlsbD0iIzJhNjNiZiIgbGV0dGVyLXNwYWNpbmc9IjQiPk9DSSBURDwvdGV4dD4KPC9zdmc+",import.meta.url).href,vK=`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 Zw(t){for(const e of document.querySelectorAll('link[rel="icon"], link[rel="apple-touch-icon"]'))e.href=t}const wK="ARGUS",Jw="argus-audio",yK=.4;let ur=!1;const zK={audio1:{file:"press",cue:"press"},audio2:{file:"arrive",cue:"ack"},audio3:{file:"retreat",cue:"close"},audio4:{file:"refuse",cue:"deny"}},lO=new Set;function SK(){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"&&lO.add(s.replace(/\.[a-z0-9]+$/,""))}).catch(()=>{})}function Ri(t){if(ur)return;const e=zK[t];if(e!==void 0&&!lO.has(e.file)){Ni.cue_play(e.cue);return}const s=document.getElementById(t);s instanceof HTMLAudioElement&&(s.currentTime=0,s.volume=yK,s.play().catch(()=>{}))}function xK(){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 OK(){const t=Qe("audio-pill");try{ur=window.localStorage.getItem(Jw)==="off"}catch{ur=!1}const e=()=>{t.classList.toggle("audio-off",ur),Ni.muted_set(ur)};e(),SK(),t.addEventListener("click",()=>{ur=!ur;try{window.localStorage.setItem(Jw,ur?"off":"on")}catch{}e(),Ri("audio2")})}function EK(){return IO(window.location)}let Pf=null,vd=0;function D_(t,e){const s=()=>{e.dataset.zoom!==void 0||e.dataset.header==="away"||(vd=Math.ceil(t.offsetTop+t.offsetHeight),e.style.setProperty("--zoom-header-height",`${vd}px`))};s(),Pf===null&&(Pf=new ResizeObserver(s),Pf.observe(t))}const Qw=120,AK=96;function TK(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),Ri("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(Qw,window.innerHeight-AK),u=a+(h.clientY-o),p=Math.min(Math.max(Qw,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 DK(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,vd>0&&e.style.setProperty("--zoom-header-height",`${vd}px`)):s!==null&&D_(s,e),e.dataset.zoom=r;const a=Eh(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";Ri("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 IK(){const t=new pj(document.getElementById("data-cascade")),e=document.getElementById("header-telemetry");return e!==null&&t.telemetryPanel_bind(e),t}const Lf=96,CK=220,ey="argus.headerBand.height",RK=52;function kK(){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(Lf,window.innerHeight-CK),u=Math.min(Math.max(Lf,h),d);t.style.setProperty("--header-band-h",`${u}px`);try{window.localStorage.setItem(ey,String(u))}catch{}},n=(()=>{try{return window.localStorage.getItem(ey)}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-RK)}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?Lf: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 I_=null;function NK(t){const e=t.querySelector(".gather-rows");if(e===null)return;const s=ii(e,{rows:".listing-row",label:i=>`+${i} MORE · ON STAGE`,press:()=>{I_?.()},className:"strategy-pill gather-more",mount:t});s.title="the whole cohort as a pane on the main panel"}function ty(t){ii(t,{rows:".strategy-pill, .listing-action, .holder-mark",className:"frame-more"})}function BK(){const t=e=>{for(const s of e.querySelectorAll(".mode-frame:not([data-more])"))ty(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&&ty(i),t(i))}).observe(document.body,{childList:!0,subtree:!0}),t(document)}function sy(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 GK(){const t=document.body,e=document.querySelector(".wrap:not(#gap)"),s=r=>{t.dataset.header===r?(e!==null&&D_(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(),I_?.()}),i!==null&&NK(i),BK();const n=()=>{t.dataset.zoom===void 0&&(delete t.dataset.header,Ri("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 Jo=[{key:"lower-decks",label:"LOWER DECKS"},{key:"gold",label:"CERRITOS GOLD"},{key:"medical",label:"MEDICAL"},{key:"nemesis",label:"NEMESIS"},{key:"pharos",label:"PHAROS"}],cO="argus-landing",PK=15e3;function iy(){try{return(window.localStorage.getItem(cO)??"launcher")==="launcher"}catch{return!0}}function LK(t){try{window.localStorage.setItem(cO,t?"launcher":"last")}catch{}}const ny="argus-theme",WK="argus-lcars",FK="medical",UK={sickbay:"medical"};function $K(){const t=Qe("theme-pill"),e=Math.max(Jo.findIndex(r=>r.key===FK),0);let s=e;try{const r=window.localStorage.getItem(ny)??window.localStorage.getItem(WK),o=r===null?null:UK[r]??r,a=Jo.findIndex(l=>l.key===o);s=a>=0?a:e}catch{s=e}const i=document.documentElement,n=()=>{const r=Jo[s]??Jo[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)%Jo.length,n();try{window.localStorage.setItem(ny,Jo[s]?.key??"lower-decks")}catch{}Ri("audio2")})}function jK(t){const e=document.getElementById("about-rows");if(e===null)return;e.replaceChildren();const i={...a2(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.31.1"],["ARGUS","94b107ad · 2026-10-31 16:16Z"],["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 HK(){for(const t of document.querySelectorAll(".left-frame button, .left-frame-top button"))t.addEventListener("click",()=>Ri("audio2"))}let Qo=null;async function VK(t){let e=null;const s=await RO(t),i=s==="chris";document.body.dataset.composition=s;const n=new aj(document),r=i?Q$(Qe("index-instrument"),{dag_primary:()=>Et,dag_instances:()=>a.values("dag"),universes:()=>a.values("universe"),pacs:()=>D,runs_show:I=>q(I)}):{promptContext_take:()=>{},telemetry_take:()=>{},progress_take:()=>{}},o=new cj(Qe("lane-instrument"),void 0,I=>{Te.line_run(I)});window.setInterval(()=>o.tick(),500);const a=new w$;i&&z0(wj(()=>Z)),s==="stratus"&&z0(X$(()=>({...Z,controller_open:I=>$i.open(I)})));const l=new tj;l.writeObserver_set((I,W)=>{pt.regard_send({address:I.address,...I.modelKind!==void 0?{modelKind:I.modelKind}:{},groupId:W,paneId:I.paneId}),K()});const c={get layout(){return $},panels:a,paneInstance_get:Eh,subjects:l,get dormant(){return oe},sound:Ri,get terminal(){return Te},get client(){return pt}},h=Cj(c,{catalogue_find:I=>T.get(I),run_press:(I,W,pe)=>{ce(I,W,pe)}}),d=h.entry_show,u=I=>ag(I,t),p=p$(c,{vfsUrl_build:u,downloadUrl_build:I=>kO(I,t),image_open:(I,W)=>k(I,W),process_open:(I,W)=>B(I,W),run_press:(I,W,pe)=>{ce(I,W,pe)},cohort_gather:I=>ie(I),verbLine_run:(I,W)=>St(I,W),askOnPane_await:(I,W)=>P(I,W),binEntry_show:d,catalogue_find:I=>T.get(I),promptUser:()=>M,template_stamp:Xi,pane_find:Ys}),{previewProvider:f,fileText_fetch:_,file_save:g,rootedListing_show:m,listing_refresh:v,directory_make:y,files_deliver:b,filesBody_stamp:w,rowVerbs_build:z}=p,x=p.instance_build;let M=null,S=null;const T=new Map,{imageInstance_build:A,tagsInstance_build:E,tagsPane_follow:O,tagsPane_open:R,series_ask:C,image_open:k}=L$({client:()=>pt,terminal:()=>Te,panels:()=>a,subjects:()=>l,layout:()=>$,desktop:()=>re,instance_spawn:(I,W)=>Ie(I,W),errandHost_find:()=>H(),launcher_yield:()=>_e(),birth_record:(I,W,pe,Ee,Le)=>ge(I,W,pe,Ee,Le),vfsUrl_build:I=>u(I)}),B=(I,W)=>{_e();const pe=new Set($.panes_shown());for(const[ut,di]of T)if(pe.has(ut)&&di.input===W.input){$.focus_set(ut);return}const Ee=pe.has(I)?I:H()??I,Le=Ie("catalogue",I);if(!$.leaf_split(Ee,re.replayPlace_get()?.dir??"col",Le.id,re.replayPlace_get()?.before??!1)){As(Le.id),$.mount_remove(Le.id);return}ge(Le.id,Ee,re.replayPlace_get()?.dir??"col",re.replayPlace_get()?.before??!1),T.set(Le.id,W);const Mt=a.get("files",Le.id);Mt!==void 0&&(Mt.binding_set({input:W.input,place:W.feed===null?"new feed":`feed ${W.feed}${W.node===null?"":` · node ${W.node}`}`}),Mt.feedOpen_declare(ut=>X(Le.id,ut)),m(Le.id,Mt,"/bin"),ee(Mt),$.focus_set(Le.id))},L=5,U=40,ee=I=>{pt.line_execute(`plugininstance list --limit ${U} --fields id,plugin_name,plugin_version,owner_username`,{silent:!0,observe:!1}).then(pe=>{const Ee=[];for(const Le of pe.envelopes)if(!(Le.model?.kind!=="plugininstance.list"||!Array.isArray(Le.model.data)))for(const Mt of Le.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 ut=`${Mt.pluginName}-v${Mt.pluginVersion}`;if(Ee.includes(ut)||Ee.push(ut),Ee.length>=L)break}I.recent_set(Ee.length===0?null:Ee)}).catch(()=>{})},X=(I,W)=>{_e();const pe=new Set($.panes_shown());for(const[Mt,ut]of a.entries("dag"))if(Mt!=="dag"&&pe.has(Mt)&&ut.feed_get()===W){$.focus_set(Mt);return}const Ee=pe.has(I)?I:H()??I,Le=Ie("dag",I);if(!$.leaf_split(Ee,re.replayPlace_get()?.dir??"col",Le.id,re.replayPlace_get()?.before??!1)){As(Le.id),$.mount_remove(Le.id);return}ge(Le.id,Ee,re.replayPlace_get()?.dir??"col",re.replayPlace_get()?.before??!1),a.get("dag",Le.id)?.feed_enter(W)},ce=async(I,W,pe)=>{const Ee=T.get(I),Le=a.get("files",I);if(Ee===void 0||Le===void 0)return;const Mt=js=>{Te.output_write("err",`\x1B[31m${js}\x1B[0m
|
|
4391
|
+
`))}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=lK(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 oK){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 dK="argus.consoleMode",uK="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 fK(){try{localStorage.removeItem(dK)}catch{}}function pK(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 hK(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 fK(),a(i?"terminal":"transcript"),i||s.line_note(uK),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 f_(s,c,l)}finally{c.remove()}}}}const mK=new Set(["busy","asking","playing"]);function gK(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")?mK.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 Zr=()=>{};function Xw(){Zr(document.body.dataset.zoom==="console"?null:"console")}const _K=AO(),bK=DO(),MK=new URL("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNDAgMjkwIj4KPGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJnIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjQwIiB5MT0iMCIgeDI9IjIwMCIgeTI9IjIyNCI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjMmE2M2JmIi8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjN2FkM2YxIi8+PC9saW5lYXJHcmFkaWVudD4KPHJhZGlhbEdyYWRpZW50IGlkPSJoIj48c3RvcCBvZmZzZXQ9IjAiIHN0b3AtY29sb3I9IiM3YWQzZjEiIHN0b3Atb3BhY2l0eT0iMC40NSIvPjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzdhZDNmMSIgc3RvcC1vcGFjaXR5PSIwIi8+PC9yYWRpYWxHcmFkaWVudD48L2RlZnM+CjxjaXJjbGUgY3g9IjEyMCIgY3k9IjExMiIgcj0iMTA0IiBmaWxsPSJ1cmwoI2gpIi8+PHJlY3QgeD0iMjIuMCIgeT0iNDguMCIgd2lkdGg9IjE5NiIgaGVpZ2h0PSIxMjgiIHJ4PSI2NC4wIiBmaWxsPSJub25lIiBzdHJva2U9IiNjNzQ2MzQiIHN0cm9rZS13aWR0aD0iMTYiLz48bGluZSB4MT0iMTIwIiB5MT0iMTEyIiB4Mj0iMjE0IiB5Mj0iMjIiIHN0cm9rZT0iIzdhZDNmMSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtZGFzaGFycmF5PSIyIDUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgb3BhY2l0eT0iMC44Ii8+PGxpbmUgeDE9IjEyMCIgeTE9IjExMiIgeDI9IjI2IiB5Mj0iMjAyIiBzdHJva2U9IiM3YWQzZjEiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWRhc2hhcnJheT0iMiA1IiBzdHJva2UtbGluZWNhcD0icm91bmQiIG9wYWNpdHk9IjAuOCIvPjxwYXRoIGQ9Ik0yMTQsMC4wIEwyMTguNSwxNy41IEwyMzAuMCwyMiBMMjE4LjUsMjYuNSBMMjE0LDQ0LjAgTDIwOS41LDI2LjUgTDE5OC4wLDIyIEwyMDkuNSwxNy41WiIgZmlsbD0idXJsKCNnKSIvPjxwYXRoIGQ9Ik0yNiwxODguOCBMMjguNywxOTkuMyBMMzUuNiwyMDIgTDI4LjcsMjA0LjcgTDI2LDIxNS4yIEwyMy4zLDIwNC43IEwxNi40LDIwMiBMMjMuMywxOTkuM1oiIGZpbGw9InVybCgjZykiLz48cG9seWdvbiBwb2ludHM9IjEyMC4wLDExMi4wIDEwOC42LDg0LjYgMTIwLjAsMi4wIiBmaWxsPSJ1cmwoI2cpIi8+PHBvbHlnb24gcG9pbnRzPSIxMjAuMCwxMTIuMCAxMjAuMCwyLjAgMTMxLjQsODQuNiIgZmlsbD0idXJsKCNnKSIgZmlsbC1vcGFjaXR5PSIwLjciLz48cG9seWdvbiBwb2ludHM9IjEyMC4wLDExMi4wIDEzMS40LDg0LjYgMTUxLjEsODAuOSIgZmlsbD0idXJsKCNnKSIvPjxwb2x5Z29uIHBvaW50cz0iMTIwLjAsMTEyLjAgMTUxLjEsODAuOSAxNDcuNCwxMDAuNiIgZmlsbD0idXJsKCNnKSIgZmlsbC1vcGFjaXR5PSIwLjciLz48cG9seWdvbiBwb2ludHM9IjEyMC4wLDExMi4wIDE0Ny40LDEwMC42IDE5Mi4wLDExMi4wIiBmaWxsPSJ1cmwoI2cpIi8+PHBvbHlnb24gcG9pbnRzPSIxMjAuMCwxMTIuMCAxOTIuMCwxMTIuMCAxNDcuNCwxMjMuNCIgZmlsbD0idXJsKCNnKSIgZmlsbC1vcGFjaXR5PSIwLjciLz48cG9seWdvbiBwb2ludHM9IjEyMC4wLDExMi4wIDE0Ny40LDEyMy40IDE1MS4xLDE0My4xIiBmaWxsPSJ1cmwoI2cpIi8+PHBvbHlnb24gcG9pbnRzPSIxMjAuMCwxMTIuMCAxNTEuMSwxNDMuMSAxMzEuNCwxMzkuNCIgZmlsbD0idXJsKCNnKSIgZmlsbC1vcGFjaXR5PSIwLjciLz48cG9seWdvbiBwb2ludHM9IjEyMC4wLDExMi4wIDEzMS40LDEzOS40IDEyMC4wLDIyMi4wIiBmaWxsPSJ1cmwoI2cpIi8+PHBvbHlnb24gcG9pbnRzPSIxMjAuMCwxMTIuMCAxMjAuMCwyMjIuMCAxMDguNiwxMzkuNCIgZmlsbD0idXJsKCNnKSIgZmlsbC1vcGFjaXR5PSIwLjciLz48cG9seWdvbiBwb2ludHM9IjEyMC4wLDExMi4wIDEwOC42LDEzOS40IDg4LjksMTQzLjEiIGZpbGw9InVybCgjZykiLz48cG9seWdvbiBwb2ludHM9IjEyMC4wLDExMi4wIDg4LjksMTQzLjEgOTIuNiwxMjMuNCIgZmlsbD0idXJsKCNnKSIgZmlsbC1vcGFjaXR5PSIwLjciLz48cG9seWdvbiBwb2ludHM9IjEyMC4wLDExMi4wIDkyLjYsMTIzLjQgNDguMCwxMTIuMCIgZmlsbD0idXJsKCNnKSIvPjxwb2x5Z29uIHBvaW50cz0iMTIwLjAsMTEyLjAgNDguMCwxMTIuMCA5Mi42LDEwMC42IiBmaWxsPSJ1cmwoI2cpIiBmaWxsLW9wYWNpdHk9IjAuNyIvPjxwb2x5Z29uIHBvaW50cz0iMTIwLjAsMTEyLjAgOTIuNiwxMDAuNiA4OC45LDgwLjkiIGZpbGw9InVybCgjZykiLz48cG9seWdvbiBwb2ludHM9IjEyMC4wLDExMi4wIDg4LjksODAuOSAxMDguNiw4NC42IiBmaWxsPSJ1cmwoI2cpIiBmaWxsLW9wYWNpdHk9IjAuNyIvPgo8ZyBzdHJva2U9IiNmZmYiIHN0cm9rZS13aWR0aD0iMyIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBmaWxsPSJub25lIj48bGluZSB4MT0iMTIwIiB5MT0iMTEyIiB4Mj0iMTIwLjAiIHkyPSIxNy40Ii8+PGxpbmUgeDE9IjEyMCIgeTE9IjExMiIgeDI9IjE4MS45IiB5Mj0iMTEyLjAiLz48bGluZSB4MT0iMTIwIiB5MT0iMTEyIiB4Mj0iMTIwLjAiIHkyPSIyMDYuNiIvPjxsaW5lIHgxPSIxMjAiIHkxPSIxMTIiIHgyPSI1OC4xIiB5Mj0iMTEyLjAiLz48cG9seWdvbiBwb2ludHM9IjEzMS40LDg0LjYgMTQ3LjQsMTAwLjYgMTQ3LjQsMTIzLjQgMTMxLjQsMTM5LjQgMTA4LjYsMTM5LjQgOTIuNiwxMjMuNCA5Mi42LDEwMC42IDEwOC42LDg0LjYiLz48L2c+CjxnIGZpbGw9IiNmZmYiPjxjaXJjbGUgY3g9IjEyMCIgY3k9IjExMiIgcj0iMTAiLz48Y2lyY2xlIGN4PSIxMjAuMCIgY3k9IjUxLjUiIHI9IjQuNSIvPjxjaXJjbGUgY3g9IjE1OS42IiBjeT0iMTEyLjAiIHI9IjQuNSIvPjxjaXJjbGUgY3g9IjEyMC4wIiBjeT0iMTcyLjUiIHI9IjQuNSIvPjxjaXJjbGUgY3g9IjgwLjQiIGN5PSIxMTIuMCIgcj0iNC41Ii8+PGNpcmNsZSBjeD0iMTMxLjQiIGN5PSI4NC42IiByPSIzLjUiLz48Y2lyY2xlIGN4PSIxNDcuNCIgY3k9IjEwMC42IiByPSIzLjUiLz48Y2lyY2xlIGN4PSIxNDcuNCIgY3k9IjEyMy40IiByPSIzLjUiLz48Y2lyY2xlIGN4PSIxMzEuNCIgY3k9IjEzOS40IiByPSIzLjUiLz48Y2lyY2xlIGN4PSIxMDguNiIgY3k9IjEzOS40IiByPSIzLjUiLz48Y2lyY2xlIGN4PSI5Mi42IiBjeT0iMTIzLjQiIHI9IjMuNSIvPjxjaXJjbGUgY3g9IjkyLjYiIGN5PSIxMDAuNiIgcj0iMy41Ii8+PGNpcmNsZSBjeD0iMTA4LjYiIGN5PSI4NC42IiByPSIzLjUiLz48L2c+Cjx0ZXh0IHg9IjEyMCIgeT0iMjY4IiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBmb250LWZhbWlseT0iTW9udHNlcnJhdCxIZWx2ZXRpY2EsQXJpYWwsc2Fucy1zZXJpZiIgZm9udC13ZWlnaHQ9IjcwMCIgZm9udC1zaXplPSIzOCIgZmlsbD0iIzJhNjNiZiIgbGV0dGVyLXNwYWNpbmc9IjQiPk9DSSBURDwvdGV4dD4KPC9zdmc+",import.meta.url).href,vK=`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 Zw(t){for(const e of document.querySelectorAll('link[rel="icon"], link[rel="apple-touch-icon"]'))e.href=t}const wK="ARGUS",Jw="argus-audio",yK=.4;let ur=!1;const zK={audio1:{file:"press",cue:"press"},audio2:{file:"arrive",cue:"ack"},audio3:{file:"retreat",cue:"close"},audio4:{file:"refuse",cue:"deny"}},lO=new Set;function SK(){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"&&lO.add(s.replace(/\.[a-z0-9]+$/,""))}).catch(()=>{})}function Ri(t){if(ur)return;const e=zK[t];if(e!==void 0&&!lO.has(e.file)){Ni.cue_play(e.cue);return}const s=document.getElementById(t);s instanceof HTMLAudioElement&&(s.currentTime=0,s.volume=yK,s.play().catch(()=>{}))}function xK(){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 OK(){const t=Qe("audio-pill");try{ur=window.localStorage.getItem(Jw)==="off"}catch{ur=!1}const e=()=>{t.classList.toggle("audio-off",ur),Ni.muted_set(ur)};e(),SK(),t.addEventListener("click",()=>{ur=!ur;try{window.localStorage.setItem(Jw,ur?"off":"on")}catch{}e(),Ri("audio2")})}function EK(){return IO(window.location)}let Pf=null,vd=0;function D_(t,e){const s=()=>{e.dataset.zoom!==void 0||e.dataset.header==="away"||(vd=Math.ceil(t.offsetTop+t.offsetHeight),e.style.setProperty("--zoom-header-height",`${vd}px`))};s(),Pf===null&&(Pf=new ResizeObserver(s),Pf.observe(t))}const Qw=120,AK=96;function TK(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),Ri("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(Qw,window.innerHeight-AK),u=a+(h.clientY-o),p=Math.min(Math.max(Qw,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 DK(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,vd>0&&e.style.setProperty("--zoom-header-height",`${vd}px`)):s!==null&&D_(s,e),e.dataset.zoom=r;const a=Eh(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";Ri("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 IK(){const t=new pj(document.getElementById("data-cascade")),e=document.getElementById("header-telemetry");return e!==null&&t.telemetryPanel_bind(e),t}const Lf=96,CK=220,ey="argus.headerBand.height",RK=52;function kK(){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(Lf,window.innerHeight-CK),u=Math.min(Math.max(Lf,h),d);t.style.setProperty("--header-band-h",`${u}px`);try{window.localStorage.setItem(ey,String(u))}catch{}},n=(()=>{try{return window.localStorage.getItem(ey)}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-RK)}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?Lf: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 I_=null;function NK(t){const e=t.querySelector(".gather-rows");if(e===null)return;const s=ii(e,{rows:".listing-row",label:i=>`+${i} MORE · ON STAGE`,press:()=>{I_?.()},className:"strategy-pill gather-more",mount:t});s.title="the whole cohort as a pane on the main panel"}function ty(t){ii(t,{rows:".strategy-pill, .listing-action, .holder-mark",className:"frame-more"})}function BK(){const t=e=>{for(const s of e.querySelectorAll(".mode-frame:not([data-more])"))ty(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&&ty(i),t(i))}).observe(document.body,{childList:!0,subtree:!0}),t(document)}function sy(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 GK(){const t=document.body,e=document.querySelector(".wrap:not(#gap)"),s=r=>{t.dataset.header===r?(e!==null&&D_(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(),I_?.()}),i!==null&&NK(i),BK();const n=()=>{t.dataset.zoom===void 0&&(delete t.dataset.header,Ri("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 Jo=[{key:"lower-decks",label:"LOWER DECKS"},{key:"gold",label:"CERRITOS GOLD"},{key:"medical",label:"MEDICAL"},{key:"nemesis",label:"NEMESIS"},{key:"pharos",label:"PHAROS"}],cO="argus-landing",PK=15e3;function iy(){try{return(window.localStorage.getItem(cO)??"launcher")==="launcher"}catch{return!0}}function LK(t){try{window.localStorage.setItem(cO,t?"launcher":"last")}catch{}}const ny="argus-theme",WK="argus-lcars",FK="medical",UK={sickbay:"medical"};function $K(){const t=Qe("theme-pill"),e=Math.max(Jo.findIndex(r=>r.key===FK),0);let s=e;try{const r=window.localStorage.getItem(ny)??window.localStorage.getItem(WK),o=r===null?null:UK[r]??r,a=Jo.findIndex(l=>l.key===o);s=a>=0?a:e}catch{s=e}const i=document.documentElement,n=()=>{const r=Jo[s]??Jo[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)%Jo.length,n();try{window.localStorage.setItem(ny,Jo[s]?.key??"lower-decks")}catch{}Ri("audio2")})}function jK(t){const e=document.getElementById("about-rows");if(e===null)return;e.replaceChildren();const i={...a2(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.32.0"],["ARGUS","a863f341 · 2026-11-02 01:51Z"],["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 HK(){for(const t of document.querySelectorAll(".left-frame button, .left-frame-top button"))t.addEventListener("click",()=>Ri("audio2"))}let Qo=null;async function VK(t){let e=null;const s=await RO(t),i=s==="chris";document.body.dataset.composition=s;const n=new aj(document),r=i?Q$(Qe("index-instrument"),{dag_primary:()=>Et,dag_instances:()=>a.values("dag"),universes:()=>a.values("universe"),pacs:()=>D,runs_show:I=>q(I)}):{promptContext_take:()=>{},telemetry_take:()=>{},progress_take:()=>{}},o=new cj(Qe("lane-instrument"),void 0,I=>{Te.line_run(I)});window.setInterval(()=>o.tick(),500);const a=new w$;i&&z0(wj(()=>Z)),s==="stratus"&&z0(X$(()=>({...Z,controller_open:I=>$i.open(I)})));const l=new tj;l.writeObserver_set((I,W)=>{pt.regard_send({address:I.address,...I.modelKind!==void 0?{modelKind:I.modelKind}:{},groupId:W,paneId:I.paneId}),K()});const c={get layout(){return $},panels:a,paneInstance_get:Eh,subjects:l,get dormant(){return oe},sound:Ri,get terminal(){return Te},get client(){return pt}},h=Cj(c,{catalogue_find:I=>T.get(I),run_press:(I,W,pe)=>{ce(I,W,pe)}}),d=h.entry_show,u=I=>ag(I,t),p=p$(c,{vfsUrl_build:u,downloadUrl_build:I=>kO(I,t),image_open:(I,W)=>k(I,W),process_open:(I,W)=>B(I,W),run_press:(I,W,pe)=>{ce(I,W,pe)},cohort_gather:I=>ie(I),verbLine_run:(I,W)=>St(I,W),askOnPane_await:(I,W)=>P(I,W),binEntry_show:d,catalogue_find:I=>T.get(I),promptUser:()=>M,template_stamp:Xi,pane_find:Ys}),{previewProvider:f,fileText_fetch:_,file_save:g,rootedListing_show:m,listing_refresh:v,directory_make:y,files_deliver:b,filesBody_stamp:w,rowVerbs_build:z}=p,x=p.instance_build;let M=null,S=null;const T=new Map,{imageInstance_build:A,tagsInstance_build:E,tagsPane_follow:O,tagsPane_open:R,series_ask:C,image_open:k}=L$({client:()=>pt,terminal:()=>Te,panels:()=>a,subjects:()=>l,layout:()=>$,desktop:()=>re,instance_spawn:(I,W)=>Ie(I,W),errandHost_find:()=>H(),launcher_yield:()=>_e(),birth_record:(I,W,pe,Ee,Le)=>ge(I,W,pe,Ee,Le),vfsUrl_build:I=>u(I)}),B=(I,W)=>{_e();const pe=new Set($.panes_shown());for(const[ut,di]of T)if(pe.has(ut)&&di.input===W.input){$.focus_set(ut);return}const Ee=pe.has(I)?I:H()??I,Le=Ie("catalogue",I);if(!$.leaf_split(Ee,re.replayPlace_get()?.dir??"col",Le.id,re.replayPlace_get()?.before??!1)){As(Le.id),$.mount_remove(Le.id);return}ge(Le.id,Ee,re.replayPlace_get()?.dir??"col",re.replayPlace_get()?.before??!1),T.set(Le.id,W);const Mt=a.get("files",Le.id);Mt!==void 0&&(Mt.binding_set({input:W.input,place:W.feed===null?"new feed":`feed ${W.feed}${W.node===null?"":` · node ${W.node}`}`}),Mt.feedOpen_declare(ut=>X(Le.id,ut)),m(Le.id,Mt,"/bin"),ee(Mt),$.focus_set(Le.id))},L=5,U=40,ee=I=>{pt.line_execute(`plugininstance list --limit ${U} --fields id,plugin_name,plugin_version,owner_username`,{silent:!0,observe:!1}).then(pe=>{const Ee=[];for(const Le of pe.envelopes)if(!(Le.model?.kind!=="plugininstance.list"||!Array.isArray(Le.model.data)))for(const Mt of Le.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 ut=`${Mt.pluginName}-v${Mt.pluginVersion}`;if(Ee.includes(ut)||Ee.push(ut),Ee.length>=L)break}I.recent_set(Ee.length===0?null:Ee)}).catch(()=>{})},X=(I,W)=>{_e();const pe=new Set($.panes_shown());for(const[Mt,ut]of a.entries("dag"))if(Mt!=="dag"&&pe.has(Mt)&&ut.feed_get()===W){$.focus_set(Mt);return}const Ee=pe.has(I)?I:H()??I,Le=Ie("dag",I);if(!$.leaf_split(Ee,re.replayPlace_get()?.dir??"col",Le.id,re.replayPlace_get()?.before??!1)){As(Le.id),$.mount_remove(Le.id);return}ge(Le.id,Ee,re.replayPlace_get()?.dir??"col",re.replayPlace_get()?.before??!1),a.get("dag",Le.id)?.feed_enter(W)},ce=async(I,W,pe)=>{const Ee=T.get(I),Le=a.get("files",I);if(Ee===void 0||Le===void 0)return;const Mt=js=>{Te.output_write("err",`\x1B[31m${js}\x1B[0m
|
|
4392
4392
|
`);const Qd=Le.indicated_get();Qd!==null&&Le.rowReadout_show(Qd,js.toUpperCase().slice(0,80))};if(pe==="pipeline"&&Ee.node===null){Mt(`${W}: a pipeline runs on a node — PROCESS a node of a feed`);return}let ut=Le.commandLine_get();if((ut===""||uS(ut)!==W)&&(ut=cS(Ee.input,W)),Ee.feed===null&&!$B(ut)){const js=Ee.input.split("/").filter(Boolean).pop()??"feed",L_=(await P(I,{message:"Feed title: ",kind:"text",suggest:js,commit:"RUN"})??"").trim();if(L_==="")return;ut=jB(ut,L_)}Le.commandLine_set(ut),Te.line_echo(ut);let di;try{di=await pt.line_execute(ut,{silent:!0})}catch(js){Mt(js instanceof Error?js.message:String(js));return}Te.outcome_write(di),di.envelopes.some(js=>js.model?.kind==="fs.cwd")&&pt.line_execute("ls",{silent:!0});const nc=di.envelopes.find(js=>js.model?.kind==="run.scheduled"||js.model?.kind==="pipeline.scheduled")?.model?.data;if(typeof nc?.feedId=="number"){Le.run_show(nc.feedId);return}const G_=di.envelopes.map(js=>js.renderedErr??"").join(" ").replace(/\x1b\[[0-9;]*m/g,"").trim().split(`
|
|
4393
|
-
`)[0]??"",P_=Le.indicated_get();P_!==null&&Le.rowReadout_show(P_,G_===""?"NOT SCHEDULED":G_.toUpperCase().slice(0,80))},Oe=I=>{_e();const W=new Set($.panes_shown());for(const[ut]of a.entries("files"))if(W.has(ut)&&l.regard_get(ut)?.address===I){$.focus_set(ut);return}let pe;for(const[ut,di]of a.entries("image"))if(W.has(ut)&&(l.regard_get(ut)?.address===I||di.state_get()?.path===I)){pe=ut;break}const Ee=H();if(Ee===null)return;const Le=Ie("files",pe);if(!$.leaf_split(Ee,re.replayPlace_get()?.dir??"col",Le.id,re.replayPlace_get()?.before??!1)){As(Le.id),$.mount_remove(Le.id);return}ge(Le.id,Ee,re.replayPlace_get()?.dir??"col",re.replayPlace_get()?.before??!1),pe===void 0&&l.regard_write(Le.id,{address:I,modelKind:"dicom.series"});const Mt=a.get("files",Le.id);Mt!==void 0&&m(Le.id,Mt,I)},Ce=Lj(c,{image_open:(I,W)=>k(I,W),process_open:(I,W)=>B(I,W),feed_open:(I,W)=>X(I,W),askOnPane_await:(I,W)=>P(I,W),errandHost_find:()=>H(),instance_spawn:(I,W)=>Ie(I,W),birth_record:(I,W,pe,Ee)=>ge(I,W,pe,Ee),replayPlace_get:()=>re.replayPlace_get(),stage_relight:()=>K(),home_apply:()=>Fe(),orphans_dispose:()=>ve(),template_stamp:Xi,pane_find:Ys,element_require:Qe}),Ne=Ce.instance_build,ie=Ce.gather,ae=Ce.open,ue=I=>{const W=Xi("tpl-pane-view");ii(Ys(W,".view-body"));const pe=new ej(Ys(W,".view-body"),Ys(W,".view-title"),{content_fetch:async Ee=>(await _(Ee)).text,imageUrl_build:u,path_isImage:Dd});return a.set("view",I,pe),{id:I,kind:"view",mount:W,dispose:()=>{a.delete(I),l.pane_leave(I)}}},We=Rj(c,{filesBody_stamp:w,rootedListing_show:m,rowVerbs_build:z,image_open:(I,W)=>k(I,W),imagery_is:B1,tableFile_is:I=>N1.test(I),vfsUrl_build:u,fileText_fetch:_,previewProvider:f}),Ze=We.open;We.close;const qe=e$(c,{askOnPane_await:(I,W)=>P(I,W),promptUser:()=>M,changed:()=>{for(const I of a.values("dag"))I.roster_ask(),I.marks_refresh(),I.indicated_refresh()}}),yt=_$({client:()=>pt,terminal:()=>Te,panels:()=>a,subjects:()=>l,context:()=>c,feedVerbs:()=>qe,nodeOverlay:()=>We,nodeOverlay_open:(I,W)=>Ze(I,W),process_open:(I,W)=>B(I,W),promptUser:()=>M,runs_show:()=>q(),dag_primary:()=>Et,binEntry_show:(I,W,pe,Ee)=>d(I,W,pe,Ee),dag_summon:()=>Ue()}),Be=x("files",!0);Jc(Be);const vt=W$({panes:yt,dicom:{imageInstance_build:A,tagsInstance_build:E},gather_build:Ne,pacsMount:Qe("pacs-workspace")}),dt=i?vt:{primaries:[],domains:[],presets:[],factories:[]};for(const I of dt.primaries)Jc(I);for(const I of dt.domains)b$(I);const lt=Xi("tpl-pane-launcher");Jc({id:"launcher",kind:"launcher",mount:lt});const Wt=Xi("tpl-pane-panes");Jc({id:"panes",kind:"panes",mount:Wt});const is=a.get("files","files"),Et=a.get("dag","dag"),as=new _j(Qe("pipeline-cycler"),Qe("pipeline-cycler-name"),I=>{pt.line_execute(I,{silent:!0})});let Gt=null;const Ht=kj(c,{instance_spawn:(I,W)=>Ie(I,W),birth_record:(I,W,pe,Ee)=>ge(I,W,pe,Ee),replayPlace_get:()=>re.replayPlace_get(),rootedListing_show:m,console_expose:()=>Gt?.(!1),questionSheet_ask:I=>e!==null&&e.terminal_is()?e.question_sheet(I):null}),{errandHost_find:H,errand_open:Bs,verbLine_run:St,askOnPane_await:P}=Ht;ii(Qe("pacs-workspace"),{rows:".listing-row"});const D=new tG(Qe("pacs-workspace"),{command_run:I=>{const W=/^(pacs query|pull )/.test(I);W&&Te.line_echo(I),pt.line_execute(I,{silent:!0,operator:W}).then(pe=>{for(const Ee of pe.envelopes)D.envelope_observe(Ee)})},command_show:I=>{Te.line_run(I)},note:I=>Te.line_note(I),image_open:I=>{k(null,I).then(W=>Te.line_note(W))},dir_open:I=>Oe(I),process_open:I=>B("pacs",{input:I,feed:null,node:null}),gather_add:I=>ie([I]),gathered_is:I=>Ce.has(I),workspace_close:()=>Fe()}),K=()=>{const I=new Set($.panes_shown()),W=new Map;for(const pe of Ah()){if(!I.has(pe.id))continue;const Ee=l.regard_get(pe.id)?.address;if(Ee===void 0)continue;const Le=J(pe.id);if(Le!=="image"&&Le!=="files")continue;const Mt=Ee.replace(/\/$/,""),ut=W.get(Mt)??{viewer:!1,browser:!1};Le==="image"?ut.viewer=!0:ut.browser=!0,W.set(Mt,ut)}D.stage_lit(W)},$=new yj(Qe("layout-root"),new Map([...dt.primaries.map(I=>[I.id,I.mount]),["files",Be.mount],["launcher",lt],["panes",Wt]]));let ne=!1;const me=()=>ne?{dir:"col",ratio:.45,first:{pane:"files"},second:{pane:"dag"}}:{pane:"files"};$.preset_register("files",me);for(const[I,W]of dt.presets)$.preset_register(I,W);$.preset_register("panes",()=>({pane:"panes"})),$.preset_register("launcher",()=>({pane:"launcher"})),$.renderObserver_set(()=>{document.body.dataset.zoom==="launcher"&&!$.panes_shown().includes("launcher")&&Zr(null),window.requestAnimationFrame(()=>{for(const I of a.values("dag"))I.size_fit()})});const Me=(I,W,pe,Ee)=>{const Le=W==="view"?Ie("view",I):W==="fs"?Ie("files",I):Ie("empty");if(!$.leaf_split(I,pe,Le.id,Ee))return As(Le.id),$.mount_remove(Le.id),null;if(ge(Le.id,I,pe,Ee,W),W==="fs"){const Mt=di=>{const Jd=a.get("files",Le.id);if(Jd===void 0)return;const nc=di.modelKind==="fs.file"?di.address.replace(/\/[^/]*$/,"")||"/":di.address;m(Le.id,Jd,nc)};l.regard_subscribe(Le.id,Mt);const ut=l.regard_get(I);ut!==null&&Mt(ut)}return Le.id},oe=new mO(ry,oy());Object.assign(globalThis,{__argusDormant:{list:()=>oe.list(),get:I=>oe.get(I),dismiss:I=>oe.dismiss(I)}});const re=Oj(c,{image_open:k,dir_open:Oe,process_open:B,gather_open:ae,feed_open:X,edit_open:I=>Ba.edit_open(I),pillPane_spawn:Me,pacsQuery_get:()=>D.query_get(),catalogue_find:I=>T.get(I),catalogueIds:()=>[...T.keys()],stage_relight:()=>K()}),{birth_record:ge,domain_enter:Ge,orphans_dispose:ve}=re,we=re.capture,Ye=re.restore,Fe=()=>{Ge("files"),Et.size_fit()},nt=()=>{Ge("launcher"),ze.render(),$.focus_set("launcher"),Zr("launcher")},j=(I=!1)=>{if(document.body.dataset.zoom!=="launcher"||(Zr(null),!I))return;const W=document.querySelector(".wrap:not(#gap)");W!==null&&D_(W,document.body),document.body.dataset.header="away",Gt?.(!0)},_e=()=>{j(),$.activePreset_get()==="launcher"&&(ne=!1,Fe())};let he=!1;const ye=LB({ask:I=>pt.line_execute(I,{silent:!0,observe:!1}),home_open:()=>{ne=!1,Fe(),$.focus_set("files")},home_cd:I=>{ne=!1,Fe(),Te.line_run(`cd "${I}"`)},desktops:()=>oe.list(),desktop_restore:I=>{Ye(I)},panes_open:()=>{Ge("panes"),fe.render(),$.focus_set("panes")},keys_open:()=>{Fr()},notes_open:()=>{xo.open()},notes_latest:()=>xo.latest(),daemon_stale:()=>he,console_open:()=>Qe("gutter-console").click(),...i?{contribution:F$({ask:I=>pt.line_execute(I,{silent:!0,observe:!1}),universe_show:()=>te(),runs_show:I=>q(I),feed_enter:I=>{q(),a.get("dag","dag")?.feed_enter(I)},line_offer:I=>Te.line_offer(I),pacs_query:()=>D.query_get()??"",pacs_open:()=>{Ge("pacs"),$.focus_set("pacs")},cloud_enter:xa(window.location.search)?()=>{Qe("gutter-console").click(),Te.line_run("stratus oci")}:null})}:{},...s!=="stratus"?{}:{contribution:K$({ask:I=>pt.line_execute(I,{silent:!0,observe:!1}),domain_open:I=>{$i.open(I)},home_open:()=>{ne=!1,Fe(),$.focus_set("files")},line_run:I=>{Qe("gutter-console").click(),Te.line_run(I)},capacity_open:I=>{Na.open(I)},names_seen:I=>ka(I),repaint:()=>ze.render()})}}),ze=new bB(lt,{tiles:ye,leave:()=>j(!0),startHere_get:iy,startHere_set:LK});setInterval(()=>{$.activePreset_get()==="launcher"&&(!lt.isConnected||document.visibilityState!=="visible"||ze.render())},PK),ii(Ys(Wt,".panes-body"),{rows:".panes-card"});const fe=new zO(Wt,{list:()=>oe.list(),restore:I=>{Ye(I)},dismiss:I=>{oe.dismiss(I)}}),Ue=()=>{const I=$.activePreset_get();if(I==="pacs"||I==="dag"||I==="launcher"){ne=!0;return}ne&&I==="files"||(ne=!0,Fe())},Ie=(I,W)=>{const pe=v$(I);return l.pane_join(pe.id,W!==void 0?l.group_resolve(W):pe.id),I==="tags"&&l.regard_subscribe(pe.id,Ee=>{Ee.modelKind==="dicom.instance"&&O(pe.id,Ee.address)}),I==="view"&&(l.viewer_mark(pe.id),l.regard_subscribe(pe.id,Ee=>{Ee.modelKind!=="dicom.instance"&&a.get("view",pe.id)?.regard_show(Ee)})),$.mount_register(pe.id,pe.mount),Lr(pe.id,I,pe.mount),pe},{bar_note:Vt,move:Ct,flip:li,resize:ci,chordKeys_format:Zd}=Sj(c),Lr=ZH(c,{verbs:{move:Ct,chordKeys_format:Zd},browser:p,pillPane_spawn:Me,process_open:(I,W)=>B(I,W),overlay_back:I=>We.back(I),home_apply:()=>Fe(),orphans_dispose:()=>ve(),dag_dismiss:()=>{ne=!1}});Lr("files","files",Be.mount);for(const I of dt.primaries)Lr(I.id,I.kind,I.mount);Lr("launcher","launcher",lt),Lr("panes","panes",Wt);let Wr=!1;const Fi=I=>{Wr=I};for(const I of["click","focusin"])document.addEventListener(I,W=>{W.target instanceof Element&&(W.target.closest("#drawer")!==null?Wr=!0:W.target.closest("#layout-root")!==null&&(Wr=!1))});const ic=()=>{let I=!1;for(const W of document.querySelectorAll(".pane-drawer:not([hidden])"))W.hidden=!0,I=!0;return I},Da=()=>{let I=!1;for(const W of document.querySelectorAll('.workspace-pane[data-modes="open"], [data-frame-host][data-modes="open"]'))delete W.dataset.modes,I=!0;return D.serverStrip_isOpen()&&(D.serverStrip_close(),I=!0),I};document.addEventListener("click",I=>{if(!(I.target instanceof Element)||I.target.closest(".mode-frame")!==null&&I.target.closest(".mode-fill")===null||I.target.closest("#pacs-server-strip")!==null||I.target.closest("#pacs-f-server")!==null||I.target.closest(".listing-framed .listing-row, .ask-bar")!==null)return;const W=I.target.closest(".mode-strip"),pe=W?.closest(".workspace-pane, [data-frame-host]")??null,Ee=pe?.dataset.modes==="open",Le=Da();if(W!==null&&pe!==null&&!Ee){pe.dataset.modes="open",Ri("audio3");return}Le&&Ri("audio3")}),XH(c,{palette_isOpen:()=>!Se.hidden,palette_open:()=>$e(),palette_close:()=>Je(),errand_abandon:()=>Ht.errand_abandon(),dive_leave:()=>h.dive_leave(),overlay_escape:()=>We.escape(),drawers_close:ic,modeFrames_close:Da,consoleFocused:()=>Wr,console_release:()=>Fi(!1),verbs:{bar_note:Vt,flip:li,resize:ci},host:()=>Z,stage_alone:I=>{we(),$.tree_set({pane:I}),ve()},element_require:Qe});const Ui=new oG,nn=(I,W)=>{const pe=Ie(W);return $.leaf_replace(I,pe.id),As(I),$.mount_remove(I),pe};Ui.claim_add("fs.listing","files"),i&&aG(Ui,{dag_target:()=>{const I=$.focused_get();return I!==null&&a.has("dag",I)?a.get("dag",I):Et},dags:()=>[Et,...a.values("dag")],universes:()=>a.values("universe"),pacs:()=>D,pacs_present:()=>{$.preset_apply("pacs"),ve()},image_open:(I,W)=>{k($.focused_get(),I,W?{force:!0}:{}).then(pe=>Te.line_note(pe))},pane_replace:(I,W)=>nn(I,W).id,cohort_adopt:I=>Ce.envelope_observe(I),dag_get:I=>a.get("dag",I),image_get:I=>a.get("image",I),tags_get:I=>a.get("tags",I)});const Ia=(I,W,pe)=>{const Ee=Ui.claimer_get(W);if(Ee!==void 0){Ee(I,pe);return}const Le=nn(I,W),Mt=a.get("files",Le.id);for(const ut of pe)Mt?.envelope_observe(ut)},Qn={instance_spawn:Ie,birth_record:ge,launcher_yield:_e,launcher_active:()=>$.activePreset_get()==="launcher",template_stamp:Xi},Ca=$j(c,Qn),Fr=Ca.open,Ra=h6(c,Qn),$s=zH(c);function ka(I){Y$(I)&&c.client.claims_send(y0())}const $i=GH(c,I=>ka(I)),xo=UH(c,{...Qn,ask:I=>pt.line_execute(I,{silent:!0})}),Na=qH(c,{...Qn,ask:I=>pt.line_execute(I,{silent:!0})}),Ba=Fj(c,{...Qn,replayPlace_get:re.replayPlace_get,errandHost_find:H,saved:()=>{for(const I of a.values("dag"))I.marks_refresh()}});an("files",I=>x(I,!1)),an("catalogue",I=>x(I,!1,!0)),an("view",ue),an("help",Ca.instance_build),an("games",Ra.instance_build),an("notes",xo.instance_build),an("capacity",Na.instance_build),an("edit",Ba.instance_build);for(const[I,W]of dt.factories)an(I,W);an("empty",I=>{const W=Xi("tpl-pane-empty");return new nG(W,{execute:pe=>pt.line_execute(pe,{silent:!0,observe:!1}),claim:(pe,Ee)=>Ia(I,pe,Ee),claimKind_find:pe=>Ui.claimKind_find(pe)}),{id:I,kind:"empty",mount:W}});const Ga=I=>{I?document.body.dataset.gutter="away":delete document.body.dataset.gutter,Ri("audio3")},N=(I,W)=>{if($.activePreset_get()===I&&$.panes_shown().includes(I)){Ga(!0);return}document.body.dataset.gutter==="away"&&delete document.body.dataset.gutter,W()};Qe("gutter-restore").addEventListener("click",()=>Ga(!1)),window.addEventListener("keydown",I=>{I.key==="Escape"&&document.body.dataset.gutter==="away"&&document.body.dataset.zoom===void 0&&Ga(!1)}),Qe("gutter-files").addEventListener("click",()=>{N("files",()=>{ne=!1,Fe(),$.focus_set("files"),Fi(!1)})});const q=(I="")=>{Ge("dag"),Et.stage_returned(),Et.list_reset(),Et.roster_filter(I),Et.feedsChooser_request(),$.focus_set("dag"),Fi(!1)},te=()=>{Ge("universe");const I=a.get("universe","universe");I!==void 0&&!I.shown_get()&&I.request(),I?.stage_returned(),$.focus_set("universe"),Fi(!1)};Qe("gutter-runs").addEventListener("click",()=>N("dag",()=>q())),Qe("gutter-console").addEventListener("click",()=>{Qe("drawer").classList.contains("drawer-closed")&&Qe("drawer-toggle").click(),Te.focus_take(),Fi(!0)}),Qe("gutter-tools").addEventListener("click",()=>{N("pacs",()=>{Ge("pacs"),$.focus_set("pacs"),Fi(!1)})}),Qe("gutter-dashboard").addEventListener("click",()=>{N("launcher",nt)}),Qe("gutter-panes").addEventListener("click",()=>{N("panes",()=>{Ge("panes"),fe.render(),$.focus_set("panes"),Fi(!1)})});const J=I=>Eh(I)?.kind??null,Z=QH(c,{verbs:{move:Ct,flip:li,resize:ci},help_open:Fr,notes_open:xo.open,capacity_open:Na.open,launcher_enter:nt,trek_open:I=>$s.active_is()?"trek: the bridge is already up":($s.open(I),"trek: the bridge takes the screen (Esc or LEAVE BRIDGE gives it back)"),identity_get:()=>S,consoleZoom_toggle:Xw,feed_enter:I=>Et.feed_enter(I),file_save:g,stage_keep:()=>we(),files_open:(I,W)=>{const pe=a.get("files",I);return pe===void 0?!1:(p.follow_set(I,!1),m(I,pe,W),!0)},image_open:(I,W,pe)=>k(I,W,pe),series_ask:C,tagsPane_open:R}),Se=Qe("lang-palette"),Ae=Qe("lang-input"),xe=Qe("lang-result"),Pe=Qe("lang-pill"),$e=()=>{ic(),Se.hidden=!1,Pe.classList.add("lang-live"),xe.textContent="",Ae.value="",Ae.focus(),Ri("audio3")},Je=()=>{Se.hidden=!0,Pe.classList.remove("lang-live"),xe.textContent=""};Pe.addEventListener("click",()=>{Se.hidden?$e():Je()});const ot=["pane","view","runs","node","dag","file","pacs","header","console","back","desktop","argus","help","notes","capacity"],He={pane:["split","zoom","close","bind","claim","focus","flip","resize"],resize:["left","right","up","down"],help:["keys","verbs"],notes:["pane"],capacity:["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(Ae.addEventListener("keydown",I=>{if(I.key==="Escape"){I.stopPropagation(),Je();return}if(I.key==="Tab"){I.preventDefault();const W=Ae.value.split(/\s+/),pe=W[W.length-1]??"",Ee=W.length<=1?"":W[W.length-2]??"",Mt=(W.length<=1?ot:He[Ee]??He[W[0]??""]??[]).find(ut=>ut.startsWith(pe.toLowerCase()));Mt!==void 0&&(W[W.length-1]=Mt,Ae.value=`${W.join(" ")} `);return}if(I.key==="Enter"){const W=Ae.value.trim();if(W.length===0){Je();return}bh(Z,W).then(pe=>{pe!==null&&($s.active_is()||$i.active_is())?(Te.output_write("data",`: ${W}
|
|
4393
|
+
`)[0]??"",P_=Le.indicated_get();P_!==null&&Le.rowReadout_show(P_,G_===""?"NOT SCHEDULED":G_.toUpperCase().slice(0,80))},Oe=I=>{_e();const W=new Set($.panes_shown());for(const[ut]of a.entries("files"))if(W.has(ut)&&l.regard_get(ut)?.address===I){$.focus_set(ut);return}let pe;for(const[ut,di]of a.entries("image"))if(W.has(ut)&&(l.regard_get(ut)?.address===I||di.state_get()?.path===I)){pe=ut;break}const Ee=H();if(Ee===null)return;const Le=Ie("files",pe);if(!$.leaf_split(Ee,re.replayPlace_get()?.dir??"col",Le.id,re.replayPlace_get()?.before??!1)){As(Le.id),$.mount_remove(Le.id);return}ge(Le.id,Ee,re.replayPlace_get()?.dir??"col",re.replayPlace_get()?.before??!1),pe===void 0&&l.regard_write(Le.id,{address:I,modelKind:"dicom.series"});const Mt=a.get("files",Le.id);Mt!==void 0&&m(Le.id,Mt,I)},Ce=Lj(c,{image_open:(I,W)=>k(I,W),process_open:(I,W)=>B(I,W),feed_open:(I,W)=>X(I,W),askOnPane_await:(I,W)=>P(I,W),errandHost_find:()=>H(),instance_spawn:(I,W)=>Ie(I,W),birth_record:(I,W,pe,Ee)=>ge(I,W,pe,Ee),replayPlace_get:()=>re.replayPlace_get(),stage_relight:()=>K(),home_apply:()=>Fe(),orphans_dispose:()=>ve(),template_stamp:Xi,pane_find:Ys,element_require:Qe}),Ne=Ce.instance_build,ie=Ce.gather,ae=Ce.open,ue=I=>{const W=Xi("tpl-pane-view");ii(Ys(W,".view-body"));const pe=new ej(Ys(W,".view-body"),Ys(W,".view-title"),{content_fetch:async Ee=>(await _(Ee)).text,imageUrl_build:u,path_isImage:Dd});return a.set("view",I,pe),{id:I,kind:"view",mount:W,dispose:()=>{a.delete(I),l.pane_leave(I)}}},We=Rj(c,{filesBody_stamp:w,rootedListing_show:m,rowVerbs_build:z,image_open:(I,W)=>k(I,W),imagery_is:B1,tableFile_is:I=>N1.test(I),vfsUrl_build:u,fileText_fetch:_,previewProvider:f}),Ze=We.open;We.close;const qe=e$(c,{askOnPane_await:(I,W)=>P(I,W),promptUser:()=>M,changed:()=>{for(const I of a.values("dag"))I.roster_ask(),I.marks_refresh(),I.indicated_refresh()}}),yt=_$({client:()=>pt,terminal:()=>Te,panels:()=>a,subjects:()=>l,context:()=>c,feedVerbs:()=>qe,nodeOverlay:()=>We,nodeOverlay_open:(I,W)=>Ze(I,W),process_open:(I,W)=>B(I,W),promptUser:()=>M,runs_show:()=>q(),dag_primary:()=>Et,binEntry_show:(I,W,pe,Ee)=>d(I,W,pe,Ee),dag_summon:()=>Ue()}),Be=x("files",!0);Jc(Be);const vt=W$({panes:yt,dicom:{imageInstance_build:A,tagsInstance_build:E},gather_build:Ne,pacsMount:Qe("pacs-workspace")}),dt=i?vt:{primaries:[],domains:[],presets:[],factories:[]};for(const I of dt.primaries)Jc(I);for(const I of dt.domains)b$(I);const lt=Xi("tpl-pane-launcher");Jc({id:"launcher",kind:"launcher",mount:lt});const Wt=Xi("tpl-pane-panes");Jc({id:"panes",kind:"panes",mount:Wt});const is=a.get("files","files"),Et=a.get("dag","dag"),as=new _j(Qe("pipeline-cycler"),Qe("pipeline-cycler-name"),I=>{pt.line_execute(I,{silent:!0})});let Gt=null;const Ht=kj(c,{instance_spawn:(I,W)=>Ie(I,W),birth_record:(I,W,pe,Ee)=>ge(I,W,pe,Ee),replayPlace_get:()=>re.replayPlace_get(),rootedListing_show:m,console_expose:()=>Gt?.(!1),questionSheet_ask:I=>e!==null&&e.terminal_is()?e.question_sheet(I):null}),{errandHost_find:H,errand_open:Bs,verbLine_run:St,askOnPane_await:P}=Ht;ii(Qe("pacs-workspace"),{rows:".listing-row"});const D=new tG(Qe("pacs-workspace"),{command_run:I=>{const W=/^(pacs query|pull )/.test(I);W&&Te.line_echo(I),pt.line_execute(I,{silent:!0,operator:W}).then(pe=>{for(const Ee of pe.envelopes)D.envelope_observe(Ee)})},command_show:I=>{Te.line_run(I)},note:I=>Te.line_note(I),image_open:I=>{k(null,I).then(W=>Te.line_note(W))},dir_open:I=>Oe(I),process_open:I=>B("pacs",{input:I,feed:null,node:null}),gather_add:I=>ie([I]),gathered_is:I=>Ce.has(I),workspace_close:()=>Fe()}),K=()=>{const I=new Set($.panes_shown()),W=new Map;for(const pe of Ah()){if(!I.has(pe.id))continue;const Ee=l.regard_get(pe.id)?.address;if(Ee===void 0)continue;const Le=J(pe.id);if(Le!=="image"&&Le!=="files")continue;const Mt=Ee.replace(/\/$/,""),ut=W.get(Mt)??{viewer:!1,browser:!1};Le==="image"?ut.viewer=!0:ut.browser=!0,W.set(Mt,ut)}D.stage_lit(W)},$=new yj(Qe("layout-root"),new Map([...dt.primaries.map(I=>[I.id,I.mount]),["files",Be.mount],["launcher",lt],["panes",Wt]]));let ne=!1;const me=()=>ne?{dir:"col",ratio:.45,first:{pane:"files"},second:{pane:"dag"}}:{pane:"files"};$.preset_register("files",me);for(const[I,W]of dt.presets)$.preset_register(I,W);$.preset_register("panes",()=>({pane:"panes"})),$.preset_register("launcher",()=>({pane:"launcher"})),$.renderObserver_set(()=>{document.body.dataset.zoom==="launcher"&&!$.panes_shown().includes("launcher")&&Zr(null),window.requestAnimationFrame(()=>{for(const I of a.values("dag"))I.size_fit()})});const Me=(I,W,pe,Ee)=>{const Le=W==="view"?Ie("view",I):W==="fs"?Ie("files",I):Ie("empty");if(!$.leaf_split(I,pe,Le.id,Ee))return As(Le.id),$.mount_remove(Le.id),null;if(ge(Le.id,I,pe,Ee,W),W==="fs"){const Mt=di=>{const Jd=a.get("files",Le.id);if(Jd===void 0)return;const nc=di.modelKind==="fs.file"?di.address.replace(/\/[^/]*$/,"")||"/":di.address;m(Le.id,Jd,nc)};l.regard_subscribe(Le.id,Mt);const ut=l.regard_get(I);ut!==null&&Mt(ut)}return Le.id},oe=new mO(ry,oy());Object.assign(globalThis,{__argusDormant:{list:()=>oe.list(),get:I=>oe.get(I),dismiss:I=>oe.dismiss(I)}});const re=Oj(c,{image_open:k,dir_open:Oe,process_open:B,gather_open:ae,feed_open:X,edit_open:I=>Ba.edit_open(I),pillPane_spawn:Me,pacsQuery_get:()=>D.query_get(),catalogue_find:I=>T.get(I),catalogueIds:()=>[...T.keys()],stage_relight:()=>K()}),{birth_record:ge,domain_enter:Ge,orphans_dispose:ve}=re,we=re.capture,Ye=re.restore,Fe=()=>{Ge("files"),Et.size_fit()},nt=()=>{Ge("launcher"),ze.render(),$.focus_set("launcher"),Zr("launcher")},j=(I=!1)=>{if(document.body.dataset.zoom!=="launcher"||(Zr(null),!I))return;const W=document.querySelector(".wrap:not(#gap)");W!==null&&D_(W,document.body),document.body.dataset.header="away",Gt?.(!0)},_e=()=>{j(),$.activePreset_get()==="launcher"&&(ne=!1,Fe())};let he=!1;const ye=LB({ask:I=>pt.line_execute(I,{silent:!0,observe:!1}),home_open:()=>{ne=!1,Fe(),$.focus_set("files")},home_cd:I=>{ne=!1,Fe(),Te.line_run(`cd "${I}"`)},desktops:()=>oe.list(),desktop_restore:I=>{Ye(I)},panes_open:()=>{Ge("panes"),fe.render(),$.focus_set("panes")},keys_open:()=>{Fr()},notes_open:()=>{xo.open()},notes_latest:()=>xo.latest(),daemon_stale:()=>he,console_open:()=>Qe("gutter-console").click(),...i?{contribution:F$({ask:I=>pt.line_execute(I,{silent:!0,observe:!1}),universe_show:()=>te(),runs_show:I=>q(I),feed_enter:I=>{q(),a.get("dag","dag")?.feed_enter(I)},line_offer:I=>Te.line_offer(I),pacs_query:()=>D.query_get()??"",pacs_open:()=>{Ge("pacs"),$.focus_set("pacs")},cloud_enter:xa(window.location.search)?()=>{Qe("gutter-console").click(),Te.line_run("stratus oci")}:null})}:{},...s!=="stratus"?{}:{contribution:K$({ask:I=>pt.line_execute(I,{silent:!0,observe:!1}),cluster_open:I=>{$i.open(I)},home_open:()=>{ne=!1,Fe(),$.focus_set("files")},line_run:I=>{Qe("gutter-console").click(),Te.line_run(I)},capacity_open:I=>{Na.open(I)},names_seen:I=>ka(I),repaint:()=>ze.render()})}}),ze=new bB(lt,{tiles:ye,leave:()=>j(!0),startHere_get:iy,startHere_set:LK});setInterval(()=>{$.activePreset_get()==="launcher"&&(!lt.isConnected||document.visibilityState!=="visible"||ze.render())},PK),ii(Ys(Wt,".panes-body"),{rows:".panes-card"});const fe=new zO(Wt,{list:()=>oe.list(),restore:I=>{Ye(I)},dismiss:I=>{oe.dismiss(I)}}),Ue=()=>{const I=$.activePreset_get();if(I==="pacs"||I==="dag"||I==="launcher"){ne=!0;return}ne&&I==="files"||(ne=!0,Fe())},Ie=(I,W)=>{const pe=v$(I);return l.pane_join(pe.id,W!==void 0?l.group_resolve(W):pe.id),I==="tags"&&l.regard_subscribe(pe.id,Ee=>{Ee.modelKind==="dicom.instance"&&O(pe.id,Ee.address)}),I==="view"&&(l.viewer_mark(pe.id),l.regard_subscribe(pe.id,Ee=>{Ee.modelKind!=="dicom.instance"&&a.get("view",pe.id)?.regard_show(Ee)})),$.mount_register(pe.id,pe.mount),Lr(pe.id,I,pe.mount),pe},{bar_note:Vt,move:Ct,flip:li,resize:ci,chordKeys_format:Zd}=Sj(c),Lr=ZH(c,{verbs:{move:Ct,chordKeys_format:Zd},browser:p,pillPane_spawn:Me,process_open:(I,W)=>B(I,W),overlay_back:I=>We.back(I),home_apply:()=>Fe(),orphans_dispose:()=>ve(),dag_dismiss:()=>{ne=!1}});Lr("files","files",Be.mount);for(const I of dt.primaries)Lr(I.id,I.kind,I.mount);Lr("launcher","launcher",lt),Lr("panes","panes",Wt);let Wr=!1;const Fi=I=>{Wr=I};for(const I of["click","focusin"])document.addEventListener(I,W=>{W.target instanceof Element&&(W.target.closest("#drawer")!==null?Wr=!0:W.target.closest("#layout-root")!==null&&(Wr=!1))});const ic=()=>{let I=!1;for(const W of document.querySelectorAll(".pane-drawer:not([hidden])"))W.hidden=!0,I=!0;return I},Da=()=>{let I=!1;for(const W of document.querySelectorAll('.workspace-pane[data-modes="open"], [data-frame-host][data-modes="open"]'))delete W.dataset.modes,I=!0;return D.serverStrip_isOpen()&&(D.serverStrip_close(),I=!0),I};document.addEventListener("click",I=>{if(!(I.target instanceof Element)||I.target.closest(".mode-frame")!==null&&I.target.closest(".mode-fill")===null||I.target.closest("#pacs-server-strip")!==null||I.target.closest("#pacs-f-server")!==null||I.target.closest(".listing-framed .listing-row, .ask-bar")!==null)return;const W=I.target.closest(".mode-strip"),pe=W?.closest(".workspace-pane, [data-frame-host]")??null,Ee=pe?.dataset.modes==="open",Le=Da();if(W!==null&&pe!==null&&!Ee){pe.dataset.modes="open",Ri("audio3");return}Le&&Ri("audio3")}),XH(c,{palette_isOpen:()=>!Se.hidden,palette_open:()=>$e(),palette_close:()=>Je(),errand_abandon:()=>Ht.errand_abandon(),dive_leave:()=>h.dive_leave(),overlay_escape:()=>We.escape(),drawers_close:ic,modeFrames_close:Da,consoleFocused:()=>Wr,console_release:()=>Fi(!1),verbs:{bar_note:Vt,flip:li,resize:ci},host:()=>Z,stage_alone:I=>{we(),$.tree_set({pane:I}),ve()},element_require:Qe});const Ui=new oG,nn=(I,W)=>{const pe=Ie(W);return $.leaf_replace(I,pe.id),As(I),$.mount_remove(I),pe};Ui.claim_add("fs.listing","files"),i&&aG(Ui,{dag_target:()=>{const I=$.focused_get();return I!==null&&a.has("dag",I)?a.get("dag",I):Et},dags:()=>[Et,...a.values("dag")],universes:()=>a.values("universe"),pacs:()=>D,pacs_present:()=>{$.preset_apply("pacs"),ve()},image_open:(I,W)=>{k($.focused_get(),I,W?{force:!0}:{}).then(pe=>Te.line_note(pe))},pane_replace:(I,W)=>nn(I,W).id,cohort_adopt:I=>Ce.envelope_observe(I),dag_get:I=>a.get("dag",I),image_get:I=>a.get("image",I),tags_get:I=>a.get("tags",I)});const Ia=(I,W,pe)=>{const Ee=Ui.claimer_get(W);if(Ee!==void 0){Ee(I,pe);return}const Le=nn(I,W),Mt=a.get("files",Le.id);for(const ut of pe)Mt?.envelope_observe(ut)},Qn={instance_spawn:Ie,birth_record:ge,launcher_yield:_e,launcher_active:()=>$.activePreset_get()==="launcher",template_stamp:Xi},Ca=$j(c,Qn),Fr=Ca.open,Ra=h6(c,Qn),$s=zH(c);function ka(I){Y$(I)&&c.client.claims_send(y0())}const $i=GH(c,I=>ka(I)),xo=UH(c,{...Qn,ask:I=>pt.line_execute(I,{silent:!0})}),Na=qH(c,{...Qn,ask:I=>pt.line_execute(I,{silent:!0})}),Ba=Fj(c,{...Qn,replayPlace_get:re.replayPlace_get,errandHost_find:H,saved:()=>{for(const I of a.values("dag"))I.marks_refresh()}});an("files",I=>x(I,!1)),an("catalogue",I=>x(I,!1,!0)),an("view",ue),an("help",Ca.instance_build),an("games",Ra.instance_build),an("notes",xo.instance_build),an("capacity",Na.instance_build),an("edit",Ba.instance_build);for(const[I,W]of dt.factories)an(I,W);an("empty",I=>{const W=Xi("tpl-pane-empty");return new nG(W,{execute:pe=>pt.line_execute(pe,{silent:!0,observe:!1}),claim:(pe,Ee)=>Ia(I,pe,Ee),claimKind_find:pe=>Ui.claimKind_find(pe)}),{id:I,kind:"empty",mount:W}});const Ga=I=>{I?document.body.dataset.gutter="away":delete document.body.dataset.gutter,Ri("audio3")},N=(I,W)=>{if($.activePreset_get()===I&&$.panes_shown().includes(I)){Ga(!0);return}document.body.dataset.gutter==="away"&&delete document.body.dataset.gutter,W()};Qe("gutter-restore").addEventListener("click",()=>Ga(!1)),window.addEventListener("keydown",I=>{I.key==="Escape"&&document.body.dataset.gutter==="away"&&document.body.dataset.zoom===void 0&&Ga(!1)}),Qe("gutter-files").addEventListener("click",()=>{N("files",()=>{ne=!1,Fe(),$.focus_set("files"),Fi(!1)})});const q=(I="")=>{Ge("dag"),Et.stage_returned(),Et.list_reset(),Et.roster_filter(I),Et.feedsChooser_request(),$.focus_set("dag"),Fi(!1)},te=()=>{Ge("universe");const I=a.get("universe","universe");I!==void 0&&!I.shown_get()&&I.request(),I?.stage_returned(),$.focus_set("universe"),Fi(!1)};Qe("gutter-runs").addEventListener("click",()=>N("dag",()=>q())),Qe("gutter-console").addEventListener("click",()=>{Qe("drawer").classList.contains("drawer-closed")&&Qe("drawer-toggle").click(),Te.focus_take(),Fi(!0)}),Qe("gutter-tools").addEventListener("click",()=>{N("pacs",()=>{Ge("pacs"),$.focus_set("pacs"),Fi(!1)})}),Qe("gutter-dashboard").addEventListener("click",()=>{N("launcher",nt)}),Qe("gutter-panes").addEventListener("click",()=>{N("panes",()=>{Ge("panes"),fe.render(),$.focus_set("panes"),Fi(!1)})});const J=I=>Eh(I)?.kind??null,Z=QH(c,{verbs:{move:Ct,flip:li,resize:ci},help_open:Fr,notes_open:xo.open,capacity_open:Na.open,launcher_enter:nt,trek_open:I=>$s.active_is()?"trek: the bridge is already up":($s.open(I),"trek: the bridge takes the screen (Esc or LEAVE BRIDGE gives it back)"),identity_get:()=>S,consoleZoom_toggle:Xw,feed_enter:I=>Et.feed_enter(I),file_save:g,stage_keep:()=>we(),files_open:(I,W)=>{const pe=a.get("files",I);return pe===void 0?!1:(p.follow_set(I,!1),m(I,pe,W),!0)},image_open:(I,W,pe)=>k(I,W,pe),series_ask:C,tagsPane_open:R}),Se=Qe("lang-palette"),Ae=Qe("lang-input"),xe=Qe("lang-result"),Pe=Qe("lang-pill"),$e=()=>{ic(),Se.hidden=!1,Pe.classList.add("lang-live"),xe.textContent="",Ae.value="",Ae.focus(),Ri("audio3")},Je=()=>{Se.hidden=!0,Pe.classList.remove("lang-live"),xe.textContent=""};Pe.addEventListener("click",()=>{Se.hidden?$e():Je()});const ot=["pane","view","runs","node","dag","file","pacs","header","console","back","desktop","argus","help","notes","capacity"],He={pane:["split","zoom","close","bind","claim","focus","flip","resize"],resize:["left","right","up","down"],help:["keys","verbs"],notes:["pane"],capacity:["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(Ae.addEventListener("keydown",I=>{if(I.key==="Escape"){I.stopPropagation(),Je();return}if(I.key==="Tab"){I.preventDefault();const W=Ae.value.split(/\s+/),pe=W[W.length-1]??"",Ee=W.length<=1?"":W[W.length-2]??"",Mt=(W.length<=1?ot:He[Ee]??He[W[0]??""]??[]).find(ut=>ut.startsWith(pe.toLowerCase()));Mt!==void 0&&(W[W.length-1]=Mt,Ae.value=`${W.join(" ")} `);return}if(I.key==="Enter"){const W=Ae.value.trim();if(W.length===0){Je();return}bh(Z,W).then(pe=>{pe!==null&&($s.active_is()||$i.active_is())?(Te.output_write("data",`: ${W}
|
|
4394
4394
|
${pe}
|
|
4395
4395
|
`),Je()):pe!==null?(xe.textContent=pe,Te.output_write("data",`: ${W}
|
|
4396
4396
|
${pe}
|