@spencerboucher/switchyard 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/dist/bridge/pi-model.js +44 -0
- package/dist/bridge/switchyard-bridge.js +24 -2
- package/dist/bridge/switchyard-terminal.js +608 -0
- package/dist/switchyard.mjs +3811 -1811
- package/dist/terminal/holder.js +305 -0
- package/package.json +6 -3
- package/web-dist/assets/{AutomationView-BhEfjAtI.js → AutomationView-DgZn3ltn.js} +2 -2
- package/web-dist/assets/{AutomationView-BhEfjAtI.js.map → AutomationView-DgZn3ltn.js.map} +1 -1
- package/web-dist/assets/{InteractionCard-DxEZUNrD.js → InteractionCard-cvPWKSu1.js} +2 -2
- package/web-dist/assets/{InteractionCard-DxEZUNrD.js.map → InteractionCard-cvPWKSu1.js.map} +1 -1
- package/web-dist/assets/{Menu-C4GUY_ym.js → Menu-GymfuHGP.js} +2 -2
- package/web-dist/assets/Menu-GymfuHGP.js.map +1 -0
- package/web-dist/assets/{Overlay-C-GqmwUn.js → Overlay-oYnnwvFM.js} +2 -2
- package/web-dist/assets/{Overlay-C-GqmwUn.js.map → Overlay-oYnnwvFM.js.map} +1 -1
- package/web-dist/assets/{attention-Dzqdk9Gz.js → attention-Bxg9W15n.js} +2 -2
- package/web-dist/assets/{attention-Dzqdk9Gz.js.map → attention-Bxg9W15n.js.map} +1 -1
- package/web-dist/assets/{automations-DzTTwxBl.js → automations-DdB97dnL.js} +2 -2
- package/web-dist/assets/{automations-DzTTwxBl.js.map → automations-DdB97dnL.js.map} +1 -1
- package/web-dist/assets/{board-C5mG_8rg.js → board-s4LuDPcg.js} +2 -2
- package/web-dist/assets/{board-C5mG_8rg.js.map → board-s4LuDPcg.js.map} +1 -1
- package/web-dist/assets/code-B0KXn7lD.js +8 -0
- package/web-dist/assets/code-B0KXn7lD.js.map +1 -0
- package/web-dist/assets/{describe-BbCZVvJP.js → describe-C_3FJuSs.js} +2 -2
- package/web-dist/assets/{describe-BbCZVvJP.js.map → describe-C_3FJuSs.js.map} +1 -1
- package/web-dist/assets/dist-Bgkh2hc5.js +56 -0
- package/web-dist/assets/dist-Bgkh2hc5.js.map +1 -0
- package/web-dist/assets/{enroll-DWJANJtw.js → enroll-DijmoolY.js} +2 -2
- package/web-dist/assets/{enroll-DWJANJtw.js.map → enroll-DijmoolY.js.map} +1 -1
- package/web-dist/assets/index-C5n2QB-Y.css +2 -0
- package/web-dist/assets/{index-afOJ8NRR.js → index-Cf6ZUCfK.js} +3 -3
- package/web-dist/assets/{index-afOJ8NRR.js.map → index-Cf6ZUCfK.js.map} +1 -1
- package/web-dist/assets/{more-B6qxC6M-.js → more-CRGJsz6E.js} +2 -2
- package/web-dist/assets/{more-B6qxC6M-.js.map → more-CRGJsz6E.js.map} +1 -1
- package/web-dist/assets/{now-BOWxgbt3.js → now-D6lDofYy.js} +2 -2
- package/web-dist/assets/{now-BOWxgbt3.js.map → now-D6lDofYy.js.map} +1 -1
- package/web-dist/assets/{settings-BpkmIv_4.js → settings-Csal1F-W.js} +6 -6
- package/web-dist/assets/settings-Csal1F-W.js.map +1 -0
- package/web-dist/assets/{useNow-D9Zxr5Jb.js → useNow-Bc_NlDY3.js} +2 -2
- package/web-dist/assets/{useNow-D9Zxr5Jb.js.map → useNow-Bc_NlDY3.js.map} +1 -1
- package/web-dist/index.html +2 -2
- package/web-dist/sw.js +1 -1
- package/web-dist/assets/Menu-C4GUY_ym.js.map +0 -1
- package/web-dist/assets/code-9shyh1Gw.js +0 -8
- package/web-dist/assets/code-9shyh1Gw.js.map +0 -1
- package/web-dist/assets/dist-PaQekTP8.js +0 -56
- package/web-dist/assets/dist-PaQekTP8.js.map +0 -1
- package/web-dist/assets/index-ByiuDoG0.css +0 -2
- package/web-dist/assets/settings-BpkmIv_4.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{_ as e,c as t,f as n,i as r,l as i,m as a,n as o,p as s,t as c,u as l}from"./jsx-runtime-D13aM9HY.js";import{A as u,B as d,E as f,G as p,H as m,P as h,R as g,T as _,U as v,V as y,W as b,_ as x,c as S,d as C,g as w,h as T,i as E,l as D,m as O,n as k,o as A,p as j,r as M,t as N,v as ee}from"./states-DrTQuYXw.js";import{n as te,t as ne}from"./server-SxFxIScj.js";import{i as re,n as ie,r as ae,t as oe}from"./sliders-horizontal-S3tmwxsP.js";import{t as se}from"./chevron-right-evVLS6hq.js";import{t as ce}from"./copy-oWgGHmkS.js";import{n as le,t as ue}from"./pencil-DI8QbCN8.js";import{t as de}from"./key-round-VDbE9E4X.js";import{t as P}from"./plus-BLP-wIYD.js";import{t as fe}from"./save-DEvZPWlS.js";import{t as pe}from"./trash-C6X2OLrI.js";import{A as me,B as he,C as ge,F as _e,H as ve,I as F,L as ye,T as be,c as I,d as xe,h as Se,j as Ce,k as we,n as Te,r as Ee,s as De,z as Oe}from"./index-afOJ8NRR.js";import{n as L,t as ke}from"./TextArea-BsQHOQMe.js";import{i as Ae,l as je,o as Me,s as Ne,t as Pe,u as Fe}from"./dist-PaQekTP8.js";import{t as R}from"./Overlay-C-GqmwUn.js";import{_ as Ie,c as Le,d as Re,f as ze,g as Be,l as Ve,m as He,p as Ue,r as We,u as Ge}from"./logic-D_Eq9DMW.js";var Ke={name:`bell-off`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]};Ke.node;var qe=o(Ke),Je={name:`bell-ring`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]};Je.node;var Ye=o(Je),Xe={name:`database-backup`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 12a9 3 0 0 0 5 2.69`,key:`1ui2ym`}],[`path`,{d:`M21 9.3V5`,key:`6k6cib`}],[`path`,{d:`M3 5v14a9 3 0 0 0 6.47 2.88`,key:`i62tjy`}],[`path`,{d:`M12 12v4h4`,key:`1bxaet`}],[`path`,{d:`M13 20a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L12 16`,key:`1f4ei9`}]]};Xe.node;var Ze=o(Xe),Qe={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};Qe.node;var $e=o(Qe),et={name:`folder-search`,size:24,node:[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]};et.node;var tt=o(et),nt={name:`keyboard`,size:24,node:[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]};nt.node;var rt=o(nt),it={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};it.node;var at=o(it),ot={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};ot.node;var st=o(ot),ct={name:`monitor-smartphone`,size:24,node:[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]};ct.node;var lt=o(ct),ut={name:`rotate-ccw-clock`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]],aliases:[`history`]};ut.node;var dt=o(ut),ft={name:`shield-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]};ft.node;var pt=o(ft),mt={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};mt.node;var ht=o(mt),gt={name:`star`,size:24,node:[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]};gt.node;var _t=o(gt),vt={name:`stethoscope`,size:24,node:[[`path`,{d:`M11 2v2`,key:`1539x4`}],[`path`,{d:`M5 2v2`,key:`1yf1q8`}],[`path`,{d:`M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1`,key:`rb5t3r`}],[`path`,{d:`M8 15a6 6 0 0 0 12 0v-3`,key:`x18d4x`}],[`circle`,{cx:`20`,cy:`10`,r:`2`,key:`ts1r5v`}]]};vt.node;var yt=o(vt),bt={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};bt.node;var xt=o(bt),z=e(a(),1),B=c(),St=[{path:`hosts`,label:`Hosts`,description:`Execution hosts, capabilities and versions`,icon:ne},{path:`devices`,label:`Devices`,description:`Signed-in browsers, apps and terminals`,icon:lt},{path:`sign-in`,label:`Sign-in`,description:`Passkeys, single sign-on and signing out`,icon:de},{path:`projects`,label:`Projects`,description:`Repositories, checkouts and workspaces`,icon:ae},{path:`profiles`,label:`Pi profiles`,description:`Provider, model and thinking presets`,icon:oe},{path:`adapters`,label:`Adapters`,description:`Extension adapters on each host`,icon:ee},{path:`notifications`,label:`Notifications`,description:`Push, quiet hours and previews`,icon:ye},{path:`backups`,label:`Backups`,description:`Back up and restore the coordinator`,icon:Ze},{path:`diagnostics`,label:`Diagnostics`,description:`Versions, migrations, events and recent problems`,icon:yt},{path:`device`,label:`This device`,description:`Preferences stored on this device`,icon:rt}],V=e=>e?`/settings/${e}`:`/settings`;function H({title:e,description:t,actions:n,back:i,testId:a,children:o}){let s=Te(),c=i??(s===`mobile`?{to:`/settings`,label:`Settings`}:null);return(0,B.jsxs)(`section`,{"data-testid":a,className:`mx-auto flex w-full min-w-0 max-w-4xl flex-col gap-4 px-4 py-4 md:px-6`,children:[c&&(0,B.jsxs)(r,{to:c.to,className:`tap -ml-2 inline-flex w-fit items-center gap-1 rounded-md px-2 py-1 text-sm font-medium text-accent hover:bg-surface-2`,children:[(0,B.jsx)(re,{"aria-hidden":!0,className:`size-4`}),`Back to `,c.label]}),(0,B.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-start gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-[1_1_15rem]`,children:[(0,B.jsx)(`h1`,{className:`break-words text-lg font-semibold`,children:e}),t&&(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:t})]}),n&&(0,B.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:n})]}),o]})}function U({title:e,description:t,actions:n,children:r,className:i}){return(0,B.jsxs)(`section`,{className:T(`min-w-0 rounded-lg border border-border bg-surface p-4`,i),children:[(e||n)&&(0,B.jsxs)(`div`,{className:`mb-3 flex min-w-0 flex-wrap items-start gap-2`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-[1_1_12rem]`,children:[e&&(0,B.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),t&&(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:t})]}),n&&(0,B.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:n})]}),r]})}function W({items:e}){return(0,B.jsx)(`dl`,{className:`grid min-w-0 gap-x-4 gap-y-1 text-sm sm:grid-cols-[minmax(8rem,12rem)_minmax(0,1fr)]`,children:e.map(([e,t],n)=>(0,B.jsxs)(`div`,{className:`contents`,children:[(0,B.jsx)(`dt`,{className:`text-muted`,children:e}),(0,B.jsx)(`dd`,{className:`mb-1 min-w-0 break-words sm:mb-0`,children:t})]},n))})}function G(){let e=_();return e.state===`live`||e.state===`connecting`?null:(0,B.jsxs)(`p`,{role:`status`,className:`flex items-center gap-1.5 text-sm text-muted`,children:[(0,B.jsx)(dt,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,B.jsxs)(`span`,{children:[`Showing last known data`,e.lastSyncedAt?` from ${O(e.lastSyncedAt)}`:``,`. Changes made elsewhere appear after reconnecting.`]})]})}function K(){return h(e=>e.hydrated)}function q({icon:e,label:t,tone:n=`neutral`,spin:r,className:i}){return(0,B.jsxs)(`span`,{className:T(`inline-flex max-w-full items-center gap-1 rounded-full border px-2 text-xs leading-6 font-medium`,Se[n],i),children:[(0,B.jsx)(e,{"aria-hidden":!0,className:T(`size-3.5 shrink-0`,r&&`animate-spin`)}),(0,B.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]})}var Ct={darwin:`macOS`,linux:`Linux`};function wt({host:e}){return e.piVersion?e.piCompatible?(0,B.jsx)(q,{icon:F,tone:`success`,label:`Pi ${e.piVersion} (compatible)`}):(0,B.jsx)(q,{icon:w,tone:`danger`,label:`Pi ${e.piVersion} (incompatible, needs ${Pe})`}):(0,B.jsx)(q,{icon:w,tone:`warning`,label:`Pi not detected (incompatible)`})}function J({id:e,label:t,hint:n,error:r,children:i,className:a}){return(0,B.jsxs)(`div`,{className:T(`flex min-w-0 flex-col gap-1`,a),children:[(0,B.jsx)(`label`,{htmlFor:e,className:`text-sm font-medium`,children:t}),i,n&&(0,B.jsx)(`p`,{id:`${e}-hint`,className:`text-xs text-muted`,children:n}),r&&(0,B.jsxs)(`p`,{id:`${e}-error`,className:`flex items-start gap-1 text-xs text-danger`,children:[(0,B.jsx)(w,{"aria-hidden":!0,className:`mt-0.5 size-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`min-w-0 whitespace-pre-line break-words`,children:r})]})]})}function Y(e,t){let n=[t.hint&&`${e}-hint`,t.error&&`${e}-error`].filter(Boolean);return{"aria-describedby":n.length?n.join(` `):void 0,"aria-invalid":t.error?!0:void 0}}function X({className:e,children:t,...n}){return(0,B.jsx)(`select`,{className:T(`tap block h-9 w-full min-w-0 rounded-md border border-border bg-surface px-2 text-base text-text md:text-sm`,`focus:border-accent focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-0`,e),...n,children:t})}function Tt({label:e,description:t,checked:n,onChange:r,disabled:i}){let a=(0,z.useId)();return(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,B.jsx)(`input`,{id:a,type:`checkbox`,role:`switch`,"aria-checked":n,checked:n,disabled:i,onChange:e=>r(e.target.checked),"aria-describedby":t?`${a}-desc`:void 0,className:`peer sr-only`}),(0,B.jsxs)(`label`,{htmlFor:a,className:T(`tap flex min-w-0 flex-1 cursor-pointer items-start gap-3 rounded-md`,`peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-[var(--sy-focus)]`,i&&`cursor-not-allowed opacity-60`),children:[(0,B.jsx)(`span`,{"aria-hidden":!0,className:T(`relative mt-0.5 inline-flex h-6 w-10 shrink-0 items-center rounded-full border transition-colors`,n?`border-accent bg-accent`:`border-border-strong bg-surface-3`),children:(0,B.jsx)(`span`,{className:T(`absolute size-4 rounded-full bg-surface shadow transition-transform`,n?`translate-x-5`:`translate-x-1`)})}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`span`,{className:`block text-sm font-medium`,children:[e,` `,(0,B.jsxs)(`span`,{className:`font-normal text-muted`,children:[`(`,n?`On`:`Off`,`)`]})]}),t&&(0,B.jsx)(`span`,{id:`${a}-desc`,className:`block text-sm text-muted`,children:t})]})]})]})}function Et({label:e,description:t,checked:n,onChange:r}){let i=(0,z.useId)();return(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,B.jsx)(`input`,{id:i,type:`checkbox`,checked:n,onChange:e=>r(e.target.checked),"aria-describedby":t?`${i}-desc`:void 0,className:`tap mt-0.5 size-5 shrink-0 accent-[var(--sy-accent)]`}),(0,B.jsxs)(`label`,{htmlFor:i,className:`min-w-0 flex-1 cursor-pointer text-sm`,children:[(0,B.jsx)(`span`,{className:`block font-medium`,children:e}),t&&(0,B.jsx)(`span`,{id:`${i}-desc`,className:`block text-muted`,children:t})]})]})}function Dt(e){let t=e.trim();return t?t.startsWith(`/`)?null:`Use an absolute path that starts with /, e.g. /Users/me/src/app.`:`Enter the path of the checkout on the host.`}function Ot(e){if(typeof e!=`object`||!e)return!1;let t=e;return Array.isArray(t.passkeys)&&typeof t.passkeyAvailability==`object`}function kt(e){return e.split(`
|
|
1
|
+
import{_ as e,c as t,f as n,i as r,l as i,m as a,n as o,p as s,t as c,u as l}from"./jsx-runtime-D13aM9HY.js";import{A as u,B as d,E as f,G as p,H as m,P as h,R as g,T as _,U as v,V as y,W as b,_ as x,c as S,d as C,g as w,h as T,i as E,l as D,m as O,n as k,o as A,p as j,r as M,t as N,v as ee}from"./states-DrTQuYXw.js";import{n as te,t as ne}from"./server-SxFxIScj.js";import{i as re,n as ie,r as ae,t as oe}from"./sliders-horizontal-S3tmwxsP.js";import{t as se}from"./chevron-right-evVLS6hq.js";import{t as ce}from"./copy-oWgGHmkS.js";import{n as le,t as ue}from"./pencil-DI8QbCN8.js";import{t as de}from"./key-round-VDbE9E4X.js";import{t as P}from"./plus-BLP-wIYD.js";import{t as fe}from"./save-DEvZPWlS.js";import{t as pe}from"./trash-C6X2OLrI.js";import{A as me,B as he,C as ge,F as _e,H as ve,I as F,L as ye,T as be,c as I,d as xe,h as Se,j as Ce,k as we,n as Te,r as Ee,s as De,z as Oe}from"./index-Cf6ZUCfK.js";import{n as L,t as ke}from"./TextArea-BsQHOQMe.js";import{i as Ae,l as je,o as Me,s as Ne,t as Pe,u as Fe}from"./dist-Bgkh2hc5.js";import{t as R}from"./Overlay-oYnnwvFM.js";import{_ as Ie,c as Le,d as Re,f as ze,g as Be,l as Ve,m as He,p as Ue,r as We,u as Ge}from"./logic-D_Eq9DMW.js";var Ke={name:`bell-off`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]};Ke.node;var qe=o(Ke),Je={name:`bell-ring`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]};Je.node;var Ye=o(Je),Xe={name:`database-backup`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 12a9 3 0 0 0 5 2.69`,key:`1ui2ym`}],[`path`,{d:`M21 9.3V5`,key:`6k6cib`}],[`path`,{d:`M3 5v14a9 3 0 0 0 6.47 2.88`,key:`i62tjy`}],[`path`,{d:`M12 12v4h4`,key:`1bxaet`}],[`path`,{d:`M13 20a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L12 16`,key:`1f4ei9`}]]};Xe.node;var Ze=o(Xe),Qe={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};Qe.node;var $e=o(Qe),et={name:`folder-search`,size:24,node:[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]};et.node;var tt=o(et),nt={name:`keyboard`,size:24,node:[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]};nt.node;var rt=o(nt),it={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};it.node;var at=o(it),ot={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};ot.node;var st=o(ot),ct={name:`monitor-smartphone`,size:24,node:[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]};ct.node;var lt=o(ct),ut={name:`rotate-ccw-clock`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]],aliases:[`history`]};ut.node;var dt=o(ut),ft={name:`shield-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]};ft.node;var pt=o(ft),mt={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};mt.node;var ht=o(mt),gt={name:`star`,size:24,node:[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]};gt.node;var _t=o(gt),vt={name:`stethoscope`,size:24,node:[[`path`,{d:`M11 2v2`,key:`1539x4`}],[`path`,{d:`M5 2v2`,key:`1yf1q8`}],[`path`,{d:`M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1`,key:`rb5t3r`}],[`path`,{d:`M8 15a6 6 0 0 0 12 0v-3`,key:`x18d4x`}],[`circle`,{cx:`20`,cy:`10`,r:`2`,key:`ts1r5v`}]]};vt.node;var yt=o(vt),bt={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};bt.node;var xt=o(bt),z=e(a(),1),B=c(),St=[{path:`hosts`,label:`Hosts`,description:`Execution hosts, capabilities and versions`,icon:ne},{path:`devices`,label:`Devices`,description:`Signed-in browsers, apps and terminals`,icon:lt},{path:`sign-in`,label:`Sign-in`,description:`Passkeys, single sign-on and signing out`,icon:de},{path:`projects`,label:`Projects`,description:`Repositories, checkouts and workspaces`,icon:ae},{path:`profiles`,label:`Pi profiles`,description:`Provider, model and thinking presets`,icon:oe},{path:`adapters`,label:`Adapters`,description:`Extension adapters on each host`,icon:ee},{path:`notifications`,label:`Notifications`,description:`Push, quiet hours and previews`,icon:ye},{path:`backups`,label:`Backups`,description:`Back up and restore the coordinator`,icon:Ze},{path:`diagnostics`,label:`Diagnostics`,description:`Versions, migrations, events and recent problems`,icon:yt},{path:`device`,label:`This device`,description:`Preferences stored on this device`,icon:rt}],V=e=>e?`/settings/${e}`:`/settings`;function H({title:e,description:t,actions:n,back:i,testId:a,children:o}){let s=Te(),c=i??(s===`mobile`?{to:`/settings`,label:`Settings`}:null);return(0,B.jsxs)(`section`,{"data-testid":a,className:`mx-auto flex w-full min-w-0 max-w-4xl flex-col gap-4 px-4 py-4 md:px-6`,children:[c&&(0,B.jsxs)(r,{to:c.to,className:`tap -ml-2 inline-flex w-fit items-center gap-1 rounded-md px-2 py-1 text-sm font-medium text-accent hover:bg-surface-2`,children:[(0,B.jsx)(re,{"aria-hidden":!0,className:`size-4`}),`Back to `,c.label]}),(0,B.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-start gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-[1_1_15rem]`,children:[(0,B.jsx)(`h1`,{className:`break-words text-lg font-semibold`,children:e}),t&&(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:t})]}),n&&(0,B.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:n})]}),o]})}function U({title:e,description:t,actions:n,children:r,className:i}){return(0,B.jsxs)(`section`,{className:T(`min-w-0 rounded-lg border border-border bg-surface p-4`,i),children:[(e||n)&&(0,B.jsxs)(`div`,{className:`mb-3 flex min-w-0 flex-wrap items-start gap-2`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-[1_1_12rem]`,children:[e&&(0,B.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),t&&(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:t})]}),n&&(0,B.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:n})]}),r]})}function W({items:e}){return(0,B.jsx)(`dl`,{className:`grid min-w-0 gap-x-4 gap-y-1 text-sm sm:grid-cols-[minmax(8rem,12rem)_minmax(0,1fr)]`,children:e.map(([e,t],n)=>(0,B.jsxs)(`div`,{className:`contents`,children:[(0,B.jsx)(`dt`,{className:`text-muted`,children:e}),(0,B.jsx)(`dd`,{className:`mb-1 min-w-0 break-words sm:mb-0`,children:t})]},n))})}function G(){let e=_();return e.state===`live`||e.state===`connecting`?null:(0,B.jsxs)(`p`,{role:`status`,className:`flex items-center gap-1.5 text-sm text-muted`,children:[(0,B.jsx)(dt,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,B.jsxs)(`span`,{children:[`Showing last known data`,e.lastSyncedAt?` from ${O(e.lastSyncedAt)}`:``,`. Changes made elsewhere appear after reconnecting.`]})]})}function K(){return h(e=>e.hydrated)}function q({icon:e,label:t,tone:n=`neutral`,spin:r,className:i}){return(0,B.jsxs)(`span`,{className:T(`inline-flex max-w-full items-center gap-1 rounded-full border px-2 text-xs leading-6 font-medium`,Se[n],i),children:[(0,B.jsx)(e,{"aria-hidden":!0,className:T(`size-3.5 shrink-0`,r&&`animate-spin`)}),(0,B.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]})}var Ct={darwin:`macOS`,linux:`Linux`};function wt({host:e}){return e.piVersion?e.piCompatible?(0,B.jsx)(q,{icon:F,tone:`success`,label:`Pi ${e.piVersion} (compatible)`}):(0,B.jsx)(q,{icon:w,tone:`danger`,label:`Pi ${e.piVersion} (incompatible, needs ${Pe})`}):(0,B.jsx)(q,{icon:w,tone:`warning`,label:`Pi not detected (incompatible)`})}function J({id:e,label:t,hint:n,error:r,children:i,className:a}){return(0,B.jsxs)(`div`,{className:T(`flex min-w-0 flex-col gap-1`,a),children:[(0,B.jsx)(`label`,{htmlFor:e,className:`text-sm font-medium`,children:t}),i,n&&(0,B.jsx)(`p`,{id:`${e}-hint`,className:`text-xs text-muted`,children:n}),r&&(0,B.jsxs)(`p`,{id:`${e}-error`,className:`flex items-start gap-1 text-xs text-danger`,children:[(0,B.jsx)(w,{"aria-hidden":!0,className:`mt-0.5 size-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`min-w-0 whitespace-pre-line break-words`,children:r})]})]})}function Y(e,t){let n=[t.hint&&`${e}-hint`,t.error&&`${e}-error`].filter(Boolean);return{"aria-describedby":n.length?n.join(` `):void 0,"aria-invalid":t.error?!0:void 0}}function X({className:e,children:t,...n}){return(0,B.jsx)(`select`,{className:T(`tap block h-9 w-full min-w-0 rounded-md border border-border bg-surface px-2 text-base text-text md:text-sm`,`focus:border-accent focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-0`,e),...n,children:t})}function Tt({label:e,description:t,checked:n,onChange:r,disabled:i}){let a=(0,z.useId)();return(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,B.jsx)(`input`,{id:a,type:`checkbox`,role:`switch`,"aria-checked":n,checked:n,disabled:i,onChange:e=>r(e.target.checked),"aria-describedby":t?`${a}-desc`:void 0,className:`peer sr-only`}),(0,B.jsxs)(`label`,{htmlFor:a,className:T(`tap flex min-w-0 flex-1 cursor-pointer items-start gap-3 rounded-md`,`peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-[var(--sy-focus)]`,i&&`cursor-not-allowed opacity-60`),children:[(0,B.jsx)(`span`,{"aria-hidden":!0,className:T(`relative mt-0.5 inline-flex h-6 w-10 shrink-0 items-center rounded-full border transition-colors`,n?`border-accent bg-accent`:`border-border-strong bg-surface-3`),children:(0,B.jsx)(`span`,{className:T(`absolute size-4 rounded-full bg-surface shadow transition-transform`,n?`translate-x-5`:`translate-x-1`)})}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`span`,{className:`block text-sm font-medium`,children:[e,` `,(0,B.jsxs)(`span`,{className:`font-normal text-muted`,children:[`(`,n?`On`:`Off`,`)`]})]}),t&&(0,B.jsx)(`span`,{id:`${a}-desc`,className:`block text-sm text-muted`,children:t})]})]})]})}function Et({label:e,description:t,checked:n,onChange:r}){let i=(0,z.useId)();return(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,B.jsx)(`input`,{id:i,type:`checkbox`,checked:n,onChange:e=>r(e.target.checked),"aria-describedby":t?`${i}-desc`:void 0,className:`tap mt-0.5 size-5 shrink-0 accent-[var(--sy-accent)]`}),(0,B.jsxs)(`label`,{htmlFor:i,className:`min-w-0 flex-1 cursor-pointer text-sm`,children:[(0,B.jsx)(`span`,{className:`block font-medium`,children:e}),t&&(0,B.jsx)(`span`,{id:`${i}-desc`,className:`block text-muted`,children:t})]})]})}function Dt(e){let t=e.trim();return t?t.startsWith(`/`)?null:`Use an absolute path that starts with /, e.g. /Users/me/src/app.`:`Enter the path of the checkout on the host.`}function Ot(e){if(typeof e!=`object`||!e)return!1;let t=e;return Array.isArray(t.passkeys)&&typeof t.passkeyAvailability==`object`}function kt(e){return e.split(`
|
|
2
2
|
`).map(e=>e.trim()).filter(Boolean)}function Z({error:e}){return e?(0,B.jsxs)(`p`,{role:`alert`,className:`flex items-start gap-2 rounded-md border border-border bg-danger-soft px-3 py-2 text-sm`,children:[(0,B.jsx)(w,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-danger`}),(0,B.jsx)(`span`,{className:`min-w-0 break-words`,children:b(e)})]}):null}async function At(e,t=`Copied to clipboard`){try{return await navigator.clipboard.writeText(e),I.success(t),!0}catch{return I.error(`Could not copy. Select the text and copy it manually.`),!1}}function jt({text:e,label:t=`Copy`,toastMessage:n,size:r=`sm`}){let[i,a]=(0,z.useState)(!1),o=(0,z.useRef)(null);return(0,z.useEffect)(()=>()=>void(o.current&&clearTimeout(o.current)),[]),(0,B.jsx)(D,{size:r,icon:i?(0,B.jsx)(te,{className:`size-4`}):(0,B.jsx)(ce,{className:`size-4`}),onClick:async()=>{await At(e,n)&&(a(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>a(!1),2e3))},children:i?`Copied`:t})}function Mt({text:e,label:t,copyLabel:n=`Copy`}){return(0,B.jsxs)(`figure`,{className:`m-0 flex min-w-0 flex-col gap-2 sm:flex-row sm:items-start`,children:[(0,B.jsx)(`figcaption`,{className:`sr-only`,children:t}),(0,B.jsx)(`pre`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-all rounded-md border border-border bg-surface-2 px-3 py-2 font-mono text-sm`,children:e}),(0,B.jsx)(jt,{text:e,label:n})]})}function Nt(e){let[t,n]=(0,z.useState)(()=>Date.now());if((0,z.useEffect)(()=>{if(!e)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),!e)return null;let r=Date.parse(e);return Number.isNaN(r)?null:Math.max(0,r-t)}function Pt(e){let t=Math.ceil(e/1e3);return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function Ft({open:e,onClose:t,title:n,description:r,confirmLabel:i,onConfirm:a,busy:o,error:s,danger:c=!0,confirmDisabled:l,disabledReason:u,children:d}){return(0,B.jsx)(R,{open:e,onClose:o?()=>void 0:t,dismissOnBackdrop:!o,title:n,description:r,footer:(0,B.jsxs)(B.Fragment,{children:[l&&u&&(0,B.jsx)(`p`,{className:`mr-auto min-w-0 flex-1 basis-full text-xs text-muted sm:basis-auto`,children:u}),(0,B.jsx)(D,{onClick:t,disabled:o,children:`Cancel`}),(0,B.jsx)(D,{variant:c?`danger`:`primary`,busy:o,disabled:l,onClick:a,children:i})]}),children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,(0,B.jsx)(Z,{error:s})]})})}var It=class extends Error{constructor(e){super(`Unexpected response from ${e}. The coordinator and this app may be out of sync.`),this.name=`UnexpectedResponseError`}};function Lt(e,t){let[n,r]=(0,z.useState)({data:void 0,error:null,loading:e!==null,fatal:!1}),[i,a]=(0,z.useState)(0);(0,z.useEffect)(()=>{if(!e)return;let n=new AbortController;return r(e=>({...e,loading:!0,error:null,fatal:!1})),y(e,void 0,n.signal).then(i=>{n.signal.aborted||(t&&!t(i)?r(t=>({...t,loading:!1,error:new It(e),fatal:!0})):r({data:i,error:null,loading:!1,fatal:!1}))}).catch(e=>{n.signal.aborted||r(t=>({...t,loading:!1,error:e,fatal:!1}))}),()=>n.abort()},[e,i]);let o=(0,z.useCallback)(()=>a(e=>e+1),[]),s=(0,z.useCallback)(e=>r({data:e,error:null,loading:!1,fatal:!1}),[]);return{...n,reload:o,setData:s}}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Rt={active:{icon:F,label:`Active`,tone:`success`},disabled:{icon:Ce,label:`Disabled`,tone:`neutral`},error:{icon:me,label:`Error`,tone:`danger`}};function zt({status:e}){let t=Rt[e]??Rt.error;return(0,B.jsx)(q,{icon:t.icon,label:t.label,tone:t.tone})}var Bt={project:`Project`,owner:`Owner`,plugin:`Plugin`,bundled:`Bundled`},Vt={info:{icon:be,label:`Info`,tone:`info`},warning:{icon:w,label:`Warning`,tone:`warning`},error:{icon:me,label:`Error`,tone:`danger`}};function Ht({level:e}){let t=Vt[e]??Vt.info;return(0,B.jsx)(q,{icon:t.icon,label:t.label,tone:t.tone})}function Ut(e){let t=h(e=>e.diagnostics);return(0,z.useMemo)(()=>{let n=new Set,r=[];for(let i of[...e??[],...t]){let e=`${i.at}|${i.adapterId??``}|${i.sessionId??``}|${i.message}`;n.has(e)||(n.add(e),r.push(i))}return r.sort((e,t)=>t.at.localeCompare(e.at))},[e,t])}function Wt(){let e=K(),t=h(e=>e.adapters),n=h(e=>e.hosts),i=Lt(`/api/diagnostics`,Q),a=Ut(Array.isArray(i.data?.diagnostics)?i.data.diagnostics:void 0),o=(0,z.useMemo)(()=>Object.entries(t).filter(([,e])=>e.length>0).map(([e,t])=>({hostId:e,hostName:n[e]?.name??`Unknown host (${e})`,adapters:[...t].sort((e,t)=>e.id.localeCompare(t.id))})).sort((e,t)=>e.hostName.localeCompare(t.hostName)),[t,n]);return(0,B.jsxs)(H,{title:`Adapters`,description:`Adapters translate Pi extensions into Switchyard cards, panels and interactions. Each host reports its own.`,children:[(0,B.jsx)(G,{}),i.error!==null&&!i.fatal&&(0,B.jsx)(k,{compact:!0,title:`Could not load adapter diagnostics history`,error:i.error,onRetry:i.reload}),e?o.length===0?(0,B.jsx)(N,{icon:(0,B.jsx)(ee,{className:`size-8`}),title:`No adapters reported`,description:`Hosts report adapters when their agent connects. Check that your hosts are connected.`,action:{label:`Open hosts`,to:V(`hosts`)}}):o.map(e=>(0,B.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,B.jsx)(`h2`,{className:`text-base font-semibold`,children:(0,B.jsx)(r,{to:V(`hosts/${encodeURIComponent(e.hostId)}`),className:`hover:underline`,children:e.hostName})}),e.adapters.map(e=>(0,B.jsx)(Gt,{adapter:e,diagnostics:a.filter(t=>t.adapterId===e.id)},e.id))]},e.hostId)):(0,B.jsx)(A,{label:`Loading adapters…`})]})}function Gt({adapter:e,diagnostics:t}){return(0,B.jsxs)(U,{title:(0,B.jsx)(`span`,{className:`break-all font-mono`,children:e.id}),actions:(0,B.jsx)(zt,{status:e.status}),children:[(0,B.jsx)(W,{items:[[`Version`,e.version],[`Tier`,Bt[e.tier]??e.tier],[`Target extension`,(0,B.jsx)(`span`,{className:`break-all font-mono`,children:e.target.extension},`t`)],[`Version range`,(0,B.jsx)(`span`,{className:`font-mono`,children:e.target.versionRange},`r`)],[`Tested versions`,e.target.testedVersions.length?e.target.testedVersions.join(`, `):`None recorded`],[`Capabilities`,e.capabilities.length?e.capabilities.join(`, `):`None`],[`Web renderer`,e.webRenderer?`Yes (runs in a sandboxed frame; mobile uses a fallback)`:`No (native cards only)`],...e.detail?[[`Detail`,e.detail]]:[]]}),(0,B.jsx)(`h3`,{className:`mt-3 mb-1 text-sm font-semibold`,children:`Recent diagnostics`}),t.length===0?(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`No diagnostics for this adapter.`}):(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:t.slice(0,10).map(e=>(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-2 text-sm`,children:[(0,B.jsx)(Ht,{level:e.level}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),(0,B.jsx)(`time`,{dateTime:e.at,className:`text-xs text-muted`,children:O(e.at)})]},`${e.at}-${e.message}`))})]})}function Kt(e){return Q(e)&&Q(e.versions)}var qt=`/api/diagnostics`,Jt=`switchyard coordinator backup <file>`,Yt=`switchyard coordinator restore <file>`;function Xt(e){let t=e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/_/g,` `);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function Zt(e,t){return t==null?`None`:typeof t==`string`&&/At$|time|date/i.test(e)?O(t):typeof t==`object`?JSON.stringify(t):String(t)}function Qt(){let e=Lt(qt,Kt),t=e.data&&Q(e.data.backup)?e.data.backup:null;return(0,B.jsxs)(H,{title:`Backups`,description:`The coordinator keeps all state in one SQLite database. Back it up from the machine that runs the coordinator.`,children:[(0,B.jsxs)(U,{title:`Back up`,children:[(0,B.jsx)(`p`,{className:`mb-2 text-sm`,children:`Writes a consistent copy of the database to a file while the coordinator keeps running.`}),(0,B.jsx)(Mt,{text:Jt,label:`Backup command`,copyLabel:`Copy command`})]}),(0,B.jsxs)(U,{title:`Restore`,children:[(0,B.jsxs)(`p`,{className:`mb-2 text-sm`,children:[`Restore refuses to run while the coordinator is running: stop it first. The current database is kept next to it as`,` `,(0,B.jsx)(`code`,{className:`break-all`,children:`coordinator.db.bak-<ts>`}),`.`]}),(0,B.jsx)(Mt,{text:Yt,label:`Restore command`,copyLabel:`Copy command`}),(0,B.jsx)(`p`,{className:`mt-2 text-sm text-muted`,children:`Hosts keep running sessions during a coordinator restart and replay their events when it comes back.`})]}),(0,B.jsx)(U,{title:`Last backup`,children:e.fatal?(0,B.jsx)(M,{error:e.error}):e.error&&!e.data?(0,B.jsx)(k,{compact:!0,title:`Could not load backup info`,error:e.error,onRetry:e.reload}):e.data?t&&Object.keys(t).length>0?(0,B.jsx)(W,{items:Object.entries(t).map(([e,t])=>[Xt(e),Zt(e,t)])}):(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`No backup info is recorded by the coordinator. Keep track of your backup files yourself, or schedule the backup command with cron or launchd.`}):(0,B.jsx)(A,{label:`Loading backup info…`})})]})}function $t(e){return v(`/api/enrollments`,{kind:e})}function en({expiresAt:e,onRenew:t,busy:n}){let r=Nt(e);return r!==null&&r<=0?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,role:`status`,children:[(0,B.jsx)(w,{"aria-hidden":!0,className:`size-4 shrink-0 text-warning`}),(0,B.jsx)(`span`,{className:`font-medium`,children:`Expired: create a new link`}),(0,B.jsx)(D,{size:`sm`,busy:n,icon:(0,B.jsx)(x,{className:`size-4`}),onClick:t,children:`Create new link`})]}):(0,B.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted`,children:[(0,B.jsx)(we,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,B.jsxs)(`span`,{children:[`Expires in`,` `,(0,B.jsx)(`span`,{className:`font-mono tabular-nums`,children:r===null?`unknown`:Pt(r)}),`. Single use.`]})]})}function tn({busy:e,error:t,onRetry:n}){return e?(0,B.jsx)(A,{label:`Creating a single-use link…`}):t?(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsx)(Z,{error:t}),(0,B.jsx)(D,{icon:(0,B.jsx)(x,{className:`size-4`}),onClick:n,children:`Retry`})]}):null}var nn={browser:`Browser`,pwa:`Home Screen app`,terminal:`Terminal`,cli:`CLI`},rn={granted:`allowed`,denied:`blocked`,default:`not requested`,unknown:`unknown`};function an({kind:e}){return(0,B.jsx)(e===`pwa`?ht:e===`browser`?at:xt,{"aria-hidden":!0,className:`mt-0.5 size-5 shrink-0 text-muted`})}function on(){let e=K(),t=h(e=>e.devices);ve(e=>e.me);let n=Oe(),r=(0,z.useMemo)(()=>Object.values(t).filter(e=>e.revokedAt===null).sort((e,t)=>Number(t.id===n)-Number(e.id===n)||(t.lastSeenAt??``).localeCompare(e.lastSeenAt??``)),[t,n]),[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(null),[c,l]=(0,z.useState)(!1),[u,d]=(0,z.useState)(null),[f,p]=(0,z.useState)(null),g=async()=>{if(o){l(!0),d(null);try{await v(`/api/devices/${encodeURIComponent(o.id)}/revoke`),I.success(`${o.name} revoked`),s(null)}catch(e){d(e)}finally{l(!1)}}},_=async e=>{p(e.id);try{await m(`/api/devices/${encodeURIComponent(e.id)}`,{preferredMobile:!0}),I.success(`${e.name} is now the preferred mobile device`)}catch(e){I.error(`Could not set the preferred device: ${b(e)}`)}finally{p(null)}};return(0,B.jsxs)(H,{testId:`settings-devices`,title:`Devices`,description:`Browsers, Home Screen apps and terminals signed in to this coordinator. Each has its own revocable credential.`,actions:(0,B.jsx)(D,{variant:`primary`,icon:(0,B.jsx)(P,{className:`size-4`}),onClick:()=>a(!0),children:`Add device`}),children:[(0,B.jsx)(G,{}),e?r.length===0?(0,B.jsx)(N,{icon:(0,B.jsx)(lt,{className:`size-8`}),title:`No devices`,description:`Add a phone, tablet or another computer with a single-use QR link.`,action:{label:`Add device`,onClick:()=>a(!0)}}):(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:r.map(e=>{let t=e.id===n;return(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-3 border-b border-border px-4 py-3 last:border-b-0`,children:[(0,B.jsx)(an,{kind:e.kind}),(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.name}),t&&(0,B.jsx)(q,{icon:at,tone:`info`,label:`This device`}),e.preferredMobile&&(0,B.jsx)(q,{icon:_t,tone:`success`,label:`Preferred mobile`})]}),(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-muted`,children:[(0,B.jsx)(`span`,{children:nn[e.kind]}),(0,B.jsxs)(`span`,{children:[`Last seen `,j(e.lastSeenAt)]}),(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e.push.subscribed?(0,B.jsx)(Ye,{"aria-hidden":!0,className:`size-4 shrink-0`}):(0,B.jsx)(qe,{"aria-hidden":!0,className:`size-4 shrink-0`}),e.push.subscribed?`Push subscribed`:`No push subscription`,`, permission`,` `,rn[e.push.permission]]})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[!e.preferredMobile&&(0,B.jsx)(D,{size:`sm`,icon:(0,B.jsx)(_t,{className:`size-4`}),busy:f===e.id,onClick:()=>_(e),children:`Set as preferred mobile device`}),(0,B.jsx)(D,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,B.jsx)(pt,{className:`size-4`}),onClick:()=>{d(null),s(e)},children:`Revoke`})]})]},e.id)})}):(0,B.jsx)(A,{label:`Loading devices…`}),(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`The preferred mobile device receives push notifications when no desktop was recently active.`}),(0,B.jsx)(sn,{open:i,onClose:()=>a(!1)}),(0,B.jsxs)(Ft,{open:o!==null,onClose:()=>s(null),title:o?`Revoke ${o.name}?`:`Revoke device`,confirmLabel:`Revoke device`,busy:c,error:u,onConfirm:g,children:[(0,B.jsx)(`p`,{className:`text-sm`,children:`Its credential stops working immediately and its push subscription is removed. To use it again, add it with a new link.`}),o?.id===n&&(0,B.jsx)(`p`,{className:`text-sm font-medium text-danger`,children:`This is the device you are using now. Revoking it signs you out here.`})]})]})}function sn({open:e,onClose:t}){let[n,r]=(0,z.useState)(null),[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(null),c=async()=>{a(!0),s(null);try{r(await $t(`device`))}catch(e){s(e)}finally{a(!1)}};(0,z.useEffect)(()=>{e&&c()},[e]);let l=()=>{r(null),s(null),t()};return(0,B.jsx)(R,{open:e,onClose:l,title:`Add device`,description:`Scan the code with the new device's camera, or open the link on it.`,footer:(0,B.jsx)(D,{onClick:l,children:`Done`}),children:(0,B.jsxs)(`div`,{"data-testid":`add-device-dialog`,className:`flex min-w-0 flex-col items-stretch gap-3`,children:[(0,B.jsx)(tn,{busy:i,error:o,onRetry:c}),n&&!i&&(0,B.jsxs)(B.Fragment,{children:[n.qrSvg&&(0,B.jsx)(`div`,{role:`img`,"aria-label":`QR code for the enrollment link`,className:`mx-auto size-56 max-w-full rounded-md bg-white p-2 [&>svg]:size-full`,dangerouslySetInnerHTML:{__html:n.qrSvg}}),(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,B.jsx)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`,className:`min-w-0 flex-1 break-all font-mono text-sm text-accent underline`,children:n.url}),(0,B.jsx)(jt,{text:n.url,label:`Copy link`,toastMessage:`Link copied`})]}),(0,B.jsx)(en,{expiresAt:n.expiresAt,onRenew:c,busy:i}),(0,B.jsx)(`p`,{className:`text-xs text-muted`,children:`Anyone with this link can enroll a device until it expires or is used. Share it only with your own devices.`})]})]})})}function cn(){let e=De(e=>e.sendWithEnter),t=De(e=>e.set),n=Te(),r=Ee();ve(e=>e.me);let i=Oe(),a=h(e=>i?e.devices[i]:void 0);return(0,B.jsxs)(H,{title:`This device`,description:`These preferences are stored in this browser only; your other devices keep their own.`,children:[(0,B.jsx)(U,{title:`Composer`,children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,B.jsx)(Tt,{label:`Send with Enter`,description:`On desktop, Enter sends the message and Shift+Enter inserts a newline. When off, Enter inserts a newline; send with the Send button.`,checked:e,onChange:e=>t(`sendWithEnter`,e)}),(0,B.jsxs)(`p`,{className:`text-sm text-muted`,children:[`On mobile, Return always inserts a newline and messages are sent with the Send button.`,n===`mobile`||r?` That applies on this device now.`:``]})]})}),(0,B.jsx)(U,{title:`Identity`,children:(0,B.jsx)(W,{items:[[`Name`,a?.name??`Unknown`],[`Kind`,a?nn[a.kind]:`Unknown`],[`Device ID`,(0,B.jsx)(`span`,{className:`break-all font-mono`,children:i??`Unknown`},`id`)]]})})]})}var $=e=>e==null||e===``?`Unknown`:String(e);function ln(){let e=Lt(qt,Kt),t=e.data,n=Ut(Array.isArray(t?.diagnostics)?t.diagnostics:void 0),r=h(e=>e.hosts),i=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(D,{icon:(0,B.jsx)(ce,{className:`size-4`}),disabled:!t,onClick:()=>t&&At(JSON.stringify(t,null,2),`Diagnostics JSON copied`),children:`Copy diagnostics JSON`}),(0,B.jsx)(D,{busy:e.loading&&!!t,icon:(0,B.jsx)(x,{className:`size-4`}),onClick:e.reload,children:`Refresh`})]}),a;if(e.fatal)a=(0,B.jsx)(M,{error:e.error,diagnosticsHref:`/settings/diagnostics`});else if(e.error&&!t)a=(0,B.jsx)(k,{title:`Could not load diagnostics`,error:e.error,onRetry:e.reload});else if(!t)a=(0,B.jsx)(A,{label:`Loading diagnostics…`});else{let i=t.migrationLevel!==void 0&&t.latestMigration!==void 0&&t.migrationLevel>=t.latestMigration,o=(t.hosts??[]).filter(e=>!e.revokedAt);a=(0,B.jsxs)(B.Fragment,{children:[e.error?(0,B.jsx)(k,{compact:!0,title:`Refresh failed`,error:e.error,onRetry:e.reload}):null,(0,B.jsx)(U,{title:`Versions`,children:(0,B.jsx)(`div`,{className:`overflow-x-auto`,children:(0,B.jsxs)(`table`,{className:`w-full min-w-0 text-left text-sm`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{className:`border-b border-border text-muted`,children:[(0,B.jsx)(`th`,{scope:`col`,className:`py-1 pr-4 font-medium`,children:`Component`}),(0,B.jsx)(`th`,{scope:`col`,className:`py-1 font-medium`,children:`Version`})]})}),(0,B.jsxs)(`tbody`,{children:[Object.entries(t.versions).map(([e,t])=>(0,B.jsxs)(`tr`,{className:`border-b border-border last:border-b-0`,children:[(0,B.jsx)(`th`,{scope:`row`,className:`py-1 pr-4 font-normal capitalize`,children:e}),(0,B.jsx)(`td`,{className:`py-1 font-mono break-all`,children:$(t)})]},e)),(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{scope:`row`,className:`py-1 pr-4 font-normal`,children:`Supported Pi`}),(0,B.jsx)(`td`,{className:`py-1 font-mono`,children:Pe})]})]})]})})}),(0,B.jsx)(U,{title:`Coordinator`,children:(0,B.jsx)(W,{items:[[`Database migration`,(0,B.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`span`,{children:[`Level `,$(t.migrationLevel),` of `,$(t.latestMigration)]}),i?(0,B.jsx)(q,{icon:F,tone:`success`,label:`Up to date`}):(0,B.jsx)(q,{icon:w,tone:`warning`,label:`Behind latest`})]},`m`)],[`Public URL`,(0,B.jsx)(`span`,{className:`break-all`,children:$(t.publicUrl)},`u`)],[`Events`,t.events?`Seq ${$(t.events.minSeq)} to ${$(t.events.maxSeq)} stored (current ${$(t.events.currentSeq)}, oldest retained ${$(t.events.minRetainedSeq)})`:`Unknown`],[`Event retention`,t.events?.retentionDays==null?`Unknown`:`${t.events.retentionDays} days`],[`Push`,t.push?`${t.push.vapidConfigured?`VAPID keys configured`:`VAPID keys not configured`}, ${$(t.push.subscriptions)} subscription(s)`:`Unknown`],[`Connected clients`,`${$(t.clients?.connectedDevices)} device(s)`]]})}),(0,B.jsx)(U,{title:`Hosts`,children:o.length===0?(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`No hosts enrolled.`}):(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:o.map(e=>{let t=r[e.id];return(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1 py-2 text-sm`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,B.jsx)(xe,{kind:`host`,value:t?.connectivity??e.connectivity}),(0,B.jsx)(wt,{host:e})]}),(0,B.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Agent `,$(e.agentVersion),` · Last seen `,j(e.lastSeenAt)]}),e.unsupported&&e.unsupported.length>0&&(0,B.jsx)(`ul`,{className:`list-disc pl-5 text-xs text-muted`,children:e.unsupported.map(e=>(0,B.jsxs)(`li`,{className:`break-words`,children:[e.capability,`: `,e.reason]},e.capability))})]},e.id)})})}),(0,B.jsx)(U,{title:`Recent diagnostics`,children:n.length===0?(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`No diagnostics recorded.`}):(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:n.slice(0,100).map((e,t)=>(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-2 text-sm`,children:[(0,B.jsx)(Ht,{level:e.level}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[e.message,e.adapterId&&(0,B.jsxs)(`span`,{className:`block text-xs text-muted`,children:[`Adapter `,e.adapterId]})]}),(0,B.jsx)(`time`,{dateTime:e.at,className:`text-xs text-muted`,children:O(e.at)})]},`${e.at}-${t}`))})})]})}return(0,B.jsxs)(H,{title:`Diagnostics`,description:`Versions, database state, hosts and recent problems. Copy the JSON when reporting a problem.`,actions:i,children:[(0,B.jsx)(G,{}),a]})}function un(e){let t=kt(e),n=t.find(e=>!Ae(e));return n?{folders:t,problem:`"${n}" is not an absolute path or a ~/ path.`}:t.length>20?{folders:t,problem:`Use at most 20 folders.`}:{folders:t,problem:null}}function dn(e,t=Date.now()){return e?e.state===`running`?`Scanning…`:e.state===`failed`?`Last scan failed ${j(e.finishedAt??e.startedAt,t)}: ${e.errors.at(-1)??`unknown error`}`:`Last scanned ${j(e.finishedAt,t)}: ${e.repositories} repositories, ${e.checkoutsAdded} new checkouts, ${e.projectsCreated} new projects.`:`Not scanned yet.`}function fn({host:e}){let t=(0,z.useId)(),n=(e.projectFolders??[]).join(`
|
|
3
3
|
`),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)(null),d=r??n,f=r!==null&&r!==n,{folders:p,problem:h}=un(d),g=e.projectScan,_=s||g?.state===`running`,y=e.connectivity===`connected`,b=n?y?_?`A scan is running`:null:`${e.name} is offline`:`Save a folder first`,x=async()=>{o(!0),u(null);try{await m(`/api/hosts/${encodeURIComponent(e.id)}`,{projectFolders:p}),I.success(`Project folders saved`),i(null)}catch(e){u(e)}finally{o(!1)}},S=async()=>{c(!0),u(null);try{let t=await v(`/api/hosts/${encodeURIComponent(e.id)}/scan-projects`);I.success(`Found ${t.repositories} repositories; ${t.projectsCreated} new projects`)}catch(e){u(e)}finally{c(!1)}},C=f?h:null;return(0,B.jsx)(U,{title:`Project folders`,description:`Every Git repository directly inside these folders becomes a project, or another checkout of the project with the same remote. Folders are rescanned when the host connects and every 10 minutes; nothing is removed automatically.`,children:(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,B.jsx)(J,{id:`${t}-folders`,label:`Folders on this host`,hint:`One per line: an absolute path or ~/..., e.g. ~/Projects.`,error:C,children:(0,B.jsx)(ke,{id:`${t}-folders`,value:d,onChange:e=>i(e.target.value),minRows:3,placeholder:`~/Projects`,className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,autoComplete:`off`,...Y(`${t}-folders`,{hint:!0,error:C})})}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(D,{variant:`primary`,icon:(0,B.jsx)(fe,{className:`size-4`}),busy:a,disabled:!f||!!h,onClick:x,children:`Save folders`}),(0,B.jsx)(D,{icon:(0,B.jsx)(tt,{className:`size-4`}),busy:s,disabled:!!b,title:b??void 0,onClick:S,children:`Scan now`})]}),(0,B.jsx)(`p`,{"aria-live":`polite`,className:`text-sm text-muted`,children:s?`Scanning…`:dn(g)}),g&&g.state!==`running`&&g.errors.length>0&&(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-0.5 text-xs text-muted`,children:g.errors.map(e=>(0,B.jsx)(`li`,{className:`break-words`,children:e},e))}),(0,B.jsx)(Z,{error:l})]})})}var pn={prompt:`Prompt`,steer:`Steer a running turn`,followUp:`Queue follow-up`,abort:`Abort`,resume:`Resume`,rename:`Rename session`,importInactive:`Import inactive sessions`,extensionDialogs:`Extension dialogs`,customUi:`Custom extension UI`,widgetsText:`Text widgets`,widgetsComponent:`Component widgets`,tokenAccounting:`Token accounting`,costAccounting:`Cost accounting`};function mn(){let e=K(),t=f(),[n,r]=(0,z.useState)(!1),i=t.filter(e=>e.connectivity!==`connected`);return(0,B.jsxs)(H,{testId:`settings-hosts`,title:`Hosts`,description:`Machines that run Pi sessions through the Switchyard host agent.`,actions:(0,B.jsx)(D,{variant:`primary`,icon:(0,B.jsx)(P,{className:`size-4`}),onClick:()=>r(!0),children:`Add host`}),children:[(0,B.jsx)(G,{}),e?t.length===0?(0,B.jsx)(N,{icon:(0,B.jsx)(ne,{className:`size-8`}),title:`No hosts yet`,description:`Add a host to run Pi sessions. You will get a command to run on that machine.`,action:{label:`Add host`,onClick:()=>r(!0)}}):(0,B.jsxs)(B.Fragment,{children:[i.map(e=>(0,B.jsx)(E,{compact:!0,hostName:e.name,connectivity:e.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:e.lastSeenAt},e.id)),(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:t.map(e=>(0,B.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,B.jsx)(hn,{host:e})},e.id))})]}):(0,B.jsx)(A,{label:`Loading hosts…`}),(0,B.jsx)(vn,{open:n,onClose:()=>r(!1)})]})}function hn({host:e}){return(0,B.jsxs)(r,{to:V(`hosts/${encodeURIComponent(e.id)}`),className:`tap flex min-w-0 items-center gap-3 px-4 py-3 hover:bg-surface-2`,children:[(0,B.jsx)(ne,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.name}),(0,B.jsx)(`span`,{className:`text-sm text-muted`,children:Ct[e.platform]})]}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsx)(xe,{kind:`host`,value:e.connectivity}),(0,B.jsx)(wt,{host:e}),(0,B.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Last seen `,j(e.lastSeenAt)]})]})]}),(0,B.jsx)(se,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})}var gn=`@spencerboucher/switchyard`;function _n(e){return[`npm install -g ${gn}`,e,`switchyard host install-service`].join(`
|
|
4
|
-
`)}function vn({open:e,onClose:t}){let[n,r]=(0,z.useState)(null),[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(null),c=async()=>{a(!0),s(null);try{r(await $t(`host`))}catch(e){s(e)}finally{a(!1)}},l=()=>{r(null),s(null),t()};return(0,B.jsx)(R,{open:e,onClose:l,title:`Add host`,description:`Enroll a machine that runs Pi. Provider credentials stay on that machine.`,footer:(0,B.jsx)(D,{onClick:l,children:`Done`}),children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!n&&!i&&!o&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`text-sm`,children:`Create a single-use enrollment, then run the command it shows on the new host. The host appears here once its agent connects.`}),(0,B.jsx)(D,{variant:`primary`,onClick:c,children:`Create enrollment command`})]}),(0,B.jsx)(tn,{busy:i,error:o,onRetry:c}),n&&!i&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`text-sm`,children:`Run this on the host, as the user that should run Pi (it needs Node 24 or newer, git and Pi):`}),(0,B.jsx)(Mt,{text:n.command?_n(n.command):n.url,label:n.command?`Host setup commands`:`Host enrollment link`,copyLabel:`Copy commands`}),(0,B.jsx)(en,{expiresAt:n.expiresAt,onRenew:c,busy:i})]})]})})}function yn(){let{hostId:e=``}=s(),t=K(),i=h(t=>t.hosts[e]),a=h(t=>t.adapters[e]),o=h(e=>e.checkouts),c=h(e=>e.projects),l=n(),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(!1),[m,g]=(0,z.useState)(null),_=(0,z.useMemo)(()=>Object.values(o).filter(t=>t.hostId===e).sort((e,t)=>e.path.localeCompare(t.path)),[o,e]),y={to:V(`hosts`),label:`Hosts`};if(!t)return(0,B.jsx)(H,{title:`Host`,back:y,children:(0,B.jsx)(A,{label:`Loading host…`})});if(!i||i.revokedAt)return(0,B.jsx)(H,{title:`Host`,back:y,children:(0,B.jsx)(N,{icon:(0,B.jsx)(ne,{className:`size-8`}),title:i?`This host was revoked`:`Host not found`,description:i?`${i.name} was revoked ${j(i.revokedAt)}. Add it again to use it.`:`It may have been revoked or never enrolled with this coordinator.`,action:{label:`Back to hosts`,to:V(`hosts`)}})});let b=async()=>{p(!0),g(null);try{await v(`/api/hosts/${encodeURIComponent(i.id)}/revoke`),I.success(`Host ${i.name} revoked`),d(!1),l(V(`hosts`))}catch(e){g(e)}finally{p(!1)}},x=i.capabilities,C=e=>x?.unsupported.find(t=>t.capability===e)?.reason,w=x?.unsupported.filter(e=>!Me.includes(e.capability))??[];return(0,B.jsxs)(H,{title:i.name,description:`${Ct[i.platform]} host`,back:y,actions:(0,B.jsx)(D,{variant:`danger`,icon:(0,B.jsx)(pt,{className:`size-4`}),onClick:()=>{g(null),d(!0)},children:`Revoke host`}),children:[(0,B.jsx)(G,{}),i.connectivity!==`connected`&&(0,B.jsx)(E,{compact:!0,hostName:i.name,connectivity:i.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:i.lastSeenAt}),(0,B.jsx)(U,{title:`Connectivity and versions`,children:(0,B.jsx)(W,{items:[[`Status`,(0,B.jsx)(xe,{kind:`host`,value:i.connectivity},`s`)],[`Last seen`,i.lastSeenAt?`${j(i.lastSeenAt)} (${O(i.lastSeenAt)})`:`Never`],[`Platform`,Ct[i.platform]],[`Agent version`,(0,B.jsx)(`span`,{className:`font-mono`,children:i.agentVersion},`a`)],[`Pi`,(0,B.jsx)(wt,{host:i},`p`)],[`Enrolled`,O(i.createdAt)]]})}),(0,B.jsx)(U,{title:`Capabilities`,description:`What Pi on this host supports. Unsupported features are hidden or explained in sessions.`,children:x?(0,B.jsxs)(`ul`,{className:`grid min-w-0 gap-2 sm:grid-cols-2`,children:[Me.map(e=>{let t=x[e],n=C(e);return(0,B.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[t?(0,B.jsx)(F,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-success`}):(0,B.jsx)(Ce,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,B.jsxs)(`span`,{className:`min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:pn[e]}),(0,B.jsxs)(`span`,{className:`text-muted`,children:[`: `,t?`Supported`:`Not supported`]}),!t&&n&&(0,B.jsx)(`span`,{className:`block break-words text-xs text-muted`,children:n})]})]},e)}),w.map(e=>(0,B.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[(0,B.jsx)(Ce,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,B.jsxs)(`span`,{className:`min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-medium break-words`,children:e.capability}),(0,B.jsx)(`span`,{className:`text-muted`,children:`: Not supported`}),(0,B.jsx)(`span`,{className:`block break-words text-xs text-muted`,children:e.reason})]})]},e.capability))]}):(0,B.jsx)(S,{capability:`Capability report`,reason:`This host has not reported its Pi capabilities yet. It may be offline, or Pi may be missing or incompatible.`})}),(0,B.jsx)(fn,{host:i}),(0,B.jsx)(U,{title:`Checkout mappings`,description:`Project clones on this host. Sessions and runs for a project use these paths.`,children:_.length===0?(0,B.jsx)(N,{className:`py-4`,title:`No checkouts on this host`,description:`Create a project or add a checkout to an existing project.`,action:{label:`Open projects`,to:V(`projects`)}}):(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:_.map(e=>(0,B.jsxs)(`li`,{className:`min-w-0 py-2 text-sm`,children:[(0,B.jsx)(r,{to:V(`projects/${encodeURIComponent(e.projectId)}`),className:`font-medium text-accent hover:underline`,children:c[e.projectId]?.name??`Unknown project`}),(0,B.jsx)(`div`,{className:`break-all font-mono text-xs`,children:e.path}),(0,B.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Default branch: `,e.defaultBranch]})]},e.id))})}),(0,B.jsx)(U,{title:`Adapters`,actions:(0,B.jsx)(r,{to:V(`adapters`),className:`text-sm font-medium text-accent`,children:`All adapters`}),children:!a||a.length===0?(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`No adapters reported by this host.`}):(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:a.map(e=>(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm`,children:[(0,B.jsx)(`span`,{className:`break-all font-mono`,children:e.id}),(0,B.jsx)(`span`,{className:`text-muted`,children:e.version}),(0,B.jsx)(zt,{status:e.status})]},e.id))})}),(0,B.jsx)(Ft,{open:u,onClose:()=>d(!1),title:`Revoke ${i.name}?`,confirmLabel:`Revoke host`,busy:f,error:m,onConfirm:b,children:(0,B.jsx)(`p`,{className:`text-sm`,children:`The host agent is disconnected and its credential stops working. Sessions on it are not moved or restarted elsewhere. To use this machine again, add it as a new host.`})})]})}var bn={granted:{icon:Ye,label:`Allowed`,tone:`success`,guidance:`This device can show Switchyard notifications.`},denied:{icon:qe,label:`Blocked`,tone:`danger`,guidance:`Notifications are blocked for this site. Allow them in your browser's site settings (or the system notification settings for the Home Screen app), then reload.`},default:{icon:ye,label:`Not requested yet`,tone:`neutral`,guidance:`Enable notifications to hear about sessions that need input, failed, or are ready for review.`},unknown:{icon:ye,label:`Unknown`,tone:`neutral`,guidance:`The browser did not report a permission state. Try enabling notifications.`},unsupported:{icon:Ce,label:`Not supported`,tone:`warning`,guidance:`This browser cannot receive web push here. On iPhone and iPad, add Switchyard to the Home Screen first.`}};function xn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{return`UTC`}}function Sn(e){let t=Q(e)&&Q(e.settings)?e.settings:e;return!Q(t)||typeof t.privatePreviews!=`boolean`?null:{quietHours:Q(t.quietHours)?t.quietHours:null,privatePreviews:t.privatePreviews,preferredDeviceId:typeof t.preferredDeviceId==`string`?t.preferredDeviceId:null}}function Cn(){let[e,t]=(0,z.useState)(()=>Re()),[n,r]=(0,z.useState)(null),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(null),c=Ve()&&!Ge();(0,z.useEffect)(()=>{let e=!0;Le().then(t=>e&&r(t!==null)).catch(()=>e&&r(!1));let n=()=>{document.visibilityState===`visible`&&t(Re())};return document.addEventListener(`visibilitychange`,n),()=>{e=!1,document.removeEventListener(`visibilitychange`,n)}},[]);let l=()=>{a(`enable`),s(null),Ue().then(e=>{t(e),e===`granted`?(r(!0),I.success(`Notifications enabled on this device`)):e===`denied`&&I.error(`Notifications were blocked. Allow them in your browser settings.`)}).catch(e=>{s(e),t(Re())}).finally(()=>a(null))},u=async()=>{a(`disable`),s(null);try{await He(),r(!1),I.success(`Notifications disabled on this device`)}catch(e){s(e)}finally{a(null)}},d=async()=>{a(`test`),s(null);try{await ze(),I.success(`Test notification sent. It can take a few seconds to arrive.`)}catch(e){s(e),I.error(`Test notification failed: ${b(e)}`)}finally{a(null)}},f=bn[e]??bn.unknown;return(0,B.jsxs)(H,{testId:`settings-notifications`,title:`Notifications`,description:`Push notifications for sessions that need input, failed, or are ready for review.`,children:[(0,B.jsx)(U,{title:`This device`,children:(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:`Permission:`}),(0,B.jsx)(q,{icon:f.icon,label:f.label,tone:f.tone}),n!==null&&e===`granted`&&(0,B.jsx)(`span`,{className:`text-muted`,children:n?`Subscribed to push`:`Not subscribed to push`})]}),(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:f.guidance}),c&&(0,B.jsxs)(`div`,{className:`rounded-md border border-border bg-surface-2 p-3 text-sm`,children:[(0,B.jsxs)(`p`,{className:`mb-2 flex items-center gap-2 font-medium`,children:[(0,B.jsx)(ht,{"aria-hidden":!0,className:`size-4 shrink-0`}),`On iPhone and iPad, notifications need the Home Screen app`]}),(0,B.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,B.jsx)(`li`,{children:`Tap Share`}),(0,B.jsx)(`li`,{children:`Add to Home Screen`}),(0,B.jsx)(`li`,{children:`Open Switchyard from the Home Screen`}),(0,B.jsx)(`li`,{children:`Enable notifications here`})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e!==`unsupported`&&!(e===`granted`&&n)&&(0,B.jsx)(D,{variant:`primary`,icon:(0,B.jsx)(Ye,{className:`size-4`}),busy:i===`enable`,disabled:i!==null&&i!==`enable`,onClick:l,children:`Enable notifications`}),n&&(0,B.jsx)(D,{icon:(0,B.jsx)(qe,{className:`size-4`}),busy:i===`disable`,disabled:i!==null&&i!==`disable`,onClick:u,children:`Disable on this device`}),(0,B.jsx)(D,{icon:(0,B.jsx)(ie,{className:`size-4`}),busy:i===`test`,disabled:i!==null&&i!==`test`,onClick:d,children:`Send test notification`})]}),e===`unsupported`&&(0,B.jsx)(`p`,{className:`text-xs text-muted`,children:`Enabling is not possible in this browser. A test notification still goes to your other subscribed devices.`}),(0,B.jsx)(Z,{error:o}),(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`Delivery and clearing are best effort: browsers and operating systems may delay, group or keep notifications even after you answer elsewhere.`})]})}),(0,B.jsx)(wn,{})]})}function wn(){let e=Lt(`/api/me/notification-settings`,e=>!!Sn(e)),t=(0,z.useMemo)(()=>e.data?Sn(e.data):null,[e.data]),n=e.error instanceof g&&e.error.status===404;return(0,B.jsx)(U,{title:`Delivery preferences`,description:`Shared by all your devices. Attention items in Switchyard are unaffected.`,children:n?(0,B.jsx)(S,{capability:`Notification settings`,reason:`This coordinator does not expose notification settings yet`}):e.fatal?(0,B.jsx)(M,{error:e.error}):e.error&&!t?(0,B.jsx)(k,{compact:!0,title:`Could not load notification settings`,error:e.error,onRetry:e.reload}):t?(0,B.jsx)(En,{settings:t,onSaved:t=>e.setData(t)}):(0,B.jsx)(A,{label:`Loading notification settings…`})})}var Tn=/^\d{2}:\d{2}$/;function En({settings:e,onSaved:t}){let n=(0,z.useId)(),r=h(e=>e.devices),i=(0,z.useMemo)(()=>Object.values(r).filter(e=>e.revokedAt===null).sort((e,t)=>e.name.localeCompare(t.name)),[r]),[a,o]=(0,z.useState)(e.quietHours!==null),[s,c]=(0,z.useState)(e.quietHours?.start??`22:00`),[l,u]=(0,z.useState)(e.quietHours?.end??`07:00`),[d,f]=(0,z.useState)(e.quietHours?.timezone??xn()),[p,g]=(0,z.useState)(e.privatePreviews),[_,v]=(0,z.useState)(e.preferredDeviceId??``),[y,b]=(0,z.useState)(!1),[x,S]=(0,z.useState)(null),C=a&&!Tn.test(s)?`Use a time like 22:00.`:null,w=a&&!Tn.test(l)?`Use a time like 07:00.`:null,T=a&&!d.trim()?`Enter a time zone, e.g. Europe/Berlin.`:null,E=!_||i.some(e=>e.id===_);return(0,B.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:async e=>{if(e.preventDefault(),C||w||T)return;let n={quietHours:a?{start:s,end:l,timezone:d.trim()}:null,privatePreviews:p,preferredDeviceId:_||null};b(!0),S(null);try{t(Sn(await m(`/api/me/notification-settings`,n))??n),I.success(`Notification preferences saved`)}catch(e){S(e)}finally{b(!1)}},noValidate:!0,children:[(0,B.jsx)(Tt,{label:`Quiet hours`,description:`No push notifications during these hours. Attention items still collect in Switchyard.`,checked:a,onChange:o}),a&&(0,B.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-3`,children:[(0,B.jsx)(J,{id:`${n}-start`,label:`From`,error:C,children:(0,B.jsx)(L,{id:`${n}-start`,type:`time`,value:s,onChange:e=>c(e.target.value),...Y(`${n}-start`,{error:C})})}),(0,B.jsx)(J,{id:`${n}-end`,label:`Until`,error:w,children:(0,B.jsx)(L,{id:`${n}-end`,type:`time`,value:l,onChange:e=>u(e.target.value),...Y(`${n}-end`,{error:w})})}),(0,B.jsx)(J,{id:`${n}-tz`,label:`Time zone`,error:T,children:(0,B.jsx)(L,{id:`${n}-tz`,value:d,onChange:e=>f(e.target.value),autoCapitalize:`off`,spellCheck:!1,...Y(`${n}-tz`,{error:T})})})]}),(0,B.jsx)(Tt,{label:`Private previews`,description:`Hide task and session text in notifications; show only the status, e.g. Needs input.`,checked:p,onChange:g}),(0,B.jsx)(J,{id:`${n}-device`,label:`Preferred device`,hint:`Receives push when no desktop was recently active.`,children:(0,B.jsxs)(X,{id:`${n}-device`,value:_,onChange:e=>v(e.target.value),...Y(`${n}-device`,{hint:!0}),children:[(0,B.jsx)(`option`,{value:``,children:`Automatic (the preferred mobile device)`}),i.map(e=>(0,B.jsxs)(`option`,{value:e.id,children:[e.name,e.push.subscribed?``:` (no push subscription)`]},e.id)),!E&&(0,B.jsxs)(`option`,{value:_,children:[`Unknown device (`,_,`)`]})]})}),(0,B.jsx)(Z,{error:x}),(0,B.jsx)(`div`,{children:(0,B.jsx)(D,{type:`submit`,variant:`primary`,busy:y,icon:(0,B.jsx)(fe,{className:`size-4`}),children:`Save preferences`})})]})}var Dn={ask:`Ask`,approve:`Approve`,ignore:`Ignore`},On={ask:`Ask before trusting project-local Pi settings and extensions.`,approve:`Trust project-local Pi settings and extensions automatically.`,ignore:`Never load project-local Pi settings or extensions.`},kn=je.options;function An(e){let t=[];return e.forEach((e,n)=>{let r=Ne.safeParse(e);r.success||t.push(`Line ${n+1} (${e}): ${r.error.issues[0]?.message??`invalid argument`}`)}),t}function jn(){let e=K(),t=h(e=>e.profiles),n=h(e=>e.projects),r=(0,z.useMemo)(()=>Object.values(t).sort((e,t)=>e.name.localeCompare(t.name)),[t]),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(null),[c,l]=(0,z.useState)(!1),[u,f]=(0,z.useState)(null),p=async()=>{if(o){l(!0),f(null);try{await d(`/api/profiles/${encodeURIComponent(o.id)}`),I.success(`Profile ${o.name} deleted`),s(null)}catch(e){f(e)}finally{l(!1)}}},m=e=>Object.values(n).filter(t=>t.defaultProfileId===e).map(e=>e.name);return(0,B.jsxs)(H,{title:`Pi profiles`,description:`Presets for provider, model, thinking level and Pi flags. Sessions keep a snapshot of the profile they started with.`,actions:(0,B.jsx)(D,{variant:`primary`,icon:(0,B.jsx)(P,{className:`size-4`}),onClick:()=>a(`new`),children:`New profile`}),children:[(0,B.jsx)(G,{}),e?r.length===0?(0,B.jsx)(N,{icon:(0,B.jsx)(oe,{className:`size-8`}),title:`No profiles`,description:`Create a profile to choose a provider and model for sessions.`,action:{label:`New profile`,onClick:()=>a(`new`)}}):(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:r.map(e=>{let t=m(e.id);return(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-3 border-b border-border px-4 py-3 last:border-b-0`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 text-sm`,children:[(0,B.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,B.jsxs)(`span`,{className:`break-words text-muted`,children:[e.provider??`Default provider`,` / `,e.model??`default model`,` · Thinking`,` `,e.thinking??`default`,` · Project trust `,Dn[e.projectTrust]]}),e.extraArgs.length>0&&(0,B.jsx)(`span`,{className:`break-all font-mono text-xs text-muted`,children:e.extraArgs.join(` `)}),t.length>0&&(0,B.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Default for `,t.join(`, `)]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(D,{size:`sm`,icon:(0,B.jsx)(ue,{className:`size-4`}),onClick:()=>a(e),children:`Edit`}),(0,B.jsx)(D,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,B.jsx)(pe,{className:`size-4`}),onClick:()=>{f(null),s(e)},children:`Delete`})]})]},e.id)})}):(0,B.jsx)(A,{label:`Loading profiles…`}),i&&(0,B.jsx)(Mn,{profile:i===`new`?null:i,onClose:()=>a(null)},i===`new`?`new`:i.id),(0,B.jsx)(Ft,{open:o!==null,onClose:()=>s(null),title:o?`Delete ${o.name}?`:`Delete profile`,confirmLabel:`Delete profile`,busy:c,error:u,onConfirm:p,children:(0,B.jsx)(`p`,{className:`text-sm`,children:`Existing sessions keep their snapshot of this profile. Projects that use it as their default must be changed first.`})})]})}function Mn({profile:e,onClose:t}){let n=(0,z.useId)(),[r,i]=(0,z.useState)(e?.name??``),[a,o]=(0,z.useState)(e?.provider??``),[s,c]=(0,z.useState)(e?.model??``),[l,u]=(0,z.useState)(e?.thinking??``),[d,f]=(0,z.useState)(e?.projectTrust??`ask`),[p,h]=(0,z.useState)((e?.extraArgs??[]).join(`
|
|
5
|
-
`)),[
|
|
6
|
-
`):null,
|
|
7
|
-
`)),[u,d]=(0,z.useState)(String(e.maxConcurrentRuns)),[f,p]=(0,z.useState)(e.automationEnabled),[h,g]=(0,z.useState)(e.workspaceSharing),[_,v]=(0,z.useState)(e.defaultProfileId??``),[y,b]=(0,z.useState)(e.defaultHostId??``),[x,S]=(0,z.useState)(e.worktreeDir??`.worktrees`),[C,w]=(0,z.useState)(!1),[T,E]=(0,z.useState)(null),O=Number(u),k=i.trim()?null:`Enter a project name.`,A=Number.isInteger(O)&&O>=1&&O<=32?null:`Use a whole number from 1 to 32.`,j=zn(x),M=async t=>{if(t.preventDefault(),!(k||A||j)){w(!0),E(null);try{await m(`/api/projects/${encodeURIComponent(e.id)}`,{name:i.trim(),setupCommand:o.trim()||null,checks:kt(c),maxConcurrentRuns:O,automationEnabled:f,workspaceSharing:h,defaultProfileId:_||null,defaultHostId:y||null,worktreeDir:x.trim()}),I.success(`Project settings saved`)}catch(e){E(e)}finally{w(!1)}}},N=!y||t.some(e=>e.id===y),ee=!_||n.some(e=>e.id===_);return(0,B.jsx)(U,{title:`Project settings`,children:(0,B.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:M,noValidate:!0,children:[(0,B.jsx)(J,{id:`${r}-name`,label:`Name`,error:k,children:(0,B.jsx)(L,{id:`${r}-name`,value:i,onChange:e=>a(e.target.value),...Y(`${r}-name`,{error:k})})}),(0,B.jsx)(J,{id:`${r}-setup`,label:`Setup command`,hint:`Runs in each new workspace before the first session, e.g. pnpm install. Leave empty for none.`,children:(0,B.jsx)(L,{id:`${r}-setup`,value:o,onChange:e=>s(e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,...Y(`${r}-setup`,{hint:!0})})}),(0,B.jsx)(J,{id:`${r}-checks`,label:`Checks`,hint:`One command per line. Runs must pass these before review.`,children:(0,B.jsx)(ke,{id:`${r}-checks`,value:c,minRows:3,onChange:e=>l(e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,...Y(`${r}-checks`,{hint:!0})})}),(0,B.jsx)(J,{id:`${r}-runs`,label:`Max concurrent runs`,hint:`Between 1 and 32.`,error:A,children:(0,B.jsx)(L,{id:`${r}-runs`,type:`number`,inputMode:`numeric`,min:1,max:32,step:1,value:u,onChange:e=>d(e.target.value),className:`max-w-32`,...Y(`${r}-runs`,{hint:!0,error:A})})}),(0,B.jsx)(J,{id:`${r}-worktree`,label:`Worktree folder`,hint:Rn,error:j,children:(0,B.jsx)(L,{id:`${r}-worktree`,"data-testid":`project-worktree-dir`,value:x,onChange:e=>S(e.target.value),placeholder:`.worktrees`,className:`font-mono`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,...Y(`${r}-worktree`,{hint:!0,error:j})})}),(0,B.jsx)(Tt,{label:`Automation`,description:`When off, ready tasks in this project wait instead of starting automatically.`,checked:f,onChange:p}),(0,B.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,B.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:`Workspace sharing`}),[[`single_writer`,`Single writer`,`Only one run or session writes in a workspace at a time; others wait. Safest.`],[`shared`,`Shared`,`Several sessions may write in the same workspace at once. Their changes can interleave.`]].map(([e,t,n])=>(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(`input`,{id:`${r}-sharing-${e}`,type:`radio`,name:`${r}-sharing`,value:e,checked:h===e,onChange:()=>g(e),"aria-describedby":`${r}-sharing-${e}-desc`,className:`tap mt-0.5 size-5 shrink-0 accent-[var(--sy-accent)]`}),(0,B.jsxs)(`label`,{htmlFor:`${r}-sharing-${e}`,className:`min-w-0 text-sm`,children:[(0,B.jsx)(`span`,{className:`block font-medium`,children:t}),(0,B.jsx)(`span`,{id:`${r}-sharing-${e}-desc`,className:`block text-muted`,children:n})]})]},e))]}),(0,B.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,B.jsx)(J,{id:`${r}-profile`,label:`Default Pi profile`,children:(0,B.jsxs)(X,{id:`${r}-profile`,value:_,onChange:e=>v(e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:`None (use the coordinator default)`}),n.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id)),!ee&&(0,B.jsxs)(`option`,{value:_,children:[`Unknown profile (`,_,`)`]})]})}),(0,B.jsx)(J,{id:`${r}-host`,label:`Default host`,hint:`Runs start here when the task does not choose a host.`,children:(0,B.jsxs)(X,{id:`${r}-host`,value:y,onChange:e=>b(e.target.value),...Y(`${r}-host`,{hint:!0}),children:[(0,B.jsx)(`option`,{value:``,children:`None (any host with a checkout)`}),t.map(e=>(0,B.jsxs)(`option`,{value:e.id,children:[e.name,e.connectivity===`connected`?``:` (${e.connectivity})`]},e.id)),!N&&(0,B.jsxs)(`option`,{value:y,children:[`Unknown host (`,y,`)`]})]})})]}),(0,B.jsx)(Z,{error:T}),(0,B.jsx)(`div`,{children:(0,B.jsx)(D,{type:`submit`,variant:`primary`,busy:C,icon:(0,B.jsx)(fe,{className:`size-4`}),children:`Save project`})})]})})}function Hn({project:e,hosts:t,hostsById:n}){let r=h(e=>e.checkouts),i=(0,z.useMemo)(()=>Object.values(r).filter(t=>t.projectId===e.id).sort((e,t)=>e.createdAt.localeCompare(t.createdAt)),[r,e.id]),[a,o]=(0,z.useState)(!1);return(0,B.jsxs)(U,{title:`Checkouts`,description:`Clones of this repository. Add one per host that should run this project.`,actions:(0,B.jsx)(D,{size:`sm`,icon:(0,B.jsx)(P,{className:`size-4`}),onClick:()=>o(!0),children:`Add checkout`}),children:[i.length===0?(0,B.jsx)(N,{className:`py-4`,title:`No checkouts`,description:`Add a checkout so sessions and runs have somewhere to work.`,action:{label:`Add checkout`,onClick:()=>o(!0)}}):(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:i.map(e=>{let t=n[e.hostId];return(0,B.jsxs)(`li`,{className:`min-w-0 py-2 text-sm`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:t?.name??`Unknown host`}),t&&t.connectivity!==`connected`&&(0,B.jsxs)(`span`,{className:`text-xs text-muted`,children:[`(`,t.connectivity,`)`]})]}),(0,B.jsx)(`div`,{className:`break-all font-mono text-xs`,children:e.path}),(0,B.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Default branch: `,e.defaultBranch]})]},e.id)})}),(0,B.jsx)(Un,{open:a,onClose:()=>o(!1),project:e,hosts:t})]})}function Un({open:e,onClose:t,project:n,hosts:r}){let i=(0,z.useId)(),a=r.filter(e=>e.connectivity===`connected`),[o,s]=(0,z.useState)(``),[c,l]=(0,z.useState)(``),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)(null),g=o||a[0]?.id||``,_=u||c?Dt(c):null,y=()=>{f||(d(!1),h(null),t())},b=async e=>{if(e.preventDefault(),d(!0),g&&!Dt(c)){p(!0),h(null);try{await v(`/api/projects/${encodeURIComponent(n.id)}/checkouts`,{hostId:g,path:c.trim()}),I.success(`Checkout added`),l(``),d(!1),t()}catch(e){h(e)}finally{p(!1)}}},x=`${i}-form`;return(0,B.jsx)(R,{open:e,onClose:y,dismissOnBackdrop:!f,title:`Add checkout`,description:`Another clone of ${n.repoIdentity}.`,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(D,{onClick:y,disabled:f,children:`Cancel`}),(0,B.jsx)(D,{type:`submit`,form:x,variant:`primary`,busy:f,disabled:a.length===0,children:`Add checkout`})]}),children:(0,B.jsxs)(`form`,{id:x,className:`flex min-w-0 flex-col gap-4`,onSubmit:b,noValidate:!0,children:[a.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`No host is connected. The checkout is inspected on its host, so the host must be online.`}),(0,B.jsx)(J,{id:`${i}-host`,label:`Host`,hint:`Only connected hosts are listed.`,children:(0,B.jsxs)(X,{id:`${i}-host`,value:g,onChange:e=>s(e.target.value),disabled:a.length===0,...Y(`${i}-host`,{hint:!0}),children:[a.length===0&&(0,B.jsx)(`option`,{value:``,children:`No connected hosts`}),a.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,B.jsx)(J,{id:`${i}-path`,label:`Checkout path on the host`,hint:`Absolute path of an existing clone of this repository.`,error:_,children:(0,B.jsx)(L,{id:`${i}-path`,value:c,onChange:e=>l(e.target.value),placeholder:`/Users/me/src/app`,className:`font-mono`,autoCapitalize:`off`,autoComplete:`off`,spellCheck:!1,...Y(`${i}-path`,{hint:!0,error:_})})}),(0,B.jsx)(Z,{error:m})]})})}var Wn=e=>V(`projects/${encodeURIComponent(e)}`);function Gn(){let e=K(),t=u(),n=h(e=>e.checkouts),i=h(e=>e.workspaces),a=(0,z.useMemo)(()=>{let e={},t=t=>(e[t]??={checkouts:0,workspaces:0},e[t]);for(let e of Object.values(n))t(e.projectId).checkouts++;for(let e of Object.values(i))e.archivedAt||t(e.projectId).workspaces++;return e},[n,i]);return(0,B.jsxs)(H,{testId:`settings-projects`,title:`Projects`,description:`A project is one repository. It can have checkouts on several hosts. Repositories in a host's project folders are added automatically.`,actions:(0,B.jsxs)(r,{to:V(`projects/new`),className:C(`primary`),children:[(0,B.jsx)(P,{"aria-hidden":!0,className:`size-4`}),`New project`]}),children:[(0,B.jsx)(G,{}),e?t.length===0?(0,B.jsx)(N,{icon:(0,B.jsx)(ae,{className:`size-8`}),title:`No projects yet`,description:`Create a project from a Git checkout on one of your hosts.`,action:{label:`New project`,to:V(`projects/new`)}}):(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:t.map(e=>(0,B.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,B.jsx)(Kn,{project:e,counts:a[e.id]})},e.id))}):(0,B.jsx)(A,{label:`Loading projects…`})]})}function Kn({project:e,counts:t}){let n=t??{checkouts:0,workspaces:0};return(0,B.jsxs)(r,{to:Wn(e.id),className:`tap flex min-w-0 items-center gap-3 px-4 py-3 hover:bg-surface-2`,children:[(0,B.jsx)(ae,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,B.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,B.jsx)(`span`,{className:`break-all text-xs text-muted`,children:e.repoIdentity}),(0,B.jsxs)(`span`,{className:`flex flex-wrap gap-x-3 text-xs text-muted`,children:[(0,B.jsxs)(`span`,{children:[n.checkouts,` checkout`,n.checkouts===1?``:`s`]}),(0,B.jsxs)(`span`,{children:[n.workspaces,` workspace`,n.workspaces===1?``:`s`]}),(0,B.jsxs)(`span`,{children:[`Automation `,e.automationEnabled?`on`:`off`]})]})]}),(0,B.jsx)(se,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})}function qn(){let e=K(),t=f(),i=h(e=>e.profiles),a=(0,z.useMemo)(()=>Object.values(i).sort((e,t)=>e.name.localeCompare(t.name)),[i]),o=t.filter(e=>e.connectivity===`connected`),s=n(),c=(0,z.useId)(),[l,u]=(0,z.useState)(``),[d,p]=(0,z.useState)(``),[m,g]=(0,z.useState)(``),[_,y]=(0,z.useState)(``),[b,x]=(0,z.useState)(`.worktrees`),[C,w]=(0,z.useState)(!1),[T,E]=(0,z.useState)(!1),[O,k]=(0,z.useState)(null),j=d||o[0]?.id||``,M=C&&!l.trim()?`Enter a project name.`:null,N=C&&!j?`Choose a connected host.`:null,ee=C||m?Dt(m):null,te=zn(b),ne=async e=>{if(e.preventDefault(),w(!0),l.trim()&&j&&!Dt(m)&&!te){E(!0),k(null);try{let e=await v(`/api/projects`,{name:l.trim(),hostId:j,path:m.trim(),defaultProfileId:_||null,worktreeDir:b.trim()});I.success(`Project ${l.trim()} created`),s(e?.id?Wn(e.id):V(`projects`))}catch(e){k(e)}finally{E(!1)}}},re={to:V(`projects`),label:`Projects`};return e?(0,B.jsxs)(H,{title:`New project`,description:`Switchyard inspects the checkout on the host, then discovers its worktrees.`,back:re,children:[o.length===0&&(0,B.jsx)(S,{capability:`Creating a project`,reason:t.length===0?`No hosts are enrolled. Add a host first.`:`No host is connected. The checkout is inspected on its host, so the host must be online.`,fallback:(0,B.jsx)(r,{to:V(`hosts`),className:`font-medium text-accent`,children:`Open hosts`})}),(0,B.jsx)(U,{children:(0,B.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:ne,noValidate:!0,children:[(0,B.jsx)(J,{id:`${c}-name`,label:`Name`,error:M,children:(0,B.jsx)(L,{id:`${c}-name`,value:l,onChange:e=>u(e.target.value),autoComplete:`off`,...Y(`${c}-name`,{error:M})})}),(0,B.jsx)(J,{id:`${c}-host`,label:`Host`,hint:`Only connected hosts are listed.`,error:N,children:(0,B.jsxs)(X,{id:`${c}-host`,value:j,onChange:e=>p(e.target.value),disabled:o.length===0,...Y(`${c}-host`,{hint:!0,error:N}),children:[o.length===0&&(0,B.jsx)(`option`,{value:``,children:`No connected hosts`}),o.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,B.jsx)(J,{id:`${c}-path`,label:`Checkout path on the host`,hint:`Absolute path of an existing Git checkout, e.g. /Users/me/src/app.`,error:ee,children:(0,B.jsx)(L,{id:`${c}-path`,value:m,onChange:e=>g(e.target.value),placeholder:`/Users/me/src/app`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,className:`font-mono`,...Y(`${c}-path`,{hint:!0,error:ee})})}),(0,B.jsx)(J,{id:`${c}-worktree`,label:`Worktree folder`,hint:Rn,error:te,children:(0,B.jsx)(L,{id:`${c}-worktree`,value:b,onChange:e=>x(e.target.value),placeholder:`.worktrees`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,className:`font-mono`,...Y(`${c}-worktree`,{hint:!0,error:te})})}),(0,B.jsx)(J,{id:`${c}-profile`,label:`Default Pi profile (optional)`,children:(0,B.jsxs)(X,{id:`${c}-profile`,value:_,onChange:e=>y(e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:`None`}),a.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,B.jsx)(Z,{error:O}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(D,{type:`submit`,variant:`primary`,busy:T,icon:(0,B.jsx)($e,{className:`size-4`}),disabled:o.length===0,children:`Create project`}),o.length===0&&(0,B.jsx)(q,{icon:$e,label:`Needs a connected host`})]})]})})]}):(0,B.jsx)(H,{title:`New project`,back:re,children:(0,B.jsx)(A,{})})}function Jn(){let e=Lt(`/api/auth/methods`,Ot),[t,n]=(0,z.useState)(!1),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(!1),[f,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)(null),g=async()=>{if(r){o(!0),c(null);try{await d(`/api/auth/passkeys/${encodeURIComponent(r.id)}`),I.success(`Passkey ${r.name} removed`),i(null),e.reload()}catch(e){c(e)}finally{o(!1)}}},_=async()=>{p(!0),h(null);try{await v(`/api/logout`),u(!1),he(null)}catch(e){h(e)}finally{p(!1)}},y=e.data,b=y?.passkeyAvailability,x=Ie(),S=y?b?.available?x?null:`This browser does not support passkeys.`:b?.reason??`Passkeys are not available on this server.`:null;return(0,B.jsxs)(H,{testId:`settings-signin`,title:`Sign-in`,description:`How you sign in to Switchyard on new devices. Each signed-in device keeps its own revocable credential.`,children:[(0,B.jsx)(G,{}),e.loading&&!y?(0,B.jsx)(A,{label:`Loading sign-in methods…`}):e.error&&!y?(0,B.jsx)(k,{title:`Could not load sign-in methods`,error:e.error,onRetry:e.reload}):y?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(U,{title:`Passkeys`,description:`Sign in on any device with its fingerprint, face or screen lock. Passkeys are stored on this server only as public keys.`,actions:(0,B.jsx)(D,{"data-testid":`passkey-add`,variant:`primary`,icon:(0,B.jsx)(P,{className:`size-4`}),disabled:S!==null,onClick:()=>n(!0),children:`Add a passkey`}),children:[S&&(0,B.jsxs)(`p`,{role:`status`,className:`mb-3 flex items-start gap-2 rounded-md bg-warning-soft px-3 py-2 text-sm`,children:[(0,B.jsx)(w,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0`}),(0,B.jsxs)(`span`,{className:`min-w-0 break-words`,children:[`Adding a passkey is unavailable: `,S]})]}),y.passkeys.length===0?(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`No passkeys yet. Add one so your other devices can sign in without a link.`}):(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border`,children:y.passkeys.map(e=>(0,B.jsxs)(`li`,{"data-testid":`passkey-row`,className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-border px-3 py-2 last:border-b-0`,children:[(0,B.jsx)(de,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`break-words font-medium`,children:e.name}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 text-sm text-muted`,children:[(0,B.jsxs)(`span`,{children:[`Added `,j(e.createdAt)]}),(0,B.jsxs)(`span`,{children:[`Last used `,j(e.lastUsedAt)]})]})]}),(0,B.jsx)(D,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,B.jsx)(pe,{className:`size-4`}),"aria-label":`Remove passkey ${e.name}`,onClick:()=>{c(null),i(e)},children:`Remove`})]},e.id))})]}),(0,B.jsx)(U,{title:`Single sign-on`,description:`Configured on the server`,children:y.oidc?(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsx)(W,{items:[[`Button label`,y.oidc.label],[`Provider`,(0,B.jsx)(`span`,{className:`break-all`,children:y.oidc.issuer},`i`)],[`Allowed account`,y.oidc.ownerMatch],[`Status`,y.oidc.status===`ready`?(0,B.jsx)(q,{icon:F,tone:`success`,label:`Ready`},`s`):(0,B.jsx)(q,{icon:w,tone:`danger`,label:`Error`},`s`)]]}),y.oidc.status===`error`&&y.oidc.error&&(0,B.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-danger`,children:y.oidc.error})]}):(0,B.jsxs)(`p`,{"data-testid":`signin-oidc-status`,className:`text-sm text-muted`,children:[`Not configured. Set the `,(0,B.jsx)(`code`,{children:`SWITCHYARD_OIDC_*`}),` variables on the server to sign in with an identity provider.`]})})]}):null,(0,B.jsx)(U,{title:`This device`,description:`Signing out removes this device's credential here. Other devices stay signed in; revoke a device in Settings › Devices to cut it off.`,children:(0,B.jsx)(D,{icon:(0,B.jsx)(st,{className:`size-4`}),onClick:()=>{h(null),u(!0)},children:`Sign out of this device`})}),(0,B.jsx)(Yn,{open:t,onClose:()=>n(!1),onAdded:()=>{n(!1),e.reload()}}),(0,B.jsx)(Ft,{open:r!==null,onClose:()=>i(null),title:r?`Remove passkey ${r.name}?`:`Remove passkey`,confirmLabel:`Remove passkey`,busy:a,error:s,onConfirm:g,children:(0,B.jsxs)(`p`,{className:`text-sm`,children:[`Devices already signed in stay signed in. This passkey can no longer sign in new devices.`,y&&y.passkeys.length===1&&!y.oidc?` It is your only passkey and no single sign-on is set up: afterwards new devices need a pairing link.`:``]})}),(0,B.jsx)(Ft,{open:l,onClose:()=>u(!1),title:`Sign out of this device?`,confirmLabel:`Sign out`,busy:f,error:m,onConfirm:_,children:(0,B.jsx)(`p`,{className:`text-sm`,children:`You will need a passkey, single sign-on or a pairing link to sign in here again.`})})]})}function Yn({open:e,onClose:t,onAdded:n}){let r=(0,z.useId)(),[i,a]=(0,z.useState)(()=>We()),[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(null),u=i.trim()?null:`Enter a name for this passkey.`,d=()=>{o||(l(null),t())},f=async e=>{if(e.preventDefault(),!u){s(!0),l(null);try{let{challengeId:e,options:t}=await v(`/api/auth/passkeys/register/options`),r=await Be({optionsJSON:t});await v(`/api/auth/passkeys/register/verify`,{challengeId:e,name:i.trim().slice(0,80),response:r}),I.success(`Passkey added`),n()}catch(e){l(e instanceof Error&&e.name===`NotAllowedError`?Error(`The passkey prompt was cancelled or timed out. Try again.`):e instanceof Error?e:Error(b(e)))}finally{s(!1)}}},p=`${r}-form`;return(0,B.jsx)(R,{open:e,onClose:d,dismissOnBackdrop:!o,title:`Add a passkey`,description:`Name it after where it is stored, then confirm with your device.`,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(D,{onClick:d,disabled:o,children:`Cancel`}),(0,B.jsx)(D,{type:`submit`,form:p,variant:`primary`,busy:o,children:`Create passkey`})]}),children:(0,B.jsxs)(`form`,{id:p,className:`flex min-w-0 flex-col gap-4`,onSubmit:f,noValidate:!0,children:[(0,B.jsx)(J,{id:`${r}-name`,label:`Passkey name`,error:u,children:(0,B.jsx)(L,{id:`${r}-name`,value:i,maxLength:80,autoComplete:`off`,onChange:e=>a(e.target.value),...Y(`${r}-name`,{error:u})})}),(0,B.jsx)(Z,{error:c})]})})}function Xn(){let e=Te(),n=e===`mobile`,r=(0,B.jsxs)(i,{children:[(0,B.jsx)(t,{index:!0,element:n?(0,B.jsx)(tr,{}):(0,B.jsx)(er,{})}),(0,B.jsx)(t,{path:`hosts`,element:(0,B.jsx)(mn,{})}),(0,B.jsx)(t,{path:`hosts/:hostId`,element:(0,B.jsx)(yn,{})}),(0,B.jsx)(t,{path:`devices`,element:(0,B.jsx)(on,{})}),(0,B.jsx)(t,{path:`sign-in`,element:(0,B.jsx)(Jn,{})}),(0,B.jsx)(t,{path:`projects`,element:(0,B.jsx)(Gn,{})}),(0,B.jsx)(t,{path:`projects/new`,element:(0,B.jsx)(qn,{})}),(0,B.jsx)(t,{path:`projects/:projectId`,element:(0,B.jsx)(Bn,{})}),(0,B.jsx)(t,{path:`profiles`,element:(0,B.jsx)(jn,{})}),(0,B.jsx)(t,{path:`adapters`,element:(0,B.jsx)(Wt,{})}),(0,B.jsx)(t,{path:`notifications`,element:(0,B.jsx)(Cn,{})}),(0,B.jsx)(t,{path:`backups`,element:(0,B.jsx)(Qt,{})}),(0,B.jsx)(t,{path:`diagnostics`,element:(0,B.jsx)(ln,{})}),(0,B.jsx)(t,{path:`device`,element:(0,B.jsx)(cn,{})}),(0,B.jsx)(t,{path:`*`,element:(0,B.jsx)(nr,{})})]});return n?(0,B.jsx)(`div`,{className:`min-w-0`,children:r}):(0,B.jsxs)(`div`,{className:`flex min-h-full min-w-0`,children:[(0,B.jsx)(Qn,{compact:e===`compact`}),(0,B.jsx)(`div`,{className:`min-w-0 flex-1`,children:r})]})}function Zn(){let{pathname:e}=l(),t=e.split(`/`),n=t.indexOf(`settings`);return n>=0&&(t[n+1]??null)||null}function Qn({compact:e}){let t=Zn();return(0,B.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-testid":`settings-nav`,className:T(`sticky top-0 flex max-h-dvh shrink-0 flex-col gap-1 self-start overflow-y-auto border-r border-border px-2 py-4`,e?`w-52`:`w-60`),children:[(0,B.jsx)(r,{to:V(),"aria-current":t===null?`page`:void 0,className:T(`tap mb-2 rounded-md px-3 py-1 text-base font-semibold`,t===null?`bg-accent-soft`:`hover:bg-surface-2`),children:`Settings`}),(0,B.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:St.map(({path:e,label:n,icon:i})=>{let a=t===e;return(0,B.jsx)(`li`,{children:(0,B.jsxs)(r,{to:V(e),"aria-current":a?`page`:void 0,className:T(`tap flex h-10 items-center gap-3 rounded-md px-3 text-sm font-medium`,a?`bg-accent-soft text-text`:`text-muted hover:bg-surface-2 hover:text-text`),children:[(0,B.jsx)(i,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,B.jsx)(`span`,{className:`min-w-0 truncate`,children:n})]})},e)})})]})}function $n(){let e=h(e=>e.hosts),t=h(e=>e.devices),n=h(e=>e.projects),r=h(e=>e.profiles),i=h(e=>e.adapters),a=h(e=>e.hydrated);return(0,z.useMemo)(()=>{if(!a)return{};let o=Object.values(e).filter(e=>e.revokedAt===null),s=o.filter(e=>e.connectivity===`connected`).length,c=Object.values(i).reduce((e,t)=>e+t.length,0),l=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return{hosts:`${l(o.length,`host`)}, ${s} connected`,devices:l(Object.values(t).filter(e=>e.revokedAt===null).length,`device`),projects:l(Object.keys(n).length,`project`),profiles:l(Object.keys(r).length,`profile`),adapters:l(c,`adapter`)}},[e,t,n,r,i,a])}function er(){let e=$n();return(0,B.jsxs)(H,{title:`Settings`,description:`Configure Switchyard and check its health.`,children:[(0,B.jsx)(G,{}),(0,B.jsx)(`ul`,{className:`grid min-w-0 gap-3 lg:grid-cols-2`,children:St.map(({path:t,label:n,description:i,icon:a})=>(0,B.jsx)(`li`,{className:`min-w-0`,children:(0,B.jsxs)(r,{to:V(t),className:`tap flex h-full min-w-0 items-start gap-3 rounded-lg border border-border bg-surface p-4 hover:bg-surface-2`,children:[(0,B.jsx)(a,{"aria-hidden":!0,className:`mt-0.5 size-5 shrink-0 text-muted`}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`span`,{className:`block font-medium`,children:n}),(0,B.jsx)(`span`,{className:`block text-sm text-muted`,children:i}),e[t]&&(0,B.jsx)(`span`,{className:`mt-1 block text-xs text-subtle`,children:e[t]})]}),(0,B.jsx)(se,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-subtle`})]})},t))})]})}function tr(){let e=$n();return(0,B.jsxs)(`div`,{className:`mx-auto flex w-full min-w-0 max-w-xl flex-col gap-3 px-4 py-4`,children:[(0,B.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Settings`}),(0,B.jsx)(G,{}),(0,B.jsx)(`nav`,{"aria-label":`Settings sections`,"data-testid":`settings-nav`,children:(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:St.map(({path:t,label:n,description:i,icon:a})=>(0,B.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,B.jsxs)(r,{to:V(t),className:`tap flex min-h-14 items-center gap-3 px-4 py-2 hover:bg-surface-2`,children:[(0,B.jsx)(a,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`span`,{className:`block font-medium`,children:n}),(0,B.jsx)(`span`,{className:`block truncate text-sm text-muted`,children:e[t]??i})]}),(0,B.jsx)(se,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})},t))})})]})}function nr(){return(0,B.jsx)(N,{title:`Settings page not found`,description:`This link does not match a settings section.`,action:{label:`Open Settings`,to:V()}})}export{Xn as default};
|
|
8
|
-
//# sourceMappingURL=settings-
|
|
4
|
+
`)}function vn({open:e,onClose:t}){let[n,r]=(0,z.useState)(null),[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(null),c=async()=>{a(!0),s(null);try{r(await $t(`host`))}catch(e){s(e)}finally{a(!1)}},l=()=>{r(null),s(null),t()};return(0,B.jsx)(R,{open:e,onClose:l,title:`Add host`,description:`Enroll a machine that runs Pi. Provider credentials stay on that machine.`,footer:(0,B.jsx)(D,{onClick:l,children:`Done`}),children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!n&&!i&&!o&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`text-sm`,children:`Create a single-use enrollment, then run the command it shows on the new host. The host appears here once its agent connects.`}),(0,B.jsx)(D,{variant:`primary`,onClick:c,children:`Create enrollment command`})]}),(0,B.jsx)(tn,{busy:i,error:o,onRetry:c}),n&&!i&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`text-sm`,children:`Run this on the host, as the user that should run Pi (it needs Node 24 or newer, git and Pi):`}),(0,B.jsx)(Mt,{text:n.command?_n(n.command):n.url,label:n.command?`Host setup commands`:`Host enrollment link`,copyLabel:`Copy commands`}),(0,B.jsx)(en,{expiresAt:n.expiresAt,onRenew:c,busy:i})]})]})})}function yn(){let{hostId:e=``}=s(),t=K(),i=h(t=>t.hosts[e]),a=h(t=>t.adapters[e]),o=h(e=>e.checkouts),c=h(e=>e.projects),l=n(),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(!1),[m,g]=(0,z.useState)(null),_=(0,z.useMemo)(()=>Object.values(o).filter(t=>t.hostId===e).sort((e,t)=>e.path.localeCompare(t.path)),[o,e]),y={to:V(`hosts`),label:`Hosts`};if(!t)return(0,B.jsx)(H,{title:`Host`,back:y,children:(0,B.jsx)(A,{label:`Loading host…`})});if(!i||i.revokedAt)return(0,B.jsx)(H,{title:`Host`,back:y,children:(0,B.jsx)(N,{icon:(0,B.jsx)(ne,{className:`size-8`}),title:i?`This host was revoked`:`Host not found`,description:i?`${i.name} was revoked ${j(i.revokedAt)}. Add it again to use it.`:`It may have been revoked or never enrolled with this coordinator.`,action:{label:`Back to hosts`,to:V(`hosts`)}})});let b=async()=>{p(!0),g(null);try{await v(`/api/hosts/${encodeURIComponent(i.id)}/revoke`),I.success(`Host ${i.name} revoked`),d(!1),l(V(`hosts`))}catch(e){g(e)}finally{p(!1)}},x=i.capabilities,C=e=>x?.unsupported.find(t=>t.capability===e)?.reason,w=x?.unsupported.filter(e=>!Me.includes(e.capability))??[];return(0,B.jsxs)(H,{title:i.name,description:`${Ct[i.platform]} host`,back:y,actions:(0,B.jsx)(D,{variant:`danger`,icon:(0,B.jsx)(pt,{className:`size-4`}),onClick:()=>{g(null),d(!0)},children:`Revoke host`}),children:[(0,B.jsx)(G,{}),i.connectivity!==`connected`&&(0,B.jsx)(E,{compact:!0,hostName:i.name,connectivity:i.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:i.lastSeenAt}),(0,B.jsx)(U,{title:`Connectivity and versions`,children:(0,B.jsx)(W,{items:[[`Status`,(0,B.jsx)(xe,{kind:`host`,value:i.connectivity},`s`)],[`Last seen`,i.lastSeenAt?`${j(i.lastSeenAt)} (${O(i.lastSeenAt)})`:`Never`],[`Platform`,Ct[i.platform]],[`Agent version`,(0,B.jsx)(`span`,{className:`font-mono`,children:i.agentVersion},`a`)],[`Pi`,(0,B.jsx)(wt,{host:i},`p`)],[`Enrolled`,O(i.createdAt)]]})}),(0,B.jsx)(U,{title:`Capabilities`,description:`What Pi on this host supports. Unsupported features are hidden or explained in sessions.`,children:x?(0,B.jsxs)(`ul`,{className:`grid min-w-0 gap-2 sm:grid-cols-2`,children:[Me.map(e=>{let t=x[e],n=C(e);return(0,B.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[t?(0,B.jsx)(F,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-success`}):(0,B.jsx)(Ce,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,B.jsxs)(`span`,{className:`min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:pn[e]}),(0,B.jsxs)(`span`,{className:`text-muted`,children:[`: `,t?`Supported`:`Not supported`]}),!t&&n&&(0,B.jsx)(`span`,{className:`block break-words text-xs text-muted`,children:n})]})]},e)}),w.map(e=>(0,B.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[(0,B.jsx)(Ce,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,B.jsxs)(`span`,{className:`min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-medium break-words`,children:e.capability}),(0,B.jsx)(`span`,{className:`text-muted`,children:`: Not supported`}),(0,B.jsx)(`span`,{className:`block break-words text-xs text-muted`,children:e.reason})]})]},e.capability))]}):(0,B.jsx)(S,{capability:`Capability report`,reason:`This host has not reported its Pi capabilities yet. It may be offline, or Pi may be missing or incompatible.`})}),(0,B.jsx)(fn,{host:i}),(0,B.jsx)(U,{title:`Checkout mappings`,description:`Project clones on this host. Sessions and runs for a project use these paths.`,children:_.length===0?(0,B.jsx)(N,{className:`py-4`,title:`No checkouts on this host`,description:`Create a project or add a checkout to an existing project.`,action:{label:`Open projects`,to:V(`projects`)}}):(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:_.map(e=>(0,B.jsxs)(`li`,{className:`min-w-0 py-2 text-sm`,children:[(0,B.jsx)(r,{to:V(`projects/${encodeURIComponent(e.projectId)}`),className:`font-medium text-accent hover:underline`,children:c[e.projectId]?.name??`Unknown project`}),(0,B.jsx)(`div`,{className:`break-all font-mono text-xs`,children:e.path}),(0,B.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Default branch: `,e.defaultBranch]})]},e.id))})}),(0,B.jsx)(U,{title:`Adapters`,actions:(0,B.jsx)(r,{to:V(`adapters`),className:`text-sm font-medium text-accent`,children:`All adapters`}),children:!a||a.length===0?(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`No adapters reported by this host.`}):(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:a.map(e=>(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm`,children:[(0,B.jsx)(`span`,{className:`break-all font-mono`,children:e.id}),(0,B.jsx)(`span`,{className:`text-muted`,children:e.version}),(0,B.jsx)(zt,{status:e.status})]},e.id))})}),(0,B.jsx)(Ft,{open:u,onClose:()=>d(!1),title:`Revoke ${i.name}?`,confirmLabel:`Revoke host`,busy:f,error:m,onConfirm:b,children:(0,B.jsx)(`p`,{className:`text-sm`,children:`The host agent is disconnected and its credential stops working. Sessions on it are not moved or restarted elsewhere. To use this machine again, add it as a new host.`})})]})}var bn={granted:{icon:Ye,label:`Allowed`,tone:`success`,guidance:`This device can show Switchyard notifications.`},denied:{icon:qe,label:`Blocked`,tone:`danger`,guidance:`Notifications are blocked for this site. Allow them in your browser's site settings (or the system notification settings for the Home Screen app), then reload.`},default:{icon:ye,label:`Not requested yet`,tone:`neutral`,guidance:`Enable notifications to hear about sessions that need input, failed, or are ready for review.`},unknown:{icon:ye,label:`Unknown`,tone:`neutral`,guidance:`The browser did not report a permission state. Try enabling notifications.`},unsupported:{icon:Ce,label:`Not supported`,tone:`warning`,guidance:`This browser cannot receive web push here. On iPhone and iPad, add Switchyard to the Home Screen first.`}};function xn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{return`UTC`}}function Sn(e){let t=Q(e)&&Q(e.settings)?e.settings:e;return!Q(t)||typeof t.privatePreviews!=`boolean`?null:{quietHours:Q(t.quietHours)?t.quietHours:null,privatePreviews:t.privatePreviews,preferredDeviceId:typeof t.preferredDeviceId==`string`?t.preferredDeviceId:null}}function Cn(){let[e,t]=(0,z.useState)(()=>Re()),[n,r]=(0,z.useState)(null),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(null),c=Ve()&&!Ge();(0,z.useEffect)(()=>{let e=!0;Le().then(t=>e&&r(t!==null)).catch(()=>e&&r(!1));let n=()=>{document.visibilityState===`visible`&&t(Re())};return document.addEventListener(`visibilitychange`,n),()=>{e=!1,document.removeEventListener(`visibilitychange`,n)}},[]);let l=()=>{a(`enable`),s(null),Ue().then(e=>{t(e),e===`granted`?(r(!0),I.success(`Notifications enabled on this device`)):e===`denied`&&I.error(`Notifications were blocked. Allow them in your browser settings.`)}).catch(e=>{s(e),t(Re())}).finally(()=>a(null))},u=async()=>{a(`disable`),s(null);try{await He(),r(!1),I.success(`Notifications disabled on this device`)}catch(e){s(e)}finally{a(null)}},d=async()=>{a(`test`),s(null);try{await ze(),I.success(`Test notification sent. It can take a few seconds to arrive.`)}catch(e){s(e),I.error(`Test notification failed: ${b(e)}`)}finally{a(null)}},f=bn[e]??bn.unknown;return(0,B.jsxs)(H,{testId:`settings-notifications`,title:`Notifications`,description:`Push notifications for sessions that need input, failed, or are ready for review.`,children:[(0,B.jsx)(U,{title:`This device`,children:(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:`Permission:`}),(0,B.jsx)(q,{icon:f.icon,label:f.label,tone:f.tone}),n!==null&&e===`granted`&&(0,B.jsx)(`span`,{className:`text-muted`,children:n?`Subscribed to push`:`Not subscribed to push`})]}),(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:f.guidance}),c&&(0,B.jsxs)(`div`,{className:`rounded-md border border-border bg-surface-2 p-3 text-sm`,children:[(0,B.jsxs)(`p`,{className:`mb-2 flex items-center gap-2 font-medium`,children:[(0,B.jsx)(ht,{"aria-hidden":!0,className:`size-4 shrink-0`}),`On iPhone and iPad, notifications need the Home Screen app`]}),(0,B.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,B.jsx)(`li`,{children:`Tap Share`}),(0,B.jsx)(`li`,{children:`Add to Home Screen`}),(0,B.jsx)(`li`,{children:`Open Switchyard from the Home Screen`}),(0,B.jsx)(`li`,{children:`Enable notifications here`})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e!==`unsupported`&&!(e===`granted`&&n)&&(0,B.jsx)(D,{variant:`primary`,icon:(0,B.jsx)(Ye,{className:`size-4`}),busy:i===`enable`,disabled:i!==null&&i!==`enable`,onClick:l,children:`Enable notifications`}),n&&(0,B.jsx)(D,{icon:(0,B.jsx)(qe,{className:`size-4`}),busy:i===`disable`,disabled:i!==null&&i!==`disable`,onClick:u,children:`Disable on this device`}),(0,B.jsx)(D,{icon:(0,B.jsx)(ie,{className:`size-4`}),busy:i===`test`,disabled:i!==null&&i!==`test`,onClick:d,children:`Send test notification`})]}),e===`unsupported`&&(0,B.jsx)(`p`,{className:`text-xs text-muted`,children:`Enabling is not possible in this browser. A test notification still goes to your other subscribed devices.`}),(0,B.jsx)(Z,{error:o}),(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`Delivery and clearing are best effort: browsers and operating systems may delay, group or keep notifications even after you answer elsewhere.`})]})}),(0,B.jsx)(wn,{})]})}function wn(){let e=Lt(`/api/me/notification-settings`,e=>!!Sn(e)),t=(0,z.useMemo)(()=>e.data?Sn(e.data):null,[e.data]),n=e.error instanceof g&&e.error.status===404;return(0,B.jsx)(U,{title:`Delivery preferences`,description:`Shared by all your devices. Attention items in Switchyard are unaffected.`,children:n?(0,B.jsx)(S,{capability:`Notification settings`,reason:`This coordinator does not expose notification settings yet`}):e.fatal?(0,B.jsx)(M,{error:e.error}):e.error&&!t?(0,B.jsx)(k,{compact:!0,title:`Could not load notification settings`,error:e.error,onRetry:e.reload}):t?(0,B.jsx)(En,{settings:t,onSaved:t=>e.setData(t)}):(0,B.jsx)(A,{label:`Loading notification settings…`})})}var Tn=/^\d{2}:\d{2}$/;function En({settings:e,onSaved:t}){let n=(0,z.useId)(),r=h(e=>e.devices),i=(0,z.useMemo)(()=>Object.values(r).filter(e=>e.revokedAt===null).sort((e,t)=>e.name.localeCompare(t.name)),[r]),[a,o]=(0,z.useState)(e.quietHours!==null),[s,c]=(0,z.useState)(e.quietHours?.start??`22:00`),[l,u]=(0,z.useState)(e.quietHours?.end??`07:00`),[d,f]=(0,z.useState)(e.quietHours?.timezone??xn()),[p,g]=(0,z.useState)(e.privatePreviews),[_,v]=(0,z.useState)(e.preferredDeviceId??``),[y,b]=(0,z.useState)(!1),[x,S]=(0,z.useState)(null),C=a&&!Tn.test(s)?`Use a time like 22:00.`:null,w=a&&!Tn.test(l)?`Use a time like 07:00.`:null,T=a&&!d.trim()?`Enter a time zone, e.g. Europe/Berlin.`:null,E=!_||i.some(e=>e.id===_);return(0,B.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:async e=>{if(e.preventDefault(),C||w||T)return;let n={quietHours:a?{start:s,end:l,timezone:d.trim()}:null,privatePreviews:p,preferredDeviceId:_||null};b(!0),S(null);try{t(Sn(await m(`/api/me/notification-settings`,n))??n),I.success(`Notification preferences saved`)}catch(e){S(e)}finally{b(!1)}},noValidate:!0,children:[(0,B.jsx)(Tt,{label:`Quiet hours`,description:`No push notifications during these hours. Attention items still collect in Switchyard.`,checked:a,onChange:o}),a&&(0,B.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-3`,children:[(0,B.jsx)(J,{id:`${n}-start`,label:`From`,error:C,children:(0,B.jsx)(L,{id:`${n}-start`,type:`time`,value:s,onChange:e=>c(e.target.value),...Y(`${n}-start`,{error:C})})}),(0,B.jsx)(J,{id:`${n}-end`,label:`Until`,error:w,children:(0,B.jsx)(L,{id:`${n}-end`,type:`time`,value:l,onChange:e=>u(e.target.value),...Y(`${n}-end`,{error:w})})}),(0,B.jsx)(J,{id:`${n}-tz`,label:`Time zone`,error:T,children:(0,B.jsx)(L,{id:`${n}-tz`,value:d,onChange:e=>f(e.target.value),autoCapitalize:`off`,spellCheck:!1,...Y(`${n}-tz`,{error:T})})})]}),(0,B.jsx)(Tt,{label:`Private previews`,description:`Hide task and session text in notifications; show only the status, e.g. Needs input.`,checked:p,onChange:g}),(0,B.jsx)(J,{id:`${n}-device`,label:`Preferred device`,hint:`Receives push when no desktop was recently active.`,children:(0,B.jsxs)(X,{id:`${n}-device`,value:_,onChange:e=>v(e.target.value),...Y(`${n}-device`,{hint:!0}),children:[(0,B.jsx)(`option`,{value:``,children:`Automatic (the preferred mobile device)`}),i.map(e=>(0,B.jsxs)(`option`,{value:e.id,children:[e.name,e.push.subscribed?``:` (no push subscription)`]},e.id)),!E&&(0,B.jsxs)(`option`,{value:_,children:[`Unknown device (`,_,`)`]})]})}),(0,B.jsx)(Z,{error:x}),(0,B.jsx)(`div`,{children:(0,B.jsx)(D,{type:`submit`,variant:`primary`,busy:y,icon:(0,B.jsx)(fe,{className:`size-4`}),children:`Save preferences`})})]})}var Dn={ask:`Ask`,approve:`Approve`,ignore:`Ignore`},On={ask:`Ask before trusting project-local Pi settings and extensions.`,approve:`Trust project-local Pi settings and extensions automatically.`,ignore:`Never load project-local Pi settings or extensions.`},kn=je.options,An={all:`Loads your extensions, skills and prompt templates.`,vanilla:`Starts Pi with --no-extensions --no-skills --no-prompt-templates (also no built-in MCP). Your logins, default model and AGENTS.md still apply, and Switchyard's model, effort, context and command controls keep working.`};function jn(e){let t=[];return e.forEach((e,n)=>{let r=Ne.safeParse(e);r.success||t.push(`Line ${n+1} (${e}): ${r.error.issues[0]?.message??`invalid argument`}`)}),t}function Mn(){let e=K(),t=h(e=>e.profiles),n=h(e=>e.projects),r=(0,z.useMemo)(()=>Object.values(t).sort((e,t)=>e.name.localeCompare(t.name)),[t]),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(null),[c,l]=(0,z.useState)(!1),[u,f]=(0,z.useState)(null),p=async()=>{if(o){l(!0),f(null);try{await d(`/api/profiles/${encodeURIComponent(o.id)}`),I.success(`Profile ${o.name} deleted`),s(null)}catch(e){f(e)}finally{l(!1)}}},m=e=>Object.values(n).filter(t=>t.defaultProfileId===e).map(e=>e.name);return(0,B.jsxs)(H,{title:`Pi profiles`,description:`Presets for provider, model, thinking level and Pi flags. Sessions keep a snapshot of the profile they started with.`,actions:(0,B.jsx)(D,{variant:`primary`,icon:(0,B.jsx)(P,{className:`size-4`}),onClick:()=>a(`new`),children:`New profile`}),children:[(0,B.jsx)(G,{}),e?r.length===0?(0,B.jsx)(N,{icon:(0,B.jsx)(oe,{className:`size-8`}),title:`No profiles`,description:`Create a profile to choose a provider and model for sessions.`,action:{label:`New profile`,onClick:()=>a(`new`)}}):(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:r.map(e=>{let t=m(e.id);return(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-3 border-b border-border px-4 py-3 last:border-b-0`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 text-sm`,children:[(0,B.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,B.jsxs)(`span`,{className:`break-words text-muted`,children:[e.provider??`Default provider`,` / `,e.model??`default model`,` · Thinking`,` `,e.thinking??`default`,` · Project trust `,Dn[e.projectTrust],e.resources===`vanilla`&&` · Vanilla Pi`]}),e.extraArgs.length>0&&(0,B.jsx)(`span`,{className:`break-all font-mono text-xs text-muted`,children:e.extraArgs.join(` `)}),t.length>0&&(0,B.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Default for `,t.join(`, `)]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(D,{size:`sm`,icon:(0,B.jsx)(ue,{className:`size-4`}),onClick:()=>a(e),children:`Edit`}),(0,B.jsx)(D,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,B.jsx)(pe,{className:`size-4`}),onClick:()=>{f(null),s(e)},children:`Delete`})]})]},e.id)})}):(0,B.jsx)(A,{label:`Loading profiles…`}),i&&(0,B.jsx)(Nn,{profile:i===`new`?null:i,onClose:()=>a(null)},i===`new`?`new`:i.id),(0,B.jsx)(Ft,{open:o!==null,onClose:()=>s(null),title:o?`Delete ${o.name}?`:`Delete profile`,confirmLabel:`Delete profile`,busy:c,error:u,onConfirm:p,children:(0,B.jsx)(`p`,{className:`text-sm`,children:`Existing sessions keep their snapshot of this profile. Projects that use it as their default must be changed first.`})})]})}function Nn({profile:e,onClose:t}){let n=(0,z.useId)(),[r,i]=(0,z.useState)(e?.name??``),[a,o]=(0,z.useState)(e?.provider??``),[s,c]=(0,z.useState)(e?.model??``),[l,u]=(0,z.useState)(e?.thinking??``),[d,f]=(0,z.useState)(e?.projectTrust??`ask`),[p,h]=(0,z.useState)(e?.resources??`all`),[g,_]=(0,z.useState)((e?.extraArgs??[]).join(`
|
|
5
|
+
`)),[y,b]=(0,z.useState)(!1),[x,S]=(0,z.useState)(!1),[C,w]=(0,z.useState)(null),T=kt(g),E=jn(T),O=y&&!r.trim()?`Enter a profile name.`:null,k=E.length?E.join(`
|
|
6
|
+
`):null,A=async n=>{if(n.preventDefault(),b(!0),!r.trim()||E.length)return;let i={name:r.trim(),provider:a.trim()||null,model:s.trim()||null,thinking:l||null,projectTrust:d,resources:p,extraArgs:T};S(!0),w(null);try{e?(await m(`/api/profiles/${encodeURIComponent(e.id)}`,i),I.success(`Profile ${i.name} saved`)):(await v(`/api/profiles`,i),I.success(`Profile ${i.name} created`)),t()}catch(e){w(e)}finally{S(!1)}},j=`${n}-form`;return(0,B.jsx)(R,{open:!0,onClose:x?()=>void 0:t,dismissOnBackdrop:!x,title:e?`Edit ${e.name}`:`New profile`,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(D,{onClick:t,disabled:x,children:`Cancel`}),(0,B.jsx)(D,{type:`submit`,form:j,variant:`primary`,busy:x,children:e?`Save profile`:`Create profile`})]}),children:(0,B.jsxs)(`form`,{id:j,className:`flex min-w-0 flex-col gap-4`,onSubmit:A,noValidate:!0,children:[(0,B.jsx)(J,{id:`${n}-name`,label:`Name`,error:O,children:(0,B.jsx)(L,{id:`${n}-name`,value:r,onChange:e=>i(e.target.value),...Y(`${n}-name`,{error:O})})}),(0,B.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,B.jsx)(J,{id:`${n}-provider`,label:`Provider`,hint:`Empty uses Pi's default.`,children:(0,B.jsx)(L,{id:`${n}-provider`,value:a,onChange:e=>o(e.target.value),placeholder:`anthropic`,autoCapitalize:`off`,spellCheck:!1,...Y(`${n}-provider`,{hint:!0})})}),(0,B.jsx)(J,{id:`${n}-model`,label:`Model`,hint:`Empty uses Pi's default.`,children:(0,B.jsx)(L,{id:`${n}-model`,value:s,onChange:e=>c(e.target.value),autoCapitalize:`off`,spellCheck:!1,...Y(`${n}-model`,{hint:!0})})})]}),(0,B.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,B.jsx)(J,{id:`${n}-thinking`,label:`Thinking`,children:(0,B.jsxs)(X,{id:`${n}-thinking`,value:l,onChange:e=>u(e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:`Default (none)`}),kn.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})}),(0,B.jsx)(J,{id:`${n}-trust`,label:`Project trust`,hint:On[d],children:(0,B.jsx)(X,{id:`${n}-trust`,value:d,onChange:e=>f(e.target.value),...Y(`${n}-trust`,{hint:!0}),children:Object.keys(Dn).map(e=>(0,B.jsx)(`option`,{value:e,children:Dn[e]},e))})})]}),(0,B.jsx)(J,{id:`${n}-resources`,label:`Resources`,hint:An[p],children:(0,B.jsxs)(X,{id:`${n}-resources`,value:p,onChange:e=>h(e.target.value),...Y(`${n}-resources`,{hint:!0}),children:[(0,B.jsx)(`option`,{value:`all`,children:`Your Pi setup`}),(0,B.jsx)(`option`,{value:`vanilla`,children:`Vanilla Pi`})]})}),(0,B.jsx)(J,{id:`${n}-extra`,label:`Extra Pi arguments`,hint:`One long flag per line, e.g. --max-turns=40. Session, mode and extension flags are managed by Switchyard.`,error:k,children:(0,B.jsx)(ke,{id:`${n}-extra`,value:g,minRows:3,onChange:e=>_(e.target.value),className:`font-mono`,autoCapitalize:`off`,spellCheck:!1,...Y(`${n}-extra`,{hint:!0,error:k})})}),(0,B.jsx)(Z,{error:C})]})})}var Pn={managed:`Managed by Switchyard`,discovered:`Discovered worktree`,main:`Main checkout`},Fn={none:{icon:_e,label:`No setup`,tone:`neutral`},running:{icon:ge,label:`Setup running`,tone:`info`},succeeded:{icon:F,label:`Setup succeeded`,tone:`success`},failed:{icon:me,label:`Setup failed`,tone:`danger`}};function In(e){let t=[e.dirty?`Uncommitted changes (${e.changedFiles} file${e.changedFiles===1?``:`s`})`:`Clean`];return(e.ahead||e.behind)&&t.push(`${e.ahead} ahead, ${e.behind} behind`),t.push(e.unmerged?`Not merged into base`:`Merged`),t.join(` · `)}function Ln({project:e}){let t=h(e=>e.workspaces),n=h(e=>e.hosts),r=(0,z.useMemo)(()=>Object.values(t).filter(t=>t.projectId===e.id&&t.archivedAt===null).sort((e,t)=>Number(t.provenance===`main`)-Number(e.provenance===`main`)||(e.branch??``).localeCompare(t.branch??``)),[t,e.id]),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(null),c=async e=>{s(e.id);try{await v(`/api/workspaces/${encodeURIComponent(e.id)}/refresh`),I.success(`Workspace status refreshed`)}catch(e){I.error(`Could not refresh: ${b(e)}`)}finally{s(null)}};return(0,B.jsxs)(U,{title:`Workspaces`,description:`Worktrees where sessions and runs work. Removing one never deletes its branch.`,children:[r.length===0?(0,B.jsx)(N,{className:`py-4`,title:`No workspaces`,description:`Workspaces appear after a checkout is discovered. Use Refresh to discover them again.`}):(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:r.map(e=>{let t=n[e.hostId],r=t?.connectivity!==`connected`,i=Fn[e.setup.state]??Fn.none;return(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1.5 py-3 text-sm`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsx)(le,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),(0,B.jsx)(`span`,{className:`min-w-0 break-all font-mono font-medium`,children:e.branch??`(detached HEAD)`}),(0,B.jsx)(`span`,{className:`text-xs text-muted`,children:Pn[e.provenance]})]}),(0,B.jsxs)(`div`,{className:`break-all font-mono text-xs text-muted`,children:[t?.name?`${t.name}: `:``,e.path]}),(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{children:In(e.git)}),(0,B.jsx)(q,{icon:i.icon,label:i.label,tone:i.tone,spin:e.setup.state===`running`})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(D,{size:`sm`,icon:(0,B.jsx)(x,{className:`size-4`}),busy:o===e.id,disabled:r,onClick:()=>c(e),children:`Refresh status`}),e.provenance!==`main`&&(0,B.jsx)(D,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,B.jsx)(pe,{className:`size-4`}),disabled:r,onClick:()=>a(e),children:`Remove`}),e.provenance===`main`&&(0,B.jsx)(`span`,{className:`text-xs text-muted`,children:`The main checkout cannot be removed; remove the project's checkout instead.`}),r&&(0,B.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Host `,t?.name??`unknown`,` is `,t?.connectivity??`unknown`,`: refresh and removal need it online.`]})]})]},e.id)})}),i&&(0,B.jsx)(Rn,{workspace:t[i.id]??i,onClose:()=>a(null)},i.id)]})}function Rn({workspace:e,onClose:t}){let[n,r]=(0,z.useState)(e.git.dirty),[i,a]=(0,z.useState)(e.git.unmerged),[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(!1),[u,d]=(0,z.useState)(!1),[f,m]=(0,z.useState)(null),h=n&&!o||i&&!c;return(0,B.jsxs)(Ft,{open:!0,onClose:t,title:`Remove workspace?`,description:(0,B.jsx)(`span`,{className:`break-all font-mono`,children:e.branch??e.path}),confirmLabel:`Remove workspace`,busy:u,error:f,onConfirm:async()=>{d(!0),m(null);try{await v(`/api/workspaces/${encodeURIComponent(e.id)}/remove`,{force:{dirty:o,unmerged:c}}),I.success(`Workspace ${e.branch??e.path} removed`),t()}catch(e){p(e,`workspace_dirty`)&&r(!0),p(e,`workspace_unmerged`)&&a(!0),m(e)}finally{d(!1)}},confirmDisabled:h,disabledReason:`Check the boxes above to confirm what will be lost.`,children:[(0,B.jsxs)(`p`,{className:`text-sm`,children:[`The worktree at `,(0,B.jsx)(`span`,{className:`break-all font-mono`,children:e.path}),` is deleted from the host. The branch is kept.`]}),n&&(0,B.jsx)(Et,{label:`Discard uncommitted changes`,description:e.git.dirty?`${e.git.changedFiles} changed file${e.git.changedFiles===1?``:`s`} will be lost.`:`The host reported uncommitted changes; they will be lost.`,checked:o,onChange:s}),i&&(0,B.jsx)(Et,{label:`Remove although the branch is not merged`,description:`Commits stay on the branch, but the workspace is gone.`,checked:c,onChange:l})]})}var zn=`Inside the repository, for example .worktrees or .git/worktrees-switchyard`;function Bn(e){let t=e.trim();return t?t.startsWith(`/`)||/^[A-Za-z]:/.test(t)||t.includes(`\\`)?`Use a relative path inside the repository, e.g. .worktrees.`:t.split(`/`).includes(`..`)?`The folder must stay inside the repository (no ..).`:Fe.safeParse(t).success?null:`Use a plain relative path such as .worktrees (no empty or . segments).`:`Enter a folder inside the repository, e.g. .worktrees.`}function Vn(){let{projectId:e=``}=s(),t=K(),n=h(t=>t.projects[e]),r=h(e=>e.hosts),i=h(e=>e.profiles),[a,o]=(0,z.useState)(!1),[c,l]=(0,z.useState)([]),u=f(),d=(0,z.useMemo)(()=>Object.values(i).sort((e,t)=>e.name.localeCompare(t.name)),[i]),p={to:V(`projects`),label:`Projects`};return t?n?(0,B.jsxs)(H,{title:n.name,description:(0,B.jsx)(`span`,{className:`break-all`,children:n.repoIdentity}),back:p,actions:(0,B.jsx)(D,{busy:a,icon:(0,B.jsx)(x,{className:`size-4`}),onClick:async()=>{o(!0);try{let e=await v(`/api/projects/${encodeURIComponent(n.id)}/refresh`),t=Array.isArray(e?.errors)?e.errors:[];l(t),t.length?I.error(`Refreshed with ${t.length} checkout error(s)`):I.success(`Workspaces refreshed`)}catch(e){I.error(`Refresh failed: ${b(e)}`)}finally{o(!1)}},children:`Refresh`}),children:[(0,B.jsx)(G,{}),c&&c.length>0&&(0,B.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-border bg-danger-soft px-3 py-2 text-sm`,children:[(0,B.jsx)(`p`,{className:`font-medium`,children:`Some checkouts could not be refreshed`}),(0,B.jsx)(`ul`,{className:`list-disc pl-5`,children:c.map(e=>(0,B.jsx)(`li`,{className:`break-words`,children:e.message},e.checkoutId))})]}),(0,B.jsx)(Hn,{project:n,hosts:u,profiles:d},n.id),(0,B.jsx)(Un,{project:n,hosts:u,hostsById:r}),(0,B.jsx)(Ln,{project:n})]}):(0,B.jsx)(H,{title:`Project`,back:p,children:(0,B.jsx)(N,{icon:(0,B.jsx)(ae,{className:`size-8`}),title:`Project not found`,description:`It may have been removed, or this link is from another coordinator.`,action:{label:`Back to projects`,to:V(`projects`)}})}):(0,B.jsx)(H,{title:`Project`,back:p,children:(0,B.jsx)(A,{label:`Loading project…`})})}function Hn({project:e,hosts:t,profiles:n}){let r=(0,z.useId)(),[i,a]=(0,z.useState)(e.name),[o,s]=(0,z.useState)(e.setupCommand??``),[c,l]=(0,z.useState)(e.checks.join(`
|
|
7
|
+
`)),[u,d]=(0,z.useState)(String(e.maxConcurrentRuns)),[f,p]=(0,z.useState)(e.automationEnabled),[h,g]=(0,z.useState)(e.workspaceSharing),[_,v]=(0,z.useState)(e.defaultProfileId??``),[y,b]=(0,z.useState)(e.defaultHostId??``),[x,S]=(0,z.useState)(e.worktreeDir??`.worktrees`),[C,w]=(0,z.useState)(!1),[T,E]=(0,z.useState)(null),O=Number(u),k=i.trim()?null:`Enter a project name.`,A=Number.isInteger(O)&&O>=1&&O<=32?null:`Use a whole number from 1 to 32.`,j=Bn(x),M=async t=>{if(t.preventDefault(),!(k||A||j)){w(!0),E(null);try{await m(`/api/projects/${encodeURIComponent(e.id)}`,{name:i.trim(),setupCommand:o.trim()||null,checks:kt(c),maxConcurrentRuns:O,automationEnabled:f,workspaceSharing:h,defaultProfileId:_||null,defaultHostId:y||null,worktreeDir:x.trim()}),I.success(`Project settings saved`)}catch(e){E(e)}finally{w(!1)}}},N=!y||t.some(e=>e.id===y),ee=!_||n.some(e=>e.id===_);return(0,B.jsx)(U,{title:`Project settings`,children:(0,B.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:M,noValidate:!0,children:[(0,B.jsx)(J,{id:`${r}-name`,label:`Name`,error:k,children:(0,B.jsx)(L,{id:`${r}-name`,value:i,onChange:e=>a(e.target.value),...Y(`${r}-name`,{error:k})})}),(0,B.jsx)(J,{id:`${r}-setup`,label:`Setup command`,hint:`Runs in each new workspace before the first session, e.g. pnpm install. Leave empty for none.`,children:(0,B.jsx)(L,{id:`${r}-setup`,value:o,onChange:e=>s(e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,...Y(`${r}-setup`,{hint:!0})})}),(0,B.jsx)(J,{id:`${r}-checks`,label:`Checks`,hint:`One command per line. Runs must pass these before review.`,children:(0,B.jsx)(ke,{id:`${r}-checks`,value:c,minRows:3,onChange:e=>l(e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,...Y(`${r}-checks`,{hint:!0})})}),(0,B.jsx)(J,{id:`${r}-runs`,label:`Max concurrent runs`,hint:`Between 1 and 32.`,error:A,children:(0,B.jsx)(L,{id:`${r}-runs`,type:`number`,inputMode:`numeric`,min:1,max:32,step:1,value:u,onChange:e=>d(e.target.value),className:`max-w-32`,...Y(`${r}-runs`,{hint:!0,error:A})})}),(0,B.jsx)(J,{id:`${r}-worktree`,label:`Worktree folder`,hint:zn,error:j,children:(0,B.jsx)(L,{id:`${r}-worktree`,"data-testid":`project-worktree-dir`,value:x,onChange:e=>S(e.target.value),placeholder:`.worktrees`,className:`font-mono`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,...Y(`${r}-worktree`,{hint:!0,error:j})})}),(0,B.jsx)(Tt,{label:`Automation`,description:`When off, ready tasks in this project wait instead of starting automatically.`,checked:f,onChange:p}),(0,B.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,B.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:`Workspace sharing`}),[[`single_writer`,`Single writer`,`Only one run or session writes in a workspace at a time; others wait. Safest.`],[`shared`,`Shared`,`Several sessions may write in the same workspace at once. Their changes can interleave.`]].map(([e,t,n])=>(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(`input`,{id:`${r}-sharing-${e}`,type:`radio`,name:`${r}-sharing`,value:e,checked:h===e,onChange:()=>g(e),"aria-describedby":`${r}-sharing-${e}-desc`,className:`tap mt-0.5 size-5 shrink-0 accent-[var(--sy-accent)]`}),(0,B.jsxs)(`label`,{htmlFor:`${r}-sharing-${e}`,className:`min-w-0 text-sm`,children:[(0,B.jsx)(`span`,{className:`block font-medium`,children:t}),(0,B.jsx)(`span`,{id:`${r}-sharing-${e}-desc`,className:`block text-muted`,children:n})]})]},e))]}),(0,B.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,B.jsx)(J,{id:`${r}-profile`,label:`Default Pi profile`,children:(0,B.jsxs)(X,{id:`${r}-profile`,value:_,onChange:e=>v(e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:`None (use the coordinator default)`}),n.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id)),!ee&&(0,B.jsxs)(`option`,{value:_,children:[`Unknown profile (`,_,`)`]})]})}),(0,B.jsx)(J,{id:`${r}-host`,label:`Default host`,hint:`Runs start here when the task does not choose a host.`,children:(0,B.jsxs)(X,{id:`${r}-host`,value:y,onChange:e=>b(e.target.value),...Y(`${r}-host`,{hint:!0}),children:[(0,B.jsx)(`option`,{value:``,children:`None (any host with a checkout)`}),t.map(e=>(0,B.jsxs)(`option`,{value:e.id,children:[e.name,e.connectivity===`connected`?``:` (${e.connectivity})`]},e.id)),!N&&(0,B.jsxs)(`option`,{value:y,children:[`Unknown host (`,y,`)`]})]})})]}),(0,B.jsx)(Z,{error:T}),(0,B.jsx)(`div`,{children:(0,B.jsx)(D,{type:`submit`,variant:`primary`,busy:C,icon:(0,B.jsx)(fe,{className:`size-4`}),children:`Save project`})})]})})}function Un({project:e,hosts:t,hostsById:n}){let r=h(e=>e.checkouts),i=(0,z.useMemo)(()=>Object.values(r).filter(t=>t.projectId===e.id).sort((e,t)=>e.createdAt.localeCompare(t.createdAt)),[r,e.id]),[a,o]=(0,z.useState)(!1);return(0,B.jsxs)(U,{title:`Checkouts`,description:`Clones of this repository. Add one per host that should run this project.`,actions:(0,B.jsx)(D,{size:`sm`,icon:(0,B.jsx)(P,{className:`size-4`}),onClick:()=>o(!0),children:`Add checkout`}),children:[i.length===0?(0,B.jsx)(N,{className:`py-4`,title:`No checkouts`,description:`Add a checkout so sessions and runs have somewhere to work.`,action:{label:`Add checkout`,onClick:()=>o(!0)}}):(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:i.map(e=>{let t=n[e.hostId];return(0,B.jsxs)(`li`,{className:`min-w-0 py-2 text-sm`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:t?.name??`Unknown host`}),t&&t.connectivity!==`connected`&&(0,B.jsxs)(`span`,{className:`text-xs text-muted`,children:[`(`,t.connectivity,`)`]})]}),(0,B.jsx)(`div`,{className:`break-all font-mono text-xs`,children:e.path}),(0,B.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Default branch: `,e.defaultBranch]})]},e.id)})}),(0,B.jsx)(Wn,{open:a,onClose:()=>o(!1),project:e,hosts:t})]})}function Wn({open:e,onClose:t,project:n,hosts:r}){let i=(0,z.useId)(),a=r.filter(e=>e.connectivity===`connected`),[o,s]=(0,z.useState)(``),[c,l]=(0,z.useState)(``),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)(null),g=o||a[0]?.id||``,_=u||c?Dt(c):null,y=()=>{f||(d(!1),h(null),t())},b=async e=>{if(e.preventDefault(),d(!0),g&&!Dt(c)){p(!0),h(null);try{await v(`/api/projects/${encodeURIComponent(n.id)}/checkouts`,{hostId:g,path:c.trim()}),I.success(`Checkout added`),l(``),d(!1),t()}catch(e){h(e)}finally{p(!1)}}},x=`${i}-form`;return(0,B.jsx)(R,{open:e,onClose:y,dismissOnBackdrop:!f,title:`Add checkout`,description:`Another clone of ${n.repoIdentity}.`,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(D,{onClick:y,disabled:f,children:`Cancel`}),(0,B.jsx)(D,{type:`submit`,form:x,variant:`primary`,busy:f,disabled:a.length===0,children:`Add checkout`})]}),children:(0,B.jsxs)(`form`,{id:x,className:`flex min-w-0 flex-col gap-4`,onSubmit:b,noValidate:!0,children:[a.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`No host is connected. The checkout is inspected on its host, so the host must be online.`}),(0,B.jsx)(J,{id:`${i}-host`,label:`Host`,hint:`Only connected hosts are listed.`,children:(0,B.jsxs)(X,{id:`${i}-host`,value:g,onChange:e=>s(e.target.value),disabled:a.length===0,...Y(`${i}-host`,{hint:!0}),children:[a.length===0&&(0,B.jsx)(`option`,{value:``,children:`No connected hosts`}),a.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,B.jsx)(J,{id:`${i}-path`,label:`Checkout path on the host`,hint:`Absolute path of an existing clone of this repository.`,error:_,children:(0,B.jsx)(L,{id:`${i}-path`,value:c,onChange:e=>l(e.target.value),placeholder:`/Users/me/src/app`,className:`font-mono`,autoCapitalize:`off`,autoComplete:`off`,spellCheck:!1,...Y(`${i}-path`,{hint:!0,error:_})})}),(0,B.jsx)(Z,{error:m})]})})}var Gn=e=>V(`projects/${encodeURIComponent(e)}`);function Kn(){let e=K(),t=u(),n=h(e=>e.checkouts),i=h(e=>e.workspaces),a=(0,z.useMemo)(()=>{let e={},t=t=>(e[t]??={checkouts:0,workspaces:0},e[t]);for(let e of Object.values(n))t(e.projectId).checkouts++;for(let e of Object.values(i))e.archivedAt||t(e.projectId).workspaces++;return e},[n,i]);return(0,B.jsxs)(H,{testId:`settings-projects`,title:`Projects`,description:`A project is one repository. It can have checkouts on several hosts. Repositories in a host's project folders are added automatically.`,actions:(0,B.jsxs)(r,{to:V(`projects/new`),className:C(`primary`),children:[(0,B.jsx)(P,{"aria-hidden":!0,className:`size-4`}),`New project`]}),children:[(0,B.jsx)(G,{}),e?t.length===0?(0,B.jsx)(N,{icon:(0,B.jsx)(ae,{className:`size-8`}),title:`No projects yet`,description:`Create a project from a Git checkout on one of your hosts.`,action:{label:`New project`,to:V(`projects/new`)}}):(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:t.map(e=>(0,B.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,B.jsx)(qn,{project:e,counts:a[e.id]})},e.id))}):(0,B.jsx)(A,{label:`Loading projects…`})]})}function qn({project:e,counts:t}){let n=t??{checkouts:0,workspaces:0};return(0,B.jsxs)(r,{to:Gn(e.id),className:`tap flex min-w-0 items-center gap-3 px-4 py-3 hover:bg-surface-2`,children:[(0,B.jsx)(ae,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,B.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,B.jsx)(`span`,{className:`break-all text-xs text-muted`,children:e.repoIdentity}),(0,B.jsxs)(`span`,{className:`flex flex-wrap gap-x-3 text-xs text-muted`,children:[(0,B.jsxs)(`span`,{children:[n.checkouts,` checkout`,n.checkouts===1?``:`s`]}),(0,B.jsxs)(`span`,{children:[n.workspaces,` workspace`,n.workspaces===1?``:`s`]}),(0,B.jsxs)(`span`,{children:[`Automation `,e.automationEnabled?`on`:`off`]})]})]}),(0,B.jsx)(se,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})}function Jn(){let e=K(),t=f(),i=h(e=>e.profiles),a=(0,z.useMemo)(()=>Object.values(i).sort((e,t)=>e.name.localeCompare(t.name)),[i]),o=t.filter(e=>e.connectivity===`connected`),s=n(),c=(0,z.useId)(),[l,u]=(0,z.useState)(``),[d,p]=(0,z.useState)(``),[m,g]=(0,z.useState)(``),[_,y]=(0,z.useState)(``),[b,x]=(0,z.useState)(`.worktrees`),[C,w]=(0,z.useState)(!1),[T,E]=(0,z.useState)(!1),[O,k]=(0,z.useState)(null),j=d||o[0]?.id||``,M=C&&!l.trim()?`Enter a project name.`:null,N=C&&!j?`Choose a connected host.`:null,ee=C||m?Dt(m):null,te=Bn(b),ne=async e=>{if(e.preventDefault(),w(!0),l.trim()&&j&&!Dt(m)&&!te){E(!0),k(null);try{let e=await v(`/api/projects`,{name:l.trim(),hostId:j,path:m.trim(),defaultProfileId:_||null,worktreeDir:b.trim()});I.success(`Project ${l.trim()} created`),s(e?.id?Gn(e.id):V(`projects`))}catch(e){k(e)}finally{E(!1)}}},re={to:V(`projects`),label:`Projects`};return e?(0,B.jsxs)(H,{title:`New project`,description:`Switchyard inspects the checkout on the host, then discovers its worktrees.`,back:re,children:[o.length===0&&(0,B.jsx)(S,{capability:`Creating a project`,reason:t.length===0?`No hosts are enrolled. Add a host first.`:`No host is connected. The checkout is inspected on its host, so the host must be online.`,fallback:(0,B.jsx)(r,{to:V(`hosts`),className:`font-medium text-accent`,children:`Open hosts`})}),(0,B.jsx)(U,{children:(0,B.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:ne,noValidate:!0,children:[(0,B.jsx)(J,{id:`${c}-name`,label:`Name`,error:M,children:(0,B.jsx)(L,{id:`${c}-name`,value:l,onChange:e=>u(e.target.value),autoComplete:`off`,...Y(`${c}-name`,{error:M})})}),(0,B.jsx)(J,{id:`${c}-host`,label:`Host`,hint:`Only connected hosts are listed.`,error:N,children:(0,B.jsxs)(X,{id:`${c}-host`,value:j,onChange:e=>p(e.target.value),disabled:o.length===0,...Y(`${c}-host`,{hint:!0,error:N}),children:[o.length===0&&(0,B.jsx)(`option`,{value:``,children:`No connected hosts`}),o.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,B.jsx)(J,{id:`${c}-path`,label:`Checkout path on the host`,hint:`Absolute path of an existing Git checkout, e.g. /Users/me/src/app.`,error:ee,children:(0,B.jsx)(L,{id:`${c}-path`,value:m,onChange:e=>g(e.target.value),placeholder:`/Users/me/src/app`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,className:`font-mono`,...Y(`${c}-path`,{hint:!0,error:ee})})}),(0,B.jsx)(J,{id:`${c}-worktree`,label:`Worktree folder`,hint:zn,error:te,children:(0,B.jsx)(L,{id:`${c}-worktree`,value:b,onChange:e=>x(e.target.value),placeholder:`.worktrees`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,className:`font-mono`,...Y(`${c}-worktree`,{hint:!0,error:te})})}),(0,B.jsx)(J,{id:`${c}-profile`,label:`Default Pi profile (optional)`,children:(0,B.jsxs)(X,{id:`${c}-profile`,value:_,onChange:e=>y(e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:`None`}),a.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,B.jsx)(Z,{error:O}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(D,{type:`submit`,variant:`primary`,busy:T,icon:(0,B.jsx)($e,{className:`size-4`}),disabled:o.length===0,children:`Create project`}),o.length===0&&(0,B.jsx)(q,{icon:$e,label:`Needs a connected host`})]})]})})]}):(0,B.jsx)(H,{title:`New project`,back:re,children:(0,B.jsx)(A,{})})}function Yn(){let e=Lt(`/api/auth/methods`,Ot),[t,n]=(0,z.useState)(!1),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(!1),[f,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)(null),g=async()=>{if(r){o(!0),c(null);try{await d(`/api/auth/passkeys/${encodeURIComponent(r.id)}`),I.success(`Passkey ${r.name} removed`),i(null),e.reload()}catch(e){c(e)}finally{o(!1)}}},_=async()=>{p(!0),h(null);try{await v(`/api/logout`),u(!1),he(null)}catch(e){h(e)}finally{p(!1)}},y=e.data,b=y?.passkeyAvailability,x=Ie(),S=y?b?.available?x?null:`This browser does not support passkeys.`:b?.reason??`Passkeys are not available on this server.`:null;return(0,B.jsxs)(H,{testId:`settings-signin`,title:`Sign-in`,description:`How you sign in to Switchyard on new devices. Each signed-in device keeps its own revocable credential.`,children:[(0,B.jsx)(G,{}),e.loading&&!y?(0,B.jsx)(A,{label:`Loading sign-in methods…`}):e.error&&!y?(0,B.jsx)(k,{title:`Could not load sign-in methods`,error:e.error,onRetry:e.reload}):y?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(U,{title:`Passkeys`,description:`Sign in on any device with its fingerprint, face or screen lock. Passkeys are stored on this server only as public keys.`,actions:(0,B.jsx)(D,{"data-testid":`passkey-add`,variant:`primary`,icon:(0,B.jsx)(P,{className:`size-4`}),disabled:S!==null,onClick:()=>n(!0),children:`Add a passkey`}),children:[S&&(0,B.jsxs)(`p`,{role:`status`,className:`mb-3 flex items-start gap-2 rounded-md bg-warning-soft px-3 py-2 text-sm`,children:[(0,B.jsx)(w,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0`}),(0,B.jsxs)(`span`,{className:`min-w-0 break-words`,children:[`Adding a passkey is unavailable: `,S]})]}),y.passkeys.length===0?(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`No passkeys yet. Add one so your other devices can sign in without a link.`}):(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border`,children:y.passkeys.map(e=>(0,B.jsxs)(`li`,{"data-testid":`passkey-row`,className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-border px-3 py-2 last:border-b-0`,children:[(0,B.jsx)(de,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`break-words font-medium`,children:e.name}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 text-sm text-muted`,children:[(0,B.jsxs)(`span`,{children:[`Added `,j(e.createdAt)]}),(0,B.jsxs)(`span`,{children:[`Last used `,j(e.lastUsedAt)]})]})]}),(0,B.jsx)(D,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,B.jsx)(pe,{className:`size-4`}),"aria-label":`Remove passkey ${e.name}`,onClick:()=>{c(null),i(e)},children:`Remove`})]},e.id))})]}),(0,B.jsx)(U,{title:`Single sign-on`,description:`Configured on the server`,children:y.oidc?(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsx)(W,{items:[[`Button label`,y.oidc.label],[`Provider`,(0,B.jsx)(`span`,{className:`break-all`,children:y.oidc.issuer},`i`)],[`Allowed account`,y.oidc.ownerMatch],[`Status`,y.oidc.status===`ready`?(0,B.jsx)(q,{icon:F,tone:`success`,label:`Ready`},`s`):(0,B.jsx)(q,{icon:w,tone:`danger`,label:`Error`},`s`)]]}),y.oidc.status===`error`&&y.oidc.error&&(0,B.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-danger`,children:y.oidc.error})]}):(0,B.jsxs)(`p`,{"data-testid":`signin-oidc-status`,className:`text-sm text-muted`,children:[`Not configured. Set the `,(0,B.jsx)(`code`,{children:`SWITCHYARD_OIDC_*`}),` variables on the server to sign in with an identity provider.`]})})]}):null,(0,B.jsx)(U,{title:`This device`,description:`Signing out removes this device's credential here. Other devices stay signed in; revoke a device in Settings › Devices to cut it off.`,children:(0,B.jsx)(D,{icon:(0,B.jsx)(st,{className:`size-4`}),onClick:()=>{h(null),u(!0)},children:`Sign out of this device`})}),(0,B.jsx)(Xn,{open:t,onClose:()=>n(!1),onAdded:()=>{n(!1),e.reload()}}),(0,B.jsx)(Ft,{open:r!==null,onClose:()=>i(null),title:r?`Remove passkey ${r.name}?`:`Remove passkey`,confirmLabel:`Remove passkey`,busy:a,error:s,onConfirm:g,children:(0,B.jsxs)(`p`,{className:`text-sm`,children:[`Devices already signed in stay signed in. This passkey can no longer sign in new devices.`,y&&y.passkeys.length===1&&!y.oidc?` It is your only passkey and no single sign-on is set up: afterwards new devices need a pairing link.`:``]})}),(0,B.jsx)(Ft,{open:l,onClose:()=>u(!1),title:`Sign out of this device?`,confirmLabel:`Sign out`,busy:f,error:m,onConfirm:_,children:(0,B.jsx)(`p`,{className:`text-sm`,children:`You will need a passkey, single sign-on or a pairing link to sign in here again.`})})]})}function Xn({open:e,onClose:t,onAdded:n}){let r=(0,z.useId)(),[i,a]=(0,z.useState)(()=>We()),[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(null),u=i.trim()?null:`Enter a name for this passkey.`,d=()=>{o||(l(null),t())},f=async e=>{if(e.preventDefault(),!u){s(!0),l(null);try{let{challengeId:e,options:t}=await v(`/api/auth/passkeys/register/options`),r=await Be({optionsJSON:t});await v(`/api/auth/passkeys/register/verify`,{challengeId:e,name:i.trim().slice(0,80),response:r}),I.success(`Passkey added`),n()}catch(e){l(e instanceof Error&&e.name===`NotAllowedError`?Error(`The passkey prompt was cancelled or timed out. Try again.`):e instanceof Error?e:Error(b(e)))}finally{s(!1)}}},p=`${r}-form`;return(0,B.jsx)(R,{open:e,onClose:d,dismissOnBackdrop:!o,title:`Add a passkey`,description:`Name it after where it is stored, then confirm with your device.`,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(D,{onClick:d,disabled:o,children:`Cancel`}),(0,B.jsx)(D,{type:`submit`,form:p,variant:`primary`,busy:o,children:`Create passkey`})]}),children:(0,B.jsxs)(`form`,{id:p,className:`flex min-w-0 flex-col gap-4`,onSubmit:f,noValidate:!0,children:[(0,B.jsx)(J,{id:`${r}-name`,label:`Passkey name`,error:u,children:(0,B.jsx)(L,{id:`${r}-name`,value:i,maxLength:80,autoComplete:`off`,onChange:e=>a(e.target.value),...Y(`${r}-name`,{error:u})})}),(0,B.jsx)(Z,{error:c})]})})}function Zn(){let e=Te(),n=e===`mobile`,r=(0,B.jsxs)(i,{children:[(0,B.jsx)(t,{index:!0,element:n?(0,B.jsx)(nr,{}):(0,B.jsx)(tr,{})}),(0,B.jsx)(t,{path:`hosts`,element:(0,B.jsx)(mn,{})}),(0,B.jsx)(t,{path:`hosts/:hostId`,element:(0,B.jsx)(yn,{})}),(0,B.jsx)(t,{path:`devices`,element:(0,B.jsx)(on,{})}),(0,B.jsx)(t,{path:`sign-in`,element:(0,B.jsx)(Yn,{})}),(0,B.jsx)(t,{path:`projects`,element:(0,B.jsx)(Kn,{})}),(0,B.jsx)(t,{path:`projects/new`,element:(0,B.jsx)(Jn,{})}),(0,B.jsx)(t,{path:`projects/:projectId`,element:(0,B.jsx)(Vn,{})}),(0,B.jsx)(t,{path:`profiles`,element:(0,B.jsx)(Mn,{})}),(0,B.jsx)(t,{path:`adapters`,element:(0,B.jsx)(Wt,{})}),(0,B.jsx)(t,{path:`notifications`,element:(0,B.jsx)(Cn,{})}),(0,B.jsx)(t,{path:`backups`,element:(0,B.jsx)(Qt,{})}),(0,B.jsx)(t,{path:`diagnostics`,element:(0,B.jsx)(ln,{})}),(0,B.jsx)(t,{path:`device`,element:(0,B.jsx)(cn,{})}),(0,B.jsx)(t,{path:`*`,element:(0,B.jsx)(rr,{})})]});return n?(0,B.jsx)(`div`,{className:`min-w-0`,children:r}):(0,B.jsxs)(`div`,{className:`flex min-h-full min-w-0`,children:[(0,B.jsx)($n,{compact:e===`compact`}),(0,B.jsx)(`div`,{className:`min-w-0 flex-1`,children:r})]})}function Qn(){let{pathname:e}=l(),t=e.split(`/`),n=t.indexOf(`settings`);return n>=0&&(t[n+1]??null)||null}function $n({compact:e}){let t=Qn();return(0,B.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-testid":`settings-nav`,className:T(`sticky top-0 flex max-h-dvh shrink-0 flex-col gap-1 self-start overflow-y-auto border-r border-border px-2 py-4`,e?`w-52`:`w-60`),children:[(0,B.jsx)(r,{to:V(),"aria-current":t===null?`page`:void 0,className:T(`tap mb-2 rounded-md px-3 py-1 text-base font-semibold`,t===null?`bg-accent-soft`:`hover:bg-surface-2`),children:`Settings`}),(0,B.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:St.map(({path:e,label:n,icon:i})=>{let a=t===e;return(0,B.jsx)(`li`,{children:(0,B.jsxs)(r,{to:V(e),"aria-current":a?`page`:void 0,className:T(`tap flex h-10 items-center gap-3 rounded-md px-3 text-sm font-medium`,a?`bg-accent-soft text-text`:`text-muted hover:bg-surface-2 hover:text-text`),children:[(0,B.jsx)(i,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,B.jsx)(`span`,{className:`min-w-0 truncate`,children:n})]})},e)})})]})}function er(){let e=h(e=>e.hosts),t=h(e=>e.devices),n=h(e=>e.projects),r=h(e=>e.profiles),i=h(e=>e.adapters),a=h(e=>e.hydrated);return(0,z.useMemo)(()=>{if(!a)return{};let o=Object.values(e).filter(e=>e.revokedAt===null),s=o.filter(e=>e.connectivity===`connected`).length,c=Object.values(i).reduce((e,t)=>e+t.length,0),l=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return{hosts:`${l(o.length,`host`)}, ${s} connected`,devices:l(Object.values(t).filter(e=>e.revokedAt===null).length,`device`),projects:l(Object.keys(n).length,`project`),profiles:l(Object.keys(r).length,`profile`),adapters:l(c,`adapter`)}},[e,t,n,r,i,a])}function tr(){let e=er();return(0,B.jsxs)(H,{title:`Settings`,description:`Configure Switchyard and check its health.`,children:[(0,B.jsx)(G,{}),(0,B.jsx)(`ul`,{className:`grid min-w-0 gap-3 lg:grid-cols-2`,children:St.map(({path:t,label:n,description:i,icon:a})=>(0,B.jsx)(`li`,{className:`min-w-0`,children:(0,B.jsxs)(r,{to:V(t),className:`tap flex h-full min-w-0 items-start gap-3 rounded-lg border border-border bg-surface p-4 hover:bg-surface-2`,children:[(0,B.jsx)(a,{"aria-hidden":!0,className:`mt-0.5 size-5 shrink-0 text-muted`}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`span`,{className:`block font-medium`,children:n}),(0,B.jsx)(`span`,{className:`block text-sm text-muted`,children:i}),e[t]&&(0,B.jsx)(`span`,{className:`mt-1 block text-xs text-subtle`,children:e[t]})]}),(0,B.jsx)(se,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-subtle`})]})},t))})]})}function nr(){let e=er();return(0,B.jsxs)(`div`,{className:`mx-auto flex w-full min-w-0 max-w-xl flex-col gap-3 px-4 py-4`,children:[(0,B.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Settings`}),(0,B.jsx)(G,{}),(0,B.jsx)(`nav`,{"aria-label":`Settings sections`,"data-testid":`settings-nav`,children:(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:St.map(({path:t,label:n,description:i,icon:a})=>(0,B.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,B.jsxs)(r,{to:V(t),className:`tap flex min-h-14 items-center gap-3 px-4 py-2 hover:bg-surface-2`,children:[(0,B.jsx)(a,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`span`,{className:`block font-medium`,children:n}),(0,B.jsx)(`span`,{className:`block truncate text-sm text-muted`,children:e[t]??i})]}),(0,B.jsx)(se,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})},t))})})]})}function rr(){return(0,B.jsx)(N,{title:`Settings page not found`,description:`This link does not match a settings section.`,action:{label:`Open Settings`,to:V()}})}export{Zn as default};
|
|
8
|
+
//# sourceMappingURL=settings-Csal1F-W.js.map
|