@huynle/hub 0.8.4 → 0.8.6
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/CHANGELOG.md +55 -0
- package/README.md +40 -3
- package/package.json +1 -1
- package/packages/claude-code/package.json +1 -1
- package/packages/cli/dist/hub-cli.js +5288 -4415
- package/packages/cli/package.json +1 -1
- package/packages/cli/src/bootstrap/PHASE2-CONTRACT.md +87 -0
- package/packages/cli/src/bootstrap/adapters/claude/node.ts +11 -43
- package/packages/cli/src/bootstrap/adapters/codex/verify.ts +19 -12
- package/packages/cli/src/bootstrap/adapters/opencode/README.md +42 -6
- package/packages/cli/src/bootstrap/adapters/opencode/apply.ts +18 -7
- package/packages/cli/src/bootstrap/adapters/opencode/archive.ts +36 -19
- package/packages/cli/src/bootstrap/adapters/opencode/config.ts +19 -3
- package/packages/cli/src/bootstrap/adapters/opencode/index.ts +2 -5
- package/packages/cli/src/bootstrap/adapters/opencode/plan.ts +37 -6
- package/packages/cli/src/bootstrap/adapters/opencode/verify.ts +49 -26
- package/packages/cli/src/bootstrap/adapters/process-tree.ts +263 -0
- package/packages/cli/src/bootstrap/contracts/paths.ts +7 -4
- package/packages/cli/src/bootstrap/contracts/platform.ts +9 -5
- package/packages/cli/src/bootstrap/contracts/validate.ts +20 -4
- package/packages/cli/src/bootstrap/discovery/discover.ts +3 -1
- package/packages/cli/src/bootstrap/discovery/executables.ts +49 -14
- package/packages/cli/src/bootstrap/discovery/host.ts +16 -8
- package/packages/cli/src/bootstrap/discovery/node-probe.ts +41 -5
- package/packages/cli/src/bootstrap/discovery/probe.ts +7 -3
- package/packages/cli/src/bootstrap/discovery/util.ts +42 -5
- package/packages/cli/src/bootstrap/enrollment/store.ts +13 -6
- package/packages/cli/src/bootstrap/preview/plan.ts +3 -0
- package/packages/cli/src/bootstrap/profiles/desired.ts +10 -3
- package/packages/cli/src/bootstrap/release/README.md +63 -9
- package/packages/cli/src/bootstrap/release/cli.ts +94 -16
- package/packages/cli/src/bootstrap/release/harness-pins.pending.json +24 -0
- package/packages/cli/src/bootstrap/release/manifest.ts +3 -0
- package/packages/cli/src/bootstrap/release/pins.ts +60 -9
- package/packages/cli/src/bootstrap/transaction/builtin.ts +18 -6
- package/packages/cli/src/bootstrap/transaction/engine.ts +166 -12
- package/packages/cli/src/bootstrap/transaction/executor.ts +5 -0
- package/packages/cli/src/bootstrap/transaction/fs.ts +142 -3
- package/packages/cli/src/bootstrap/transaction/shim.ts +31 -0
- package/packages/cli/src/bootstrap/transaction/state.ts +11 -6
- package/packages/cli/src/credentials.ts +5 -2
- package/packages/cli/src/main.ts +3 -2
- package/packages/cli/src/setup/commands.ts +96 -18
- package/packages/cli/src/setup/contributors.ts +45 -10
- package/packages/cli/src/setup/runtime.ts +25 -6
- package/packages/cli/src/setup/self-aside.ts +130 -0
- package/packages/codex/package.json +1 -1
- package/packages/node/package.json +1 -1
- package/packages/node/src/opencode-warm.ts +12 -4
- package/packages/preset/package.json +1 -1
- package/packages/protocol/package.json +1 -1
- package/packages/runtime-openshell/package.json +1 -1
- package/packages/runtime-sdk/package.json +1 -1
- package/packages/sdk/package.json +1 -1
- package/packages/spoke-sdk/package.json +1 -1
- package/src/central/config.ts +12 -0
- package/src/central/http.ts +10 -0
- package/src/central/install/CONTRACT.md +66 -0
- package/src/central/install/install.ps1 +349 -0
- package/src/central/install/install.sh +266 -0
- package/src/central/install/render.ts +146 -0
- package/src/central/install/templates.ts +6 -0
- package/src/central/install/text-assets.d.ts +9 -0
- package/src/config.ts +12 -7
- package/src/spoke/env-inject.ts +17 -2
- package/src/spoke/herdr.ts +3 -2
- package/src/spoke/launchers.ts +145 -9
- package/src/spoke/localhub.ts +1 -0
- package/src/win-acl.ts +154 -0
- package/web/dist/assets/ArtifactPage-Dq7VW-bU.js +1 -0
- package/web/dist/assets/{ArtifactPane-XTnwXl-Y.js → ArtifactPane-DKwbMTX9.js} +1 -1
- package/web/dist/assets/ArtifactWorkbench-vrgIfncX.js +6 -0
- package/web/dist/assets/Library-D6-Go6Cu.js +2 -0
- package/web/dist/assets/{ProfilesDestination-dZa3vioh.js → ProfilesDestination-BOML2Dgf.js} +1 -1
- package/web/dist/assets/{TeamsPage-DJt-Kk84.js → TeamsPage-CNBTE8gB.js} +1 -1
- package/web/dist/assets/Watchtower-Dor1Ubjy.js +2 -0
- package/web/dist/assets/Watchtower-RphjcL0_.css +1 -0
- package/web/dist/assets/hub-CrbItiwP.js +13 -0
- package/web/dist/assets/index-82Ce0IAf.css +1 -0
- package/web/dist/assets/index-D9SP3_0z.js +22 -0
- package/web/dist/assets/{live-D-RZbeUi.js → live-BNJgy0vg.js} +3 -3
- package/web/dist/assets/{pane-layout-Csk-vPNe.js → pane-layout-EdR1kRrG.js} +1 -1
- package/web/dist/assets/preload-helper-DqrJTq0t.js +1 -0
- package/web/dist/assets/{renderer2d-DILxLFEq.js → renderer2d-CYag1CnR.js} +1 -1
- package/web/dist/assets/{renderer3d-PvN9Qbt2.js → renderer3d-BRB6rgDJ.js} +1 -1
- package/web/dist/assets/{safe-area-BS6ii3M7.js → safe-area-fOy0AOuG.js} +1 -1
- package/web/dist/assets/{source-BFLJQ43_.js → source-Wbq35qGp.js} +1 -1
- package/web/dist/assets/{ui-Qo2Pd9-O.js → ui-j5FFk90B.js} +1 -1
- package/web/dist/index.html +6 -4
- package/web/dist/assets/ArtifactPage-Cb1DcrQf.js +0 -1
- package/web/dist/assets/ArtifactWorkbench-C37tZZ3e.js +0 -6
- package/web/dist/assets/Library-CZSSHvOJ.js +0 -2
- package/web/dist/assets/Watchtower-BXaUaXO1.js +0 -2
- package/web/dist/assets/Watchtower-CTgqHk5g.css +0 -1
- package/web/dist/assets/index-DVSkeAvn.css +0 -1
- package/web/dist/assets/index-DifgVuKS.js +0 -34
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{$ as e,At as t,Ct as n,Et as r,G as i,Ht as a,Lt as o,Mt as s,Nt as c,Ot as l,Pt as u,Tt as d,Ut as f,Vt as p,Wt as m,a as h,bt as g,dt as _,ft as v,g as y,gt as b,ht as x,i as S,it as C,lt as w,nt as T,pt as E,q as D,r as O,st as k,tt as A,u as j,ut as M,vt as N,wt as P,yt as F}from"./ui-Qo2Pd9-O.js";import{A as I,O as L,P as R,U as z,V as ee,k as te,z as ne}from"./index-DifgVuKS.js";import{c as re,d as ie,f as ae,i as oe,l as se,n as ce,r as le,t as ue,u as de}from"./source-BFLJQ43_.js";var fe=`ai-actions`,B=16,pe=[`ask`,`propose-edit`,`run-action`],me=[`queued`,`running`,`succeeded`,`failed`,`cancelled`],he=[`starting`,`waiting`,`offline`,`ready`,`ended`,`failed`],ge=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/,V=e=>typeof e==`object`&&!!e&&!Array.isArray(e),H=e=>typeof e==`string`&&e.length>0,U=e=>typeof e==`number`&&Number.isFinite(e),_e=(e,t)=>typeof t==`string`&&e.includes(t),ve=e=>e.replace(/\/+$/,``).split(`/`).pop()||e;function ye(e){if(V(e)&&_e(he,e.status)){if(e.kind===`session`&&H(e.address))return e;if(e.kind===`launch`&&H(e.machine)&&H(e.repo))return{harness:``,mode:`checkout`,...e}}}function be(e){if(!V(e)||!_e([`pending`,`applied`,`conflict`],e.state)||!Array.isArray(e.files))return;let t=e.files.filter(e=>V(e)&&H(e.mediaType)&&U(e.bytes)&&H(e.hash));return{state:e.state,files:t,...Array.isArray(e.keep)?{keep:e.keep.filter(H)}:{},...H(e.entry)?{entry:e.entry}:{},...H(e.appliedRevisionID)?{appliedRevisionID:e.appliedRevisionID}:{}}}function xe(e){if(!V(e)||!H(e.id)||!H(e.artifactID)||!H(e.baseRevisionID)||!U(e.revision)||!_e(me,e.state)||!_e(pe,e.kind)||typeof e.instruction!=`string`||!H(e.by)||!U(e.createdAt)||!U(e.updatedAt))return;let t=ye(e.handler);if(!t)return;let n=be(e.proposal),{proposal:r,...i}=e;return{...i,handler:t,...n?{proposal:n}:{},...typeof e.answer==`string`?{answer:e.answer}:{},...typeof e.error==`string`?{error:e.error}:{}}}function Se(e){let t=V(e)?e:{};return{items:Array.isArray(t.items)?t.items.flatMap(e=>xe(e)??[]):[],...H(t.cursor)?{cursor:t.cursor}:{}}}function Ce(e){let t=e?.[fe];return t?t.split(`,`).map(e=>e.trim()).filter(D).slice(0,B):[]}var W=e=>e.state===`queued`||e.state===`running`;function G(e,t){return e.kind===`session`?e.address.startsWith(`@`)?e.address:t?.(e.sessionID??e.address)??(e.sessionID?t?.(e.address):void 0)??e.address:`New ${e.harness||`agent`} session on ${e.machine} · ${ve(e.repo)}`}function we(e,t){let n=(e,t)=>({tone:e,active:!1,text:t});if(e.state===`failed`)return n(`failed`,`Failed: ${e.error||`no reason given`}`);if(e.state===`cancelled`)return n(`cancelled`,`Cancelled`);if(e.state===`succeeded`){if(e.kind!==`propose-edit`)return n(`done`,`Answered`);let t=e.proposal;return t?t.state===`applied`?n(`done`,`Edit accepted`):t.state===`conflict`?n(`failed`,`Not accepted: the artifact changed after this edit was proposed. Request it again on the latest revision.`):n(`done`,`Proposed an edit: review it below`):n(`done`,`Finished without a proposal`)}let r=e.handler,i=(e,t)=>({tone:e,active:!0,text:t});switch(r.status){case`offline`:return r.kind===`session`?i(`offline`,`Waiting: ${G(r,t)} is offline. The request is queued and is delivered when it reconnects.`):i(`offline`,`Waiting: ${r.machine} is offline. The request is queued until it's back.`);case`starting`:return i(`waiting`,r.kind===`session`?`Sending to ${G(r,t)}…`:`Starting a session on ${r.machine}…`);case`waiting`:return i(`waiting`,r.kind===`launch`?`Waiting for a session on ${r.machine}${r.reason?`: ${r.reason}`:``}`:`Waiting for ${G(r,t)}`);case`ready`:return e.state===`running`?i(`running`,`Working: ${G(r,t)} has the request.`):i(`waiting`,`Request delivered to ${G(r,t)}; waiting for it to pick it up.`);default:return i(`waiting`,`The handler ${r.status===`ended`?`ended`:`failed`}; the job finishes shortly.`)}}function Te(e){return e===`user`?`You`:e.startsWith(`app:`)?`App ${e.slice(4)}`:`Session ${e}`}function K(e,t){let n=t.get(e);return n===void 0?`revision ${e.slice(-6)}`:`revision ${n}`}function Ee(e){let t=[],n=[];for(let r of e.sessions){if(r.archived)continue;let e=r.name?.replace(/^@+/,``)?`@${r.name.replace(/^@+/,``)}`:void 0,i=r.title||r.id,a=[r.machineName,r.harness].filter(Boolean).join(` · `),o=`${r.online?`●`:`○`} ${e?`${e} — ${i} · ${a}`:`${i} · ${a}`}${r.online?``:` (offline: queued until it reconnects)`}`,s={key:`session:${r.id}`,kind:`session`,label:o,display:e??i,online:r.online,handler:{session:r.id},search:[e,r.title,r.id,r.machineName,r.harness].filter(Boolean).join(` `).toLowerCase()};e?t.push({...s,sortName:e.toLowerCase()}):n.push(s)}t.sort((e,t)=>e.sortName<t.sortName?-1:+(e.sortName>t.sortName));let r=[...t.map(({sortName:e,...t})=>t),...n];for(let t of e.bindings){let n=e.machines.find(e=>e.id===t.machineID),i=n?.online??!1,a=`New session in ${t.label||ve(t.repo)} on ${n?.name??t.machineID}`;r.push({key:`launch:${t.id}`,kind:`launch`,label:`${a}${i?``:` (machine offline: waits for it)`}`,display:a,online:i,handler:{launch:{machine:t.machineID,repo:t.repo}},search:[a,t.repo,t.machineID].join(` `).toLowerCase()})}return r}function De(e,t,n){let r=t.trim().toLowerCase();return r?e.filter(e=>e.key===n||e.search.includes(r)):[...e]}function Oe(e){let t=new Map;for(let n of e)n.kind===`session`&&`session`in n.handler&&n.handler.session&&t.set(n.handler.session,n.display);return t}function ke(e){return e.kind===`session`?{session:e.sessionID??e.address}:{launch:{machine:e.machine,repo:e.repo,...e.harness?{harness:e.harness}:{},...e.model?{model:e.model}:{},...e.agent?{agent:e.agent}:{},mode:e.mode}}}function Ae(e){let t=e=>({ok:!1,problem:e});if(!e.handler)return t(`Choose who handles this request.`);let n=e.instruction.trim();if(e.kind===`run-action`){let r=e.actions??[];if(r.length===0)return t(`This artifact declares no AI actions.`);if(!e.action||!r.includes(e.action))return t(`Choose one of the artifact's actions.`);n||=`Run the ${e.action} action.`}if(!n)return t(e.kind===`ask`?`Write a question.`:`Describe the edit.`);if(n.length>de.aiInstructionChars)return t(`Keep it under ${de.aiInstructionChars.toLocaleString(`en-US`)} characters.`);if(ge.test(n))return t(`Use plain text (no control characters).`);let r={kind:e.kind,baseRevisionID:e.baseRevisionID,instruction:n,handler:e.handler};return e.kind===`run-action`?{ok:!0,request:{kind:`run-action`,action:e.action,baseRevisionID:e.baseRevisionID,instruction:n,handler:e.handler}}:{ok:!0,request:e.kind===`propose-edit`?{...r,apply:`manual`}:r}}var je=4e6,Me=3,Ne=e=>{let t=e.replace(/\r\n?/g,`
|
|
2
|
-
`).split(`
|
|
3
|
-
`);return t.length>1&&t[t.length-1]===``&&t.pop(),e===``?[]:t};function Pe(e,t){let n=Ne(e),r=Ne(t),i=[{type:`meta`,text:`Too large to compare line by line.`}];if(n.length+r.length>1e4)return i;let a=0;for(;a<n.length&&a<r.length&&n[a]===r[a];)a++;let o=n.length,s=r.length;for(;o>a&&s>a&&n[o-1]===r[s-1];)o--,s--;let c=o-a,l=s-a;if((c+1)*(l+1)>je)return i;let u=l+1,d=new Uint32Array((c+1)*u);for(let e=c-1;e>=0;e--)for(let t=l-1;t>=0;t--)d[e*u+t]=n[a+e]===r[a+t]?d[(e+1)*u+t+1]+1:Math.max(d[(e+1)*u+t],d[e*u+t+1]);let f=[];for(let e=0;e<a;e++)f.push({type:`context`,text:n[e],oldNo:e+1,newNo:e+1});let p=0,m=0,h=[],g=[],_=()=>{f.push(...h,...g),h=[],g=[]};for(;p<c||m<l;)p<c&&m<l&&n[a+p]===r[a+m]?(_(),f.push({type:`context`,text:n[a+p],oldNo:a+p+1,newNo:a+m+1}),p++,m++):m<l&&(p===c||d[p*u+m+1]>=d[(p+1)*u+m])?(g.push({type:`add`,text:r[a+m],newNo:a+m+1}),m++):(h.push({type:`del`,text:n[a+p],oldNo:a+p+1}),p++);_();for(let e=0;e<n.length-o;e++)f.push({type:`context`,text:n[o+e],oldNo:o+e+1,newNo:s+e+1});let v=new Uint8Array(f.length);f.forEach((e,t)=>{if(e.type!==`context`)for(let e=Math.max(0,t-Me);e<=Math.min(f.length-1,t+Me);e++)v[e]=1});let y=[],b=0;for(;b<f.length;){if(!v[b]){b++;continue}let e=b;for(;e<f.length&&v[e];)e++;let t=f.slice(b,e),n=t.find(e=>e.oldNo!==void 0)?.oldNo??0,r=t.find(e=>e.newNo!==void 0)?.newNo??0,i=t.filter(e=>e.type!==`add`).length,a=t.filter(e=>e.type!==`del`).length;y.push({type:`hunk`,text:`@@ -${n},${i} +${r},${a} @@`});for(let e of t)y.push(e);b=e}return y}function Fe(e,t){if(!(t.files.some(e=>e.path!==void 0)||t.keep.length>0||e.some(e=>e.path!==void 0))){let n=e[0];return t.files.map(e=>({change:n?n.hash===e.hash?`unchanged`:`changed`:`added`,mediaType:e.mediaType,bytes:e.bytes,...n?{baseBytes:n.bytes}:{}}))}let n=new Map(e.map(e=>[e.path??``,e])),r=[],i=new Set;for(let e of t.files){let t=e.path??``;i.add(t);let a=n.get(t);r.push({path:t,change:a?a.hash===e.hash?`unchanged`:`changed`:`added`,mediaType:e.mediaType,bytes:e.bytes,...a?{baseBytes:a.bytes}:{}})}for(let e of t.keep){if(i.has(e))continue;i.add(e);let t=n.get(e);r.push({path:e,change:`kept`,mediaType:t?.mediaType??``,bytes:t?.bytes??0,...t?{baseBytes:t.bytes}:{}})}for(let t of e){let e=t.path??``;i.has(e)||r.push({path:e,change:`removed`,mediaType:t.mediaType,bytes:0,baseBytes:t.bytes})}return r}function Ie(e){let t=V(e)||e instanceof Error?e:{},n=U(t.status)?t.status:0,r=typeof t.code==`string`?t.code:``,i=typeof t.message==`string`?t.message:String(e),a=V(t.details)?t.details:{};if(n===422||r===`unsupported`){let e=typeof a.feature==`string`?a.feature:``;return e===`artifactActions`?{kind:`unsupported`,text:`This artifact declares no AI actions.`}:!e||e===`artifacts`?{kind:`unsupported`,text:`AI requests aren't supported on this hub.`}:{kind:`unsupported`,text:`Not supported on this hub (${e}): ${i}`}}return n===404||r===`not_found`?{kind:`unavailable`,text:`AI requests aren't available for this artifact (it doesn't exist, or you can't see it).`}:n===401||n===403||r===`forbidden`?{kind:`forbidden`,text:`Not allowed: ${i}`}:n===409||r===`conflict`?{kind:`conflict`,text:i}:n===429||r===`rate_limited`?{kind:`rate_limited`,text:`Too many AI requests are running (on this artifact or for you). Wait for one to finish.`}:n===503||r===`offline`?{kind:`offline`,text:`Offline: ${i}`}:n===400||r===`invalid`?{kind:`invalid`,text:i}:{kind:`error`,text:i}}function Le(e){return e.proposal?.state===`conflict`?`stale-base`:`job-changed`}function Re(e){return Math.min(1e4,Math.round(1500*1.5**Math.max(0,e)))}var ze={set(e,t){let n=setTimeout(e,t);return()=>clearTimeout(n)}},Be=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`,Ve=e=>!(e&&typeof e==`object`&&typeof e.status==`number`);function He(e){let{source:t,artifactID:n,onState:r}=e,i=e.timers??ze,a=e.key??Be,o={status:`loading`,actions:[],revisionNumbers:new Map,jobs:[],more:!1,loadingMore:!1,handlers:[],sending:!1,pending:{},notices:{},reviews:{}},s,c,l=0,u=!1,d,f=e=>{u||(o={...o,...e},r(o))},p=e=>o.jobs.find(t=>t.id===e),m=e=>f({jobs:o.jobs.some(t=>t.id===e.id)?o.jobs.map(t=>t.id===e.id?e:t):[e,...o.jobs]}),h=(e,t)=>{let{[e]:n,...r}=o.notices;f({notices:t?{...r,[e]:t}:r})},g=(e,t)=>{let{[e]:n,...r}=o.pending;f({pending:t?{...r,[e]:t}:r})};async function _(){let[e,r]=await Promise.all([t.artifact(n),t.revisionNumbers(n).catch(()=>o.revisionNumbers)]);f({artifact:e,actions:Ce(e.metadata),revisionNumbers:r})}function v(){c?.(),c=void 0,u||!o.jobs.some(W)?l=0:c=i.set(()=>{c=void 0,x()},Re(l))}async function y(){f({status:`loading`});try{let[,e]=await Promise.all([_(),t.jobs(n)]);s=e.cursor,f({status:`ready`,jobs:e.items,more:!!e.cursor,error:void 0})}catch(e){f({status:`error`,error:Ie(e)});return}v(),await b()}async function b(){if(!u&&o.artifact)try{f({handlers:await t.handlers(o.artifact),handlersError:void 0})}catch(e){f({handlersError:Ie(e).text})}}async function x(){if(!(u||o.status!==`ready`)){try{let e=await t.jobs(n),r=new Map(o.jobs.map(e=>[e.id,e])),i=new Set(e.items.map(e=>e.id)),a=e.items.some(e=>r.get(e.id)?.revision!==e.revision),s=e.items.some(e=>!W(e)&&r.get(e.id)&&W(r.get(e.id)));f({jobs:[...e.items,...o.jobs.filter(e=>!i.has(e.id))]}),l=a?0:l+1,s&&await _().catch(()=>void 0)}catch{l++}v()}}async function S(){if(s&&!o.loadingMore){f({loadingMore:!0});try{let e=await t.jobs(n,s);s=e.cursor;let r=new Set(o.jobs.map(e=>e.id));f({jobs:[...o.jobs,...e.items.filter(e=>!r.has(e.id))],more:!!e.cursor,loadingMore:!1})}catch(e){f({loadingMore:!1,sendError:Ie(e)})}}}async function C(e){let r=JSON.stringify(e),i=d?.body===r?d.key:a();try{let r=await t.create(n,e,i);return d=void 0,m(r),f({sending:!1,sendError:void 0}),l=0,v(),r}catch(e){d=Ve(e)?{body:r,key:i}:void 0;let t=Ie(e);f({sending:!1,sendError:t}),t.kind===`conflict`&&await _().catch(()=>void 0);return}}async function w(e){return await T(e)!==void 0}async function T(e){if(o.sending||!o.artifact)return;if(e.baseRevisionID!==void 0&&e.baseRevisionID!==o.artifact.latestRevisionID){f({sendError:{kind:`conflict`,text:`The artifact changed since that view opened: the request was not sent.`}});return}let t=o.handlers.find(t=>t.key===e.handlerKey)?.handler,n=Ae({kind:e.kind,instruction:e.instruction,baseRevisionID:o.artifact.latestRevisionID,...t?{handler:t}:{},...e.action?{action:e.action}:{},actions:o.actions});if(!n.ok)f({sendError:{kind:`invalid`,text:n.problem}});else return f({sending:!0,sendError:void 0}),C(n.request)}async function E(e){try{let r=await t.job(n,e);return m(r),r}catch{return}}async function D(e){let r=p(e);if(!r||o.pending[e]||!W(r))return!1;g(e,`cancel`);try{return m(await t.cancel(n,e,r.revision)),h(e,void 0),!0}catch(t){let n=Ie(t),r=n.kind===`conflict`?await E(e):void 0;return h(e,{kind:n.kind===`conflict`?`conflict`:`error`,text:r&&!W(r)?`Not cancelled: it already ${r.state===`succeeded`?`finished`:r.state}.`:n.text}),!1}finally{g(e,void 0),v()}}async function O(e){let r=p(e);if(!r||o.pending[e]||r.kind!==`propose-edit`||r.state!==`succeeded`||r.proposal?.state!==`pending`)return!1;g(e,`apply`);try{let i=await t.apply(n,e,r.revision);m(i.job),await _().catch(()=>void 0);let a=i.revisionNumber??o.revisionNumbers.get(i.revisionID);return h(e,{kind:`info`,text:a===void 0?`Accepted as a new revision.`:`Accepted as revision ${a}.`}),!0}catch(t){let n=Ie(t);if(n.kind!==`conflict`)return h(e,{kind:`error`,text:n.text}),!1;let[r]=await Promise.all([E(e),_().catch(()=>void 0)]);if(r&&Le(r)===`stale-base`){let t=o.artifact?K(o.artifact.latestRevisionID,o.revisionNumbers):`a newer revision`;h(e,{kind:`conflict`,stale:!0,text:`Not accepted: the artifact changed since this edit was proposed (it is at ${t} now). Nothing was changed. Request the edit again on the latest revision.`})}else h(e,{kind:`conflict`,stale:!1,text:`This request changed since you read it. Review it again, then Accept.`});return!1}finally{g(e,void 0)}}async function k(e){let t=p(e);if(!t||o.pending[e]||o.sending||t.kind!==`propose-edit`)return!1;g(e,`rerequest`),f({sending:!0,sendError:void 0});try{await _();let n=!!await C({kind:`propose-edit`,baseRevisionID:o.artifact.latestRevisionID,instruction:t.instruction,handler:ke(t.handler),apply:`manual`});return n&&h(e,{kind:`info`,text:`Requested again on the latest revision.`}),n}catch(e){return f({sending:!1,sendError:Ie(e)}),!1}finally{g(e,void 0)}}async function A(e){let r=p(e);if(r?.proposal){f({reviews:{...o.reviews,[e]:{status:`loading`}}});try{let[i,a]=await Promise.all([t.proposal(n,e),t.revisionFiles(n,r.baseRevisionID)]),s=Fe(a,{files:i.files,keep:i.keep}),c=a.length<=1&&i.files.every(e=>e.path===void 0),l=i.files.map(e=>{let t=c?a[0]:a.find(t=>t.path===e.path),n=e.path===void 0?{}:{path:e.path};return e.omitted===`binary`?{...n,note:`Binary file: not compared.`}:e.omitted===`budget`||e.text===void 0?{...n,note:`Too large to show here.`}:t&&t.text===void 0?{...n,note:t.omitted===`binary`?`Replaces a binary file.`:`The current file is too large to compare.`}:t&&t.hash===e.hash?{...n,note:`Unchanged.`}:{...n,lines:Pe(t?.text??``,e.text)}});f({reviews:{...o.reviews,[e]:{status:`ready`,changes:s,diffs:l,truncated:i.truncated}}})}catch(t){f({reviews:{...o.reviews,[e]:{status:`error`,text:Ie(t).text}}})}}}return{state:()=>o,load:y,refresh:x,more:S,request:w,requestJob:T,cancel:D,accept:O,rerequest:k,review:A,reloadHandlers:b,dispose(){c?.(),c=void 0,u=!0}}}var Ue=`/api/agent/artifacts`,q={textBytes:2097152,imageBytes:10485760,editBytes:1048576,revisionsPage:20},We=encodeURIComponent,Ge=e=>`${Ue}/${We(e)}`,Ke=(e,t)=>`${Ge(e)}/revisions?limit=${q.revisionsPage}${t?`&cursor=${We(t)}`:``}`,qe=(e,t)=>`${Ge(e)}/revisions/${We(t)}`,Je=(e,t,n)=>`${qe(e,t)}/blobs/${We(n)}`,Ye=e=>typeof e==`object`&&!!e&&!Array.isArray(e),J=e=>typeof e==`string`&&e.length>0,Xe=e=>typeof e==`number`&&Number.isFinite(e),Ze=e=>typeof e==`string`&&se.includes(e),Qe=(e,t)=>Ye(e)&&Ye(e[t])?e[t]:e;function $e(e){let t=Qe(e,`artifact`);if(!Ye(t)||!J(t.id)||typeof t.title!=`string`||!Ze(t.kind)||!J(t.latestRevisionID)||!Xe(t.revision))return;let n=Array.isArray(t.tags)?t.tags.filter(e=>typeof e==`string`):void 0;return{v:1,id:t.id,title:t.title,kind:t.kind,state:t.state===`archived`?`archived`:`active`,visibility:t.visibility===`workspace`?`workspace`:`private`,latestRevisionID:t.latestRevisionID,revision:t.revision,createdAt:Xe(t.createdAt)?t.createdAt:0,updatedAt:Xe(t.updatedAt)?t.updatedAt:0,...J(t.description)?{description:t.description}:{},...J(t.workspaceID)?{workspaceID:t.workspaceID}:{},...J(t.createdBySessionID)?{createdBySessionID:t.createdBySessionID}:{},...n?.length?{tags:n}:{}}}function et(e){if(Ye(e)){if(e.kind===`user`)return{kind:`user`};if(e.kind===`session`&&J(e.sessionID))return{kind:`session`,sessionID:e.sessionID};if(e.kind===`ai_job`&&J(e.jobID))return{kind:`ai_job`,jobID:e.jobID}}}function tt(e){let t=Qe(e,`revision`);if(!Ye(t)||!J(t.id)||!J(t.artifactID)||!Xe(t.number)||!Array.isArray(t.blobs))return;let n=et(t.author);if(!n)return;let r=t.blobs.filter(e=>ae(e)===void 0);return{v:1,id:t.id,artifactID:t.artifactID,number:t.number,blobs:r.map(e=>({hash:e.hash,bytes:e.bytes,mediaType:e.mediaType,...e.path===void 0?{}:{path:e.path}})),author:n,createdAt:Xe(t.createdAt)?t.createdAt:0,...J(t.baseRevisionID)?{baseRevisionID:t.baseRevisionID}:{},...J(t.entry)?{entry:t.entry}:{}}}function nt(e){let t=Ye(e)?e:{};return{items:Array.isArray(t.items)?t.items.flatMap(e=>tt(e)??[]):[],...J(t.cursor)?{cursor:t.cursor}:{}}}function rt(e){return e.kind===`user`?`You`:e.kind===`session`?`Session ${e.sessionID.slice(0,12)}…`:`AI job`}var it=[`text/markdown`,`text/plain`,`text/csv`,`text/html`,`text/css`,`text/javascript`,`application/json`],at=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`],ot={markdown:{"text/markdown":`markdown`,"text/plain":`markdown`},code:Object.fromEntries(it.map(e=>[e,`code`])),image:Object.fromEntries(at.map(e=>[e,`image`])),table:{"text/csv":`table`,"application/json":`table`},chart:{"application/json":`chart`},dashboard:{"application/json":`dashboard`},file:{...Object.fromEntries(at.map(e=>[e,`image`])),"text/plain":`text`,"text/markdown":`text`}},st={ts:`ts`,tsx:`tsx`,js:`js`,jsx:`jsx`,mjs:`js`,cjs:`js`,py:`python`,go:`go`,rs:`rust`,sh:`bash`,bash:`bash`,json:`json`,css:`css`,html:`html`,htm:`html`,md:`markdown`,yaml:`yaml`,yml:`yaml`,toml:`toml`,sql:`sql`,java:`java`,c:`c`,h:`c`,cpp:`cpp`,rb:`ruby`,swift:`swift`,kt:`kotlin`,diff:`diff`,csv:`csv`,txt:``},ct={"text/javascript":`js`,"text/css":`css`,"application/json":`json`,"text/html":`html`,"text/markdown":`markdown`,"text/csv":`csv`};function lt(e){let t=e.path?.split(`/`).pop()?.split(`.`).slice(1).pop()?.toLowerCase();return t!==void 0&&t in st?st[t]:ct[e.mediaType]??``}function ut(e,t){let n=t.blobs;if(ie.includes(e))return{mode:`isolated`,files:n,...n[0]?{file:dt(t)??n[0]}:{}};if(!n.length)return{mode:`empty`,files:n};let r=ot[e],i=dt(t)??n.find(e=>r[e.mediaType])??n[0],a=r[i.mediaType];if(!a)return{mode:`download`,file:i,files:n,note:`A ${i.mediaType} file can't be shown as ${e===`image`?`an`:`a`} ${e} here.`};let o=a===`image`?q.imageBytes:q.textBytes;return i.bytes>o?{mode:`download`,file:i,files:n,note:`This file is too large to preview (${Math.ceil(i.bytes/1024)} KiB).`}:{mode:a,file:i,files:n,...a===`code`?{lang:lt(i)}:{}}}function dt(e){return e.entry===void 0?void 0:e.blobs.find(t=>t.path===e.entry)}var ft=class extends Error{limit;name=`TooLargeError`;code=`too_large`;constructor(e){super(`A file here is at most ${Math.round(e/1024)} KiB`),this.limit=e}};async function pt(e,t){let n=Number(e.headers.get(`content-length`)??``);if(Number.isFinite(n)&&n>t)throw await e.body?.cancel().catch(()=>{}),new ft(t);if(!e.body)return new Uint8Array;let r=e.body.getReader(),i=[],a=0;for(;;){let{done:e,value:n}=await r.read();if(e)break;if(a+=n.byteLength,a>t)throw await r.cancel().catch(()=>{}),new ft(t);i.push(n)}let o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.byteLength;return o}function mt(e){let t=e&&typeof e==`object`?e:{},n=typeof t.status==`number`?t.status:0,r=typeof t.message==`string`?t.message:``;return t.name===`NetworkError`||n===503?{kind:`offline`,text:`Can't reach the hub right now. Nothing was lost; try again when it's back.`}:t.name===`TooLargeError`||t.code===`too_large`?{kind:`too_large`,text:r||`The file is too large.`}:n===404||n===403?{kind:`not_found`,text:`This artifact doesn't exist or you can't see it.`}:n===401?{kind:`forbidden`,text:`This device isn't signed in to the hub.`}:n===422||t.code===`unsupported`?{kind:`unsupported`,text:`Artifacts aren't supported on this hub yet.`}:n===409||t.code===`conflict`?{kind:`conflict`,text:`The artifact changed since you opened it.`}:n===429||t.code===`rate_limited`?{kind:`rate_limited`,text:r?`Limit reached: ${r}`:`A limit was reached; try again later.`}:n===400?{kind:`invalid`,text:r||`The hub refused the change.`}:{kind:`error`,text:r?`Something went wrong: ${r}`:`Something went wrong (HTTP ${n}).`}}var ht=e=>new TextEncoder().encode(e).byteLength;function gt(e,t){if(e.state!==`active`||t.id!==e.latestRevisionID||ie.includes(e.kind)||t.blobs.length!==1)return!1;let n=t.blobs[0];return it.includes(n.mediaType)&&n.bytes<=q.editBytes}function _t(e,t,n){if(ht(n)>q.editBytes)throw new ft(q.editBytes);return{baseRevisionID:e,upload:[{mediaType:t.mediaType,data:n,encoding:`utf8`,...t.path===void 0?{}:{path:t.path}}]}}var vt=e=>`hub.artifactDraft.v1.${e}`;function yt(e,t){try{let n=e?.getItem(vt(t)),r=n?JSON.parse(n):void 0;return Ye(r)&&r.v===1&&J(r.base)&&typeof r.text==`string`?{v:1,base:r.base,text:r.text}:void 0}catch{return}}function bt(e,t){let n=yt(t.storage,e.artifactID),r=n?n.base===e.baseRevisionID?{status:`editing`,draft:n.text,baseRevisionID:n.base,restored:!0}:{status:`conflict`,draft:n.text,baseRevisionID:n.base,latestRevisionID:e.baseRevisionID,restored:!0}:{status:`editing`,draft:e.original,baseRevisionID:e.baseRevisionID},i=e.original,a,o=e=>{r=e,t.onChange()},s=()=>{try{r.draft===i&&r.baseRevisionID===e.baseRevisionID?t.storage?.removeItem(vt(e.artifactID)):ht(r.draft)<=q.editBytes&&t.storage?.setItem(vt(e.artifactID),JSON.stringify({v:1,base:r.baseRevisionID,text:r.draft}))}catch{}};return{state:()=>r,setDraft(e){o({...r,draft:e,status:r.status===`conflict`?`conflict`:`editing`}),s()},async save(){if(r.status===`saving`||r.status===`conflict`||r.draft===i&&r.baseRevisionID===e.baseRevisionID)return;let n;try{n=_t(r.baseRevisionID,e.file,r.draft)}catch(e){o({...r,status:`error`,error:{kind:`too_large`,text:`${e.message}; shorten the draft to save it.`}});return}let c=`${r.baseRevisionID}\n${r.draft}`,l=a?.sig===c?a.key:t.newKey();a={sig:c,key:l};let u=r;o({...r,status:`saving`});try{let r=await t.revise(e.artifactID,n,l);return i=u.draft,t.storage?.removeItem(vt(e.artifactID)),o({status:`saved`,draft:u.draft,baseRevisionID:r.id}),r}catch(e){let t=mt(e),n=e.details;t.kind===`conflict`?o({...u,status:`conflict`,error:t,...J(n?.latestRevisionID)?{latestRevisionID:n.latestRevisionID}:{}}):o({...u,status:`error`,error:t}),s();return}},rebase(e){let{latestRevisionID:t,error:n,...i}=r;o({...i,status:`editing`,baseRevisionID:e}),s()},discard(){t.storage?.removeItem(vt(e.artifactID)),a=void 0,o({status:`editing`,draft:i,baseRevisionID:e.baseRevisionID})}}}var xt={markdown:`Markdown`,code:`Code`,image:`Image`,table:`Table`,chart:`Chart`,dashboard:`Dashboard`,html:`HTML`,app:`App`,file:`File`};function St(e){let t=[[]];for(let n of e)n.text.split(`
|
|
4
|
-
`).forEach((e,r)=>{r>0&&t.push([]),e&&t[t.length-1].push(n.kind?{text:e,kind:n.kind}:{text:e})});return t.length>1&&t[t.length-1].length===0&&t.pop(),t}var Ct={ts:`TypeScript`,tsx:`TypeScript (TSX)`,js:`JavaScript`,jsx:`JavaScript (JSX)`,python:`Python`,go:`Go`,rust:`Rust`,bash:`Shell`,json:`JSON`,css:`CSS`,html:`HTML`,markdown:`Markdown`,yaml:`YAML`,toml:`TOML`,sql:`SQL`,java:`Java`,c:`C`,cpp:`C++`,ruby:`Ruby`,swift:`Swift`,kotlin:`Kotlin`,diff:`Diff`,csv:`CSV`};function wt(e,t){return{name:e?.path?.split(`/`).pop()||`Untitled`,language:t?Ct[t]??t.toUpperCase():`Plain text`}}function Tt(e,t){let n=[{label:`Type`,value:xt[e.kind]??e.kind},{label:`Visibility`,value:e.visibility===`workspace`?`Workspace members`:`Private (only you)`}];e.workspaceID&&n.push({label:`Workspace`,value:t.workspaceName??e.workspaceID}),n.push({label:`Created by`,value:e.createdBySessionID?rt({kind:`session`,sessionID:e.createdBySessionID}):`You`}),n.push({label:`Created`,value:t.when(e.createdAt)},{label:`Updated`,value:t.when(e.updatedAt)}),e.state===`archived`&&n.push({label:`State`,value:`Archived (read only)`}),e.tags?.length&&n.push({label:`Tags`,value:e.tags.join(`, `)});let r=Ce(e.metadata);r.length&&n.push({label:`AI actions`,value:r.join(`, `)});for(let[t,r]of Object.entries(e.metadata??{}))t!==`ai-actions`&&n.push({label:t,value:r});return n}var Et={ask:`ask`,edit:`propose-edit`,action:`run-action`};function Dt(e,t){let n=/^\/([a-z]+)(?:\s+([\s\S]*))?$/.exec(e),r=n?Et[n[1]]:void 0;if(!n||!r)return{text:e};let i=n[2]??``;if(r!==`run-action`)return{kind:r,text:i};let a=/^(\S+)\s*([\s\S]*)$/.exec(i);return!a||!t.includes(a[1])?{text:e}:{kind:r,action:a[1],text:a[2]}}var Ot=`hub.artifactAiHandler.v1`;function kt(e,t){try{e?.setItem(Ot,t)}catch{}}function At(e,t){let n=null;try{n=e?.getItem(`hub.artifactAiHandler.v1`)??null}catch{return}return n?t.find(e=>e.key===n):void 0}function jt(e){return[...e].reverse()}var Mt=`hub.artifactAiPanel.v1`,Y={min:280,max:640,default:380,share:.6};function Nt(e,t){if(!Number.isFinite(e))return Y.default;let n=Math.max(Y.min,Math.min(Y.max,Math.floor(t*Y.share)));return Math.min(n,Math.max(Y.min,Math.round(e)))}function Pt(e){try{let t=JSON.parse(e?.getItem(`hub.artifactAiPanel.v1`)??`null`);if(!t||typeof t!=`object`)return{};let{open:n,width:r}=t;return{...typeof n==`boolean`?{open:n}:{},...typeof r==`number`&&Number.isFinite(r)?{width:r}:{}}}catch{return{}}}function Ft(e,t){try{e?.setItem(Mt,JSON.stringify(t))}catch{}}var It=F(`<input type=search class=aai-picker-search aria-label="Search handlers"placeholder=Find… title="Find a handler by @name, title or session ID">`),Lt=F(`<optgroup label="Your sessions">`),Rt=F(`<optgroup label="New session in a workspace repo">`),zt=F(`<span><select aria-label="Handled by"title="Who handles this request"><option value>`),Bt=F(`<option>`),Vt=F(`<button type=button class=aai-recent>Use `);function Ht(){try{return window.localStorage}catch{return}}function Ut(e){let[i,a]=o(``),s=()=>e.value?void 0:At(Ht(),e.handlers),l=c(()=>De(e.handlers,i(),e.value)),d=()=>l().filter(e=>e.kind===`session`),f=()=>l().filter(e=>e.kind===`launch`),p=()=>!!i().trim()&&!l().some(t=>t.key!==e.value);return(()=>{var o=zt(),c=o.firstChild,l=c.firstChild;return v(o,t(r,{get when(){return e.handlers.length>1},get children(){var t=It();return t.$$input=e=>a(e.currentTarget.value),t.addEventListener(`focus`,()=>e.onPick?.()),u(()=>t.value=i()),t}}),c),c.addEventListener(`change`,t=>e.onChange(t.currentTarget.value)),c.addEventListener(`focus`,()=>e.onPick?.()),v(l,()=>p()?`No handler matches the search`:`Choose a session…`),v(c,t(r,{get when(){return d().length},get children(){var r=Lt();return v(r,t(n,{get each(){return d()},children:t=>(()=>{var n=Bt();return v(n,()=>t.label),u(()=>n.selected=t.key===e.value),u(()=>n.value=t.key),n})()})),r}}),null),v(c,t(r,{get when(){return f().length},get children(){var r=Rt();return v(r,t(n,{get each(){return f()},children:t=>(()=>{var n=Bt();return v(n,()=>t.label),u(()=>n.selected=t.key===e.value),u(()=>n.value=t.key),n})()})),r}}),null),v(o,t(r,{get when(){return s()},children:t=>(()=>{var n=Vt();return n.firstChild,n.$$click=()=>e.onChange(t().key),v(n,()=>t().display,null),u(e=>{var r=`Last used on this device: ${t().label}`,i=`Use ${t().display} (last used)`;return r!==e.e&&x(n,`title`,e.e=r),i!==e.t&&x(n,`aria-label`,e.t=i),e},{e:void 0,t:void 0}),n})()}),null),u(()=>M(o,`aai-picker ${e.class??``}`)),u(()=>c.value=e.value),o})()}_([`input`,`click`]);var Wt=`/api/agent/artifacts`,Gt=50,Kt=262144,qt=e=>e.startsWith(`text/`)||e===`application/json`||e===`image/svg+xml`,X=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Jt=t=>new e(502,`The hub answered an unexpected ${t}`);function Yt(e){let t=X(e)&&X(e.artifact)?e.artifact:e;if(!X(t)||typeof t.id!=`string`||typeof t.latestRevisionID!=`string`||typeof t.revision!=`number`)throw Jt(`artifact`);return{id:t.id,title:typeof t.title==`string`?t.title:``,kind:typeof t.kind==`string`?t.kind:`file`,state:typeof t.state==`string`?t.state:`active`,latestRevisionID:t.latestRevisionID,revision:t.revision,...typeof t.workspaceID==`string`?{workspaceID:t.workspaceID}:{},...X(t.metadata)?{metadata:t.metadata}:{}}}var Xt=e=>{let t=xe(X(e)?e.job:void 0);if(!t)throw Jt(`job`);return t},Zt=async(e,t,n={})=>(await A(e,{method:`POST`,json:t,headers:n})).json();async function Qt(){try{let e=await C(`/api/agent/who`),t=X(e)&&Array.isArray(e.sessions)?e.sessions:[];return new Map(t.flatMap(e=>X(e)&&typeof e.sessionID==`string`&&typeof e.name==`string`&&e.name?[[e.sessionID,e.name]]:[]))}catch{return new Map}}function $t(e){let t=e=>`${Wt}/${T(e)}/jobs`,n=(e,n,r=``)=>`${t(e)}/${T(n)}${r}`;return{artifact:async e=>Yt(await C(`${Wt}/${T(e)}`)),async revisionNumbers(e){let t=await C(`${Wt}/${T(e)}/revisions?limit=200`),n=X(t)&&Array.isArray(t.items)?t.items:[];return new Map(n.flatMap(e=>X(e)&&typeof e.id==`string`&&typeof e.number==`number`?[[e.id,e.number]]:[]))},jobs:async(e,n)=>Se(await C(`${t(e)}?limit=${Gt}${n?`&cursor=${T(n)}`:``}`)),job:async(e,t)=>Xt(await C(n(e,t))),create:async(e,n,r)=>Xt(await Zt(t(e),n,{"idempotency-key":r})),cancel:async(e,t,r)=>Xt(await Zt(n(e,t,`/cancel`),{expectedRevision:r})),async apply(e,t,r){let i=await Zt(n(e,t,`/apply`),{expectedRevision:r}),a=X(i)&&X(i.revision)?i.revision:{};if(typeof a.id!=`string`)throw Jt(`revision`);return{job:Xt(i),revisionID:a.id,...typeof a.number==`number`?{revisionNumber:a.number}:{}}},proposal:async(e,t)=>{let r=await C(n(e,t,`/proposal`));if(!X(r)||!Array.isArray(r.files))throw Jt(`proposal`);return{...r,keep:Array.isArray(r.keep)?r.keep:[],truncated:r.truncated===!0}},async revisionFiles(e,t){let n=await C(`${Wt}/${T(e)}/revisions/${T(t)}`),r=X(n)&&X(n.revision)&&Array.isArray(n.revision.blobs)?n.revision.blobs:[],i=Kt,a=[];for(let n of r){if(!X(n)||typeof n.hash!=`string`||typeof n.mediaType!=`string`||typeof n.bytes!=`number`)continue;let r={...typeof n.path==`string`?{path:n.path}:{},hash:n.hash,mediaType:n.mediaType,bytes:n.bytes};qt(n.mediaType)?n.bytes>i?a.push({...r,omitted:`budget`}):(i-=n.bytes,a.push({...r,text:await(await A(`${Wt}/${T(e)}/revisions/${T(t)}/blobs/${T(n.hash)}`)).text()})):a.push({...r,omitted:`binary`})}return a},async handlers(t){let[n,r]=await Promise.all([(async()=>{if(!t.workspaceID)return[];try{let e=await C(`/api/agent/workspaces/${T(t.workspaceID)}/bindings`);return(X(e)&&Array.isArray(e.bindings)?e.bindings:[]).flatMap(e=>X(e)&&typeof e.id==`string`&&typeof e.machineID==`string`&&typeof e.repo==`string`?[{id:e.id,machineID:e.machineID,repo:e.repo,...typeof e.label==`string`?{label:e.label}:{}}]:[])}catch{return[]}})(),Qt()]);return Ee({sessions:e.sessions().map(e=>r.get(e.id)?{...e,name:r.get(e.id)}:e),bindings:n,machines:e.machines()})}}}var en=F(`<span>an unknown revision`),tn=F(`<button type=button class=aai-link>`),nn=F(`<span>`),rn=F(`<strong class=aai-older>You are viewing an older revision.`),an=F(`<p class=aai-sub>Requests use the latest revision (<!>).`),on=F(`<p class=aai-note role=status>Loading AI requests…`),sn=F(`<button type=button class="btn small aai-older-btn">Load older requests`),cn=F(`<ol class=aai-jobs aria-label="AI request history">`),ln=F(`<p class=aai-note>Could not list handlers: `),un=F(`<p class=aai-note role=status>`),dn=F(`<div class=aai-confirm role=group aria-label="Confirm action"><p>Run <strong></strong> on <!>, handled by <strong></strong>? It gets a read-only copy of this revision; its answer shows here and nothing is changed.</p><div class=aai-actions><button type=button class="btn primary small">Confirm and run</button><button type=button class="btn small">Back`),fn=F(`<select class=aai-action aria-label="Declared action"><option value>Choose an action…`),pn=F(`<form class=aai-composer aria-label="New AI request"><div class=aai-box><div class=aai-box-top><div class=aai-seg role=radiogroup aria-label="Request type"></div></div><textarea class=aai-input rows=2></textarea><div class=aai-box-foot><span class=aai-hint>Ctrl+Enter</span><button type=submit class=aai-send><span class=aai-send-text>`),mn=F(`<section class=aai><header class=aai-head><span class=aai-mark aria-hidden=true></span><div class=aai-head-text><h2 class=aai-title>AI requests</h2></div></header><div class=aai-scroll>`),hn=F(`<button type=button class="btn small">Retry`),gn=F(`<p class=aai-note> `),_n=F(`<kbd>/action `),vn=F(`<div class=aai-empty><p><strong>Ask about this artifact, or describe an edit.</strong></p><p>The session you choose gets a read-only copy. Nothing changes until you accept an edit.</p><p class=aai-tips>Tip: start with <kbd>/ask</kbd>, <kbd>/edit</kbd>.`),yn=F(`<p class="aai-note err"role=alert>`),bn=F(`<label class=aai-seg-item><input type=radio>`),xn=F(`<option>`),Sn=F(`<span class=aai-dot aria-hidden=true>`),Cn=F(`<div class=aai-answer>`),wn=F(`<p class="aai-note warn"role=status>The artifact changed since this edit was proposed: accepting it will be refused. Request it again on the latest revision.`),Tn=F(`<button type=button class="btn primary small">`),En=F(`<button type=button class="btn small">Request again on the latest revision`),Dn=F(`<button type=button class="btn small">`),On=F(`<button type=button class="btn small">Continue in side chat`),kn=F(`<li class=aai-job><div class=aai-q><div class=aai-q-meta><span class=aai-badge></span><span class=aai-meta> · </span></div><p class=aai-instruction></p></div><div class=aai-a><p class="aai-meta aai-prov">On <!> · handled by </p><p role=status aria-live=polite></p><div class=aai-actions>`),An=F(`<div class=aai-proposal>`),jn=F(`<button type=button class="btn small">Review proposed edit (<!> file<!>)`),Mn=F(`<p class=aai-note role=status>Loading the proposal…`),Nn=F(`<p class="aai-note err">Could not load the proposal: `),Pn=F(`<ul class=aai-files aria-label="Proposed files">`),Fn=F(`<p class=aai-note>Some files are too large to show here.`),In=F(`<li><span class=aai-file-change></span> <code>`),Ln=F(`<p class=aai-meta><code>`),Rn=F(`<table class=diff><tbody>`),zn=F(`<div class=aai-diff>`),Bn=F(`<p class=aai-note>`),Vn=F(`<tr><td class=ln></td><td class=ln></td><td class=code-line><span class=sign>`),Hn=F(`<p>`),Un={ask:`Ask`,"propose-edit":`Edit`,"run-action":`Action`},Wn={ask:`Ask a question (answer only)`,"propose-edit":`Propose an edit you review before it applies`,"run-action":`Run one of the artifact's declared actions`},Gn=e=>e.kind===`ask`?`Question`:e.kind===`propose-edit`?`Edit`:`Action: ${e.action??`?`}`;function Kn(){return $t({sessions:()=>{let e=new Map;for(let t of ee.machines??[])for(let n of t.processes)for(let t of n.sessions)e.set(t.id,n.harness||`opencode`);return z().filter(e=>!e.hidden&&!e.archived).map(t=>({id:t.id,title:t.title,machineName:t.machineName,online:t.machineOnline,...e.get(t.id)?{harness:e.get(t.id)}:{}}))},machines:()=>(ee.machines??[]).map(e=>({id:e.id,name:e.name,online:!!e.online}))})}function qn(e){let[i,p]=o(),h=!e.controller,_=e.controller?.ai??He({source:e.source??Kn(),artifactID:e.artifactID,onState:p});m(()=>h&&void _.load()),f(()=>h&&_.dispose());let y=()=>(h?i():e.controller.state())??_.state(),b=()=>y().revisionNumbers,S=()=>y().artifact?.latestRevisionID,[C,w]=o(`ask`),[T,D]=o(``),[k,A]=o(``),[j,M]=o(``),[N,P]=o(!1),F,I,L,R=c(()=>y().handlers.find(e=>e.key===k())),z=()=>C()===`ask`?`Ask`:C()===`propose-edit`?`Propose edit`:j()?`Run ${j()}…`:`Run action…`,ee=c(()=>jt(y().jobs));s(a(()=>[y().jobs.length,e.tailCount??0],()=>queueMicrotask(()=>L&&(L.scrollTop=L.scrollHeight))));async function te(){let e=k(),t=await _.request({kind:C(),instruction:T(),...e?{handlerKey:e}:{},...C()===`run-action`&&j()?{action:j()}:{}});P(!1),t&&(D(``),kt(Ht(),e))}function ne(e){e?.preventDefault(),!y().sending&&(C()===`run-action`&&j()&&k()?(P(!0),queueMicrotask(()=>F?.focus())):te())}function re(e){let t=Dt(e,y().actions);t.kind&&/\s$/.test(e)?(w(t.kind),t.action&&M(t.action),P(!1),D(t.text),I&&(I.value=t.text)):D(e)}async function ie(t){if(await _.accept(t.id)){let t=S();t&&e.onRevised?.(t)}}let ae=(n,i=``)=>t(r,{when:n,get fallback(){return(()=>{var e=en(),t=e.firstChild;return v(e,i,t),e})()},children:n=>t(r,{get when(){return e.onShowRevision},get fallback(){return(()=>{var e=nn();return v(e,()=>i+K(n(),b())),e})()},get children(){var t=tn();return t.$$click=()=>e.onShowRevision?.(n()),v(t,()=>i+K(n(),b())),t}})});return(()=>{var i=mn(),a=i.firstChild,o=a.firstChild,s=o.nextSibling,c=s.firstChild,f=a.nextSibling;v(o,t(O,{name:`spark`})),v(s,t(r,{get when(){return y().status===`ready`},get children(){var n=an(),i=n.firstChild.nextSibling;return i.nextSibling,v(n,()=>ae(S()),i),v(n,t(r,{get when(){return E(()=>!!(e.revisionID&&S()))()&&e.revisionID!==S()},get children(){return[` `,rn()]}}),null),n}}),null),v(a,()=>e.headerActions,null);var p=L;return typeof p==`function`?g(p,f):L=f,v(f,t(l,{get children(){return[t(d,{get when(){return y().status===`loading`},get children(){return on()}}),t(d,{get when(){return E(()=>y().status===`error`)()&&y().error},children:e=>(()=>{var n=gn(),i=n.firstChild;return v(n,()=>e().text,i),v(n,t(r,{get when(){return e().kind===`error`||e().kind===`offline`},get children(){var e=hn();return e.$$click=()=>void _.load(),e}}),null),u(t=>{var r=e().kind===`error`,i=e().kind===`error`?`alert`:`status`;return r!==t.e&&n.classList.toggle(`err`,t.e=r),i!==t.t&&x(n,`role`,t.t=i),t},{e:void 0,t:void 0}),n})()}),t(d,{get when(){return y().status===`ready`},get children(){return[t(r,{get when(){return y().more},get children(){var e=sn();return e.$$click=()=>void _.more(),u(t=>{var n=y().loadingMore,r=y().loadingMore;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&x(e,`aria-busy`,t.t=r),t},{e:void 0,t:void 0}),e}}),t(r,{get when(){return y().jobs.length},get fallback(){return(()=>{var e=vn(),n=e.firstChild.nextSibling.nextSibling,i=n.firstChild.nextSibling.nextSibling.nextSibling.nextSibling;return v(n,t(r,{get when(){return y().actions.length},get children(){return[` `,`or `,(()=>{var e=_n();return e.firstChild,v(e,()=>y().actions[0],null),e})()]}}),i),e})()},get children(){var r=cn();return v(r,t(n,{get each(){return ee()},children:n=>t(Jn,{job:n,get state(){return y()},revisionRef:ae,onCancel:()=>void _.cancel(n.id),onReview:()=>void _.review(n.id),onAccept:()=>void ie(n),onRerequest:()=>void _.rerequest(n.id),get onContinue(){return e.onContinueInSideChat}})})),r}})]}})]}}),null),v(f,()=>e.threadTail,null),v(i,t(r,{get when(){return y().status===`ready`},get children(){var i=pn(),a=i.firstChild,o=a.firstChild,s=o.firstChild,c=o.nextSibling,l=c.nextSibling,d=l.firstChild,f=d.nextSibling,p=f.firstChild;i.addEventListener(`submit`,ne),v(i,t(r,{get when(){return y().sendError},children:e=>(()=>{var t=yn();return v(t,()=>e().text),t})()}),a),v(i,t(r,{get when(){return y().handlersError},get children(){var e=ln();return e.firstChild,v(e,()=>y().handlersError,null),e}}),a),v(i,t(r,{get when(){return E(()=>!!R())()&&!R().online},get children(){var e=un();return v(e,()=>R().kind===`session`?`That session is offline: the request is queued and delivered when it reconnects.`:`That machine is offline: the new session starts when it's back.`),e}}),a),v(i,t(r,{get when(){return N()},get children(){var e=dn(),t=e.firstChild,n=t.firstChild.nextSibling,r=n.nextSibling.nextSibling,i=r.nextSibling.nextSibling,a=t.nextSibling.firstChild,o=a.nextSibling;e.$$keydown=e=>{e.key===`Escape`&&(e.preventDefault(),P(!1),I?.focus())},v(n,j),v(t,()=>K(S()??``,b()),r),v(i,()=>R()?.display),a.$$click=()=>void te();var s=F;return typeof s==`function`?g(s,a):F=a,o.$$click=()=>{P(!1),I?.focus()},u(()=>a.disabled=y().sending),e}}),a),v(s,t(n,{each:[`ask`,`propose-edit`,`run-action`],children:t=>{let n=()=>t===`run-action`&&y().actions.length===0;return(()=>{var r=bn(),i=r.firstChild;return i.addEventListener(`change`,()=>{w(t),P(!1)}),i.value=t,v(r,()=>Un[t],null),u(a=>{var o=C()===t,s=!!n(),c=n()?`This artifact declares no AI actions`:Wn[t],l=`aai-mode-${e.artifactID}`,u=n();return o!==a.e&&r.classList.toggle(`on`,a.e=o),s!==a.t&&r.classList.toggle(`disabled`,a.t=s),c!==a.a&&x(r,`title`,a.a=c),l!==a.o&&x(i,`name`,a.o=l),u!==a.i&&(i.disabled=a.i=u),a},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),u(()=>i.checked=C()===t),r})()}})),v(o,t(r,{get when(){return C()===`run-action`},get children(){var e=fn();return e.firstChild,e.addEventListener(`change`,e=>(M(e.currentTarget.value),P(!1))),v(e,t(n,{get each(){return y().actions},children:e=>(()=>{var t=xn();return t.value=e,v(t,e),t})()}),null),u(()=>e.value=j()),e}}),null),c.$$keydown=e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&ne(e)},c.$$input=e=>re(e.currentTarget.value);var m=I;return typeof m==`function`?g(m,c):I=c,v(l,t(Ut,{get handlers(){return y().handlers},get value(){return k()},onPick:()=>void _.reloadHandlers(),onChange:e=>(A(e),P(!1))}),d),v(f,t(O,{name:`send`}),p),v(p,(()=>{var e=E(()=>!!y().sending);return()=>e()?`Sending…`:z()})()),u(e=>{var t=C()===`ask`?`Question`:C()===`propose-edit`?`Describe the edit`:`Notes for the action (optional)`,n=C()===`ask`?`Ask about this artifact…`:C()===`propose-edit`?`Describe the edit, e.g. Add a rollback section`:`Notes for the action (optional)`,r=y().sending||N(),i=y().sending,a=y().sending?`Sending…`:z(),o=`${z()} (Ctrl+Enter)`;return t!==e.e&&x(c,`aria-label`,e.e=t),n!==e.t&&x(c,`placeholder`,e.t=n),r!==e.a&&(f.disabled=e.a=r),i!==e.o&&x(f,`aria-busy`,e.o=i),a!==e.i&&x(f,`aria-label`,e.i=a),o!==e.n&&x(f,`title`,e.n=o),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),u(()=>c.value=T()),i}}),null),u(t=>{var n=`aai-h-${e.artifactID}`,r=`aai-h-${e.artifactID}`;return n!==t.e&&x(i,`aria-labelledby`,t.e=n),r!==t.t&&x(c,`id`,t.t=r),t},{e:void 0,t:void 0}),i})()}function Jn(e){let i=()=>e.job,a=c(()=>Oe(e.state.handlers)),o=e=>a().get(e)??z().find(t=>t.id===e)?.title,s=()=>we(i(),o),f=()=>e.state.pending[i().id],p=()=>e.state.notices[i().id],m=()=>e.state.reviews[i().id],h=()=>e.state.artifact?.latestRevisionID,g=()=>i().kind===`propose-edit`&&i().state===`succeeded`&&i().proposal?.state===`pending`,_=()=>g()&&h()!==void 0&&i().baseRevisionID!==h(),y=()=>i().kind===`propose-edit`&&(i().proposal?.state===`conflict`||_()||p()?.stale);return(()=>{var a=kn(),c=a.firstChild,h=c.firstChild,b=h.firstChild,S=b.nextSibling,C=S.firstChild,T=h.nextSibling,D=c.nextSibling,O=D.firstChild,k=O.firstChild.nextSibling;k.nextSibling;var A=O.nextSibling,N=A.nextSibling;return v(b,()=>Gn(i())),v(S,()=>Te(i().by),C),v(S,()=>j(i().createdAt),null),v(T,()=>i().instruction),v(O,()=>e.revisionRef(i().baseRevisionID),k),v(O,()=>G(i().handler,o),null),v(O,t(r,{get when(){return i().proposal?.appliedRevisionID},children:t=>[` · became `,E(()=>e.revisionRef(t()))]}),null),v(A,t(r,{get when(){return s().active},get children(){return Sn()}}),null),v(A,()=>s().text,null),v(D,t(r,{get when(){return i().answer},get children(){var t=Cn();return v(t,()=>i().answer),u(()=>x(t,`aria-label`,`Answer from ${G(i().handler,o)} on ${K(i().baseRevisionID,e.state.revisionNumbers)}`)),t}}),N),v(D,t(r,{get when(){return E(()=>!!(i().proposal&&i().proposal.state!==`applied`))()&&i().proposal},children:i=>(()=>{var a=An();return v(a,t(r,{get when(){return m()},get fallback(){return(()=>{var t=jn(),n=t.firstChild.nextSibling,r=n.nextSibling.nextSibling;return r.nextSibling,w(t,`click`,e.onReview,!0),v(t,()=>i().files.length,n),v(t,()=>i().files.length===1?``:`s`,r),v(t,(()=>{var e=E(()=>!!i().keep?.length);return()=>e()?`, ${i().keep.length} kept`:``})(),r),t})()},children:e=>t(l,{get children(){return[t(d,{get when(){return e().status===`loading`},get children(){return Mn()}}),t(d,{get when(){return E(()=>e().status===`error`)()&&e()},children:e=>(()=>{var t=Nn();return t.firstChild,v(t,()=>e().text,null),t})()}),t(d,{get when(){return E(()=>e().status===`ready`)()&&e()},children:e=>{let i=()=>e();return[t(r,{get when(){return i().changes.some(e=>e.path!==void 0)},get children(){var e=Pn();return v(e,t(n,{get each(){return i().changes},children:e=>(()=>{var t=In(),n=t.firstChild,r=n.nextSibling.nextSibling;return v(n,()=>e.change),v(r,()=>e.path),u(()=>M(t,`aai-file ${e.change}`)),t})()})),e}}),t(n,{get each(){return i().diffs},children:e=>(()=>{var i=zn();return v(i,t(r,{get when(){return e.path},get children(){var t=Ln(),n=t.firstChild;return v(n,()=>e.path),t}}),null),v(i,t(r,{get when(){return e.lines},get fallback(){return(()=>{var t=Bn();return v(t,()=>e.note),t})()},get children(){var r=Rn(),i=r.firstChild;return v(i,t(n,{get each(){return e.lines},children:e=>(()=>{var t=Vn(),n=t.firstChild,r=n.nextSibling,i=r.nextSibling,a=i.firstChild;return v(n,()=>e.oldNo??``),v(r,()=>e.newNo??``),v(a,(()=>{var t=E(()=>e.type===`add`);return()=>t()?`+`:e.type===`del`?`−`:` `})()),v(i,()=>e.text,null),u(()=>M(t,e.type)),t})()})),u(()=>x(r,`aria-label`,`Changes${e.path?` to ${e.path}`:``}`)),r}}),null),i})()}),t(r,{get when(){return i().truncated},get children(){return Fn()}})]}})]}})})),a})()}),N),v(D,t(r,{get when(){return E(()=>!!_())()&&!p()},get children(){return wn()}}),N),v(D,t(r,{get when(){return p()},children:e=>(()=>{var t=Hn();return v(t,()=>e().text),u(n=>{var r=`aai-note ${e().kind===`info`?`ok`:e().kind===`conflict`?`warn`:`err`}`,i=e().kind===`info`?`status`:`alert`;return r!==n.e&&M(t,n.e=r),i!==n.t&&x(t,`role`,n.t=i),n},{e:void 0,t:void 0}),t})()}),N),v(N,t(r,{get when(){return g()},get children(){var t=Tn();return w(t,`click`,e.onAccept,!0),v(t,()=>f()===`apply`?`Accepting…`:`Accept as new revision`),u(e=>{var n=!!f(),r=f()===`apply`;return n!==e.e&&(t.disabled=e.e=n),r!==e.t&&x(t,`aria-busy`,e.t=r),e},{e:void 0,t:void 0}),t}}),null),v(N,t(r,{get when(){return y()},get children(){var t=En();return w(t,`click`,e.onRerequest,!0),u(()=>t.disabled=!!f()||e.state.sending),t}}),null),v(N,t(r,{get when(){return W(i())},get children(){var t=Dn();return w(t,`click`,e.onCancel,!0),v(t,()=>f()===`cancel`?`Cancelling…`:`Cancel`),u(e=>{var n=!!f(),r=f()===`cancel`;return n!==e.e&&(t.disabled=e.e=n),r!==e.t&&x(t,`aria-busy`,e.t=r),e},{e:void 0,t:void 0}),t}}),null),v(N,t(r,{get when(){return E(()=>!!e.onContinue)()&&i().handler.sessionID},get children(){var t=On();return t.$$click=()=>e.onContinue?.(i()),t}}),null),u(e=>{var t=i().id,n=i().state,r=`${Gn(i())}: ${i().instruction}`,o=`aai-status ${s().tone}`;return t!==e.e&&x(a,`data-job`,e.e=t),n!==e.t&&x(a,`data-state`,e.t=n),r!==e.a&&x(a,`aria-label`,e.a=r),o!==e.o&&M(A,e.o=o),e},{e:void 0,t:void 0,a:void 0,o:void 0}),a})()}_([`click`,`keydown`,`input`]);var Yn={rows:1e3,columns:50,cellChars:2e3};function Xn(e){let t=e.length>Yn.columns,n=e.slice(0,Yn.columns).map(e=>i(e)),r=[];function i(e){return typeof e==`string`&&e.length>Yn.cellChars?(t=!0,e.slice(0,Yn.cellChars)):e}return{add(e,a){return r.length>=Yn.rows?(t=!0,!1):(r.push(n.map((t,n)=>i(n<e.length?e[n]:a))),!0)},done:()=>({columns:n,rows:r,truncated:t})}}function Zn(e){let t=[],n=[],r=``,i=!1,a=0,o=()=>{n.push(r),r=``,(n.length!==1||n[0]!==``)&&t.push(n),n=[]};for(;a<e.length&&t.length<=Yn.rows+1;){let t=e[a];i?t===`"`?e[a+1]===`"`?(r+=`"`,a++):i=!1:r+=t:t===`"`&&r===``?i=!0:t===`,`?(n.push(r),r=``):t===`
|
|
5
|
-
`||t===`\r`?(t===`\r`&&e[a+1]===`
|
|
6
|
-
`&&a++,o()):r+=t,a++}(r!==``||n.length)&&o();let[s,...c]=t;if(!s)return{columns:[],rows:[],truncated:!1};let l=Xn(s);for(let e of c)if(!l.add(e,``))break;return l.done()}var Qn=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null};function $n(e){if(e==null)return null;if(typeof e==`string`||typeof e==`boolean`)return e;if(typeof e==`number`)return Number.isFinite(e)?e:null;try{return JSON.stringify(e)??null}catch{return null}}function er(e){if(Qn(e)&&Array.isArray(e.columns)&&Array.isArray(e.rows)){let t=Xn(e.columns.map(String));for(let n of e.rows)if(!t.add(Array.isArray(n)?n.map($n):[],null))break;return t.done()}if(Array.isArray(e)){if(e.every(Qn)){let t=[],n=new Set;for(let r of e){for(let e of Object.keys(r))n.has(e)||(n.add(e),t.push(e));if(t.length>Yn.columns)break}let r=Xn(t);for(let n of e)if(!r.add(t.slice(0,Yn.columns).map(e=>$n(Object.hasOwn(n,e)?n[e]:null)),null))break;return r.done()}if(e.length&&e.every(Array.isArray)){let[t,...n]=e,r=Xn(t.map(String));for(let e of n)if(!r.add(e.map($n),null))break;return r.done()}}}function tr(e,t){if(t===``)return e;let n=e;for(let e of t.split(`.`))if(Array.isArray(n)){if(!/^\d{1,6}$/.test(e))return;let t=Number(e);if(t>=n.length)return;n=n[t]}else if(Qn(n)){if(e===`__proto__`||!Object.hasOwn(n,e))return;n=n[e]}else return;return n}function nr(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e!=`string`||e.trim()===``)return;let t=Number(e.trim());return Number.isFinite(t)?t:void 0}function rr(e,t){switch(t){case`application/json`:try{return{ok:!0,format:`json`,value:JSON.parse(e)}}catch{return{ok:!1,error:`The JSON is not valid`}}case`text/csv`:return{ok:!0,format:`table`,value:Zn(e)};case`text/markdown`:case`text/plain`:return{ok:!0,format:`text`,value:e};default:return{ok:!1,error:`${t} isn't data`}}}function ir(e){if(e.ok){if(e.format===`table`)return e.value;if(e.format===`json`)return er(e.value)}}var Z={widgets:24,sources:8,refreshMinSeconds:30,refreshMaxSeconds:86400,defaultRefreshSeconds:300,staleFactor:2,concurrent:4,sourceBytes:524288,titleChars:120,markdownChars:2e4,chartSeries:4,chartPoints:500,tableRows:1e3,defaultTableRows:50},ar=e=>typeof e==`object`&&!!e&&!Array.isArray(e),or=(e,t,n)=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=t&&e<=n,sr=e=>typeof e==`string`&&e.length>=1&&e.length<=120,cr=/^(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))[A-Za-z0-9._/-]{1,200}$/,lr=/^[A-Za-z0-9_$ -]{1,64}$/,ur=/^[A-Za-z0-9_-]{1,40}$/,dr={dashboard:[`v`,`title`,`refreshSeconds`,`widgets`],binding:[`artifact`,`path`,`select`],metric:[`id`,`type`,`title`,`width`,`source`,`unit`,`precision`],table:[`id`,`type`,`title`,`width`,`source`,`columns`,`limit`],chart:[`id`,`type`,`title`,`width`,`source`,`chart`,`x`,`y`],markdown:[`id`,`type`,`title`,`width`,`text`,`source`],chartSpec:[`v`,`title`,`chart`,`x`,`y`,`data`]};function fr(e,t,n){let r=Object.keys(e).find(e=>!t.includes(e));return r===void 0?void 0:`${n} has an unknown field ${JSON.stringify(r.slice(0,40))}`}var pr=e=>`${e.artifact}|${e.path??``}`;function mr(e,t,n,r){if(!ar(e))return void r.push(`${t}.source must be an object`);let a=fr(e,dr.binding,`${t}.source`);if(a)return void r.push(a);if(!i(`artifact`,e.artifact))return void r.push(`${t}.source.artifact must be an artifact ID`);if(n!==void 0&&e.artifact===n)return void r.push(`${t}: a dashboard can't bind to itself`);if(e.path!==void 0&&(typeof e.path!=`string`||!cr.test(e.path)))return void r.push(`${t}.source.path must be a relative file path`);if(e.select!==void 0&&(typeof e.select!=`string`||e.select.length>200||!e.select.split(`.`).every(e=>lr.test(e))))r.push(`${t}.source.select must be a dot path like "0.count"`);else return{artifact:e.artifact,...e.path===void 0?{}:{path:e.path},...e.select===void 0?{}:{select:e.select}}}function hr(e,t,n,r){let i=`widget ${t+1}`;if(!ar(e))return void r.push(`${i} must be an object`);let a=e.type;if(a!==`metric`&&a!==`table`&&a!==`chart`&&a!==`markdown`)return void r.push(`${i}: type must be metric, table, chart or markdown`);let o=fr(e,dr[a],i);if(o)return void r.push(o);let s=r.length;(typeof e.id!=`string`||!ur.test(e.id))&&r.push(`${i}: id must be 1–40 letters, digits, - or _`),e.title!==void 0&&(typeof e.title!=`string`||e.title.length>Z.titleChars)&&r.push(`${i}: title must be at most ${Z.titleChars} characters`),e.width!==void 0&&e.width!==1&&e.width!==2&&e.width!==3&&r.push(`${i}: width must be 1, 2 or 3`);let c={id:e.id,...e.title===void 0?{}:{title:e.title},width:e.width??1};if(a===`markdown`){e.text!==void 0&&e.source!==void 0?r.push(`${i}: a markdown widget has either text or a source`):e.text===void 0&&e.source===void 0&&r.push(`${i}: a markdown widget needs text or a source`),e.text!==void 0&&(typeof e.text!=`string`||e.text.length>Z.markdownChars)&&r.push(`${i}: text must be at most ${Z.markdownChars} characters`);let t=e.source===void 0?void 0:mr(e.source,i,n,r);return r.length>s?void 0:{...c,type:a,...e.text===void 0?{}:{text:e.text},...t?{source:t}:{}}}let l=mr(e.source,i,n,r);if(a===`metric`)return e.unit!==void 0&&(typeof e.unit!=`string`||e.unit.length>16)&&r.push(`${i}: unit must be at most 16 characters`),e.precision!==void 0&&!or(e.precision,0,6)&&r.push(`${i}: precision must be 0–6`),r.length>s||!l?void 0:{...c,type:a,source:l,...e.unit===void 0?{}:{unit:e.unit},...e.precision===void 0?{}:{precision:e.precision}};if(a===`table`)return e.columns!==void 0&&(!Array.isArray(e.columns)||e.columns.length>50||!e.columns.every(sr))&&r.push(`${i}: columns must be at most 50 column names`),e.limit!==void 0&&!or(e.limit,1,Z.tableRows)&&r.push(`${i}: limit must be 1–${Z.tableRows}`),r.length>s||!l?void 0:{...c,type:a,source:l,...e.columns===void 0?{}:{columns:e.columns},limit:e.limit??Z.defaultTableRows};let u=gr(e,i,r);if(!(r.length>s||!l||!u))return{...c,type:a,source:l,...u}}function gr(e,t,n){let r=n.length;return e.chart!==`line`&&e.chart!==`bar`&&n.push(`${t}: chart must be line or bar`),sr(e.x)||n.push(`${t}: x must be a column name`),(!Array.isArray(e.y)||e.y.length<1||e.y.length>Z.chartSeries||!e.y.every(sr))&&n.push(`${t}: y must be 1–${Z.chartSeries} column names`),n.length>r?void 0:{chart:e.chart,x:e.x,y:e.y}}function _r(e,t={}){if(!ar(e))return{ok:!1,problems:[`A dashboard must be a JSON object`]};if(e.v!==1)return{ok:!1,problems:[`v must be 1 (this console reads dashboard schema v1)`]};let n=fr(e,dr.dashboard,`The dashboard`);if(n)return{ok:!1,problems:[n]};let r=[];if(e.title!==void 0&&(typeof e.title!=`string`||e.title.length>Z.titleChars)&&r.push(`title must be at most ${Z.titleChars} characters`),e.refreshSeconds!==void 0&&!or(e.refreshSeconds,Z.refreshMinSeconds,Z.refreshMaxSeconds)&&r.push(`refreshSeconds must be ${Z.refreshMinSeconds}–${Z.refreshMaxSeconds}`),!Array.isArray(e.widgets))return{ok:!1,problems:[...r,`widgets must be a list`]};if(e.widgets.length>Z.widgets)return{ok:!1,problems:[`A dashboard has at most ${Z.widgets} widgets`,...r]};let i=e.widgets.flatMap((e,n)=>hr(e,n,t.selfID,r)??[]);return new Set(i.map(e=>e.id)).size!==i.length&&r.unshift(`widget ids must be unique`),new Set(i.flatMap(e=>e.source?[pr(e.source)]:[])).size>Z.sources&&r.unshift(`A dashboard reads at most ${Z.sources} data sources (artifact + file)`),r.length?{ok:!1,problems:r}:{ok:!0,spec:{v:1,...e.title===void 0?{}:{title:e.title},refreshSeconds:e.refreshSeconds??Z.defaultRefreshSeconds,widgets:i}}}function vr(e,t,n){let r=e.columns.indexOf(t);if(r<0)return{ok:!1,error:`No column "${t}"`};let i=n.map(t=>e.columns.indexOf(t)),a=n.find((e,t)=>i[t]<0);if(a!==void 0)return{ok:!1,error:`No column "${a}"`};let o=e.rows.slice(0,Z.chartPoints);return{ok:!0,chart:{labels:o.map(e=>String(e[r]??``)),series:n.map((e,t)=>({name:e,values:o.map(e=>nr(e[i[t]])??null)})),truncated:e.truncated||e.rows.length>o.length}}}function yr(e){if(!ar(e))return{ok:!1,error:`A chart must be a JSON object`};if(e.v!==1)return{ok:!1,error:`v must be 1`};let t=fr(e,dr.chartSpec,`The chart`);if(t)return{ok:!1,error:t};let n=[],r=gr(e,`The chart`,n);if(!r)return{ok:!1,error:n[0]};if(e.title!==void 0&&(typeof e.title!=`string`||e.title.length>Z.titleChars))return{ok:!1,error:`title is too long`};let i=er(e.data);if(!i)return{ok:!1,error:`data must be a table (a list of objects, a list of lists or {columns, rows})`};let a=vr(i,r.x,r.y);return a.ok?{ok:!0,kind:r.chart,...e.title===void 0?{}:{title:e.title},chart:a.chart}:a}function br(e){let t=e&&typeof e==`object`?e:{},n=typeof t.status==`number`?t.status:0;return t.name===`NetworkError`||n===503||t.code===`offline`?{kind:`offline`,text:`Can't reach the hub; showing the last data loaded.`}:n===404||t.code===`not_found`?{kind:`not_found`,text:`The source artifact doesn't exist or you can't see it.`}:n===401||n===403?{kind:`forbidden`,text:`This device isn't allowed to read the source artifact.`}:n===422||t.code===`unsupported`?{kind:`unsupported`,text:`Artifacts aren't supported on this hub.`}:t.name===`TooLargeError`||t.code===`too_large`?{kind:`too_large`,text:`The source file is larger than ${Z.sourceBytes/1024} KiB.`}:{kind:`error`,text:`Could not read the source: ${typeof t.message==`string`&&t.message?t.message:`HTTP ${n}`}`}}function xr(e){let t=new Map;for(let n of e.widgets)n.source&&!t.has(pr(n.source))&&t.set(pr(n.source),{artifact:n.source.artifact,...n.source.path?{path:n.source.path}:{}});return[...t.values()]}function Sr(e,t,n){let r=xr(e),i=new Map(r.map(e=>[pr(e),{status:`loading`}])),a,o=!1,s=(e,t)=>{o||(i.set(e,t),n.onChange())},c=(e,t)=>{let r=i.get(e),a=n.now();s(e,r?.status===`ready`?{...r,error:t,failedAt:a}:{status:`error`,error:t,failedAt:a})};async function l(e){let r=pr(e);try{let{data:i,revisionNumber:a}=await t.read(e);i.ok?s(r,{status:`ready`,data:i,revisionNumber:a,loadedAt:n.now()}):c(r,{kind:`invalid`,text:i.error})}catch(e){c(r,br(e))}}function u(){if(o)return Promise.resolve();if(a)return a;let e=[...r];return a=Promise.all(Array.from({length:Math.min(Z.concurrent,e.length)},async()=>{for(let t=e.shift();t;t=e.shift())await l(t)})).then(()=>{a=void 0}),a}return{refresh:u,bindings:()=>r,state:e=>i.get(e),get refreshing(){return a!==void 0},dispose(){o=!0}}}function Cr(e){if(!e.ok||e.format===`text`)return;if(e.format===`json`)return e.value;let{columns:t,rows:n}=e.value;return n.map(e=>Object.fromEntries(t.map((t,n)=>[t,e[n]??null])))}function wr(e,t){return t===void 0?ir(e):er(tr(Cr(e),t))}function Tr(e,t){let n=nr(e);if(n!==void 0)return t===void 0?String(Math.round(n*1e6)/1e6):n.toFixed(t);if(typeof e==`string`||typeof e==`boolean`)return String(e)}function Er(e,t){switch(e.type){case`markdown`:return t.ok&&t.format===`text`?{kind:`markdown`,text:t.value.slice(0,Z.markdownChars)}:`This widget needs a Markdown or text source.`;case`metric`:{if(!t.ok||t.format===`text`)return`This widget needs JSON or CSV data.`;let n=Tr(tr(Cr(t),e.source.select??``),e.precision);return n===void 0?`No single value at "${e.source.select??``}".`:{kind:`metric`,text:n,...e.unit?{unit:e.unit}:{}}}case`table`:{let n=wr(t,e.source.select);if(!n)return`This widget needs table data (CSV or a JSON list).`;let r=e.columns?e.columns.map(e=>n.columns.indexOf(e)).filter(e=>e>=0):n.columns.map((e,t)=>t);if(!r.length)return`None of the widget's columns are in the data.`;let i=n.rows.slice(0,e.limit).map(e=>r.map(t=>e[t]??null));return{kind:`table`,table:{columns:r.map(e=>n.columns[e]),rows:i,truncated:n.truncated||n.rows.length>i.length}}}case`chart`:{let n=wr(t,e.source.select);if(!n)return`This widget needs table data (CSV or a JSON list).`;let r=vr(n,e.x,e.y);return r.ok?{kind:`chart`,chart:r.chart,type:e.chart}:r.error}}}function Dr(e,t,n,r){if(e.type===`markdown`&&e.text!==void 0)return{status:`ready`,stale:!1,content:{kind:`markdown`,text:e.text}};if(!t||t.status===`loading`)return{status:`loading`};if(t.status===`error`)return{status:`error`,text:t.error.text};let i=Er(e,t.data);return typeof i==`string`?{status:`error`,text:i}:{status:`ready`,stale:t.error!==void 0||n-t.loadedAt>Z.staleFactor*r,updatedAt:t.loadedAt,revisionNumber:t.revisionNumber,...t.error?{error:t.error.text}:{},content:i}}var Or=F(`<a class="av-download btn small"rel=noopener> <span class=faint>(<!>)`),kr=F(`<div class=cv><div class=cv-head><span class=cv-name></span><span class=cv-lang></span><span class=cv-count> line</span></div><div class=cv-scroll tabindex=0 role=region><pre class=cv-code><code>`),Ar=F(`<span class=cv-line><span class=cv-ln aria-hidden=true></span><span class=cv-tx>`),jr=F(`<span>`),Mr=F(`<pre class=av-text>`),Nr=F(`<div class=av-image-wrap><img class=av-image decoding=async referrerpolicy=no-referrer>`),Pr=F(`<p class=av-note>Only part of the data is shown (limits: rows, columns or cell length).`),Fr=F(`<div class=av-table-wrap><table class=av-table><thead><tr></tr></thead><tbody>`),Ir=F(`<th scope=col>`),Lr=F(`<tr>`),Rr=F(`<td>`),zr=F(`<figure class=av-chart><svg viewBox="0 0 600 240"role=img preserveAspectRatio=none><line class=av-axis></line><text class=av-tick text-anchor=end></text><text class=av-tick text-anchor=end></text></svg><figcaption class=av-legend><button type=button class="btn small">`),Br=F(`<svg><text class=av-tick y=232 text-anchor=middle></svg>`,!1,!0,!1),Vr=F(`<svg><rect class=av-bar></svg>`,!1,!0,!1),Hr=F(`<svg><polyline class=av-line fill=none stroke-width=2></svg>`,!1,!0,!1),Ur=F(`<span><i></i> `),Wr=F(`<div class=av-isolated role=note><p>This <!> artifact opens in the isolated viewer. It isn't shown inside the console, so its scripts and styles can't reach your hub session.`);function Gr(e){return e.path??`${e.mediaType} file`}var Kr=e=>e<1024?`${e} B`:`${Math.ceil(e/1024)} KiB`;function qr(e){return(()=>{var t=Or(),n=t.firstChild,r=n.nextSibling,i=r.firstChild.nextSibling;return i.nextSibling,v(t,()=>e.label??`Download ${Gr(e.file)}`,n),v(r,()=>Kr(e.file.bytes),i),u(n=>{var r=Je(e.artifactID,e.revisionID,e.file.hash),i=e.file.path?.split(`/`).pop()??``;return r!==n.e&&x(t,`href`,n.e=r),i!==n.t&&x(t,`download`,n.t=i),n},{e:void 0,t:void 0}),t})()}function Jr(e){let[n,i]=o(!1),[a,s]=o(!1),l;f(()=>clearTimeout(l));let d=c(()=>St(I(e.lang,e.text))),p=()=>wt(e.file,e.lang),m=async()=>{await te(e.text)&&(s(!0),clearTimeout(l),l=setTimeout(()=>s(!1),1500))};return(()=>{var o=kr(),s=o.firstChild,c=s.firstChild,l=c.nextSibling,f=l.nextSibling,h=f.firstChild,g=s.nextSibling,_=g.firstChild,y=_.firstChild;return v(s,t(O,{name:`code`}),c),v(c,()=>p().name),v(l,()=>p().language),v(f,()=>d().length,h),v(f,()=>d().length===1?``:`s`,null),v(s,t(S,{icon:`wrap`,get label(){return n()?`Scroll long lines`:`Wrap long lines`},get"aria-pressed"(){return n()},onClick:()=>i(!n())}),null),v(s,t(S,{get icon(){return a()?`check`:`copy`},get label(){return a()?`Copied`:`Copy code`},onClick:()=>void m()}),null),v(y,t(P,{get each(){return d()},children:(e,n)=>(()=>{var i=Ar(),a=i.firstChild,o=a.nextSibling;return x(a,`data-n`,n+1),v(o,t(P,{get each(){return e()},children:e=>t(r,{get when(){return e().kind},get fallback(){return e().text},get children(){return(()=>{var t=jr();return v(t,()=>e().text),u(()=>M(t,`tok-${e().kind}`)),t})()}})})),i})()})),u(t=>{var r=!!n(),i=String(String(d().length).length),a=e.file?.path,s=`${p().name} source`,l=e.lang||void 0;return r!==t.e&&o.classList.toggle(`wrap`,t.e=r),i!==t.t&&b(o,`--cv-digits`,t.t=i),a!==t.a&&x(c,`title`,t.a=a),s!==t.o&&x(g,`aria-label`,t.o=s),l!==t.i&&x(_,`data-lang`,t.i=l),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),o})()}function Yr(e){return(()=>{var t=Mr();return v(t,()=>e.text),t})()}function Xr(e){let t=c(t=>(t&&URL.revokeObjectURL(t),URL.createObjectURL(new Blob([e.bytes],{type:e.mediaType}))));return f(()=>URL.revokeObjectURL(t())),(()=>{var n=Nr(),r=n.firstChild;return u(n=>{var i=t(),a=e.alt;return i!==n.e&&x(r,`src`,n.e=i),a!==n.t&&x(r,`alt`,n.t=a),n},{e:void 0,t:void 0}),n})()}var Zr=e=>e==null?``:String(e);function Qr(e){return(()=>{var i=Fr(),a=i.firstChild,o=a.firstChild,s=o.firstChild,c=o.nextSibling;return v(s,t(n,{get each(){return e.table.columns},children:e=>(()=>{var t=Ir();return v(t,e),t})()})),v(c,t(P,{get each(){return e.table.rows},children:e=>(()=>{var n=Lr();return v(n,t(P,{get each(){return e()},children:e=>(()=>{var t=Rr();return v(t,()=>Zr(e())),u(()=>M(t,typeof e()==`number`?`num`:void 0)),t})()})),n})()})),v(i,t(r,{get when(){return e.table.truncated},get children(){return Pr()}}),null),u(()=>x(a,`aria-label`,e.label)),i})()}var $r=600,ei=240,Q={l:44,r:8,t:10,b:28},ti=[`var(--accent)`,`#c26b1a`,`#6b5bd6`,`#2f8f4e`];function ni(e){let i=c(()=>e.chart.series.flatMap(e=>e.values.filter(e=>e!==null))),a=c(()=>Math.min(0,...i())),s=c(()=>{let e=Math.max(0,...i());return e===a()?a()+1:e}),l=e=>Q.t+(ei-Q.t-Q.b)*(1-(e-a())/(s()-a())),d=()=>Math.max(1,e.chart.labels.length),f=()=>($r-Q.l-Q.r)/d(),p=e=>Q.l+f()*e+f()/2,m=()=>Math.max(1,Math.ceil(d()/10)),h=()=>`${e.type===`bar`?`Bar`:`Line`} chart${e.title?` of ${e.title}`:``}: ${e.chart.series.map(e=>e.name).join(`, `)} by ${e.chart.labels.length} points`,[g,_]=o(!1),y=()=>({columns:[``,...e.chart.series.map(e=>e.name)],rows:e.chart.labels.map((t,n)=>[t,...e.chart.series.map(e=>e.values[n]??null)]),truncated:e.chart.truncated});return(()=>{var i=zr(),o=i.firstChild,c=o.firstChild,d=c.nextSibling,S=d.nextSibling,C=o.nextSibling,w=C.firstChild;return v(d,()=>ri(s())),v(S,()=>ri(a())),v(o,t(P,{get each(){return e.chart.labels},children:(e,n)=>t(r,{get when(){return n%m()===0},get children(){var t=Br();return v(t,()=>e().slice(0,12)),u(()=>x(t,`x`,p(n))),t}})}),null),v(o,t(P,{get each(){return e.chart.series},children:(n,i)=>e.type===`bar`?t(P,{get each(){return n().values},children:(n,a)=>{let o=()=>f()*.8/e.chart.series.length;return t(r,{get when(){return n()!==null},get children(){var e=Vr();return u(t=>{var r=Q.l+f()*a+f()*.1+o()*i,s=Math.min(l(n()),l(0)),c=Math.max(1,o()-1),u=Math.max(1,Math.abs(l(0)-l(n()))),d=ti[i%ti.length];return r!==t.e&&x(e,`x`,t.e=r),s!==t.t&&x(e,`y`,t.t=s),c!==t.a&&x(e,`width`,t.a=c),u!==t.o&&x(e,`height`,t.o=u),d!==t.i&&x(e,`fill`,t.i=d),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}})}}):(()=>{var e=Hr();return u(t=>{var r=ti[i%ti.length],a=n().values.flatMap((e,t)=>e===null?[]:[`${p(t)},${l(e)}`]).join(` `);return r!==t.e&&x(e,`stroke`,t.e=r),a!==t.t&&x(e,`points`,t.t=a),t},{e:void 0,t:void 0}),e})()}),null),v(C,t(n,{get each(){return e.chart.series},children:(e,t)=>(()=>{var n=Ur(),r=n.firstChild;return r.nextSibling,v(n,()=>e.name,null),u(e=>b(r,`background`,ti[t()%ti.length])),n})()}),w),w.$$click=()=>_(!g()),v(w,()=>g()?`Hide data`:`Show data`),v(i,t(r,{get when(){return g()},get children(){return t(Qr,{get table(){return y()}})}}),null),u(e=>{var t=h(),n=Q.l,r=$r-Q.r,i=l(0),u=l(0),f=Q.l-6,p=l(s())+4,m=Q.l-6,_=l(a())+4,v=g();return t!==e.e&&x(o,`aria-label`,e.e=t),n!==e.t&&x(c,`x1`,e.t=n),r!==e.a&&x(c,`x2`,e.a=r),i!==e.o&&x(c,`y1`,e.o=i),u!==e.i&&x(c,`y2`,e.i=u),f!==e.n&&x(d,`x`,e.n=f),p!==e.s&&x(d,`y`,e.s=p),m!==e.h&&x(S,`x`,e.h=m),_!==e.r&&x(S,`y`,e.r=_),v!==e.d&&x(w,`aria-expanded`,e.d=v),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0}),i})()}function ri(e){let t=Math.abs(e);return t>=1e6?`${Math.round(e/1e5)/10}M`:t>=1e3?`${Math.round(e/100)/10}k`:String(Math.round(e*100)/100)}function ii(e){return(()=>{var t=Wr(),n=t.firstChild,r=n.firstChild.nextSibling;return r.nextSibling,v(n,()=>e.kind===`app`?`app`:`HTML`,r),v(t,()=>e.children,null),t})()}_([`click`]);var ai=F(`<div class="av-note err"role=alert><p>This dashboard can't be shown:</p><ul>`),oi=F(`<li>`),si=F(`<h2 class=dash-title>`),ci=F(`<section class=dash><div class=dash-bar><span class=faint>Refreshes every <!> while open · <!> of at most <!> sources</span><button type=button class="btn small dash-refresh">Refresh</button></div><div class=dash-grid>`),li=F(`<article><header class=dash-head><h3>`),ui=F(`<span class=dash-stale>Stale · updated `),di=F(`<span class="dash-rev faint">rev `),fi=F(`<p class=faint role=status>Loading…`),pi=F(`<p class=dash-error>`),mi=F(`<small> `),hi=F(`<p class=dash-metric><span>`);function gi(e){let i=c(()=>{try{return _r(JSON.parse(e.text),{selfID:e.artifactID})}catch{return{ok:!1,problems:[`The dashboard is not valid JSON.`]}}});return t(r,{get when(){return E(()=>!!i().ok)()&&i()},keyed:!0,get fallback(){return(()=>{var e=ai(),r=e.firstChild.nextSibling;return v(r,t(n,{get each(){return i().problems.slice(0,8)},children:e=>(()=>{var t=oi();return v(t,e),t})()})),e})()},children:n=>t(_i,{get spec(){return n.spec},get source(){return e.source}})})}function _i(e){let[i,a]=o(0),[s,c]=o(Date.now()),[l,d]=o(!1),p=Sr(e.spec,e.source,{now:Date.now,onChange:()=>a(e=>e+1)}),h=e.spec.refreshSeconds*1e3,g=async()=>{d(!0),await p.refresh(),c(Date.now()),d(!1)},_=()=>typeof document>`u`||document.visibilityState===`visible`;m(()=>{g();let e=setInterval(()=>_()&&void g(),h),t=setInterval(()=>c(Date.now()),15e3),n=()=>_()&&void g();document.addEventListener(`visibilitychange`,n),f(()=>{clearInterval(e),clearInterval(t),document.removeEventListener(`visibilitychange`,n),p.dispose()})});let y=e=>(i(),Dr(e,e.source?p.state(pr(e.source)):void 0,s(),h));return(()=>{var i=ci(),a=i.firstChild,o=a.firstChild,c=o.firstChild.nextSibling,d=c.nextSibling.nextSibling,f=d.nextSibling.nextSibling;f.nextSibling;var m=o.nextSibling,h=a.nextSibling;return v(a,t(r,{get when(){return e.spec.title},get children(){var t=si();return v(t,()=>e.spec.title),t}}),o),v(o,(()=>{var t=E(()=>e.spec.refreshSeconds<120);return()=>t()?`${e.spec.refreshSeconds} s`:`${Math.round(e.spec.refreshSeconds/60)} min`})(),c),v(o,()=>p.bindings().length,d),v(o,()=>Z.sources,f),m.$$click=()=>void g(),v(h,t(n,{get each(){return e.spec.widgets},children:e=>(()=>{var n=li(),r=n.firstChild,i=r.firstChild;return v(i,()=>e.title??``),v(r,t(vi,{get view(){return y(e)},get now(){return s()}}),null),v(n,t(yi,{get view(){return y(e)},get title(){return e.title}}),null),u(t=>{var r=`dash-widget span-${e.width}`,i=e.id,a=e.title??e.id;return r!==t.e&&M(n,t.e=r),i!==t.t&&x(n,`data-widget`,t.t=i),a!==t.a&&x(n,`aria-label`,t.a=a),t},{e:void 0,t:void 0,a:void 0}),n})()})),u(t=>{var n=e.spec.title??`Dashboard`,r=l(),a=l();return n!==t.e&&x(i,`aria-label`,t.e=n),r!==t.t&&x(m,`aria-busy`,t.t=r),a!==t.a&&(m.disabled=t.a=a),t},{e:void 0,t:void 0,a:void 0}),i})()}function vi(e){let n=()=>e.view.status===`ready`?e.view:void 0;return t(r,{get when(){return E(()=>n()?.updatedAt!==void 0)()&&n()},children:n=>t(r,{get when(){return n().stale},get fallback(){return(()=>{var e=di();return e.firstChild,v(e,()=>n().revisionNumber,null),e})()},get children(){var t=ui();return t.firstChild,v(t,()=>j(n().updatedAt,e.now),null),u(()=>x(t,`title`,n().error??`The data is older than two refresh intervals.`)),t}})})}function yi(e){return t(l,{get children(){return[t(d,{get when(){return e.view.status===`loading`},get children(){return fi()}}),t(d,{get when(){return E(()=>e.view.status===`error`)()&&e.view},children:e=>(()=>{var t=pi();return v(t,()=>e().text),t})()}),t(d,{get when(){return E(()=>e.view.status===`ready`)()&&e.view},children:n=>{let i=()=>n().content;return t(l,{get children(){return[t(d,{get when(){return E(()=>i().kind===`metric`)()&&i()},children:e=>(()=>{var n=hi(),i=n.firstChild;return v(i,()=>e().text),v(n,t(r,{get when(){return e().unit},get children(){var t=mi();return t.firstChild,v(t,()=>e().unit,null),t}}),null),n})()}),t(d,{get when(){return E(()=>i().kind===`table`)()&&i()},children:n=>t(Qr,{get table(){return n().table},get label(){return e.title}})}),t(d,{get when(){return E(()=>i().kind===`chart`)()&&i()},children:n=>t(ni,{get chart(){return n().chart},get type(){return n().type},get title(){return e.title}})}),t(d,{get when(){return E(()=>i().kind===`markdown`)()&&i()},children:e=>t(L,{get text(){return e().text}})})]}})}})]}})}_([`click`]);var bi=()=>new e(404,`No such artifact`),xi={async artifact(e){let t=$e(await C(Ge(e)));if(!t)throw bi();return t},async revisions(e,t){return nt(await C(Ke(e,t)))},async revision(e,t){let n=tt(await C(qe(e,t)));if(!n)throw bi();return n},async bytes(e,t,n,r){return pt(await A(Je(e,t,n.hash)),r)},async revise(t,n,r){let i=tt(await(await A(`${Ge(t)}/revisions`,{method:`POST`,json:n,headers:{"idempotency-key":r}})).json());if(!i)throw new e(500,`The hub answered without a revision`);return i},async archive(t,n,r){let i=$e(await(await A(`${Ge(t)}/${r?`archive`:`unarchive`}`,{method:`POST`,json:{expectedRevision:n}})).json());if(!i)throw new e(500,`The hub answered without an artifact`);return i}},Si=[`application/json`,`text/csv`,`text/markdown`,`text/plain`];function Ci(e,t){return t===void 0?(e.entry===void 0?void 0:e.blobs.find(t=>t.path===e.entry))??e.blobs.find(e=>Si.includes(e.mediaType))??e.blobs[0]:e.blobs.find(e=>e.path===t)}function wi(e=xi){return{async read(t){let n=await e.artifact(t.artifact),r=await e.revision(n.id,n.latestRevisionID),i=Ci(r,t.path);if(!i)return{data:{ok:!1,error:t.path?`The source has no file "${t.path}"`:`The source has no files`},revisionNumber:r.number};if(!Si.includes(i.mediaType))return{data:{ok:!1,error:`A ${i.mediaType} file isn't data`},revisionNumber:r.number};let a=await e.bytes(n.id,r.id,i,Z.sourceBytes);return{data:rr(new TextDecoder().decode(a),i.mediaType),revisionNumber:r.number}}}}var Ti=F(`<p class=faint>`),Ei=F(`<p class=faint>Nothing else in this workspace yet.`),Di=F(`<button type=button class="btn small">Load more`),Oi=F(`<aside class=av-outputs><h2>More in </h2><ul></ul><a class=av-outputs-all>All in the library`),ki=F(`<li><a></a> <button type=button class="btn small">Pane</button><span class=faint> · `);function Ai(e){let[i,a]=o({status:`loading`}),s=oe(e.source??ue,a),c={workspace:e.workspaceID,type:``};m(()=>s.load(c));let l=()=>{let t=i();return t.status===`ready`?t.items.filter(t=>t.id!==e.excludeID):[]};return(()=>{var a=Oi(),o=a.firstChild;o.firstChild;var c=o.nextSibling,d=c.nextSibling;return v(o,()=>e.workspaceName,null),v(a,t(r,{get when(){return i().status===`error`},get children(){var e=Ti();return v(e,()=>i().error.text),e}}),c),v(a,t(r,{get when(){return E(()=>i().status===`ready`)()&&!l().length},get children(){return Ei()}}),c),v(c,t(n,{get each(){return l()},children:e=>(()=>{var t=ki(),n=t.firstChild,r=n.nextSibling.nextSibling,i=r.nextSibling,a=i.firstChild;return v(n,()=>e.title||`Untitled`),r.$$click=()=>ne(e.id),v(i,()=>xt[e.kind],a),v(i,()=>j(e.updatedAt),null),u(t=>{var i=le(e.id),a=`Open ${e.title||`Untitled`} in a pane`;return i!==t.e&&x(n,`href`,t.e=i),a!==t.t&&x(r,`aria-label`,t.t=a),t},{e:void 0,t:void 0}),t})()})),v(a,t(r,{get when(){return E(()=>i().status===`ready`)()&&i().more},get children(){var e=Di();return e.$$click=()=>s.more(),e}}),d),u(t=>{var n=`More in ${e.workspaceName}`,r=`/artifacts?workspace=${encodeURIComponent(e.workspaceID)}`;return n!==t.e&&x(a,`aria-label`,t.e=n),r!==t.t&&x(d,`href`,t.t=r),t},{e:void 0,t:void 0}),a})()}_([`click`]);var ji=F(`<header class=av-bar><span class=av-bar-gap>`),Mi=F(`<div><div class=av-empty><p class=muted role=status>Loading…`),Ni=F(`<button type=button class="btn small">Retry`),Pi=F(`<div><div class=av-empty><p class=av-note role=alert> `),Fi=F(`<span class=av-chip>Archived`),Ii=F(`<a class="icon-btn av-wide"rel=noopener aria-label=Download>`),Li=F(`<div class=av-old role=status><span>You're viewing revision <!>.</span><button type=button class="btn small">Back to latest`),Ri=F(`<span class=av-draft>You have an unsaved draft of this artifact<!>.`),zi=F(`<div class=av-status>`),Bi=F(`<p class=av-desc>`),Vi=F(`<div><header class=av-bar><span class=av-kind role=img></span><span class=av-bar-gap></span><div class=av-tools></div></header><div class=av-split><div class=av-stage><div class="av-card av-body">`),Hi=F(`<span>`),Ui=F(`<div class=av-conflict role=alert><p>Someone changed this artifact since you opened it<!>. Your draft is kept; the latest revision is shown below. Save over it, or discard your draft.</p><button type=button class="btn small primary">Save over latest</button> <button type=button class="btn small">Discard draft`),Wi=F(`<section class=av-latest aria-label="Latest revision"><p class=av-latest-head>Latest revision`),Gi=F(`<form class=av-edit><div class=av-edit-head><span class=av-edit-name>Editing </span><span class="faint av-wide">New revision on revision </span><span class=av-bar-gap></span><button type=button class="btn small"title="Close the editor; the draft stays on this device">Close</button><button type=button class="btn small">Discard</button><button type=submit class="btn small primary">Save</button></div><textarea>`),Ki=F(`<p class="av-note err av-edit-err"role=alert>`),qi=F(`<div class=av-files><h4>Files in revision </h4><ul>`),Ji=F(`<section class=av-details role=dialog aria-label=Details><div class=av-details-head><h3>Details</h3><button type=button class=icon-btn aria-label="Close details"title="Close details"></button></div><dl class=av-facts>`),Yi=F(`<dt>`),Xi=F(`<dd>`),Zi=F(`<li>`),Qi=F(`<p class="av-note av-pad">This revision has no files.`),$i=F(`<div class=av-download-card><p class=av-note>`),ea=F(`<p class="muted av-pad"role=status>Loading…`),ta=F(`<article class=av-prose>`),na=F(`<div class=av-pad>`),ra=F(`<p class="muted av-pad">Loading…`),ia=F(`<p class="av-note av-pad"role=alert>`),aa=F(`<p class="av-note err av-pad"role=alert>`),oa=F(`<p class="av-note err av-pad">This file isn't a table (CSV or a JSON list).`),sa=F(`<p class="av-note err av-pad">This chart can't be shown: `),ca=new Set([`markdown`,`text`,`code`,`table`,`chart`,`dashboard`]),la={markdown:`doc`,code:`code`,image:`image`,table:`table`,chart:`chart`,dashboard:`grid`,html:`app`,app:`app`,file:`file`};function ua(){try{return window.localStorage}catch{return}}function da(){return`console-${[...crypto.getRandomValues(new Uint8Array(16))].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function fa(e){let n=e.source??xi,i=wi(n),[a,s]=o(),[p,g]=o(),[_,y]=o([]),[b,C]=o(),[w,T]=o(),[D,A]=o(),[j,N]=o({status:`loading`}),[P,F]=o(),[I,L]=o(new Map),[R,z]=o(),[ee,ne]=o(0),[ie,ae]=o(!1),[oe,se]=o(!1),[le,ue]=o(!1),de;f(()=>clearTimeout(de));let fe=0,B=c(()=>{let e=a(),t=D();return e&&t?ut(e.kind,t):void 0}),pe=()=>_()[0]?.number,me=()=>D()!==void 0&&D().id===a()?.latestRevisionID,he=()=>ae(!!ua()?.getItem(vt(e.id))),ge=()=>{let e=j();return e.status===`ready`?e.text:void 0};async function V(t,r){let i=++fe;N({status:`loading`});try{let a=await n.revision(t.id,r);if(i!==fe)return;A(a),e.onRevision?.(a);let o=ut(t.kind,a);if(!o.file||!ca.has(o.mode)&&o.mode!==`image`)return void N({status:`none`});let s=await n.bytes(t.id,a.id,o.file,o.mode===`image`?q.imageBytes:q.textBytes);if(i!==fe)return;N({status:`ready`,bytes:s,...o.mode===`image`?{}:{text:new TextDecoder().decode(s)}})}catch(e){i===fe&&N({status:`error`,error:mt(e)})}}async function H(e,t){try{let r=await n.revisions(e,t);y(e=>{let n=t?[...e,...r.items]:r.items,i=new Set;return n.filter(e=>!i.has(e.id)&&i.add(e.id))}),C(r.cursor)}catch{}}async function U(){try{let t=await n.artifact(e.id);s(t),g(void 0),e.onArtifact?.(t),await Promise.all([H(t.id),V(t,w()??t.latestRevisionID)])}catch(e){g(mt(e))}}m(()=>{he(),ce().then(e=>L(new Map(e.map(e=>[e.id,e.title])))),U(),e.control?.({view:e=>_e(e===a()?.latestRevisionID?void 0:e),reload:()=>{T(void 0),U()}})});let _e=e=>{T(e),F(void 0);let t=a();t&&V(t,e??t.latestRevisionID)};function ve(){let e=a(),t=D(),r=B(),i=j();e&&t&&r?.file&&i.status===`ready`&&i.text!==void 0&&(F(void 0),z(bt({artifactID:e.id,baseRevisionID:t.id,file:r.file,original:i.text},{revise:n.revise,storage:ua(),newKey:da,onChange:()=>ne(e=>e+1)})))}let ye=()=>(ee(),R()?.state());async function be(e=!1){let t=R();if(!t)return;if(e){let e=a()?.latestRevisionID;e&&t.rebase(e)}let n=await t.save();n?(z(void 0),T(void 0),await U(),F({text:`Saved revision ${n.number}.`})):t.state().status===`conflict`&&(T(void 0),await U()),he()}let xe=e=>{e&&R()?.discard(),z(void 0),he()};async function Se(){let e=ge();e!==void 0&&await te(e)&&(ue(!0),clearTimeout(de),de=setTimeout(()=>ue(!1),1500))}function Ce(){let e=a(),t=D(),n=B()?.file;if(!e||!t||!n)return;let r=document.createElement(`a`);r.href=Je(e.id,t.id,n.hash),r.download=n.path?.split(`/`).pop()??``,r.rel=`noopener`,document.body.append(r),r.click(),r.remove()}async function W(t){let r=a();if(r&&n.archive)try{let i=await n.archive(r.id,r.revision,t);s(i),e.onArtifact?.(i),F({text:t?`Archived: read only until you unarchive it.`:`Unarchived.`})}catch(e){F({text:mt(e).text,error:!0}),U()}}let G=e=>e.workspaceID?I().get(e.workspaceID)??re(e.workspaceID,I()):`Private`,we=()=>{let e=a(),t=D(),n=j();return!!e&&!!t&&me()&&!R()&&n.status===`ready`&&n.text!==void 0&>(e,t)},Te=()=>{let e=a(),t=[{label:`Details`,run:()=>se(!0)}];return ge()!==void 0&&t.push({label:`Copy contents`,run:()=>void Se()}),B()?.file&&t.push({label:`Download ${Gr(B().file)}`,run:Ce}),e&&n.archive&&t.push(`sep`,e.state===`archived`?{label:`Unarchive`,run:()=>void W(!1)}:{label:`Archive`,hint:`read only, reversible`,run:()=>void W(!0)}),t},K=()=>(()=>{var n=ji(),r=n.firstChild;return v(n,()=>e.lead,r),v(n,t(k,{get component(){return e.variant===`pane`?`h2`:`h1`},class:`av-title`,children:`Artifact`}),r),v(n,()=>e.trailing,null),n})();return t(l,{get children(){return[t(d,{get when(){return p()},children:n=>(()=>{var i=Pi(),a=i.firstChild,o=a.firstChild,s=o.firstChild;return v(i,K,a),v(o,()=>n().text,s),v(o,t(r,{get when(){return n().kind===`offline`||n().kind===`error`},get children(){var e=Ni();return e.$$click=()=>void U(),e}}),null),u(()=>M(i,`av ${e.variant??`page`}`)),i})()}),t(d,{get when(){return!a()},get children(){var t=Mi(),n=t.firstChild;return v(t,K,n),u(()=>M(t,`av ${e.variant??`page`}`)),t}}),t(d,{get when(){return a()},children:n=>(()=>{var a=Vi(),o=a.firstChild,s=o.firstChild,c=s.nextSibling,l=c.nextSibling,d=o.nextSibling,f=d.firstChild,p=f.firstChild;return v(o,()=>e.lead,s),v(s,t(O,{get name(){return la[n().kind]}})),v(o,t(k,{get component(){return e.variant===`pane`?`h2`:`h1`},class:`av-title`,get title(){return n().title||`Untitled`},get children(){return n().title||`Untitled`}}),c),v(o,t(pa,{get revs(){return _()},get current(){return D()},get latestID(){return n().latestRevisionID},get more(){return b()!==void 0},onMore:()=>void H(n().id,b()),onView:e=>_e(e===n().latestRevisionID?void 0:e)}),c),v(o,t(r,{get when(){return n().state===`archived`},get children(){return Fi()}}),c),v(l,t(r,{get when(){return ge()!==void 0},get children(){return t(S,{class:`av-wide`,get icon(){return le()?`check`:`copy`},get label(){return le()?`Copied`:`Copy`},onClick:()=>void Se()})}}),null),v(l,t(r,{get when(){return E(()=>!!D())()&&B()?.file},get children(){var e=Ii();return v(e,t(O,{name:`download`})),u(t=>{var r=Je(n().id,D().id,B().file.hash),i=B().file.path?.split(`/`).pop()??``,a=`Download ${Gr(B().file)}`;return r!==t.e&&x(e,`href`,t.e=r),i!==t.t&&x(e,`download`,t.t=i),a!==t.a&&x(e,`title`,t.a=a),t},{e:void 0,t:void 0,a:void 0}),e}}),null),v(l,t(r,{get when(){return we()},get children(){return t(S,{icon:`edit`,label:`Edit`,onClick:ve})}}),null),v(l,()=>e.actions,null),v(l,t(h,{label:`Artifact actions`,items:Te}),null),v(l,()=>e.trailing,null),v(a,t(r,{get when(){return oe()},get children(){return t(ma,{get artifact(){return n()},get revision(){return D()},get plan(){return B()},get where(){return G(n())},onClose:()=>se(!1)})}}),d),v(f,t(r,{get when(){return E(()=>!!D())()&&!me()},get children(){var e=Li(),n=e.firstChild,r=n.firstChild.nextSibling;r.nextSibling;var i=n.nextSibling;return v(e,t(O,{name:`info`}),n),v(n,()=>D().number,r),v(n,(()=>{var e=E(()=>!!pe());return()=>e()?` of ${Math.max(pe(),D().number)}`:``})(),r),i.$$click=()=>_e(void 0),e}}),p),v(f,t(r,{get when(){return E(()=>!!ie())()&&!R()||P()},get children(){var e=zi();return v(e,t(r,{get when(){return E(()=>!!ie())()&&!R()},get children(){var e=Ri(),t=e.firstChild.nextSibling;return t.nextSibling,v(e,()=>we()?`; Edit to continue it`:``,t),e}}),null),v(e,t(r,{get when(){return P()},children:e=>(()=>{var t=Hi();return v(t,()=>e().text),u(n=>{var r=e().error?`av-note err`:`av-saved`,i=e().error?`alert`:`status`;return r!==n.e&&M(t,n.e=r),i!==n.t&&x(t,`role`,n.t=i),n},{e:void 0,t:void 0}),t})()}),null),e}}),p),v(f,t(r,{get when(){return n().description},get children(){var e=Bi();return v(e,()=>n().description),e}}),p),v(p,t(r,{get when(){return E(()=>!!R())()&&ye()},get fallback(){return t(ha,{get artifact(){return n()},get revision(){return D()},get plan(){return B()},get content(){return j()},get isolated(){return e.isolated},dash:i})},children:a=>(()=>{var o=Gi(),s=o.firstChild,c=s.firstChild;c.firstChild;var l=c.nextSibling;l.firstChild;var d=l.nextSibling.nextSibling,f=d.nextSibling,p=f.nextSibling,m=s.nextSibling;return o.addEventListener(`submit`,e=>{e.preventDefault(),be()}),v(s,t(O,{name:`edit`}),c),v(c,(()=>{var e=E(()=>!!B()?.file);return()=>e()?Gr(B().file):n().title})(),null),v(l,()=>_().find(e=>e.id===a().baseRevisionID)?.number??`?`,null),d.$$click=()=>xe(!1),f.$$click=()=>xe(!0),v(o,t(r,{get when(){return a().status===`conflict`},get children(){var e=Ui(),t=e.firstChild,n=t.firstChild.nextSibling;n.nextSibling;var r=t.nextSibling,i=r.nextSibling.nextSibling;return v(t,()=>a().restored?` (your draft was saved on an older revision)`:``,n),r.$$click=()=>void be(!0),i.$$click=()=>xe(!0),e}}),m),v(o,t(r,{get when(){return E(()=>a().status===`error`)()&&a().error},children:e=>(()=>{var t=Ki();return v(t,()=>e().text),t})()}),m),m.$$keydown=e=>{e.key===`s`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),be())},m.$$input=e=>R()?.setDraft(e.currentTarget.value),x(m,`spellcheck`,!1),v(o,t(r,{get when(){return a().status===`conflict`},get children(){var r=Wi();return r.firstChild,v(r,t(ha,{get artifact(){return n()},get revision(){return D()},get plan(){return B()},get content(){return j()},get isolated(){return e.isolated},dash:i}),null),r}}),null),u(e=>{var t=a().status===`saving`||a().status===`conflict`,r=a().status===`saving`,i=`Edit ${n().title||`artifact`}`;return t!==e.e&&(p.disabled=e.e=t),r!==e.t&&x(p,`aria-busy`,e.t=r),i!==e.a&&x(m,`aria-label`,e.a=i),e},{e:void 0,t:void 0,a:void 0}),u(()=>m.value=a().draft),o})()})),v(d,()=>e.side,null),u(t=>{var r=`av ${e.variant??`page`}`,i=n().kind,o=xt[n().kind],c=xt[n().kind],l=R()?`edit`:B()?.mode;return r!==t.e&&M(a,t.e=r),i!==t.t&&x(a,`data-kind`,t.t=i),o!==t.a&&x(s,`aria-label`,t.a=o),c!==t.o&&x(s,`title`,t.o=c),l!==t.i&&x(p,`data-mode`,t.i=l),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),a})()})]}})}function pa(e){let n=()=>[{section:`Versions`},...e.revs.map(t=>({label:`Revision ${t.number}${t.id===e.latestID?` (latest)`:``}`,hint:`${rt(t.author)} · ${j(t.createdAt)}`,checked:t.id===e.current?.id,run:()=>e.onView(t.id)})),...e.more?[`sep`,{label:`Older revisions…`,run:()=>e.onMore()}]:[]];return t(r,{get when(){return e.current},children:r=>t(h,{get label(){return`Version: revision ${r().number}${r().id===e.latestID?` (latest)`:``}. Show versions`},get class(){return`av-ver${r().id===e.latestID?``:` old`}`},align:`left`,get text(){return[`v`,E(()=>r().number),t(O,{name:`down`})]},items:n})})}function ma(e){let i,a,o=t=>{t.key===`Escape`&&!y(i)&&(t.preventDefault(),e.onClose())},s=t=>{!i.contains(t.target)&&!t.target.closest?.(`.menu`)&&e.onClose()};m(()=>{document.addEventListener(`keydown`,o),setTimeout(()=>document.addEventListener(`mousedown`,s),0),a.focus()}),f(()=>{document.removeEventListener(`keydown`,o),document.removeEventListener(`mousedown`,s)});let c=()=>Tt(e.artifact,{...e.artifact.workspaceID?{workspaceName:e.where}:{},when:j});return(()=>{var o=Ji(),s=o.firstChild,l=s.firstChild.nextSibling,u=s.nextSibling,d=i;typeof d==`function`?g(d,o):i=o,l.$$click=()=>e.onClose();var f=a;return typeof f==`function`?g(f,l):a=l,v(l,t(O,{name:`close`})),v(o,t(r,{get when(){return e.artifact.description},get children(){var t=Bi();return v(t,()=>e.artifact.description),t}}),u),v(u,t(n,{get each(){return c()},children:e=>[(()=>{var t=Yi();return v(t,()=>e.label),t})(),(()=>{var t=Xi();return v(t,()=>e.value),t})()]})),v(o,t(r,{get when(){return E(()=>!!e.revision)()&&e.plan?.files.length},get children(){var r=qi(),i=r.firstChild;i.firstChild;var a=i.nextSibling;return v(i,()=>e.revision.number,null),v(a,t(n,{get each(){return e.plan.files},children:n=>(()=>{var r=Zi();return v(r,t(qr,{get artifactID(){return e.artifact.id},get revisionID(){return e.revision.id},file:n,get label(){return Gr(n)}})),r})()})),r}}),null),v(o,t(r,{get when(){return e.artifact.workspaceID},children:n=>t(Ai,{get workspaceID(){return n()},get workspaceName(){return e.where},get excludeID(){return e.artifact.id}})}),null),o})()}function ha(e){let n=()=>e.content.status===`ready`?e.content.text??``:``,i=c(()=>e.plan?.mode===`table`&&e.plan.file?ir(rr(n(),e.plan.file.mediaType)):void 0),a=c(()=>{if(e.plan?.mode===`chart`)try{return yr(JSON.parse(n()))}catch{return{ok:!1,error:`The chart is not valid JSON.`}}});return t(l,{get children(){return[t(d,{get when(){return!e.plan||!e.revision},get children(){return t(r,{get when(){return E(()=>e.content.status===`error`)()&&e.content},get fallback(){return ra()},children:e=>(()=>{var t=ia();return v(t,()=>e().error.text),t})()})}}),t(d,{get when(){return e.plan.mode===`isolated`},get children(){return t(r,{get when(){return e.isolated},get fallback(){return t(ii,{get kind(){return e.artifact.kind}})},children:n=>t(r,{get when(){return e.revision?.id},keyed:!0,children:t=>n()(e.artifact,e.revision)})})}}),t(d,{get when(){return e.plan.mode===`empty`},get children(){return Qi()}}),t(d,{get when(){return e.plan.mode===`download`},get children(){var n=$i(),r=n.firstChild;return v(n,t(O,{name:`file`}),r),v(r,()=>e.plan.note),v(n,t(qr,{get artifactID(){return e.artifact.id},get revisionID(){return e.revision.id},get file(){return e.plan.file}}),null),n}}),t(d,{get when(){return e.content.status===`loading`},get children(){return ea()}}),t(d,{get when(){return E(()=>e.content.status===`error`)()&&e.content},children:e=>(()=>{var t=aa();return v(t,()=>e().error.text),t})()}),t(d,{get when(){return e.plan.mode===`markdown`},get children(){var e=ta();return v(e,t(L,{get text(){return n()}})),e}}),t(d,{get when(){return e.plan.mode===`text`},get children(){var e=ta();return v(e,t(Yr,{get text(){return n()}})),e}}),t(d,{get when(){return e.plan.mode===`code`},get children(){return t(Jr,p({get lang(){return e.plan.lang??``},get text(){return n()}},()=>e.plan.file?{file:e.plan.file}:{}))}}),t(d,{get when(){return E(()=>e.plan.mode===`image`&&e.content.status===`ready`)()&&e.content},children:n=>t(Xr,{get bytes(){return n().bytes},get mediaType(){return e.plan.file.mediaType},get alt(){return e.artifact.title}})}),t(d,{get when(){return e.plan.mode===`table`},get children(){return t(r,{get when(){return i()},get fallback(){return oa()},children:n=>t(Qr,{get table(){return n()},get label(){return e.artifact.title}})})}}),t(d,{get when(){return E(()=>e.plan.mode===`chart`)()&&a()},children:n=>t(r,{get when(){return E(()=>!!n().ok)()&&n()},get fallback(){return(()=>{var e=sa();return e.firstChild,v(e,()=>n().error,null),e})()},children:n=>(()=>{var r=na();return v(r,t(ni,{get chart(){return n().chart},get type(){return n().kind},get title(){return n().title??e.artifact.title}})),r})()})}),t(d,{get when(){return e.plan.mode===`dashboard`},get children(){var r=na();return v(r,t(gi,{get artifactID(){return e.artifact.id},get text(){return n()},get source(){return e.dash}})),r}})]}})}_([`click`,`input`,`keydown`]);var ga=F(`<section class=cmp-consent aria-label="Requests from this artifact">`),_a=F(`<p role=status><span><span class=cmp-quote>“<!>”</span> `),va=F(`<p class="cmp-note err"role=status>`),ya=F(`<select class=aai-action aria-label="Declared action"><option value>Choose an action…`),ba=F(`<p class=cmp-note role=status>`),xa=F(`<p class="cmp-note err"role=alert>`),Sa=F(`<form class=cmp-card role=group aria-label="AI request from the artifact"><p class=cmp-card-head><span class=cmp-card-icon aria-hidden=true></span><span><strong></strong> <span class=faint>(<!>)</span> asks for AI help</span></p><blockquote class=cmp-instruction></blockquote><p class=cmp-note>Written by the artifact, not by you. Nothing is sent unless you send it. The handler you choose gets this text and a read-only copy of <!>; the artifact gets back only the answer, or that an edit awaits your review. Edits still need your Accept under AI requests.</p><div class=cmp-row><div class=aai-seg role=radiogroup aria-label="Request type"></div></div><div class=cmp-actions><button type=button class="btn small">Decline</button><button type=submit class="btn primary small">`),Ca=F(`<label class=aai-seg-item><input type=radio>`),wa=F(`<option>`),Ta={ask:`Ask`,"propose-edit":`Edit`,"run-action":`Action`},Ea={ask:`Ask (answer only)`,"propose-edit":`Propose an edit (you review it)`,"run-action":`Run a declared action`},Da={sending:`Sending…`,running:`Sent: the answer goes back to the artifact when the handler finishes (see AI requests).`,answered:`Answered: the artifact received the answer.`,proposed:`Proposed: review and Accept it under AI requests; the artifact only knows an edit awaits review.`,declined:`Declined: the artifact was told no.`,revoked:`Withdrawn: this view of the artifact ended.`,conflict:`Not sent: the artifact changed since this view opened. Reload the artifact to ask again.`,failed:`Not completed: see AI requests for why.`,cancelled:`Cancelled.`};function Oa(e){let t=e.handler;return t.session?z().find(e=>e.id===t.session)?.machineOnline??!1:t.launch?.machine?(ee.machines??[]).some(e=>e.id===t.launch.machine&&e.online):e.online}function ka(e){let i=()=>e.feed.requests().filter(e=>e.status===`awaiting`),a=()=>e.feed.requests().filter(e=>e.status!==`awaiting`).slice(-3);return t(r,{get when(){return i().length||a().length},get children(){var r=ga();return v(r,t(n,{get each(){return a()},children:e=>(()=>{var n=_a(),r=n.firstChild,i=r.firstChild,a=i.firstChild.nextSibling;return a.nextSibling,i.nextSibling,v(n,t(O,{name:`app`}),r),v(i,(()=>{var t=E(()=>e.instruction.length>80);return()=>t()?`${e.instruction.slice(0,80)}…`:e.instruction})(),a),v(r,()=>Da[e.status],null),u(t=>{var r=`cmp-done ${e.status}`,i=e.status;return r!==t.e&&M(n,t.e=r),i!==t.t&&x(n,`data-status`,t.t=i),t},{e:void 0,t:void 0}),n})()}),null),v(r,t(n,{get each(){return i()},children:n=>t(Aa,{request:n,get title(){return e.feed.title},get revName(){return e.feed.revName()},get state(){return e.state},onPick:()=>e.feed.reloadHandlers(),onApprove:t=>e.feed.approve(n.id,t),onDecline:()=>e.feed.decline(n.id)})}),null),r}})}function Aa(e){let[i,a]=o(`ask`),[s,l]=o(``),[d,f]=o(``),[p,m]=o(!1),[h,g]=o(),_=()=>e.state()?.handlers??[],y=()=>e.state()?.actions??[],b=c(()=>_().find(e=>e.key===s())),S=()=>!!s()&&(i()!==`run-action`||!!d()),C=`cmp-kind-${e.request.id}`;async function w(t){if(t.preventDefault(),!S()||p())return;m(!0),g(void 0);let n=s(),r=await e.onApprove({kind:i(),handlerKey:n,...i()===`run-action`?{action:d()}:{}});m(!1),r?kt(Ht(),n):g(e.state()?.sendError?.text??`Not sent.`)}return(()=>{var o=Sa(),c=o.firstChild,m=c.firstChild,g=m.nextSibling.firstChild,T=g.nextSibling.nextSibling,D=T.firstChild.nextSibling;D.nextSibling;var k=c.nextSibling,A=k.nextSibling,j=A.firstChild.nextSibling;j.nextSibling;var M=A.nextSibling,N=M.firstChild,P=M.nextSibling,F=P.firstChild,I=F.nextSibling;return o.addEventListener(`submit`,w),v(m,t(O,{name:`app`})),v(g,()=>e.title),v(T,()=>e.revName,D),v(k,()=>e.request.instruction),v(A,()=>e.revName,j),v(o,t(r,{get when(){return e.state()?.status===`error`},get children(){var t=va();return v(t,()=>e.state()?.error?.text??`AI requests aren't available.`),t}}),M),v(N,t(n,{each:[`ask`,`propose-edit`,`run-action`],children:e=>{let t=()=>e===`run-action`&&!y().length;return(()=>{var n=Ca(),r=n.firstChild;return r.addEventListener(`change`,()=>a(e)),x(r,`name`,C),r.value=e,v(n,()=>Ta[e],null),u(a=>{var o=i()===e,s=!!t(),c=Ea[e],l=Ea[e],u=t();return o!==a.e&&n.classList.toggle(`on`,a.e=o),s!==a.t&&n.classList.toggle(`disabled`,a.t=s),c!==a.a&&x(n,`title`,a.a=c),l!==a.o&&x(r,`aria-label`,a.o=l),u!==a.i&&(r.disabled=a.i=u),a},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),u(()=>r.checked=i()===e),n})()}})),v(M,t(r,{get when(){return i()===`run-action`},get children(){var e=ya();return e.firstChild,e.addEventListener(`change`,e=>f(e.currentTarget.value)),v(e,t(n,{get each(){return y()},children:e=>(()=>{var t=wa();return t.value=e,v(t,e),t})()}),null),u(()=>e.value=d()),e}}),null),v(o,t(Ut,{get handlers(){return _()},get value(){return s()},get onPick(){return e.onPick},onChange:l}),P),v(o,t(r,{get when(){return E(()=>!!b())()&&!Oa(b())},get children(){var e=ba();return v(e,()=>b().kind===`session`?`That session is offline: the request is queued and delivered when it reconnects.`:`That machine is offline: the new session starts when it's back.`),e}}),P),F.$$click=()=>e.onDecline(),v(I,()=>p()?`Sending…`:`Send request`),v(o,t(r,{get when(){return h()},get children(){var e=xa();return v(e,h),e}}),null),u(t=>{var n=p(),r=!S()||p()||e.state()?.status!==`ready`,i=p();return n!==t.e&&(F.disabled=t.e=n),r!==t.t&&(I.disabled=t.t=r),i!==t.a&&x(I,`aria-busy`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),o})()}_([`click`]);var ja={waiting:2,answerChars:8e3},Ma=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`ConsentRefusal`}},Na={denied:`The user declined this request`,revoked:`This view ended; the request was withdrawn`,conflict:`The artifact changed since this view opened; reload it to ask again`,cancelled:`The request was cancelled`,failed:`The AI request failed`,rate_limited:`At most ${ja.waiting} requests can wait for the user at once`},Pa=e=>new Ma(e,Na[e]),Fa=new Set([`succeeded`,`failed`,`cancelled`]);function Ia(e){let t=e.now??Date.now,n=[],r=new Map,i=!1,a=0,o=()=>e.onChange(n),s=e=>n.find(t=>t.id===e),c=(e,t)=>{n=n.map(n=>n.id===e?{...n,...t}:n),o()},l=(e,t,n)=>{let i=r.get(e);r.delete(e),c(e,{status:t}),i&&(n instanceof Ma?i.reject(n):i.resolve(n))},u=e=>e.status===`awaiting`||e.status===`sending`||e.status===`running`;function d(e){if(e.state===`cancelled`)return{status:`cancelled`,result:Pa(`cancelled`)};if(e.state!==`succeeded`)return{status:`failed`,result:Pa(`failed`)};if(e.kind===`propose-edit`)return{status:`proposed`,result:{status:`proposed`}};let t=e.answer??``,n=t.length>ja.answerChars;return{status:`answered`,result:{status:`answered`,answer:n?t.slice(0,ja.answerChars):t,...n?{truncated:!0}:{}}}}return{ask(s){if(i)return Promise.reject(Pa(`revoked`));if(n.filter(e=>e.status===`awaiting`).length>=ja.waiting)return Promise.reject(Pa(`rate_limited`));let c=`req_${++a}`;return new Promise((i,a)=>{r.set(c,{resolve:i,reject:a}),n=[...n,{id:c,instruction:s,revisionID:e.revisionID,status:`awaiting`,at:t()}],o()})},requests:()=>n,async approve(t,n){let r=s(t);if(i||!r||r.status!==`awaiting`||!n.handlerKey||n.kind===`run-action`&&(!n.action||!e.actions().includes(n.action))||n.kind!==`run-action`&&n.action!==void 0)return!1;if(e.latestRevisionID()!==e.revisionID)return l(t,`conflict`,Pa(`conflict`)),!1;c(t,{status:`sending`,kind:n.kind});let a;try{a=await e.submit({kind:n.kind,instruction:r.instruction,handlerKey:n.handlerKey,...n.action?{action:n.action}:{},baseRevisionID:e.revisionID})}catch{a=void 0}if(s(t)?.status!==`sending`)return!1;if(!a)return l(t,`failed`,Pa(`failed`)),!1;if(c(t,{status:`running`,jobID:a.id}),Fa.has(a.state)){let e=d(a);l(t,e.status,e.result)}return!0},decline(e){s(e)?.status===`awaiting`&&l(e,`declined`,Pa(`denied`))},jobs(e){if(!i)for(let t of n){if(t.status!==`running`||!t.jobID)continue;let n=e.find(e=>e.id===t.jobID);if(!n||!Fa.has(n.state))continue;let r=d(n);l(t.id,r.status,r.result)}},revoke(){if(!i){i=!0;for(let e of n)u(e)&&l(e.id,`revoked`,Pa(`revoked`))}}}}var La=`hub.artifact-bridge`,Ra=[`resize`,`askAI`],$={messageChars:16384,instructionChars:2e3,idChars:64,ratePerSecond:10,burst:20,pendingAsks:2,minHeight:0,maxHeight:2e4,errorChars:200};function za(){let e=new Uint8Array(16);return globalThis.crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}var Ba=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype,Va=[`p`,`v`,`channel`,`type`],Ha={resize:[`height`],askAI:[`id`,`instruction`]},Ua=/^[A-Za-z0-9_-]+$/,Wa=new Set([`denied`,`revoked`,`conflict`,`cancelled`,`rate_limited`,`unsupported`]);function Ga(e,t){if(!Ba(e))return{ok:!1,reason:`malformed`};let n;try{n=JSON.stringify(e).length}catch{return{ok:!1,reason:`malformed`}}if(n>$.messageChars)return{ok:!1,reason:`too_large`};if(e.p!==`hub.artifact-bridge`)return{ok:!1,reason:`protocol`};if(e.v!==1)return{ok:!1,reason:`version`};if(e.channel!==t)return{ok:!1,reason:`channel`};let r=e.type;if(r!==`resize`&&r!==`askAI`)return{ok:!1,reason:`type`};let i=new Set([...Va,...Ha[r]]);if(Object.keys(e).some(e=>!i.has(e)))return{ok:!1,reason:`invalid`};if(r===`resize`){let t=e.height;return typeof t!=`number`||!Number.isFinite(t)||t<0?{ok:!1,reason:`invalid`}:{ok:!0,message:{type:r,height:t}}}let{id:a,instruction:o}=e;return typeof a!=`string`||a.length<1||a.length>$.idChars||!Ua.test(a)||typeof o!=`string`||o.trim()===``||o.length>$.instructionChars?{ok:!1,reason:`invalid`}:{ok:!0,message:{type:r,id:a,instruction:o}}}function Ka(e){let t=e.now??Date.now,n=e.origins??[`null`],r=new Set,i=$.burst,a=t(),o=!0,s={p:La,v:1,channel:e.channel},c=t=>{o&&e.post({...s,...t})},l=(e,t)=>c(t.ok?{type:`reply`,id:e,ok:!0,result:t.result}:{type:`reply`,id:e,ok:!1,error:{code:t.code,message:t.message.slice(0,$.errorChars)}}),u=t=>(e.onReject?.(t),!1),d=()=>{let e=t();return i=Math.min($.burst,i+(e-a)/1e3*$.ratePerSecond),a=e,i<1?!1:(--i,!0)},f=(t,n)=>{if(r.has(t))return l(t,{ok:!1,code:`invalid`,message:`That request ID is already in flight`});if(r.size>=$.pendingAsks)return l(t,{ok:!1,code:`rate_limited`,message:`At most ${$.pendingAsks} requests at once`});let i=e.onAskAI;if(!i)return l(t,{ok:!1,code:`unsupported`,message:`Ask AI isn't available for this artifact view`});r.add(t),Promise.resolve().then(()=>i(n)).then(e=>l(t,{ok:!0,result:e}),e=>{let n=e?.code;l(t,{ok:!1,code:typeof n==`string`&&Wa.has(n)?n:`failed`,message:e instanceof Error?e.message:`The request failed`})}).finally(()=>r.delete(t))};return{receive(t){if(!o)return!1;let r=e.source();if(r==null||t.source!==r)return u(`source`);if(!n.includes(t.origin))return u(`origin`);if(!d())return u(`rate`);let i=Ga(t.data,e.channel);if(!i.ok)return u(i.reason);let a=i.message;return a.type===`resize`?e.onResize?.(Math.min($.maxHeight,Math.max($.minHeight,Math.ceil(a.height)))):f(a.id,a.instruction),!0},init(e){c({type:`init`,artifactID:e.artifactID,revisionID:e.revisionID,files:e.files.map(e=>({...e.path===void 0?{}:{path:e.path},mediaType:e.mediaType,bytes:e.bytes})),capabilities:[...Ra]})},dispose(){o=!1,r.clear()}}}var qa=`allow-scripts`,Ja=[`camera`,`microphone`,`geolocation`,`display-capture`,`clipboard-read`,`clipboard-write`,`fullscreen`,`payment`,`usb`,`serial`,`hid`,`midi`,`publickey-credentials-get`].map(e=>`${e} 'none'`).join(`; `),Ya=`/artifact-host/v1/`,Xa=/^\/artifact-host\/v1\/[A-Za-z0-9._-]+\/[A-Za-z0-9._/-]*$/;function Za(e){let t=e;if(t&&typeof t==`object`&&t.capability&&typeof t.capability.id==`string`&&typeof t.capability.expiresAt==`number`&&typeof t.base==`string`&&typeof t.url==`string`&&t.base.startsWith(Ya)&&t.url.startsWith(t.base)&&Xa.test(t.url)&&Array.isArray(t.files))return{capability:t.capability,base:t.base,url:t.url,files:t.files.filter(e=>e&&typeof e.mediaType==`string`&&typeof e.bytes==`number`)}}function Qa(e,t){let n=t?.error?.message,r=typeof n==`string`?n:void 0;return e===0?{kind:`error`,message:`The hub can't be reached. Check your connection and try again.`}:e===404?{kind:`error`,message:`This artifact or revision isn't available to you.`}:e===422?{kind:`error`,message:`This hub can't run interactive artifacts.`,unsupported:!0}:e===429?{kind:`error`,message:r??`Too many artifact views are open. Close some and try again.`}:e===400?{kind:`error`,message:r??`This artifact can't run in the artifact host.`}:{kind:`error`,message:r??`The artifact view failed (${e}).`}}function $a(e,t){let n=t.fetch??globalThis.fetch.bind(globalThis),r=e=>t.onState?.(e),i=encodeURIComponent,a=!1,o,s,c,l=e=>void s?.receive(e),u=()=>{let e=c;c=void 0,e&&n(`/api/agent/artifact-host/${i(e)}`,{method:`DELETE`,credentials:`same-origin`,keepalive:!0}).catch(()=>{})},d=()=>{s?.dispose(),s=void 0,window.removeEventListener(`message`,l),o?.remove(),o=void 0,u()};return r({kind:`loading`}),(async()=>{let f;try{f=await n(`/api/agent/artifacts/${i(t.artifactID)}/revisions/${i(t.revisionID)}/host`,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:JSON.stringify({ttlSeconds:t.ttlSeconds??1800})})}catch{a||r(Qa(0,void 0));return}let p=await f.json().catch(()=>void 0),m=f.status===201?Za(p):void 0;if(a){m&&(c=m.capability.id,u());return}if(!m)return r(f.status===201?{kind:`error`,message:`The hub's answer wasn't an artifact view.`}:Qa(f.status,p));c=m.capability.id;let h=document.createElement(`iframe`);h.setAttribute(`sandbox`,qa),h.setAttribute(`credentialless`,``),h.setAttribute(`referrerpolicy`,`no-referrer`),h.setAttribute(`allow`,Ja),h.title=t.title,h.className=`artifact-host-frame`,o=h,s=Ka({channel:za(),source:()=>h.contentWindow,...t.origins?{origins:t.origins}:{},post:e=>h.contentWindow?.postMessage(e,`*`),onResize:e=>h.style.height=`${Math.max(120,Math.min($.maxHeight,e))}px`,...t.onAskAI?{onAskAI:t.onAskAI}:{},...t.onReject?{onReject:t.onReject}:{}});let g=0;h.addEventListener(`load`,()=>{g++,g===1?(s?.init({artifactID:t.artifactID,revisionID:t.revisionID,files:m.files}),r({kind:`ready`})):(d(),r({kind:`stopped`,message:`The artifact tried to navigate away, so it was stopped. Reload to run it again.`}))}),window.addEventListener(`message`,l),h.src=m.url,e.append(h)})(),{iframe:()=>o,dispose(){a=!0,d()}}}var eo=F(`<p class=artifact-host-status role=status>Starting the artifact…`),to=F(`<section class=artifact-host><p class=artifact-host-note>Runs isolated: no access to your hub session, cookies or the network.</p><div class=artifact-host-box>`),no=F(`<button type=button class=artifact-host-retry>Reload`),ro=F(`<div class=artifact-host-status role=alert><p>`);function io(e){let[n,i]=o({kind:`loading`}),[a,s]=o(0),c,l,d=()=>{l?.dispose(),l=$a(c,{artifactID:e.artifactID,revisionID:e.revisionID,title:e.title,onState:i,...e.onAskAI?{onAskAI:e.onAskAI}:{}})};m(d),f(()=>l?.dispose());let p=()=>{let e=n();return e.kind===`error`?{message:e.message,unsupported:e.unsupported===!0}:e.kind===`stopped`?{message:e.message,unsupported:!1}:void 0},h=()=>{s(a()+1),d()};return(()=>{var i=to(),o=i.firstChild.nextSibling;v(i,t(r,{get when(){return n().kind===`loading`},get children(){return eo()}}),o),v(i,t(r,{get when(){return p()},keyed:!0,children:e=>(()=>{var n=ro(),i=n.firstChild;return v(i,()=>e.message),v(n,t(r,{get when(){return!e.unsupported},get children(){var e=no();return e.$$click=h,e}}),null),n})()}),o);var s=c;return typeof s==`function`?g(s,o):c=o,u(t=>{var r=`${e.title} (interactive, isolated)`,s=n().kind===`loading`,c=a();return r!==t.e&&x(i,`aria-label`,t.e=r),s!==t.t&&x(i,`aria-busy`,t.t=s),c!==t.a&&x(o,`data-attempt`,t.a=c),t},{e:void 0,t:void 0,a:void 0}),i})()}_([`click`]);var ao=F(`<div class=cmp-interactive><p class=cmp-disclose aria-label="What this artifact may do"><span><strong>Sandboxed.</strong> This artifact may: resize its frame; ask for AI help on <!> — each request waits for your consent in the AI panel, and you choose who handles it. It can't read your hub, sessions, cookies or other artifacts, or apply changes.`),oo=()=>Object.assign(Error(`Ask AI isn't available for this artifact`),{code:`unsupported`});function so(e){let[n,r]=o([]),i=()=>e.state(),a=e.artifact.id,c=e.revision.id,l=Ia({artifactID:a,revisionID:c,latestRevisionID:()=>i()?.artifact?.latestRevisionID,actions:()=>i()?.actions??[],submit:({kind:t,instruction:n,handlerKey:r,action:i,baseRevisionID:a})=>e.ai.requestJob({kind:t,instruction:n,handlerKey:r,...i?{action:i}:{},baseRevisionID:a}),onChange:r});s(()=>l.jobs(i()?.jobs??[]));let u=()=>K(c,i()?.revisionNumbers??new Map),d={title:e.artifact.title||`This artifact`,requests:n,revName:u,approve:(e,t)=>l.approve(e,t),decline:e=>l.decline(e),reloadHandlers:()=>void e.ai.reloadHandlers()};e.onConsent(d,!0),f(()=>{l.revoke(`closed`),e.onConsent(d,!1)});let p=e=>i()?.status===`error`?Promise.reject(oo()):l.ask(e);return(()=>{var n=ao(),r=n.firstChild,i=r.firstChild,o=i.firstChild.nextSibling.nextSibling;return o.nextSibling,v(n,t(io,{artifactID:a,revisionID:c,get title(){return e.artifact.title||`Interactive artifact`},onAskAI:p}),r),v(r,t(O,{name:`lock`}),i),v(i,u,o),n})()}var co=F(`<div class=awb-scrim aria-hidden=true>`),lo=F(`<div class=awb-resize role=separator aria-orientation=vertical aria-label="Resize AI panel"tabindex=0>`),uo=F(`<div class=awb-grab aria-hidden=true>`),fo=F(`<div class=awb-side>`),po=F(`<button type=button class=icon-btn aria-label="Close AI panel"title="Close AI panel">`),mo=F(`<div>`),ho=F(`<span class=awb-badge aria-hidden=true>`),go=F(`<button type=button class=awb-ai-toggle aria-label="AI panel"><span class=awb-ai-text>AI`),_o=720;function vo(e){let[n,i]=o(),c=He({source:Kn(),artifactID:e.id,onState:i});m(()=>void c.load()),f(()=>c.dispose());let[l,d]=o(),[h,_]=o(),y,b,S=Pt(Ht()),[C,w]=o(!1),[T,D]=o(!1),[k,A]=o(S.width??Y.default),j=()=>!C()&&Ft(Ht(),{open:T(),width:k()}),P=(e=!T())=>{D(e),j()};m(()=>{let e=!1,t=()=>{let t=b.clientWidth;if(!t)return;let n=C(),r=t<_o;(r!==n||!e)&&(w(r),D(r?!1:Pt(Ht()).open??!0)),e=!0,r||A(e=>Nt(e,t))};t();let n=new ResizeObserver(t);n.observe(b),f(()=>n.disconnect())});let F=()=>h()?.requests().filter(e=>e.status===`awaiting`).length??0;s(a(F,(e,t)=>e>(t??0)&&D(!0)));let I=()=>F()+(n()?.jobs.filter(e=>W(e)).length??0);function L(e){if(e.button!==0)return;e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId);let n=b.getBoundingClientRect().right,r=b.clientWidth,i=e=>A(Nt(n-e.clientX,r)),a=()=>{t.removeEventListener(`pointermove`,i),t.removeEventListener(`pointerup`,a),t.removeEventListener(`pointercancel`,a),b.classList.remove(`resizing`),j()};b.classList.add(`resizing`),t.addEventListener(`pointermove`,i),t.addEventListener(`pointerup`,a),t.addEventListener(`pointercancel`,a)}function z(e){let t=b.clientWidth,n=e.shiftKey?64:24,r=e.key===`ArrowLeft`?k()+n:e.key===`ArrowRight`?k()-n:e.key===`Home`?Y.min:e.key===`End`?Y.max:void 0;r!==void 0&&(e.preventDefault(),A(Nt(r,t)),j())}let ee=[t(r,{get when(){return E(()=>!!C())()&&T()},get children(){var e=co();return e.$$click=()=>P(!1),e}}),(()=>{var i=fo();return i.$$keydown=e=>{e.key===`Escape`&&C()&&!e.defaultPrevented&&(e.preventDefault(),P(!1))},v(i,t(r,{get when(){return!C()},get children(){var e=lo();return e.$$keydown=z,e.$$pointerdown=L,u(t=>{var n=Y.min,r=Y.max,i=k();return n!==t.e&&x(e,`aria-valuemin`,t.e=n),r!==t.t&&x(e,`aria-valuemax`,t.t=r),i!==t.a&&x(e,`aria-valuenow`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e}}),null),v(i,t(r,{get when(){return C()},get children(){return uo()}}),null),v(i,t(qn,{get artifactID(){return e.id},controller:{ai:c,state:n},get revisionID(){return l()},onShowRevision:e=>y?.view(e),onRevised:()=>y?.reload(),onContinueInSideChat:e=>e.handler.sessionID&&R(e.handler.sessionID),get headerActions(){return(()=>{var e=po();return e.$$click=()=>P(!1),v(e,t(O,{name:`close`})),e})()},get threadTail(){return t(r,{get when(){return h()},children:e=>t(ka,{get feed(){return e()},state:n})})},get tailCount(){return h()?.requests().length??0}}),null),u(e=>{var t=!!C(),n=!T(),r=C()?void 0:{width:`${k()}px`};return t!==e.e&&i.classList.toggle(`sheet`,e.e=t),n!==e.t&&(i.hidden=e.t=n),e.a=N(i,r,e.a),e},{e:void 0,t:void 0,a:void 0}),i})()];return(()=>{var i=mo(),a=b;return typeof a==`function`?g(a,i):b=i,v(i,t(fa,p({get id(){return e.id},get variant(){return e.layout},control:e=>y=e,onRevision:e=>d(e.id),onArtifact:t=>e.onArtifact?.(t),isolated:(e,r)=>t(so,{artifact:e,revision:r,ai:c,state:n,onConsent:(e,t)=>_(n=>t?e:n===e?void 0:n)})},()=>e.lead?{lead:e.lead}:{},{get actions(){return[E(()=>e.actions),(()=>{var e=go(),n=e.firstChild;return e.$$click=()=>P(),v(e,t(O,{name:`spark`}),n),v(e,t(r,{get when(){return I()},get children(){var e=ho();return v(e,I),e}}),null),u(t=>{var n=T(),r=T()?`Hide the AI panel`:`Ask AI about this artifact`;return n!==t.e&&x(e,`aria-pressed`,t.e=n),r!==t.t&&x(e,`title`,t.t=r),t},{e:void 0,t:void 0}),e})()]}},()=>e.trailing?{trailing:e.trailing}:{},{side:ee}))),u(t=>{var n=`awb ${e.layout}`,r=!!C(),a=e.id;return n!==t.e&&M(i,t.e=n),r!==t.t&&i.classList.toggle(`narrow`,t.t=r),a!==t.a&&x(i,`data-artifact`,t.a=a),t},{e:void 0,t:void 0,a:void 0}),i})()}_([`click`,`keydown`,`pointerdown`]);export{vo as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ArtifactPage-Cb1DcrQf.js","assets/ui-Qo2Pd9-O.js","assets/index-DifgVuKS.js","assets/pane-layout-Csk-vPNe.js","assets/plural-Bspvoqfq.js","assets/index-DVSkeAvn.css","assets/ArtifactWorkbench-C37tZZ3e.js","assets/source-BFLJQ43_.js","assets/ArtifactWorkbench-9eTj1CeW.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{At as e,Bt as t,C as n,Ct as r,Et as i,Lt as a,Mt as o,Nt as s,Ot as c,Pt as l,S as u,Tt as d,Wt as f,dt as p,ft as m,ht as h,lt as g,pt as _,u as v,yt as y}from"./ui-Qo2Pd9-O.js";import{F as b,I as x,L as S,j as C,t as w,z as T}from"./index-DifgVuKS.js";import{a as E,c as D,i as O,l as k,n as A,o as j,r as M,s as N,t as P}from"./source-BFLJQ43_.js";var F=y(`<p class="lib-intro muted">Everything your sessions made, across workspaces.`),I=y(`<div class=lib-filters><label><span>Workspace</span><select aria-label=Workspace><option value>All workspaces</option><option value=none>No workspace</option></select></label><label><span>Type</span><select aria-label=Type><option value>All types`),L=y(`<p class=muted role=status>Loading artifacts…`),R=y(`<option>`),z=y(`<p class="lib-note err"role=alert> <button type=button class="btn small">Retry`),B=y(`<p class=lib-note>`),V=y(`<ul class=lib-list aria-label=Artifacts>`),H=y(`<p class="lib-note err"role=alert>`),U=y(`<button type=button class="btn lib-more">Load more`),W=y(`<p class=lib-desc>`),G=y(`<li class=lib-row><a class=lib-title></a><button type=button class="btn small lib-pane">Open in pane</button><span class=lib-meta><span class=lib-kind></span><span></span><span>`),K=t(()=>C(()=>import(`./ArtifactPage-Cb1DcrQf.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))),q={markdown:`Markdown`,code:`Code`,image:`Image`,table:`Table`,chart:`Chart`,dashboard:`Dashboard`,html:`HTML`,app:`App`,file:`File`};function J(t){return e(i,{get when(){return t.rest[0]},keyed:!0,get fallback(){return e(X,{})},children:t=>e(K,{id:t})})}var Y=(e,t)=>e.workspace===t.workspace&&e.type===t.type;function X(){let t=s(()=>N(u().search),void 0,{equals:Y}),[p,g]=a({status:`loading`}),v=O(P,g);o(()=>v.load(t()));let[y,b]=a(new Map);f(()=>void A().then(e=>b(new Map(e.map(e=>[e.id,e.title])))));let x=e=>n(`/artifacts${j({...t(),...e})}`),S=s(()=>{let e=new Set(y().keys()),n=p();if(n.status===`ready`)for(let t of n.items)t.workspaceID&&e.add(t.workspaceID);let r=t().workspace;return r&&r!==`none`&&e.add(r),[...e].map(e=>({id:e,label:D(e,y())}))}),C=()=>{let e=p();return e.status===`error`&&e.error.kind!==`error`};return e(w,{title:`Artifacts`,get children(){return[F(),e(i,{get when(){return!C()},get children(){var n=I(),i=n.firstChild,a=i.firstChild.nextSibling,o=a.firstChild,s=o.nextSibling,c=i.nextSibling.firstChild.nextSibling,u=c.firstChild;return a.addEventListener(`change`,e=>x({workspace:e.currentTarget.value})),m(a,e(r,{get each(){return S()},children:e=>(()=>{var n=R();return m(n,()=>e.label),l(()=>n.selected=t().workspace===e.id),l(()=>n.value=e.id),n})()}),null),c.addEventListener(`change`,e=>x({type:e.currentTarget.value})),m(c,e(r,{get each(){return[...k]},children:e=>(()=>{var n=R();return n.value=e,m(n,()=>q[e]),l(()=>n.selected=t().type===e),n})()}),null),l(e=>{var n=t().workspace===``,r=t().workspace===`none`,i=t().type===``;return n!==e.e&&(o.selected=e.e=n),r!==e.t&&(s.selected=e.t=r),i!==e.a&&(u.selected=e.a=i),e},{e:void 0,t:void 0,a:void 0}),n}}),e(c,{get children(){return[e(d,{get when(){return p().status===`loading`},get children(){return L()}}),e(d,{get when(){return _(()=>p().status===`error`)()&&p()},children:t=>{let n=()=>t().error;return e(i,{get when(){return n().kind===`error`},get fallback(){return(()=>{var e=B();return m(e,()=>n().text),e})()},get children(){var e=z(),t=e.firstChild,r=t.nextSibling;return m(e,()=>n().text,t),r.$$click=()=>v.reload(),e}})}}),e(d,{get when(){return _(()=>p().status===`ready`)()&&p()},children:n=>{let a=()=>n();return[e(i,{get when(){return a().items.length},get fallback(){return(()=>{var e=B();return m(e,()=>E(t(),a().more)),e})()},get children(){var t=V();return m(t,e(r,{get each(){return a().items},children:t=>e(Q,{item:t,get names(){return y()}})})),t}}),e(i,{get when(){return a().moreError},get children(){var e=H();return m(e,()=>a().moreError),e}}),e(i,{get when(){return a().more},get children(){var e=U();return e.$$click=()=>v.more(),l(t=>{var n=a().loadingMore,r=a().loadingMore;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&h(e,`aria-busy`,t.t=r),t},{e:void 0,t:void 0}),e}})]}})]}})]}})}function Z(e,t){return e.workspaceID?D(e.workspaceID,t):`Private`}function Q(t){let n=()=>t.item;return(()=>{var r=G(),a=r.firstChild,o=a.nextSibling,s=o.nextSibling.firstChild,c=s.nextSibling,u=c.nextSibling;return g(r,`dragend`,b),r.addEventListener(`dragstart`,e=>x(e,{target:{artifactID:n().id},label:n().title||`Untitled`})),m(a,()=>n().title||`Untitled`),o.$$click=()=>T(n().id),m(s,()=>q[n().kind]),m(c,()=>Z(n(),t.names)),m(u,()=>v(n().updatedAt)),m(r,e(i,{get when(){return n().description},get children(){var e=W();return m(e,()=>n().description),e}}),null),l(e=>{var t=n().id,i=!S(),s=M(n().id),c=`Open ${n().title||`Untitled`} in a pane`;return t!==e.e&&h(r,`data-artifact`,e.e=t),i!==e.t&&h(r,`draggable`,e.t=i),s!==e.a&&h(a,`href`,e.a=s),c!==e.o&&h(o,`aria-label`,e.o=c),e},{e:void 0,t:void 0,a:void 0,o:void 0}),r})()}p([`click`]);export{J as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderer2d-DILxLFEq.js","assets/live-D-RZbeUi.js","assets/ui-Qo2Pd9-O.js","assets/plural-Bspvoqfq.js","assets/index-DifgVuKS.js","assets/pane-layout-Csk-vPNe.js","assets/index-DVSkeAvn.css","assets/live-BUofsQpz.css","assets/safe-area-BS6ii3M7.js","assets/renderer3d-PvN9Qbt2.js","assets/renderer3d-Co5yCKMg.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{$ as e,At as t,C as n,Ct as r,Et as i,Gt as a,Ht as o,It as s,Lt as c,Mt as l,Nt as u,Ot as d,Pt as f,S as p,T as m,Tt as h,Ut as g,Vt as _,Wt as v,a as y,bt as b,dt as x,ft as S,g as ee,gt as C,ht as w,i as T,lt as E,pt as D,r as O,u as k,ut as A,yt as j}from"./ui-Qo2Pd9-O.js";import{B as M,F as N,H as te,I as P,L as F,N as ne,P as I,R as re,j as L}from"./index-DifgVuKS.js";import{$ as ie,A as R,C as ae,D as oe,F as se,H as ce,I as le,J as ue,K as de,L as fe,M as pe,N as me,O as he,P as ge,Q as _e,R as ve,S as ye,T as be,U as xe,V as Se,W as Ce,X as we,Y as Te,Z as Ee,a as De,at as Oe,b as ke,ct as Ae,et as je,f as Me,ft as Ne,g as Pe,i as Fe,it as Ie,j as Le,k as z,l as Re,lt as B,m as ze,n as Be,nt as Ve,o as He,ot as Ue,p as We,q as Ge,r as Ke,rt as qe,s as V,t as Je,tt as Ye,u as Xe,ut as Ze,v as Qe,w as H,x as U,z as $e}from"./live-D-RZbeUi.js";var et=Object.create,W=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,nt=Object.getOwnPropertyNames,rt=Object.getPrototypeOf,it=Object.prototype.hasOwnProperty,at=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),G=(e,t)=>{let n={};for(var r in e)W(n,r,{get:e[r],enumerable:!0});return t||W(n,Symbol.toStringTag,{value:`Module`}),n},K=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=nt(t),a=0,o=i.length,s;a<o;a++)s=i[a],!it.call(e,s)&&s!==n&&W(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=tt(t,s))||r.enumerable});return e},ot=(e,t,n)=>(n=e==null?{}:et(rt(e)),K(t||!e||!e.__esModule||!it.call(e,`default`)?W(n,`default`,{value:e,enumerable:!0}):n,e)),st=[`machine`,`harness`,`state`,`team`,`role`,`project`,`workspace`,`tag`,`meta`],q={machine:`Machine`,harness:`Harness`,state:`State`,team:`Team`,role:`Role`,project:`Project`,workspace:`Workspace`,tag:`Tag`,meta:`Metadata`},ct=`watchtower.filtersOpen`,lt=`watchtower.legendOpen`;function ut(e,t={}){let n=[];for(let r of st){let i=e[r];if(!i)continue;let a=r===`state`?R[e.state]:r===`machine`||r===`harness`||r===`team`?t[r]?.(i)??i:i;n.push({key:r,label:q[r],value:a,clear:{[r]:void 0}})}if(e.q&&n.push({key:`q`,label:`Search`,value:e.q,clear:{q:void 0}}),e.kinds){let t=ie(e).kinds.size;n.push({key:`kinds`,label:`Lines`,value:t===be.length?`all kinds`:`${t} of ${be.length} kinds`,clear:{kinds:void 0}})}return e.tree===!1&&n.push({key:`tree`,label:`Session tree`,value:`off`,clear:{tree:void 0}}),n}var dt=e=>ut(e).filter(e=>e.key!==`q`).length,ft=(e,t)=>st.filter(n=>!!e[n]||t.includes(n)),pt=(e,t)=>{let n=new Set(ft(e,t));return st.filter(e=>!n.has(e))},mt=(e,t)=>e===`1`||e!==`0`&&t;function ht(e,t,n){if(!(n<=0))switch(t){case`ArrowRight`:case`ArrowDown`:return(e+1)%n;case`ArrowLeft`:case`ArrowUp`:return(e-1+n)%n;case`Home`:return 0;case`End`:return n-1;default:return}}var gt=2500;function J(e){return e.panelOpen||e.focusInside||e.hover?!1:e.now-e.lastActivity>=gt}var _t=(e,t)=>e>Math.min(120,t/4),vt=j(`<div class=wt-backdrop aria-hidden=true>`),yt=j(`<section role=dialog tabindex=-1><header class=wt-panel-head><h2></h2></header><div class=wt-panel-body>`),bt=j(`<div class=wt-handle aria-hidden=true>`);function xt(e){let n,r=t=>{e.onClose(),t&&e.opener&&queueMicrotask(()=>document.getElementById(e.opener)?.focus())};return v(()=>{e.autoFocus&&n.focus({preventScroll:!0})}),[t(i,{get when(){return e.phone},get children(){var e=vt();return e.$$click=()=>r(!1),e}}),(()=>{var i=yt(),a=i.firstChild,o=a.firstChild,s=a.nextSibling;i.$$keydown=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),r(!0))};var c=n;return typeof c==`function`?b(c,i):n=i,S(i,t(St,{onClose:()=>r(!1)}),a),S(o,()=>e.title),S(a,()=>e.actions,null),S(a,t(T,{icon:`close`,get label(){return`Close ${e.title.toLowerCase()}`},onClick:()=>r(!0)}),null),S(s,()=>e.children),f(t=>{var n=e.id,r=`wt-panel wt-sheetable ${e.class??``}`,a=!!e.phone,s=e.phone?`true`:`false`,c=`${e.id}-title`,l=`${e.id}-title`;return n!==t.e&&w(i,`id`,t.e=n),r!==t.t&&A(i,t.t=r),a!==t.a&&i.classList.toggle(`wt-sheet`,t.a=a),s!==t.o&&w(i,`aria-modal`,t.o=s),c!==t.i&&w(i,`aria-labelledby`,t.i=c),l!==t.n&&w(o,`id`,t.n=l),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),i})()]}function St(e){let t=0,n=0,r=null,i=t=>{if(!r)return;let i=r.offsetHeight;r.style.transform=``,r.style.transition=``,r=null,t&&_t(n,i)&&e.onClose()};return(()=>{var e=bt();return e.addEventListener(`pointercancel`,()=>i(!1)),e.$$pointerup=()=>i(!0),e.$$pointermove=e=>{r&&(n=Math.max(0,e.clientY-t),r.style.transform=`translateY(${n}px)`)},e.$$pointerdown=e=>{r=e.currentTarget.closest(`.wt-sheetable`),r&&(t=e.clientY,n=0,r.style.transition=`none`,e.currentTarget.setPointerCapture?.(e.pointerId))},e})()}x([`click`,`keydown`,`pointerdown`,`pointermove`,`pointerup`]);var Ct=j(`<div class=te-row><button type=button class="btn small">Edit team</button><a class="btn small">Open team page`),wt=j(`<p role=alert class=wt-error>Could not load the timeline: <!> <button type=button class=btn>Retry`),Tt=j(`<p class=muted>Loading…`),Et=j(`<p class=muted>No messages in this window.`),Dt=j(`<button type=button class=btn>Load older`),Ot=j(`<aside class="wt-slider wt-sheetable"aria-label=Details><header class=wt-slider-head><h2></h2></header><div class=wt-slider-body><section class=wt-section><h3>Timeline</h3><ol class=wt-timeline>`),kt=j(`<p class=muted>This is no longer in the chosen window.`),At=j(`<span class=muted>Loading…`),jt=j(`<span class=wt-error>`),Mt=j(`<div class=wt-text>`),Nt=j(`<div class="wt-text wt-answer"><span class=muted>Answer: `),Pt=j(`<li><div class=wt-tl-row><span class=wt-tl-kind></span><span> → </span><span class=muted> · `),Ft=j(`<button type=button class="btn wt-show-text">Show text`),It=j(`<dl class=wt-facts>`),Lt=j(`<dt>`),Rt=j(`<dd>`),zt=j(`<section class=wt-section><h3>Members</h3><ul class=wt-peers>`),Bt=j(`<p class=wt-actions><a class="btn primary"href=/concierge>`),Vt=j(`<span class="btn wt-drag"draggable=true title="Drag onto a pane: an edge splits, the centre replaces"aria-hidden=true> Drag into a pane`),Ht=j(`<p class=wt-actions><a class="btn primary">Open session</a> <button type=button class=btn>Open in pane beside</button> <button type=button class=btn>Start side chat…`),Ut=j(`<section class=wt-section><h3>Supervised by</h3><button type=button class=wt-link>`),Wt=j(`<section class=wt-section><h3>Parent</h3><button type=button class=wt-link>`),Gt=j(`<section class=wt-section><h3>Subsessions</h3><ul class=wt-peers>`),Kt=j(`<section class=wt-section><h3>Talks with</h3><ul class=wt-peers>`),qt=j(`<li><button type=button class=wt-link></button><span class=muted> · `),Jt=j(`<li><button type=button class=wt-link>`),Yt=j(`<p class=wt-endpoints><button type=button class=wt-link></button><span aria-hidden=true> → </span><span class=sr-only> to </span><button type=button class=wt-link>`),Xt={msg:`Message`,ask:`Ask`,reply:`Reply`,decline:`Decline`};function Zt(e){let n,a=t=>e.snap.nodes.find(e=>e.id===t)?.label??t,[s,u]=c([]),[p,m]=c(),[_,y]=c(`loading`),[x,C]=c(``),[E,O]=c({}),A=0,j=async t=>{let n=++A,r=e.selection;y(`loading`);try{let i=await ke(r,e.window,Date.now(),t?p():void 0);if(n!==A)return;u(t?[...s(),...i.messages]:i.messages),m(i.cursor),y(`ready`)}catch(e){if(n!==A)return;C(ae(e).message),y(`error`)}};l(o(()=>`${e.selection.type}:${e.selection.id}:${e.window}`,()=>{u([]),m(void 0),O({}),j(!1)}));let M=async e=>{O({...E(),[e]:`loading`});try{let t=await U(e);O({...E(),[e]:t})}catch(t){O({...E(),[e]:{error:ae(t).message}})}};v(()=>{let t=t=>{t.key===`Escape`&&!t.defaultPrevented&&!ee()&&e.onClose()};document.addEventListener(`keydown`,t),g(()=>document.removeEventListener(`keydown`,t))});let N=()=>e.edge?e.edge.label:e.node?.title??e.selection.id;return(()=>{var o=Ot(),c=o.firstChild,l=c.firstChild,u=c.nextSibling,m=u.firstChild,g=m.firstChild.nextSibling,v=n;return typeof v==`function`?b(v,o):n=o,S(o,t(St,{onClose:()=>e.onClose()}),c),S(l,N),S(c,t(T,{icon:`close`,label:`Close details`,onClick:()=>e.onClose()}),null),S(u,t(d,{get fallback(){return kt()},get children(){return[t(h,{get when(){return e.edge},children:n=>t(rn,{get edge(){return n()},get onSelect(){return e.onSelect}})}),t(h,{get when(){return e.node},children:n=>t(nn,{get node(){return n()},label:a,get onSelect(){return e.onSelect}})})]}}),m),S(u,t(i,{get when(){return D(()=>e.node?.kind===`team`)()&&e.onEditTeam},get children(){var t=Ct(),n=t.firstChild,r=n.nextSibling;return n.$$click=()=>e.onEditTeam(e.node.id),f(()=>w(r,`href`,`/teams/${encodeURIComponent(e.node.id)}`)),t}}),m),S(m,t(i,{get when(){return _()===`error`},get children(){var e=wt(),t=e.firstChild.nextSibling,n=t.nextSibling.nextSibling;return S(e,x,t),n.$$click=()=>void j(!1),e}}),g),S(g,t(r,{get each(){return s()},children:e=>{let n=()=>E()[e.id];return(()=>{var r=Pt(),o=r.firstChild.firstChild,s=o.nextSibling,c=s.firstChild,l=s.nextSibling,u=l.firstChild;return S(o,()=>Xt[e.kind]??e.kind),S(s,()=>a(e.from),c),S(s,()=>a(e.to),null),S(l,()=>e.state,u),S(l,(()=>{var t=D(()=>!!e.delivery);return()=>t()?` · ${$e(e.delivery)}`:``})(),u),S(l,()=>e.decisionID?` · Decision`:``,u),S(l,()=>k(e.at),null),S(r,t(d,{get fallback(){return(()=>{var t=Ft();return t.$$click=()=>void M(e.id),t})()},get children(){return[t(h,{get when(){return n()===`loading`},get children(){return At()}}),t(h,{get when(){return D(()=>typeof n()==`object`&&n()!==null)()&&`error`in n()},get children(){var e=jt();return S(e,()=>n().error),e}}),t(h,{get when(){return D(()=>typeof n()==`object`&&n()!==null)()&&`text`in n()},get children(){return[(()=>{var e=Mt();return S(e,()=>n().text),e})(),t(i,{get when(){return n().answer},get children(){var e=Nt();return e.firstChild,S(e,()=>n().answer,null),e}})]}})]}}),null),r})()}})),S(m,t(i,{get when(){return _()===`loading`},get children(){return Tt()}}),null),S(m,t(i,{get when(){return D(()=>_()===`ready`)()&&!s().length},get children(){return Et()}}),null),S(m,t(i,{get when(){return D(()=>_()===`ready`)()&&p()},get children(){var e=Dt();return e.$$click=()=>void j(!0),e}}),null),o})()}function Qt(e){return(()=>{var n=It();return S(n,t(r,{get each(){return e.rows.filter(e=>e[1]!==void 0&&e[1]!==``)},children:([e,t])=>[(()=>{var t=Lt();return S(t,e),t})(),(()=>{var e=Rt();return S(e,t),e})()]})),n})()}var $t=e=>Se(e),en=e=>e&&Object.keys(e).length?Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`, `):void 0,tn=e=>e?Object.entries(e).map(([e,t])=>`${e} ${t}`).join(`, `):void 0;function nn(e){let n=()=>e.node,a={current:`Concierge (hub-managed session)`,previous:`Previous Concierge session (ended)`,service:`The hub's Concierge service (its updates, digests and launches)`},o=()=>n().conciergeRole?a[n().conciergeRole]:n().concierge?a.current:{hub:`Hub`,user:`You`,app:`App`,machine:`Machine`,session:`Session`,team:`Team`}[n().kind];return[t(Qt,{get rows(){return[[`Kind`,o()],[`State`,n().ring?R[n().ring]:void 0],[`Machine`,n().machine],[`Harness`,n().harness],[`Project`,n().project],[`Mode`,n().team?.mode===`restricted`?`Restricted: only its team paths`:n().team?.mode===`open`?`Open: everyone may message everyone`:void 0],[`Entry role`,n().team?.entryRole],[`Paused`,n().team?.paused?`yes`:void 0],[n().kind===`team`?`Roles`:`Directory roles`,n().roles.join(`, `)||void 0],[`Teams`,n().seats.map(e=>`${e.team} (${e.role})`).join(`, `)||void 0],[`Tags`,(n().team?.tags??n().tags).join(`, `)||void 0],[`Launch labels`,en(n().labels)],[`Metadata`,en(n().team?.metadata)],[`Workspaces`,n().workspaceIDs.join(`, `)||void 0],[`Launch`,n().launchID],[`Last seen`,n().lastSeen?k(n().lastSeen):void 0],...n().kind===`hub`||n().kind===`machine`?[[`Messages through it`,n().routed]]:[[`Sent`,n().sent],[`Received`,n().received]],[`By kind`,Object.entries(n().byKind).map(([e,t])=>`${$t(e)} ${t}`).join(`, `)||void 0],[`Sessions`,n().states?Object.entries(n().states).map(([e,t])=>`${R[e]} ${t}`).join(`, `):void 0],[`Machines online`,n().machinesOnline?`${n().machinesOnline.online} of ${n().machinesOnline.total}`:void 0]]}}),t(i,{get when(){return n().team?.members.length},get children(){var i=zt(),a=i.firstChild.nextSibling;return S(a,t(r,{get each(){return[...n().team.members]},children:t=>(()=>{var n=qt(),r=n.firstChild,i=r.nextSibling;return i.firstChild,r.$$click=()=>e.onSelect({type:`node`,id:t.id}),S(r,()=>t.label),S(i,()=>t.role,null),n})()})),i}}),t(i,{get when(){return D(()=>!!n().openable)()&&n().concierge},get children(){var e=Bt(),t=e.firstChild;return S(t,()=>n().conciergeRole===`previous`?`Open the current Concierge`:`Open the Concierge`),e}}),t(i,{get when(){return D(()=>!!n().openable)()&&!n().concierge},get children(){var e=Ht(),r=e.firstChild,a=r.nextSibling.nextSibling,o=a.nextSibling.nextSibling;return a.$$click=()=>M(n().id),S(e,t(i,{get when(){return!F()},get children(){return[(()=>{var e=Vt(),r=e.firstChild;return E(e,`dragend`,N),e.addEventListener(`dragstart`,e=>P(e,{target:{sessionID:n().id},label:n().title})),S(e,t(O,{name:`grip`}),r),e})(),` `]}}),o),o.$$click=()=>I(n().id,n().workspaceIDs[0]?{workspaceID:n().workspaceIDs[0]}:{}),f(()=>w(r,`href`,m(n().id))),e}}),t(i,{get when(){return n().supervisorID},get children(){var t=Ut(),r=t.firstChild.nextSibling;return r.$$click=()=>e.onSelect({type:`node`,id:n().supervisorID}),S(r,()=>n().supervisorLabel??n().supervisorID),t}}),t(i,{get when(){return n().parentID},get children(){var t=Wt(),r=t.firstChild.nextSibling;return r.$$click=()=>e.onSelect({type:`node`,id:n().parentID}),S(r,()=>e.label(n().parentID)),t}}),t(i,{get when(){return n().children.length},get children(){var i=Gt(),a=i.firstChild.nextSibling;return S(a,t(r,{get each(){return[...n().children]},children:t=>(()=>{var n=Jt(),r=n.firstChild;return r.$$click=()=>e.onSelect({type:`node`,id:t}),S(r,()=>e.label(t)),n})()})),i}}),t(i,{get when(){return n().peers.length},get children(){var i=Kt(),a=i.firstChild.nextSibling;return S(a,t(r,{get each(){return[...n().peers]},children:t=>(()=>{var n=qt(),r=n.firstChild,i=r.nextSibling;return i.firstChild,r.$$click=()=>e.onSelect({type:`node`,id:t.id}),S(r,()=>t.label),S(i,()=>t.count,null),n})()})),i}})]}function rn(e){let n=()=>e.edge;return[(()=>{var t=Yt(),r=t.firstChild,i=r.nextSibling.nextSibling.nextSibling;return r.$$click=()=>e.onSelect({type:`node`,id:n().from}),S(r,()=>n().fromLabel),i.$$click=()=>e.onSelect({type:`node`,id:n().to}),S(i,()=>n().toLabel),t})(),t(Qt,{get rows(){return[[`Messages`,n().kind===`policy`?void 0:n().count],[`First`,n().firstAt?k(n().firstAt):void 0],[`Last`,n().lastAt?k(n().lastAt):void 0],[`States`,tn(n().states)],[`Delivery`,ve(n().delivery)],[`Declined`,n().declined],[`Refused by team policy`,n().denied],[`To a role address`,n().roleAddressed],[`Team`,n().teamLabel??n().teamID],[`Permitted kinds`,n().kinds?.join(`, `)],[`Permitted path`,n().permitted===void 0?void 0:n().permitted?`yes`:`no (refused attempts only)`]]}})]}x([`click`]);var an=j(`<svg viewBox="0 0 24 24"width=16 height=16 fill=none stroke=currentColor stroke-width=1.8 stroke-linecap=round stroke-linejoin=round aria-hidden=true>`),on=j(`<svg><path></svg>`,!1,!0,!1),sn=j(`<button type=button class=wt-dock-item><span class=wt-dock-text>`),cn=j(`<span class="wt-dock-matches muted"role=status> `),ln=j(`<span class=wt-dock-search><input type=search aria-label="Search nodes"placeholder="Search @name, role, machine…"><button type=button class=wt-dock-close aria-label="Close search"title="Close search">`),un=j(`<div class=wt-dock-wrap><div class=wt-dock role=toolbar aria-label="Watchtower controls"aria-orientation=horizontal><div class=wt-dock-seg role=group aria-label=View></div><span class=wt-dock-sep aria-hidden=true></span><span class=wt-dock-more>`),dn=j(`<button type=button class="wt-dock-item wt-dock-view">`),fn=j(`<span class=wt-badge aria-hidden=true>`),pn=j(`<button type=button class=wt-dock-item aria-label=Search title="Search nodes"aria-expanded=false>`),mn={filters:[`M4 6h16`,`M7 12h10`,`M10 18h4`],legend:[`M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18z`,`M12 11v6`,`M12 7.5h.01`],teams:[`M9 11a3 3 0 1 0 0-6a3 3 0 0 0 0 6z`,`M3 20a6 6 0 0 1 12 0`,`M16 5.5a3 3 0 0 1 0 5.5`,`M21 20a6 6 0 0 0-4-5.6`],hub:[`M12 9a3 3 0 1 0 0 6a3 3 0 0 0 0-6z`,`M12 3v6`,`M12 15v6`,`M3 12h6`,`M15 12h6`],reset:[`M4 9V4h5`,`M20 9V4h-5`,`M4 15v5h5`,`M20 15v5h-5`],pause:[`M8 5v14`,`M16 5v14`],play:[`M7 5l12 7-12 7z`],search:[`M11 4a7 7 0 1 0 0 14a7 7 0 0 0 0-14z`,`M20 20l-4-4`],close:[`M6 6l12 12`,`M18 6L6 18`],more:[`M5 12h.01`,`M12 12h.01`,`M19 12h.01`]};function hn(e){return(()=>{var n=an();return S(n,t(r,{get each(){return[...mn[e.name]]},children:e=>(()=>{var t=on();return w(t,`d`,e),t})()})),f(()=>w(n,`class`,`wt-glyph wt-glyph-${e.name}`)),n})()}function gn(e){let n,a,[o,s]=c(!!e.search),[l,u]=c(!1),[d,p]=c(Date.now()),[m,h]=c(Date.now()),[_,x]=c(!1),[ee,C]=c(!1),T=()=>J({now:m(),lastActivity:d(),panelOpen:e.panelOpen,focusInside:ee(),hover:_()}),E,D=()=>{let e=Date.now();e-d()<150&&!T()||(p(e),h(e),clearTimeout(E),E=setTimeout(()=>h(Date.now()),gt+50))},O=!1;v(()=>{let e=[`pointermove`,`pointerdown`,`touchstart`,`keydown`,`wheel`];for(let t of e)window.addEventListener(t,D,{passive:!0});let t=e=>{O&&(O=!1,e.preventDefault(),e.stopPropagation())};n.addEventListener(`click`,t,!0),D(),A();let r=n.parentElement,i=r?new ResizeObserver(()=>u(r.clientWidth<=540)):void 0;r&&i.observe(r),g(()=>i?.disconnect()),g(()=>{n.removeEventListener(`click`,t,!0);for(let t of e)window.removeEventListener(t,D);clearTimeout(E)})});let k=()=>[...n.querySelectorAll(`.wt-dock-item`)].filter(e=>e.offsetParent!==null&&!e.disabled),A=e=>{let t=k(),r=e&&t.includes(e)?e:t.find(e=>e.tabIndex===0)??t[0];for(let e of n.querySelectorAll(`.wt-dock-item`))e.tabIndex=e===r?0:-1},j=e=>{let t=e.target;if(t.tagName===`INPUT`||!t.classList.contains(`wt-dock-item`))return;let n=k(),r=ht(n.indexOf(t),e.key,n.length);r!==void 0&&(e.preventDefault(),n[r].focus())},M=!1,N=()=>{M=!0,s(!0)},te=()=>{s(!1),queueMicrotask(()=>a?.focus())},P=e=>(()=>{var n=sn(),r=n.firstChild;return n.$$click=()=>e.onClick(),S(n,t(i,{get when(){return e.glyph},children:e=>t(hn,{get name(){return e()}})}),r),S(r,()=>e.text),S(n,()=>e.badge,null),f(t=>{var r=e.id,i=!!e.wide,a=e.label,o=e.title??e.label,s=e.pressed,c=e.expanded,l=e.expanded?e.controls:void 0,u=e.disabled;return r!==t.e&&w(n,`id`,t.e=r),i!==t.t&&n.classList.toggle(`wt-dock-wide`,t.t=i),a!==t.a&&w(n,`aria-label`,t.a=a),o!==t.o&&w(n,`title`,t.o=o),s!==t.i&&w(n,`aria-pressed`,t.i=s),c!==t.n&&w(n,`aria-expanded`,t.n=c),l!==t.s&&w(n,`aria-controls`,t.s=l),u!==t.h&&(n.disabled=t.h=u),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),n})();return(()=>{var s=un(),c=s.firstChild,u=c.firstChild,d=u.nextSibling.nextSibling;c.$$focusout=e=>{n.contains(e.relatedTarget)||C(!1)},c.$$focusin=e=>{C(!0),e.target.classList.contains(`wt-dock-item`)&&A(e.target)},c.$$pointerdown=e=>{O=T()&&e.pointerType===`touch`},c.addEventListener(`pointerleave`,()=>x(!1)),c.addEventListener(`pointerenter`,()=>x(!0)),c.$$keydown=j;var p=n;return typeof p==`function`?b(p,c):n=c,S(u,t(r,{each:[[`3d`,`3D`],[`2d`,`2D`],[`list`,`List`]],children:([t,n])=>(()=>{var r=dn();return r.$$click=()=>e.setView(t),S(r,n),f(()=>w(r,`aria-pressed`,e.view===t)),r})()})),S(c,()=>P({id:`wt-dock-filters`,label:e.filterCount?`Filters (${e.filterCount} active)`:`Filters`,text:`Filters`,glyph:`filters`,expanded:e.filtersOpen,controls:`wt-filters`,onClick:e.onFilters,badge:t(i,{get when(){return e.filterCount},get children(){var t=fn();return S(t,()=>e.filterCount),t}})}),d),S(c,()=>P({id:`wt-dock-legend`,label:`Legend`,text:`Legend`,glyph:`legend`,expanded:e.legendOpen,controls:`wt-legend`,onClick:e.onLegend}),d),S(c,()=>P({id:`wt-dock-teams`,label:`Teams`,text:`Teams`,glyph:`teams`,pressed:e.teamsOpen,onClick:e.onTeams}),d),S(c,()=>P({label:`Hub details`,text:`Hub`,glyph:`hub`,wide:!0,onClick:e.onHub}),d),S(c,()=>P({label:`Reset view`,text:`Reset`,glyph:`reset`,wide:!0,disabled:!e.drawn,onClick:e.onReset}),d),S(c,()=>P({label:e.paused?`Resume motion`:`Pause motion`,text:e.paused?`Resume`:`Pause`,glyph:e.paused?`play`:`pause`,wide:!0,pressed:e.paused,disabled:e.reduced,...e.reduced?{title:`Motion is off: your system asks for reduced motion`}:{},onClick:e.onPause}),d),S(d,t(y,{label:`More controls`,class:`wt-dock-item`,up:!0,align:`right`,items:()=>[...l()?[{label:`Hub details`,run:e.onHub},{label:`Reset view`,run:e.onReset,disabled:!e.drawn},{label:e.paused?`Resume motion`:`Pause motion`,run:e.onPause,disabled:e.reduced}]:[],{label:`Re-layout`,run:()=>e.onRelayout?.(),disabled:!e.canRelayout}],get text(){return t(hn,{name:`more`})}})),S(c,t(i,{get when(){return o()},get fallback(){return(()=>{var e=pn();e.$$click=N;var n=a;return typeof n==`function`?b(n,e):a=e,S(e,t(hn,{name:`search`})),e})()},get children(){var n=ln(),r=n.firstChild,a=r.nextSibling;return S(n,t(hn,{name:`search`}),r),r.$$keydown=t=>{t.key===`Enter`?(t.preventDefault(),e.onSearchEnter()):t.key===`Escape`&&(t.preventDefault(),te())},r.$$input=t=>e.onSearch(t.currentTarget.value),b(e=>{M&&(M=!1,queueMicrotask(()=>e.focus()))},r),S(n,t(i,{get when(){return e.search.trim()},get children(){var t=cn(),n=t.firstChild;return S(t,()=>e.matches??0,n),S(t,()=>e.matches===1?`match`:`matches`,null),t}}),a),a.$$click=te,S(a,t(hn,{name:`close`})),f(()=>r.value=e.search),n}}),null),f(e=>{var t=T()?`true`:`false`,n=o()?`open`:void 0;return t!==e.e&&w(c,`data-faded`,e.e=t),n!==e.t&&w(c,`data-search`,e.t=n),e},{e:void 0,t:void 0}),s})()}x([`click`,`keydown`,`pointerdown`,`focusin`,`focusout`,`input`]);var _n=j(`<label class=wt-field><span></span><input type=text class=wt-meta aria-label=Metadata aria-describedby=wt-meta-help placeholder="key=value"list=wt-meta-keys><datalist id=wt-meta-keys></datalist><span id=wt-meta-help class=sr-only>Launch labels and team metadata: key=value or key, several separated by spaces (all must match).`),vn=j(`<option>`),yn=j(`<fieldset class=wt-fs><legend>View</legend><div class=wt-fs-row><label class=wt-field><span>Time window</span><select aria-label="Time window"></select></label><label class=wt-field><span>Group by</span><select aria-label="Group by"></select></label><label class=wt-check><input type=checkbox><span>Session tree`),bn=j(`<div class=wt-scope>`),xn=j(`<select class=wt-add aria-label="Add filter"><option value selected>+ Add filter`),Sn=j(`<fieldset class=wt-fs><legend>Scope`),Cn=j(`<fieldset class=wt-fs><legend>Show</legend><div class=wt-kinds>`),wn=j(`<form class=wt-preset-form><input type=text aria-label="Preset name"placeholder="Preset name"maxlength=60><button type=submit class="btn small">Save</button><button type=button class="btn small">Cancel`),Tn=j(`<button type=button class="btn small">Delete preset`),En=j(`<footer class=wt-panel-foot role=group aria-label=Presets><select aria-label="Filter presets"><option value></option></select><span class=wt-foot-gap></span><button type=button class="btn small">Clear filters</button><button type=button class="btn small">Copy link</button><span class="muted wt-copied"role=status>`),Dn=j(`<p class="muted wt-fs-empty">Everything is shown. Add a filter to narrow it.`),On=j(`<div class=wt-scope-row><button type=button class=wt-x>×`),kn=j(`<label class=wt-toggle><input type=checkbox><span>`),An=j(`<button type=button class="btn small">Save preset`),jn=j(`<button type=button class=wt-chip-clear>Clear all`),Mn=j(`<div class=wt-chipbar><ul class=wt-chips aria-label="Active filters">`),Nn=j(`<li class=wt-chip><span><span class=wt-chip-label>:</span> </span><button type=button class=wt-x title=Remove>×`),Pn=j(`<label class=wt-field><span></span><select><option value>`),Fn={machine:void 0,harness:void 0,state:void 0,team:void 0,role:void 0,project:void 0,workspace:void 0,tag:void 0,meta:void 0,q:void 0,kinds:void 0,tree:void 0},In={get(e){try{return localStorage.getItem(e)}catch{return null}},set(e,t){try{localStorage.setItem(e,t)}catch{}}};function Ln(e){let[n,a]=c([]),o=()=>ft(e.url,n()),s=()=>pt(e.url,n()),l=()=>ie(e.url).kinds,u=(t,n)=>e.setURL({[t]:n.trim()?n:void 0}),d=e=>{a([...n(),e]),queueMicrotask(()=>document.getElementById(`wt-scope-${e}`)?.focus())},p=t=>{a(n().filter(e=>e!==t)),e.setURL({[t]:void 0})},m=(t,n)=>{let r=new Set(l());n?r.add(t):r.delete(t),e.setURL({kinds:be.filter(e=>r.has(e))})},[h,g]=c(je(In.get(oe))),[_,v]=c(``),[y,x]=c(!1),[ee,C]=c(``),[T,E]=c(``),D=e=>{g(e),In.set(oe,JSON.stringify(e))},O=t=>{v(t);let n=h().find(e=>e.name===t);n&&e.go(se(e.url,n.search))},k=()=>{let t=ee().trim();t&&(D(Oe(h(),t,qe(e.url))),v(t),x(!1),C(``))},A=async()=>{try{await navigator.clipboard.writeText(location.href),E(`Link copied`)}catch{E(`Copy the address bar to share these filters`)}setTimeout(()=>E(``),3e3)},j=n=>{let i=q[n],a=`wt-scope-${n}`;switch(n){case`machine`:return t(Y,{id:a,label:i,all:`All machines`,get value(){return e.url.machine},get options(){return e.machines},onChange:e=>u(n,e)});case`harness`:return t(Y,{id:a,label:i,all:`All harnesses`,get value(){return e.url.harness},get options(){return e.harnesses},onChange:e=>u(n,e)});case`state`:return t(Y,{id:a,label:i,all:`Any state`,get value(){return e.url.state},get options(){return he.map(e=>({value:e,label:R[e]}))},onChange:t=>e.setURL({state:t||void 0})});case`team`:return t(Y,{id:a,label:i,all:`All teams`,get value(){return e.teamValue},get options(){return e.choices.teams.map(e=>({value:e.id,label:e.label}))},onChange:e=>u(n,e)});case`role`:return t(Y,{id:a,label:i,all:`Any role`,get value(){return e.url.role},get options(){return e.choices.roles.map(e=>({value:e,label:e}))},onChange:e=>u(n,e)});case`project`:return t(Y,{id:a,label:i,all:`All projects`,get value(){return e.url.project},get options(){return e.choices.projects.map(e=>({value:e,label:e}))},onChange:e=>u(n,e)});case`workspace`:return t(Y,{id:a,label:i,all:`All workspaces`,get value(){return e.url.workspace},get options(){return e.choices.workspaces.map(e=>({value:e,label:e}))},onChange:e=>u(n,e)});case`tag`:return t(Y,{id:a,label:i,all:`Any tag`,get value(){return e.url.tag},get options(){return e.choices.tags.map(e=>({value:e,label:e}))},onChange:e=>u(n,e)});case`meta`:return(()=>{var n=_n(),o=n.firstChild,s=o.nextSibling,c=s.nextSibling;return w(n,`for`,a),S(o,i),s.$$input=e=>u(`meta`,e.currentTarget.value),s.addEventListener(`change`,e=>u(`meta`,e.currentTarget.value)),w(s,`id`,a),S(c,t(r,{get each(){return[...e.choices.metaKeys]},children:e=>(()=>{var t=vn();return t.value=`${e}=`,t})()})),f(()=>s.value=e.url.meta??``),n})()}};return t(xt,{id:`wt-filters`,title:`Filters`,class:`wt-pop wt-pop-filters`,get phone(){return e.phone},get autoFocus(){return e.autoFocus},opener:`wt-dock-filters`,get onClose(){return e.onClose},get children(){return[(()=>{var n=yn(),i=n.firstChild.nextSibling.firstChild,a=i.firstChild.nextSibling,o=i.nextSibling,s=o.firstChild.nextSibling,c=o.nextSibling.firstChild;return a.addEventListener(`change`,t=>e.setURL({window:t.currentTarget.value})),S(a,t(r,{get each(){return Object.entries(ge)},children:([t,n])=>(()=>{var r=vn();return r.value=t,S(r,()=>n.label),f(()=>r.selected=e.url.window===t),r})()})),s.addEventListener(`change`,t=>e.setURL({groupBy:t.currentTarget.value})),S(s,t(r,{get each(){return Object.entries(H)},children:([t,n])=>(()=>{var r=vn();return r.value=t,S(r,n),f(()=>r.selected=e.url.groupBy===t),r})()})),c.addEventListener(`change`,t=>e.setURL({tree:t.currentTarget.checked?void 0:!1})),f(()=>c.checked=e.url.tree!==!1),n})(),(()=>{var e=Sn();return e.firstChild,S(e,t(i,{get when(){return o().length},get fallback(){return Dn()},get children(){var e=bn();return S(e,t(r,{get each(){return o()},children:e=>(()=>{var t=On(),n=t.firstChild;return S(t,()=>j(e),n),n.$$click=()=>p(e),f(t=>{var r=`Remove ${q[e]} filter`,i=`Remove ${q[e]} filter`;return r!==t.e&&w(n,`aria-label`,t.e=r),i!==t.t&&w(n,`title`,t.t=i),t},{e:void 0,t:void 0}),t})()})),e}}),null),S(e,t(i,{get when(){return s().length},get children(){var e=xn();return e.firstChild,e.addEventListener(`change`,e=>{let t=e.currentTarget.value;e.currentTarget.value=``,t&&d(t)}),S(e,t(r,{get each(){return s()},children:e=>(()=>{var t=vn();return t.value=e,S(t,()=>q[e]),t})()}),null),e}}),null),e})(),(()=>{var e=Cn(),n=e.firstChild.nextSibling;return S(n,t(r,{get each(){return[...ce()]},children:e=>(()=>{var t=kn(),n=t.firstChild,r=n.nextSibling;return n.addEventListener(`change`,t=>m(e.kind,t.currentTarget.checked)),S(r,()=>e.label),f(()=>w(t,`title`,e.description)),f(()=>n.checked=l().has(e.kind)),t})()})),e})(),(()=>{var n=En(),o=n.firstChild,s=o.firstChild,c=o.nextSibling,l=c.nextSibling,u=l.nextSibling,d=u.nextSibling;return o.addEventListener(`change`,e=>O(e.currentTarget.value)),S(s,()=>h().length?`Choose a preset…`:`No presets yet`),S(o,t(r,{get each(){return h()},children:e=>(()=>{var t=vn();return S(t,()=>e.name),f(()=>t.selected=_()===e.name),f(()=>t.value=e.name),t})()}),null),S(n,t(i,{get when(){return y()},get fallback(){return(()=>{var e=An();return e.$$click=()=>x(!0),e})()},get children(){var e=wn(),t=e.firstChild,n=t.nextSibling,r=n.nextSibling;return e.addEventListener(`submit`,e=>{e.preventDefault(),k()}),b(e=>queueMicrotask(()=>e.focus()),t),t.$$input=e=>C(e.currentTarget.value),r.$$click=()=>x(!1),f(()=>n.disabled=!ee().trim()),f(()=>t.value=ee()),e}}),c),S(n,t(i,{get when(){return _()},get children(){var e=Tn();return e.$$click=()=>{D(fe(h(),_())),v(``)},e}}),c),l.$$click=()=>{a([]),e.setURL(Fn)},u.$$click=()=>void A(),S(d,T),f(t=>{var n=_()===``,r=!ut(e.url).length;return n!==t.e&&(s.selected=t.e=n),r!==t.t&&(l.disabled=t.t=r),t},{e:void 0,t:void 0}),n})()]}})}function Rn(e){return t(i,{get when(){return e.chips.length},get children(){var n=Mn(),a=n.firstChild;return S(a,t(r,{get each(){return e.chips},children:t=>(()=>{var n=Nn(),r=n.firstChild,i=r.firstChild,a=i.firstChild;i.nextSibling;var o=r.nextSibling;return S(i,()=>t.label,a),S(r,()=>t.value,null),o.$$click=()=>e.onRemove(t),f(()=>w(o,`aria-label`,`Remove filter ${t.label}: ${t.value}`)),n})()})),S(n,t(i,{get when(){return e.chips.length>1},get children(){var t=jn();return t.$$click=()=>e.onClear(),t}}),null),n}})}function Y(e){let n=()=>e.value&&!e.options.some(t=>t.value===e.value)?[...e.options,{value:e.value,label:e.value}]:e.options;return(()=>{var i=Pn(),a=i.firstChild,o=a.nextSibling,s=o.firstChild;return S(a,()=>e.label),o.addEventListener(`change`,t=>e.onChange(t.currentTarget.value)),S(s,()=>e.all),S(o,t(r,{get each(){return n()},children:t=>(()=>{var n=vn();return S(n,()=>t.label),f(()=>n.selected=e.value===t.value),f(()=>n.value=t.value),n})()}),null),f(t=>{var n=e.id,r=e.id,a=e.label,c=!e.value;return n!==t.e&&w(i,`for`,t.e=n),r!==t.t&&w(o,`id`,t.t=r),a!==t.a&&w(o,`aria-label`,t.a=a),c!==t.o&&(s.selected=t.o=c),t},{e:void 0,t:void 0,a:void 0,o:void 0}),i})()}x([`input`,`click`]);var zn=j(`<div class="wt-canvas wt-2d"><div class=wt-2d-host tabindex=0 role=application aria-roledescription="graph canvas"aria-label="Interaction graph (2D)"aria-describedby=wt-2d-help></div><p id=wt-2d-help class=sr-only>Arrow keys move between nodes, Enter opens the focused node, Home goes to the hub, Shift and arrow keys pan, plus and minus zoom, 0 fits everything. The list view shows the same as a table.</p><p class="sr-only wt-2d-live"role=status aria-live=polite>`);function Bn(e){let t,n,r=!1,i,[a,o]=c(``);return v(()=>{L(()=>import(`./renderer2d-DILxLFEq.js`).then(a=>{if(r)return;try{n=a.createRenderer2D(t,{onNode:t=>e.onNode(t),onLink:t=>e.onLink(t),onBackground:()=>e.onBackground(),announce:o})}catch(t){e.onFail(t);return}n.resize(t.clientWidth,t.clientHeight),i=e.onRenderer?.(n,t),l(()=>n?.update(e.view,e.palette,{motion:e.motion,...e.selected===void 0?{}:{selected:e.selected},...e.look?{look:e.look}:{}})),l(()=>{let t=e.focus;t&&n?.focus(t.id,e.motion)});let s=!0;l(()=>{e.resetSeq,s?s=!1:n?.reset(e.motion)})}),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).catch(t=>!r&&e.onFail(t));let a=new ResizeObserver(()=>n?.resize(t.clientWidth,t.clientHeight));a.observe(t),g(()=>{r=!0,a.disconnect(),i?.(),n?.destroy(),n=void 0})}),(()=>{var e=zn(),n=e.firstChild,r=n.nextSibling.nextSibling,i=t;return typeof i==`function`?b(i,n):t=n,S(r,a),e})()}var Vn=j(`<div class=wt-canvas>`);function Hn(){try{let e=document.createElement(`canvas`);return!!(e.getContext(`webgl2`)??e.getContext(`webgl`))}catch{return!1}}function Un(e){let t,n,r=!1,i;return v(()=>{L(()=>import(`./renderer3d-PvN9Qbt2.js`).then(a=>{if(r)return;try{n=a.createRenderer(t,{onNode:t=>e.onNode(t),onLink:t=>e.onLink(t),onBackground:()=>e.onBackground()},{motion:e.motion,...e.options?{options:e.options}:{}})}catch(t){e.onFail(t);return}n.resize(t.clientWidth,t.clientHeight),i=e.onRenderer?.(n)??void 0,l(()=>e.options&&n?.setOptions(e.options)),l(()=>n?.setSelected(e.selected));let o=!1;l(()=>{n?.update(e.view,e.palette,e.motion),o||(o=!0,setTimeout(()=>n?.reset(!1),250))}),l(()=>{let t=e.focus;t&&n?.focus(t.id,e.motion)});let s=!0;l(()=>{e.resetSeq,s?s=!1:n?.reset(e.motion)})}),__vite__mapDeps([9,1,2,3,4,5,6,7,8,10])).catch(t=>!r&&e.onFail(t));let a=new ResizeObserver(()=>n?.resize(t.clientWidth,t.clientHeight));a.observe(t);let o=()=>document.visibilityState===`hidden`?n?.pause():n?.resume();document.addEventListener(`visibilitychange`,o),g(()=>{r=!0,i?.(),a.disconnect(),document.removeEventListener(`visibilitychange`,o),n?.destroy(),n=void 0})}),(()=>{var e=Vn(),n=t;return typeof n==`function`?b(n,e):t=e,e})()}var Wn={sphere:`circle`,cube:`square`,octahedron:`diamond`,tetrahedron:`triangle`,dodecahedron:`pentagon`};function Gn(e){switch(e.kind){case`hub`:return`hub`;case`machine`:return`hexagon`;case`user`:return`ring`;case`app`:return`hollow-triangle`;case`team`:case`cluster`:return`hollow-square`;case`role`:return e.vacant?`dashed-ring`:`pill`;case`aggregate`:return`dashed-ring`;default:return Wn[e.shape??`dodecahedron`]??`pentagon`}}var Kn=e=>e===`hexagon`||e===`ring`||e===`hollow-triangle`||e===`hollow-square`||e===`dashed-ring`||e===`pill`;function qn(e,t,n,r,i,a=-Math.PI/2){e.beginPath();for(let o=0;o<i;o++){let s=a+o*2*Math.PI/i;o===0?e.moveTo(t+r*Math.cos(s),n+r*Math.sin(s)):e.lineTo(t+r*Math.cos(s),n+r*Math.sin(s))}e.closePath()}function Jn(e,t,n,r,i){switch(t){case`square`:case`hollow-square`:e.beginPath(),e.roundRect(n-i*.82,r-i*.82,i*1.64,i*1.64,i*.28);return;case`diamond`:qn(e,n,r,i*1.08,4);return;case`triangle`:case`hollow-triangle`:qn(e,n,r+i*.15,i*1.12,3);return;case`pentagon`:qn(e,n,r,i,5);return;case`hexagon`:qn(e,n,r,i,6,0);return;case`pill`:e.beginPath(),e.roundRect(n-i*1.4,r-i*.6,i*2.8,i*1.2,i*.6);return;default:e.beginPath(),e.arc(n,r,i,0,Math.PI*2)}}function Yn(e,t,n,r,i,a,o=`#ffffff`){if(e.save(),Jn(e,t,n,r,i),Kn(t))e.lineWidth=Math.max(1.2,i*.24),e.strokeStyle=a,t===`dashed-ring`&&e.setLineDash([i*.5,i*.35]),e.stroke(),e.setLineDash([]),e.beginPath(),e.arc(n,r,i*.24,0,Math.PI*2),e.fillStyle=a,e.fill();else{let s=e.createRadialGradient(n-i*.25,r-i*.3,i*.05,n,r,i*1.1);s.addColorStop(0,o),s.addColorStop(t===`hub`?.45:.3,a),s.addColorStop(1,a),e.fillStyle=s,e.fill()}e.restore()}function Xn(e,t,n,r,i,a){if(a<=0||r<=0)return;e.save(),e.globalAlpha=Math.min(1,a);let o=e.createRadialGradient(t,n,0,t,n,r);o.addColorStop(0,Zn(i,.9)),o.addColorStop(.3,Zn(i,.32)),o.addColorStop(1,Zn(i,0)),e.fillStyle=o,e.beginPath(),e.arc(t,n,r,0,Math.PI*2),e.fill(),e.restore()}function Zn(e,t){let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!n)return e;let r=n[1].length===3?[...n[1]].map(e=>e+e).join(``):n[1],[i,a,o]=[0,2,4].map(e=>parseInt(r.slice(e,e+2),16));return`rgba(${i}, ${a}, ${o}, ${Math.max(0,Math.min(1,t))})`}function Qn(e){let t=/^#([0-9a-f]{6})$/i.exec(e.trim());if(!t)return!1;let[n,r,i]=[0,2,4].map(e=>parseInt(t[1].slice(e,e+2),16)/255);return .2126*n+.7152*r+.0722*i<.4}var $n=j(`<canvas class=wt-glyph-swatch aria-hidden=true>`),er=j(`<details class=wt-legend-sec open><summary>Teams</summary><ul><li><span class="wt-hull wt-hull-open"aria-hidden=true></span><span>Open team <span class=muted>· solid hull: everyone may message everyone, so no lines are drawn</span></span></li><li><span class="wt-hull wt-hull-restricted"aria-hidden=true></span><span>Restricted team <span class=muted>· dashed hull: only its team paths</span></span></li><li><span class="wt-role wt-role-entry"aria-hidden=true>★</span><span>Entry role <span class=muted>· ★, bold and tinted: receives the team's work</span></span></li><li><span class=wt-role aria-hidden=true></span><span>Role <span class=muted>· a row of its members, each tied to it by a violet tether</span></span></li><li><span class="wt-role wt-role-vacant"aria-hidden=true></span><span>Vacant role <span class=muted>· hollow and dashed, labelled “vacant”: nobody holds it</span></span></li><li><span class="wt-line wt-line-solid wt-line-tether"aria-hidden=true></span><span>Staffed <span class=muted>· a tether from a role to each session that holds it</span></span></li><li><span class=wt-multi aria-hidden=true>×2</span><span>In several teams <span class=muted>· dotted outer ring and ×N, drawn once; a dashed bridge reaches each other seat`),tr=j(`<div class=wt-legend-body><details class=wt-legend-sec open><summary>Machines (color)</summary><ul></ul></details><details class=wt-legend-sec open><summary>Harness (glyph)</summary><ul></ul></details><details class=wt-legend-sec open><summary>Markers</summary><ul><li><span class=wt-region aria-hidden=true></span><span>Region <span class=muted>· a soft tinted area per group of the current Group by (a machine keeps its colour)</span></span></li></ul></details><details class=wt-legend-sec open><summary>State (ring)</summary><ul></ul></details><details class=wt-legend-sec open><summary>Interactions (line)</summary><ul><li><span class="wt-line wt-line-solid wt-line-structure"aria-hidden=true></span><span>Structure <span class=muted>· thin grey: hub → group → session → subsession</span></span></li></ul><p class="muted wt-legend-note">Fibers brighten towards the receiver; brighter fibers carry more messages. Pulses travel along a fiber after a message, fade with its age, and stop once nothing on it is working or waiting.`),nr=j(`<button type=button class="btn small wt-compact"title="Hide the explanations">Compact`),rr=j(`<li><span class=wt-swatch role=img></span><span><span class=muted> · <!> sessions`),ir=j(`<li><span> <span class=muted>· <!> · `),ar=j(`<li><span> <span class=muted>· `),or=j(`<li><span aria-hidden=true></span><span> <span class=muted>· `),sr={sphere:`circle`,cube:`square`,octahedron:`diamond`,tetrahedron:`triangle`,dodecahedron:`pentagon`},cr={policy:`dotted; in 2D an arrowhead at one end is one-way, at both ends two-way`,denied:`dashed red with ✕ and the count`},lr=[{glyph:`hub`,color:`--accent`,label:`Hub`,text:`the bright core in the middle`},{glyph:`ring`,color:`--text`,label:`You`,text:`hollow circle`},{glyph:`hollow-triangle`,color:`--text`,label:`App`,text:`hollow triangle`},{glyph:`hexagon`,color:`--muted`,label:`Machine`,text:`hollow hexagon, at the head of its region`},{glyph:`hollow-square`,color:`--violet`,label:`Team or cluster`,text:`hollow square`},{glyph:`dashed-ring`,color:`--muted`,label:`Folded sessions`,text:`dashed ring with the count`}];function ur(e){let t,n=()=>e.size??14,[r,i]=c(0);return v(()=>{let e=matchMedia(`(prefers-color-scheme: dark)`),t=()=>i(e=>e+1);e.addEventListener(`change`,t),g(()=>e.removeEventListener(`change`,t))}),l(()=>{ne(),r();let i=window.devicePixelRatio||1,a=n();t.width=Math.round(a*i),t.height=Math.round(a*i);let o=t.getContext(`2d`);if(!o)return;o.setTransform(i,0,0,i,0,0),o.clearRect(0,0,a,a);let s=getComputedStyle(t).getPropertyValue(e.color).trim()||`#888888`;Yn(o,e.glyph,a/2,a/2,a*.36,s,`#ffffff`)}),(()=>{var e=$n(),r=t;return typeof r==`function`?b(r,e):t=e,f(t=>{var r=`${n()}px`,i=`${n()}px`;return r!==t.e&&C(e,`width`,t.e=r),i!==t.t&&C(e,`height`,t.t=i),t},{e:void 0,t:void 0}),e})()}var dr={pulse:`pulsing ring`,thin:`thin ring`,thick:`thick ring`,double:`double ring`,broken:`broken ring`,none:`no ring`},fr=`watchtower.legendCompact`;function pr(e){let n=()=>e.view.teams.length>0||e.view.nodes.some(e=>e.teams||e.kind===`role`),[a,o]=c(mr(fr)===`1`),s=e=>{o(e);try{localStorage.setItem(fr,e?`1`:`0`)}catch{}};return t(xt,{id:`wt-legend`,title:`Legend`,get class(){return e.mode===`list`&&!e.phone?`wt-legend wt-panel-inline`:`wt-legend wt-pop wt-pop-legend`},get phone(){return e.phone},get autoFocus(){return e.autoFocus},opener:`wt-dock-legend`,get onClose(){return e.onClose},get actions(){return(()=>{var e=nr();return e.$$click=()=>s(!a()),f(()=>w(e,`aria-pressed`,a())),e})()},get children(){var o=tr(),s=o.firstChild,c=s.firstChild.nextSibling,l=s.nextSibling,u=l.firstChild.nextSibling,d=l.nextSibling,p=d.firstChild.nextSibling,m=p.firstChild,h=d.nextSibling,g=h.firstChild.nextSibling,_=h.nextSibling,v=_.firstChild.nextSibling,y=v.firstChild;return S(c,t(r,{get each(){return e.view.machines},children:e=>(()=>{var t=rr(),n=t.firstChild,r=n.nextSibling,i=r.firstChild,a=i.firstChild.nextSibling;return a.nextSibling,S(n,()=>e.symbol),S(r,()=>e.label,i),S(i,()=>e.sessions,a),S(i,()=>e.online?``:` · offline`,null),f(t=>{var r=`var(${e.color})`,i=`Marker ${e.symbol}`;return r!==t.e&&C(n,`color`,t.e=r),i!==t.t&&w(n,`aria-label`,t.t=i),t},{e:void 0,t:void 0}),t})()})),S(u,t(r,{get each(){return e.view.harnesses},children:e=>(()=>{var n=ir(),r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=a.firstChild.nextSibling;return o.nextSibling,S(n,t(ur,{get glyph(){return sr[e.shape]},color:`--muted`}),r),S(r,()=>e.label,i),S(a,()=>pe[e.shape],o),S(a,()=>e.sessions,null),n})()})),S(p,t(r,{get each(){return[...lr]},children:e=>(()=>{var n=ar(),r=n.firstChild,i=r.firstChild,a=i.nextSibling;return a.firstChild,S(n,t(ur,{get glyph(){return e.glyph},get color(){return e.color}}),r),S(r,()=>e.label,i),S(a,()=>e.text,null),n})()}),m),S(g,t(r,{get each(){return[...he]},children:e=>(()=>{var t=or(),n=t.firstChild,r=n.nextSibling,i=r.firstChild,a=i.nextSibling;return a.firstChild,S(r,()=>R[e],i),S(a,()=>dr[Le[e]],null),f(t=>{var r=`wt-ring wt-ring-${Le[e]}`,i=`var(${z[e]})`;return r!==t.e&&A(n,t.e=r),i!==t.t&&C(n,`border-color`,t.t=i),t},{e:void 0,t:void 0}),t})()})),S(o,t(i,{get when(){return n()},get children(){return er()}}),_),S(v,t(r,{get each(){return[...ce()]},children:e=>(()=>{var t=or(),n=t.firstChild,r=n.nextSibling,i=r.firstChild,a=i.nextSibling;return a.firstChild,S(r,()=>e.label,i),S(a,()=>cr[e.kind]??`solid, dashed while waiting`,null),f(r=>{var i=e.description,a=`wt-line wt-line-${e.style}`,o=`var(${e.color})`;return i!==r.e&&w(t,`title`,r.e=i),a!==r.t&&A(n,r.t=a),o!==r.a&&C(n,`border-color`,r.a=o),r},{e:void 0,t:void 0,a:void 0}),t})()}),y),f(()=>o.classList.toggle(`wt-legend-compact`,!!a())),o}})}function mr(e){try{return localStorage.getItem(e)}catch{return null}}x([`click`]);var hr=j(`<p class=muted>No sessions match.`),gr=j(`<p class=muted>No interactions match.`),_r=j(`<div class=wt-list><table class=wt-table aria-label=Sessions><thead><tr><th scope=col>Session</th><th scope=col>Machine</th><th scope=col>Harness</th><th scope=col>State</th><th scope=col>Sent</th><th scope=col>Received</th></tr></thead><tbody></tbody></table><table class=wt-table aria-label=Interactions><thead><tr><th scope=col>Kind</th><th scope=col>From → to</th><th scope=col>Messages</th><th scope=col>Last</th></tr></thead><tbody>`),vr=j(`<span class=muted aria-hidden=true>↳ `),yr=j(`<tr><td><button type=button class=wt-link></button></td><td></td><td></td><td></td><td></td><td>`),br=j(`<span class=muted> (<!>)`),xr=j(`<tr><td></td><td><button type=button class=wt-link> → </button></td><td></td><td>`);function Sr(e){return(()=>{var n=_r(),a=n.firstChild,o=a.firstChild.nextSibling,s=a.nextSibling,c=s.firstChild.nextSibling;return S(n,()=>e.children,a),S(o,t(r,{get each(){return e.nodes},children:n=>(()=>{var r=yr(),a=r.firstChild,o=a.firstChild,s=a.nextSibling,c=s.nextSibling,l=c.nextSibling,u=l.nextSibling,d=u.nextSibling;return S(a,t(i,{get when(){return n.depth>0},get children(){return vr()}}),o),o.$$click=()=>e.onNode(n.id),S(o,()=>n.label),S(s,()=>n.machine),S(c,()=>n.harness),S(l,()=>n.state),S(u,()=>n.sent),S(d,()=>n.received),f(t=>{var i=e.selected===n.id,o=`${8+n.depth*16}px`;return i!==t.e&&r.classList.toggle(`selected`,t.e=i),o!==t.t&&C(a,`padding-left`,t.t=o),t},{e:void 0,t:void 0}),r})()})),S(n,t(i,{get when(){return!e.nodes.length},get children(){return hr()}}),s),S(c,t(r,{get each(){return e.edges},children:n=>(()=>{var r=xr(),a=r.firstChild,o=a.nextSibling,s=o.firstChild,c=s.firstChild,l=o.nextSibling,u=l.nextSibling;return S(a,()=>n.kind,null),S(a,t(i,{get when(){return n.style!==`solid`},get children(){var e=br(),t=e.firstChild.nextSibling;return t.nextSibling,S(e,()=>n.style===`dashed`?`waiting`:`permitted path`,t),e}}),null),s.$$click=()=>e.onEdge(n.id),S(s,()=>n.from,c),S(s,()=>n.to,null),S(l,()=>n.count),S(u,(()=>{var e=D(()=>!!n.lastAt);return()=>e()?k(n.lastAt):`—`})()),f(t=>{var i=e.selected===n.id,a=`${n.kind} from ${n.from} to ${n.to}`;return i!==t.e&&r.classList.toggle(`selected`,t.e=i),a!==t.t&&w(s,`aria-label`,t.t=a),t},{e:void 0,t:void 0}),r})()})),S(n,t(i,{get when(){return!e.edges.length},get children(){return gr()}}),null),n})()}x([`click`]);var[Cr,wr]=c(),[Tr,Er]=c(),[Dr,Or]=c(),kr=0,X=Cr,Z=Tr,Ar=Dr,Q=(e=`pick`)=>wr(e);function jr(){wr(void 0),Er(void 0)}var Mr=Er,Nr=e=>Or({...e,seq:++kr}),Pr=(e,t)=>getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t;function Fr(e,t,n,r){let i=Math.atan2(n.y-t.y,n.x-t.x);e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(n.x-r*Math.cos(i-.4),n.y-r*Math.sin(i-.4)),e.lineTo(n.x-r*Math.cos(i+.4),n.y-r*Math.sin(i+.4)),e.closePath(),e.fill()}function Ir(e,t,n){let r=Math.hypot(t.x-e.x,t.y-e.y)||1,i=(t.x-e.x)/r,a=(t.y-e.y)/r;return[{x:e.x+i*n,y:e.y+a*n},{x:t.x-i*n,y:t.y-a*n}]}function Lr(e,t,n){let r,i,a=(t,n)=>{let a=Z(),o=e.layout();if(!a||!o)return;c(a.id,o.positions,n);let s=e=>o.positions.get(`role:${a.id}:${e}`),l=Pr(`--accent`,`#3b82f6`);if(t.lineWidth=2/Math.max(.5,n.k),t.strokeStyle=l,t.fillStyle=l,t.font=`${11/Math.max(.6,n.k)}px system-ui, sans-serif`,t.textAlign=`center`,a.spec.mode===`restricted`)for(let e of a.spec.edges){let n=s(e.from),r=s(e.to);if(!n||!r)continue;let[i,a]=Ir(n,r,16);t.setLineDash([6,4]),t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(a.x,a.y),t.stroke(),t.setLineDash([]),Fr(t,i,a,9),e.direction===`two-way`&&Fr(t,a,i,9),t.fillText(`${e.kinds.join(`+`)}${e.direction===`two-way`?` ⇄`:``}`,(i.x+a.x)/2,(i.y+a.y)/2-6)}if(r?.moved&&r.at){let e=o.positions.get(r.from);if(e){let a=i?o.positions.get(i)??r.at:r.at;t.setLineDash([]),t.lineWidth=3/Math.max(.5,n.k),t.beginPath(),t.moveTo(e.x,e.y),t.lineTo(a.x,a.y),t.stroke(),Fr(t,e,a,11),i&&(t.beginPath(),t.arc(a.x,a.y,20,0,Math.PI*2),t.stroke())}}},o=``,c=(e,n,r)=>{let i=t.getBoundingClientRect(),a={};for(let[t,o]of n)(Ze(t,e)!==void 0||t.startsWith(`ses_`))&&(a[t]=[Math.round(i.left+o.x*r.k+r.x),Math.round(i.top+o.y*r.k+r.y)]);let s=JSON.stringify(a);s!==o&&(t.dataset.editorPoints=o=s)},u=e=>{let t=Z();return!!t&&(Ze(e,t.id)!==void 0||e.startsWith(`ses_`))},d=n=>{if(n.button!==0||!Z())return;let i=e.hitTest(n.clientX,n.clientY);i?.type===`node`&&u(i.id)&&(n.stopPropagation(),n.preventDefault(),n.target.setPointerCapture?.(n.pointerId),r={from:i.id,start:{x:n.clientX,y:n.clientY},moved:!1,pointer:n.pointerId},t.dataset.editorDrag=`pending`)},f=n=>{if(!r||n.pointerId!==r.pointer||(n.stopPropagation(),!r.moved&&Math.hypot(n.clientX-r.start.x,n.clientY-r.start.y)>5&&(r.moved=!0),!r.moved))return;r.at=e.toWorld(n.clientX,n.clientY);let o=e.hitTest(n.clientX,n.clientY),s=Z();i=o?.type===`node`&&s&&Ae(s.id,r.from,o.id)?o.id:void 0,t.dataset.editorDrag=i?`over`:`dragging`,e.setOverlay(a)},p=o=>{if(!r||o.pointerId!==r.pointer)return;o.stopPropagation();let s=r;r=void 0;let c=i;if(i=void 0,delete t.dataset.editorDrag,e.setOverlay(a),!s.moved)return n(s.from);let l=Z(),u=l&&c?Ae(l.id,s.from,c):void 0;u&&Nr(u)},m=()=>{r=void 0,i=void 0,delete t.dataset.editorDrag,e.setOverlay(a)};t.addEventListener(`pointerdown`,d,!0),t.addEventListener(`pointermove`,f,!0),t.addEventListener(`pointerup`,p,!0),t.addEventListener(`pointercancel`,m,!0);let h=s(n=>(l(()=>{let n=Z();t.dataset.editorPaths=n?String(n.spec.mode===`restricted`?n.spec.edges.length:0):``,e.setOverlay(n?a:void 0)}),n));return()=>{h(),t.removeEventListener(`pointerdown`,d,!0),t.removeEventListener(`pointermove`,f,!0),t.removeEventListener(`pointerup`,p,!0),t.removeEventListener(`pointercancel`,m,!0),e.setOverlay(void 0)}}var Rr=j(`<aside class="wt-slider wt-sheetable te-panel"aria-label="Team editor">`),zr=j(`<div class=wt-slider-head><h2>Teams`),Br=j(`<p role=alert class=wt-error>`),Vr=j(`<ul class="te-list te-team-list">`),Hr=j(`<section class=wt-section aria-labelledby=te-teams><div class="te-row te-picker-head"><h3 id=te-teams>Open a team</h3><button type=button class="btn small primary">New team</button></div><p class=muted>Teams also have their own page: <a href=/teams>Teams</a>.`),Ur=j(`<div class=wt-slider-body>`),Wr=j(`<p class=muted>No teams yet. Create one to staff roles and give it work.`),Gr=j(`<li><button type=button class=te-team-open><strong></strong><span class=muted>#`),Kr=j(`<div class=wt-slider-head><h2>`),qr=j(`<button type=button class="btn small">All teams`),Jr=j(`<div class="te-row te-panel-links"><span class=muted> #</span><a class="btn small">Open team page`),Yr=j(`<section class=wt-section aria-labelledby=te-members><h3 id=te-members>Members`),Xr=j(`<section class=wt-section aria-labelledby=te-intake><h3 id=te-intake>Submit a task to the team</h3><h4 class=te-sub>Recent tasks`),Zr=j(`<section class="wt-section te-draft"aria-labelledby=te-draft><h3 id=te-draft>Edit the team (draft)</h3><h4 class=te-sub id=te-details>Details</h4><h4 class=te-sub id=te-roles>Roles</h4><h4 class=te-sub id=te-paths>Communication paths`),Qr=j(`<section class=wt-section aria-labelledby=te-life><h3 id=te-life>Team</h3><div class=te-row><button type=button class="btn small"></button><button type=button class="btn small">All teams`),$r=j(`<div class="wt-slider-body te-body">`),ei=j(`<dt>Paths`),ti=j(`<dd>`),ni=j(`<dt>Tags`),ri=j(`<section class=wt-section aria-label="Team overview"><dl class=wt-facts><dt>Communication</dt><dd></dd><dt>Entry role</dt><dd></dd><dt>Roles</dt><dd></dd></dl><h3>Members</h3><button type=button class=btn>Edit with form`);function ii(e){return(()=>{var n=Rr();return S(n,t(St,{onClose:jr}),null),S(n,t(i,{get when(){return X()===`pick`},get fallback(){return t(i,{get when(){return X()},keyed:!0,children:n=>t(oi,_({id:n},e))})},get children(){return t(ai,e)}}),null),n})()}function ai(n){let[a,o]=c(),[s,l]=c(``),[u,d]=c(!1);return v(async()=>{try{o(await Qe())}catch(t){l(t instanceof e&&t.status===404?`This hub doesn't have teams yet.`:B(t).message)}}),[(()=>{var e=zr();return e.firstChild,S(e,t(T,{icon:`close`,label:`Close the team editor`,onClick:jr}),null),e})(),(()=>{var e=Ur();return S(e,t(i,{get when(){return s()},get children(){var e=Br();return S(e,s),e}}),null),S(e,t(i,{get when(){return a()},get children(){var e=Hr(),n=e.firstChild,o=n.firstChild.nextSibling,s=n.nextSibling;return o.$$click=()=>d(!0),S(e,t(i,{get when(){return a().length},get fallback(){return Wr()},get children(){var e=Vr();return S(e,t(r,{get each(){return a()},children:e=>(()=>{var t=Gr(),n=t.firstChild,r=n.firstChild,i=r.nextSibling;return i.firstChild,n.$$click=()=>Q(e.id),S(r,()=>e.title),S(i,()=>e.name,null),S(i,()=>e.paused?` · paused`:``,null),S(i,()=>e.hasDraft?` · draft`:``,null),f(()=>w(n,`aria-label`,`Edit ${e.title}`)),t})()})),e}}),s),e}}),null),e})(),t(Be,{get open(){return u()},onClose:()=>d(!1),onCreated:e=>{n.onChanged(),Q(e)}})]}function oi(e){let n=Pe(e.id,{intake:!0,onChanged:e.onChanged}),[r,a]=c(e.phone);v(()=>void n.load()),Je(()=>n.refresh(),n.openWork),l(()=>{let e=n.team(),t=n.spec();e&&t&&Mr({id:e.id,name:e.name,spec:t,...n.roster()?{seats:n.roster().seats}:{}})}),g(()=>Mr(void 0));let s,u,d=new Map,p=t=>e.snap?.nodes.find(e=>e.id===t)?.label??t;return l(o(Ar,e=>{if(e&&n.spec()&&!r()){if(e.type===`connect`)u?.prefill(e.from,e.to),n.setNotice({kind:`ok`,text:`Path ${e.from} → ${e.to}: choose its direction and kinds, then Add path.`});else if(e.type===`attach`){if(!n.publishedRoles().has(e.role))return n.setNotice({kind:`error`,text:`${e.role} isn't published yet: publish the draft, then staff it.`});n.setNotice({kind:`ok`,text:`Add ${p(e.sessionID)} to ${e.role}? Check its other teams, then confirm.`}),s?.add(e.role,e.sessionID)}else e.type===`role`&&queueMicrotask(()=>d.get(e.role)?.focus())}},{defer:!0})),[(()=>{var e=Kr(),r=e.firstChild;return S(r,(()=>{var e=D(()=>!!n.team());return()=>e()?`Team: ${n.spec()?.title||n.team().title}`:`Team`})()),S(e,t(T,{icon:`close`,label:`Close the team editor`,onClick:jr}),null),e})(),(()=>{var o=$r();return E(o,`keydown`,n.onKey,!0),S(o,t(i,{get when(){return n.loadError()},get children(){return[(()=>{var e=Br();return S(e,()=>n.loadError()),e})(),(()=>{var e=qr();return e.$$click=()=>Q(`pick`),e})()]}}),null),S(o,t(i,{get when(){return D(()=>!!n.team())()&&n.spec()},get children(){return[(()=>{var e=Jr(),r=e.firstChild;r.firstChild;var i=r.nextSibling;return S(e,t(ze,{c:n}),r),S(r,()=>n.team().name,null),f(()=>w(i,`href`,Ke(n.team().id))),e})(),t(Re,{get notice(){return n.notice()}}),t(i,{get when(){return!r()},get fallback(){return t(si,{c:n,get snap(){return e.snap},onEdit:()=>a(!1)})},get children(){return[(()=>{var r=Yr();return r.firstChild,S(r,t(V,{c:n,get snap(){return e.snap},canvasHint:!0,handle:e=>s=e}),null),r})(),(()=>{var r=Xr(),i=r.firstChild.nextSibling;return S(r,t(We,{c:n}),i),S(r,t(He,{c:n,get snap(){return e.snap},limit:5}),null),r})(),(()=>{var e=Zr(),r=e.firstChild.nextSibling,i=r.nextSibling,a=i.nextSibling;return S(e,t(De,{c:n}),r),S(e,t(Fe,{c:n,withMode:!0}),i),S(e,t(Me,{c:n,roleInput:(e,t)=>d.set(e,t)}),a),S(e,t(Xe,{c:n,canvasHint:!0,handle:e=>u=e}),null),e})()]}}),(()=>{var e=Qr(),t=e.firstChild.nextSibling.firstChild,r=t.nextSibling;return t.$$click=()=>void n.togglePause(),S(t,()=>n.team().paused?`Resume team`:`Pause team`),r.$$click=()=>Q(`pick`),f(()=>t.disabled=n.busy()),e})()]}}),null),o})()]}function si(e){let n=()=>e.c.read().published;return(()=>{var r=ri(),a=r.firstChild,o=a.firstChild.nextSibling,s=o.nextSibling.nextSibling,c=s.nextSibling.nextSibling,l=a.nextSibling.nextSibling;return S(o,()=>n().mode===`open`?`Open: everyone may message everyone`:`Restricted: only the drawn paths`),S(s,()=>n().entryRole),S(c,()=>n().roles.map(e=>e.label?`${e.name} (${e.label})`:e.name).join(`, `)),S(a,t(i,{get when(){return n().mode===`restricted`},get children(){return[ei(),(()=>{var e=ti();return S(e,()=>n().edges.map(e=>`${e.from} ${e.direction===`two-way`?`⇄`:`→`} ${e.to} (${e.kinds.join(`+`)})`).join(`, `)||`none`),e})()]}}),null),S(a,t(i,{get when(){return n().tags?.length},get children(){return[ni(),(()=>{var e=ti();return S(e,()=>n().tags.join(`, `)),e})()]}}),null),S(r,t(V,{get c(){return e.c},get snap(){return e.snap}}),l),E(l,`click`,e.onEdit,!0),r})()}x([`click`,`keydown`]);var ci=G({default:()=>Mi}),li=j(`<p role=status class=wt-notice>Older interactions may have been evicted: the hub keeps only the most recent messages.`),ui=j(`<p role=status class=wt-notice>The hub cut this graph at its limits. Narrow the time window to see everything.`),di=j(`<p role=status class=wt-notice> messages with archived or deleted sessions are left out.`),fi=j(`<p role=status class=wt-notice>Subsessions are folded into their root to keep the picture readable. The list shows every session.`),pi=j(`<p role=status class=wt-notice>Sessions are folded per group to keep the picture readable. Narrow the filters or pick another grouping to see them; the list shows every session.`),mi=j(`<p role=status class=wt-notice>3D needs WebGL, which this browser can't use, so here's the 2D view.`),hi=j(`<p role=status class=wt-notice>This graph is too large to draw, so here's the list. Narrow the filters or group by machine.`),gi=j(`<p role=alert class="wt-notice wt-error">Couldn't refresh: <!>. Showing the last snapshot. <button type=button class="btn small">Retry`),_i=j(`<p role=alert class=wt-error>Could not load the interaction graph: `),vi=j(`<button type=button class=btn>Retry`),yi=j(`<div class=wt-center>`),bi=j(`<div class=wt-center><p class=muted>Loading…`),xi=j(`<a class="btn primary wt-empty-cta"href=/settings#machines>Connect a machine`),Si=j(`<p class="muted small">In OpenCode run /hub → Connect to a hub…, then approve the machine in Settings.`),Ci=j(`<div class=wt-empty><p class=muted>No sessions or interactions in this window yet.`),wi=j(`<div class=wt-page><header class="topbar wt-top"><h1 class=title>Watchtower</h1><span class="wt-live muted"role=status></span></header><div class=wt-notices></div><div class=wt-stage><div class=wt-overlay>`),Ti=j(`<p class=muted>`),Ei=j(`<p class="muted small">Start a session on a machine, or pick a longer time window in Filters.`),Di=3e3,Oi=3e4;function ki(){let e=matchMedia(`(prefers-color-scheme: dark)`),[t,n]=c(0),r=()=>n(e=>e+1);return e.addEventListener(`change`,r),g(()=>e.removeEventListener(`change`,r)),u(()=>{ne(),t();let e=getComputedStyle(document.documentElement),n=new Map;return t=>{let r=n.get(t);return r===void 0&&n.set(t,r=e.getPropertyValue(t).trim()||`#888888`),r}})}function Ai(){let e=matchMedia(`(prefers-reduced-motion: reduce)`),[t,n]=c(e.matches),r=()=>n(e.matches);return e.addEventListener(`change`,r),g(()=>e.removeEventListener(`change`,r)),t}var $={get(e){try{return localStorage.getItem(e)}catch{return null}},set(e,t){try{localStorage.setItem(e,t)}catch{}}},ji=1100;function Mi(e){try{Ee(localStorage)}catch{}let[r,s]=c(Ve($.get(me))),m=u(()=>Ye(p().search,r()),void 0,{equals:(e,t)=>Ue(e)===Ue(t)}),y=e=>n(`/watchtower${Ue(e,r()??`3d`)}`,{replace:!0}),x=e=>y({...m(),...e}),E=e=>{$.set(me,e),s(e),x({view:e})},O=()=>m().q??``,[k,A]=c(!1),[j,M]=c(innerWidth),N=()=>!F()&&j()>=ji,[P,ne]=c(!F()&&mt($.get(`watchtower.filtersOpen`),!1)),[I,L]=c(!F()&&mt($.get(`watchtower.legendOpen`),innerWidth>=1280));P()&&I()&&innerWidth<1280&&L(!1);let[R,oe]=c(),se=e=>{oe(e?`filters`:void 0),ne(e),$.set(ct,e?`1`:`0`),e&&fe(`filters`)},ce=e=>{oe(e?`legend`:void 0),L(e),$.set(lt,e?`1`:`0`),e&&fe(`legend`)},fe=e=>{e!==`filters`&&!N()&&ne(!1),e!==`legend`&&!N()&&L(!1),e!==`side`&&F()&&(a(m).selected&&K(void 0),X()&&jr())},pe=Ai(),he=()=>!pe()&&!k(),ge=ki(),[ve]=c(Hn()),[be,Se]=c(!1),[De,Oe]=c(!1),[ke,Ae]=c(),[je,Me]=c(0),[Pe,Fe]=c(),Le=u(()=>m().window),[z,Re]=c(),[B,ze]=c(),[Be,He]=c(!0),We=0,Ke,qe=0,V=async()=>{clearTimeout(Ke),Ke=void 0;let e=++qe;We=Date.now(),He(!0);try{let t=await ye(de({window:a(Le)},Date.now()));if(e!==qe)return;Re(t),ze(void 0)}catch(t){if(e!==qe)return;ze(ae(t))}finally{e===qe&&He(!1)}},Je=()=>{Ke||document.visibilityState===`hidden`||(Ke=setTimeout(()=>void V(),Math.max(0,We+Di-Date.now())))};l(o(Le,()=>void V())),v(()=>{let e=te(e=>Te(e)&&Je()),t=setInterval(()=>document.visibilityState===`visible`&&Date.now()-We>=Oi&&void V(),5e3),n=()=>document.visibilityState===`visible`&&Date.now()-We>=Oi&&void V();document.addEventListener(`visibilitychange`,n),g(()=>{e(),clearInterval(t),clearTimeout(Ke),document.removeEventListener(`visibilitychange`,n)})});let Xe=u(()=>{let e=z(),t=Z();return e&&t?Ne(e,t,t.spec,t.seats):e});g(jr),v(()=>{let e=p().searchParams.get(`edit`);e&&Q(e)}),l(o(X,e=>e&&e!==`pick`&&a(m).groupBy!==`team`&&x({groupBy:`team`})));let Qe=u(()=>ie(m())),H=u(()=>{let e=Xe();return e?le(e,Qe(),{now:e.at,reducedMotion:!he()}):void 0}),U=u(()=>{let e=Ie({webgl:ve()&&!be(),tooLarge:H()?.tooLarge??!1,chosen:m().view});return e.mode===`2d`&&De()?{mode:`list`,reason:`chosen`}:e}),$e=()=>U().reason,et=()=>U().mode===`3d`||U().mode===`2d`,W=u(()=>{let e=z();return e?Ce(e):{teams:[],roles:[],projects:[],workspaces:[],tags:[],metaKeys:[]}}),tt=u(()=>(z()?.nodes??[]).filter(e=>e.kind===`team`)),nt=u(()=>ut(m(),{machine:e=>H()?.machines.find(t=>t.id===e)?.label??e,harness:ue,team:e=>W().teams.find(t=>t.id===e)?.label??e})),rt=u(()=>{let e=Xe(),t=H();return e&&t&&U().mode===`list`?we(e,t):{nodes:[],edges:[]}}),it=u(()=>[...new Set((z()?.nodes??[]).filter(e=>e.kind===`session`).map(Ge))].sort((e,t)=>ue(e).localeCompare(ue(t)))),at=u(()=>{let e=z();return!!e&&!e.nodes.some(e=>e.kind===`session`)&&!e.edges.length}),G=()=>m().selected,K=e=>x({selected:e}),ot=u(()=>{let e=z(),t=G();return e&&t?.type===`node`?_e(e,t.id):void 0}),st=u(()=>{let e=z(),t=G();return e&&t?.type===`edge`?xe(e,t.id):void 0});l(o([G,X],([e,t])=>(e||t)&&F()&&fe(`side`)));let q=e=>{if(e.startsWith(`agg:`)||e.startsWith(`group:`))return;let t=Z(),n=t?Ze(e,t.id):void 0;if(n!==void 0)return Nr({type:`role`,role:n});let r=/^role:([^:]+):/.exec(e);K({type:`node`,id:r?r[1]:e})},ft=e=>{let t=z(),n=[...e.edgeIDs].sort((e,n)=>(t?.edges.find(e=>e.id===n)?.count??0)-(t?.edges.find(t=>t.id===e)?.count??0))[0];n&&K({type:`edge`,id:n})},pt=()=>{let e=H()?.nodes.find(e=>e.match&&!e.id.startsWith(`agg:`)&&!e.id.startsWith(`group:`)&&!e.id.startsWith(`role:`));e&&(K({type:`node`,id:e.id}),Ae({id:e.id,seq:(ke()?.seq??0)+1}))},ht=()=>!!(z()&&G())||!!X(),gt=()=>F()?`0px`:X()?`min(440px, 100%)`:z()&&G()?`min(380px, 100%)`:`0px`,J;return v(()=>{let e=new ResizeObserver(()=>M(J.clientWidth));e.observe(J),M(J.clientWidth),P()&&I()&&!N()&&L(!1);let t=e=>{e.key!==`Escape`||e.defaultPrevented||ee()||G()||X()||(P()?se(!1):I()&&ce(!1))};document.addEventListener(`keydown`,t),g(()=>{e.disconnect(),document.removeEventListener(`keydown`,t)})}),(()=>{var e=wi(),n=e.firstChild,r=n.firstChild,a=r.nextSibling,o=n.nextSibling,s=o.nextSibling,c=s.firstChild;S(n,t(i,{get when(){return F()},get children(){return t(T,{icon:`menu`,label:`Open sidebar`,onClick:re})}}),r),S(a,()=>Be()&&z()?`Updating…`:``),S(n,t(i,{get when(){return!F()},get children(){return t(T,{icon:`sidebar`,label:`Toggle sidebar (⌘B)`,onClick:re})}}),null),S(o,t(i,{get when(){return z()?.truncated},get children(){return li()}}),null),S(o,t(i,{get when(){return z()?.capped},get children(){return ui()}}),null),S(o,t(i,{get when(){return(z()?.hiddenMessages??0)>0},get children(){var e=di(),t=e.firstChild;return S(e,()=>z().hiddenMessages,t),e}}),null),S(o,t(i,{get when(){return D(()=>H()?.lod===`roots`)()&&et()},get children(){return fi()}}),null),S(o,t(i,{get when(){return D(()=>H()?.lod===`groups`)()&&et()},get children(){return pi()}}),null),S(o,t(i,{get when(){return D(()=>U().mode===`2d`)()&&$e()===`webgl`},get children(){return mi()}}),null),S(o,t(i,{get when(){return D(()=>U().mode===`list`)()&&$e()===`large`},get children(){return hi()}}),null),S(o,t(i,{get when(){return D(()=>!!B())()&&z()},get children(){var e=gi(),t=e.firstChild.nextSibling,n=t.nextSibling.nextSibling;return S(e,()=>B().message,t),n.$$click=()=>void V(),e}}),null);var l=J;return typeof l==`function`?b(l,s):J=s,S(s,t(d,{get children(){return[t(h,{get when(){return D(()=>!z())()&&B()},get children(){var e=yi();return S(e,t(i,{get when(){return B().kind!==`missing`},get fallback(){return(()=>{var e=Ti();return S(e,()=>B().message),e})()},get children(){return[(()=>{var e=_i();return e.firstChild,S(e,()=>B().message,null),e})(),(()=>{var e=vi();return e.$$click=()=>void V(),e})()]}})),e}}),t(h,{get when(){return!z()},get children(){return bi()}}),t(h,{get when(){return D(()=>U().mode===`3d`)()&&H()},children:e=>t(Un,_({get view(){return e()},get palette(){return ge()},get motion(){return he()},get focus(){return ke()},get resetSeq(){return je()},onNode:q,onLink:ft,onBackground:()=>void 0,onFail:()=>Se(!0)},()=>G()?.type===`node`?{selected:G().id}:{},{onRenderer:e=>(Fe(e),()=>Fe(void 0))}))}),t(h,{get when(){return D(()=>U().mode===`2d`)()&&H()},children:e=>t(Bn,_({get view(){return e()},get palette(){return ge()},get motion(){return he()}},()=>G()?.type===`node`?{selected:G().id}:{},{get focus(){return ke()},get resetSeq(){return je()},onNode:q,onLink:ft,onBackground:()=>void 0,onFail:()=>Oe(!0),onRenderer:(e,t)=>Lr(e,t,q)}))}),t(h,{get when(){return U().mode===`list`},get children(){return t(Sr,{get nodes(){return rt().nodes},get edges(){return rt().edges},get selected(){return G()?.id},onNode:q,onEdge:e=>K({type:`edge`,id:e}),get children(){return t(i,{get when(){return D(()=>!(!I()||F()))()&&H()},children:e=>t(pr,{get view(){return e()},mode:`list`,phone:!1,get autoFocus(){return R()===`legend`},onClose:()=>ce(!1)})})}})}})]}}),c),S(s,t(i,{get when(){return at()},get children(){var e=Ci();return e.firstChild,S(e,t(i,{get when(){return!z().nodes.some(e=>e.kind===`machine`)},get fallback(){return Ei()},get children(){return[xi(),Si()]}}),null),f(()=>e.classList.toggle(`wt-empty-drawn`,!!et())),e}}),c),S(c,t(Rn,{get chips(){return nt()},onRemove:e=>x(e.clear),onClear:()=>x(Fn)}),null),S(c,t(i,{get when(){return D(()=>!!(I()&&H()))()&&(et()||F())},get children(){return t(pr,{get view(){return H()},get mode(){return D(()=>U().mode===`2d`)()?`2d`:U().mode===`list`?`list`:`3d`},get phone(){return F()},get autoFocus(){return R()===`legend`},onClose:()=>ce(!1)})}}),null),S(c,t(i,{get when(){return D(()=>!!P())()&&z()},get children(){return t(Ln,{get url(){return m()},get phone(){return F()},get autoFocus(){return R()===`filters`},get machines(){return(H()?.machines??[]).map(e=>({value:e.id,label:e.label}))},get harnesses(){return it().map(e=>({value:e,label:ue(e)}))},get choices(){return W()},get teamValue(){return tt().find(e=>e.id===m().team||e.name===m().team)?.id??m().team},setURL:x,go:y,onClose:()=>se(!1)})}}),null),S(c,t(gn,_({get view(){return m().view},get drawn(){return et()},get filtersOpen(){return P()},get filterCount(){return dt(m())},get legendOpen(){return I()},get teamsOpen(){return!!X()},get paused(){return k()},get reduced(){return pe()},get panelOpen(){return P()||I()&&F()||F()&&ht()},get search(){return O()}},()=>O().trim()?{matches:H()?.matches??0}:{},{setView:E,onFilters:()=>se(!P()),onLegend:()=>ce(!I()),onTeams:()=>X()?jr():Q(),onHub:()=>K({type:`node`,id:`hub`}),onReset:()=>Me(e=>e+1),onPause:()=>A(!k()),get canRelayout(){return D(()=>U().mode===`3d`)()&&!!Pe()},onRelayout:()=>Pe()?.relayout(),onSearch:e=>x({q:e.trim()?e:void 0}),onSearchEnter:pt})),null),S(s,t(i,{get when(){return D(()=>!!(z()&&G()))()&&!X()},get children(){return t(Zt,{get snap(){return z()},get selection(){return G()},get node(){return ot()},get edge(){return st()},get window(){return m().window},onSelect:K,onClose:()=>K(void 0),onEditTeam:e=>Q(e)})}}),null),S(s,t(i,{get when(){return X()},get children(){return t(ii,{get snap(){return Xe()},get phone(){return F()},onChanged:()=>void V()})}}),null),f(e=>{var t=U().mode,n=he()?`live`:`static`,r=nt().length?``:void 0,i=gt();return t!==e.e&&w(s,`data-mode`,e.e=t),n!==e.t&&w(s,`data-motion`,e.t=n),r!==e.a&&w(s,`data-chips`,e.a=r),i!==e.o&&C(s,`--wt-side`,e.o=i),e},{e:void 0,t:void 0,a:void 0,o:void 0}),e})()}x([`click`]);export{Qn as a,ot as c,Mi as default,Gn as i,Xn as n,Zn as o,Yn as r,at as s,ci as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.te-panel{width:min(460px,100%)}.wt-stage:has(.te-panel) .wt-minimap{right:calc(min(460px,100%) + 10px)}.te-body{align-content:start;gap:4px;display:grid}.te-panel .wt-check{align-items:center;gap:6px;display:flex}.te-panel .te-toolbar{z-index:1;background:var(--raise);position:sticky;top:-10px}.te-panel-links{justify-content:space-between}.te-panel-links .te-status{margin:0}.te-sub{color:var(--muted);margin:12px 0 4px;font-size:.8125rem;font-weight:600}.te-picker-head{justify-content:space-between}.te-picker-head h3{margin:0}.te-team-list{gap:6px}.te-team-open{all:unset;box-sizing:border-box;border:1px solid var(--line-2);border-radius:var(--r);background:var(--bg);cursor:pointer;gap:2px;width:100%;padding:10px 12px;display:grid}.te-team-open:hover{border-color:var(--accent)}.te-team-open:focus-visible{outline:2px solid var(--accent);outline-offset:1px}.wt-2d-host[data-editor-drag=dragging] canvas,.wt-2d-host[data-editor-drag=pending] canvas{cursor:crosshair!important}.wt-2d-host[data-editor-drag=over] canvas{cursor:copy!important}@media (max-width:760px){.te-panel{width:100%}}.wt-page{flex-direction:column;flex:1;min-width:0;min-height:0;display:flex;position:relative}.wt-top{gap:10px}.wt-top .title{flex:none}.wt-live{flex:1;font-size:.75rem}.wt-notices:empty{display:none}.wt-notices{flex:none}.wt-notice{color:var(--muted);border-bottom:1px solid var(--line);background:var(--raise);margin:0;padding:6px 12px;font-size:.8125rem}.wt-error{color:var(--err)}.wt-stage{background:var(--bg);flex:1;min-height:0;position:relative;overflow:hidden}.wt-canvas{touch-action:none;position:absolute;inset:0}.wt-canvas canvas{display:block}.wt-center{text-align:center;flex-direction:column;justify-content:center;align-items:center;gap:10px;padding:20px;display:flex;position:absolute;inset:0}.wt-empty{text-align:center;pointer-events:none;flex-direction:column;align-items:center;gap:8px;padding:0 20px;display:flex;position:absolute;top:50%;left:0;right:0;transform:translateY(-50%)}.wt-empty p{margin:0}.wt-empty-drawn{margin-top:84px;transform:none}.wt-empty a{pointer-events:auto}.wt-2d-host{outline:none;position:absolute;inset:0}.wt-2d-host:focus-visible{box-shadow:inset 0 0 0 2px var(--accent)}.wt-canvas2d{cursor:grab;touch-action:none;display:block}.wt-minimap{border:1px solid var(--line);border-radius:var(--r);width:180px;height:120px;box-shadow:0 4px 16px var(--shadow);cursor:crosshair;z-index:1;position:absolute;bottom:66px;right:10px}.wt-tip2d{pointer-events:none;z-index:2;max-width:260px;position:absolute}.wt-stage:has(.wt-slider) .wt-minimap{right:calc(min(380px,100%) + 10px)}.wt-tip{background:var(--raise);color:var(--text);border:1px solid var(--line-2);font:.75rem var(--sans);border-radius:6px;padding:3px 7px;display:inline-block}.wt-legend{font-size:.75rem}.wt-panel-inline .wt-legend-body{grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:0 16px;display:grid}.wt-legend-sec summary{text-transform:uppercase;letter-spacing:.04em;color:var(--muted);cursor:pointer;margin:6px 0 3px;font-size:.7rem;font-weight:600}.wt-legend-sec summary:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:4px}.wt-legend-sec[open]{margin-bottom:4px}.wt-legend-compact .muted{display:none}.wt-compact[aria-pressed=true]{border-color:var(--accent);background:var(--raise-2)}.wt-legend ul{gap:2px;margin:0;padding:0;list-style:none;display:grid}.wt-legend li{align-items:center;gap:7px;display:flex}.wt-legend-note{margin:6px 0 0}.wt-swatch{text-align:center;width:14px;font-size:.875rem}.wt-glyph-swatch{flex:none;display:block}.wt-region{background:color-mix(in srgb, var(--accent) 14%, transparent);width:18px;height:12px;box-shadow:0 0 6px color-mix(in srgb, var(--accent) 35%, transparent);border:1px solid color-mix(in srgb, var(--accent) 40%, transparent);border-radius:6px;flex:none}.wt-role-vacant{background:0 0!important;border-style:dashed!important}.wt-line-tether{border-color:var(--violet);border-top-width:1.5px}.wt-ring{border:2px solid;border-radius:50%;flex:none;width:10px;height:10px}.wt-ring-thin{border-width:1px}.wt-ring-thick{border-width:3px}.wt-ring-double{border-style:double;border-width:4px}.wt-ring-broken{border-style:dashed}.wt-ring-none{background:var(--line);border-color:#0000!important}.wt-line{border-top:2px solid;flex:none;width:22px;height:0}.wt-line-dashed{border-top-style:dashed}.wt-line-dotted{border-top-style:dotted}.wt-line-structure{border-color:var(--line-2);border-top-width:1px}.wt-hull{border:2px solid var(--violet);background:color-mix(in srgb, var(--violet) 10%, transparent);border-radius:6px;flex:none;width:18px;height:12px}.wt-hull-restricted{border-style:dashed}.wt-role{border:1.5px solid var(--violet);text-align:center;border-radius:6px;flex:none;width:18px;height:11px;font-size:8px;line-height:9px}.wt-role-entry{background:color-mix(in srgb, var(--accent) 15%, transparent);color:var(--text);border-width:2.5px}.wt-multi{border:1.5px dotted var(--violet);width:18px;height:18px;color:var(--violet);text-align:center;border-radius:50%;flex:none;font-size:8px;font-weight:700;line-height:15px}.wt-list{padding:12px 16px 96px;position:absolute;inset:0;overflow:auto}.wt-stage[data-chips] .wt-list{padding-top:50px}.wt-list>*{max-width:1100px}.wt-table{border-collapse:collapse;width:100%;margin-bottom:18px;font-size:.8125rem}.wt-table th{text-align:left;color:var(--muted);border-bottom:1px solid var(--line);padding:6px 8px;font-weight:500}.wt-table td{border-bottom:1px solid var(--line);padding:5px 8px}.wt-table tr.selected td{background:var(--raise-2)}.wt-link{all:unset;cursor:pointer;color:var(--accent);border-radius:4px}.wt-link:hover{text-decoration:underline}.wt-link:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.wt-slider{background:var(--raise);border-left:1px solid var(--line);width:min(380px,100%);box-shadow:-8px 0 24px var(--shadow);z-index:3;flex-direction:column;animation:.18s ease-out wt-slide;display:flex;position:absolute;top:0;bottom:0;right:0}@keyframes wt-slide{0%{opacity:0;transform:translate(24px)}}@media (prefers-reduced-motion:reduce){.wt-slider{animation:none}}.wt-slider-head{border-bottom:1px solid var(--line);align-items:center;gap:8px;padding:10px 12px;display:flex}.wt-slider-head h2{text-overflow:ellipsis;white-space:nowrap;flex:1;margin:0;font-size:1rem;overflow:hidden}.wt-slider-body{flex:1;padding:10px 14px 30px;font-size:.8125rem;overflow:auto}.wt-facts{grid-template-columns:auto 1fr;gap:4px 12px;margin:0 0 10px;display:grid}.wt-facts dt{color:var(--muted)}.wt-facts dd{margin:0}.wt-endpoints{margin:0 0 10px;font-size:.9375rem}.wt-section h3{text-transform:uppercase;letter-spacing:.04em;color:var(--muted);margin:14px 0 6px;font-size:.75rem}.wt-peers{gap:3px;margin:0;padding:0;list-style:none;display:grid}.wt-timeline{gap:8px;margin:0;padding:0;list-style:none;display:grid}.wt-timeline li{border-left:2px solid var(--line-2);justify-items:start;gap:4px;padding-left:8px;display:grid}.wt-tl-row{flex-wrap:wrap;gap:4px 8px;display:flex}.wt-tl-kind{font-weight:600}.wt-text{white-space:pre-wrap;overflow-wrap:anywhere;background:var(--bg);border:1px solid var(--line);box-sizing:border-box;border-radius:6px;width:100%;padding:6px 8px}.wt-show-text{min-height:26px;font-size:.75rem}.wt-slider .wt-actions{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:6px;display:flex}@media (max-width:760px){.wt-minimap,.wt-canvas .wt-minimap{display:none}.wt-top .title{font-size:.875rem}.wt-live{text-align:right}.wt-list{padding:10px 8px 96px}.wt-stage[data-chips] .wt-list{padding-top:50px}.wt-table td,.wt-table th{padding:8px 6px}.wt-slider{z-index:30;border-left:none;border-top:1px solid var(--line);width:100%;height:min(85dvh,100dvh - 40px);box-shadow:0 -8px 28px var(--shadow);padding-bottom:env(safe-area-inset-bottom);border-radius:14px 14px 0 0;animation:.2s ease-out wt-sheet-up;position:fixed;inset:auto 0 0}.wt-slider .wt-handle{display:block}.wt-slider-head{padding-top:2px}}.wt-overlay{inset:0 var(--wt-side,0px) 0 0;pointer-events:none;z-index:4;--wt-dock-space:66px;position:absolute}.wt-overlay>*{pointer-events:auto}.wt-overlay>.wt-chipbar{pointer-events:none;flex-wrap:wrap;align-items:center;gap:6px;display:flex;position:absolute;top:10px;left:10px;right:10px}.wt-chipbar>*{pointer-events:auto}.wt-chips{flex-wrap:wrap;gap:6px;margin:0;padding:0;list-style:none;display:flex}.wt-chip{background:color-mix(in srgb, var(--raise) 94%, transparent);border:1px solid var(--line-2);box-shadow:0 2px 8px var(--shadow);border-radius:999px;align-items:center;gap:2px;max-width:100%;padding:2px 3px 2px 10px;font-size:.75rem;display:inline-flex}.wt-chip>span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.wt-chip-label{color:var(--muted)}.wt-chip-clear{all:unset;cursor:pointer;color:var(--accent);border-radius:999px;padding:3px 8px;font-size:.75rem}.wt-chip-clear:hover{text-decoration:underline}.wt-chip-clear:focus-visible{outline:2px solid var(--accent)}.wt-x{all:unset;cursor:pointer;width:22px;height:22px;color:var(--muted);border-radius:50%;flex:none;place-items:center;font-size:1rem;line-height:1;display:inline-grid}.wt-x:hover{background:var(--raise-2);color:var(--text)}.wt-x:focus-visible{outline:2px solid var(--accent)}.wt-dock-wrap{left:0;right:0;bottom:max(10px, calc(env(safe-area-inset-bottom) + 6px));pointer-events:none;justify-content:center;padding:0 8px;display:flex;position:absolute;container:wt-dock/inline-size}.wt-dock{pointer-events:auto;box-sizing:border-box;border:1px solid var(--line);background:color-mix(in srgb, var(--raise) 94%, transparent);max-width:100%;box-shadow:0 6px 22px var(--shadow);-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);border-radius:12px;align-items:center;gap:2px;padding:4px;transition:opacity .35s,translate .35s;display:flex}.wt-dock[data-faded=true]{opacity:0;translate:0 6px}.wt-dock-seg{background:var(--bg);border-radius:9px;padding:2px;display:inline-flex}.wt-dock-item{all:unset;box-sizing:border-box;min-width:34px;height:34px;color:var(--text);cursor:pointer;white-space:nowrap;border-radius:8px;justify-content:center;align-items:center;gap:5px;padding:0 9px;font-size:.8125rem;display:inline-flex;position:relative}.wt-dock-view{min-width:38px;height:30px;color:var(--muted);padding:0 8px;font-weight:500}.wt-dock-item:hover:not(:disabled){background:var(--raise-2)}.wt-dock-item:focus-visible{outline:2px solid var(--accent);outline-offset:1px}.wt-dock-item:disabled{opacity:.45;cursor:default}.wt-dock-item[aria-pressed=true],.wt-dock-item[aria-expanded=true]{background:var(--raise-2);box-shadow:inset 0 0 0 1px var(--accent);color:var(--text)}.wt-dock-view[aria-pressed=true]{background:var(--raise);box-shadow:0 1px 3px var(--shadow), inset 0 0 0 1px var(--accent)}.wt-dock-sep{background:var(--line);flex:none;width:1px;height:20px;margin:0 3px}.wt-glyph{flex:none}.wt-glyph-more{stroke-width:3.2px}.wt-badge{box-sizing:border-box;background:var(--accent);min-width:16px;height:16px;color:var(--accent-ink);border-radius:8px;place-items:center;padding:0 4px;font-size:.6875rem;font-weight:700;display:inline-grid}.wt-dock-more{display:inline-flex}.wt-dock-search{background:var(--bg);height:34px;color:var(--muted);border-radius:8px;align-items:center;gap:6px;min-width:0;padding:0 2px 0 9px;display:inline-flex}.wt-dock-search:focus-within{box-shadow:0 0 0 2px var(--accent)}.wt-dock-search input{all:unset;width:190px;min-width:0;color:var(--text);font-size:.8125rem}.wt-dock-search input::-webkit-search-cancel-button{display:none}.wt-dock-search input::placeholder{color:var(--faint,var(--muted))}.wt-dock-matches{white-space:nowrap;font-size:.75rem}.wt-dock-close{all:unset;cursor:pointer;border-radius:6px;place-items:center;width:28px;height:28px;display:inline-grid}.wt-dock-close:hover{background:var(--raise-2);color:var(--text)}.wt-dock-close:focus-visible{outline:2px solid var(--accent)}@container wt-dock (width<=780px){.wt-dock-text{display:none}.wt-badge{min-width:14px;height:14px;padding:0 3px;font-size:.625rem;position:absolute;top:1px;right:1px}.wt-dock-search input{width:130px}}@container wt-dock (width<=540px){.wt-dock{gap:1px}.wt-dock-wide{display:none}.wt-dock-sep{margin:0 1px}.wt-dock[data-search]{flex-wrap:wrap;justify-content:center;row-gap:4px}.wt-dock[data-search] .wt-dock-search{flex:1 0 100%;order:-1}.wt-dock[data-search] .wt-dock-search input{flex:1;width:auto}}@media (pointer:coarse){.wt-dock-item{min-width:38px;height:40px;padding:0 7px}.wt-dock-view{min-width:36px;height:36px;padding:0 6px}.wt-dock-search{height:40px}}.wt-panel{box-sizing:border-box;background:var(--raise);border:1px solid var(--line);box-shadow:0 10px 30px var(--shadow);border-radius:12px;outline:none;flex-direction:column;font-size:.8125rem;display:flex;overflow:hidden}.wt-panel:focus-visible{box-shadow:0 10px 30px var(--shadow), 0 0 0 2px var(--accent)}.wt-panel-head{border-bottom:1px solid var(--line);background:var(--raise);flex:none;align-items:center;gap:8px;padding:6px 6px 6px 14px;display:flex}.wt-panel-head h2{flex:1;margin:0;font-size:.875rem;font-weight:600}.wt-panel-body{overscroll-behavior:contain;flex:1;min-height:0;padding:8px 14px 12px;overflow:auto}.wt-pop{bottom:var(--wt-dock-space);max-height:calc(100% - var(--wt-dock-space) - 56px);animation:.16s ease-out wt-rise;position:absolute}.wt-pop-filters{width:min(620px,100% - 24px);left:50%;translate:-50%}.wt-pop-legend{width:min(330px,100% - 24px);left:12px}.wt-overlay:has(.wt-pop-legend) .wt-pop-filters{left:max(50%,354px + min(310px,50% - 12px))}.wt-panel-inline{box-shadow:none;max-width:none;margin-bottom:12px;position:static}@keyframes wt-rise{0%{opacity:0;transform:translateY(8px)}}.wt-handle{display:none}.wt-fs{border:none;min-width:0;margin:0 0 12px;padding:0}.wt-fs>legend{text-transform:uppercase;letter-spacing:.05em;color:var(--muted);margin-bottom:6px;padding:0;font-size:.6875rem;font-weight:600}.wt-fs-row{flex-wrap:wrap;align-items:flex-end;gap:8px 14px;display:flex}.wt-fs-empty{margin:0 0 6px;font-size:.75rem}.wt-field{flex-direction:column;gap:2px;min-width:0;display:flex}.wt-field>span{color:var(--muted);font-size:.75rem}.wt-check{align-items:center;gap:6px;min-height:30px;display:inline-flex}.wt-panel select,.wt-panel input[type=text]{box-sizing:border-box;border:1px solid var(--line-2);border-radius:var(--r);background:var(--bg);min-height:30px;color:var(--text);font:inherit;max-width:100%;padding:0 8px}.wt-scope{grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:6px 12px;margin-bottom:8px;display:grid}.wt-scope-row{align-items:flex-end;gap:2px;min-width:0;display:flex}.wt-scope-row .wt-field{flex:1}.wt-scope-row select,.wt-scope-row input{width:100%}.wt-scope-row .wt-x{margin-bottom:4px}.wt-panel select.wt-add{color:var(--accent);cursor:pointer;background:0 0;border-style:dashed}.wt-kinds{flex-wrap:wrap;gap:6px;display:flex}.wt-toggle{display:inline-flex;position:relative}.wt-toggle input{opacity:0;cursor:pointer;width:100%;height:100%;margin:0;position:absolute;inset:0}.wt-toggle span{border:1px solid var(--line-2);color:var(--muted);border-radius:999px;padding:3px 10px;font-size:.75rem}.wt-toggle input:checked+span{color:var(--text);border-color:var(--accent);background:color-mix(in srgb, var(--accent) 14%, transparent)}.wt-toggle input:checked+span:before{content:"✓ "}.wt-toggle input:focus-visible+span{outline:2px solid var(--accent);outline-offset:2px}.wt-panel-foot{border-top:1px solid var(--line);background:var(--raise);flex-wrap:wrap;align-items:center;gap:6px;margin:4px -14px -12px;padding:8px 14px;display:flex;position:sticky;bottom:-12px}.wt-foot-gap{flex:1}.wt-copied:empty{display:none}.wt-preset-form{align-items:center;gap:4px;display:flex}.wt-preset-form input{width:140px}.wt-backdrop{z-index:29;background:#00000052;animation:.16s ease-out wt-fade;position:fixed;inset:0}.wt-panel.wt-sheet{z-index:30;width:100%;max-height:min(78dvh,100dvh - 40px);padding-bottom:env(safe-area-inset-bottom);box-shadow:0 -8px 28px var(--shadow);border-width:1px 0 0;border-radius:14px 14px 0 0;animation:.2s ease-out wt-sheet-up;position:fixed;inset:auto 0 0;translate:none}.wt-sheet .wt-handle{display:block}.wt-handle{cursor:grab;touch-action:none;flex:none;height:18px;position:relative}.wt-handle:before{content:"";background:var(--line-2);border-radius:2px;width:38px;height:4px;margin-left:-19px;position:absolute;top:7px;left:50%}.wt-sheet .wt-panel-head{border-top:none;padding-top:0}.wt-sheet .wt-scope{grid-template-columns:1fr}@keyframes wt-sheet-up{0%{opacity:.4;transform:translateY(40px)}}@keyframes wt-fade{0%{opacity:0}}@media (prefers-reduced-motion:reduce){.wt-dock{transition:none}.wt-pop,.wt-panel.wt-sheet,.wt-backdrop,.wt-slider{animation:none}}
|