my-durable 0.0.119 → 0.0.120
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/apps/dpi-backend/src/git.ts +83 -8
- package/apps/dpi-backend/src/vitals.ts +5 -4
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/{index-CLWbWp89.js → index-CG_nQ-Sz.js} +1 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/index.html +1 -1
- package/apps/dpi-sdk/src/api.ts +6 -1
- package/apps/dpi-tui/src/commands.ts +76 -1
- package/apps/dpi-tui/src/pickers.ts +170 -29
- package/apps/dpi-tui/src/views.ts +1 -1
- package/package.json +1 -1
|
@@ -223,8 +223,43 @@ let gitSpawnLive = 0;
|
|
|
223
223
|
// low holds every fan-out (status-batch, the boot project-seed walk,
|
|
224
224
|
// git-files turns). FIFO within each lane; a freed slot wakes high first;
|
|
225
225
|
// nobody is ever refused and no spawn changes shape — only the wake order.
|
|
226
|
-
|
|
227
|
-
|
|
226
|
+
//
|
|
227
|
+
// run-13 (run-11 cold-review f4): the lanes fixed singles-vs-fan-out but
|
|
228
|
+
// left the inverse starvation — releaseGitSpawn wakes the HIGH lane first,
|
|
229
|
+
// always, so sustained interactive traffic keeps the high lane non-empty
|
|
230
|
+
// and a low waiter (a status-batch fan-out, the boot seed walk) queues
|
|
231
|
+
// FOREVER. AGING closes it: a low waiter queued longer than
|
|
232
|
+
// GIT_SPAWN_AGE_MS is promoted into the high lane, ahead of the fresh high
|
|
233
|
+
// traffic that would otherwise starve it. No timers — ages are checked at
|
|
234
|
+
// the only two moments the queue state is decided anyway: when a new low
|
|
235
|
+
// waiter is about to park (acquireGitSpawn) and before each lane choice
|
|
236
|
+
// (releaseGitSpawn). Promotion is pure queue surgery: it moves a callback
|
|
237
|
+
// between arrays, holds no slot, wakes nobody, refuses nobody, and changes
|
|
238
|
+
// nothing for waiters that are not aged.
|
|
239
|
+
const GIT_SPAWN_AGE_MS = 10_000;
|
|
240
|
+
/** Queued waiters — run-13 (f4) gave the low lane an aging clock: a bare
|
|
241
|
+
* `() => void` could not say HOW LONG it had waited. The high lane shares
|
|
242
|
+
* the shape so both queues stay one type; its timestamp is unused. */
|
|
243
|
+
interface GitSpawnWaiter {
|
|
244
|
+
wake: () => void;
|
|
245
|
+
/** When this waiter entered its lane (gitSpawnNow) — the aging clock. */
|
|
246
|
+
enqueuedAt: number;
|
|
247
|
+
}
|
|
248
|
+
const gitSpawnQueueHigh: GitSpawnWaiter[] = [];
|
|
249
|
+
const gitSpawnQueueLow: GitSpawnWaiter[] = [];
|
|
250
|
+
/** How many PROMOTED waiters sit at the HEAD of the high queue: new
|
|
251
|
+
* promotions splice in after them (still ahead of fresh high traffic), so
|
|
252
|
+
* promoted waiters keep arrival FIFO among themselves — run-13 (f4). */
|
|
253
|
+
let gitSpawnPromotedHead = 0;
|
|
254
|
+
/** Cumulative low→high promotions — gitSpawnStats() surfaces this as
|
|
255
|
+
* queuedAged (run-13 f4: the f4 starvation gauge). */
|
|
256
|
+
let gitSpawnQueuedAged = 0;
|
|
257
|
+
/** The aging clock, injectable like setGitExecForTests so tests cross the
|
|
258
|
+
* 10s boundary instantly instead of sleeping the suite (run-13). */
|
|
259
|
+
let gitSpawnNow: () => number = Date.now;
|
|
260
|
+
export function setGitClockForTests(fn?: () => number) {
|
|
261
|
+
gitSpawnNow = fn ?? Date.now;
|
|
262
|
+
}
|
|
228
263
|
|
|
229
264
|
/** Take a slot (or queue FIFO in your lane for one) — the caller owns the slot
|
|
230
265
|
* until releaseGitSpawn(). No nesting: a slot is held across exactly ONE
|
|
@@ -235,26 +270,66 @@ function acquireGitSpawn(priority?: "high" | "low"): Promise<void> {
|
|
|
235
270
|
gitSpawnLive++;
|
|
236
271
|
return Promise.resolve();
|
|
237
272
|
}
|
|
238
|
-
|
|
273
|
+
// run-13 (f4): before parking a NEW low waiter, promote every low waiter
|
|
274
|
+
// already past the age — the aged ones escape to the high lane and the
|
|
275
|
+
// newcomer queues behind whatever low traffic remains. A high arrival
|
|
276
|
+
// does NOT trigger this: releases re-check ages on every freed slot,
|
|
277
|
+
// which is what actually drains promotions under load.
|
|
278
|
+
if (priority !== "high") promoteAgedLowWaiters();
|
|
279
|
+
return new Promise<void>((wake) =>
|
|
280
|
+
(priority === "high" ? gitSpawnQueueHigh : gitSpawnQueueLow).push({ wake, enqueuedAt: gitSpawnNow() }),
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** run-13 (run-11 cold-review f4): move every low waiter older than
|
|
285
|
+
* GIT_SPAWN_AGE_MS into the high lane. enqueuedAt is monotone along the
|
|
286
|
+
* low queue (FIFO tail push), so the aged waiters are always a PREFIX —
|
|
287
|
+
* spliced off whole, arrival order intact, and inserted behind the
|
|
288
|
+
* already-promoted head so promotions stay globally FIFO among themselves
|
|
289
|
+
* while still waking ahead of fresh high traffic. */
|
|
290
|
+
function promoteAgedLowWaiters(): void {
|
|
291
|
+
const now = gitSpawnNow();
|
|
292
|
+
let aged = 0;
|
|
293
|
+
while (aged < gitSpawnQueueLow.length && now - gitSpawnQueueLow[aged]!.enqueuedAt > GIT_SPAWN_AGE_MS) aged++;
|
|
294
|
+
if (!aged) return;
|
|
295
|
+
const moving = gitSpawnQueueLow.splice(0, aged);
|
|
296
|
+
gitSpawnQueueHigh.splice(gitSpawnPromotedHead, 0, ...moving);
|
|
297
|
+
gitSpawnPromotedHead += moving.length;
|
|
298
|
+
gitSpawnQueuedAged += moving.length;
|
|
239
299
|
}
|
|
240
300
|
|
|
241
301
|
/** Free a slot — handed straight to the longest-waiting HIGH caller first
|
|
242
302
|
* (run-11 h2-2), then the longest-waiting low one, when either exists (the
|
|
243
|
-
* live count already covers the handover), else returned.
|
|
303
|
+
* live count already covers the handover), else returned. run-13 (f4):
|
|
304
|
+
* the age check runs BEFORE the lane choice, so a waiter promoted this
|
|
305
|
+
* instant sits at the high head and wakes on THIS release — exactly the
|
|
306
|
+
* sustained-high-traffic starvation f4 describes.
|
|
307
|
+
*/
|
|
244
308
|
function releaseGitSpawn() {
|
|
245
|
-
|
|
246
|
-
|
|
309
|
+
promoteAgedLowWaiters();
|
|
310
|
+
let next: GitSpawnWaiter | undefined;
|
|
311
|
+
if (gitSpawnQueueHigh.length) {
|
|
312
|
+
next = gitSpawnQueueHigh.shift();
|
|
313
|
+
// The head waiter was a promoted one — one fewer in the promoted prefix.
|
|
314
|
+
if (gitSpawnPromotedHead > 0) gitSpawnPromotedHead--;
|
|
315
|
+
} else {
|
|
316
|
+
next = gitSpawnQueueLow.shift();
|
|
317
|
+
}
|
|
318
|
+
if (next) next.wake();
|
|
247
319
|
else gitSpawnLive--;
|
|
248
320
|
}
|
|
249
321
|
|
|
250
322
|
/** run-11 h2-2: the semaphore's state for deviceVitals — live children,
|
|
251
323
|
* waiting callers, and how many of those waiters are interactive ("high")
|
|
252
|
-
* ops parked behind a fan-out. Pure read, no side effects.
|
|
253
|
-
|
|
324
|
+
* ops parked behind a fan-out. Pure read, no side effects. run-13 (f4):
|
|
325
|
+
* queuedAged counts how many low waiters aging has had to rescue —
|
|
326
|
+
* deviceVitals carries this object through untouched, field and all. */
|
|
327
|
+
export function gitSpawnStats(): { live: number; queued: number; queuedHigh: number; queuedAged: number } {
|
|
254
328
|
return {
|
|
255
329
|
live: gitSpawnLive,
|
|
256
330
|
queued: gitSpawnQueueHigh.length + gitSpawnQueueLow.length,
|
|
257
331
|
queuedHigh: gitSpawnQueueHigh.length,
|
|
332
|
+
queuedAged: gitSpawnQueuedAged,
|
|
258
333
|
};
|
|
259
334
|
}
|
|
260
335
|
|
|
@@ -100,10 +100,11 @@ export interface DeviceVitals {
|
|
|
100
100
|
disk: DiskVitals;
|
|
101
101
|
/** Event-loop lag — the number `loadavg` cannot express: how long ready JS waited to run. */
|
|
102
102
|
eventLoop: EventLoopLagVitals;
|
|
103
|
-
/** Git spawn semaphore (run-11 h2-2): children live now,
|
|
104
|
-
* for a slot,
|
|
105
|
-
*
|
|
106
|
-
|
|
103
|
+
/** Git spawn semaphore (run-11 h2-2 + run-13 f4): children live now,
|
|
104
|
+
* callers waiting for a slot, how many waiters sit in the interactive
|
|
105
|
+
* "high" lane, and how many low waiters aging (>10s) has had to rescue
|
|
106
|
+
* from high-lane starvation — the f4 gauge. */
|
|
107
|
+
gitSpawns: { live: number; queued: number; queuedHigh: number; queuedAged: number };
|
|
107
108
|
pid: number;
|
|
108
109
|
at: number;
|
|
109
110
|
}
|
|
@@ -79,5 +79,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
79
79
|
`)[0]?.slice(0,100):``;if(i){m.value=i;return}c.push(`${e.provider}/${e.id}: ${n.status===`unanswered`?n.reason:`empty answer`}`)}finally{t.session(r).archive().catch(()=>{})}}Y(`ai message failed on every model — ${c.join(`; `).slice(0,140)}`)}catch(e){Y(`ai message failed: ${e.message.slice(0,120)}`)}finally{f.value=``}}async function ft(){if(r.value&&d.value){f.value=`session-files`;try{let e=await G(r.value).sessionGitFiles(d.value);ne.value=e.files;let t=e=>e.startsWith(`/`)||e.includes(`:\\`)?e:`${n.value}/${e}`,i=new Set(e.files.map(t)),a=O.value.filter(e=>i.has(t(e.path)));h.value=new Set(a.map(e=>e.path)),Y(a.length?`${a.length} session file(s) still changed — checked`:`the session touched nothing that is still changed`)}catch(e){Y(`session files failed: ${e.message.slice(0,120)}`)}finally{f.value=``}}}async function pt(e){if(le.value.has(e)){le.value.delete(e),le.value=new Map(le.value);return}if(r.value&&n.value)try{let t=await G(r.value).gitOp(n.value,`show-files`,{target:e});le.value=new Map(le.value).set(e,t.changed??[])}catch(e){Y(`commit files failed: ${e.message.slice(0,120)}`)}}async function mt(){if(!r.value||!n.value)return;let e=`cp-${new Date().toISOString().slice(0,16).replace(/[-:T]/g,``)}`;f.value=`checkpoint`;try{Y((await G(r.value).gitOp(n.value,`checkpoint`,{name:e})).text),ce.value=!0,await ht()}catch(e){Y(`checkpoint failed: ${e.message.slice(0,120)}`)}finally{f.value=``}}async function ht(){if(r.value&&n.value)try{let e=await G(r.value).gitOp(n.value,`checkpoints`);se.value=e.checkpoints??[]}catch{se.value=[]}}async function gt(e){if(!r.value||!n.value)return;let t=e;ae({title:`Rewind to ${t}?`,body:`reset --hard — ALL uncommitted changes in this worktree are LOST.`,confirmLabel:`Rewind`,danger:!0,action:()=>void _t(t)})}async function _t(e){if(r.value&&n.value){f.value=`rewind`;try{Y((await G(r.value).gitOp(n.value,`rewind`,{name:e})).text),await Fe(),Dt(!0)}catch(e){Y(`rewind failed: ${e.message.slice(0,120)}`)}finally{f.value=``}}}N(ce,e=>{e&&ht()});async function vt(e){if(_.value=!1,r.value&&n.value&&a.value?.root){f.value=`wt`;try{Y((await Ap(G(r.value),n.value,a.value.root,e)).text),v.value=``,await Fe()}catch(e){Y(`worktree failed: ${e.message.slice(0,140)}`)}finally{f.value=``}}}async function yt(e,t){if(r.value){f.value=`session`;try{let n=Ju.devices.value.find(e=>e.id===r.value)?.info,i=ut(n)[0];if(!i)return Y(`no model available on ${r.value} — cannot create a session`);let a=await jp(G(r.value),e,t??e.slice(e.lastIndexOf(`/`)+1),{provider:i.provider,modelId:i.id});dd({deviceId:r.value,sessionId:a.id,agentId:1}),Y(`session "${a.name}" on ${e}`)}catch(e){Y(`session failed: ${e.message.slice(0,160)}`)}finally{f.value=``}}}async function bt(e){if(r.value){f.value=`go`;try{let t=(await G(r.value).sessions()).find(t=>t.cwd===e);t?(dd({deviceId:r.value,sessionId:t.id,agentId:1}),Y(`switched to session "${t.name}"`)):await yt(e,null)}catch(e){Y(`switch failed: ${e.message.slice(0,120)}`)}finally{f.value=``}}}async function xt(e){if(!r.value||!n.value)return;f.value=`wt`;let t=`Uncommitted changes in it will be LOST.`;try{let n=(await G(r.value).gitStatusBatch([e],{timeoutMs:6e4}))[e];t=(n?.staged??0)+(n?.unstaged??0)+(n?.untracked??0)>0?`It CONTAINS uncommitted changes — they will be LOST.`:`Its checkout is clean.`}catch{}ae({title:`Remove worktree?`,body:`${e} — ${t}`,confirmLabel:`Remove`,danger:!0,action:()=>void St(e)})}async function St(e){f.value=`wt`;try{await G(r.value).gitOp(n.value,`worktree-remove`,{target:e}),await Fe()}catch(e){Y(`remove failed: ${e.message.slice(0,140)}`)}finally{f.value=``}}let Ct=A([]),wt=A(!1),Tt=A(``),Et=0;async function Dt(e=!1){if(!r.value||!n.value||!e&&Ct.value.length&&Date.now()-Et<12e4)return;let t=Ef(r.value,n.value);if(!t.ok){Ct.value=[],Tt.value=t.reason,Et=Date.now();return}wt.value=!0;try{let e=await G(r.value).gitOp(n.value,`log-list`);Ct.value=e.commits??[],Tt.value=``,Et=Date.now()}catch(e){Tt.value=e.message.slice(0,120)}finally{wt.value=!1}}Dt(),N([r,n],()=>{Ct.value=[],Et=0,Dt()});let Ot=U(()=>(a.value?.worktrees??[]).filter(e=>e.path)),kt=[`#4f8cc9`,`#b8860b`,`#7aa25c`,`#a061ba`,`#c96f6f`,`#5fa8a0`],At=U(()=>{let e=new Map,t=[],n=[];for(let r of Ct.value){let i=e.get(r.hash);i===void 0&&(i=n.indexOf(null),i===-1&&(n.push(null),i=n.length-1),e.set(r.hash,i)),n[i]=null;let a=[];r.parents.forEach((t,r)=>{let o=e.get(t);(o===void 0||n[o]===t)&&(o=n.indexOf(null),o===-1&&(n.push(null),o=n.length-1),e.set(t,o)),n[o]=t,r===0&&(n[i]=t),a.push(o)}),t.push({lane:i,parents:a,width:Math.max(1,n.length)})}return t}),jt=e=>e*12+7;return(e,t)=>(I(),L(`div`,kx,[n.value?(I(),L(F,{key:1},[o.value?(I(),L(`p`,jx,`loading git…`)):l.value?(I(),L(`p`,Mx,`refreshing…`)):H(``,!0),c.value?(I(),L(`div`,Nx,[z(`p`,null,[z(`strong`,null,D(n.value),1),t[41]||=V(` is outside the folders this device serves — it serves `,-1),z(`code`,null,D(c.value),1),t[42]||=V(`. `,-1)]),t[43]||=z(`p`,{class:`muted-line`},[V(` Your session and its history are intact, and the agent still runs in that folder; only the Git and Files panels (the device's HTTP surface) are confined. Nothing has to be recreated: add the folder to `),z(`code`,null,`DPI_START_DIRS`),V(` and restart the device, and this panel works again for the same session. `)],-1),z(`p`,Px,[V(` Example (`+D(s.value?`Windows: separate with ;`:`Linux/macOS: separate with :`)+`) — `,1),z(`code`,null,D(s.value?`setx DPI_START_DIRS "%USERPROFILE%\\dpi-work;D:\\source"`:`DPI_START_DIRS="$HOME/dpi-work:/srv/src"`),1)])])):u.value?(I(),L(`p`,Fx,[V(D(u.value)+` `,1),z(`button`,{onClick:t[0]||=e=>Fe()},`retry`)])):H(``,!0),a.value?(I(),L(`div`,{key:4,class:E({stale:!!u.value||!!l.value})},[a.value.repo?(I(),L(F,{key:1},[a.value.merge?(I(),L(`p`,Lx,[V(` merge in progress — `+D(a.value.conflicts??Be.value.length)+` unmerged path(s). Resolve them in the lists above, or `,1),z(`button`,{class:`small`,disabled:!!f.value,onClick:t[1]||=e=>ot()},`abort merge`,8,Rx)])):H(``,!0),z(`div`,zx,[z(`div`,Bx,[z(`button`,{class:`branch-btn`,disabled:!!f.value,onClick:t[2]||=e=>g.value=!g.value},[B(j(xc),{size:16}),z(`strong`,null,D(a.value.branch??`detached`),1),B(j(nc),{size:14})],8,Vx),g.value?(I(),L(`div`,Hx,[(I(!0),L(F,null,P(a.value.branches??[],e=>(I(),L(`button`,{key:e.name,class:E({cur:e.current}),onClick:t=>ct(e.name)},[B(j(xc),{size:13}),z(`span`,null,D(e.name),1),z(`span`,Wx,D(e.current?`current`:e.upstream?`→ ${e.upstream}`:``),1),t[45]||=z(`span`,{class:`grow`},null,-1),e.current?H(``,!0):(I(),R(j(Sc),{key:0,size:13,title:`compare with this base`,onClick:ks(t=>st(e.name),[`stop`])},null,8,[`onClick`]))],10,Ux))),128)),z(`div`,Gx,[M(z(`input`,{"onUpdate:modelValue":t[3]||=e=>v.value=e,placeholder:`new branch…`,onKeyup:t[4]||=js(e=>v.value.trim()&&ct(v.value.trim(),!0),[`enter`])},null,544),[[ys,v.value]]),z(`button`,{disabled:!v.value.trim(),onClick:t[5]||=e=>ct(v.value.trim(),!0)},[B(j(Xc),{size:13})],8,Kx)]),z(`label`,qx,[M(z(`input`,{type:`checkbox`,"onUpdate:modelValue":t[6]||=e=>C.value=e},null,512),[[bs,C.value]]),t[46]||=V(` auto-stash on switch`,-1)])])):H(``,!0)]),z(`span`,Jx,D(a.value.upstream??`no upstream`),1),a.value.ahead?(I(),L(`span`,Yx,`↑`+D(a.value.ahead),1)):H(``,!0),a.value.behind?(I(),L(`span`,Xx,`↓`+D(a.value.behind),1)):H(``,!0),S.value?(I(),L(`span`,Zx,[V(` vs `+D(S.value.ref)+`: ↑`+D(S.value.ahead)+` ↓`+D(S.value.behind)+` `,1),z(`button`,{class:`tag-x`,onClick:t[7]||=e=>S.value=null},[B(j(xl),{size:11})])])):H(``,!0),z(`span`,Qx,`+`+D(a.value.staged??0)+` ~`+D(a.value.unstaged??0)+` ?`+D(a.value.untracked??0),1),We.value?(I(),L(`a`,{key:3,class:`icon-button`,href:`${We.value}/tree/${a.value.branch??``}`,target:`_blank`,rel:`noopener`,title:`open on the remote`},[B(j(Ks),{size:15,style:{transform:`rotate(45deg)`}})],8,$x)):H(``,!0),z(`button`,{class:`icon-button`,disabled:!!f.value||o.value||l.value,title:`refresh`,onClick:t[8]||=e=>Fe()},[B(j($c),{size:16})],8,eS)]),z(`div`,tS,[z(`button`,{class:`small`,disabled:!!f.value,onClick:t[9]||=e=>Qe(`fetch`)},[B(j(Ws),{size:14}),t[47]||=V(`fetch`,-1)],8,nS),z(`button`,{class:`small`,disabled:!!f.value,onClick:t[10]||=e=>Qe(`pull`)},[B(j(Ws),{size:14}),t[48]||=V(`pull`,-1)],8,rS),z(`button`,{class:`small primary`,disabled:!!f.value,title:`push`,onClick:t[11]||=e=>Qe(`push`)},[B(j(Ks),{size:14}),t[49]||=V(`push`,-1)],8,iS),z(`button`,{class:`small`,disabled:!!f.value,title:`stash changes`,onClick:t[12]||=e=>Qe(`stash-push`,{message:m.value.trim()||void 0})},[B(j(dl),{size:14}),t[50]||=V(`stash`,-1)],8,aS),z(`button`,{class:`small`,disabled:!!f.value,title:`pop the newest stash`,onClick:t[13]||=e=>Qe(`stash-pop`)},[B(j(Hc),{size:14}),t[51]||=V(`unstash`,-1)],8,oS)]),ee.value?(I(),L(`p`,sS,[V(D(ee.value)+` `,1),ee.value.includes(`upstream`)?(I(),L(`button`,{key:0,class:`small primary`,disabled:!!f.value,onClick:t[14]||=e=>Qe(`push`,{setUpstream:!0,ref:a.value.branch})},`push -u origin `+D(a.value.branch),9,cS)):ee.value.includes(`remote has work`)?(I(),L(`button`,{key:1,class:`small primary`,disabled:!!f.value,onClick:t[15]||=e=>Qe(`pull`)},`pull now`,8,lS)):H(``,!0)])):H(``,!0),te.value?(I(),L(`p`,uS,[t[52]||=V(` fast-forward is not possible — branches diverged. `,-1),z(`button`,{class:`small primary`,disabled:!!f.value,onClick:t[16]||=e=>Qe(`pull`,{rebase:!0})},`pull --rebase`,8,dS)])):H(``,!0),z(`section`,fS,[z(`div`,pS,[t[53]||=z(`h4`,null,`Commit`,-1),z(`span`,mS,D(O.value.length?`${h.value.size}/${O.value.length} files`:`no changes`),1),t[54]||=z(`span`,{class:`grow`},null,-1),d.value?(I(),L(`button`,{key:0,class:`small`,disabled:!!f.value,title:`check the files this session's agent touched`,onClick:ft},[B(j(_c),{size:13}),V(` session files`+D(re.value?` (${re.value.changed}/${re.value.total})`:``),1)],8,hS)):H(``,!0),d.value?(I(),L(`button`,{key:1,class:`small`,disabled:!!f.value,title:`what each turn of this session changed`,onClick:t[17]||=e=>Ae.value=!Ae.value},` turns `,8,gS)):H(``,!0)]),Ue.value?(I(),L(`p`,_S,[...t[55]||=[V(` git on the device cannot resolve an author, so commits would be refused. Set one for the account that runs the device: `,-1),z(`code`,null,`git config --global user.name "Your Name"`,-1),V(` and `,-1),z(`code`,null,`git config --global user.email "you@example.com"`,-1),V(` (or just this repo: `,-1),z(`code`,null,`git config user.name …`,-1),V(`), then restart the device so it picks the new config up. `,-1)]])):H(``,!0),Ae.value?(I(),L(`div`,vS,[ke.value.length?H(``,!0):(I(),L(`p`,yS,`no turns recorded yet for this session.`)),(I(!0),L(F,null,P(ke.value,(e,t)=>(I(),L(`div`,{key:t,class:`cp-row`},[z(`code`,null,`t`+D(ke.value.length-t),1),z(`span`,bS,D(e.when.slice(0,16).replace(`T`,` `)),1),z(`span`,xS,D(e.files.map(e=>`${e.path}×${e.writes}${e.a!==void 0||e.d!==void 0?` (+${e.a??0} −${e.d??0})`:``}`).join(`, `)||`(no file writes)`),1)]))),128))])):H(``,!0),Ve.value?(I(),L(`p`,SS,`showing the first 500 changed files — commit in smaller batches`)):H(``,!0),Be.value.length?(I(),L(`div`,CS,[z(`label`,wS,[z(`span`,TS,`Conflicts · `+D(Be.value.length)+` — pick a side per file`,1)]),(I(!0),L(F,null,P(Be.value,e=>(I(),L(`div`,{key:e.path,class:`file`},[z(`label`,ES,[z(`code`,DS,D(e.x)+D(e.y),1),z(`span`,{class:`path`,title:e.path},D(e.path),9,OS)]),z(`span`,kS,[z(`button`,{class:`icon-button`,title:`view the conflict`,onClick:t=>rt(e.path)},[B(j(hc),{size:13})],8,AS),z(`button`,{class:`small`,disabled:!!f.value,title:`keep this branch's version and stage it`,onClick:t=>tt(`ours`,e.path)},`ours`,8,jS),z(`button`,{class:`small`,disabled:!!f.value,title:`take the incoming version and stage it`,onClick:t=>tt(`theirs`,e.path)},`theirs`,8,MS)])]))),128))])):H(``,!0),Le.value.length?(I(),L(`div`,NS,[z(`label`,PS,[z(`input`,{type:`checkbox`,checked:Le.value.every(e=>h.value.has(e.path)),onChange:t[18]||=e=>Ke(Le.value)},null,40,FS),z(`span`,IS,`Staged · `+D(Le.value.length),1),t[58]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`icon-button`,title:`stage every changed file`,onClick:t[19]||=e=>$e(`stage`)},[B(j(Xc),{size:13}),t[56]||=V(` all`,-1)]),z(`button`,{class:`icon-button`,title:`unstage all (git reset HEAD)`,onClick:t[20]||=e=>et(Le.value.map(e=>e.path))},[B(j(Rc),{size:13}),t[57]||=V(` none`,-1)])]),(I(!0),L(F,null,P(Je(Le.value),e=>(I(),L(F,{key:e.dir},[e.dir===`.`?H(``,!0):(I(),L(`button`,{key:0,class:`dir-row`,onClick:t=>Ye(e.dir)},[B(j(rc),{size:12,class:E({open:e.open})},null,8,[`class`]),V(D(e.dir),1),z(`span`,RS,`· `+D(e.files.length),1)],8,LS)),(I(!0),L(F,null,P(e.files,t=>M((I(),L(`div`,{key:t.path,class:`file`},[z(`label`,zS,[z(`input`,{type:`checkbox`,checked:h.value.has(t.path),onChange:e=>Ge(t.path)},null,40,BS),z(`code`,{class:`xy`,title:`index ${t.x} · worktree ${t.y}`},D(t.x)+D(t.y),9,VS),z(`span`,{class:`path`,title:t.path},D(t.path),9,HS),Xe(t)?(I(),L(`span`,{key:0,class:E([`nums`,{bin:Xe(t)===`bin`}])},D(Xe(t)),3)):H(``,!0)]),z(`span`,US,[z(`button`,{class:`icon-button`,title:`view diff`,onClick:e=>rt(t.path)},[B(j(hc),{size:13})],8,WS),z(`button`,{class:`icon-button`,title:`unstage (git reset HEAD)`,onClick:e=>et([t.path])},[B(j(Rc),{size:13})],8,GS),z(`button`,{class:`icon-button`,title:`roll back to HEAD`,onClick:e=>$e(`discard`,t.path)},[B(j(uc),{size:13})],8,KS)])])),[[Ro,e.open]])),128))],64))),128))])):H(``,!0),Re.value.length?(I(),L(`div`,qS,[z(`label`,JS,[z(`input`,{type:`checkbox`,checked:Re.value.every(e=>h.value.has(e.path)),onChange:t[21]||=e=>Ke(Re.value)},null,40,YS),z(`span`,XS,`Unstaged · `+D(Re.value.length),1)]),(I(!0),L(F,null,P(Je(Re.value),e=>(I(),L(F,{key:e.dir},[e.dir===`.`?H(``,!0):(I(),L(`button`,{key:0,class:`dir-row`,onClick:t=>Ye(e.dir)},[B(j(rc),{size:12,class:E({open:e.open})},null,8,[`class`]),V(D(e.dir),1),z(`span`,QS,`· `+D(e.files.length),1)],8,ZS)),(I(!0),L(F,null,P(e.files,t=>M((I(),L(`div`,{key:t.path,class:`file`},[z(`label`,$S,[z(`input`,{type:`checkbox`,checked:h.value.has(t.path),onChange:e=>Ge(t.path)},null,40,eC),z(`code`,{class:`xy`,title:`index ${t.x} · worktree ${t.y}`},D(t.x)+D(t.y),9,tC),z(`span`,{class:`path`,title:t.path},D(t.path),9,nC),Xe(t)?(I(),L(`span`,{key:0,class:E([`nums`,{bin:Xe(t)===`bin`}])},D(Xe(t)),3)):H(``,!0)]),z(`span`,rC,[z(`button`,{class:`icon-button`,title:`view diff`,onClick:e=>rt(t.path)},[B(j(hc),{size:13})],8,iC),t.x===`?`?(I(),L(`button`,{key:0,class:`icon-button`,title:`add to .gitignore`,onClick:e=>nt([t.path])},[B(j(Ys),{size:13})],8,aC)):(I(),L(`button`,{key:1,class:`icon-button`,title:`stage (git add)`,onClick:e=>$e(`stage`,t.path)},[B(j(Xc),{size:13})],8,oC)),t.x===`?`?H(``,!0):(I(),L(`button`,{key:2,class:`icon-button`,title:`roll back to HEAD`,onClick:e=>$e(`discard`,t.path)},[B(j(uc),{size:13})],8,sC)),z(`button`,{class:`icon-button`,title:`copy path`,onClick:e=>Ze(t.path)},[B(j(sc),{size:13})],8,cC)])])),[[Ro,e.open]])),128))],64))),128))])):H(``,!0),y.value?(I(),L(`p`,lC,[z(`strong`,null,D(y.value.path),1),z(`span`,uC,[z(`button`,{class:E({on:b.value===`working`}),onClick:t[22]||=e=>{b.value=`working`,it()}},`working`,2),z(`button`,{class:E({on:b.value===`staged`}),onClick:t[23]||=e=>{b.value=`staged`,it()}},`staged`,2)]),at.value?(I(),L(`span`,dC,`binary file`)):y.value.text.length>8e3?(I(),L(`span`,fC,`truncated at 8000 chars`)):H(``,!0),z(`button`,{class:`icon-button`,title:`close diff`,onClick:t[24]||=e=>y.value=null},[B(j(xl),{size:13})]),at.value?H(``,!0):(I(),L(`pre`,pC,D(y.value.text.slice(0,8e3)),1))])):H(``,!0),M(z(`textarea`,{"onUpdate:modelValue":t[25]||=e=>m.value=e,rows:`4`,placeholder:`Commit message… (Ctrl+Enter to commit)`,onKeydown:[t[26]||=js(ks(e=>lt(),[`exact`,`prevent`]),[`enter`]),t[27]||=js(ks(e=>lt(),[`meta`,`prevent`]),[`enter`]),t[28]||=js(ks(e=>lt(),[`ctrl`,`prevent`]),[`enter`])]},null,544),[[ys,m.value]]),z(`div`,mC,[z(`button`,{class:`small`,disabled:!!f.value||!h.value.size,title:`ask the device's model for a message`,onClick:dt},[B(j(ll),{size:14}),t[59]||=V(` ai message`,-1)],8,hC),t[61]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`primary small`,disabled:!!f.value||!m.value.trim()||!Ie.value,onClick:t[29]||=e=>lt(!1)},[B(j(tc),{size:14}),V(` Commit`+D(h.value.size?` ${h.value.size} file${h.value.size>1?`s`:``}`:``),1)],8,gC),a.value.upstream?(I(),L(`button`,{key:0,class:`primary small`,disabled:!!f.value||!m.value.trim()||!Ie.value,title:`commit, then push`,onClick:t[30]||=e=>lt(!0)},[B(j(tc),{size:14}),t[60]||=V(` Commit & push `,-1)],8,_C)):H(``,!0)])]),z(`section`,vC,[z(`div`,yC,[z(`h4`,null,[B(j(Ec),{size:16}),t[62]||=V(` Log`,-1)]),t[64]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`small`,disabled:!!f.value,title:`save a checkpoint ref of HEAD`,onClick:mt},[B(j(_c),{size:13}),t[63]||=V(` checkpoint`,-1)],8,bC),z(`button`,{class:`small`,disabled:!!f.value,onClick:t[31]||=e=>ce.value=!ce.value},`checkpoints `+D(se.value.length?`(${se.value.length})`:``),9,xC),z(`button`,{class:`icon-button`,disabled:wt.value,title:`refresh log`,onClick:t[32]||=e=>Dt(!0)},[B(j($c),{size:14})],8,SC)]),ce.value?(I(),L(`div`,CC,[se.value.length?H(``,!0):(I(),L(`p`,wC,`no checkpoints yet — one click saves a named ref of HEAD.`)),(I(!0),L(F,null,P(se.value,e=>(I(),L(`div`,{key:e.name,class:`cp-row`},[z(`code`,null,D(e.name),1),z(`span`,TC,D(e.hash)+` · `+D(e.date),1),z(`span`,EC,D(e.subject),1),t[66]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`small`,disabled:!!f.value,title:`reset --hard to this checkpoint (this worktree)`,onClick:t=>gt(e.name)},[B(j(hl),{size:13}),t[65]||=V(` rewind`,-1)],8,DC)]))),128))])):H(``,!0),wt.value&&!Ct.value.length?(I(),L(`p`,OC,`loading log…`)):Ct.value.length?(I(),L(`div`,kC,[(I(!0),L(F,null,P(Ct.value,(e,t)=>(I(),L(F,{key:e.hash},[z(`div`,{class:`commit-row`,title:e.refs},[At.value[t]?(I(),L(`svg`,{key:0,class:`lane`,viewBox:`0 0 ${At.value[t].width*12+4} 24`,style:T({width:`${At.value[t].width*.75+.25}rem`,height:`1.5rem`}),"aria-hidden":`true`},[(I(!0),L(F,null,P(At.value[t].width,e=>(I(),L(`line`,{key:e,x1:jt(e-1),x2:jt(e-1),y1:`0`,y2:`24`,stroke:`#3a3134`,"stroke-width":`2`},null,8,MC))),128)),(I(!0),L(F,null,P(At.value[t].parents,(e,n)=>(I(),L(`line`,{key:`p`+n,x1:jt(At.value[t].lane),x2:jt(e),y1:`12`,y2:`24`,stroke:kt[e%kt.length],"stroke-width":`2`},null,8,NC))),128)),z(`circle`,{cx:jt(At.value[t].lane),cy:`12`,r:`4`,fill:kt[At.value[t].lane%kt.length]},null,8,PC)],12,jC)):H(``,!0),z(`button`,{class:`icon-button hash-btn`,title:`files in this commit`,onClick:t=>pt(e.hash)},[B(j(rc),{size:12,class:E({open:le.value.has(e.hash)})},null,8,[`class`])],8,FC),z(`code`,IC,[We.value?(I(),L(`a`,{key:0,href:`${We.value}/commit/${e.hash}`,target:`_blank`,rel:`noopener`,title:`on the remote`},D(e.hash),9,LC)):(I(),L(F,{key:1},[V(D(e.hash),1)],64))]),e.refs?(I(),L(`span`,RC,D(e.refs.split(`,`)[0]),1)):H(``,!0),z(`span`,zC,D(e.subject),1),z(`span`,BC,D(e.author)+` · `+D(e.date),1)],8,AC),le.value.has(e.hash)?(I(),L(`div`,VC,[(I(!0),L(F,null,P(le.value.get(e.hash),e=>(I(),L(`div`,{key:e.path,class:`cf`},[z(`code`,{class:`cf-status`,"data-s":e.status},D(e.status),9,HC),z(`span`,UC,D(e.path),1)]))),128)),le.value.get(e.hash)?.length?H(``,!0):(I(),L(`p`,WC,`no files (merge/empty commit)`))])):H(``,!0)],64))),128))])):Tt.value?(I(),L(`p`,GC,`log failed: `+D(Tt.value),1)):(I(),L(`p`,KC,`no commits`))]),z(`section`,qC,[z(`div`,JC,[z(`h4`,null,[B(j(Hc),{size:16}),t[67]||=V(` Worktrees`,-1)]),z(`div`,YC,[z(`button`,{class:`small`,disabled:!!f.value,onClick:t[33]||=e=>_.value=!_.value},[B(j(Xc),{size:13}),t[68]||=V(` worktree`,-1)],8,XC),_.value?(I(),L(`div`,ZC,[(I(!0),L(F,null,P((a.value.branches??[]).filter(e=>!e.current),e=>(I(),L(`button`,{key:e.name,onClick:t=>vt(e.name)},[B(j(xc),{size:13}),z(`span`,null,D(e.name),1),t[69]||=z(`span`,{class:`muted-line`},`existing`,-1)],8,QC))),128)),z(`div`,$C,[M(z(`input`,{"onUpdate:modelValue":t[34]||=e=>v.value=e,placeholder:`or a NEW branch…`,onKeyup:t[35]||=js(e=>v.value.trim()&&vt(v.value.trim()),[`enter`])},null,544),[[ys,v.value]]),z(`button`,{disabled:!v.value.trim(),onClick:t[36]||=e=>vt(v.value.trim())},`create`,8,ew)])])):H(``,!0)])]),(I(!0),L(F,null,P(Ot.value,e=>(I(),L(`div`,{key:e.path,class:E([`wt`,{main:e.path===a.value.root}])},[z(`code`,{title:e.path},D(e.path),9,tw),z(`span`,nw,D(e.branch??e.head),1),t[70]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`icon-button`,disabled:!!f.value,title:`jump to this worktree (session or new)`,onClick:t=>bt(e.path)},[B(j(Gs),{size:13})],8,rw),z(`button`,{class:`small`,disabled:!!f.value,title:`create a session on this worktree`,onClick:t=>yt(e.path,e.branch)},`session`,8,iw),e.path===a.value.root?H(``,!0):(I(),L(`button`,{key:0,class:`icon-button`,disabled:!!f.value,onClick:t=>xt(e.path)},[B(j(xl),{size:13})],8,aw)),e.path===a.value.root?(I(),R(j(tc),{key:1,size:13,class:`muted-line`})):H(``,!0)],2))),128))]),ge.value?(I(),L(`section`,ow,[z(`div`,sw,[z(`h4`,null,[B(j(wc),{size:16}),V(` `+D(he.value?`Pull requests`:_e.value+`s`),1)]),t[71]||=z(`span`,{class:`grow`},null,-1),!he.value&&ve.value?(I(),L(`a`,{key:0,class:`small btn-like`,href:ve.value,target:`_blank`,rel:`noopener`},`new `+D(_e.value),9,cw)):H(``,!0),!he.value&&ye.value?(I(),L(`a`,{key:1,class:`small btn-like`,href:ye.value,target:`_blank`,rel:`noopener`},`open `+D(_e.value)+`s`,9,lw)):H(``,!0),!he.value&&ge.value?(I(),L(`a`,{key:2,class:`small btn-like`,href:ge.value,target:`_blank`,rel:`noopener`},`repo`,8,uw)):H(``,!0)]),he.value?(I(),L(F,{key:1},[z(`div`,fw,[t[74]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`small`,disabled:pe.value||!!f.value,onClick:Se},`create PR`,8,pw),z(`button`,{class:`small`,disabled:pe.value,onClick:t[37]||=e=>de.value=!de.value},D(de.value?`hide`:`list`),9,mw)]),de.value&&!ue.value.length&&!pe.value?(I(),L(`p`,hw,`no open PRs (or gh is not logged in on the device — every action will say so).`)):H(``,!0),de.value?(I(),L(`div`,gw,[(I(!0),L(F,null,P(ue.value,e=>(I(),L(`div`,{key:e.n,class:`pr-row`},[z(`code`,_w,`#`+D(e.n),1),z(`span`,{class:E([`tag`,{open:e.state===`OPEN`}])},D(e.state.toLowerCase())+D(e.draft?` · draft`:``),3),z(`span`,vw,D(e.title),1),z(`span`,yw,D(e.branch),1),t[75]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`icon-button`,title:`run checks`,disabled:pe.value,onClick:t=>we(e.n)},[B(j($c),{size:13})],8,bw),z(`button`,{class:`icon-button`,title:`comment`,disabled:pe.value,onClick:t=>De(e.n)},[B(j(sc),{size:13})],8,xw),e.state===`OPEN`?(I(),L(`button`,{key:0,class:`small`,disabled:pe.value||!!f.value,onClick:t=>Te(e.n)},`squash & merge`,8,Sw)):H(``,!0),be(e.url)?(I(),L(`a`,{key:1,class:`icon-button`,href:be(e.url),target:`_blank`,rel:`noopener`,title:`open on the forge`},[B(j(Ks),{size:13,style:{transform:`rotate(45deg)`}})],8,Cw)):H(``,!0)]))),128)),(I(!0),L(F,null,P(fe.value,([e,t])=>(I(),L(`pre`,{key:e,class:`pr-checks`},`#`+D(e)+` checks:`+D(`
|
|
80
80
|
`)+D(t),1))),128))])):H(``,!0)],64)):(I(),L(`p`,dw,[V(D(me.value===`gitlab`?`GitLab`:me.value===`bitbucket`?`Bitbucket`:`this forge`)+` — `+D(_e.value)+`s open on the website: review, approve and merge there (the device drives `,1),t[72]||=z(`code`,null,`git`,-1),t[73]||=V(` itself; only GitHub has a CLI it can drive). `,-1)]))])):H(``,!0),p.value?(I(),L(`pre`,ww,D(p.value.slice(0,6e3)),1)):H(``,!0)],64)):(I(),L(`p`,Ix,[...t[44]||=[V(`Not a git repository — run `,-1),z(`code`,null,`git init`,-1),V(` (or open a session inside a repo).`,-1)]]))],2)):H(``,!0),w.value?(I(),L(`div`,{key:5,class:`modal-veil`,onClick:t[40]||=ks(e=>w.value=null,[`self`])},[z(`div`,{class:E([`modal`,{danger:w.value.danger}]),role:`dialog`,"aria-modal":`true`},[z(`h5`,null,D(w.value.title),1),z(`p`,null,D(w.value.body),1),w.value.input?M((I(),L(`textarea`,{key:0,"onUpdate:modelValue":t[38]||=e=>ie.value=e,rows:`2`,placeholder:w.value.input.placeholder},null,8,Tw)),[[ys,ie.value]]):H(``,!0),z(`div`,Ew,[t[77]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`small`,onClick:t[39]||=e=>w.value=null},[...t[76]||=[V(`cancel `,-1),z(`span`,{class:`muted-line`},`(esc)`,-1)]]),z(`button`,{class:E([`primary small`,{danger:w.value.danger}]),disabled:!(!w.value.input||ie.value.trim()),onClick:oe},D(w.value.confirmLabel??`confirm`),11,Dw)])],2)])):H(``,!0)],64)):(I(),L(`p`,Ax,`No session selected — open a session to see its git.`))]))}}),[[`__scopeId`,`data-v-282c66da`]]),kw={class:`host-panel`,"aria-label":`Device vitals`},Aw={class:`panel-heading`},jw=[`disabled`],Mw={key:0,class:`hint`},Nw={key:1,class:`message-error`},Pw={key:2,class:`hint`},Fw={class:`vitals-grid`},Iw={class:`vital`},Lw={class:`vital`},Rw={key:0,class:`vital`},zw={class:`vital`},Bw={class:`vital`},Vw={class:`meter`},Hw={class:`meter-head`},Uw={class:`hint`},Ww=[`aria-valuenow`],Gw={class:`meter`},Kw={class:`meter-head`},qw={class:`hint`},Jw=[`aria-valuenow`],Yw={class:`path`},Xw={class:`hint`},Zw=pf(Er({__name:`HostPanel`,setup(e){let t=A(),n=A(!1),r=A(``),i=U(()=>q.value?.deviceId),a=U(()=>Ju.devices.value.find(e=>e.id===i.value)?.info?.keepAwake),o=e=>{if(!Number.isFinite(e)||e<=0)return`0`;let t=[`B`,`KiB`,`MiB`,`GiB`,`TiB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=100||r===0?Math.round(n):n.toFixed(1)} ${t[r]}`},s=e=>{let t=Math.max(0,Math.floor(e));if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`},c=(e,t)=>t>0?Math.max(0,Math.min(100,Math.round(e/t*100))):0,l=U(()=>t.value?c(t.value.memory.usedBytes,t.value.memory.totalBytes):0),u=U(()=>t.value?.disk.known?c(t.value.disk.totalBytes-t.value.disk.freeBytes,t.value.disk.totalBytes):0);async function d(){let e=i.value;if(t.value=void 0,r.value=``,e){n.value=!0;try{t.value=await G(e).vitals()}catch(e){r.value=K(e).slice(0,160)}finally{n.value=!1}}}N(i,d,{immediate:!0});async function f(){await d(),r.value||Y(`Vitals refreshed.`)}return(e,c)=>(I(),L(`section`,kw,[z(`header`,Aw,[z(`span`,null,[B(j(il),{size:16}),c[0]||=V(`HOST`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh vitals`,title:`Refresh vitals`,onClick:f},[B(j($c),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,jw)]),i.value?r.value?(I(),L(`p`,Nw,D(r.value),1)):t.value?(I(),L(F,{key:3},[z(`div`,Fw,[z(`div`,Iw,[c[1]||=z(`span`,{class:`label`},`Host uptime`,-1),z(`strong`,null,D(s(t.value.uptime)),1)]),z(`div`,Lw,[c[2]||=z(`span`,{class:`label`},`Device process`,-1),z(`strong`,null,D(s(t.value.processUptime)),1),z(`em`,null,`pid `+D(t.value.pid),1)]),a.value?(I(),L(`div`,Rw,[c[3]||=z(`span`,{class:`label`},`Keep-awake`,-1),z(`strong`,null,D(a.value===`none`?`off`:a.value),1),z(`em`,null,D(a.value===`none`?`no inhibitor here`:`held while sessions run`),1)])):H(``,!0),z(`div`,zw,[c[4]||=z(`span`,{class:`label`},`Load (1/5/15m)`,-1),z(`strong`,null,D(t.value.loadavg.map(e=>e.toFixed(2)).join(` · `)),1),z(`em`,null,D(t.value.cpuCount)+` CPU`+D(t.value.cpuCount===1?``:`s`),1)]),z(`div`,Bw,[c[5]||=z(`span`,{class:`label`},`Sessions`,-1),z(`strong`,null,D(t.value.counts?.sessions??0),1),z(`em`,null,D(t.value.counts?.archived??0)+` archived`,1)])]),z(`div`,Vw,[z(`div`,Hw,[c[6]||=z(`span`,{class:`label`},`Memory`,-1),z(`span`,Uw,D(o(t.value.memory.usedBytes))+` / `+D(o(t.value.memory.totalBytes))+` · device `+D(o(t.value.memory.processRssBytes)),1)]),z(`div`,{class:`bar`,role:`meter`,"aria-valuenow":l.value,"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`Memory used`},[z(`i`,{style:T({width:`${l.value}%`}),class:E({high:l.value>=90})},null,6)],8,Ww)]),z(`div`,Gw,[z(`div`,Kw,[c[7]||=z(`span`,{class:`label`},`Disk · data dir`,-1),z(`span`,qw,[t.value.disk.known?(I(),L(F,{key:0},[V(D(o(t.value.disk.totalBytes-t.value.disk.freeBytes))+` used · `+D(o(t.value.disk.freeBytes))+` free `,1)],64)):(I(),L(F,{key:1},[V(`unknown on this volume`)],64))])]),z(`div`,{class:`bar`,role:`meter`,"aria-valuenow":u.value,"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`Disk used`},[z(`i`,{style:T({width:`${u.value}%`}),class:E({high:u.value>=90})},null,6)],8,Jw),z(`code`,Yw,D(t.value.disk.path),1)]),z(`p`,Xw,[B(j(Vs),{size:13}),c[8]||=V(` Read on demand — open this tab or press refresh. Nothing polls the device. `,-1)])],64)):(I(),L(`p`,Pw,D(n.value?`Reading host…`:`No vitals.`),1)):(I(),L(`p`,Mw,`Select a session to see its device.`))]))}}),[[`__scopeId`,`data-v-481bbe80`]]);function Qw(e){let t=K(e);return e.code===`not_found`||/allowlist|not found/i.test(t)}function $w(e,t){let n=Ju.devices.value.find(t=>t.id===e),r=n?.name||`This device`,i=n?.info;return i&&!i.packageVersion&&i.durableVersion?`${r} runs the pre-rename build (durable ${i.durableVersion}) — ${t} needs the new one. On that machine: npm i -g my-durable@latest, then dpi device stop && dpi device start.`:`${r} runs an older build — ${t}. Update it on that machine (\`dpi update\`).`}var eT={class:`usage-panel`,"aria-label":`Device usage`},tT={class:`panel-heading`},nT=[`disabled`],rT={key:0,class:`hint`},iT={key:1,class:`message-error`},aT={key:2,class:`hint`},oT={key:3,class:`hint`},sT={class:`usage-block`,"aria-labelledby":`usage-totals`},cT={class:`totals`},lT={class:`total`},uT={class:`total`},dT={class:`total`},fT={class:`total`},pT={class:`usage-block`,"aria-labelledby":`usage-models`},mT={class:`section-label block-label`},hT={class:`table-scroll`},gT={class:`usage-table`,"aria-label":`Usage by model`},_T=[`title`],vT={class:`num`},yT={class:`num`},bT={class:`share-col`},xT={class:`share`},ST=[`aria-valuenow`,`aria-label`],CT={class:`pct`},wT={class:`usage-block`,"aria-labelledby":`usage-projects`},TT={class:`section-label block-label`},ET={key:0,class:`hint`},DT={key:1,class:`rows`},OT=[`title`],kT={class:`row-main`},AT={class:`row-num`},jT={class:`row-num`},MT={class:`row-meta`},NT={class:`usage-block`,"aria-labelledby":`usage-sessions`},PT={key:0,class:`hint`},FT={key:1,class:`rows scroll`},IT=[`title`],LT={class:`row-main`},RT={class:`row-num`},zT={class:`row-num`},BT={class:`row-meta`},VT={class:`hint`},HT=pf(Er({__name:`UsagePanel`,setup(e){let t=A(),n=A(!1),r=A(``),i=U(()=>q.value?.deviceId),a=e=>Math.round(e||0).toLocaleString(`en-US`),o=e=>{let t=e||0;return t===0?`$0.0000`:t<1e-4?`$${t.toPrecision(2)}`:t<.01?`$${t.toFixed(6)}`:`$${t.toFixed(4)}`},s=U(()=>(t.value?.models??[]).reduce((e,t)=>Math.max(e,t.cost||0),0)),c=e=>s.value>0?Math.max(0,Math.min(100,Math.round((e||0)/s.value*100))):0,l=U(()=>{let e=t.value;return!e||!e.models.length&&!e.sessions.length&&!e.projects.length}),u=U(()=>t.value?new Date(t.value.at).toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`}):``),d=(e,t)=>`${a(e)} ${t}${e===1?``:`s`}`;async function f(){let e=i.value;if(t.value=void 0,r.value=``,e){n.value=!0;try{t.value=await G(e).deviceUsage()}catch(e){r.value=Qw(e)?$w(i.value,`usage`):K(e).slice(0,220)}finally{n.value=!1}}}N(i,f,{immediate:!0});async function p(){await f(),r.value||Y(`Usage refreshed.`)}return(e,s)=>(I(),L(`section`,eT,[z(`header`,tT,[z(`span`,null,[B(j(Vs),{size:16}),s[0]||=V(`USAGE`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh usage`,title:`Refresh usage`,onClick:p},[B(j($c),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,nT)]),i.value?r.value?(I(),L(`p`,iT,D(r.value),1)):t.value?l.value?(I(),L(`p`,oT,`No usage recorded yet.`)):(I(),L(F,{key:4},[z(`section`,sT,[s[6]||=z(`div`,{class:`section-label block-label`},[z(`span`,{id:`usage-totals`},`TOTALS`)],-1),z(`div`,cT,[z(`div`,lT,[s[1]||=z(`span`,{class:`label`},`Tokens`,-1),z(`strong`,null,D(a(t.value.totals.tokens)),1)]),z(`div`,uT,[s[2]||=z(`span`,{class:`label`},`Cost`,-1),z(`strong`,null,D(o(t.value.totals.cost)),1)]),z(`div`,dT,[s[3]||=z(`span`,{class:`label`},`Sessions`,-1),z(`strong`,null,D(a(t.value.sessions.length)),1),z(`em`,null,D(a(t.value.projects.length))+` projects`,1)]),z(`div`,fT,[s[4]||=z(`span`,{class:`label`},`Models`,-1),z(`strong`,null,D(a(t.value.models.length)),1),s[5]||=z(`em`,null,`costliest first`,-1)])])]),z(`section`,pT,[z(`div`,mT,[s[7]||=z(`span`,{id:`usage-models`},`BY MODEL`,-1),B(j(dc),{size:13})]),z(`div`,hT,[z(`table`,gT,[s[8]||=z(`colgroup`,null,[z(`col`),z(`col`),z(`col`),z(`col`)],-1),s[9]||=z(`thead`,null,[z(`tr`,null,[z(`th`,{scope:`col`},`Model`),z(`th`,{scope:`col`,class:`num`},`Tokens`),z(`th`,{scope:`col`,class:`num`},`Cost`),z(`th`,{scope:`col`,class:`share-col`},`Share`)])],-1),z(`tbody`,null,[(I(!0),L(F,null,P(t.value.models,e=>(I(),L(`tr`,{key:e.key},[z(`th`,{scope:`row`,class:`model-key`,title:`${e.key} — in ${e.input} · out ${e.output} · cache read ${e.cacheRead} · cache write ${e.cacheWrite}`},D(e.key),9,_T),z(`td`,vT,D(a(e.tokens)),1),z(`td`,yT,D(o(e.cost)),1),z(`td`,bT,[z(`div`,xT,[z(`div`,{class:`bar`,role:`meter`,"aria-valuenow":c(e.cost),"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`${e.key} share of the costliest model`},[z(`i`,{style:T({width:`${c(e.cost)}%`}),class:E({high:c(e.cost)>90})},null,6)],8,ST),z(`em`,CT,D(c(e.cost))+`%`,1)])])]))),128))])])])]),z(`section`,wT,[z(`div`,TT,[s[10]||=z(`span`,{id:`usage-projects`},`BY PROJECT`,-1),B(j(vc),{size:13})]),t.value.projects.length?(I(),L(`ul`,DT,[(I(!0),L(F,null,P(t.value.projects,e=>(I(),L(`li`,{key:e.rootPath,class:`row`,title:e.rootPath},[z(`span`,kT,[z(`strong`,null,D(e.name),1),z(`em`,null,D(e.rootPath),1)]),z(`span`,AT,D(a(e.tokens))+` tok`,1),z(`span`,jT,D(o(e.cost)),1),z(`span`,MT,D(d(e.sessions,`session`)),1)],8,OT))),128))])):(I(),L(`p`,ET,`No project usage recorded yet.`))]),z(`section`,NT,[s[11]||=z(`div`,{class:`section-label block-label`},[z(`span`,{id:`usage-sessions`},`BY SESSION`)],-1),t.value.sessions.length?(I(),L(`ul`,FT,[(I(!0),L(F,null,P(t.value.sessions,e=>(I(),L(`li`,{key:e.id,class:`row`,title:e.cwd},[z(`span`,LT,[z(`strong`,null,D(e.name),1),z(`em`,null,D(e.project??e.cwd),1)]),z(`span`,RT,D(a(e.tokens))+` tok`,1),z(`span`,zT,D(o(e.cost)),1),z(`span`,BT,D(d(e.agents,`agent`)),1)],8,IT))),128))])):(I(),L(`p`,PT,`No session usage recorded yet.`))]),z(`p`,VT,[B(j(Vs),{size:13}),V(` Read on demand — open this tab or press refresh (`+D(u.value)+`). Nothing polls the device. `,1)])],64)):(I(),L(`p`,aT,D(n.value?`Reading usage…`:`No usage recorded yet.`),1)):(I(),L(`p`,rT,`Select a session to see its device's usage.`))]))}}),[[`__scopeId`,`data-v-e7ae1fd0`]]),UT={class:`schedules-panel`,"aria-label":`Scheduled sessions`},WT={class:`panel-heading`},GT=[`disabled`],KT=[`disabled`],qT={key:0,class:`hint`},JT={key:1,class:`message-error`},YT=[`disabled`],XT={key:0,value:``},ZT={key:1,value:``},QT=[`value`],$T={class:`trigger-row`},eE={class:`inline`},tE=[`disabled`],nE={class:`inline`},rE=[`disabled`],iE={class:`row`},aE=[`disabled`],oE={key:3,class:`hint`},sE={key:4,class:`schedule-list`},cE={class:`head`},lE={class:`tag`},uE={key:0,class:`tag running`},dE=[`title`],fE={class:`next`},pE={class:`cwd`},mE={key:0,class:`message-error`},hE={class:`row`},gE=[`disabled`,`onClick`],_E=[`disabled`,`onClick`],vE=[`disabled`,`onClick`],yE=pf(Er({__name:`SchedulesPanel`,setup(e){let t=A([]),n=A(``),r=A(``),i=A(!1),a=U(()=>q.value?.deviceId),o=()=>G(a.value??``),s=A(`60`),c=A(``),l=A(!1),u=A({name:``,cwd:``,prompt:``,model:``});async function d(){if(!a.value)return void(t.value=[]);i.value=!0,r.value=``;try{t.value=(await o().schedules()).schedules}catch(e){r.value=Qw(e)?$w(a.value,`schedules`):K(e).slice(0,220)}finally{i.value=!1}}N(a,d,{immediate:!0});let f=e=>{if(!e)return`—`;let t=e-Date.now(),n=Math.round(Math.abs(t)/6e4),r=n<60?`${n}m`:n<1440?`${Math.round(n/60)}h`:`${Math.round(n/1440)}d`;return t>=0?`in ${r}`:`${r} ago`},p=e=>e.everyMinutes?`every ${e.everyMinutes}m`:`daily ${e.dailyAt}`;async function m(e,t,r){n.value=e;try{await t(),await d(),Y(r)}catch(e){Y(K(e).slice(0,140))}finally{n.value=``}}let h=e=>m(e.id,()=>o().updateSchedule(e.id,{enabled:!e.enabled}),e.enabled?`Schedule paused.`:`Schedule resumed.`),g=e=>m(e.id,()=>o().runSchedule(e.id),`${e.name}: run started.`),_=e=>J.dialog={kind:`prompt`,title:`Remove ${e.name}?`,hint:`The schedule stops being run. Sessions it already created are untouched.`,submit:`Remove schedule`,danger:!0,run:()=>m(e.id,()=>o().removeSchedule(e.id),`Schedule removed.`)},v=A([]),y=A(!1);async function b(){l.value=!0,u.value={name:``,cwd:``,prompt:``,model:``},v.value=[],y.value=!0;try{let e=await o().device();v.value=e.models.map(e=>({key:`${e.provider}/${e.id}`})),u.value.model=e.defaultModel}catch{v.value=[]}finally{y.value=!1}}async function x(){let e=u.value,[t,...r]=e.model.split(`/`),i=r.join(`/`);if(e.name.trim()&&e.cwd.trim()&&e.prompt.trim()){if(!t||!i){Y(y.value?`Still loading the model list — one moment.`:`Pick a model first.`);return}n.value=`new`;try{await o().createSchedule({name:e.name.trim(),cwd:e.cwd.trim(),prompt:e.prompt,model:{provider:t,modelId:i},...c.value.trim()?{dailyAt:c.value.trim()}:{everyMinutes:Number(s.value)||60}}),l.value=!1,await d(),Y(`Schedule created. The device runs it on its own clock.`)}catch(e){Y(K(e).slice(0,160))}finally{n.value=``}}}return(e,o)=>(I(),L(`section`,UT,[z(`header`,WT,[z(`span`,null,[B(j(ec),{size:16}),o[7]||=V(`SCHEDULES`,-1)]),z(`button`,{class:`icon-button`,disabled:i.value||!a.value,"aria-label":`Refresh schedules`,title:`Refresh schedules`,onClick:d},[B(j($c),{size:15,class:E({spin:i.value})},null,8,[`class`])],8,GT),z(`button`,{class:`icon-button`,disabled:!a.value,"aria-label":`Add schedule`,title:`Add schedule`,onClick:b},[B(j(Xc),{size:15})],8,KT)]),o[18]||=z(`p`,{class:`hint`},`Runs on the device's own clock — no browser needs to be open.`,-1),a.value?r.value?(I(),L(`p`,JT,D(r.value),1)):H(``,!0):(I(),L(`p`,qT,`Select a session to see its device.`)),l.value?(I(),L(`form`,{key:2,class:`add-form`,onSubmit:ks(x,[`prevent`])},[z(`label`,null,[o[8]||=V(`Name`,-1),M(z(`input`,{"onUpdate:modelValue":o[0]||=e=>u.value.name=e,placeholder:`Nightly smoke`,required:``},null,512),[[ys,u.value.name]])]),z(`label`,null,[o[9]||=V(`Directory`,-1),M(z(`input`,{"onUpdate:modelValue":o[1]||=e=>u.value.cwd=e,placeholder:`/home/me/project`,required:``},null,512),[[ys,u.value.cwd]])]),z(`label`,null,[o[10]||=V(`Prompt`,-1),M(z(`textarea`,{"onUpdate:modelValue":o[2]||=e=>u.value.prompt=e,rows:`3`,placeholder:`Run the tests and summarise failures`,required:``},null,512),[[ys,u.value.prompt]])]),z(`label`,null,[o[11]||=V(`Model `,-1),M(z(`select`,{"onUpdate:modelValue":o[3]||=e=>u.value.model=e,disabled:y.value},[y.value?(I(),L(`option`,XT,`loading…`)):v.value.length?H(``,!0):(I(),L(`option`,ZT,`(no models — check the device)`)),(I(!0),L(F,null,P(v.value,e=>(I(),L(`option`,{key:e.key,value:e.key},D(e.key),9,QT))),128))],8,YT),[[Ss,u.value.model]])]),z(`div`,$T,[z(`label`,eE,[o[12]||=V(`Every `,-1),M(z(`input`,{"onUpdate:modelValue":o[4]||=e=>s.value=e,class:`num`,disabled:!!c.value.trim()},null,8,tE),[[ys,s.value]]),o[13]||=V(` min`,-1)]),o[15]||=z(`span`,{class:`muted`},`or`,-1),z(`label`,nE,[o[14]||=V(`daily at `,-1),M(z(`input`,{"onUpdate:modelValue":o[5]||=e=>c.value=e,class:`num time`,placeholder:`03:00`,disabled:!!s.value},null,8,rE),[[ys,c.value]])])]),z(`div`,iE,[z(`button`,{class:`primary small`,type:`submit`,disabled:n.value===`new`||y.value||!u.value.model},D(n.value===`new`?`creating…`:y.value?`loading models…`:`Create schedule`),9,aE),z(`button`,{class:`small`,type:`button`,onClick:o[6]||=e=>l.value=!1},`Cancel`)])],32)):H(``,!0),!l.value&&!t.value.length&&a.value&&!r.value?(I(),L(`p`,oE,D(i.value?`Reading schedules…`:`No schedules yet. Press + to add one.`),1)):H(``,!0),t.value.length?(I(),L(`ul`,sE,[(I(!0),L(F,null,P(t.value,e=>(I(),L(`li`,{key:e.id,class:E([`schedule`,{off:!e.enabled}])},[z(`div`,cE,[z(`b`,null,D(e.name),1),z(`span`,lE,D(p(e)),1),e.running?(I(),L(`span`,uE,`running`)):e.lastOutcome===`failed`?(I(),L(`span`,{key:1,class:`tag bad`,title:e.lastError},`last run failed`,8,dE)):H(``,!0),z(`span`,fE,D(e.enabled?`next ${f(e.nextRunAt)}`:`paused`),1)]),z(`code`,pE,D(e.cwd),1),e.lastError?(I(),L(`p`,mE,D(e.lastError.slice(0,160)),1)):H(``,!0),z(`div`,hE,[z(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>g(e)},[B(j(Yc),{size:12}),o[16]||=V(`run now`,-1)],8,gE),z(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>h(e)},[B(j(Zc),{size:12}),V(D(e.enabled?`pause`:`resume`),1)],8,_E),z(`button`,{class:`small danger`,disabled:n.value===e.id,onClick:t=>_(e)},[B(j(ml),{size:12}),o[17]||=V(`remove`,-1)],8,vE)])],2))),128))])):H(``,!0)]))}}),[[`__scopeId`,`data-v-7a785dcc`]]),bE={class:`archive-panel`,"aria-label":`Old sessions`},xE={class:`panel-heading`},SE=[`disabled`],CE={key:0,class:`hint`},wE={key:1,class:`message-error`},TE={key:2,class:`hint`},EE={key:3,class:`old-list`},DE={class:`head`},OE=[`title`],kE={class:`meta`},AE=[`aria-label`,`onClick`],jE=[`aria-label`,`onClick`],ME={class:`facts`},NE={key:0,class:`cwd`},PE={key:1,class:`tag`},FE={class:`meta`},IE={class:`meta`},LE={key:2,class:`meta`},RE=pf(Er({__name:`ArchivePanel`,setup(e){let t=A(null),n=A(!1),r=A(``),i=U(()=>q.value?.deviceId),a=()=>G(i.value??``);async function o(){if(!i.value)return void(t.value=null);n.value=!0,r.value=``;try{t.value=(await a().archived()).sessions}catch(e){r.value=Qw(e)?$w(i.value,`browsing old sessions`):K(e).slice(0,220)}finally{n.value=!1}}N(i,o,{immediate:!0});let s=e=>{if(e<=0)return`0`;let t=[`B`,`KiB`,`MiB`,`GiB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=100||r===0?Math.round(n):n.toFixed(1)} ${t[r]}`},c=e=>{let t=Math.max(0,(Date.now()-e)/1e3);return t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`};function l(e){J.dialog={kind:`prompt`,title:`Restore “${e.name}”?`,hint:`The session returns to the live list with its transcript and jobs intact. Nothing is copied — the bundle simply moves back.`,submit:`Restore`,run:async()=>{await a().restoreArchived(e.sessionId),await o(),Y(`${e.name} restored to the live list.`)}}}async function u(e){try{let t=await a().archivedTranscript(e.sessionId,`markdown`),n=new Blob([t.text??``],{type:`text/markdown`}),r=document.createElement(`a`);r.href=URL.createObjectURL(n),r.download=`${e.name.replace(/[^\w.-]+/g,`_`)||e.sessionId}.md`,r.click(),URL.revokeObjectURL(r.href)}catch(e){Y(K(e).slice(0,160))}}return(e,a)=>(I(),L(`section`,bE,[z(`header`,xE,[z(`span`,null,[B(j(Us),{size:16}),a[0]||=V(`ARCHIVE`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh archive`,title:`Refresh archive`,onClick:o},[B(j($c),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,SE)]),a[2]||=z(`p`,{class:`hint`},` Every session this device ever archived — read-only. Restore brings one back to the live list; nothing here deletes. `,-1),i.value?r.value?(I(),L(`p`,wE,D(r.value),1)):t.value&&!t.value.length?(I(),L(`p`,TE,`Nothing archived on this device yet.`)):H(``,!0):(I(),L(`p`,CE,`Select a session to see its device.`)),t.value?.length?(I(),L(`ul`,EE,[(I(!0),L(F,null,P(t.value,e=>(I(),L(`li`,{key:`${e.sessionId}-${e.archivedAt}`,class:`old`},[z(`div`,DE,[z(`b`,null,D(e.name),1),z(`span`,{class:`tag`,title:e.hasManifest?`bundled with full identity`:`old bundle — name unknown`},D(e.hasManifest?`manifest`:`legacy`),9,OE),z(`span`,kE,`archived `+D(c(e.archivedAt)),1),a[1]||=z(`span`,{class:`spacer`},null,-1),z(`button`,{class:`icon-button`,"aria-label":`Download transcript of ${e.name}`,title:`Download transcript (markdown)`,onClick:t=>u(e)},[B(j(pc),{size:13})],8,AE),z(`button`,{class:`icon-button`,"aria-label":`Restore ${e.name}`,title:`Restore to the live list`,onClick:t=>l(e)},[B(j(tl),{size:13})],8,jE)]),z(`div`,ME,[e.cwd?(I(),L(`span`,NE,D(e.cwd),1)):H(``,!0),e.model?(I(),L(`span`,PE,D(e.model),1)):H(``,!0),z(`span`,FE,D(e.turns>=0?`${e.turns} turns`:`turns unknown`),1),z(`span`,IE,D(s(e.bytes)),1),e.lastMessageAt?(I(),L(`span`,LE,`last message `+D(c(e.lastMessageAt)),1)):H(``,!0)])]))),128))])):H(``,!0)]))}}),[[`__scopeId`,`data-v-dfb29802`]]),zE={class:`graph-panel`,"aria-label":`Task graphs`},BE={class:`panel-heading`},VE=[`disabled`],HE=[`disabled`],UE={key:0,class:`hint`},WE={key:1,class:`message-error`},GE={key:2,class:`hint`},KE={class:`row`},qE=[`disabled`],JE={class:`head`},YE=[`title`],XE=[`aria-label`,`disabled`,`onClick`],ZE=[`aria-label`,`onClick`],QE={class:`tasks`},$E=[`title`],eD={key:0,class:`deps`},tD={class:`tag`},nD={key:1,class:`err`},rD=pf(Er({__name:`GraphPanel`,setup(e){let t=A([]),n=A({}),r=A(!1),i=A(``),a=A(``),o=A(!1),s=A(``),c=U(()=>q.value?.deviceId),l=()=>G(c.value??``);async function u(){if(!c.value)return void(t.value=[]);r.value=!0,i.value=``;try{let e=await l().graphs();t.value=e.graphs,n.value={}}catch(e){i.value=Qw(e)?$w(c.value,`running task-graphs`):K(e).slice(0,220)}finally{r.value=!1}}N(c,u,{immediate:!0});let d={ok:`ok`,failed:`bad`,running:`run`,pending:``,skipped:`skip`};function f(e,t){return n.value[e.id]?.tasks[t]?.status??e.lastRun?.tasks[t]?.status??`pending`}async function p(e){try{let t=await l().graph(e.id);n.value={...n.value,[e.id]:t.runs[0]??e.lastRun},t.runs.length||Y(`This graph has not run yet.`)}catch(e){Y(K(e).slice(0,140))}}async function m(e){a.value=e.id;try{let{run:t}=await l().runGraph(e.id);n.value={...n.value,[e.id]:t},Y(`Run started: ${Object.keys(t.tasks).length} tasks.`),p(e)}catch(e){Y(K(e).slice(0,140))}finally{a.value=``}}function h(e){J.dialog={kind:`prompt`,title:`Remove the graph "${e.name}"?`,hint:`The registry record goes. Sessions the graph created are never touched.`,submit:`Remove graph`,danger:!0,run:async()=>{await l().removeGraph(e.id),await u()}}}async function g(){let e=s.value.trim();if(e){a.value=`new`;try{let t=JSON.parse(e),n=await l().createGraph({name:String(t.name??``),cwd:String(t.cwd??``),tasks:t.tasks});o.value=!1,s.value=``,Y(`Graph "${n.name}" added (${n.tasks.length} tasks).`),await u()}catch(e){Y(K(e).slice(0,200))}finally{a.value=``}}}return(e,l)=>(I(),L(`section`,zE,[z(`header`,BE,[z(`span`,null,[B(j(gl),{size:16}),l[3]||=V(`DAG`,-1)]),z(`button`,{class:`icon-button`,disabled:r.value||!c.value,"aria-label":`Refresh graphs`,title:`Refresh`,onClick:u},[B(j($c),{size:15,class:E({spin:r.value})},null,8,[`class`])],8,VE),z(`button`,{class:`icon-button`,disabled:!c.value||!!i.value,"aria-label":`Add a graph`,title:`Add a graph from JSON`,onClick:l[0]||=e=>o.value=!o.value},[B(j(Xc),{size:15})],8,HE)]),l[7]||=z(`p`,{class:`hint`},`Tasks run on the device, in dependency order — one fresh session each.`,-1),c.value?i.value?(I(),L(`p`,WE,D(i.value),1)):!t.value.length&&!o.value?(I(),L(`p`,GE,` No graphs yet. Press + and paste a graph JSON ({ name, cwd, tasks: [{ id, name, prompt, dependsOn }] }). `)):H(``,!0):(I(),L(`p`,UE,`Select a session to see its device.`)),o.value?(I(),L(`form`,{key:3,class:`add-form`,onSubmit:ks(g,[`prevent`])},[z(`label`,null,[l[4]||=V(`Graph JSON `,-1),M(z(`textarea`,{"onUpdate:modelValue":l[1]||=e=>s.value=e,rows:`8`,placeholder:`{ "name": "nightly", "cwd": "~/work/app", "tasks": [{ "id": "build", "name": "Build", "prompt": "run the build", "dependsOn": [] }, { "id": "report", "name": "Report", "prompt": "summarise", "dependsOn": ["build"] }] }`},null,512),[[ys,s.value]])]),z(`div`,KE,[z(`button`,{class:`primary small`,type:`submit`,disabled:a.value===`new`},D(a.value===`new`?`adding…`:`Add graph`),9,qE),z(`button`,{class:`small`,type:`button`,onClick:l[2]||=e=>o.value=!1},`Cancel`)])],32)):H(``,!0),(I(!0),L(F,null,P(t.value,e=>(I(),L(`div`,{key:e.id,class:`graph`},[z(`div`,JE,[z(`b`,null,D(e.name),1),z(`code`,{class:`cwd`,title:e.cwd},D(e.cwd.split(`/`).filter(Boolean).at(-1)||e.cwd),9,YE),z(`span`,{class:E([`tag`,d[e.lastRun?.status??`pending`]??``])},D(e.lastRun?e.lastRun.status:`never run`),3),l[5]||=z(`span`,{class:`spacer`},null,-1),z(`button`,{class:`icon-button`,"aria-label":`Run ${e.name}`,title:`Run now`,disabled:a.value===e.id,onClick:t=>m(e)},[B(j(Yc),{size:14})],8,XE),z(`button`,{class:`icon-button`,"aria-label":`Remove ${e.name}`,title:`Remove graph`,onClick:t=>h(e)},[B(j(ml),{size:14})],8,ZE)]),z(`ul`,QE,[(I(!0),L(F,null,P(e.tasks,t=>(I(),L(`li`,{key:t.id,class:E(d[f(e,t.id)])},[l[6]||=z(`span`,{class:`dot`,"aria-hidden":`true`},null,-1),z(`span`,{class:`name`,title:t.prompt},D(t.name),9,$E),t.dependsOn.length?(I(),L(`code`,eD,`← `+D(t.dependsOn.join(`, `)),1)):H(``,!0),z(`span`,tD,D(f(e,t.id)),1),n.value[e.id]?.tasks[t.id]?.error?(I(),L(`em`,nD,D(n.value[e.id].tasks[t.id].error.slice(0,120)),1)):H(``,!0)],2))),128))])]))),128))]))}}),[[`__scopeId`,`data-v-af2970aa`]]),iD={class:`notify-panel`,"aria-label":`Notification sinks`},aD={class:`panel-heading`},oD=[`disabled`],sD=[`disabled`],cD=[`disabled`],lD={key:0,class:`hint`},uD={key:1,class:`message-error`},dD=[`placeholder`],fD={class:`row`},pD=[`disabled`],mD={key:3,class:`hint`},hD={key:4,class:`sink-list`},gD={class:`head`},_D={class:`tag`},vD={class:`next`},yD={class:`url`},bD={key:0,class:`hint`},xD={key:1,class:`message-error`},SD={class:`row`},CD=[`disabled`,`onClick`],wD=[`disabled`,`onClick`],TD={key:5,class:`results`,"aria-label":`Test results`},ED={class:`tag`},DD={key:0},OD=pf(Er({__name:`NotifyPanel`,setup(e){let t=A([]),n=A(``),r=A(``),i=A(!1),a=A([]),o=U(()=>q.value?.deviceId),s=()=>G(o.value??``),c=A(!1),l=A({kind:`webhook`,url:``,label:``,events:``});async function u(){if(!o.value)return void(t.value=[]);i.value=!0,r.value=``;try{t.value=(await s().notifySinks()).sinks}catch(e){r.value=Qw(e)?$w(o.value,`notifications`):K(e).slice(0,220)}finally{i.value=!1}}N(o,u,{immediate:!0});let d=e=>{if(!e)return`never`;let t=Math.round((Date.now()-e)/6e4);return t<1?`just now`:t<60?`${t}m ago`:`${Math.round(t/60)}h ago`};async function f(){let e=l.value;if(e.url.trim()){n.value=`new`;try{await s().createNotifySink({kind:e.kind,url:e.url.trim(),...e.label.trim()?{label:e.label.trim()}:{},...e.events.trim()?{events:e.events.split(`,`).map(e=>e.trim()).filter(Boolean)}:{}}),c.value=!1,l.value={kind:`webhook`,url:``,label:``,events:``},await u(),Y(`Sink added on the device.`)}catch(e){Y(K(e).slice(0,160))}finally{n.value=``}}}async function p(e){n.value=e.id;try{await s().updateNotifySink(e.id,{enabled:!e.enabled}),await u()}catch(e){Y(K(e).slice(0,140))}finally{n.value=``}}function m(e){J.dialog={kind:`prompt`,title:`Remove this ${e.kind} sink?`,hint:`The device stops notifying this target. Nothing else changes.`,submit:`Remove sink`,danger:!0,run:async()=>{await s().removeNotifySink(e.id),await u()}}}async function h(){n.value=`test`,a.value=[];try{a.value=(await s().testNotifySinks()).results;let e=a.value.filter(e=>e.status===`failed`).length;Y(a.value.length?`Test: ${a.value.length-e} sent${e?`, ${e} failed`:``}.`:`No enabled sinks matched — nothing was sent.`)}catch(e){Y(K(e).slice(0,160))}finally{n.value=``}}return(e,s)=>(I(),L(`section`,iD,[z(`header`,aD,[z(`span`,null,[B(j(Xs),{size:16}),s[6]||=V(`NOTIFY`,-1)]),z(`button`,{class:`icon-button`,disabled:i.value||!o.value,"aria-label":`Refresh sinks`,title:`Refresh sinks`,onClick:u},[B(j($c),{size:15,class:E({spin:i.value})},null,8,[`class`])],8,oD),z(`button`,{class:`icon-button`,disabled:!o.value||!t.value.length||n.value===`test`,"aria-label":`Send a test notification`,title:`Send a test event through every enabled sink`,onClick:h},[B(j(rl),{size:15})],8,sD),z(`button`,{class:`icon-button`,disabled:!o.value,"aria-label":`Add a sink`,title:`Add a sink`,onClick:s[0]||=e=>c.value=!c.value},[B(j(Xc),{size:15})],8,cD)]),s[14]||=z(`p`,{class:`hint`},`Delivered by the device — no browser needs to be open.`,-1),o.value?r.value?(I(),L(`p`,uD,D(r.value),1)):H(``,!0):(I(),L(`p`,lD,`Select a session to see its device.`)),c.value?(I(),L(`form`,{key:2,class:`add-form`,onSubmit:ks(f,[`prevent`])},[z(`label`,null,[s[8]||=V(`Kind `,-1),M(z(`select`,{"onUpdate:modelValue":s[1]||=e=>l.value.kind=e},[...s[7]||=[z(`option`,{value:`webhook`},`webhook (JSON POST)`,-1),z(`option`,{value:`ntfy`},`ntfy (topic)`,-1)]],512),[[Ss,l.value.kind]])]),z(`label`,null,[s[9]||=V(`URL `,-1),M(z(`input`,{"onUpdate:modelValue":s[2]||=e=>l.value.url=e,placeholder:l.value.kind===`ntfy`?`https://ntfy.sh/my-topic`:`https://example.com/hook`,required:``},null,8,dD),[[ys,l.value.url]])]),z(`label`,null,[s[10]||=V(`Label`,-1),M(z(`input`,{"onUpdate:modelValue":s[3]||=e=>l.value.label=e,placeholder:`phone`},null,512),[[ys,l.value.label]])]),z(`label`,null,[s[11]||=V(`Events `,-1),M(z(`input`,{"onUpdate:modelValue":s[4]||=e=>l.value.events=e,placeholder:`empty = all — e.g. session.failed,schedule.*`},null,512),[[ys,l.value.events]])]),z(`div`,fD,[z(`button`,{class:`primary small`,type:`submit`,disabled:n.value===`new`},D(n.value===`new`?`adding…`:`Add sink`),9,pD),z(`button`,{class:`small`,type:`button`,onClick:s[5]||=e=>c.value=!1},`Cancel`)]),s[12]||=z(`p`,{class:`hint`},[V(`LAN targets (192.168.x, localhost) need `),z(`code`,null,`DPI_NOTIFY_ALLOW_PRIVATE=1`),V(` on the device.`)],-1)],32)):H(``,!0),!c.value&&!t.value.length&&o.value&&!r.value?(I(),L(`p`,mD,` No sinks yet. Press + to add a webhook or an ntfy topic. `)):H(``,!0),t.value.length?(I(),L(`ul`,hD,[(I(!0),L(F,null,P(t.value,e=>(I(),L(`li`,{key:e.id,class:E([`sink`,{off:!e.enabled}])},[z(`div`,gD,[z(`span`,_D,D(e.kind),1),z(`b`,null,D(e.label||e.url),1),z(`em`,vD,D(e.lastError?`last failed`:`sent ${d(e.lastDeliveryAt)}`),1)]),z(`code`,yD,D(e.url),1),e.events?.length?(I(),L(`p`,bD,`events: `+D(e.events.join(`, `)),1)):H(``,!0),e.lastError?(I(),L(`p`,xD,D(e.lastError.slice(0,160)),1)):H(``,!0),z(`div`,SD,[z(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>p(e)},[B(j(Zc),{size:12}),V(D(e.enabled?`disable`:`enable`),1)],8,CD),z(`button`,{class:`small danger`,disabled:n.value===e.id,onClick:t=>m(e)},[B(j(ml),{size:12}),s[13]||=V(`remove`,-1)],8,wD)])],2))),128))])):H(``,!0),a.value.length?(I(),L(`ul`,TD,[(I(!0),L(F,null,P(a.value,e=>(I(),L(`li`,{key:e.id,class:E(e.status)},[z(`span`,ED,D(e.status),1),V(` `+D(e.kind)+` `+D(e.id.slice(0,8))+` `,1),e.detail?(I(),L(`em`,DD,D(e.detail),1)):H(``,!0)],2))),128))])):H(``,!0)]))}}),[[`__scopeId`,`data-v-305864c8`]]),kD={class:`env-panel`,"aria-label":`Device environment`},AD={class:`panel-heading`},jD=[`disabled`],MD=[`disabled`],ND={key:0,class:`hint`},PD={key:1,class:`message-error`},FD={key:2,class:`message-restart`},ID={class:`row`},LD=[`disabled`],RD={key:4,class:`hint`},zD={key:5,class:`var-list`},BD={class:`head`},VD={class:`key`},HD={class:`tag`},UD={key:0,class:`tag`,title:`Has its own setting; edit that instead`},WD=[`aria-label`,`title`,`onClick`],GD=[`aria-label`,`onClick`],KD=[`title`],qD={key:6,class:`hint path`},JD={class:`panel-heading keys-heading`},YD=[`disabled`],XD=[`disabled`],ZD={key:7,class:`message-error`},QD={class:`row`},$D=[`disabled`],eO={key:9,class:`hint`},tO={key:10,class:`var-list`},nO={class:`head`},rO={class:`key`},iO={class:`tag`},aO={key:0,class:`tag`,title:`Set by pi /login — read-only here`},oO=[`aria-label`,`onClick`],sO={class:`value`,title:`write-only — masked tail`},cO=pf(Er({__name:`EnvPanel`,setup(e){let t=A(null),n=A(!1),r=A(``),i=A(``),a=U(()=>q.value?.deviceId),o=()=>G(a.value??``),s=A(!1),c=A({key:``,value:``});async function l(){if(!a.value)return void(t.value=null);n.value=!0,r.value=``;try{t.value=await o().envView()}catch(e){r.value=Qw(e)?$w(a.value,`editing env vars`):K(e).slice(0,220)}finally{n.value=!1}m()}N(a,l,{immediate:!0});let u=A(null),d=A(``),f=A(!1),p=A({providerId:``,key:``});async function m(){if(!a.value)return void(u.value=null);try{u.value=await o().piAuth(),d.value=``}catch(e){K(e),d.value=Qw(e)?$w(a.value,`managing pi keys`):K(e).slice(0,220)}}async function h(){let e=p.value.providerId.trim();if(e&&p.value.key){i.value=`pi-key`;try{let t=await o().setPiApiKey(e,p.value.key);p.value={providerId:``,key:``},f.value=!1,await m(),Y(`${e} saved (now ${t.masked}) — restart the device to apply it.`)}catch(e){Y(K(e).slice(0,160))}finally{i.value=``}}}function g(e){J.dialog={kind:`prompt`,title:`Remove the ${e} key?`,hint:`The entry is deleted from pi's auth.json. pi's own logins are never touched. Restart the device to apply.`,submit:`Remove`,danger:!0,run:async()=>{await o().removePiApiKey(e),await m(),Y(`${e} removed — restart the device to apply it.`)}}}let _=e=>e.source===`file`&&!e.managed;async function v(){let e=c.value.key.trim().toUpperCase();if(e&&c.value.value){i.value=`new`;try{await o().setEnvVar(e,c.value.value),s.value=!1,c.value={key:``,value:``},await l(),Y(`${e} saved — restart the device to apply it.`)}catch(e){Y(K(e).slice(0,160))}finally{i.value=``}}}function y(e){J.dialog={kind:`prompt`,title:`Set ${e.key}`,label:`Value`,hint:e.secret?`The current value is secret and stays masked. Type a new value to replace it.`:`Single line. Applies after the next device restart.`,value:e.secret?``:e.masked,placeholder:e.secret?e.masked:``,submit:`Save value`,run:async t=>{if(!t)throw Error(`A value is required`);await o().setEnvVar(e.key,t),await l(),Y(`${e.key} saved — restart the device to apply it.`)}}}function b(e){J.dialog={kind:`prompt`,title:`Remove ${e.key} from the env file?`,hint:`The line is deleted from the file. Restart the device to apply it.`,submit:`Remove`,danger:!0,run:async()=>{await o().removeEnvVar(e.key),await l(),Y(`${e.key} removed — restart the device to apply it.`)}}}return(e,o)=>(I(),L(`section`,kD,[z(`header`,AD,[z(`span`,null,[B(j(gc),{size:16}),o[8]||=V(`ENV`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!a.value,"aria-label":`Refresh env`,title:`Refresh`,onClick:l},[B(j($c),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,jD),z(`button`,{class:`icon-button`,disabled:!a.value||!!r.value,"aria-label":`Add an env var`,title:`Add an env var to the device's env file`,onClick:o[0]||=e=>s.value=!s.value},[B(j(Xc),{size:15})],8,MD)]),o[19]||=z(`p`,{class:`hint`},` The device's env file — loaded once at boot. Keys here reach the daemon and its sessions. `,-1),a.value?r.value?(I(),L(`p`,PD,D(r.value),1)):t.value?.restartRequired?(I(),L(`p`,FD,[...o[9]||=[V(` Changed since boot — restart the device (`,-1),z(`code`,null,`dpi device stop && dpi device start`,-1),V(`) to apply. `,-1)]])):H(``,!0):(I(),L(`p`,ND,`Select a session to see its device.`)),s.value?(I(),L(`form`,{key:3,class:`add-form`,onSubmit:ks(v,[`prevent`])},[z(`label`,null,[o[10]||=V(`Key (UPPER_SNAKE_CASE)`,-1),M(z(`input`,{"onUpdate:modelValue":o[1]||=e=>c.value.key=e,placeholder:`DPI_NOTIFY_ALLOW_PRIVATE`,required:``},null,512),[[ys,c.value.key]])]),z(`label`,null,[o[11]||=V(`Value`,-1),M(z(`input`,{"onUpdate:modelValue":o[2]||=e=>c.value.value=e,placeholder:`1`,required:``},null,512),[[ys,c.value.value]])]),z(`div`,ID,[z(`button`,{class:`primary small`,type:`submit`,disabled:i.value===`new`},D(i.value===`new`?`saving…`:`Save to env file`),9,LD),z(`button`,{class:`small`,type:`button`,onClick:o[3]||=e=>s.value=!1},`Cancel`)]),o[12]||=z(`p`,{class:`hint`},` Managed keys (DPI_TOKEN, DPI_PORT, start dirs…) have their own settings and are refused here. `,-1)],32)):H(``,!0),!s.value&&t.value&&!t.value.vars.length&&!r.value?(I(),L(`p`,RD,` No vars in the env file yet. `)):H(``,!0),t.value?.vars.length?(I(),L(`ul`,zD,[(I(!0),L(F,null,P(t.value.vars,e=>(I(),L(`li`,{key:e.key,class:E([`var`,{ro:!_(e)}])},[z(`div`,BD,[z(`code`,VD,D(e.key),1),z(`span`,HD,D(e.source===`process`?`process`:`file`),1),e.managed?(I(),L(`span`,UD,`managed`)):H(``,!0),o[13]||=z(`span`,{class:`spacer`},null,-1),_(e)?(I(),L(`button`,{key:1,class:`icon-button`,"aria-label":`Edit ${e.key}`,title:e.secret?`Replace the value`:`Edit the value`,onClick:t=>y(e)},[B(j(qc),{size:13})],8,WD)):H(``,!0),_(e)?(I(),L(`button`,{key:2,class:`icon-button`,"aria-label":`Remove ${e.key}`,title:`Remove from the env file`,onClick:t=>b(e)},[B(j(ml),{size:13})],8,GD)):H(``,!0)]),z(`code`,{class:`value`,title:e.secret?`secret — masked`:e.masked},D(e.masked),9,KD)],2))),128))])):H(``,!0),t.value?(I(),L(`p`,qD,D(t.value.envFile),1)):H(``,!0),z(`header`,JD,[z(`span`,null,[B(j(kc),{size:16}),o[14]||=V(`PI KEYS`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!a.value,"aria-label":`Refresh pi keys`,title:`Refresh`,onClick:m},[B(j($c),{size:15})],8,YD),z(`button`,{class:`icon-button`,disabled:!a.value||!!d.value,"aria-label":`Add a pi provider key`,title:`Add a provider key to pi's auth.json`,onClick:o[4]||=e=>f.value=!f.value},[B(j(Xc),{size:15})],8,XD)]),o[20]||=z(`p`,{class:`hint`},[V(` Provider keys in pi's own `),z(`code`,null,`auth.json`),V(` — write-only: values are never shown, pi's interactive logins (oauth) are never touched. `)],-1),d.value?(I(),L(`p`,ZD,D(d.value),1)):H(``,!0),f.value?(I(),L(`form`,{key:8,class:`add-form`,onSubmit:ks(h,[`prevent`])},[z(`label`,null,[o[15]||=V(`Provider id`,-1),M(z(`input`,{"onUpdate:modelValue":o[5]||=e=>p.value.providerId=e,placeholder:`zai`,required:``},null,512),[[ys,p.value.providerId]])]),z(`label`,null,[o[16]||=V(`Key`,-1),M(z(`input`,{"onUpdate:modelValue":o[6]||=e=>p.value.key=e,type:`password`,autocomplete:`off`,placeholder:`paste the api key`,required:``},null,512),[[ys,p.value.key]])]),z(`div`,QD,[z(`button`,{class:`primary small`,type:`submit`,disabled:i.value===`pi-key`},D(i.value===`pi-key`?`saving…`:`Save to auth.json`),9,$D),z(`button`,{class:`small`,type:`button`,onClick:o[7]||=e=>f.value=!1},`Cancel`)]),o[17]||=z(`p`,{class:`hint`},`Applies after the next device restart. Existing keys for other providers stay as they are.`,-1)],32)):H(``,!0),!f.value&&u.value&&!u.value.entries.length&&!d.value?(I(),L(`p`,eO,` No provider keys found. `)):H(``,!0),u.value?.entries.length?(I(),L(`ul`,tO,[(I(!0),L(F,null,P(u.value.entries,e=>(I(),L(`li`,{key:e.providerId,class:`var`},[z(`div`,nO,[z(`code`,rO,D(e.providerId),1),z(`span`,iO,D(e.source),1),e.type===`api_key`?H(``,!0):(I(),L(`span`,aO,D(e.type),1)),o[18]||=z(`span`,{class:`spacer`},null,-1),e.type===`api_key`?(I(),L(`button`,{key:1,class:`icon-button`,"aria-label":`Remove ${e.providerId} key`,title:`Remove from auth.json`,onClick:t=>g(e.providerId)},[B(j(ml),{size:13})],8,oO)):H(``,!0)]),z(`code`,sO,D(e.masked),1)]))),128))])):H(``,!0)]))}}),[[`__scopeId`,`data-v-f6b52e88`]]),lO={class:`extensions-panel`},uO={class:`panel-heading`},dO={key:0,class:`task-empty`},fO=[`data-extension`],pO={class:`ext-head`},mO=[`aria-checked`,`aria-label`,`disabled`,`onClick`],hO=[`checked`,`disabled`,`onChange`],gO=Er({__name:`ExtensionsPanel`,setup(e){let t=nn(),n=A(!1);async function r(){let e=ld.value;if(!e||!rd.value)return void(t.value=void 0);t.value=await e.extensions().catch(()=>void 0)??t.value}N([ld,rd,()=>JSON.stringify(yd.value.agent.extensions??null)],r,{immediate:!0});async function i(e){let r=ld.value;if(r&&!n.value){n.value=!0;try{let n=await Fd(()=>r.setExtension(e));n&&(t.value=n),Ad()}finally{n.value=!1}}}return(e,r)=>(I(),L(`div`,lO,[z(`div`,uO,[r[0]||=z(`h2`,null,`Extensions`,-1),B(j(Qc),{size:18})]),r[3]||=z(`p`,{class:`hint`},` Custom harness capabilities for this agent. Turn one on and the next request uses it. The choice is stored with the agent, so it survives restarts. `,-1),t.value?H(``,!0):(I(),L(`p`,dO,`Loading extensions…`)),(I(!0),L(F,null,P(t.value?.extensions??[],e=>(I(),L(`article`,{key:e.name,class:E([`ext-card`,{on:e.enabled}]),"data-extension":e.name},[z(`div`,pO,[z(`div`,null,[z(`strong`,null,D(e.title),1),z(`code`,null,D(e.name),1)]),z(`button`,{class:E([`switch`,{on:e.enabled}]),role:`switch`,"aria-checked":e.enabled,"aria-label":e.title,disabled:n.value,onClick:t=>i({name:e.name,enabled:!e.enabled})},[...r[1]||=[z(`span`,null,null,-1)]],10,mO)]),z(`p`,null,D(e.description),1),e.prompts?(I(),L(`ul`,{key:0,class:E([`ext-prompts`,{off:!e.enabled}])},[(I(!0),L(F,null,P(e.prompts,e=>(I(),L(`li`,{key:e.id},[z(`label`,null,[z(`input`,{type:`checkbox`,checked:e.enabled,disabled:n.value,onChange:t=>i({prompt:e.id,enabled:t.target.checked})},null,40,hO),z(`code`,null,D(e.id),1)]),z(`span`,null,D(e.description),1),z(`details`,null,[r[2]||=z(`summary`,null,`View prompt`,-1),z(`pre`,null,D(e.text),1)])]))),128))],2)):H(``,!0)],10,fO))),128))]))}}),_O={class:`context-section`,"aria-labelledby":`context-title`},vO={class:`section-label`},yO={key:0,class:`hint`},bO={key:1,class:`hint`},xO={class:`context-numbers`},SO={class:`context-pct`},CO={key:0,class:`context-compacting`},wO=[`aria-valuemax`,`aria-valuenow`,`aria-valuetext`],TO={class:`context-marker-label`},EO=[`aria-valuemin`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`],DO={class:`context-marker-label`},OO={class:`hint context-hint`},kO={class:`modal compaction-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`compaction-title`},AO={class:`context-toggle`},jO=[`checked`],MO=512,NO=4096,PO=1024,FO=Er({__name:`ContextBar`,setup(e){let t=e=>e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e),n=U(()=>Dd.value?.contextWindow??0),r=U(()=>{let e=Ed.value;return e&&!Dd.value?`${e.provider?`${e.provider} / `:``}${e.modelId}`:``}),i=U(()=>{let e=yd.value.entries;for(let t=e.length-1;t>=0;t--){if(e[t].kind!==`pi.assistant`)continue;let n=e[t].model?.find(e=>e.role===`assistant`)?.usage;if(n)return n.totalTokens||n.input+n.output+n.cacheRead+n.cacheWrite}return 0}),a=U(()=>yd.value.compactions.length>0),o=A(),s=U(()=>o.value??sd.value?.compaction??Zv(n.value));N(()=>JSON.stringify(sd.value?.compaction),e=>{o.value&&e===JSON.stringify(o.value)&&(o.value=void 0)});let c=A(),l=U(()=>J.dialog?.kind===`compaction`),u=()=>void(J.dialog=void 0);Gr(()=>l.value&&u());let d=U(()=>c.value??Qv(n.value,s.value)),f=e=>`${Math.min(100,Math.max(0,100*e/(n.value||1)))}%`,p=U(()=>Math.round(100*i.value/(n.value||1))),m=e=>{let t=e/(n.value||1);return t<.35?`start`:t>.65?`end`:`center`},h=(e,t)=>Math.min(n.value-PO,Math.max((t??NO)+PO,e)),g=(e,t)=>Math.min(t-PO,Math.max(NO,e));function _(e,t){let n=d.value,r=Math.round(t/MO)*MO;c.value=e===`wait`?{auto:n.auto,wait:h(r,n.auto)}:{auto:g(r,n.wait),wait:n.wait}}async function v(e){let t=ud.value;if(!t)return;let n=await Fd(()=>t.setCompaction(e));n&&(o.value=n),c.value=void 0}function y(){let e=c.value;e&&v({reserveTokens:n.value-e.wait,...e.auto===void 0?{}:{backgroundTokens:e.wait-e.auto}})}let b=A(),x;function S(e,t){x=e,t.currentTarget.setPointerCapture(t.pointerId)}function C(e){if(!x||!b.value)return;let t=b.value.getBoundingClientRect();_(x,(e.clientX-t.left)/t.width*n.value)}function ee(){x&&(x=void 0,y())}function te(e,t){let n=(t.shiftKey?8192:1024)*(t.key===`ArrowRight`||t.key===`ArrowUp`?1:t.key===`ArrowLeft`||t.key===`ArrowDown`?-1:0);if(!n)return;t.preventDefault();let r=d.value;_(e,(e===`auto`?r.auto??NO:r.wait)+n)}return(e,o)=>(I(),L(F,null,[z(`section`,_O,[z(`div`,vO,[o[7]||=z(`span`,{id:`context-title`},`CONTEXT`,-1),n.value?(I(),L(`button`,{key:0,class:`context-details-toggle`,onClick:o[0]||=e=>j(J).dialog={kind:`compaction`}},[B(j(Oc),{size:16}),o[6]||=V(`Details `,-1)])):H(``,!0)]),r.value?(I(),L(`div`,yO,D(r.value)+` — not in this device's catalog, so its context window is unknown here. `,1)):n.value?(I(),L(F,{key:2},[z(`div`,xO,[z(`strong`,null,D(t(i.value)),1),z(`span`,null,`of `+D(t(n.value))+` tokens`,1),z(`span`,SO,D(p.value)+`%`,1),a.value?(I(),L(`span`,CO,[...o[8]||=[z(`i`,null,null,-1),V(`Compacting`,-1)]])):H(``,!0)]),z(`div`,{ref_key:`bar`,ref:b,class:E([`context-bar`,{off:!s.value.enabled}]),onPointermove:C,onPointerup:ee,onPointercancel:ee},[z(`div`,{class:E([`context-fill`,{hot:d.value.auto!==void 0&&i.value>=d.value.auto}]),style:T({width:f(i.value)})},null,6),z(`div`,{class:`context-reserve`,style:T({left:f(d.value.wait)}),title:`Reserved for the answer`},null,4),d.value.auto===void 0?H(``,!0):(I(),L(`button`,{key:0,class:E([`context-marker auto`,`label-${m(d.value.auto)}`]),role:`slider`,"aria-label":`Automatic compaction starts at`,"aria-valuemin":NO,"aria-valuemax":d.value.wait-PO,"aria-valuenow":d.value.auto,"aria-valuetext":`${t(d.value.auto)} tokens`,style:T({left:f(d.value.auto)}),onPointerdown:o[1]||=e=>S(`auto`,e),onKeydown:o[2]||=e=>te(`auto`,e),onKeyup:y,onBlur:y},[z(`span`,TO,`Auto-compact at `+D(t(d.value.auto)),1)],46,wO)),z(`button`,{class:E([`context-marker wait`,`label-${m(d.value.wait)}`]),role:`slider`,"aria-label":`The next request waits for a summary at`,"aria-valuemin":(d.value.auto??NO)+PO,"aria-valuemax":n.value-PO,"aria-valuenow":d.value.wait,"aria-valuetext":`${t(d.value.wait)} tokens, ${t(n.value-d.value.wait)} reserved`,style:T({left:f(d.value.wait)}),onPointerdown:o[3]||=e=>S(`wait`,e),onKeydown:o[4]||=e=>te(`wait`,e),onKeyup:y,onBlur:y},[z(`span`,DO,`Reserve at `+D(t(d.value.wait)),1)],46,EO)],34),z(`p`,OO,[s.value.enabled?(I(),L(F,{key:0},[o[9]||=V(`Compacts in the background at `,-1),z(`strong`,null,D(t(d.value.auto??d.value.wait)),1),o[10]||=V(` and waits at `,-1),z(`strong`,null,D(t(d.value.wait)),1),o[11]||=V(`.`,-1)],64)):(I(),L(F,{key:1},[V(`Automatic compaction is off.`)],64))])],64)):(I(),L(`div`,bO,`Pick a model to see its context window.`))]),(I(),R(cr,{to:`body`},[l.value?(I(),L(`div`,{key:0,class:`modal-backdrop`,onClick:ks(u,[`self`])},[z(`section`,kO,[z(`header`,null,[o[12]||=z(`h2`,{id:`compaction-title`},`Context compaction`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close context compaction`,onClick:u},[B(j(xl),{size:18})])]),z(`p`,null,[o[13]||=V(` A summary starts in the background at `,-1),z(`strong`,null,D(t(d.value.auto??d.value.wait)),1),o[14]||=V(`. Above `,-1),z(`strong`,null,D(t(d.value.wait)),1),V(` the next request waits for it, keeping `+D(t(n.value-d.value.wait))+` free for the answer. Drag a marker on the bar to change either point. `,1)]),o[16]||=z(`p`,null,[V(`Older entries stay stored, and `),z(`code`,null,`search_history`),V(` still finds them.`)],-1),z(`label`,AO,[z(`input`,{type:`checkbox`,checked:s.value.enabled,onChange:o[5]||=e=>v({enabled:e.target.checked})},null,40,jO),o[15]||=V(` Automatic compaction `,-1)]),o[17]||=z(`p`,{class:`hint`},[V(` Applies to every agent in this session. `),z(`code`,null,`/compact`),V(` works either way. `)],-1),z(`footer`,null,[z(`button`,{class:`secondary`,onClick:u},`Close`)])])])):H(``,!0)]))],64))}}),IO=/^[A-Za-z_$][\w$]*$/,LO=e=>` `.repeat(e);function RO(e,t){let n=[],r=(e,t=`text`)=>n.push({text:e,kind:t});return r(`function`,`keyword`),r(` `),r(e,`function`),r(`(`,`punct`),r(`args`),r(`: `,`punct`),zO(t,0,r),r(`): `,`punct`),r(`Promise`,`type`),r(`<`,`punct`),r(`ToolResult`,`type`),r(`>;`,`punct`),n}function zO(e,t,n){if(!e||typeof e!=`object`)return n(`unknown`,`type`);if(`const`in e)return HO(e.const,n);if(e.enum)return VO(e.enum.map(e=>({const:e})),t,n);if(e.anyOf??e.oneOf)return VO(e.anyOf??e.oneOf,t,n);if(Array.isArray(e.type))return VO(e.type.map(t=>({...e,type:t})),t,n);switch(e.type){case`string`:case`boolean`:case`null`:return n(e.type,`type`);case`number`:case`integer`:return n(`number`,`type`);case`array`:{let r=!!(e.items?.anyOf??e.items?.oneOf??e.items?.enum);return r&&n(`(`,`punct`),zO(e.items,t,n),r&&n(`)`,`punct`),n(`[]`,`punct`)}case`object`:return BO(e,t,n);default:return n(`unknown`,`type`)}}function BO(e,t,n){let r=Object.entries(e.properties??{});if(!r.length)return e.additionalProperties&&typeof e.additionalProperties==`object`?(n(`Record`,`type`),n(`<`,`punct`),n(`string`,`type`),n(`, `,`punct`),zO(e.additionalProperties,t,n),n(`>`,`punct`)):n(`{}`,`punct`);let i=new Set(e.required??[]);n(`{`,`punct`),n(`
|
|
81
81
|
`);for(let[e,a]of r){let r=UO(a);r&&n(`${LO(t+1)}${r}\n`,`comment`),n(LO(t+1)),n(IO.test(e)?e:JSON.stringify(e),`property`),n(i.has(e)?`: `:`?: `,`punct`),zO(a,t+1,n),n(`;`,`punct`),n(`
|
|
82
|
-
`)}n(LO(t)),n(`}`,`punct`)}function VO(e,t,n){e.forEach((e,r)=>{r&&n(` | `,`punct`),zO(e,t,n)})}function HO(e,t){if(typeof e==`string`)return t(JSON.stringify(e),`string`);if(typeof e==`number`)return t(String(e),`number`);t(String(e),`type`)}function UO(e){let t=[e.description,e.minimum===void 0?``:`@minimum ${e.minimum}`,e.maximum===void 0?``:`@maximum ${e.maximum}`,e.default===void 0?``:`@default ${JSON.stringify(e.default)}`].filter(Boolean);return t.length?`/** ${t.join(` `)} */`:``}var WO=12582912;function GO(e){if(e.bytes.byteLength>12582912)throw Error(`bundle is ${e.bytes.byteLength} bytes, over the ${WO} byte download cap`);let t=document.createElement(`a`),n=(e.filename||`device-response`).replace(/[^A-Za-z0-9._-]/g,`_`).slice(0,80)||`device-response`;/\.zip$/i.test(e.filename)&&!/\.zip$/i.test(n)&&(n=`${n.slice(0,76)}.zip`),t.href=URL.createObjectURL(new Blob([e.bytes.slice()],{type:`application/zip`})),t.download=n,t.click(),URL.revokeObjectURL(t.href)}function KO(e,t={}){let n=t.fetchBundle??((e,t)=>G(e).exportSession(t)),r=t.download??GO,i=t.notify??(()=>{}),a=A(!1),o=A(``);async function s(){let{device:t,summary:s}=e.value;if(t&&s&&!a.value){a.value=!0,o.value=``;try{let e=await n(t.id,s.id);r(e),i(`Bundle downloaded (${Math.max(1,Math.round(e.bytes.length/1024))} KiB).`)}catch(e){o.value=`bundle export failed: ${K(e).slice(0,300)}`,i(o.value.slice(0,120))}finally{a.value=!1}}}return N(()=>e.value.summary?.id,()=>o.value=``),{exporting:a,error:o,run:s}}function qO(e){try{let t=JSON.parse(e);if(!t||Array.isArray(t)||typeof t!=`object`)throw Error(`App State must be a JSON object.`);return lb({},{operation:`update`,path:``,value:t}),``}catch(e){return K(e)}}function JO(e,t){let n=A(``),r=A(``),i=A(0),a=A(),o=A(!1),s=A(``),c=U(()=>n.value!==r.value),l=U(()=>c.value&&a.value!==t.value),u=U(()=>c.value&&(l.value||e.value?.revision!==i.value));function d(){n.value=JSON.stringify(e.value?.value??{},null,2),r.value=n.value,i.value=e.value?.revision??0,a.value=t.value,s.value=``}function f(e,t){n.value=JSON.stringify(e,null,2),r.value=n.value,i.value=t,s.value=``}N(e,()=>!c.value&&d(),{immediate:!0}),N(t,()=>d());let p;return N(n,()=>{clearTimeout(p),p=setTimeout(()=>s.value=c.value?qO(n.value):``,250)}),{draft:n,dirty:c,conflict:u,deviceChanged:l,saving:o,problem:s,revision:i,reset:d,commit:f}}var YO={key:0,class:`panel-rail`,"aria-label":`Inspector (collapsed)`},XO=[`title`],ZO=[`aria-label`,`title`,`onClick`],QO={key:0,class:`count`},$O={class:`inspector-tabs`,role:`tablist`,"aria-label":`Session details`},ek=[`id`,`aria-selected`,`title`,`onClick`],tk={class:`tab-label`},nk={key:0,class:`count`},rk=[`title`],ik=[`aria-labelledby`],ak={class:`session-heading`},ok=[`disabled`],sk=[`disabled`],ck=[`title`],lk={class:`cwd-trail`,dir:`rtl`},uk={dir:`ltr`},dk={class:`session-status`},fk={key:0,class:`background-pill`},pk=[`title`],mk={key:0,class:`message-error`,role:`alert`},hk=[`disabled`],gk={class:`model-section`},_k=[`src`],vk={key:0,class:`hint model-provenance`},yk={class:`thinking-row`},bk=[`value`],xk={class:`stats-section`,"aria-labelledby":`stats-title`},Sk={class:`metrics`},Ck=[`title`],wk={class:`usage-breakdown`,"aria-label":`Agent token and cost breakdown`},Tk={scope:`row`},Ek={class:`usage-total`},Dk={class:`panel-heading`},Ok={class:`hint app-state-description`},kk=[`disabled`],Ak={class:`state-json-actions`},jk={key:0,class:`hint`},Mk=[`disabled`],Nk=[`disabled`],Pk={key:0,class:`message-error`,role:`alert`},Fk={key:1,class:`message-error`,role:`alert`},Ik={class:`panel-heading`},Lk={class:`tag`},Rk={class:`hook-card`},zk=[`aria-checked`],Bk={key:0,class:`tag tool-disabled`},Vk={class:`tag`},Hk=[`aria-label`],Uk=pf(Er({__name:`Inspector`,setup(e){let t=U(()=>new Map(Od.value?.tools.map(e=>[e.name,RO(e.name,e.parameters)]))),n=[{id:`session`,label:`Session`,icon:yc},{id:`git`,label:`Git`,icon:xc},{id:`host`,label:`Host`,icon:Vs},{id:`usage`,label:`Usage`,icon:Jc},{id:`auto`,label:`Auto`,icon:ec},{id:`archive`,label:`Archive`,icon:Us},{id:`dag`,label:`DAG`,icon:gl},{id:`notify`,label:`Notify`,icon:Xs},{id:`env`,label:`Env`,icon:gc},{id:`state`,label:`State`,icon:Qs},{id:`tasks`,label:`Tasks`,icon:Vs},{id:`tools`,label:`Tools`,icon:bl},{id:`extensions`,label:`Extend`,icon:Qc}],r=U(()=>[{label:`Input`,tokens:wd.value.input,cost:wd.value.inputCost},{label:`Output`,tokens:wd.value.output,cost:wd.value.outputCost},{label:`Cache read`,tokens:wd.value.cacheRead,cost:wd.value.cacheReadCost},{label:`Cache write`,tokens:wd.value.cacheWrite,cost:wd.value.cacheWriteCost}]),i=U(()=>Sd.value.filter(e=>e.background).length);function a(e,t){Fd(async()=>{await ld.value.configure(e),await Ad(),t&&Y(t)})}async function o(){let e=nd.value,t=sd.value;if(e&&t)try{let n=await G(e.id).agent(t.id,q.value?.agentId??1).transcript(`markdown`),r=new Blob([typeof n==`string`?n:JSON.stringify(n)],{type:`text/markdown`}),i=document.createElement(`a`);i.href=URL.createObjectURL(r),i.download=`${t.name.replace(/[^\w.-]+/g,`_`)||`session`}-${t.id.slice(0,8)}.md`,i.click(),URL.revokeObjectURL(i.href),Y(`Transcript downloaded.`)}catch(e){Y(`transcript download failed: ${K(e).slice(0,120)}`)}}let{exporting:s,error:c,run:l}=KO(U(()=>({device:nd.value,summary:sd.value}))),u=A(!1);function d(){let e=nd.value,t=sd.value;e&&t&&!u.value&&(J.dialog={kind:`prompt`,title:`Share this transcript publicly?`,hint:`Anyone with the link can read this session's transcripts. The link expires in 7 days and can be removed on the hub.`,submit:`Create share link`,run:async()=>{u.value=!0;try{let n=G(e.id),r=t.agents.length?t.agents:[{id:1,name:`main`}],i=[];for(let e of r){let r=await n.agent(t.id,e.id).transcript(`markdown`),a=typeof r==`string`?r:r.text??JSON.stringify(r,null,2);i.push({name:e.name||`agent ${e.id}`,markdown:a})}let a=await Mu.createShare({title:`${t.name} · ${e.name}`,agents:i}),o=`${location.origin}${a.url}`;await navigator.clipboard?.writeText(o).catch(()=>{}),Y(`Share link copied — expires ${a.expiresAt.slice(0,10)}.`)}catch(e){Y(`share failed: ${K(e).slice(0,140)}`)}finally{u.value=!1}}})}function f(){let e=ud.value;e&&(J.dialog={kind:`prompt`,title:`Rename session`,label:`Session name`,value:sd.value?.name??``,submit:`Save name`,run:t=>e.rename(t)})}let p=A({});N(nd,async e=>{if(p.value={},e)try{let{projects:t}=await G(e.id).projects(!0);p.value=Object.fromEntries(t.filter(e=>e.model).map(e=>[e.rootPath,e.model]))}catch{}},{immediate:!0});let m=U(()=>{let e=Ed.value;if(!e)return!1;let t=sd.value?.cwd,n=Object.keys(p.value).filter(e=>t===e||(t??``).startsWith(`${e}/`)).sort((e,t)=>t.length-e.length),r=n.length?p.value[n[0]]:void 0,i=r?`${r.provider}/${r.modelId}`:nd.value?.info?.defaultModel??``;return!!i&&i===`${e.provider}/${e.modelId}`}),h=U(()=>Ed.value&&`model: ${Ed.value.modelId} (${Ed.value.provider})${m.value?` (default)`:``}`),g=od.sharedState,{draft:_,dirty:v,conflict:y,deviceChanged:b,problem:x,revision:S,reset:C,commit:ee}=JO(g,td),te=A(!1),ne=A(``);async function re(e){if(!te.value&&ld.value){te.value=!0,ne.value=``;try{await ld.value.demo(`state`,e)}catch(e){ne.value=K(e)}finally{te.value=!1}}}async function w(){if(!(te.value||y.value||!ld.value)){ne.value=``,te.value=!0;try{let e=JSON.parse(_.value);if(!e||Array.isArray(e)||typeof e!=`object`)throw Error(`App State must be a JSON object.`);let t=await ld.value.demo(`state`,{operation:`update`,path:``,value:e,expectedRevision:S.value});ee(t.value,t.revision),Y(`Shared App State saved.`)}catch(e){ne.value=K(e)}finally{te.value=!1}}}let ie=U(()=>Od.value?.config.readOnly===!0),ae=U(()=>Od.value?.tools.filter(e=>e.offered).length??0);return(e,p)=>(I(),L(`aside`,{class:E([`inspector`,{collapsed:!j(Gd),overlay:j(J).inspectorOverlay}])},[j(Gd)?(I(),L(F,{key:1},[z(`div`,$O,[(I(),L(F,null,P(n,e=>z(`button`,{id:`inspector-tab-${e.id}`,key:e.id,role:`tab`,"aria-controls":`inspector-panel`,"aria-selected":j(J).tab===e.id,title:e.label,class:E({active:j(J).tab===e.id}),onClick:t=>j(J).tab=e.id},[(I(),R($r(e.icon),{size:18})),z(`span`,tk,D(e.label),1),e.id===`tasks`&&j(Sd).length?(I(),L(`span`,nk,D(j(Sd).length),1)):H(``,!0)],10,ek)),64)),z(`button`,{class:`icon-button panel-toggle`,"aria-label":`Collapse inspector`,title:`Collapse inspector (${j(Zd).inspector})`,onClick:p[1]||=e=>j(qd)()},[B(j(Uc),{size:18})],8,rk)]),z(`div`,{id:`inspector-panel`,class:E([`inspector-body`,{"session-panel":j(J).tab===`session`}]),role:`tabpanel`,"aria-labelledby":`inspector-tab-${j(J).tab}`},[j(J).tab===`session`?(I(),L(F,{key:0},[z(`section`,ak,[z(`h1`,null,[z(`span`,null,D(j(sd)?.name??`Loading session`),1),z(`button`,{class:`icon-button`,title:`Rename session`,"aria-label":`Rename session`,onClick:f},[B(j(qc),{size:18})]),z(`button`,{class:`icon-button`,title:`Download transcript (markdown)`,"aria-label":`Download transcript`,onClick:o},[B(j(pc),{size:18})]),z(`button`,{class:`icon-button`,title:`Download session bundle (.zip: manifest, transcripts, configs)`,"aria-label":`Download session bundle`,disabled:j(s),onClick:p[2]||=(...e)=>j(l)&&j(l)(...e)},[B(j(Hc),{size:18})],8,ok),z(`button`,{class:`icon-button`,title:`Share a public read-only link to this transcript`,"aria-label":`Share transcript`,disabled:u.value,onClick:d},[B(j(al),{size:18})],8,sk)]),z(`button`,{class:`path cwd-button`,title:j(sd)?.cwd,"aria-label":`Show full working directory`,onClick:p[3]||=e=>j(J).dialog={kind:`path`,path:j(sd)?.cwd??``}},[B(j(yc),{size:18}),z(`span`,lk,[z(`bdi`,uk,D(j(sd)?.cwd),1)])],8,ck),z(`div`,dk,[z(`span`,{class:E([`status-pill`,{working:j(Cd)}])},[p[10]||=z(`i`,null,null,-1),V(D(j(Cd)?`Working`:`Idle`),1)],2),i.value?(I(),L(`span`,fk,D(i.value)+` background`,1)):H(``,!0),z(`span`,{class:`saved`,title:j(nd)?.id},[B(j(il),{size:18}),V(D(j(nd)?.name??j(nd)?.id),1)],8,pk),j(nd)?(I(),R(Pb,{key:1,device:j(nd)},null,8,[`device`])):H(``,!0)]),j(c)?(I(),L(`p`,mk,[V(D(j(c))+` `,1),z(`button`,{class:`small`,disabled:j(s),onClick:p[4]||=(...e)=>j(l)&&j(l)(...e)},` retry `,8,hk)])):H(``,!0)]),j(nd)?(I(),R(Zb,{key:0,device:j(nd)},null,8,[`device`])):H(``,!0),z(`section`,gk,[p[18]||=z(`div`,{class:`section-label`},[z(`span`,null,`AGENT`)],-1),z(`button`,{class:`model-button`,onClick:p[5]||=e=>j(J).dialog={kind:`models`}},[z(`img`,{src:j(zd)(j(yd).agent.model?.modelId),alt:``},null,8,_k),z(`div`,null,[z(`strong`,null,D(j(Td)?.name??j(yd).agent.model?.modelId??`Loading…`),1),z(`small`,null,D(j(Td)?.tier??``)+` / `+D(j(yd).agent.model?.provider??``),1)]),B(j(nc),{size:18})]),h.value?(I(),L(`p`,vk,D(h.value),1)):H(``,!0),z(`div`,yk,[p[11]||=z(`span`,null,`Thinking`,-1),z(`select`,{"aria-label":`Thinking level`,value:j(yd).agent.thinkingLevel??`medium`,onChange:p[6]||=e=>a({thinkingLevel:e.target.value},`Thinking ${e.target.value}. Used on the next turn.`)},[(I(!0),L(F,null,P(j(Jv),e=>(I(),L(`option`,{key:e},D(e),1))),128))],40,bk)]),B(FO),z(`section`,xk,[p[17]||=z(`div`,{class:`section-label`},[z(`span`,{id:`stats-title`},`STATS`)],-1),z(`div`,Sk,[z(`div`,{title:`${j(wd).tokens.toLocaleString(`en-US`)} total tokens`},[z(`span`,null,D(j(Ld)(j(wd).tokens)),1),p[12]||=z(`small`,null,`total tokens`,-1)],8,Ck),z(`div`,null,[z(`span`,null,`$`+D(j(wd).cost.toFixed(4)),1),p[13]||=z(`small`,null,`agent cost`,-1)]),z(`div`,null,[z(`span`,null,D(j(Od)?.tools.length??0),1),p[14]||=z(`small`,null,`tools`,-1)])]),z(`table`,wk,[p[16]||=z(`thead`,null,[z(`tr`,null,[z(`th`,{scope:`col`},`Type`),z(`th`,{scope:`col`},`Tokens`),z(`th`,{scope:`col`},`Cost (USD)`)])],-1),z(`tbody`,null,[(I(!0),L(F,null,P(r.value,e=>(I(),L(`tr`,{key:e.label},[z(`th`,Tk,D(e.label),1),z(`td`,null,D(e.tokens.toLocaleString(`en-US`)),1),z(`td`,null,`$`+D(e.cost.toFixed(4)),1)]))),128)),z(`tr`,Ek,[p[15]||=z(`th`,{scope:`row`},`Total`,-1),z(`td`,null,D(j(wd).tokens.toLocaleString(`en-US`)),1),z(`td`,null,`$`+D(j(wd).cost.toFixed(4)),1)])])])])])],64)):H(``,!0),j(J).tab===`state`?(I(),L(F,{key:1},[z(`div`,Dk,[p[19]||=z(`h2`,null,`App State`,-1),B(j(Qs),{size:18})]),z(`p`,Ok,` One shared JSON object for every agent, session and fork on `+D(j(nd)?.name??j(nd)?.id)+`. You and your agents can read, create, update or delete values and fields. Changes appear live and persist across closed browsers, interrupted agents and backend restarts. `,1),M(z(`textarea`,{"onUpdate:modelValue":p[7]||=e=>tn(_)?_.value=e:null,class:`app-state-json`,"aria-label":`App State JSON`,spellcheck:`false`,disabled:te.value||!j(g),rows:`12`},null,8,kk),[[ys,j(_)]]),p[20]||=z(`p`,{class:`hint state-limits`},` One JSON object, at most 24 levels of nesting and 100,000 characters, checked as you type. `,-1),z(`div`,Ak,[j(y)?(I(),L(`span`,jk,D(j(b)?`Device changed since this draft loaded. Load the latest JSON before saving.`:`State changed elsewhere. Load the latest JSON before saving.`),1)):H(``,!0),j(v)?(I(),L(`button`,{key:1,class:`secondary`,disabled:te.value,onClick:p[8]||=(...e)=>j(C)&&j(C)(...e)},D(j(y)?`Load latest`:`Reset`),9,Mk)):H(``,!0),z(`button`,{class:`primary small`,disabled:!j(v)||te.value||j(y)||!!j(x),onClick:w},D(te.value?`Saving…`:`Save JSON`),9,Nk)]),j(x)?(I(),L(`p`,Pk,D(j(x)),1)):H(``,!0),ne.value?(I(),L(`p`,Fk,D(ne.value),1)):H(``,!0),B(Ob,{value:j(g)?.value??{},disabled:te.value||j(v)||!j(g),onChange:re},null,8,[`value`,`disabled`])],64)):H(``,!0),j(J).tab===`tasks`?(I(),R(Ox,{key:2})):H(``,!0),j(J).tab===`git`?(I(),R(Ow,{key:3})):H(``,!0),j(J).tab===`host`?(I(),R(Zw,{key:4})):H(``,!0),j(J).tab===`usage`?(I(),R(HT,{key:5})):H(``,!0),j(J).tab===`auto`?(I(),R(yE,{key:6})):H(``,!0),j(J).tab===`archive`?(I(),R(RE,{key:7})):H(``,!0),j(J).tab===`dag`?(I(),R(rD,{key:8})):H(``,!0),j(J).tab===`notify`?(I(),R(OD,{key:9})):H(``,!0),j(J).tab===`env`?(I(),R(cO,{key:10})):H(``,!0),j(J).tab===`extensions`?(I(),R(gO,{key:11})):H(``,!0),j(J).tab===`tools`?(I(),L(F,{key:12},[z(`div`,Ik,[p[21]||=z(`h2`,null,`Tools`,-1),z(`span`,Lk,D(ae.value)+` / `+D(j(Od)?.tools.length??0),1)]),p[25]||=z(`p`,{class:`hint`},` Every tool this agent's extensions provide. Open one to see its definition. `,-1),z(`div`,Rk,[z(`div`,null,[B(j(sl),{size:18}),p[23]||=z(`strong`,null,`Read only`,-1),z(`button`,{class:E([`switch`,{on:ie.value}]),role:`switch`,"aria-checked":ie.value,"aria-label":`Read only`,onClick:p[9]||=e=>a({readOnly:!ie.value},ie.value?`Read only off. Every tool is back.`:`Read only on. Tools that write are disabled.`)},[...p[22]||=[z(`span`,null,null,-1)]],10,zk)]),p[24]||=z(`p`,null,` Offers this agent only tools that read. Tools that create, update or delete leave its next request, and the choice is stored with the agent. `,-1)]),(I(!0),L(F,null,P(j(Od)?.tools,e=>(I(),L(`details`,{key:e.name,class:E([`tool-row`,{disabled:!e.offered}])},[z(`summary`,null,[B(j(bl),{size:18}),z(`strong`,null,D(e.name),1),e.offered?H(``,!0):(I(),L(`span`,Bk,`disabled`)),z(`span`,Vk,D(e.replay===`safe`?`replay safe`:`interrupt on crash`),1)]),z(`p`,null,D(e.description),1),e.parameters?(I(),L(`pre`,{key:0,class:`tool-signature`,"aria-label":`${e.name} TypeScript definition`},[z(`code`,null,[(I(!0),L(F,null,P(t.value.get(e.name),(e,t)=>(I(),L(`span`,{key:t,class:E(`tk-${e.kind}`)},D(e.text),3))),128))])],8,Hk)):H(``,!0),z(`small`,null,D(e.replay===`safe`?`An interrupted execution may run again after recovery.`:`A crash records an interrupted result instead of rerunning this effect.`),1)],2))),128))],64)):H(``,!0)],10,ik)],64)):(I(),L(`div`,YO,[z(`button`,{class:`icon-button panel-toggle`,"aria-label":`Expand inspector`,title:`Expand inspector (${j(Zd).inspector})`,onClick:p[0]||=e=>j(Kd)()},[B(j(Wc),{size:18})],8,XO),(I(),L(F,null,P(n,e=>z(`button`,{key:e.id,class:E([`rail-tab`,{active:j(J).tab===e.id}]),"aria-label":`Open ${e.label}`,title:e.label,onClick:t=>j(Kd)(e.id)},[(I(),R($r(e.icon),{size:20})),e.id===`tasks`&&j(Sd).length?(I(),L(`span`,QO,D(j(Sd).length),1)):H(``,!0)],10,ZO)),64))]))],2))}}),[[`__scopeId`,`data-v-419eb6ed`]]),Wk={class:`chat-empty`},Gk={class:`eyebrow`},Kk={key:3,class:`hint offline-error`},qk={key:4,class:`offline-command`},Jk={key:5,class:`hint`},Yk={key:6,class:`hint`},Xk={class:`offline-actions`},Zk=[`disabled`],Qk={key:7,class:`message-error`,role:`alert`},$k=Er({__name:`OfflinePanel`,props:{device:{}},setup(e){let t=e,n=A(!1),r=A(``),i=U(()=>{let e=t.device,n=e.source===`config`;switch(e.status){case`checking`:return{title:`Checking ${e.name}…`,text:`Probing the device. This view fills in as soon as it answers.`};case`unauthorized`:return e.transport===`tunnel`?{title:`${e.name} tunnel credentials are not valid`,text:`Pair the device again — the hub will mint a fresh credential.`}:{title:e.hasToken?`${e.name} rejected its token`:`No token for ${e.name}`,text:e.hasToken?`The device's DPI_TOKEN changed (a rotate or a rebuilt device). Copy the current token into this hub's registry, then check again.`:`This hub has no token for the device yet. Register it, then check again.`,command:n&&e.kind!==`url`?`just net register ${e.id}`:`just net register ${e.id} --token <token>`};case`mismatch`:return{title:`${e.name} answers as a different device`,text:`The URL now reaches a backend with another identity (a rebuilt VM or a new data directory). If that is expected, register it again: that trusts the identity it answers with now.`,command:e.kind===`url`?`just net register ${e.id} --token <token>`:`just net register ${e.id}`};case`incompatible`:return{title:`${e.name} speaks another API version`,text:`Update the device's dpi-backend.`,command:n?`just net deploy ${e.id}`:void 0};default:return{title:`${e.name} is offline`,text:`Last seen ${Bd(e.lastSeenAt)}. Its agents keep their state on the device and resume when its backend starts again. The tree shows the last known sessions.`,command:n?e.kind===`local`?`just backend run`:e.kind===`url`?void 0:`just net restart ${e.id}`:void 0,alt:n&&e.kind!==`local`&&e.kind!==`url`?`just net up ${e.id}`:void 0}}});async function a(){n.value=!0,r.value=``;try{let e=await Mu.check(t.device.id);e.status===`online`&&Y(`${e.id} is online.`)}catch(e){r.value=K(e)}finally{n.value=!1}}async function o(e){try{await navigator.clipboard.writeText(e),Y(`Copied.`)}catch{Y(`Clipboard needs localhost or HTTPS. Select the text to copy.`)}}return(t,s)=>(I(),L(`section`,{class:E([`chat-panel offline-panel`,e.device.status]),"aria-live":`polite`},[z(`div`,Wk,[e.device.status===`checking`?(I(),R(j(Ic),{key:0,class:`spin`,size:30})):e.device.status===`mismatch`||e.device.status===`unauthorized`?(I(),R(j(ol),{key:1,size:30})):(I(),R(j(_l),{key:2,size:30})),z(`span`,Gk,D(e.device.kind.toUpperCase())+` · `+D(e.device.url??(e.device.transport===`tunnel`?`tunnel`:`no endpoint`)),1),z(`h2`,null,D(i.value.title),1),z(`p`,null,D(i.value.text),1),e.device.error?(I(),L(`p`,Kk,D(e.device.error),1)):H(``,!0),i.value.command?(I(),L(`div`,qk,[z(`code`,null,D(i.value.command),1),z(`button`,{class:`icon-button`,"aria-label":`Copy command`,onClick:s[0]||=e=>o(i.value.command)},[B(j(sc),{size:18})])])):H(``,!0),i.value.command?(I(),L(`p`,Jk,`Run it in this repo's terminal, then press Check now.`)):H(``,!0),i.value.alt?(I(),L(`p`,Yk,[s[2]||=V(` Never deployed or rebuilt? `,-1),z(`code`,null,D(i.value.alt),1),s[3]||=V(` provisions it from scratch. `,-1)])):H(``,!0),z(`div`,Xk,[z(`button`,{class:`secondary`,disabled:n.value,onClick:s[1]||=e=>a()},[B(j($c),{size:18}),V(D(n.value?`Checking…`:`Check now`),1)],8,Zk)]),r.value?(I(),L(`p`,Qk,D(r.value),1)):H(``,!0)])],2))}}),eA={class:`dir-browser`},tA={class:`dir-path`},nA=[`disabled`],rA=[`aria-busy`],iA=[`title`],aA=[`aria-selected`,`title`,`onClick`],oA={key:1,class:`hint`},sA={key:0,class:`message-error`,role:`alert`},cA=Er({__name:`DirBrowser`,props:si({deviceId:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=Di(e,`modelValue`),r=A(),i=A(!1),a=A(``),o=0;async function s(e){let s=++o,c=t.deviceId;i.value=!0,a.value=``;try{let t=await G(c).dirs(e);return s===o?(r.value=t,t.path&&(n.value=t.path),t):void 0}catch(e){s===o&&(a.value=K(e));return}finally{s===o&&(i.value=!1)}}return N(()=>t.deviceId,async()=>{r.value=void 0;let e=await s(``),t=e?.dirs[0];t&&!e.path&&await s(t.path)},{immediate:!0}),(e,t)=>(I(),L(`div`,eA,[z(`div`,tA,[M(z(`input`,{"onUpdate:modelValue":t[0]||=e=>n.value=e,"aria-label":`Working directory`,required:``,placeholder:`/path/to/project`,spellcheck:`false`,autocomplete:`off`,onKeydown:t[1]||=js(ks(e=>s(n.value),[`prevent`]),[`enter`])},null,544),[[ys,n.value]]),z(`button`,{type:`button`,class:`secondary small`,disabled:i.value||!n.value,onClick:t[2]||=e=>s(n.value)},` Go `,8,nA)]),z(`div`,{class:`dir-list`,role:`listbox`,"aria-label":`Directories`,"aria-busy":i.value},[z(`button`,{type:`button`,class:`dir-item`,title:`Start directories`,onClick:t[3]||=e=>s(``)},[B(j(Dc),{size:16}),t[5]||=z(`span`,null,`Start dirs`,-1)]),r.value?.parent?(I(),L(`button`,{key:0,type:`button`,class:`dir-item`,title:r.value.parent,onClick:t[4]||=e=>s(r.value.parent)},[B(j(lc),{size:16}),t[6]||=z(`span`,null,`..`,-1)],8,iA)):H(``,!0),(I(!0),L(F,null,P(r.value?.dirs,e=>(I(),L(`button`,{key:e.path,type:`button`,class:`dir-item`,role:`option`,"aria-selected":e.path===n.value,title:e.path,onClick:t=>s(e.path)},[e.path===n.value?(I(),R(j(yc),{key:0,size:16})):(I(),R(j(bc),{key:1,size:16})),z(`span`,null,D(e.name),1)],8,aA))),128)),r.value&&!r.value.dirs.length?(I(),L(`p`,oA,`No subdirectories.`)):H(``,!0)],8,rA),a.value?(I(),L(`p`,sA,D(a.value),1)):H(``,!0)]))}}),lA={key:0,class:`message-error`},uA=[`value`],dA={class:`field`},fA={key:0,class:`recent-cwds`},pA=[`title`,`onClick`],mA={key:0,class:`hint`,title:`The device has no provider key — it lists its built-in catalog, and chat needs OPENROUTER_API_KEY set in the device's env file`},hA=[`value`],gA=[`value`],_A={key:2,class:`message-error`,role:`alert`},vA=[`disabled`],yA=`dpi-recent-cwds`,bA=pf(Er({__name:`NewSessionDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=U(()=>Ju.devices.value.filter(e=>e.status===`online`)),a=A(i.value.find(e=>e.id===n.deviceId)?.id??i.value[0]?.id??``),o=U(()=>i.value.find(e=>e.id===a.value)),s=U(()=>{let e=o.value?.info?.models??[];if(e.length)return e;let t=o.value?.info;return t?.defaultModel&&t.provider?[{id:t.defaultModel,provider:t.provider,name:`${t.defaultModel} (device default)`,tier:`—`,icon:`lab.png`,contextWindow:0,reasoning:!1,cost:{input:0,output:0}}]:[]}),c=U(()=>!s.value.length||(o.value?.info?.models?.length??0)===0),l=U(()=>!!o.value?.info?.providerKeyMissing),u=e=>`${e.provider}/${e.id}`,d=A({name:``,cwd:``,model:``,thinking:`medium`}),f=U(()=>{try{return JSON.parse(localStorage.getItem(yA)??`{}`)[a.value]??[]}catch{return[]}}),p=(e,t)=>{try{let n=JSON.parse(localStorage.getItem(yA)??`{}`),r=[t,...(n[e]??[]).filter(e=>e!==t)].slice(0,6);localStorage.setItem(yA,JSON.stringify({...n,[e]:r}))}catch{}},m=A(!1),h=A(``),g=A({});N(a,async e=>{if(g.value={},e)try{let{projects:t}=await G(e).projects(!0);g.value=Object.fromEntries(t.filter(e=>e.model).map(e=>[e.rootPath,e.model]))}catch{}},{immediate:!0}),N([()=>d.value.cwd,g],()=>{let e=d.value.cwd;if(!e)return;let t=Object.keys(g.value).filter(t=>e===t||e.startsWith(`${t}/`)).sort((e,t)=>t.length-e.length),n=t.length?g.value[t[0]]:void 0;n&&(d.value.model=`${n.provider}/${n.modelId}`)},{immediate:!0}),N(o,e=>{let t=s.value,n=t.find(t=>t.id===e?.info?.defaultModel)??t[0];d.value.model=n?u(n):``,d.value.cwd=``},{immediate:!0});async function _(){if(!m.value&&o.value){m.value=!0,h.value=``;try{let e=s.value.find(e=>u(e)===d.value.model)??s.value[0];if(!e)throw Error(`Choose a model`);let t=await G(o.value.id).createSession({name:d.value.name.trim()||`New session`,cwd:d.value.cwd.trim(),model:{provider:e.provider,modelId:e.id},thinkingLevel:d.value.thinking});p(o.value.id,t.cwd);let n=t.agents.find(e=>e.kind===`root`)??t.agents[0];dd({deviceId:o.value.id,sessionId:t.id,agentId:n?.id??1}),Y(`Session created on ${o.value.id}.`),r(`close`)}catch(e){h.value=K(e)}finally{m.value=!1}}}return(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:t[7]||=ks(e=>r(`close`),[`self`])},[z(`form`,{class:`modal session-modal`,onSubmit:ks(_,[`prevent`])},[z(`header`,null,[t[8]||=z(`div`,null,[z(`span`,{class:`eyebrow`},`A PERSISTENT WORKSPACE`),z(`h2`,null,`New session`)],-1),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close new session`,onClick:t[0]||=e=>r(`close`)},[B(j(xl),{size:18})])]),i.value.length?(I(),L(F,{key:1},[z(`label`,null,[t[9]||=V(`Device`,-1),M(z(`select`,{"onUpdate:modelValue":t[1]||=e=>a.value=e,"aria-label":`Device`},[(I(!0),L(F,null,P(i.value,e=>(I(),L(`option`,{key:e.id,value:e.id},D(e.name)+D(e.info?.hostname&&e.info.hostname!==e.name?` · ${e.info.hostname}`:``),9,uA))),128))],512),[[Ss,a.value]])]),z(`label`,null,[t[10]||=V(`Session name`,-1),M(z(`input`,{"onUpdate:modelValue":t[2]||=e=>d.value.name=e,autofocus:``,placeholder:`My durable agent`,maxlength:`100`},null,512),[[ys,d.value.name]])]),z(`div`,dA,[z(`span`,null,`Working directory on `+D(i.value.find(e=>e.id===a.value)?.name??a.value),1),f.value.length?(I(),L(`div`,fA,[(I(!0),L(F,null,P(f.value,e=>(I(),L(`button`,{key:e,type:`button`,class:E([`chip`,{on:e===d.value.cwd}]),title:e,onClick:t=>d.value.cwd=e},D(e.split(`/`).filter(Boolean).at(-1)||e),11,pA))),128))])):H(``,!0),B(cA,{modelValue:d.value.cwd,"onUpdate:modelValue":t[3]||=e=>d.value.cwd=e,"device-id":a.value},null,8,[`modelValue`,`device-id`])]),z(`label`,null,[t[11]||=V(`Model`,-1),c.value||l.value?(I(),L(`span`,mA,`no API key on device — chat needs one`)):H(``,!0),M(z(`select`,{"onUpdate:modelValue":t[4]||=e=>d.value.model=e,"aria-label":`New session model`},[(I(!0),L(F,null,P(s.value,e=>(I(),L(`option`,{key:u(e),value:u(e)},D(e.tier)+` / `+D(e.name),9,hA))),128))],512),[[Ss,d.value.model]])]),z(`label`,null,[t[12]||=V(`Thinking`,-1),M(z(`select`,{"onUpdate:modelValue":t[5]||=e=>d.value.thinking=e,"aria-label":`New session thinking level`},[(I(!0),L(F,null,P(j(Jv),e=>(I(),L(`option`,{key:e,value:e},D(e),9,gA))),128))],512),[[Ss,d.value.thinking]])])],64)):(I(),L(`p`,lA,` No device is online. Start one with just backend run or just net up <id>, then try again. `)),h.value?(I(),L(`p`,_A,D(h.value),1)):H(``,!0),z(`footer`,null,[z(`button`,{type:`button`,class:`secondary`,onClick:t[6]||=e=>r(`close`)},`Cancel`),z(`button`,{class:`primary`,disabled:m.value||!d.value.model||!d.value.cwd||!o.value},[B(j(Xc),{size:18}),V(D(m.value?`Creating…`:`Create session`),1)],8,vA)])],32)]))}}),[[`__scopeId`,`data-v-4e298b1e`]]),xA=new Uint8Array(512),SA=new Uint8Array(256);(()=>{let e=1;for(let t=0;t<255;t++)xA[t]=e,SA[e]=t,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)xA[e]=xA[e-255]})();var CA=(e,t)=>e===0||t===0?0:xA[SA[e]+SA[t]];function wA(e){let t=[1];for(let n=0;n<e;n++){let e=Array(t.length+1).fill(0);for(let r=0;r<t.length;r++)e[r]^=t[r],e[r+1]^=CA(t[r],xA[n]);t=e}return t}function TA(e,t){let n=wA(t),r=Array(t).fill(0);for(let i of e){let e=i^r[0];r.shift(),r.push(0);for(let i=0;i<t;i++)r[i]^=CA(n[i+1],e)}return r}var EA=[21,25,29,33,37,41,45,49,53,57,61,65],DA=[19,34,55,80,108,136,156,194,232,274,324,370],OA=[7,10,15,20,26,36,40,48,60,72,80,96],kA=[7,10,15,20,26,18,20,24,30,18,20,24],AA=[[[1,19]],[[1,34]],[[1,55]],[[1,80]],[[1,108]],[[2,68]],[[2,78]],[[2,97]],[[2,116]],[[2,68],[2,69]],[[4,81]],[[2,92],[2,93]]],jA=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58]],MA=e=>e<=9?8:16;function NA(e){for(let t=1;t<=EA.length;t++)if(4+MA(t)+e*8<=DA[t-1]*8)return t;throw Error(`qr: payload too long (${e} bytes; v12L max ${DA[11]-3})`)}function PA(e,t){let n=[...new TextEncoder().encode(e)],r=[],i=(e,t)=>{for(let n=t-1;n>=0;n--)r.push(e>>n&1)};i(4,4),i(n.length,MA(t));for(let e of n)i(e,8);let a=DA[t-1],o=a*8;for(i(0,Math.min(4,o-r.length));r.length%8!=0;)r.push(0);let s=[236,17],c=0;for(;r.length<o;)i(s[c++%2],8);let l=[];for(let e=0;e<a;e++){let t=0;for(let n=0;n<8;n++)t=t<<1|r[e*8+n];l.push(t)}return l}function FA(e,t){let n=kA[e-1],r=[],i=0;for(let[n,a]of AA[e-1])for(let e=0;e<n;e++)r.push(t.slice(i,i+=a));let a=[],o=Math.max(...r.map(e=>e.length));for(let e=0;e<o;e++)for(let t of r)e<t.length&&a.push(t[e]);let s=r.map(e=>TA(e,n));for(let e=0;e<n;e++)for(let t of s)a.push(t[e]);return a}function IA(e){return Array.from({length:e},()=>Array(e).fill(!1))}function LA(e,t){let n=EA[t-1],r=(t,r)=>{for(let i=-1;i<=7;i++)for(let a=-1;a<=7;a++){let o=t+i,s=r+a;if(o<0||o>=n||s<0||s>=n)continue;let c=i>=0&&i<=6&&a>=0&&a<=6&&(i===0||i===6||a===0||a===6),l=i>=2&&i<=4&&a>=2&&a<=4;e[o][s]=c||l}};r(0,0),r(0,n-7),r(n-7,0);for(let t=8;t<n-8;t++)e[6][t]=t%2==0,e[t][6]=t%2==0;let i=jA[t-1];for(let t of i)for(let r of i)if(!(t<=8&&r<=8||t<=8&&r>=n-9||t>=n-9&&r<=8))for(let n=-2;n<=2;n++)for(let i=-2;i<=2;i++)e[t+n][r+i]=Math.max(Math.abs(n),Math.abs(i))!==1;if(e[n-8][8]=!0,t>=7){let r=t<<12;for(let e=17;e>=12;e--)r>>e&1&&(r^=7973<<e-12);let i=t<<12|r&4095;for(let t=0;t<18;t++){let r=(i>>t&1)==1,a=n-11+t%3,o=t/3|0;e[a][o]=r,e[o][a]=r}}}function RA(e){let t=8|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>9&1?1335:0);let r=(t<<10|n)^21522,i=[];for(let e=14;e>=0;e--)i.push((r>>e&1)==1);return i}function zA(e,t){let n=EA[0]*0+e.length,r=RA(t);for(let t=0;t<=5;t++)e[8][t]=r[t];e[8][7]=r[6],e[8][8]=r[7],e[7][8]=r[8];for(let t=9;t<15;t++)e[14-t][8]=r[t];for(let t=0;t<7;t++)e[n-1-t][8]=r[t];e[8][n-8]=r[7];for(let t=8;t<15;t++)e[8][n-15+t]=r[t];e[n-8][8]=!0}function BA(e,t,n,r){let i=e.length;EA[n-1]*EA[n-1];let a=e=>((t[e>>3]??0)>>7-(e&7)&1)==1,o=0,s=!0;for(let t=i-1;t>0;t-=2){t===6&&t--;for(let c=0;c<i;c++){let l=s?i-1-c:c;for(let i of[t,t-1]){if(HA(l,i,n))continue;if(o>=(DA[n-1]+OA[n-1])*8){o++;continue}let t=a(o++);VA(l,i,r)&&(t=!t),e[l][i]=t}}s=!s}}function VA(e,t,n){switch(n){case 0:return(e+t)%2==0;case 1:return e%2==0;case 2:return t%3==0;case 3:return(e+t)%3==0;case 4:return(Math.floor(e/2)+Math.floor(t/3))%2==0;case 5:return e*t%2+e*t%3==0;case 6:return(e*t%2+e*t%3)%2==0;default:return((e+t)%2+e*t%3)%2==0}}function HA(e,t,n){let r=EA[n-1];if(e<=8&&t<=8||e<=8&&t>=r-8||e>=r-8&&t<=8||e===6||t===6||n>=7&&(e>=r-11&&e<=r-9&&t<=5||t>=r-11&&t<=r-9&&e<=5))return!0;let i=jA[n-1];for(let n of i)for(let a of i)if(!(n<=8&&a<=8||n<=8&&a>=r-9||n>=r-9&&a<=8)&&Math.abs(e-n)<=2&&Math.abs(t-a)<=2)return!0;return!1}function UA(e){let t=e.length,n=0;for(let r=0;r<2;r++)for(let i=0;i<t;i++){let a=1;for(let o=1;o<t;o++)(r===0?e[i][o]:e[o][i])===(r===0?e[i][o-1]:e[o-1][i])?(a++,o===t-1&&a>=5&&(n+=3+(a-5))):(a>=5&&(n+=3+(a-5)),a=1)}for(let r=0;r<t-1;r++)for(let i=0;i<t-1;i++){let t=e[r][i];e[r][i+1]===t&&e[r+1][i]===t&&e[r+1][i+1]===t&&(n+=3)}let r=[!0,!1,!0,!0,!0,!1,!0,!1,!1,!1,!1],i=(e,t)=>{for(let i=0;i+11<=t;i++){let t=!0;for(let n=0;n<11;n++)if(e(i+n)!==r[n]){t=!1;break}t&&(n+=40)}};for(let n=0;n<t;n++)i(t=>e[n][t],t);for(let n=0;n<t;n++)i(t=>e[t][n],t);let a=0;for(let t of e)for(let e of t)e&&a++;let o=a*100/(t*t);return n+=Math.floor(Math.abs(o-50)/5)*10,n}function WA(e,t){let n=NA(new TextEncoder().encode(e).length),r=EA[n-1],i=FA(n,PA(e,n)),a=IA(r);return LA(a,n),BA(a,i,n,t),zA(a,t),a}function GA(e,t){if(t!==void 0)return WA(e,t);let n;for(let t=0;t<8;t++){let r=WA(e,t),i=UA(r);(!n||i<n.score)&&(n={m:r,score:i})}return n.m}function KA(e,t=160){let n=GA(e),r=n.length,i=t/(r+8),a=``;for(let e=0;e<r;e++)for(let t=0;t<r;t++)n[e][t]&&(a+=`<rect x="${((t+4)*i).toFixed(2)}" y="${((e+4)*i).toFixed(2)}" width="${i.toFixed(3)}" height="${i.toFixed(3)}"/>`);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${t} ${t}" shape-rendering="crispEdges"><rect width="${t}" height="${t}" fill="#fff"/><g fill="#000">${a}</g></svg>`}var qA={class:`device-handoff`,"aria-label":`Pair this machine`},JA={class:`row`},YA=[`disabled`],XA=[`disabled`],ZA={key:0,class:`target`,"data-testid":`device-url`},QA={key:1,class:`err`},$A=pf(Er({__name:`DeviceHandoff`,props:{offerFragment:{}},setup(e){let t=e,n=A(`4780`),r=A(!1),i=U(()=>{let e=/^\d{1,5}$/.test(n.value)?Number(n.value):0;if(!(!e||e<1||e>65535))return`http://127.0.0.1:${e}/pair#${t.offerFragment}`});function a(){let e=i.value;e&&window.open(e,`_blank`,`noopener`)}async function o(){let e=i.value;if(e)try{await navigator.clipboard.writeText(e),r.value=!0,setTimeout(()=>r.value=!1,1600)}catch{}}return(e,t)=>(I(),L(`section`,qA,[z(`header`,null,[B(j(zc),{size:18}),t[1]||=z(`h3`,null,`Pair THIS machine`,-1)]),t[4]||=z(`p`,{class:`what`},[V(` If this browser runs on the device itself, open its local pairing page — the offer is relayed inside the link, nothing is sent to the hub. Start `),z(`code`,null,`dpi device`),V(` there first. `)],-1),z(`div`,JA,[z(`label`,null,[t[2]||=V(` local port `,-1),M(z(`input`,{"onUpdate:modelValue":t[0]||=e=>n.value=e,inputmode:`numeric`,spellcheck:`false`,"aria-label":`Local dpi backend port`},null,512),[[ys,n.value]])]),z(`button`,{class:`primary`,type:`button`,disabled:!i.value,onClick:a},[B(j(mc),{size:15}),t[3]||=V(`Open the device page `,-1)],8,YA),z(`button`,{class:`secondary`,type:`button`,disabled:!i.value,onClick:o},[B(j(sc),{size:15}),V(D(r.value?`Copied`:`Copy link`),1)],8,XA)]),i.value?(I(),L(`p`,ZA,D(i.value),1)):H(``,!0),i.value?H(``,!0):(I(),L(`p`,QA,`port must be 1–65535`))]))}}),[[`__scopeId`,`data-v-1e8e00d8`]]);function ej(e){return lj(e)&&!tj(e)&&!pj(e)&&Symbol.asyncIterator in e}function tj(e){return Array.isArray(e)}function nj(e){return typeof e==`bigint`}function rj(e){return typeof e==`boolean`}function ij(e){return e instanceof globalThis.Date}function aj(e){return typeof e==`function`}function oj(e){return lj(e)&&!tj(e)&&!pj(e)&&Symbol.iterator in e}function sj(e){return e===null}function cj(e){return typeof e==`number`}function lj(e){return typeof e==`object`&&!!e}function uj(e){return e instanceof globalThis.RegExp}function dj(e){return typeof e==`string`}function fj(e){return typeof e==`symbol`}function pj(e){return e instanceof globalThis.Uint8Array}function mj(e){return e===void 0}function hj(e){return e.map(e=>bj(e))}function gj(e){return new Date(e.getTime())}function _j(e){return new Uint8Array(e)}function vj(e){return new RegExp(e.source,e.flags)}function yj(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=bj(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=bj(e[n]);return t}function bj(e){return tj(e)?hj(e):ij(e)?gj(e):pj(e)?_j(e):uj(e)?vj(e):lj(e)?yj(e):e}function xj(e){return bj(e)}function Sj(e,t){return xj(t===void 0?e:{...t,...e})}function Cj(e){return typeof e==`object`&&!!e}function wj(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function Tj(e){return e===void 0}function Ej(e){return typeof e==`number`}var Dj;(function(e){e.InstanceMode=`default`,e.ExactOptionalPropertyTypes=!1,e.AllowArrayObject=!1,e.AllowNaN=!1,e.AllowNullVoid=!1;function t(t,n){return e.ExactOptionalPropertyTypes?n in t:t[n]!==void 0}e.IsExactOptionalProperty=t;function n(t){let n=Cj(t);return e.AllowArrayObject?n:n&&!wj(t)}e.IsObjectLike=n;function r(e){return n(e)&&!(e instanceof Date)&&!(e instanceof Uint8Array)}e.IsRecordLike=r;function i(t){return e.AllowNaN?Ej(t):Number.isFinite(t)}e.IsNumberLike=i;function a(t){let n=Tj(t);return e.AllowNullVoid?n||t===null:n}e.IsVoidLike=a})(Dj||={});function Oj(e){return globalThis.Object.freeze(e).map(e=>Nj(e))}function kj(e){return e}function Aj(e){return e}function jj(e){return e}function Mj(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=Nj(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=Nj(e[n]);return globalThis.Object.freeze(t)}function Nj(e){return tj(e)?Oj(e):ij(e)?kj(e):pj(e)?Aj(e):uj(e)?jj(e):lj(e)?Mj(e):e}function X(e,t){let n=t===void 0?e:{...t,...e};switch(Dj.InstanceMode){case`freeze`:return Nj(n);case`clone`:return xj(n);default:return n}}var Pj=class extends Error{constructor(e){super(e)}},Fj=Symbol.for(`TypeBox.Transform`),Ij=Symbol.for(`TypeBox.Readonly`),Lj=Symbol.for(`TypeBox.Optional`),Rj=Symbol.for(`TypeBox.Hint`),Z=Symbol.for(`TypeBox.Kind`);function zj(e){return lj(e)&&e[Ij]===`Readonly`}function Bj(e){return lj(e)&&e[Lj]===`Optional`}function Vj(e){return eM(e,`Any`)}function Hj(e){return eM(e,`Argument`)}function Uj(e){return eM(e,`Array`)}function Wj(e){return eM(e,`AsyncIterator`)}function Gj(e){return eM(e,`BigInt`)}function Kj(e){return eM(e,`Boolean`)}function qj(e){return eM(e,`Computed`)}function Jj(e){return eM(e,`Constructor`)}function Yj(e){return eM(e,`Date`)}function Xj(e){return eM(e,`Function`)}function Zj(e){return eM(e,`Integer`)}function Qj(e){return eM(e,`Intersect`)}function $j(e){return eM(e,`Iterator`)}function eM(e,t){return lj(e)&&Z in e&&e[Z]===t}function tM(e){return rj(e)||cj(e)||dj(e)}function nM(e){return eM(e,`Literal`)}function rM(e){return eM(e,`MappedKey`)}function iM(e){return eM(e,`MappedResult`)}function aM(e){return eM(e,`Never`)}function oM(e){return eM(e,`Not`)}function sM(e){return eM(e,`Null`)}function cM(e){return eM(e,`Number`)}function lM(e){return eM(e,`Object`)}function uM(e){return eM(e,`Promise`)}function dM(e){return eM(e,`Record`)}function fM(e){return eM(e,`Ref`)}function pM(e){return eM(e,`RegExp`)}function mM(e){return eM(e,`String`)}function hM(e){return eM(e,`Symbol`)}function gM(e){return eM(e,`TemplateLiteral`)}function _M(e){return eM(e,`This`)}function vM(e){return lj(e)&&Fj in e}function yM(e){return eM(e,`Tuple`)}function bM(e){return eM(e,`Undefined`)}function xM(e){return eM(e,`Union`)}function SM(e){return eM(e,`Uint8Array`)}function CM(e){return eM(e,`Unknown`)}function wM(e){return eM(e,`Unsafe`)}function TM(e){return eM(e,`Void`)}function EM(e){return lj(e)&&Z in e&&dj(e[Z])}function DM(e){return Vj(e)||Hj(e)||Uj(e)||Kj(e)||Gj(e)||Wj(e)||qj(e)||Jj(e)||Yj(e)||Xj(e)||Zj(e)||Qj(e)||$j(e)||nM(e)||rM(e)||iM(e)||aM(e)||oM(e)||sM(e)||cM(e)||lM(e)||uM(e)||dM(e)||fM(e)||pM(e)||mM(e)||hM(e)||gM(e)||_M(e)||yM(e)||bM(e)||xM(e)||SM(e)||CM(e)||wM(e)||TM(e)||EM(e)}var OM=`Argument.Any.Array.AsyncIterator.BigInt.Boolean.Computed.Constructor.Date.Enum.Function.Integer.Intersect.Iterator.Literal.MappedKey.MappedResult.Not.Null.Number.Object.Promise.Record.Ref.RegExp.String.Symbol.TemplateLiteral.This.Tuple.Undefined.Union.Uint8Array.Unknown.Void`.split(`.`);function kM(e){try{return new RegExp(e),!0}catch{return!1}}function AM(e){if(!dj(e))return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n>=7&&n<=13||n===27||n===127)return!1}return!0}function jM(e){return PM(e)||AN(e)}function MM(e){return mj(e)||nj(e)}function NM(e){return mj(e)||cj(e)}function PM(e){return mj(e)||rj(e)}function FM(e){return mj(e)||dj(e)}function IM(e){return mj(e)||dj(e)&&AM(e)&&kM(e)}function LM(e){return mj(e)||dj(e)&&AM(e)}function RM(e){return mj(e)||AN(e)}function zM(e){return lj(e)&&e[Lj]===`Optional`}function BM(e){return eN(e,`Any`)&&FM(e.$id)}function VM(e){return eN(e,`Argument`)&&cj(e.index)}function HM(e){return eN(e,`Array`)&&e.type===`array`&&FM(e.$id)&&AN(e.items)&&NM(e.minItems)&&NM(e.maxItems)&&PM(e.uniqueItems)&&RM(e.contains)&&NM(e.minContains)&&NM(e.maxContains)}function UM(e){return eN(e,`AsyncIterator`)&&e.type===`AsyncIterator`&&FM(e.$id)&&AN(e.items)}function WM(e){return eN(e,`BigInt`)&&e.type===`bigint`&&FM(e.$id)&&MM(e.exclusiveMaximum)&&MM(e.exclusiveMinimum)&&MM(e.maximum)&&MM(e.minimum)&&MM(e.multipleOf)}function GM(e){return eN(e,`Boolean`)&&e.type===`boolean`&&FM(e.$id)}function KM(e){return eN(e,`Computed`)&&dj(e.target)&&tj(e.parameters)&&e.parameters.every(e=>AN(e))}function qM(e){return eN(e,`Constructor`)&&e.type===`Constructor`&&FM(e.$id)&&tj(e.parameters)&&e.parameters.every(e=>AN(e))&&AN(e.returns)}function JM(e){return eN(e,`Date`)&&e.type===`Date`&&FM(e.$id)&&NM(e.exclusiveMaximumTimestamp)&&NM(e.exclusiveMinimumTimestamp)&&NM(e.maximumTimestamp)&&NM(e.minimumTimestamp)&&NM(e.multipleOfTimestamp)}function YM(e){return eN(e,`Function`)&&e.type===`Function`&&FM(e.$id)&&tj(e.parameters)&&e.parameters.every(e=>AN(e))&&AN(e.returns)}function XM(e){return eN(e,`Integer`)&&e.type===`integer`&&FM(e.$id)&&NM(e.exclusiveMaximum)&&NM(e.exclusiveMinimum)&&NM(e.maximum)&&NM(e.minimum)&&NM(e.multipleOf)}function ZM(e){return lj(e)&&Object.entries(e).every(([e,t])=>AM(e)&&AN(t))}function QM(e){return eN(e,`Intersect`)&&!(dj(e.type)&&e.type!==`object`)&&tj(e.allOf)&&e.allOf.every(e=>AN(e)&&!xN(e))&&FM(e.type)&&(PM(e.unevaluatedProperties)||RM(e.unevaluatedProperties))&&FM(e.$id)}function $M(e){return eN(e,`Iterator`)&&e.type===`Iterator`&&FM(e.$id)&&AN(e.items)}function eN(e,t){return lj(e)&&Z in e&&e[Z]===t}function tN(e){return iN(e)&&dj(e.const)}function nN(e){return iN(e)&&cj(e.const)}function rN(e){return iN(e)&&rj(e.const)}function iN(e){return eN(e,`Literal`)&&FM(e.$id)&&aN(e.const)}function aN(e){return rj(e)||cj(e)||dj(e)}function oN(e){return eN(e,`MappedKey`)&&tj(e.keys)&&e.keys.every(e=>cj(e)||dj(e))}function sN(e){return eN(e,`MappedResult`)&&ZM(e.properties)}function cN(e){return eN(e,`Never`)&&lj(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function lN(e){return eN(e,`Not`)&&AN(e.not)}function uN(e){return eN(e,`Null`)&&e.type===`null`&&FM(e.$id)}function dN(e){return eN(e,`Number`)&&e.type===`number`&&FM(e.$id)&&NM(e.exclusiveMaximum)&&NM(e.exclusiveMinimum)&&NM(e.maximum)&&NM(e.minimum)&&NM(e.multipleOf)}function fN(e){return eN(e,`Object`)&&e.type===`object`&&FM(e.$id)&&ZM(e.properties)&&jM(e.additionalProperties)&&NM(e.minProperties)&&NM(e.maxProperties)}function pN(e){return eN(e,`Promise`)&&e.type===`Promise`&&FM(e.$id)&&AN(e.item)}function mN(e){return eN(e,`Record`)&&e.type===`object`&&FM(e.$id)&&jM(e.additionalProperties)&&lj(e.patternProperties)&&(e=>{let t=Object.getOwnPropertyNames(e.patternProperties);return t.length===1&&kM(t[0])&&lj(e.patternProperties)&&AN(e.patternProperties[t[0]])})(e)}function hN(e){return eN(e,`Ref`)&&FM(e.$id)&&dj(e.$ref)}function gN(e){return eN(e,`RegExp`)&&FM(e.$id)&&dj(e.source)&&dj(e.flags)&&NM(e.maxLength)&&NM(e.minLength)}function _N(e){return eN(e,`String`)&&e.type===`string`&&FM(e.$id)&&NM(e.minLength)&&NM(e.maxLength)&&IM(e.pattern)&&LM(e.format)}function vN(e){return eN(e,`Symbol`)&&e.type===`symbol`&&FM(e.$id)}function yN(e){return eN(e,`TemplateLiteral`)&&e.type===`string`&&dj(e.pattern)&&e.pattern[0]===`^`&&e.pattern[e.pattern.length-1]===`$`}function bN(e){return eN(e,`This`)&&FM(e.$id)&&dj(e.$ref)}function xN(e){return lj(e)&&Fj in e}function SN(e){return eN(e,`Tuple`)&&e.type===`array`&&FM(e.$id)&&cj(e.minItems)&&cj(e.maxItems)&&e.minItems===e.maxItems&&(mj(e.items)&&mj(e.additionalItems)&&e.minItems===0||tj(e.items)&&e.items.every(e=>AN(e)))}function CN(e){return eN(e,`Undefined`)&&e.type===`undefined`&&FM(e.$id)}function wN(e){return eN(e,`Union`)&&FM(e.$id)&&lj(e)&&tj(e.anyOf)&&e.anyOf.every(e=>AN(e))}function TN(e){return eN(e,`Uint8Array`)&&e.type===`Uint8Array`&&FM(e.$id)&&NM(e.minByteLength)&&NM(e.maxByteLength)}function EN(e){return eN(e,`Unknown`)&&FM(e.$id)}function DN(e){return eN(e,`Unsafe`)}function ON(e){return eN(e,`Void`)&&e.type===`void`&&FM(e.$id)}function kN(e){return lj(e)&&Z in e&&dj(e[Z])&&!OM.includes(e[Z])}function AN(e){return lj(e)&&(BM(e)||VM(e)||HM(e)||GM(e)||WM(e)||UM(e)||KM(e)||qM(e)||JM(e)||YM(e)||XM(e)||QM(e)||$M(e)||iN(e)||oN(e)||sN(e)||cN(e)||lN(e)||uN(e)||dN(e)||fN(e)||pN(e)||mN(e)||hN(e)||gN(e)||_N(e)||vN(e)||yN(e)||bN(e)||SN(e)||CN(e)||wN(e)||TN(e)||EN(e)||DN(e)||ON(e)||kN(e))}var jN=`(true|false)`,MN=`(0|[1-9][0-9]*)`,NN=`(.*)`,PN=`(?!.*)`;`${jN}`;var FN=`^${MN}$`,IN=`^${NN}$`,LN=`^${PN}$`;function RN(e,t){return e.includes(t)}function zN(e){return[...new Set(e)]}function BN(e,t){return e.filter(e=>t.includes(e))}function VN(e,t){return e.reduce((e,t)=>BN(e,t),t)}function HN(e){return e.length===1?e[0]:e.length>1?VN(e.slice(1),e[0]):[]}function UN(e){let t=[];for(let n of e)t.push(...n);return t}function WN(e){return X({[Z]:`Any`},e)}function GN(e,t){return X({[Z]:`Array`,type:`array`,items:e},t)}function KN(e){return X({[Z]:`Argument`,index:e})}function qN(e,t){return X({[Z]:`AsyncIterator`,type:`AsyncIterator`,items:e},t)}function JN(e,t,n){return X({[Z]:`Computed`,target:e,parameters:t},n)}function YN(e,t){let{[t]:n,...r}=e;return r}function XN(e,t){return t.reduce((e,t)=>YN(e,t),e)}function ZN(e){return X({[Z]:`Never`,not:{}},e)}function QN(e){return X({[Z]:`MappedResult`,properties:e})}function $N(e,t,n){return X({[Z]:`Constructor`,type:`Constructor`,parameters:e,returns:t},n)}function eP(e,t,n){return X({[Z]:`Function`,type:`Function`,parameters:e,returns:t},n)}function tP(e,t){return X({[Z]:`Union`,anyOf:e},t)}function nP(e){return e.some(e=>Bj(e))}function rP(e){return e.map(e=>Bj(e)?iP(e):e)}function iP(e){return XN(e,[Lj])}function aP(e,t){return nP(e)?GF(tP(rP(e),t)):tP(rP(e),t)}function oP(e,t){return e.length===1?X(e[0],t):e.length===0?ZN(t):aP(e,t)}function sP(e,t){return e.length===0?ZN(t):e.length===1?X(e[0],t):tP(e,t)}var cP=class extends Pj{};function lP(e){return e.replace(/\\\$/g,`$`).replace(/\\\*/g,`*`).replace(/\\\^/g,`^`).replace(/\\\|/g,`|`).replace(/\\\(/g,`(`).replace(/\\\)/g,`)`)}function uP(e,t,n){return e[t]===n&&e.charCodeAt(t-1)!==92}function dP(e,t){return uP(e,t,`(`)}function fP(e,t){return uP(e,t,`)`)}function pP(e,t){return uP(e,t,`|`)}function mP(e){if(!(dP(e,0)&&fP(e,e.length-1)))return!1;let t=0;for(let n=0;n<e.length;n++)if(dP(e,n)&&(t+=1),fP(e,n)&&--t,t===0&&n!==e.length-1)return!1;return!0}function hP(e){return e.slice(1,e.length-1)}function gP(e){let t=0;for(let n=0;n<e.length;n++)if(dP(e,n)&&(t+=1),fP(e,n)&&--t,pP(e,n)&&t===0)return!0;return!1}function _P(e){for(let t=0;t<e.length;t++)if(dP(e,t))return!0;return!1}function vP(e){let[t,n]=[0,0],r=[];for(let i=0;i<e.length;i++)if(dP(e,i)&&(t+=1),fP(e,i)&&--t,pP(e,i)&&t===0){let t=e.slice(n,i);t.length>0&&r.push(bP(t)),n=i+1}let i=e.slice(n);return i.length>0&&r.push(bP(i)),r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`or`,expr:r}}function yP(e){function t(e,t){if(!dP(e,t))throw new cP(`TemplateLiteralParser: Index must point to open parens`);let n=0;for(let r=t;r<e.length;r++)if(dP(e,r)&&(n+=1),fP(e,r)&&--n,n===0)return[t,r];throw new cP(`TemplateLiteralParser: Unclosed group parens in expression`)}function n(e,t){for(let n=t;n<e.length;n++)if(dP(e,n))return[t,n];return[t,e.length]}let r=[];for(let i=0;i<e.length;i++)if(dP(e,i)){let[n,a]=t(e,i),o=e.slice(n,a+1);r.push(bP(o)),i=a}else{let[t,a]=n(e,i),o=e.slice(t,a);o.length>0&&r.push(bP(o)),i=a-1}return r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`and`,expr:r}}function bP(e){return mP(e)?bP(hP(e)):gP(e)?vP(e):_P(e)?yP(e):{type:`const`,const:lP(e)}}function xP(e){return bP(e.slice(1,e.length-1))}var SP=class extends Pj{};function CP(e){return e.type===`or`&&e.expr.length===2&&e.expr[0].type===`const`&&e.expr[0].const===`0`&&e.expr[1].type===`const`&&e.expr[1].const===`[1-9][0-9]*`}function wP(e){return e.type===`or`&&e.expr.length===2&&e.expr[0].type===`const`&&e.expr[0].const===`true`&&e.expr[1].type===`const`&&e.expr[1].const===`false`}function TP(e){return e.type===`const`&&e.const===`.*`}function EP(e){return CP(e)||TP(e)?!1:wP(e)?!0:e.type===`and`||e.type===`or`?e.expr.every(e=>EP(e)):e.type===`const`||(()=>{throw new SP(`Unknown expression type`)})()}function DP(e){return EP(xP(e.pattern))}var OP=class extends Pj{};function*kP(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let n of kP(e.slice(1)))yield`${t}${n}`}function*AP(e){return yield*kP(e.expr.map(e=>[...NP(e)]))}function*jP(e){for(let t of e.expr)yield*NP(t)}function*MP(e){return yield e.const}function*NP(e){return e.type===`and`?yield*AP(e):e.type===`or`?yield*jP(e):e.type===`const`?yield*MP(e):(()=>{throw new OP(`Unknown expression`)})()}function PP(e){let t=xP(e.pattern);return EP(t)?[...NP(t)]:[]}function FP(e,t){return X({[Z]:`Literal`,const:e,type:typeof e},t)}function IP(e){return X({[Z]:`Boolean`,type:`boolean`},e)}function LP(e){return X({[Z]:`BigInt`,type:`bigint`},e)}function RP(e){return X({[Z]:`Number`,type:`number`},e)}function zP(e){return X({[Z]:`String`,type:`string`},e)}function*BP(e){let t=e.trim().replace(/"|'/g,``);return t===`boolean`?yield IP():t===`number`?yield RP():t===`bigint`?yield LP():t===`string`?yield zP():yield(()=>{let e=t.split(`|`).map(e=>FP(e.trim()));return e.length===0?ZN():e.length===1?e[0]:oP(e)})()}function*VP(e){if(e[1]!==`{`)return yield*[FP(`$`),...HP(e.slice(1))];for(let t=2;t<e.length;t++)if(e[t]===`}`){let n=BP(e.slice(2,t)),r=HP(e.slice(t+1));return yield*[...n,...r]}yield FP(e)}function*HP(e){for(let t=0;t<e.length;t++)if(e[t]===`$`)return yield*[FP(e.slice(0,t)),...VP(e.slice(t))];yield FP(e)}function UP(e){return[...HP(e)]}var WP=class extends Pj{};function GP(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function KP(e,t){return gM(e)?e.pattern.slice(1,e.pattern.length-1):xM(e)?`(${e.anyOf.map(e=>KP(e,t)).join(`|`)})`:cM(e)||Zj(e)||Gj(e)?`${t}${MN}`:mM(e)?`${t}${NN}`:nM(e)?`${t}${GP(e.const.toString())}`:Kj(e)?`${t}${jN}`:(()=>{throw new WP(`Unexpected Kind '${e[Z]}'`)})()}function qP(e){return`^${e.map(e=>KP(e,``)).join(``)}$`}function JP(e){return oP(PP(e).map(e=>FP(e)))}function YP(e,t){let n=dj(e)?qP(UP(e)):qP(e);return X({[Z]:`TemplateLiteral`,type:`string`,pattern:n},t)}function XP(e){return PP(e).map(e=>e.toString())}function ZP(e){let t=[];for(let n of e)t.push(...$P(n));return t}function QP(e){return[e.toString()]}function $P(e){return[...new Set(gM(e)?XP(e):xM(e)?ZP(e.anyOf):nM(e)?QP(e.const):cM(e)||Zj(e)?[`[number]`]:[])]}function eF(e,t,n){let r={};for(let i of Object.getOwnPropertyNames(t))r[i]=mF(e,$P(t[i]),n);return r}function tF(e,t,n){return eF(e,t.properties,n)}function nF(e,t,n){return QN(tF(e,t,n))}function rF(e,t){return e.map(e=>dF(e,t))}function iF(e){return e.filter(e=>!aM(e))}function aF(e,t){return eI(iF(rF(e,t)))}function oF(e){return e.some(e=>aM(e))?[]:e}function sF(e,t){return oP(oF(rF(e,t)))}function cF(e,t){return t in e?e[t]:t===`[number]`?oP(e):ZN()}function lF(e,t){return t===`[number]`?e:ZN()}function uF(e,t){return t in e?e[t]:ZN()}function dF(e,t){return Qj(e)?aF(e.allOf,t):xM(e)?sF(e.anyOf,t):yM(e)?cF(e.items??[],t):Uj(e)?lF(e.items,t):lM(e)?uF(e.properties,t):ZN()}function fF(e,t){return t.map(t=>dF(e,t))}function pF(e,t){return oP(fF(e,t))}function mF(e,t,n){if(fM(e)||fM(t)){if(!DM(e)||!DM(t))throw new Pj(`Index types using Ref parameters require both Type and Key to be of TSchema`);return JN(`Index`,[e,t])}return iM(t)?nF(e,t,n):rM(t)?vF(e,t,n):X(DM(t)?pF(e,$P(t)):pF(e,t),n)}function hF(e,t,n){return{[t]:mF(e,[t],xj(n))}}function gF(e,t,n){return t.reduce((t,r)=>({...t,...hF(e,r,n)}),{})}function _F(e,t,n){return gF(e,t.keys,n)}function vF(e,t,n){return QN(_F(e,t,n))}function yF(e,t){return X({[Z]:`Iterator`,type:`Iterator`,items:e},t)}function bF(e){return globalThis.Object.keys(e).filter(t=>!Bj(e[t]))}function xF(e,t){let n=bF(e);return X(n.length>0?{[Z]:`Object`,type:`object`,required:n,properties:e}:{[Z]:`Object`,type:`object`,properties:e},t)}var SF=xF;function CF(e,t){return X({[Z]:`Promise`,type:`Promise`,item:e},t)}function wF(e){return X(XN(e,[Ij]))}function TF(e){return X({...e,[Ij]:`Readonly`})}function EF(e,t){return t===!1?wF(e):TF(e)}function DF(e,t){let n=t??!0;return iM(e)?AF(e,n):EF(e,n)}function OF(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=DF(e[r],t);return n}function kF(e,t){return OF(e.properties,t)}function AF(e,t){return QN(kF(e,t))}function jF(e,t){return X(e.length>0?{[Z]:`Tuple`,type:`array`,items:e,additionalItems:!1,minItems:e.length,maxItems:e.length}:{[Z]:`Tuple`,type:`array`,minItems:e.length,maxItems:e.length},t)}function MF(e,t){return e in t?zF(e,t[e]):QN(t)}function NF(e){return{[e]:FP(e)}}function PF(e){let t={};for(let n of e)t[n]=FP(n);return t}function FF(e,t){return RN(t,e)?NF(e):PF(t)}function IF(e,t){return MF(e,FF(e,t))}function LF(e,t){return t.map(t=>zF(e,t))}function RF(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(t))n[r]=zF(e,t[r]);return n}function zF(e,t){let n={...t};return Bj(t)?GF(zF(e,XN(t,[Lj]))):zj(t)?DF(zF(e,XN(t,[Ij]))):iM(t)?MF(e,t.properties):rM(t)?IF(e,t.keys):Jj(t)?$N(LF(e,t.parameters),zF(e,t.returns),n):Xj(t)?eP(LF(e,t.parameters),zF(e,t.returns),n):Wj(t)?qN(zF(e,t.items),n):$j(t)?yF(zF(e,t.items),n):Qj(t)?tI(LF(e,t.allOf),n):xM(t)?sP(LF(e,t.anyOf),n):yM(t)?jF(LF(e,t.items??[]),n):lM(t)?SF(RF(e,t.properties),n):Uj(t)?GN(zF(e,t.items),n):uM(t)?CF(zF(e,t.item),n):t}function BF(e,t){let n={};for(let r of e)n[r]=zF(r,t);return n}function VF(e,t,n){let r=DM(e)?$P(e):e;return SF(BF(r,t({[Z]:`MappedKey`,keys:r})),n)}function HF(e){return X(XN(e,[Lj]))}function UF(e){return X({...e,[Lj]:`Optional`})}function WF(e,t){return t===!1?HF(e):UF(e)}function GF(e,t){let n=t??!0;return iM(e)?JF(e,n):WF(e,n)}function KF(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=GF(e[r],t);return n}function qF(e,t){return KF(e.properties,t)}function JF(e,t){return QN(qF(e,t))}function YF(e,t={}){let n=e.every(e=>lM(e)),r=DM(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return X(t.unevaluatedProperties===!1||DM(t.unevaluatedProperties)||n?{...r,[Z]:`Intersect`,type:`object`,allOf:e}:{...r,[Z]:`Intersect`,allOf:e},t)}function XF(e){return e.every(e=>Bj(e))}function ZF(e){return XN(e,[Lj])}function QF(e){return e.map(e=>Bj(e)?ZF(e):e)}function $F(e,t){return XF(e)?GF(YF(QF(e),t)):YF(QF(e),t)}function eI(e,t={}){if(e.length===1)return X(e[0],t);if(e.length===0)return ZN(t);if(e.some(e=>vM(e)))throw Error(`Cannot intersect transform types`);return $F(e,t)}function tI(e,t){if(e.length===1)return X(e[0],t);if(e.length===0)return ZN(t);if(e.some(e=>vM(e)))throw Error(`Cannot intersect transform types`);return YF(e,t)}function nI(...e){let[t,n]=typeof e[0]==`string`?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=`string`)throw new Pj(`Ref: $ref must be a string`);return X({[Z]:`Ref`,$ref:t},n)}function rI(e,t){return JN(`Awaited`,[JN(e,t)])}function iI(e){return JN(`Awaited`,[nI(e)])}function aI(e){return tI(cI(e))}function oI(e){return sP(cI(e))}function sI(e){return lI(e)}function cI(e){return e.map(e=>lI(e))}function lI(e,t){return X(qj(e)?rI(e.target,e.parameters):Qj(e)?aI(e.allOf):xM(e)?oI(e.anyOf):uM(e)?sI(e.item):fM(e)?iI(e.$ref):e,t)}function uI(e){let t=[];for(let n of e)t.push(_I(n));return t}function dI(e){return UN(uI(e))}function fI(e){return HN(uI(e))}function pI(e){return e.map((e,t)=>t.toString())}function mI(e){return[`[number]`]}function hI(e){return globalThis.Object.getOwnPropertyNames(e)}function gI(e){return vI?globalThis.Object.getOwnPropertyNames(e).map(e=>e[0]===`^`&&e[e.length-1]===`$`?e.slice(1,e.length-1):e):[]}function _I(e){return Qj(e)?dI(e.allOf):xM(e)?fI(e.anyOf):yM(e)?pI(e.items??[]):Uj(e)?mI(e.items):lM(e)?hI(e.properties):dM(e)?gI(e.patternProperties):[]}var vI=!1;function yI(e,t){return JN(`KeyOf`,[JN(e,t)])}function bI(e){return JN(`KeyOf`,[nI(e)])}function xI(e,t){return X(oP(SI(_I(e))),t)}function SI(e){return e.map(e=>e===`[number]`?RP():FP(e))}function CI(e,t){return qj(e)?yI(e.target,e.parameters):fM(e)?bI(e.$ref):iM(e)?EI(e,t):xI(e,t)}function wI(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=CI(e[r],xj(t));return n}function TI(e,t){return wI(e.properties,t)}function EI(e,t){return QN(TI(e,t))}function DI(e){let t=[];for(let n of e)t.push(..._I(n));return zN(t)}function OI(e){return e.filter(e=>!aM(e))}function kI(e,t){let n=[];for(let r of e)n.push(...fF(r,[t]));return OI(n)}function AI(e,t){let n={};for(let r of t)n[r]=eI(kI(e,r));return n}function jI(e,t){return SF(AI(e,DI(e)),t)}function MI(e){return X({[Z]:`Date`,type:`Date`},e)}function NI(e){return X({[Z]:`Null`,type:`null`},e)}function PI(e){return X({[Z]:`Symbol`,type:`symbol`},e)}function FI(e){return X({[Z]:`Undefined`,type:`undefined`},e)}function II(e){return X({[Z]:`Uint8Array`,type:`Uint8Array`},e)}function LI(e){return X({[Z]:`Unknown`},e)}function RI(e){return e.map(e=>VI(e,!1))}function zI(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=DF(VI(e[n],!1));return t}function BI(e,t){return t===!0?e:DF(e)}function VI(e,t){return ej(e)||oj(e)?BI(WN(),t):tj(e)?DF(jF(RI(e))):pj(e)?II():ij(e)?MI():lj(e)?BI(SF(zI(e)),t):aj(e)?BI(eP([],LI()),t):mj(e)?FI():sj(e)?NI():fj(e)?PI():nj(e)?LP():cj(e)||rj(e)||dj(e)?FP(e):SF({})}function HI(e,t){return X(VI(e,!0),t)}function UI(e,t){return Jj(e)?jF(e.parameters,t):ZN(t)}function WI(e,t){if(mj(e))throw Error(`Enum undefined or empty`);let n=globalThis.Object.getOwnPropertyNames(e).filter(e=>isNaN(e)).map(t=>e[t]);return sP([...new Set(n)].map(e=>FP(e)),{...t,[Rj]:`Enum`})}var GI=class extends Pj{},Q;(function(e){e[e.Union=0]=`Union`,e[e.True=1]=`True`,e[e.False=2]=`False`})(Q||={});function KI(e){return e===Q.False?e:Q.True}function qI(e){throw new GI(e)}function JI(e){return cN(e)||QM(e)||wN(e)||EN(e)||BM(e)}function YI(e,t){return cN(t)?pL(e,t):QM(t)?lL(e,t):wN(t)?XL(e,t):EN(t)?QL(e,t):BM(t)?XI(e,t):qI(`StructuralRight`)}function XI(e,t){return Q.True}function ZI(e,t){return QM(t)?lL(e,t):wN(t)&&t.anyOf.some(e=>BM(e)||EN(e))?Q.True:wN(t)?Q.Union:EN(t)||BM(t)?Q.True:Q.Union}function QI(e,t){return EN(e)?Q.False:BM(e)?Q.Union:cN(e)?Q.True:Q.False}function $I(e,t){return fN(t)&&AL(t)?Q.True:JI(t)?YI(e,t):HM(t)?KI(nR(e.items,t.items)):Q.False}function eL(e,t){return JI(t)?YI(e,t):UM(t)?KI(nR(e.items,t.items)):Q.False}function tL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):WM(t)?Q.True:Q.False}function nL(e,t){return rN(e)||GM(e)?Q.True:Q.False}function rL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):GM(t)?Q.True:Q.False}function iL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):qM(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>KI(nR(t.parameters[n],e))===Q.True)?KI(nR(e.returns,t.returns)):Q.False:Q.False}function aL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):JM(t)?Q.True:Q.False}function oL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):YM(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>KI(nR(t.parameters[n],e))===Q.True)?KI(nR(e.returns,t.returns)):Q.False:Q.False}function sL(e,t){return iN(e)&&cj(e.const)||dN(e)||XM(e)?Q.True:Q.False}function cL(e,t){return XM(t)||dN(t)?Q.True:JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):Q.False}function lL(e,t){return t.allOf.every(t=>nR(e,t)===Q.True)?Q.True:Q.False}function uL(e,t){return e.allOf.some(e=>nR(e,t)===Q.True)?Q.True:Q.False}function dL(e,t){return JI(t)?YI(e,t):$M(t)?KI(nR(e.items,t.items)):Q.False}function fL(e,t){return iN(t)&&t.const===e.const?Q.True:JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):_N(t)?VL(e,t):dN(t)?vL(e,t):XM(t)?sL(e,t):GM(t)?nL(e,t):Q.False}function pL(e,t){return Q.False}function mL(e,t){return Q.True}function hL(e){let[t,n]=[e,0];for(;lN(t);)t=t.not,n+=1;return n%2==0?t:LI()}function gL(e,t){return lN(e)?nR(hL(e),t):lN(t)?nR(e,hL(t)):qI(`Invalid fallthrough for Not`)}function _L(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):uN(t)?Q.True:Q.False}function vL(e,t){return nN(e)||dN(e)||XM(e)?Q.True:Q.False}function yL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):XM(t)||dN(t)?Q.True:Q.False}function bL(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function xL(e){return AL(e)}function SL(e){return bL(e,0)||bL(e,1)&&`description`in e.properties&&wN(e.properties.description)&&e.properties.description.anyOf.length===2&&(_N(e.properties.description.anyOf[0])&&CN(e.properties.description.anyOf[1])||_N(e.properties.description.anyOf[1])&&CN(e.properties.description.anyOf[0]))}function CL(e){return bL(e,0)}function wL(e){return bL(e,0)}function TL(e){return bL(e,0)}function EL(e){return bL(e,0)}function DL(e){return AL(e)}function OL(e){let t=RP();return bL(e,0)||bL(e,1)&&`length`in e.properties&&KI(nR(e.properties.length,t))===Q.True}function kL(e){return bL(e,0)}function AL(e){let t=RP();return bL(e,0)||bL(e,1)&&`length`in e.properties&&KI(nR(e.properties.length,t))===Q.True}function jL(e){let t=eP([WN()],WN());return bL(e,0)||bL(e,1)&&`then`in e.properties&&KI(nR(e.properties.then,t))===Q.True}function ML(e,t){return nR(e,t)===Q.False||zM(e)&&!zM(t)?Q.False:Q.True}function NL(e,t){return EN(e)?Q.False:BM(e)?Q.Union:cN(e)||tN(e)&&xL(t)||nN(e)&&CL(t)||rN(e)&&wL(t)||vN(e)&&SL(t)||WM(e)&&TL(t)||_N(e)&&xL(t)||vN(e)&&SL(t)||dN(e)&&CL(t)||XM(e)&&CL(t)||GM(e)&&wL(t)||TN(e)&&DL(t)||JM(e)&&EL(t)||qM(e)&&kL(t)||YM(e)&&OL(t)?Q.True:mN(e)&&_N(IL(e))?t[Rj]===`Record`?Q.True:Q.False:mN(e)&&dN(IL(e))&&bL(t,0)?Q.True:Q.False}function PL(e,t){return JI(t)?YI(e,t):mN(t)?RL(e,t):fN(t)?(()=>{for(let n of Object.getOwnPropertyNames(t.properties)){if(!(n in e.properties)&&!zM(t.properties[n]))return Q.False;if(zM(t.properties[n]))return Q.True;if(ML(e.properties[n],t.properties[n])===Q.False)return Q.False}return Q.True})():Q.False}function FL(e,t){return JI(t)?YI(e,t):fN(t)&&jL(t)?Q.True:pN(t)?KI(nR(e.item,t.item)):Q.False}function IL(e){return FN in e.patternProperties?RP():IN in e.patternProperties?zP():qI(`Unknown record key pattern`)}function LL(e){return FN in e.patternProperties?e.patternProperties[FN]:IN in e.patternProperties?e.patternProperties[IN]:qI(`Unable to get record value schema`)}function RL(e,t){let[n,r]=[IL(t),LL(t)];return tN(e)&&dN(n)&&KI(nR(e,r))===Q.True?Q.True:TN(e)&&dN(n)||_N(e)&&dN(n)||HM(e)&&dN(n)?nR(e,r):fN(e)?(()=>{for(let t of Object.getOwnPropertyNames(e.properties))if(ML(r,e.properties[t])===Q.False)return Q.False;return Q.True})():Q.False}function zL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?nR(LL(e),LL(t)):Q.False}function BL(e,t){return nR(gN(e)?zP():e,gN(t)?zP():t)}function VL(e,t){return iN(e)&&dj(e.const)||_N(e)?Q.True:Q.False}function HL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):_N(t)?Q.True:Q.False}function UL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):vN(t)?Q.True:Q.False}function WL(e,t){return yN(e)?nR(JP(e),t):yN(t)?nR(e,JP(t)):qI(`Invalid fallthrough for TemplateLiteral`)}function GL(e,t){return HM(t)&&e.items!==void 0&&e.items.every(e=>nR(e,t.items)===Q.True)}function KL(e,t){return cN(e)?Q.True:EN(e)?Q.False:BM(e)?Q.Union:Q.False}function qL(e,t){return JI(t)?YI(e,t):fN(t)&&AL(t)||HM(t)&&GL(e,t)?Q.True:SN(t)?mj(e.items)&&!mj(t.items)||!mj(e.items)&&mj(t.items)?Q.False:mj(e.items)&&!mj(t.items)||e.items.every((e,n)=>nR(e,t.items[n])===Q.True)?Q.True:Q.False:Q.False}function JL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):TN(t)?Q.True:Q.False}function YL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):ON(t)?eR(e,t):CN(t)?Q.True:Q.False}function XL(e,t){return t.anyOf.some(t=>nR(e,t)===Q.True)?Q.True:Q.False}function ZL(e,t){return e.anyOf.every(e=>nR(e,t)===Q.True)?Q.True:Q.False}function QL(e,t){return Q.True}function $L(e,t){return cN(t)?pL(e,t):QM(t)?lL(e,t):wN(t)?XL(e,t):BM(t)?XI(e,t):_N(t)?VL(e,t):dN(t)?vL(e,t):XM(t)?sL(e,t):GM(t)?nL(e,t):HM(t)?QI(e,t):SN(t)?KL(e,t):fN(t)?NL(e,t):EN(t)?Q.True:Q.False}function eR(e,t){return CN(e)||CN(e)?Q.True:Q.False}function tR(e,t){return QM(t)?lL(e,t):wN(t)?XL(e,t):EN(t)?QL(e,t):BM(t)?XI(e,t):fN(t)?NL(e,t):ON(t)?Q.True:Q.False}function nR(e,t){return yN(e)||yN(t)?WL(e,t):gN(e)||gN(t)?BL(e,t):lN(e)||lN(t)?gL(e,t):BM(e)?ZI(e,t):HM(e)?$I(e,t):WM(e)?tL(e,t):GM(e)?rL(e,t):UM(e)?eL(e,t):qM(e)?iL(e,t):JM(e)?aL(e,t):YM(e)?oL(e,t):XM(e)?cL(e,t):QM(e)?uL(e,t):$M(e)?dL(e,t):iN(e)?fL(e,t):cN(e)?mL(e,t):uN(e)?_L(e,t):dN(e)?yL(e,t):fN(e)?PL(e,t):mN(e)?zL(e,t):_N(e)?HL(e,t):vN(e)?UL(e,t):SN(e)?qL(e,t):pN(e)?FL(e,t):TN(e)?JL(e,t):CN(e)?YL(e,t):wN(e)?ZL(e,t):EN(e)?$L(e,t):ON(e)?tR(e,t):qI(`Unknown left type operand '${e[Z]}'`)}function rR(e,t){return nR(e,t)}function iR(e,t,n,r,i){let a={};for(let o of globalThis.Object.getOwnPropertyNames(e))a[o]=cR(e[o],t,n,r,xj(i));return a}function aR(e,t,n,r,i){return iR(e.properties,t,n,r,i)}function oR(e,t,n,r,i){return QN(aR(e,t,n,r,i))}function sR(e,t,n,r){let i=rR(e,t);return i===Q.Union?sP([n,r]):i===Q.True?n:r}function cR(e,t,n,r,i){return iM(e)?oR(e,t,n,r,i):rM(e)?X(fR(e,t,n,r,i)):X(sR(e,t,n,r),i)}function lR(e,t,n,r,i){return{[e]:cR(FP(e),t,n,r,xj(i))}}function uR(e,t,n,r,i){return e.reduce((e,a)=>({...e,...lR(a,t,n,r,i)}),{})}function dR(e,t,n,r,i){return uR(e.keys,t,n,r,i)}function fR(e,t,n,r,i){return QN(dR(e,t,n,r,i))}function pR(e,t){return hR(JP(e),t)}function mR(e,t){let n=e.filter(e=>rR(e,t)===Q.False);return n.length===1?n[0]:sP(n)}function hR(e,t,n={}){return gM(e)?X(pR(e,t),n):iM(e)?X(vR(e,t),n):X(xM(e)?mR(e.anyOf,t):rR(e,t)===Q.False?e:ZN(),n)}function gR(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=hR(e[r],t);return n}function _R(e,t){return gR(e.properties,t)}function vR(e,t){return QN(_R(e,t))}function yR(e,t){return xR(JP(e),t)}function bR(e,t){let n=e.filter(e=>rR(e,t)!==Q.False);return n.length===1?n[0]:sP(n)}function xR(e,t,n){return gM(e)?X(yR(e,t),n):iM(e)?X(wR(e,t),n):X(xM(e)?bR(e.anyOf,t):rR(e,t)===Q.False?ZN():e,n)}function SR(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=xR(e[r],t);return n}function CR(e,t){return SR(e.properties,t)}function wR(e,t){return QN(CR(e,t))}function TR(e,t){return Jj(e)?X(e.returns,t):ZN(t)}function ER(e){return DF(GF(e))}function DR(e,t,n){return X({[Z]:`Record`,type:`object`,patternProperties:{[e]:t}},n)}function OR(e,t,n){let r={};for(let n of e)r[n]=t;return SF(r,{...n,[Rj]:`Record`})}function kR(e,t,n){return DP(e)?OR($P(e),t,n):DR(e.pattern,t,n)}function AR(e,t,n){return OR($P(sP(e)),t,n)}function jR(e,t,n){return OR([e.toString()],t,n)}function MR(e,t,n){return DR(e.source,t,n)}function NR(e,t,n){return DR(mj(e.pattern)?IN:e.pattern,t,n)}function PR(e,t,n){return DR(IN,t,n)}function FR(e,t,n){return DR(LN,t,n)}function IR(e,t,n){return SF({true:t,false:t},n)}function LR(e,t,n){return DR(FN,t,n)}function RR(e,t,n){return DR(FN,t,n)}function zR(e,t,n={}){return xM(e)?AR(e.anyOf,t,n):gM(e)?kR(e,t,n):nM(e)?jR(e.const,t,n):Kj(e)?IR(e,t,n):Zj(e)?LR(e,t,n):cM(e)?RR(e,t,n):pM(e)?MR(e,t,n):mM(e)?NR(e,t,n):Vj(e)?PR(e,t,n):aM(e)?FR(e,t,n):ZN(n)}function BR(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function VR(e){let t=BR(e);return t===IN?zP():t===FN?RP():zP({pattern:t})}function HR(e){return e.patternProperties[BR(e)]}function UR(e,t){return t.parameters=rz(e,t.parameters),t.returns=iz(e,t.returns),t}function WR(e,t){return t.parameters=rz(e,t.parameters),t.returns=iz(e,t.returns),t}function GR(e,t){return t.allOf=rz(e,t.allOf),t}function KR(e,t){return t.anyOf=rz(e,t.anyOf),t}function qR(e,t){return mj(t.items)||(t.items=rz(e,t.items)),t}function JR(e,t){return t.items=iz(e,t.items),t}function YR(e,t){return t.items=iz(e,t.items),t}function XR(e,t){return t.items=iz(e,t.items),t}function ZR(e,t){return t.item=iz(e,t.item),t}function QR(e,t){let n=nz(e,t.properties);return{...t,...SF(n)}}function $R(e,t){let n=zR(iz(e,VR(t)),iz(e,HR(t)));return{...t,...n}}function ez(e,t){return t.index in e?e[t.index]:LI()}function tz(e,t){let n=zj(t),r=Bj(t),i=iz(e,t);return n&&r?ER(i):n&&!r?DF(i):!n&&r?GF(i):i}function nz(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((n,r)=>({...n,[r]:tz(e,t[r])}),{})}function rz(e,t){return t.map(t=>iz(e,t))}function iz(e,t){return Jj(t)?UR(e,t):Xj(t)?WR(e,t):Qj(t)?GR(e,t):xM(t)?KR(e,t):yM(t)?qR(e,t):Uj(t)?JR(e,t):Wj(t)?YR(e,t):$j(t)?XR(e,t):uM(t)?ZR(e,t):lM(t)?QR(e,t):dM(t)?$R(e,t):Hj(t)?ez(e,t):t}function az(e,t){return iz(t,Sj(e))}function oz(e){return X({[Z]:`Integer`,type:`integer`},e)}function sz(e,t,n){return{[e]:vz(FP(e),t,xj(n))}}function cz(e,t,n){return e.reduce((e,r)=>({...e,...sz(r,t,n)}),{})}function lz(e,t,n){return cz(e.keys,t,n)}function uz(e,t,n){return QN(lz(e,t,n))}function dz(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),n].join(``)}function fz(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),n].join(``)}function pz(e){return e.toUpperCase()}function mz(e){return e.toLowerCase()}function hz(e,t,n){let r=xP(e.pattern);return EP(r)?YP([sP(_z([...NP(r)].map(e=>FP(e)),t))],n):{...e,pattern:gz(e.pattern,t)}}function gz(e,t){return typeof e==`string`?t===`Uncapitalize`?dz(e):t===`Capitalize`?fz(e):t===`Uppercase`?pz(e):t===`Lowercase`?mz(e):e:e.toString()}function _z(e,t){return e.map(e=>vz(e,t))}function vz(e,t,n={}){return rM(e)?uz(e,t,n):gM(e)?hz(e,t,n):xM(e)?sP(_z(e.anyOf,t),n):nM(e)?FP(gz(e.const,t),n):X(e,n)}function yz(e,t={}){return vz(e,`Capitalize`,t)}function bz(e,t={}){return vz(e,`Lowercase`,t)}function xz(e,t={}){return vz(e,`Uncapitalize`,t)}function Sz(e,t={}){return vz(e,`Uppercase`,t)}function Cz(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=Nz(e[i],t,xj(n));return r}function wz(e,t,n){return Cz(e.properties,t,n)}function Tz(e,t,n){return QN(wz(e,t,n))}function Ez(e,t){return e.map(e=>Mz(e,t))}function Dz(e,t){return e.map(e=>Mz(e,t))}function Oz(e,t){let{[t]:n,...r}=e;return r}function kz(e,t){return t.reduce((e,t)=>Oz(e,t),e)}function Az(e,t,n){let r=XN(e,[Fj,`$id`,`required`,`properties`]);return SF(kz(n,t),r)}function jz(e){return sP(e.reduce((e,t)=>tM(t)?[...e,FP(t)]:e,[]))}function Mz(e,t){return Qj(e)?tI(Ez(e.allOf,t)):xM(e)?sP(Dz(e.anyOf,t)):lM(e)?Az(e,t,e.properties):SF({})}function Nz(e,t,n){let r=tj(t)?jz(t):t,i=DM(t)?$P(t):t,a=fM(e),o=fM(t);return iM(e)?Tz(e,i,n):rM(t)?Lz(e,t,n):a&&o||!a&&o||a&&!o?JN(`Omit`,[e,r],n):X({...Mz(e,i),...n})}function Pz(e,t,n){return{[t]:Nz(e,[t],xj(n))}}function Fz(e,t,n){return t.reduce((t,r)=>({...t,...Pz(e,r,n)}),{})}function Iz(e,t,n){return Fz(e,t.keys,n)}function Lz(e,t,n){return QN(Iz(e,t,n))}function Rz(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=qz(e[i],t,xj(n));return r}function zz(e,t,n){return Rz(e.properties,t,n)}function Bz(e,t,n){return QN(zz(e,t,n))}function Vz(e,t){return e.map(e=>Kz(e,t))}function Hz(e,t){return e.map(e=>Kz(e,t))}function Uz(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function Wz(e,t,n){let r=XN(e,[Fj,`$id`,`required`,`properties`]);return SF(Uz(n,t),r)}function Gz(e){return sP(e.reduce((e,t)=>tM(t)?[...e,FP(t)]:e,[]))}function Kz(e,t){return Qj(e)?tI(Vz(e.allOf,t)):xM(e)?sP(Hz(e.anyOf,t)):lM(e)?Wz(e,t,e.properties):SF({})}function qz(e,t,n){let r=tj(t)?Gz(t):t,i=DM(t)?$P(t):t,a=fM(e),o=fM(t);return iM(e)?Bz(e,i,n):rM(t)?Zz(e,t,n):a&&o||!a&&o||a&&!o?JN(`Pick`,[e,r],n):X({...Kz(e,i),...n})}function Jz(e,t,n){return{[t]:qz(e,[t],xj(n))}}function Yz(e,t,n){return t.reduce((t,r)=>({...t,...Jz(e,r,n)}),{})}function Xz(e,t,n){return Yz(e,t.keys,n)}function Zz(e,t,n){return QN(Xz(e,t,n))}function Qz(e,t){return JN(`Partial`,[JN(e,t)])}function $z(e){return JN(`Partial`,[nI(e)])}function eB(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=GF(e[n]);return t}function tB(e,t){let n=XN(e,[Fj,`$id`,`required`,`properties`]);return SF(eB(t),n)}function nB(e){return e.map(e=>rB(e))}function rB(e){return qj(e)?Qz(e.target,e.parameters):fM(e)?$z(e.$ref):Qj(e)?tI(nB(e.allOf)):xM(e)?sP(nB(e.anyOf)):lM(e)?tB(e,e.properties):Gj(e)||Kj(e)||Zj(e)||nM(e)||sM(e)||cM(e)||mM(e)||hM(e)||bM(e)?e:SF({})}function iB(e,t){return iM(e)?sB(e,t):X({...rB(e),...t})}function aB(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=iB(e[r],xj(t));return n}function oB(e,t){return aB(e.properties,t)}function sB(e,t){return QN(oB(e,t))}function cB(e,t){return JN(`Required`,[JN(e,t)])}function lB(e){return JN(`Required`,[nI(e)])}function uB(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=XN(e[n],[Lj]);return t}function dB(e,t){let n=XN(e,[Fj,`$id`,`required`,`properties`]);return SF(uB(t),n)}function fB(e){return e.map(e=>pB(e))}function pB(e){return qj(e)?cB(e.target,e.parameters):fM(e)?lB(e.$ref):Qj(e)?tI(fB(e.allOf)):xM(e)?sP(fB(e.anyOf)):lM(e)?dB(e,e.properties):Gj(e)||Kj(e)||Zj(e)||nM(e)||sM(e)||cM(e)||mM(e)||hM(e)||bM(e)?e:SF({})}function mB(e,t){return iM(e)?_B(e,t):X({...pB(e),...t})}function hB(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=mB(e[r],t);return n}function gB(e,t){return hB(e.properties,t)}function _B(e,t){return QN(gB(e,t))}function vB(e,t){return t.map(t=>fM(t)?yB(e,t.$ref):BB(e,t))}function yB(e,t){return t in e?fM(e[t])?yB(e,e[t].$ref):BB(e,e[t]):ZN()}function bB(e){return lI(e[0])}function xB(e){return mF(e[0],e[1])}function SB(e){return CI(e[0])}function CB(e){return iB(e[0])}function wB(e){return Nz(e[0],e[1])}function TB(e){return qz(e[0],e[1])}function EB(e){return mB(e[0])}function DB(e,t,n){let r=vB(e,n);return t===`Awaited`?bB(r):t===`Index`?xB(r):t===`KeyOf`?SB(r):t===`Partial`?CB(r):t===`Omit`?wB(r):t===`Pick`?TB(r):t===`Required`?EB(r):ZN()}function OB(e,t){return GN(BB(e,t))}function kB(e,t){return qN(BB(e,t))}function AB(e,t,n){return $N(zB(e,t),BB(e,n))}function jB(e,t,n){return eP(zB(e,t),BB(e,n))}function MB(e,t){return tI(zB(e,t))}function NB(e,t){return yF(BB(e,t))}function PB(e,t){return SF(globalThis.Object.keys(t).reduce((n,r)=>({...n,[r]:BB(e,t[r])}),{}))}function FB(e,t){let[n,r]=[BB(e,HR(t)),BR(t)],i=Sj(t);return i.patternProperties[r]=n,i}function IB(e,t){return fM(t)?{...yB(e,t.$ref),[Fj]:t[Fj]}:t}function LB(e,t){return jF(zB(e,t))}function RB(e,t){return sP(zB(e,t))}function zB(e,t){return t.map(t=>BB(e,t))}function BB(e,t){return Bj(t)?X(BB(e,XN(t,[Lj])),t):zj(t)?X(BB(e,XN(t,[Ij])),t):vM(t)?X(IB(e,t),t):Uj(t)?X(OB(e,t.items),t):Wj(t)?X(kB(e,t.items),t):qj(t)?X(DB(e,t.target,t.parameters)):Jj(t)?X(AB(e,t.parameters,t.returns),t):Xj(t)?X(jB(e,t.parameters,t.returns),t):Qj(t)?X(MB(e,t.allOf),t):$j(t)?X(NB(e,t.items),t):lM(t)?X(PB(e,t.properties),t):dM(t)?X(FB(e,t)):yM(t)?X(LB(e,t.items||[]),t):xM(t)?X(RB(e,t.anyOf),t):t}function VB(e,t){return t in e?BB(e,e[t]):ZN()}function HB(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:VB(e,n)}),{})}var UB=class{constructor(e){let t=HB(e),n=this.WithIdentifiers(t);this.$defs=n}Import(e,t){let n={...this.$defs,[e]:X(this.$defs[e],t)};return X({[Z]:`Import`,$defs:n,$ref:e})}WithIdentifiers(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:{...e[n],$id:n}}),{})}};function WB(e){return new UB(e)}function GB(e,t){return X({[Z]:`Not`,not:e},t)}function KB(e,t){return Xj(e)?jF(e.parameters,t):ZN()}var qB=0;function JB(e,t={}){mj(t.$id)&&(t.$id=`T${qB++}`);let n=Sj(e({[Z]:`This`,$ref:`${t.$id}`}));return n.$id=t.$id,X({[Rj]:`Recursive`,...n},t)}function YB(e,t){let n=dj(e)?new globalThis.RegExp(e):e;return X({[Z]:`RegExp`,type:`RegExp`,source:n.source,flags:n.flags},t)}function XB(e){return Qj(e)?e.allOf:xM(e)?e.anyOf:yM(e)?e.items??[]:[]}function ZB(e){return XB(e)}function QB(e,t){return Xj(e)?X(e.returns,t):ZN(t)}var $B=class{constructor(e){this.schema=e}Decode(e){return new eV(this.schema,e)}},eV=class{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let n={Encode:n=>t[Fj].Encode(e(n)),Decode:e=>this.decode(t[Fj].Decode(e))};return{...t,[Fj]:n}}EncodeSchema(e,t){let n={Decode:this.decode,Encode:e};return{...t,[Fj]:n}}Encode(e){return vM(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}};function tV(e){return new $B(e)}function nV(e={}){return X({[Z]:e[Z]??`Unsafe`},e)}function rV(e){return X({[Z]:`Void`,type:`void`},e)}var $=t({Any:()=>WN,Argument:()=>KN,Array:()=>GN,AsyncIterator:()=>qN,Awaited:()=>lI,BigInt:()=>LP,Boolean:()=>IP,Capitalize:()=>yz,Composite:()=>jI,Const:()=>HI,Constructor:()=>$N,ConstructorParameters:()=>UI,Date:()=>MI,Enum:()=>WI,Exclude:()=>hR,Extends:()=>cR,Extract:()=>xR,Function:()=>eP,Index:()=>mF,InstanceType:()=>TR,Instantiate:()=>az,Integer:()=>oz,Intersect:()=>tI,Iterator:()=>yF,KeyOf:()=>CI,Literal:()=>FP,Lowercase:()=>bz,Mapped:()=>VF,Module:()=>WB,Never:()=>ZN,Not:()=>GB,Null:()=>NI,Number:()=>RP,Object:()=>SF,Omit:()=>Nz,Optional:()=>GF,Parameters:()=>KB,Partial:()=>iB,Pick:()=>qz,Promise:()=>CF,Readonly:()=>DF,ReadonlyOptional:()=>ER,Record:()=>zR,Recursive:()=>JB,Ref:()=>nI,RegExp:()=>YB,Required:()=>mB,Rest:()=>ZB,ReturnType:()=>QB,String:()=>zP,Symbol:()=>PI,TemplateLiteral:()=>YP,Transform:()=>tV,Tuple:()=>jF,Uint8Array:()=>II,Uncapitalize:()=>xz,Undefined:()=>FI,Union:()=>sP,Unknown:()=>LI,Unsafe:()=>nV,Uppercase:()=>Sz,Void:()=>rV}),iV={additionalProperties:!1},aV=$.String({pattern:`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`,minLength:36,maxLength:36}),oV=$.String({pattern:`^[a-z0-9][a-z0-9-]{0,31}(?![\\s\\S])`,minLength:1,maxLength:32}),sV=$.String({pattern:`^sha256:[0-9a-f]{64}$`,minLength:71,maxLength:71}),cV=$.String({pattern:`^[A-Za-z0-9_-]{43}$`,minLength:43,maxLength:43}),lV=$.String({pattern:`^dpt_[A-Za-z0-9_-]{43}$`,minLength:47,maxLength:47}),uV=`[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}`,dV=`^(?:${uV}|[A-Z2-7]{12}|[A-Z2-7]{8})(?![\\s\\S])`,fV=$.String({pattern:dV,minLength:8,maxLength:36}),pV=new RegExp(dV),mV=/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/;function hV(e){return typeof e!=`string`||e.length>36?!1:pV.test(e)}function gV(e){if(typeof e!=`string`)return;if(mV.test(e)){let t=e.toLowerCase();return hV(t)?t:void 0}let t=e.replace(/[\s-]+/g,``).toUpperCase();if(hV(t)&&!(/[\s-]/.test(e)&&t.length!==12))return t}$.Object({type:$.Literal(`pair.request`),v:$.Literal(1),requestId:aV,code:fV,deviceUid:aV,deviceName:$.String({minLength:1,maxLength:64}),hostname:$.Optional($.String({minLength:1,maxLength:128})),platform:$.Optional($.String({minLength:1,maxLength:64})),publicKey:$.String({minLength:1,maxLength:256}),keyFingerprint:sV,clientTime:$.Integer(),hubNonce:$.Optional(cV)},iV),$.Object({type:$.Literal(`pair.device-request`),v:$.Literal(1),requestId:aV,deviceUid:aV,deviceName:$.String({minLength:1,maxLength:64}),hostname:$.Optional($.String({minLength:1,maxLength:128})),platform:$.Optional($.String({minLength:1,maxLength:64})),publicKey:$.String({minLength:1,maxLength:256}),keyFingerprint:sV,clientTime:$.Integer(),hubNonce:$.Optional(cV)},iV);var _V=$.Object({type:$.Literal(`pair.challenge`),v:$.Literal(1),enrollmentId:aV,nonce:cV,issuedAt:$.Integer(),hubId:aV,hubPublicKey:$.Optional($.String({minLength:1,maxLength:256})),hubKeyFingerprint:$.Optional(sV),hubSignature:$.Optional($.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86}))},iV);$.Object({type:$.Literal(`pair.device-ack`),v:$.Literal(1),codeId:aV,code:fV,expiresAt:$.Integer(),hubOrigin:$.String(),hubId:aV,challenge:_V},iV),$.Object({type:$.Literal(`pair.response`),v:$.Literal(1),enrollmentId:aV,nonce:cV,signature:$.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86})},iV),$.Object({type:$.Literal(`pair.pending`),v:$.Literal(1),enrollmentId:aV,state:$.Literal(`awaiting_approval`),expiresAt:$.Integer(),pollAfterMs:$.Integer({minimum:1})},iV),$.Object({type:$.Literal(`pair.token`),v:$.Literal(1),enrollmentId:aV,deviceUid:aV,deviceId:oV,pairingEpoch:aV,credentialId:aV,generation:$.Integer({minimum:1}),hubId:aV,hubOrigin:$.String(),hubUrl:$.String(),tunnelToken:lV,issuedAt:$.Integer(),expiresAt:$.Null(),hubKeyFingerprint:$.Optional(sV)},iV),$.Object({enrollmentId:aV,deviceUid:aV,keyFingerprint:sV,replaceKey:$.Optional($.Boolean())},iV),$.Object({type:$.Literal(`pair.revoke`),v:$.Literal(1),deviceId:oV,pairingEpoch:aV,reason:$.Union([$.Literal(`user`),$.Literal(`compromise`),$.Literal(`hub_migrated`)]),revokedAt:$.Integer()},iV);var vV=$.Object({type:$.Literal(`pair.error`),v:$.Literal(1),code:$.Union([$.Literal(`code_invalid`),$.Literal(`code_expired`),$.Literal(`code_used`),$.Literal(`code_in_use`),$.Literal(`rate_limited`),$.Literal(`signature_invalid`),$.Literal(`clock_skew`),$.Literal(`paired_elsewhere`),$.Literal(`hub_required`),$.Literal(`fingerprint_mismatch`),$.Literal(`identity_conflict`),$.Literal(`enrollment_lost`),$.Literal(`enrollment_cancelled`),$.Literal(`already_issued`),$.Literal(`challenge_expired`)]),message:$.String({maxLength:512}),retryAfterMs:$.Optional($.Integer({minimum:1}))},iV);$.Object({type:$.Literal(`pair.code`),v:$.Literal(1),codeId:aV,code:fV,expiresAt:$.Integer(),hubOrigin:$.String({maxLength:2048}),pairUrl:$.String({maxLength:4096}),offerUrl:$.Optional($.String({maxLength:2048}))},iV);var yV=$.Union([$.Literal(`open`),$.Literal(`awaiting_proof`),$.Literal(`awaiting_approval`),$.Literal(`approved`),$.Literal(`issued`),$.Literal(`connected`),$.Literal(`cancelled`),$.Literal(`expired`)]);$.Object({type:$.Literal(`pair.code-state`),v:$.Literal(1),codeId:aV,expiresAt:$.Integer(),phase:yV,enrollment:$.Optional($.Object({enrollmentId:aV,deviceUid:aV,deviceName:$.String({minLength:1,maxLength:64}),keyFingerprint:sV,proofVerified:$.Boolean(),keyChanged:$.Boolean()},iV)),deviceId:$.Optional(oV),error:$.Optional(vV)},iV);function bV(e){if(typeof e!=`string`||e.length===0||e.length>2048)return{ok:!1,error:`origin: empty or too long`};if(/\s|\n|\r|\t/.test(e))return{ok:!1,error:`origin: whitespace not allowed`};let t;try{t=new URL(e)}catch{return{ok:!1,error:`origin: not a valid URL`}}return t.protocol!==`https:`&&!(t.protocol===`http:`&&/^(127\.0\.0\.1|\[::1\]|localhost)$/.test(t.hostname))?{ok:!1,error:`origin: HTTPS origin required`}:t.username||t.password?{ok:!1,error:`origin: userinfo not allowed`}:t.search||t.hash?{ok:!1,error:`origin: query/fragment not allowed`}:t.pathname!==`/`&&t.pathname!==``?{ok:!1,error:`origin: base path not allowed`}:{ok:!0,origin:t.origin,tunnelUrl:`${t.origin}/api/tunnel`}}function xV(e){if(e!==``&&/^[A-Za-z0-9_-]+$/.test(e))try{let t=atob(e.replace(/-/g,`+`).replace(/_/g,`/`)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch{return}}var SV=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,CV=RegExp(`^${uV}$`),wV=/^sha256:[0-9a-f]{64}$/;function TV(e){let t=xV(e);if(!t||t.length>1024)return;let n;try{n=JSON.parse(new TextDecoder().decode(t))}catch{return}if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n;if(r.v!==2&&r.v!==3)return;let i=r.v===3?6:5;if(Object.keys(r).length!==i||typeof r.hub!=`string`)return;let a=bV(r.hub);if(a.ok&&a.origin===r.hub&&typeof r.id==`string`&&SV.test(r.id)&&typeof r.code==`string`&&CV.test(r.code)&&typeof r.exp==`number`&&Number.isSafeInteger(r.exp))return r.v===3?typeof r.kfp!=`string`||!wV.test(r.kfp)?void 0:{v:3,hub:r.hub,id:r.id,code:r.code,exp:r.exp,kfp:r.kfp}:{v:2,hub:r.hub,id:r.id,code:r.code,exp:r.exp}}function EV(e,t=Date.now()){let n=TV(e);if(n&&!(n.exp<t-3e4)&&!(n.exp>t+6e5))return n}function DV(e,t=Date.now()){let n;try{n=new URL(e)}catch{return}if(!/^\/pair\/?$/.test(n.pathname)||n.username||n.password||n.search||!n.hash.startsWith(`#offer=`))return;let r=EV(n.hash.slice(7),t);if(r&&r.hub===n.origin)return{offer:r,rest:`${n.origin}/pair`}}function OV(e){if(!/^\/pair\/?$/.test(e.pathname))return;if(e.hash.startsWith(`#offer=`)){let t=DV(e.href);if(t)return{code:t.offer.code,origin:e.origin,offerFragment:e.hash.slice(1)};let n=EV(e.hash.slice(7));return n&&n.hub!==e.origin?{error:`This pairing link does not belong to this hub. Open the original hub link instead.`}:{error:`Invalid pairing link. Use a complete link from the hub wizard.`}}let t=e.searchParams;if(!t.has(`code`)&&!t.has(`origin`)&&!t.has(`v`))return;let n=t.get(`code`),r=n===null?void 0:gV(n);if(e.username||e.password||e.hash||t.getAll(`code`).length!==1||!r||t.getAll(`v`).length!==1||t.get(`v`)!==`1`)return{error:`Invalid pairing link. Use a complete version 1 link from the hub wizard.`};if(t.has(`origin`))try{let n=new URL(t.get(`origin`));if(t.getAll(`origin`).length!==1||n.origin!==e.origin||n.pathname!==`/`||n.username||n.password||n.search||n.hash)throw Error(`origin mismatch`)}catch{return{error:`This pairing link does not belong to this hub. Open the original hub link instead.`}}return{code:r,origin:e.origin}}var kV=e=>/^\/pair\/?$/.test(e.pathname)?`/`:void 0,AV=e=>/^\/pair\/?$/.test(e.pathname)&&OV(e)===void 0?`/`:void 0,jV=4e3;async function MV(e){if(!e.needsCancel)return{closed:!0,confirmed:!0};let t,n=await Promise.race([e.cancel().catch(()=>`failed`),new Promise(n=>t=setTimeout(()=>n(`failed`),e.timeoutMs))]);return clearTimeout(t),{closed:n!==`issued`,confirmed:n===`cancelled`}}var NV={class:`modal pair-wizard`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pair-title`},PV={key:1,class:`pair-pending`,"aria-label":`Machines waiting for approval`},FV={class:`who`},IV={key:0,class:`muted`},LV={key:1,class:`muted`},RV={class:`fp`},zV={class:`row`},BV={class:`phase`},VV=[`onClick`],HV={key:2,class:`hint`},UV={class:`pair-steps`,"aria-label":`Pairing progress`},WV={class:`pair-grid`},GV={class:`pair-code-box`},KV={class:`pair-code`,"aria-label":`Pairing code`},qV={class:`pair-copy-actions`},JV=[`innerHTML`],YV={class:`pair-side`},XV={key:0,class:`hint`},ZV={class:`pair-fingerprint`},QV={class:`fp`},$V={class:`pair-confirm`},eH={key:0,class:`pair-confirm warn`},tH=[`disabled`],nH=[`disabled`],rH={class:`hint`},iH=[`disabled`],aH={key:5,class:`error`,role:`alert`},oH={key:4},sH={class:`error`,role:`alert`},cH=Er({__name:`PairDeviceWizard`,props:{handoff:{}},emits:[`close`],setup(e,{expose:t,emit:n}){let r=n,i=e,a=A(`boot`),o=A(),s=A(),c=A(),l=A(``),u=A(!1),d=A(!1),f=A(!1),p=A(!1),m=A(!1),h=A(!1),g=A(),_=A([]),v=U(()=>{let e=s.value?.code??``;return!hV(e)||e.includes(`-`)?e:(e.match(/.{4}/g)??[]).join(`-`)}),y=U(()=>s.value?Ib(s.value):``),b=U(()=>y.value?KA(y.value,148):``),x=U(()=>c.value?.enrollment?.keyFingerprint??``),S=U(()=>c.value?.deviceId??``);N(S,e=>{g.value?.(),e&&(g.value=N(()=>Ju.devices.value.find(t=>t.id===e)?.status,e=>{e===`online`&&(Y(`Device paired and online.`),g.value?.(),g.value=void 0)},{immediate:!0}))});async function C(e){a.value=`boot`,l.value=``,f.value=!1,p.value=!1,c.value=void 0,s.value=void 0,o.value?.close();let t=zb();o.value=t;try{let n=e?await Lb.resolveCode(e):await Lb.createCode();if(t.closed()){await Lb.cancel(n.codeId).catch(()=>{Y(`The late pairing code could not be cancelled. Check device credentials before retrying.`)});return}if(s.value=n,a.value=`code`,e){let e=kV(new URL(window.location.href));e&&window.history.replaceState(window.history.state,``,e)}Hb(t,n.codeId,{intervalMs:1e3,onState:e=>{c.value=e,e.phase===`awaiting_proof`?a.value=`proof`:e.phase===`awaiting_approval`||e.phase===`approved`?a.value=`approve`:e.phase===`issued`||e.phase===`connected`?a.value=`issued`:e.phase===`cancelled`?a.value=`cancelled`:e.phase===`expired`&&(a.value=`expired`)}}).catch(e=>{t.closed()||(l.value=e instanceof Error?e.message:String(e),a.value=`expired`)})}catch(e){l.value=e instanceof Error?e.message:String(e),a.value=`expired`}}async function ee(){let e=c.value,t=o.value;if(e?.enrollment&&t&&!u.value){u.value=!0,l.value=``;try{let t=await Lb.approve(s.value.codeId,{enrollmentId:e.enrollment.enrollmentId,deviceUid:e.enrollment.deviceUid,keyFingerprint:e.enrollment.keyFingerprint,...p.value?{replaceKey:!0}:{}});c.value=t,(t.phase===`issued`||t.phase===`connected`)&&(a.value=`issued`)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}}async function te(e){if(!s.value)return`cancelled`;try{let t=await Lb.cancel(s.value.codeId,void 0,e);return c.value=t,o.value&&(o.value.state=t),a.value=t.phase===`expired`?`expired`:`cancelled`,o.value?.close(),`cancelled`}catch(e){if(e instanceof Sl&&e.status===409&&String(e.code)===`already_issued`){let e=await Lb.codeState(s.value.codeId).catch(()=>void 0);return e&&(c.value=e,o.value&&(o.value.state=e)),a.value=`issued`,l.value=`Credential already issued. Closing does not revoke it; choose Revoke explicitly if needed.`,`issued`}return l.value=e instanceof Error?e.message:String(e),`failed`}}let ne=()=>te(!1),re=()=>[`issued`,`connected`,`cancelled`,`expired`].includes(c.value?.phase??``);async function w(){let e=S.value;if(e){u.value=!0;try{await Lb.revoke(e,`user`),Y(`Issued credential revoked.`),r(`close`)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}}async function ie(){if(s.value)try{await navigator.clipboard.writeText(s.value.code),m.value=!0,setTimeout(()=>m.value=!1,1500)}catch{l.value=`Clipboard unavailable; copy the code manually.`}}async function ae(){if(s.value)try{await navigator.clipboard.writeText(s.value.offerUrl??s.value.pairUrl),h.value=!0,setTimeout(()=>h.value=!1,1500)}catch{l.value=`Clipboard unavailable; copy the link manually.`}}async function oe(){if(!d.value){d.value=!0,u.value=!0;try{let e=await MV({needsCancel:!!s.value&&!re(),cancel:ne,timeoutMs:jV});if(!e.closed)return;o.value?.close(),g.value?.(),e.confirmed||Y(`Pairing cancellation was not confirmed. The code expires on its own; check device credentials before retrying.`),r(`close`)}finally{d.value=!1,u.value=!1}}}t({close:oe});let se;async function ce(){try{_.value=(await Lb.pending()).codes}catch{}}async function le(e){s.value=void 0,c.value=void 0,l.value=``;let t=zb();o.value=t,a.value=e.phase===`approved_ready`?`approve`:`proof`,Hb(t,e.codeId,{intervalMs:1e3,onState:e=>{c.value=e,e.phase===`awaiting_proof`?a.value=`proof`:e.phase===`awaiting_approval`||e.phase===`approved`?a.value=`approve`:e.phase===`issued`||e.phase===`connected`?a.value=`issued`:e.phase===`cancelled`?a.value=`cancelled`:e.phase===`expired`&&(a.value=`expired`)}}).catch(e=>{l.value=e instanceof Error?e.message:String(e)})}return Vr(()=>{if(ce(),se=setInterval(()=>void ce(),3e3),i.handoff&&`error`in i.handoff){l.value=i.handoff.error,a.value=`expired`;return}C(i.handoff?.code)}),Wr(()=>{clearInterval(se);let e=o.value;e&&!e.closed()&&s.value&&!re()&&te(!0).then(e=>{e!==`cancelled`&&Y(`Pairing cancellation was not confirmed. Check device credentials before retrying.`)}),e?.close(),g.value?.()}),(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:ks(oe,[`self`])},[z(`div`,NV,[z(`header`,null,[t[5]||=z(`h2`,{id:`pair-title`},`Pair a device`,-1),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,onClick:oe},[B(j(xl),{size:18})])]),i.handoff&&`offerFragment`in i.handoff&&i.handoff.offerFragment?(I(),R($A,{key:0,"offer-fragment":i.handoff.offerFragment},null,8,[`offer-fragment`])):H(``,!0),_.value.length?(I(),L(`section`,PV,[t[6]||=z(`h3`,null,`Machines waiting for you`,-1),z(`ul`,null,[(I(!0),L(F,null,P(_.value,e=>(I(),L(`li`,{key:e.codeId},[z(`div`,FV,[z(`strong`,null,D(e.deviceName??`unnamed device`),1),e.hostname?(I(),L(`span`,IV,D(e.hostname),1)):H(``,!0),e.platform?(I(),L(`span`,LV,D(e.platform),1)):H(``,!0)]),z(`div`,RV,D(e.keyFingerprint),1),z(`div`,zV,[z(`span`,BV,D(e.phase.replaceAll(`_`,` `)),1),z(`button`,{type:`button`,class:`small`,onClick:t=>le(e)},`Review`,8,VV)])]))),128))]),t[7]||=z(`p`,{class:`hint`},` Compare each fingerprint with the machine's own terminal before approving. Codes are minted by the hub — nothing has to be copied to the machine. `,-1)])):H(``,!0),a.value===`boot`?(I(),L(`p`,HV,`Minting a pairing code…`)):s.value?(I(),L(F,{key:3},[z(`ol`,UV,[t[8]||=z(`li`,{class:E({on:!0})},`Code`,-1),z(`li`,{class:E({on:[`proof`,`approve`,`issued`].includes(a.value)})},`Proof`,2),z(`li`,{class:E({on:[`approve`,`issued`].includes(a.value)})},`Fingerprint`,2),z(`li`,{class:E({on:a.value===`issued`})},`Online`,2)]),z(`div`,WV,[z(`div`,GV,[z(`div`,KV,D(v.value),1),z(`div`,qV,[z(`button`,{type:`button`,class:`small`,onClick:ie},[B(j(sc),{size:14}),V(` `+D(m.value?`Copied`:`Copy code`),1)]),z(`button`,{type:`button`,class:`small`,onClick:ae,title:`Self-contained link: hub, code and expiry all in the fragment — it never reaches server logs`},[B(j(sc),{size:14}),V(` `+D(h.value?`Copied link`:`Copy link`),1)])]),t[9]||=z(`p`,{class:`hint`},` Run the device pairing command and scan, or enter this code on the device. Expires in 5 minutes. `,-1),z(`div`,{class:`pair-qr`,"aria-label":`Pairing QR code`,title:`Same offer link as Copy link: hub, code and expiry all in the #offer= fragment — it never reaches server logs`,innerHTML:b.value},null,8,JV)]),z(`div`,YV,[a.value===`code`||a.value===`proof`?(I(),L(`p`,XV,[B(j($c),{size:14,class:`spin`}),t[10]||=V(` Waiting for the device to submit its signing proof… `,-1)])):a.value===`approve`?(I(),L(F,{key:1},[z(`div`,ZV,[t[11]||=z(`h3`,null,`Device key fingerprint`,-1),z(`code`,QV,D(x.value),1),t[12]||=z(`p`,{class:`hint`},` Compare ALL 64 hex characters with the fingerprint shown on the device screen. `,-1)]),z(`label`,$V,[M(z(`input`,{"onUpdate:modelValue":t[0]||=e=>f.value=e,type:`checkbox`},null,512),[[bs,f.value]]),t[13]||=V(` The fingerprint matches the device display exactly `,-1)]),c.value?.enrollment?.keyChanged?(I(),L(`label`,eH,[M(z(`input`,{"onUpdate:modelValue":t[1]||=e=>p.value=e,type:`checkbox`},null,512),[[bs,p.value]]),B(j(ol),{size:14}),t[14]||=V(` Device is already paired with a DIFFERENT key — replace the stored key (replaceKey) `,-1)])):H(``,!0),z(`button`,{type:`button`,class:`primary`,disabled:!f.value||u.value||c.value?.enrollment?.keyChanged===!0&&!p.value,onClick:ee},` Approve device `,8,tH),z(`button`,{type:`button`,class:`small`,disabled:u.value,onClick:ne},` Cancel pairing `,8,nH)],64)):a.value===`issued`?(I(),L(F,{key:2},[z(`p`,rH,[B(j(ic),{size:14}),t[15]||=V(` Credential issued. The device is connecting through the tunnel — you will get a toast once the monitor probe reports it online. `,-1)]),z(`button`,{type:`button`,class:`small`,onClick:oe},`Close`),z(`button`,{type:`button`,class:`small danger`,disabled:!S.value||u.value,title:`Mistaken approval? Revoke the credential now.`,onClick:w},` Revoke this credential `,8,iH)],64)):a.value===`cancelled`?(I(),L(F,{key:3},[t[16]||=z(`p`,{class:`hint`},`Pairing was cancelled (or the signature failed too many times).`,-1),z(`button`,{type:`button`,class:`small`,onClick:t[2]||=e=>C()},`Start over`)],64)):a.value===`expired`?(I(),L(F,{key:4},[t[17]||=z(`p`,{class:`hint`},`The pairing code expired.`,-1),z(`button`,{type:`button`,class:`small`,onClick:t[3]||=e=>C()},`New code`)],64)):H(``,!0),l.value?(I(),L(`p`,aH,D(l.value),1)):H(``,!0)])])],64)):(I(),L(`div`,oH,[z(`p`,sH,D(l.value||`This pairing link is unavailable.`),1),z(`button`,{type:`button`,class:`small`,onClick:t[4]||=e=>C()},`New code`)]))])]))}}),lH={class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`device-credentials-title`},uH={class:`hint`},dH={key:1,class:`hint`},fH=Er({__name:`DeviceCredentialsDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=U(()=>Ju.devices.value.find(e=>e.id===n.deviceId));return(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:t[2]||=ks(e=>r(`close`),[`self`])},[z(`section`,lH,[z(`header`,null,[t[3]||=z(`h2`,{id:`device-credentials-title`},`Device credentials`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close device credentials`,onClick:t[0]||=e=>r(`close`)},[B(j(xl),{size:18})])]),i.value?(I(),L(F,{key:0},[z(`p`,null,[V(D(i.value.name)+` `,1),z(`code`,null,D(i.value.id),1)]),z(`p`,uH,D(i.value.status)+` · tunnel `+D(i.value.tunnel?.state??`disconnected`)+` · `+D(i.value.tunnel?.readerCount??0)+` readers `,1),B(Zb,{device:i.value},null,8,[`device`])],64)):(I(),L(`p`,dH,`This device is no longer in the registry.`)),z(`footer`,null,[z(`button`,{class:`secondary`,onClick:t[1]||=e=>r(`close`)},`Close`)])])]))}}),pH={id:`prompt-title`},mH=[`disabled`],hH={key:0,class:`hint`},gH={key:1},_H={key:0,class:`muted`},vH=[`placeholder`,`disabled`],yH=[`required`,`placeholder`,`aria-label`,`disabled`],bH={key:2,class:`message-error`,role:`alert`},xH=[`disabled`],SH=[`disabled`],CH=Er({__name:`PromptDialog`,props:{dialog:{}},emits:[`close`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=A(r.dialog.value??``),o=A(!1),s=A(``),c=A(),l=!!r.dialog.label;async function u(){if(!o.value&&(!l||r.dialog.optional||a.value.trim())){o.value=!0,s.value=``;try{await r.dialog.run(a.value.trim()),i(`close`)}catch(e){s.value=K(e)}finally{o.value=!1}}}return Vr(()=>void kn(()=>(c.value?.focus(),c.value?.select()))),t({busy:o}),(t,n)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:n[4]||=ks(e=>!o.value&&i(`close`),[`self`])},[z(`form`,{class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`prompt-title`,onSubmit:ks(u,[`prevent`])},[z(`header`,null,[z(`h2`,pH,D(e.dialog.title),1),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,disabled:o.value,onClick:n[0]||=e=>i(`close`)},[B(j(xl),{size:18})],8,mH)]),e.dialog.hint?(I(),L(`p`,hH,D(e.dialog.hint),1)):H(``,!0),l?(I(),L(`label`,gH,[V(D(e.dialog.label)+` `,1),e.dialog.optional?(I(),L(`span`,_H,`(optional)`)):H(``,!0),e.dialog.multiline?M((I(),L(`textarea`,{key:1,ref_key:`input`,ref:c,"onUpdate:modelValue":n[1]||=e=>a.value=e,rows:`4`,placeholder:e.dialog.placeholder,disabled:o.value},null,8,vH)),[[ys,a.value]]):M((I(),L(`input`,{key:2,ref_key:`input`,ref:c,"onUpdate:modelValue":n[2]||=e=>a.value=e,maxlength:`100`,required:!e.dialog.optional,placeholder:e.dialog.placeholder,"aria-label":e.dialog.label,disabled:o.value},null,8,yH)),[[ys,a.value]])])):H(``,!0),s.value?(I(),L(`p`,bH,D(s.value),1)):H(``,!0),z(`footer`,null,[z(`button`,{type:`button`,class:`secondary`,disabled:o.value,onClick:n[3]||=e=>i(`close`)},` Cancel `,8,xH),z(`button`,{class:E([`primary`,{danger:e.dialog.danger}]),disabled:o.value||l&&!e.dialog.optional&&!a.value.trim()},D(o.value?`Working…`:e.dialog.submit),11,SH)])],32)]))}}),wH={class:`modal model-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":`Model picker`},TH={class:`eyebrow`},EH={class:`model-list`},DH={key:0,class:`model-row off-catalog`,"aria-disabled":`true`},OH=[`src`],kH=[`onClick`],AH=[`src`],jH={class:`hint`},MH=Er({__name:`ModelPicker`,emits:[`close`],setup(e,{emit:t}){let n=t,r=A(``),i=A();Vr(()=>void kn(()=>i.value?.focus()));let a=U(()=>vd.value.filter(e=>`${e.name} ${e.id} ${e.tier}`.toLowerCase().includes(r.value.toLowerCase()))),o=e=>{let t=Ed.value;return!!t&&e.id===t.modelId&&e.provider===t.provider},s=U(()=>{let e=Ed.value;return e&&!vd.value.some(t=>t.provider===e.provider&&t.id===e.modelId)?e:void 0});async function c(e){await Fd(()=>ld.value.configure({model:{provider:e.provider,modelId:e.id}}))&&(await Ad(),Y(`Model saved. Used on the next turn.`),n(`close`))}return(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:t[2]||=ks(e=>n(`close`),[`self`])},[z(`section`,wH,[z(`header`,null,[z(`div`,null,[z(`span`,TH,`PER AGENT · `+D(j(nd)?.name??j(nd)?.id),1),t[3]||=z(`h2`,null,`Choose a model`,-1)]),z(`button`,{class:`icon-button`,"aria-label":`Close model picker`,onClick:t[0]||=e=>n(`close`)},[B(j(xl),{size:18})])]),M(z(`input`,{ref_key:`searchInput`,ref:i,"onUpdate:modelValue":t[1]||=e=>r.value=e,placeholder:`Search models or tiers…`,"aria-label":`Search models`},null,512),[[ys,r.value]]),z(`div`,EH,[s.value?(I(),L(`div`,DH,[z(`img`,{src:j(zd)(s.value.modelId),alt:``},null,8,OH),z(`div`,null,[z(`strong`,null,D(s.value.modelId),1),z(`small`,null,D(s.value.provider)+` / current · not in this device's catalog`,1)])])):H(``,!0),(I(!0),L(F,null,P(a.value,e=>(I(),L(`button`,{key:`${e.provider}/${e.id}`,class:E({selected:o(e)}),onClick:t=>c(e)},[z(`img`,{src:j(zd)(e.id),alt:``},null,8,AH),z(`div`,null,[z(`strong`,null,D(e.name),1),z(`small`,null,D(e.tier)+` / `+D(e.provider)+` / `+D(j(Ld)(e.contextWindow))+` context`,1)]),o(e)?(I(),R(j(tc),{key:0,size:18})):H(``,!0)],10,kH))),128))]),z(`p`,jH,`Models available on `+D(j(nd)?.id)+`. Provider keys stay on the device.`,1)])]))}}),NH={class:`dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`help-title`},PH={class:`dialog-head`},FH={class:`dialog-body`},IH={class:`n`},LH={class:`body`},RH={class:`help-callout`},zH={class:`dialog-foot`},BH={class:`right`},VH=Er({__name:`HelpDialog`,setup(e){let t=[{title:`Pick a device, start a session`,body:`Every device in the tree runs dpi-backend. A session gets its own SQLite database on that device, in the directory you choose.`},{title:`Send work, then close the browser`,body:`The device owns the run. Reopening restores committed messages, state and live progress.`},{title:`Change state and fork`,body:`Edit App State by hand or through the agent. Every session and fork on a device shares it.`},{title:`Interrupt deliberately`,body:`Interrupt stops foreground work and owned subagents. Background jobs continue. Stop all includes them.`},{title:`Explore the boundaries`,body:`Queue a follow-up, steer after tools, wait for approval, compact context, reset or inspect raw state.`},{title:`Restart a device`,body:`Its tree dims and shows the restart command. Checkpointed jobs recover on boot. Replay-safe tools may rerun. Other interrupted tools return an error.`}];return(e,n)=>(I(),L(`div`,{class:`scrim`,onClick:n[2]||=ks(e=>j(J).dialog=void 0,[`self`])},[z(`section`,NH,[z(`div`,PH,[n[3]||=z(`div`,null,[z(`span`,{class:`dialog-eyebrow`},`LEARN BY DOING`),z(`h3`,{id:`help-title`},`What makes this durable?`)],-1),z(`button`,{class:`icon-button`,"aria-label":`Close help`,onClick:n[0]||=e=>j(J).dialog=void 0},[B(j(xl),{size:18})])]),z(`div`,FH,[(I(),L(F,null,P(t,(e,t)=>z(`div`,{key:e.title,class:`help-step`},[z(`span`,IH,D(String(t+1).padStart(2,`0`)),1),z(`div`,null,[z(`b`,null,D(e.title),1),z(`div`,LH,D(e.body),1)])])),64)),z(`div`,RH,[B(j(Oc),{size:18}),n[4]||=z(`span`,null,`Durable does not mean exactly-once external effects. Checkpoints protect progress. Tools still need their own idempotency.`,-1)])]),z(`div`,zH,[z(`div`,BH,[z(`button`,{class:`secondary`,type:`button`,onClick:n[1]||=e=>j(J).dialog=void 0},`Close`)])])])]))}}),HH=Wt({needed:!1,busy:!1,error:``}),UH=new Set,WH=e=>{let t=[...UH];UH=new Set;for(let n of t)n(e)},GH=()=>new Promise(e=>UH.add(e));async function KH(e){if(HH.busy||!e)return!1;HH.busy=!0,HH.error=``;try{let t=await fetch(`/api/session`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})});return await t.text().catch(()=>``),t.ok?(HH.needed=!1,WH(!0),!0):(HH.error=t.status===401?`That token was not accepted.`:t.status===429?`Too many attempts. Wait a minute and try again.`:`Login failed (${t.status}).`,!1)}catch{return HH.error=`Cannot reach the hub.`,!1}finally{HH.busy=!1}}var qH=e=>{try{return new URL(e,location.href).pathname===`/api/session`}catch{return e===`/api/session`}};function JH(e){return(async(t,n)=>{let r=()=>e(t,n),i=await r();if(i.status!==401||qH(typeof t==`string`?t:t instanceof URL?t.href:t.url)||n?.body instanceof ReadableStream)return i;HH.needed=!0;let a=await i.text().catch(()=>``);return await GH()?r():new Response(a,{status:i.status,headers:i.headers})})}function YH(){typeof window>`u`||window.__adminFetch||(window.__adminFetch=!0,window.fetch=JH(window.fetch.bind(window)))}var XH={class:`login-veil`,"data-testid":`login-card`},ZH=[`disabled`],QH={key:0,class:`message-error`,role:`alert`},$H=[`disabled`],eU=Er({__name:`LoginCard`,setup(e){let t=A(``),n=A();async function r(){if(HH.busy||!t.value.trim())return;let e=await KH(t.value.trim());t.value=``,e&&n.value?.blur()}return Vr(()=>void kn(()=>n.value?.focus())),(e,i)=>(I(),L(`div`,XH,[z(`form`,{class:`modal login-card`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`login-title`,onSubmit:ks(r,[`prevent`])},[i[2]||=z(`header`,null,[z(`h2`,{id:`login-title`},`Admin token`)],-1),i[3]||=z(`p`,{class:`hint`},[V(` This hub is locked. Sign in with the token from its `),z(`code`,null,`admin.token`),V(` file. `)],-1),i[4]||=z(`label`,{for:`admin-token`},`Admin token`,-1),M(z(`input`,{id:`admin-token`,ref_key:`input`,ref:n,"onUpdate:modelValue":i[0]||=e=>t.value=e,type:`password`,name:`admin-token`,autocomplete:`off`,spellcheck:`false`,placeholder:`adm_…`,"aria-label":`Admin token`,disabled:j(HH).busy,onKeydown:i[1]||=js(e=>j(HH).error=``,[`esc`])},null,40,ZH),[[ys,t.value]]),j(HH).error?(I(),L(`p`,QH,D(j(HH).error),1)):H(``,!0),z(`footer`,null,[z(`button`,{class:`primary`,type:`submit`,disabled:j(HH).busy||!t.value.trim()},D(j(HH).busy?`Checking…`:`Sign in`),9,$H)])],32)]))}}),tU={key:0,class:`toast`,role:`status`},nU=Er({__name:`Toast`,setup(e){return(e,t)=>(I(),R(bo,{name:`toast`},{default:Vn(()=>[j(J).toast?(I(),L(`div`,tU,[B(j(tc),{size:18}),V(D(j(J).toast),1)])):H(``,!0)]),_:1}))}});function rU(e,t=!1){return e.kind===`pair`?`pair`:e.kind===`prompt`&&t?`keep`:`close`}var iU={class:`shell`,"data-testid":`app-shell`},aU={key:0,class:`error-banner`,role:`alert`},oU={key:4,class:`welcome`,"data-testid":`welcome-empty`},sU=[`disabled`],cU={class:`welcome-features`},lU={class:`build-stamp`},uU={class:`modal path-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`path-title`},dU={class:`full-directory`},fU=Er({__name:`App`,setup(e){let t=()=>Ju.devices.value.filter(e=>e.status===`online`).length,n=A(),r=A();function i(){J.dialog={kind:`new-session`,deviceId:q.value?.deviceId}}function a(e){let t=J.dialog?void 0:Qd(e);if(t)return e.preventDefault(),t===`tree`?Jd():Yd();if(e.key===`Escape`){if(J.dialog){let e=rU(J.dialog,r.value?.busy??!1);e===`pair`?n.value?.close():e===`close`&&(J.dialog=void 0);return}!e.repeat&&!e.isComposing&&Cd.value&&(e.preventDefault(),Hd()),J.drawer=!1,J.inspectorOverlay=!1}}function o(e){let t=e.clientX,n=Qu.value,r=e=>Qu.value=Math.max(220,Math.min(560,n+e.clientX-t)),i=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)}return Vr(()=>Lf()),Vr(()=>{document.addEventListener(`keydown`,a),gd()}),Wr(()=>{Ku.stop(),document.removeEventListener(`keydown`,a)}),(e,a)=>(I(),L(`div`,iU,[B(mf,{onNewSession:i}),j(J).error?(I(),L(`div`,aU,[B(j(Oc),{size:18}),z(`span`,null,D(j(J).error),1),z(`button`,{class:`icon-button`,"aria-label":`Dismiss error`,onClick:a[0]||=e=>j(J).error=``},`×`)])):H(``,!0),z(`main`,{class:`net-workspace`,style:T({"--tree-w":`${j(Qu)}px`})},[B(Qp),j($u).tree?(I(),L(`div`,{key:0,class:`tree-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize network tree`,onPointerdown:ks(o,[`prevent`])},null,32)):H(``,!0),j(J).drawer?(I(),L(`div`,{key:1,class:`tree-backdrop`,onClick:a[1]||=e=>j(J).drawer=!1})):H(``,!0),j(q)&&j(nd)&&j(rd)?(I(),L(F,{key:2},[B(Uk),j(J).inspectorOverlay?(I(),L(`div`,{key:0,class:`inspector-backdrop`,onClick:a[2]||=e=>j(qd)()})):H(``,!0),(I(),R(ib,{key:`${j(q).deviceId}/${j(q).sessionId}`}))],64)):j(q)&&j(nd)?(I(),R($k,{key:3,device:j(nd)},null,8,[`device`])):(I(),L(`section`,oU,[a[14]||=z(`img`,{class:`welcome-symbol`,src:`/icons/durable-pi.svg`,alt:`Durable Pi`},null,-1),a[15]||=z(`span`,{class:`eyebrow`},`THE DURABLE AGENT NETWORK`,-1),a[16]||=z(`h1`,null,[V(`Close the tab.`),z(`br`),V(`The work continues.`)],-1),a[17]||=z(`p`,null,`Agents run on your devices. This page is only a window into them.`,-1),z(`button`,{class:`primary`,disabled:!t(),onClick:i},[B(j(Xc),{size:18}),V(D(j(Ju).devices.value.length?`Create a session`:`Add a device to dpi-network.yaml`),1)],8,sU),z(`div`,cU,[z(`span`,null,[B(j(fc),{size:18}),a[11]||=V(`SQLite on each device`,-1)]),z(`span`,null,[B(j(Cc),{size:18}),a[12]||=V(`Branch any agent`,-1)]),z(`span`,null,[B(j(Vs),{size:18}),a[13]||=V(`Watch from anywhere`,-1)])]),z(`p`,lU,`ui `+D(j(`0.0.119`)),1)]))],4),B(_f),j(J).dialog?.kind===`pair`?(I(),R(cH,{key:1,ref_key:`pairWizard`,ref:n,handoff:j(J).dialog.handoff,onClose:a[3]||=e=>j(J).dialog=void 0},null,8,[`handoff`])):H(``,!0),j(J).dialog?.kind===`credentials`?(I(),R(fH,{key:2,"device-id":j(J).dialog.deviceId,onClose:a[4]||=e=>j(J).dialog=void 0},null,8,[`device-id`])):H(``,!0),j(J).dialog?.kind===`new-session`?(I(),R(bA,{key:3,"device-id":j(J).dialog.deviceId,onClose:a[5]||=e=>j(J).dialog=void 0},null,8,[`device-id`])):j(J).dialog?.kind===`prompt`?(I(),R(CH,{key:4,ref_key:`promptDialog`,ref:r,dialog:j(J).dialog,onClose:a[6]||=e=>j(J).dialog=void 0},null,8,[`dialog`])):j(J).dialog?.kind===`models`?(I(),R(MH,{key:5,onClose:a[7]||=e=>j(J).dialog=void 0})):j(J).dialog?.kind===`path`?(I(),L(`div`,{key:6,class:`modal-backdrop`,onClick:a[10]||=ks(e=>j(J).dialog=void 0,[`self`])},[z(`section`,uU,[z(`header`,null,[a[18]||=z(`h2`,{id:`path-title`},`Working directory`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close working directory`,onClick:a[8]||=e=>j(J).dialog=void 0},[B(j(xl),{size:18})])]),z(`code`,dU,D(j(J).dialog.path),1),z(`footer`,null,[z(`button`,{class:`secondary`,onClick:a[9]||=e=>j(J).dialog=void 0},`Close`)])])])):j(J).dialog?.kind===`help`?(I(),R(VH,{key:7})):H(``,!0),j(HH).needed?(I(),R(eU,{key:8})):H(``,!0),B(nU)]))}});YH();var pU=new URL(window.location.href);if(/^\/pair\/?$/.test(pU.pathname)){let e=OV(pU);e?(pU.search=``,pU.hash=``,window.history.replaceState(window.history.state,``,pU),J.dialog={kind:`pair`,handoff:e}):window.history.replaceState(window.history.state,``,AV(pU))}Fs(fU).mount(`#app`);{let e=window.visualViewport,t=document.documentElement,n=()=>{let n=Math.max(e?.height??window.innerHeight,window.innerHeight);t.style.setProperty(`--vvh`,`${Math.round(n)}px`)};e?.addEventListener(`resize`,n),e?.addEventListener(`scroll`,n),window.addEventListener(`resize`,n),window.addEventListener(`orientationchange`,n),n()}/[?&]debug=1\b/.test(location.search)&&setTimeout(()=>{let e=document.createElement(`pre`);e.style.cssText=`position:fixed;left:6px;bottom:6px;z-index:99999;background:#000d;color:#fff;padding:8px;font:11px/1.5 ui-monospace,monospace;max-width:92vw;border-radius:6px;white-space:pre-wrap`;let t=window.visualViewport,n=()=>{e.textContent=[`UA: ${navigator.userAgent}`,`innerW×H: ${innerWidth}×${innerHeight}`,`clientW: ${document.documentElement.clientWidth}`,`visualViewport: ${t?`${Math.round(t.width)}×${Math.round(t.height)} scale=${t.scale.toFixed(3)}`:`none`}`,`root font-size: ${getComputedStyle(document.documentElement).fontSize}`,`dpr: ${devicePixelRatio}`,`mq740: ${matchMedia(`(max-width: 740px)`).matches}`,`touch: ${matchMedia(`(pointer: coarse)`).matches}`].join(`
|
|
82
|
+
`)}n(LO(t)),n(`}`,`punct`)}function VO(e,t,n){e.forEach((e,r)=>{r&&n(` | `,`punct`),zO(e,t,n)})}function HO(e,t){if(typeof e==`string`)return t(JSON.stringify(e),`string`);if(typeof e==`number`)return t(String(e),`number`);t(String(e),`type`)}function UO(e){let t=[e.description,e.minimum===void 0?``:`@minimum ${e.minimum}`,e.maximum===void 0?``:`@maximum ${e.maximum}`,e.default===void 0?``:`@default ${JSON.stringify(e.default)}`].filter(Boolean);return t.length?`/** ${t.join(` `)} */`:``}var WO=12582912;function GO(e){if(e.bytes.byteLength>12582912)throw Error(`bundle is ${e.bytes.byteLength} bytes, over the ${WO} byte download cap`);let t=document.createElement(`a`),n=(e.filename||`device-response`).replace(/[^A-Za-z0-9._-]/g,`_`).slice(0,80)||`device-response`;/\.zip$/i.test(e.filename)&&!/\.zip$/i.test(n)&&(n=`${n.slice(0,76)}.zip`),t.href=URL.createObjectURL(new Blob([e.bytes.slice()],{type:`application/zip`})),t.download=n,t.click(),URL.revokeObjectURL(t.href)}function KO(e,t={}){let n=t.fetchBundle??((e,t)=>G(e).exportSession(t)),r=t.download??GO,i=t.notify??(()=>{}),a=A(!1),o=A(``);async function s(){let{device:t,summary:s}=e.value;if(t&&s&&!a.value){a.value=!0,o.value=``;try{let e=await n(t.id,s.id);r(e),i(`Bundle downloaded (${Math.max(1,Math.round(e.bytes.length/1024))} KiB).`)}catch(e){o.value=`bundle export failed: ${K(e).slice(0,300)}`,i(o.value.slice(0,120))}finally{a.value=!1}}}return N(()=>e.value.summary?.id,()=>o.value=``),{exporting:a,error:o,run:s}}function qO(e){try{let t=JSON.parse(e);if(!t||Array.isArray(t)||typeof t!=`object`)throw Error(`App State must be a JSON object.`);return lb({},{operation:`update`,path:``,value:t}),``}catch(e){return K(e)}}function JO(e,t){let n=A(``),r=A(``),i=A(0),a=A(),o=A(!1),s=A(``),c=U(()=>n.value!==r.value),l=U(()=>c.value&&a.value!==t.value),u=U(()=>c.value&&(l.value||e.value?.revision!==i.value));function d(){n.value=JSON.stringify(e.value?.value??{},null,2),r.value=n.value,i.value=e.value?.revision??0,a.value=t.value,s.value=``}function f(e,t){n.value=JSON.stringify(e,null,2),r.value=n.value,i.value=t,s.value=``}N(e,()=>!c.value&&d(),{immediate:!0}),N(t,()=>d());let p;return N(n,()=>{clearTimeout(p),p=setTimeout(()=>s.value=c.value?qO(n.value):``,250)}),{draft:n,dirty:c,conflict:u,deviceChanged:l,saving:o,problem:s,revision:i,reset:d,commit:f}}var YO={key:0,class:`panel-rail`,"aria-label":`Inspector (collapsed)`},XO=[`title`],ZO=[`aria-label`,`title`,`onClick`],QO={key:0,class:`count`},$O={class:`inspector-tabs`,role:`tablist`,"aria-label":`Session details`},ek=[`id`,`aria-selected`,`title`,`onClick`],tk={class:`tab-label`},nk={key:0,class:`count`},rk=[`title`],ik=[`aria-labelledby`],ak={class:`session-heading`},ok=[`disabled`],sk=[`disabled`],ck=[`title`],lk={class:`cwd-trail`,dir:`rtl`},uk={dir:`ltr`},dk={class:`session-status`},fk={key:0,class:`background-pill`},pk=[`title`],mk={key:0,class:`message-error`,role:`alert`},hk=[`disabled`],gk={class:`model-section`},_k=[`src`],vk={key:0,class:`hint model-provenance`},yk={class:`thinking-row`},bk=[`value`],xk={class:`stats-section`,"aria-labelledby":`stats-title`},Sk={class:`metrics`},Ck=[`title`],wk={class:`usage-breakdown`,"aria-label":`Agent token and cost breakdown`},Tk={scope:`row`},Ek={class:`usage-total`},Dk={class:`panel-heading`},Ok={class:`hint app-state-description`},kk=[`disabled`],Ak={class:`state-json-actions`},jk={key:0,class:`hint`},Mk=[`disabled`],Nk=[`disabled`],Pk={key:0,class:`message-error`,role:`alert`},Fk={key:1,class:`message-error`,role:`alert`},Ik={class:`panel-heading`},Lk={class:`tag`},Rk={class:`hook-card`},zk=[`aria-checked`],Bk={key:0,class:`tag tool-disabled`},Vk={class:`tag`},Hk=[`aria-label`],Uk=pf(Er({__name:`Inspector`,setup(e){let t=U(()=>new Map(Od.value?.tools.map(e=>[e.name,RO(e.name,e.parameters)]))),n=[{id:`session`,label:`Session`,icon:yc},{id:`git`,label:`Git`,icon:xc},{id:`host`,label:`Host`,icon:Vs},{id:`usage`,label:`Usage`,icon:Jc},{id:`auto`,label:`Auto`,icon:ec},{id:`archive`,label:`Archive`,icon:Us},{id:`dag`,label:`DAG`,icon:gl},{id:`notify`,label:`Notify`,icon:Xs},{id:`env`,label:`Env`,icon:gc},{id:`state`,label:`State`,icon:Qs},{id:`tasks`,label:`Tasks`,icon:Vs},{id:`tools`,label:`Tools`,icon:bl},{id:`extensions`,label:`Extend`,icon:Qc}],r=U(()=>[{label:`Input`,tokens:wd.value.input,cost:wd.value.inputCost},{label:`Output`,tokens:wd.value.output,cost:wd.value.outputCost},{label:`Cache read`,tokens:wd.value.cacheRead,cost:wd.value.cacheReadCost},{label:`Cache write`,tokens:wd.value.cacheWrite,cost:wd.value.cacheWriteCost}]),i=U(()=>Sd.value.filter(e=>e.background).length);function a(e,t){Fd(async()=>{await ld.value.configure(e),await Ad(),t&&Y(t)})}async function o(){let e=nd.value,t=sd.value;if(e&&t)try{let n=await G(e.id).agent(t.id,q.value?.agentId??1).transcript(`markdown`),r=new Blob([typeof n==`string`?n:JSON.stringify(n)],{type:`text/markdown`}),i=document.createElement(`a`);i.href=URL.createObjectURL(r),i.download=`${t.name.replace(/[^\w.-]+/g,`_`)||`session`}-${t.id.slice(0,8)}.md`,i.click(),URL.revokeObjectURL(i.href),Y(`Transcript downloaded.`)}catch(e){Y(`transcript download failed: ${K(e).slice(0,120)}`)}}let{exporting:s,error:c,run:l}=KO(U(()=>({device:nd.value,summary:sd.value}))),u=A(!1);function d(){let e=nd.value,t=sd.value;e&&t&&!u.value&&(J.dialog={kind:`prompt`,title:`Share this transcript publicly?`,hint:`Anyone with the link can read this session's transcripts. The link expires in 7 days and can be removed on the hub.`,submit:`Create share link`,run:async()=>{u.value=!0;try{let n=G(e.id),r=t.agents.length?t.agents:[{id:1,name:`main`}],i=[];for(let e of r){let r=await n.agent(t.id,e.id).transcript(`markdown`),a=typeof r==`string`?r:r.text??JSON.stringify(r,null,2);i.push({name:e.name||`agent ${e.id}`,markdown:a})}let a=await Mu.createShare({title:`${t.name} · ${e.name}`,agents:i}),o=`${location.origin}${a.url}`;await navigator.clipboard?.writeText(o).catch(()=>{}),Y(`Share link copied — expires ${a.expiresAt.slice(0,10)}.`)}catch(e){Y(`share failed: ${K(e).slice(0,140)}`)}finally{u.value=!1}}})}function f(){let e=ud.value;e&&(J.dialog={kind:`prompt`,title:`Rename session`,label:`Session name`,value:sd.value?.name??``,submit:`Save name`,run:t=>e.rename(t)})}let p=A({});N(nd,async e=>{if(p.value={},e)try{let{projects:t}=await G(e.id).projects(!0);p.value=Object.fromEntries(t.filter(e=>e.model).map(e=>[e.rootPath,e.model]))}catch{}},{immediate:!0});let m=U(()=>{let e=Ed.value;if(!e)return!1;let t=sd.value?.cwd,n=Object.keys(p.value).filter(e=>t===e||(t??``).startsWith(`${e}/`)).sort((e,t)=>t.length-e.length),r=n.length?p.value[n[0]]:void 0,i=r?`${r.provider}/${r.modelId}`:nd.value?.info?.defaultModel??``;return!!i&&i===`${e.provider}/${e.modelId}`}),h=U(()=>Ed.value&&`model: ${Ed.value.modelId} (${Ed.value.provider})${m.value?` (default)`:``}`),g=od.sharedState,{draft:_,dirty:v,conflict:y,deviceChanged:b,problem:x,revision:S,reset:C,commit:ee}=JO(g,td),te=A(!1),ne=A(``);async function re(e){if(!te.value&&ld.value){te.value=!0,ne.value=``;try{await ld.value.demo(`state`,e)}catch(e){ne.value=K(e)}finally{te.value=!1}}}async function w(){if(!(te.value||y.value||!ld.value)){ne.value=``,te.value=!0;try{let e=JSON.parse(_.value);if(!e||Array.isArray(e)||typeof e!=`object`)throw Error(`App State must be a JSON object.`);let t=await ld.value.demo(`state`,{operation:`update`,path:``,value:e,expectedRevision:S.value});ee(t.value,t.revision),Y(`Shared App State saved.`)}catch(e){ne.value=K(e)}finally{te.value=!1}}}let ie=U(()=>Od.value?.config.readOnly===!0),ae=U(()=>Od.value?.tools.filter(e=>e.offered).length??0);return(e,p)=>(I(),L(`aside`,{class:E([`inspector`,{collapsed:!j(Gd),overlay:j(J).inspectorOverlay}])},[j(Gd)?(I(),L(F,{key:1},[z(`div`,$O,[(I(),L(F,null,P(n,e=>z(`button`,{id:`inspector-tab-${e.id}`,key:e.id,role:`tab`,"aria-controls":`inspector-panel`,"aria-selected":j(J).tab===e.id,title:e.label,class:E({active:j(J).tab===e.id}),onClick:t=>j(J).tab=e.id},[(I(),R($r(e.icon),{size:18})),z(`span`,tk,D(e.label),1),e.id===`tasks`&&j(Sd).length?(I(),L(`span`,nk,D(j(Sd).length),1)):H(``,!0)],10,ek)),64)),z(`button`,{class:`icon-button panel-toggle`,"aria-label":`Collapse inspector`,title:`Collapse inspector (${j(Zd).inspector})`,onClick:p[1]||=e=>j(qd)()},[B(j(Uc),{size:18})],8,rk)]),z(`div`,{id:`inspector-panel`,class:E([`inspector-body`,{"session-panel":j(J).tab===`session`}]),role:`tabpanel`,"aria-labelledby":`inspector-tab-${j(J).tab}`},[j(J).tab===`session`?(I(),L(F,{key:0},[z(`section`,ak,[z(`h1`,null,[z(`span`,null,D(j(sd)?.name??`Loading session`),1),z(`button`,{class:`icon-button`,title:`Rename session`,"aria-label":`Rename session`,onClick:f},[B(j(qc),{size:18})]),z(`button`,{class:`icon-button`,title:`Download transcript (markdown)`,"aria-label":`Download transcript`,onClick:o},[B(j(pc),{size:18})]),z(`button`,{class:`icon-button`,title:`Download session bundle (.zip: manifest, transcripts, configs)`,"aria-label":`Download session bundle`,disabled:j(s),onClick:p[2]||=(...e)=>j(l)&&j(l)(...e)},[B(j(Hc),{size:18})],8,ok),z(`button`,{class:`icon-button`,title:`Share a public read-only link to this transcript`,"aria-label":`Share transcript`,disabled:u.value,onClick:d},[B(j(al),{size:18})],8,sk)]),z(`button`,{class:`path cwd-button`,title:j(sd)?.cwd,"aria-label":`Show full working directory`,onClick:p[3]||=e=>j(J).dialog={kind:`path`,path:j(sd)?.cwd??``}},[B(j(yc),{size:18}),z(`span`,lk,[z(`bdi`,uk,D(j(sd)?.cwd),1)])],8,ck),z(`div`,dk,[z(`span`,{class:E([`status-pill`,{working:j(Cd)}])},[p[10]||=z(`i`,null,null,-1),V(D(j(Cd)?`Working`:`Idle`),1)],2),i.value?(I(),L(`span`,fk,D(i.value)+` background`,1)):H(``,!0),z(`span`,{class:`saved`,title:j(nd)?.id},[B(j(il),{size:18}),V(D(j(nd)?.name??j(nd)?.id),1)],8,pk),j(nd)?(I(),R(Pb,{key:1,device:j(nd)},null,8,[`device`])):H(``,!0)]),j(c)?(I(),L(`p`,mk,[V(D(j(c))+` `,1),z(`button`,{class:`small`,disabled:j(s),onClick:p[4]||=(...e)=>j(l)&&j(l)(...e)},` retry `,8,hk)])):H(``,!0)]),j(nd)?(I(),R(Zb,{key:0,device:j(nd)},null,8,[`device`])):H(``,!0),z(`section`,gk,[p[18]||=z(`div`,{class:`section-label`},[z(`span`,null,`AGENT`)],-1),z(`button`,{class:`model-button`,onClick:p[5]||=e=>j(J).dialog={kind:`models`}},[z(`img`,{src:j(zd)(j(yd).agent.model?.modelId),alt:``},null,8,_k),z(`div`,null,[z(`strong`,null,D(j(Td)?.name??j(yd).agent.model?.modelId??`Loading…`),1),z(`small`,null,D(j(Td)?.tier??``)+` / `+D(j(yd).agent.model?.provider??``),1)]),B(j(nc),{size:18})]),h.value?(I(),L(`p`,vk,D(h.value),1)):H(``,!0),z(`div`,yk,[p[11]||=z(`span`,null,`Thinking`,-1),z(`select`,{"aria-label":`Thinking level`,value:j(yd).agent.thinkingLevel??`medium`,onChange:p[6]||=e=>a({thinkingLevel:e.target.value},`Thinking ${e.target.value}. Used on the next turn.`)},[(I(!0),L(F,null,P(j(Jv),e=>(I(),L(`option`,{key:e},D(e),1))),128))],40,bk)]),B(FO),z(`section`,xk,[p[17]||=z(`div`,{class:`section-label`},[z(`span`,{id:`stats-title`},`STATS`)],-1),z(`div`,Sk,[z(`div`,{title:`${j(wd).tokens.toLocaleString(`en-US`)} total tokens`},[z(`span`,null,D(j(Ld)(j(wd).tokens)),1),p[12]||=z(`small`,null,`total tokens`,-1)],8,Ck),z(`div`,null,[z(`span`,null,`$`+D(j(wd).cost.toFixed(4)),1),p[13]||=z(`small`,null,`agent cost`,-1)]),z(`div`,null,[z(`span`,null,D(j(Od)?.tools.length??0),1),p[14]||=z(`small`,null,`tools`,-1)])]),z(`table`,wk,[p[16]||=z(`thead`,null,[z(`tr`,null,[z(`th`,{scope:`col`},`Type`),z(`th`,{scope:`col`},`Tokens`),z(`th`,{scope:`col`},`Cost (USD)`)])],-1),z(`tbody`,null,[(I(!0),L(F,null,P(r.value,e=>(I(),L(`tr`,{key:e.label},[z(`th`,Tk,D(e.label),1),z(`td`,null,D(e.tokens.toLocaleString(`en-US`)),1),z(`td`,null,`$`+D(e.cost.toFixed(4)),1)]))),128)),z(`tr`,Ek,[p[15]||=z(`th`,{scope:`row`},`Total`,-1),z(`td`,null,D(j(wd).tokens.toLocaleString(`en-US`)),1),z(`td`,null,`$`+D(j(wd).cost.toFixed(4)),1)])])])])])],64)):H(``,!0),j(J).tab===`state`?(I(),L(F,{key:1},[z(`div`,Dk,[p[19]||=z(`h2`,null,`App State`,-1),B(j(Qs),{size:18})]),z(`p`,Ok,` One shared JSON object for every agent, session and fork on `+D(j(nd)?.name??j(nd)?.id)+`. You and your agents can read, create, update or delete values and fields. Changes appear live and persist across closed browsers, interrupted agents and backend restarts. `,1),M(z(`textarea`,{"onUpdate:modelValue":p[7]||=e=>tn(_)?_.value=e:null,class:`app-state-json`,"aria-label":`App State JSON`,spellcheck:`false`,disabled:te.value||!j(g),rows:`12`},null,8,kk),[[ys,j(_)]]),p[20]||=z(`p`,{class:`hint state-limits`},` One JSON object, at most 24 levels of nesting and 100,000 characters, checked as you type. `,-1),z(`div`,Ak,[j(y)?(I(),L(`span`,jk,D(j(b)?`Device changed since this draft loaded. Load the latest JSON before saving.`:`State changed elsewhere. Load the latest JSON before saving.`),1)):H(``,!0),j(v)?(I(),L(`button`,{key:1,class:`secondary`,disabled:te.value,onClick:p[8]||=(...e)=>j(C)&&j(C)(...e)},D(j(y)?`Load latest`:`Reset`),9,Mk)):H(``,!0),z(`button`,{class:`primary small`,disabled:!j(v)||te.value||j(y)||!!j(x),onClick:w},D(te.value?`Saving…`:`Save JSON`),9,Nk)]),j(x)?(I(),L(`p`,Pk,D(j(x)),1)):H(``,!0),ne.value?(I(),L(`p`,Fk,D(ne.value),1)):H(``,!0),B(Ob,{value:j(g)?.value??{},disabled:te.value||j(v)||!j(g),onChange:re},null,8,[`value`,`disabled`])],64)):H(``,!0),j(J).tab===`tasks`?(I(),R(Ox,{key:2})):H(``,!0),j(J).tab===`git`?(I(),R(Ow,{key:3})):H(``,!0),j(J).tab===`host`?(I(),R(Zw,{key:4})):H(``,!0),j(J).tab===`usage`?(I(),R(HT,{key:5})):H(``,!0),j(J).tab===`auto`?(I(),R(yE,{key:6})):H(``,!0),j(J).tab===`archive`?(I(),R(RE,{key:7})):H(``,!0),j(J).tab===`dag`?(I(),R(rD,{key:8})):H(``,!0),j(J).tab===`notify`?(I(),R(OD,{key:9})):H(``,!0),j(J).tab===`env`?(I(),R(cO,{key:10})):H(``,!0),j(J).tab===`extensions`?(I(),R(gO,{key:11})):H(``,!0),j(J).tab===`tools`?(I(),L(F,{key:12},[z(`div`,Ik,[p[21]||=z(`h2`,null,`Tools`,-1),z(`span`,Lk,D(ae.value)+` / `+D(j(Od)?.tools.length??0),1)]),p[25]||=z(`p`,{class:`hint`},` Every tool this agent's extensions provide. Open one to see its definition. `,-1),z(`div`,Rk,[z(`div`,null,[B(j(sl),{size:18}),p[23]||=z(`strong`,null,`Read only`,-1),z(`button`,{class:E([`switch`,{on:ie.value}]),role:`switch`,"aria-checked":ie.value,"aria-label":`Read only`,onClick:p[9]||=e=>a({readOnly:!ie.value},ie.value?`Read only off. Every tool is back.`:`Read only on. Tools that write are disabled.`)},[...p[22]||=[z(`span`,null,null,-1)]],10,zk)]),p[24]||=z(`p`,null,` Offers this agent only tools that read. Tools that create, update or delete leave its next request, and the choice is stored with the agent. `,-1)]),(I(!0),L(F,null,P(j(Od)?.tools,e=>(I(),L(`details`,{key:e.name,class:E([`tool-row`,{disabled:!e.offered}])},[z(`summary`,null,[B(j(bl),{size:18}),z(`strong`,null,D(e.name),1),e.offered?H(``,!0):(I(),L(`span`,Bk,`disabled`)),z(`span`,Vk,D(e.replay===`safe`?`replay safe`:`interrupt on crash`),1)]),z(`p`,null,D(e.description),1),e.parameters?(I(),L(`pre`,{key:0,class:`tool-signature`,"aria-label":`${e.name} TypeScript definition`},[z(`code`,null,[(I(!0),L(F,null,P(t.value.get(e.name),(e,t)=>(I(),L(`span`,{key:t,class:E(`tk-${e.kind}`)},D(e.text),3))),128))])],8,Hk)):H(``,!0),z(`small`,null,D(e.replay===`safe`?`An interrupted execution may run again after recovery.`:`A crash records an interrupted result instead of rerunning this effect.`),1)],2))),128))],64)):H(``,!0)],10,ik)],64)):(I(),L(`div`,YO,[z(`button`,{class:`icon-button panel-toggle`,"aria-label":`Expand inspector`,title:`Expand inspector (${j(Zd).inspector})`,onClick:p[0]||=e=>j(Kd)()},[B(j(Wc),{size:18})],8,XO),(I(),L(F,null,P(n,e=>z(`button`,{key:e.id,class:E([`rail-tab`,{active:j(J).tab===e.id}]),"aria-label":`Open ${e.label}`,title:e.label,onClick:t=>j(Kd)(e.id)},[(I(),R($r(e.icon),{size:20})),e.id===`tasks`&&j(Sd).length?(I(),L(`span`,QO,D(j(Sd).length),1)):H(``,!0)],10,ZO)),64))]))],2))}}),[[`__scopeId`,`data-v-419eb6ed`]]),Wk={class:`chat-empty`},Gk={class:`eyebrow`},Kk={key:3,class:`hint offline-error`},qk={key:4,class:`offline-command`},Jk={key:5,class:`hint`},Yk={key:6,class:`hint`},Xk={class:`offline-actions`},Zk=[`disabled`],Qk={key:7,class:`message-error`,role:`alert`},$k=Er({__name:`OfflinePanel`,props:{device:{}},setup(e){let t=e,n=A(!1),r=A(``),i=U(()=>{let e=t.device,n=e.source===`config`;switch(e.status){case`checking`:return{title:`Checking ${e.name}…`,text:`Probing the device. This view fills in as soon as it answers.`};case`unauthorized`:return e.transport===`tunnel`?{title:`${e.name} tunnel credentials are not valid`,text:`Pair the device again — the hub will mint a fresh credential.`}:{title:e.hasToken?`${e.name} rejected its token`:`No token for ${e.name}`,text:e.hasToken?`The device's DPI_TOKEN changed (a rotate or a rebuilt device). Copy the current token into this hub's registry, then check again.`:`This hub has no token for the device yet. Register it, then check again.`,command:n&&e.kind!==`url`?`just net register ${e.id}`:`just net register ${e.id} --token <token>`};case`mismatch`:return{title:`${e.name} answers as a different device`,text:`The URL now reaches a backend with another identity (a rebuilt VM or a new data directory). If that is expected, register it again: that trusts the identity it answers with now.`,command:e.kind===`url`?`just net register ${e.id} --token <token>`:`just net register ${e.id}`};case`incompatible`:return{title:`${e.name} speaks another API version`,text:`Update the device's dpi-backend.`,command:n?`just net deploy ${e.id}`:void 0};default:return{title:`${e.name} is offline`,text:`Last seen ${Bd(e.lastSeenAt)}. Its agents keep their state on the device and resume when its backend starts again. The tree shows the last known sessions.`,command:n?e.kind===`local`?`just backend run`:e.kind===`url`?void 0:`just net restart ${e.id}`:void 0,alt:n&&e.kind!==`local`&&e.kind!==`url`?`just net up ${e.id}`:void 0}}});async function a(){n.value=!0,r.value=``;try{let e=await Mu.check(t.device.id);e.status===`online`&&Y(`${e.id} is online.`)}catch(e){r.value=K(e)}finally{n.value=!1}}async function o(e){try{await navigator.clipboard.writeText(e),Y(`Copied.`)}catch{Y(`Clipboard needs localhost or HTTPS. Select the text to copy.`)}}return(t,s)=>(I(),L(`section`,{class:E([`chat-panel offline-panel`,e.device.status]),"aria-live":`polite`},[z(`div`,Wk,[e.device.status===`checking`?(I(),R(j(Ic),{key:0,class:`spin`,size:30})):e.device.status===`mismatch`||e.device.status===`unauthorized`?(I(),R(j(ol),{key:1,size:30})):(I(),R(j(_l),{key:2,size:30})),z(`span`,Gk,D(e.device.kind.toUpperCase())+` · `+D(e.device.url??(e.device.transport===`tunnel`?`tunnel`:`no endpoint`)),1),z(`h2`,null,D(i.value.title),1),z(`p`,null,D(i.value.text),1),e.device.error?(I(),L(`p`,Kk,D(e.device.error),1)):H(``,!0),i.value.command?(I(),L(`div`,qk,[z(`code`,null,D(i.value.command),1),z(`button`,{class:`icon-button`,"aria-label":`Copy command`,onClick:s[0]||=e=>o(i.value.command)},[B(j(sc),{size:18})])])):H(``,!0),i.value.command?(I(),L(`p`,Jk,`Run it in this repo's terminal, then press Check now.`)):H(``,!0),i.value.alt?(I(),L(`p`,Yk,[s[2]||=V(` Never deployed or rebuilt? `,-1),z(`code`,null,D(i.value.alt),1),s[3]||=V(` provisions it from scratch. `,-1)])):H(``,!0),z(`div`,Xk,[z(`button`,{class:`secondary`,disabled:n.value,onClick:s[1]||=e=>a()},[B(j($c),{size:18}),V(D(n.value?`Checking…`:`Check now`),1)],8,Zk)]),r.value?(I(),L(`p`,Qk,D(r.value),1)):H(``,!0)])],2))}}),eA={class:`dir-browser`},tA={class:`dir-path`},nA=[`disabled`],rA=[`aria-busy`],iA=[`title`],aA=[`aria-selected`,`title`,`onClick`],oA={key:1,class:`hint`},sA={key:0,class:`message-error`,role:`alert`},cA=Er({__name:`DirBrowser`,props:si({deviceId:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=Di(e,`modelValue`),r=A(),i=A(!1),a=A(``),o=0;async function s(e){let s=++o,c=t.deviceId;i.value=!0,a.value=``;try{let t=await G(c).dirs(e);return s===o?(r.value=t,t.path&&(n.value=t.path),t):void 0}catch(e){s===o&&(a.value=K(e));return}finally{s===o&&(i.value=!1)}}return N(()=>t.deviceId,async()=>{r.value=void 0;let e=await s(``),t=e?.dirs[0];t&&!e.path&&await s(t.path)},{immediate:!0}),(e,t)=>(I(),L(`div`,eA,[z(`div`,tA,[M(z(`input`,{"onUpdate:modelValue":t[0]||=e=>n.value=e,"aria-label":`Working directory`,required:``,placeholder:`/path/to/project`,spellcheck:`false`,autocomplete:`off`,onKeydown:t[1]||=js(ks(e=>s(n.value),[`prevent`]),[`enter`])},null,544),[[ys,n.value]]),z(`button`,{type:`button`,class:`secondary small`,disabled:i.value||!n.value,onClick:t[2]||=e=>s(n.value)},` Go `,8,nA)]),z(`div`,{class:`dir-list`,role:`listbox`,"aria-label":`Directories`,"aria-busy":i.value},[z(`button`,{type:`button`,class:`dir-item`,title:`Start directories`,onClick:t[3]||=e=>s(``)},[B(j(Dc),{size:16}),t[5]||=z(`span`,null,`Start dirs`,-1)]),r.value?.parent?(I(),L(`button`,{key:0,type:`button`,class:`dir-item`,title:r.value.parent,onClick:t[4]||=e=>s(r.value.parent)},[B(j(lc),{size:16}),t[6]||=z(`span`,null,`..`,-1)],8,iA)):H(``,!0),(I(!0),L(F,null,P(r.value?.dirs,e=>(I(),L(`button`,{key:e.path,type:`button`,class:`dir-item`,role:`option`,"aria-selected":e.path===n.value,title:e.path,onClick:t=>s(e.path)},[e.path===n.value?(I(),R(j(yc),{key:0,size:16})):(I(),R(j(bc),{key:1,size:16})),z(`span`,null,D(e.name),1)],8,aA))),128)),r.value&&!r.value.dirs.length?(I(),L(`p`,oA,`No subdirectories.`)):H(``,!0)],8,rA),a.value?(I(),L(`p`,sA,D(a.value),1)):H(``,!0)]))}}),lA={key:0,class:`message-error`},uA=[`value`],dA={class:`field`},fA={key:0,class:`recent-cwds`},pA=[`title`,`onClick`],mA={key:0,class:`hint`,title:`The device has no provider key — it lists its built-in catalog, and chat needs OPENROUTER_API_KEY set in the device's env file`},hA=[`value`],gA=[`value`],_A={key:2,class:`message-error`,role:`alert`},vA=[`disabled`],yA=`dpi-recent-cwds`,bA=pf(Er({__name:`NewSessionDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=U(()=>Ju.devices.value.filter(e=>e.status===`online`)),a=A(i.value.find(e=>e.id===n.deviceId)?.id??i.value[0]?.id??``),o=U(()=>i.value.find(e=>e.id===a.value)),s=U(()=>{let e=o.value?.info?.models??[];if(e.length)return e;let t=o.value?.info;return t?.defaultModel&&t.provider?[{id:t.defaultModel,provider:t.provider,name:`${t.defaultModel} (device default)`,tier:`—`,icon:`lab.png`,contextWindow:0,reasoning:!1,cost:{input:0,output:0}}]:[]}),c=U(()=>!s.value.length||(o.value?.info?.models?.length??0)===0),l=U(()=>!!o.value?.info?.providerKeyMissing),u=e=>`${e.provider}/${e.id}`,d=A({name:``,cwd:``,model:``,thinking:`medium`}),f=U(()=>{try{return JSON.parse(localStorage.getItem(yA)??`{}`)[a.value]??[]}catch{return[]}}),p=(e,t)=>{try{let n=JSON.parse(localStorage.getItem(yA)??`{}`),r=[t,...(n[e]??[]).filter(e=>e!==t)].slice(0,6);localStorage.setItem(yA,JSON.stringify({...n,[e]:r}))}catch{}},m=A(!1),h=A(``),g=A({});N(a,async e=>{if(g.value={},e)try{let{projects:t}=await G(e).projects(!0);g.value=Object.fromEntries(t.filter(e=>e.model).map(e=>[e.rootPath,e.model]))}catch{}},{immediate:!0}),N([()=>d.value.cwd,g],()=>{let e=d.value.cwd;if(!e)return;let t=Object.keys(g.value).filter(t=>e===t||e.startsWith(`${t}/`)).sort((e,t)=>t.length-e.length),n=t.length?g.value[t[0]]:void 0;n&&(d.value.model=`${n.provider}/${n.modelId}`)},{immediate:!0}),N(o,e=>{let t=s.value,n=t.find(t=>t.id===e?.info?.defaultModel)??t[0];d.value.model=n?u(n):``,d.value.cwd=``},{immediate:!0});async function _(){if(!m.value&&o.value){m.value=!0,h.value=``;try{let e=s.value.find(e=>u(e)===d.value.model)??s.value[0];if(!e)throw Error(`Choose a model`);let t=await G(o.value.id).createSession({name:d.value.name.trim()||`New session`,cwd:d.value.cwd.trim(),model:{provider:e.provider,modelId:e.id},thinkingLevel:d.value.thinking});p(o.value.id,t.cwd);let n=t.agents.find(e=>e.kind===`root`)??t.agents[0];dd({deviceId:o.value.id,sessionId:t.id,agentId:n?.id??1}),Y(`Session created on ${o.value.id}.`),r(`close`)}catch(e){h.value=K(e)}finally{m.value=!1}}}return(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:t[7]||=ks(e=>r(`close`),[`self`])},[z(`form`,{class:`modal session-modal`,onSubmit:ks(_,[`prevent`])},[z(`header`,null,[t[8]||=z(`div`,null,[z(`span`,{class:`eyebrow`},`A PERSISTENT WORKSPACE`),z(`h2`,null,`New session`)],-1),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close new session`,onClick:t[0]||=e=>r(`close`)},[B(j(xl),{size:18})])]),i.value.length?(I(),L(F,{key:1},[z(`label`,null,[t[9]||=V(`Device`,-1),M(z(`select`,{"onUpdate:modelValue":t[1]||=e=>a.value=e,"aria-label":`Device`},[(I(!0),L(F,null,P(i.value,e=>(I(),L(`option`,{key:e.id,value:e.id},D(e.name)+D(e.info?.hostname&&e.info.hostname!==e.name?` · ${e.info.hostname}`:``),9,uA))),128))],512),[[Ss,a.value]])]),z(`label`,null,[t[10]||=V(`Session name`,-1),M(z(`input`,{"onUpdate:modelValue":t[2]||=e=>d.value.name=e,autofocus:``,placeholder:`My durable agent`,maxlength:`100`},null,512),[[ys,d.value.name]])]),z(`div`,dA,[z(`span`,null,`Working directory on `+D(i.value.find(e=>e.id===a.value)?.name??a.value),1),f.value.length?(I(),L(`div`,fA,[(I(!0),L(F,null,P(f.value,e=>(I(),L(`button`,{key:e,type:`button`,class:E([`chip`,{on:e===d.value.cwd}]),title:e,onClick:t=>d.value.cwd=e},D(e.split(`/`).filter(Boolean).at(-1)||e),11,pA))),128))])):H(``,!0),B(cA,{modelValue:d.value.cwd,"onUpdate:modelValue":t[3]||=e=>d.value.cwd=e,"device-id":a.value},null,8,[`modelValue`,`device-id`])]),z(`label`,null,[t[11]||=V(`Model`,-1),c.value||l.value?(I(),L(`span`,mA,`no API key on device — chat needs one`)):H(``,!0),M(z(`select`,{"onUpdate:modelValue":t[4]||=e=>d.value.model=e,"aria-label":`New session model`},[(I(!0),L(F,null,P(s.value,e=>(I(),L(`option`,{key:u(e),value:u(e)},D(e.tier)+` / `+D(e.name),9,hA))),128))],512),[[Ss,d.value.model]])]),z(`label`,null,[t[12]||=V(`Thinking`,-1),M(z(`select`,{"onUpdate:modelValue":t[5]||=e=>d.value.thinking=e,"aria-label":`New session thinking level`},[(I(!0),L(F,null,P(j(Jv),e=>(I(),L(`option`,{key:e,value:e},D(e),9,gA))),128))],512),[[Ss,d.value.thinking]])])],64)):(I(),L(`p`,lA,` No device is online. Start one with just backend run or just net up <id>, then try again. `)),h.value?(I(),L(`p`,_A,D(h.value),1)):H(``,!0),z(`footer`,null,[z(`button`,{type:`button`,class:`secondary`,onClick:t[6]||=e=>r(`close`)},`Cancel`),z(`button`,{class:`primary`,disabled:m.value||!d.value.model||!d.value.cwd||!o.value},[B(j(Xc),{size:18}),V(D(m.value?`Creating…`:`Create session`),1)],8,vA)])],32)]))}}),[[`__scopeId`,`data-v-4e298b1e`]]),xA=new Uint8Array(512),SA=new Uint8Array(256);(()=>{let e=1;for(let t=0;t<255;t++)xA[t]=e,SA[e]=t,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)xA[e]=xA[e-255]})();var CA=(e,t)=>e===0||t===0?0:xA[SA[e]+SA[t]];function wA(e){let t=[1];for(let n=0;n<e;n++){let e=Array(t.length+1).fill(0);for(let r=0;r<t.length;r++)e[r]^=t[r],e[r+1]^=CA(t[r],xA[n]);t=e}return t}function TA(e,t){let n=wA(t),r=Array(t).fill(0);for(let i of e){let e=i^r[0];r.shift(),r.push(0);for(let i=0;i<t;i++)r[i]^=CA(n[i+1],e)}return r}var EA=[21,25,29,33,37,41,45,49,53,57,61,65],DA=[19,34,55,80,108,136,156,194,232,274,324,370],OA=[7,10,15,20,26,36,40,48,60,72,80,96],kA=[7,10,15,20,26,18,20,24,30,18,20,24],AA=[[[1,19]],[[1,34]],[[1,55]],[[1,80]],[[1,108]],[[2,68]],[[2,78]],[[2,97]],[[2,116]],[[2,68],[2,69]],[[4,81]],[[2,92],[2,93]]],jA=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58]],MA=e=>e<=9?8:16;function NA(e){for(let t=1;t<=EA.length;t++)if(4+MA(t)+e*8<=DA[t-1]*8)return t;throw Error(`qr: payload too long (${e} bytes; v12L max ${DA[11]-3})`)}function PA(e,t){let n=[...new TextEncoder().encode(e)],r=[],i=(e,t)=>{for(let n=t-1;n>=0;n--)r.push(e>>n&1)};i(4,4),i(n.length,MA(t));for(let e of n)i(e,8);let a=DA[t-1],o=a*8;for(i(0,Math.min(4,o-r.length));r.length%8!=0;)r.push(0);let s=[236,17],c=0;for(;r.length<o;)i(s[c++%2],8);let l=[];for(let e=0;e<a;e++){let t=0;for(let n=0;n<8;n++)t=t<<1|r[e*8+n];l.push(t)}return l}function FA(e,t){let n=kA[e-1],r=[],i=0;for(let[n,a]of AA[e-1])for(let e=0;e<n;e++)r.push(t.slice(i,i+=a));let a=[],o=Math.max(...r.map(e=>e.length));for(let e=0;e<o;e++)for(let t of r)e<t.length&&a.push(t[e]);let s=r.map(e=>TA(e,n));for(let e=0;e<n;e++)for(let t of s)a.push(t[e]);return a}function IA(e){return Array.from({length:e},()=>Array(e).fill(!1))}function LA(e,t){let n=EA[t-1],r=(t,r)=>{for(let i=-1;i<=7;i++)for(let a=-1;a<=7;a++){let o=t+i,s=r+a;if(o<0||o>=n||s<0||s>=n)continue;let c=i>=0&&i<=6&&a>=0&&a<=6&&(i===0||i===6||a===0||a===6),l=i>=2&&i<=4&&a>=2&&a<=4;e[o][s]=c||l}};r(0,0),r(0,n-7),r(n-7,0);for(let t=8;t<n-8;t++)e[6][t]=t%2==0,e[t][6]=t%2==0;let i=jA[t-1];for(let t of i)for(let r of i)if(!(t<=8&&r<=8||t<=8&&r>=n-9||t>=n-9&&r<=8))for(let n=-2;n<=2;n++)for(let i=-2;i<=2;i++)e[t+n][r+i]=Math.max(Math.abs(n),Math.abs(i))!==1;if(e[n-8][8]=!0,t>=7){let r=t<<12;for(let e=17;e>=12;e--)r>>e&1&&(r^=7973<<e-12);let i=t<<12|r&4095;for(let t=0;t<18;t++){let r=(i>>t&1)==1,a=n-11+t%3,o=t/3|0;e[a][o]=r,e[o][a]=r}}}function RA(e){let t=8|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>9&1?1335:0);let r=(t<<10|n)^21522,i=[];for(let e=14;e>=0;e--)i.push((r>>e&1)==1);return i}function zA(e,t){let n=EA[0]*0+e.length,r=RA(t);for(let t=0;t<=5;t++)e[8][t]=r[t];e[8][7]=r[6],e[8][8]=r[7],e[7][8]=r[8];for(let t=9;t<15;t++)e[14-t][8]=r[t];for(let t=0;t<7;t++)e[n-1-t][8]=r[t];e[8][n-8]=r[7];for(let t=8;t<15;t++)e[8][n-15+t]=r[t];e[n-8][8]=!0}function BA(e,t,n,r){let i=e.length;EA[n-1]*EA[n-1];let a=e=>((t[e>>3]??0)>>7-(e&7)&1)==1,o=0,s=!0;for(let t=i-1;t>0;t-=2){t===6&&t--;for(let c=0;c<i;c++){let l=s?i-1-c:c;for(let i of[t,t-1]){if(HA(l,i,n))continue;if(o>=(DA[n-1]+OA[n-1])*8){o++;continue}let t=a(o++);VA(l,i,r)&&(t=!t),e[l][i]=t}}s=!s}}function VA(e,t,n){switch(n){case 0:return(e+t)%2==0;case 1:return e%2==0;case 2:return t%3==0;case 3:return(e+t)%3==0;case 4:return(Math.floor(e/2)+Math.floor(t/3))%2==0;case 5:return e*t%2+e*t%3==0;case 6:return(e*t%2+e*t%3)%2==0;default:return((e+t)%2+e*t%3)%2==0}}function HA(e,t,n){let r=EA[n-1];if(e<=8&&t<=8||e<=8&&t>=r-8||e>=r-8&&t<=8||e===6||t===6||n>=7&&(e>=r-11&&e<=r-9&&t<=5||t>=r-11&&t<=r-9&&e<=5))return!0;let i=jA[n-1];for(let n of i)for(let a of i)if(!(n<=8&&a<=8||n<=8&&a>=r-9||n>=r-9&&a<=8)&&Math.abs(e-n)<=2&&Math.abs(t-a)<=2)return!0;return!1}function UA(e){let t=e.length,n=0;for(let r=0;r<2;r++)for(let i=0;i<t;i++){let a=1;for(let o=1;o<t;o++)(r===0?e[i][o]:e[o][i])===(r===0?e[i][o-1]:e[o-1][i])?(a++,o===t-1&&a>=5&&(n+=3+(a-5))):(a>=5&&(n+=3+(a-5)),a=1)}for(let r=0;r<t-1;r++)for(let i=0;i<t-1;i++){let t=e[r][i];e[r][i+1]===t&&e[r+1][i]===t&&e[r+1][i+1]===t&&(n+=3)}let r=[!0,!1,!0,!0,!0,!1,!0,!1,!1,!1,!1],i=(e,t)=>{for(let i=0;i+11<=t;i++){let t=!0;for(let n=0;n<11;n++)if(e(i+n)!==r[n]){t=!1;break}t&&(n+=40)}};for(let n=0;n<t;n++)i(t=>e[n][t],t);for(let n=0;n<t;n++)i(t=>e[t][n],t);let a=0;for(let t of e)for(let e of t)e&&a++;let o=a*100/(t*t);return n+=Math.floor(Math.abs(o-50)/5)*10,n}function WA(e,t){let n=NA(new TextEncoder().encode(e).length),r=EA[n-1],i=FA(n,PA(e,n)),a=IA(r);return LA(a,n),BA(a,i,n,t),zA(a,t),a}function GA(e,t){if(t!==void 0)return WA(e,t);let n;for(let t=0;t<8;t++){let r=WA(e,t),i=UA(r);(!n||i<n.score)&&(n={m:r,score:i})}return n.m}function KA(e,t=160){let n=GA(e),r=n.length,i=t/(r+8),a=``;for(let e=0;e<r;e++)for(let t=0;t<r;t++)n[e][t]&&(a+=`<rect x="${((t+4)*i).toFixed(2)}" y="${((e+4)*i).toFixed(2)}" width="${i.toFixed(3)}" height="${i.toFixed(3)}"/>`);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${t} ${t}" shape-rendering="crispEdges"><rect width="${t}" height="${t}" fill="#fff"/><g fill="#000">${a}</g></svg>`}var qA={class:`device-handoff`,"aria-label":`Pair this machine`},JA={class:`row`},YA=[`disabled`],XA=[`disabled`],ZA={key:0,class:`target`,"data-testid":`device-url`},QA={key:1,class:`err`},$A=pf(Er({__name:`DeviceHandoff`,props:{offerFragment:{}},setup(e){let t=e,n=A(`4780`),r=A(!1),i=U(()=>{let e=/^\d{1,5}$/.test(n.value)?Number(n.value):0;if(!(!e||e<1||e>65535))return`http://127.0.0.1:${e}/pair#${t.offerFragment}`});function a(){let e=i.value;e&&window.open(e,`_blank`,`noopener`)}async function o(){let e=i.value;if(e)try{await navigator.clipboard.writeText(e),r.value=!0,setTimeout(()=>r.value=!1,1600)}catch{}}return(e,t)=>(I(),L(`section`,qA,[z(`header`,null,[B(j(zc),{size:18}),t[1]||=z(`h3`,null,`Pair THIS machine`,-1)]),t[4]||=z(`p`,{class:`what`},[V(` If this browser runs on the device itself, open its local pairing page — the offer is relayed inside the link, nothing is sent to the hub. Start `),z(`code`,null,`dpi device`),V(` there first. `)],-1),z(`div`,JA,[z(`label`,null,[t[2]||=V(` local port `,-1),M(z(`input`,{"onUpdate:modelValue":t[0]||=e=>n.value=e,inputmode:`numeric`,spellcheck:`false`,"aria-label":`Local dpi backend port`},null,512),[[ys,n.value]])]),z(`button`,{class:`primary`,type:`button`,disabled:!i.value,onClick:a},[B(j(mc),{size:15}),t[3]||=V(`Open the device page `,-1)],8,YA),z(`button`,{class:`secondary`,type:`button`,disabled:!i.value,onClick:o},[B(j(sc),{size:15}),V(D(r.value?`Copied`:`Copy link`),1)],8,XA)]),i.value?(I(),L(`p`,ZA,D(i.value),1)):H(``,!0),i.value?H(``,!0):(I(),L(`p`,QA,`port must be 1–65535`))]))}}),[[`__scopeId`,`data-v-1e8e00d8`]]);function ej(e){return lj(e)&&!tj(e)&&!pj(e)&&Symbol.asyncIterator in e}function tj(e){return Array.isArray(e)}function nj(e){return typeof e==`bigint`}function rj(e){return typeof e==`boolean`}function ij(e){return e instanceof globalThis.Date}function aj(e){return typeof e==`function`}function oj(e){return lj(e)&&!tj(e)&&!pj(e)&&Symbol.iterator in e}function sj(e){return e===null}function cj(e){return typeof e==`number`}function lj(e){return typeof e==`object`&&!!e}function uj(e){return e instanceof globalThis.RegExp}function dj(e){return typeof e==`string`}function fj(e){return typeof e==`symbol`}function pj(e){return e instanceof globalThis.Uint8Array}function mj(e){return e===void 0}function hj(e){return e.map(e=>bj(e))}function gj(e){return new Date(e.getTime())}function _j(e){return new Uint8Array(e)}function vj(e){return new RegExp(e.source,e.flags)}function yj(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=bj(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=bj(e[n]);return t}function bj(e){return tj(e)?hj(e):ij(e)?gj(e):pj(e)?_j(e):uj(e)?vj(e):lj(e)?yj(e):e}function xj(e){return bj(e)}function Sj(e,t){return xj(t===void 0?e:{...t,...e})}function Cj(e){return typeof e==`object`&&!!e}function wj(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function Tj(e){return e===void 0}function Ej(e){return typeof e==`number`}var Dj;(function(e){e.InstanceMode=`default`,e.ExactOptionalPropertyTypes=!1,e.AllowArrayObject=!1,e.AllowNaN=!1,e.AllowNullVoid=!1;function t(t,n){return e.ExactOptionalPropertyTypes?n in t:t[n]!==void 0}e.IsExactOptionalProperty=t;function n(t){let n=Cj(t);return e.AllowArrayObject?n:n&&!wj(t)}e.IsObjectLike=n;function r(e){return n(e)&&!(e instanceof Date)&&!(e instanceof Uint8Array)}e.IsRecordLike=r;function i(t){return e.AllowNaN?Ej(t):Number.isFinite(t)}e.IsNumberLike=i;function a(t){let n=Tj(t);return e.AllowNullVoid?n||t===null:n}e.IsVoidLike=a})(Dj||={});function Oj(e){return globalThis.Object.freeze(e).map(e=>Nj(e))}function kj(e){return e}function Aj(e){return e}function jj(e){return e}function Mj(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=Nj(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=Nj(e[n]);return globalThis.Object.freeze(t)}function Nj(e){return tj(e)?Oj(e):ij(e)?kj(e):pj(e)?Aj(e):uj(e)?jj(e):lj(e)?Mj(e):e}function X(e,t){let n=t===void 0?e:{...t,...e};switch(Dj.InstanceMode){case`freeze`:return Nj(n);case`clone`:return xj(n);default:return n}}var Pj=class extends Error{constructor(e){super(e)}},Fj=Symbol.for(`TypeBox.Transform`),Ij=Symbol.for(`TypeBox.Readonly`),Lj=Symbol.for(`TypeBox.Optional`),Rj=Symbol.for(`TypeBox.Hint`),Z=Symbol.for(`TypeBox.Kind`);function zj(e){return lj(e)&&e[Ij]===`Readonly`}function Bj(e){return lj(e)&&e[Lj]===`Optional`}function Vj(e){return eM(e,`Any`)}function Hj(e){return eM(e,`Argument`)}function Uj(e){return eM(e,`Array`)}function Wj(e){return eM(e,`AsyncIterator`)}function Gj(e){return eM(e,`BigInt`)}function Kj(e){return eM(e,`Boolean`)}function qj(e){return eM(e,`Computed`)}function Jj(e){return eM(e,`Constructor`)}function Yj(e){return eM(e,`Date`)}function Xj(e){return eM(e,`Function`)}function Zj(e){return eM(e,`Integer`)}function Qj(e){return eM(e,`Intersect`)}function $j(e){return eM(e,`Iterator`)}function eM(e,t){return lj(e)&&Z in e&&e[Z]===t}function tM(e){return rj(e)||cj(e)||dj(e)}function nM(e){return eM(e,`Literal`)}function rM(e){return eM(e,`MappedKey`)}function iM(e){return eM(e,`MappedResult`)}function aM(e){return eM(e,`Never`)}function oM(e){return eM(e,`Not`)}function sM(e){return eM(e,`Null`)}function cM(e){return eM(e,`Number`)}function lM(e){return eM(e,`Object`)}function uM(e){return eM(e,`Promise`)}function dM(e){return eM(e,`Record`)}function fM(e){return eM(e,`Ref`)}function pM(e){return eM(e,`RegExp`)}function mM(e){return eM(e,`String`)}function hM(e){return eM(e,`Symbol`)}function gM(e){return eM(e,`TemplateLiteral`)}function _M(e){return eM(e,`This`)}function vM(e){return lj(e)&&Fj in e}function yM(e){return eM(e,`Tuple`)}function bM(e){return eM(e,`Undefined`)}function xM(e){return eM(e,`Union`)}function SM(e){return eM(e,`Uint8Array`)}function CM(e){return eM(e,`Unknown`)}function wM(e){return eM(e,`Unsafe`)}function TM(e){return eM(e,`Void`)}function EM(e){return lj(e)&&Z in e&&dj(e[Z])}function DM(e){return Vj(e)||Hj(e)||Uj(e)||Kj(e)||Gj(e)||Wj(e)||qj(e)||Jj(e)||Yj(e)||Xj(e)||Zj(e)||Qj(e)||$j(e)||nM(e)||rM(e)||iM(e)||aM(e)||oM(e)||sM(e)||cM(e)||lM(e)||uM(e)||dM(e)||fM(e)||pM(e)||mM(e)||hM(e)||gM(e)||_M(e)||yM(e)||bM(e)||xM(e)||SM(e)||CM(e)||wM(e)||TM(e)||EM(e)}var OM=`Argument.Any.Array.AsyncIterator.BigInt.Boolean.Computed.Constructor.Date.Enum.Function.Integer.Intersect.Iterator.Literal.MappedKey.MappedResult.Not.Null.Number.Object.Promise.Record.Ref.RegExp.String.Symbol.TemplateLiteral.This.Tuple.Undefined.Union.Uint8Array.Unknown.Void`.split(`.`);function kM(e){try{return new RegExp(e),!0}catch{return!1}}function AM(e){if(!dj(e))return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n>=7&&n<=13||n===27||n===127)return!1}return!0}function jM(e){return PM(e)||AN(e)}function MM(e){return mj(e)||nj(e)}function NM(e){return mj(e)||cj(e)}function PM(e){return mj(e)||rj(e)}function FM(e){return mj(e)||dj(e)}function IM(e){return mj(e)||dj(e)&&AM(e)&&kM(e)}function LM(e){return mj(e)||dj(e)&&AM(e)}function RM(e){return mj(e)||AN(e)}function zM(e){return lj(e)&&e[Lj]===`Optional`}function BM(e){return eN(e,`Any`)&&FM(e.$id)}function VM(e){return eN(e,`Argument`)&&cj(e.index)}function HM(e){return eN(e,`Array`)&&e.type===`array`&&FM(e.$id)&&AN(e.items)&&NM(e.minItems)&&NM(e.maxItems)&&PM(e.uniqueItems)&&RM(e.contains)&&NM(e.minContains)&&NM(e.maxContains)}function UM(e){return eN(e,`AsyncIterator`)&&e.type===`AsyncIterator`&&FM(e.$id)&&AN(e.items)}function WM(e){return eN(e,`BigInt`)&&e.type===`bigint`&&FM(e.$id)&&MM(e.exclusiveMaximum)&&MM(e.exclusiveMinimum)&&MM(e.maximum)&&MM(e.minimum)&&MM(e.multipleOf)}function GM(e){return eN(e,`Boolean`)&&e.type===`boolean`&&FM(e.$id)}function KM(e){return eN(e,`Computed`)&&dj(e.target)&&tj(e.parameters)&&e.parameters.every(e=>AN(e))}function qM(e){return eN(e,`Constructor`)&&e.type===`Constructor`&&FM(e.$id)&&tj(e.parameters)&&e.parameters.every(e=>AN(e))&&AN(e.returns)}function JM(e){return eN(e,`Date`)&&e.type===`Date`&&FM(e.$id)&&NM(e.exclusiveMaximumTimestamp)&&NM(e.exclusiveMinimumTimestamp)&&NM(e.maximumTimestamp)&&NM(e.minimumTimestamp)&&NM(e.multipleOfTimestamp)}function YM(e){return eN(e,`Function`)&&e.type===`Function`&&FM(e.$id)&&tj(e.parameters)&&e.parameters.every(e=>AN(e))&&AN(e.returns)}function XM(e){return eN(e,`Integer`)&&e.type===`integer`&&FM(e.$id)&&NM(e.exclusiveMaximum)&&NM(e.exclusiveMinimum)&&NM(e.maximum)&&NM(e.minimum)&&NM(e.multipleOf)}function ZM(e){return lj(e)&&Object.entries(e).every(([e,t])=>AM(e)&&AN(t))}function QM(e){return eN(e,`Intersect`)&&!(dj(e.type)&&e.type!==`object`)&&tj(e.allOf)&&e.allOf.every(e=>AN(e)&&!xN(e))&&FM(e.type)&&(PM(e.unevaluatedProperties)||RM(e.unevaluatedProperties))&&FM(e.$id)}function $M(e){return eN(e,`Iterator`)&&e.type===`Iterator`&&FM(e.$id)&&AN(e.items)}function eN(e,t){return lj(e)&&Z in e&&e[Z]===t}function tN(e){return iN(e)&&dj(e.const)}function nN(e){return iN(e)&&cj(e.const)}function rN(e){return iN(e)&&rj(e.const)}function iN(e){return eN(e,`Literal`)&&FM(e.$id)&&aN(e.const)}function aN(e){return rj(e)||cj(e)||dj(e)}function oN(e){return eN(e,`MappedKey`)&&tj(e.keys)&&e.keys.every(e=>cj(e)||dj(e))}function sN(e){return eN(e,`MappedResult`)&&ZM(e.properties)}function cN(e){return eN(e,`Never`)&&lj(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function lN(e){return eN(e,`Not`)&&AN(e.not)}function uN(e){return eN(e,`Null`)&&e.type===`null`&&FM(e.$id)}function dN(e){return eN(e,`Number`)&&e.type===`number`&&FM(e.$id)&&NM(e.exclusiveMaximum)&&NM(e.exclusiveMinimum)&&NM(e.maximum)&&NM(e.minimum)&&NM(e.multipleOf)}function fN(e){return eN(e,`Object`)&&e.type===`object`&&FM(e.$id)&&ZM(e.properties)&&jM(e.additionalProperties)&&NM(e.minProperties)&&NM(e.maxProperties)}function pN(e){return eN(e,`Promise`)&&e.type===`Promise`&&FM(e.$id)&&AN(e.item)}function mN(e){return eN(e,`Record`)&&e.type===`object`&&FM(e.$id)&&jM(e.additionalProperties)&&lj(e.patternProperties)&&(e=>{let t=Object.getOwnPropertyNames(e.patternProperties);return t.length===1&&kM(t[0])&&lj(e.patternProperties)&&AN(e.patternProperties[t[0]])})(e)}function hN(e){return eN(e,`Ref`)&&FM(e.$id)&&dj(e.$ref)}function gN(e){return eN(e,`RegExp`)&&FM(e.$id)&&dj(e.source)&&dj(e.flags)&&NM(e.maxLength)&&NM(e.minLength)}function _N(e){return eN(e,`String`)&&e.type===`string`&&FM(e.$id)&&NM(e.minLength)&&NM(e.maxLength)&&IM(e.pattern)&&LM(e.format)}function vN(e){return eN(e,`Symbol`)&&e.type===`symbol`&&FM(e.$id)}function yN(e){return eN(e,`TemplateLiteral`)&&e.type===`string`&&dj(e.pattern)&&e.pattern[0]===`^`&&e.pattern[e.pattern.length-1]===`$`}function bN(e){return eN(e,`This`)&&FM(e.$id)&&dj(e.$ref)}function xN(e){return lj(e)&&Fj in e}function SN(e){return eN(e,`Tuple`)&&e.type===`array`&&FM(e.$id)&&cj(e.minItems)&&cj(e.maxItems)&&e.minItems===e.maxItems&&(mj(e.items)&&mj(e.additionalItems)&&e.minItems===0||tj(e.items)&&e.items.every(e=>AN(e)))}function CN(e){return eN(e,`Undefined`)&&e.type===`undefined`&&FM(e.$id)}function wN(e){return eN(e,`Union`)&&FM(e.$id)&&lj(e)&&tj(e.anyOf)&&e.anyOf.every(e=>AN(e))}function TN(e){return eN(e,`Uint8Array`)&&e.type===`Uint8Array`&&FM(e.$id)&&NM(e.minByteLength)&&NM(e.maxByteLength)}function EN(e){return eN(e,`Unknown`)&&FM(e.$id)}function DN(e){return eN(e,`Unsafe`)}function ON(e){return eN(e,`Void`)&&e.type===`void`&&FM(e.$id)}function kN(e){return lj(e)&&Z in e&&dj(e[Z])&&!OM.includes(e[Z])}function AN(e){return lj(e)&&(BM(e)||VM(e)||HM(e)||GM(e)||WM(e)||UM(e)||KM(e)||qM(e)||JM(e)||YM(e)||XM(e)||QM(e)||$M(e)||iN(e)||oN(e)||sN(e)||cN(e)||lN(e)||uN(e)||dN(e)||fN(e)||pN(e)||mN(e)||hN(e)||gN(e)||_N(e)||vN(e)||yN(e)||bN(e)||SN(e)||CN(e)||wN(e)||TN(e)||EN(e)||DN(e)||ON(e)||kN(e))}var jN=`(true|false)`,MN=`(0|[1-9][0-9]*)`,NN=`(.*)`,PN=`(?!.*)`;`${jN}`;var FN=`^${MN}$`,IN=`^${NN}$`,LN=`^${PN}$`;function RN(e,t){return e.includes(t)}function zN(e){return[...new Set(e)]}function BN(e,t){return e.filter(e=>t.includes(e))}function VN(e,t){return e.reduce((e,t)=>BN(e,t),t)}function HN(e){return e.length===1?e[0]:e.length>1?VN(e.slice(1),e[0]):[]}function UN(e){let t=[];for(let n of e)t.push(...n);return t}function WN(e){return X({[Z]:`Any`},e)}function GN(e,t){return X({[Z]:`Array`,type:`array`,items:e},t)}function KN(e){return X({[Z]:`Argument`,index:e})}function qN(e,t){return X({[Z]:`AsyncIterator`,type:`AsyncIterator`,items:e},t)}function JN(e,t,n){return X({[Z]:`Computed`,target:e,parameters:t},n)}function YN(e,t){let{[t]:n,...r}=e;return r}function XN(e,t){return t.reduce((e,t)=>YN(e,t),e)}function ZN(e){return X({[Z]:`Never`,not:{}},e)}function QN(e){return X({[Z]:`MappedResult`,properties:e})}function $N(e,t,n){return X({[Z]:`Constructor`,type:`Constructor`,parameters:e,returns:t},n)}function eP(e,t,n){return X({[Z]:`Function`,type:`Function`,parameters:e,returns:t},n)}function tP(e,t){return X({[Z]:`Union`,anyOf:e},t)}function nP(e){return e.some(e=>Bj(e))}function rP(e){return e.map(e=>Bj(e)?iP(e):e)}function iP(e){return XN(e,[Lj])}function aP(e,t){return nP(e)?GF(tP(rP(e),t)):tP(rP(e),t)}function oP(e,t){return e.length===1?X(e[0],t):e.length===0?ZN(t):aP(e,t)}function sP(e,t){return e.length===0?ZN(t):e.length===1?X(e[0],t):tP(e,t)}var cP=class extends Pj{};function lP(e){return e.replace(/\\\$/g,`$`).replace(/\\\*/g,`*`).replace(/\\\^/g,`^`).replace(/\\\|/g,`|`).replace(/\\\(/g,`(`).replace(/\\\)/g,`)`)}function uP(e,t,n){return e[t]===n&&e.charCodeAt(t-1)!==92}function dP(e,t){return uP(e,t,`(`)}function fP(e,t){return uP(e,t,`)`)}function pP(e,t){return uP(e,t,`|`)}function mP(e){if(!(dP(e,0)&&fP(e,e.length-1)))return!1;let t=0;for(let n=0;n<e.length;n++)if(dP(e,n)&&(t+=1),fP(e,n)&&--t,t===0&&n!==e.length-1)return!1;return!0}function hP(e){return e.slice(1,e.length-1)}function gP(e){let t=0;for(let n=0;n<e.length;n++)if(dP(e,n)&&(t+=1),fP(e,n)&&--t,pP(e,n)&&t===0)return!0;return!1}function _P(e){for(let t=0;t<e.length;t++)if(dP(e,t))return!0;return!1}function vP(e){let[t,n]=[0,0],r=[];for(let i=0;i<e.length;i++)if(dP(e,i)&&(t+=1),fP(e,i)&&--t,pP(e,i)&&t===0){let t=e.slice(n,i);t.length>0&&r.push(bP(t)),n=i+1}let i=e.slice(n);return i.length>0&&r.push(bP(i)),r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`or`,expr:r}}function yP(e){function t(e,t){if(!dP(e,t))throw new cP(`TemplateLiteralParser: Index must point to open parens`);let n=0;for(let r=t;r<e.length;r++)if(dP(e,r)&&(n+=1),fP(e,r)&&--n,n===0)return[t,r];throw new cP(`TemplateLiteralParser: Unclosed group parens in expression`)}function n(e,t){for(let n=t;n<e.length;n++)if(dP(e,n))return[t,n];return[t,e.length]}let r=[];for(let i=0;i<e.length;i++)if(dP(e,i)){let[n,a]=t(e,i),o=e.slice(n,a+1);r.push(bP(o)),i=a}else{let[t,a]=n(e,i),o=e.slice(t,a);o.length>0&&r.push(bP(o)),i=a-1}return r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`and`,expr:r}}function bP(e){return mP(e)?bP(hP(e)):gP(e)?vP(e):_P(e)?yP(e):{type:`const`,const:lP(e)}}function xP(e){return bP(e.slice(1,e.length-1))}var SP=class extends Pj{};function CP(e){return e.type===`or`&&e.expr.length===2&&e.expr[0].type===`const`&&e.expr[0].const===`0`&&e.expr[1].type===`const`&&e.expr[1].const===`[1-9][0-9]*`}function wP(e){return e.type===`or`&&e.expr.length===2&&e.expr[0].type===`const`&&e.expr[0].const===`true`&&e.expr[1].type===`const`&&e.expr[1].const===`false`}function TP(e){return e.type===`const`&&e.const===`.*`}function EP(e){return CP(e)||TP(e)?!1:wP(e)?!0:e.type===`and`||e.type===`or`?e.expr.every(e=>EP(e)):e.type===`const`||(()=>{throw new SP(`Unknown expression type`)})()}function DP(e){return EP(xP(e.pattern))}var OP=class extends Pj{};function*kP(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let n of kP(e.slice(1)))yield`${t}${n}`}function*AP(e){return yield*kP(e.expr.map(e=>[...NP(e)]))}function*jP(e){for(let t of e.expr)yield*NP(t)}function*MP(e){return yield e.const}function*NP(e){return e.type===`and`?yield*AP(e):e.type===`or`?yield*jP(e):e.type===`const`?yield*MP(e):(()=>{throw new OP(`Unknown expression`)})()}function PP(e){let t=xP(e.pattern);return EP(t)?[...NP(t)]:[]}function FP(e,t){return X({[Z]:`Literal`,const:e,type:typeof e},t)}function IP(e){return X({[Z]:`Boolean`,type:`boolean`},e)}function LP(e){return X({[Z]:`BigInt`,type:`bigint`},e)}function RP(e){return X({[Z]:`Number`,type:`number`},e)}function zP(e){return X({[Z]:`String`,type:`string`},e)}function*BP(e){let t=e.trim().replace(/"|'/g,``);return t===`boolean`?yield IP():t===`number`?yield RP():t===`bigint`?yield LP():t===`string`?yield zP():yield(()=>{let e=t.split(`|`).map(e=>FP(e.trim()));return e.length===0?ZN():e.length===1?e[0]:oP(e)})()}function*VP(e){if(e[1]!==`{`)return yield*[FP(`$`),...HP(e.slice(1))];for(let t=2;t<e.length;t++)if(e[t]===`}`){let n=BP(e.slice(2,t)),r=HP(e.slice(t+1));return yield*[...n,...r]}yield FP(e)}function*HP(e){for(let t=0;t<e.length;t++)if(e[t]===`$`)return yield*[FP(e.slice(0,t)),...VP(e.slice(t))];yield FP(e)}function UP(e){return[...HP(e)]}var WP=class extends Pj{};function GP(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function KP(e,t){return gM(e)?e.pattern.slice(1,e.pattern.length-1):xM(e)?`(${e.anyOf.map(e=>KP(e,t)).join(`|`)})`:cM(e)||Zj(e)||Gj(e)?`${t}${MN}`:mM(e)?`${t}${NN}`:nM(e)?`${t}${GP(e.const.toString())}`:Kj(e)?`${t}${jN}`:(()=>{throw new WP(`Unexpected Kind '${e[Z]}'`)})()}function qP(e){return`^${e.map(e=>KP(e,``)).join(``)}$`}function JP(e){return oP(PP(e).map(e=>FP(e)))}function YP(e,t){let n=dj(e)?qP(UP(e)):qP(e);return X({[Z]:`TemplateLiteral`,type:`string`,pattern:n},t)}function XP(e){return PP(e).map(e=>e.toString())}function ZP(e){let t=[];for(let n of e)t.push(...$P(n));return t}function QP(e){return[e.toString()]}function $P(e){return[...new Set(gM(e)?XP(e):xM(e)?ZP(e.anyOf):nM(e)?QP(e.const):cM(e)||Zj(e)?[`[number]`]:[])]}function eF(e,t,n){let r={};for(let i of Object.getOwnPropertyNames(t))r[i]=mF(e,$P(t[i]),n);return r}function tF(e,t,n){return eF(e,t.properties,n)}function nF(e,t,n){return QN(tF(e,t,n))}function rF(e,t){return e.map(e=>dF(e,t))}function iF(e){return e.filter(e=>!aM(e))}function aF(e,t){return eI(iF(rF(e,t)))}function oF(e){return e.some(e=>aM(e))?[]:e}function sF(e,t){return oP(oF(rF(e,t)))}function cF(e,t){return t in e?e[t]:t===`[number]`?oP(e):ZN()}function lF(e,t){return t===`[number]`?e:ZN()}function uF(e,t){return t in e?e[t]:ZN()}function dF(e,t){return Qj(e)?aF(e.allOf,t):xM(e)?sF(e.anyOf,t):yM(e)?cF(e.items??[],t):Uj(e)?lF(e.items,t):lM(e)?uF(e.properties,t):ZN()}function fF(e,t){return t.map(t=>dF(e,t))}function pF(e,t){return oP(fF(e,t))}function mF(e,t,n){if(fM(e)||fM(t)){if(!DM(e)||!DM(t))throw new Pj(`Index types using Ref parameters require both Type and Key to be of TSchema`);return JN(`Index`,[e,t])}return iM(t)?nF(e,t,n):rM(t)?vF(e,t,n):X(DM(t)?pF(e,$P(t)):pF(e,t),n)}function hF(e,t,n){return{[t]:mF(e,[t],xj(n))}}function gF(e,t,n){return t.reduce((t,r)=>({...t,...hF(e,r,n)}),{})}function _F(e,t,n){return gF(e,t.keys,n)}function vF(e,t,n){return QN(_F(e,t,n))}function yF(e,t){return X({[Z]:`Iterator`,type:`Iterator`,items:e},t)}function bF(e){return globalThis.Object.keys(e).filter(t=>!Bj(e[t]))}function xF(e,t){let n=bF(e);return X(n.length>0?{[Z]:`Object`,type:`object`,required:n,properties:e}:{[Z]:`Object`,type:`object`,properties:e},t)}var SF=xF;function CF(e,t){return X({[Z]:`Promise`,type:`Promise`,item:e},t)}function wF(e){return X(XN(e,[Ij]))}function TF(e){return X({...e,[Ij]:`Readonly`})}function EF(e,t){return t===!1?wF(e):TF(e)}function DF(e,t){let n=t??!0;return iM(e)?AF(e,n):EF(e,n)}function OF(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=DF(e[r],t);return n}function kF(e,t){return OF(e.properties,t)}function AF(e,t){return QN(kF(e,t))}function jF(e,t){return X(e.length>0?{[Z]:`Tuple`,type:`array`,items:e,additionalItems:!1,minItems:e.length,maxItems:e.length}:{[Z]:`Tuple`,type:`array`,minItems:e.length,maxItems:e.length},t)}function MF(e,t){return e in t?zF(e,t[e]):QN(t)}function NF(e){return{[e]:FP(e)}}function PF(e){let t={};for(let n of e)t[n]=FP(n);return t}function FF(e,t){return RN(t,e)?NF(e):PF(t)}function IF(e,t){return MF(e,FF(e,t))}function LF(e,t){return t.map(t=>zF(e,t))}function RF(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(t))n[r]=zF(e,t[r]);return n}function zF(e,t){let n={...t};return Bj(t)?GF(zF(e,XN(t,[Lj]))):zj(t)?DF(zF(e,XN(t,[Ij]))):iM(t)?MF(e,t.properties):rM(t)?IF(e,t.keys):Jj(t)?$N(LF(e,t.parameters),zF(e,t.returns),n):Xj(t)?eP(LF(e,t.parameters),zF(e,t.returns),n):Wj(t)?qN(zF(e,t.items),n):$j(t)?yF(zF(e,t.items),n):Qj(t)?tI(LF(e,t.allOf),n):xM(t)?sP(LF(e,t.anyOf),n):yM(t)?jF(LF(e,t.items??[]),n):lM(t)?SF(RF(e,t.properties),n):Uj(t)?GN(zF(e,t.items),n):uM(t)?CF(zF(e,t.item),n):t}function BF(e,t){let n={};for(let r of e)n[r]=zF(r,t);return n}function VF(e,t,n){let r=DM(e)?$P(e):e;return SF(BF(r,t({[Z]:`MappedKey`,keys:r})),n)}function HF(e){return X(XN(e,[Lj]))}function UF(e){return X({...e,[Lj]:`Optional`})}function WF(e,t){return t===!1?HF(e):UF(e)}function GF(e,t){let n=t??!0;return iM(e)?JF(e,n):WF(e,n)}function KF(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=GF(e[r],t);return n}function qF(e,t){return KF(e.properties,t)}function JF(e,t){return QN(qF(e,t))}function YF(e,t={}){let n=e.every(e=>lM(e)),r=DM(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return X(t.unevaluatedProperties===!1||DM(t.unevaluatedProperties)||n?{...r,[Z]:`Intersect`,type:`object`,allOf:e}:{...r,[Z]:`Intersect`,allOf:e},t)}function XF(e){return e.every(e=>Bj(e))}function ZF(e){return XN(e,[Lj])}function QF(e){return e.map(e=>Bj(e)?ZF(e):e)}function $F(e,t){return XF(e)?GF(YF(QF(e),t)):YF(QF(e),t)}function eI(e,t={}){if(e.length===1)return X(e[0],t);if(e.length===0)return ZN(t);if(e.some(e=>vM(e)))throw Error(`Cannot intersect transform types`);return $F(e,t)}function tI(e,t){if(e.length===1)return X(e[0],t);if(e.length===0)return ZN(t);if(e.some(e=>vM(e)))throw Error(`Cannot intersect transform types`);return YF(e,t)}function nI(...e){let[t,n]=typeof e[0]==`string`?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=`string`)throw new Pj(`Ref: $ref must be a string`);return X({[Z]:`Ref`,$ref:t},n)}function rI(e,t){return JN(`Awaited`,[JN(e,t)])}function iI(e){return JN(`Awaited`,[nI(e)])}function aI(e){return tI(cI(e))}function oI(e){return sP(cI(e))}function sI(e){return lI(e)}function cI(e){return e.map(e=>lI(e))}function lI(e,t){return X(qj(e)?rI(e.target,e.parameters):Qj(e)?aI(e.allOf):xM(e)?oI(e.anyOf):uM(e)?sI(e.item):fM(e)?iI(e.$ref):e,t)}function uI(e){let t=[];for(let n of e)t.push(_I(n));return t}function dI(e){return UN(uI(e))}function fI(e){return HN(uI(e))}function pI(e){return e.map((e,t)=>t.toString())}function mI(e){return[`[number]`]}function hI(e){return globalThis.Object.getOwnPropertyNames(e)}function gI(e){return vI?globalThis.Object.getOwnPropertyNames(e).map(e=>e[0]===`^`&&e[e.length-1]===`$`?e.slice(1,e.length-1):e):[]}function _I(e){return Qj(e)?dI(e.allOf):xM(e)?fI(e.anyOf):yM(e)?pI(e.items??[]):Uj(e)?mI(e.items):lM(e)?hI(e.properties):dM(e)?gI(e.patternProperties):[]}var vI=!1;function yI(e,t){return JN(`KeyOf`,[JN(e,t)])}function bI(e){return JN(`KeyOf`,[nI(e)])}function xI(e,t){return X(oP(SI(_I(e))),t)}function SI(e){return e.map(e=>e===`[number]`?RP():FP(e))}function CI(e,t){return qj(e)?yI(e.target,e.parameters):fM(e)?bI(e.$ref):iM(e)?EI(e,t):xI(e,t)}function wI(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=CI(e[r],xj(t));return n}function TI(e,t){return wI(e.properties,t)}function EI(e,t){return QN(TI(e,t))}function DI(e){let t=[];for(let n of e)t.push(..._I(n));return zN(t)}function OI(e){return e.filter(e=>!aM(e))}function kI(e,t){let n=[];for(let r of e)n.push(...fF(r,[t]));return OI(n)}function AI(e,t){let n={};for(let r of t)n[r]=eI(kI(e,r));return n}function jI(e,t){return SF(AI(e,DI(e)),t)}function MI(e){return X({[Z]:`Date`,type:`Date`},e)}function NI(e){return X({[Z]:`Null`,type:`null`},e)}function PI(e){return X({[Z]:`Symbol`,type:`symbol`},e)}function FI(e){return X({[Z]:`Undefined`,type:`undefined`},e)}function II(e){return X({[Z]:`Uint8Array`,type:`Uint8Array`},e)}function LI(e){return X({[Z]:`Unknown`},e)}function RI(e){return e.map(e=>VI(e,!1))}function zI(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=DF(VI(e[n],!1));return t}function BI(e,t){return t===!0?e:DF(e)}function VI(e,t){return ej(e)||oj(e)?BI(WN(),t):tj(e)?DF(jF(RI(e))):pj(e)?II():ij(e)?MI():lj(e)?BI(SF(zI(e)),t):aj(e)?BI(eP([],LI()),t):mj(e)?FI():sj(e)?NI():fj(e)?PI():nj(e)?LP():cj(e)||rj(e)||dj(e)?FP(e):SF({})}function HI(e,t){return X(VI(e,!0),t)}function UI(e,t){return Jj(e)?jF(e.parameters,t):ZN(t)}function WI(e,t){if(mj(e))throw Error(`Enum undefined or empty`);let n=globalThis.Object.getOwnPropertyNames(e).filter(e=>isNaN(e)).map(t=>e[t]);return sP([...new Set(n)].map(e=>FP(e)),{...t,[Rj]:`Enum`})}var GI=class extends Pj{},Q;(function(e){e[e.Union=0]=`Union`,e[e.True=1]=`True`,e[e.False=2]=`False`})(Q||={});function KI(e){return e===Q.False?e:Q.True}function qI(e){throw new GI(e)}function JI(e){return cN(e)||QM(e)||wN(e)||EN(e)||BM(e)}function YI(e,t){return cN(t)?pL(e,t):QM(t)?lL(e,t):wN(t)?XL(e,t):EN(t)?QL(e,t):BM(t)?XI(e,t):qI(`StructuralRight`)}function XI(e,t){return Q.True}function ZI(e,t){return QM(t)?lL(e,t):wN(t)&&t.anyOf.some(e=>BM(e)||EN(e))?Q.True:wN(t)?Q.Union:EN(t)||BM(t)?Q.True:Q.Union}function QI(e,t){return EN(e)?Q.False:BM(e)?Q.Union:cN(e)?Q.True:Q.False}function $I(e,t){return fN(t)&&AL(t)?Q.True:JI(t)?YI(e,t):HM(t)?KI(nR(e.items,t.items)):Q.False}function eL(e,t){return JI(t)?YI(e,t):UM(t)?KI(nR(e.items,t.items)):Q.False}function tL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):WM(t)?Q.True:Q.False}function nL(e,t){return rN(e)||GM(e)?Q.True:Q.False}function rL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):GM(t)?Q.True:Q.False}function iL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):qM(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>KI(nR(t.parameters[n],e))===Q.True)?KI(nR(e.returns,t.returns)):Q.False:Q.False}function aL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):JM(t)?Q.True:Q.False}function oL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):YM(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>KI(nR(t.parameters[n],e))===Q.True)?KI(nR(e.returns,t.returns)):Q.False:Q.False}function sL(e,t){return iN(e)&&cj(e.const)||dN(e)||XM(e)?Q.True:Q.False}function cL(e,t){return XM(t)||dN(t)?Q.True:JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):Q.False}function lL(e,t){return t.allOf.every(t=>nR(e,t)===Q.True)?Q.True:Q.False}function uL(e,t){return e.allOf.some(e=>nR(e,t)===Q.True)?Q.True:Q.False}function dL(e,t){return JI(t)?YI(e,t):$M(t)?KI(nR(e.items,t.items)):Q.False}function fL(e,t){return iN(t)&&t.const===e.const?Q.True:JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):_N(t)?VL(e,t):dN(t)?vL(e,t):XM(t)?sL(e,t):GM(t)?nL(e,t):Q.False}function pL(e,t){return Q.False}function mL(e,t){return Q.True}function hL(e){let[t,n]=[e,0];for(;lN(t);)t=t.not,n+=1;return n%2==0?t:LI()}function gL(e,t){return lN(e)?nR(hL(e),t):lN(t)?nR(e,hL(t)):qI(`Invalid fallthrough for Not`)}function _L(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):uN(t)?Q.True:Q.False}function vL(e,t){return nN(e)||dN(e)||XM(e)?Q.True:Q.False}function yL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):XM(t)||dN(t)?Q.True:Q.False}function bL(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function xL(e){return AL(e)}function SL(e){return bL(e,0)||bL(e,1)&&`description`in e.properties&&wN(e.properties.description)&&e.properties.description.anyOf.length===2&&(_N(e.properties.description.anyOf[0])&&CN(e.properties.description.anyOf[1])||_N(e.properties.description.anyOf[1])&&CN(e.properties.description.anyOf[0]))}function CL(e){return bL(e,0)}function wL(e){return bL(e,0)}function TL(e){return bL(e,0)}function EL(e){return bL(e,0)}function DL(e){return AL(e)}function OL(e){let t=RP();return bL(e,0)||bL(e,1)&&`length`in e.properties&&KI(nR(e.properties.length,t))===Q.True}function kL(e){return bL(e,0)}function AL(e){let t=RP();return bL(e,0)||bL(e,1)&&`length`in e.properties&&KI(nR(e.properties.length,t))===Q.True}function jL(e){let t=eP([WN()],WN());return bL(e,0)||bL(e,1)&&`then`in e.properties&&KI(nR(e.properties.then,t))===Q.True}function ML(e,t){return nR(e,t)===Q.False||zM(e)&&!zM(t)?Q.False:Q.True}function NL(e,t){return EN(e)?Q.False:BM(e)?Q.Union:cN(e)||tN(e)&&xL(t)||nN(e)&&CL(t)||rN(e)&&wL(t)||vN(e)&&SL(t)||WM(e)&&TL(t)||_N(e)&&xL(t)||vN(e)&&SL(t)||dN(e)&&CL(t)||XM(e)&&CL(t)||GM(e)&&wL(t)||TN(e)&&DL(t)||JM(e)&&EL(t)||qM(e)&&kL(t)||YM(e)&&OL(t)?Q.True:mN(e)&&_N(IL(e))?t[Rj]===`Record`?Q.True:Q.False:mN(e)&&dN(IL(e))&&bL(t,0)?Q.True:Q.False}function PL(e,t){return JI(t)?YI(e,t):mN(t)?RL(e,t):fN(t)?(()=>{for(let n of Object.getOwnPropertyNames(t.properties)){if(!(n in e.properties)&&!zM(t.properties[n]))return Q.False;if(zM(t.properties[n]))return Q.True;if(ML(e.properties[n],t.properties[n])===Q.False)return Q.False}return Q.True})():Q.False}function FL(e,t){return JI(t)?YI(e,t):fN(t)&&jL(t)?Q.True:pN(t)?KI(nR(e.item,t.item)):Q.False}function IL(e){return FN in e.patternProperties?RP():IN in e.patternProperties?zP():qI(`Unknown record key pattern`)}function LL(e){return FN in e.patternProperties?e.patternProperties[FN]:IN in e.patternProperties?e.patternProperties[IN]:qI(`Unable to get record value schema`)}function RL(e,t){let[n,r]=[IL(t),LL(t)];return tN(e)&&dN(n)&&KI(nR(e,r))===Q.True?Q.True:TN(e)&&dN(n)||_N(e)&&dN(n)||HM(e)&&dN(n)?nR(e,r):fN(e)?(()=>{for(let t of Object.getOwnPropertyNames(e.properties))if(ML(r,e.properties[t])===Q.False)return Q.False;return Q.True})():Q.False}function zL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?nR(LL(e),LL(t)):Q.False}function BL(e,t){return nR(gN(e)?zP():e,gN(t)?zP():t)}function VL(e,t){return iN(e)&&dj(e.const)||_N(e)?Q.True:Q.False}function HL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):_N(t)?Q.True:Q.False}function UL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):vN(t)?Q.True:Q.False}function WL(e,t){return yN(e)?nR(JP(e),t):yN(t)?nR(e,JP(t)):qI(`Invalid fallthrough for TemplateLiteral`)}function GL(e,t){return HM(t)&&e.items!==void 0&&e.items.every(e=>nR(e,t.items)===Q.True)}function KL(e,t){return cN(e)?Q.True:EN(e)?Q.False:BM(e)?Q.Union:Q.False}function qL(e,t){return JI(t)?YI(e,t):fN(t)&&AL(t)||HM(t)&&GL(e,t)?Q.True:SN(t)?mj(e.items)&&!mj(t.items)||!mj(e.items)&&mj(t.items)?Q.False:mj(e.items)&&!mj(t.items)||e.items.every((e,n)=>nR(e,t.items[n])===Q.True)?Q.True:Q.False:Q.False}function JL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):TN(t)?Q.True:Q.False}function YL(e,t){return JI(t)?YI(e,t):fN(t)?NL(e,t):mN(t)?RL(e,t):ON(t)?eR(e,t):CN(t)?Q.True:Q.False}function XL(e,t){return t.anyOf.some(t=>nR(e,t)===Q.True)?Q.True:Q.False}function ZL(e,t){return e.anyOf.every(e=>nR(e,t)===Q.True)?Q.True:Q.False}function QL(e,t){return Q.True}function $L(e,t){return cN(t)?pL(e,t):QM(t)?lL(e,t):wN(t)?XL(e,t):BM(t)?XI(e,t):_N(t)?VL(e,t):dN(t)?vL(e,t):XM(t)?sL(e,t):GM(t)?nL(e,t):HM(t)?QI(e,t):SN(t)?KL(e,t):fN(t)?NL(e,t):EN(t)?Q.True:Q.False}function eR(e,t){return CN(e)||CN(e)?Q.True:Q.False}function tR(e,t){return QM(t)?lL(e,t):wN(t)?XL(e,t):EN(t)?QL(e,t):BM(t)?XI(e,t):fN(t)?NL(e,t):ON(t)?Q.True:Q.False}function nR(e,t){return yN(e)||yN(t)?WL(e,t):gN(e)||gN(t)?BL(e,t):lN(e)||lN(t)?gL(e,t):BM(e)?ZI(e,t):HM(e)?$I(e,t):WM(e)?tL(e,t):GM(e)?rL(e,t):UM(e)?eL(e,t):qM(e)?iL(e,t):JM(e)?aL(e,t):YM(e)?oL(e,t):XM(e)?cL(e,t):QM(e)?uL(e,t):$M(e)?dL(e,t):iN(e)?fL(e,t):cN(e)?mL(e,t):uN(e)?_L(e,t):dN(e)?yL(e,t):fN(e)?PL(e,t):mN(e)?zL(e,t):_N(e)?HL(e,t):vN(e)?UL(e,t):SN(e)?qL(e,t):pN(e)?FL(e,t):TN(e)?JL(e,t):CN(e)?YL(e,t):wN(e)?ZL(e,t):EN(e)?$L(e,t):ON(e)?tR(e,t):qI(`Unknown left type operand '${e[Z]}'`)}function rR(e,t){return nR(e,t)}function iR(e,t,n,r,i){let a={};for(let o of globalThis.Object.getOwnPropertyNames(e))a[o]=cR(e[o],t,n,r,xj(i));return a}function aR(e,t,n,r,i){return iR(e.properties,t,n,r,i)}function oR(e,t,n,r,i){return QN(aR(e,t,n,r,i))}function sR(e,t,n,r){let i=rR(e,t);return i===Q.Union?sP([n,r]):i===Q.True?n:r}function cR(e,t,n,r,i){return iM(e)?oR(e,t,n,r,i):rM(e)?X(fR(e,t,n,r,i)):X(sR(e,t,n,r),i)}function lR(e,t,n,r,i){return{[e]:cR(FP(e),t,n,r,xj(i))}}function uR(e,t,n,r,i){return e.reduce((e,a)=>({...e,...lR(a,t,n,r,i)}),{})}function dR(e,t,n,r,i){return uR(e.keys,t,n,r,i)}function fR(e,t,n,r,i){return QN(dR(e,t,n,r,i))}function pR(e,t){return hR(JP(e),t)}function mR(e,t){let n=e.filter(e=>rR(e,t)===Q.False);return n.length===1?n[0]:sP(n)}function hR(e,t,n={}){return gM(e)?X(pR(e,t),n):iM(e)?X(vR(e,t),n):X(xM(e)?mR(e.anyOf,t):rR(e,t)===Q.False?e:ZN(),n)}function gR(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=hR(e[r],t);return n}function _R(e,t){return gR(e.properties,t)}function vR(e,t){return QN(_R(e,t))}function yR(e,t){return xR(JP(e),t)}function bR(e,t){let n=e.filter(e=>rR(e,t)!==Q.False);return n.length===1?n[0]:sP(n)}function xR(e,t,n){return gM(e)?X(yR(e,t),n):iM(e)?X(wR(e,t),n):X(xM(e)?bR(e.anyOf,t):rR(e,t)===Q.False?ZN():e,n)}function SR(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=xR(e[r],t);return n}function CR(e,t){return SR(e.properties,t)}function wR(e,t){return QN(CR(e,t))}function TR(e,t){return Jj(e)?X(e.returns,t):ZN(t)}function ER(e){return DF(GF(e))}function DR(e,t,n){return X({[Z]:`Record`,type:`object`,patternProperties:{[e]:t}},n)}function OR(e,t,n){let r={};for(let n of e)r[n]=t;return SF(r,{...n,[Rj]:`Record`})}function kR(e,t,n){return DP(e)?OR($P(e),t,n):DR(e.pattern,t,n)}function AR(e,t,n){return OR($P(sP(e)),t,n)}function jR(e,t,n){return OR([e.toString()],t,n)}function MR(e,t,n){return DR(e.source,t,n)}function NR(e,t,n){return DR(mj(e.pattern)?IN:e.pattern,t,n)}function PR(e,t,n){return DR(IN,t,n)}function FR(e,t,n){return DR(LN,t,n)}function IR(e,t,n){return SF({true:t,false:t},n)}function LR(e,t,n){return DR(FN,t,n)}function RR(e,t,n){return DR(FN,t,n)}function zR(e,t,n={}){return xM(e)?AR(e.anyOf,t,n):gM(e)?kR(e,t,n):nM(e)?jR(e.const,t,n):Kj(e)?IR(e,t,n):Zj(e)?LR(e,t,n):cM(e)?RR(e,t,n):pM(e)?MR(e,t,n):mM(e)?NR(e,t,n):Vj(e)?PR(e,t,n):aM(e)?FR(e,t,n):ZN(n)}function BR(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function VR(e){let t=BR(e);return t===IN?zP():t===FN?RP():zP({pattern:t})}function HR(e){return e.patternProperties[BR(e)]}function UR(e,t){return t.parameters=rz(e,t.parameters),t.returns=iz(e,t.returns),t}function WR(e,t){return t.parameters=rz(e,t.parameters),t.returns=iz(e,t.returns),t}function GR(e,t){return t.allOf=rz(e,t.allOf),t}function KR(e,t){return t.anyOf=rz(e,t.anyOf),t}function qR(e,t){return mj(t.items)||(t.items=rz(e,t.items)),t}function JR(e,t){return t.items=iz(e,t.items),t}function YR(e,t){return t.items=iz(e,t.items),t}function XR(e,t){return t.items=iz(e,t.items),t}function ZR(e,t){return t.item=iz(e,t.item),t}function QR(e,t){let n=nz(e,t.properties);return{...t,...SF(n)}}function $R(e,t){let n=zR(iz(e,VR(t)),iz(e,HR(t)));return{...t,...n}}function ez(e,t){return t.index in e?e[t.index]:LI()}function tz(e,t){let n=zj(t),r=Bj(t),i=iz(e,t);return n&&r?ER(i):n&&!r?DF(i):!n&&r?GF(i):i}function nz(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((n,r)=>({...n,[r]:tz(e,t[r])}),{})}function rz(e,t){return t.map(t=>iz(e,t))}function iz(e,t){return Jj(t)?UR(e,t):Xj(t)?WR(e,t):Qj(t)?GR(e,t):xM(t)?KR(e,t):yM(t)?qR(e,t):Uj(t)?JR(e,t):Wj(t)?YR(e,t):$j(t)?XR(e,t):uM(t)?ZR(e,t):lM(t)?QR(e,t):dM(t)?$R(e,t):Hj(t)?ez(e,t):t}function az(e,t){return iz(t,Sj(e))}function oz(e){return X({[Z]:`Integer`,type:`integer`},e)}function sz(e,t,n){return{[e]:vz(FP(e),t,xj(n))}}function cz(e,t,n){return e.reduce((e,r)=>({...e,...sz(r,t,n)}),{})}function lz(e,t,n){return cz(e.keys,t,n)}function uz(e,t,n){return QN(lz(e,t,n))}function dz(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),n].join(``)}function fz(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),n].join(``)}function pz(e){return e.toUpperCase()}function mz(e){return e.toLowerCase()}function hz(e,t,n){let r=xP(e.pattern);return EP(r)?YP([sP(_z([...NP(r)].map(e=>FP(e)),t))],n):{...e,pattern:gz(e.pattern,t)}}function gz(e,t){return typeof e==`string`?t===`Uncapitalize`?dz(e):t===`Capitalize`?fz(e):t===`Uppercase`?pz(e):t===`Lowercase`?mz(e):e:e.toString()}function _z(e,t){return e.map(e=>vz(e,t))}function vz(e,t,n={}){return rM(e)?uz(e,t,n):gM(e)?hz(e,t,n):xM(e)?sP(_z(e.anyOf,t),n):nM(e)?FP(gz(e.const,t),n):X(e,n)}function yz(e,t={}){return vz(e,`Capitalize`,t)}function bz(e,t={}){return vz(e,`Lowercase`,t)}function xz(e,t={}){return vz(e,`Uncapitalize`,t)}function Sz(e,t={}){return vz(e,`Uppercase`,t)}function Cz(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=Nz(e[i],t,xj(n));return r}function wz(e,t,n){return Cz(e.properties,t,n)}function Tz(e,t,n){return QN(wz(e,t,n))}function Ez(e,t){return e.map(e=>Mz(e,t))}function Dz(e,t){return e.map(e=>Mz(e,t))}function Oz(e,t){let{[t]:n,...r}=e;return r}function kz(e,t){return t.reduce((e,t)=>Oz(e,t),e)}function Az(e,t,n){let r=XN(e,[Fj,`$id`,`required`,`properties`]);return SF(kz(n,t),r)}function jz(e){return sP(e.reduce((e,t)=>tM(t)?[...e,FP(t)]:e,[]))}function Mz(e,t){return Qj(e)?tI(Ez(e.allOf,t)):xM(e)?sP(Dz(e.anyOf,t)):lM(e)?Az(e,t,e.properties):SF({})}function Nz(e,t,n){let r=tj(t)?jz(t):t,i=DM(t)?$P(t):t,a=fM(e),o=fM(t);return iM(e)?Tz(e,i,n):rM(t)?Lz(e,t,n):a&&o||!a&&o||a&&!o?JN(`Omit`,[e,r],n):X({...Mz(e,i),...n})}function Pz(e,t,n){return{[t]:Nz(e,[t],xj(n))}}function Fz(e,t,n){return t.reduce((t,r)=>({...t,...Pz(e,r,n)}),{})}function Iz(e,t,n){return Fz(e,t.keys,n)}function Lz(e,t,n){return QN(Iz(e,t,n))}function Rz(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=qz(e[i],t,xj(n));return r}function zz(e,t,n){return Rz(e.properties,t,n)}function Bz(e,t,n){return QN(zz(e,t,n))}function Vz(e,t){return e.map(e=>Kz(e,t))}function Hz(e,t){return e.map(e=>Kz(e,t))}function Uz(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function Wz(e,t,n){let r=XN(e,[Fj,`$id`,`required`,`properties`]);return SF(Uz(n,t),r)}function Gz(e){return sP(e.reduce((e,t)=>tM(t)?[...e,FP(t)]:e,[]))}function Kz(e,t){return Qj(e)?tI(Vz(e.allOf,t)):xM(e)?sP(Hz(e.anyOf,t)):lM(e)?Wz(e,t,e.properties):SF({})}function qz(e,t,n){let r=tj(t)?Gz(t):t,i=DM(t)?$P(t):t,a=fM(e),o=fM(t);return iM(e)?Bz(e,i,n):rM(t)?Zz(e,t,n):a&&o||!a&&o||a&&!o?JN(`Pick`,[e,r],n):X({...Kz(e,i),...n})}function Jz(e,t,n){return{[t]:qz(e,[t],xj(n))}}function Yz(e,t,n){return t.reduce((t,r)=>({...t,...Jz(e,r,n)}),{})}function Xz(e,t,n){return Yz(e,t.keys,n)}function Zz(e,t,n){return QN(Xz(e,t,n))}function Qz(e,t){return JN(`Partial`,[JN(e,t)])}function $z(e){return JN(`Partial`,[nI(e)])}function eB(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=GF(e[n]);return t}function tB(e,t){let n=XN(e,[Fj,`$id`,`required`,`properties`]);return SF(eB(t),n)}function nB(e){return e.map(e=>rB(e))}function rB(e){return qj(e)?Qz(e.target,e.parameters):fM(e)?$z(e.$ref):Qj(e)?tI(nB(e.allOf)):xM(e)?sP(nB(e.anyOf)):lM(e)?tB(e,e.properties):Gj(e)||Kj(e)||Zj(e)||nM(e)||sM(e)||cM(e)||mM(e)||hM(e)||bM(e)?e:SF({})}function iB(e,t){return iM(e)?sB(e,t):X({...rB(e),...t})}function aB(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=iB(e[r],xj(t));return n}function oB(e,t){return aB(e.properties,t)}function sB(e,t){return QN(oB(e,t))}function cB(e,t){return JN(`Required`,[JN(e,t)])}function lB(e){return JN(`Required`,[nI(e)])}function uB(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=XN(e[n],[Lj]);return t}function dB(e,t){let n=XN(e,[Fj,`$id`,`required`,`properties`]);return SF(uB(t),n)}function fB(e){return e.map(e=>pB(e))}function pB(e){return qj(e)?cB(e.target,e.parameters):fM(e)?lB(e.$ref):Qj(e)?tI(fB(e.allOf)):xM(e)?sP(fB(e.anyOf)):lM(e)?dB(e,e.properties):Gj(e)||Kj(e)||Zj(e)||nM(e)||sM(e)||cM(e)||mM(e)||hM(e)||bM(e)?e:SF({})}function mB(e,t){return iM(e)?_B(e,t):X({...pB(e),...t})}function hB(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=mB(e[r],t);return n}function gB(e,t){return hB(e.properties,t)}function _B(e,t){return QN(gB(e,t))}function vB(e,t){return t.map(t=>fM(t)?yB(e,t.$ref):BB(e,t))}function yB(e,t){return t in e?fM(e[t])?yB(e,e[t].$ref):BB(e,e[t]):ZN()}function bB(e){return lI(e[0])}function xB(e){return mF(e[0],e[1])}function SB(e){return CI(e[0])}function CB(e){return iB(e[0])}function wB(e){return Nz(e[0],e[1])}function TB(e){return qz(e[0],e[1])}function EB(e){return mB(e[0])}function DB(e,t,n){let r=vB(e,n);return t===`Awaited`?bB(r):t===`Index`?xB(r):t===`KeyOf`?SB(r):t===`Partial`?CB(r):t===`Omit`?wB(r):t===`Pick`?TB(r):t===`Required`?EB(r):ZN()}function OB(e,t){return GN(BB(e,t))}function kB(e,t){return qN(BB(e,t))}function AB(e,t,n){return $N(zB(e,t),BB(e,n))}function jB(e,t,n){return eP(zB(e,t),BB(e,n))}function MB(e,t){return tI(zB(e,t))}function NB(e,t){return yF(BB(e,t))}function PB(e,t){return SF(globalThis.Object.keys(t).reduce((n,r)=>({...n,[r]:BB(e,t[r])}),{}))}function FB(e,t){let[n,r]=[BB(e,HR(t)),BR(t)],i=Sj(t);return i.patternProperties[r]=n,i}function IB(e,t){return fM(t)?{...yB(e,t.$ref),[Fj]:t[Fj]}:t}function LB(e,t){return jF(zB(e,t))}function RB(e,t){return sP(zB(e,t))}function zB(e,t){return t.map(t=>BB(e,t))}function BB(e,t){return Bj(t)?X(BB(e,XN(t,[Lj])),t):zj(t)?X(BB(e,XN(t,[Ij])),t):vM(t)?X(IB(e,t),t):Uj(t)?X(OB(e,t.items),t):Wj(t)?X(kB(e,t.items),t):qj(t)?X(DB(e,t.target,t.parameters)):Jj(t)?X(AB(e,t.parameters,t.returns),t):Xj(t)?X(jB(e,t.parameters,t.returns),t):Qj(t)?X(MB(e,t.allOf),t):$j(t)?X(NB(e,t.items),t):lM(t)?X(PB(e,t.properties),t):dM(t)?X(FB(e,t)):yM(t)?X(LB(e,t.items||[]),t):xM(t)?X(RB(e,t.anyOf),t):t}function VB(e,t){return t in e?BB(e,e[t]):ZN()}function HB(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:VB(e,n)}),{})}var UB=class{constructor(e){let t=HB(e),n=this.WithIdentifiers(t);this.$defs=n}Import(e,t){let n={...this.$defs,[e]:X(this.$defs[e],t)};return X({[Z]:`Import`,$defs:n,$ref:e})}WithIdentifiers(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:{...e[n],$id:n}}),{})}};function WB(e){return new UB(e)}function GB(e,t){return X({[Z]:`Not`,not:e},t)}function KB(e,t){return Xj(e)?jF(e.parameters,t):ZN()}var qB=0;function JB(e,t={}){mj(t.$id)&&(t.$id=`T${qB++}`);let n=Sj(e({[Z]:`This`,$ref:`${t.$id}`}));return n.$id=t.$id,X({[Rj]:`Recursive`,...n},t)}function YB(e,t){let n=dj(e)?new globalThis.RegExp(e):e;return X({[Z]:`RegExp`,type:`RegExp`,source:n.source,flags:n.flags},t)}function XB(e){return Qj(e)?e.allOf:xM(e)?e.anyOf:yM(e)?e.items??[]:[]}function ZB(e){return XB(e)}function QB(e,t){return Xj(e)?X(e.returns,t):ZN(t)}var $B=class{constructor(e){this.schema=e}Decode(e){return new eV(this.schema,e)}},eV=class{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let n={Encode:n=>t[Fj].Encode(e(n)),Decode:e=>this.decode(t[Fj].Decode(e))};return{...t,[Fj]:n}}EncodeSchema(e,t){let n={Decode:this.decode,Encode:e};return{...t,[Fj]:n}}Encode(e){return vM(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}};function tV(e){return new $B(e)}function nV(e={}){return X({[Z]:e[Z]??`Unsafe`},e)}function rV(e){return X({[Z]:`Void`,type:`void`},e)}var $=t({Any:()=>WN,Argument:()=>KN,Array:()=>GN,AsyncIterator:()=>qN,Awaited:()=>lI,BigInt:()=>LP,Boolean:()=>IP,Capitalize:()=>yz,Composite:()=>jI,Const:()=>HI,Constructor:()=>$N,ConstructorParameters:()=>UI,Date:()=>MI,Enum:()=>WI,Exclude:()=>hR,Extends:()=>cR,Extract:()=>xR,Function:()=>eP,Index:()=>mF,InstanceType:()=>TR,Instantiate:()=>az,Integer:()=>oz,Intersect:()=>tI,Iterator:()=>yF,KeyOf:()=>CI,Literal:()=>FP,Lowercase:()=>bz,Mapped:()=>VF,Module:()=>WB,Never:()=>ZN,Not:()=>GB,Null:()=>NI,Number:()=>RP,Object:()=>SF,Omit:()=>Nz,Optional:()=>GF,Parameters:()=>KB,Partial:()=>iB,Pick:()=>qz,Promise:()=>CF,Readonly:()=>DF,ReadonlyOptional:()=>ER,Record:()=>zR,Recursive:()=>JB,Ref:()=>nI,RegExp:()=>YB,Required:()=>mB,Rest:()=>ZB,ReturnType:()=>QB,String:()=>zP,Symbol:()=>PI,TemplateLiteral:()=>YP,Transform:()=>tV,Tuple:()=>jF,Uint8Array:()=>II,Uncapitalize:()=>xz,Undefined:()=>FI,Union:()=>sP,Unknown:()=>LI,Unsafe:()=>nV,Uppercase:()=>Sz,Void:()=>rV}),iV={additionalProperties:!1},aV=$.String({pattern:`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`,minLength:36,maxLength:36}),oV=$.String({pattern:`^[a-z0-9][a-z0-9-]{0,31}(?![\\s\\S])`,minLength:1,maxLength:32}),sV=$.String({pattern:`^sha256:[0-9a-f]{64}$`,minLength:71,maxLength:71}),cV=$.String({pattern:`^[A-Za-z0-9_-]{43}$`,minLength:43,maxLength:43}),lV=$.String({pattern:`^dpt_[A-Za-z0-9_-]{43}$`,minLength:47,maxLength:47}),uV=`[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}`,dV=`^(?:${uV}|[A-Z2-7]{12}|[A-Z2-7]{8})(?![\\s\\S])`,fV=$.String({pattern:dV,minLength:8,maxLength:36}),pV=new RegExp(dV),mV=/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/;function hV(e){return typeof e!=`string`||e.length>36?!1:pV.test(e)}function gV(e){if(typeof e!=`string`)return;if(mV.test(e)){let t=e.toLowerCase();return hV(t)?t:void 0}let t=e.replace(/[\s-]+/g,``).toUpperCase();if(hV(t)&&!(/[\s-]/.test(e)&&t.length!==12))return t}$.Object({type:$.Literal(`pair.request`),v:$.Literal(1),requestId:aV,code:fV,deviceUid:aV,deviceName:$.String({minLength:1,maxLength:64}),hostname:$.Optional($.String({minLength:1,maxLength:128})),platform:$.Optional($.String({minLength:1,maxLength:64})),publicKey:$.String({minLength:1,maxLength:256}),keyFingerprint:sV,clientTime:$.Integer(),hubNonce:$.Optional(cV)},iV),$.Object({type:$.Literal(`pair.device-request`),v:$.Literal(1),requestId:aV,deviceUid:aV,deviceName:$.String({minLength:1,maxLength:64}),hostname:$.Optional($.String({minLength:1,maxLength:128})),platform:$.Optional($.String({minLength:1,maxLength:64})),publicKey:$.String({minLength:1,maxLength:256}),keyFingerprint:sV,clientTime:$.Integer(),hubNonce:$.Optional(cV)},iV);var _V=$.Object({type:$.Literal(`pair.challenge`),v:$.Literal(1),enrollmentId:aV,nonce:cV,issuedAt:$.Integer(),hubId:aV,hubPublicKey:$.Optional($.String({minLength:1,maxLength:256})),hubKeyFingerprint:$.Optional(sV),hubSignature:$.Optional($.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86}))},iV);$.Object({type:$.Literal(`pair.device-ack`),v:$.Literal(1),codeId:aV,code:fV,expiresAt:$.Integer(),hubOrigin:$.String(),hubId:aV,challenge:_V},iV),$.Object({type:$.Literal(`pair.response`),v:$.Literal(1),enrollmentId:aV,nonce:cV,signature:$.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86})},iV),$.Object({type:$.Literal(`pair.pending`),v:$.Literal(1),enrollmentId:aV,state:$.Literal(`awaiting_approval`),expiresAt:$.Integer(),pollAfterMs:$.Integer({minimum:1})},iV),$.Object({type:$.Literal(`pair.token`),v:$.Literal(1),enrollmentId:aV,deviceUid:aV,deviceId:oV,pairingEpoch:aV,credentialId:aV,generation:$.Integer({minimum:1}),hubId:aV,hubOrigin:$.String(),hubUrl:$.String(),tunnelToken:lV,issuedAt:$.Integer(),expiresAt:$.Null(),hubKeyFingerprint:$.Optional(sV)},iV),$.Object({enrollmentId:aV,deviceUid:aV,keyFingerprint:sV,replaceKey:$.Optional($.Boolean())},iV),$.Object({type:$.Literal(`pair.revoke`),v:$.Literal(1),deviceId:oV,pairingEpoch:aV,reason:$.Union([$.Literal(`user`),$.Literal(`compromise`),$.Literal(`hub_migrated`)]),revokedAt:$.Integer()},iV);var vV=$.Object({type:$.Literal(`pair.error`),v:$.Literal(1),code:$.Union([$.Literal(`code_invalid`),$.Literal(`code_expired`),$.Literal(`code_used`),$.Literal(`code_in_use`),$.Literal(`rate_limited`),$.Literal(`signature_invalid`),$.Literal(`clock_skew`),$.Literal(`paired_elsewhere`),$.Literal(`hub_required`),$.Literal(`fingerprint_mismatch`),$.Literal(`identity_conflict`),$.Literal(`enrollment_lost`),$.Literal(`enrollment_cancelled`),$.Literal(`already_issued`),$.Literal(`challenge_expired`)]),message:$.String({maxLength:512}),retryAfterMs:$.Optional($.Integer({minimum:1}))},iV);$.Object({type:$.Literal(`pair.code`),v:$.Literal(1),codeId:aV,code:fV,expiresAt:$.Integer(),hubOrigin:$.String({maxLength:2048}),pairUrl:$.String({maxLength:4096}),offerUrl:$.Optional($.String({maxLength:2048}))},iV);var yV=$.Union([$.Literal(`open`),$.Literal(`awaiting_proof`),$.Literal(`awaiting_approval`),$.Literal(`approved`),$.Literal(`issued`),$.Literal(`connected`),$.Literal(`cancelled`),$.Literal(`expired`)]);$.Object({type:$.Literal(`pair.code-state`),v:$.Literal(1),codeId:aV,expiresAt:$.Integer(),phase:yV,enrollment:$.Optional($.Object({enrollmentId:aV,deviceUid:aV,deviceName:$.String({minLength:1,maxLength:64}),keyFingerprint:sV,proofVerified:$.Boolean(),keyChanged:$.Boolean()},iV)),deviceId:$.Optional(oV),error:$.Optional(vV)},iV);function bV(e){if(typeof e!=`string`||e.length===0||e.length>2048)return{ok:!1,error:`origin: empty or too long`};if(/\s|\n|\r|\t/.test(e))return{ok:!1,error:`origin: whitespace not allowed`};let t;try{t=new URL(e)}catch{return{ok:!1,error:`origin: not a valid URL`}}return t.protocol!==`https:`&&!(t.protocol===`http:`&&/^(127\.0\.0\.1|\[::1\]|localhost)$/.test(t.hostname))?{ok:!1,error:`origin: HTTPS origin required`}:t.username||t.password?{ok:!1,error:`origin: userinfo not allowed`}:t.search||t.hash?{ok:!1,error:`origin: query/fragment not allowed`}:t.pathname!==`/`&&t.pathname!==``?{ok:!1,error:`origin: base path not allowed`}:{ok:!0,origin:t.origin,tunnelUrl:`${t.origin}/api/tunnel`}}function xV(e){if(e!==``&&/^[A-Za-z0-9_-]+$/.test(e))try{let t=atob(e.replace(/-/g,`+`).replace(/_/g,`/`)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch{return}}var SV=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,CV=RegExp(`^${uV}$`),wV=/^sha256:[0-9a-f]{64}$/;function TV(e){let t=xV(e);if(!t||t.length>1024)return;let n;try{n=JSON.parse(new TextDecoder().decode(t))}catch{return}if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n;if(r.v!==2&&r.v!==3)return;let i=r.v===3?6:5;if(Object.keys(r).length!==i||typeof r.hub!=`string`)return;let a=bV(r.hub);if(a.ok&&a.origin===r.hub&&typeof r.id==`string`&&SV.test(r.id)&&typeof r.code==`string`&&CV.test(r.code)&&typeof r.exp==`number`&&Number.isSafeInteger(r.exp))return r.v===3?typeof r.kfp!=`string`||!wV.test(r.kfp)?void 0:{v:3,hub:r.hub,id:r.id,code:r.code,exp:r.exp,kfp:r.kfp}:{v:2,hub:r.hub,id:r.id,code:r.code,exp:r.exp}}function EV(e,t=Date.now()){let n=TV(e);if(n&&!(n.exp<t-3e4)&&!(n.exp>t+6e5))return n}function DV(e,t=Date.now()){let n;try{n=new URL(e)}catch{return}if(!/^\/pair\/?$/.test(n.pathname)||n.username||n.password||n.search||!n.hash.startsWith(`#offer=`))return;let r=EV(n.hash.slice(7),t);if(r&&r.hub===n.origin)return{offer:r,rest:`${n.origin}/pair`}}function OV(e){if(!/^\/pair\/?$/.test(e.pathname))return;if(e.hash.startsWith(`#offer=`)){let t=DV(e.href);if(t)return{code:t.offer.code,origin:e.origin,offerFragment:e.hash.slice(1)};let n=EV(e.hash.slice(7));return n&&n.hub!==e.origin?{error:`This pairing link does not belong to this hub. Open the original hub link instead.`}:{error:`Invalid pairing link. Use a complete link from the hub wizard.`}}let t=e.searchParams;if(!t.has(`code`)&&!t.has(`origin`)&&!t.has(`v`))return;let n=t.get(`code`),r=n===null?void 0:gV(n);if(e.username||e.password||e.hash||t.getAll(`code`).length!==1||!r||t.getAll(`v`).length!==1||t.get(`v`)!==`1`)return{error:`Invalid pairing link. Use a complete version 1 link from the hub wizard.`};if(t.has(`origin`))try{let n=new URL(t.get(`origin`));if(t.getAll(`origin`).length!==1||n.origin!==e.origin||n.pathname!==`/`||n.username||n.password||n.search||n.hash)throw Error(`origin mismatch`)}catch{return{error:`This pairing link does not belong to this hub. Open the original hub link instead.`}}return{code:r,origin:e.origin}}var kV=e=>/^\/pair\/?$/.test(e.pathname)?`/`:void 0,AV=e=>/^\/pair\/?$/.test(e.pathname)&&OV(e)===void 0?`/`:void 0,jV=4e3;async function MV(e){if(!e.needsCancel)return{closed:!0,confirmed:!0};let t,n=await Promise.race([e.cancel().catch(()=>`failed`),new Promise(n=>t=setTimeout(()=>n(`failed`),e.timeoutMs))]);return clearTimeout(t),{closed:n!==`issued`,confirmed:n===`cancelled`}}var NV={class:`modal pair-wizard`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pair-title`},PV={key:1,class:`pair-pending`,"aria-label":`Machines waiting for approval`},FV={class:`who`},IV={key:0,class:`muted`},LV={key:1,class:`muted`},RV={class:`fp`},zV={class:`row`},BV={class:`phase`},VV=[`onClick`],HV={key:2,class:`hint`},UV={class:`pair-steps`,"aria-label":`Pairing progress`},WV={class:`pair-grid`},GV={class:`pair-code-box`},KV={class:`pair-code`,"aria-label":`Pairing code`},qV={class:`pair-copy-actions`},JV=[`innerHTML`],YV={class:`pair-side`},XV={key:0,class:`hint`},ZV={class:`pair-fingerprint`},QV={class:`fp`},$V={class:`pair-confirm`},eH={key:0,class:`pair-confirm warn`},tH=[`disabled`],nH=[`disabled`],rH={class:`hint`},iH=[`disabled`],aH={key:5,class:`error`,role:`alert`},oH={key:4},sH={class:`error`,role:`alert`},cH=Er({__name:`PairDeviceWizard`,props:{handoff:{}},emits:[`close`],setup(e,{expose:t,emit:n}){let r=n,i=e,a=A(`boot`),o=A(),s=A(),c=A(),l=A(``),u=A(!1),d=A(!1),f=A(!1),p=A(!1),m=A(!1),h=A(!1),g=A(),_=A([]),v=U(()=>{let e=s.value?.code??``;return!hV(e)||e.includes(`-`)?e:(e.match(/.{4}/g)??[]).join(`-`)}),y=U(()=>s.value?Ib(s.value):``),b=U(()=>y.value?KA(y.value,148):``),x=U(()=>c.value?.enrollment?.keyFingerprint??``),S=U(()=>c.value?.deviceId??``);N(S,e=>{g.value?.(),e&&(g.value=N(()=>Ju.devices.value.find(t=>t.id===e)?.status,e=>{e===`online`&&(Y(`Device paired and online.`),g.value?.(),g.value=void 0)},{immediate:!0}))});async function C(e){a.value=`boot`,l.value=``,f.value=!1,p.value=!1,c.value=void 0,s.value=void 0,o.value?.close();let t=zb();o.value=t;try{let n=e?await Lb.resolveCode(e):await Lb.createCode();if(t.closed()){await Lb.cancel(n.codeId).catch(()=>{Y(`The late pairing code could not be cancelled. Check device credentials before retrying.`)});return}if(s.value=n,a.value=`code`,e){let e=kV(new URL(window.location.href));e&&window.history.replaceState(window.history.state,``,e)}Hb(t,n.codeId,{intervalMs:1e3,onState:e=>{c.value=e,e.phase===`awaiting_proof`?a.value=`proof`:e.phase===`awaiting_approval`||e.phase===`approved`?a.value=`approve`:e.phase===`issued`||e.phase===`connected`?a.value=`issued`:e.phase===`cancelled`?a.value=`cancelled`:e.phase===`expired`&&(a.value=`expired`)}}).catch(e=>{t.closed()||(l.value=e instanceof Error?e.message:String(e),a.value=`expired`)})}catch(e){l.value=e instanceof Error?e.message:String(e),a.value=`expired`}}async function ee(){let e=c.value,t=o.value;if(e?.enrollment&&t&&!u.value){u.value=!0,l.value=``;try{let t=await Lb.approve(s.value.codeId,{enrollmentId:e.enrollment.enrollmentId,deviceUid:e.enrollment.deviceUid,keyFingerprint:e.enrollment.keyFingerprint,...p.value?{replaceKey:!0}:{}});c.value=t,(t.phase===`issued`||t.phase===`connected`)&&(a.value=`issued`)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}}async function te(e){if(!s.value)return`cancelled`;try{let t=await Lb.cancel(s.value.codeId,void 0,e);return c.value=t,o.value&&(o.value.state=t),a.value=t.phase===`expired`?`expired`:`cancelled`,o.value?.close(),`cancelled`}catch(e){if(e instanceof Sl&&e.status===409&&String(e.code)===`already_issued`){let e=await Lb.codeState(s.value.codeId).catch(()=>void 0);return e&&(c.value=e,o.value&&(o.value.state=e)),a.value=`issued`,l.value=`Credential already issued. Closing does not revoke it; choose Revoke explicitly if needed.`,`issued`}return l.value=e instanceof Error?e.message:String(e),`failed`}}let ne=()=>te(!1),re=()=>[`issued`,`connected`,`cancelled`,`expired`].includes(c.value?.phase??``);async function w(){let e=S.value;if(e){u.value=!0;try{await Lb.revoke(e,`user`),Y(`Issued credential revoked.`),r(`close`)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}}async function ie(){if(s.value)try{await navigator.clipboard.writeText(s.value.code),m.value=!0,setTimeout(()=>m.value=!1,1500)}catch{l.value=`Clipboard unavailable; copy the code manually.`}}async function ae(){if(s.value)try{await navigator.clipboard.writeText(s.value.offerUrl??s.value.pairUrl),h.value=!0,setTimeout(()=>h.value=!1,1500)}catch{l.value=`Clipboard unavailable; copy the link manually.`}}async function oe(){if(!d.value){d.value=!0,u.value=!0;try{let e=await MV({needsCancel:!!s.value&&!re(),cancel:ne,timeoutMs:jV});if(!e.closed)return;o.value?.close(),g.value?.(),e.confirmed||Y(`Pairing cancellation was not confirmed. The code expires on its own; check device credentials before retrying.`),r(`close`)}finally{d.value=!1,u.value=!1}}}t({close:oe});let se;async function ce(){try{_.value=(await Lb.pending()).codes}catch{}}async function le(e){s.value=void 0,c.value=void 0,l.value=``;let t=zb();o.value=t,a.value=e.phase===`approved_ready`?`approve`:`proof`,Hb(t,e.codeId,{intervalMs:1e3,onState:e=>{c.value=e,e.phase===`awaiting_proof`?a.value=`proof`:e.phase===`awaiting_approval`||e.phase===`approved`?a.value=`approve`:e.phase===`issued`||e.phase===`connected`?a.value=`issued`:e.phase===`cancelled`?a.value=`cancelled`:e.phase===`expired`&&(a.value=`expired`)}}).catch(e=>{l.value=e instanceof Error?e.message:String(e)})}return Vr(()=>{if(ce(),se=setInterval(()=>void ce(),3e3),i.handoff&&`error`in i.handoff){l.value=i.handoff.error,a.value=`expired`;return}C(i.handoff?.code)}),Wr(()=>{clearInterval(se);let e=o.value;e&&!e.closed()&&s.value&&!re()&&te(!0).then(e=>{e!==`cancelled`&&Y(`Pairing cancellation was not confirmed. Check device credentials before retrying.`)}),e?.close(),g.value?.()}),(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:ks(oe,[`self`])},[z(`div`,NV,[z(`header`,null,[t[5]||=z(`h2`,{id:`pair-title`},`Pair a device`,-1),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,onClick:oe},[B(j(xl),{size:18})])]),i.handoff&&`offerFragment`in i.handoff&&i.handoff.offerFragment?(I(),R($A,{key:0,"offer-fragment":i.handoff.offerFragment},null,8,[`offer-fragment`])):H(``,!0),_.value.length?(I(),L(`section`,PV,[t[6]||=z(`h3`,null,`Machines waiting for you`,-1),z(`ul`,null,[(I(!0),L(F,null,P(_.value,e=>(I(),L(`li`,{key:e.codeId},[z(`div`,FV,[z(`strong`,null,D(e.deviceName??`unnamed device`),1),e.hostname?(I(),L(`span`,IV,D(e.hostname),1)):H(``,!0),e.platform?(I(),L(`span`,LV,D(e.platform),1)):H(``,!0)]),z(`div`,RV,D(e.keyFingerprint),1),z(`div`,zV,[z(`span`,BV,D(e.phase.replaceAll(`_`,` `)),1),z(`button`,{type:`button`,class:`small`,onClick:t=>le(e)},`Review`,8,VV)])]))),128))]),t[7]||=z(`p`,{class:`hint`},` Compare each fingerprint with the machine's own terminal before approving. Codes are minted by the hub — nothing has to be copied to the machine. `,-1)])):H(``,!0),a.value===`boot`?(I(),L(`p`,HV,`Minting a pairing code…`)):s.value?(I(),L(F,{key:3},[z(`ol`,UV,[t[8]||=z(`li`,{class:E({on:!0})},`Code`,-1),z(`li`,{class:E({on:[`proof`,`approve`,`issued`].includes(a.value)})},`Proof`,2),z(`li`,{class:E({on:[`approve`,`issued`].includes(a.value)})},`Fingerprint`,2),z(`li`,{class:E({on:a.value===`issued`})},`Online`,2)]),z(`div`,WV,[z(`div`,GV,[z(`div`,KV,D(v.value),1),z(`div`,qV,[z(`button`,{type:`button`,class:`small`,onClick:ie},[B(j(sc),{size:14}),V(` `+D(m.value?`Copied`:`Copy code`),1)]),z(`button`,{type:`button`,class:`small`,onClick:ae,title:`Self-contained link: hub, code and expiry all in the fragment — it never reaches server logs`},[B(j(sc),{size:14}),V(` `+D(h.value?`Copied link`:`Copy link`),1)])]),t[9]||=z(`p`,{class:`hint`},` Run the device pairing command and scan, or enter this code on the device. Expires in 5 minutes. `,-1),z(`div`,{class:`pair-qr`,"aria-label":`Pairing QR code`,title:`Same offer link as Copy link: hub, code and expiry all in the #offer= fragment — it never reaches server logs`,innerHTML:b.value},null,8,JV)]),z(`div`,YV,[a.value===`code`||a.value===`proof`?(I(),L(`p`,XV,[B(j($c),{size:14,class:`spin`}),t[10]||=V(` Waiting for the device to submit its signing proof… `,-1)])):a.value===`approve`?(I(),L(F,{key:1},[z(`div`,ZV,[t[11]||=z(`h3`,null,`Device key fingerprint`,-1),z(`code`,QV,D(x.value),1),t[12]||=z(`p`,{class:`hint`},` Compare ALL 64 hex characters with the fingerprint shown on the device screen. `,-1)]),z(`label`,$V,[M(z(`input`,{"onUpdate:modelValue":t[0]||=e=>f.value=e,type:`checkbox`},null,512),[[bs,f.value]]),t[13]||=V(` The fingerprint matches the device display exactly `,-1)]),c.value?.enrollment?.keyChanged?(I(),L(`label`,eH,[M(z(`input`,{"onUpdate:modelValue":t[1]||=e=>p.value=e,type:`checkbox`},null,512),[[bs,p.value]]),B(j(ol),{size:14}),t[14]||=V(` Device is already paired with a DIFFERENT key — replace the stored key (replaceKey) `,-1)])):H(``,!0),z(`button`,{type:`button`,class:`primary`,disabled:!f.value||u.value||c.value?.enrollment?.keyChanged===!0&&!p.value,onClick:ee},` Approve device `,8,tH),z(`button`,{type:`button`,class:`small`,disabled:u.value,onClick:ne},` Cancel pairing `,8,nH)],64)):a.value===`issued`?(I(),L(F,{key:2},[z(`p`,rH,[B(j(ic),{size:14}),t[15]||=V(` Credential issued. The device is connecting through the tunnel — you will get a toast once the monitor probe reports it online. `,-1)]),z(`button`,{type:`button`,class:`small`,onClick:oe},`Close`),z(`button`,{type:`button`,class:`small danger`,disabled:!S.value||u.value,title:`Mistaken approval? Revoke the credential now.`,onClick:w},` Revoke this credential `,8,iH)],64)):a.value===`cancelled`?(I(),L(F,{key:3},[t[16]||=z(`p`,{class:`hint`},`Pairing was cancelled (or the signature failed too many times).`,-1),z(`button`,{type:`button`,class:`small`,onClick:t[2]||=e=>C()},`Start over`)],64)):a.value===`expired`?(I(),L(F,{key:4},[t[17]||=z(`p`,{class:`hint`},`The pairing code expired.`,-1),z(`button`,{type:`button`,class:`small`,onClick:t[3]||=e=>C()},`New code`)],64)):H(``,!0),l.value?(I(),L(`p`,aH,D(l.value),1)):H(``,!0)])])],64)):(I(),L(`div`,oH,[z(`p`,sH,D(l.value||`This pairing link is unavailable.`),1),z(`button`,{type:`button`,class:`small`,onClick:t[4]||=e=>C()},`New code`)]))])]))}}),lH={class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`device-credentials-title`},uH={class:`hint`},dH={key:1,class:`hint`},fH=Er({__name:`DeviceCredentialsDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=U(()=>Ju.devices.value.find(e=>e.id===n.deviceId));return(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:t[2]||=ks(e=>r(`close`),[`self`])},[z(`section`,lH,[z(`header`,null,[t[3]||=z(`h2`,{id:`device-credentials-title`},`Device credentials`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close device credentials`,onClick:t[0]||=e=>r(`close`)},[B(j(xl),{size:18})])]),i.value?(I(),L(F,{key:0},[z(`p`,null,[V(D(i.value.name)+` `,1),z(`code`,null,D(i.value.id),1)]),z(`p`,uH,D(i.value.status)+` · tunnel `+D(i.value.tunnel?.state??`disconnected`)+` · `+D(i.value.tunnel?.readerCount??0)+` readers `,1),B(Zb,{device:i.value},null,8,[`device`])],64)):(I(),L(`p`,dH,`This device is no longer in the registry.`)),z(`footer`,null,[z(`button`,{class:`secondary`,onClick:t[1]||=e=>r(`close`)},`Close`)])])]))}}),pH={id:`prompt-title`},mH=[`disabled`],hH={key:0,class:`hint`},gH={key:1},_H={key:0,class:`muted`},vH=[`placeholder`,`disabled`],yH=[`required`,`placeholder`,`aria-label`,`disabled`],bH={key:2,class:`message-error`,role:`alert`},xH=[`disabled`],SH=[`disabled`],CH=Er({__name:`PromptDialog`,props:{dialog:{}},emits:[`close`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=A(r.dialog.value??``),o=A(!1),s=A(``),c=A(),l=!!r.dialog.label;async function u(){if(!o.value&&(!l||r.dialog.optional||a.value.trim())){o.value=!0,s.value=``;try{await r.dialog.run(a.value.trim()),i(`close`)}catch(e){s.value=K(e)}finally{o.value=!1}}}return Vr(()=>void kn(()=>(c.value?.focus(),c.value?.select()))),t({busy:o}),(t,n)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:n[4]||=ks(e=>!o.value&&i(`close`),[`self`])},[z(`form`,{class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`prompt-title`,onSubmit:ks(u,[`prevent`])},[z(`header`,null,[z(`h2`,pH,D(e.dialog.title),1),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,disabled:o.value,onClick:n[0]||=e=>i(`close`)},[B(j(xl),{size:18})],8,mH)]),e.dialog.hint?(I(),L(`p`,hH,D(e.dialog.hint),1)):H(``,!0),l?(I(),L(`label`,gH,[V(D(e.dialog.label)+` `,1),e.dialog.optional?(I(),L(`span`,_H,`(optional)`)):H(``,!0),e.dialog.multiline?M((I(),L(`textarea`,{key:1,ref_key:`input`,ref:c,"onUpdate:modelValue":n[1]||=e=>a.value=e,rows:`4`,placeholder:e.dialog.placeholder,disabled:o.value},null,8,vH)),[[ys,a.value]]):M((I(),L(`input`,{key:2,ref_key:`input`,ref:c,"onUpdate:modelValue":n[2]||=e=>a.value=e,maxlength:`100`,required:!e.dialog.optional,placeholder:e.dialog.placeholder,"aria-label":e.dialog.label,disabled:o.value},null,8,yH)),[[ys,a.value]])])):H(``,!0),s.value?(I(),L(`p`,bH,D(s.value),1)):H(``,!0),z(`footer`,null,[z(`button`,{type:`button`,class:`secondary`,disabled:o.value,onClick:n[3]||=e=>i(`close`)},` Cancel `,8,xH),z(`button`,{class:E([`primary`,{danger:e.dialog.danger}]),disabled:o.value||l&&!e.dialog.optional&&!a.value.trim()},D(o.value?`Working…`:e.dialog.submit),11,SH)])],32)]))}}),wH={class:`modal model-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":`Model picker`},TH={class:`eyebrow`},EH={class:`model-list`},DH={key:0,class:`model-row off-catalog`,"aria-disabled":`true`},OH=[`src`],kH=[`onClick`],AH=[`src`],jH={class:`hint`},MH=Er({__name:`ModelPicker`,emits:[`close`],setup(e,{emit:t}){let n=t,r=A(``),i=A();Vr(()=>void kn(()=>i.value?.focus()));let a=U(()=>vd.value.filter(e=>`${e.name} ${e.id} ${e.tier}`.toLowerCase().includes(r.value.toLowerCase()))),o=e=>{let t=Ed.value;return!!t&&e.id===t.modelId&&e.provider===t.provider},s=U(()=>{let e=Ed.value;return e&&!vd.value.some(t=>t.provider===e.provider&&t.id===e.modelId)?e:void 0});async function c(e){await Fd(()=>ld.value.configure({model:{provider:e.provider,modelId:e.id}}))&&(await Ad(),Y(`Model saved. Used on the next turn.`),n(`close`))}return(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:t[2]||=ks(e=>n(`close`),[`self`])},[z(`section`,wH,[z(`header`,null,[z(`div`,null,[z(`span`,TH,`PER AGENT · `+D(j(nd)?.name??j(nd)?.id),1),t[3]||=z(`h2`,null,`Choose a model`,-1)]),z(`button`,{class:`icon-button`,"aria-label":`Close model picker`,onClick:t[0]||=e=>n(`close`)},[B(j(xl),{size:18})])]),M(z(`input`,{ref_key:`searchInput`,ref:i,"onUpdate:modelValue":t[1]||=e=>r.value=e,placeholder:`Search models or tiers…`,"aria-label":`Search models`},null,512),[[ys,r.value]]),z(`div`,EH,[s.value?(I(),L(`div`,DH,[z(`img`,{src:j(zd)(s.value.modelId),alt:``},null,8,OH),z(`div`,null,[z(`strong`,null,D(s.value.modelId),1),z(`small`,null,D(s.value.provider)+` / current · not in this device's catalog`,1)])])):H(``,!0),(I(!0),L(F,null,P(a.value,e=>(I(),L(`button`,{key:`${e.provider}/${e.id}`,class:E({selected:o(e)}),onClick:t=>c(e)},[z(`img`,{src:j(zd)(e.id),alt:``},null,8,AH),z(`div`,null,[z(`strong`,null,D(e.name),1),z(`small`,null,D(e.tier)+` / `+D(e.provider)+` / `+D(j(Ld)(e.contextWindow))+` context`,1)]),o(e)?(I(),R(j(tc),{key:0,size:18})):H(``,!0)],10,kH))),128))]),z(`p`,jH,`Models available on `+D(j(nd)?.id)+`. Provider keys stay on the device.`,1)])]))}}),NH={class:`dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`help-title`},PH={class:`dialog-head`},FH={class:`dialog-body`},IH={class:`n`},LH={class:`body`},RH={class:`help-callout`},zH={class:`dialog-foot`},BH={class:`right`},VH=Er({__name:`HelpDialog`,setup(e){let t=[{title:`Pick a device, start a session`,body:`Every device in the tree runs dpi-backend. A session gets its own SQLite database on that device, in the directory you choose.`},{title:`Send work, then close the browser`,body:`The device owns the run. Reopening restores committed messages, state and live progress.`},{title:`Change state and fork`,body:`Edit App State by hand or through the agent. Every session and fork on a device shares it.`},{title:`Interrupt deliberately`,body:`Interrupt stops foreground work and owned subagents. Background jobs continue. Stop all includes them.`},{title:`Explore the boundaries`,body:`Queue a follow-up, steer after tools, wait for approval, compact context, reset or inspect raw state.`},{title:`Restart a device`,body:`Its tree dims and shows the restart command. Checkpointed jobs recover on boot. Replay-safe tools may rerun. Other interrupted tools return an error.`}];return(e,n)=>(I(),L(`div`,{class:`scrim`,onClick:n[2]||=ks(e=>j(J).dialog=void 0,[`self`])},[z(`section`,NH,[z(`div`,PH,[n[3]||=z(`div`,null,[z(`span`,{class:`dialog-eyebrow`},`LEARN BY DOING`),z(`h3`,{id:`help-title`},`What makes this durable?`)],-1),z(`button`,{class:`icon-button`,"aria-label":`Close help`,onClick:n[0]||=e=>j(J).dialog=void 0},[B(j(xl),{size:18})])]),z(`div`,FH,[(I(),L(F,null,P(t,(e,t)=>z(`div`,{key:e.title,class:`help-step`},[z(`span`,IH,D(String(t+1).padStart(2,`0`)),1),z(`div`,null,[z(`b`,null,D(e.title),1),z(`div`,LH,D(e.body),1)])])),64)),z(`div`,RH,[B(j(Oc),{size:18}),n[4]||=z(`span`,null,`Durable does not mean exactly-once external effects. Checkpoints protect progress. Tools still need their own idempotency.`,-1)])]),z(`div`,zH,[z(`div`,BH,[z(`button`,{class:`secondary`,type:`button`,onClick:n[1]||=e=>j(J).dialog=void 0},`Close`)])])])]))}}),HH=Wt({needed:!1,busy:!1,error:``}),UH=new Set,WH=e=>{let t=[...UH];UH=new Set;for(let n of t)n(e)},GH=()=>new Promise(e=>UH.add(e));async function KH(e){if(HH.busy||!e)return!1;HH.busy=!0,HH.error=``;try{let t=await fetch(`/api/session`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})});return await t.text().catch(()=>``),t.ok?(HH.needed=!1,WH(!0),!0):(HH.error=t.status===401?`That token was not accepted.`:t.status===429?`Too many attempts. Wait a minute and try again.`:`Login failed (${t.status}).`,!1)}catch{return HH.error=`Cannot reach the hub.`,!1}finally{HH.busy=!1}}var qH=e=>{try{return new URL(e,location.href).pathname===`/api/session`}catch{return e===`/api/session`}};function JH(e){return(async(t,n)=>{let r=()=>e(t,n),i=await r();if(i.status!==401||qH(typeof t==`string`?t:t instanceof URL?t.href:t.url)||n?.body instanceof ReadableStream)return i;HH.needed=!0;let a=await i.text().catch(()=>``);return await GH()?r():new Response(a,{status:i.status,headers:i.headers})})}function YH(){typeof window>`u`||window.__adminFetch||(window.__adminFetch=!0,window.fetch=JH(window.fetch.bind(window)))}var XH={class:`login-veil`,"data-testid":`login-card`},ZH=[`disabled`],QH={key:0,class:`message-error`,role:`alert`},$H=[`disabled`],eU=Er({__name:`LoginCard`,setup(e){let t=A(``),n=A();async function r(){if(HH.busy||!t.value.trim())return;let e=await KH(t.value.trim());t.value=``,e&&n.value?.blur()}return Vr(()=>void kn(()=>n.value?.focus())),(e,i)=>(I(),L(`div`,XH,[z(`form`,{class:`modal login-card`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`login-title`,onSubmit:ks(r,[`prevent`])},[i[2]||=z(`header`,null,[z(`h2`,{id:`login-title`},`Admin token`)],-1),i[3]||=z(`p`,{class:`hint`},[V(` This hub is locked. Sign in with the token from its `),z(`code`,null,`admin.token`),V(` file. `)],-1),i[4]||=z(`label`,{for:`admin-token`},`Admin token`,-1),M(z(`input`,{id:`admin-token`,ref_key:`input`,ref:n,"onUpdate:modelValue":i[0]||=e=>t.value=e,type:`password`,name:`admin-token`,autocomplete:`off`,spellcheck:`false`,placeholder:`adm_…`,"aria-label":`Admin token`,disabled:j(HH).busy,onKeydown:i[1]||=js(e=>j(HH).error=``,[`esc`])},null,40,ZH),[[ys,t.value]]),j(HH).error?(I(),L(`p`,QH,D(j(HH).error),1)):H(``,!0),z(`footer`,null,[z(`button`,{class:`primary`,type:`submit`,disabled:j(HH).busy||!t.value.trim()},D(j(HH).busy?`Checking…`:`Sign in`),9,$H)])],32)]))}}),tU={key:0,class:`toast`,role:`status`},nU=Er({__name:`Toast`,setup(e){return(e,t)=>(I(),R(bo,{name:`toast`},{default:Vn(()=>[j(J).toast?(I(),L(`div`,tU,[B(j(tc),{size:18}),V(D(j(J).toast),1)])):H(``,!0)]),_:1}))}});function rU(e,t=!1){return e.kind===`pair`?`pair`:e.kind===`prompt`&&t?`keep`:`close`}var iU={class:`shell`,"data-testid":`app-shell`},aU={key:0,class:`error-banner`,role:`alert`},oU={key:4,class:`welcome`,"data-testid":`welcome-empty`},sU=[`disabled`],cU={class:`welcome-features`},lU={class:`build-stamp`},uU={class:`modal path-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`path-title`},dU={class:`full-directory`},fU=Er({__name:`App`,setup(e){let t=()=>Ju.devices.value.filter(e=>e.status===`online`).length,n=A(),r=A();function i(){J.dialog={kind:`new-session`,deviceId:q.value?.deviceId}}function a(e){let t=J.dialog?void 0:Qd(e);if(t)return e.preventDefault(),t===`tree`?Jd():Yd();if(e.key===`Escape`){if(J.dialog){let e=rU(J.dialog,r.value?.busy??!1);e===`pair`?n.value?.close():e===`close`&&(J.dialog=void 0);return}!e.repeat&&!e.isComposing&&Cd.value&&(e.preventDefault(),Hd()),J.drawer=!1,J.inspectorOverlay=!1}}function o(e){let t=e.clientX,n=Qu.value,r=e=>Qu.value=Math.max(220,Math.min(560,n+e.clientX-t)),i=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)}return Vr(()=>Lf()),Vr(()=>{document.addEventListener(`keydown`,a),gd()}),Wr(()=>{Ku.stop(),document.removeEventListener(`keydown`,a)}),(e,a)=>(I(),L(`div`,iU,[B(mf,{onNewSession:i}),j(J).error?(I(),L(`div`,aU,[B(j(Oc),{size:18}),z(`span`,null,D(j(J).error),1),z(`button`,{class:`icon-button`,"aria-label":`Dismiss error`,onClick:a[0]||=e=>j(J).error=``},`×`)])):H(``,!0),z(`main`,{class:`net-workspace`,style:T({"--tree-w":`${j(Qu)}px`})},[B(Qp),j($u).tree?(I(),L(`div`,{key:0,class:`tree-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize network tree`,onPointerdown:ks(o,[`prevent`])},null,32)):H(``,!0),j(J).drawer?(I(),L(`div`,{key:1,class:`tree-backdrop`,onClick:a[1]||=e=>j(J).drawer=!1})):H(``,!0),j(q)&&j(nd)&&j(rd)?(I(),L(F,{key:2},[B(Uk),j(J).inspectorOverlay?(I(),L(`div`,{key:0,class:`inspector-backdrop`,onClick:a[2]||=e=>j(qd)()})):H(``,!0),(I(),R(ib,{key:`${j(q).deviceId}/${j(q).sessionId}`}))],64)):j(q)&&j(nd)?(I(),R($k,{key:3,device:j(nd)},null,8,[`device`])):(I(),L(`section`,oU,[a[14]||=z(`img`,{class:`welcome-symbol`,src:`/icons/durable-pi.svg`,alt:`Durable Pi`},null,-1),a[15]||=z(`span`,{class:`eyebrow`},`THE DURABLE AGENT NETWORK`,-1),a[16]||=z(`h1`,null,[V(`Close the tab.`),z(`br`),V(`The work continues.`)],-1),a[17]||=z(`p`,null,`Agents run on your devices. This page is only a window into them.`,-1),z(`button`,{class:`primary`,disabled:!t(),onClick:i},[B(j(Xc),{size:18}),V(D(j(Ju).devices.value.length?`Create a session`:`Add a device to dpi-network.yaml`),1)],8,sU),z(`div`,cU,[z(`span`,null,[B(j(fc),{size:18}),a[11]||=V(`SQLite on each device`,-1)]),z(`span`,null,[B(j(Cc),{size:18}),a[12]||=V(`Branch any agent`,-1)]),z(`span`,null,[B(j(Vs),{size:18}),a[13]||=V(`Watch from anywhere`,-1)])]),z(`p`,lU,`ui `+D(j(`0.0.120`)),1)]))],4),B(_f),j(J).dialog?.kind===`pair`?(I(),R(cH,{key:1,ref_key:`pairWizard`,ref:n,handoff:j(J).dialog.handoff,onClose:a[3]||=e=>j(J).dialog=void 0},null,8,[`handoff`])):H(``,!0),j(J).dialog?.kind===`credentials`?(I(),R(fH,{key:2,"device-id":j(J).dialog.deviceId,onClose:a[4]||=e=>j(J).dialog=void 0},null,8,[`device-id`])):H(``,!0),j(J).dialog?.kind===`new-session`?(I(),R(bA,{key:3,"device-id":j(J).dialog.deviceId,onClose:a[5]||=e=>j(J).dialog=void 0},null,8,[`device-id`])):j(J).dialog?.kind===`prompt`?(I(),R(CH,{key:4,ref_key:`promptDialog`,ref:r,dialog:j(J).dialog,onClose:a[6]||=e=>j(J).dialog=void 0},null,8,[`dialog`])):j(J).dialog?.kind===`models`?(I(),R(MH,{key:5,onClose:a[7]||=e=>j(J).dialog=void 0})):j(J).dialog?.kind===`path`?(I(),L(`div`,{key:6,class:`modal-backdrop`,onClick:a[10]||=ks(e=>j(J).dialog=void 0,[`self`])},[z(`section`,uU,[z(`header`,null,[a[18]||=z(`h2`,{id:`path-title`},`Working directory`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close working directory`,onClick:a[8]||=e=>j(J).dialog=void 0},[B(j(xl),{size:18})])]),z(`code`,dU,D(j(J).dialog.path),1),z(`footer`,null,[z(`button`,{class:`secondary`,onClick:a[9]||=e=>j(J).dialog=void 0},`Close`)])])])):j(J).dialog?.kind===`help`?(I(),R(VH,{key:7})):H(``,!0),j(HH).needed?(I(),R(eU,{key:8})):H(``,!0),B(nU)]))}});YH();var pU=new URL(window.location.href);if(/^\/pair\/?$/.test(pU.pathname)){let e=OV(pU);e?(pU.search=``,pU.hash=``,window.history.replaceState(window.history.state,``,pU),J.dialog={kind:`pair`,handoff:e}):window.history.replaceState(window.history.state,``,AV(pU))}Fs(fU).mount(`#app`);{let e=window.visualViewport,t=document.documentElement,n=()=>{let n=Math.max(e?.height??window.innerHeight,window.innerHeight);t.style.setProperty(`--vvh`,`${Math.round(n)}px`)};e?.addEventListener(`resize`,n),e?.addEventListener(`scroll`,n),window.addEventListener(`resize`,n),window.addEventListener(`orientationchange`,n),n()}/[?&]debug=1\b/.test(location.search)&&setTimeout(()=>{let e=document.createElement(`pre`);e.style.cssText=`position:fixed;left:6px;bottom:6px;z-index:99999;background:#000d;color:#fff;padding:8px;font:11px/1.5 ui-monospace,monospace;max-width:92vw;border-radius:6px;white-space:pre-wrap`;let t=window.visualViewport,n=()=>{e.textContent=[`UA: ${navigator.userAgent}`,`innerW×H: ${innerWidth}×${innerHeight}`,`clientW: ${document.documentElement.clientWidth}`,`visualViewport: ${t?`${Math.round(t.width)}×${Math.round(t.height)} scale=${t.scale.toFixed(3)}`:`none`}`,`root font-size: ${getComputedStyle(document.documentElement).fontSize}`,`dpr: ${devicePixelRatio}`,`mq740: ${matchMedia(`(max-width: 740px)`).matches}`,`touch: ${matchMedia(`(pointer: coarse)`).matches}`].join(`
|
|
83
83
|
`)};t?.addEventListener(`resize`,n),t?.addEventListener(`scroll`,n),window.addEventListener(`resize`,n),n(),document.body.appendChild(e)},600);
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<meta name="referrer" content="no-referrer" />
|
|
8
8
|
<link rel="icon" type="image/svg+xml" href="/icons/durable-pi.svg" />
|
|
9
9
|
<title>Durable Pi | Network</title>
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-CG_nQ-Sz.js"></script>
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/assets/index-DD66rPUN.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
package/apps/dpi-sdk/src/api.ts
CHANGED
|
@@ -503,7 +503,12 @@ export interface DeviceVitals {
|
|
|
503
503
|
* is stalling the panel". Required: the backend always returns it (0.0.117+,
|
|
504
504
|
* pinned by dpi-backend/tests/git-priority-r11.test.ts).
|
|
505
505
|
*/
|
|
506
|
-
|
|
506
|
+
/**
|
|
507
|
+
* Git spawn semaphore (run-11 h2-2; queuedAged in run-13): live children,
|
|
508
|
+
* waiting callers, interactive "high"-lane waiters, and cumulative low→high
|
|
509
|
+
* aging rescues (>10s — the f4 starvation gauge, backend 0.0.120+).
|
|
510
|
+
*/
|
|
511
|
+
gitSpawns: { live: number; queued: number; queuedHigh: number; queuedAged: number };
|
|
507
512
|
pid: number;
|
|
508
513
|
at: number;
|
|
509
514
|
/** Sessions this device knows about; `archived` counts the archive directories. */
|
|
@@ -4,11 +4,12 @@ import { THINKING_LEVELS, type ThinkingLevel } from "../../dpi-sdk/src/api.ts";
|
|
|
4
4
|
import type { App } from "./app.ts";
|
|
5
5
|
import { sanitizeTerminal, oneLine } from "./sanitize.ts";
|
|
6
6
|
export { oneLine };
|
|
7
|
-
import { Panel, pickAgent, pickDevice, pickEnv, pickModel, pickNotify, pickSession, pickSchedules, pickThinking } from "./pickers.ts";
|
|
7
|
+
import { Panel, pickAgent, pickArchived, pickDevice, pickEnv, pickModel, pickNotify, pickSession, pickSchedules, pickThinking } from "./pickers.ts";
|
|
8
8
|
import { parsePairArgs, runPairing } from "./pairing.ts";
|
|
9
9
|
import { gitStateSuffix } from "./views.ts";
|
|
10
10
|
import { c } from "./theme.ts";
|
|
11
11
|
import { basename, dirname, isAbsolute, join } from "node:path";
|
|
12
|
+
import { access, writeFile } from "node:fs/promises";
|
|
12
13
|
|
|
13
14
|
export const COMMANDS: SlashCommand[] = [
|
|
14
15
|
{ name: "sessions", description: "switch or create a session on this device" },
|
|
@@ -29,6 +30,11 @@ export const COMMANDS: SlashCommand[] = [
|
|
|
29
30
|
{ name: "name", description: "rename this agent", argumentHint: "<name>" },
|
|
30
31
|
{ name: "tasks", description: "live tasks in this session" },
|
|
31
32
|
{ name: "find", description: "search every session's transcript on this device", argumentHint: "<text>" },
|
|
33
|
+
// run-13 wave 2 — session take-out. :export writes the device's zip bundle
|
|
34
|
+
// to a local path; :archive walks the archived sessions (transcript /
|
|
35
|
+
// restore). No delete door: the SDK exposes no endpoint for it.
|
|
36
|
+
{ name: "export", description: "save a session bundle (zip) to a local path", argumentHint: "[sessionId]" },
|
|
37
|
+
{ name: "archive", description: "archived sessions: read a transcript, restore" },
|
|
32
38
|
{ name: "pair", description: "pair THIS device with a hub", argumentHint: "<CODE|PAIR_URL> [--hub ORIGIN] [--force]" },
|
|
33
39
|
{
|
|
34
40
|
name: "git",
|
|
@@ -204,6 +210,56 @@ async function usageCommand(app: App) {
|
|
|
204
210
|
}
|
|
205
211
|
}
|
|
206
212
|
|
|
213
|
+
// ---------------------------------------------- run-13: :export
|
|
214
|
+
|
|
215
|
+
/** run-13 A1: the export download name is DEVICE-AUTHORED (Content-Disposition
|
|
216
|
+
* — SessionExport.filename), so before it seeds the save-path prompt it gets
|
|
217
|
+
* the FE r16 fold: oneLine first (it is chrome AND a path segment — CR/LF
|
|
218
|
+
* must go before the charset fold), then [^A-Za-z0-9._-] → "_", capped at 80.
|
|
219
|
+
* The operator's TYPED path is trusted; only the seeded default passes here. */
|
|
220
|
+
export function sanitizeExportName(filename: string): string {
|
|
221
|
+
return oneLine(String(filename ?? ""))
|
|
222
|
+
.replace(/[^A-Za-z0-9._-]/g, "_")
|
|
223
|
+
.slice(0, 80);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** /export (run-13 A1) — pull a session's zip bundle and write it to a local
|
|
227
|
+
* path. Every failure mode (device refusal, bad path, disk full) lands in one
|
|
228
|
+
* error toast: the command is operator-driven (prompts between awaits), so it
|
|
229
|
+
* must never throw out of runCommand. */
|
|
230
|
+
async function exportCommand(app: App, sessionId: string) {
|
|
231
|
+
let filename = "session.bundle.zip";
|
|
232
|
+
let bytes: Uint8Array = new Uint8Array();
|
|
233
|
+
try {
|
|
234
|
+
const ex = await app.client.exportSession(sessionId);
|
|
235
|
+
filename = sanitizeExportName(ex.filename) || filename;
|
|
236
|
+
bytes = ex.bytes;
|
|
237
|
+
} catch (e) {
|
|
238
|
+
return app.notify(`export: ${(e as Error).message.slice(0, 80)}`, true);
|
|
239
|
+
}
|
|
240
|
+
const typed = await app.prompt("Save export as", `./${filename}`);
|
|
241
|
+
if (typed === undefined || !typed.trim()) return app.flash("export cancelled"), true;
|
|
242
|
+
const target = typed.trim();
|
|
243
|
+
try {
|
|
244
|
+
// The overwrite gate — the same y/n /reset asks (R4 finding 4): only the
|
|
245
|
+
// operator's explicit y may clobber an existing file.
|
|
246
|
+
const exists = await access(target).then(
|
|
247
|
+
() => true,
|
|
248
|
+
() => false,
|
|
249
|
+
);
|
|
250
|
+
if (exists) {
|
|
251
|
+
const ok = await app.prompt(`Overwrite ${target}? y/n`, "");
|
|
252
|
+
if (ok === undefined || !ok.trim().toLowerCase().startsWith("y"))
|
|
253
|
+
return app.flash("export cancelled — kept the existing file"), true;
|
|
254
|
+
}
|
|
255
|
+
await writeFile(target, bytes);
|
|
256
|
+
app.notify(`saved ${target} (${fmtBytes(bytes.length)})`);
|
|
257
|
+
app.logEvent("export", `saved ${oneLine(target)} · ${fmtBytes(bytes.length)} · ${oneLine(filename)}`);
|
|
258
|
+
} catch (e) {
|
|
259
|
+
app.notify(`export: ${(e as Error).message.slice(0, 80)}`, true);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
207
263
|
const KEYS: [string, string][] = [
|
|
208
264
|
["enter", "send; steers the agent while it works"],
|
|
209
265
|
["alt+enter", "queue as a follow-up"],
|
|
@@ -335,6 +391,25 @@ export async function runCommand(app: App, text: string): Promise<boolean> {
|
|
|
335
391
|
case "git":
|
|
336
392
|
await gitCommand(app, arg);
|
|
337
393
|
break;
|
|
394
|
+
// run-13 wave 2: session take-out — :export writes a bundle to disk,
|
|
395
|
+
// :archive opens the archived-session picker (pickers.ts owns its rows).
|
|
396
|
+
case "export": {
|
|
397
|
+
// No argument → the session picker (attach-on-pick is that door's
|
|
398
|
+
// documented behavior), then export the picked id. Esc and +New resolve
|
|
399
|
+
// undefined — /export stays quiet rather than flashing "cancelled" over
|
|
400
|
+
// a flow that tells its own story.
|
|
401
|
+
let id = arg;
|
|
402
|
+
if (!id) {
|
|
403
|
+
const picked = await pickSession(app);
|
|
404
|
+
if (picked === undefined) break;
|
|
405
|
+
id = picked;
|
|
406
|
+
}
|
|
407
|
+
await exportCommand(app, id);
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
case "archive":
|
|
411
|
+
await pickArchived(app);
|
|
412
|
+
break;
|
|
338
413
|
// run-12: the five device-ops doors — the pickers own their row hotkeys.
|
|
339
414
|
case "schedules":
|
|
340
415
|
await pickSchedules(app);
|
|
@@ -12,8 +12,9 @@ import {
|
|
|
12
12
|
type SelectItem,
|
|
13
13
|
} from "@earendil-works/pi-tui";
|
|
14
14
|
import { THINKING_LEVELS, type ThinkingLevel } from "../../dpi-sdk/src/api.ts";
|
|
15
|
-
import type { EnvFileView, NotifySinkView, ScheduleView } from "../../dpi-sdk/src/api.ts";
|
|
15
|
+
import type { ArchivedView, DeviceTree, EnvFileView, NotifySinkView, ScheduleView } from "../../dpi-sdk/src/api.ts";
|
|
16
16
|
import { agentTree, type TreeNode } from "../../dpi-sdk/src/models.ts";
|
|
17
|
+
import { fmtBytes, fmtDur } from "./commands.ts";
|
|
17
18
|
import { oneLine, sanitizeTerminal } from "./sanitize.ts";
|
|
18
19
|
import type { App } from "./app.ts";
|
|
19
20
|
import { c, selectTheme } from "./theme.ts";
|
|
@@ -290,34 +291,59 @@ export class Panel extends Box {
|
|
|
290
291
|
|
|
291
292
|
// ------------------------------------------------------------------ flows
|
|
292
293
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
294
|
+
/**
|
|
295
|
+
* The session picker. run-13: resolves with the picked session's id
|
|
296
|
+
* (undefined on esc or +New) so /export can reuse this same door — every
|
|
297
|
+
* existing caller ignores the value, and attach-on-pick is unchanged. A
|
|
298
|
+
* failed tree() now lands in an error toast like the other ops pickers
|
|
299
|
+
* (through /sessions it used to surface as an unhandled rejection).
|
|
300
|
+
*/
|
|
301
|
+
export function pickSession(app: App): Promise<string | undefined> {
|
|
302
|
+
return new Promise((done) => {
|
|
303
|
+
void (async () => {
|
|
304
|
+
let tree: DeviceTree;
|
|
305
|
+
try {
|
|
306
|
+
tree = await app.client.tree();
|
|
307
|
+
} catch (e) {
|
|
308
|
+
app.notify(`sessions: ${(e as Error).message.slice(0, 80)}`, true);
|
|
309
|
+
return done(undefined);
|
|
310
|
+
}
|
|
311
|
+
const items: SelectItem[] = [
|
|
312
|
+
{ value: "+new", label: "+ New session", description: `choose a directory on ${oneLine(app.device.id)}` },
|
|
313
|
+
...tree.sessions.map((s) => {
|
|
314
|
+
const agents = Array.isArray(s.agents) ? s.agents : [];
|
|
315
|
+
return {
|
|
316
|
+
value: s.id,
|
|
317
|
+
label: oneLine(String(s.name ?? "")),
|
|
318
|
+
description: `${oneLine(String(s.cwd ?? "").split("/").slice(-2).join("/"))} │ ${agents.length} agent${agents.length === 1 ? "" : "s"}${s.busy ? " │ working" : ""}`,
|
|
319
|
+
};
|
|
320
|
+
}),
|
|
321
|
+
];
|
|
322
|
+
app.overlay(
|
|
323
|
+
new Picker(`Sessions on ${oneLine(app.device.id)}`, items, (item) => {
|
|
324
|
+
app.closeOverlay();
|
|
325
|
+
// +New hands the flow to the new-session chain — resolve undefined so
|
|
326
|
+
// a waiting /export stays quiet instead of flashing "cancelled" over
|
|
327
|
+
// a flow that is telling its own story.
|
|
328
|
+
if (item.value === "+new") {
|
|
329
|
+
done(undefined);
|
|
330
|
+
return void newSession(app);
|
|
331
|
+
}
|
|
332
|
+
const s = tree.sessions.find((x) => x.id === item.value)!;
|
|
333
|
+
const root = s.agents.find((a) => a.kind === "root") ?? s.agents[0];
|
|
334
|
+
void app.attach(s.id, root?.id ?? 1);
|
|
335
|
+
done(s.id);
|
|
336
|
+
}, () => {
|
|
337
|
+
// Esc must never surprise-quit (0.0.52): with no attached session the
|
|
338
|
+
// cancel used to pass exitIfNothing=true and picker→Esc→Esc killed the
|
|
339
|
+
// whole process (R4 finding 1). Landing in the herd/network view is the
|
|
340
|
+
// honest cancel; quitting stays on q / ctrl+c / /quit.
|
|
341
|
+
app.closeOverlay();
|
|
342
|
+
done(undefined);
|
|
343
|
+
}),
|
|
344
|
+
);
|
|
345
|
+
})();
|
|
346
|
+
});
|
|
321
347
|
}
|
|
322
348
|
|
|
323
349
|
export async function newSession(app: App, presetName?: string) {
|
|
@@ -827,3 +853,118 @@ export async function pickNotify(app: App) {
|
|
|
827
853
|
),
|
|
828
854
|
);
|
|
829
855
|
}
|
|
856
|
+
|
|
857
|
+
// ---------------------------------------------- run-13: :archive
|
|
858
|
+
// The SDK's archive surface (policy #3): list bundles, read a transcript,
|
|
859
|
+
// restore. NO delete door — the SDK exposes no endpoint, and the palette does
|
|
860
|
+
// not invent one (run-13 scope). fmtBytes/fmtDur come from commands.ts (their
|
|
861
|
+
// home since run-12); the import is function-referenced only, so the benign
|
|
862
|
+
// pickers↔commands cycle is safe under ESM live bindings.
|
|
863
|
+
|
|
864
|
+
/** Transcript dump caps (run-13 A2, the r9 diagnostics-caps pattern): the log
|
|
865
|
+
* view is a 500-entry ring, so one :archive enter may add at most 400 lines /
|
|
866
|
+
* 100 KiB, with a LEADING marker naming what was cut — never a silent crop.
|
|
867
|
+
* Each surviving line is sanitizeTerminal'd HERE: logEvent writes its text
|
|
868
|
+
* verbatim (no normalizer downstream), so this helper is the chokepoint. */
|
|
869
|
+
const TRANSCRIPT_MAX_LINES = 400;
|
|
870
|
+
const TRANSCRIPT_MAX_BYTES = 100 * 1024;
|
|
871
|
+
|
|
872
|
+
export function capTranscriptLines(text: string): string[] {
|
|
873
|
+
const raw = String(text ?? "");
|
|
874
|
+
let cut = false;
|
|
875
|
+
let body = raw;
|
|
876
|
+
if (Buffer.byteLength(body, "utf8") > TRANSCRIPT_MAX_BYTES) {
|
|
877
|
+
// Byte-boundary cut on the UTF-8 encoding (a char-count slice could leave
|
|
878
|
+
// up to 4× the budget for multibyte text); toString drops any dangling
|
|
879
|
+
// multibyte fragment as U+FFFD.
|
|
880
|
+
cut = true;
|
|
881
|
+
body = Buffer.from(body, "utf8").subarray(0, TRANSCRIPT_MAX_BYTES).toString("utf8");
|
|
882
|
+
}
|
|
883
|
+
const total = raw.split("\n").length;
|
|
884
|
+
const all = body.split("\n");
|
|
885
|
+
const lines = all.slice(0, TRANSCRIPT_MAX_LINES);
|
|
886
|
+
if (all.length > TRANSCRIPT_MAX_LINES) cut = true;
|
|
887
|
+
const out = lines.map((l) => sanitizeTerminal(l));
|
|
888
|
+
if (cut) {
|
|
889
|
+
// The count names the lines the operator will not see (a byte cut can hide
|
|
890
|
+
// more than the count shows — it is a lower bound, still honest).
|
|
891
|
+
const dropped = Math.max(1, total - lines.length);
|
|
892
|
+
out.unshift(`... truncated (${dropped} line${dropped === 1 ? "" : "s"})`);
|
|
893
|
+
}
|
|
894
|
+
return out;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/** /archive (run-13 A2): archived sessions, newest first. Every device-
|
|
898
|
+
* authored field goes through oneLine INCLUDING the label path — pi-tui
|
|
899
|
+
* LF-normalizes descriptions only, so label strings must be collapsed at
|
|
900
|
+
* compose time (the r12 m1 lesson, pinned by test). Enter keeps the list up
|
|
901
|
+
* (reading is read-only, the pickNotify pattern) and dumps the markdown
|
|
902
|
+
* transcript into the log view through the caps above; r restores behind the
|
|
903
|
+
* same y/n gate /reset uses, then the list refetches without the row. */
|
|
904
|
+
export async function pickArchived(app: App) {
|
|
905
|
+
let list: ArchivedView[];
|
|
906
|
+
try {
|
|
907
|
+
list = (await app.client.archived()).sessions;
|
|
908
|
+
} catch (e) {
|
|
909
|
+
return app.notify(`archive: ${(e as Error).message.slice(0, 80)}`, true);
|
|
910
|
+
}
|
|
911
|
+
if (!list.length) return app.notify("no archived sessions on this device");
|
|
912
|
+
// archivedAt is relay-borne — coerce (a string/garbage field must not break
|
|
913
|
+
// the sort, R19 discipline) and sort newest-first.
|
|
914
|
+
const sessions = [...list].sort((a, b) => (Number(b.archivedAt) || 0) - (Number(a.archivedAt) || 0));
|
|
915
|
+
const items: SelectItem[] = sessions.map((s) => ({
|
|
916
|
+
// value is never rendered (filter matches label+description only) — keep
|
|
917
|
+
// the RAW id so transcript/restore hit the device's true session.
|
|
918
|
+
value: String(s.sessionId ?? ""),
|
|
919
|
+
label: `${s.hasManifest === true ? "◈" : "◇"} ${oneLine(String(s.name ?? ""))}`,
|
|
920
|
+
description: `${oneLine(String(s.cwd ?? ""))} · ${oneLine(String(Number(s.turns) || 0))} turns · ${fmtBytes(Number(s.bytes) || 0)} · archived ${fmtDur(Math.max(0, (Date.now() - (Number(s.archivedAt) || 0)) / 1000))} ago`,
|
|
921
|
+
}));
|
|
922
|
+
const showTranscript = async (item: SelectItem) => {
|
|
923
|
+
const s = sessions.find((x) => x.sessionId === item.value);
|
|
924
|
+
const label = oneLine(String(s?.name ?? item.value));
|
|
925
|
+
try {
|
|
926
|
+
const view = await app.client.archivedTranscript(item.value, "markdown");
|
|
927
|
+
const raw = String(view.text ?? "");
|
|
928
|
+
if (!raw.trim()) return app.notify(`transcript: ${label} is empty`);
|
|
929
|
+
const lines = capTranscriptLines(raw);
|
|
930
|
+
// Raw markdown is fine — the TUI does not render md, it prints lines.
|
|
931
|
+
for (const line of lines) app.logEvent("arch", line);
|
|
932
|
+
app.notify(`${label} — transcript, ${lines.length} line${lines.length === 1 ? "" : "s"} (log view: L)`);
|
|
933
|
+
} catch (e) {
|
|
934
|
+
app.notify(`transcript: ${(e as Error).message.slice(0, 80)}`, true);
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
const restore = async (item: SelectItem) => {
|
|
938
|
+
const s = sessions.find((x) => x.sessionId === item.value);
|
|
939
|
+
const label = oneLine(String(s?.name ?? item.value));
|
|
940
|
+
// The same y/n gate /reset and /schedules d ask (R4 finding 4): a
|
|
941
|
+
// state-changing door confirms; esc or anything not starting with y keeps
|
|
942
|
+
// the bundle archived.
|
|
943
|
+
const ok = await app.prompt(`Restore ${label}? y/n`, "");
|
|
944
|
+
if (ok === undefined || !ok.trim().toLowerCase().startsWith("y"))
|
|
945
|
+
return app.flash("restore cancelled"), undefined;
|
|
946
|
+
app.closeOverlay();
|
|
947
|
+
await app.run(async () => {
|
|
948
|
+
const restored = await app.client.restoreArchived(item.value);
|
|
949
|
+
const name = oneLine(String((restored as { name?: string })?.name ?? label));
|
|
950
|
+
// The app's session list refetches on its next view entry — no hook
|
|
951
|
+
// needed; the toast points the operator at g.
|
|
952
|
+
app.notify(`restored ${name} — press g to open it`);
|
|
953
|
+
app.logEvent("arch", `restored ${name}`);
|
|
954
|
+
});
|
|
955
|
+
// The row is gone on the device — refetch instead of showing a stale list
|
|
956
|
+
// (the pickSchedules d pattern).
|
|
957
|
+
void pickArchived(app);
|
|
958
|
+
};
|
|
959
|
+
app.overlay(
|
|
960
|
+
new ActionPicker(
|
|
961
|
+
`Archived on ${oneLine(app.device.id)}`,
|
|
962
|
+
items,
|
|
963
|
+
(item) => void showTranscript(item),
|
|
964
|
+
() => app.closeOverlay(),
|
|
965
|
+
"enter transcript · r restore · esc close",
|
|
966
|
+
{ r: restore },
|
|
967
|
+
"◈ manifest · ◇ bundle only",
|
|
968
|
+
),
|
|
969
|
+
);
|
|
970
|
+
}
|
|
@@ -492,7 +492,7 @@ export function renderOps(
|
|
|
492
492
|
// loadavg cannot express, and gitSpawns' queued(+high) is the number
|
|
493
493
|
// that says "a status fan-out is stalling the panel" (run-11 h2-2).
|
|
494
494
|
` ${c.muted("evlag")} ${c.text(`${Math.round(Number(v.eventLoop?.lagMsLast) || 0)}ms`)} ${c.muted("last")} ${c.text(`${Math.round(Number(v.eventLoop?.lagMsMax1m) || 0)}ms`)} ${c.muted("max 1m")} ${c.muted(`${Number(v.eventLoop?.samples) || 0} samples`)}`,
|
|
495
|
-
` ${c.muted("git")} ${c.text(`${Number(v.gitSpawns?.live) || 0} live`)} ${c.muted("·")} ${c.text(`${Number(v.gitSpawns?.queued) || 0} queued`)}${Number(v.gitSpawns?.queuedHigh) > 0 ? c.warn(` · ${Number(v.gitSpawns.queuedHigh)} high`) : ""}`,
|
|
495
|
+
` ${c.muted("git")} ${c.text(`${Number(v.gitSpawns?.live) || 0} live`)} ${c.muted("·")} ${c.text(`${Number(v.gitSpawns?.queued) || 0} queued`)}${Number(v.gitSpawns?.queuedHigh) > 0 ? c.warn(` · ${Number(v.gitSpawns.queuedHigh)} high`) : ""}${Number(v.gitSpawns?.queuedAged) > 0 ? c.warn(` · ${Number(v.gitSpawns.queuedAged)} aged`) : ""}`,
|
|
496
496
|
];
|
|
497
497
|
if (v.counts)
|
|
498
498
|
out.push(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "my-durable",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.120",
|
|
4
4
|
"description": "Durable Pi — the durable agent network: hub web UI, device backend daemon, TUI admin and the shared SDK, packaged as one runnable monorepo install",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|