my-durable 0.0.45 → 0.0.46
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/config.ts +7 -1
- package/apps/dpi-backend/src/crash.ts +338 -0
- package/apps/dpi-backend/src/doctor.ts +16 -1
- package/apps/dpi-backend/src/main.ts +33 -2
- package/apps/dpi-backend/src/pi-config.ts +102 -1
- package/apps/dpi-backend/src/routes.ts +11 -0
- package/apps/dpi-backend/src/store.ts +31 -2
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-B5d1JP_j.css +1 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/{index-CIMZq9MU.js → index-CAtBlkjt.js} +4 -4
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/index.html +2 -2
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/EnvPanel.vue +136 -2
- package/apps/dpi-sdk/src/api.ts +18 -0
- package/apps/dpi-sdk/src/client.ts +15 -0
- package/apps/dpi-sdk/src/protocol/rest-routes.ts +3 -0
- package/docs/host-project-checklist.md +3 -3
- package/package.json +1 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-Dp-HJ4Vs.css +0 -1
|
@@ -12,7 +12,7 @@ var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],en
|
|
|
12
12
|
|
|
13
13
|
`))>=0;){let e=f.slice(0,p),t=$l(e);if(t>n)throw a();f=f.slice(p+2),s-=t+2;let r=tu(e);r&&(yield r)}if(s>n)throw a();o=f?[f]:[],c=f.slice(-1)}}finally{r.cancel().catch(()=>{})}}function tu(e){let t=`message`,n,r=[];for(let i of e.split(`
|
|
14
14
|
`)){if(!i||i.startsWith(`:`))continue;let e=i.indexOf(`:`),a=e<0?i:i.slice(0,e),o=e<0?``:i.slice(e+1).replace(/^ /,``);a===`event`?t=o:a===`data`?r.push(o):a===`id`&&(n=o)}return r.length?{event:t,data:r.join(`
|
|
15
|
-
`),id:n}:void 0}var nu=encodeURIComponent,ru=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`,iu=class{token;baseUrl;constructor(e,t){this.token=t,this.baseUrl=e.replace(/\/+$/,``)}headers(e,t={}){return{...this.token?{authorization:`Bearer ${this.token}`,"x-dpi-token":this.token}:{},...e?{"content-type":`application/json`}:{},...t}}async request(e,t,n,r={}){let i=AbortSignal.timeout(r.timeoutMs??2e4),a=r.signal?AbortSignal.any([r.signal,i]):i,o;try{o=await fetch(this.baseUrl+t,{method:e,signal:a,headers:this.headers(n!==void 0,r.idempotencyKey?{"idempotency-key":r.idempotencyKey}:{}),body:n===void 0?void 0:JSON.stringify(n)})}catch(e){throw r.signal?.aborted?e:new Jl(`offline`,`Cannot reach ${this.baseUrl}`,0,{cause:e})}let s=await o.text(),c;try{c=s?JSON.parse(s):void 0}catch{c=void 0}if(!o.ok){let e=c?.error;throw new Jl(e?.code??(o.status===401?`unauthorized`:o.status===404?`not_found`:`internal`),e?.message??`${o.status} ${o.statusText}`,o.status)}return c}async*stream(e,t,n){let r;try{r=await fetch(this.baseUrl+e,{headers:{...this.headers(!1),accept:`text/event-stream`},signal:t})}catch(e){if(t.aborted)return;throw new Jl(`offline`,`Cannot reach ${this.baseUrl}`,0,{cause:e})}if(!r.ok||!r.body){let e=await r.json().catch(()=>void 0);throw new Jl(e?.error?.code??(r.status===401?`unauthorized`:`unavailable`),e?.error?.message??`Stream failed (${r.status})`,r.status)}try{for await(let e of eu(r.body,n))yield JSON.parse(e.data)}catch(e){if(t.aborted)return;throw e}}device(e){return this.request(`GET`,`/v1/device`,void 0,e)}vitals(){return this.request(`GET`,`/v1/device/vitals`)}tree(){return this.request(`GET`,`/v1/tree`)}projects(e=!1){return this.request(`GET`,`/v1/projects${e?`?includeArchived=1`:``}`)}updateProject(e,t){return this.request(`PATCH`,`/v1/projects/${nu(e)}`,t)}archiveProject(e){return this.request(`POST`,`/v1/projects/${nu(e)}/archive`,{})}unarchiveProject(e){return this.request(`POST`,`/v1/projects/${nu(e)}/unarchive`,{})}notifySinks(){return this.request(`GET`,`/v1/notify/sinks`)}createNotifySink(e){return this.request(`POST`,`/v1/notify/sinks`,e)}updateNotifySink(e,t){return this.request(`PATCH`,`/v1/notify/sinks/${nu(e)}`,t)}removeNotifySink(e){return this.request(`DELETE`,`/v1/notify/sinks/${nu(e)}`)}testNotifySinks(){return this.request(`POST`,`/v1/notify/test`,{})}envView(){return this.request(`GET`,`/v1/device/env`)}setEnvVar(e,t){return this.request(`POST`,`/v1/device/env`,{key:e,value:t})}removeEnvVar(e){return this.request(`DELETE`,`/v1/device/env/${nu(e)}`)}graphs(){return this.request(`GET`,`/v1/graphs`)}graph(e){return this.request(`GET`,`/v1/graphs/${nu(e)}`)}createGraph(e){return this.request(`POST`,`/v1/graphs`,e)}runGraph(e){return this.request(`POST`,`/v1/graphs/${nu(e)}/run`,{})}removeGraph(e){return this.request(`DELETE`,`/v1/graphs/${nu(e)}`)}schedules(){return this.request(`GET`,`/v1/schedules`)}createSchedule(e){return this.request(`POST`,`/v1/schedules`,e)}updateSchedule(e,t){return this.request(`PATCH`,`/v1/schedules/${nu(e)}`,t)}removeSchedule(e){return this.request(`DELETE`,`/v1/schedules/${nu(e)}`)}runSchedule(e){return this.request(`POST`,`/v1/schedules/${nu(e)}/run`,{})}deviceUsage(){return this.request(`GET`,`/v1/device/usage`)}searchSessions(e){return this.request(`GET`,`/v1/sessions/search?q=${nu(e)}`)}dirs(e=``){return this.request(`GET`,`/v1/fs/dirs?path=${nu(e)}`)}deviceDoc(e){return this.request(`GET`,`/v1/docs/${nu(e)}`)}deviceEvents(e,t=[]){return this.stream(`/v1/events${t.length?`?docs=${t.map(nu).join(`,`)}`:``}`,e)}gitStatus(e,t={}){return this.request(`GET`,`/v1/git/status?path=${nu(e)}`,void 0,t)}gitOp(e,t,n={}){return this.request(`POST`,`/v1/git`,{path:e,op:t,...n})}exportSession(e){return this.request(`GET`,`/v1/sessions/${nu(e)}/export`)}sessionGitFiles(e){return this.request(`GET`,`/v1/sessions/${nu(e)}/git-files`)}sessionGitTurns(e){return this.request(`GET`,`/v1/sessions/${nu(e)}/git-turns`)}gitStatusBatch(e,t={}){return this.request(`POST`,`/v1/git/status-batch`,{paths:e},t)}sessions(){return this.request(`GET`,`/v1/sessions`)}createSession(e,t=ru()){return this.request(`POST`,`/v1/sessions`,e,{idempotencyKey:t})}session(e){return new au(this,e)}agent(e,t){return new ou(this,e,String(t))}},au=class{client;ref;constructor(e,t){this.client=e,this.ref=t}get base(){return`/v1/sessions/${nu(this.ref)}`}get(){return this.client.request(`GET`,this.base)}rename(e){return this.client.request(`PATCH`,this.base,{name:e})}archive(){return this.client.request(`DELETE`,this.base)}agents(){return this.client.request(`GET`,`${this.base}/agents`)}createAgent(e={},t=ru()){return this.client.request(`POST`,`${this.base}/agents`,e,{idempotencyKey:t})}tasks(e=`terminal`,t=20){return this.client.request(`GET`,`${this.base}/tasks?status=${e}&limit=${t}`)}abortTask(e){return this.client.request(`POST`,`${this.base}/tasks/${e}/abort`,{})}inspect(){return this.client.request(`GET`,`${this.base}/inspect`)}compaction(){return this.client.request(`GET`,`${this.base}/compaction`)}setCompaction(e){return this.client.request(`PATCH`,`${this.base}/compaction`,e)}submission(e,t=0){return this.client.request(`GET`,`${this.base}/submissions/${e}?waitMs=${t}`,void 0,{timeoutMs:t+2e4})}events(e){return this.client.stream(`${this.base}/events`,e)}},ou=class{client;session;agent;constructor(e,t,n){this.client=e,this.session=t,this.agent=n}get base(){return`/v1/sessions/${nu(this.session)}/agents/${nu(this.agent)}`}get(){return this.client.request(`GET`,this.base)}rename(e){return this.client.request(`PATCH`,this.base,{name:e})}send(e,t=`followUp`,n=ru(),r){return this.client.request(`POST`,`${this.base}/messages`,{content:e,whenBusy:t,requestId:n,waitMs:r},{timeoutMs:(r??0)+2e4})}withdraw(e){return this.client.request(`DELETE`,`${this.base}/inbox/${e}`)}abort(e=!1){return this.client.request(`POST`,`${this.base}/abort`,{background:e})}fork(e,t=ru()){return this.client.request(`POST`,`${this.base}/fork`,e,{idempotencyKey:t})}config(){return this.client.request(`GET`,`${this.base}/config`)}configure(e){return this.client.request(`PATCH`,`${this.base}/config`,e)}compact(e){return this.client.request(`POST`,`${this.base}/compact`,{instructions:e})}reset(e){return this.client.request(`POST`,`${this.base}/reset`,{note:e})}entries(e={}){let t=new URLSearchParams({scope:e.scope??`all`,limit:String(e.limit??500),...e.cursor?{cursor:e.cursor}:{}});return this.client.request(`GET`,`${this.base}/entries?${t}`)}transcript(e=`json`){return this.client.request(`GET`,`${this.base}/transcript?format=${e}`)}doc(e){return this.client.request(`GET`,`${this.base}/docs/${nu(e)}`)}extensions(){return this.client.request(`GET`,`${this.base}/extensions`)}setExtension(e){return this.client.request(`PATCH`,`${this.base}/extensions`,e)}demo(e,t,n=`POST`){return this.client.request(n,`${this.base}/demo/${e}`,t)}events(e,t=[]){return this.client.stream(`${this.base}/events${t.length?`?docs=${t.map(nu).join(`,`)}`:``}`,e)}},W=e=>new iu(`/api/devices/${encodeURIComponent(e)}`);async function su(e,t,n){let r=await fetch(`/api${t}`,{method:e,headers:n===void 0?{}:{"content-type":`application/json`},body:n===void 0?void 0:JSON.stringify(n)}),i=await r.json().catch(()=>void 0);if(!r.ok){let e=i?.error;throw new Jl(e?.code??`internal`,e?.message??`${r.status} ${r.statusText}`,r.status)}return i}var cu={network:()=>su(`GET`,`/network`),version:()=>su(`GET`,`/version`),check:e=>su(`POST`,`/devices/${encodeURIComponent(e)}/check`,{}),createShare:e=>su(`POST`,`/shares`,e),async uiGet(e){return(await su(`GET`,`/ui-state/${encodeURIComponent(e)}`)).value??void 0},uiSet:(e,t)=>su(`PUT`,`/ui-state/${encodeURIComponent(e)}`,{value:t})},lu=e=>e instanceof Error?e.message:String(e),uu=[`demo.job-runs`,`demo.workspace`],du=e=>`${e.deviceId}/agent/${e.sessionId}/${e.agentId}?docs=${uu.join(`,`)}`,fu=e=>`${e.deviceId}/session/${e.sessionId}`,pu=e=>`${e}/device?docs=app.shared-state`;function mu(e,t,n,r=`hello`){let i=O(`idle`),a=O(``);return e.route(t,e=>{e.type===`hello`?(i.value=r===`hello`?`live`:`connecting`,r===`hello`&&(a.value=``)):e.type===`disconnected`?i.value=`reconnecting`:e.type===`fault`?(i.value=`fault`,a.value=e.error.message):(n(e),e.type===r&&(a.value=``,i.value=`live`))}),{status:i,fault:a,select:n=>{a.value=``,i.value=n?`connecting`:`idle`,e.set(t,n)},retry:()=>{i.value=`connecting`,e.reopen(t)}}}function hu(e){let t=new Bl,n=O(0);return t.subscribe(()=>n.value++),e.onNetwork(e=>t.apply({type:`network`,devices:e})),{model:t,devices:H(()=>(n.value,t.devices)),tree:H(()=>(n.value,t.tree()))}}function gu(e,t){let n=an(),r=an([]),{status:i,select:a}=mu(e,`device`,e=>{e.type===`doc`&&e.kind===`app.shared-state`?n.value={value:e.value,revision:e.revision??0}:e.type===`activity`&&(r.value=[...r.value,...e.items].slice(-50))});return j(t,e=>{n.value=void 0,a(e?pu(e):void 0)},{immediate:!0}),{sharedState:n,activity:r,status:i}}function _u(e,t){let n=new Nl,r=O(0);n.subscribe(()=>r.value++);let{status:i,fault:a,select:o}=mu(e,`session`,e=>n.apply(e));return j(()=>t.value?fu(t.value):void 0,e=>{n.clear(),o(e)},{immediate:!0}),{model:n,state:H(()=>(r.value,n.state)),status:i,fault:a}}function vu(e,t){let n=new Ml,r=O(0);n.subscribe(()=>r.value++);let{status:i,fault:a,select:o,retry:s}=mu(e,`agent`,e=>n.apply(e),`snapshot`);return j(()=>t.value?du(t.value):void 0,e=>{n.clear(),o(e)},{immediate:!0}),{model:n,state:H(()=>(r.value,{...n.state})),status:i,fault:a,version:r,retry:s}}var yu=new Gl,bu=O(yu.state);yu.onState(e=>bu.value=e);var xu=hu(yu),Su=O(),Cu=O(),G=O(),wu=O(new Set),Tu=O(300),Eu=Gt({tree:!0,inspector:!0}),Du=O(!1),Ou=H(()=>G.value?.deviceId),ku=H(()=>xu.devices.value.find(e=>e.id===Ou.value)),Au=H(()=>ku.value?.status===`online`),ju=_u(yu,H(()=>G.value?{deviceId:G.value.deviceId,sessionId:G.value.sessionId}:void 0)),Mu=vu(yu,G),Nu=gu(yu,Ou),Pu=H(()=>ku.value?.tree?.sessions.find(e=>e.id===G.value?.sessionId)),Fu=H(()=>Ou.value?W(Ou.value):void 0),Iu=H(()=>G.value&&Fu.value?Fu.value.agent(G.value.sessionId,G.value.agentId):void 0),Lu=H(()=>G.value&&Fu.value?Fu.value.session(G.value.sessionId):void 0);function Ru(e){G.value=e,K.drawer=!1,zu=!!e,Bu()}var zu=!1;function Bu(){let e=G.value;if(!zu||!e)return;let t=xu.devices.value.find(t=>t.id===e.deviceId)?.tree?.sessions.find(t=>t.id===e.sessionId)?.agents,n=new Map((t??[]).map(e=>[e.id,e])),r=[e.deviceId,`${e.deviceId}/s/${e.sessionId}`,`${e.deviceId}/s/${e.sessionId}/a/${e.agentId}`],i=n.get(e.agentId),a=new Set;for(;i&&!a.has(i.id);){a.add(i.id);let t=i.parentId??i.ownerAgentId;if(t===void 0)break;r.push(`${e.deviceId}/s/${e.sessionId}/a/${t}`),i=n.get(t)}r.some(e=>!wu.value.has(e))&&(wu.value=new Set([...wu.value,...r])),n.has(e.agentId)&&(zu=!1)}j(()=>xu.devices.value,Bu);function Vu(e,t){let n=new Set(wu.value);t??!n.has(e)?n.add(e):n.delete(e),wu.value=n}var Hu=(()=>{let e=new Map;return(t,n)=>{clearTimeout(e.get(t)),e.set(t,setTimeout(()=>void cu.uiSet(t,n).catch(()=>{}),300))}})();j(G,e=>Du.value&&void cu.uiSet(`tree.selected`,e??null).catch(()=>{})),j(Tu,e=>Du.value&&Hu(`tree.width`,e)),j(Eu,e=>Du.value&&Hu(`layout.panels`,{...e}));async function Uu(){yu.start();try{let[e,t,n,r]=await Promise.all([cu.network(),cu.uiGet(`tree.selected`),cu.uiGet(`tree.width`),cu.uiGet(`layout.panels`)]);r&&Object.assign(Eu,r),cu.version().then(e=>Cu.value=e.version).catch(()=>{}),Su.value=e.configFile,xu.model.devices.length||xu.model.apply({type:`network`,devices:e.devices}),wu.value=new Set,n&&(Tu.value=n),t&&e.devices.some(e=>e.id===t.deviceId)?Ru(t):Wu(e.devices)}catch(e){K.error=lu(e)}finally{Du.value=!0}}function Wu(e){for(let t of e){let e=t.status===`online`?t.tree?.sessions[0]:void 0,n=e?.agents.find(e=>e.kind===`root`)??e?.agents[0];if(e&&n)return Ru({deviceId:t.id,sessionId:e.id,agentId:n.id})}}j(()=>[Mu.status.value,Pu.value],([e,t])=>{e===`fault`&&!t&&Au.value&&(q(`That session was archived on its device.`),Ru(void 0))});var Gu=H(()=>ku.value?.info?.models??[]),Ku=Mu.state,qu=H(()=>ju.state.value.agents.length?ju.state.value.agents:Pu.value?.agents??[]),Ju=H(()=>G.value?Pl(qu.value,G.value.agentId):[]),Yu=H(()=>{let e=G.value?.agentId;if(e===void 0)return[];let t=qu.value,n=new Set([e]);for(let e=!0;e;){e=!1;for(let r of t)r.ownerAgentId!==void 0&&n.has(r.ownerAgentId)&&!n.has(r.id)&&(n.add(r.id),e=!0)}let r=ju.state.value.tasks,i=new Map(r.map(e=>[e.id,e])),a=new Map(t.map(e=>[e.id,e.ownerTaskId]));return r.filter(e=>n.has(e.conversationId)).map(e=>{let t=e,n=!1,r=new Set;for(;t&&!r.has(t.id);){if(r.add(t.id),t.background){n=!0;break}let e=t.owner??a.get(t.conversationId);t=e===void 0?void 0:i.get(e)}return{...e,effectiveBackground:n}})}),Xu=H(()=>Ku.value.running||Yu.value.some(e=>!e.effectiveBackground&&e.conversationId===G.value?.agentId)),Zu=H(()=>Dl(Ku.value.usage)),Qu=H(()=>{let e=Ku.value.agent.model;return Gu.value.find(t=>t.provider===e?.provider&&t.id===e?.modelId)}),$u=an(),ed=0;async function td(){let e=Iu.value,t=++ed;if(!e||!Au.value)return void($u.value=void 0);try{let n=await e.get();t===ed&&($u.value=n)}catch{t===ed&&($u.value=void 0)}}j([Iu,Au],()=>void td(),{immediate:!0});var K=Gt({error:``,toast:``,drawer:!1,inspectorOverlay:!1,tab:`session`,composer:``,dialog:void 0}),nd,rd=Gt([]),id=1;function ad(){for(let e of rd)e.read=!0}function q(e){K.toast=e,e&&(rd.unshift({id:id++,text:e,at:Date.now(),read:!1}),rd.length>50&&(rd.length=50)),clearTimeout(nd),nd=setTimeout(()=>K.toast=``,4500)}async function od(e){K.error=``;try{return await e()}catch(e){K.error=lu(e);return}}function sd(e){K.composer=e,setTimeout(()=>document.querySelector(`.composer textarea`)?.focus())}var cd=e=>Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(e),ld=e=>JSON.stringify(e,null,2),ud=(e=``)=>ql(Gu.value.find(t=>t.id===e)?.icon);function dd(e){if(!e)return`never`;let t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t}s ago`:t<3600?`${Math.round(t/60)}m ago`:t<86400?`${Math.round(t/3600)}h ago`:`${Math.round(t/86400)}d ago`}var fd=O(!1);async function pd(){Xu.value&&!fd.value&&Iu.value&&(fd.value=!0,await od(()=>Iu.value.abort(!1))&&q(`Foreground work interrupted. Background jobs continue.`),fd.value=!1)}var md=window.matchMedia(`(max-width: 1100px)`),hd=O(md.matches);md.addEventListener(`change`,e=>hd.value=e.matches);var gd=H(()=>hd.value?K.inspectorOverlay:Eu.inspector);function _d(e){e&&(K.tab=e),hd.value?(K.drawer=!1,K.inspectorOverlay=!0):Eu.inspector=!0}function vd(){hd.value?K.inspectorOverlay=!1:Eu.inspector=!1}function yd(){hd.value?(K.drawer=!K.drawer)&&(K.inspectorOverlay=!1,Eu.tree=!0):Eu.tree=!Eu.tree}function bd(){gd.value?vd():_d()}var xd=/Mac|iPhone|iPad/.test(navigator.userAgent),Sd=xd?{tree:`Ctrl+N`,inspector:`Ctrl+T`}:{tree:`Alt+Shift+N`,inspector:`Alt+Shift+T`};function Cd(e){if(!(!(xd?e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey:e.altKey&&e.shiftKey&&!e.ctrlKey&&!e.metaKey)||e.repeat||e.isComposing)){if(e.code===`KeyN`)return`tree`;if(e.code===`KeyT`)return`inspector`}}var wd={class:`topbar`},Td={class:`brand`},Ed={class:`daemon`,"data-testid":`topbar-stats`},Dd=[`title`],Od={class:`top-actions`},kd={key:0,class:`usage-chip`,title:`This session's token usage and cost`},Ad=[`aria-label`,`title`],jd={key:0,class:`bell-dot`},Md={key:0,class:`hint`},Nd={class:`when`},Pd=[`disabled`],Fd=[`disabled`],Id=M({__name:`TopBar`,emits:[`newSession`],setup(e,{emit:t}){let n=O(!1),r=H(()=>rd.filter(e=>!e.read).length),i=()=>{n.value=!n.value,n.value&&ad()},a=e=>{let t=Math.round((Date.now()-e)/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`},o=H(()=>Zu.value.input+Zu.value.output+Zu.value.cacheRead+Zu.value.cacheWrite),s=H(()=>(Zu.value.inputCost??0)+(Zu.value.outputCost??0)+(Zu.value.cacheReadCost??0)+(Zu.value.cacheWriteCost??0)),c=H(()=>xu.devices.value.filter(e=>e.status===`online`).length),l=H(()=>xu.devices.value.reduce((e,t)=>e+(t.tree?.sessions.length??0),0)),u=H(()=>xu.devices.value.reduce((e,t)=>e+(t.tree?.sessions.reduce((e,t)=>e+t.agents.length,0)??0),0)),d=O(!1);async function f(){let e=Lu.value,t=G.value;if(!e||!t||d.value)return;d.value=!0;let n=await od(()=>e.createAgent({}));d.value=!1,n&&(Ru({...t,agentId:n.id}),q(`New agent. Same session, same shared App State.`))}let p=t;return(e,t)=>(F(),I(`header`,wd,[R(`div`,Td,[R(`button`,{class:`icon-button tree-toggle`,"aria-label":`Toggle network`,title:`Network`,onClick:t[0]||=e=>k(K).drawer=!k(K).drawer},[z(k(Kc),{size:19})]),t[6]||=R(`img`,{class:`brandmark`,src:`/icons/durable-pi.svg`,alt:`Durable Pi`},null,-1),t[7]||=R(`strong`,null,`Durable Pi`,-1)]),t[15]||=R(`span`,{class:`topbar-sep`,"aria-hidden":`true`},null,-1),R(`div`,Ed,[R(`span`,{class:T([`dot`,{off:!c.value}]),"aria-hidden":`true`},null,2),R(`span`,{class:`network-summary`,title:`${c.value} of ${k(xu).devices.value.length} devices online`},[z(k(Vc),{size:16}),B(E(c.value)+` of `+E(k(xu).devices.value.length)+` online`,1)],8,Dd),t[10]||=R(`span`,{class:`sep`,"aria-hidden":`true`},`·`,-1),R(`span`,null,[R(`b`,null,E(l.value),1),t[8]||=B(` sessions`,-1)]),t[11]||=R(`span`,{class:`sep`,"aria-hidden":`true`},`·`,-1),R(`span`,null,[R(`b`,null,E(u.value),1),t[9]||=B(` agents`,-1)])]),R(`div`,Od,[R(`span`,{class:T([`chip connection`,{accent:k(bu)===`live`}])},[R(`span`,{class:T([`dot`,{off:k(bu)!==`live`}]),"aria-hidden":`true`},null,2),B(E(k(bu)===`live`?`Connected`:`Reconnecting`),1)],2),o.value?(F(),I(`span`,kd,E(o.value.toLocaleString())+` tok · $`+E(s.value.toFixed(3)),1)):V(``,!0),R(`button`,{class:`icon-button`,"aria-label":`Notifications${r.value?` (${r.value} unread)`:``}`,title:`Notification center${r.value?` — ${r.value} unread`:``}`,onClick:i},[z(k(Zs),{size:18}),r.value?(F(),I(`i`,jd,E(r.value>9?`9+`:r.value),1)):V(``,!0)],8,Ad),n.value?(F(),I(`div`,{key:1,class:`notif-panel`,onClick:t[2]||=As(()=>{},[`stop`])},[R(`header`,null,[t[12]||=R(`b`,null,`Notifications`,-1),R(`button`,{class:`icon-button`,"aria-label":`Close notifications`,onClick:t[1]||=e=>n.value=!1},`✕`)]),k(rd).length?V(``,!0):(F(),I(`p`,Md,`Nothing yet — events land here as they happen.`)),R(`ul`,null,[(F(!0),I(P,null,N(k(rd),e=>(F(),I(`li`,{key:e.id,class:T({unread:!e.read})},[R(`span`,Nd,E(a(e.at)),1),R(`span`,null,E(e.text),1)],2))),128))])])):V(``,!0),R(`button`,{class:`icon-button`,title:`How this works`,"aria-label":`How this works`,onClick:t[3]||=e=>k(K).dialog={kind:`help`}},[z(k(oc),{size:19})]),R(`button`,{class:`secondary small new-agent-button`,disabled:!k(G)||!k(Au)||d.value,title:`Start a fresh agent in this session`,onClick:f},[z(k(Zc),{size:18}),t[13]||=B(`New agent `,-1)],8,Pd),R(`button`,{class:`primary small`,onClick:t[4]||=e=>p(`newSession`)},[z(k(Zc),{size:18}),t[14]||=B(`New session `,-1)]),R(`button`,{class:`icon-button inspector-toggle`,"aria-label":`Toggle inspector`,title:`Inspector`,disabled:!k(G)||!k(Au),onClick:t[5]||=e=>k(K).inspectorOverlay?k(vd)():k(_d)()},[z(k(qc),{size:19})],8,Fd)])]))}}),Ld=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},Rd=Ld(Id,[[`__scopeId`,`data-v-15b1b2ee`]]),zd={class:`mnav`,"aria-label":`Panels`},Bd={key:0,class:`badge`},Vd=M({__name:`MobileNav`,setup(e){function t(){K.drawer=!1,K.inspectorOverlay=!1}return(e,n)=>(F(),I(`nav`,zd,[R(`button`,{type:`button`,class:T({"is-on":!k(K).drawer&&!k(gd)}),onClick:t},[z(k(Rc),{size:18}),n[2]||=B(`Chat `,-1)],2),R(`button`,{type:`button`,class:T({"is-on":k(gd)}),onClick:n[0]||=e=>k(gd)?k(vd)():k(_d)()},[z(k(qc),{size:18}),n[3]||=B(`Details`,-1),k(Yu).length?(F(),I(`span`,Bd,E(k(Yu).length),1)):V(``,!0)],2),R(`button`,{type:`button`,class:T({"is-on":k(K).drawer}),onClick:n[1]||=e=>k(yd)()},[z(k(ml),{size:18}),n[4]||=B(`Network `,-1)],2)]))}}),Hd=[`width`,`height`,`aria-label`],Ud=[`width`,`height`,`aria-label`],Wd=M({__name:`DeviceIcon`,props:{device:{},size:{default:16}},setup(e){let t=e,n=H(()=>{let e=t.device;return e?.kind===`exe-dev`||e?.url?.includes(`.exe.xyz`)?`exe`:e?.info?.platform.startsWith(`darwin`)?`apple`:e?.kind===`local`?`laptop`:`server`}),r=H(()=>{let e={exe:`exe.dev VM`,apple:`macOS`,laptop:`This computer`,server:`Server`}[n.value];return t.device?.transport===`tunnel`?`${e} (tunnel)`:e});return(t,i)=>n.value===`exe`?(F(),I(`svg`,{key:0,class:`device-icon exe`,viewBox:`0 0 512 512`,width:e.size,height:e.size,role:`img`,"aria-label":r.value},[R(`title`,null,E(r.value),1),i[0]||=R(`path`,{fill:`currentColor`,"fill-rule":`evenodd`,d:`M8 332.2l.9 1.4 1.5 .5 38.5-4.1 3.1 .4 2.7 2.2 8.8 13.2 10.1 12.8 1.1 2.6-.3 3.2-16.4 35.6 0 1.7 1 1.2 2.2 0 33.8-18.2 3.1-.8 3.4 1 12.4 8.7 15.3 9.4 1.5 2.1 .5 2.5-3.1 38.9 .4 1.5 1.3 .9 2.3-.7 25.9-29.2 2.1-1.3 2.8-.4 16.3 4.4 15.7 3.2 3 1.8 1.6 2.8 9.8 37.1 1.5 1.6 1.7-.1 1.1-1.1 14.5-35.6 1.8-2.5 3.4-1.5 15.7-1.1 16.1-2.4 3.2 .5 2.3 1.8 22.4 32 2.2 .9 1.4-.7 .6-1.5 1.4-39 1-2.7 2.4-2.2 14.7-6.8 13.8-7.8 3.4-.7 3 1 32.4 21 2.3 0 1.1-1.1 0-1.6-13.4-36.6-.3-2.5 .7-2.4 12.2-13.9 8.8-12.1 2.8-2 3.1-.3 38.4 5.4 2.1-.9 .5-1.5-.6-1.4-27.5-27.4-1.6-2.7-.2-3.1 4.6-15.8 2.9-15.8 1.3-2.6 2.5-1.9 37.3-12.2 1.6-1.9-.3-1.5-1.1-1-36.8-12.5-2.4-1.4-1.8-3.3-3.1-17.7 0-2.2 .9-2.4 3.1-2.9 10.6-15.3 3.3-1.8 3.4 .3 3.8 3 4.5 6.8 8.9 11.2 12.5 12.5 6.2 4.8 7.3 4.3 6.3 2.4 3.8 .3 4-.3 5.1-2.4 6.5-7 4.8-10.6 3.3-11.9 2-14.1 1.3-3.4 0-66.6-.8-2.6-2-13.6-3.8-14.6-7.5-18.7-4.7-9.4-4-6-7.2-7.1-5-2.1-6.5 0-2.2 .7-6 3.5-12 12-13.1 17.8-11.7 18.2-3.7 1.6-11.8-.1-3.1-1.6-1.8-2.9-.3-8.8-2.8-12.7-1.5-4-7.1-13.3-5.9-7.8-10.7-9.3-8.6-4.7-5.9-2-4.1-.5-6.7-.5-4.1 .5-7 2-7.3 3.8-7.5 7-2.2 3.2-2.5 5.5-2.8 10.5-.5 3.6 .1 17.1-.3 2.2-1.1 1.9-1.7 1.5-3.7 1.5-2.6 .3-27.5-10.5-14.5-4-15.7-3.2-2.6-1.3-1.9-3-9.9-37.5-.9-1.2-1.4-.4-1.3 .4-.8 1-14.7 36.1-1.8 2.1-2.2 1.2-17.8 1.4-15 2.2-3.4-.7-2.4-2.1-22-31.5-2-.9-1.5 .5-.7 1.5-1.4 38.6-.9 3-2.5 2.5-14.7 6.8-13.8 7.8-2.8 .7-3.1-.7-32.9-21.3-2.3 0-1.1 1.1-.1 1.6 13.6 36.9 0 3.1-1.2 2.6-10.8 12-9.5 12.9-2.8 2-3.2 .3-38.4-5.4-1.5 .4-.9 1.4 .6 2.1 27.6 27.6 1.2 1.8 .5 2.2-3 10.6-1.5 2.4-2.4 1.6-5.8 1-4.4 1.8-3.8 3-3 3.8-1.7 4-.7 4.7 .4 4.7 1.5 4.2 .3 .5 30.7 0 1.7 .6 1.4 1.1 1.1 3-1.1 2.9-2.7 1.6-31.1 .1-.6 1.1-1.2 3.6-.4 4.1 .4 4.2 1.2 3.5 2.5 4 3.2 3.1 4.1 2.3 5.6 1.8 2.4 2.1 .9 2.1 5.1 21.2-.6 2.1-1.2 1.9-28.5 26.5zM283.6 189.4l6.6 .5 5.6 1.2 6.2 2.2 5.9 3.1 4.6 3.4 4.8 4.5 3.5 4.4 3.4 5.8 2.6 6.2 1.6 6.4 .6 5.6-.2 6.7-1.1 6.5-1.7 5.4-2.9 6-3.6 5.5-7.1 7.3-8.4 5.4-9.4 3.5-9.9 1.3-11-1-40.4-10.4-2.8-1.1-3.1-2.4-1.7-.6-.9-1.1-.1-2.2-1.4-2.2 1.6-6.3 18.1-38.5 4.7-7.5 7.1-7.3 8.4-5.4 9.4-3.5zM173.9 198l-1.1 5.9-2.3 5.5-3.4 5-4.2 4.3-5 3.3-5.5 2.3-5.9 1.2-6 0-5.9-1.2-5.6-2.3-5-3.3-4.2-4.3-3.3-5-2.3-5.5-1.2-5.9 0-6 1.2-5.9 2.3-5.5 3.3-5 4.2-4.3 5-3.3 5.6-2.3 5.9-1.2 6 0 5.9 1.2 5.5 2.3 5 3.3 4.2 4.3 3.4 5 2.3 5.5 1.1 5.9zM315.1 213.5l-63.1 37.7 69.5-12.9 0-6.2-1-6.5-2.1-6.1zM237.3 260l-2.6 1.5 40.6 10.5 7.4 .9 7.4-.5 5.4-1.4 5.2-2.1 8.5-5.8 3.8-4.1 3.2-4.5 2.6-5 1.6-4.9zM284.5 196.9l-7.4 .5-8.1 2.3-7.3 4.1-6.3 5.5-5.8 8.5-17.4 37.1 3-.6 76.1-45.5-5.8-5-6.5-3.7-7.1-2.3zM141.1 183.6l-1.1-2.9-2-2.3-2.8-1.3-3.1-.1-2.9 1-2.3 2.1-1.3 2.8-.1 3 1 2.9 2.1 2.3 2.7 1.3 3.1 .2 2.9-1.1 2.3-2 1.3-2.8z`},null,-1)],8,Hd)):n.value===`apple`?(F(),I(`svg`,{key:1,class:`device-icon apple`,viewBox:`0 0 384 512`,width:e.size,height:e.size,role:`img`,"aria-label":r.value},[R(`title`,null,E(r.value),1),i[1]||=R(`path`,{fill:`currentColor`,d:`M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z`},null,-1)],8,Ud)):n.value===`laptop`?(F(),L(k(jc),{key:2,class:`device-icon`,size:e.size,"aria-label":r.value},null,8,[`size`,`aria-label`])):(F(),L(k(il),{key:3,class:`device-icon`,size:e.size,"aria-label":r.value},null,8,[`size`,`aria-label`]))}}),Gd=new Map,Kd=new Map;async function qd(e,t){let n=t.filter(t=>!$d(Qd(e,t),Jd));if(n.length)try{let t=await W(e).gitStatusBatch(n,{timeoutMs:6e4});for(let[n,r]of Object.entries(t)){let t=Qd(e,n);t.status=r,t.at=Date.now(),t.error=``}}catch{}}var Jd=6e4,Yd=!1;function Xd(){Yd||(Yd=!0,j(()=>xu.devices.value,e=>{let t=Date.now();for(let n of e){let e=(n.tree?.git??[]).filter(e=>t-e.at<6e4);if(e.length)for(let r of[...Gd.keys()]){let[i,a]=r.split(`::`);if(i!==n.id||!a)continue;let o=Gd.get(r);e.some(e=>a===e.root||a.startsWith(e.root+`/`)||a.startsWith(e.root+`\\`))&&(o.loading||t-o.at<4e3||ef(i,a,{force:!0}))}}}))}var Zd=(e,t)=>`${e}::${t}`;function Qd(e,t){let n=Zd(e,t),r=Gd.get(n);return r||(r=Gt({at:0,status:null,error:``,loading:!1,refreshing:!1}),Gd.set(n,r)),r}var $d=(e,t)=>e.at>0&&Date.now()-e.at<t&&(e.status!==null||e.error);async function ef(e,t,n={}){let{staleMs:r=6e4,force:i=!1,timeoutMs:a=6e4}=n;if(!e||!t)return;let o=Zd(e,t),s=Qd(e,t);if(!i&&$d(s,r))return;let c=Kd.get(o);if(c)return c;s.status===null&&!s.error?s.loading=!0:s.refreshing=!0,s.error=``;let l=(async()=>{try{s.status=await W(e).gitStatus(t,{timeoutMs:a}),s.at=Date.now()}catch(e){let t=e.message??``;s.error=/fetch failed|Cannot reach|Failed to fetch|NetworkError|abort/i.test(t)?`device unreachable — check that it is online, then retry (${t.slice(0,80)})`:t.slice(0,160),s.at=Date.now()}finally{s.loading=!1,s.refreshing=!1,Kd.delete(o)}})();return Kd.set(o,l),l}var tf=new Map;function nf(){j(()=>xu.devices.value.map(e=>`${e.id}:${e.status}:${e.tree?.sessions.length??0}:${e.tree?.sessions.map(e=>e.cwd).join(`|`)}`).join(`;`),()=>{for(let e of xu.devices.value){if(e.status!==`online`||!e.tree?.sessions.length)continue;let t=Date.now();t-(tf.get(e.id)??0)<6e4||(tf.set(e.id,t),qd(e.id,e.tree.sessions.map(e=>e.cwd)))}},{immediate:!0})}var rf=(e,t)=>Qd(e,t).status?.branch,af=[`aria-level`,`aria-expanded`,`aria-selected`,`data-key`,`title`],of=[`aria-label`],sf={key:1,class:`chev`},cf={class:`name`},lf={class:`badge`},uf=[`title`],df=[`aria-label`],ff=[`disabled`,`aria-label`],pf=[`aria-label`],mf=[`checked`,`aria-label`],hf={class:`name`},gf={class:`path`},_f=[`title`],vf={key:2,class:`dot work`,title:`Working`},yf=[`title`],bf=[`disabled`,`aria-label`],xf=[`disabled`,`aria-label`],Sf=[`disabled`,`aria-label`],Cf={class:`name`},wf={key:3,class:`meta`},Tf={key:4,class:`dot work`,title:`Working`},Ef=[`title`],Df=[`disabled`,`aria-label`],Of=Ld(M({__name:`TreeRow`,props:{node:{},depth:{},open:{type:Boolean},selected:{type:Boolean},focused:{type:Boolean},online:{type:Boolean},checkbox:{type:Boolean},checked:{type:Boolean}},emits:[`toggle`,`activate`,`action`,`check`],setup(e,{emit:t}){let n=e,r=t,i=H(()=>n.node.children.length>0),a=H(()=>n.node.type===`device`?n.node.device:void 0),o=H(()=>n.node.type===`session`?n.node.session:void 0),s=H(()=>n.node.type===`agent`?n.node.agent:void 0),c=H(()=>o.value?o.value.agents.reduce((e,t)=>e+t.background,0):s.value?.background??0),l=H(()=>o.value?.busy||s.value?.busy),u=H(()=>{let e=a.value?.info?.packageVersion,t=Cu.value;return!!(e&&t&&t!==`unknown`&&e!==t)}),d=H(()=>{let e=a.value;if(!e)return``;let t=e.tree?.sessions.length??0;switch(e.status){case`online`:return`${t} session${t===1?``:`s`}`;case`checking`:return`checking…`;case`unauthorized`:return e.hasToken?`token rejected`:`no token`;case`mismatch`:return`identity changed`;case`incompatible`:return`incompatible`;default:return`offline · ${dd(e.lastSeenAt)}`}}),f=H(()=>{let e=a.value?.status;return e===`online`?`on`:e===`checking`?`chk`:e===`offline`?`off`:`err`}),p=H(()=>{let e=n.node;return e.type===`session`?rf(e.deviceId,e.session.cwd):void 0}),m=H(()=>a.value?.name??a.value?.id??o.value?.name??s.value?.name??``),h=H(()=>{if(a.value)return`${a.value.name} · ${a.value.url}${a.value.error?`\n${a.value.error}`:``}`;if(o.value)return`${o.value.name}\n${o.value.cwd}`;let e=s.value;return e.kind===`fork`?`Fork of agent #${e.parentId} at entry #${e.forkedAt}`:e.kind===`subagent`?`Subagent owned by agent #${e.ownerAgentId}`:`Root agent`});return(t,n)=>(F(),I(`div`,{class:T([`tree-row`,[e.node.type,{sel:e.selected,focus:e.focused,stale:e.node.stale}]]),style:_e({"--depth":e.depth}),role:`treeitem`,"aria-level":e.depth+1,"aria-expanded":i.value?e.open:void 0,"aria-selected":e.selected,"data-key":e.node.key,title:h.value,onClick:n[13]||=e=>r(`activate`)},[i.value?(F(),I(`button`,{key:0,class:`chev`,tabindex:`-1`,"aria-label":e.open?`Collapse ${m.value}`:`Expand ${m.value}`,onClick:n[0]||=As(e=>r(`toggle`),[`stop`])},[e.open?(F(),L(k(rc),{key:0,size:16})):(F(),L(k(ic),{key:1,size:16}))],8,of)):(F(),I(`span`,sf)),a.value?(F(),I(P,{key:2},[R(`i`,{class:T([`dot`,f.value])},null,2),z(Wd,{device:a.value,size:16},null,8,[`device`]),R(`b`,cf,E(m.value),1),R(`span`,lf,E(a.value.kind),1),u.value?(F(),I(`span`,{key:0,class:`tag update`,title:`device runs ${a.value?.info?.packageVersion??`?`}; hub runs ${k(Cu)}. Devices self-update: dpi update`},`update`,8,uf)):V(``,!0),R(`span`,{class:T([`meta`,{err:f.value===`err`}])},E(d.value),3),R(`span`,{class:`acts`,onClick:n[4]||=As(()=>{},[`stop`])},[a.value.pairing?(F(),I(`button`,{key:0,class:`icon-button`,"aria-label":`Manage credentials for ${m.value}`,title:`Manage device credentials, including while offline`,onClick:n[1]||=e=>r(`action`,`credentials`)},[z(k(Ac),{size:16})],8,df)):V(``,!0),R(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`New session on ${m.value}`,title:`New session on this device`,onClick:n[2]||=e=>r(`action`,`new-session`)},[z(k(Zc),{size:16})],8,ff),R(`button`,{class:`icon-button`,"aria-label":`Check ${m.value}`,title:`Check connection now`,onClick:n[3]||=e=>r(`action`,`check`)},[z(k(el),{size:16})],8,pf)])],64)):o.value?(F(),I(P,{key:3},[e.checkbox?(F(),I(`input`,{key:0,type:`checkbox`,class:`bulk-check`,checked:e.checked,"aria-label":`Select ${m.value}`,tabindex:`-1`,onClick:n[5]||=As(()=>{},[`stop`]),onChange:n[6]||=e=>r(`check`)},null,40,mf)):V(``,!0),z(k(bc),{class:`ico`,size:16}),R(`b`,hf,E(m.value),1),R(`span`,gf,`…/`+E(o.value.cwd.split(`/`).filter(Boolean).at(-1)),1),p.value?(F(),I(`span`,{key:1,class:`branch`,title:`git branch of ${o.value.cwd}`},`⎇ `+E(p.value),9,_f)):V(``,!0),l.value?(F(),I(`i`,vf)):V(``,!0),c.value?(F(),I(`span`,{key:3,class:`bg-count`,title:`${c.value} background task(s)`},[n[14]||=R(`i`,{class:`dot bg`},null,-1),B(E(c.value)+` bg`,1)],8,yf)):V(``,!0),R(`span`,{class:`acts`,onClick:n[10]||=As(()=>{},[`stop`])},[R(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`New agent in ${m.value}`,title:`New agent in this session`,onClick:n[7]||=e=>r(`action`,`new-agent`)},[z(k(Zc),{size:16})],8,bf),R(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`Rename session ${m.value}`,title:`Rename session`,onClick:n[8]||=e=>r(`action`,`rename`)},[z(k(Jc),{size:16})],8,xf),R(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`Archive session ${m.value}`,title:`Archive session`,onClick:n[9]||=e=>r(`action`,`archive`)},[z(k(Ws),{size:16})],8,Sf)])],64)):s.value?(F(),I(P,{key:4},[s.value.kind===`fork`?(F(),L(k(wc),{key:0,class:`ico`,size:16})):s.value.kind===`subagent`?(F(),L(k(lc),{key:1,class:`ico`,size:16})):(F(),L(k(Rc),{key:2,class:`ico root`,size:16})),R(`span`,Cf,E(m.value),1),s.value.kind===`fork`&&s.value.forkedAt!==void 0?(F(),I(`span`,wf,`@ #`+E(s.value.forkedAt),1)):V(``,!0),l.value?(F(),I(`i`,Tf)):V(``,!0),c.value?(F(),I(`span`,{key:5,class:`bg-count`,title:`${c.value} background task(s)`},[n[15]||=R(`i`,{class:`dot bg`},null,-1),B(E(c.value),1)],8,Ef)):V(``,!0),R(`span`,{class:`acts`,onClick:n[12]||=As(()=>{},[`stop`])},[R(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`Rename agent ${m.value}`,title:`Rename agent`,onClick:n[11]||=e=>r(`action`,`rename`)},[z(k(Jc),{size:16})],8,Df)])],64)):V(``,!0)],14,af))}}),[[`__scopeId`,`data-v-f2a70cbb`]]),kf={class:`project-bar`,"aria-label":`Projects`},Af={class:`project-head`},jf={class:`project-title`},Mf=[`aria-label`,`title`],Nf={key:0,class:`project-hint`},Pf={key:0,class:`chips`},Ff=[`title`,`onClick`,`onDblclick`],If={class:`chip-name`},Lf={class:`chip-count`},Rf={key:1,class:`project-hint`},zf={key:2,class:`project-actions`},Bf=[`onClick`],Vf=[`onClick`],Hf=[`onClick`],Uf=[`onClick`],Wf={key:3,class:`message-error`},Gf={key:4,class:`project-hint labels-hint`},Kf=Ld(M({__name:`ProjectBar`,props:{active:{},activeModifiers:{}},emits:[`update:active`],setup(e,{expose:t}){let n=Oi(e,`active`),r=O([]),i=O(!1),a=O(``),o=O(!1),s=H(()=>xu.devices.value.filter(e=>e.status===`online`).map(e=>e.id));async function c(){i.value=!0,a.value=``;let e=[],t=[];for(let n of s.value){let r=xu.devices.value.find(e=>e.id===n),i=await W(n).projects(o.value).catch(e=>{let r=lu(e);e.code===`not_found`||/allowlist|not found/i.test(r)||t.push(`${n}: ${r.slice(0,60)}`)});for(let t of i?.projects??[]){let i=(r?.tree?.sessions??[]).filter(e=>e.cwd===t.rootPath||e.cwd.startsWith(`${t.rootPath}/`)).length;e.push({deviceId:n,project:t,sessions:i})}}r.value=e.sort((e,t)=>l(e.project).localeCompare(l(t.project))),t.length&&(a.value=t.join(` · `)),i.value=!1}j([s,o],c,{immediate:!0});let l=e=>e.customName??e.name,u=e=>n.value?.deviceId===e.deviceId&&n.value.rootPath===e.project.rootPath;function d(e){n.value=u(e)?void 0:{deviceId:e.deviceId,rootPath:e.project.rootPath}}function f(e){let t=e.project;K.dialog={kind:`prompt`,title:`Rename ${l(t)}`,label:`Project name`,hint:`Shown in the tree and in usage rollups. Leave empty to use the folder name.`,value:t.customName??``,placeholder:t.name,submit:`Save name`,run:async n=>{let r=await W(e.deviceId).updateProject(t.id,{customName:n});q(`Project renamed to ${r.customName??r.name}.`),await c()}}}function p(e){let t=e.project;K.dialog={kind:`prompt`,title:`Labels for ${l(t)}`,label:`Labels (comma separated)`,hint:`Lowercase, up to 12 labels of 32 characters. Used to filter projects.`,value:t.labels.join(`, `),submit:`Save labels`,run:async n=>{let r=await W(e.deviceId).updateProject(t.id,{labels:n.split(`,`).map(e=>e.trim()).filter(Boolean)});q(r.labels.length?`Labels: ${r.labels.join(`, `)}.`:`Labels cleared on ${l(r)}.`),await c()}}}function m(e){let t=e.project,n=xu.devices.value.find(t=>t.id===e.deviceId)?.info?.models??[];K.dialog={kind:`prompt`,title:`Default model for ${l(t)}`,label:`Model (provider/modelId)`,hint:n.length?`New sessions in this project start on this model instead of the device default. Leave empty to use the device default. E.g. ${n[0].provider}/${n[0].id}`:`New sessions in this project start on this model. Leave empty to use the device default.`,value:t.model?`${t.model.provider}/${t.model.modelId}`:``,placeholder:`device default`,submit:`Save default model`,run:async r=>{if(!r.trim()){await W(e.deviceId).updateProject(t.id,{model:``}),q(`Default model cleared on ${l(t)}.`),await c();return}let[i,...a]=r.trim().split(`/`),o=a.join(`/`),s=n.some(e=>e.provider===i&&e.id===o);if(!i||!o)throw Error(`Format: provider/modelId`);if(!s)throw Error(`${r.trim()} is not in this device's catalog`);await W(e.deviceId).updateProject(t.id,{model:{provider:i,modelId:o}}),q(`New sessions in ${l(t)} start on ${o}.`),await c()}}}function h(e){let t=e.project,r=t.archivedAt!==null;K.dialog={kind:`prompt`,title:`${r?`Restore`:`Archive`} ${l(t)}?`,hint:r?`The project returns to the tree. Its sessions were never touched.`:`Bookkeeping only: the project leaves the list, its sessions keep running. Nothing is deleted.`,submit:r?`Restore project`:`Archive project`,danger:!r,run:async()=>{let i=W(e.deviceId);r?await i.unarchiveProject(t.id):await g(i,t.id),!r&&u(e)&&(n.value=void 0),await c()}}}let g=(e,t)=>e.archiveProject(t);return t({reload:c}),(e,t)=>(F(),I(`div`,kf,[R(`div`,Af,[R(`span`,jf,[z(k(yc),{size:13}),t[2]||=B(`PROJECTS`,-1)]),R(`button`,{class:T([`icon-button tiny`,{on:o.value}]),"aria-label":o.value?`Hide archived projects`:`Show archived projects`,title:o.value?`Hide archived projects`:`Show archived projects`,onClick:t[0]||=e=>o.value=!o.value},[z(k(Ws),{size:12})],10,Mf),i.value?(F(),I(`span`,Nf,`…`)):V(``,!0)]),r.value.length?(F(),I(`div`,Pf,[(F(!0),I(P,null,N(r.value,e=>(F(),I(`button`,{key:`${e.deviceId}-${e.project.id}`,class:T([`chip`,{on:u(e),archived:e.project.archivedAt}]),title:`${e.project.rootPath} — ${e.sessions} session${e.sessions===1?``:`s`}`,onClick:t=>d(e),onDblclick:t=>f(e)},[e.project.kind===`plain`?(F(),L(k(xc),{key:0,size:11})):(F(),L(k(yc),{key:1,size:11})),R(`span`,If,E(l(e.project)),1),R(`em`,Lf,E(e.sessions),1),(F(!0),I(P,null,N(e.project.labels.slice(0,2),e=>(F(),I(`span`,{key:e,class:`chip-label`},E(e),1))),128))],42,Ff))),128))])):i.value?V(``,!0):(F(),I(`p`,Rf,` No projects yet — a project appears when a session starts in a folder. `)),n.value?(F(),I(`div`,zf,[t[5]||=R(`span`,{class:`project-hint`},`filtering`,-1),(F(!0),I(P,null,N(r.value.filter(u),e=>(F(),I(P,{key:e.project.id},[R(`button`,{class:`small`,onClick:t=>f(e)},[z(k(Jc),{size:12}),t[3]||=B(`name`,-1)],8,Bf),R(`button`,{class:`small`,onClick:t=>p(e)},[z(k(ul),{size:12}),t[4]||=B(`labels`,-1)],8,Vf),R(`button`,{class:`small`,onClick:t=>m(e),title:`Default model for new sessions in this project`},[z(k(fc),{size:12}),B(E(e.project.model?`model ✓`:`model`),1)],8,Hf),R(`button`,{class:`small`,onClick:t=>h(e)},[e.project.archivedAt?(F(),L(k(Us),{key:0,size:12})):(F(),L(k(Ws),{key:1,size:12})),B(` `+E(e.project.archivedAt?`restore`:`archive`),1)],8,Uf),R(`button`,{class:`icon-button tiny`,"aria-label":`Clear project filter`,onClick:t[1]||=e=>n.value=void 0},[z(k(yl),{size:12})])],64))),128))])):V(``,!0),a.value?(F(),I(`p`,Wf,E(a.value),1)):V(``,!0),r.value.some(e=>e.project.labels.length)?(F(),I(`p`,Gf,[z(k(ul),{size:11}),B(`labels: `+E([...new Set(r.value.flatMap(e=>e.project.labels))].join(` · `)),1)])):V(``,!0)]))}}),[[`__scopeId`,`data-v-77864963`]]),qf={class:`tree-head`},Jf=[`aria-label`,`title`],Yf=[`title`],Xf={class:`tree-search`},Zf={key:1,class:`searching`,"aria-label":`Searching devices`},Qf={key:0,class:`bulk-bar`},$f=[`disabled`],ep=[`disabled`],tp={class:`hit-head hint`},np=[`title`,`onClick`],rp={class:`hit-name`},ip={class:`hit-cwd`},ap={key:0,class:`hit-where`},op={key:2,class:`hint tree-empty`},sp={key:3,class:`hint tree-empty`,"data-testid":`tree-empty`},cp={key:1,class:`panel-rail`,"aria-label":`Network (collapsed)`},lp=[`title`],up=[`title`,`aria-label`,`onClick`],dp=Ld(M({__name:`NetworkSidebar`,setup(e){let t=H(()=>{let e=[],t=(n,r,i)=>{for(let a of n)e.push({node:a,depth:r,parent:i}),a.children.length&&wu.value.has(a.key)&&t(a.children,r+1,a.key)};return t(xu.tree.value,0),e}),n=O(),r=O(),i=O(``),a=O([]),o=O(!1),s=H(()=>i.value.trim().toLowerCase()),c=H(()=>s.value.length>=2),l=H(()=>{let e=new Set;if(!c.value)return e;for(let t of xu.devices.value)for(let n of t.tree?.sessions??[])`${n.name}\n${n.cwd}`.toLowerCase().includes(s.value)&&e.add(n.id);return e}),u=O(),d=(e,t)=>!u.value||u.value.deviceId===e&&(t===u.value.rootPath||t.startsWith(`${u.value.rootPath}/`)),f=H(()=>{if(!c.value&&!u.value)return t.value;let e=e=>{if(u.value){let t=e.type===`device`?e.device.id:e.deviceId;if(e.type===`session`&&!d(t,e.session.cwd))return!1;if(e.type===`agent`){let t=xu.devices.value.find(t=>t.id===e.deviceId)?.tree?.sessions.find(t=>t.id===e.sessionId);if(t&&!d(e.deviceId,t.cwd))return!1}if(e.type===`device`)return(e.device.tree?.sessions??[]).some(t=>d(e.device.id,t.cwd))}return c.value?e.type===`session`?l.value.has(e.session.id):e.type===`agent`?l.value.has(e.sessionId)||e.agent.name.toLowerCase().includes(s.value):(e.device.tree?.sessions??[]).some(e=>l.value.has(e.id)):!0},n=new Set(t.value.filter(t=>e(t.node)).map(e=>e.node.key));return t.value.filter(e=>n.has(e.node.key))}),p=H(()=>a.value.filter(e=>!t.value.some(t=>t.node.type===`session`&&t.node.session.id===e.id))),m;j(i,e=>{clearTimeout(m);let t=e.trim();if(t.length<2){a.value=[],o.value=!1;return}m=setTimeout(async()=>{o.value=!0;let e=[];for(let n of xu.devices.value.filter(e=>e.status===`online`)){let r=await W(n.id).searchSessions(t).catch(()=>void 0);for(let t of r?.matches??[])e.push({deviceId:n.id,id:t.id,name:t.name,cwd:t.cwd,where:t.where})}a.value=e,o.value=!1},250)});let h=()=>(i.value=``,a.value=[]),g=O(!1),_=O(new Set),v=O(``),y=e=>{if(e.type!==`session`)return;let t=new Set(_.value);t.has(e.session.id)?t.delete(e.session.id):t.add(e.session.id),_.value=t},b=async e=>{v.value=e;let n=0,r=[];for(let i of t.value.map(e=>e.node)){if(i.type!==`session`||!_.value.has(i.session.id))continue;let t=ee(i);if(!t)continue;let a=W(t.id);try{e===`archive`?await a.session(i.session.id).archive():await a.agent(i.session.id,1).abort(!0),n++,e===`archive`&&G.value?.sessionId===i.session.id&&Ru(void 0)}catch{r.push(i.session.name)}}q(`${e}: ${n} done${r.length?`, ${r.length} failed (${r.slice(0,3).join(`, `)})`:``}`),_.value=new Set,v.value=``},ee=e=>xu.devices.value.find(t=>t.id===(e.type===`device`?e.device.id:e.deviceId)),x=e=>ee(e)?.status===`online`,S=e=>e.type===`agent`&&G.value?.deviceId===e.deviceId&&G.value.sessionId===e.sessionId&&G.value.agentId===e.agent.id;function te(e){if(n.value=e.key,g.value&&e.type===`session`)return y(e);if(e.type===`device`)return Vu(e.key);if(e.type===`agent`)return Ru({deviceId:e.deviceId,sessionId:e.sessionId,agentId:e.agent.id});let t=e.session.agents.find(e=>e.kind===`root`)??e.session.agents[0];Vu(e.key,!0),t&&Ru({deviceId:e.deviceId,sessionId:e.session.id,agentId:t.id})}async function ne(e,t){let n=ee(e);if(!n)return;let r=W(n.id);if(e.type===`device`){t===`new-session`?K.dialog={kind:`new-session`,deviceId:n.id}:t===`check`?await od(()=>cu.check(n.id)):t===`credentials`&&(K.dialog={kind:`credentials`,deviceId:n.id});return}if(e.type===`session`){let i=e.session;if(t===`new-agent`){let e=await od(()=>r.session(i.id).createAgent({}));e&&(Ru({deviceId:n.id,sessionId:i.id,agentId:e.id}),q(`New agent. Same session, same shared App State.`))}else t===`rename`?K.dialog={kind:`prompt`,title:`Rename session`,label:`Session name`,value:i.name,submit:`Save name`,run:e=>r.session(i.id).rename(e)}:t===`archive`&&(K.dialog={kind:`prompt`,title:`Archive ${i.name}?`,hint:`Stops all of its work and moves its files to archive/ on ${n.id}. Nothing is deleted.`,submit:`Archive session`,danger:!0,run:async()=>{await r.session(i.id).archive(),G.value?.sessionId===i.id&&Ru(void 0)}});return}let i=e.agent;t===`rename`&&(K.dialog={kind:`prompt`,title:`Rename agent`,label:`Agent name`,value:i.named?i.name:``,placeholder:i.name,submit:`Save name`,run:t=>r.agent(e.sessionId,i.id).rename(t)})}function C(e){let i=t.value.findIndex(e=>e.node.key===n.value),a=t.value[Math.max(0,Math.min(t.value.length-1,(i<0?0:i)+e))];a&&(n.value=a.node.key,jn(()=>r.value?.querySelector(`[data-key="${CSS.escape(a.node.key)}"]`)?.scrollIntoView({block:`nearest`})))}function re(){n.value??=t.value[0]?.node.key}function ie(e){let r=t.value.find(e=>e.node.key===n.value);if(e.key===`ArrowDown`)C(1);else if(e.key===`ArrowUp`)C(-1);else if(e.key===`ArrowRight`&&r){if(!r.node.children.length)return;wu.value.has(r.node.key)?C(1):Vu(r.node.key,!0)}else if(e.key===`ArrowLeft`&&r)r.node.children.length&&wu.value.has(r.node.key)?Vu(r.node.key,!1):r.parent&&(n.value=r.parent);else if((e.key===`Enter`||e.key===` `)&&r)te(r.node);else return;e.preventDefault()}return(e,a)=>(F(),I(`aside`,{class:T([`network-sidebar`,{open:k(K).drawer,collapsed:!k(Eu).tree&&!k(K).drawer}]),"aria-label":`Network`},[k(Eu).tree||k(K).drawer?(F(),I(P,{key:0},[R(`header`,qf,[R(`span`,null,[z(k(Vc),{size:16}),a[8]||=B(`NETWORK`,-1)]),R(`button`,{class:T([`icon-button`,{on:g.value}]),"aria-label":g.value?`Exit bulk select`:`Bulk manage sessions`,title:g.value?`Exit bulk select`:`Bulk manage sessions (select → archive / abort)`,onClick:a[0]||=e=>(g.value=!g.value,_.value=new Set)},[z(k(Fc),{size:15})],10,Jf),R(`button`,{class:`icon-button`,"aria-label":`Pair a device`,title:`Pair a device`,onClick:a[1]||=e=>k(K).dialog={kind:`pair`}},[z(k(Pc),{size:15})]),R(`button`,{class:`icon-button panel-toggle`,"aria-label":`Collapse network`,title:`Collapse network (${k(Sd).tree})`,onClick:a[2]||=e=>(k(Eu).tree=!1,k(K).drawer=!1)},[z(k(Wc),{size:18})],8,Yf)]),R(`div`,Xf,[z(k(nl),{size:14,class:`search-icon`}),A(R(`input`,{"onUpdate:modelValue":a[3]||=e=>i.value=e,type:`search`,class:`search-input`,placeholder:`Search sessions…`,"aria-label":`Search sessions`,spellcheck:`false`},null,512),[[bs,i.value]]),i.value?(F(),I(`button`,{key:0,class:`icon-button clear`,"aria-label":`Clear search`,onClick:h},[z(k(yl),{size:13})])):V(``,!0),o.value?(F(),I(`span`,Zf,`…`)):V(``,!0)]),z(Kf,{active:u.value,"onUpdate:active":a[4]||=e=>u.value=e},null,8,[`active`]),R(`div`,{ref_key:`list`,ref:r,class:`tree-list`,role:`tree`,tabindex:`0`,"aria-label":`Devices, sessions and agents`,onKeydown:ie,onFocus:re},[g.value&&_.value.size?(F(),I(`div`,Qf,[R(`span`,null,E(_.value.size)+` selected`,1),R(`button`,{class:`small`,disabled:!!v.value,onClick:a[5]||=e=>b(`abort`)},`abort work`,8,$f),R(`button`,{class:`small danger`,disabled:!!v.value,onClick:a[6]||=e=>b(`archive`)},E(v.value===`archive`?`archiving…`:`archive`),9,ep)])):V(``,!0),(F(!0),I(P,null,N(f.value,e=>(F(),L(Of,{key:e.node.key,node:e.node,depth:e.depth,open:k(wu).has(e.node.key),selected:S(e.node),focused:n.value===e.node.key,online:x(e.node),checkbox:g.value&&e.node.type===`session`,checked:e.node.type===`session`&&_.value.has(e.node.session.id),onToggle:t=>k(Vu)(e.node.key),onActivate:t=>te(e.node),onAction:t=>ne(e.node,t),onCheck:t=>y(e.node)},null,8,[`node`,`depth`,`open`,`selected`,`focused`,`online`,`checkbox`,`checked`,`onToggle`,`onActivate`,`onAction`,`onCheck`]))),128)),c.value&&p.value.length?(F(),I(P,{key:1},[R(`div`,tp,E(p.value.length)+` more on device`,1),(F(!0),I(P,null,N(p.value,e=>(F(),I(`button`,{key:`${e.deviceId}-${e.id}`,class:`hit`,title:e.cwd,onClick:t=>k(Ru)({deviceId:e.deviceId,sessionId:e.id,agentId:1})},[R(`span`,rp,E(e.name),1),R(`code`,ip,E(e.cwd),1),e.where.length?(F(),I(`em`,ap,E(e.where.join(` · `)),1)):V(``,!0)],8,np))),128))],64)):V(``,!0),c.value&&!f.value.length&&!p.value.length?(F(),I(`p`,op,` No session matches “`+E(i.value.trim())+`”. `,1)):V(``,!0),!t.value.length&&!c.value?(F(),I(`p`,sp,[...a[9]||=[B(` No devices yet. Declare them in `,-1),R(`code`,null,`dpi-network.yaml`,-1),B(` (start from `,-1),R(`code`,null,`dpi-network.example.yaml`,-1),B(`), then run `,-1),R(`code`,null,`just net up <id>`,-1),B(`. `,-1)]])):V(``,!0)],544)],64)):(F(),I(`div`,cp,[R(`button`,{class:`icon-button panel-toggle`,"aria-label":`Expand network`,title:`Expand network (${k(Sd).tree})`,onClick:a[7]||=e=>k(Eu).tree=!0},[z(k(Gc),{size:18})],8,lp),(F(!0),I(P,null,N(k(xu).devices.value,e=>(F(),I(`button`,{key:e.id,class:`rail-device`,title:`${e.id} · ${e.status}`,"aria-label":`Show ${e.id}`,onClick:t=>(k(Eu).tree=!0,k(Vu)(e.id,!0))},[z(Wd,{device:e,size:20},null,8,[`device`]),R(`i`,{class:T([`dot`,e.status===`online`?`on`:e.status===`checking`?`chk`:e.status===`offline`?`off`:`err`])},null,2)],8,up))),128))]))],2))}}),[[`__scopeId`,`data-v-5ce92b7d`]]);function fp(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var pp=fp();function mp(e){pp=e}var hp={exec:()=>null};function gp(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(vp.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var _p=(()=>{try{return!0}catch{return!1}})(),vp={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},yp=/^(?:[ \t]*(?:\n|$))+/,bp=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,xp=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Sp=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Cp=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,wp=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Tp=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ep=gp(Tp).replace(/bull/g,wp).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Dp=gp(Tp).replace(/bull/g,wp).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Op=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,kp=/^[^\n]+/,Ap=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,jp=gp(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Ap).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Mp=gp(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,wp).getRegex(),Np=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Pp=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Fp=gp(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Pp).replace(`tag`,Np).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ip=gp(Op).replace(`hr`,Sp).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Np).getRegex(),Lp={blockquote:gp(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Ip).getRegex(),code:bp,def:jp,fences:xp,heading:Cp,hr:Sp,html:Fp,lheading:Ep,list:Mp,newline:yp,paragraph:Ip,table:hp,text:kp},Rp=gp(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Sp).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Np).getRegex(),zp={...Lp,lheading:Dp,table:Rp,paragraph:gp(Op).replace(`hr`,Sp).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Rp).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Np).getRegex()},Bp={...Lp,html:gp(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Pp).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:hp,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:gp(Op).replace(`hr`,Sp).replace(`heading`,` *#{1,6} *[^
|
|
15
|
+
`),id:n}:void 0}var nu=encodeURIComponent,ru=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`,iu=class{token;baseUrl;constructor(e,t){this.token=t,this.baseUrl=e.replace(/\/+$/,``)}headers(e,t={}){return{...this.token?{authorization:`Bearer ${this.token}`,"x-dpi-token":this.token}:{},...e?{"content-type":`application/json`}:{},...t}}async request(e,t,n,r={}){let i=AbortSignal.timeout(r.timeoutMs??2e4),a=r.signal?AbortSignal.any([r.signal,i]):i,o;try{o=await fetch(this.baseUrl+t,{method:e,signal:a,headers:this.headers(n!==void 0,r.idempotencyKey?{"idempotency-key":r.idempotencyKey}:{}),body:n===void 0?void 0:JSON.stringify(n)})}catch(e){throw r.signal?.aborted?e:new Jl(`offline`,`Cannot reach ${this.baseUrl}`,0,{cause:e})}let s=await o.text(),c;try{c=s?JSON.parse(s):void 0}catch{c=void 0}if(!o.ok){let e=c?.error;throw new Jl(e?.code??(o.status===401?`unauthorized`:o.status===404?`not_found`:`internal`),e?.message??`${o.status} ${o.statusText}`,o.status)}return c}async*stream(e,t,n){let r;try{r=await fetch(this.baseUrl+e,{headers:{...this.headers(!1),accept:`text/event-stream`},signal:t})}catch(e){if(t.aborted)return;throw new Jl(`offline`,`Cannot reach ${this.baseUrl}`,0,{cause:e})}if(!r.ok||!r.body){let e=await r.json().catch(()=>void 0);throw new Jl(e?.error?.code??(r.status===401?`unauthorized`:`unavailable`),e?.error?.message??`Stream failed (${r.status})`,r.status)}try{for await(let e of eu(r.body,n))yield JSON.parse(e.data)}catch(e){if(t.aborted)return;throw e}}device(e){return this.request(`GET`,`/v1/device`,void 0,e)}vitals(){return this.request(`GET`,`/v1/device/vitals`)}tree(){return this.request(`GET`,`/v1/tree`)}projects(e=!1){return this.request(`GET`,`/v1/projects${e?`?includeArchived=1`:``}`)}updateProject(e,t){return this.request(`PATCH`,`/v1/projects/${nu(e)}`,t)}archiveProject(e){return this.request(`POST`,`/v1/projects/${nu(e)}/archive`,{})}unarchiveProject(e){return this.request(`POST`,`/v1/projects/${nu(e)}/unarchive`,{})}notifySinks(){return this.request(`GET`,`/v1/notify/sinks`)}createNotifySink(e){return this.request(`POST`,`/v1/notify/sinks`,e)}updateNotifySink(e,t){return this.request(`PATCH`,`/v1/notify/sinks/${nu(e)}`,t)}removeNotifySink(e){return this.request(`DELETE`,`/v1/notify/sinks/${nu(e)}`)}testNotifySinks(){return this.request(`POST`,`/v1/notify/test`,{})}envView(){return this.request(`GET`,`/v1/device/env`)}setEnvVar(e,t){return this.request(`POST`,`/v1/device/env`,{key:e,value:t})}removeEnvVar(e){return this.request(`DELETE`,`/v1/device/env/${nu(e)}`)}piAuth(){return this.request(`GET`,`/v1/device/pi-auth`)}setPiApiKey(e,t){return this.request(`PUT`,`/v1/device/pi-auth/${nu(e)}`,{key:t})}removePiApiKey(e){return this.request(`DELETE`,`/v1/device/pi-auth/${nu(e)}`)}graphs(){return this.request(`GET`,`/v1/graphs`)}graph(e){return this.request(`GET`,`/v1/graphs/${nu(e)}`)}createGraph(e){return this.request(`POST`,`/v1/graphs`,e)}runGraph(e){return this.request(`POST`,`/v1/graphs/${nu(e)}/run`,{})}removeGraph(e){return this.request(`DELETE`,`/v1/graphs/${nu(e)}`)}schedules(){return this.request(`GET`,`/v1/schedules`)}createSchedule(e){return this.request(`POST`,`/v1/schedules`,e)}updateSchedule(e,t){return this.request(`PATCH`,`/v1/schedules/${nu(e)}`,t)}removeSchedule(e){return this.request(`DELETE`,`/v1/schedules/${nu(e)}`)}runSchedule(e){return this.request(`POST`,`/v1/schedules/${nu(e)}/run`,{})}deviceUsage(){return this.request(`GET`,`/v1/device/usage`)}searchSessions(e){return this.request(`GET`,`/v1/sessions/search?q=${nu(e)}`)}dirs(e=``){return this.request(`GET`,`/v1/fs/dirs?path=${nu(e)}`)}deviceDoc(e){return this.request(`GET`,`/v1/docs/${nu(e)}`)}deviceEvents(e,t=[]){return this.stream(`/v1/events${t.length?`?docs=${t.map(nu).join(`,`)}`:``}`,e)}gitStatus(e,t={}){return this.request(`GET`,`/v1/git/status?path=${nu(e)}`,void 0,t)}gitOp(e,t,n={}){return this.request(`POST`,`/v1/git`,{path:e,op:t,...n})}exportSession(e){return this.request(`GET`,`/v1/sessions/${nu(e)}/export`)}sessionGitFiles(e){return this.request(`GET`,`/v1/sessions/${nu(e)}/git-files`)}sessionGitTurns(e){return this.request(`GET`,`/v1/sessions/${nu(e)}/git-turns`)}gitStatusBatch(e,t={}){return this.request(`POST`,`/v1/git/status-batch`,{paths:e},t)}sessions(){return this.request(`GET`,`/v1/sessions`)}createSession(e,t=ru()){return this.request(`POST`,`/v1/sessions`,e,{idempotencyKey:t})}session(e){return new au(this,e)}agent(e,t){return new ou(this,e,String(t))}},au=class{client;ref;constructor(e,t){this.client=e,this.ref=t}get base(){return`/v1/sessions/${nu(this.ref)}`}get(){return this.client.request(`GET`,this.base)}rename(e){return this.client.request(`PATCH`,this.base,{name:e})}archive(){return this.client.request(`DELETE`,this.base)}agents(){return this.client.request(`GET`,`${this.base}/agents`)}createAgent(e={},t=ru()){return this.client.request(`POST`,`${this.base}/agents`,e,{idempotencyKey:t})}tasks(e=`terminal`,t=20){return this.client.request(`GET`,`${this.base}/tasks?status=${e}&limit=${t}`)}abortTask(e){return this.client.request(`POST`,`${this.base}/tasks/${e}/abort`,{})}inspect(){return this.client.request(`GET`,`${this.base}/inspect`)}compaction(){return this.client.request(`GET`,`${this.base}/compaction`)}setCompaction(e){return this.client.request(`PATCH`,`${this.base}/compaction`,e)}submission(e,t=0){return this.client.request(`GET`,`${this.base}/submissions/${e}?waitMs=${t}`,void 0,{timeoutMs:t+2e4})}events(e){return this.client.stream(`${this.base}/events`,e)}},ou=class{client;session;agent;constructor(e,t,n){this.client=e,this.session=t,this.agent=n}get base(){return`/v1/sessions/${nu(this.session)}/agents/${nu(this.agent)}`}get(){return this.client.request(`GET`,this.base)}rename(e){return this.client.request(`PATCH`,this.base,{name:e})}send(e,t=`followUp`,n=ru(),r){return this.client.request(`POST`,`${this.base}/messages`,{content:e,whenBusy:t,requestId:n,waitMs:r},{timeoutMs:(r??0)+2e4})}withdraw(e){return this.client.request(`DELETE`,`${this.base}/inbox/${e}`)}abort(e=!1){return this.client.request(`POST`,`${this.base}/abort`,{background:e})}fork(e,t=ru()){return this.client.request(`POST`,`${this.base}/fork`,e,{idempotencyKey:t})}config(){return this.client.request(`GET`,`${this.base}/config`)}configure(e){return this.client.request(`PATCH`,`${this.base}/config`,e)}compact(e){return this.client.request(`POST`,`${this.base}/compact`,{instructions:e})}reset(e){return this.client.request(`POST`,`${this.base}/reset`,{note:e})}entries(e={}){let t=new URLSearchParams({scope:e.scope??`all`,limit:String(e.limit??500),...e.cursor?{cursor:e.cursor}:{}});return this.client.request(`GET`,`${this.base}/entries?${t}`)}transcript(e=`json`){return this.client.request(`GET`,`${this.base}/transcript?format=${e}`)}doc(e){return this.client.request(`GET`,`${this.base}/docs/${nu(e)}`)}extensions(){return this.client.request(`GET`,`${this.base}/extensions`)}setExtension(e){return this.client.request(`PATCH`,`${this.base}/extensions`,e)}demo(e,t,n=`POST`){return this.client.request(n,`${this.base}/demo/${e}`,t)}events(e,t=[]){return this.client.stream(`${this.base}/events${t.length?`?docs=${t.map(nu).join(`,`)}`:``}`,e)}},W=e=>new iu(`/api/devices/${encodeURIComponent(e)}`);async function su(e,t,n){let r=await fetch(`/api${t}`,{method:e,headers:n===void 0?{}:{"content-type":`application/json`},body:n===void 0?void 0:JSON.stringify(n)}),i=await r.json().catch(()=>void 0);if(!r.ok){let e=i?.error;throw new Jl(e?.code??`internal`,e?.message??`${r.status} ${r.statusText}`,r.status)}return i}var cu={network:()=>su(`GET`,`/network`),version:()=>su(`GET`,`/version`),check:e=>su(`POST`,`/devices/${encodeURIComponent(e)}/check`,{}),createShare:e=>su(`POST`,`/shares`,e),async uiGet(e){return(await su(`GET`,`/ui-state/${encodeURIComponent(e)}`)).value??void 0},uiSet:(e,t)=>su(`PUT`,`/ui-state/${encodeURIComponent(e)}`,{value:t})},lu=e=>e instanceof Error?e.message:String(e),uu=[`demo.job-runs`,`demo.workspace`],du=e=>`${e.deviceId}/agent/${e.sessionId}/${e.agentId}?docs=${uu.join(`,`)}`,fu=e=>`${e.deviceId}/session/${e.sessionId}`,pu=e=>`${e}/device?docs=app.shared-state`;function mu(e,t,n,r=`hello`){let i=O(`idle`),a=O(``);return e.route(t,e=>{e.type===`hello`?(i.value=r===`hello`?`live`:`connecting`,r===`hello`&&(a.value=``)):e.type===`disconnected`?i.value=`reconnecting`:e.type===`fault`?(i.value=`fault`,a.value=e.error.message):(n(e),e.type===r&&(a.value=``,i.value=`live`))}),{status:i,fault:a,select:n=>{a.value=``,i.value=n?`connecting`:`idle`,e.set(t,n)},retry:()=>{i.value=`connecting`,e.reopen(t)}}}function hu(e){let t=new Bl,n=O(0);return t.subscribe(()=>n.value++),e.onNetwork(e=>t.apply({type:`network`,devices:e})),{model:t,devices:H(()=>(n.value,t.devices)),tree:H(()=>(n.value,t.tree()))}}function gu(e,t){let n=an(),r=an([]),{status:i,select:a}=mu(e,`device`,e=>{e.type===`doc`&&e.kind===`app.shared-state`?n.value={value:e.value,revision:e.revision??0}:e.type===`activity`&&(r.value=[...r.value,...e.items].slice(-50))});return j(t,e=>{n.value=void 0,a(e?pu(e):void 0)},{immediate:!0}),{sharedState:n,activity:r,status:i}}function _u(e,t){let n=new Nl,r=O(0);n.subscribe(()=>r.value++);let{status:i,fault:a,select:o}=mu(e,`session`,e=>n.apply(e));return j(()=>t.value?fu(t.value):void 0,e=>{n.clear(),o(e)},{immediate:!0}),{model:n,state:H(()=>(r.value,n.state)),status:i,fault:a}}function vu(e,t){let n=new Ml,r=O(0);n.subscribe(()=>r.value++);let{status:i,fault:a,select:o,retry:s}=mu(e,`agent`,e=>n.apply(e),`snapshot`);return j(()=>t.value?du(t.value):void 0,e=>{n.clear(),o(e)},{immediate:!0}),{model:n,state:H(()=>(r.value,{...n.state})),status:i,fault:a,version:r,retry:s}}var yu=new Gl,bu=O(yu.state);yu.onState(e=>bu.value=e);var xu=hu(yu),Su=O(),Cu=O(),G=O(),wu=O(new Set),Tu=O(300),Eu=Gt({tree:!0,inspector:!0}),Du=O(!1),Ou=H(()=>G.value?.deviceId),ku=H(()=>xu.devices.value.find(e=>e.id===Ou.value)),Au=H(()=>ku.value?.status===`online`),ju=_u(yu,H(()=>G.value?{deviceId:G.value.deviceId,sessionId:G.value.sessionId}:void 0)),Mu=vu(yu,G),Nu=gu(yu,Ou),Pu=H(()=>ku.value?.tree?.sessions.find(e=>e.id===G.value?.sessionId)),Fu=H(()=>Ou.value?W(Ou.value):void 0),Iu=H(()=>G.value&&Fu.value?Fu.value.agent(G.value.sessionId,G.value.agentId):void 0),Lu=H(()=>G.value&&Fu.value?Fu.value.session(G.value.sessionId):void 0);function Ru(e){G.value=e,K.drawer=!1,zu=!!e,Bu()}var zu=!1;function Bu(){let e=G.value;if(!zu||!e)return;let t=xu.devices.value.find(t=>t.id===e.deviceId)?.tree?.sessions.find(t=>t.id===e.sessionId)?.agents,n=new Map((t??[]).map(e=>[e.id,e])),r=[e.deviceId,`${e.deviceId}/s/${e.sessionId}`,`${e.deviceId}/s/${e.sessionId}/a/${e.agentId}`],i=n.get(e.agentId),a=new Set;for(;i&&!a.has(i.id);){a.add(i.id);let t=i.parentId??i.ownerAgentId;if(t===void 0)break;r.push(`${e.deviceId}/s/${e.sessionId}/a/${t}`),i=n.get(t)}r.some(e=>!wu.value.has(e))&&(wu.value=new Set([...wu.value,...r])),n.has(e.agentId)&&(zu=!1)}j(()=>xu.devices.value,Bu);function Vu(e,t){let n=new Set(wu.value);t??!n.has(e)?n.add(e):n.delete(e),wu.value=n}var Hu=(()=>{let e=new Map;return(t,n)=>{clearTimeout(e.get(t)),e.set(t,setTimeout(()=>void cu.uiSet(t,n).catch(()=>{}),300))}})();j(G,e=>Du.value&&void cu.uiSet(`tree.selected`,e??null).catch(()=>{})),j(Tu,e=>Du.value&&Hu(`tree.width`,e)),j(Eu,e=>Du.value&&Hu(`layout.panels`,{...e}));async function Uu(){yu.start();try{let[e,t,n,r]=await Promise.all([cu.network(),cu.uiGet(`tree.selected`),cu.uiGet(`tree.width`),cu.uiGet(`layout.panels`)]);r&&Object.assign(Eu,r),cu.version().then(e=>Cu.value=e.version).catch(()=>{}),Su.value=e.configFile,xu.model.devices.length||xu.model.apply({type:`network`,devices:e.devices}),wu.value=new Set,n&&(Tu.value=n),t&&e.devices.some(e=>e.id===t.deviceId)?Ru(t):Wu(e.devices)}catch(e){K.error=lu(e)}finally{Du.value=!0}}function Wu(e){for(let t of e){let e=t.status===`online`?t.tree?.sessions[0]:void 0,n=e?.agents.find(e=>e.kind===`root`)??e?.agents[0];if(e&&n)return Ru({deviceId:t.id,sessionId:e.id,agentId:n.id})}}j(()=>[Mu.status.value,Pu.value],([e,t])=>{e===`fault`&&!t&&Au.value&&(q(`That session was archived on its device.`),Ru(void 0))});var Gu=H(()=>ku.value?.info?.models??[]),Ku=Mu.state,qu=H(()=>ju.state.value.agents.length?ju.state.value.agents:Pu.value?.agents??[]),Ju=H(()=>G.value?Pl(qu.value,G.value.agentId):[]),Yu=H(()=>{let e=G.value?.agentId;if(e===void 0)return[];let t=qu.value,n=new Set([e]);for(let e=!0;e;){e=!1;for(let r of t)r.ownerAgentId!==void 0&&n.has(r.ownerAgentId)&&!n.has(r.id)&&(n.add(r.id),e=!0)}let r=ju.state.value.tasks,i=new Map(r.map(e=>[e.id,e])),a=new Map(t.map(e=>[e.id,e.ownerTaskId]));return r.filter(e=>n.has(e.conversationId)).map(e=>{let t=e,n=!1,r=new Set;for(;t&&!r.has(t.id);){if(r.add(t.id),t.background){n=!0;break}let e=t.owner??a.get(t.conversationId);t=e===void 0?void 0:i.get(e)}return{...e,effectiveBackground:n}})}),Xu=H(()=>Ku.value.running||Yu.value.some(e=>!e.effectiveBackground&&e.conversationId===G.value?.agentId)),Zu=H(()=>Dl(Ku.value.usage)),Qu=H(()=>{let e=Ku.value.agent.model;return Gu.value.find(t=>t.provider===e?.provider&&t.id===e?.modelId)}),$u=an(),ed=0;async function td(){let e=Iu.value,t=++ed;if(!e||!Au.value)return void($u.value=void 0);try{let n=await e.get();t===ed&&($u.value=n)}catch{t===ed&&($u.value=void 0)}}j([Iu,Au],()=>void td(),{immediate:!0});var K=Gt({error:``,toast:``,drawer:!1,inspectorOverlay:!1,tab:`session`,composer:``,dialog:void 0}),nd,rd=Gt([]),id=1;function ad(){for(let e of rd)e.read=!0}function q(e){K.toast=e,e&&(rd.unshift({id:id++,text:e,at:Date.now(),read:!1}),rd.length>50&&(rd.length=50)),clearTimeout(nd),nd=setTimeout(()=>K.toast=``,4500)}async function od(e){K.error=``;try{return await e()}catch(e){K.error=lu(e);return}}function sd(e){K.composer=e,setTimeout(()=>document.querySelector(`.composer textarea`)?.focus())}var cd=e=>Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(e),ld=e=>JSON.stringify(e,null,2),ud=(e=``)=>ql(Gu.value.find(t=>t.id===e)?.icon);function dd(e){if(!e)return`never`;let t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t}s ago`:t<3600?`${Math.round(t/60)}m ago`:t<86400?`${Math.round(t/3600)}h ago`:`${Math.round(t/86400)}d ago`}var fd=O(!1);async function pd(){Xu.value&&!fd.value&&Iu.value&&(fd.value=!0,await od(()=>Iu.value.abort(!1))&&q(`Foreground work interrupted. Background jobs continue.`),fd.value=!1)}var md=window.matchMedia(`(max-width: 1100px)`),hd=O(md.matches);md.addEventListener(`change`,e=>hd.value=e.matches);var gd=H(()=>hd.value?K.inspectorOverlay:Eu.inspector);function _d(e){e&&(K.tab=e),hd.value?(K.drawer=!1,K.inspectorOverlay=!0):Eu.inspector=!0}function vd(){hd.value?K.inspectorOverlay=!1:Eu.inspector=!1}function yd(){hd.value?(K.drawer=!K.drawer)&&(K.inspectorOverlay=!1,Eu.tree=!0):Eu.tree=!Eu.tree}function bd(){gd.value?vd():_d()}var xd=/Mac|iPhone|iPad/.test(navigator.userAgent),Sd=xd?{tree:`Ctrl+N`,inspector:`Ctrl+T`}:{tree:`Alt+Shift+N`,inspector:`Alt+Shift+T`};function Cd(e){if(!(!(xd?e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey:e.altKey&&e.shiftKey&&!e.ctrlKey&&!e.metaKey)||e.repeat||e.isComposing)){if(e.code===`KeyN`)return`tree`;if(e.code===`KeyT`)return`inspector`}}var wd={class:`topbar`},Td={class:`brand`},Ed={class:`daemon`,"data-testid":`topbar-stats`},Dd=[`title`],Od={class:`top-actions`},kd={key:0,class:`usage-chip`,title:`This session's token usage and cost`},Ad=[`aria-label`,`title`],jd={key:0,class:`bell-dot`},Md={key:0,class:`hint`},Nd={class:`when`},Pd=[`disabled`],Fd=[`disabled`],Id=M({__name:`TopBar`,emits:[`newSession`],setup(e,{emit:t}){let n=O(!1),r=H(()=>rd.filter(e=>!e.read).length),i=()=>{n.value=!n.value,n.value&&ad()},a=e=>{let t=Math.round((Date.now()-e)/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`},o=H(()=>Zu.value.input+Zu.value.output+Zu.value.cacheRead+Zu.value.cacheWrite),s=H(()=>(Zu.value.inputCost??0)+(Zu.value.outputCost??0)+(Zu.value.cacheReadCost??0)+(Zu.value.cacheWriteCost??0)),c=H(()=>xu.devices.value.filter(e=>e.status===`online`).length),l=H(()=>xu.devices.value.reduce((e,t)=>e+(t.tree?.sessions.length??0),0)),u=H(()=>xu.devices.value.reduce((e,t)=>e+(t.tree?.sessions.reduce((e,t)=>e+t.agents.length,0)??0),0)),d=O(!1);async function f(){let e=Lu.value,t=G.value;if(!e||!t||d.value)return;d.value=!0;let n=await od(()=>e.createAgent({}));d.value=!1,n&&(Ru({...t,agentId:n.id}),q(`New agent. Same session, same shared App State.`))}let p=t;return(e,t)=>(F(),I(`header`,wd,[R(`div`,Td,[R(`button`,{class:`icon-button tree-toggle`,"aria-label":`Toggle network`,title:`Network`,onClick:t[0]||=e=>k(K).drawer=!k(K).drawer},[z(k(Kc),{size:19})]),t[6]||=R(`img`,{class:`brandmark`,src:`/icons/durable-pi.svg`,alt:`Durable Pi`},null,-1),t[7]||=R(`strong`,null,`Durable Pi`,-1)]),t[15]||=R(`span`,{class:`topbar-sep`,"aria-hidden":`true`},null,-1),R(`div`,Ed,[R(`span`,{class:T([`dot`,{off:!c.value}]),"aria-hidden":`true`},null,2),R(`span`,{class:`network-summary`,title:`${c.value} of ${k(xu).devices.value.length} devices online`},[z(k(Vc),{size:16}),B(E(c.value)+` of `+E(k(xu).devices.value.length)+` online`,1)],8,Dd),t[10]||=R(`span`,{class:`sep`,"aria-hidden":`true`},`·`,-1),R(`span`,null,[R(`b`,null,E(l.value),1),t[8]||=B(` sessions`,-1)]),t[11]||=R(`span`,{class:`sep`,"aria-hidden":`true`},`·`,-1),R(`span`,null,[R(`b`,null,E(u.value),1),t[9]||=B(` agents`,-1)])]),R(`div`,Od,[R(`span`,{class:T([`chip connection`,{accent:k(bu)===`live`}])},[R(`span`,{class:T([`dot`,{off:k(bu)!==`live`}]),"aria-hidden":`true`},null,2),B(E(k(bu)===`live`?`Connected`:`Reconnecting`),1)],2),o.value?(F(),I(`span`,kd,E(o.value.toLocaleString())+` tok · $`+E(s.value.toFixed(3)),1)):V(``,!0),R(`button`,{class:`icon-button`,"aria-label":`Notifications${r.value?` (${r.value} unread)`:``}`,title:`Notification center${r.value?` — ${r.value} unread`:``}`,onClick:i},[z(k(Zs),{size:18}),r.value?(F(),I(`i`,jd,E(r.value>9?`9+`:r.value),1)):V(``,!0)],8,Ad),n.value?(F(),I(`div`,{key:1,class:`notif-panel`,onClick:t[2]||=As(()=>{},[`stop`])},[R(`header`,null,[t[12]||=R(`b`,null,`Notifications`,-1),R(`button`,{class:`icon-button`,"aria-label":`Close notifications`,onClick:t[1]||=e=>n.value=!1},`✕`)]),k(rd).length?V(``,!0):(F(),I(`p`,Md,`Nothing yet — events land here as they happen.`)),R(`ul`,null,[(F(!0),I(P,null,N(k(rd),e=>(F(),I(`li`,{key:e.id,class:T({unread:!e.read})},[R(`span`,Nd,E(a(e.at)),1),R(`span`,null,E(e.text),1)],2))),128))])])):V(``,!0),R(`button`,{class:`icon-button`,title:`How this works`,"aria-label":`How this works`,onClick:t[3]||=e=>k(K).dialog={kind:`help`}},[z(k(oc),{size:19})]),R(`button`,{class:`secondary small new-agent-button`,disabled:!k(G)||!k(Au)||d.value,title:`Start a fresh agent in this session`,onClick:f},[z(k(Zc),{size:18}),t[13]||=B(`New agent `,-1)],8,Pd),R(`button`,{class:`primary small`,onClick:t[4]||=e=>p(`newSession`)},[z(k(Zc),{size:18}),t[14]||=B(`New session `,-1)]),R(`button`,{class:`icon-button inspector-toggle`,"aria-label":`Toggle inspector`,title:`Inspector`,disabled:!k(G)||!k(Au),onClick:t[5]||=e=>k(K).inspectorOverlay?k(vd)():k(_d)()},[z(k(qc),{size:19})],8,Fd)])]))}}),Ld=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},Rd=Ld(Id,[[`__scopeId`,`data-v-15b1b2ee`]]),zd={class:`mnav`,"aria-label":`Panels`},Bd={key:0,class:`badge`},Vd=M({__name:`MobileNav`,setup(e){function t(){K.drawer=!1,K.inspectorOverlay=!1}return(e,n)=>(F(),I(`nav`,zd,[R(`button`,{type:`button`,class:T({"is-on":!k(K).drawer&&!k(gd)}),onClick:t},[z(k(Rc),{size:18}),n[2]||=B(`Chat `,-1)],2),R(`button`,{type:`button`,class:T({"is-on":k(gd)}),onClick:n[0]||=e=>k(gd)?k(vd)():k(_d)()},[z(k(qc),{size:18}),n[3]||=B(`Details`,-1),k(Yu).length?(F(),I(`span`,Bd,E(k(Yu).length),1)):V(``,!0)],2),R(`button`,{type:`button`,class:T({"is-on":k(K).drawer}),onClick:n[1]||=e=>k(yd)()},[z(k(ml),{size:18}),n[4]||=B(`Network `,-1)],2)]))}}),Hd=[`width`,`height`,`aria-label`],Ud=[`width`,`height`,`aria-label`],Wd=M({__name:`DeviceIcon`,props:{device:{},size:{default:16}},setup(e){let t=e,n=H(()=>{let e=t.device;return e?.kind===`exe-dev`||e?.url?.includes(`.exe.xyz`)?`exe`:e?.info?.platform.startsWith(`darwin`)?`apple`:e?.kind===`local`?`laptop`:`server`}),r=H(()=>{let e={exe:`exe.dev VM`,apple:`macOS`,laptop:`This computer`,server:`Server`}[n.value];return t.device?.transport===`tunnel`?`${e} (tunnel)`:e});return(t,i)=>n.value===`exe`?(F(),I(`svg`,{key:0,class:`device-icon exe`,viewBox:`0 0 512 512`,width:e.size,height:e.size,role:`img`,"aria-label":r.value},[R(`title`,null,E(r.value),1),i[0]||=R(`path`,{fill:`currentColor`,"fill-rule":`evenodd`,d:`M8 332.2l.9 1.4 1.5 .5 38.5-4.1 3.1 .4 2.7 2.2 8.8 13.2 10.1 12.8 1.1 2.6-.3 3.2-16.4 35.6 0 1.7 1 1.2 2.2 0 33.8-18.2 3.1-.8 3.4 1 12.4 8.7 15.3 9.4 1.5 2.1 .5 2.5-3.1 38.9 .4 1.5 1.3 .9 2.3-.7 25.9-29.2 2.1-1.3 2.8-.4 16.3 4.4 15.7 3.2 3 1.8 1.6 2.8 9.8 37.1 1.5 1.6 1.7-.1 1.1-1.1 14.5-35.6 1.8-2.5 3.4-1.5 15.7-1.1 16.1-2.4 3.2 .5 2.3 1.8 22.4 32 2.2 .9 1.4-.7 .6-1.5 1.4-39 1-2.7 2.4-2.2 14.7-6.8 13.8-7.8 3.4-.7 3 1 32.4 21 2.3 0 1.1-1.1 0-1.6-13.4-36.6-.3-2.5 .7-2.4 12.2-13.9 8.8-12.1 2.8-2 3.1-.3 38.4 5.4 2.1-.9 .5-1.5-.6-1.4-27.5-27.4-1.6-2.7-.2-3.1 4.6-15.8 2.9-15.8 1.3-2.6 2.5-1.9 37.3-12.2 1.6-1.9-.3-1.5-1.1-1-36.8-12.5-2.4-1.4-1.8-3.3-3.1-17.7 0-2.2 .9-2.4 3.1-2.9 10.6-15.3 3.3-1.8 3.4 .3 3.8 3 4.5 6.8 8.9 11.2 12.5 12.5 6.2 4.8 7.3 4.3 6.3 2.4 3.8 .3 4-.3 5.1-2.4 6.5-7 4.8-10.6 3.3-11.9 2-14.1 1.3-3.4 0-66.6-.8-2.6-2-13.6-3.8-14.6-7.5-18.7-4.7-9.4-4-6-7.2-7.1-5-2.1-6.5 0-2.2 .7-6 3.5-12 12-13.1 17.8-11.7 18.2-3.7 1.6-11.8-.1-3.1-1.6-1.8-2.9-.3-8.8-2.8-12.7-1.5-4-7.1-13.3-5.9-7.8-10.7-9.3-8.6-4.7-5.9-2-4.1-.5-6.7-.5-4.1 .5-7 2-7.3 3.8-7.5 7-2.2 3.2-2.5 5.5-2.8 10.5-.5 3.6 .1 17.1-.3 2.2-1.1 1.9-1.7 1.5-3.7 1.5-2.6 .3-27.5-10.5-14.5-4-15.7-3.2-2.6-1.3-1.9-3-9.9-37.5-.9-1.2-1.4-.4-1.3 .4-.8 1-14.7 36.1-1.8 2.1-2.2 1.2-17.8 1.4-15 2.2-3.4-.7-2.4-2.1-22-31.5-2-.9-1.5 .5-.7 1.5-1.4 38.6-.9 3-2.5 2.5-14.7 6.8-13.8 7.8-2.8 .7-3.1-.7-32.9-21.3-2.3 0-1.1 1.1-.1 1.6 13.6 36.9 0 3.1-1.2 2.6-10.8 12-9.5 12.9-2.8 2-3.2 .3-38.4-5.4-1.5 .4-.9 1.4 .6 2.1 27.6 27.6 1.2 1.8 .5 2.2-3 10.6-1.5 2.4-2.4 1.6-5.8 1-4.4 1.8-3.8 3-3 3.8-1.7 4-.7 4.7 .4 4.7 1.5 4.2 .3 .5 30.7 0 1.7 .6 1.4 1.1 1.1 3-1.1 2.9-2.7 1.6-31.1 .1-.6 1.1-1.2 3.6-.4 4.1 .4 4.2 1.2 3.5 2.5 4 3.2 3.1 4.1 2.3 5.6 1.8 2.4 2.1 .9 2.1 5.1 21.2-.6 2.1-1.2 1.9-28.5 26.5zM283.6 189.4l6.6 .5 5.6 1.2 6.2 2.2 5.9 3.1 4.6 3.4 4.8 4.5 3.5 4.4 3.4 5.8 2.6 6.2 1.6 6.4 .6 5.6-.2 6.7-1.1 6.5-1.7 5.4-2.9 6-3.6 5.5-7.1 7.3-8.4 5.4-9.4 3.5-9.9 1.3-11-1-40.4-10.4-2.8-1.1-3.1-2.4-1.7-.6-.9-1.1-.1-2.2-1.4-2.2 1.6-6.3 18.1-38.5 4.7-7.5 7.1-7.3 8.4-5.4 9.4-3.5zM173.9 198l-1.1 5.9-2.3 5.5-3.4 5-4.2 4.3-5 3.3-5.5 2.3-5.9 1.2-6 0-5.9-1.2-5.6-2.3-5-3.3-4.2-4.3-3.3-5-2.3-5.5-1.2-5.9 0-6 1.2-5.9 2.3-5.5 3.3-5 4.2-4.3 5-3.3 5.6-2.3 5.9-1.2 6 0 5.9 1.2 5.5 2.3 5 3.3 4.2 4.3 3.4 5 2.3 5.5 1.1 5.9zM315.1 213.5l-63.1 37.7 69.5-12.9 0-6.2-1-6.5-2.1-6.1zM237.3 260l-2.6 1.5 40.6 10.5 7.4 .9 7.4-.5 5.4-1.4 5.2-2.1 8.5-5.8 3.8-4.1 3.2-4.5 2.6-5 1.6-4.9zM284.5 196.9l-7.4 .5-8.1 2.3-7.3 4.1-6.3 5.5-5.8 8.5-17.4 37.1 3-.6 76.1-45.5-5.8-5-6.5-3.7-7.1-2.3zM141.1 183.6l-1.1-2.9-2-2.3-2.8-1.3-3.1-.1-2.9 1-2.3 2.1-1.3 2.8-.1 3 1 2.9 2.1 2.3 2.7 1.3 3.1 .2 2.9-1.1 2.3-2 1.3-2.8z`},null,-1)],8,Hd)):n.value===`apple`?(F(),I(`svg`,{key:1,class:`device-icon apple`,viewBox:`0 0 384 512`,width:e.size,height:e.size,role:`img`,"aria-label":r.value},[R(`title`,null,E(r.value),1),i[1]||=R(`path`,{fill:`currentColor`,d:`M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z`},null,-1)],8,Ud)):n.value===`laptop`?(F(),L(k(jc),{key:2,class:`device-icon`,size:e.size,"aria-label":r.value},null,8,[`size`,`aria-label`])):(F(),L(k(il),{key:3,class:`device-icon`,size:e.size,"aria-label":r.value},null,8,[`size`,`aria-label`]))}}),Gd=new Map,Kd=new Map;async function qd(e,t){let n=t.filter(t=>!$d(Qd(e,t),Jd));if(n.length)try{let t=await W(e).gitStatusBatch(n,{timeoutMs:6e4});for(let[n,r]of Object.entries(t)){let t=Qd(e,n);t.status=r,t.at=Date.now(),t.error=``}}catch{}}var Jd=6e4,Yd=!1;function Xd(){Yd||(Yd=!0,j(()=>xu.devices.value,e=>{let t=Date.now();for(let n of e){let e=(n.tree?.git??[]).filter(e=>t-e.at<6e4);if(e.length)for(let r of[...Gd.keys()]){let[i,a]=r.split(`::`);if(i!==n.id||!a)continue;let o=Gd.get(r);e.some(e=>a===e.root||a.startsWith(e.root+`/`)||a.startsWith(e.root+`\\`))&&(o.loading||t-o.at<4e3||ef(i,a,{force:!0}))}}}))}var Zd=(e,t)=>`${e}::${t}`;function Qd(e,t){let n=Zd(e,t),r=Gd.get(n);return r||(r=Gt({at:0,status:null,error:``,loading:!1,refreshing:!1}),Gd.set(n,r)),r}var $d=(e,t)=>e.at>0&&Date.now()-e.at<t&&(e.status!==null||e.error);async function ef(e,t,n={}){let{staleMs:r=6e4,force:i=!1,timeoutMs:a=6e4}=n;if(!e||!t)return;let o=Zd(e,t),s=Qd(e,t);if(!i&&$d(s,r))return;let c=Kd.get(o);if(c)return c;s.status===null&&!s.error?s.loading=!0:s.refreshing=!0,s.error=``;let l=(async()=>{try{s.status=await W(e).gitStatus(t,{timeoutMs:a}),s.at=Date.now()}catch(e){let t=e.message??``;s.error=/fetch failed|Cannot reach|Failed to fetch|NetworkError|abort/i.test(t)?`device unreachable — check that it is online, then retry (${t.slice(0,80)})`:t.slice(0,160),s.at=Date.now()}finally{s.loading=!1,s.refreshing=!1,Kd.delete(o)}})();return Kd.set(o,l),l}var tf=new Map;function nf(){j(()=>xu.devices.value.map(e=>`${e.id}:${e.status}:${e.tree?.sessions.length??0}:${e.tree?.sessions.map(e=>e.cwd).join(`|`)}`).join(`;`),()=>{for(let e of xu.devices.value){if(e.status!==`online`||!e.tree?.sessions.length)continue;let t=Date.now();t-(tf.get(e.id)??0)<6e4||(tf.set(e.id,t),qd(e.id,e.tree.sessions.map(e=>e.cwd)))}},{immediate:!0})}var rf=(e,t)=>Qd(e,t).status?.branch,af=[`aria-level`,`aria-expanded`,`aria-selected`,`data-key`,`title`],of=[`aria-label`],sf={key:1,class:`chev`},cf={class:`name`},lf={class:`badge`},uf=[`title`],df=[`aria-label`],ff=[`disabled`,`aria-label`],pf=[`aria-label`],mf=[`checked`,`aria-label`],hf={class:`name`},gf={class:`path`},_f=[`title`],vf={key:2,class:`dot work`,title:`Working`},yf=[`title`],bf=[`disabled`,`aria-label`],xf=[`disabled`,`aria-label`],Sf=[`disabled`,`aria-label`],Cf={class:`name`},wf={key:3,class:`meta`},Tf={key:4,class:`dot work`,title:`Working`},Ef=[`title`],Df=[`disabled`,`aria-label`],Of=Ld(M({__name:`TreeRow`,props:{node:{},depth:{},open:{type:Boolean},selected:{type:Boolean},focused:{type:Boolean},online:{type:Boolean},checkbox:{type:Boolean},checked:{type:Boolean}},emits:[`toggle`,`activate`,`action`,`check`],setup(e,{emit:t}){let n=e,r=t,i=H(()=>n.node.children.length>0),a=H(()=>n.node.type===`device`?n.node.device:void 0),o=H(()=>n.node.type===`session`?n.node.session:void 0),s=H(()=>n.node.type===`agent`?n.node.agent:void 0),c=H(()=>o.value?o.value.agents.reduce((e,t)=>e+t.background,0):s.value?.background??0),l=H(()=>o.value?.busy||s.value?.busy),u=H(()=>{let e=a.value?.info?.packageVersion,t=Cu.value;return!!(e&&t&&t!==`unknown`&&e!==t)}),d=H(()=>{let e=a.value;if(!e)return``;let t=e.tree?.sessions.length??0;switch(e.status){case`online`:return`${t} session${t===1?``:`s`}`;case`checking`:return`checking…`;case`unauthorized`:return e.hasToken?`token rejected`:`no token`;case`mismatch`:return`identity changed`;case`incompatible`:return`incompatible`;default:return`offline · ${dd(e.lastSeenAt)}`}}),f=H(()=>{let e=a.value?.status;return e===`online`?`on`:e===`checking`?`chk`:e===`offline`?`off`:`err`}),p=H(()=>{let e=n.node;return e.type===`session`?rf(e.deviceId,e.session.cwd):void 0}),m=H(()=>a.value?.name??a.value?.id??o.value?.name??s.value?.name??``),h=H(()=>{if(a.value)return`${a.value.name} · ${a.value.url}${a.value.error?`\n${a.value.error}`:``}`;if(o.value)return`${o.value.name}\n${o.value.cwd}`;let e=s.value;return e.kind===`fork`?`Fork of agent #${e.parentId} at entry #${e.forkedAt}`:e.kind===`subagent`?`Subagent owned by agent #${e.ownerAgentId}`:`Root agent`});return(t,n)=>(F(),I(`div`,{class:T([`tree-row`,[e.node.type,{sel:e.selected,focus:e.focused,stale:e.node.stale}]]),style:_e({"--depth":e.depth}),role:`treeitem`,"aria-level":e.depth+1,"aria-expanded":i.value?e.open:void 0,"aria-selected":e.selected,"data-key":e.node.key,title:h.value,onClick:n[13]||=e=>r(`activate`)},[i.value?(F(),I(`button`,{key:0,class:`chev`,tabindex:`-1`,"aria-label":e.open?`Collapse ${m.value}`:`Expand ${m.value}`,onClick:n[0]||=As(e=>r(`toggle`),[`stop`])},[e.open?(F(),L(k(rc),{key:0,size:16})):(F(),L(k(ic),{key:1,size:16}))],8,of)):(F(),I(`span`,sf)),a.value?(F(),I(P,{key:2},[R(`i`,{class:T([`dot`,f.value])},null,2),z(Wd,{device:a.value,size:16},null,8,[`device`]),R(`b`,cf,E(m.value),1),R(`span`,lf,E(a.value.kind),1),u.value?(F(),I(`span`,{key:0,class:`tag update`,title:`device runs ${a.value?.info?.packageVersion??`?`}; hub runs ${k(Cu)}. Devices self-update: dpi update`},`update`,8,uf)):V(``,!0),R(`span`,{class:T([`meta`,{err:f.value===`err`}])},E(d.value),3),R(`span`,{class:`acts`,onClick:n[4]||=As(()=>{},[`stop`])},[a.value.pairing?(F(),I(`button`,{key:0,class:`icon-button`,"aria-label":`Manage credentials for ${m.value}`,title:`Manage device credentials, including while offline`,onClick:n[1]||=e=>r(`action`,`credentials`)},[z(k(Ac),{size:16})],8,df)):V(``,!0),R(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`New session on ${m.value}`,title:`New session on this device`,onClick:n[2]||=e=>r(`action`,`new-session`)},[z(k(Zc),{size:16})],8,ff),R(`button`,{class:`icon-button`,"aria-label":`Check ${m.value}`,title:`Check connection now`,onClick:n[3]||=e=>r(`action`,`check`)},[z(k(el),{size:16})],8,pf)])],64)):o.value?(F(),I(P,{key:3},[e.checkbox?(F(),I(`input`,{key:0,type:`checkbox`,class:`bulk-check`,checked:e.checked,"aria-label":`Select ${m.value}`,tabindex:`-1`,onClick:n[5]||=As(()=>{},[`stop`]),onChange:n[6]||=e=>r(`check`)},null,40,mf)):V(``,!0),z(k(bc),{class:`ico`,size:16}),R(`b`,hf,E(m.value),1),R(`span`,gf,`…/`+E(o.value.cwd.split(`/`).filter(Boolean).at(-1)),1),p.value?(F(),I(`span`,{key:1,class:`branch`,title:`git branch of ${o.value.cwd}`},`⎇ `+E(p.value),9,_f)):V(``,!0),l.value?(F(),I(`i`,vf)):V(``,!0),c.value?(F(),I(`span`,{key:3,class:`bg-count`,title:`${c.value} background task(s)`},[n[14]||=R(`i`,{class:`dot bg`},null,-1),B(E(c.value)+` bg`,1)],8,yf)):V(``,!0),R(`span`,{class:`acts`,onClick:n[10]||=As(()=>{},[`stop`])},[R(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`New agent in ${m.value}`,title:`New agent in this session`,onClick:n[7]||=e=>r(`action`,`new-agent`)},[z(k(Zc),{size:16})],8,bf),R(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`Rename session ${m.value}`,title:`Rename session`,onClick:n[8]||=e=>r(`action`,`rename`)},[z(k(Jc),{size:16})],8,xf),R(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`Archive session ${m.value}`,title:`Archive session`,onClick:n[9]||=e=>r(`action`,`archive`)},[z(k(Ws),{size:16})],8,Sf)])],64)):s.value?(F(),I(P,{key:4},[s.value.kind===`fork`?(F(),L(k(wc),{key:0,class:`ico`,size:16})):s.value.kind===`subagent`?(F(),L(k(lc),{key:1,class:`ico`,size:16})):(F(),L(k(Rc),{key:2,class:`ico root`,size:16})),R(`span`,Cf,E(m.value),1),s.value.kind===`fork`&&s.value.forkedAt!==void 0?(F(),I(`span`,wf,`@ #`+E(s.value.forkedAt),1)):V(``,!0),l.value?(F(),I(`i`,Tf)):V(``,!0),c.value?(F(),I(`span`,{key:5,class:`bg-count`,title:`${c.value} background task(s)`},[n[15]||=R(`i`,{class:`dot bg`},null,-1),B(E(c.value),1)],8,Ef)):V(``,!0),R(`span`,{class:`acts`,onClick:n[12]||=As(()=>{},[`stop`])},[R(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`Rename agent ${m.value}`,title:`Rename agent`,onClick:n[11]||=e=>r(`action`,`rename`)},[z(k(Jc),{size:16})],8,Df)])],64)):V(``,!0)],14,af))}}),[[`__scopeId`,`data-v-f2a70cbb`]]),kf={class:`project-bar`,"aria-label":`Projects`},Af={class:`project-head`},jf={class:`project-title`},Mf=[`aria-label`,`title`],Nf={key:0,class:`project-hint`},Pf={key:0,class:`chips`},Ff=[`title`,`onClick`,`onDblclick`],If={class:`chip-name`},Lf={class:`chip-count`},Rf={key:1,class:`project-hint`},zf={key:2,class:`project-actions`},Bf=[`onClick`],Vf=[`onClick`],Hf=[`onClick`],Uf=[`onClick`],Wf={key:3,class:`message-error`},Gf={key:4,class:`project-hint labels-hint`},Kf=Ld(M({__name:`ProjectBar`,props:{active:{},activeModifiers:{}},emits:[`update:active`],setup(e,{expose:t}){let n=Oi(e,`active`),r=O([]),i=O(!1),a=O(``),o=O(!1),s=H(()=>xu.devices.value.filter(e=>e.status===`online`).map(e=>e.id));async function c(){i.value=!0,a.value=``;let e=[],t=[];for(let n of s.value){let r=xu.devices.value.find(e=>e.id===n),i=await W(n).projects(o.value).catch(e=>{let r=lu(e);e.code===`not_found`||/allowlist|not found/i.test(r)||t.push(`${n}: ${r.slice(0,60)}`)});for(let t of i?.projects??[]){let i=(r?.tree?.sessions??[]).filter(e=>e.cwd===t.rootPath||e.cwd.startsWith(`${t.rootPath}/`)).length;e.push({deviceId:n,project:t,sessions:i})}}r.value=e.sort((e,t)=>l(e.project).localeCompare(l(t.project))),t.length&&(a.value=t.join(` · `)),i.value=!1}j([s,o],c,{immediate:!0});let l=e=>e.customName??e.name,u=e=>n.value?.deviceId===e.deviceId&&n.value.rootPath===e.project.rootPath;function d(e){n.value=u(e)?void 0:{deviceId:e.deviceId,rootPath:e.project.rootPath}}function f(e){let t=e.project;K.dialog={kind:`prompt`,title:`Rename ${l(t)}`,label:`Project name`,hint:`Shown in the tree and in usage rollups. Leave empty to use the folder name.`,value:t.customName??``,placeholder:t.name,submit:`Save name`,run:async n=>{let r=await W(e.deviceId).updateProject(t.id,{customName:n});q(`Project renamed to ${r.customName??r.name}.`),await c()}}}function p(e){let t=e.project;K.dialog={kind:`prompt`,title:`Labels for ${l(t)}`,label:`Labels (comma separated)`,hint:`Lowercase, up to 12 labels of 32 characters. Used to filter projects.`,value:t.labels.join(`, `),submit:`Save labels`,run:async n=>{let r=await W(e.deviceId).updateProject(t.id,{labels:n.split(`,`).map(e=>e.trim()).filter(Boolean)});q(r.labels.length?`Labels: ${r.labels.join(`, `)}.`:`Labels cleared on ${l(r)}.`),await c()}}}function m(e){let t=e.project,n=xu.devices.value.find(t=>t.id===e.deviceId)?.info?.models??[];K.dialog={kind:`prompt`,title:`Default model for ${l(t)}`,label:`Model (provider/modelId)`,hint:n.length?`New sessions in this project start on this model instead of the device default. Leave empty to use the device default. E.g. ${n[0].provider}/${n[0].id}`:`New sessions in this project start on this model. Leave empty to use the device default.`,value:t.model?`${t.model.provider}/${t.model.modelId}`:``,placeholder:`device default`,submit:`Save default model`,run:async r=>{if(!r.trim()){await W(e.deviceId).updateProject(t.id,{model:``}),q(`Default model cleared on ${l(t)}.`),await c();return}let[i,...a]=r.trim().split(`/`),o=a.join(`/`),s=n.some(e=>e.provider===i&&e.id===o);if(!i||!o)throw Error(`Format: provider/modelId`);if(!s)throw Error(`${r.trim()} is not in this device's catalog`);await W(e.deviceId).updateProject(t.id,{model:{provider:i,modelId:o}}),q(`New sessions in ${l(t)} start on ${o}.`),await c()}}}function h(e){let t=e.project,r=t.archivedAt!==null;K.dialog={kind:`prompt`,title:`${r?`Restore`:`Archive`} ${l(t)}?`,hint:r?`The project returns to the tree. Its sessions were never touched.`:`Bookkeeping only: the project leaves the list, its sessions keep running. Nothing is deleted.`,submit:r?`Restore project`:`Archive project`,danger:!r,run:async()=>{let i=W(e.deviceId);r?await i.unarchiveProject(t.id):await g(i,t.id),!r&&u(e)&&(n.value=void 0),await c()}}}let g=(e,t)=>e.archiveProject(t);return t({reload:c}),(e,t)=>(F(),I(`div`,kf,[R(`div`,Af,[R(`span`,jf,[z(k(yc),{size:13}),t[2]||=B(`PROJECTS`,-1)]),R(`button`,{class:T([`icon-button tiny`,{on:o.value}]),"aria-label":o.value?`Hide archived projects`:`Show archived projects`,title:o.value?`Hide archived projects`:`Show archived projects`,onClick:t[0]||=e=>o.value=!o.value},[z(k(Ws),{size:12})],10,Mf),i.value?(F(),I(`span`,Nf,`…`)):V(``,!0)]),r.value.length?(F(),I(`div`,Pf,[(F(!0),I(P,null,N(r.value,e=>(F(),I(`button`,{key:`${e.deviceId}-${e.project.id}`,class:T([`chip`,{on:u(e),archived:e.project.archivedAt}]),title:`${e.project.rootPath} — ${e.sessions} session${e.sessions===1?``:`s`}`,onClick:t=>d(e),onDblclick:t=>f(e)},[e.project.kind===`plain`?(F(),L(k(xc),{key:0,size:11})):(F(),L(k(yc),{key:1,size:11})),R(`span`,If,E(l(e.project)),1),R(`em`,Lf,E(e.sessions),1),(F(!0),I(P,null,N(e.project.labels.slice(0,2),e=>(F(),I(`span`,{key:e,class:`chip-label`},E(e),1))),128))],42,Ff))),128))])):i.value?V(``,!0):(F(),I(`p`,Rf,` No projects yet — a project appears when a session starts in a folder. `)),n.value?(F(),I(`div`,zf,[t[5]||=R(`span`,{class:`project-hint`},`filtering`,-1),(F(!0),I(P,null,N(r.value.filter(u),e=>(F(),I(P,{key:e.project.id},[R(`button`,{class:`small`,onClick:t=>f(e)},[z(k(Jc),{size:12}),t[3]||=B(`name`,-1)],8,Bf),R(`button`,{class:`small`,onClick:t=>p(e)},[z(k(ul),{size:12}),t[4]||=B(`labels`,-1)],8,Vf),R(`button`,{class:`small`,onClick:t=>m(e),title:`Default model for new sessions in this project`},[z(k(fc),{size:12}),B(E(e.project.model?`model ✓`:`model`),1)],8,Hf),R(`button`,{class:`small`,onClick:t=>h(e)},[e.project.archivedAt?(F(),L(k(Us),{key:0,size:12})):(F(),L(k(Ws),{key:1,size:12})),B(` `+E(e.project.archivedAt?`restore`:`archive`),1)],8,Uf),R(`button`,{class:`icon-button tiny`,"aria-label":`Clear project filter`,onClick:t[1]||=e=>n.value=void 0},[z(k(yl),{size:12})])],64))),128))])):V(``,!0),a.value?(F(),I(`p`,Wf,E(a.value),1)):V(``,!0),r.value.some(e=>e.project.labels.length)?(F(),I(`p`,Gf,[z(k(ul),{size:11}),B(`labels: `+E([...new Set(r.value.flatMap(e=>e.project.labels))].join(` · `)),1)])):V(``,!0)]))}}),[[`__scopeId`,`data-v-77864963`]]),qf={class:`tree-head`},Jf=[`aria-label`,`title`],Yf=[`title`],Xf={class:`tree-search`},Zf={key:1,class:`searching`,"aria-label":`Searching devices`},Qf={key:0,class:`bulk-bar`},$f=[`disabled`],ep=[`disabled`],tp={class:`hit-head hint`},np=[`title`,`onClick`],rp={class:`hit-name`},ip={class:`hit-cwd`},ap={key:0,class:`hit-where`},op={key:2,class:`hint tree-empty`},sp={key:3,class:`hint tree-empty`,"data-testid":`tree-empty`},cp={key:1,class:`panel-rail`,"aria-label":`Network (collapsed)`},lp=[`title`],up=[`title`,`aria-label`,`onClick`],dp=Ld(M({__name:`NetworkSidebar`,setup(e){let t=H(()=>{let e=[],t=(n,r,i)=>{for(let a of n)e.push({node:a,depth:r,parent:i}),a.children.length&&wu.value.has(a.key)&&t(a.children,r+1,a.key)};return t(xu.tree.value,0),e}),n=O(),r=O(),i=O(``),a=O([]),o=O(!1),s=H(()=>i.value.trim().toLowerCase()),c=H(()=>s.value.length>=2),l=H(()=>{let e=new Set;if(!c.value)return e;for(let t of xu.devices.value)for(let n of t.tree?.sessions??[])`${n.name}\n${n.cwd}`.toLowerCase().includes(s.value)&&e.add(n.id);return e}),u=O(),d=(e,t)=>!u.value||u.value.deviceId===e&&(t===u.value.rootPath||t.startsWith(`${u.value.rootPath}/`)),f=H(()=>{if(!c.value&&!u.value)return t.value;let e=e=>{if(u.value){let t=e.type===`device`?e.device.id:e.deviceId;if(e.type===`session`&&!d(t,e.session.cwd))return!1;if(e.type===`agent`){let t=xu.devices.value.find(t=>t.id===e.deviceId)?.tree?.sessions.find(t=>t.id===e.sessionId);if(t&&!d(e.deviceId,t.cwd))return!1}if(e.type===`device`)return(e.device.tree?.sessions??[]).some(t=>d(e.device.id,t.cwd))}return c.value?e.type===`session`?l.value.has(e.session.id):e.type===`agent`?l.value.has(e.sessionId)||e.agent.name.toLowerCase().includes(s.value):(e.device.tree?.sessions??[]).some(e=>l.value.has(e.id)):!0},n=new Set(t.value.filter(t=>e(t.node)).map(e=>e.node.key));return t.value.filter(e=>n.has(e.node.key))}),p=H(()=>a.value.filter(e=>!t.value.some(t=>t.node.type===`session`&&t.node.session.id===e.id))),m;j(i,e=>{clearTimeout(m);let t=e.trim();if(t.length<2){a.value=[],o.value=!1;return}m=setTimeout(async()=>{o.value=!0;let e=[];for(let n of xu.devices.value.filter(e=>e.status===`online`)){let r=await W(n.id).searchSessions(t).catch(()=>void 0);for(let t of r?.matches??[])e.push({deviceId:n.id,id:t.id,name:t.name,cwd:t.cwd,where:t.where})}a.value=e,o.value=!1},250)});let h=()=>(i.value=``,a.value=[]),g=O(!1),_=O(new Set),v=O(``),y=e=>{if(e.type!==`session`)return;let t=new Set(_.value);t.has(e.session.id)?t.delete(e.session.id):t.add(e.session.id),_.value=t},b=async e=>{v.value=e;let n=0,r=[];for(let i of t.value.map(e=>e.node)){if(i.type!==`session`||!_.value.has(i.session.id))continue;let t=ee(i);if(!t)continue;let a=W(t.id);try{e===`archive`?await a.session(i.session.id).archive():await a.agent(i.session.id,1).abort(!0),n++,e===`archive`&&G.value?.sessionId===i.session.id&&Ru(void 0)}catch{r.push(i.session.name)}}q(`${e}: ${n} done${r.length?`, ${r.length} failed (${r.slice(0,3).join(`, `)})`:``}`),_.value=new Set,v.value=``},ee=e=>xu.devices.value.find(t=>t.id===(e.type===`device`?e.device.id:e.deviceId)),x=e=>ee(e)?.status===`online`,S=e=>e.type===`agent`&&G.value?.deviceId===e.deviceId&&G.value.sessionId===e.sessionId&&G.value.agentId===e.agent.id;function te(e){if(n.value=e.key,g.value&&e.type===`session`)return y(e);if(e.type===`device`)return Vu(e.key);if(e.type===`agent`)return Ru({deviceId:e.deviceId,sessionId:e.sessionId,agentId:e.agent.id});let t=e.session.agents.find(e=>e.kind===`root`)??e.session.agents[0];Vu(e.key,!0),t&&Ru({deviceId:e.deviceId,sessionId:e.session.id,agentId:t.id})}async function ne(e,t){let n=ee(e);if(!n)return;let r=W(n.id);if(e.type===`device`){t===`new-session`?K.dialog={kind:`new-session`,deviceId:n.id}:t===`check`?await od(()=>cu.check(n.id)):t===`credentials`&&(K.dialog={kind:`credentials`,deviceId:n.id});return}if(e.type===`session`){let i=e.session;if(t===`new-agent`){let e=await od(()=>r.session(i.id).createAgent({}));e&&(Ru({deviceId:n.id,sessionId:i.id,agentId:e.id}),q(`New agent. Same session, same shared App State.`))}else t===`rename`?K.dialog={kind:`prompt`,title:`Rename session`,label:`Session name`,value:i.name,submit:`Save name`,run:e=>r.session(i.id).rename(e)}:t===`archive`&&(K.dialog={kind:`prompt`,title:`Archive ${i.name}?`,hint:`Stops all of its work and moves its files to archive/ on ${n.id}. Nothing is deleted.`,submit:`Archive session`,danger:!0,run:async()=>{await r.session(i.id).archive(),G.value?.sessionId===i.id&&Ru(void 0)}});return}let i=e.agent;t===`rename`&&(K.dialog={kind:`prompt`,title:`Rename agent`,label:`Agent name`,value:i.named?i.name:``,placeholder:i.name,submit:`Save name`,run:t=>r.agent(e.sessionId,i.id).rename(t)})}function C(e){let i=t.value.findIndex(e=>e.node.key===n.value),a=t.value[Math.max(0,Math.min(t.value.length-1,(i<0?0:i)+e))];a&&(n.value=a.node.key,jn(()=>r.value?.querySelector(`[data-key="${CSS.escape(a.node.key)}"]`)?.scrollIntoView({block:`nearest`})))}function re(){n.value??=t.value[0]?.node.key}function ie(e){let r=t.value.find(e=>e.node.key===n.value);if(e.key===`ArrowDown`)C(1);else if(e.key===`ArrowUp`)C(-1);else if(e.key===`ArrowRight`&&r){if(!r.node.children.length)return;wu.value.has(r.node.key)?C(1):Vu(r.node.key,!0)}else if(e.key===`ArrowLeft`&&r)r.node.children.length&&wu.value.has(r.node.key)?Vu(r.node.key,!1):r.parent&&(n.value=r.parent);else if((e.key===`Enter`||e.key===` `)&&r)te(r.node);else return;e.preventDefault()}return(e,a)=>(F(),I(`aside`,{class:T([`network-sidebar`,{open:k(K).drawer,collapsed:!k(Eu).tree&&!k(K).drawer}]),"aria-label":`Network`},[k(Eu).tree||k(K).drawer?(F(),I(P,{key:0},[R(`header`,qf,[R(`span`,null,[z(k(Vc),{size:16}),a[8]||=B(`NETWORK`,-1)]),R(`button`,{class:T([`icon-button`,{on:g.value}]),"aria-label":g.value?`Exit bulk select`:`Bulk manage sessions`,title:g.value?`Exit bulk select`:`Bulk manage sessions (select → archive / abort)`,onClick:a[0]||=e=>(g.value=!g.value,_.value=new Set)},[z(k(Fc),{size:15})],10,Jf),R(`button`,{class:`icon-button`,"aria-label":`Pair a device`,title:`Pair a device`,onClick:a[1]||=e=>k(K).dialog={kind:`pair`}},[z(k(Pc),{size:15})]),R(`button`,{class:`icon-button panel-toggle`,"aria-label":`Collapse network`,title:`Collapse network (${k(Sd).tree})`,onClick:a[2]||=e=>(k(Eu).tree=!1,k(K).drawer=!1)},[z(k(Wc),{size:18})],8,Yf)]),R(`div`,Xf,[z(k(nl),{size:14,class:`search-icon`}),A(R(`input`,{"onUpdate:modelValue":a[3]||=e=>i.value=e,type:`search`,class:`search-input`,placeholder:`Search sessions…`,"aria-label":`Search sessions`,spellcheck:`false`},null,512),[[bs,i.value]]),i.value?(F(),I(`button`,{key:0,class:`icon-button clear`,"aria-label":`Clear search`,onClick:h},[z(k(yl),{size:13})])):V(``,!0),o.value?(F(),I(`span`,Zf,`…`)):V(``,!0)]),z(Kf,{active:u.value,"onUpdate:active":a[4]||=e=>u.value=e},null,8,[`active`]),R(`div`,{ref_key:`list`,ref:r,class:`tree-list`,role:`tree`,tabindex:`0`,"aria-label":`Devices, sessions and agents`,onKeydown:ie,onFocus:re},[g.value&&_.value.size?(F(),I(`div`,Qf,[R(`span`,null,E(_.value.size)+` selected`,1),R(`button`,{class:`small`,disabled:!!v.value,onClick:a[5]||=e=>b(`abort`)},`abort work`,8,$f),R(`button`,{class:`small danger`,disabled:!!v.value,onClick:a[6]||=e=>b(`archive`)},E(v.value===`archive`?`archiving…`:`archive`),9,ep)])):V(``,!0),(F(!0),I(P,null,N(f.value,e=>(F(),L(Of,{key:e.node.key,node:e.node,depth:e.depth,open:k(wu).has(e.node.key),selected:S(e.node),focused:n.value===e.node.key,online:x(e.node),checkbox:g.value&&e.node.type===`session`,checked:e.node.type===`session`&&_.value.has(e.node.session.id),onToggle:t=>k(Vu)(e.node.key),onActivate:t=>te(e.node),onAction:t=>ne(e.node,t),onCheck:t=>y(e.node)},null,8,[`node`,`depth`,`open`,`selected`,`focused`,`online`,`checkbox`,`checked`,`onToggle`,`onActivate`,`onAction`,`onCheck`]))),128)),c.value&&p.value.length?(F(),I(P,{key:1},[R(`div`,tp,E(p.value.length)+` more on device`,1),(F(!0),I(P,null,N(p.value,e=>(F(),I(`button`,{key:`${e.deviceId}-${e.id}`,class:`hit`,title:e.cwd,onClick:t=>k(Ru)({deviceId:e.deviceId,sessionId:e.id,agentId:1})},[R(`span`,rp,E(e.name),1),R(`code`,ip,E(e.cwd),1),e.where.length?(F(),I(`em`,ap,E(e.where.join(` · `)),1)):V(``,!0)],8,np))),128))],64)):V(``,!0),c.value&&!f.value.length&&!p.value.length?(F(),I(`p`,op,` No session matches “`+E(i.value.trim())+`”. `,1)):V(``,!0),!t.value.length&&!c.value?(F(),I(`p`,sp,[...a[9]||=[B(` No devices yet. Declare them in `,-1),R(`code`,null,`dpi-network.yaml`,-1),B(` (start from `,-1),R(`code`,null,`dpi-network.example.yaml`,-1),B(`), then run `,-1),R(`code`,null,`just net up <id>`,-1),B(`. `,-1)]])):V(``,!0)],544)],64)):(F(),I(`div`,cp,[R(`button`,{class:`icon-button panel-toggle`,"aria-label":`Expand network`,title:`Expand network (${k(Sd).tree})`,onClick:a[7]||=e=>k(Eu).tree=!0},[z(k(Gc),{size:18})],8,lp),(F(!0),I(P,null,N(k(xu).devices.value,e=>(F(),I(`button`,{key:e.id,class:`rail-device`,title:`${e.id} · ${e.status}`,"aria-label":`Show ${e.id}`,onClick:t=>(k(Eu).tree=!0,k(Vu)(e.id,!0))},[z(Wd,{device:e,size:20},null,8,[`device`]),R(`i`,{class:T([`dot`,e.status===`online`?`on`:e.status===`checking`?`chk`:e.status===`offline`?`off`:`err`])},null,2)],8,up))),128))]))],2))}}),[[`__scopeId`,`data-v-5ce92b7d`]]);function fp(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var pp=fp();function mp(e){pp=e}var hp={exec:()=>null};function gp(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(vp.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var _p=(()=>{try{return!0}catch{return!1}})(),vp={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},yp=/^(?:[ \t]*(?:\n|$))+/,bp=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,xp=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Sp=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Cp=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,wp=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Tp=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ep=gp(Tp).replace(/bull/g,wp).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Dp=gp(Tp).replace(/bull/g,wp).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Op=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,kp=/^[^\n]+/,Ap=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,jp=gp(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Ap).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Mp=gp(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,wp).getRegex(),Np=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Pp=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Fp=gp(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Pp).replace(`tag`,Np).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ip=gp(Op).replace(`hr`,Sp).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Np).getRegex(),Lp={blockquote:gp(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Ip).getRegex(),code:bp,def:jp,fences:xp,heading:Cp,hr:Sp,html:Fp,lheading:Ep,list:Mp,newline:yp,paragraph:Ip,table:hp,text:kp},Rp=gp(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Sp).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Np).getRegex(),zp={...Lp,lheading:Dp,table:Rp,paragraph:gp(Op).replace(`hr`,Sp).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Rp).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Np).getRegex()},Bp={...Lp,html:gp(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Pp).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:hp,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:gp(Op).replace(`hr`,Sp).replace(`heading`,` *#{1,6} *[^
|
|
16
16
|
]`).replace(`lheading`,Ep).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Vp=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Hp=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Up=/^( {2,}|\\)\n(?!\s*$)/,Wp=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Gp=/[\p{P}\p{S}]/u,Kp=/[\s\p{P}\p{S}]/u,qp=/[^\s\p{P}\p{S}]/u,Jp=gp(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Kp).getRegex(),Yp=/(?!~)[\p{P}\p{S}]/u,Xp=/(?!~)[\s\p{P}\p{S}]/u,Zp=/(?:[^\s\p{P}\p{S}]|~)/u,Qp=gp(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,_p?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),$p=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,em=gp($p,`u`).replace(/punct/g,Gp).getRegex(),tm=gp($p,`u`).replace(/punct/g,Yp).getRegex(),nm=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,rm=gp(nm,`gu`).replace(/notPunctSpace/g,qp).replace(/punctSpace/g,Kp).replace(/punct/g,Gp).getRegex(),im=gp(nm,`gu`).replace(/notPunctSpace/g,Zp).replace(/punctSpace/g,Xp).replace(/punct/g,Yp).getRegex(),am=gp(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,qp).replace(/punctSpace/g,Kp).replace(/punct/g,Gp).getRegex(),om=gp(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Gp).getRegex(),sm=gp(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,qp).replace(/punctSpace/g,Kp).replace(/punct/g,Gp).getRegex(),cm=gp(/\\(punct)/,`gu`).replace(/punct/g,Gp).getRegex(),lm=gp(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),um=gp(Pp).replace(`(?:-->|$)`,`-->`).getRegex(),dm=gp(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,um).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),fm=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,pm=gp(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,fm).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),mm=gp(/^!?\[(label)\]\[(ref)\]/).replace(`label`,fm).replace(`ref`,Ap).getRegex(),hm=gp(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Ap).getRegex(),gm=gp(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,mm).replace(`nolink`,hm).getRegex(),_m=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,vm={_backpedal:hp,anyPunctuation:cm,autolink:lm,blockSkip:Qp,br:Up,code:Hp,del:hp,delLDelim:hp,delRDelim:hp,emStrongLDelim:em,emStrongRDelimAst:rm,emStrongRDelimUnd:am,escape:Vp,link:pm,nolink:hm,punctuation:Jp,reflink:mm,reflinkSearch:gm,tag:dm,text:Wp,url:hp},ym={...vm,link:gp(/^!?\[(label)\]\((.*?)\)/).replace(`label`,fm).getRegex(),reflink:gp(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,fm).getRegex()},bm={...vm,emStrongRDelimAst:im,emStrongLDelim:tm,delLDelim:om,delRDelim:sm,url:gp(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,_m).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:gp(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,_m).getRegex()},xm={...bm,br:gp(Up).replace(`{2,}`,`*`).getRegex(),text:gp(bm.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Sm={normal:Lp,gfm:zp,pedantic:Bp},Cm={normal:vm,gfm:bm,breaks:xm,pedantic:ym},wm={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Tm=e=>wm[e];function Em(e,t){if(t){if(vp.escapeTest.test(e))return e.replace(vp.escapeReplace,Tm)}else if(vp.escapeTestNoEncode.test(e))return e.replace(vp.escapeReplaceNoEncode,Tm);return e}function Dm(e){try{e=encodeURI(e).replace(vp.percentDecode,`%`)}catch{return null}return e}function Om(e,t){let n=e.replace(vp.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(vp.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(vp.slashPipe,`|`);return n}function km(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Am(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function jm(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function Mm(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function Nm(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
17
17
|
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
|
|
18
18
|
`)}var Pm=class{options;rules;lexer;constructor(e){this.options=e||pp}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:km(e,`
|
|
@@ -76,6 +76,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
76
76
|
`)[0]??`PR created`),await pe()}catch(e){q(`pr create failed: ${e.message.slice(0,140)}`)}finally{de.value=!1}}}async function ge(e){if(r.value&&n.value){de.value=!0;try{let t=await W(r.value).gitOp(n.value,`pr-checks`,{n:e});w.value=new Map(w.value).set(e,t.text.slice(0,1500))}catch(e){q(`pr checks failed: ${e.message.slice(0,120)}`)}finally{de.value=!1}}}let _e=e=>ie({title:`Merge PR #${e}?`,body:`squash-merge via gh on the device.`,confirmLabel:`Squash & merge`,danger:!0,action:()=>void ve(e)});async function ve(e){if(r.value&&n.value){de.value=!0;try{q((await W(r.value).gitOp(n.value,`pr-merge`,{n:e})).text||`PR #${e} merged`),await pe(),await De()}catch(e){q(`pr merge failed: ${e.message.slice(0,140)}`)}finally{de.value=!1}}}let ye=e=>ie({title:`Comment on PR #${e}`,body:`posted as the device's gh login`,confirmLabel:`Comment`,input:{placeholder:`comment…`,value:``},action:t=>void be(e,t)});async function be(e,t){if(r.value&&n.value&&t.trim()){de.value=!0;try{q((await W(r.value).gitOp(n.value,`pr-comment`,{n:e,body:t.trim()})).text||`comment posted`)}catch(e){q(`pr comment failed: ${e.message.slice(0,140)}`)}finally{de.value=!1}}}let xe=O([]),Se=O(!1),Ce=async()=>{if(r.value&&l.value)try{let e=await W(r.value).sessionGitTurns(l.value);xe.value=e.turns}catch{xe.value=[]}};j(Se,e=>{e&&Ce()});let we=0;window.addEventListener(`focus`,()=>{!n.value||Date.now()-we<15e3||(we=Date.now(),ef(r.value||`?`,n.value||`?`,{force:!0}))});let Te=O(new Set),Ee=()=>{typeof localStorage<`u`&&(f.value=localStorage.getItem(y.value)??``)};Xd(),ef(r.value||`?`,n.value||`?`),Ee(),qr(()=>ef(r.value||`?`,n.value||`?`)),j(f,e=>{typeof localStorage<`u`&&(e?localStorage.setItem(y.value,e):localStorage.removeItem(y.value))}),j([r,n],()=>{m.value=!1,h.value=!1,_.value=null,b.value=null,x.value=``,S.value=!1,te.value=[],ce.value=new Map,Te.value=new Set,ef(r.value||`?`,n.value||`?`),Ee()});let De=()=>(p.value=new Set,_.value=null,ef(r.value||`?`,n.value||`?`,{force:!0})),Oe=H(()=>a.value?.files??[]);j(Oe,e=>{let t=new Set;for(let n of e)n.x!==`?`&&n.y!==`?`&&t.add(n.path);p.value=t},{immediate:!0});let ke=H(()=>Oe.value.some(e=>p.value.has(e.path))),Ae=H(()=>Oe.value.filter(e=>!Me(e)&&e.x!==` `&&e.x!==`?`)),je=H(()=>Oe.value.filter(e=>!Me(e)&&(e.x===` `||e.x===`?`))),Me=e=>`UAD`.includes(e.x)&&`UAD`.includes(e.y),Ne=H(()=>Oe.value.filter(Me)),Pe=H(()=>Oe.value.length>=500),Fe=H(()=>(a.value?.staged??0)+(a.value?.unstaged??0)+(a.value?.untracked??0)>0),Ie=H(()=>!a.value?.identity?.name||!a.value?.identity?.email),D=H(()=>{let e=a.value?.remoteUrl??``,t=e.match(/git@([^:]+):(.+?)(?:\.git)?$/)??e.match(/^https?:\/\/([^/]+)\/(.+?)(?:\.git)?$/);return t?`https://${t[1]}/${t[2]}`:``}),Le=e=>{let t=new Set(p.value);t.has(e)?t.delete(e):t.add(e),p.value=t},Re=e=>{let t=e.every(e=>p.value.has(e.path)),n=new Set(p.value);for(let r of e)t?n.delete(r.path):n.add(r.path);p.value=n},ze=e=>{let t=e.lastIndexOf(`/`);return t===-1?`.`:e.slice(0,t)},Be=e=>{let t=new Map;for(let n of e){let e=ze(n.path);t.has(e)||t.set(e,[]),t.get(e).push(n)}return[...t.entries()].map(([e,t])=>({dir:e,files:t,open:!Te.value.has(e)}))},Ve=e=>{let t=new Set(Te.value);t.has(e)?t.delete(e):t.add(e),Te.value=t},He=e=>e.a===void 0&&e.d===void 0?``:e.a===-1||e.d===-1?`bin`:`+${e.a??0} −${e.d??0}`,Ue=e=>{navigator.clipboard?.writeText(e).then(()=>q(`copied ${e}`))};async function We(e,t={}){if(r.value&&n.value){u.value=e,d.value=``;try{let i=await W(r.value).gitOp(n.value,e,t);d.value=i.text||`(empty)`,e===`push`&&(x.value=``),e===`pull`&&(S.value=!1),[`fetch`,`pull`,`push`,`stash-push`,`stash-pop`].includes(e)&&q(`git ${e} ✓`),await De(),yt(!0)}catch(t){let n=t.message;e===`push`&&(/no upstream|has no upstream|upstream is gone/i.test(n)?x.value=`no upstream — set it while pushing?`:/fetch first|non-fast-forward|rejected.*fetch|behind/i.test(n)?x.value=`the remote has work you lack — pull first`:/authentication|permission|could not read|403|denied/i.test(n)?x.value=`credentials rejected on the device — check its git login`:x.value=``),e===`pull`&&/not possible to fast-forward|divergent|unrelated histories/i.test(n)&&(S.value=!0),q(`git ${e}: ${n.slice(0,160)}`)}finally{u.value=``}}}async function Ge(e,t,i=!1){if(!r.value||!n.value||(i&&(u.value=e),!t&&e!==`stage`))return;if(e===`discard`&&t&&!i){ie({title:`Roll back to HEAD?`,body:`${t} — uncommitted changes are lost.`,confirmLabel:`Roll back`,danger:!0,action:()=>void Ge(e,t,!0)});return}u.value=e;let a=t?[t]:Oe.value.filter(e=>e.x===` `||e.x===`M`).map(e=>e.path);try{q((await W(r.value).gitOp(n.value,e,{files:a})).text),await De()}catch(t){q(`${e} failed: ${t.message.slice(0,140)}`)}finally{u.value=``}}async function Ke(e){if(r.value&&n.value&&e.length){u.value=`unstage`;try{q((await W(r.value).gitOp(n.value,`unstage`,{files:e})).text),await De()}catch(e){q(`unstage failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}async function qe(e,t){if(r.value&&n.value){u.value=`resolve`;try{q((await W(r.value).gitOp(n.value,`resolve`,{side:e,files:[t]})).text),await De()}catch(e){q(`resolve failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}async function Je(e){if(r.value&&n.value&&e.length){u.value=`ignore`;try{q((await W(r.value).gitOp(n.value,`ignore`,{lines:e})).text),await De()}catch(e){q(`ignore failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}async function Ye(e){if(r.value&&n.value){if(_.value?.path===e)return _.value=null;u.value=`diff`;try{let t=await W(r.value).gitOp(n.value,`diff-file`,{target:e,staged:v.value===`staged`});_.value={path:e,text:t.text}}catch(e){q(`diff failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}let Xe=async()=>{let e=_.value?.path;_.value=null,e&&await Ye(e)},Ze=H(()=>/Binary files .* differ/i.test(_.value?.text??``));async function Qe(){if(r.value&&n.value){u.value=`abort`;try{q((await W(r.value).gitOp(n.value,`merge-abort`)).text),await De()}catch(e){q(`abort failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}}async function $e(e){if(m.value=!1,r.value&&n.value){u.value=`compare`;try{let t=await W(r.value).gitOp(n.value,`compare`,{ref:e});b.value={ref:e,ahead:t.ahead??0,behind:t.behind??0}}catch(e){q(`compare failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}async function et(e,t=!1){if(m.value=!1,!r.value||!n.value||e===a.value?.branch&&!t)return;u.value=`switch`;let i=W(r.value),o=!1;try{if(ee.value&&!t&&Fe.value&&(await i.gitOp(n.value,`stash-push`,{message:`dpi auto-stash before ${e}`}),o=!0),q((await i.gitOp(n.value,`switch`,{ref:e,create:t})).text||`switched to ${e}`),o)try{let e=await i.gitOp(n.value,`stash-pop`);/conflict/i.test(e.text)&&q(`stash popped WITH CONFLICTS — resolve in the file list`)}catch{q(`switched, but the stash did not pop — resolve manually (git stash list)`)}await De(),yt(!0)}catch(e){if(q(`switch failed: ${e.message.slice(0,140)}`),o)try{await i.gitOp(n.value,`stash-pop`)}catch{}}finally{u.value=``}}async function tt(e=!1){if(!r.value||!n.value||!f.value.trim())return;u.value=`commit`;let t=Oe.value.filter(e=>p.value.has(e.path)).map(e=>e.path);if(!t.length)return q(`check the files to commit — nothing is selected`);let i=W(r.value);try{if(q((await i.gitOp(n.value,`commit`,{message:f.value.trim(),...a.value?.merge?{}:{files:t}})).text),f.value=``,e)try{q(`pushed: ${(await i.gitOp(n.value,`push`)).text.slice(0,80)}`)}catch(e){q(`committed, but push failed: ${e.message.slice(0,120)}`)}await De(),yt(!0)}catch(e){q(`commit failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}function nt(e){let t=e?.models??[],n=t.find(t=>`${t.provider}/${t.id}`===e?.defaultModel),r=new Map;for(let e of t)r.has(e.provider)||r.set(e.provider,e);let i=[...r.values()].filter(e=>e!==n).slice(0,3);return(n?[n,...i]:i).slice(0,4)}async function rt(){if(!r.value||!n.value)return;let e=Oe.value.filter(e=>p.value.has(e.path)).map(e=>e.path);if(!e.length)return q(`check files first — the model summarises THOSE`);u.value=`ai`;let t=W(r.value),i=``;for(let r of e.slice(0,5)){let e=await t.gitOp(n.value,`diff-file`,{target:r});if(i+=`${e.text}\n`,i.length>4e3)break}i=i.slice(0,4e3);let a=`Write ONE concise git commit message (under 72 chars, imperative, no quotes, no backticks) for these changes:\n\n${i}`,o=xu.devices.value.find(e=>e.id===r.value)?.info,s=nt(o);if(!s.length)return u.value=``,q(`no model on the device`);let c=[];try{for(let e of s){let r=await t.createSession({name:`git-msg`,cwd:n.value,model:{provider:e.provider,modelId:e.id}}).then(e=>e.id).catch(()=>``);if(!r){c.push(`${e.provider}: no session`);continue}try{let n=await t.agent(r,1).send(a,`followUp`,void 0,12e4),i=n.status===`done`?n.answer.text.trim().split(`
|
|
77
77
|
`)[0]?.slice(0,100):``;if(i){f.value=i;return}c.push(`${e.provider}/${e.id}: ${n.status===`unanswered`?n.reason:`empty answer`}`)}finally{t.session(r).archive().catch(()=>{})}}q(`ai message failed on every model — ${c.join(`; `).slice(0,140)}`)}catch(e){q(`ai message failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}async function it(){if(r.value&&l.value){u.value=`session-files`;try{let e=await W(r.value).sessionGitFiles(l.value);te.value=e.files;let t=e=>e.startsWith(`/`)||e.includes(`:\\`)?e:`${n.value}/${e}`,i=new Set(e.files.map(t)),a=Oe.value.filter(e=>i.has(t(e.path)));p.value=new Set(a.map(e=>e.path)),q(a.length?`${a.length} session file(s) still changed — checked`:`the session touched nothing that is still changed`)}catch(e){q(`session files failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}}async function at(e){if(ce.value.has(e)){ce.value.delete(e),ce.value=new Map(ce.value);return}if(r.value&&n.value)try{let t=await W(r.value).gitOp(n.value,`show-files`,{target:e});ce.value=new Map(ce.value).set(e,t.changed??[])}catch(e){q(`commit files failed: ${e.message.slice(0,120)}`)}}async function ot(){if(!r.value||!n.value)return;let e=`cp-${new Date().toISOString().slice(0,16).replace(/[-:T]/g,``)}`;u.value=`checkpoint`;try{q((await W(r.value).gitOp(n.value,`checkpoint`,{name:e})).text),se.value=!0,await st()}catch(e){q(`checkpoint failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}async function st(){if(r.value&&n.value)try{let e=await W(r.value).gitOp(n.value,`checkpoints`);oe.value=e.checkpoints??[]}catch{oe.value=[]}}async function ct(e){if(!r.value||!n.value)return;let t=e;ie({title:`Rewind to ${t}?`,body:`reset --hard — ALL uncommitted changes in this worktree are LOST.`,confirmLabel:`Rewind`,danger:!0,action:()=>void lt(t)})}async function lt(e){if(r.value&&n.value){u.value=`rewind`;try{q((await W(r.value).gitOp(n.value,`rewind`,{name:e})).text),await De(),yt(!0)}catch(e){q(`rewind failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}}j(se,e=>{e&&st()});async function ut(e){if(h.value=!1,!r.value||!n.value||!a.value?.root)return;let t=a.value.root,i=`${t.slice(0,t.lastIndexOf(`/`))}/${t.slice(t.lastIndexOf(`/`)+1)}-${e.replace(/[/\\]+/g,`-`)}`;u.value=`wt`;try{q((await W(r.value).gitOp(n.value,`worktree-add`,{branch:e,target:i})).text.split(`
|
|
78
78
|
`)[0]??`worktree ${i}`),g.value=``,await De()}catch(e){q(`worktree failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}async function dt(e,t){if(r.value){u.value=`session`;try{let n=xu.devices.value.find(e=>e.id===r.value)?.info,i=nt(n)[0];if(!i)return q(`no model available on ${r.value} — cannot create a session`);let a=await W(r.value).createSession({name:t??e.slice(e.lastIndexOf(`/`)+1),cwd:e,model:{provider:i.provider,modelId:i.id}});Ru({deviceId:r.value,sessionId:a.id,agentId:1}),q(`session "${a.name}" on ${e}`)}catch(e){q(`session failed: ${e.message.slice(0,160)}`)}finally{u.value=``}}}async function ft(e){if(r.value){u.value=`go`;try{let t=(await W(r.value).sessions()).find(t=>t.cwd===e);t?(Ru({deviceId:r.value,sessionId:t.id,agentId:1}),q(`switched to session "${t.name}"`)):await dt(e,null)}catch(e){q(`switch failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}}async function pt(e){if(!r.value||!n.value)return;u.value=`wt`;let t=`Uncommitted changes in it will be LOST.`;try{let n=(await W(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{}ie({title:`Remove worktree?`,body:`${e} — ${t}`,confirmLabel:`Remove`,danger:!0,action:()=>void mt(e)})}async function mt(e){u.value=`wt`;try{await W(r.value).gitOp(n.value,`worktree-remove`,{target:e}),await De()}catch(e){q(`remove failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}let ht=O([]),gt=O(!1),_t=O(``),vt=0;async function yt(e=!1){if(r.value&&n.value&&!(!e&&ht.value.length&&Date.now()-vt<12e4)){gt.value=!0;try{let e=await W(r.value).gitOp(n.value,`log-list`);ht.value=e.commits??[],_t.value=``,vt=Date.now()}catch(e){_t.value=e.message.slice(0,120)}finally{gt.value=!1}}}yt(),j([r,n],()=>{ht.value=[],vt=0,yt()});let bt=H(()=>(a.value?.worktrees??[]).filter(e=>e.path)),xt=[`#4f8cc9`,`#b8860b`,`#7aa25c`,`#a061ba`,`#c96f6f`,`#5fa8a0`],St=H(()=>{let e=new Map,t=[],n=[];for(let r of ht.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}),Ct=e=>e*12+7;return(e,t)=>(F(),I(`div`,Pb,[n.value?(F(),I(P,{key:1},[o.value?(F(),I(`p`,Ib,`loading git…`)):s.value?(F(),I(`p`,Lb,`refreshing…`)):V(``,!0),c.value?(F(),I(`p`,Rb,[B(E(c.value)+` `,1),R(`button`,{onClick:t[0]||=e=>De()},`retry`)])):V(``,!0),a.value?(F(),I(`div`,{key:3,class:T({stale:!!c.value||!!s.value})},[a.value.repo?(F(),I(P,{key:1},[a.value.merge?(F(),I(`p`,Bb,[B(` merge in progress — `+E(a.value.conflicts??Ne.value.length)+` unmerged path(s). Resolve them in the lists above, or `,1),R(`button`,{class:`small`,disabled:!!u.value,onClick:t[1]||=e=>Qe()},`abort merge`,8,Vb)])):V(``,!0),R(`div`,Hb,[R(`div`,Ub,[R(`button`,{class:`branch-btn`,disabled:!!u.value,onClick:t[2]||=e=>m.value=!m.value},[z(k(Sc),{size:16}),R(`strong`,null,E(a.value.branch??`detached`),1),z(k(rc),{size:14})],8,Wb),m.value?(F(),I(`div`,Gb,[(F(!0),I(P,null,N(a.value.branches??[],e=>(F(),I(`button`,{key:e.name,class:T({cur:e.current}),onClick:t=>et(e.name)},[z(k(Sc),{size:13}),R(`span`,null,E(e.name),1),R(`span`,qb,E(e.current?`current`:e.upstream?`→ ${e.upstream}`:``),1),t[42]||=R(`span`,{class:`grow`},null,-1),e.current?V(``,!0):(F(),L(k(Cc),{key:0,size:13,title:`compare with this base`,onClick:As(t=>$e(e.name),[`stop`])},null,8,[`onClick`]))],10,Kb))),128)),R(`div`,Jb,[A(R(`input`,{"onUpdate:modelValue":t[3]||=e=>g.value=e,placeholder:`new branch…`,onKeyup:t[4]||=Ms(e=>g.value.trim()&&et(g.value.trim(),!0),[`enter`])},null,544),[[bs,g.value]]),R(`button`,{disabled:!g.value.trim(),onClick:t[5]||=e=>et(g.value.trim(),!0)},[z(k(Zc),{size:13})],8,Yb)]),R(`label`,Xb,[A(R(`input`,{type:`checkbox`,"onUpdate:modelValue":t[6]||=e=>ee.value=e},null,512),[[xs,ee.value]]),t[43]||=B(` auto-stash on switch`,-1)])])):V(``,!0)]),R(`span`,Zb,E(a.value.upstream??`no upstream`),1),a.value.ahead?(F(),I(`span`,Qb,`↑`+E(a.value.ahead),1)):V(``,!0),a.value.behind?(F(),I(`span`,$b,`↓`+E(a.value.behind),1)):V(``,!0),b.value?(F(),I(`span`,ex,[B(` vs `+E(b.value.ref)+`: ↑`+E(b.value.ahead)+` ↓`+E(b.value.behind)+` `,1),R(`button`,{class:`tag-x`,onClick:t[7]||=e=>b.value=null},[z(k(yl),{size:11})])])):V(``,!0),R(`span`,tx,`+`+E(a.value.staged??0)+` ~`+E(a.value.unstaged??0)+` ?`+E(a.value.untracked??0),1),D.value?(F(),I(`a`,{key:3,class:`icon-button`,href:`${D.value}/tree/${a.value.branch??``}`,target:`_blank`,rel:`noopener`,title:`open on the remote`},[z(k(qs),{size:15,style:{transform:`rotate(45deg)`}})],8,nx)):V(``,!0),R(`button`,{class:`icon-button`,disabled:!!u.value||o.value||s.value,title:`refresh`,onClick:t[8]||=e=>De()},[z(k(el),{size:16})],8,rx)]),R(`div`,ix,[R(`button`,{class:`small`,disabled:!!u.value,onClick:t[9]||=e=>We(`fetch`)},[z(k(Gs),{size:14}),t[44]||=B(`fetch`,-1)],8,ax),R(`button`,{class:`small`,disabled:!!u.value,onClick:t[10]||=e=>We(`pull`)},[z(k(Gs),{size:14}),t[45]||=B(`pull`,-1)],8,ox),R(`button`,{class:`small primary`,disabled:!!u.value,title:`push`,onClick:t[11]||=e=>We(`push`)},[z(k(qs),{size:14}),t[46]||=B(`push`,-1)],8,sx),R(`button`,{class:`small`,disabled:!!u.value,title:`stash changes`,onClick:t[12]||=e=>We(`stash-push`,{message:f.value.trim()||void 0})},[z(k(ll),{size:14}),t[47]||=B(`stash`,-1)],8,cx),R(`button`,{class:`small`,disabled:!!u.value,title:`pop the newest stash`,onClick:t[13]||=e=>We(`stash-pop`)},[z(k(Uc),{size:14}),t[48]||=B(`unstash`,-1)],8,lx)]),x.value?(F(),I(`p`,ux,[B(E(x.value)+` `,1),x.value.includes(`upstream`)?(F(),I(`button`,{key:0,class:`small primary`,disabled:!!u.value,onClick:t[14]||=e=>We(`push`,{setUpstream:!0,ref:a.value.branch})},`push -u origin `+E(a.value.branch),9,dx)):x.value.includes(`remote has work`)?(F(),I(`button`,{key:1,class:`small primary`,disabled:!!u.value,onClick:t[15]||=e=>We(`pull`)},`pull now`,8,fx)):V(``,!0)])):V(``,!0),S.value?(F(),I(`p`,px,[t[49]||=B(` fast-forward is not possible — branches diverged. `,-1),R(`button`,{class:`small primary`,disabled:!!u.value,onClick:t[16]||=e=>We(`pull`,{rebase:!0})},`pull --rebase`,8,mx)])):V(``,!0),R(`section`,hx,[R(`div`,gx,[t[50]||=R(`h4`,null,`Commit`,-1),R(`span`,_x,E(Oe.value.length?`${p.value.size}/${Oe.value.length} files`:`no changes`),1),t[51]||=R(`span`,{class:`grow`},null,-1),l.value?(F(),I(`button`,{key:0,class:`small`,disabled:!!u.value,title:`check the files this session's agent touched`,onClick:it},[z(k(vc),{size:13}),B(` session files`+E(ne.value?` (${ne.value.changed}/${ne.value.total})`:``),1)],8,vx)):V(``,!0),l.value?(F(),I(`button`,{key:1,class:`small`,disabled:!!u.value,title:`what each turn of this session changed`,onClick:t[17]||=e=>Se.value=!Se.value},` turns `,8,yx)):V(``,!0)]),Ie.value?(F(),I(`p`,bx,[...t[52]||=[B(`git user.name/user.email is not set on the device — `,-1),R(`code`,null,`dpi device config`,-1),B(` or `,-1),R(`code`,null,`git config --global`,-1),B(` before committing.`,-1)]])):V(``,!0),Se.value?(F(),I(`div`,xx,[xe.value.length?V(``,!0):(F(),I(`p`,Sx,`no turns recorded yet for this session.`)),(F(!0),I(P,null,N(xe.value,(e,t)=>(F(),I(`div`,{key:t,class:`cp-row`},[R(`code`,null,`t`+E(xe.value.length-t),1),R(`span`,Cx,E(e.when.slice(0,16).replace(`T`,` `)),1),R(`span`,wx,E(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))])):V(``,!0),Pe.value?(F(),I(`p`,Tx,`showing the first 500 changed files — commit in smaller batches`)):V(``,!0),Ne.value.length?(F(),I(`div`,Ex,[R(`label`,Dx,[R(`span`,Ox,`Conflicts · `+E(Ne.value.length)+` — pick a side per file`,1)]),(F(!0),I(P,null,N(Ne.value,e=>(F(),I(`div`,{key:e.path,class:`file`},[R(`label`,kx,[R(`code`,Ax,E(e.x)+E(e.y),1),R(`span`,{class:`path`,title:e.path},E(e.path),9,jx)]),R(`span`,Mx,[R(`button`,{class:`icon-button`,title:`view the conflict`,onClick:t=>Ye(e.path)},[z(k(gc),{size:13})],8,Nx),R(`button`,{class:`small`,disabled:!!u.value,title:`keep this branch's version and stage it`,onClick:t=>qe(`ours`,e.path)},`ours`,8,Px),R(`button`,{class:`small`,disabled:!!u.value,title:`take the incoming version and stage it`,onClick:t=>qe(`theirs`,e.path)},`theirs`,8,Fx)])]))),128))])):V(``,!0),Ae.value.length?(F(),I(`div`,Ix,[R(`label`,Lx,[R(`input`,{type:`checkbox`,checked:Ae.value.every(e=>p.value.has(e.path)),onChange:t[18]||=e=>Re(Ae.value)},null,40,Rx),R(`span`,zx,`Staged · `+E(Ae.value.length),1),t[55]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`icon-button`,title:`stage every changed file`,onClick:t[19]||=e=>Ge(`stage`)},[z(k(Zc),{size:13}),t[53]||=B(` all`,-1)]),R(`button`,{class:`icon-button`,title:`unstage all (git reset HEAD)`,onClick:t[20]||=e=>Ke(Ae.value.map(e=>e.path))},[z(k(zc),{size:13}),t[54]||=B(` none`,-1)])]),(F(!0),I(P,null,N(Be(Ae.value),e=>(F(),I(P,{key:e.dir},[e.dir===`.`?V(``,!0):(F(),I(`button`,{key:0,class:`dir-row`,onClick:t=>Ve(e.dir)},[z(k(ic),{size:12,class:T({open:e.open})},null,8,[`class`]),B(E(e.dir),1),R(`span`,Vx,`· `+E(e.files.length),1)],8,Bx)),(F(!0),I(P,null,N(e.files,t=>A((F(),I(`div`,{key:t.path,class:`file`},[R(`label`,Hx,[R(`input`,{type:`checkbox`,checked:p.value.has(t.path),onChange:e=>Le(t.path)},null,40,Ux),R(`code`,{class:`xy`,title:`index ${t.x} · worktree ${t.y}`},E(t.x)+E(t.y),9,Wx),R(`span`,{class:`path`,title:t.path},E(t.path),9,Gx),He(t)?(F(),I(`span`,{key:0,class:T([`nums`,{bin:He(t)===`bin`}])},E(He(t)),3)):V(``,!0)]),R(`span`,Kx,[R(`button`,{class:`icon-button`,title:`view diff`,onClick:e=>Ye(t.path)},[z(k(gc),{size:13})],8,qx),R(`button`,{class:`icon-button`,title:`unstage (git reset HEAD)`,onClick:e=>Ke([t.path])},[z(k(zc),{size:13})],8,Jx),R(`button`,{class:`icon-button`,title:`roll back to HEAD`,onClick:e=>Ge(`discard`,t.path)},[z(k(dc),{size:13})],8,Yx)])])),[[zo,e.open]])),128))],64))),128))])):V(``,!0),je.value.length?(F(),I(`div`,Xx,[R(`label`,Zx,[R(`input`,{type:`checkbox`,checked:je.value.every(e=>p.value.has(e.path)),onChange:t[21]||=e=>Re(je.value)},null,40,Qx),R(`span`,$x,`Unstaged · `+E(je.value.length),1)]),(F(!0),I(P,null,N(Be(je.value),e=>(F(),I(P,{key:e.dir},[e.dir===`.`?V(``,!0):(F(),I(`button`,{key:0,class:`dir-row`,onClick:t=>Ve(e.dir)},[z(k(ic),{size:12,class:T({open:e.open})},null,8,[`class`]),B(E(e.dir),1),R(`span`,tS,`· `+E(e.files.length),1)],8,eS)),(F(!0),I(P,null,N(e.files,t=>A((F(),I(`div`,{key:t.path,class:`file`},[R(`label`,nS,[R(`input`,{type:`checkbox`,checked:p.value.has(t.path),onChange:e=>Le(t.path)},null,40,rS),R(`code`,{class:`xy`,title:`index ${t.x} · worktree ${t.y}`},E(t.x)+E(t.y),9,iS),R(`span`,{class:`path`,title:t.path},E(t.path),9,aS),He(t)?(F(),I(`span`,{key:0,class:T([`nums`,{bin:He(t)===`bin`}])},E(He(t)),3)):V(``,!0)]),R(`span`,oS,[R(`button`,{class:`icon-button`,title:`view diff`,onClick:e=>Ye(t.path)},[z(k(gc),{size:13})],8,sS),t.x===`?`?(F(),I(`button`,{key:0,class:`icon-button`,title:`add to .gitignore`,onClick:e=>Je([t.path])},[z(k(Xs),{size:13})],8,cS)):(F(),I(`button`,{key:1,class:`icon-button`,title:`stage (git add)`,onClick:e=>Ge(`stage`,t.path)},[z(k(Zc),{size:13})],8,lS)),t.x===`?`?V(``,!0):(F(),I(`button`,{key:2,class:`icon-button`,title:`roll back to HEAD`,onClick:e=>Ge(`discard`,t.path)},[z(k(dc),{size:13})],8,uS)),R(`button`,{class:`icon-button`,title:`copy path`,onClick:e=>Ue(t.path)},[z(k(cc),{size:13})],8,dS)])])),[[zo,e.open]])),128))],64))),128))])):V(``,!0),_.value?(F(),I(`p`,fS,[R(`strong`,null,E(_.value.path),1),R(`span`,pS,[R(`button`,{class:T({on:v.value===`working`}),onClick:t[22]||=e=>{v.value=`working`,Xe()}},`working`,2),R(`button`,{class:T({on:v.value===`staged`}),onClick:t[23]||=e=>{v.value=`staged`,Xe()}},`staged`,2)]),Ze.value?(F(),I(`span`,mS,`binary file`)):_.value.text.length>8e3?(F(),I(`span`,hS,`truncated at 8000 chars`)):V(``,!0),R(`button`,{class:`icon-button`,title:`close diff`,onClick:t[24]||=e=>_.value=null},[z(k(yl),{size:13})]),Ze.value?V(``,!0):(F(),I(`pre`,gS,E(_.value.text.slice(0,8e3)),1))])):V(``,!0),A(R(`textarea`,{"onUpdate:modelValue":t[25]||=e=>f.value=e,rows:`4`,placeholder:`Commit message… (Ctrl+Enter to commit)`,onKeydown:[t[26]||=Ms(As(e=>tt(),[`exact`,`prevent`]),[`enter`]),t[27]||=Ms(As(e=>tt(),[`meta`,`prevent`]),[`enter`]),t[28]||=Ms(As(e=>tt(),[`ctrl`,`prevent`]),[`enter`])]},null,544),[[bs,f.value]]),R(`div`,_S,[R(`button`,{class:`small`,disabled:!!u.value||!p.value.size,title:`ask the device's model for a message`,onClick:rt},[z(k(cl),{size:14}),t[56]||=B(` ai message`,-1)],8,vS),t[58]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`primary small`,disabled:!!u.value||!f.value.trim()||!ke.value,onClick:t[29]||=e=>tt(!1)},[z(k(nc),{size:14}),B(` Commit`+E(p.value.size?` ${p.value.size} file${p.value.size>1?`s`:``}`:``),1)],8,yS),a.value.upstream?(F(),I(`button`,{key:0,class:`primary small`,disabled:!!u.value||!f.value.trim()||!ke.value,title:`commit, then push`,onClick:t[30]||=e=>tt(!0)},[z(k(nc),{size:14}),t[57]||=B(` Commit & push `,-1)],8,bS)):V(``,!0)])]),R(`section`,xS,[R(`div`,SS,[R(`h4`,null,[z(k(Dc),{size:16}),t[59]||=B(` Log`,-1)]),t[61]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`small`,disabled:!!u.value,title:`save a checkpoint ref of HEAD`,onClick:ot},[z(k(vc),{size:13}),t[60]||=B(` checkpoint`,-1)],8,CS),R(`button`,{class:`small`,disabled:!!u.value,onClick:t[31]||=e=>se.value=!se.value},`checkpoints `+E(oe.value.length?`(${oe.value.length})`:``),9,wS),R(`button`,{class:`icon-button`,disabled:gt.value,title:`refresh log`,onClick:t[32]||=e=>yt(!0)},[z(k(el),{size:14})],8,TS)]),se.value?(F(),I(`div`,ES,[oe.value.length?V(``,!0):(F(),I(`p`,DS,`no checkpoints yet — one click saves a named ref of HEAD.`)),(F(!0),I(P,null,N(oe.value,e=>(F(),I(`div`,{key:e.name,class:`cp-row`},[R(`code`,null,E(e.name),1),R(`span`,OS,E(e.hash)+` · `+E(e.date),1),R(`span`,kS,E(e.subject),1),t[63]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`small`,disabled:!!u.value,title:`reset --hard to this checkpoint (this worktree)`,onClick:t=>ct(e.name)},[z(k(pl),{size:13}),t[62]||=B(` rewind`,-1)],8,AS)]))),128))])):V(``,!0),gt.value&&!ht.value.length?(F(),I(`p`,jS,`loading log…`)):ht.value.length?(F(),I(`div`,MS,[(F(!0),I(P,null,N(ht.value,(e,t)=>(F(),I(P,{key:e.hash},[R(`div`,{class:`commit-row`,title:e.refs},[St.value[t]?(F(),I(`svg`,{key:0,class:`lane`,width:St.value[t].width*12+4,height:`24`,"aria-hidden":`true`},[(F(!0),I(P,null,N(St.value[t].width,e=>(F(),I(`line`,{key:e,x1:Ct(e-1),x2:Ct(e-1),y1:`0`,y2:`24`,stroke:`#3a3134`,"stroke-width":`2`},null,8,FS))),128)),(F(!0),I(P,null,N(St.value[t].parents,(e,n)=>(F(),I(`line`,{key:`p`+n,x1:Ct(St.value[t].lane),x2:Ct(e),y1:`12`,y2:`24`,stroke:xt[e%xt.length],"stroke-width":`2`},null,8,IS))),128)),R(`circle`,{cx:Ct(St.value[t].lane),cy:`12`,r:`4`,fill:xt[St.value[t].lane%xt.length]},null,8,LS)],8,PS)):V(``,!0),R(`button`,{class:`icon-button hash-btn`,title:`files in this commit`,onClick:t=>at(e.hash)},[z(k(ic),{size:12,class:T({open:ce.value.has(e.hash)})},null,8,[`class`])],8,RS),R(`code`,zS,[D.value?(F(),I(`a`,{key:0,href:`${D.value}/commit/${e.hash}`,target:`_blank`,rel:`noopener`,title:`on the remote`},E(e.hash),9,BS)):(F(),I(P,{key:1},[B(E(e.hash),1)],64))]),e.refs?(F(),I(`span`,VS,E(e.refs.split(`,`)[0]),1)):V(``,!0),R(`span`,HS,E(e.subject),1),R(`span`,US,E(e.author)+` · `+E(e.date),1)],8,NS),ce.value.has(e.hash)?(F(),I(`div`,WS,[(F(!0),I(P,null,N(ce.value.get(e.hash),e=>(F(),I(`div`,{key:e.path,class:`cf`},[R(`code`,{class:`cf-status`,"data-s":e.status},E(e.status),9,GS),R(`span`,KS,E(e.path),1)]))),128)),ce.value.get(e.hash)?.length?V(``,!0):(F(),I(`p`,qS,`no files (merge/empty commit)`))])):V(``,!0)],64))),128))])):_t.value?(F(),I(`p`,JS,`log failed: `+E(_t.value),1)):(F(),I(`p`,YS,`no commits`))]),R(`section`,XS,[R(`div`,ZS,[R(`h4`,null,[z(k(Uc),{size:16}),t[64]||=B(` Worktrees`,-1)]),R(`div`,QS,[R(`button`,{class:`small`,disabled:!!u.value,onClick:t[33]||=e=>h.value=!h.value},[z(k(Zc),{size:13}),t[65]||=B(` worktree`,-1)],8,$S),h.value?(F(),I(`div`,eC,[(F(!0),I(P,null,N((a.value.branches??[]).filter(e=>!e.current),e=>(F(),I(`button`,{key:e.name,onClick:t=>ut(e.name)},[z(k(Sc),{size:13}),R(`span`,null,E(e.name),1),t[66]||=R(`span`,{class:`muted-line`},`existing`,-1)],8,tC))),128)),R(`div`,nC,[A(R(`input`,{"onUpdate:modelValue":t[34]||=e=>g.value=e,placeholder:`or a NEW branch…`,onKeyup:t[35]||=Ms(e=>g.value.trim()&&ut(g.value.trim()),[`enter`])},null,544),[[bs,g.value]]),R(`button`,{disabled:!g.value.trim(),onClick:t[36]||=e=>ut(g.value.trim())},`create`,8,rC)])])):V(``,!0)])]),(F(!0),I(P,null,N(bt.value,e=>(F(),I(`div`,{key:e.path,class:T([`wt`,{main:e.path===a.value.root}])},[R(`code`,{title:e.path},E(e.path),9,iC),R(`span`,aC,E(e.branch??e.head),1),t[67]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`icon-button`,disabled:!!u.value,title:`jump to this worktree (session or new)`,onClick:t=>ft(e.path)},[z(k(Ks),{size:13})],8,oC),R(`button`,{class:`small`,disabled:!!u.value,title:`create a session on this worktree`,onClick:t=>dt(e.path,e.branch)},`session`,8,sC),e.path===a.value.root?V(``,!0):(F(),I(`button`,{key:0,class:`icon-button`,disabled:!!u.value,onClick:t=>pt(e.path)},[z(k(yl),{size:13})],8,cC)),e.path===a.value.root?(F(),L(k(nc),{key:1,size:13,class:`muted-line`})):V(``,!0)],2))),128))]),fe.value?(F(),I(`section`,lC,[R(`div`,uC,[R(`h4`,null,[z(k(Tc),{size:16}),t[68]||=B(` Pull requests`,-1)]),t[69]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`small`,disabled:de.value||!!u.value,onClick:me},`create PR`,8,dC),R(`button`,{class:`small`,disabled:de.value,onClick:t[37]||=e=>ue.value=!ue.value},E(ue.value?`hide`:`list`),9,fC)]),ue.value&&!le.value.length&&!de.value?(F(),I(`p`,pC,`no open PRs (or gh is not logged in on the device — every action will say so).`)):V(``,!0),ue.value?(F(),I(`div`,mC,[(F(!0),I(P,null,N(le.value,e=>(F(),I(`div`,{key:e.n,class:`pr-row`},[R(`code`,hC,`#`+E(e.n),1),R(`span`,{class:T([`tag`,{open:e.state===`OPEN`}])},E(e.state.toLowerCase())+E(e.draft?` · draft`:``),3),R(`span`,gC,E(e.title),1),R(`span`,_C,E(e.branch),1),t[70]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`icon-button`,title:`run checks`,disabled:de.value,onClick:t=>ge(e.n)},[z(k(el),{size:13})],8,vC),R(`button`,{class:`icon-button`,title:`comment`,disabled:de.value,onClick:t=>ye(e.n)},[z(k(cc),{size:13})],8,yC),e.state===`OPEN`?(F(),I(`button`,{key:0,class:`small`,disabled:de.value||!!u.value,onClick:t=>_e(e.n)},`squash & merge`,8,bC)):V(``,!0),R(`a`,{class:`icon-button`,href:e.url,target:`_blank`,rel:`noopener`,title:`open on the forge`},[z(k(qs),{size:13,style:{transform:`rotate(45deg)`}})],8,xC)]))),128)),(F(!0),I(P,null,N(w.value,([e,t])=>(F(),I(`pre`,{key:e,class:`pr-checks`},`#`+E(e)+` checks:`+E(`
|
|
79
|
-
`)+E(t),1))),128))])):V(``,!0)])):V(``,!0),d.value?(F(),I(`pre`,SC,E(d.value.slice(0,6e3)),1)):V(``,!0)],64)):(F(),I(`p`,zb,[...t[41]||=[B(`Not a git repository — run `,-1),R(`code`,null,`git init`,-1),B(` (or open a session inside a repo).`,-1)]]))],2)):V(``,!0),C.value?(F(),I(`div`,{key:4,class:`modal-veil`,onClick:t[40]||=As(e=>C.value=null,[`self`])},[R(`div`,{class:T([`modal`,{danger:C.value.danger}]),role:`dialog`,"aria-modal":`true`},[R(`h5`,null,E(C.value.title),1),R(`p`,null,E(C.value.body),1),C.value.input?A((F(),I(`textarea`,{key:0,"onUpdate:modelValue":t[38]||=e=>re.value=e,rows:`2`,placeholder:C.value.input.placeholder},null,8,CC)),[[bs,re.value]]):V(``,!0),R(`div`,wC,[t[72]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`small`,onClick:t[39]||=e=>C.value=null},[...t[71]||=[B(`cancel `,-1),R(`span`,{class:`muted-line`},`(esc)`,-1)]]),R(`button`,{class:T([`primary small`,{danger:C.value.danger}]),disabled:!(!C.value.input||re.value.trim()),onClick:ae},E(C.value.confirmLabel??`confirm`),11,TC)])],2)])):V(``,!0)],64)):(F(),I(`p`,Fb,`No session selected — open a session to see its git.`))]))}}),[[`__scopeId`,`data-v-e5829ed1`]]),DC={class:`host-panel`,"aria-label":`Device vitals`},OC={class:`panel-heading`},kC=[`disabled`],AC={key:0,class:`hint`},jC={key:1,class:`message-error`},MC={key:2,class:`hint`},NC={class:`vitals-grid`},PC={class:`vital`},FC={class:`vital`},IC={key:0,class:`vital`},LC={class:`vital`},RC={class:`vital`},zC={class:`meter`},BC={class:`meter-head`},VC={class:`hint`},HC=[`aria-valuenow`],UC={class:`meter`},WC={class:`meter-head`},GC={class:`hint`},KC=[`aria-valuenow`],qC={class:`path`},JC={class:`hint`},YC=Ld(M({__name:`HostPanel`,setup(e){let t=O(),n=O(!1),r=O(``),i=H(()=>G.value?.deviceId),a=H(()=>xu.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=H(()=>t.value?c(t.value.memory.usedBytes,t.value.memory.totalBytes):0),u=H(()=>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 W(e).vitals()}catch(e){r.value=lu(e).slice(0,160)}finally{n.value=!1}}}j(i,d,{immediate:!0});async function f(){await d(),r.value||q(`Vitals refreshed.`)}return(e,c)=>(F(),I(`section`,DC,[R(`header`,OC,[R(`span`,null,[z(k(il),{size:16}),c[0]||=B(`HOST`,-1)]),R(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh vitals`,title:`Refresh vitals`,onClick:f},[z(k(el),{size:15,class:T({spin:n.value})},null,8,[`class`])],8,kC)]),i.value?r.value?(F(),I(`p`,jC,E(r.value),1)):t.value?(F(),I(P,{key:3},[R(`div`,NC,[R(`div`,PC,[c[1]||=R(`span`,{class:`label`},`Host uptime`,-1),R(`strong`,null,E(s(t.value.uptime)),1)]),R(`div`,FC,[c[2]||=R(`span`,{class:`label`},`Device process`,-1),R(`strong`,null,E(s(t.value.processUptime)),1),R(`em`,null,`pid `+E(t.value.pid),1)]),a.value?(F(),I(`div`,IC,[c[3]||=R(`span`,{class:`label`},`Keep-awake`,-1),R(`strong`,null,E(a.value===`none`?`off`:a.value),1),R(`em`,null,E(a.value===`none`?`no inhibitor here`:`held while sessions run`),1)])):V(``,!0),R(`div`,LC,[c[4]||=R(`span`,{class:`label`},`Load (1/5/15m)`,-1),R(`strong`,null,E(t.value.loadavg.map(e=>e.toFixed(2)).join(` · `)),1),R(`em`,null,E(t.value.cpuCount)+` CPU`+E(t.value.cpuCount===1?``:`s`),1)]),R(`div`,RC,[c[5]||=R(`span`,{class:`label`},`Sessions`,-1),R(`strong`,null,E(t.value.counts?.sessions??0),1),R(`em`,null,E(t.value.counts?.archived??0)+` archived`,1)])]),R(`div`,zC,[R(`div`,BC,[c[6]||=R(`span`,{class:`label`},`Memory`,-1),R(`span`,VC,E(o(t.value.memory.usedBytes))+` / `+E(o(t.value.memory.totalBytes))+` · device `+E(o(t.value.memory.processRssBytes)),1)]),R(`div`,{class:`bar`,role:`meter`,"aria-valuenow":l.value,"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`Memory used`},[R(`i`,{style:_e({width:`${l.value}%`}),class:T({high:l.value>=90})},null,6)],8,HC)]),R(`div`,UC,[R(`div`,WC,[c[7]||=R(`span`,{class:`label`},`Disk · data dir`,-1),R(`span`,GC,[t.value.disk.known?(F(),I(P,{key:0},[B(E(o(t.value.disk.totalBytes-t.value.disk.freeBytes))+` used · `+E(o(t.value.disk.freeBytes))+` free `,1)],64)):(F(),I(P,{key:1},[B(`unknown on this volume`)],64))])]),R(`div`,{class:`bar`,role:`meter`,"aria-valuenow":u.value,"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`Disk used`},[R(`i`,{style:_e({width:`${u.value}%`}),class:T({high:u.value>=90})},null,6)],8,KC),R(`code`,qC,E(t.value.disk.path),1)]),R(`p`,JC,[z(k(Hs),{size:13}),c[8]||=B(` Read on demand — open this tab or press refresh. Nothing polls the device. `,-1)])],64)):(F(),I(`p`,MC,E(n.value?`Reading host…`:`No vitals.`),1)):(F(),I(`p`,AC,`Select a session to see its device.`))]))}}),[[`__scopeId`,`data-v-ef6f9dc5`]]),XC={class:`usage-panel`,"aria-label":`Device usage`},ZC={class:`panel-heading`},QC=[`disabled`],$C={key:0,class:`hint`},ew={key:1,class:`message-error`},tw={key:2,class:`hint`},nw={key:3,class:`hint`},rw={class:`usage-block`,"aria-labelledby":`usage-totals`},iw={class:`totals`},aw={class:`total`},ow={class:`total`},sw={class:`total`},cw={class:`total`},lw={class:`usage-block`,"aria-labelledby":`usage-models`},uw={class:`section-label block-label`},dw={class:`table-scroll`},fw={class:`usage-table`,"aria-label":`Usage by model`},pw=[`title`],mw={class:`num`},hw={class:`num`},gw={class:`share-col`},_w={class:`share`},vw=[`aria-valuenow`,`aria-label`],yw={class:`pct`},bw={class:`usage-block`,"aria-labelledby":`usage-projects`},xw={class:`section-label block-label`},Sw={key:0,class:`hint`},Cw={key:1,class:`rows`},ww=[`title`],Tw={class:`row-main`},Ew={class:`row-num`},Dw={class:`row-num`},Ow={class:`row-meta`},kw={class:`usage-block`,"aria-labelledby":`usage-sessions`},Aw={key:0,class:`hint`},jw={key:1,class:`rows scroll`},Mw=[`title`],Nw={class:`row-main`},Pw={class:`row-num`},Fw={class:`row-num`},Iw={class:`row-meta`},Lw={class:`hint`},Rw=Ld(M({__name:`UsagePanel`,setup(e){let t=O(),n=O(!1),r=O(``),i=H(()=>G.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=H(()=>(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=H(()=>{let e=t.value;return!e||!e.models.length&&!e.sessions.length&&!e.projects.length}),u=H(()=>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 W(e).deviceUsage()}catch(e){r.value=lu(e).slice(0,160)}finally{n.value=!1}}}j(i,f,{immediate:!0});async function p(){await f(),r.value||q(`Usage refreshed.`)}return(e,s)=>(F(),I(`section`,XC,[R(`header`,ZC,[R(`span`,null,[z(k(Hs),{size:16}),s[0]||=B(`USAGE`,-1)]),R(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh usage`,title:`Refresh usage`,onClick:p},[z(k(el),{size:15,class:T({spin:n.value})},null,8,[`class`])],8,QC)]),i.value?r.value?(F(),I(`p`,ew,E(r.value),1)):t.value?l.value?(F(),I(`p`,nw,`No usage recorded yet.`)):(F(),I(P,{key:4},[R(`section`,rw,[s[6]||=R(`div`,{class:`section-label block-label`},[R(`span`,{id:`usage-totals`},`TOTALS`)],-1),R(`div`,iw,[R(`div`,aw,[s[1]||=R(`span`,{class:`label`},`Tokens`,-1),R(`strong`,null,E(a(t.value.totals.tokens)),1)]),R(`div`,ow,[s[2]||=R(`span`,{class:`label`},`Cost`,-1),R(`strong`,null,E(o(t.value.totals.cost)),1)]),R(`div`,sw,[s[3]||=R(`span`,{class:`label`},`Sessions`,-1),R(`strong`,null,E(a(t.value.sessions.length)),1),R(`em`,null,E(a(t.value.projects.length))+` projects`,1)]),R(`div`,cw,[s[4]||=R(`span`,{class:`label`},`Models`,-1),R(`strong`,null,E(a(t.value.models.length)),1),s[5]||=R(`em`,null,`costliest first`,-1)])])]),R(`section`,lw,[R(`div`,uw,[s[7]||=R(`span`,{id:`usage-models`},`BY MODEL`,-1),z(k(fc),{size:13})]),R(`div`,dw,[R(`table`,fw,[s[8]||=R(`colgroup`,null,[R(`col`),R(`col`),R(`col`),R(`col`)],-1),s[9]||=R(`thead`,null,[R(`tr`,null,[R(`th`,{scope:`col`},`Model`),R(`th`,{scope:`col`,class:`num`},`Tokens`),R(`th`,{scope:`col`,class:`num`},`Cost`),R(`th`,{scope:`col`,class:`share-col`},`Share`)])],-1),R(`tbody`,null,[(F(!0),I(P,null,N(t.value.models,e=>(F(),I(`tr`,{key:e.key},[R(`th`,{scope:`row`,class:`model-key`,title:`${e.key} — in ${e.input} · out ${e.output} · cache read ${e.cacheRead} · cache write ${e.cacheWrite}`},E(e.key),9,pw),R(`td`,mw,E(a(e.tokens)),1),R(`td`,hw,E(o(e.cost)),1),R(`td`,gw,[R(`div`,_w,[R(`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`},[R(`i`,{style:_e({width:`${c(e.cost)}%`}),class:T({high:c(e.cost)>90})},null,6)],8,vw),R(`em`,yw,E(c(e.cost))+`%`,1)])])]))),128))])])])]),R(`section`,bw,[R(`div`,xw,[s[10]||=R(`span`,{id:`usage-projects`},`BY PROJECT`,-1),z(k(yc),{size:13})]),t.value.projects.length?(F(),I(`ul`,Cw,[(F(!0),I(P,null,N(t.value.projects,e=>(F(),I(`li`,{key:e.rootPath,class:`row`,title:e.rootPath},[R(`span`,Tw,[R(`strong`,null,E(e.name),1),R(`em`,null,E(e.rootPath),1)]),R(`span`,Ew,E(a(e.tokens))+` tok`,1),R(`span`,Dw,E(o(e.cost)),1),R(`span`,Ow,E(d(e.sessions,`session`)),1)],8,ww))),128))])):(F(),I(`p`,Sw,`No project usage recorded yet.`))]),R(`section`,kw,[s[11]||=R(`div`,{class:`section-label block-label`},[R(`span`,{id:`usage-sessions`},`BY SESSION`)],-1),t.value.sessions.length?(F(),I(`ul`,jw,[(F(!0),I(P,null,N(t.value.sessions,e=>(F(),I(`li`,{key:e.id,class:`row`,title:e.cwd},[R(`span`,Nw,[R(`strong`,null,E(e.name),1),R(`em`,null,E(e.project??e.cwd),1)]),R(`span`,Pw,E(a(e.tokens))+` tok`,1),R(`span`,Fw,E(o(e.cost)),1),R(`span`,Iw,E(d(e.agents,`agent`)),1)],8,Mw))),128))])):(F(),I(`p`,Aw,`No session usage recorded yet.`))]),R(`p`,Lw,[z(k(Hs),{size:13}),B(` Read on demand — open this tab or press refresh (`+E(u.value)+`). Nothing polls the device. `,1)])],64)):(F(),I(`p`,tw,E(n.value?`Reading usage…`:`No usage recorded yet.`),1)):(F(),I(`p`,$C,`Select a session to see its device's usage.`))]))}}),[[`__scopeId`,`data-v-81e8eb49`]]),zw={class:`schedules-panel`,"aria-label":`Scheduled sessions`},Bw={class:`panel-heading`},Vw=[`disabled`],Hw=[`disabled`],Uw={key:0,class:`hint`},Ww={key:1,class:`message-error`},Gw=[`value`],Kw={class:`trigger-row`},qw={class:`inline`},Jw=[`disabled`],Yw={class:`inline`},Xw=[`disabled`],Zw={class:`row`},Qw=[`disabled`],$w={key:3,class:`hint`},eT={key:4,class:`schedule-list`},tT={class:`head`},nT={class:`tag`},rT={key:0,class:`tag running`},iT=[`title`],aT={class:`next`},oT={class:`cwd`},sT={key:0,class:`message-error`},cT={class:`row`},lT=[`disabled`,`onClick`],uT=[`disabled`,`onClick`],dT=[`disabled`,`onClick`],fT=Ld(M({__name:`SchedulesPanel`,setup(e){let t=O([]),n=O(``),r=O(``),i=O(!1),a=H(()=>G.value?.deviceId),o=()=>W(a.value??``),s=O(`60`),c=O(``),l=O(!1),u=O({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){let t=e.code;r.value=t===`not_found`||/allowlist/i.test(lu(e))?"This device runs an older build: update it (`dpi update`) to use schedules.":lu(e).slice(0,160)}finally{i.value=!1}}j(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(),q(r)}catch(e){q(lu(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 finished.`),_=e=>K.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=O([]);async function y(){l.value=!0,u.value={name:``,cwd:(G.value?.sessionId,``),prompt:``,model:``};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=[]}}async function b(){let e=u.value,[t,...r]=e.model.split(`/`),i=r.join(`/`);if(e.name.trim()&&e.cwd.trim()&&e.prompt.trim()&&t&&i){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(),q(`Schedule created. The device runs it on its own clock.`)}catch(e){q(lu(e).slice(0,160))}finally{n.value=``}}}return(e,o)=>(F(),I(`section`,zw,[R(`header`,Bw,[R(`span`,null,[z(k(tc),{size:16}),o[7]||=B(`SCHEDULES`,-1)]),R(`button`,{class:`icon-button`,disabled:i.value||!a.value,"aria-label":`Refresh schedules`,title:`Refresh schedules`,onClick:d},[z(k(el),{size:15,class:T({spin:i.value})},null,8,[`class`])],8,Vw),R(`button`,{class:`icon-button`,disabled:!a.value,"aria-label":`Add schedule`,title:`Add schedule`,onClick:y},[z(k(Zc),{size:15})],8,Hw)]),o[18]||=R(`p`,{class:`hint`},`Runs on the device's own clock — no browser needs to be open.`,-1),a.value?r.value?(F(),I(`p`,Ww,E(r.value),1)):V(``,!0):(F(),I(`p`,Uw,`Select a session to see its device.`)),l.value?(F(),I(`form`,{key:2,class:`add-form`,onSubmit:As(b,[`prevent`])},[R(`label`,null,[o[8]||=B(`Name`,-1),A(R(`input`,{"onUpdate:modelValue":o[0]||=e=>u.value.name=e,placeholder:`Nightly smoke`,required:``},null,512),[[bs,u.value.name]])]),R(`label`,null,[o[9]||=B(`Directory`,-1),A(R(`input`,{"onUpdate:modelValue":o[1]||=e=>u.value.cwd=e,placeholder:`/home/me/project`,required:``},null,512),[[bs,u.value.cwd]])]),R(`label`,null,[o[10]||=B(`Prompt`,-1),A(R(`textarea`,{"onUpdate:modelValue":o[2]||=e=>u.value.prompt=e,rows:`3`,placeholder:`Run the tests and summarise failures`,required:``},null,512),[[bs,u.value.prompt]])]),R(`label`,null,[o[11]||=B(`Model `,-1),A(R(`select`,{"onUpdate:modelValue":o[3]||=e=>u.value.model=e},[(F(!0),I(P,null,N(v.value,e=>(F(),I(`option`,{key:e.key,value:e.key},E(e.key),9,Gw))),128))],512),[[Cs,u.value.model]])]),R(`div`,Kw,[R(`label`,qw,[o[12]||=B(`Every `,-1),A(R(`input`,{"onUpdate:modelValue":o[4]||=e=>s.value=e,class:`num`,disabled:!!c.value.trim()},null,8,Jw),[[bs,s.value]]),o[13]||=B(` min`,-1)]),o[15]||=R(`span`,{class:`muted`},`or`,-1),R(`label`,Yw,[o[14]||=B(`daily at `,-1),A(R(`input`,{"onUpdate:modelValue":o[5]||=e=>c.value=e,class:`num time`,placeholder:`03:00`,disabled:!!s.value},null,8,Xw),[[bs,c.value]])])]),R(`div`,Zw,[R(`button`,{class:`primary small`,type:`submit`,disabled:n.value===`new`},E(n.value===`new`?`creating…`:`Create schedule`),9,Qw),R(`button`,{class:`small`,type:`button`,onClick:o[6]||=e=>l.value=!1},`Cancel`)])],32)):V(``,!0),!l.value&&!t.value.length&&a.value&&!r.value?(F(),I(`p`,$w,` No schedules yet. Press + to add one. `)):V(``,!0),t.value.length?(F(),I(`ul`,eT,[(F(!0),I(P,null,N(t.value,e=>(F(),I(`li`,{key:e.id,class:T([`schedule`,{off:!e.enabled}])},[R(`div`,tT,[R(`b`,null,E(e.name),1),R(`span`,nT,E(p(e)),1),e.running?(F(),I(`span`,rT,`running`)):e.lastOutcome===`failed`?(F(),I(`span`,{key:1,class:`tag bad`,title:e.lastError},`last run failed`,8,iT)):V(``,!0),R(`span`,aT,E(e.enabled?`next ${f(e.nextRunAt)}`:`paused`),1)]),R(`code`,oT,E(e.cwd),1),e.lastError?(F(),I(`p`,sT,E(e.lastError.slice(0,160)),1)):V(``,!0),R(`div`,cT,[R(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>g(e)},[z(k(Xc),{size:12}),o[16]||=B(`run now`,-1)],8,lT),R(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>h(e)},[z(k(Qc),{size:12}),B(E(e.enabled?`pause`:`resume`),1)],8,uT),R(`button`,{class:`small danger`,disabled:n.value===e.id,onClick:t=>_(e)},[z(k(fl),{size:12}),o[17]||=B(`remove`,-1)],8,dT)])],2))),128))])):V(``,!0)]))}}),[[`__scopeId`,`data-v-7f6db3c9`]]),pT={class:`graph-panel`,"aria-label":`Task graphs`},mT={class:`panel-heading`},hT=[`disabled`],gT=[`disabled`],_T={key:0,class:`hint`},vT={key:1,class:`message-error`},yT={key:2,class:`hint`},bT={class:`row`},xT=[`disabled`],ST={class:`head`},CT=[`title`],wT=[`aria-label`,`disabled`,`onClick`],TT=[`aria-label`,`onClick`],ET={class:`tasks`},DT=[`title`],OT={key:0,class:`deps`},kT={class:`tag`},AT={key:1,class:`err`},jT=Ld(M({__name:`GraphPanel`,setup(e){let t=O([]),n=O({}),r=O(!1),i=O(``),a=O(``),o=O(!1),s=O(``),c=H(()=>G.value?.deviceId),l=()=>W(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){let t=e.code;i.value=t===`not_found`||/allowlist/i.test(lu(e))?"This device runs an older build: update it (`dpi update`) to run task-graphs.":lu(e).slice(0,160)}finally{r.value=!1}}j(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||q(`This graph has not run yet.`)}catch(e){q(lu(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},q(`Run started: ${Object.keys(t.tasks).length} tasks.`),p(e)}catch(e){q(lu(e).slice(0,140))}finally{a.value=``}}function h(e){K.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=``,q(`Graph "${n.name}" added (${n.tasks.length} tasks).`),await u()}catch(e){q(lu(e).slice(0,200))}finally{a.value=``}}}return(e,l)=>(F(),I(`section`,pT,[R(`header`,mT,[R(`span`,null,[z(k(ml),{size:16}),l[3]||=B(`DAG`,-1)]),R(`button`,{class:`icon-button`,disabled:r.value||!c.value,"aria-label":`Refresh graphs`,title:`Refresh`,onClick:u},[z(k(el),{size:15,class:T({spin:r.value})},null,8,[`class`])],8,hT),R(`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},[z(k(Zc),{size:15})],8,gT)]),l[7]||=R(`p`,{class:`hint`},`Tasks run on the device, in dependency order — one fresh session each.`,-1),c.value?i.value?(F(),I(`p`,vT,E(i.value),1)):!t.value.length&&!o.value?(F(),I(`p`,yT,` No graphs yet. Press + and paste a graph JSON ({ name, cwd, tasks: [{ id, name, prompt, dependsOn }] }). `)):V(``,!0):(F(),I(`p`,_T,`Select a session to see its device.`)),o.value?(F(),I(`form`,{key:3,class:`add-form`,onSubmit:As(g,[`prevent`])},[R(`label`,null,[l[4]||=B(`Graph JSON `,-1),A(R(`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),[[bs,s.value]])]),R(`div`,bT,[R(`button`,{class:`primary small`,type:`submit`,disabled:a.value===`new`},E(a.value===`new`?`adding…`:`Add graph`),9,xT),R(`button`,{class:`small`,type:`button`,onClick:l[2]||=e=>o.value=!1},`Cancel`)])],32)):V(``,!0),(F(!0),I(P,null,N(t.value,e=>(F(),I(`div`,{key:e.id,class:`graph`},[R(`div`,ST,[R(`b`,null,E(e.name),1),R(`code`,{class:`cwd`,title:e.cwd},E(e.cwd.split(`/`).filter(Boolean).at(-1)||e.cwd),9,CT),R(`span`,{class:T([`tag`,d[e.lastRun?.status??`pending`]??``])},E(e.lastRun?e.lastRun.status:`never run`),3),l[5]||=R(`span`,{class:`spacer`},null,-1),R(`button`,{class:`icon-button`,"aria-label":`Run ${e.name}`,title:`Run now`,disabled:a.value===e.id,onClick:t=>m(e)},[z(k(Xc),{size:14})],8,wT),R(`button`,{class:`icon-button`,"aria-label":`Remove ${e.name}`,title:`Remove graph`,onClick:t=>h(e)},[z(k(fl),{size:14})],8,TT)]),R(`ul`,ET,[(F(!0),I(P,null,N(e.tasks,t=>(F(),I(`li`,{key:t.id,class:T(d[f(e,t.id)])},[l[6]||=R(`span`,{class:`dot`,"aria-hidden":`true`},null,-1),R(`span`,{class:`name`,title:t.prompt},E(t.name),9,DT),t.dependsOn.length?(F(),I(`code`,OT,`← `+E(t.dependsOn.join(`, `)),1)):V(``,!0),R(`span`,kT,E(f(e,t.id)),1),n.value[e.id]?.tasks[t.id]?.error?(F(),I(`em`,AT,E(n.value[e.id].tasks[t.id].error.slice(0,120)),1)):V(``,!0)],2))),128))])]))),128))]))}}),[[`__scopeId`,`data-v-25093c69`]]),MT={class:`notify-panel`,"aria-label":`Notification sinks`},NT={class:`panel-heading`},PT=[`disabled`],FT=[`disabled`],IT=[`disabled`],LT={key:0,class:`hint`},RT={key:1,class:`message-error`},zT=[`placeholder`],BT={class:`row`},VT=[`disabled`],HT={key:3,class:`hint`},UT={key:4,class:`sink-list`},WT={class:`head`},GT={class:`tag`},KT={class:`next`},qT={class:`url`},JT={key:0,class:`hint`},YT={key:1,class:`message-error`},XT={class:`row`},ZT=[`disabled`,`onClick`],QT=[`disabled`,`onClick`],$T={key:5,class:`results`,"aria-label":`Test results`},eE={class:`tag`},tE={key:0},nE=Ld(M({__name:`NotifyPanel`,setup(e){let t=O([]),n=O(``),r=O(``),i=O(!1),a=O([]),o=H(()=>G.value?.deviceId),s=()=>W(o.value??``),c=O(!1),l=O({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){let t=e.code;r.value=t===`not_found`||/allowlist/i.test(lu(e))?"This device runs an older build: update it (`dpi update`) to use notifications.":lu(e).slice(0,160)}finally{i.value=!1}}j(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(),q(`Sink added on the device.`)}catch(e){q(lu(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){q(lu(e).slice(0,140))}finally{n.value=``}}function m(e){K.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;q(a.value.length?`Test: ${a.value.length-e} sent${e?`, ${e} failed`:``}.`:`No enabled sinks matched — nothing was sent.`)}catch(e){q(lu(e).slice(0,160))}finally{n.value=``}}return(e,s)=>(F(),I(`section`,MT,[R(`header`,NT,[R(`span`,null,[z(k(Zs),{size:16}),s[6]||=B(`NOTIFY`,-1)]),R(`button`,{class:`icon-button`,disabled:i.value||!o.value,"aria-label":`Refresh sinks`,title:`Refresh sinks`,onClick:u},[z(k(el),{size:15,class:T({spin:i.value})},null,8,[`class`])],8,PT),R(`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},[z(k(rl),{size:15})],8,FT),R(`button`,{class:`icon-button`,disabled:!o.value,"aria-label":`Add a sink`,title:`Add a sink`,onClick:s[0]||=e=>c.value=!c.value},[z(k(Zc),{size:15})],8,IT)]),s[14]||=R(`p`,{class:`hint`},`Delivered by the device — no browser needs to be open.`,-1),o.value?r.value?(F(),I(`p`,RT,E(r.value),1)):V(``,!0):(F(),I(`p`,LT,`Select a session to see its device.`)),c.value?(F(),I(`form`,{key:2,class:`add-form`,onSubmit:As(f,[`prevent`])},[R(`label`,null,[s[8]||=B(`Kind `,-1),A(R(`select`,{"onUpdate:modelValue":s[1]||=e=>l.value.kind=e},[...s[7]||=[R(`option`,{value:`webhook`},`webhook (JSON POST)`,-1),R(`option`,{value:`ntfy`},`ntfy (topic)`,-1)]],512),[[Cs,l.value.kind]])]),R(`label`,null,[s[9]||=B(`URL `,-1),A(R(`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,zT),[[bs,l.value.url]])]),R(`label`,null,[s[10]||=B(`Label`,-1),A(R(`input`,{"onUpdate:modelValue":s[3]||=e=>l.value.label=e,placeholder:`phone`},null,512),[[bs,l.value.label]])]),R(`label`,null,[s[11]||=B(`Events `,-1),A(R(`input`,{"onUpdate:modelValue":s[4]||=e=>l.value.events=e,placeholder:`empty = all — e.g. session.failed,schedule.*`},null,512),[[bs,l.value.events]])]),R(`div`,BT,[R(`button`,{class:`primary small`,type:`submit`,disabled:n.value===`new`},E(n.value===`new`?`adding…`:`Add sink`),9,VT),R(`button`,{class:`small`,type:`button`,onClick:s[5]||=e=>c.value=!1},`Cancel`)]),s[12]||=R(`p`,{class:`hint`},[B(`LAN targets (192.168.x, localhost) need `),R(`code`,null,`DPI_NOTIFY_ALLOW_PRIVATE=1`),B(` on the device.`)],-1)],32)):V(``,!0),!c.value&&!t.value.length&&o.value&&!r.value?(F(),I(`p`,HT,` No sinks yet. Press + to add a webhook or an ntfy topic. `)):V(``,!0),t.value.length?(F(),I(`ul`,UT,[(F(!0),I(P,null,N(t.value,e=>(F(),I(`li`,{key:e.id,class:T([`sink`,{off:!e.enabled}])},[R(`div`,WT,[R(`span`,GT,E(e.kind),1),R(`b`,null,E(e.label||e.url),1),R(`em`,KT,E(e.lastError?`last failed`:`sent ${d(e.lastDeliveryAt)}`),1)]),R(`code`,qT,E(e.url),1),e.events?.length?(F(),I(`p`,JT,`events: `+E(e.events.join(`, `)),1)):V(``,!0),e.lastError?(F(),I(`p`,YT,E(e.lastError.slice(0,160)),1)):V(``,!0),R(`div`,XT,[R(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>p(e)},[z(k(Qc),{size:12}),B(E(e.enabled?`disable`:`enable`),1)],8,ZT),R(`button`,{class:`small danger`,disabled:n.value===e.id,onClick:t=>m(e)},[z(k(fl),{size:12}),s[13]||=B(`remove`,-1)],8,QT)])],2))),128))])):V(``,!0),a.value.length?(F(),I(`ul`,$T,[(F(!0),I(P,null,N(a.value,e=>(F(),I(`li`,{key:e.id,class:T(e.status)},[R(`span`,eE,E(e.status),1),B(` `+E(e.kind)+` `+E(e.id.slice(0,8))+` `,1),e.detail?(F(),I(`em`,tE,E(e.detail),1)):V(``,!0)],2))),128))])):V(``,!0)]))}}),[[`__scopeId`,`data-v-4b0b0465`]]),rE={class:`env-panel`,"aria-label":`Device environment`},iE={class:`panel-heading`},aE=[`disabled`],oE=[`disabled`],sE={key:0,class:`hint`},cE={key:1,class:`message-error`},lE={key:2,class:`message-restart`},uE={class:`row`},dE=[`disabled`],fE={key:4,class:`hint`},pE={key:5,class:`var-list`},mE={class:`head`},hE={class:`key`},gE={class:`tag`},_E={key:0,class:`tag`,title:`Has its own setting; edit that instead`},vE=[`aria-label`,`title`,`onClick`],yE=[`aria-label`,`onClick`],bE=[`title`],xE={key:6,class:`hint path`},SE=Ld(M({__name:`EnvPanel`,setup(e){let t=O(null),n=O(!1),r=O(``),i=O(``),a=H(()=>G.value?.deviceId),o=()=>W(a.value??``),s=O(!1),c=O({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){let t=lu(e);r.value=e.code===`not_found`||/allowlist/i.test(t)?"This device runs an older build: update it (`dpi update`) to edit env vars.":t.slice(0,160)}finally{n.value=!1}}j(a,l,{immediate:!0});let u=e=>e.source===`file`&&!e.managed;async function d(){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(),q(`${e} saved — restart the device to apply it.`)}catch(e){q(lu(e).slice(0,160))}finally{i.value=``}}}function f(e){K.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(),q(`${e.key} saved — restart the device to apply it.`)}}}function p(e){K.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(),q(`${e.key} removed — restart the device to apply it.`)}}}return(e,o)=>(F(),I(`section`,rE,[R(`header`,iE,[R(`span`,null,[z(k(_c),{size:16}),o[4]||=B(`ENV`,-1)]),R(`button`,{class:`icon-button`,disabled:n.value||!a.value,"aria-label":`Refresh env`,title:`Refresh`,onClick:l},[z(k(el),{size:15,class:T({spin:n.value})},null,8,[`class`])],8,aE),R(`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},[z(k(Zc),{size:15})],8,oE)]),o[10]||=R(`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?(F(),I(`p`,cE,E(r.value),1)):t.value?.restartRequired?(F(),I(`p`,lE,[...o[5]||=[B(` Changed since boot — restart the device (`,-1),R(`code`,null,`dpi device stop && dpi device start`,-1),B(`) to apply. `,-1)]])):V(``,!0):(F(),I(`p`,sE,`Select a session to see its device.`)),s.value?(F(),I(`form`,{key:3,class:`add-form`,onSubmit:As(d,[`prevent`])},[R(`label`,null,[o[6]||=B(`Key (UPPER_SNAKE_CASE)`,-1),A(R(`input`,{"onUpdate:modelValue":o[1]||=e=>c.value.key=e,placeholder:`DPI_NOTIFY_ALLOW_PRIVATE`,required:``},null,512),[[bs,c.value.key]])]),R(`label`,null,[o[7]||=B(`Value`,-1),A(R(`input`,{"onUpdate:modelValue":o[2]||=e=>c.value.value=e,placeholder:`1`,required:``},null,512),[[bs,c.value.value]])]),R(`div`,uE,[R(`button`,{class:`primary small`,type:`submit`,disabled:i.value===`new`},E(i.value===`new`?`saving…`:`Save to env file`),9,dE),R(`button`,{class:`small`,type:`button`,onClick:o[3]||=e=>s.value=!1},`Cancel`)]),o[8]||=R(`p`,{class:`hint`},` Managed keys (DPI_TOKEN, DPI_PORT, start dirs…) have their own settings and are refused here. `,-1)],32)):V(``,!0),!s.value&&t.value&&!t.value.vars.length&&!r.value?(F(),I(`p`,fE,` No vars in the env file yet. `)):V(``,!0),t.value?.vars.length?(F(),I(`ul`,pE,[(F(!0),I(P,null,N(t.value.vars,e=>(F(),I(`li`,{key:e.key,class:T([`var`,{ro:!u(e)}])},[R(`div`,mE,[R(`code`,hE,E(e.key),1),R(`span`,gE,E(e.source===`process`?`process`:`file`),1),e.managed?(F(),I(`span`,_E,`managed`)):V(``,!0),o[9]||=R(`span`,{class:`spacer`},null,-1),u(e)?(F(),I(`button`,{key:1,class:`icon-button`,"aria-label":`Edit ${e.key}`,title:e.secret?`Replace the value`:`Edit the value`,onClick:t=>f(e)},[z(k(Jc),{size:13})],8,vE)):V(``,!0),u(e)?(F(),I(`button`,{key:2,class:`icon-button`,"aria-label":`Remove ${e.key}`,title:`Remove from the env file`,onClick:t=>p(e)},[z(k(fl),{size:13})],8,yE)):V(``,!0)]),R(`code`,{class:`value`,title:e.secret?`secret — masked`:e.masked},E(e.masked),9,bE)],2))),128))])):V(``,!0),t.value?(F(),I(`p`,xE,E(t.value.envFile),1)):V(``,!0)]))}}),[[`__scopeId`,`data-v-3c11d19f`]]),CE={class:`extensions-panel`},wE={class:`panel-heading`},TE={key:0,class:`task-empty`},EE=[`data-extension`],DE={class:`ext-head`},OE=[`aria-checked`,`aria-label`,`disabled`,`onClick`],kE=[`checked`,`disabled`,`onChange`],AE=M({__name:`ExtensionsPanel`,setup(e){let t=an(),n=O(!1);async function r(){let e=Iu.value;if(!e||!Au.value)return void(t.value=void 0);t.value=await e.extensions().catch(()=>void 0)??t.value}j([Iu,Au,()=>JSON.stringify(Ku.value.agent.extensions??null)],r,{immediate:!0});async function i(e){let r=Iu.value;if(r&&!n.value){n.value=!0;try{let n=await od(()=>r.setExtension(e));n&&(t.value=n),td()}finally{n.value=!1}}}return(e,r)=>(F(),I(`div`,CE,[R(`div`,wE,[r[0]||=R(`h2`,null,`Extensions`,-1),z(k($c),{size:18})]),r[3]||=R(`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?V(``,!0):(F(),I(`p`,TE,`Loading extensions…`)),(F(!0),I(P,null,N(t.value?.extensions??[],e=>(F(),I(`article`,{key:e.name,class:T([`ext-card`,{on:e.enabled}]),"data-extension":e.name},[R(`div`,DE,[R(`div`,null,[R(`strong`,null,E(e.title),1),R(`code`,null,E(e.name),1)]),R(`button`,{class:T([`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]||=[R(`span`,null,null,-1)]],10,OE)]),R(`p`,null,E(e.description),1),e.prompts?(F(),I(`ul`,{key:0,class:T([`ext-prompts`,{off:!e.enabled}])},[(F(!0),I(P,null,N(e.prompts,e=>(F(),I(`li`,{key:e.id},[R(`label`,null,[R(`input`,{type:`checkbox`,checked:e.enabled,disabled:n.value,onChange:t=>i({prompt:e.id,enabled:t.target.checked})},null,40,kE),R(`code`,null,E(e.id),1)]),R(`span`,null,E(e.description),1),R(`details`,null,[r[2]||=R(`summary`,null,`View prompt`,-1),R(`pre`,null,E(e.text),1)])]))),128))],2)):V(``,!0)],10,EE))),128))]))}}),jE={class:`context-section`,"aria-labelledby":`context-title`},ME={class:`section-label`},NE={key:0,class:`hint`},PE={class:`context-numbers`},FE={class:`context-pct`},IE={key:0,class:`context-compacting`},LE=[`aria-valuemax`,`aria-valuenow`,`aria-valuetext`],RE={class:`context-marker-label`},zE=[`aria-valuemin`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`],BE={class:`context-marker-label`},VE={class:`hint context-hint`},HE={class:`modal compaction-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`compaction-title`},UE={class:`context-toggle`},WE=[`checked`],GE=512,KE=4096,qE=1024,JE=M({__name:`ContextBar`,setup(e){let t=e=>e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e),n=H(()=>Qu.value?.contextWindow??0),r=H(()=>{let e=Ku.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}),i=H(()=>Ku.value.compactions.length>0),a=O(),o=H(()=>a.value??Pu.value?.compaction??ov(n.value));j(()=>JSON.stringify(Pu.value?.compaction),e=>{a.value&&e===JSON.stringify(a.value)&&(a.value=void 0)});let s=O(),c=H(()=>K.dialog?.kind===`compaction`),l=()=>void(K.dialog=void 0);Kr(()=>c.value&&l());let u=H(()=>s.value??sv(n.value,o.value)),d=e=>`${Math.min(100,Math.max(0,100*e/(n.value||1)))}%`,f=H(()=>Math.round(100*r.value/(n.value||1))),p=e=>{let t=e/(n.value||1);return t<.35?`start`:t>.65?`end`:`center`},m=(e,t)=>Math.min(n.value-qE,Math.max((t??KE)+qE,e)),h=(e,t)=>Math.min(t-qE,Math.max(KE,e));function g(e,t){let n=u.value,r=Math.round(t/GE)*GE;s.value=e===`wait`?{auto:n.auto,wait:m(r,n.auto)}:{auto:h(r,n.wait),wait:n.wait}}async function _(e){let t=Lu.value;if(!t)return;let n=await od(()=>t.setCompaction(e));n&&(a.value=n),s.value=void 0}function v(){let e=s.value;e&&_({reserveTokens:n.value-e.wait,...e.auto===void 0?{}:{backgroundTokens:e.wait-e.auto}})}let y=O(),b;function ee(e,t){b=e,t.currentTarget.setPointerCapture(t.pointerId)}function x(e){if(!b||!y.value)return;let t=y.value.getBoundingClientRect();g(b,(e.clientX-t.left)/t.width*n.value)}function S(){b&&(b=void 0,v())}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=u.value;g(e,(e===`auto`?r.auto??KE:r.wait)+n)}return(e,a)=>(F(),I(P,null,[R(`section`,jE,[R(`div`,ME,[a[7]||=R(`span`,{id:`context-title`},`CONTEXT`,-1),n.value?(F(),I(`button`,{key:0,class:`context-details-toggle`,onClick:a[0]||=e=>k(K).dialog={kind:`compaction`}},[z(k(kc),{size:16}),a[6]||=B(`Details `,-1)])):V(``,!0)]),n.value?(F(),I(P,{key:1},[R(`div`,PE,[R(`strong`,null,E(t(r.value)),1),R(`span`,null,`of `+E(t(n.value))+` tokens`,1),R(`span`,FE,E(f.value)+`%`,1),i.value?(F(),I(`span`,IE,[...a[8]||=[R(`i`,null,null,-1),B(`Compacting`,-1)]])):V(``,!0)]),R(`div`,{ref_key:`bar`,ref:y,class:T([`context-bar`,{off:!o.value.enabled}]),onPointermove:x,onPointerup:S,onPointercancel:S},[R(`div`,{class:T([`context-fill`,{hot:u.value.auto!==void 0&&r.value>=u.value.auto}]),style:_e({width:d(r.value)})},null,6),R(`div`,{class:`context-reserve`,style:_e({left:d(u.value.wait)}),title:`Reserved for the answer`},null,4),u.value.auto===void 0?V(``,!0):(F(),I(`button`,{key:0,class:T([`context-marker auto`,`label-${p(u.value.auto)}`]),role:`slider`,"aria-label":`Automatic compaction starts at`,"aria-valuemin":KE,"aria-valuemax":u.value.wait-qE,"aria-valuenow":u.value.auto,"aria-valuetext":`${t(u.value.auto)} tokens`,style:_e({left:d(u.value.auto)}),onPointerdown:a[1]||=e=>ee(`auto`,e),onKeydown:a[2]||=e=>te(`auto`,e),onKeyup:v,onBlur:v},[R(`span`,RE,`Auto-compact at `+E(t(u.value.auto)),1)],46,LE)),R(`button`,{class:T([`context-marker wait`,`label-${p(u.value.wait)}`]),role:`slider`,"aria-label":`The next request waits for a summary at`,"aria-valuemin":(u.value.auto??KE)+qE,"aria-valuemax":n.value-qE,"aria-valuenow":u.value.wait,"aria-valuetext":`${t(u.value.wait)} tokens, ${t(n.value-u.value.wait)} reserved`,style:_e({left:d(u.value.wait)}),onPointerdown:a[3]||=e=>ee(`wait`,e),onKeydown:a[4]||=e=>te(`wait`,e),onKeyup:v,onBlur:v},[R(`span`,BE,`Reserve at `+E(t(u.value.wait)),1)],46,zE)],34),R(`p`,VE,[o.value.enabled?(F(),I(P,{key:0},[a[9]||=B(`Compacts in the background at `,-1),R(`strong`,null,E(t(u.value.auto??u.value.wait)),1),a[10]||=B(` and waits at `,-1),R(`strong`,null,E(t(u.value.wait)),1),a[11]||=B(`.`,-1)],64)):(F(),I(P,{key:1},[B(`Automatic compaction is off.`)],64))])],64)):(F(),I(`div`,NE,`Pick a model to see its context window.`))]),(F(),L(ur,{to:`body`},[c.value?(F(),I(`div`,{key:0,class:`modal-backdrop`,onClick:As(l,[`self`])},[R(`section`,HE,[R(`header`,null,[a[12]||=R(`h2`,{id:`compaction-title`},`Context compaction`,-1),R(`button`,{class:`icon-button`,"aria-label":`Close context compaction`,onClick:l},[z(k(yl),{size:18})])]),R(`p`,null,[a[13]||=B(` A summary starts in the background at `,-1),R(`strong`,null,E(t(u.value.auto??u.value.wait)),1),a[14]||=B(`. Above `,-1),R(`strong`,null,E(t(u.value.wait)),1),B(` the next request waits for it, keeping `+E(t(n.value-u.value.wait))+` free for the answer. Drag a marker on the bar to change either point. `,1)]),a[16]||=R(`p`,null,[B(`Older entries stay stored, and `),R(`code`,null,`search_history`),B(` still finds them.`)],-1),R(`label`,UE,[R(`input`,{type:`checkbox`,checked:o.value.enabled,onChange:a[5]||=e=>_({enabled:e.target.checked})},null,40,WE),a[15]||=B(` Automatic compaction `,-1)]),a[17]||=R(`p`,{class:`hint`},[B(` Applies to every agent in this session. `),R(`code`,null,`/compact`),B(` works either way. `)],-1),R(`footer`,null,[R(`button`,{class:`secondary`,onClick:l},`Close`)])])])):V(``,!0)]))],64))}}),YE=/^[A-Za-z_$][\w$]*$/,XE=e=>` `.repeat(e);function ZE(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`),QE(t,0,r),r(`): `,`punct`),r(`Promise`,`type`),r(`<`,`punct`),r(`ToolResult`,`type`),r(`>;`,`punct`),n}function QE(e,t,n){if(!e||typeof e!=`object`)return n(`unknown`,`type`);if(`const`in e)return tD(e.const,n);if(e.enum)return eD(e.enum.map(e=>({const:e})),t,n);if(e.anyOf??e.oneOf)return eD(e.anyOf??e.oneOf,t,n);if(Array.isArray(e.type))return eD(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`),QE(e.items,t,n),r&&n(`)`,`punct`),n(`[]`,`punct`)}case`object`:return $E(e,t,n);default:return n(`unknown`,`type`)}}function $E(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`),QE(e.additionalProperties,t,n),n(`>`,`punct`)):n(`{}`,`punct`);let i=new Set(e.required??[]);n(`{`,`punct`),n(`
|
|
80
|
-
`);for(let[e,a]of r){let r=
|
|
81
|
-
`)}n(XE(t)),n(`}`,`punct`)}function eD(e,t,n){e.forEach((e,r)=>{r&&n(` | `,`punct`),QE(e,t,n)})}function tD(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 nD(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 rD={key:0,class:`panel-rail`,"aria-label":`Inspector (collapsed)`},iD=[`title`],aD=[`aria-label`,`title`,`onClick`],oD={key:0,class:`count`},sD={class:`inspector-tabs`,role:`tablist`,"aria-label":`Session details`},cD=[`id`,`aria-selected`,`onClick`],lD={key:0,class:`count`},uD=[`title`],dD=[`aria-labelledby`],fD={class:`session-heading`},pD=[`disabled`],mD=[`disabled`],hD=[`title`],gD={class:`cwd-trail`,dir:`rtl`},_D={dir:`ltr`},vD={class:`session-status`},yD={key:0,class:`background-pill`},bD=[`title`],xD={class:`model-section`},SD=[`src`],CD={class:`thinking-row`},wD=[`value`],TD={class:`stats-section`,"aria-labelledby":`stats-title`},ED={class:`metrics`},DD=[`title`],OD={class:`usage-breakdown`,"aria-label":`Agent token and cost breakdown`},kD={scope:`row`},AD={class:`usage-total`},jD={class:`panel-heading`},MD={class:`hint app-state-description`},ND=[`disabled`],PD={class:`state-json-actions`},FD={key:0,class:`hint`},ID=[`disabled`],LD=[`disabled`],RD={key:0,class:`message-error`,role:`alert`},zD={class:`panel-heading`},BD={class:`tag`},VD={class:`hook-card`},HD=[`aria-checked`],UD={key:0,class:`tag tool-disabled`},WD={class:`tag`},GD=[`aria-label`],KD=Ld(M({__name:`Inspector`,setup(e){let t=H(()=>new Map($u.value?.tools.map(e=>[e.name,ZE(e.name,e.parameters)]))),n=[{id:`session`,label:`Session`,icon:bc},{id:`git`,label:`Git`,icon:Sc},{id:`host`,label:`Host`,icon:Hs},{id:`usage`,label:`Usage`,icon:Yc},{id:`auto`,label:`Auto`,icon:tc},{id:`dag`,label:`DAG`,icon:ml},{id:`notify`,label:`Notify`,icon:Zs},{id:`env`,label:`Env`,icon:_c},{id:`state`,label:`State`,icon:$s},{id:`tasks`,label:`Tasks`,icon:Hs},{id:`tools`,label:`Tools`,icon:vl},{id:`extensions`,label:`Extend`,icon:$c}],r=H(()=>[{label:`Input`,tokens:Zu.value.input,cost:Zu.value.inputCost},{label:`Output`,tokens:Zu.value.output,cost:Zu.value.outputCost},{label:`Cache read`,tokens:Zu.value.cacheRead,cost:Zu.value.cacheReadCost},{label:`Cache write`,tokens:Zu.value.cacheWrite,cost:Zu.value.cacheWriteCost}]),i=H(()=>Yu.value.filter(e=>e.background).length),a=O(!1);function o(e,t){od(async()=>{await Iu.value.configure(e),await td(),t&&q(t)})}async function s(){let e=ku.value,t=Pu.value;if(e&&t)try{let n=await W(e.id).agent(t.id,G.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),q(`Transcript downloaded.`)}catch(e){q(`transcript download failed: ${lu(e).slice(0,120)}`)}}async function c(){let e=ku.value,t=Pu.value;if(e&&t){a.value=!0;try{let n=await W(e.id).exportSession(t.id),r=Uint8Array.from(atob(n.base64),e=>e.charCodeAt(0)),i=URL.createObjectURL(new Blob([r],{type:n.mime||`application/zip`})),a=document.createElement(`a`);a.href=i,a.download=n.filename,a.click(),URL.revokeObjectURL(i),q(`Bundle downloaded (${Math.max(1,Math.round(n.bytes/1024))} KiB).`)}catch(e){q(`bundle export failed: ${lu(e).slice(0,120)}`)}finally{a.value=!1}}}let l=O(!1);function u(){let e=ku.value,t=Pu.value;e&&t&&!l.value&&(K.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()=>{l.value=!0;try{let n=W(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 cu.createShare({title:`${t.name} · ${e.name}`,agents:i}),o=`${location.origin}${a.url}`;await navigator.clipboard?.writeText(o).catch(()=>{}),q(`Share link copied — expires ${a.expiresAt.slice(0,10)}.`)}catch(e){q(`share failed: ${lu(e).slice(0,140)}`)}finally{l.value=!1}}})}function d(){let e=Lu.value;e&&(K.dialog={kind:`prompt`,title:`Rename session`,label:`Session name`,value:Pu.value?.name??``,submit:`Save name`,run:t=>e.rename(t)})}let f=Nu.sharedState,p=O(``),m=O(``),h=O(0),g=O(!1),_=O(``),v=H(()=>p.value!==m.value),y=H(()=>v.value&&f.value?.revision!==h.value);function b(){p.value=ld(f.value?.value??{}),m.value=p.value,h.value=f.value?.revision??0,_.value=``}j(f,()=>!v.value&&b(),{immediate:!0});async function ee(e){if(!g.value&&Iu.value){g.value=!0,_.value=``;try{await Iu.value.demo(`state`,e)}catch(e){_.value=lu(e)}finally{g.value=!1}}}async function x(){if(!g.value&&Iu.value){_.value=``,g.value=!0;try{let e=JSON.parse(p.value);if(!e||Array.isArray(e)||typeof e!=`object`)throw Error(`App State must be a JSON object.`);let t=await Iu.value.demo(`state`,{operation:`update`,path:``,value:e,expectedRevision:h.value});p.value=ld(t.value),m.value=p.value,h.value=t.revision,q(`Shared App State saved.`)}catch(e){_.value=lu(e)}finally{g.value=!1}}}let S=H(()=>$u.value?.config.readOnly===!0),te=H(()=>$u.value?.tools.filter(e=>e.offered).length??0);return(e,m)=>{let h=Qr(`Share2`);return F(),I(`aside`,{class:T([`inspector`,{collapsed:!k(gd),overlay:k(K).inspectorOverlay}])},[k(gd)?(F(),I(P,{key:1},[R(`div`,sD,[(F(),I(P,null,N(n,e=>R(`button`,{id:`inspector-tab-${e.id}`,key:e.id,role:`tab`,"aria-controls":`inspector-panel`,"aria-selected":k(K).tab===e.id,class:T({active:k(K).tab===e.id}),onClick:t=>k(K).tab=e.id},[(F(),L(ei(e.icon),{size:18})),B(E(e.label),1),e.id===`tasks`&&k(Yu).length?(F(),I(`span`,lD,E(k(Yu).length),1)):V(``,!0)],10,cD)),64)),R(`button`,{class:`icon-button panel-toggle`,"aria-label":`Collapse inspector`,title:`Collapse inspector (${k(Sd).inspector})`,onClick:m[1]||=e=>k(vd)()},[z(k(Wc),{size:18})],8,uD)]),R(`div`,{id:`inspector-panel`,class:T([`inspector-body`,{"session-panel":k(K).tab===`session`}]),role:`tabpanel`,"aria-labelledby":`inspector-tab-${k(K).tab}`},[k(K).tab===`session`?(F(),I(P,{key:0},[R(`section`,fD,[R(`h1`,null,[R(`span`,null,E(k(Pu)?.name??`Loading session`),1),R(`button`,{class:`icon-button`,title:`Rename session`,"aria-label":`Rename session`,onClick:d},[z(k(Jc),{size:18})]),R(`button`,{class:`icon-button`,title:`Download transcript (markdown)`,"aria-label":`Download transcript`,onClick:s},[z(k(mc),{size:18})]),R(`button`,{class:`icon-button`,title:`Download session bundle (.zip: manifest, transcripts, configs)`,"aria-label":`Download session bundle`,disabled:a.value,onClick:c},[z(k(Uc),{size:18})],8,pD),R(`button`,{class:`icon-button`,title:`Share a public read-only link to this transcript`,"aria-label":`Share transcript`,disabled:l.value,onClick:u},[z(h,{size:18})],8,mD)]),R(`button`,{class:`path cwd-button`,title:k(Pu)?.cwd,"aria-label":`Show full working directory`,onClick:m[2]||=e=>k(K).dialog={kind:`path`,path:k(Pu)?.cwd??``}},[z(k(bc),{size:18}),R(`span`,gD,[R(`bdi`,_D,E(k(Pu)?.cwd),1)])],8,hD),R(`div`,vD,[R(`span`,{class:T([`status-pill`,{working:k(Xu)}])},[m[7]||=R(`i`,null,null,-1),B(E(k(Xu)?`Working`:`Idle`),1)],2),i.value?(F(),I(`span`,yD,E(i.value)+` background`,1)):V(``,!0),R(`span`,{class:`saved`,title:k(ku)?.id},[z(k(il),{size:18}),B(E(k(ku)?.name??k(ku)?.id),1)],8,bD),k(ku)?(F(),L(zy,{key:1,device:k(ku)},null,8,[`device`])):V(``,!0)])]),k(ku)?(F(),L(nb,{key:0,device:k(ku)},null,8,[`device`])):V(``,!0),R(`section`,xD,[m[15]||=R(`div`,{class:`section-label`},[R(`span`,null,`AGENT`)],-1),R(`button`,{class:`model-button`,onClick:m[3]||=e=>k(K).dialog={kind:`models`}},[R(`img`,{src:k(ud)(k(Ku).agent.model?.modelId),alt:``},null,8,SD),R(`div`,null,[R(`strong`,null,E(k(Qu)?.name??k(Ku).agent.model?.modelId??`Loading…`),1),R(`small`,null,E(k(Qu)?.tier??``)+` / `+E(k(Ku).agent.model?.provider??``),1)]),z(k(rc),{size:18})]),R(`div`,CD,[m[8]||=R(`span`,null,`Thinking`,-1),R(`select`,{"aria-label":`Thinking level`,value:k(Ku).agent.thinkingLevel??`low`,onChange:m[4]||=e=>o({thinkingLevel:e.target.value},`Thinking ${e.target.value}. Used on the next turn.`)},[(F(!0),I(P,null,N(k(rv),e=>(F(),I(`option`,{key:e},E(e),1))),128))],40,wD)]),z(JE),R(`section`,TD,[m[14]||=R(`div`,{class:`section-label`},[R(`span`,{id:`stats-title`},`STATS`)],-1),R(`div`,ED,[R(`div`,{title:`${k(Zu).tokens.toLocaleString(`en-US`)} total tokens`},[R(`span`,null,E(k(cd)(k(Zu).tokens)),1),m[9]||=R(`small`,null,`total tokens`,-1)],8,DD),R(`div`,null,[R(`span`,null,`$`+E(k(Zu).cost.toFixed(4)),1),m[10]||=R(`small`,null,`agent cost`,-1)]),R(`div`,null,[R(`span`,null,E(k($u)?.tools.length??0),1),m[11]||=R(`small`,null,`tools`,-1)])]),R(`table`,OD,[m[13]||=R(`thead`,null,[R(`tr`,null,[R(`th`,{scope:`col`},`Type`),R(`th`,{scope:`col`},`Tokens`),R(`th`,{scope:`col`},`Cost (USD)`)])],-1),R(`tbody`,null,[(F(!0),I(P,null,N(r.value,e=>(F(),I(`tr`,{key:e.label},[R(`th`,kD,E(e.label),1),R(`td`,null,E(e.tokens.toLocaleString(`en-US`)),1),R(`td`,null,`$`+E(e.cost.toFixed(4)),1)]))),128)),R(`tr`,AD,[m[12]||=R(`th`,{scope:`row`},`Total`,-1),R(`td`,null,E(k(Zu).tokens.toLocaleString(`en-US`)),1),R(`td`,null,`$`+E(k(Zu).cost.toFixed(4)),1)])])])])])],64)):V(``,!0),k(K).tab===`state`?(F(),I(P,{key:1},[R(`div`,jD,[m[16]||=R(`h2`,null,`App State`,-1),z(k($s),{size:18})]),R(`p`,MD,` One shared JSON object for every agent, session and fork on `+E(k(ku)?.name??k(ku)?.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),A(R(`textarea`,{"onUpdate:modelValue":m[5]||=e=>p.value=e,class:`app-state-json`,"aria-label":`App State JSON`,spellcheck:`false`,disabled:g.value||!k(f),rows:`12`},null,8,ND),[[bs,p.value]]),R(`div`,PD,[y.value?(F(),I(`span`,FD,`State changed elsewhere. Load the latest JSON before saving.`)):V(``,!0),v.value?(F(),I(`button`,{key:1,class:`secondary`,disabled:g.value,onClick:b},E(y.value?`Load latest`:`Reset`),9,ID)):V(``,!0),R(`button`,{class:`primary small`,disabled:!v.value||g.value||y.value,onClick:x},E(g.value?`Saving…`:`Save JSON`),9,LD)]),_.value?(F(),I(`p`,RD,E(_.value),1)):V(``,!0),z(Ny,{value:k(f)?.value??{},disabled:g.value||v.value||!k(f),onChange:ee},null,8,[`value`,`disabled`])],64)):V(``,!0),k(K).tab===`tasks`?(F(),L(Nb,{key:2})):V(``,!0),k(K).tab===`git`?(F(),L(EC,{key:3})):V(``,!0),k(K).tab===`host`?(F(),L(YC,{key:4})):V(``,!0),k(K).tab===`usage`?(F(),L(Rw,{key:5})):V(``,!0),k(K).tab===`auto`?(F(),L(fT,{key:6})):V(``,!0),k(K).tab===`dag`?(F(),L(jT,{key:7})):V(``,!0),k(K).tab===`notify`?(F(),L(nE,{key:8})):V(``,!0),k(K).tab===`env`?(F(),L(SE,{key:9})):V(``,!0),k(K).tab===`extensions`?(F(),L(AE,{key:10})):V(``,!0),k(K).tab===`tools`?(F(),I(P,{key:11},[R(`div`,zD,[m[17]||=R(`h2`,null,`Tools`,-1),R(`span`,BD,E(te.value)+` / `+E(k($u)?.tools.length??0),1)]),m[21]||=R(`p`,{class:`hint`},` Every tool this agent's extensions provide. Open one to see its definition. `,-1),R(`div`,VD,[R(`div`,null,[z(k(ol),{size:18}),m[19]||=R(`strong`,null,`Read only`,-1),R(`button`,{class:T([`switch`,{on:S.value}]),role:`switch`,"aria-checked":S.value,"aria-label":`Read only`,onClick:m[6]||=e=>o({readOnly:!S.value},S.value?`Read only off. Every tool is back.`:`Read only on. Tools that write are disabled.`)},[...m[18]||=[R(`span`,null,null,-1)]],10,HD)]),m[20]||=R(`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)]),(F(!0),I(P,null,N(k($u)?.tools,e=>(F(),I(`details`,{key:e.name,class:T([`tool-row`,{disabled:!e.offered}])},[R(`summary`,null,[z(k(vl),{size:18}),R(`strong`,null,E(e.name),1),e.offered?V(``,!0):(F(),I(`span`,UD,`disabled`)),R(`span`,WD,E(e.replay===`safe`?`replay safe`:`interrupt on crash`),1)]),R(`p`,null,E(e.description),1),e.parameters?(F(),I(`pre`,{key:0,class:`tool-signature`,"aria-label":`${e.name} TypeScript definition`},[R(`code`,null,[(F(!0),I(P,null,N(t.value.get(e.name),(e,t)=>(F(),I(`span`,{key:t,class:T(`tk-${e.kind}`)},E(e.text),3))),128))])],8,GD)):V(``,!0),R(`small`,null,E(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)):V(``,!0)],10,dD)],64)):(F(),I(`div`,rD,[R(`button`,{class:`icon-button panel-toggle`,"aria-label":`Expand inspector`,title:`Expand inspector (${k(Sd).inspector})`,onClick:m[0]||=e=>k(_d)()},[z(k(Gc),{size:18})],8,iD),(F(),I(P,null,N(n,e=>R(`button`,{key:e.id,class:T([`rail-tab`,{active:k(K).tab===e.id}]),"aria-label":`Open ${e.label}`,title:e.label,onClick:t=>k(_d)(e.id)},[(F(),L(ei(e.icon),{size:20})),e.id===`tasks`&&k(Yu).length?(F(),I(`span`,oD,E(k(Yu).length),1)):V(``,!0)],10,aD)),64))]))],2)}}}),[[`__scopeId`,`data-v-7856a74f`]]),qD={class:`chat-empty`},JD={class:`eyebrow`},YD={key:3,class:`hint offline-error`},XD={key:4,class:`offline-command`},ZD={key:5,class:`hint`},QD={key:6,class:`hint`},$D={class:`offline-actions`},eO=[`disabled`],tO={key:7,class:`message-error`,role:`alert`},nO=M({__name:`OfflinePanel`,props:{device:{}},setup(e){let t=e,n=O(!1),r=O(``),i=H(()=>{let e=t.device,n=e.source===`config`;switch(e.status){case`checking`:return{title:`Checking ${e.id}…`,text:`Probing the device. This view fills in as soon as it answers.`};case`unauthorized`:return e.transport===`tunnel`?{title:`${e.id} tunnel credentials are not valid`,text:`Pair the device again — the hub will mint a fresh credential.`}:{title:e.hasToken?`${e.id} rejected its token`:`No token for ${e.id}`,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.id} 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.id} speaks another API version`,text:`Update the device's dpi-backend.`,command:n?`just net deploy ${e.id}`:void 0};default:return{title:`${e.id} is offline`,text:`Last seen ${dd(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 cu.check(t.device.id);e.status===`online`&&q(`${e.id} is online.`)}catch(e){r.value=lu(e)}finally{n.value=!1}}async function o(e){try{await navigator.clipboard.writeText(e),q(`Copied.`)}catch{q(`Clipboard needs localhost or HTTPS. Select the text to copy.`)}}return(t,s)=>(F(),I(`section`,{class:T([`chat-panel offline-panel`,e.device.status]),"aria-live":`polite`},[R(`div`,qD,[e.device.status===`checking`?(F(),L(k(Lc),{key:0,class:`spin`,size:30})):e.device.status===`mismatch`||e.device.status===`unauthorized`?(F(),L(k(al),{key:1,size:30})):(F(),L(k(hl),{key:2,size:30})),R(`span`,JD,E(e.device.kind.toUpperCase())+` · `+E(e.device.url??(e.device.transport===`tunnel`?`tunnel`:`no endpoint`)),1),R(`h2`,null,E(i.value.title),1),R(`p`,null,E(i.value.text),1),e.device.error?(F(),I(`p`,YD,E(e.device.error),1)):V(``,!0),i.value.command?(F(),I(`div`,XD,[R(`code`,null,E(i.value.command),1),R(`button`,{class:`icon-button`,"aria-label":`Copy command`,onClick:s[0]||=e=>o(i.value.command)},[z(k(cc),{size:18})])])):V(``,!0),i.value.command?(F(),I(`p`,ZD,`Run it in this repo's terminal, then press Check now.`)):V(``,!0),i.value.alt?(F(),I(`p`,QD,[s[2]||=B(` Never deployed or rebuilt? `,-1),R(`code`,null,E(i.value.alt),1),s[3]||=B(` provisions it from scratch. `,-1)])):V(``,!0),R(`div`,$D,[R(`button`,{class:`secondary`,disabled:n.value,onClick:s[1]||=e=>a()},[z(k(el),{size:18}),B(E(n.value?`Checking…`:`Check now`),1)],8,eO)]),r.value?(F(),I(`p`,tO,E(r.value),1)):V(``,!0)])],2))}}),rO={class:`dir-browser`},iO={class:`dir-path`},aO=[`disabled`],oO=[`aria-busy`],sO=[`title`],cO=[`aria-selected`,`title`,`onClick`],lO={key:1,class:`hint`},uO={key:0,class:`message-error`,role:`alert`},dO=M({__name:`DirBrowser`,props:ci({deviceId:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=Oi(e,`modelValue`),r=O(),i=O(!1),a=O(``),o=0;async function s(e){let s=++o,c=t.deviceId;i.value=!0,a.value=``;try{let t=await W(c).dirs(e);return s===o?(r.value=t,t.path&&(n.value=t.path),t):void 0}catch(e){s===o&&(a.value=lu(e));return}finally{s===o&&(i.value=!1)}}return j(()=>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)=>(F(),I(`div`,rO,[R(`div`,iO,[A(R(`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]||=Ms(As(e=>s(n.value),[`prevent`]),[`enter`])},null,544),[[bs,n.value]]),R(`button`,{type:`button`,class:`secondary small`,disabled:i.value||!n.value,onClick:t[2]||=e=>s(n.value)},` Go `,8,aO)]),R(`div`,{class:`dir-list`,role:`listbox`,"aria-label":`Directories`,"aria-busy":i.value},[R(`button`,{type:`button`,class:`dir-item`,title:`Start directories`,onClick:t[3]||=e=>s(``)},[z(k(Oc),{size:16}),t[5]||=R(`span`,null,`Start dirs`,-1)]),r.value?.parent?(F(),I(`button`,{key:0,type:`button`,class:`dir-item`,title:r.value.parent,onClick:t[4]||=e=>s(r.value.parent)},[z(k(uc),{size:16}),t[6]||=R(`span`,null,`..`,-1)],8,sO)):V(``,!0),(F(!0),I(P,null,N(r.value?.dirs,e=>(F(),I(`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?(F(),L(k(bc),{key:0,size:16})):(F(),L(k(xc),{key:1,size:16})),R(`span`,null,E(e.name),1)],8,cO))),128)),r.value&&!r.value.dirs.length?(F(),I(`p`,lO,`No subdirectories.`)):V(``,!0)],8,oO),a.value?(F(),I(`p`,uO,E(a.value),1)):V(``,!0)]))}}),fO={key:0,class:`message-error`},pO=[`value`],mO={class:`field`},hO={key:0,class:`recent-cwds`},gO=[`title`,`onClick`],_O={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`},vO=[`value`],yO={key:2,class:`message-error`,role:`alert`},bO=[`disabled`],xO=`dpi-recent-cwds`,SO=Ld(M({__name:`NewSessionDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=H(()=>xu.devices.value.filter(e=>e.status===`online`)),a=O(i.value.find(e=>e.id===n.deviceId)?.id??i.value[0]?.id??``),o=H(()=>i.value.find(e=>e.id===a.value)),s=H(()=>{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=H(()=>!s.value.length||(o.value?.info?.models?.length??0)===0),l=H(()=>!!o.value?.info?.providerKeyMissing),u=e=>`${e.provider}/${e.id}`,d=O({name:``,cwd:``,model:``}),f=H(()=>{try{return JSON.parse(localStorage.getItem(xO)??`{}`)[a.value]??[]}catch{return[]}}),p=(e,t)=>{try{let n=JSON.parse(localStorage.getItem(xO)??`{}`),r=[t,...(n[e]??[]).filter(e=>e!==t)].slice(0,6);localStorage.setItem(xO,JSON.stringify({...n,[e]:r}))}catch{}},m=O(!1),h=O(``),g=O({});j(a,async e=>{if(g.value={},e)try{let{projects:t}=await W(e).projects(!0);g.value=Object.fromEntries(t.filter(e=>e.model).map(e=>[e.rootPath,e.model]))}catch{}},{immediate:!0}),j([()=>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}),j(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 W(o.value.id).createSession({name:d.value.name.trim()||`New session`,cwd:d.value.cwd.trim(),model:{provider:e.provider,modelId:e.id}});p(o.value.id,t.cwd);let n=t.agents.find(e=>e.kind===`root`)??t.agents[0];Ru({deviceId:o.value.id,sessionId:t.id,agentId:n?.id??1}),q(`Session created on ${o.value.id}.`),r(`close`)}catch(e){h.value=lu(e)}finally{m.value=!1}}}return(e,t)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:t[6]||=As(e=>r(`close`),[`self`])},[R(`form`,{class:`modal session-modal`,onSubmit:As(_,[`prevent`])},[R(`header`,null,[t[7]||=R(`div`,null,[R(`span`,{class:`eyebrow`},`A PERSISTENT WORKSPACE`),R(`h2`,null,`New session`)],-1),R(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close new session`,onClick:t[0]||=e=>r(`close`)},[z(k(yl),{size:18})])]),i.value.length?(F(),I(P,{key:1},[R(`label`,null,[t[8]||=B(`Device`,-1),A(R(`select`,{"onUpdate:modelValue":t[1]||=e=>a.value=e,"aria-label":`Device`},[(F(!0),I(P,null,N(i.value,e=>(F(),I(`option`,{key:e.id,value:e.id},E(e.name)+E(e.info?.hostname&&e.info.hostname!==e.name?` · ${e.info.hostname}`:``),9,pO))),128))],512),[[Cs,a.value]])]),R(`label`,null,[t[9]||=B(`Session name`,-1),A(R(`input`,{"onUpdate:modelValue":t[2]||=e=>d.value.name=e,autofocus:``,placeholder:`My durable agent`,maxlength:`100`},null,512),[[bs,d.value.name]])]),R(`div`,mO,[R(`span`,null,`Working directory on `+E(i.value.find(e=>e.id===a.value)?.name??a.value),1),f.value.length?(F(),I(`div`,hO,[(F(!0),I(P,null,N(f.value,e=>(F(),I(`button`,{key:e,type:`button`,class:T([`chip`,{on:e===d.value.cwd}]),title:e,onClick:t=>d.value.cwd=e},E(e.split(`/`).filter(Boolean).at(-1)||e),11,gO))),128))])):V(``,!0),z(dO,{modelValue:d.value.cwd,"onUpdate:modelValue":t[3]||=e=>d.value.cwd=e,"device-id":a.value},null,8,[`modelValue`,`device-id`])]),R(`label`,null,[t[10]||=B(`Model`,-1),c.value||l.value?(F(),I(`span`,_O,`no API key on device — chat needs one`)):V(``,!0),A(R(`select`,{"onUpdate:modelValue":t[4]||=e=>d.value.model=e,"aria-label":`New session model`},[(F(!0),I(P,null,N(s.value,e=>(F(),I(`option`,{key:u(e),value:u(e)},E(e.tier)+` / `+E(e.name),9,vO))),128))],512),[[Cs,d.value.model]])])],64)):(F(),I(`p`,fO,` No device is online. Start one with just backend run or just net up <id>, then try again. `)),h.value?(F(),I(`p`,yO,E(h.value),1)):V(``,!0),R(`footer`,null,[R(`button`,{type:`button`,class:`secondary`,onClick:t[5]||=e=>r(`close`)},`Cancel`),R(`button`,{class:`primary`,disabled:m.value||!d.value.model||!d.value.cwd||!o.value},[z(k(Zc),{size:18}),B(E(m.value?`Creating…`:`Create session`),1)],8,bO)])],32)]))}}),[[`__scopeId`,`data-v-78a7a326`]]),CO=new Uint8Array(512),wO=new Uint8Array(256);(()=>{let e=1;for(let t=0;t<255;t++)CO[t]=e,wO[e]=t,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)CO[e]=CO[e-255]})();var TO=(e,t)=>e===0||t===0?0:CO[wO[e]+wO[t]];function EO(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]^=TO(t[r],CO[n]);t=e}return t}function DO(e,t){let n=EO(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]^=TO(n[i+1],e)}return r}var OO=[21,25,29,33,37,41,45,49,53,57,61,65],kO=[19,34,55,80,108,136,156,194,232,274,324,370],AO=[7,10,15,20,26,36,40,48,60,72,80,96],jO=[7,10,15,20,26,18,20,24,30,18,20,24],MO=[[[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]]],NO=[[],[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]],PO=e=>e<=9?8:16;function FO(e){for(let t=1;t<=OO.length;t++)if(4+PO(t)+e*8<=kO[t-1]*8)return t;throw Error(`qr: payload too long (${e} bytes; v12L max ${kO[11]-3})`)}function IO(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,PO(t));for(let e of n)i(e,8);let a=kO[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 LO(e,t){let n=jO[e-1],r=[],i=0;for(let[n,a]of MO[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=>DO(e,n));for(let e=0;e<n;e++)for(let t of s)a.push(t[e]);return a}function RO(e){return Array.from({length:e},()=>Array(e).fill(!1))}function zO(e,t){let n=OO[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=NO[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 BO(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 VO(e,t){let n=OO[0]*0+e.length,r=BO(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 HO(e,t,n,r){let i=e.length;OO[n-1]*OO[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(WO(l,i,n))continue;if(o>=(kO[n-1]+AO[n-1])*8){o++;continue}let t=a(o++);UO(l,i,r)&&(t=!t),e[l][i]=t}}s=!s}}function UO(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 WO(e,t,n){let r=OO[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=NO[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 GO(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 KO(e,t){let n=FO(new TextEncoder().encode(e).length),r=OO[n-1],i=LO(n,IO(e,n)),a=RO(r);return zO(a,n),HO(a,i,n,t),VO(a,t),a}function qO(e,t){if(t!==void 0)return KO(e,t);let n;for(let t=0;t<8;t++){let r=KO(e,t),i=GO(r);(!n||i<n.score)&&(n={m:r,score:i})}return n.m}function JO(e,t=160){let n=qO(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 YO={class:`device-handoff`,"aria-label":`Pair this machine`},XO={class:`row`},ZO=[`disabled`],QO=[`disabled`],$O={key:0,class:`target`,"data-testid":`device-url`},ek={key:1,class:`err`},tk=Ld(M({__name:`DeviceHandoff`,props:{offerFragment:{}},setup(e){let t=e,n=O(`4780`),r=O(!1),i=H(()=>{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)=>(F(),I(`section`,YO,[R(`header`,null,[z(k(Bc),{size:18}),t[1]||=R(`h3`,null,`Pair THIS machine`,-1)]),t[4]||=R(`p`,{class:`what`},[B(` 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 `),R(`code`,null,`dpi device`),B(` there first. `)],-1),R(`div`,XO,[R(`label`,null,[t[2]||=B(` local port `,-1),A(R(`input`,{"onUpdate:modelValue":t[0]||=e=>n.value=e,inputmode:`numeric`,spellcheck:`false`,"aria-label":`Local dpi backend port`},null,512),[[bs,n.value]])]),R(`button`,{class:`primary`,type:`button`,disabled:!i.value,onClick:a},[z(k(hc),{size:15}),t[3]||=B(`Open the device page `,-1)],8,ZO),R(`button`,{class:`secondary`,type:`button`,disabled:!i.value,onClick:o},[z(k(cc),{size:15}),B(E(r.value?`Copied`:`Copy link`),1)],8,QO)]),i.value?(F(),I(`p`,$O,E(i.value),1)):V(``,!0),i.value?V(``,!0):(F(),I(`p`,ek,`port must be 1–65535`))]))}}),[[`__scopeId`,`data-v-01884b7b`]]);function nk(e){return dk(e)&&!rk(e)&&!hk(e)&&Symbol.asyncIterator in e}function rk(e){return Array.isArray(e)}function ik(e){return typeof e==`bigint`}function ak(e){return typeof e==`boolean`}function ok(e){return e instanceof globalThis.Date}function sk(e){return typeof e==`function`}function ck(e){return dk(e)&&!rk(e)&&!hk(e)&&Symbol.iterator in e}function lk(e){return e===null}function uk(e){return typeof e==`number`}function dk(e){return typeof e==`object`&&!!e}function fk(e){return e instanceof globalThis.RegExp}function pk(e){return typeof e==`string`}function mk(e){return typeof e==`symbol`}function hk(e){return e instanceof globalThis.Uint8Array}function gk(e){return e===void 0}function _k(e){return e.map(e=>Sk(e))}function vk(e){return new Date(e.getTime())}function yk(e){return new Uint8Array(e)}function bk(e){return new RegExp(e.source,e.flags)}function xk(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=Sk(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=Sk(e[n]);return t}function Sk(e){return rk(e)?_k(e):ok(e)?vk(e):hk(e)?yk(e):fk(e)?bk(e):dk(e)?xk(e):e}function Ck(e){return Sk(e)}function wk(e,t){return Ck(t===void 0?e:{...t,...e})}function Tk(e){return typeof e==`object`&&!!e}function Ek(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function Dk(e){return e===void 0}function Ok(e){return typeof e==`number`}var kk;(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=Tk(t);return e.AllowArrayObject?n:n&&!Ek(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?Ok(t):Number.isFinite(t)}e.IsNumberLike=i;function a(t){let n=Dk(t);return e.AllowNullVoid?n||t===null:n}e.IsVoidLike=a})(kk||={});function Ak(e){return globalThis.Object.freeze(e).map(e=>Fk(e))}function jk(e){return e}function Mk(e){return e}function Nk(e){return e}function Pk(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=Fk(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=Fk(e[n]);return globalThis.Object.freeze(t)}function Fk(e){return rk(e)?Ak(e):ok(e)?jk(e):hk(e)?Mk(e):fk(e)?Nk(e):dk(e)?Pk(e):e}function J(e,t){let n=t===void 0?e:{...t,...e};switch(kk.InstanceMode){case`freeze`:return Fk(n);case`clone`:return Ck(n);default:return n}}var Ik=class extends Error{constructor(e){super(e)}},Lk=Symbol.for(`TypeBox.Transform`),Rk=Symbol.for(`TypeBox.Readonly`),zk=Symbol.for(`TypeBox.Optional`),Bk=Symbol.for(`TypeBox.Hint`),Y=Symbol.for(`TypeBox.Kind`);function Vk(e){return dk(e)&&e[Rk]===`Readonly`}function Hk(e){return dk(e)&&e[zk]===`Optional`}function Uk(e){return X(e,`Any`)}function Wk(e){return X(e,`Argument`)}function Gk(e){return X(e,`Array`)}function Kk(e){return X(e,`AsyncIterator`)}function qk(e){return X(e,`BigInt`)}function Jk(e){return X(e,`Boolean`)}function Yk(e){return X(e,`Computed`)}function Xk(e){return X(e,`Constructor`)}function Zk(e){return X(e,`Date`)}function Qk(e){return X(e,`Function`)}function $k(e){return X(e,`Integer`)}function eA(e){return X(e,`Intersect`)}function tA(e){return X(e,`Iterator`)}function X(e,t){return dk(e)&&Y in e&&e[Y]===t}function nA(e){return ak(e)||uk(e)||pk(e)}function rA(e){return X(e,`Literal`)}function iA(e){return X(e,`MappedKey`)}function aA(e){return X(e,`MappedResult`)}function oA(e){return X(e,`Never`)}function sA(e){return X(e,`Not`)}function cA(e){return X(e,`Null`)}function lA(e){return X(e,`Number`)}function uA(e){return X(e,`Object`)}function dA(e){return X(e,`Promise`)}function fA(e){return X(e,`Record`)}function pA(e){return X(e,`Ref`)}function mA(e){return X(e,`RegExp`)}function hA(e){return X(e,`String`)}function gA(e){return X(e,`Symbol`)}function _A(e){return X(e,`TemplateLiteral`)}function vA(e){return X(e,`This`)}function yA(e){return dk(e)&&Lk in e}function bA(e){return X(e,`Tuple`)}function xA(e){return X(e,`Undefined`)}function SA(e){return X(e,`Union`)}function CA(e){return X(e,`Uint8Array`)}function wA(e){return X(e,`Unknown`)}function TA(e){return X(e,`Unsafe`)}function EA(e){return X(e,`Void`)}function DA(e){return dk(e)&&Y in e&&pk(e[Y])}function OA(e){return Uk(e)||Wk(e)||Gk(e)||Jk(e)||qk(e)||Kk(e)||Yk(e)||Xk(e)||Zk(e)||Qk(e)||$k(e)||eA(e)||tA(e)||rA(e)||iA(e)||aA(e)||oA(e)||sA(e)||cA(e)||lA(e)||uA(e)||dA(e)||fA(e)||pA(e)||mA(e)||hA(e)||gA(e)||_A(e)||vA(e)||bA(e)||xA(e)||SA(e)||CA(e)||wA(e)||TA(e)||EA(e)||DA(e)}var kA=`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 AA(e){try{return new RegExp(e),!0}catch{return!1}}function jA(e){if(!pk(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 MA(e){return FA(e)||Aj(e)}function NA(e){return gk(e)||ik(e)}function PA(e){return gk(e)||uk(e)}function FA(e){return gk(e)||ak(e)}function IA(e){return gk(e)||pk(e)}function LA(e){return gk(e)||pk(e)&&jA(e)&&AA(e)}function RA(e){return gk(e)||pk(e)&&jA(e)}function zA(e){return gk(e)||Aj(e)}function BA(e){return dk(e)&&e[zk]===`Optional`}function VA(e){return Z(e,`Any`)&&IA(e.$id)}function HA(e){return Z(e,`Argument`)&&uk(e.index)}function UA(e){return Z(e,`Array`)&&e.type===`array`&&IA(e.$id)&&Aj(e.items)&&PA(e.minItems)&&PA(e.maxItems)&&FA(e.uniqueItems)&&zA(e.contains)&&PA(e.minContains)&&PA(e.maxContains)}function WA(e){return Z(e,`AsyncIterator`)&&e.type===`AsyncIterator`&&IA(e.$id)&&Aj(e.items)}function GA(e){return Z(e,`BigInt`)&&e.type===`bigint`&&IA(e.$id)&&NA(e.exclusiveMaximum)&&NA(e.exclusiveMinimum)&&NA(e.maximum)&&NA(e.minimum)&&NA(e.multipleOf)}function KA(e){return Z(e,`Boolean`)&&e.type===`boolean`&&IA(e.$id)}function qA(e){return Z(e,`Computed`)&&pk(e.target)&&rk(e.parameters)&&e.parameters.every(e=>Aj(e))}function JA(e){return Z(e,`Constructor`)&&e.type===`Constructor`&&IA(e.$id)&&rk(e.parameters)&&e.parameters.every(e=>Aj(e))&&Aj(e.returns)}function YA(e){return Z(e,`Date`)&&e.type===`Date`&&IA(e.$id)&&PA(e.exclusiveMaximumTimestamp)&&PA(e.exclusiveMinimumTimestamp)&&PA(e.maximumTimestamp)&&PA(e.minimumTimestamp)&&PA(e.multipleOfTimestamp)}function XA(e){return Z(e,`Function`)&&e.type===`Function`&&IA(e.$id)&&rk(e.parameters)&&e.parameters.every(e=>Aj(e))&&Aj(e.returns)}function ZA(e){return Z(e,`Integer`)&&e.type===`integer`&&IA(e.$id)&&PA(e.exclusiveMaximum)&&PA(e.exclusiveMinimum)&&PA(e.maximum)&&PA(e.minimum)&&PA(e.multipleOf)}function QA(e){return dk(e)&&Object.entries(e).every(([e,t])=>jA(e)&&Aj(t))}function $A(e){return Z(e,`Intersect`)&&!(pk(e.type)&&e.type!==`object`)&&rk(e.allOf)&&e.allOf.every(e=>Aj(e)&&!xj(e))&&IA(e.type)&&(FA(e.unevaluatedProperties)||zA(e.unevaluatedProperties))&&IA(e.$id)}function ej(e){return Z(e,`Iterator`)&&e.type===`Iterator`&&IA(e.$id)&&Aj(e.items)}function Z(e,t){return dk(e)&&Y in e&&e[Y]===t}function tj(e){return ij(e)&&pk(e.const)}function nj(e){return ij(e)&&uk(e.const)}function rj(e){return ij(e)&&ak(e.const)}function ij(e){return Z(e,`Literal`)&&IA(e.$id)&&aj(e.const)}function aj(e){return ak(e)||uk(e)||pk(e)}function oj(e){return Z(e,`MappedKey`)&&rk(e.keys)&&e.keys.every(e=>uk(e)||pk(e))}function sj(e){return Z(e,`MappedResult`)&&QA(e.properties)}function cj(e){return Z(e,`Never`)&&dk(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function lj(e){return Z(e,`Not`)&&Aj(e.not)}function uj(e){return Z(e,`Null`)&&e.type===`null`&&IA(e.$id)}function dj(e){return Z(e,`Number`)&&e.type===`number`&&IA(e.$id)&&PA(e.exclusiveMaximum)&&PA(e.exclusiveMinimum)&&PA(e.maximum)&&PA(e.minimum)&&PA(e.multipleOf)}function fj(e){return Z(e,`Object`)&&e.type===`object`&&IA(e.$id)&&QA(e.properties)&&MA(e.additionalProperties)&&PA(e.minProperties)&&PA(e.maxProperties)}function pj(e){return Z(e,`Promise`)&&e.type===`Promise`&&IA(e.$id)&&Aj(e.item)}function mj(e){return Z(e,`Record`)&&e.type===`object`&&IA(e.$id)&&MA(e.additionalProperties)&&dk(e.patternProperties)&&(e=>{let t=Object.getOwnPropertyNames(e.patternProperties);return t.length===1&&AA(t[0])&&dk(e.patternProperties)&&Aj(e.patternProperties[t[0]])})(e)}function hj(e){return Z(e,`Ref`)&&IA(e.$id)&&pk(e.$ref)}function gj(e){return Z(e,`RegExp`)&&IA(e.$id)&&pk(e.source)&&pk(e.flags)&&PA(e.maxLength)&&PA(e.minLength)}function _j(e){return Z(e,`String`)&&e.type===`string`&&IA(e.$id)&&PA(e.minLength)&&PA(e.maxLength)&&LA(e.pattern)&&RA(e.format)}function vj(e){return Z(e,`Symbol`)&&e.type===`symbol`&&IA(e.$id)}function yj(e){return Z(e,`TemplateLiteral`)&&e.type===`string`&&pk(e.pattern)&&e.pattern[0]===`^`&&e.pattern[e.pattern.length-1]===`$`}function bj(e){return Z(e,`This`)&&IA(e.$id)&&pk(e.$ref)}function xj(e){return dk(e)&&Lk in e}function Sj(e){return Z(e,`Tuple`)&&e.type===`array`&&IA(e.$id)&&uk(e.minItems)&&uk(e.maxItems)&&e.minItems===e.maxItems&&(gk(e.items)&&gk(e.additionalItems)&&e.minItems===0||rk(e.items)&&e.items.every(e=>Aj(e)))}function Cj(e){return Z(e,`Undefined`)&&e.type===`undefined`&&IA(e.$id)}function wj(e){return Z(e,`Union`)&&IA(e.$id)&&dk(e)&&rk(e.anyOf)&&e.anyOf.every(e=>Aj(e))}function Tj(e){return Z(e,`Uint8Array`)&&e.type===`Uint8Array`&&IA(e.$id)&&PA(e.minByteLength)&&PA(e.maxByteLength)}function Ej(e){return Z(e,`Unknown`)&&IA(e.$id)}function Dj(e){return Z(e,`Unsafe`)}function Oj(e){return Z(e,`Void`)&&e.type===`void`&&IA(e.$id)}function kj(e){return dk(e)&&Y in e&&pk(e[Y])&&!kA.includes(e[Y])}function Aj(e){return dk(e)&&(VA(e)||HA(e)||UA(e)||KA(e)||GA(e)||WA(e)||qA(e)||JA(e)||YA(e)||XA(e)||ZA(e)||$A(e)||ej(e)||ij(e)||oj(e)||sj(e)||cj(e)||lj(e)||uj(e)||dj(e)||fj(e)||pj(e)||mj(e)||hj(e)||gj(e)||_j(e)||vj(e)||yj(e)||bj(e)||Sj(e)||Cj(e)||wj(e)||Tj(e)||Ej(e)||Dj(e)||Oj(e)||kj(e))}var jj=`(true|false)`,Mj=`(0|[1-9][0-9]*)`,Nj=`(.*)`,Pj=`(?!.*)`;`${jj}`;var Fj=`^${Mj}$`,Ij=`^${Nj}$`,Lj=`^${Pj}$`;function Rj(e,t){return e.includes(t)}function zj(e){return[...new Set(e)]}function Bj(e,t){return e.filter(e=>t.includes(e))}function Vj(e,t){return e.reduce((e,t)=>Bj(e,t),t)}function Hj(e){return e.length===1?e[0]:e.length>1?Vj(e.slice(1),e[0]):[]}function Uj(e){let t=[];for(let n of e)t.push(...n);return t}function Wj(e){return J({[Y]:`Any`},e)}function Gj(e,t){return J({[Y]:`Array`,type:`array`,items:e},t)}function Kj(e){return J({[Y]:`Argument`,index:e})}function qj(e,t){return J({[Y]:`AsyncIterator`,type:`AsyncIterator`,items:e},t)}function Jj(e,t,n){return J({[Y]:`Computed`,target:e,parameters:t},n)}function Yj(e,t){let{[t]:n,...r}=e;return r}function Xj(e,t){return t.reduce((e,t)=>Yj(e,t),e)}function Zj(e){return J({[Y]:`Never`,not:{}},e)}function Qj(e){return J({[Y]:`MappedResult`,properties:e})}function $j(e,t,n){return J({[Y]:`Constructor`,type:`Constructor`,parameters:e,returns:t},n)}function eM(e,t,n){return J({[Y]:`Function`,type:`Function`,parameters:e,returns:t},n)}function tM(e,t){return J({[Y]:`Union`,anyOf:e},t)}function nM(e){return e.some(e=>Hk(e))}function rM(e){return e.map(e=>Hk(e)?iM(e):e)}function iM(e){return Xj(e,[zk])}function aM(e,t){return nM(e)?GN(tM(rM(e),t)):tM(rM(e),t)}function oM(e,t){return e.length===1?J(e[0],t):e.length===0?Zj(t):aM(e,t)}function sM(e,t){return e.length===0?Zj(t):e.length===1?J(e[0],t):tM(e,t)}var cM=class extends Ik{};function lM(e){return e.replace(/\\\$/g,`$`).replace(/\\\*/g,`*`).replace(/\\\^/g,`^`).replace(/\\\|/g,`|`).replace(/\\\(/g,`(`).replace(/\\\)/g,`)`)}function uM(e,t,n){return e[t]===n&&e.charCodeAt(t-1)!==92}function dM(e,t){return uM(e,t,`(`)}function fM(e,t){return uM(e,t,`)`)}function pM(e,t){return uM(e,t,`|`)}function mM(e){if(!(dM(e,0)&&fM(e,e.length-1)))return!1;let t=0;for(let n=0;n<e.length;n++)if(dM(e,n)&&(t+=1),fM(e,n)&&--t,t===0&&n!==e.length-1)return!1;return!0}function hM(e){return e.slice(1,e.length-1)}function gM(e){let t=0;for(let n=0;n<e.length;n++)if(dM(e,n)&&(t+=1),fM(e,n)&&--t,pM(e,n)&&t===0)return!0;return!1}function _M(e){for(let t=0;t<e.length;t++)if(dM(e,t))return!0;return!1}function vM(e){let[t,n]=[0,0],r=[];for(let i=0;i<e.length;i++)if(dM(e,i)&&(t+=1),fM(e,i)&&--t,pM(e,i)&&t===0){let t=e.slice(n,i);t.length>0&&r.push(bM(t)),n=i+1}let i=e.slice(n);return i.length>0&&r.push(bM(i)),r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`or`,expr:r}}function yM(e){function t(e,t){if(!dM(e,t))throw new cM(`TemplateLiteralParser: Index must point to open parens`);let n=0;for(let r=t;r<e.length;r++)if(dM(e,r)&&(n+=1),fM(e,r)&&--n,n===0)return[t,r];throw new cM(`TemplateLiteralParser: Unclosed group parens in expression`)}function n(e,t){for(let n=t;n<e.length;n++)if(dM(e,n))return[t,n];return[t,e.length]}let r=[];for(let i=0;i<e.length;i++)if(dM(e,i)){let[n,a]=t(e,i),o=e.slice(n,a+1);r.push(bM(o)),i=a}else{let[t,a]=n(e,i),o=e.slice(t,a);o.length>0&&r.push(bM(o)),i=a-1}return r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`and`,expr:r}}function bM(e){return mM(e)?bM(hM(e)):gM(e)?vM(e):_M(e)?yM(e):{type:`const`,const:lM(e)}}function xM(e){return bM(e.slice(1,e.length-1))}var SM=class extends Ik{};function CM(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 wM(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 TM(e){return e.type===`const`&&e.const===`.*`}function EM(e){return CM(e)||TM(e)?!1:wM(e)?!0:e.type===`and`||e.type===`or`?e.expr.every(e=>EM(e)):e.type===`const`||(()=>{throw new SM(`Unknown expression type`)})()}function DM(e){return EM(xM(e.pattern))}var OM=class extends Ik{};function*kM(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let n of kM(e.slice(1)))yield`${t}${n}`}function*AM(e){return yield*kM(e.expr.map(e=>[...NM(e)]))}function*jM(e){for(let t of e.expr)yield*NM(t)}function*MM(e){return yield e.const}function*NM(e){return e.type===`and`?yield*AM(e):e.type===`or`?yield*jM(e):e.type===`const`?yield*MM(e):(()=>{throw new OM(`Unknown expression`)})()}function PM(e){let t=xM(e.pattern);return EM(t)?[...NM(t)]:[]}function FM(e,t){return J({[Y]:`Literal`,const:e,type:typeof e},t)}function IM(e){return J({[Y]:`Boolean`,type:`boolean`},e)}function LM(e){return J({[Y]:`BigInt`,type:`bigint`},e)}function RM(e){return J({[Y]:`Number`,type:`number`},e)}function zM(e){return J({[Y]:`String`,type:`string`},e)}function*BM(e){let t=e.trim().replace(/"|'/g,``);return t===`boolean`?yield IM():t===`number`?yield RM():t===`bigint`?yield LM():t===`string`?yield zM():yield(()=>{let e=t.split(`|`).map(e=>FM(e.trim()));return e.length===0?Zj():e.length===1?e[0]:oM(e)})()}function*VM(e){if(e[1]!==`{`)return yield*[FM(`$`),...HM(e.slice(1))];for(let t=2;t<e.length;t++)if(e[t]===`}`){let n=BM(e.slice(2,t)),r=HM(e.slice(t+1));return yield*[...n,...r]}yield FM(e)}function*HM(e){for(let t=0;t<e.length;t++)if(e[t]===`$`)return yield*[FM(e.slice(0,t)),...VM(e.slice(t))];yield FM(e)}function UM(e){return[...HM(e)]}var WM=class extends Ik{};function GM(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function KM(e,t){return _A(e)?e.pattern.slice(1,e.pattern.length-1):SA(e)?`(${e.anyOf.map(e=>KM(e,t)).join(`|`)})`:lA(e)||$k(e)||qk(e)?`${t}${Mj}`:hA(e)?`${t}${Nj}`:rA(e)?`${t}${GM(e.const.toString())}`:Jk(e)?`${t}${jj}`:(()=>{throw new WM(`Unexpected Kind '${e[Y]}'`)})()}function qM(e){return`^${e.map(e=>KM(e,``)).join(``)}$`}function JM(e){return oM(PM(e).map(e=>FM(e)))}function YM(e,t){let n=pk(e)?qM(UM(e)):qM(e);return J({[Y]:`TemplateLiteral`,type:`string`,pattern:n},t)}function XM(e){return PM(e).map(e=>e.toString())}function ZM(e){let t=[];for(let n of e)t.push(...$M(n));return t}function QM(e){return[e.toString()]}function $M(e){return[...new Set(_A(e)?XM(e):SA(e)?ZM(e.anyOf):rA(e)?QM(e.const):lA(e)||$k(e)?[`[number]`]:[])]}function eN(e,t,n){let r={};for(let i of Object.getOwnPropertyNames(t))r[i]=mN(e,$M(t[i]),n);return r}function tN(e,t,n){return eN(e,t.properties,n)}function nN(e,t,n){return Qj(tN(e,t,n))}function rN(e,t){return e.map(e=>dN(e,t))}function iN(e){return e.filter(e=>!oA(e))}function aN(e,t){return eP(iN(rN(e,t)))}function oN(e){return e.some(e=>oA(e))?[]:e}function sN(e,t){return oM(oN(rN(e,t)))}function cN(e,t){return t in e?e[t]:t===`[number]`?oM(e):Zj()}function lN(e,t){return t===`[number]`?e:Zj()}function uN(e,t){return t in e?e[t]:Zj()}function dN(e,t){return eA(e)?aN(e.allOf,t):SA(e)?sN(e.anyOf,t):bA(e)?cN(e.items??[],t):Gk(e)?lN(e.items,t):uA(e)?uN(e.properties,t):Zj()}function fN(e,t){return t.map(t=>dN(e,t))}function pN(e,t){return oM(fN(e,t))}function mN(e,t,n){if(pA(e)||pA(t)){if(!OA(e)||!OA(t))throw new Ik(`Index types using Ref parameters require both Type and Key to be of TSchema`);return Jj(`Index`,[e,t])}return aA(t)?nN(e,t,n):iA(t)?vN(e,t,n):J(OA(t)?pN(e,$M(t)):pN(e,t),n)}function hN(e,t,n){return{[t]:mN(e,[t],Ck(n))}}function gN(e,t,n){return t.reduce((t,r)=>({...t,...hN(e,r,n)}),{})}function _N(e,t,n){return gN(e,t.keys,n)}function vN(e,t,n){return Qj(_N(e,t,n))}function yN(e,t){return J({[Y]:`Iterator`,type:`Iterator`,items:e},t)}function bN(e){return globalThis.Object.keys(e).filter(t=>!Hk(e[t]))}function xN(e,t){let n=bN(e);return J(n.length>0?{[Y]:`Object`,type:`object`,required:n,properties:e}:{[Y]:`Object`,type:`object`,properties:e},t)}var SN=xN;function CN(e,t){return J({[Y]:`Promise`,type:`Promise`,item:e},t)}function wN(e){return J(Xj(e,[Rk]))}function TN(e){return J({...e,[Rk]:`Readonly`})}function EN(e,t){return t===!1?wN(e):TN(e)}function DN(e,t){let n=t??!0;return aA(e)?AN(e,n):EN(e,n)}function ON(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=DN(e[r],t);return n}function kN(e,t){return ON(e.properties,t)}function AN(e,t){return Qj(kN(e,t))}function jN(e,t){return J(e.length>0?{[Y]:`Tuple`,type:`array`,items:e,additionalItems:!1,minItems:e.length,maxItems:e.length}:{[Y]:`Tuple`,type:`array`,minItems:e.length,maxItems:e.length},t)}function MN(e,t){return e in t?zN(e,t[e]):Qj(t)}function NN(e){return{[e]:FM(e)}}function PN(e){let t={};for(let n of e)t[n]=FM(n);return t}function FN(e,t){return Rj(t,e)?NN(e):PN(t)}function IN(e,t){return MN(e,FN(e,t))}function LN(e,t){return t.map(t=>zN(e,t))}function RN(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(t))n[r]=zN(e,t[r]);return n}function zN(e,t){let n={...t};return Hk(t)?GN(zN(e,Xj(t,[zk]))):Vk(t)?DN(zN(e,Xj(t,[Rk]))):aA(t)?MN(e,t.properties):iA(t)?IN(e,t.keys):Xk(t)?$j(LN(e,t.parameters),zN(e,t.returns),n):Qk(t)?eM(LN(e,t.parameters),zN(e,t.returns),n):Kk(t)?qj(zN(e,t.items),n):tA(t)?yN(zN(e,t.items),n):eA(t)?tP(LN(e,t.allOf),n):SA(t)?sM(LN(e,t.anyOf),n):bA(t)?jN(LN(e,t.items??[]),n):uA(t)?SN(RN(e,t.properties),n):Gk(t)?Gj(zN(e,t.items),n):dA(t)?CN(zN(e,t.item),n):t}function BN(e,t){let n={};for(let r of e)n[r]=zN(r,t);return n}function VN(e,t,n){let r=OA(e)?$M(e):e;return SN(BN(r,t({[Y]:`MappedKey`,keys:r})),n)}function HN(e){return J(Xj(e,[zk]))}function UN(e){return J({...e,[zk]:`Optional`})}function WN(e,t){return t===!1?HN(e):UN(e)}function GN(e,t){let n=t??!0;return aA(e)?JN(e,n):WN(e,n)}function KN(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=GN(e[r],t);return n}function qN(e,t){return KN(e.properties,t)}function JN(e,t){return Qj(qN(e,t))}function YN(e,t={}){let n=e.every(e=>uA(e)),r=OA(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return J(t.unevaluatedProperties===!1||OA(t.unevaluatedProperties)||n?{...r,[Y]:`Intersect`,type:`object`,allOf:e}:{...r,[Y]:`Intersect`,allOf:e},t)}function XN(e){return e.every(e=>Hk(e))}function ZN(e){return Xj(e,[zk])}function QN(e){return e.map(e=>Hk(e)?ZN(e):e)}function $N(e,t){return XN(e)?GN(YN(QN(e),t)):YN(QN(e),t)}function eP(e,t={}){if(e.length===1)return J(e[0],t);if(e.length===0)return Zj(t);if(e.some(e=>yA(e)))throw Error(`Cannot intersect transform types`);return $N(e,t)}function tP(e,t){if(e.length===1)return J(e[0],t);if(e.length===0)return Zj(t);if(e.some(e=>yA(e)))throw Error(`Cannot intersect transform types`);return YN(e,t)}function nP(...e){let[t,n]=typeof e[0]==`string`?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=`string`)throw new Ik(`Ref: $ref must be a string`);return J({[Y]:`Ref`,$ref:t},n)}function rP(e,t){return Jj(`Awaited`,[Jj(e,t)])}function iP(e){return Jj(`Awaited`,[nP(e)])}function aP(e){return tP(cP(e))}function oP(e){return sM(cP(e))}function sP(e){return lP(e)}function cP(e){return e.map(e=>lP(e))}function lP(e,t){return J(Yk(e)?rP(e.target,e.parameters):eA(e)?aP(e.allOf):SA(e)?oP(e.anyOf):dA(e)?sP(e.item):pA(e)?iP(e.$ref):e,t)}function uP(e){let t=[];for(let n of e)t.push(_P(n));return t}function dP(e){return Uj(uP(e))}function fP(e){return Hj(uP(e))}function pP(e){return e.map((e,t)=>t.toString())}function mP(e){return[`[number]`]}function hP(e){return globalThis.Object.getOwnPropertyNames(e)}function gP(e){return vP?globalThis.Object.getOwnPropertyNames(e).map(e=>e[0]===`^`&&e[e.length-1]===`$`?e.slice(1,e.length-1):e):[]}function _P(e){return eA(e)?dP(e.allOf):SA(e)?fP(e.anyOf):bA(e)?pP(e.items??[]):Gk(e)?mP(e.items):uA(e)?hP(e.properties):fA(e)?gP(e.patternProperties):[]}var vP=!1;function yP(e,t){return Jj(`KeyOf`,[Jj(e,t)])}function bP(e){return Jj(`KeyOf`,[nP(e)])}function xP(e,t){return J(oM(SP(_P(e))),t)}function SP(e){return e.map(e=>e===`[number]`?RM():FM(e))}function CP(e,t){return Yk(e)?yP(e.target,e.parameters):pA(e)?bP(e.$ref):aA(e)?EP(e,t):xP(e,t)}function wP(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=CP(e[r],Ck(t));return n}function TP(e,t){return wP(e.properties,t)}function EP(e,t){return Qj(TP(e,t))}function DP(e){let t=[];for(let n of e)t.push(..._P(n));return zj(t)}function OP(e){return e.filter(e=>!oA(e))}function kP(e,t){let n=[];for(let r of e)n.push(...fN(r,[t]));return OP(n)}function AP(e,t){let n={};for(let r of t)n[r]=eP(kP(e,r));return n}function jP(e,t){return SN(AP(e,DP(e)),t)}function MP(e){return J({[Y]:`Date`,type:`Date`},e)}function NP(e){return J({[Y]:`Null`,type:`null`},e)}function PP(e){return J({[Y]:`Symbol`,type:`symbol`},e)}function FP(e){return J({[Y]:`Undefined`,type:`undefined`},e)}function IP(e){return J({[Y]:`Uint8Array`,type:`Uint8Array`},e)}function LP(e){return J({[Y]:`Unknown`},e)}function RP(e){return e.map(e=>VP(e,!1))}function zP(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=DN(VP(e[n],!1));return t}function BP(e,t){return t===!0?e:DN(e)}function VP(e,t){return nk(e)||ck(e)?BP(Wj(),t):rk(e)?DN(jN(RP(e))):hk(e)?IP():ok(e)?MP():dk(e)?BP(SN(zP(e)),t):sk(e)?BP(eM([],LP()),t):gk(e)?FP():lk(e)?NP():mk(e)?PP():ik(e)?LM():uk(e)||ak(e)||pk(e)?FM(e):SN({})}function HP(e,t){return J(VP(e,!0),t)}function UP(e,t){return Xk(e)?jN(e.parameters,t):Zj(t)}function WP(e,t){if(gk(e))throw Error(`Enum undefined or empty`);let n=globalThis.Object.getOwnPropertyNames(e).filter(e=>isNaN(e)).map(t=>e[t]);return sM([...new Set(n)].map(e=>FM(e)),{...t,[Bk]:`Enum`})}var GP=class extends Ik{},Q;(function(e){e[e.Union=0]=`Union`,e[e.True=1]=`True`,e[e.False=2]=`False`})(Q||={});function KP(e){return e===Q.False?e:Q.True}function qP(e){throw new GP(e)}function JP(e){return cj(e)||$A(e)||wj(e)||Ej(e)||VA(e)}function YP(e,t){return cj(t)?pF(e,t):$A(t)?lF(e,t):wj(t)?XF(e,t):Ej(t)?QF(e,t):VA(t)?XP(e,t):qP(`StructuralRight`)}function XP(e,t){return Q.True}function ZP(e,t){return $A(t)?lF(e,t):wj(t)&&t.anyOf.some(e=>VA(e)||Ej(e))?Q.True:wj(t)?Q.Union:Ej(t)||VA(t)?Q.True:Q.Union}function QP(e,t){return Ej(e)?Q.False:VA(e)?Q.Union:cj(e)?Q.True:Q.False}function $P(e,t){return fj(t)&&AF(t)?Q.True:JP(t)?YP(e,t):UA(t)?KP(nI(e.items,t.items)):Q.False}function eF(e,t){return JP(t)?YP(e,t):WA(t)?KP(nI(e.items,t.items)):Q.False}function tF(e,t){return JP(t)?YP(e,t):fj(t)?NF(e,t):mj(t)?RF(e,t):GA(t)?Q.True:Q.False}function nF(e,t){return rj(e)||KA(e)?Q.True:Q.False}function rF(e,t){return JP(t)?YP(e,t):fj(t)?NF(e,t):mj(t)?RF(e,t):KA(t)?Q.True:Q.False}function iF(e,t){return JP(t)?YP(e,t):fj(t)?NF(e,t):JA(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>KP(nI(t.parameters[n],e))===Q.True)?KP(nI(e.returns,t.returns)):Q.False:Q.False}function aF(e,t){return JP(t)?YP(e,t):fj(t)?NF(e,t):mj(t)?RF(e,t):YA(t)?Q.True:Q.False}function oF(e,t){return JP(t)?YP(e,t):fj(t)?NF(e,t):XA(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>KP(nI(t.parameters[n],e))===Q.True)?KP(nI(e.returns,t.returns)):Q.False:Q.False}function sF(e,t){return ij(e)&&uk(e.const)||dj(e)||ZA(e)?Q.True:Q.False}function cF(e,t){return ZA(t)||dj(t)?Q.True:JP(t)?YP(e,t):fj(t)?NF(e,t):mj(t)?RF(e,t):Q.False}function lF(e,t){return t.allOf.every(t=>nI(e,t)===Q.True)?Q.True:Q.False}function uF(e,t){return e.allOf.some(e=>nI(e,t)===Q.True)?Q.True:Q.False}function dF(e,t){return JP(t)?YP(e,t):ej(t)?KP(nI(e.items,t.items)):Q.False}function fF(e,t){return ij(t)&&t.const===e.const?Q.True:JP(t)?YP(e,t):fj(t)?NF(e,t):mj(t)?RF(e,t):_j(t)?VF(e,t):dj(t)?vF(e,t):ZA(t)?sF(e,t):KA(t)?nF(e,t):Q.False}function pF(e,t){return Q.False}function mF(e,t){return Q.True}function hF(e){let[t,n]=[e,0];for(;lj(t);)t=t.not,n+=1;return n%2==0?t:LP()}function gF(e,t){return lj(e)?nI(hF(e),t):lj(t)?nI(e,hF(t)):qP(`Invalid fallthrough for Not`)}function _F(e,t){return JP(t)?YP(e,t):fj(t)?NF(e,t):mj(t)?RF(e,t):uj(t)?Q.True:Q.False}function vF(e,t){return nj(e)||dj(e)||ZA(e)?Q.True:Q.False}function yF(e,t){return JP(t)?YP(e,t):fj(t)?NF(e,t):mj(t)?RF(e,t):ZA(t)||dj(t)?Q.True:Q.False}function bF(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function xF(e){return AF(e)}function SF(e){return bF(e,0)||bF(e,1)&&`description`in e.properties&&wj(e.properties.description)&&e.properties.description.anyOf.length===2&&(_j(e.properties.description.anyOf[0])&&Cj(e.properties.description.anyOf[1])||_j(e.properties.description.anyOf[1])&&Cj(e.properties.description.anyOf[0]))}function CF(e){return bF(e,0)}function wF(e){return bF(e,0)}function TF(e){return bF(e,0)}function EF(e){return bF(e,0)}function DF(e){return AF(e)}function OF(e){let t=RM();return bF(e,0)||bF(e,1)&&`length`in e.properties&&KP(nI(e.properties.length,t))===Q.True}function kF(e){return bF(e,0)}function AF(e){let t=RM();return bF(e,0)||bF(e,1)&&`length`in e.properties&&KP(nI(e.properties.length,t))===Q.True}function jF(e){let t=eM([Wj()],Wj());return bF(e,0)||bF(e,1)&&`then`in e.properties&&KP(nI(e.properties.then,t))===Q.True}function MF(e,t){return nI(e,t)===Q.False||BA(e)&&!BA(t)?Q.False:Q.True}function NF(e,t){return Ej(e)?Q.False:VA(e)?Q.Union:cj(e)||tj(e)&&xF(t)||nj(e)&&CF(t)||rj(e)&&wF(t)||vj(e)&&SF(t)||GA(e)&&TF(t)||_j(e)&&xF(t)||vj(e)&&SF(t)||dj(e)&&CF(t)||ZA(e)&&CF(t)||KA(e)&&wF(t)||Tj(e)&&DF(t)||YA(e)&&EF(t)||JA(e)&&kF(t)||XA(e)&&OF(t)?Q.True:mj(e)&&_j(IF(e))?t[Bk]===`Record`?Q.True:Q.False:mj(e)&&dj(IF(e))&&bF(t,0)?Q.True:Q.False}function PF(e,t){return JP(t)?YP(e,t):mj(t)?RF(e,t):fj(t)?(()=>{for(let n of Object.getOwnPropertyNames(t.properties)){if(!(n in e.properties)&&!BA(t.properties[n]))return Q.False;if(BA(t.properties[n]))return Q.True;if(MF(e.properties[n],t.properties[n])===Q.False)return Q.False}return Q.True})():Q.False}function FF(e,t){return JP(t)?YP(e,t):fj(t)&&jF(t)?Q.True:pj(t)?KP(nI(e.item,t.item)):Q.False}function IF(e){return Fj in e.patternProperties?RM():Ij in e.patternProperties?zM():qP(`Unknown record key pattern`)}function LF(e){return Fj in e.patternProperties?e.patternProperties[Fj]:Ij in e.patternProperties?e.patternProperties[Ij]:qP(`Unable to get record value schema`)}function RF(e,t){let[n,r]=[IF(t),LF(t)];return tj(e)&&dj(n)&&KP(nI(e,r))===Q.True?Q.True:Tj(e)&&dj(n)||_j(e)&&dj(n)||UA(e)&&dj(n)?nI(e,r):fj(e)?(()=>{for(let t of Object.getOwnPropertyNames(e.properties))if(MF(r,e.properties[t])===Q.False)return Q.False;return Q.True})():Q.False}function zF(e,t){return JP(t)?YP(e,t):fj(t)?NF(e,t):mj(t)?nI(LF(e),LF(t)):Q.False}function BF(e,t){return nI(gj(e)?zM():e,gj(t)?zM():t)}function VF(e,t){return ij(e)&&pk(e.const)||_j(e)?Q.True:Q.False}function HF(e,t){return JP(t)?YP(e,t):fj(t)?NF(e,t):mj(t)?RF(e,t):_j(t)?Q.True:Q.False}function UF(e,t){return JP(t)?YP(e,t):fj(t)?NF(e,t):mj(t)?RF(e,t):vj(t)?Q.True:Q.False}function WF(e,t){return yj(e)?nI(JM(e),t):yj(t)?nI(e,JM(t)):qP(`Invalid fallthrough for TemplateLiteral`)}function GF(e,t){return UA(t)&&e.items!==void 0&&e.items.every(e=>nI(e,t.items)===Q.True)}function KF(e,t){return cj(e)?Q.True:Ej(e)?Q.False:VA(e)?Q.Union:Q.False}function qF(e,t){return JP(t)?YP(e,t):fj(t)&&AF(t)||UA(t)&&GF(e,t)?Q.True:Sj(t)?gk(e.items)&&!gk(t.items)||!gk(e.items)&&gk(t.items)?Q.False:gk(e.items)&&!gk(t.items)||e.items.every((e,n)=>nI(e,t.items[n])===Q.True)?Q.True:Q.False:Q.False}function JF(e,t){return JP(t)?YP(e,t):fj(t)?NF(e,t):mj(t)?RF(e,t):Tj(t)?Q.True:Q.False}function YF(e,t){return JP(t)?YP(e,t):fj(t)?NF(e,t):mj(t)?RF(e,t):Oj(t)?eI(e,t):Cj(t)?Q.True:Q.False}function XF(e,t){return t.anyOf.some(t=>nI(e,t)===Q.True)?Q.True:Q.False}function ZF(e,t){return e.anyOf.every(e=>nI(e,t)===Q.True)?Q.True:Q.False}function QF(e,t){return Q.True}function $F(e,t){return cj(t)?pF(e,t):$A(t)?lF(e,t):wj(t)?XF(e,t):VA(t)?XP(e,t):_j(t)?VF(e,t):dj(t)?vF(e,t):ZA(t)?sF(e,t):KA(t)?nF(e,t):UA(t)?QP(e,t):Sj(t)?KF(e,t):fj(t)?NF(e,t):Ej(t)?Q.True:Q.False}function eI(e,t){return Cj(e)||Cj(e)?Q.True:Q.False}function tI(e,t){return $A(t)?lF(e,t):wj(t)?XF(e,t):Ej(t)?QF(e,t):VA(t)?XP(e,t):fj(t)?NF(e,t):Oj(t)?Q.True:Q.False}function nI(e,t){return yj(e)||yj(t)?WF(e,t):gj(e)||gj(t)?BF(e,t):lj(e)||lj(t)?gF(e,t):VA(e)?ZP(e,t):UA(e)?$P(e,t):GA(e)?tF(e,t):KA(e)?rF(e,t):WA(e)?eF(e,t):JA(e)?iF(e,t):YA(e)?aF(e,t):XA(e)?oF(e,t):ZA(e)?cF(e,t):$A(e)?uF(e,t):ej(e)?dF(e,t):ij(e)?fF(e,t):cj(e)?mF(e,t):uj(e)?_F(e,t):dj(e)?yF(e,t):fj(e)?PF(e,t):mj(e)?zF(e,t):_j(e)?HF(e,t):vj(e)?UF(e,t):Sj(e)?qF(e,t):pj(e)?FF(e,t):Tj(e)?JF(e,t):Cj(e)?YF(e,t):wj(e)?ZF(e,t):Ej(e)?$F(e,t):Oj(e)?tI(e,t):qP(`Unknown left type operand '${e[Y]}'`)}function rI(e,t){return nI(e,t)}function iI(e,t,n,r,i){let a={};for(let o of globalThis.Object.getOwnPropertyNames(e))a[o]=cI(e[o],t,n,r,Ck(i));return a}function aI(e,t,n,r,i){return iI(e.properties,t,n,r,i)}function oI(e,t,n,r,i){return Qj(aI(e,t,n,r,i))}function sI(e,t,n,r){let i=rI(e,t);return i===Q.Union?sM([n,r]):i===Q.True?n:r}function cI(e,t,n,r,i){return aA(e)?oI(e,t,n,r,i):iA(e)?J(fI(e,t,n,r,i)):J(sI(e,t,n,r),i)}function lI(e,t,n,r,i){return{[e]:cI(FM(e),t,n,r,Ck(i))}}function uI(e,t,n,r,i){return e.reduce((e,a)=>({...e,...lI(a,t,n,r,i)}),{})}function dI(e,t,n,r,i){return uI(e.keys,t,n,r,i)}function fI(e,t,n,r,i){return Qj(dI(e,t,n,r,i))}function pI(e,t){return hI(JM(e),t)}function mI(e,t){let n=e.filter(e=>rI(e,t)===Q.False);return n.length===1?n[0]:sM(n)}function hI(e,t,n={}){return _A(e)?J(pI(e,t),n):aA(e)?J(vI(e,t),n):J(SA(e)?mI(e.anyOf,t):rI(e,t)===Q.False?e:Zj(),n)}function gI(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=hI(e[r],t);return n}function _I(e,t){return gI(e.properties,t)}function vI(e,t){return Qj(_I(e,t))}function yI(e,t){return xI(JM(e),t)}function bI(e,t){let n=e.filter(e=>rI(e,t)!==Q.False);return n.length===1?n[0]:sM(n)}function xI(e,t,n){return _A(e)?J(yI(e,t),n):aA(e)?J(wI(e,t),n):J(SA(e)?bI(e.anyOf,t):rI(e,t)===Q.False?Zj():e,n)}function SI(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=xI(e[r],t);return n}function CI(e,t){return SI(e.properties,t)}function wI(e,t){return Qj(CI(e,t))}function TI(e,t){return Xk(e)?J(e.returns,t):Zj(t)}function EI(e){return DN(GN(e))}function DI(e,t,n){return J({[Y]:`Record`,type:`object`,patternProperties:{[e]:t}},n)}function OI(e,t,n){let r={};for(let n of e)r[n]=t;return SN(r,{...n,[Bk]:`Record`})}function kI(e,t,n){return DM(e)?OI($M(e),t,n):DI(e.pattern,t,n)}function AI(e,t,n){return OI($M(sM(e)),t,n)}function jI(e,t,n){return OI([e.toString()],t,n)}function MI(e,t,n){return DI(e.source,t,n)}function NI(e,t,n){return DI(gk(e.pattern)?Ij:e.pattern,t,n)}function PI(e,t,n){return DI(Ij,t,n)}function FI(e,t,n){return DI(Lj,t,n)}function II(e,t,n){return SN({true:t,false:t},n)}function LI(e,t,n){return DI(Fj,t,n)}function RI(e,t,n){return DI(Fj,t,n)}function zI(e,t,n={}){return SA(e)?AI(e.anyOf,t,n):_A(e)?kI(e,t,n):rA(e)?jI(e.const,t,n):Jk(e)?II(e,t,n):$k(e)?LI(e,t,n):lA(e)?RI(e,t,n):mA(e)?MI(e,t,n):hA(e)?NI(e,t,n):Uk(e)?PI(e,t,n):oA(e)?FI(e,t,n):Zj(n)}function BI(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function VI(e){let t=BI(e);return t===Ij?zM():t===Fj?RM():zM({pattern:t})}function HI(e){return e.patternProperties[BI(e)]}function UI(e,t){return t.parameters=rL(e,t.parameters),t.returns=iL(e,t.returns),t}function WI(e,t){return t.parameters=rL(e,t.parameters),t.returns=iL(e,t.returns),t}function GI(e,t){return t.allOf=rL(e,t.allOf),t}function KI(e,t){return t.anyOf=rL(e,t.anyOf),t}function qI(e,t){return gk(t.items)||(t.items=rL(e,t.items)),t}function JI(e,t){return t.items=iL(e,t.items),t}function YI(e,t){return t.items=iL(e,t.items),t}function XI(e,t){return t.items=iL(e,t.items),t}function ZI(e,t){return t.item=iL(e,t.item),t}function QI(e,t){let n=nL(e,t.properties);return{...t,...SN(n)}}function $I(e,t){let n=zI(iL(e,VI(t)),iL(e,HI(t)));return{...t,...n}}function eL(e,t){return t.index in e?e[t.index]:LP()}function tL(e,t){let n=Vk(t),r=Hk(t),i=iL(e,t);return n&&r?EI(i):n&&!r?DN(i):!n&&r?GN(i):i}function nL(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((n,r)=>({...n,[r]:tL(e,t[r])}),{})}function rL(e,t){return t.map(t=>iL(e,t))}function iL(e,t){return Xk(t)?UI(e,t):Qk(t)?WI(e,t):eA(t)?GI(e,t):SA(t)?KI(e,t):bA(t)?qI(e,t):Gk(t)?JI(e,t):Kk(t)?YI(e,t):tA(t)?XI(e,t):dA(t)?ZI(e,t):uA(t)?QI(e,t):fA(t)?$I(e,t):Wk(t)?eL(e,t):t}function aL(e,t){return iL(t,wk(e))}function oL(e){return J({[Y]:`Integer`,type:`integer`},e)}function sL(e,t,n){return{[e]:vL(FM(e),t,Ck(n))}}function cL(e,t,n){return e.reduce((e,r)=>({...e,...sL(r,t,n)}),{})}function lL(e,t,n){return cL(e.keys,t,n)}function uL(e,t,n){return Qj(lL(e,t,n))}function dL(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),n].join(``)}function fL(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),n].join(``)}function pL(e){return e.toUpperCase()}function mL(e){return e.toLowerCase()}function hL(e,t,n){let r=xM(e.pattern);return EM(r)?YM([sM(_L([...NM(r)].map(e=>FM(e)),t))],n):{...e,pattern:gL(e.pattern,t)}}function gL(e,t){return typeof e==`string`?t===`Uncapitalize`?dL(e):t===`Capitalize`?fL(e):t===`Uppercase`?pL(e):t===`Lowercase`?mL(e):e:e.toString()}function _L(e,t){return e.map(e=>vL(e,t))}function vL(e,t,n={}){return iA(e)?uL(e,t,n):_A(e)?hL(e,t,n):SA(e)?sM(_L(e.anyOf,t),n):rA(e)?FM(gL(e.const,t),n):J(e,n)}function yL(e,t={}){return vL(e,`Capitalize`,t)}function bL(e,t={}){return vL(e,`Lowercase`,t)}function xL(e,t={}){return vL(e,`Uncapitalize`,t)}function SL(e,t={}){return vL(e,`Uppercase`,t)}function CL(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=NL(e[i],t,Ck(n));return r}function wL(e,t,n){return CL(e.properties,t,n)}function TL(e,t,n){return Qj(wL(e,t,n))}function EL(e,t){return e.map(e=>ML(e,t))}function DL(e,t){return e.map(e=>ML(e,t))}function OL(e,t){let{[t]:n,...r}=e;return r}function kL(e,t){return t.reduce((e,t)=>OL(e,t),e)}function AL(e,t,n){let r=Xj(e,[Lk,`$id`,`required`,`properties`]);return SN(kL(n,t),r)}function jL(e){return sM(e.reduce((e,t)=>nA(t)?[...e,FM(t)]:e,[]))}function ML(e,t){return eA(e)?tP(EL(e.allOf,t)):SA(e)?sM(DL(e.anyOf,t)):uA(e)?AL(e,t,e.properties):SN({})}function NL(e,t,n){let r=rk(t)?jL(t):t,i=OA(t)?$M(t):t,a=pA(e),o=pA(t);return aA(e)?TL(e,i,n):iA(t)?LL(e,t,n):a&&o||!a&&o||a&&!o?Jj(`Omit`,[e,r],n):J({...ML(e,i),...n})}function PL(e,t,n){return{[t]:NL(e,[t],Ck(n))}}function FL(e,t,n){return t.reduce((t,r)=>({...t,...PL(e,r,n)}),{})}function IL(e,t,n){return FL(e,t.keys,n)}function LL(e,t,n){return Qj(IL(e,t,n))}function RL(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=qL(e[i],t,Ck(n));return r}function zL(e,t,n){return RL(e.properties,t,n)}function BL(e,t,n){return Qj(zL(e,t,n))}function VL(e,t){return e.map(e=>KL(e,t))}function HL(e,t){return e.map(e=>KL(e,t))}function UL(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function WL(e,t,n){let r=Xj(e,[Lk,`$id`,`required`,`properties`]);return SN(UL(n,t),r)}function GL(e){return sM(e.reduce((e,t)=>nA(t)?[...e,FM(t)]:e,[]))}function KL(e,t){return eA(e)?tP(VL(e.allOf,t)):SA(e)?sM(HL(e.anyOf,t)):uA(e)?WL(e,t,e.properties):SN({})}function qL(e,t,n){let r=rk(t)?GL(t):t,i=OA(t)?$M(t):t,a=pA(e),o=pA(t);return aA(e)?BL(e,i,n):iA(t)?ZL(e,t,n):a&&o||!a&&o||a&&!o?Jj(`Pick`,[e,r],n):J({...KL(e,i),...n})}function JL(e,t,n){return{[t]:qL(e,[t],Ck(n))}}function YL(e,t,n){return t.reduce((t,r)=>({...t,...JL(e,r,n)}),{})}function XL(e,t,n){return YL(e,t.keys,n)}function ZL(e,t,n){return Qj(XL(e,t,n))}function QL(e,t){return Jj(`Partial`,[Jj(e,t)])}function $L(e){return Jj(`Partial`,[nP(e)])}function eR(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=GN(e[n]);return t}function tR(e,t){let n=Xj(e,[Lk,`$id`,`required`,`properties`]);return SN(eR(t),n)}function nR(e){return e.map(e=>rR(e))}function rR(e){return Yk(e)?QL(e.target,e.parameters):pA(e)?$L(e.$ref):eA(e)?tP(nR(e.allOf)):SA(e)?sM(nR(e.anyOf)):uA(e)?tR(e,e.properties):qk(e)||Jk(e)||$k(e)||rA(e)||cA(e)||lA(e)||hA(e)||gA(e)||xA(e)?e:SN({})}function iR(e,t){return aA(e)?sR(e,t):J({...rR(e),...t})}function aR(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=iR(e[r],Ck(t));return n}function oR(e,t){return aR(e.properties,t)}function sR(e,t){return Qj(oR(e,t))}function cR(e,t){return Jj(`Required`,[Jj(e,t)])}function lR(e){return Jj(`Required`,[nP(e)])}function uR(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=Xj(e[n],[zk]);return t}function dR(e,t){let n=Xj(e,[Lk,`$id`,`required`,`properties`]);return SN(uR(t),n)}function fR(e){return e.map(e=>pR(e))}function pR(e){return Yk(e)?cR(e.target,e.parameters):pA(e)?lR(e.$ref):eA(e)?tP(fR(e.allOf)):SA(e)?sM(fR(e.anyOf)):uA(e)?dR(e,e.properties):qk(e)||Jk(e)||$k(e)||rA(e)||cA(e)||lA(e)||hA(e)||gA(e)||xA(e)?e:SN({})}function mR(e,t){return aA(e)?_R(e,t):J({...pR(e),...t})}function hR(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=mR(e[r],t);return n}function gR(e,t){return hR(e.properties,t)}function _R(e,t){return Qj(gR(e,t))}function vR(e,t){return t.map(t=>pA(t)?yR(e,t.$ref):BR(e,t))}function yR(e,t){return t in e?pA(e[t])?yR(e,e[t].$ref):BR(e,e[t]):Zj()}function bR(e){return lP(e[0])}function xR(e){return mN(e[0],e[1])}function SR(e){return CP(e[0])}function CR(e){return iR(e[0])}function wR(e){return NL(e[0],e[1])}function TR(e){return qL(e[0],e[1])}function ER(e){return mR(e[0])}function DR(e,t,n){let r=vR(e,n);return t===`Awaited`?bR(r):t===`Index`?xR(r):t===`KeyOf`?SR(r):t===`Partial`?CR(r):t===`Omit`?wR(r):t===`Pick`?TR(r):t===`Required`?ER(r):Zj()}function OR(e,t){return Gj(BR(e,t))}function kR(e,t){return qj(BR(e,t))}function AR(e,t,n){return $j(zR(e,t),BR(e,n))}function jR(e,t,n){return eM(zR(e,t),BR(e,n))}function MR(e,t){return tP(zR(e,t))}function NR(e,t){return yN(BR(e,t))}function PR(e,t){return SN(globalThis.Object.keys(t).reduce((n,r)=>({...n,[r]:BR(e,t[r])}),{}))}function FR(e,t){let[n,r]=[BR(e,HI(t)),BI(t)],i=wk(t);return i.patternProperties[r]=n,i}function IR(e,t){return pA(t)?{...yR(e,t.$ref),[Lk]:t[Lk]}:t}function LR(e,t){return jN(zR(e,t))}function RR(e,t){return sM(zR(e,t))}function zR(e,t){return t.map(t=>BR(e,t))}function BR(e,t){return Hk(t)?J(BR(e,Xj(t,[zk])),t):Vk(t)?J(BR(e,Xj(t,[Rk])),t):yA(t)?J(IR(e,t),t):Gk(t)?J(OR(e,t.items),t):Kk(t)?J(kR(e,t.items),t):Yk(t)?J(DR(e,t.target,t.parameters)):Xk(t)?J(AR(e,t.parameters,t.returns),t):Qk(t)?J(jR(e,t.parameters,t.returns),t):eA(t)?J(MR(e,t.allOf),t):tA(t)?J(NR(e,t.items),t):uA(t)?J(PR(e,t.properties),t):fA(t)?J(FR(e,t)):bA(t)?J(LR(e,t.items||[]),t):SA(t)?J(RR(e,t.anyOf),t):t}function VR(e,t){return t in e?BR(e,e[t]):Zj()}function HR(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:VR(e,n)}),{})}var UR=class{constructor(e){let t=HR(e),n=this.WithIdentifiers(t);this.$defs=n}Import(e,t){let n={...this.$defs,[e]:J(this.$defs[e],t)};return J({[Y]:`Import`,$defs:n,$ref:e})}WithIdentifiers(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:{...e[n],$id:n}}),{})}};function WR(e){return new UR(e)}function GR(e,t){return J({[Y]:`Not`,not:e},t)}function KR(e,t){return Qk(e)?jN(e.parameters,t):Zj()}var qR=0;function JR(e,t={}){gk(t.$id)&&(t.$id=`T${qR++}`);let n=wk(e({[Y]:`This`,$ref:`${t.$id}`}));return n.$id=t.$id,J({[Bk]:`Recursive`,...n},t)}function YR(e,t){let n=pk(e)?new globalThis.RegExp(e):e;return J({[Y]:`RegExp`,type:`RegExp`,source:n.source,flags:n.flags},t)}function XR(e){return eA(e)?e.allOf:SA(e)?e.anyOf:bA(e)?e.items??[]:[]}function ZR(e){return XR(e)}function QR(e,t){return Qk(e)?J(e.returns,t):Zj(t)}var $R=class{constructor(e){this.schema=e}Decode(e){return new ez(this.schema,e)}},ez=class{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let n={Encode:n=>t[Lk].Encode(e(n)),Decode:e=>this.decode(t[Lk].Decode(e))};return{...t,[Lk]:n}}EncodeSchema(e,t){let n={Decode:this.decode,Encode:e};return{...t,[Lk]:n}}Encode(e){return yA(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}};function tz(e){return new $R(e)}function nz(e={}){return J({[Y]:e[Y]??`Unsafe`},e)}function rz(e){return J({[Y]:`Void`,type:`void`},e)}var $=t({Any:()=>Wj,Argument:()=>Kj,Array:()=>Gj,AsyncIterator:()=>qj,Awaited:()=>lP,BigInt:()=>LM,Boolean:()=>IM,Capitalize:()=>yL,Composite:()=>jP,Const:()=>HP,Constructor:()=>$j,ConstructorParameters:()=>UP,Date:()=>MP,Enum:()=>WP,Exclude:()=>hI,Extends:()=>cI,Extract:()=>xI,Function:()=>eM,Index:()=>mN,InstanceType:()=>TI,Instantiate:()=>aL,Integer:()=>oL,Intersect:()=>tP,Iterator:()=>yN,KeyOf:()=>CP,Literal:()=>FM,Lowercase:()=>bL,Mapped:()=>VN,Module:()=>WR,Never:()=>Zj,Not:()=>GR,Null:()=>NP,Number:()=>RM,Object:()=>SN,Omit:()=>NL,Optional:()=>GN,Parameters:()=>KR,Partial:()=>iR,Pick:()=>qL,Promise:()=>CN,Readonly:()=>DN,ReadonlyOptional:()=>EI,Record:()=>zI,Recursive:()=>JR,Ref:()=>nP,RegExp:()=>YR,Required:()=>mR,Rest:()=>ZR,ReturnType:()=>QR,String:()=>zM,Symbol:()=>PP,TemplateLiteral:()=>YM,Transform:()=>tz,Tuple:()=>jN,Uint8Array:()=>IP,Uncapitalize:()=>xL,Undefined:()=>FP,Union:()=>sM,Unknown:()=>LP,Unsafe:()=>nz,Uppercase:()=>SL,Void:()=>rz}),iz={additionalProperties:!1},az=$.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}),oz=$.String({pattern:`^[a-z0-9][a-z0-9-]{0,31}(?![\\s\\S])`,minLength:1,maxLength:32}),sz=$.String({pattern:`^sha256:[0-9a-f]{64}$`,minLength:71,maxLength:71}),cz=$.String({pattern:`^[A-Za-z0-9_-]{43}$`,minLength:43,maxLength:43}),lz=$.String({pattern:`^dpt_[A-Za-z0-9_-]{43}$`,minLength:47,maxLength:47}),uz=`[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}`,dz=`^(?:${uz}|[A-Z2-7]{12}|[A-Z2-7]{8})(?![\\s\\S])`,fz=$.String({pattern:dz,minLength:8,maxLength:36}),pz=new RegExp(dz),mz=/^[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 hz(e){return typeof e!=`string`||e.length>36?!1:pz.test(e)}function gz(e){if(typeof e!=`string`)return;if(mz.test(e)){let t=e.toLowerCase();return hz(t)?t:void 0}let t=e.replace(/[\s-]+/g,``).toUpperCase();if(hz(t)&&!(/[\s-]/.test(e)&&t.length!==12))return t}$.Object({type:$.Literal(`pair.request`),v:$.Literal(1),requestId:az,code:fz,deviceUid:az,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:sz,clientTime:$.Integer(),hubNonce:$.Optional(cz)},iz),$.Object({type:$.Literal(`pair.device-request`),v:$.Literal(1),requestId:az,deviceUid:az,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:sz,clientTime:$.Integer(),hubNonce:$.Optional(cz)},iz);var _z=$.Object({type:$.Literal(`pair.challenge`),v:$.Literal(1),enrollmentId:az,nonce:cz,issuedAt:$.Integer(),hubId:az,hubPublicKey:$.Optional($.String({minLength:1,maxLength:256})),hubKeyFingerprint:$.Optional(sz),hubSignature:$.Optional($.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86}))},iz);$.Object({type:$.Literal(`pair.device-ack`),v:$.Literal(1),codeId:az,code:fz,expiresAt:$.Integer(),hubOrigin:$.String(),hubId:az,challenge:_z},iz),$.Object({type:$.Literal(`pair.response`),v:$.Literal(1),enrollmentId:az,nonce:cz,signature:$.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86})},iz),$.Object({type:$.Literal(`pair.pending`),v:$.Literal(1),enrollmentId:az,state:$.Literal(`awaiting_approval`),expiresAt:$.Integer(),pollAfterMs:$.Integer({minimum:1})},iz),$.Object({type:$.Literal(`pair.token`),v:$.Literal(1),enrollmentId:az,deviceUid:az,deviceId:oz,pairingEpoch:az,credentialId:az,generation:$.Integer({minimum:1}),hubId:az,hubOrigin:$.String(),hubUrl:$.String(),tunnelToken:lz,issuedAt:$.Integer(),expiresAt:$.Null(),hubKeyFingerprint:$.Optional(sz)},iz),$.Object({enrollmentId:az,deviceUid:az,keyFingerprint:sz,replaceKey:$.Optional($.Boolean())},iz),$.Object({type:$.Literal(`pair.revoke`),v:$.Literal(1),deviceId:oz,pairingEpoch:az,reason:$.Union([$.Literal(`user`),$.Literal(`compromise`),$.Literal(`hub_migrated`)]),revokedAt:$.Integer()},iz);var vz=$.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}))},iz);$.Object({type:$.Literal(`pair.code`),v:$.Literal(1),codeId:az,code:fz,expiresAt:$.Integer(),hubOrigin:$.String({maxLength:2048}),pairUrl:$.String({maxLength:4096}),offerUrl:$.Optional($.String({maxLength:2048}))},iz);var yz=$.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:az,expiresAt:$.Integer(),phase:yz,enrollment:$.Optional($.Object({enrollmentId:az,deviceUid:az,deviceName:$.String({minLength:1,maxLength:64}),keyFingerprint:sz,proofVerified:$.Boolean(),keyChanged:$.Boolean()},iz)),deviceId:$.Optional(oz),error:$.Optional(vz)},iz);function bz(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 xz(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 Sz=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Cz=RegExp(`^${uz}$`),wz=/^sha256:[0-9a-f]{64}$/;function Tz(e){let t=xz(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=bz(r.hub);if(a.ok&&a.origin===r.hub&&typeof r.id==`string`&&Sz.test(r.id)&&typeof r.code==`string`&&Cz.test(r.code)&&typeof r.exp==`number`&&Number.isSafeInteger(r.exp))return r.v===3?typeof r.kfp!=`string`||!wz.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 Ez(e,t=Date.now()){let n=Tz(e);if(n&&!(n.exp<t-3e4)&&!(n.exp>t+6e5))return n}function Dz(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=Ez(n.hash.slice(7),t);if(r&&r.hub===n.origin)return{offer:r,rest:`${n.origin}/pair`}}function Oz(e){if(!/^\/pair\/?$/.test(e.pathname))return;if(e.hash.startsWith(`#offer=`)){let t=Dz(e.href);if(t)return{code:t.offer.code,origin:e.origin,offerFragment:e.hash.slice(1)};let n=Ez(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:gz(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 kz=e=>/^\/pair\/?$/.test(e.pathname)?`/`:void 0,Az=e=>/^\/pair\/?$/.test(e.pathname)&&Oz(e)===void 0?`/`:void 0,jz=4e3;async function Mz(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 Nz={class:`modal pair-wizard`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pair-title`},Pz={key:1,class:`pair-pending`,"aria-label":`Machines waiting for approval`},Fz={class:`who`},Iz={key:0,class:`muted`},Lz={key:1,class:`muted`},Rz={class:`fp`},zz={class:`row`},Bz={class:`phase`},Vz=[`onClick`],Hz={key:2,class:`hint`},Uz={class:`pair-steps`,"aria-label":`Pairing progress`},Wz={class:`pair-grid`},Gz={class:`pair-code-box`},Kz={class:`pair-code`,"aria-label":`Pairing code`},qz={class:`pair-copy-actions`},Jz=[`innerHTML`],Yz={class:`pair-side`},Xz={key:0,class:`hint`},Zz={class:`pair-fingerprint`},Qz={class:`fp`},$z={class:`pair-confirm`},eB={key:0,class:`pair-confirm warn`},tB=[`disabled`],nB=[`disabled`],rB={class:`hint`},iB=[`disabled`],aB={key:5,class:`error`,role:`alert`},oB={key:4},sB={class:`error`,role:`alert`},cB=M({__name:`PairDeviceWizard`,props:{handoff:{}},emits:[`close`],setup(e,{expose:t,emit:n}){let r=n,i=e,a=O(`boot`),o=O(),s=O(),c=O(),l=O(``),u=O(!1),d=O(!1),f=O(!1),p=O(!1),m=O(!1),h=O(!1),g=O(),_=O([]),v=H(()=>{let e=s.value?.code??``;return!hz(e)||e.includes(`-`)?e:(e.match(/.{4}/g)??[]).join(`-`)}),y=H(()=>s.value?Vy(s.value):``),b=H(()=>y.value?JO(y.value,148):``),ee=H(()=>c.value?.enrollment?.keyFingerprint??``),x=H(()=>c.value?.deviceId??``);j(x,e=>{g.value?.(),e&&(g.value=j(()=>xu.devices.value.find(t=>t.id===e)?.status,e=>{e===`online`&&(q(`Device paired and online.`),g.value?.(),g.value=void 0)},{immediate:!0}))});async function S(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=Wy();o.value=t;try{let n=e?await Hy.resolveCode(e):await Hy.createCode();if(t.closed()){await Hy.cancel(n.codeId).catch(()=>{q(`The late pairing code could not be cancelled. Check device credentials before retrying.`)});return}if(s.value=n,a.value=`code`,e){let e=kz(new URL(window.location.href));e&&window.history.replaceState(window.history.state,``,e)}qy(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 te(){let e=c.value,t=o.value;if(e?.enrollment&&t&&!u.value){u.value=!0,l.value=``;try{let t=await Hy.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 ne(e){if(!s.value)return`cancelled`;try{let t=await Hy.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 Jl&&e.status===409&&String(e.code)===`already_issued`){let e=await Hy.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 C=()=>ne(!1),re=()=>[`issued`,`connected`,`cancelled`,`expired`].includes(c.value?.phase??``);async function ie(){let e=x.value;if(e){u.value=!0;try{await Hy.revoke(e,`user`),q(`Issued credential revoked.`),r(`close`)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}}async function ae(){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 oe(){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 se(){if(!d.value){d.value=!0,u.value=!0;try{let e=await Mz({needsCancel:!!s.value&&!re(),cancel:C,timeoutMs:jz});if(!e.closed)return;o.value?.close(),g.value?.(),e.confirmed||q(`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:se});let ce;async function le(){try{_.value=(await Hy.pending()).codes}catch{}}async function ue(e){s.value=void 0,c.value=void 0,l.value=``;let t=Wy();o.value=t,a.value=e.phase===`approved_ready`?`approve`:`proof`,qy(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 Hr(()=>{if(le(),ce=setInterval(()=>void le(),3e3),i.handoff&&`error`in i.handoff){l.value=i.handoff.error,a.value=`expired`;return}S(i.handoff?.code)}),Gr(()=>{clearInterval(ce);let e=o.value;e&&!e.closed()&&s.value&&!re()&&ne(!0).then(e=>{e!==`cancelled`&&q(`Pairing cancellation was not confirmed. Check device credentials before retrying.`)}),e?.close(),g.value?.()}),(e,t)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:As(se,[`self`])},[R(`div`,Nz,[R(`header`,null,[t[5]||=R(`h2`,{id:`pair-title`},`Pair a device`,-1),R(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,onClick:se},[z(k(yl),{size:18})])]),i.handoff&&`offerFragment`in i.handoff&&i.handoff.offerFragment?(F(),L(tk,{key:0,"offer-fragment":i.handoff.offerFragment},null,8,[`offer-fragment`])):V(``,!0),_.value.length?(F(),I(`section`,Pz,[t[6]||=R(`h3`,null,`Machines waiting for you`,-1),R(`ul`,null,[(F(!0),I(P,null,N(_.value,e=>(F(),I(`li`,{key:e.codeId},[R(`div`,Fz,[R(`strong`,null,E(e.deviceName??`unnamed device`),1),e.hostname?(F(),I(`span`,Iz,E(e.hostname),1)):V(``,!0),e.platform?(F(),I(`span`,Lz,E(e.platform),1)):V(``,!0)]),R(`div`,Rz,E(e.keyFingerprint),1),R(`div`,zz,[R(`span`,Bz,E(e.phase.replaceAll(`_`,` `)),1),R(`button`,{type:`button`,class:`small`,onClick:t=>ue(e)},`Review`,8,Vz)])]))),128))]),t[7]||=R(`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)])):V(``,!0),a.value===`boot`?(F(),I(`p`,Hz,`Minting a pairing code…`)):s.value?(F(),I(P,{key:3},[R(`ol`,Uz,[t[8]||=R(`li`,{class:T({on:!0})},`Code`,-1),R(`li`,{class:T({on:[`proof`,`approve`,`issued`].includes(a.value)})},`Proof`,2),R(`li`,{class:T({on:[`approve`,`issued`].includes(a.value)})},`Fingerprint`,2),R(`li`,{class:T({on:a.value===`issued`})},`Online`,2)]),R(`div`,Wz,[R(`div`,Gz,[R(`div`,Kz,E(v.value),1),R(`div`,qz,[R(`button`,{type:`button`,class:`small`,onClick:ae},[z(k(cc),{size:14}),B(` `+E(m.value?`Copied`:`Copy code`),1)]),R(`button`,{type:`button`,class:`small`,onClick:oe,title:`Self-contained link: hub, code and expiry all in the fragment — it never reaches server logs`},[z(k(cc),{size:14}),B(` `+E(h.value?`Copied link`:`Copy link`),1)])]),t[9]||=R(`p`,{class:`hint`},` Run the device pairing command and scan, or enter this code on the device. Expires in 5 minutes. `,-1),R(`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,Jz)]),R(`div`,Yz,[a.value===`code`||a.value===`proof`?(F(),I(`p`,Xz,[z(k(el),{size:14,class:`spin`}),t[10]||=B(` Waiting for the device to submit its signing proof… `,-1)])):a.value===`approve`?(F(),I(P,{key:1},[R(`div`,Zz,[t[11]||=R(`h3`,null,`Device key fingerprint`,-1),R(`code`,Qz,E(ee.value),1),t[12]||=R(`p`,{class:`hint`},` Compare ALL 64 hex characters with the fingerprint shown on the device screen. `,-1)]),R(`label`,$z,[A(R(`input`,{"onUpdate:modelValue":t[0]||=e=>f.value=e,type:`checkbox`},null,512),[[xs,f.value]]),t[13]||=B(` The fingerprint matches the device display exactly `,-1)]),c.value?.enrollment?.keyChanged?(F(),I(`label`,eB,[A(R(`input`,{"onUpdate:modelValue":t[1]||=e=>p.value=e,type:`checkbox`},null,512),[[xs,p.value]]),z(k(al),{size:14}),t[14]||=B(` Device is already paired with a DIFFERENT key — replace the stored key (replaceKey) `,-1)])):V(``,!0),R(`button`,{type:`button`,class:`primary`,disabled:!f.value||u.value||c.value?.enrollment?.keyChanged===!0&&!p.value,onClick:te},` Approve device `,8,tB),R(`button`,{type:`button`,class:`small`,disabled:u.value,onClick:C},` Cancel pairing `,8,nB)],64)):a.value===`issued`?(F(),I(P,{key:2},[R(`p`,rB,[z(k(ac),{size:14}),t[15]||=B(` Credential issued. The device is connecting through the tunnel — you will get a toast once the monitor probe reports it online. `,-1)]),R(`button`,{type:`button`,class:`small`,onClick:se},`Close`),R(`button`,{type:`button`,class:`small danger`,disabled:!x.value||u.value,title:`Mistaken approval? Revoke the credential now.`,onClick:ie},` Revoke this credential `,8,iB)],64)):a.value===`cancelled`?(F(),I(P,{key:3},[t[16]||=R(`p`,{class:`hint`},`Pairing was cancelled (or the signature failed too many times).`,-1),R(`button`,{type:`button`,class:`small`,onClick:t[2]||=e=>S()},`Start over`)],64)):a.value===`expired`?(F(),I(P,{key:4},[t[17]||=R(`p`,{class:`hint`},`The pairing code expired.`,-1),R(`button`,{type:`button`,class:`small`,onClick:t[3]||=e=>S()},`New code`)],64)):V(``,!0),l.value?(F(),I(`p`,aB,E(l.value),1)):V(``,!0)])])],64)):(F(),I(`div`,oB,[R(`p`,sB,E(l.value||`This pairing link is unavailable.`),1),R(`button`,{type:`button`,class:`small`,onClick:t[4]||=e=>S()},`New code`)]))])]))}}),lB={class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`device-credentials-title`},uB={class:`hint`},dB={key:1,class:`hint`},fB=M({__name:`DeviceCredentialsDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=H(()=>xu.devices.value.find(e=>e.id===n.deviceId));return(e,t)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:t[2]||=As(e=>r(`close`),[`self`])},[R(`section`,lB,[R(`header`,null,[t[3]||=R(`h2`,{id:`device-credentials-title`},`Device credentials`,-1),R(`button`,{class:`icon-button`,"aria-label":`Close device credentials`,onClick:t[0]||=e=>r(`close`)},[z(k(yl),{size:18})])]),i.value?(F(),I(P,{key:0},[R(`p`,null,[B(E(i.value.name)+` `,1),R(`code`,null,E(i.value.id),1)]),R(`p`,uB,E(i.value.status)+` · tunnel `+E(i.value.tunnel?.state??`disconnected`)+` · `+E(i.value.tunnel?.readerCount??0)+` readers `,1),z(nb,{device:i.value},null,8,[`device`])],64)):(F(),I(`p`,dB,`This device is no longer in the registry.`)),R(`footer`,null,[R(`button`,{class:`secondary`,onClick:t[1]||=e=>r(`close`)},`Close`)])])]))}}),pB={id:`prompt-title`},mB=[`disabled`],hB={key:0,class:`hint`},gB={key:1},_B={key:0,class:`muted`},vB=[`placeholder`,`disabled`],yB=[`required`,`placeholder`,`aria-label`,`disabled`],bB={key:2,class:`message-error`,role:`alert`},xB=[`disabled`],SB=[`disabled`],CB=M({__name:`PromptDialog`,props:{dialog:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=O(n.dialog.value??``),a=O(!1),o=O(``),s=O(),c=!!n.dialog.label;async function l(){if(!a.value&&(!c||n.dialog.optional||i.value.trim())){a.value=!0,o.value=``;try{await n.dialog.run(i.value.trim()),r(`close`)}catch(e){o.value=lu(e)}finally{a.value=!1}}}return Hr(()=>void jn(()=>(s.value?.focus(),s.value?.select()))),(t,n)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:n[4]||=As(e=>!a.value&&r(`close`),[`self`])},[R(`form`,{class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`prompt-title`,onSubmit:As(l,[`prevent`])},[R(`header`,null,[R(`h2`,pB,E(e.dialog.title),1),R(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,disabled:a.value,onClick:n[0]||=e=>r(`close`)},[z(k(yl),{size:18})],8,mB)]),e.dialog.hint?(F(),I(`p`,hB,E(e.dialog.hint),1)):V(``,!0),c?(F(),I(`label`,gB,[B(E(e.dialog.label)+` `,1),e.dialog.optional?(F(),I(`span`,_B,`(optional)`)):V(``,!0),e.dialog.multiline?A((F(),I(`textarea`,{key:1,ref_key:`input`,ref:s,"onUpdate:modelValue":n[1]||=e=>i.value=e,rows:`4`,placeholder:e.dialog.placeholder,disabled:a.value},null,8,vB)),[[bs,i.value]]):A((F(),I(`input`,{key:2,ref_key:`input`,ref:s,"onUpdate:modelValue":n[2]||=e=>i.value=e,maxlength:`100`,required:!e.dialog.optional,placeholder:e.dialog.placeholder,"aria-label":e.dialog.label,disabled:a.value},null,8,yB)),[[bs,i.value]])])):V(``,!0),o.value?(F(),I(`p`,bB,E(o.value),1)):V(``,!0),R(`footer`,null,[R(`button`,{type:`button`,class:`secondary`,disabled:a.value,onClick:n[3]||=e=>r(`close`)},` Cancel `,8,xB),R(`button`,{class:T([`primary`,{danger:e.dialog.danger}]),disabled:a.value||c&&!e.dialog.optional&&!i.value.trim()},E(a.value?`Working…`:e.dialog.submit),11,SB)])],32)]))}}),wB={class:`modal model-modal`},TB={class:`eyebrow`},EB={class:`model-list`},DB=[`onClick`],OB=[`src`],kB={class:`hint`},AB=M({__name:`ModelPicker`,emits:[`close`],setup(e,{emit:t}){let n=t,r=O(``),i=H(()=>Gu.value.filter(e=>`${e.name} ${e.id} ${e.tier}`.toLowerCase().includes(r.value.toLowerCase()))),a=e=>e.id===Ku.value.agent.model?.modelId&&e.provider===Ku.value.agent.model?.provider;async function o(e){await od(()=>Iu.value.configure({model:{provider:e.provider,modelId:e.id}}))&&(await td(),q(`Model saved. Used on the next turn.`),n(`close`))}return(e,t)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:t[2]||=As(e=>n(`close`),[`self`])},[R(`section`,wB,[R(`header`,null,[R(`div`,null,[R(`span`,TB,`PER AGENT · `+E(k(ku)?.id),1),t[3]||=R(`h2`,null,`Choose a model`,-1)]),R(`button`,{class:`icon-button`,"aria-label":`Close model picker`,onClick:t[0]||=e=>n(`close`)},[z(k(yl),{size:18})])]),A(R(`input`,{"onUpdate:modelValue":t[1]||=e=>r.value=e,placeholder:`Search models or tiers…`,"aria-label":`Search models`},null,512),[[bs,r.value]]),R(`div`,EB,[(F(!0),I(P,null,N(i.value,e=>(F(),I(`button`,{key:`${e.provider}/${e.id}`,class:T({selected:a(e)}),onClick:t=>o(e)},[R(`img`,{src:k(ud)(e.id),alt:``},null,8,OB),R(`div`,null,[R(`strong`,null,E(e.name),1),R(`small`,null,E(e.tier)+` / `+E(e.provider)+` / `+E(k(cd)(e.contextWindow))+` context`,1)]),a(e)?(F(),L(k(nc),{key:0,size:18})):V(``,!0)],10,DB))),128))]),R(`p`,kB,`Models available on `+E(k(ku)?.id)+`. Provider keys stay on the device.`,1)])]))}}),jB={class:`dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`help-title`},MB={class:`dialog-head`},NB={class:`dialog-body`},PB={class:`n`},FB={class:`body`},IB={class:`help-callout`},LB={class:`dialog-foot`},RB={class:`right`},zB=M({__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)=>(F(),I(`div`,{class:`scrim`,onClick:n[2]||=As(e=>k(K).dialog=void 0,[`self`])},[R(`section`,jB,[R(`div`,MB,[n[3]||=R(`div`,null,[R(`span`,{class:`dialog-eyebrow`},`LEARN BY DOING`),R(`h3`,{id:`help-title`},`What makes this durable?`)],-1),R(`button`,{class:`icon-button`,"aria-label":`Close help`,onClick:n[0]||=e=>k(K).dialog=void 0},[z(k(yl),{size:18})])]),R(`div`,NB,[(F(),I(P,null,N(t,(e,t)=>R(`div`,{key:e.title,class:`help-step`},[R(`span`,PB,E(String(t+1).padStart(2,`0`)),1),R(`div`,null,[R(`b`,null,E(e.title),1),R(`div`,FB,E(e.body),1)])])),64)),R(`div`,IB,[z(k(kc),{size:18}),n[4]||=R(`span`,null,`Durable does not mean exactly-once external effects. Checkpoints protect progress. Tools still need their own idempotency.`,-1)])]),R(`div`,LB,[R(`div`,RB,[R(`button`,{class:`secondary`,type:`button`,onClick:n[1]||=e=>k(K).dialog=void 0},`Close`)])])])]))}}),BB=Gt({needed:!1,busy:!1,error:``}),VB=new Set,HB=e=>{let t=[...VB];VB=new Set;for(let n of t)n(e)},UB=()=>new Promise(e=>VB.add(e));async function WB(e){if(BB.busy||!e)return!1;BB.busy=!0,BB.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?(BB.needed=!1,HB(!0),!0):(BB.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 BB.error=`Cannot reach the hub.`,!1}finally{BB.busy=!1}}var GB=e=>{try{return new URL(e,location.href).pathname===`/api/session`}catch{return e===`/api/session`}};function KB(e){return(async(t,n)=>{let r=()=>e(t,n),i=await r();if(i.status!==401||GB(typeof t==`string`?t:t instanceof URL?t.href:t.url)||n?.body instanceof ReadableStream)return i;BB.needed=!0;let a=await i.text().catch(()=>``);return await UB()?r():new Response(a,{status:i.status,headers:i.headers})})}function qB(){typeof window>`u`||window.__adminFetch||(window.__adminFetch=!0,window.fetch=KB(window.fetch.bind(window)))}var JB={class:`login-veil`,"data-testid":`login-card`},YB=[`disabled`],XB={key:0,class:`message-error`,role:`alert`},ZB=[`disabled`],QB=M({__name:`LoginCard`,setup(e){let t=O(``),n=O();async function r(){if(BB.busy||!t.value.trim())return;let e=await WB(t.value.trim());t.value=``,e&&n.value?.blur()}return Hr(()=>void jn(()=>n.value?.focus())),(e,i)=>(F(),I(`div`,JB,[R(`form`,{class:`modal login-card`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`login-title`,onSubmit:As(r,[`prevent`])},[i[2]||=R(`header`,null,[R(`h2`,{id:`login-title`},`Admin token`)],-1),i[3]||=R(`p`,{class:`hint`},[B(` This hub is locked. Sign in with the token from its `),R(`code`,null,`admin.token`),B(` file. `)],-1),i[4]||=R(`label`,{for:`admin-token`},`Admin token`,-1),A(R(`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:k(BB).busy,onKeydown:i[1]||=Ms(e=>k(BB).error=``,[`esc`])},null,40,YB),[[bs,t.value]]),k(BB).error?(F(),I(`p`,XB,E(k(BB).error),1)):V(``,!0),R(`footer`,null,[R(`button`,{class:`primary`,type:`submit`,disabled:k(BB).busy||!t.value.trim()},E(k(BB).busy?`Checking…`:`Sign in`),9,ZB)])],32)]))}}),$B={key:0,class:`toast`,role:`status`},eV=M({__name:`Toast`,setup(e){return(e,t)=>(F(),L(xo,{name:`toast`},{default:Un(()=>[k(K).toast?(F(),I(`div`,$B,[z(k(nc),{size:18}),B(E(k(K).toast),1)])):V(``,!0)]),_:1}))}}),tV={class:`shell`,"data-testid":`app-shell`},nV={key:0,class:`error-banner`,role:`alert`},rV={key:4,class:`welcome`,"data-testid":`welcome-empty`},iV=[`disabled`],aV={class:`welcome-features`},oV={class:`modal path-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`path-title`},sV={class:`full-directory`},cV=M({__name:`App`,setup(e){let t=()=>xu.devices.value.filter(e=>e.status===`online`).length,n=O();function r(){K.dialog={kind:`new-session`,deviceId:G.value?.deviceId}}function i(e){let t=K.dialog?void 0:Cd(e);if(t)return e.preventDefault(),t===`tree`?yd():bd();if(e.key===`Escape`){if(K.dialog){K.dialog.kind===`pair`?n.value?.close():K.dialog=void 0;return}!e.repeat&&!e.isComposing&&Xu.value&&(e.preventDefault(),pd()),K.drawer=!1,K.inspectorOverlay=!1}}function a(e){let t=e.clientX,n=Tu.value,r=e=>Tu.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 Hr(()=>nf()),Hr(()=>{document.addEventListener(`keydown`,i),Uu()}),Gr(()=>{yu.stop(),document.removeEventListener(`keydown`,i)}),(e,i)=>(F(),I(`div`,tV,[z(Rd,{onNewSession:r}),k(K).error?(F(),I(`div`,nV,[z(k(kc),{size:18}),R(`span`,null,E(k(K).error),1),R(`button`,{class:`icon-button`,"aria-label":`Dismiss error`,onClick:i[0]||=e=>k(K).error=``},`×`)])):V(``,!0),R(`main`,{class:`net-workspace`,style:_e({"--tree-w":`${k(Tu)}px`})},[z(dp),k(Eu).tree?(F(),I(`div`,{key:0,class:`tree-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize network tree`,onPointerdown:As(a,[`prevent`])},null,32)):V(``,!0),k(K).drawer?(F(),I(`div`,{key:1,class:`tree-backdrop`,onClick:i[1]||=e=>k(K).drawer=!1})):V(``,!0),k(G)&&k(ku)&&k(Au)?(F(),I(P,{key:2},[z(KD),k(K).inspectorOverlay?(F(),I(`div`,{key:0,class:`inspector-backdrop`,onClick:i[2]||=e=>k(vd)()})):V(``,!0),(F(),L(py,{key:`${k(G).deviceId}/${k(G).sessionId}`}))],64)):k(G)&&k(ku)?(F(),L(nO,{key:3,device:k(ku)},null,8,[`device`])):(F(),I(`section`,rV,[i[14]||=R(`img`,{class:`welcome-symbol`,src:`/icons/durable-pi.svg`,alt:`Durable Pi`},null,-1),i[15]||=R(`span`,{class:`eyebrow`},`THE DURABLE AGENT NETWORK`,-1),i[16]||=R(`h1`,null,[B(`Close the tab.`),R(`br`),B(`The work continues.`)],-1),i[17]||=R(`p`,null,`Agents run on your devices. This page is only a window into them.`,-1),R(`button`,{class:`primary`,disabled:!t(),onClick:r},[z(k(Zc),{size:18}),B(E(k(xu).devices.value.length?`Create a session`:`Add a device to dpi-network.yaml`),1)],8,iV),R(`div`,aV,[R(`span`,null,[z(k(pc),{size:18}),i[11]||=B(`SQLite on each device`,-1)]),R(`span`,null,[z(k(wc),{size:18}),i[12]||=B(`Branch any agent`,-1)]),R(`span`,null,[z(k(Hs),{size:18}),i[13]||=B(`Watch from anywhere`,-1)])])]))],4),z(Vd),k(K).dialog?.kind===`pair`?(F(),L(cB,{key:1,ref_key:`pairWizard`,ref:n,handoff:k(K).dialog.handoff,onClose:i[3]||=e=>k(K).dialog=void 0},null,8,[`handoff`])):V(``,!0),k(K).dialog?.kind===`credentials`?(F(),L(fB,{key:2,"device-id":k(K).dialog.deviceId,onClose:i[4]||=e=>k(K).dialog=void 0},null,8,[`device-id`])):V(``,!0),k(K).dialog?.kind===`new-session`?(F(),L(SO,{key:3,"device-id":k(K).dialog.deviceId,onClose:i[5]||=e=>k(K).dialog=void 0},null,8,[`device-id`])):k(K).dialog?.kind===`prompt`?(F(),L(CB,{key:4,dialog:k(K).dialog,onClose:i[6]||=e=>k(K).dialog=void 0},null,8,[`dialog`])):k(K).dialog?.kind===`models`?(F(),L(AB,{key:5,onClose:i[7]||=e=>k(K).dialog=void 0})):k(K).dialog?.kind===`path`?(F(),I(`div`,{key:6,class:`modal-backdrop`,onClick:i[10]||=As(e=>k(K).dialog=void 0,[`self`])},[R(`section`,oV,[R(`header`,null,[i[18]||=R(`h2`,{id:`path-title`},`Working directory`,-1),R(`button`,{class:`icon-button`,"aria-label":`Close working directory`,onClick:i[8]||=e=>k(K).dialog=void 0},[z(k(yl),{size:18})])]),R(`code`,sV,E(k(K).dialog.path),1),R(`footer`,null,[R(`button`,{class:`secondary`,onClick:i[9]||=e=>k(K).dialog=void 0},`Close`)])])])):k(K).dialog?.kind===`help`?(F(),L(zB,{key:7})):V(``,!0),k(BB).needed?(F(),L(QB,{key:8})):V(``,!0),z(eV)]))}});qB();var lV=new URL(window.location.href);if(/^\/pair\/?$/.test(lV.pathname)){let e=Oz(lV);e?(lV.search=``,lV.hash=``,window.history.replaceState(window.history.state,``,lV),K.dialog={kind:`pair`,handoff:e}):window.history.replaceState(window.history.state,``,Az(lV))}Is(cV).mount(`#app`);
|
|
79
|
+
`)+E(t),1))),128))])):V(``,!0)])):V(``,!0),d.value?(F(),I(`pre`,SC,E(d.value.slice(0,6e3)),1)):V(``,!0)],64)):(F(),I(`p`,zb,[...t[41]||=[B(`Not a git repository — run `,-1),R(`code`,null,`git init`,-1),B(` (or open a session inside a repo).`,-1)]]))],2)):V(``,!0),C.value?(F(),I(`div`,{key:4,class:`modal-veil`,onClick:t[40]||=As(e=>C.value=null,[`self`])},[R(`div`,{class:T([`modal`,{danger:C.value.danger}]),role:`dialog`,"aria-modal":`true`},[R(`h5`,null,E(C.value.title),1),R(`p`,null,E(C.value.body),1),C.value.input?A((F(),I(`textarea`,{key:0,"onUpdate:modelValue":t[38]||=e=>re.value=e,rows:`2`,placeholder:C.value.input.placeholder},null,8,CC)),[[bs,re.value]]):V(``,!0),R(`div`,wC,[t[72]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`small`,onClick:t[39]||=e=>C.value=null},[...t[71]||=[B(`cancel `,-1),R(`span`,{class:`muted-line`},`(esc)`,-1)]]),R(`button`,{class:T([`primary small`,{danger:C.value.danger}]),disabled:!(!C.value.input||re.value.trim()),onClick:ae},E(C.value.confirmLabel??`confirm`),11,TC)])],2)])):V(``,!0)],64)):(F(),I(`p`,Fb,`No session selected — open a session to see its git.`))]))}}),[[`__scopeId`,`data-v-e5829ed1`]]),DC={class:`host-panel`,"aria-label":`Device vitals`},OC={class:`panel-heading`},kC=[`disabled`],AC={key:0,class:`hint`},jC={key:1,class:`message-error`},MC={key:2,class:`hint`},NC={class:`vitals-grid`},PC={class:`vital`},FC={class:`vital`},IC={key:0,class:`vital`},LC={class:`vital`},RC={class:`vital`},zC={class:`meter`},BC={class:`meter-head`},VC={class:`hint`},HC=[`aria-valuenow`],UC={class:`meter`},WC={class:`meter-head`},GC={class:`hint`},KC=[`aria-valuenow`],qC={class:`path`},JC={class:`hint`},YC=Ld(M({__name:`HostPanel`,setup(e){let t=O(),n=O(!1),r=O(``),i=H(()=>G.value?.deviceId),a=H(()=>xu.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=H(()=>t.value?c(t.value.memory.usedBytes,t.value.memory.totalBytes):0),u=H(()=>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 W(e).vitals()}catch(e){r.value=lu(e).slice(0,160)}finally{n.value=!1}}}j(i,d,{immediate:!0});async function f(){await d(),r.value||q(`Vitals refreshed.`)}return(e,c)=>(F(),I(`section`,DC,[R(`header`,OC,[R(`span`,null,[z(k(il),{size:16}),c[0]||=B(`HOST`,-1)]),R(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh vitals`,title:`Refresh vitals`,onClick:f},[z(k(el),{size:15,class:T({spin:n.value})},null,8,[`class`])],8,kC)]),i.value?r.value?(F(),I(`p`,jC,E(r.value),1)):t.value?(F(),I(P,{key:3},[R(`div`,NC,[R(`div`,PC,[c[1]||=R(`span`,{class:`label`},`Host uptime`,-1),R(`strong`,null,E(s(t.value.uptime)),1)]),R(`div`,FC,[c[2]||=R(`span`,{class:`label`},`Device process`,-1),R(`strong`,null,E(s(t.value.processUptime)),1),R(`em`,null,`pid `+E(t.value.pid),1)]),a.value?(F(),I(`div`,IC,[c[3]||=R(`span`,{class:`label`},`Keep-awake`,-1),R(`strong`,null,E(a.value===`none`?`off`:a.value),1),R(`em`,null,E(a.value===`none`?`no inhibitor here`:`held while sessions run`),1)])):V(``,!0),R(`div`,LC,[c[4]||=R(`span`,{class:`label`},`Load (1/5/15m)`,-1),R(`strong`,null,E(t.value.loadavg.map(e=>e.toFixed(2)).join(` · `)),1),R(`em`,null,E(t.value.cpuCount)+` CPU`+E(t.value.cpuCount===1?``:`s`),1)]),R(`div`,RC,[c[5]||=R(`span`,{class:`label`},`Sessions`,-1),R(`strong`,null,E(t.value.counts?.sessions??0),1),R(`em`,null,E(t.value.counts?.archived??0)+` archived`,1)])]),R(`div`,zC,[R(`div`,BC,[c[6]||=R(`span`,{class:`label`},`Memory`,-1),R(`span`,VC,E(o(t.value.memory.usedBytes))+` / `+E(o(t.value.memory.totalBytes))+` · device `+E(o(t.value.memory.processRssBytes)),1)]),R(`div`,{class:`bar`,role:`meter`,"aria-valuenow":l.value,"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`Memory used`},[R(`i`,{style:_e({width:`${l.value}%`}),class:T({high:l.value>=90})},null,6)],8,HC)]),R(`div`,UC,[R(`div`,WC,[c[7]||=R(`span`,{class:`label`},`Disk · data dir`,-1),R(`span`,GC,[t.value.disk.known?(F(),I(P,{key:0},[B(E(o(t.value.disk.totalBytes-t.value.disk.freeBytes))+` used · `+E(o(t.value.disk.freeBytes))+` free `,1)],64)):(F(),I(P,{key:1},[B(`unknown on this volume`)],64))])]),R(`div`,{class:`bar`,role:`meter`,"aria-valuenow":u.value,"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`Disk used`},[R(`i`,{style:_e({width:`${u.value}%`}),class:T({high:u.value>=90})},null,6)],8,KC),R(`code`,qC,E(t.value.disk.path),1)]),R(`p`,JC,[z(k(Hs),{size:13}),c[8]||=B(` Read on demand — open this tab or press refresh. Nothing polls the device. `,-1)])],64)):(F(),I(`p`,MC,E(n.value?`Reading host…`:`No vitals.`),1)):(F(),I(`p`,AC,`Select a session to see its device.`))]))}}),[[`__scopeId`,`data-v-ef6f9dc5`]]),XC={class:`usage-panel`,"aria-label":`Device usage`},ZC={class:`panel-heading`},QC=[`disabled`],$C={key:0,class:`hint`},ew={key:1,class:`message-error`},tw={key:2,class:`hint`},nw={key:3,class:`hint`},rw={class:`usage-block`,"aria-labelledby":`usage-totals`},iw={class:`totals`},aw={class:`total`},ow={class:`total`},sw={class:`total`},cw={class:`total`},lw={class:`usage-block`,"aria-labelledby":`usage-models`},uw={class:`section-label block-label`},dw={class:`table-scroll`},fw={class:`usage-table`,"aria-label":`Usage by model`},pw=[`title`],mw={class:`num`},hw={class:`num`},gw={class:`share-col`},_w={class:`share`},vw=[`aria-valuenow`,`aria-label`],yw={class:`pct`},bw={class:`usage-block`,"aria-labelledby":`usage-projects`},xw={class:`section-label block-label`},Sw={key:0,class:`hint`},Cw={key:1,class:`rows`},ww=[`title`],Tw={class:`row-main`},Ew={class:`row-num`},Dw={class:`row-num`},Ow={class:`row-meta`},kw={class:`usage-block`,"aria-labelledby":`usage-sessions`},Aw={key:0,class:`hint`},jw={key:1,class:`rows scroll`},Mw=[`title`],Nw={class:`row-main`},Pw={class:`row-num`},Fw={class:`row-num`},Iw={class:`row-meta`},Lw={class:`hint`},Rw=Ld(M({__name:`UsagePanel`,setup(e){let t=O(),n=O(!1),r=O(``),i=H(()=>G.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=H(()=>(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=H(()=>{let e=t.value;return!e||!e.models.length&&!e.sessions.length&&!e.projects.length}),u=H(()=>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 W(e).deviceUsage()}catch(e){r.value=lu(e).slice(0,160)}finally{n.value=!1}}}j(i,f,{immediate:!0});async function p(){await f(),r.value||q(`Usage refreshed.`)}return(e,s)=>(F(),I(`section`,XC,[R(`header`,ZC,[R(`span`,null,[z(k(Hs),{size:16}),s[0]||=B(`USAGE`,-1)]),R(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh usage`,title:`Refresh usage`,onClick:p},[z(k(el),{size:15,class:T({spin:n.value})},null,8,[`class`])],8,QC)]),i.value?r.value?(F(),I(`p`,ew,E(r.value),1)):t.value?l.value?(F(),I(`p`,nw,`No usage recorded yet.`)):(F(),I(P,{key:4},[R(`section`,rw,[s[6]||=R(`div`,{class:`section-label block-label`},[R(`span`,{id:`usage-totals`},`TOTALS`)],-1),R(`div`,iw,[R(`div`,aw,[s[1]||=R(`span`,{class:`label`},`Tokens`,-1),R(`strong`,null,E(a(t.value.totals.tokens)),1)]),R(`div`,ow,[s[2]||=R(`span`,{class:`label`},`Cost`,-1),R(`strong`,null,E(o(t.value.totals.cost)),1)]),R(`div`,sw,[s[3]||=R(`span`,{class:`label`},`Sessions`,-1),R(`strong`,null,E(a(t.value.sessions.length)),1),R(`em`,null,E(a(t.value.projects.length))+` projects`,1)]),R(`div`,cw,[s[4]||=R(`span`,{class:`label`},`Models`,-1),R(`strong`,null,E(a(t.value.models.length)),1),s[5]||=R(`em`,null,`costliest first`,-1)])])]),R(`section`,lw,[R(`div`,uw,[s[7]||=R(`span`,{id:`usage-models`},`BY MODEL`,-1),z(k(fc),{size:13})]),R(`div`,dw,[R(`table`,fw,[s[8]||=R(`colgroup`,null,[R(`col`),R(`col`),R(`col`),R(`col`)],-1),s[9]||=R(`thead`,null,[R(`tr`,null,[R(`th`,{scope:`col`},`Model`),R(`th`,{scope:`col`,class:`num`},`Tokens`),R(`th`,{scope:`col`,class:`num`},`Cost`),R(`th`,{scope:`col`,class:`share-col`},`Share`)])],-1),R(`tbody`,null,[(F(!0),I(P,null,N(t.value.models,e=>(F(),I(`tr`,{key:e.key},[R(`th`,{scope:`row`,class:`model-key`,title:`${e.key} — in ${e.input} · out ${e.output} · cache read ${e.cacheRead} · cache write ${e.cacheWrite}`},E(e.key),9,pw),R(`td`,mw,E(a(e.tokens)),1),R(`td`,hw,E(o(e.cost)),1),R(`td`,gw,[R(`div`,_w,[R(`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`},[R(`i`,{style:_e({width:`${c(e.cost)}%`}),class:T({high:c(e.cost)>90})},null,6)],8,vw),R(`em`,yw,E(c(e.cost))+`%`,1)])])]))),128))])])])]),R(`section`,bw,[R(`div`,xw,[s[10]||=R(`span`,{id:`usage-projects`},`BY PROJECT`,-1),z(k(yc),{size:13})]),t.value.projects.length?(F(),I(`ul`,Cw,[(F(!0),I(P,null,N(t.value.projects,e=>(F(),I(`li`,{key:e.rootPath,class:`row`,title:e.rootPath},[R(`span`,Tw,[R(`strong`,null,E(e.name),1),R(`em`,null,E(e.rootPath),1)]),R(`span`,Ew,E(a(e.tokens))+` tok`,1),R(`span`,Dw,E(o(e.cost)),1),R(`span`,Ow,E(d(e.sessions,`session`)),1)],8,ww))),128))])):(F(),I(`p`,Sw,`No project usage recorded yet.`))]),R(`section`,kw,[s[11]||=R(`div`,{class:`section-label block-label`},[R(`span`,{id:`usage-sessions`},`BY SESSION`)],-1),t.value.sessions.length?(F(),I(`ul`,jw,[(F(!0),I(P,null,N(t.value.sessions,e=>(F(),I(`li`,{key:e.id,class:`row`,title:e.cwd},[R(`span`,Nw,[R(`strong`,null,E(e.name),1),R(`em`,null,E(e.project??e.cwd),1)]),R(`span`,Pw,E(a(e.tokens))+` tok`,1),R(`span`,Fw,E(o(e.cost)),1),R(`span`,Iw,E(d(e.agents,`agent`)),1)],8,Mw))),128))])):(F(),I(`p`,Aw,`No session usage recorded yet.`))]),R(`p`,Lw,[z(k(Hs),{size:13}),B(` Read on demand — open this tab or press refresh (`+E(u.value)+`). Nothing polls the device. `,1)])],64)):(F(),I(`p`,tw,E(n.value?`Reading usage…`:`No usage recorded yet.`),1)):(F(),I(`p`,$C,`Select a session to see its device's usage.`))]))}}),[[`__scopeId`,`data-v-81e8eb49`]]),zw={class:`schedules-panel`,"aria-label":`Scheduled sessions`},Bw={class:`panel-heading`},Vw=[`disabled`],Hw=[`disabled`],Uw={key:0,class:`hint`},Ww={key:1,class:`message-error`},Gw=[`value`],Kw={class:`trigger-row`},qw={class:`inline`},Jw=[`disabled`],Yw={class:`inline`},Xw=[`disabled`],Zw={class:`row`},Qw=[`disabled`],$w={key:3,class:`hint`},eT={key:4,class:`schedule-list`},tT={class:`head`},nT={class:`tag`},rT={key:0,class:`tag running`},iT=[`title`],aT={class:`next`},oT={class:`cwd`},sT={key:0,class:`message-error`},cT={class:`row`},lT=[`disabled`,`onClick`],uT=[`disabled`,`onClick`],dT=[`disabled`,`onClick`],fT=Ld(M({__name:`SchedulesPanel`,setup(e){let t=O([]),n=O(``),r=O(``),i=O(!1),a=H(()=>G.value?.deviceId),o=()=>W(a.value??``),s=O(`60`),c=O(``),l=O(!1),u=O({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){let t=e.code;r.value=t===`not_found`||/allowlist/i.test(lu(e))?"This device runs an older build: update it (`dpi update`) to use schedules.":lu(e).slice(0,160)}finally{i.value=!1}}j(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(),q(r)}catch(e){q(lu(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 finished.`),_=e=>K.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=O([]);async function y(){l.value=!0,u.value={name:``,cwd:(G.value?.sessionId,``),prompt:``,model:``};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=[]}}async function b(){let e=u.value,[t,...r]=e.model.split(`/`),i=r.join(`/`);if(e.name.trim()&&e.cwd.trim()&&e.prompt.trim()&&t&&i){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(),q(`Schedule created. The device runs it on its own clock.`)}catch(e){q(lu(e).slice(0,160))}finally{n.value=``}}}return(e,o)=>(F(),I(`section`,zw,[R(`header`,Bw,[R(`span`,null,[z(k(tc),{size:16}),o[7]||=B(`SCHEDULES`,-1)]),R(`button`,{class:`icon-button`,disabled:i.value||!a.value,"aria-label":`Refresh schedules`,title:`Refresh schedules`,onClick:d},[z(k(el),{size:15,class:T({spin:i.value})},null,8,[`class`])],8,Vw),R(`button`,{class:`icon-button`,disabled:!a.value,"aria-label":`Add schedule`,title:`Add schedule`,onClick:y},[z(k(Zc),{size:15})],8,Hw)]),o[18]||=R(`p`,{class:`hint`},`Runs on the device's own clock — no browser needs to be open.`,-1),a.value?r.value?(F(),I(`p`,Ww,E(r.value),1)):V(``,!0):(F(),I(`p`,Uw,`Select a session to see its device.`)),l.value?(F(),I(`form`,{key:2,class:`add-form`,onSubmit:As(b,[`prevent`])},[R(`label`,null,[o[8]||=B(`Name`,-1),A(R(`input`,{"onUpdate:modelValue":o[0]||=e=>u.value.name=e,placeholder:`Nightly smoke`,required:``},null,512),[[bs,u.value.name]])]),R(`label`,null,[o[9]||=B(`Directory`,-1),A(R(`input`,{"onUpdate:modelValue":o[1]||=e=>u.value.cwd=e,placeholder:`/home/me/project`,required:``},null,512),[[bs,u.value.cwd]])]),R(`label`,null,[o[10]||=B(`Prompt`,-1),A(R(`textarea`,{"onUpdate:modelValue":o[2]||=e=>u.value.prompt=e,rows:`3`,placeholder:`Run the tests and summarise failures`,required:``},null,512),[[bs,u.value.prompt]])]),R(`label`,null,[o[11]||=B(`Model `,-1),A(R(`select`,{"onUpdate:modelValue":o[3]||=e=>u.value.model=e},[(F(!0),I(P,null,N(v.value,e=>(F(),I(`option`,{key:e.key,value:e.key},E(e.key),9,Gw))),128))],512),[[Cs,u.value.model]])]),R(`div`,Kw,[R(`label`,qw,[o[12]||=B(`Every `,-1),A(R(`input`,{"onUpdate:modelValue":o[4]||=e=>s.value=e,class:`num`,disabled:!!c.value.trim()},null,8,Jw),[[bs,s.value]]),o[13]||=B(` min`,-1)]),o[15]||=R(`span`,{class:`muted`},`or`,-1),R(`label`,Yw,[o[14]||=B(`daily at `,-1),A(R(`input`,{"onUpdate:modelValue":o[5]||=e=>c.value=e,class:`num time`,placeholder:`03:00`,disabled:!!s.value},null,8,Xw),[[bs,c.value]])])]),R(`div`,Zw,[R(`button`,{class:`primary small`,type:`submit`,disabled:n.value===`new`},E(n.value===`new`?`creating…`:`Create schedule`),9,Qw),R(`button`,{class:`small`,type:`button`,onClick:o[6]||=e=>l.value=!1},`Cancel`)])],32)):V(``,!0),!l.value&&!t.value.length&&a.value&&!r.value?(F(),I(`p`,$w,` No schedules yet. Press + to add one. `)):V(``,!0),t.value.length?(F(),I(`ul`,eT,[(F(!0),I(P,null,N(t.value,e=>(F(),I(`li`,{key:e.id,class:T([`schedule`,{off:!e.enabled}])},[R(`div`,tT,[R(`b`,null,E(e.name),1),R(`span`,nT,E(p(e)),1),e.running?(F(),I(`span`,rT,`running`)):e.lastOutcome===`failed`?(F(),I(`span`,{key:1,class:`tag bad`,title:e.lastError},`last run failed`,8,iT)):V(``,!0),R(`span`,aT,E(e.enabled?`next ${f(e.nextRunAt)}`:`paused`),1)]),R(`code`,oT,E(e.cwd),1),e.lastError?(F(),I(`p`,sT,E(e.lastError.slice(0,160)),1)):V(``,!0),R(`div`,cT,[R(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>g(e)},[z(k(Xc),{size:12}),o[16]||=B(`run now`,-1)],8,lT),R(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>h(e)},[z(k(Qc),{size:12}),B(E(e.enabled?`pause`:`resume`),1)],8,uT),R(`button`,{class:`small danger`,disabled:n.value===e.id,onClick:t=>_(e)},[z(k(fl),{size:12}),o[17]||=B(`remove`,-1)],8,dT)])],2))),128))])):V(``,!0)]))}}),[[`__scopeId`,`data-v-7f6db3c9`]]),pT={class:`graph-panel`,"aria-label":`Task graphs`},mT={class:`panel-heading`},hT=[`disabled`],gT=[`disabled`],_T={key:0,class:`hint`},vT={key:1,class:`message-error`},yT={key:2,class:`hint`},bT={class:`row`},xT=[`disabled`],ST={class:`head`},CT=[`title`],wT=[`aria-label`,`disabled`,`onClick`],TT=[`aria-label`,`onClick`],ET={class:`tasks`},DT=[`title`],OT={key:0,class:`deps`},kT={class:`tag`},AT={key:1,class:`err`},jT=Ld(M({__name:`GraphPanel`,setup(e){let t=O([]),n=O({}),r=O(!1),i=O(``),a=O(``),o=O(!1),s=O(``),c=H(()=>G.value?.deviceId),l=()=>W(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){let t=e.code;i.value=t===`not_found`||/allowlist/i.test(lu(e))?"This device runs an older build: update it (`dpi update`) to run task-graphs.":lu(e).slice(0,160)}finally{r.value=!1}}j(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||q(`This graph has not run yet.`)}catch(e){q(lu(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},q(`Run started: ${Object.keys(t.tasks).length} tasks.`),p(e)}catch(e){q(lu(e).slice(0,140))}finally{a.value=``}}function h(e){K.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=``,q(`Graph "${n.name}" added (${n.tasks.length} tasks).`),await u()}catch(e){q(lu(e).slice(0,200))}finally{a.value=``}}}return(e,l)=>(F(),I(`section`,pT,[R(`header`,mT,[R(`span`,null,[z(k(ml),{size:16}),l[3]||=B(`DAG`,-1)]),R(`button`,{class:`icon-button`,disabled:r.value||!c.value,"aria-label":`Refresh graphs`,title:`Refresh`,onClick:u},[z(k(el),{size:15,class:T({spin:r.value})},null,8,[`class`])],8,hT),R(`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},[z(k(Zc),{size:15})],8,gT)]),l[7]||=R(`p`,{class:`hint`},`Tasks run on the device, in dependency order — one fresh session each.`,-1),c.value?i.value?(F(),I(`p`,vT,E(i.value),1)):!t.value.length&&!o.value?(F(),I(`p`,yT,` No graphs yet. Press + and paste a graph JSON ({ name, cwd, tasks: [{ id, name, prompt, dependsOn }] }). `)):V(``,!0):(F(),I(`p`,_T,`Select a session to see its device.`)),o.value?(F(),I(`form`,{key:3,class:`add-form`,onSubmit:As(g,[`prevent`])},[R(`label`,null,[l[4]||=B(`Graph JSON `,-1),A(R(`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),[[bs,s.value]])]),R(`div`,bT,[R(`button`,{class:`primary small`,type:`submit`,disabled:a.value===`new`},E(a.value===`new`?`adding…`:`Add graph`),9,xT),R(`button`,{class:`small`,type:`button`,onClick:l[2]||=e=>o.value=!1},`Cancel`)])],32)):V(``,!0),(F(!0),I(P,null,N(t.value,e=>(F(),I(`div`,{key:e.id,class:`graph`},[R(`div`,ST,[R(`b`,null,E(e.name),1),R(`code`,{class:`cwd`,title:e.cwd},E(e.cwd.split(`/`).filter(Boolean).at(-1)||e.cwd),9,CT),R(`span`,{class:T([`tag`,d[e.lastRun?.status??`pending`]??``])},E(e.lastRun?e.lastRun.status:`never run`),3),l[5]||=R(`span`,{class:`spacer`},null,-1),R(`button`,{class:`icon-button`,"aria-label":`Run ${e.name}`,title:`Run now`,disabled:a.value===e.id,onClick:t=>m(e)},[z(k(Xc),{size:14})],8,wT),R(`button`,{class:`icon-button`,"aria-label":`Remove ${e.name}`,title:`Remove graph`,onClick:t=>h(e)},[z(k(fl),{size:14})],8,TT)]),R(`ul`,ET,[(F(!0),I(P,null,N(e.tasks,t=>(F(),I(`li`,{key:t.id,class:T(d[f(e,t.id)])},[l[6]||=R(`span`,{class:`dot`,"aria-hidden":`true`},null,-1),R(`span`,{class:`name`,title:t.prompt},E(t.name),9,DT),t.dependsOn.length?(F(),I(`code`,OT,`← `+E(t.dependsOn.join(`, `)),1)):V(``,!0),R(`span`,kT,E(f(e,t.id)),1),n.value[e.id]?.tasks[t.id]?.error?(F(),I(`em`,AT,E(n.value[e.id].tasks[t.id].error.slice(0,120)),1)):V(``,!0)],2))),128))])]))),128))]))}}),[[`__scopeId`,`data-v-25093c69`]]),MT={class:`notify-panel`,"aria-label":`Notification sinks`},NT={class:`panel-heading`},PT=[`disabled`],FT=[`disabled`],IT=[`disabled`],LT={key:0,class:`hint`},RT={key:1,class:`message-error`},zT=[`placeholder`],BT={class:`row`},VT=[`disabled`],HT={key:3,class:`hint`},UT={key:4,class:`sink-list`},WT={class:`head`},GT={class:`tag`},KT={class:`next`},qT={class:`url`},JT={key:0,class:`hint`},YT={key:1,class:`message-error`},XT={class:`row`},ZT=[`disabled`,`onClick`],QT=[`disabled`,`onClick`],$T={key:5,class:`results`,"aria-label":`Test results`},eE={class:`tag`},tE={key:0},nE=Ld(M({__name:`NotifyPanel`,setup(e){let t=O([]),n=O(``),r=O(``),i=O(!1),a=O([]),o=H(()=>G.value?.deviceId),s=()=>W(o.value??``),c=O(!1),l=O({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){let t=e.code;r.value=t===`not_found`||/allowlist/i.test(lu(e))?"This device runs an older build: update it (`dpi update`) to use notifications.":lu(e).slice(0,160)}finally{i.value=!1}}j(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(),q(`Sink added on the device.`)}catch(e){q(lu(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){q(lu(e).slice(0,140))}finally{n.value=``}}function m(e){K.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;q(a.value.length?`Test: ${a.value.length-e} sent${e?`, ${e} failed`:``}.`:`No enabled sinks matched — nothing was sent.`)}catch(e){q(lu(e).slice(0,160))}finally{n.value=``}}return(e,s)=>(F(),I(`section`,MT,[R(`header`,NT,[R(`span`,null,[z(k(Zs),{size:16}),s[6]||=B(`NOTIFY`,-1)]),R(`button`,{class:`icon-button`,disabled:i.value||!o.value,"aria-label":`Refresh sinks`,title:`Refresh sinks`,onClick:u},[z(k(el),{size:15,class:T({spin:i.value})},null,8,[`class`])],8,PT),R(`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},[z(k(rl),{size:15})],8,FT),R(`button`,{class:`icon-button`,disabled:!o.value,"aria-label":`Add a sink`,title:`Add a sink`,onClick:s[0]||=e=>c.value=!c.value},[z(k(Zc),{size:15})],8,IT)]),s[14]||=R(`p`,{class:`hint`},`Delivered by the device — no browser needs to be open.`,-1),o.value?r.value?(F(),I(`p`,RT,E(r.value),1)):V(``,!0):(F(),I(`p`,LT,`Select a session to see its device.`)),c.value?(F(),I(`form`,{key:2,class:`add-form`,onSubmit:As(f,[`prevent`])},[R(`label`,null,[s[8]||=B(`Kind `,-1),A(R(`select`,{"onUpdate:modelValue":s[1]||=e=>l.value.kind=e},[...s[7]||=[R(`option`,{value:`webhook`},`webhook (JSON POST)`,-1),R(`option`,{value:`ntfy`},`ntfy (topic)`,-1)]],512),[[Cs,l.value.kind]])]),R(`label`,null,[s[9]||=B(`URL `,-1),A(R(`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,zT),[[bs,l.value.url]])]),R(`label`,null,[s[10]||=B(`Label`,-1),A(R(`input`,{"onUpdate:modelValue":s[3]||=e=>l.value.label=e,placeholder:`phone`},null,512),[[bs,l.value.label]])]),R(`label`,null,[s[11]||=B(`Events `,-1),A(R(`input`,{"onUpdate:modelValue":s[4]||=e=>l.value.events=e,placeholder:`empty = all — e.g. session.failed,schedule.*`},null,512),[[bs,l.value.events]])]),R(`div`,BT,[R(`button`,{class:`primary small`,type:`submit`,disabled:n.value===`new`},E(n.value===`new`?`adding…`:`Add sink`),9,VT),R(`button`,{class:`small`,type:`button`,onClick:s[5]||=e=>c.value=!1},`Cancel`)]),s[12]||=R(`p`,{class:`hint`},[B(`LAN targets (192.168.x, localhost) need `),R(`code`,null,`DPI_NOTIFY_ALLOW_PRIVATE=1`),B(` on the device.`)],-1)],32)):V(``,!0),!c.value&&!t.value.length&&o.value&&!r.value?(F(),I(`p`,HT,` No sinks yet. Press + to add a webhook or an ntfy topic. `)):V(``,!0),t.value.length?(F(),I(`ul`,UT,[(F(!0),I(P,null,N(t.value,e=>(F(),I(`li`,{key:e.id,class:T([`sink`,{off:!e.enabled}])},[R(`div`,WT,[R(`span`,GT,E(e.kind),1),R(`b`,null,E(e.label||e.url),1),R(`em`,KT,E(e.lastError?`last failed`:`sent ${d(e.lastDeliveryAt)}`),1)]),R(`code`,qT,E(e.url),1),e.events?.length?(F(),I(`p`,JT,`events: `+E(e.events.join(`, `)),1)):V(``,!0),e.lastError?(F(),I(`p`,YT,E(e.lastError.slice(0,160)),1)):V(``,!0),R(`div`,XT,[R(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>p(e)},[z(k(Qc),{size:12}),B(E(e.enabled?`disable`:`enable`),1)],8,ZT),R(`button`,{class:`small danger`,disabled:n.value===e.id,onClick:t=>m(e)},[z(k(fl),{size:12}),s[13]||=B(`remove`,-1)],8,QT)])],2))),128))])):V(``,!0),a.value.length?(F(),I(`ul`,$T,[(F(!0),I(P,null,N(a.value,e=>(F(),I(`li`,{key:e.id,class:T(e.status)},[R(`span`,eE,E(e.status),1),B(` `+E(e.kind)+` `+E(e.id.slice(0,8))+` `,1),e.detail?(F(),I(`em`,tE,E(e.detail),1)):V(``,!0)],2))),128))])):V(``,!0)]))}}),[[`__scopeId`,`data-v-4b0b0465`]]),rE={class:`env-panel`,"aria-label":`Device environment`},iE={class:`panel-heading`},aE=[`disabled`],oE=[`disabled`],sE={key:0,class:`hint`},cE={key:1,class:`message-error`},lE={key:2,class:`message-restart`},uE={class:`row`},dE=[`disabled`],fE={key:4,class:`hint`},pE={key:5,class:`var-list`},mE={class:`head`},hE={class:`key`},gE={class:`tag`},_E={key:0,class:`tag`,title:`Has its own setting; edit that instead`},vE=[`aria-label`,`title`,`onClick`],yE=[`aria-label`,`onClick`],bE=[`title`],xE={key:6,class:`hint path`},SE={class:`panel-heading keys-heading`},CE=[`disabled`],wE=[`disabled`],TE={key:7,class:`message-error`},EE={class:`row`},DE=[`disabled`],OE={key:9,class:`hint`},kE={key:10,class:`var-list`},AE={class:`head`},jE={class:`key`},ME={class:`tag`},NE={key:0,class:`tag`,title:`Set by pi /login — read-only here`},PE=[`aria-label`,`onClick`],FE={class:`value`,title:`write-only — masked tail`},IE=Ld(M({__name:`EnvPanel`,setup(e){let t=O(null),n=O(!1),r=O(``),i=O(``),a=H(()=>G.value?.deviceId),o=()=>W(a.value??``),s=O(!1),c=O({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){let t=lu(e);r.value=e.code===`not_found`||/allowlist/i.test(t)?"This device runs an older build: update it (`dpi update`) to edit env vars.":t.slice(0,160)}finally{n.value=!1}m()}j(a,l,{immediate:!0});let u=O(null),d=O(``),f=O(!1),p=O({providerId:``,key:``});async function m(){if(!a.value)return void(u.value=null);try{u.value=await o().piAuth(),d.value=``}catch(e){let t=lu(e);d.value=e.code===`not_found`||/allowlist/i.test(t)?"This device runs an older build: update it (`dpi update`) to manage pi keys.":t.slice(0,160)}}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(),q(`${e} saved (now ${t.masked}) — restart the device to apply it.`)}catch(e){q(lu(e).slice(0,160))}finally{i.value=``}}}function g(e){K.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(),q(`${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(),q(`${e} saved — restart the device to apply it.`)}catch(e){q(lu(e).slice(0,160))}finally{i.value=``}}}function y(e){K.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(),q(`${e.key} saved — restart the device to apply it.`)}}}function b(e){K.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(),q(`${e.key} removed — restart the device to apply it.`)}}}return(e,o)=>(F(),I(`section`,rE,[R(`header`,iE,[R(`span`,null,[z(k(_c),{size:16}),o[8]||=B(`ENV`,-1)]),R(`button`,{class:`icon-button`,disabled:n.value||!a.value,"aria-label":`Refresh env`,title:`Refresh`,onClick:l},[z(k(el),{size:15,class:T({spin:n.value})},null,8,[`class`])],8,aE),R(`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},[z(k(Zc),{size:15})],8,oE)]),o[19]||=R(`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?(F(),I(`p`,cE,E(r.value),1)):t.value?.restartRequired?(F(),I(`p`,lE,[...o[9]||=[B(` Changed since boot — restart the device (`,-1),R(`code`,null,`dpi device stop && dpi device start`,-1),B(`) to apply. `,-1)]])):V(``,!0):(F(),I(`p`,sE,`Select a session to see its device.`)),s.value?(F(),I(`form`,{key:3,class:`add-form`,onSubmit:As(v,[`prevent`])},[R(`label`,null,[o[10]||=B(`Key (UPPER_SNAKE_CASE)`,-1),A(R(`input`,{"onUpdate:modelValue":o[1]||=e=>c.value.key=e,placeholder:`DPI_NOTIFY_ALLOW_PRIVATE`,required:``},null,512),[[bs,c.value.key]])]),R(`label`,null,[o[11]||=B(`Value`,-1),A(R(`input`,{"onUpdate:modelValue":o[2]||=e=>c.value.value=e,placeholder:`1`,required:``},null,512),[[bs,c.value.value]])]),R(`div`,uE,[R(`button`,{class:`primary small`,type:`submit`,disabled:i.value===`new`},E(i.value===`new`?`saving…`:`Save to env file`),9,dE),R(`button`,{class:`small`,type:`button`,onClick:o[3]||=e=>s.value=!1},`Cancel`)]),o[12]||=R(`p`,{class:`hint`},` Managed keys (DPI_TOKEN, DPI_PORT, start dirs…) have their own settings and are refused here. `,-1)],32)):V(``,!0),!s.value&&t.value&&!t.value.vars.length&&!r.value?(F(),I(`p`,fE,` No vars in the env file yet. `)):V(``,!0),t.value?.vars.length?(F(),I(`ul`,pE,[(F(!0),I(P,null,N(t.value.vars,e=>(F(),I(`li`,{key:e.key,class:T([`var`,{ro:!_(e)}])},[R(`div`,mE,[R(`code`,hE,E(e.key),1),R(`span`,gE,E(e.source===`process`?`process`:`file`),1),e.managed?(F(),I(`span`,_E,`managed`)):V(``,!0),o[13]||=R(`span`,{class:`spacer`},null,-1),_(e)?(F(),I(`button`,{key:1,class:`icon-button`,"aria-label":`Edit ${e.key}`,title:e.secret?`Replace the value`:`Edit the value`,onClick:t=>y(e)},[z(k(Jc),{size:13})],8,vE)):V(``,!0),_(e)?(F(),I(`button`,{key:2,class:`icon-button`,"aria-label":`Remove ${e.key}`,title:`Remove from the env file`,onClick:t=>b(e)},[z(k(fl),{size:13})],8,yE)):V(``,!0)]),R(`code`,{class:`value`,title:e.secret?`secret — masked`:e.masked},E(e.masked),9,bE)],2))),128))])):V(``,!0),t.value?(F(),I(`p`,xE,E(t.value.envFile),1)):V(``,!0),R(`header`,SE,[R(`span`,null,[z(k(Ac),{size:16}),o[14]||=B(`PI KEYS`,-1)]),R(`button`,{class:`icon-button`,disabled:n.value||!a.value,"aria-label":`Refresh pi keys`,title:`Refresh`,onClick:m},[z(k(el),{size:15})],8,CE),R(`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},[z(k(Zc),{size:15})],8,wE)]),o[20]||=R(`p`,{class:`hint`},[B(` Provider keys in pi's own `),R(`code`,null,`auth.json`),B(` — write-only: values are never shown, pi's interactive logins (oauth) are never touched. `)],-1),d.value?(F(),I(`p`,TE,E(d.value),1)):V(``,!0),f.value?(F(),I(`form`,{key:8,class:`add-form`,onSubmit:As(h,[`prevent`])},[R(`label`,null,[o[15]||=B(`Provider id`,-1),A(R(`input`,{"onUpdate:modelValue":o[5]||=e=>p.value.providerId=e,placeholder:`zai`,required:``},null,512),[[bs,p.value.providerId]])]),R(`label`,null,[o[16]||=B(`Key`,-1),A(R(`input`,{"onUpdate:modelValue":o[6]||=e=>p.value.key=e,type:`password`,autocomplete:`off`,placeholder:`paste the api key`,required:``},null,512),[[bs,p.value.key]])]),R(`div`,EE,[R(`button`,{class:`primary small`,type:`submit`,disabled:i.value===`pi-key`},E(i.value===`pi-key`?`saving…`:`Save to auth.json`),9,DE),R(`button`,{class:`small`,type:`button`,onClick:o[7]||=e=>f.value=!1},`Cancel`)]),o[17]||=R(`p`,{class:`hint`},`Applies after the next device restart. Existing keys for other providers stay as they are.`,-1)],32)):V(``,!0),!f.value&&u.value&&!u.value.entries.length&&!d.value?(F(),I(`p`,OE,` No provider keys found. `)):V(``,!0),u.value?.entries.length?(F(),I(`ul`,kE,[(F(!0),I(P,null,N(u.value.entries,e=>(F(),I(`li`,{key:e.providerId,class:`var`},[R(`div`,AE,[R(`code`,jE,E(e.providerId),1),R(`span`,ME,E(e.source),1),e.type===`api_key`?V(``,!0):(F(),I(`span`,NE,E(e.type),1)),o[18]||=R(`span`,{class:`spacer`},null,-1),e.type===`api_key`?(F(),I(`button`,{key:1,class:`icon-button`,"aria-label":`Remove ${e.providerId} key`,title:`Remove from auth.json`,onClick:t=>g(e.providerId)},[z(k(fl),{size:13})],8,PE)):V(``,!0)]),R(`code`,FE,E(e.masked),1)]))),128))])):V(``,!0)]))}}),[[`__scopeId`,`data-v-8aba9755`]]),LE={class:`extensions-panel`},RE={class:`panel-heading`},zE={key:0,class:`task-empty`},BE=[`data-extension`],VE={class:`ext-head`},HE=[`aria-checked`,`aria-label`,`disabled`,`onClick`],UE=[`checked`,`disabled`,`onChange`],WE=M({__name:`ExtensionsPanel`,setup(e){let t=an(),n=O(!1);async function r(){let e=Iu.value;if(!e||!Au.value)return void(t.value=void 0);t.value=await e.extensions().catch(()=>void 0)??t.value}j([Iu,Au,()=>JSON.stringify(Ku.value.agent.extensions??null)],r,{immediate:!0});async function i(e){let r=Iu.value;if(r&&!n.value){n.value=!0;try{let n=await od(()=>r.setExtension(e));n&&(t.value=n),td()}finally{n.value=!1}}}return(e,r)=>(F(),I(`div`,LE,[R(`div`,RE,[r[0]||=R(`h2`,null,`Extensions`,-1),z(k($c),{size:18})]),r[3]||=R(`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?V(``,!0):(F(),I(`p`,zE,`Loading extensions…`)),(F(!0),I(P,null,N(t.value?.extensions??[],e=>(F(),I(`article`,{key:e.name,class:T([`ext-card`,{on:e.enabled}]),"data-extension":e.name},[R(`div`,VE,[R(`div`,null,[R(`strong`,null,E(e.title),1),R(`code`,null,E(e.name),1)]),R(`button`,{class:T([`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]||=[R(`span`,null,null,-1)]],10,HE)]),R(`p`,null,E(e.description),1),e.prompts?(F(),I(`ul`,{key:0,class:T([`ext-prompts`,{off:!e.enabled}])},[(F(!0),I(P,null,N(e.prompts,e=>(F(),I(`li`,{key:e.id},[R(`label`,null,[R(`input`,{type:`checkbox`,checked:e.enabled,disabled:n.value,onChange:t=>i({prompt:e.id,enabled:t.target.checked})},null,40,UE),R(`code`,null,E(e.id),1)]),R(`span`,null,E(e.description),1),R(`details`,null,[r[2]||=R(`summary`,null,`View prompt`,-1),R(`pre`,null,E(e.text),1)])]))),128))],2)):V(``,!0)],10,BE))),128))]))}}),GE={class:`context-section`,"aria-labelledby":`context-title`},KE={class:`section-label`},qE={key:0,class:`hint`},JE={class:`context-numbers`},YE={class:`context-pct`},XE={key:0,class:`context-compacting`},ZE=[`aria-valuemax`,`aria-valuenow`,`aria-valuetext`],QE={class:`context-marker-label`},$E=[`aria-valuemin`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`],eD={class:`context-marker-label`},tD={class:`hint context-hint`},nD={class:`modal compaction-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`compaction-title`},rD={class:`context-toggle`},iD=[`checked`],aD=512,oD=4096,sD=1024,cD=M({__name:`ContextBar`,setup(e){let t=e=>e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e),n=H(()=>Qu.value?.contextWindow??0),r=H(()=>{let e=Ku.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}),i=H(()=>Ku.value.compactions.length>0),a=O(),o=H(()=>a.value??Pu.value?.compaction??ov(n.value));j(()=>JSON.stringify(Pu.value?.compaction),e=>{a.value&&e===JSON.stringify(a.value)&&(a.value=void 0)});let s=O(),c=H(()=>K.dialog?.kind===`compaction`),l=()=>void(K.dialog=void 0);Kr(()=>c.value&&l());let u=H(()=>s.value??sv(n.value,o.value)),d=e=>`${Math.min(100,Math.max(0,100*e/(n.value||1)))}%`,f=H(()=>Math.round(100*r.value/(n.value||1))),p=e=>{let t=e/(n.value||1);return t<.35?`start`:t>.65?`end`:`center`},m=(e,t)=>Math.min(n.value-sD,Math.max((t??oD)+sD,e)),h=(e,t)=>Math.min(t-sD,Math.max(oD,e));function g(e,t){let n=u.value,r=Math.round(t/aD)*aD;s.value=e===`wait`?{auto:n.auto,wait:m(r,n.auto)}:{auto:h(r,n.wait),wait:n.wait}}async function _(e){let t=Lu.value;if(!t)return;let n=await od(()=>t.setCompaction(e));n&&(a.value=n),s.value=void 0}function v(){let e=s.value;e&&_({reserveTokens:n.value-e.wait,...e.auto===void 0?{}:{backgroundTokens:e.wait-e.auto}})}let y=O(),b;function ee(e,t){b=e,t.currentTarget.setPointerCapture(t.pointerId)}function x(e){if(!b||!y.value)return;let t=y.value.getBoundingClientRect();g(b,(e.clientX-t.left)/t.width*n.value)}function S(){b&&(b=void 0,v())}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=u.value;g(e,(e===`auto`?r.auto??oD:r.wait)+n)}return(e,a)=>(F(),I(P,null,[R(`section`,GE,[R(`div`,KE,[a[7]||=R(`span`,{id:`context-title`},`CONTEXT`,-1),n.value?(F(),I(`button`,{key:0,class:`context-details-toggle`,onClick:a[0]||=e=>k(K).dialog={kind:`compaction`}},[z(k(kc),{size:16}),a[6]||=B(`Details `,-1)])):V(``,!0)]),n.value?(F(),I(P,{key:1},[R(`div`,JE,[R(`strong`,null,E(t(r.value)),1),R(`span`,null,`of `+E(t(n.value))+` tokens`,1),R(`span`,YE,E(f.value)+`%`,1),i.value?(F(),I(`span`,XE,[...a[8]||=[R(`i`,null,null,-1),B(`Compacting`,-1)]])):V(``,!0)]),R(`div`,{ref_key:`bar`,ref:y,class:T([`context-bar`,{off:!o.value.enabled}]),onPointermove:x,onPointerup:S,onPointercancel:S},[R(`div`,{class:T([`context-fill`,{hot:u.value.auto!==void 0&&r.value>=u.value.auto}]),style:_e({width:d(r.value)})},null,6),R(`div`,{class:`context-reserve`,style:_e({left:d(u.value.wait)}),title:`Reserved for the answer`},null,4),u.value.auto===void 0?V(``,!0):(F(),I(`button`,{key:0,class:T([`context-marker auto`,`label-${p(u.value.auto)}`]),role:`slider`,"aria-label":`Automatic compaction starts at`,"aria-valuemin":oD,"aria-valuemax":u.value.wait-sD,"aria-valuenow":u.value.auto,"aria-valuetext":`${t(u.value.auto)} tokens`,style:_e({left:d(u.value.auto)}),onPointerdown:a[1]||=e=>ee(`auto`,e),onKeydown:a[2]||=e=>te(`auto`,e),onKeyup:v,onBlur:v},[R(`span`,QE,`Auto-compact at `+E(t(u.value.auto)),1)],46,ZE)),R(`button`,{class:T([`context-marker wait`,`label-${p(u.value.wait)}`]),role:`slider`,"aria-label":`The next request waits for a summary at`,"aria-valuemin":(u.value.auto??oD)+sD,"aria-valuemax":n.value-sD,"aria-valuenow":u.value.wait,"aria-valuetext":`${t(u.value.wait)} tokens, ${t(n.value-u.value.wait)} reserved`,style:_e({left:d(u.value.wait)}),onPointerdown:a[3]||=e=>ee(`wait`,e),onKeydown:a[4]||=e=>te(`wait`,e),onKeyup:v,onBlur:v},[R(`span`,eD,`Reserve at `+E(t(u.value.wait)),1)],46,$E)],34),R(`p`,tD,[o.value.enabled?(F(),I(P,{key:0},[a[9]||=B(`Compacts in the background at `,-1),R(`strong`,null,E(t(u.value.auto??u.value.wait)),1),a[10]||=B(` and waits at `,-1),R(`strong`,null,E(t(u.value.wait)),1),a[11]||=B(`.`,-1)],64)):(F(),I(P,{key:1},[B(`Automatic compaction is off.`)],64))])],64)):(F(),I(`div`,qE,`Pick a model to see its context window.`))]),(F(),L(ur,{to:`body`},[c.value?(F(),I(`div`,{key:0,class:`modal-backdrop`,onClick:As(l,[`self`])},[R(`section`,nD,[R(`header`,null,[a[12]||=R(`h2`,{id:`compaction-title`},`Context compaction`,-1),R(`button`,{class:`icon-button`,"aria-label":`Close context compaction`,onClick:l},[z(k(yl),{size:18})])]),R(`p`,null,[a[13]||=B(` A summary starts in the background at `,-1),R(`strong`,null,E(t(u.value.auto??u.value.wait)),1),a[14]||=B(`. Above `,-1),R(`strong`,null,E(t(u.value.wait)),1),B(` the next request waits for it, keeping `+E(t(n.value-u.value.wait))+` free for the answer. Drag a marker on the bar to change either point. `,1)]),a[16]||=R(`p`,null,[B(`Older entries stay stored, and `),R(`code`,null,`search_history`),B(` still finds them.`)],-1),R(`label`,rD,[R(`input`,{type:`checkbox`,checked:o.value.enabled,onChange:a[5]||=e=>_({enabled:e.target.checked})},null,40,iD),a[15]||=B(` Automatic compaction `,-1)]),a[17]||=R(`p`,{class:`hint`},[B(` Applies to every agent in this session. `),R(`code`,null,`/compact`),B(` works either way. `)],-1),R(`footer`,null,[R(`button`,{class:`secondary`,onClick:l},`Close`)])])])):V(``,!0)]))],64))}}),lD=/^[A-Za-z_$][\w$]*$/,uD=e=>` `.repeat(e);function dD(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`),fD(t,0,r),r(`): `,`punct`),r(`Promise`,`type`),r(`<`,`punct`),r(`ToolResult`,`type`),r(`>;`,`punct`),n}function fD(e,t,n){if(!e||typeof e!=`object`)return n(`unknown`,`type`);if(`const`in e)return hD(e.const,n);if(e.enum)return mD(e.enum.map(e=>({const:e})),t,n);if(e.anyOf??e.oneOf)return mD(e.anyOf??e.oneOf,t,n);if(Array.isArray(e.type))return mD(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`),fD(e.items,t,n),r&&n(`)`,`punct`),n(`[]`,`punct`)}case`object`:return pD(e,t,n);default:return n(`unknown`,`type`)}}function pD(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`),fD(e.additionalProperties,t,n),n(`>`,`punct`)):n(`{}`,`punct`);let i=new Set(e.required??[]);n(`{`,`punct`),n(`
|
|
80
|
+
`);for(let[e,a]of r){let r=gD(a);r&&n(`${uD(t+1)}${r}\n`,`comment`),n(uD(t+1)),n(lD.test(e)?e:JSON.stringify(e),`property`),n(i.has(e)?`: `:`?: `,`punct`),fD(a,t+1,n),n(`;`,`punct`),n(`
|
|
81
|
+
`)}n(uD(t)),n(`}`,`punct`)}function mD(e,t,n){e.forEach((e,r)=>{r&&n(` | `,`punct`),fD(e,t,n)})}function hD(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 gD(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 _D={key:0,class:`panel-rail`,"aria-label":`Inspector (collapsed)`},vD=[`title`],yD=[`aria-label`,`title`,`onClick`],bD={key:0,class:`count`},xD={class:`inspector-tabs`,role:`tablist`,"aria-label":`Session details`},SD=[`id`,`aria-selected`,`onClick`],CD={key:0,class:`count`},wD=[`title`],TD=[`aria-labelledby`],ED={class:`session-heading`},DD=[`disabled`],OD=[`disabled`],kD=[`title`],AD={class:`cwd-trail`,dir:`rtl`},jD={dir:`ltr`},MD={class:`session-status`},ND={key:0,class:`background-pill`},PD=[`title`],FD={class:`model-section`},ID=[`src`],LD={class:`thinking-row`},RD=[`value`],zD={class:`stats-section`,"aria-labelledby":`stats-title`},BD={class:`metrics`},VD=[`title`],HD={class:`usage-breakdown`,"aria-label":`Agent token and cost breakdown`},UD={scope:`row`},WD={class:`usage-total`},GD={class:`panel-heading`},KD={class:`hint app-state-description`},qD=[`disabled`],JD={class:`state-json-actions`},YD={key:0,class:`hint`},XD=[`disabled`],ZD=[`disabled`],QD={key:0,class:`message-error`,role:`alert`},$D={class:`panel-heading`},eO={class:`tag`},tO={class:`hook-card`},nO=[`aria-checked`],rO={key:0,class:`tag tool-disabled`},iO={class:`tag`},aO=[`aria-label`],oO=Ld(M({__name:`Inspector`,setup(e){let t=H(()=>new Map($u.value?.tools.map(e=>[e.name,dD(e.name,e.parameters)]))),n=[{id:`session`,label:`Session`,icon:bc},{id:`git`,label:`Git`,icon:Sc},{id:`host`,label:`Host`,icon:Hs},{id:`usage`,label:`Usage`,icon:Yc},{id:`auto`,label:`Auto`,icon:tc},{id:`dag`,label:`DAG`,icon:ml},{id:`notify`,label:`Notify`,icon:Zs},{id:`env`,label:`Env`,icon:_c},{id:`state`,label:`State`,icon:$s},{id:`tasks`,label:`Tasks`,icon:Hs},{id:`tools`,label:`Tools`,icon:vl},{id:`extensions`,label:`Extend`,icon:$c}],r=H(()=>[{label:`Input`,tokens:Zu.value.input,cost:Zu.value.inputCost},{label:`Output`,tokens:Zu.value.output,cost:Zu.value.outputCost},{label:`Cache read`,tokens:Zu.value.cacheRead,cost:Zu.value.cacheReadCost},{label:`Cache write`,tokens:Zu.value.cacheWrite,cost:Zu.value.cacheWriteCost}]),i=H(()=>Yu.value.filter(e=>e.background).length),a=O(!1);function o(e,t){od(async()=>{await Iu.value.configure(e),await td(),t&&q(t)})}async function s(){let e=ku.value,t=Pu.value;if(e&&t)try{let n=await W(e.id).agent(t.id,G.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),q(`Transcript downloaded.`)}catch(e){q(`transcript download failed: ${lu(e).slice(0,120)}`)}}async function c(){let e=ku.value,t=Pu.value;if(e&&t){a.value=!0;try{let n=await W(e.id).exportSession(t.id),r=Uint8Array.from(atob(n.base64),e=>e.charCodeAt(0)),i=URL.createObjectURL(new Blob([r],{type:n.mime||`application/zip`})),a=document.createElement(`a`);a.href=i,a.download=n.filename,a.click(),URL.revokeObjectURL(i),q(`Bundle downloaded (${Math.max(1,Math.round(n.bytes/1024))} KiB).`)}catch(e){q(`bundle export failed: ${lu(e).slice(0,120)}`)}finally{a.value=!1}}}let l=O(!1);function u(){let e=ku.value,t=Pu.value;e&&t&&!l.value&&(K.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()=>{l.value=!0;try{let n=W(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 cu.createShare({title:`${t.name} · ${e.name}`,agents:i}),o=`${location.origin}${a.url}`;await navigator.clipboard?.writeText(o).catch(()=>{}),q(`Share link copied — expires ${a.expiresAt.slice(0,10)}.`)}catch(e){q(`share failed: ${lu(e).slice(0,140)}`)}finally{l.value=!1}}})}function d(){let e=Lu.value;e&&(K.dialog={kind:`prompt`,title:`Rename session`,label:`Session name`,value:Pu.value?.name??``,submit:`Save name`,run:t=>e.rename(t)})}let f=Nu.sharedState,p=O(``),m=O(``),h=O(0),g=O(!1),_=O(``),v=H(()=>p.value!==m.value),y=H(()=>v.value&&f.value?.revision!==h.value);function b(){p.value=ld(f.value?.value??{}),m.value=p.value,h.value=f.value?.revision??0,_.value=``}j(f,()=>!v.value&&b(),{immediate:!0});async function ee(e){if(!g.value&&Iu.value){g.value=!0,_.value=``;try{await Iu.value.demo(`state`,e)}catch(e){_.value=lu(e)}finally{g.value=!1}}}async function x(){if(!g.value&&Iu.value){_.value=``,g.value=!0;try{let e=JSON.parse(p.value);if(!e||Array.isArray(e)||typeof e!=`object`)throw Error(`App State must be a JSON object.`);let t=await Iu.value.demo(`state`,{operation:`update`,path:``,value:e,expectedRevision:h.value});p.value=ld(t.value),m.value=p.value,h.value=t.revision,q(`Shared App State saved.`)}catch(e){_.value=lu(e)}finally{g.value=!1}}}let S=H(()=>$u.value?.config.readOnly===!0),te=H(()=>$u.value?.tools.filter(e=>e.offered).length??0);return(e,m)=>{let h=Qr(`Share2`);return F(),I(`aside`,{class:T([`inspector`,{collapsed:!k(gd),overlay:k(K).inspectorOverlay}])},[k(gd)?(F(),I(P,{key:1},[R(`div`,xD,[(F(),I(P,null,N(n,e=>R(`button`,{id:`inspector-tab-${e.id}`,key:e.id,role:`tab`,"aria-controls":`inspector-panel`,"aria-selected":k(K).tab===e.id,class:T({active:k(K).tab===e.id}),onClick:t=>k(K).tab=e.id},[(F(),L(ei(e.icon),{size:18})),B(E(e.label),1),e.id===`tasks`&&k(Yu).length?(F(),I(`span`,CD,E(k(Yu).length),1)):V(``,!0)],10,SD)),64)),R(`button`,{class:`icon-button panel-toggle`,"aria-label":`Collapse inspector`,title:`Collapse inspector (${k(Sd).inspector})`,onClick:m[1]||=e=>k(vd)()},[z(k(Wc),{size:18})],8,wD)]),R(`div`,{id:`inspector-panel`,class:T([`inspector-body`,{"session-panel":k(K).tab===`session`}]),role:`tabpanel`,"aria-labelledby":`inspector-tab-${k(K).tab}`},[k(K).tab===`session`?(F(),I(P,{key:0},[R(`section`,ED,[R(`h1`,null,[R(`span`,null,E(k(Pu)?.name??`Loading session`),1),R(`button`,{class:`icon-button`,title:`Rename session`,"aria-label":`Rename session`,onClick:d},[z(k(Jc),{size:18})]),R(`button`,{class:`icon-button`,title:`Download transcript (markdown)`,"aria-label":`Download transcript`,onClick:s},[z(k(mc),{size:18})]),R(`button`,{class:`icon-button`,title:`Download session bundle (.zip: manifest, transcripts, configs)`,"aria-label":`Download session bundle`,disabled:a.value,onClick:c},[z(k(Uc),{size:18})],8,DD),R(`button`,{class:`icon-button`,title:`Share a public read-only link to this transcript`,"aria-label":`Share transcript`,disabled:l.value,onClick:u},[z(h,{size:18})],8,OD)]),R(`button`,{class:`path cwd-button`,title:k(Pu)?.cwd,"aria-label":`Show full working directory`,onClick:m[2]||=e=>k(K).dialog={kind:`path`,path:k(Pu)?.cwd??``}},[z(k(bc),{size:18}),R(`span`,AD,[R(`bdi`,jD,E(k(Pu)?.cwd),1)])],8,kD),R(`div`,MD,[R(`span`,{class:T([`status-pill`,{working:k(Xu)}])},[m[7]||=R(`i`,null,null,-1),B(E(k(Xu)?`Working`:`Idle`),1)],2),i.value?(F(),I(`span`,ND,E(i.value)+` background`,1)):V(``,!0),R(`span`,{class:`saved`,title:k(ku)?.id},[z(k(il),{size:18}),B(E(k(ku)?.name??k(ku)?.id),1)],8,PD),k(ku)?(F(),L(zy,{key:1,device:k(ku)},null,8,[`device`])):V(``,!0)])]),k(ku)?(F(),L(nb,{key:0,device:k(ku)},null,8,[`device`])):V(``,!0),R(`section`,FD,[m[15]||=R(`div`,{class:`section-label`},[R(`span`,null,`AGENT`)],-1),R(`button`,{class:`model-button`,onClick:m[3]||=e=>k(K).dialog={kind:`models`}},[R(`img`,{src:k(ud)(k(Ku).agent.model?.modelId),alt:``},null,8,ID),R(`div`,null,[R(`strong`,null,E(k(Qu)?.name??k(Ku).agent.model?.modelId??`Loading…`),1),R(`small`,null,E(k(Qu)?.tier??``)+` / `+E(k(Ku).agent.model?.provider??``),1)]),z(k(rc),{size:18})]),R(`div`,LD,[m[8]||=R(`span`,null,`Thinking`,-1),R(`select`,{"aria-label":`Thinking level`,value:k(Ku).agent.thinkingLevel??`low`,onChange:m[4]||=e=>o({thinkingLevel:e.target.value},`Thinking ${e.target.value}. Used on the next turn.`)},[(F(!0),I(P,null,N(k(rv),e=>(F(),I(`option`,{key:e},E(e),1))),128))],40,RD)]),z(cD),R(`section`,zD,[m[14]||=R(`div`,{class:`section-label`},[R(`span`,{id:`stats-title`},`STATS`)],-1),R(`div`,BD,[R(`div`,{title:`${k(Zu).tokens.toLocaleString(`en-US`)} total tokens`},[R(`span`,null,E(k(cd)(k(Zu).tokens)),1),m[9]||=R(`small`,null,`total tokens`,-1)],8,VD),R(`div`,null,[R(`span`,null,`$`+E(k(Zu).cost.toFixed(4)),1),m[10]||=R(`small`,null,`agent cost`,-1)]),R(`div`,null,[R(`span`,null,E(k($u)?.tools.length??0),1),m[11]||=R(`small`,null,`tools`,-1)])]),R(`table`,HD,[m[13]||=R(`thead`,null,[R(`tr`,null,[R(`th`,{scope:`col`},`Type`),R(`th`,{scope:`col`},`Tokens`),R(`th`,{scope:`col`},`Cost (USD)`)])],-1),R(`tbody`,null,[(F(!0),I(P,null,N(r.value,e=>(F(),I(`tr`,{key:e.label},[R(`th`,UD,E(e.label),1),R(`td`,null,E(e.tokens.toLocaleString(`en-US`)),1),R(`td`,null,`$`+E(e.cost.toFixed(4)),1)]))),128)),R(`tr`,WD,[m[12]||=R(`th`,{scope:`row`},`Total`,-1),R(`td`,null,E(k(Zu).tokens.toLocaleString(`en-US`)),1),R(`td`,null,`$`+E(k(Zu).cost.toFixed(4)),1)])])])])])],64)):V(``,!0),k(K).tab===`state`?(F(),I(P,{key:1},[R(`div`,GD,[m[16]||=R(`h2`,null,`App State`,-1),z(k($s),{size:18})]),R(`p`,KD,` One shared JSON object for every agent, session and fork on `+E(k(ku)?.name??k(ku)?.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),A(R(`textarea`,{"onUpdate:modelValue":m[5]||=e=>p.value=e,class:`app-state-json`,"aria-label":`App State JSON`,spellcheck:`false`,disabled:g.value||!k(f),rows:`12`},null,8,qD),[[bs,p.value]]),R(`div`,JD,[y.value?(F(),I(`span`,YD,`State changed elsewhere. Load the latest JSON before saving.`)):V(``,!0),v.value?(F(),I(`button`,{key:1,class:`secondary`,disabled:g.value,onClick:b},E(y.value?`Load latest`:`Reset`),9,XD)):V(``,!0),R(`button`,{class:`primary small`,disabled:!v.value||g.value||y.value,onClick:x},E(g.value?`Saving…`:`Save JSON`),9,ZD)]),_.value?(F(),I(`p`,QD,E(_.value),1)):V(``,!0),z(Ny,{value:k(f)?.value??{},disabled:g.value||v.value||!k(f),onChange:ee},null,8,[`value`,`disabled`])],64)):V(``,!0),k(K).tab===`tasks`?(F(),L(Nb,{key:2})):V(``,!0),k(K).tab===`git`?(F(),L(EC,{key:3})):V(``,!0),k(K).tab===`host`?(F(),L(YC,{key:4})):V(``,!0),k(K).tab===`usage`?(F(),L(Rw,{key:5})):V(``,!0),k(K).tab===`auto`?(F(),L(fT,{key:6})):V(``,!0),k(K).tab===`dag`?(F(),L(jT,{key:7})):V(``,!0),k(K).tab===`notify`?(F(),L(nE,{key:8})):V(``,!0),k(K).tab===`env`?(F(),L(IE,{key:9})):V(``,!0),k(K).tab===`extensions`?(F(),L(WE,{key:10})):V(``,!0),k(K).tab===`tools`?(F(),I(P,{key:11},[R(`div`,$D,[m[17]||=R(`h2`,null,`Tools`,-1),R(`span`,eO,E(te.value)+` / `+E(k($u)?.tools.length??0),1)]),m[21]||=R(`p`,{class:`hint`},` Every tool this agent's extensions provide. Open one to see its definition. `,-1),R(`div`,tO,[R(`div`,null,[z(k(ol),{size:18}),m[19]||=R(`strong`,null,`Read only`,-1),R(`button`,{class:T([`switch`,{on:S.value}]),role:`switch`,"aria-checked":S.value,"aria-label":`Read only`,onClick:m[6]||=e=>o({readOnly:!S.value},S.value?`Read only off. Every tool is back.`:`Read only on. Tools that write are disabled.`)},[...m[18]||=[R(`span`,null,null,-1)]],10,nO)]),m[20]||=R(`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)]),(F(!0),I(P,null,N(k($u)?.tools,e=>(F(),I(`details`,{key:e.name,class:T([`tool-row`,{disabled:!e.offered}])},[R(`summary`,null,[z(k(vl),{size:18}),R(`strong`,null,E(e.name),1),e.offered?V(``,!0):(F(),I(`span`,rO,`disabled`)),R(`span`,iO,E(e.replay===`safe`?`replay safe`:`interrupt on crash`),1)]),R(`p`,null,E(e.description),1),e.parameters?(F(),I(`pre`,{key:0,class:`tool-signature`,"aria-label":`${e.name} TypeScript definition`},[R(`code`,null,[(F(!0),I(P,null,N(t.value.get(e.name),(e,t)=>(F(),I(`span`,{key:t,class:T(`tk-${e.kind}`)},E(e.text),3))),128))])],8,aO)):V(``,!0),R(`small`,null,E(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)):V(``,!0)],10,TD)],64)):(F(),I(`div`,_D,[R(`button`,{class:`icon-button panel-toggle`,"aria-label":`Expand inspector`,title:`Expand inspector (${k(Sd).inspector})`,onClick:m[0]||=e=>k(_d)()},[z(k(Gc),{size:18})],8,vD),(F(),I(P,null,N(n,e=>R(`button`,{key:e.id,class:T([`rail-tab`,{active:k(K).tab===e.id}]),"aria-label":`Open ${e.label}`,title:e.label,onClick:t=>k(_d)(e.id)},[(F(),L(ei(e.icon),{size:20})),e.id===`tasks`&&k(Yu).length?(F(),I(`span`,bD,E(k(Yu).length),1)):V(``,!0)],10,yD)),64))]))],2)}}}),[[`__scopeId`,`data-v-7856a74f`]]),sO={class:`chat-empty`},cO={class:`eyebrow`},lO={key:3,class:`hint offline-error`},uO={key:4,class:`offline-command`},dO={key:5,class:`hint`},fO={key:6,class:`hint`},pO={class:`offline-actions`},mO=[`disabled`],hO={key:7,class:`message-error`,role:`alert`},gO=M({__name:`OfflinePanel`,props:{device:{}},setup(e){let t=e,n=O(!1),r=O(``),i=H(()=>{let e=t.device,n=e.source===`config`;switch(e.status){case`checking`:return{title:`Checking ${e.id}…`,text:`Probing the device. This view fills in as soon as it answers.`};case`unauthorized`:return e.transport===`tunnel`?{title:`${e.id} tunnel credentials are not valid`,text:`Pair the device again — the hub will mint a fresh credential.`}:{title:e.hasToken?`${e.id} rejected its token`:`No token for ${e.id}`,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.id} 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.id} speaks another API version`,text:`Update the device's dpi-backend.`,command:n?`just net deploy ${e.id}`:void 0};default:return{title:`${e.id} is offline`,text:`Last seen ${dd(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 cu.check(t.device.id);e.status===`online`&&q(`${e.id} is online.`)}catch(e){r.value=lu(e)}finally{n.value=!1}}async function o(e){try{await navigator.clipboard.writeText(e),q(`Copied.`)}catch{q(`Clipboard needs localhost or HTTPS. Select the text to copy.`)}}return(t,s)=>(F(),I(`section`,{class:T([`chat-panel offline-panel`,e.device.status]),"aria-live":`polite`},[R(`div`,sO,[e.device.status===`checking`?(F(),L(k(Lc),{key:0,class:`spin`,size:30})):e.device.status===`mismatch`||e.device.status===`unauthorized`?(F(),L(k(al),{key:1,size:30})):(F(),L(k(hl),{key:2,size:30})),R(`span`,cO,E(e.device.kind.toUpperCase())+` · `+E(e.device.url??(e.device.transport===`tunnel`?`tunnel`:`no endpoint`)),1),R(`h2`,null,E(i.value.title),1),R(`p`,null,E(i.value.text),1),e.device.error?(F(),I(`p`,lO,E(e.device.error),1)):V(``,!0),i.value.command?(F(),I(`div`,uO,[R(`code`,null,E(i.value.command),1),R(`button`,{class:`icon-button`,"aria-label":`Copy command`,onClick:s[0]||=e=>o(i.value.command)},[z(k(cc),{size:18})])])):V(``,!0),i.value.command?(F(),I(`p`,dO,`Run it in this repo's terminal, then press Check now.`)):V(``,!0),i.value.alt?(F(),I(`p`,fO,[s[2]||=B(` Never deployed or rebuilt? `,-1),R(`code`,null,E(i.value.alt),1),s[3]||=B(` provisions it from scratch. `,-1)])):V(``,!0),R(`div`,pO,[R(`button`,{class:`secondary`,disabled:n.value,onClick:s[1]||=e=>a()},[z(k(el),{size:18}),B(E(n.value?`Checking…`:`Check now`),1)],8,mO)]),r.value?(F(),I(`p`,hO,E(r.value),1)):V(``,!0)])],2))}}),_O={class:`dir-browser`},vO={class:`dir-path`},yO=[`disabled`],bO=[`aria-busy`],xO=[`title`],SO=[`aria-selected`,`title`,`onClick`],CO={key:1,class:`hint`},wO={key:0,class:`message-error`,role:`alert`},TO=M({__name:`DirBrowser`,props:ci({deviceId:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=Oi(e,`modelValue`),r=O(),i=O(!1),a=O(``),o=0;async function s(e){let s=++o,c=t.deviceId;i.value=!0,a.value=``;try{let t=await W(c).dirs(e);return s===o?(r.value=t,t.path&&(n.value=t.path),t):void 0}catch(e){s===o&&(a.value=lu(e));return}finally{s===o&&(i.value=!1)}}return j(()=>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)=>(F(),I(`div`,_O,[R(`div`,vO,[A(R(`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]||=Ms(As(e=>s(n.value),[`prevent`]),[`enter`])},null,544),[[bs,n.value]]),R(`button`,{type:`button`,class:`secondary small`,disabled:i.value||!n.value,onClick:t[2]||=e=>s(n.value)},` Go `,8,yO)]),R(`div`,{class:`dir-list`,role:`listbox`,"aria-label":`Directories`,"aria-busy":i.value},[R(`button`,{type:`button`,class:`dir-item`,title:`Start directories`,onClick:t[3]||=e=>s(``)},[z(k(Oc),{size:16}),t[5]||=R(`span`,null,`Start dirs`,-1)]),r.value?.parent?(F(),I(`button`,{key:0,type:`button`,class:`dir-item`,title:r.value.parent,onClick:t[4]||=e=>s(r.value.parent)},[z(k(uc),{size:16}),t[6]||=R(`span`,null,`..`,-1)],8,xO)):V(``,!0),(F(!0),I(P,null,N(r.value?.dirs,e=>(F(),I(`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?(F(),L(k(bc),{key:0,size:16})):(F(),L(k(xc),{key:1,size:16})),R(`span`,null,E(e.name),1)],8,SO))),128)),r.value&&!r.value.dirs.length?(F(),I(`p`,CO,`No subdirectories.`)):V(``,!0)],8,bO),a.value?(F(),I(`p`,wO,E(a.value),1)):V(``,!0)]))}}),EO={key:0,class:`message-error`},DO=[`value`],OO={class:`field`},kO={key:0,class:`recent-cwds`},AO=[`title`,`onClick`],jO={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`},MO=[`value`],NO={key:2,class:`message-error`,role:`alert`},PO=[`disabled`],FO=`dpi-recent-cwds`,IO=Ld(M({__name:`NewSessionDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=H(()=>xu.devices.value.filter(e=>e.status===`online`)),a=O(i.value.find(e=>e.id===n.deviceId)?.id??i.value[0]?.id??``),o=H(()=>i.value.find(e=>e.id===a.value)),s=H(()=>{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=H(()=>!s.value.length||(o.value?.info?.models?.length??0)===0),l=H(()=>!!o.value?.info?.providerKeyMissing),u=e=>`${e.provider}/${e.id}`,d=O({name:``,cwd:``,model:``}),f=H(()=>{try{return JSON.parse(localStorage.getItem(FO)??`{}`)[a.value]??[]}catch{return[]}}),p=(e,t)=>{try{let n=JSON.parse(localStorage.getItem(FO)??`{}`),r=[t,...(n[e]??[]).filter(e=>e!==t)].slice(0,6);localStorage.setItem(FO,JSON.stringify({...n,[e]:r}))}catch{}},m=O(!1),h=O(``),g=O({});j(a,async e=>{if(g.value={},e)try{let{projects:t}=await W(e).projects(!0);g.value=Object.fromEntries(t.filter(e=>e.model).map(e=>[e.rootPath,e.model]))}catch{}},{immediate:!0}),j([()=>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}),j(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 W(o.value.id).createSession({name:d.value.name.trim()||`New session`,cwd:d.value.cwd.trim(),model:{provider:e.provider,modelId:e.id}});p(o.value.id,t.cwd);let n=t.agents.find(e=>e.kind===`root`)??t.agents[0];Ru({deviceId:o.value.id,sessionId:t.id,agentId:n?.id??1}),q(`Session created on ${o.value.id}.`),r(`close`)}catch(e){h.value=lu(e)}finally{m.value=!1}}}return(e,t)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:t[6]||=As(e=>r(`close`),[`self`])},[R(`form`,{class:`modal session-modal`,onSubmit:As(_,[`prevent`])},[R(`header`,null,[t[7]||=R(`div`,null,[R(`span`,{class:`eyebrow`},`A PERSISTENT WORKSPACE`),R(`h2`,null,`New session`)],-1),R(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close new session`,onClick:t[0]||=e=>r(`close`)},[z(k(yl),{size:18})])]),i.value.length?(F(),I(P,{key:1},[R(`label`,null,[t[8]||=B(`Device`,-1),A(R(`select`,{"onUpdate:modelValue":t[1]||=e=>a.value=e,"aria-label":`Device`},[(F(!0),I(P,null,N(i.value,e=>(F(),I(`option`,{key:e.id,value:e.id},E(e.name)+E(e.info?.hostname&&e.info.hostname!==e.name?` · ${e.info.hostname}`:``),9,DO))),128))],512),[[Cs,a.value]])]),R(`label`,null,[t[9]||=B(`Session name`,-1),A(R(`input`,{"onUpdate:modelValue":t[2]||=e=>d.value.name=e,autofocus:``,placeholder:`My durable agent`,maxlength:`100`},null,512),[[bs,d.value.name]])]),R(`div`,OO,[R(`span`,null,`Working directory on `+E(i.value.find(e=>e.id===a.value)?.name??a.value),1),f.value.length?(F(),I(`div`,kO,[(F(!0),I(P,null,N(f.value,e=>(F(),I(`button`,{key:e,type:`button`,class:T([`chip`,{on:e===d.value.cwd}]),title:e,onClick:t=>d.value.cwd=e},E(e.split(`/`).filter(Boolean).at(-1)||e),11,AO))),128))])):V(``,!0),z(TO,{modelValue:d.value.cwd,"onUpdate:modelValue":t[3]||=e=>d.value.cwd=e,"device-id":a.value},null,8,[`modelValue`,`device-id`])]),R(`label`,null,[t[10]||=B(`Model`,-1),c.value||l.value?(F(),I(`span`,jO,`no API key on device — chat needs one`)):V(``,!0),A(R(`select`,{"onUpdate:modelValue":t[4]||=e=>d.value.model=e,"aria-label":`New session model`},[(F(!0),I(P,null,N(s.value,e=>(F(),I(`option`,{key:u(e),value:u(e)},E(e.tier)+` / `+E(e.name),9,MO))),128))],512),[[Cs,d.value.model]])])],64)):(F(),I(`p`,EO,` No device is online. Start one with just backend run or just net up <id>, then try again. `)),h.value?(F(),I(`p`,NO,E(h.value),1)):V(``,!0),R(`footer`,null,[R(`button`,{type:`button`,class:`secondary`,onClick:t[5]||=e=>r(`close`)},`Cancel`),R(`button`,{class:`primary`,disabled:m.value||!d.value.model||!d.value.cwd||!o.value},[z(k(Zc),{size:18}),B(E(m.value?`Creating…`:`Create session`),1)],8,PO)])],32)]))}}),[[`__scopeId`,`data-v-78a7a326`]]),LO=new Uint8Array(512),RO=new Uint8Array(256);(()=>{let e=1;for(let t=0;t<255;t++)LO[t]=e,RO[e]=t,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)LO[e]=LO[e-255]})();var zO=(e,t)=>e===0||t===0?0:LO[RO[e]+RO[t]];function BO(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]^=zO(t[r],LO[n]);t=e}return t}function VO(e,t){let n=BO(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]^=zO(n[i+1],e)}return r}var HO=[21,25,29,33,37,41,45,49,53,57,61,65],UO=[19,34,55,80,108,136,156,194,232,274,324,370],WO=[7,10,15,20,26,36,40,48,60,72,80,96],GO=[7,10,15,20,26,18,20,24,30,18,20,24],KO=[[[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]]],qO=[[],[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]],JO=e=>e<=9?8:16;function YO(e){for(let t=1;t<=HO.length;t++)if(4+JO(t)+e*8<=UO[t-1]*8)return t;throw Error(`qr: payload too long (${e} bytes; v12L max ${UO[11]-3})`)}function XO(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,JO(t));for(let e of n)i(e,8);let a=UO[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 ZO(e,t){let n=GO[e-1],r=[],i=0;for(let[n,a]of KO[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=>VO(e,n));for(let e=0;e<n;e++)for(let t of s)a.push(t[e]);return a}function QO(e){return Array.from({length:e},()=>Array(e).fill(!1))}function $O(e,t){let n=HO[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=qO[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 ek(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 tk(e,t){let n=HO[0]*0+e.length,r=ek(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 nk(e,t,n,r){let i=e.length;HO[n-1]*HO[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(ik(l,i,n))continue;if(o>=(UO[n-1]+WO[n-1])*8){o++;continue}let t=a(o++);rk(l,i,r)&&(t=!t),e[l][i]=t}}s=!s}}function rk(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 ik(e,t,n){let r=HO[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=qO[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 ak(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 ok(e,t){let n=YO(new TextEncoder().encode(e).length),r=HO[n-1],i=ZO(n,XO(e,n)),a=QO(r);return $O(a,n),nk(a,i,n,t),tk(a,t),a}function sk(e,t){if(t!==void 0)return ok(e,t);let n;for(let t=0;t<8;t++){let r=ok(e,t),i=ak(r);(!n||i<n.score)&&(n={m:r,score:i})}return n.m}function ck(e,t=160){let n=sk(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 lk={class:`device-handoff`,"aria-label":`Pair this machine`},uk={class:`row`},dk=[`disabled`],fk=[`disabled`],pk={key:0,class:`target`,"data-testid":`device-url`},mk={key:1,class:`err`},hk=Ld(M({__name:`DeviceHandoff`,props:{offerFragment:{}},setup(e){let t=e,n=O(`4780`),r=O(!1),i=H(()=>{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)=>(F(),I(`section`,lk,[R(`header`,null,[z(k(Bc),{size:18}),t[1]||=R(`h3`,null,`Pair THIS machine`,-1)]),t[4]||=R(`p`,{class:`what`},[B(` 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 `),R(`code`,null,`dpi device`),B(` there first. `)],-1),R(`div`,uk,[R(`label`,null,[t[2]||=B(` local port `,-1),A(R(`input`,{"onUpdate:modelValue":t[0]||=e=>n.value=e,inputmode:`numeric`,spellcheck:`false`,"aria-label":`Local dpi backend port`},null,512),[[bs,n.value]])]),R(`button`,{class:`primary`,type:`button`,disabled:!i.value,onClick:a},[z(k(hc),{size:15}),t[3]||=B(`Open the device page `,-1)],8,dk),R(`button`,{class:`secondary`,type:`button`,disabled:!i.value,onClick:o},[z(k(cc),{size:15}),B(E(r.value?`Copied`:`Copy link`),1)],8,fk)]),i.value?(F(),I(`p`,pk,E(i.value),1)):V(``,!0),i.value?V(``,!0):(F(),I(`p`,mk,`port must be 1–65535`))]))}}),[[`__scopeId`,`data-v-01884b7b`]]);function gk(e){return Tk(e)&&!_k(e)&&!kk(e)&&Symbol.asyncIterator in e}function _k(e){return Array.isArray(e)}function vk(e){return typeof e==`bigint`}function yk(e){return typeof e==`boolean`}function bk(e){return e instanceof globalThis.Date}function xk(e){return typeof e==`function`}function Sk(e){return Tk(e)&&!_k(e)&&!kk(e)&&Symbol.iterator in e}function Ck(e){return e===null}function wk(e){return typeof e==`number`}function Tk(e){return typeof e==`object`&&!!e}function Ek(e){return e instanceof globalThis.RegExp}function Dk(e){return typeof e==`string`}function Ok(e){return typeof e==`symbol`}function kk(e){return e instanceof globalThis.Uint8Array}function Ak(e){return e===void 0}function jk(e){return e.map(e=>Ik(e))}function Mk(e){return new Date(e.getTime())}function Nk(e){return new Uint8Array(e)}function Pk(e){return new RegExp(e.source,e.flags)}function Fk(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=Ik(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=Ik(e[n]);return t}function Ik(e){return _k(e)?jk(e):bk(e)?Mk(e):kk(e)?Nk(e):Ek(e)?Pk(e):Tk(e)?Fk(e):e}function Lk(e){return Ik(e)}function Rk(e,t){return Lk(t===void 0?e:{...t,...e})}function zk(e){return typeof e==`object`&&!!e}function Bk(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function Vk(e){return e===void 0}function Hk(e){return typeof e==`number`}var Uk;(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=zk(t);return e.AllowArrayObject?n:n&&!Bk(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?Hk(t):Number.isFinite(t)}e.IsNumberLike=i;function a(t){let n=Vk(t);return e.AllowNullVoid?n||t===null:n}e.IsVoidLike=a})(Uk||={});function Wk(e){return globalThis.Object.freeze(e).map(e=>Yk(e))}function Gk(e){return e}function Kk(e){return e}function qk(e){return e}function Jk(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=Yk(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=Yk(e[n]);return globalThis.Object.freeze(t)}function Yk(e){return _k(e)?Wk(e):bk(e)?Gk(e):kk(e)?Kk(e):Ek(e)?qk(e):Tk(e)?Jk(e):e}function J(e,t){let n=t===void 0?e:{...t,...e};switch(Uk.InstanceMode){case`freeze`:return Yk(n);case`clone`:return Lk(n);default:return n}}var Xk=class extends Error{constructor(e){super(e)}},Zk=Symbol.for(`TypeBox.Transform`),Qk=Symbol.for(`TypeBox.Readonly`),$k=Symbol.for(`TypeBox.Optional`),eA=Symbol.for(`TypeBox.Hint`),Y=Symbol.for(`TypeBox.Kind`);function tA(e){return Tk(e)&&e[Qk]===`Readonly`}function nA(e){return Tk(e)&&e[$k]===`Optional`}function rA(e){return X(e,`Any`)}function iA(e){return X(e,`Argument`)}function aA(e){return X(e,`Array`)}function oA(e){return X(e,`AsyncIterator`)}function sA(e){return X(e,`BigInt`)}function cA(e){return X(e,`Boolean`)}function lA(e){return X(e,`Computed`)}function uA(e){return X(e,`Constructor`)}function dA(e){return X(e,`Date`)}function fA(e){return X(e,`Function`)}function pA(e){return X(e,`Integer`)}function mA(e){return X(e,`Intersect`)}function hA(e){return X(e,`Iterator`)}function X(e,t){return Tk(e)&&Y in e&&e[Y]===t}function gA(e){return yk(e)||wk(e)||Dk(e)}function _A(e){return X(e,`Literal`)}function vA(e){return X(e,`MappedKey`)}function yA(e){return X(e,`MappedResult`)}function bA(e){return X(e,`Never`)}function xA(e){return X(e,`Not`)}function SA(e){return X(e,`Null`)}function CA(e){return X(e,`Number`)}function wA(e){return X(e,`Object`)}function TA(e){return X(e,`Promise`)}function EA(e){return X(e,`Record`)}function DA(e){return X(e,`Ref`)}function OA(e){return X(e,`RegExp`)}function kA(e){return X(e,`String`)}function AA(e){return X(e,`Symbol`)}function jA(e){return X(e,`TemplateLiteral`)}function MA(e){return X(e,`This`)}function NA(e){return Tk(e)&&Zk in e}function PA(e){return X(e,`Tuple`)}function FA(e){return X(e,`Undefined`)}function IA(e){return X(e,`Union`)}function LA(e){return X(e,`Uint8Array`)}function RA(e){return X(e,`Unknown`)}function zA(e){return X(e,`Unsafe`)}function BA(e){return X(e,`Void`)}function VA(e){return Tk(e)&&Y in e&&Dk(e[Y])}function HA(e){return rA(e)||iA(e)||aA(e)||cA(e)||sA(e)||oA(e)||lA(e)||uA(e)||dA(e)||fA(e)||pA(e)||mA(e)||hA(e)||_A(e)||vA(e)||yA(e)||bA(e)||xA(e)||SA(e)||CA(e)||wA(e)||TA(e)||EA(e)||DA(e)||OA(e)||kA(e)||AA(e)||jA(e)||MA(e)||PA(e)||FA(e)||IA(e)||LA(e)||RA(e)||zA(e)||BA(e)||VA(e)}var UA=`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 WA(e){try{return new RegExp(e),!0}catch{return!1}}function GA(e){if(!Dk(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 KA(e){return YA(e)||Wj(e)}function qA(e){return Ak(e)||vk(e)}function JA(e){return Ak(e)||wk(e)}function YA(e){return Ak(e)||yk(e)}function XA(e){return Ak(e)||Dk(e)}function ZA(e){return Ak(e)||Dk(e)&&GA(e)&&WA(e)}function QA(e){return Ak(e)||Dk(e)&&GA(e)}function $A(e){return Ak(e)||Wj(e)}function ej(e){return Tk(e)&&e[$k]===`Optional`}function tj(e){return Z(e,`Any`)&&XA(e.$id)}function nj(e){return Z(e,`Argument`)&&wk(e.index)}function rj(e){return Z(e,`Array`)&&e.type===`array`&&XA(e.$id)&&Wj(e.items)&&JA(e.minItems)&&JA(e.maxItems)&&YA(e.uniqueItems)&&$A(e.contains)&&JA(e.minContains)&&JA(e.maxContains)}function ij(e){return Z(e,`AsyncIterator`)&&e.type===`AsyncIterator`&&XA(e.$id)&&Wj(e.items)}function aj(e){return Z(e,`BigInt`)&&e.type===`bigint`&&XA(e.$id)&&qA(e.exclusiveMaximum)&&qA(e.exclusiveMinimum)&&qA(e.maximum)&&qA(e.minimum)&&qA(e.multipleOf)}function oj(e){return Z(e,`Boolean`)&&e.type===`boolean`&&XA(e.$id)}function sj(e){return Z(e,`Computed`)&&Dk(e.target)&&_k(e.parameters)&&e.parameters.every(e=>Wj(e))}function cj(e){return Z(e,`Constructor`)&&e.type===`Constructor`&&XA(e.$id)&&_k(e.parameters)&&e.parameters.every(e=>Wj(e))&&Wj(e.returns)}function lj(e){return Z(e,`Date`)&&e.type===`Date`&&XA(e.$id)&&JA(e.exclusiveMaximumTimestamp)&&JA(e.exclusiveMinimumTimestamp)&&JA(e.maximumTimestamp)&&JA(e.minimumTimestamp)&&JA(e.multipleOfTimestamp)}function uj(e){return Z(e,`Function`)&&e.type===`Function`&&XA(e.$id)&&_k(e.parameters)&&e.parameters.every(e=>Wj(e))&&Wj(e.returns)}function dj(e){return Z(e,`Integer`)&&e.type===`integer`&&XA(e.$id)&&JA(e.exclusiveMaximum)&&JA(e.exclusiveMinimum)&&JA(e.maximum)&&JA(e.minimum)&&JA(e.multipleOf)}function fj(e){return Tk(e)&&Object.entries(e).every(([e,t])=>GA(e)&&Wj(t))}function pj(e){return Z(e,`Intersect`)&&!(Dk(e.type)&&e.type!==`object`)&&_k(e.allOf)&&e.allOf.every(e=>Wj(e)&&!Fj(e))&&XA(e.type)&&(YA(e.unevaluatedProperties)||$A(e.unevaluatedProperties))&&XA(e.$id)}function mj(e){return Z(e,`Iterator`)&&e.type===`Iterator`&&XA(e.$id)&&Wj(e.items)}function Z(e,t){return Tk(e)&&Y in e&&e[Y]===t}function hj(e){return vj(e)&&Dk(e.const)}function gj(e){return vj(e)&&wk(e.const)}function _j(e){return vj(e)&&yk(e.const)}function vj(e){return Z(e,`Literal`)&&XA(e.$id)&&yj(e.const)}function yj(e){return yk(e)||wk(e)||Dk(e)}function bj(e){return Z(e,`MappedKey`)&&_k(e.keys)&&e.keys.every(e=>wk(e)||Dk(e))}function xj(e){return Z(e,`MappedResult`)&&fj(e.properties)}function Sj(e){return Z(e,`Never`)&&Tk(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function Cj(e){return Z(e,`Not`)&&Wj(e.not)}function wj(e){return Z(e,`Null`)&&e.type===`null`&&XA(e.$id)}function Tj(e){return Z(e,`Number`)&&e.type===`number`&&XA(e.$id)&&JA(e.exclusiveMaximum)&&JA(e.exclusiveMinimum)&&JA(e.maximum)&&JA(e.minimum)&&JA(e.multipleOf)}function Ej(e){return Z(e,`Object`)&&e.type===`object`&&XA(e.$id)&&fj(e.properties)&&KA(e.additionalProperties)&&JA(e.minProperties)&&JA(e.maxProperties)}function Dj(e){return Z(e,`Promise`)&&e.type===`Promise`&&XA(e.$id)&&Wj(e.item)}function Oj(e){return Z(e,`Record`)&&e.type===`object`&&XA(e.$id)&&KA(e.additionalProperties)&&Tk(e.patternProperties)&&(e=>{let t=Object.getOwnPropertyNames(e.patternProperties);return t.length===1&&WA(t[0])&&Tk(e.patternProperties)&&Wj(e.patternProperties[t[0]])})(e)}function kj(e){return Z(e,`Ref`)&&XA(e.$id)&&Dk(e.$ref)}function Aj(e){return Z(e,`RegExp`)&&XA(e.$id)&&Dk(e.source)&&Dk(e.flags)&&JA(e.maxLength)&&JA(e.minLength)}function jj(e){return Z(e,`String`)&&e.type===`string`&&XA(e.$id)&&JA(e.minLength)&&JA(e.maxLength)&&ZA(e.pattern)&&QA(e.format)}function Mj(e){return Z(e,`Symbol`)&&e.type===`symbol`&&XA(e.$id)}function Nj(e){return Z(e,`TemplateLiteral`)&&e.type===`string`&&Dk(e.pattern)&&e.pattern[0]===`^`&&e.pattern[e.pattern.length-1]===`$`}function Pj(e){return Z(e,`This`)&&XA(e.$id)&&Dk(e.$ref)}function Fj(e){return Tk(e)&&Zk in e}function Ij(e){return Z(e,`Tuple`)&&e.type===`array`&&XA(e.$id)&&wk(e.minItems)&&wk(e.maxItems)&&e.minItems===e.maxItems&&(Ak(e.items)&&Ak(e.additionalItems)&&e.minItems===0||_k(e.items)&&e.items.every(e=>Wj(e)))}function Lj(e){return Z(e,`Undefined`)&&e.type===`undefined`&&XA(e.$id)}function Rj(e){return Z(e,`Union`)&&XA(e.$id)&&Tk(e)&&_k(e.anyOf)&&e.anyOf.every(e=>Wj(e))}function zj(e){return Z(e,`Uint8Array`)&&e.type===`Uint8Array`&&XA(e.$id)&&JA(e.minByteLength)&&JA(e.maxByteLength)}function Bj(e){return Z(e,`Unknown`)&&XA(e.$id)}function Vj(e){return Z(e,`Unsafe`)}function Hj(e){return Z(e,`Void`)&&e.type===`void`&&XA(e.$id)}function Uj(e){return Tk(e)&&Y in e&&Dk(e[Y])&&!UA.includes(e[Y])}function Wj(e){return Tk(e)&&(tj(e)||nj(e)||rj(e)||oj(e)||aj(e)||ij(e)||sj(e)||cj(e)||lj(e)||uj(e)||dj(e)||pj(e)||mj(e)||vj(e)||bj(e)||xj(e)||Sj(e)||Cj(e)||wj(e)||Tj(e)||Ej(e)||Dj(e)||Oj(e)||kj(e)||Aj(e)||jj(e)||Mj(e)||Nj(e)||Pj(e)||Ij(e)||Lj(e)||Rj(e)||zj(e)||Bj(e)||Vj(e)||Hj(e)||Uj(e))}var Gj=`(true|false)`,Kj=`(0|[1-9][0-9]*)`,qj=`(.*)`,Jj=`(?!.*)`;`${Gj}`;var Yj=`^${Kj}$`,Xj=`^${qj}$`,Zj=`^${Jj}$`;function Qj(e,t){return e.includes(t)}function $j(e){return[...new Set(e)]}function eM(e,t){return e.filter(e=>t.includes(e))}function tM(e,t){return e.reduce((e,t)=>eM(e,t),t)}function nM(e){return e.length===1?e[0]:e.length>1?tM(e.slice(1),e[0]):[]}function rM(e){let t=[];for(let n of e)t.push(...n);return t}function iM(e){return J({[Y]:`Any`},e)}function aM(e,t){return J({[Y]:`Array`,type:`array`,items:e},t)}function oM(e){return J({[Y]:`Argument`,index:e})}function sM(e,t){return J({[Y]:`AsyncIterator`,type:`AsyncIterator`,items:e},t)}function cM(e,t,n){return J({[Y]:`Computed`,target:e,parameters:t},n)}function lM(e,t){let{[t]:n,...r}=e;return r}function uM(e,t){return t.reduce((e,t)=>lM(e,t),e)}function dM(e){return J({[Y]:`Never`,not:{}},e)}function fM(e){return J({[Y]:`MappedResult`,properties:e})}function pM(e,t,n){return J({[Y]:`Constructor`,type:`Constructor`,parameters:e,returns:t},n)}function mM(e,t,n){return J({[Y]:`Function`,type:`Function`,parameters:e,returns:t},n)}function hM(e,t){return J({[Y]:`Union`,anyOf:e},t)}function gM(e){return e.some(e=>nA(e))}function _M(e){return e.map(e=>nA(e)?vM(e):e)}function vM(e){return uM(e,[$k])}function yM(e,t){return gM(e)?aP(hM(_M(e),t)):hM(_M(e),t)}function bM(e,t){return e.length===1?J(e[0],t):e.length===0?dM(t):yM(e,t)}function xM(e,t){return e.length===0?dM(t):e.length===1?J(e[0],t):hM(e,t)}var SM=class extends Xk{};function CM(e){return e.replace(/\\\$/g,`$`).replace(/\\\*/g,`*`).replace(/\\\^/g,`^`).replace(/\\\|/g,`|`).replace(/\\\(/g,`(`).replace(/\\\)/g,`)`)}function wM(e,t,n){return e[t]===n&&e.charCodeAt(t-1)!==92}function TM(e,t){return wM(e,t,`(`)}function EM(e,t){return wM(e,t,`)`)}function DM(e,t){return wM(e,t,`|`)}function OM(e){if(!(TM(e,0)&&EM(e,e.length-1)))return!1;let t=0;for(let n=0;n<e.length;n++)if(TM(e,n)&&(t+=1),EM(e,n)&&--t,t===0&&n!==e.length-1)return!1;return!0}function kM(e){return e.slice(1,e.length-1)}function AM(e){let t=0;for(let n=0;n<e.length;n++)if(TM(e,n)&&(t+=1),EM(e,n)&&--t,DM(e,n)&&t===0)return!0;return!1}function jM(e){for(let t=0;t<e.length;t++)if(TM(e,t))return!0;return!1}function MM(e){let[t,n]=[0,0],r=[];for(let i=0;i<e.length;i++)if(TM(e,i)&&(t+=1),EM(e,i)&&--t,DM(e,i)&&t===0){let t=e.slice(n,i);t.length>0&&r.push(PM(t)),n=i+1}let i=e.slice(n);return i.length>0&&r.push(PM(i)),r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`or`,expr:r}}function NM(e){function t(e,t){if(!TM(e,t))throw new SM(`TemplateLiteralParser: Index must point to open parens`);let n=0;for(let r=t;r<e.length;r++)if(TM(e,r)&&(n+=1),EM(e,r)&&--n,n===0)return[t,r];throw new SM(`TemplateLiteralParser: Unclosed group parens in expression`)}function n(e,t){for(let n=t;n<e.length;n++)if(TM(e,n))return[t,n];return[t,e.length]}let r=[];for(let i=0;i<e.length;i++)if(TM(e,i)){let[n,a]=t(e,i),o=e.slice(n,a+1);r.push(PM(o)),i=a}else{let[t,a]=n(e,i),o=e.slice(t,a);o.length>0&&r.push(PM(o)),i=a-1}return r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`and`,expr:r}}function PM(e){return OM(e)?PM(kM(e)):AM(e)?MM(e):jM(e)?NM(e):{type:`const`,const:CM(e)}}function FM(e){return PM(e.slice(1,e.length-1))}var IM=class extends Xk{};function LM(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 RM(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 zM(e){return e.type===`const`&&e.const===`.*`}function BM(e){return LM(e)||zM(e)?!1:RM(e)?!0:e.type===`and`||e.type===`or`?e.expr.every(e=>BM(e)):e.type===`const`||(()=>{throw new IM(`Unknown expression type`)})()}function VM(e){return BM(FM(e.pattern))}var HM=class extends Xk{};function*UM(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let n of UM(e.slice(1)))yield`${t}${n}`}function*WM(e){return yield*UM(e.expr.map(e=>[...qM(e)]))}function*GM(e){for(let t of e.expr)yield*qM(t)}function*KM(e){return yield e.const}function*qM(e){return e.type===`and`?yield*WM(e):e.type===`or`?yield*GM(e):e.type===`const`?yield*KM(e):(()=>{throw new HM(`Unknown expression`)})()}function JM(e){let t=FM(e.pattern);return BM(t)?[...qM(t)]:[]}function YM(e,t){return J({[Y]:`Literal`,const:e,type:typeof e},t)}function XM(e){return J({[Y]:`Boolean`,type:`boolean`},e)}function ZM(e){return J({[Y]:`BigInt`,type:`bigint`},e)}function QM(e){return J({[Y]:`Number`,type:`number`},e)}function $M(e){return J({[Y]:`String`,type:`string`},e)}function*eN(e){let t=e.trim().replace(/"|'/g,``);return t===`boolean`?yield XM():t===`number`?yield QM():t===`bigint`?yield ZM():t===`string`?yield $M():yield(()=>{let e=t.split(`|`).map(e=>YM(e.trim()));return e.length===0?dM():e.length===1?e[0]:bM(e)})()}function*tN(e){if(e[1]!==`{`)return yield*[YM(`$`),...nN(e.slice(1))];for(let t=2;t<e.length;t++)if(e[t]===`}`){let n=eN(e.slice(2,t)),r=nN(e.slice(t+1));return yield*[...n,...r]}yield YM(e)}function*nN(e){for(let t=0;t<e.length;t++)if(e[t]===`$`)return yield*[YM(e.slice(0,t)),...tN(e.slice(t))];yield YM(e)}function rN(e){return[...nN(e)]}var iN=class extends Xk{};function aN(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function oN(e,t){return jA(e)?e.pattern.slice(1,e.pattern.length-1):IA(e)?`(${e.anyOf.map(e=>oN(e,t)).join(`|`)})`:CA(e)||pA(e)||sA(e)?`${t}${Kj}`:kA(e)?`${t}${qj}`:_A(e)?`${t}${aN(e.const.toString())}`:cA(e)?`${t}${Gj}`:(()=>{throw new iN(`Unexpected Kind '${e[Y]}'`)})()}function sN(e){return`^${e.map(e=>oN(e,``)).join(``)}$`}function cN(e){return bM(JM(e).map(e=>YM(e)))}function lN(e,t){let n=Dk(e)?sN(rN(e)):sN(e);return J({[Y]:`TemplateLiteral`,type:`string`,pattern:n},t)}function uN(e){return JM(e).map(e=>e.toString())}function dN(e){let t=[];for(let n of e)t.push(...pN(n));return t}function fN(e){return[e.toString()]}function pN(e){return[...new Set(jA(e)?uN(e):IA(e)?dN(e.anyOf):_A(e)?fN(e.const):CA(e)||pA(e)?[`[number]`]:[])]}function mN(e,t,n){let r={};for(let i of Object.getOwnPropertyNames(t))r[i]=ON(e,pN(t[i]),n);return r}function hN(e,t,n){return mN(e,t.properties,n)}function gN(e,t,n){return fM(hN(e,t,n))}function _N(e,t){return e.map(e=>TN(e,t))}function vN(e){return e.filter(e=>!bA(e))}function yN(e,t){return mP(vN(_N(e,t)))}function bN(e){return e.some(e=>bA(e))?[]:e}function xN(e,t){return bM(bN(_N(e,t)))}function SN(e,t){return t in e?e[t]:t===`[number]`?bM(e):dM()}function CN(e,t){return t===`[number]`?e:dM()}function wN(e,t){return t in e?e[t]:dM()}function TN(e,t){return mA(e)?yN(e.allOf,t):IA(e)?xN(e.anyOf,t):PA(e)?SN(e.items??[],t):aA(e)?CN(e.items,t):wA(e)?wN(e.properties,t):dM()}function EN(e,t){return t.map(t=>TN(e,t))}function DN(e,t){return bM(EN(e,t))}function ON(e,t,n){if(DA(e)||DA(t)){if(!HA(e)||!HA(t))throw new Xk(`Index types using Ref parameters require both Type and Key to be of TSchema`);return cM(`Index`,[e,t])}return yA(t)?gN(e,t,n):vA(t)?MN(e,t,n):J(HA(t)?DN(e,pN(t)):DN(e,t),n)}function kN(e,t,n){return{[t]:ON(e,[t],Lk(n))}}function AN(e,t,n){return t.reduce((t,r)=>({...t,...kN(e,r,n)}),{})}function jN(e,t,n){return AN(e,t.keys,n)}function MN(e,t,n){return fM(jN(e,t,n))}function NN(e,t){return J({[Y]:`Iterator`,type:`Iterator`,items:e},t)}function PN(e){return globalThis.Object.keys(e).filter(t=>!nA(e[t]))}function FN(e,t){let n=PN(e);return J(n.length>0?{[Y]:`Object`,type:`object`,required:n,properties:e}:{[Y]:`Object`,type:`object`,properties:e},t)}var IN=FN;function LN(e,t){return J({[Y]:`Promise`,type:`Promise`,item:e},t)}function RN(e){return J(uM(e,[Qk]))}function zN(e){return J({...e,[Qk]:`Readonly`})}function BN(e,t){return t===!1?RN(e):zN(e)}function VN(e,t){let n=t??!0;return yA(e)?WN(e,n):BN(e,n)}function HN(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=VN(e[r],t);return n}function UN(e,t){return HN(e.properties,t)}function WN(e,t){return fM(UN(e,t))}function GN(e,t){return J(e.length>0?{[Y]:`Tuple`,type:`array`,items:e,additionalItems:!1,minItems:e.length,maxItems:e.length}:{[Y]:`Tuple`,type:`array`,minItems:e.length,maxItems:e.length},t)}function KN(e,t){return e in t?$N(e,t[e]):fM(t)}function qN(e){return{[e]:YM(e)}}function JN(e){let t={};for(let n of e)t[n]=YM(n);return t}function YN(e,t){return Qj(t,e)?qN(e):JN(t)}function XN(e,t){return KN(e,YN(e,t))}function ZN(e,t){return t.map(t=>$N(e,t))}function QN(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(t))n[r]=$N(e,t[r]);return n}function $N(e,t){let n={...t};return nA(t)?aP($N(e,uM(t,[$k]))):tA(t)?VN($N(e,uM(t,[Qk]))):yA(t)?KN(e,t.properties):vA(t)?XN(e,t.keys):uA(t)?pM(ZN(e,t.parameters),$N(e,t.returns),n):fA(t)?mM(ZN(e,t.parameters),$N(e,t.returns),n):oA(t)?sM($N(e,t.items),n):hA(t)?NN($N(e,t.items),n):mA(t)?hP(ZN(e,t.allOf),n):IA(t)?xM(ZN(e,t.anyOf),n):PA(t)?GN(ZN(e,t.items??[]),n):wA(t)?IN(QN(e,t.properties),n):aA(t)?aM($N(e,t.items),n):TA(t)?LN($N(e,t.item),n):t}function eP(e,t){let n={};for(let r of e)n[r]=$N(r,t);return n}function tP(e,t,n){let r=HA(e)?pN(e):e;return IN(eP(r,t({[Y]:`MappedKey`,keys:r})),n)}function nP(e){return J(uM(e,[$k]))}function rP(e){return J({...e,[$k]:`Optional`})}function iP(e,t){return t===!1?nP(e):rP(e)}function aP(e,t){let n=t??!0;return yA(e)?cP(e,n):iP(e,n)}function oP(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=aP(e[r],t);return n}function sP(e,t){return oP(e.properties,t)}function cP(e,t){return fM(sP(e,t))}function lP(e,t={}){let n=e.every(e=>wA(e)),r=HA(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return J(t.unevaluatedProperties===!1||HA(t.unevaluatedProperties)||n?{...r,[Y]:`Intersect`,type:`object`,allOf:e}:{...r,[Y]:`Intersect`,allOf:e},t)}function uP(e){return e.every(e=>nA(e))}function dP(e){return uM(e,[$k])}function fP(e){return e.map(e=>nA(e)?dP(e):e)}function pP(e,t){return uP(e)?aP(lP(fP(e),t)):lP(fP(e),t)}function mP(e,t={}){if(e.length===1)return J(e[0],t);if(e.length===0)return dM(t);if(e.some(e=>NA(e)))throw Error(`Cannot intersect transform types`);return pP(e,t)}function hP(e,t){if(e.length===1)return J(e[0],t);if(e.length===0)return dM(t);if(e.some(e=>NA(e)))throw Error(`Cannot intersect transform types`);return lP(e,t)}function gP(...e){let[t,n]=typeof e[0]==`string`?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=`string`)throw new Xk(`Ref: $ref must be a string`);return J({[Y]:`Ref`,$ref:t},n)}function _P(e,t){return cM(`Awaited`,[cM(e,t)])}function vP(e){return cM(`Awaited`,[gP(e)])}function yP(e){return hP(SP(e))}function bP(e){return xM(SP(e))}function xP(e){return CP(e)}function SP(e){return e.map(e=>CP(e))}function CP(e,t){return J(lA(e)?_P(e.target,e.parameters):mA(e)?yP(e.allOf):IA(e)?bP(e.anyOf):TA(e)?xP(e.item):DA(e)?vP(e.$ref):e,t)}function wP(e){let t=[];for(let n of e)t.push(jP(n));return t}function TP(e){return rM(wP(e))}function EP(e){return nM(wP(e))}function DP(e){return e.map((e,t)=>t.toString())}function OP(e){return[`[number]`]}function kP(e){return globalThis.Object.getOwnPropertyNames(e)}function AP(e){return MP?globalThis.Object.getOwnPropertyNames(e).map(e=>e[0]===`^`&&e[e.length-1]===`$`?e.slice(1,e.length-1):e):[]}function jP(e){return mA(e)?TP(e.allOf):IA(e)?EP(e.anyOf):PA(e)?DP(e.items??[]):aA(e)?OP(e.items):wA(e)?kP(e.properties):EA(e)?AP(e.patternProperties):[]}var MP=!1;function NP(e,t){return cM(`KeyOf`,[cM(e,t)])}function PP(e){return cM(`KeyOf`,[gP(e)])}function FP(e,t){return J(bM(IP(jP(e))),t)}function IP(e){return e.map(e=>e===`[number]`?QM():YM(e))}function LP(e,t){return lA(e)?NP(e.target,e.parameters):DA(e)?PP(e.$ref):yA(e)?BP(e,t):FP(e,t)}function RP(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=LP(e[r],Lk(t));return n}function zP(e,t){return RP(e.properties,t)}function BP(e,t){return fM(zP(e,t))}function VP(e){let t=[];for(let n of e)t.push(...jP(n));return $j(t)}function HP(e){return e.filter(e=>!bA(e))}function UP(e,t){let n=[];for(let r of e)n.push(...EN(r,[t]));return HP(n)}function WP(e,t){let n={};for(let r of t)n[r]=mP(UP(e,r));return n}function GP(e,t){return IN(WP(e,VP(e)),t)}function KP(e){return J({[Y]:`Date`,type:`Date`},e)}function qP(e){return J({[Y]:`Null`,type:`null`},e)}function JP(e){return J({[Y]:`Symbol`,type:`symbol`},e)}function YP(e){return J({[Y]:`Undefined`,type:`undefined`},e)}function XP(e){return J({[Y]:`Uint8Array`,type:`Uint8Array`},e)}function ZP(e){return J({[Y]:`Unknown`},e)}function QP(e){return e.map(e=>tF(e,!1))}function $P(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=VN(tF(e[n],!1));return t}function eF(e,t){return t===!0?e:VN(e)}function tF(e,t){return gk(e)||Sk(e)?eF(iM(),t):_k(e)?VN(GN(QP(e))):kk(e)?XP():bk(e)?KP():Tk(e)?eF(IN($P(e)),t):xk(e)?eF(mM([],ZP()),t):Ak(e)?YP():Ck(e)?qP():Ok(e)?JP():vk(e)?ZM():wk(e)||yk(e)||Dk(e)?YM(e):IN({})}function nF(e,t){return J(tF(e,!0),t)}function rF(e,t){return uA(e)?GN(e.parameters,t):dM(t)}function iF(e,t){if(Ak(e))throw Error(`Enum undefined or empty`);let n=globalThis.Object.getOwnPropertyNames(e).filter(e=>isNaN(e)).map(t=>e[t]);return xM([...new Set(n)].map(e=>YM(e)),{...t,[eA]:`Enum`})}var aF=class extends Xk{},Q;(function(e){e[e.Union=0]=`Union`,e[e.True=1]=`True`,e[e.False=2]=`False`})(Q||={});function oF(e){return e===Q.False?e:Q.True}function sF(e){throw new aF(e)}function cF(e){return Sj(e)||pj(e)||Rj(e)||Bj(e)||tj(e)}function lF(e,t){return Sj(t)?DF(e,t):pj(t)?CF(e,t):Rj(t)?uI(e,t):Bj(t)?fI(e,t):tj(t)?uF(e,t):sF(`StructuralRight`)}function uF(e,t){return Q.True}function dF(e,t){return pj(t)?CF(e,t):Rj(t)&&t.anyOf.some(e=>tj(e)||Bj(e))?Q.True:Rj(t)?Q.Union:Bj(t)||tj(t)?Q.True:Q.Union}function fF(e,t){return Bj(e)?Q.False:tj(e)?Q.Union:Sj(e)?Q.True:Q.False}function pF(e,t){return Ej(t)&&WF(t)?Q.True:cF(t)?lF(e,t):rj(t)?oF(gI(e.items,t.items)):Q.False}function mF(e,t){return cF(t)?lF(e,t):ij(t)?oF(gI(e.items,t.items)):Q.False}function hF(e,t){return cF(t)?lF(e,t):Ej(t)?qF(e,t):Oj(t)?QF(e,t):aj(t)?Q.True:Q.False}function gF(e,t){return _j(e)||oj(e)?Q.True:Q.False}function _F(e,t){return cF(t)?lF(e,t):Ej(t)?qF(e,t):Oj(t)?QF(e,t):oj(t)?Q.True:Q.False}function vF(e,t){return cF(t)?lF(e,t):Ej(t)?qF(e,t):cj(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>oF(gI(t.parameters[n],e))===Q.True)?oF(gI(e.returns,t.returns)):Q.False:Q.False}function yF(e,t){return cF(t)?lF(e,t):Ej(t)?qF(e,t):Oj(t)?QF(e,t):lj(t)?Q.True:Q.False}function bF(e,t){return cF(t)?lF(e,t):Ej(t)?qF(e,t):uj(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>oF(gI(t.parameters[n],e))===Q.True)?oF(gI(e.returns,t.returns)):Q.False:Q.False}function xF(e,t){return vj(e)&&wk(e.const)||Tj(e)||dj(e)?Q.True:Q.False}function SF(e,t){return dj(t)||Tj(t)?Q.True:cF(t)?lF(e,t):Ej(t)?qF(e,t):Oj(t)?QF(e,t):Q.False}function CF(e,t){return t.allOf.every(t=>gI(e,t)===Q.True)?Q.True:Q.False}function wF(e,t){return e.allOf.some(e=>gI(e,t)===Q.True)?Q.True:Q.False}function TF(e,t){return cF(t)?lF(e,t):mj(t)?oF(gI(e.items,t.items)):Q.False}function EF(e,t){return vj(t)&&t.const===e.const?Q.True:cF(t)?lF(e,t):Ej(t)?qF(e,t):Oj(t)?QF(e,t):jj(t)?tI(e,t):Tj(t)?MF(e,t):dj(t)?xF(e,t):oj(t)?gF(e,t):Q.False}function DF(e,t){return Q.False}function OF(e,t){return Q.True}function kF(e){let[t,n]=[e,0];for(;Cj(t);)t=t.not,n+=1;return n%2==0?t:ZP()}function AF(e,t){return Cj(e)?gI(kF(e),t):Cj(t)?gI(e,kF(t)):sF(`Invalid fallthrough for Not`)}function jF(e,t){return cF(t)?lF(e,t):Ej(t)?qF(e,t):Oj(t)?QF(e,t):wj(t)?Q.True:Q.False}function MF(e,t){return gj(e)||Tj(e)||dj(e)?Q.True:Q.False}function NF(e,t){return cF(t)?lF(e,t):Ej(t)?qF(e,t):Oj(t)?QF(e,t):dj(t)||Tj(t)?Q.True:Q.False}function PF(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function FF(e){return WF(e)}function IF(e){return PF(e,0)||PF(e,1)&&`description`in e.properties&&Rj(e.properties.description)&&e.properties.description.anyOf.length===2&&(jj(e.properties.description.anyOf[0])&&Lj(e.properties.description.anyOf[1])||jj(e.properties.description.anyOf[1])&&Lj(e.properties.description.anyOf[0]))}function LF(e){return PF(e,0)}function RF(e){return PF(e,0)}function zF(e){return PF(e,0)}function BF(e){return PF(e,0)}function VF(e){return WF(e)}function HF(e){let t=QM();return PF(e,0)||PF(e,1)&&`length`in e.properties&&oF(gI(e.properties.length,t))===Q.True}function UF(e){return PF(e,0)}function WF(e){let t=QM();return PF(e,0)||PF(e,1)&&`length`in e.properties&&oF(gI(e.properties.length,t))===Q.True}function GF(e){let t=mM([iM()],iM());return PF(e,0)||PF(e,1)&&`then`in e.properties&&oF(gI(e.properties.then,t))===Q.True}function KF(e,t){return gI(e,t)===Q.False||ej(e)&&!ej(t)?Q.False:Q.True}function qF(e,t){return Bj(e)?Q.False:tj(e)?Q.Union:Sj(e)||hj(e)&&FF(t)||gj(e)&&LF(t)||_j(e)&&RF(t)||Mj(e)&&IF(t)||aj(e)&&zF(t)||jj(e)&&FF(t)||Mj(e)&&IF(t)||Tj(e)&&LF(t)||dj(e)&&LF(t)||oj(e)&&RF(t)||zj(e)&&VF(t)||lj(e)&&BF(t)||cj(e)&&UF(t)||uj(e)&&HF(t)?Q.True:Oj(e)&&jj(XF(e))?t[eA]===`Record`?Q.True:Q.False:Oj(e)&&Tj(XF(e))&&PF(t,0)?Q.True:Q.False}function JF(e,t){return cF(t)?lF(e,t):Oj(t)?QF(e,t):Ej(t)?(()=>{for(let n of Object.getOwnPropertyNames(t.properties)){if(!(n in e.properties)&&!ej(t.properties[n]))return Q.False;if(ej(t.properties[n]))return Q.True;if(KF(e.properties[n],t.properties[n])===Q.False)return Q.False}return Q.True})():Q.False}function YF(e,t){return cF(t)?lF(e,t):Ej(t)&&GF(t)?Q.True:Dj(t)?oF(gI(e.item,t.item)):Q.False}function XF(e){return Yj in e.patternProperties?QM():Xj in e.patternProperties?$M():sF(`Unknown record key pattern`)}function ZF(e){return Yj in e.patternProperties?e.patternProperties[Yj]:Xj in e.patternProperties?e.patternProperties[Xj]:sF(`Unable to get record value schema`)}function QF(e,t){let[n,r]=[XF(t),ZF(t)];return hj(e)&&Tj(n)&&oF(gI(e,r))===Q.True?Q.True:zj(e)&&Tj(n)||jj(e)&&Tj(n)||rj(e)&&Tj(n)?gI(e,r):Ej(e)?(()=>{for(let t of Object.getOwnPropertyNames(e.properties))if(KF(r,e.properties[t])===Q.False)return Q.False;return Q.True})():Q.False}function $F(e,t){return cF(t)?lF(e,t):Ej(t)?qF(e,t):Oj(t)?gI(ZF(e),ZF(t)):Q.False}function eI(e,t){return gI(Aj(e)?$M():e,Aj(t)?$M():t)}function tI(e,t){return vj(e)&&Dk(e.const)||jj(e)?Q.True:Q.False}function nI(e,t){return cF(t)?lF(e,t):Ej(t)?qF(e,t):Oj(t)?QF(e,t):jj(t)?Q.True:Q.False}function rI(e,t){return cF(t)?lF(e,t):Ej(t)?qF(e,t):Oj(t)?QF(e,t):Mj(t)?Q.True:Q.False}function iI(e,t){return Nj(e)?gI(cN(e),t):Nj(t)?gI(e,cN(t)):sF(`Invalid fallthrough for TemplateLiteral`)}function aI(e,t){return rj(t)&&e.items!==void 0&&e.items.every(e=>gI(e,t.items)===Q.True)}function oI(e,t){return Sj(e)?Q.True:Bj(e)?Q.False:tj(e)?Q.Union:Q.False}function sI(e,t){return cF(t)?lF(e,t):Ej(t)&&WF(t)||rj(t)&&aI(e,t)?Q.True:Ij(t)?Ak(e.items)&&!Ak(t.items)||!Ak(e.items)&&Ak(t.items)?Q.False:Ak(e.items)&&!Ak(t.items)||e.items.every((e,n)=>gI(e,t.items[n])===Q.True)?Q.True:Q.False:Q.False}function cI(e,t){return cF(t)?lF(e,t):Ej(t)?qF(e,t):Oj(t)?QF(e,t):zj(t)?Q.True:Q.False}function lI(e,t){return cF(t)?lF(e,t):Ej(t)?qF(e,t):Oj(t)?QF(e,t):Hj(t)?mI(e,t):Lj(t)?Q.True:Q.False}function uI(e,t){return t.anyOf.some(t=>gI(e,t)===Q.True)?Q.True:Q.False}function dI(e,t){return e.anyOf.every(e=>gI(e,t)===Q.True)?Q.True:Q.False}function fI(e,t){return Q.True}function pI(e,t){return Sj(t)?DF(e,t):pj(t)?CF(e,t):Rj(t)?uI(e,t):tj(t)?uF(e,t):jj(t)?tI(e,t):Tj(t)?MF(e,t):dj(t)?xF(e,t):oj(t)?gF(e,t):rj(t)?fF(e,t):Ij(t)?oI(e,t):Ej(t)?qF(e,t):Bj(t)?Q.True:Q.False}function mI(e,t){return Lj(e)||Lj(e)?Q.True:Q.False}function hI(e,t){return pj(t)?CF(e,t):Rj(t)?uI(e,t):Bj(t)?fI(e,t):tj(t)?uF(e,t):Ej(t)?qF(e,t):Hj(t)?Q.True:Q.False}function gI(e,t){return Nj(e)||Nj(t)?iI(e,t):Aj(e)||Aj(t)?eI(e,t):Cj(e)||Cj(t)?AF(e,t):tj(e)?dF(e,t):rj(e)?pF(e,t):aj(e)?hF(e,t):oj(e)?_F(e,t):ij(e)?mF(e,t):cj(e)?vF(e,t):lj(e)?yF(e,t):uj(e)?bF(e,t):dj(e)?SF(e,t):pj(e)?wF(e,t):mj(e)?TF(e,t):vj(e)?EF(e,t):Sj(e)?OF(e,t):wj(e)?jF(e,t):Tj(e)?NF(e,t):Ej(e)?JF(e,t):Oj(e)?$F(e,t):jj(e)?nI(e,t):Mj(e)?rI(e,t):Ij(e)?sI(e,t):Dj(e)?YF(e,t):zj(e)?cI(e,t):Lj(e)?lI(e,t):Rj(e)?dI(e,t):Bj(e)?pI(e,t):Hj(e)?hI(e,t):sF(`Unknown left type operand '${e[Y]}'`)}function _I(e,t){return gI(e,t)}function vI(e,t,n,r,i){let a={};for(let o of globalThis.Object.getOwnPropertyNames(e))a[o]=SI(e[o],t,n,r,Lk(i));return a}function yI(e,t,n,r,i){return vI(e.properties,t,n,r,i)}function bI(e,t,n,r,i){return fM(yI(e,t,n,r,i))}function xI(e,t,n,r){let i=_I(e,t);return i===Q.Union?xM([n,r]):i===Q.True?n:r}function SI(e,t,n,r,i){return yA(e)?bI(e,t,n,r,i):vA(e)?J(EI(e,t,n,r,i)):J(xI(e,t,n,r),i)}function CI(e,t,n,r,i){return{[e]:SI(YM(e),t,n,r,Lk(i))}}function wI(e,t,n,r,i){return e.reduce((e,a)=>({...e,...CI(a,t,n,r,i)}),{})}function TI(e,t,n,r,i){return wI(e.keys,t,n,r,i)}function EI(e,t,n,r,i){return fM(TI(e,t,n,r,i))}function DI(e,t){return kI(cN(e),t)}function OI(e,t){let n=e.filter(e=>_I(e,t)===Q.False);return n.length===1?n[0]:xM(n)}function kI(e,t,n={}){return jA(e)?J(DI(e,t),n):yA(e)?J(MI(e,t),n):J(IA(e)?OI(e.anyOf,t):_I(e,t)===Q.False?e:dM(),n)}function AI(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=kI(e[r],t);return n}function jI(e,t){return AI(e.properties,t)}function MI(e,t){return fM(jI(e,t))}function NI(e,t){return FI(cN(e),t)}function PI(e,t){let n=e.filter(e=>_I(e,t)!==Q.False);return n.length===1?n[0]:xM(n)}function FI(e,t,n){return jA(e)?J(NI(e,t),n):yA(e)?J(RI(e,t),n):J(IA(e)?PI(e.anyOf,t):_I(e,t)===Q.False?dM():e,n)}function II(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=FI(e[r],t);return n}function LI(e,t){return II(e.properties,t)}function RI(e,t){return fM(LI(e,t))}function zI(e,t){return uA(e)?J(e.returns,t):dM(t)}function BI(e){return VN(aP(e))}function VI(e,t,n){return J({[Y]:`Record`,type:`object`,patternProperties:{[e]:t}},n)}function HI(e,t,n){let r={};for(let n of e)r[n]=t;return IN(r,{...n,[eA]:`Record`})}function UI(e,t,n){return VM(e)?HI(pN(e),t,n):VI(e.pattern,t,n)}function WI(e,t,n){return HI(pN(xM(e)),t,n)}function GI(e,t,n){return HI([e.toString()],t,n)}function KI(e,t,n){return VI(e.source,t,n)}function qI(e,t,n){return VI(Ak(e.pattern)?Xj:e.pattern,t,n)}function JI(e,t,n){return VI(Xj,t,n)}function YI(e,t,n){return VI(Zj,t,n)}function XI(e,t,n){return IN({true:t,false:t},n)}function ZI(e,t,n){return VI(Yj,t,n)}function QI(e,t,n){return VI(Yj,t,n)}function $I(e,t,n={}){return IA(e)?WI(e.anyOf,t,n):jA(e)?UI(e,t,n):_A(e)?GI(e.const,t,n):cA(e)?XI(e,t,n):pA(e)?ZI(e,t,n):CA(e)?QI(e,t,n):OA(e)?KI(e,t,n):kA(e)?qI(e,t,n):rA(e)?JI(e,t,n):bA(e)?YI(e,t,n):dM(n)}function eL(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function tL(e){let t=eL(e);return t===Xj?$M():t===Yj?QM():$M({pattern:t})}function nL(e){return e.patternProperties[eL(e)]}function rL(e,t){return t.parameters=_L(e,t.parameters),t.returns=vL(e,t.returns),t}function iL(e,t){return t.parameters=_L(e,t.parameters),t.returns=vL(e,t.returns),t}function aL(e,t){return t.allOf=_L(e,t.allOf),t}function oL(e,t){return t.anyOf=_L(e,t.anyOf),t}function sL(e,t){return Ak(t.items)||(t.items=_L(e,t.items)),t}function cL(e,t){return t.items=vL(e,t.items),t}function lL(e,t){return t.items=vL(e,t.items),t}function uL(e,t){return t.items=vL(e,t.items),t}function dL(e,t){return t.item=vL(e,t.item),t}function fL(e,t){let n=gL(e,t.properties);return{...t,...IN(n)}}function pL(e,t){let n=$I(vL(e,tL(t)),vL(e,nL(t)));return{...t,...n}}function mL(e,t){return t.index in e?e[t.index]:ZP()}function hL(e,t){let n=tA(t),r=nA(t),i=vL(e,t);return n&&r?BI(i):n&&!r?VN(i):!n&&r?aP(i):i}function gL(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((n,r)=>({...n,[r]:hL(e,t[r])}),{})}function _L(e,t){return t.map(t=>vL(e,t))}function vL(e,t){return uA(t)?rL(e,t):fA(t)?iL(e,t):mA(t)?aL(e,t):IA(t)?oL(e,t):PA(t)?sL(e,t):aA(t)?cL(e,t):oA(t)?lL(e,t):hA(t)?uL(e,t):TA(t)?dL(e,t):wA(t)?fL(e,t):EA(t)?pL(e,t):iA(t)?mL(e,t):t}function yL(e,t){return vL(t,Rk(e))}function bL(e){return J({[Y]:`Integer`,type:`integer`},e)}function xL(e,t,n){return{[e]:ML(YM(e),t,Lk(n))}}function SL(e,t,n){return e.reduce((e,r)=>({...e,...xL(r,t,n)}),{})}function CL(e,t,n){return SL(e.keys,t,n)}function wL(e,t,n){return fM(CL(e,t,n))}function TL(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),n].join(``)}function EL(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),n].join(``)}function DL(e){return e.toUpperCase()}function OL(e){return e.toLowerCase()}function kL(e,t,n){let r=FM(e.pattern);return BM(r)?lN([xM(jL([...qM(r)].map(e=>YM(e)),t))],n):{...e,pattern:AL(e.pattern,t)}}function AL(e,t){return typeof e==`string`?t===`Uncapitalize`?TL(e):t===`Capitalize`?EL(e):t===`Uppercase`?DL(e):t===`Lowercase`?OL(e):e:e.toString()}function jL(e,t){return e.map(e=>ML(e,t))}function ML(e,t,n={}){return vA(e)?wL(e,t,n):jA(e)?kL(e,t,n):IA(e)?xM(jL(e.anyOf,t),n):_A(e)?YM(AL(e.const,t),n):J(e,n)}function NL(e,t={}){return ML(e,`Capitalize`,t)}function PL(e,t={}){return ML(e,`Lowercase`,t)}function FL(e,t={}){return ML(e,`Uncapitalize`,t)}function IL(e,t={}){return ML(e,`Uppercase`,t)}function LL(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=qL(e[i],t,Lk(n));return r}function RL(e,t,n){return LL(e.properties,t,n)}function zL(e,t,n){return fM(RL(e,t,n))}function BL(e,t){return e.map(e=>KL(e,t))}function VL(e,t){return e.map(e=>KL(e,t))}function HL(e,t){let{[t]:n,...r}=e;return r}function UL(e,t){return t.reduce((e,t)=>HL(e,t),e)}function WL(e,t,n){let r=uM(e,[Zk,`$id`,`required`,`properties`]);return IN(UL(n,t),r)}function GL(e){return xM(e.reduce((e,t)=>gA(t)?[...e,YM(t)]:e,[]))}function KL(e,t){return mA(e)?hP(BL(e.allOf,t)):IA(e)?xM(VL(e.anyOf,t)):wA(e)?WL(e,t,e.properties):IN({})}function qL(e,t,n){let r=_k(t)?GL(t):t,i=HA(t)?pN(t):t,a=DA(e),o=DA(t);return yA(e)?zL(e,i,n):vA(t)?ZL(e,t,n):a&&o||!a&&o||a&&!o?cM(`Omit`,[e,r],n):J({...KL(e,i),...n})}function JL(e,t,n){return{[t]:qL(e,[t],Lk(n))}}function YL(e,t,n){return t.reduce((t,r)=>({...t,...JL(e,r,n)}),{})}function XL(e,t,n){return YL(e,t.keys,n)}function ZL(e,t,n){return fM(XL(e,t,n))}function QL(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=sR(e[i],t,Lk(n));return r}function $L(e,t,n){return QL(e.properties,t,n)}function eR(e,t,n){return fM($L(e,t,n))}function tR(e,t){return e.map(e=>oR(e,t))}function nR(e,t){return e.map(e=>oR(e,t))}function rR(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function iR(e,t,n){let r=uM(e,[Zk,`$id`,`required`,`properties`]);return IN(rR(n,t),r)}function aR(e){return xM(e.reduce((e,t)=>gA(t)?[...e,YM(t)]:e,[]))}function oR(e,t){return mA(e)?hP(tR(e.allOf,t)):IA(e)?xM(nR(e.anyOf,t)):wA(e)?iR(e,t,e.properties):IN({})}function sR(e,t,n){let r=_k(t)?aR(t):t,i=HA(t)?pN(t):t,a=DA(e),o=DA(t);return yA(e)?eR(e,i,n):vA(t)?dR(e,t,n):a&&o||!a&&o||a&&!o?cM(`Pick`,[e,r],n):J({...oR(e,i),...n})}function cR(e,t,n){return{[t]:sR(e,[t],Lk(n))}}function lR(e,t,n){return t.reduce((t,r)=>({...t,...cR(e,r,n)}),{})}function uR(e,t,n){return lR(e,t.keys,n)}function dR(e,t,n){return fM(uR(e,t,n))}function fR(e,t){return cM(`Partial`,[cM(e,t)])}function pR(e){return cM(`Partial`,[gP(e)])}function mR(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=aP(e[n]);return t}function hR(e,t){let n=uM(e,[Zk,`$id`,`required`,`properties`]);return IN(mR(t),n)}function gR(e){return e.map(e=>_R(e))}function _R(e){return lA(e)?fR(e.target,e.parameters):DA(e)?pR(e.$ref):mA(e)?hP(gR(e.allOf)):IA(e)?xM(gR(e.anyOf)):wA(e)?hR(e,e.properties):sA(e)||cA(e)||pA(e)||_A(e)||SA(e)||CA(e)||kA(e)||AA(e)||FA(e)?e:IN({})}function vR(e,t){return yA(e)?xR(e,t):J({..._R(e),...t})}function yR(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=vR(e[r],Lk(t));return n}function bR(e,t){return yR(e.properties,t)}function xR(e,t){return fM(bR(e,t))}function SR(e,t){return cM(`Required`,[cM(e,t)])}function CR(e){return cM(`Required`,[gP(e)])}function wR(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=uM(e[n],[$k]);return t}function TR(e,t){let n=uM(e,[Zk,`$id`,`required`,`properties`]);return IN(wR(t),n)}function ER(e){return e.map(e=>DR(e))}function DR(e){return lA(e)?SR(e.target,e.parameters):DA(e)?CR(e.$ref):mA(e)?hP(ER(e.allOf)):IA(e)?xM(ER(e.anyOf)):wA(e)?TR(e,e.properties):sA(e)||cA(e)||pA(e)||_A(e)||SA(e)||CA(e)||kA(e)||AA(e)||FA(e)?e:IN({})}function OR(e,t){return yA(e)?jR(e,t):J({...DR(e),...t})}function kR(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=OR(e[r],t);return n}function AR(e,t){return kR(e.properties,t)}function jR(e,t){return fM(AR(e,t))}function MR(e,t){return t.map(t=>DA(t)?NR(e,t.$ref):ez(e,t))}function NR(e,t){return t in e?DA(e[t])?NR(e,e[t].$ref):ez(e,e[t]):dM()}function PR(e){return CP(e[0])}function FR(e){return ON(e[0],e[1])}function IR(e){return LP(e[0])}function LR(e){return vR(e[0])}function RR(e){return qL(e[0],e[1])}function zR(e){return sR(e[0],e[1])}function BR(e){return OR(e[0])}function VR(e,t,n){let r=MR(e,n);return t===`Awaited`?PR(r):t===`Index`?FR(r):t===`KeyOf`?IR(r):t===`Partial`?LR(r):t===`Omit`?RR(r):t===`Pick`?zR(r):t===`Required`?BR(r):dM()}function HR(e,t){return aM(ez(e,t))}function UR(e,t){return sM(ez(e,t))}function WR(e,t,n){return pM($R(e,t),ez(e,n))}function GR(e,t,n){return mM($R(e,t),ez(e,n))}function KR(e,t){return hP($R(e,t))}function qR(e,t){return NN(ez(e,t))}function JR(e,t){return IN(globalThis.Object.keys(t).reduce((n,r)=>({...n,[r]:ez(e,t[r])}),{}))}function YR(e,t){let[n,r]=[ez(e,nL(t)),eL(t)],i=Rk(t);return i.patternProperties[r]=n,i}function XR(e,t){return DA(t)?{...NR(e,t.$ref),[Zk]:t[Zk]}:t}function ZR(e,t){return GN($R(e,t))}function QR(e,t){return xM($R(e,t))}function $R(e,t){return t.map(t=>ez(e,t))}function ez(e,t){return nA(t)?J(ez(e,uM(t,[$k])),t):tA(t)?J(ez(e,uM(t,[Qk])),t):NA(t)?J(XR(e,t),t):aA(t)?J(HR(e,t.items),t):oA(t)?J(UR(e,t.items),t):lA(t)?J(VR(e,t.target,t.parameters)):uA(t)?J(WR(e,t.parameters,t.returns),t):fA(t)?J(GR(e,t.parameters,t.returns),t):mA(t)?J(KR(e,t.allOf),t):hA(t)?J(qR(e,t.items),t):wA(t)?J(JR(e,t.properties),t):EA(t)?J(YR(e,t)):PA(t)?J(ZR(e,t.items||[]),t):IA(t)?J(QR(e,t.anyOf),t):t}function tz(e,t){return t in e?ez(e,e[t]):dM()}function nz(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:tz(e,n)}),{})}var rz=class{constructor(e){let t=nz(e),n=this.WithIdentifiers(t);this.$defs=n}Import(e,t){let n={...this.$defs,[e]:J(this.$defs[e],t)};return J({[Y]:`Import`,$defs:n,$ref:e})}WithIdentifiers(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:{...e[n],$id:n}}),{})}};function iz(e){return new rz(e)}function az(e,t){return J({[Y]:`Not`,not:e},t)}function oz(e,t){return fA(e)?GN(e.parameters,t):dM()}var sz=0;function cz(e,t={}){Ak(t.$id)&&(t.$id=`T${sz++}`);let n=Rk(e({[Y]:`This`,$ref:`${t.$id}`}));return n.$id=t.$id,J({[eA]:`Recursive`,...n},t)}function lz(e,t){let n=Dk(e)?new globalThis.RegExp(e):e;return J({[Y]:`RegExp`,type:`RegExp`,source:n.source,flags:n.flags},t)}function uz(e){return mA(e)?e.allOf:IA(e)?e.anyOf:PA(e)?e.items??[]:[]}function dz(e){return uz(e)}function fz(e,t){return fA(e)?J(e.returns,t):dM(t)}var pz=class{constructor(e){this.schema=e}Decode(e){return new mz(this.schema,e)}},mz=class{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let n={Encode:n=>t[Zk].Encode(e(n)),Decode:e=>this.decode(t[Zk].Decode(e))};return{...t,[Zk]:n}}EncodeSchema(e,t){let n={Decode:this.decode,Encode:e};return{...t,[Zk]:n}}Encode(e){return NA(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}};function hz(e){return new pz(e)}function gz(e={}){return J({[Y]:e[Y]??`Unsafe`},e)}function _z(e){return J({[Y]:`Void`,type:`void`},e)}var $=t({Any:()=>iM,Argument:()=>oM,Array:()=>aM,AsyncIterator:()=>sM,Awaited:()=>CP,BigInt:()=>ZM,Boolean:()=>XM,Capitalize:()=>NL,Composite:()=>GP,Const:()=>nF,Constructor:()=>pM,ConstructorParameters:()=>rF,Date:()=>KP,Enum:()=>iF,Exclude:()=>kI,Extends:()=>SI,Extract:()=>FI,Function:()=>mM,Index:()=>ON,InstanceType:()=>zI,Instantiate:()=>yL,Integer:()=>bL,Intersect:()=>hP,Iterator:()=>NN,KeyOf:()=>LP,Literal:()=>YM,Lowercase:()=>PL,Mapped:()=>tP,Module:()=>iz,Never:()=>dM,Not:()=>az,Null:()=>qP,Number:()=>QM,Object:()=>IN,Omit:()=>qL,Optional:()=>aP,Parameters:()=>oz,Partial:()=>vR,Pick:()=>sR,Promise:()=>LN,Readonly:()=>VN,ReadonlyOptional:()=>BI,Record:()=>$I,Recursive:()=>cz,Ref:()=>gP,RegExp:()=>lz,Required:()=>OR,Rest:()=>dz,ReturnType:()=>fz,String:()=>$M,Symbol:()=>JP,TemplateLiteral:()=>lN,Transform:()=>hz,Tuple:()=>GN,Uint8Array:()=>XP,Uncapitalize:()=>FL,Undefined:()=>YP,Union:()=>xM,Unknown:()=>ZP,Unsafe:()=>gz,Uppercase:()=>IL,Void:()=>_z}),vz={additionalProperties:!1},yz=$.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}),bz=$.String({pattern:`^[a-z0-9][a-z0-9-]{0,31}(?![\\s\\S])`,minLength:1,maxLength:32}),xz=$.String({pattern:`^sha256:[0-9a-f]{64}$`,minLength:71,maxLength:71}),Sz=$.String({pattern:`^[A-Za-z0-9_-]{43}$`,minLength:43,maxLength:43}),Cz=$.String({pattern:`^dpt_[A-Za-z0-9_-]{43}$`,minLength:47,maxLength:47}),wz=`[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}`,Tz=`^(?:${wz}|[A-Z2-7]{12}|[A-Z2-7]{8})(?![\\s\\S])`,Ez=$.String({pattern:Tz,minLength:8,maxLength:36}),Dz=new RegExp(Tz),Oz=/^[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 kz(e){return typeof e!=`string`||e.length>36?!1:Dz.test(e)}function Az(e){if(typeof e!=`string`)return;if(Oz.test(e)){let t=e.toLowerCase();return kz(t)?t:void 0}let t=e.replace(/[\s-]+/g,``).toUpperCase();if(kz(t)&&!(/[\s-]/.test(e)&&t.length!==12))return t}$.Object({type:$.Literal(`pair.request`),v:$.Literal(1),requestId:yz,code:Ez,deviceUid:yz,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:xz,clientTime:$.Integer(),hubNonce:$.Optional(Sz)},vz),$.Object({type:$.Literal(`pair.device-request`),v:$.Literal(1),requestId:yz,deviceUid:yz,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:xz,clientTime:$.Integer(),hubNonce:$.Optional(Sz)},vz);var jz=$.Object({type:$.Literal(`pair.challenge`),v:$.Literal(1),enrollmentId:yz,nonce:Sz,issuedAt:$.Integer(),hubId:yz,hubPublicKey:$.Optional($.String({minLength:1,maxLength:256})),hubKeyFingerprint:$.Optional(xz),hubSignature:$.Optional($.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86}))},vz);$.Object({type:$.Literal(`pair.device-ack`),v:$.Literal(1),codeId:yz,code:Ez,expiresAt:$.Integer(),hubOrigin:$.String(),hubId:yz,challenge:jz},vz),$.Object({type:$.Literal(`pair.response`),v:$.Literal(1),enrollmentId:yz,nonce:Sz,signature:$.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86})},vz),$.Object({type:$.Literal(`pair.pending`),v:$.Literal(1),enrollmentId:yz,state:$.Literal(`awaiting_approval`),expiresAt:$.Integer(),pollAfterMs:$.Integer({minimum:1})},vz),$.Object({type:$.Literal(`pair.token`),v:$.Literal(1),enrollmentId:yz,deviceUid:yz,deviceId:bz,pairingEpoch:yz,credentialId:yz,generation:$.Integer({minimum:1}),hubId:yz,hubOrigin:$.String(),hubUrl:$.String(),tunnelToken:Cz,issuedAt:$.Integer(),expiresAt:$.Null(),hubKeyFingerprint:$.Optional(xz)},vz),$.Object({enrollmentId:yz,deviceUid:yz,keyFingerprint:xz,replaceKey:$.Optional($.Boolean())},vz),$.Object({type:$.Literal(`pair.revoke`),v:$.Literal(1),deviceId:bz,pairingEpoch:yz,reason:$.Union([$.Literal(`user`),$.Literal(`compromise`),$.Literal(`hub_migrated`)]),revokedAt:$.Integer()},vz);var Mz=$.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}))},vz);$.Object({type:$.Literal(`pair.code`),v:$.Literal(1),codeId:yz,code:Ez,expiresAt:$.Integer(),hubOrigin:$.String({maxLength:2048}),pairUrl:$.String({maxLength:4096}),offerUrl:$.Optional($.String({maxLength:2048}))},vz);var Nz=$.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:yz,expiresAt:$.Integer(),phase:Nz,enrollment:$.Optional($.Object({enrollmentId:yz,deviceUid:yz,deviceName:$.String({minLength:1,maxLength:64}),keyFingerprint:xz,proofVerified:$.Boolean(),keyChanged:$.Boolean()},vz)),deviceId:$.Optional(bz),error:$.Optional(Mz)},vz);function Pz(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 Fz(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 Iz=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Lz=RegExp(`^${wz}$`),Rz=/^sha256:[0-9a-f]{64}$/;function zz(e){let t=Fz(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=Pz(r.hub);if(a.ok&&a.origin===r.hub&&typeof r.id==`string`&&Iz.test(r.id)&&typeof r.code==`string`&&Lz.test(r.code)&&typeof r.exp==`number`&&Number.isSafeInteger(r.exp))return r.v===3?typeof r.kfp!=`string`||!Rz.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 Bz(e,t=Date.now()){let n=zz(e);if(n&&!(n.exp<t-3e4)&&!(n.exp>t+6e5))return n}function Vz(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=Bz(n.hash.slice(7),t);if(r&&r.hub===n.origin)return{offer:r,rest:`${n.origin}/pair`}}function Hz(e){if(!/^\/pair\/?$/.test(e.pathname))return;if(e.hash.startsWith(`#offer=`)){let t=Vz(e.href);if(t)return{code:t.offer.code,origin:e.origin,offerFragment:e.hash.slice(1)};let n=Bz(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:Az(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 Uz=e=>/^\/pair\/?$/.test(e.pathname)?`/`:void 0,Wz=e=>/^\/pair\/?$/.test(e.pathname)&&Hz(e)===void 0?`/`:void 0,Gz=4e3;async function Kz(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 qz={class:`modal pair-wizard`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pair-title`},Jz={key:1,class:`pair-pending`,"aria-label":`Machines waiting for approval`},Yz={class:`who`},Xz={key:0,class:`muted`},Zz={key:1,class:`muted`},Qz={class:`fp`},$z={class:`row`},eB={class:`phase`},tB=[`onClick`],nB={key:2,class:`hint`},rB={class:`pair-steps`,"aria-label":`Pairing progress`},iB={class:`pair-grid`},aB={class:`pair-code-box`},oB={class:`pair-code`,"aria-label":`Pairing code`},sB={class:`pair-copy-actions`},cB=[`innerHTML`],lB={class:`pair-side`},uB={key:0,class:`hint`},dB={class:`pair-fingerprint`},fB={class:`fp`},pB={class:`pair-confirm`},mB={key:0,class:`pair-confirm warn`},hB=[`disabled`],gB=[`disabled`],_B={class:`hint`},vB=[`disabled`],yB={key:5,class:`error`,role:`alert`},bB={key:4},xB={class:`error`,role:`alert`},SB=M({__name:`PairDeviceWizard`,props:{handoff:{}},emits:[`close`],setup(e,{expose:t,emit:n}){let r=n,i=e,a=O(`boot`),o=O(),s=O(),c=O(),l=O(``),u=O(!1),d=O(!1),f=O(!1),p=O(!1),m=O(!1),h=O(!1),g=O(),_=O([]),v=H(()=>{let e=s.value?.code??``;return!kz(e)||e.includes(`-`)?e:(e.match(/.{4}/g)??[]).join(`-`)}),y=H(()=>s.value?Vy(s.value):``),b=H(()=>y.value?ck(y.value,148):``),ee=H(()=>c.value?.enrollment?.keyFingerprint??``),x=H(()=>c.value?.deviceId??``);j(x,e=>{g.value?.(),e&&(g.value=j(()=>xu.devices.value.find(t=>t.id===e)?.status,e=>{e===`online`&&(q(`Device paired and online.`),g.value?.(),g.value=void 0)},{immediate:!0}))});async function S(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=Wy();o.value=t;try{let n=e?await Hy.resolveCode(e):await Hy.createCode();if(t.closed()){await Hy.cancel(n.codeId).catch(()=>{q(`The late pairing code could not be cancelled. Check device credentials before retrying.`)});return}if(s.value=n,a.value=`code`,e){let e=Uz(new URL(window.location.href));e&&window.history.replaceState(window.history.state,``,e)}qy(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 te(){let e=c.value,t=o.value;if(e?.enrollment&&t&&!u.value){u.value=!0,l.value=``;try{let t=await Hy.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 ne(e){if(!s.value)return`cancelled`;try{let t=await Hy.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 Jl&&e.status===409&&String(e.code)===`already_issued`){let e=await Hy.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 C=()=>ne(!1),re=()=>[`issued`,`connected`,`cancelled`,`expired`].includes(c.value?.phase??``);async function ie(){let e=x.value;if(e){u.value=!0;try{await Hy.revoke(e,`user`),q(`Issued credential revoked.`),r(`close`)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}}async function ae(){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 oe(){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 se(){if(!d.value){d.value=!0,u.value=!0;try{let e=await Kz({needsCancel:!!s.value&&!re(),cancel:C,timeoutMs:Gz});if(!e.closed)return;o.value?.close(),g.value?.(),e.confirmed||q(`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:se});let ce;async function le(){try{_.value=(await Hy.pending()).codes}catch{}}async function ue(e){s.value=void 0,c.value=void 0,l.value=``;let t=Wy();o.value=t,a.value=e.phase===`approved_ready`?`approve`:`proof`,qy(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 Hr(()=>{if(le(),ce=setInterval(()=>void le(),3e3),i.handoff&&`error`in i.handoff){l.value=i.handoff.error,a.value=`expired`;return}S(i.handoff?.code)}),Gr(()=>{clearInterval(ce);let e=o.value;e&&!e.closed()&&s.value&&!re()&&ne(!0).then(e=>{e!==`cancelled`&&q(`Pairing cancellation was not confirmed. Check device credentials before retrying.`)}),e?.close(),g.value?.()}),(e,t)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:As(se,[`self`])},[R(`div`,qz,[R(`header`,null,[t[5]||=R(`h2`,{id:`pair-title`},`Pair a device`,-1),R(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,onClick:se},[z(k(yl),{size:18})])]),i.handoff&&`offerFragment`in i.handoff&&i.handoff.offerFragment?(F(),L(hk,{key:0,"offer-fragment":i.handoff.offerFragment},null,8,[`offer-fragment`])):V(``,!0),_.value.length?(F(),I(`section`,Jz,[t[6]||=R(`h3`,null,`Machines waiting for you`,-1),R(`ul`,null,[(F(!0),I(P,null,N(_.value,e=>(F(),I(`li`,{key:e.codeId},[R(`div`,Yz,[R(`strong`,null,E(e.deviceName??`unnamed device`),1),e.hostname?(F(),I(`span`,Xz,E(e.hostname),1)):V(``,!0),e.platform?(F(),I(`span`,Zz,E(e.platform),1)):V(``,!0)]),R(`div`,Qz,E(e.keyFingerprint),1),R(`div`,$z,[R(`span`,eB,E(e.phase.replaceAll(`_`,` `)),1),R(`button`,{type:`button`,class:`small`,onClick:t=>ue(e)},`Review`,8,tB)])]))),128))]),t[7]||=R(`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)])):V(``,!0),a.value===`boot`?(F(),I(`p`,nB,`Minting a pairing code…`)):s.value?(F(),I(P,{key:3},[R(`ol`,rB,[t[8]||=R(`li`,{class:T({on:!0})},`Code`,-1),R(`li`,{class:T({on:[`proof`,`approve`,`issued`].includes(a.value)})},`Proof`,2),R(`li`,{class:T({on:[`approve`,`issued`].includes(a.value)})},`Fingerprint`,2),R(`li`,{class:T({on:a.value===`issued`})},`Online`,2)]),R(`div`,iB,[R(`div`,aB,[R(`div`,oB,E(v.value),1),R(`div`,sB,[R(`button`,{type:`button`,class:`small`,onClick:ae},[z(k(cc),{size:14}),B(` `+E(m.value?`Copied`:`Copy code`),1)]),R(`button`,{type:`button`,class:`small`,onClick:oe,title:`Self-contained link: hub, code and expiry all in the fragment — it never reaches server logs`},[z(k(cc),{size:14}),B(` `+E(h.value?`Copied link`:`Copy link`),1)])]),t[9]||=R(`p`,{class:`hint`},` Run the device pairing command and scan, or enter this code on the device. Expires in 5 minutes. `,-1),R(`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,cB)]),R(`div`,lB,[a.value===`code`||a.value===`proof`?(F(),I(`p`,uB,[z(k(el),{size:14,class:`spin`}),t[10]||=B(` Waiting for the device to submit its signing proof… `,-1)])):a.value===`approve`?(F(),I(P,{key:1},[R(`div`,dB,[t[11]||=R(`h3`,null,`Device key fingerprint`,-1),R(`code`,fB,E(ee.value),1),t[12]||=R(`p`,{class:`hint`},` Compare ALL 64 hex characters with the fingerprint shown on the device screen. `,-1)]),R(`label`,pB,[A(R(`input`,{"onUpdate:modelValue":t[0]||=e=>f.value=e,type:`checkbox`},null,512),[[xs,f.value]]),t[13]||=B(` The fingerprint matches the device display exactly `,-1)]),c.value?.enrollment?.keyChanged?(F(),I(`label`,mB,[A(R(`input`,{"onUpdate:modelValue":t[1]||=e=>p.value=e,type:`checkbox`},null,512),[[xs,p.value]]),z(k(al),{size:14}),t[14]||=B(` Device is already paired with a DIFFERENT key — replace the stored key (replaceKey) `,-1)])):V(``,!0),R(`button`,{type:`button`,class:`primary`,disabled:!f.value||u.value||c.value?.enrollment?.keyChanged===!0&&!p.value,onClick:te},` Approve device `,8,hB),R(`button`,{type:`button`,class:`small`,disabled:u.value,onClick:C},` Cancel pairing `,8,gB)],64)):a.value===`issued`?(F(),I(P,{key:2},[R(`p`,_B,[z(k(ac),{size:14}),t[15]||=B(` Credential issued. The device is connecting through the tunnel — you will get a toast once the monitor probe reports it online. `,-1)]),R(`button`,{type:`button`,class:`small`,onClick:se},`Close`),R(`button`,{type:`button`,class:`small danger`,disabled:!x.value||u.value,title:`Mistaken approval? Revoke the credential now.`,onClick:ie},` Revoke this credential `,8,vB)],64)):a.value===`cancelled`?(F(),I(P,{key:3},[t[16]||=R(`p`,{class:`hint`},`Pairing was cancelled (or the signature failed too many times).`,-1),R(`button`,{type:`button`,class:`small`,onClick:t[2]||=e=>S()},`Start over`)],64)):a.value===`expired`?(F(),I(P,{key:4},[t[17]||=R(`p`,{class:`hint`},`The pairing code expired.`,-1),R(`button`,{type:`button`,class:`small`,onClick:t[3]||=e=>S()},`New code`)],64)):V(``,!0),l.value?(F(),I(`p`,yB,E(l.value),1)):V(``,!0)])])],64)):(F(),I(`div`,bB,[R(`p`,xB,E(l.value||`This pairing link is unavailable.`),1),R(`button`,{type:`button`,class:`small`,onClick:t[4]||=e=>S()},`New code`)]))])]))}}),CB={class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`device-credentials-title`},wB={class:`hint`},TB={key:1,class:`hint`},EB=M({__name:`DeviceCredentialsDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=H(()=>xu.devices.value.find(e=>e.id===n.deviceId));return(e,t)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:t[2]||=As(e=>r(`close`),[`self`])},[R(`section`,CB,[R(`header`,null,[t[3]||=R(`h2`,{id:`device-credentials-title`},`Device credentials`,-1),R(`button`,{class:`icon-button`,"aria-label":`Close device credentials`,onClick:t[0]||=e=>r(`close`)},[z(k(yl),{size:18})])]),i.value?(F(),I(P,{key:0},[R(`p`,null,[B(E(i.value.name)+` `,1),R(`code`,null,E(i.value.id),1)]),R(`p`,wB,E(i.value.status)+` · tunnel `+E(i.value.tunnel?.state??`disconnected`)+` · `+E(i.value.tunnel?.readerCount??0)+` readers `,1),z(nb,{device:i.value},null,8,[`device`])],64)):(F(),I(`p`,TB,`This device is no longer in the registry.`)),R(`footer`,null,[R(`button`,{class:`secondary`,onClick:t[1]||=e=>r(`close`)},`Close`)])])]))}}),DB={id:`prompt-title`},OB=[`disabled`],kB={key:0,class:`hint`},AB={key:1},jB={key:0,class:`muted`},MB=[`placeholder`,`disabled`],NB=[`required`,`placeholder`,`aria-label`,`disabled`],PB={key:2,class:`message-error`,role:`alert`},FB=[`disabled`],IB=[`disabled`],LB=M({__name:`PromptDialog`,props:{dialog:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=O(n.dialog.value??``),a=O(!1),o=O(``),s=O(),c=!!n.dialog.label;async function l(){if(!a.value&&(!c||n.dialog.optional||i.value.trim())){a.value=!0,o.value=``;try{await n.dialog.run(i.value.trim()),r(`close`)}catch(e){o.value=lu(e)}finally{a.value=!1}}}return Hr(()=>void jn(()=>(s.value?.focus(),s.value?.select()))),(t,n)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:n[4]||=As(e=>!a.value&&r(`close`),[`self`])},[R(`form`,{class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`prompt-title`,onSubmit:As(l,[`prevent`])},[R(`header`,null,[R(`h2`,DB,E(e.dialog.title),1),R(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,disabled:a.value,onClick:n[0]||=e=>r(`close`)},[z(k(yl),{size:18})],8,OB)]),e.dialog.hint?(F(),I(`p`,kB,E(e.dialog.hint),1)):V(``,!0),c?(F(),I(`label`,AB,[B(E(e.dialog.label)+` `,1),e.dialog.optional?(F(),I(`span`,jB,`(optional)`)):V(``,!0),e.dialog.multiline?A((F(),I(`textarea`,{key:1,ref_key:`input`,ref:s,"onUpdate:modelValue":n[1]||=e=>i.value=e,rows:`4`,placeholder:e.dialog.placeholder,disabled:a.value},null,8,MB)),[[bs,i.value]]):A((F(),I(`input`,{key:2,ref_key:`input`,ref:s,"onUpdate:modelValue":n[2]||=e=>i.value=e,maxlength:`100`,required:!e.dialog.optional,placeholder:e.dialog.placeholder,"aria-label":e.dialog.label,disabled:a.value},null,8,NB)),[[bs,i.value]])])):V(``,!0),o.value?(F(),I(`p`,PB,E(o.value),1)):V(``,!0),R(`footer`,null,[R(`button`,{type:`button`,class:`secondary`,disabled:a.value,onClick:n[3]||=e=>r(`close`)},` Cancel `,8,FB),R(`button`,{class:T([`primary`,{danger:e.dialog.danger}]),disabled:a.value||c&&!e.dialog.optional&&!i.value.trim()},E(a.value?`Working…`:e.dialog.submit),11,IB)])],32)]))}}),RB={class:`modal model-modal`},zB={class:`eyebrow`},BB={class:`model-list`},VB=[`onClick`],HB=[`src`],UB={class:`hint`},WB=M({__name:`ModelPicker`,emits:[`close`],setup(e,{emit:t}){let n=t,r=O(``),i=H(()=>Gu.value.filter(e=>`${e.name} ${e.id} ${e.tier}`.toLowerCase().includes(r.value.toLowerCase()))),a=e=>e.id===Ku.value.agent.model?.modelId&&e.provider===Ku.value.agent.model?.provider;async function o(e){await od(()=>Iu.value.configure({model:{provider:e.provider,modelId:e.id}}))&&(await td(),q(`Model saved. Used on the next turn.`),n(`close`))}return(e,t)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:t[2]||=As(e=>n(`close`),[`self`])},[R(`section`,RB,[R(`header`,null,[R(`div`,null,[R(`span`,zB,`PER AGENT · `+E(k(ku)?.id),1),t[3]||=R(`h2`,null,`Choose a model`,-1)]),R(`button`,{class:`icon-button`,"aria-label":`Close model picker`,onClick:t[0]||=e=>n(`close`)},[z(k(yl),{size:18})])]),A(R(`input`,{"onUpdate:modelValue":t[1]||=e=>r.value=e,placeholder:`Search models or tiers…`,"aria-label":`Search models`},null,512),[[bs,r.value]]),R(`div`,BB,[(F(!0),I(P,null,N(i.value,e=>(F(),I(`button`,{key:`${e.provider}/${e.id}`,class:T({selected:a(e)}),onClick:t=>o(e)},[R(`img`,{src:k(ud)(e.id),alt:``},null,8,HB),R(`div`,null,[R(`strong`,null,E(e.name),1),R(`small`,null,E(e.tier)+` / `+E(e.provider)+` / `+E(k(cd)(e.contextWindow))+` context`,1)]),a(e)?(F(),L(k(nc),{key:0,size:18})):V(``,!0)],10,VB))),128))]),R(`p`,UB,`Models available on `+E(k(ku)?.id)+`. Provider keys stay on the device.`,1)])]))}}),GB={class:`dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`help-title`},KB={class:`dialog-head`},qB={class:`dialog-body`},JB={class:`n`},YB={class:`body`},XB={class:`help-callout`},ZB={class:`dialog-foot`},QB={class:`right`},$B=M({__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)=>(F(),I(`div`,{class:`scrim`,onClick:n[2]||=As(e=>k(K).dialog=void 0,[`self`])},[R(`section`,GB,[R(`div`,KB,[n[3]||=R(`div`,null,[R(`span`,{class:`dialog-eyebrow`},`LEARN BY DOING`),R(`h3`,{id:`help-title`},`What makes this durable?`)],-1),R(`button`,{class:`icon-button`,"aria-label":`Close help`,onClick:n[0]||=e=>k(K).dialog=void 0},[z(k(yl),{size:18})])]),R(`div`,qB,[(F(),I(P,null,N(t,(e,t)=>R(`div`,{key:e.title,class:`help-step`},[R(`span`,JB,E(String(t+1).padStart(2,`0`)),1),R(`div`,null,[R(`b`,null,E(e.title),1),R(`div`,YB,E(e.body),1)])])),64)),R(`div`,XB,[z(k(kc),{size:18}),n[4]||=R(`span`,null,`Durable does not mean exactly-once external effects. Checkpoints protect progress. Tools still need their own idempotency.`,-1)])]),R(`div`,ZB,[R(`div`,QB,[R(`button`,{class:`secondary`,type:`button`,onClick:n[1]||=e=>k(K).dialog=void 0},`Close`)])])])]))}}),eV=Gt({needed:!1,busy:!1,error:``}),tV=new Set,nV=e=>{let t=[...tV];tV=new Set;for(let n of t)n(e)},rV=()=>new Promise(e=>tV.add(e));async function iV(e){if(eV.busy||!e)return!1;eV.busy=!0,eV.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?(eV.needed=!1,nV(!0),!0):(eV.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 eV.error=`Cannot reach the hub.`,!1}finally{eV.busy=!1}}var aV=e=>{try{return new URL(e,location.href).pathname===`/api/session`}catch{return e===`/api/session`}};function oV(e){return(async(t,n)=>{let r=()=>e(t,n),i=await r();if(i.status!==401||aV(typeof t==`string`?t:t instanceof URL?t.href:t.url)||n?.body instanceof ReadableStream)return i;eV.needed=!0;let a=await i.text().catch(()=>``);return await rV()?r():new Response(a,{status:i.status,headers:i.headers})})}function sV(){typeof window>`u`||window.__adminFetch||(window.__adminFetch=!0,window.fetch=oV(window.fetch.bind(window)))}var cV={class:`login-veil`,"data-testid":`login-card`},lV=[`disabled`],uV={key:0,class:`message-error`,role:`alert`},dV=[`disabled`],fV=M({__name:`LoginCard`,setup(e){let t=O(``),n=O();async function r(){if(eV.busy||!t.value.trim())return;let e=await iV(t.value.trim());t.value=``,e&&n.value?.blur()}return Hr(()=>void jn(()=>n.value?.focus())),(e,i)=>(F(),I(`div`,cV,[R(`form`,{class:`modal login-card`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`login-title`,onSubmit:As(r,[`prevent`])},[i[2]||=R(`header`,null,[R(`h2`,{id:`login-title`},`Admin token`)],-1),i[3]||=R(`p`,{class:`hint`},[B(` This hub is locked. Sign in with the token from its `),R(`code`,null,`admin.token`),B(` file. `)],-1),i[4]||=R(`label`,{for:`admin-token`},`Admin token`,-1),A(R(`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:k(eV).busy,onKeydown:i[1]||=Ms(e=>k(eV).error=``,[`esc`])},null,40,lV),[[bs,t.value]]),k(eV).error?(F(),I(`p`,uV,E(k(eV).error),1)):V(``,!0),R(`footer`,null,[R(`button`,{class:`primary`,type:`submit`,disabled:k(eV).busy||!t.value.trim()},E(k(eV).busy?`Checking…`:`Sign in`),9,dV)])],32)]))}}),pV={key:0,class:`toast`,role:`status`},mV=M({__name:`Toast`,setup(e){return(e,t)=>(F(),L(xo,{name:`toast`},{default:Un(()=>[k(K).toast?(F(),I(`div`,pV,[z(k(nc),{size:18}),B(E(k(K).toast),1)])):V(``,!0)]),_:1}))}}),hV={class:`shell`,"data-testid":`app-shell`},gV={key:0,class:`error-banner`,role:`alert`},_V={key:4,class:`welcome`,"data-testid":`welcome-empty`},vV=[`disabled`],yV={class:`welcome-features`},bV={class:`modal path-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`path-title`},xV={class:`full-directory`},SV=M({__name:`App`,setup(e){let t=()=>xu.devices.value.filter(e=>e.status===`online`).length,n=O();function r(){K.dialog={kind:`new-session`,deviceId:G.value?.deviceId}}function i(e){let t=K.dialog?void 0:Cd(e);if(t)return e.preventDefault(),t===`tree`?yd():bd();if(e.key===`Escape`){if(K.dialog){K.dialog.kind===`pair`?n.value?.close():K.dialog=void 0;return}!e.repeat&&!e.isComposing&&Xu.value&&(e.preventDefault(),pd()),K.drawer=!1,K.inspectorOverlay=!1}}function a(e){let t=e.clientX,n=Tu.value,r=e=>Tu.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 Hr(()=>nf()),Hr(()=>{document.addEventListener(`keydown`,i),Uu()}),Gr(()=>{yu.stop(),document.removeEventListener(`keydown`,i)}),(e,i)=>(F(),I(`div`,hV,[z(Rd,{onNewSession:r}),k(K).error?(F(),I(`div`,gV,[z(k(kc),{size:18}),R(`span`,null,E(k(K).error),1),R(`button`,{class:`icon-button`,"aria-label":`Dismiss error`,onClick:i[0]||=e=>k(K).error=``},`×`)])):V(``,!0),R(`main`,{class:`net-workspace`,style:_e({"--tree-w":`${k(Tu)}px`})},[z(dp),k(Eu).tree?(F(),I(`div`,{key:0,class:`tree-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize network tree`,onPointerdown:As(a,[`prevent`])},null,32)):V(``,!0),k(K).drawer?(F(),I(`div`,{key:1,class:`tree-backdrop`,onClick:i[1]||=e=>k(K).drawer=!1})):V(``,!0),k(G)&&k(ku)&&k(Au)?(F(),I(P,{key:2},[z(oO),k(K).inspectorOverlay?(F(),I(`div`,{key:0,class:`inspector-backdrop`,onClick:i[2]||=e=>k(vd)()})):V(``,!0),(F(),L(py,{key:`${k(G).deviceId}/${k(G).sessionId}`}))],64)):k(G)&&k(ku)?(F(),L(gO,{key:3,device:k(ku)},null,8,[`device`])):(F(),I(`section`,_V,[i[14]||=R(`img`,{class:`welcome-symbol`,src:`/icons/durable-pi.svg`,alt:`Durable Pi`},null,-1),i[15]||=R(`span`,{class:`eyebrow`},`THE DURABLE AGENT NETWORK`,-1),i[16]||=R(`h1`,null,[B(`Close the tab.`),R(`br`),B(`The work continues.`)],-1),i[17]||=R(`p`,null,`Agents run on your devices. This page is only a window into them.`,-1),R(`button`,{class:`primary`,disabled:!t(),onClick:r},[z(k(Zc),{size:18}),B(E(k(xu).devices.value.length?`Create a session`:`Add a device to dpi-network.yaml`),1)],8,vV),R(`div`,yV,[R(`span`,null,[z(k(pc),{size:18}),i[11]||=B(`SQLite on each device`,-1)]),R(`span`,null,[z(k(wc),{size:18}),i[12]||=B(`Branch any agent`,-1)]),R(`span`,null,[z(k(Hs),{size:18}),i[13]||=B(`Watch from anywhere`,-1)])])]))],4),z(Vd),k(K).dialog?.kind===`pair`?(F(),L(SB,{key:1,ref_key:`pairWizard`,ref:n,handoff:k(K).dialog.handoff,onClose:i[3]||=e=>k(K).dialog=void 0},null,8,[`handoff`])):V(``,!0),k(K).dialog?.kind===`credentials`?(F(),L(EB,{key:2,"device-id":k(K).dialog.deviceId,onClose:i[4]||=e=>k(K).dialog=void 0},null,8,[`device-id`])):V(``,!0),k(K).dialog?.kind===`new-session`?(F(),L(IO,{key:3,"device-id":k(K).dialog.deviceId,onClose:i[5]||=e=>k(K).dialog=void 0},null,8,[`device-id`])):k(K).dialog?.kind===`prompt`?(F(),L(LB,{key:4,dialog:k(K).dialog,onClose:i[6]||=e=>k(K).dialog=void 0},null,8,[`dialog`])):k(K).dialog?.kind===`models`?(F(),L(WB,{key:5,onClose:i[7]||=e=>k(K).dialog=void 0})):k(K).dialog?.kind===`path`?(F(),I(`div`,{key:6,class:`modal-backdrop`,onClick:i[10]||=As(e=>k(K).dialog=void 0,[`self`])},[R(`section`,bV,[R(`header`,null,[i[18]||=R(`h2`,{id:`path-title`},`Working directory`,-1),R(`button`,{class:`icon-button`,"aria-label":`Close working directory`,onClick:i[8]||=e=>k(K).dialog=void 0},[z(k(yl),{size:18})])]),R(`code`,xV,E(k(K).dialog.path),1),R(`footer`,null,[R(`button`,{class:`secondary`,onClick:i[9]||=e=>k(K).dialog=void 0},`Close`)])])])):k(K).dialog?.kind===`help`?(F(),L($B,{key:7})):V(``,!0),k(eV).needed?(F(),L(fV,{key:8})):V(``,!0),z(mV)]))}});sV();var CV=new URL(window.location.href);if(/^\/pair\/?$/.test(CV.pathname)){let e=Hz(CV);e?(CV.search=``,CV.hash=``,window.history.replaceState(window.history.state,``,CV),K.dialog={kind:`pair`,handoff:e}):window.history.replaceState(window.history.state,``,Wz(CV))}Is(SV).mount(`#app`);
|