@spencerboucher/switchyard 0.8.0 → 0.10.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 +4 -4
- package/dist/bridge/lines.js +33 -0
- package/dist/bridge/switchyard-terminal.js +59 -22
- package/dist/switchyard.mjs +9769 -7208
- package/dist/terminal/holder.js +172 -55
- package/package.json +1 -1
- package/web-dist/apple-touch-icon.png +0 -0
- package/web-dist/assets/AutomationView-BsTwLnMp.js +2 -0
- package/web-dist/assets/AutomationView-BsTwLnMp.js.map +1 -0
- package/web-dist/assets/Card-CAFxHoHd.js +2 -0
- package/web-dist/assets/Card-CAFxHoHd.js.map +1 -0
- package/web-dist/assets/Checkbox-rDvnQnxc.js +2 -0
- package/web-dist/assets/Checkbox-rDvnQnxc.js.map +1 -0
- package/web-dist/assets/Copy-D8xhl7eJ.js +2 -0
- package/web-dist/assets/Copy-D8xhl7eJ.js.map +1 -0
- package/web-dist/assets/DangerZone-og55TRug.js +2 -0
- package/web-dist/assets/DangerZone-og55TRug.js.map +1 -0
- package/web-dist/assets/Field-Dbg_8KTt.js +2 -0
- package/web-dist/assets/Field-Dbg_8KTt.js.map +1 -0
- package/web-dist/assets/InteractionCard-Yu5wgLC3.js +6 -0
- package/web-dist/assets/InteractionCard-Yu5wgLC3.js.map +1 -0
- package/web-dist/assets/Menu-euseM8yR.js +2 -0
- package/web-dist/assets/Menu-euseM8yR.js.map +1 -0
- package/web-dist/assets/Overlay-BNPvMjLX.js +2 -0
- package/web-dist/assets/Overlay-BNPvMjLX.js.map +1 -0
- package/web-dist/assets/Priority-Ca1B2yFr.js +2 -0
- package/web-dist/assets/Priority-Ca1B2yFr.js.map +1 -0
- package/web-dist/assets/{SegmentedControl-BZPzNU08.js → SegmentedControl-D2d-NEr-.js} +2 -2
- package/web-dist/assets/{SegmentedControl-BZPzNU08.js.map → SegmentedControl-D2d-NEr-.js.map} +1 -1
- package/web-dist/assets/Select-C9L1HKMm.js +2 -0
- package/web-dist/assets/Select-C9L1HKMm.js.map +1 -0
- package/web-dist/assets/StatusChip-BYuVxYS7.js +2 -0
- package/web-dist/assets/StatusChip-BYuVxYS7.js.map +1 -0
- package/web-dist/assets/Switch-DAcUcSbH.js +2 -0
- package/web-dist/assets/Switch-DAcUcSbH.js.map +1 -0
- package/web-dist/assets/Tabs-xtagjtA5.js +184 -0
- package/web-dist/assets/Tabs-xtagjtA5.js.map +1 -0
- package/web-dist/assets/TextArea-CKGHwURx.js +2 -0
- package/web-dist/assets/TextArea-CKGHwURx.js.map +1 -0
- package/web-dist/assets/TextLink-Bub7sMxr.js +2 -0
- package/web-dist/assets/TextLink-Bub7sMxr.js.map +1 -0
- package/web-dist/assets/arrow-down-C-iLrN8I.js +2 -0
- package/web-dist/assets/arrow-down-C-iLrN8I.js.map +1 -0
- package/web-dist/assets/arrow-up-Dj-VTKx4.js +2 -0
- package/web-dist/assets/arrow-up-Dj-VTKx4.js.map +1 -0
- package/web-dist/assets/attention-CI4dHY81.js +2 -0
- package/web-dist/assets/attention-CI4dHY81.js.map +1 -0
- package/web-dist/assets/auth-308hUVgi.js +2 -0
- package/web-dist/assets/auth-308hUVgi.js.map +1 -0
- package/web-dist/assets/automations-BzpsJoa3.js +2 -0
- package/web-dist/assets/automations-BzpsJoa3.js.map +1 -0
- package/web-dist/assets/bell-DSwa2PAb.js +2 -0
- package/web-dist/assets/bell-DSwa2PAb.js.map +1 -0
- package/web-dist/assets/board-CeJxBVHC.js +10 -0
- package/web-dist/assets/board-CeJxBVHC.js.map +1 -0
- package/web-dist/assets/code-DkNQvMI9.js +12 -0
- package/web-dist/assets/code-DkNQvMI9.js.map +1 -0
- package/web-dist/assets/describe-CVXeUClF.js +5 -0
- package/web-dist/assets/describe-CVXeUClF.js.map +1 -0
- package/web-dist/assets/enroll-jnKygG4L.js +2 -0
- package/web-dist/assets/enroll-jnKygG4L.js.map +1 -0
- package/web-dist/assets/index-BHGZTS2e.js +16 -0
- package/web-dist/assets/index-BHGZTS2e.js.map +1 -0
- package/web-dist/assets/index-D2ml031z.css +2 -0
- package/web-dist/assets/logic-B46fwD-8.js +2 -0
- package/web-dist/assets/logic-B46fwD-8.js.map +1 -0
- package/web-dist/assets/more-DvKHMdBk.js +2 -0
- package/web-dist/assets/more-DvKHMdBk.js.map +1 -0
- package/web-dist/assets/queue-B2Vl0uSh.js +2 -0
- package/web-dist/assets/queue-B2Vl0uSh.js.map +1 -0
- package/web-dist/assets/repo-BDS8RBxq.js +2 -0
- package/web-dist/assets/repo-BDS8RBxq.js.map +1 -0
- package/web-dist/assets/server-BqZ-w6M8.js +2 -0
- package/web-dist/assets/server-BqZ-w6M8.js.map +1 -0
- package/web-dist/assets/settings-CLt7x9u8.js +8 -0
- package/web-dist/assets/settings-CLt7x9u8.js.map +1 -0
- package/web-dist/assets/states-C773NlHo.js +56 -0
- package/web-dist/assets/states-C773NlHo.js.map +1 -0
- package/web-dist/assets/terminal-BOV_MXPZ.js +2 -0
- package/web-dist/assets/terminal-BOV_MXPZ.js.map +1 -0
- package/web-dist/assets/terminal-login-BK5UjUir.js +2 -0
- package/web-dist/assets/terminal-login-BK5UjUir.js.map +1 -0
- package/web-dist/assets/useBackTo-BIrCq3W2.js +2 -0
- package/web-dist/assets/useBackTo-BIrCq3W2.js.map +1 -0
- package/web-dist/assets/useBreakpoint-BphHBrzF.js +2 -0
- package/web-dist/assets/useBreakpoint-BphHBrzF.js.map +1 -0
- package/web-dist/assets/useNow-Cm-tdyod.js +2 -0
- package/web-dist/assets/useNow-Cm-tdyod.js.map +1 -0
- package/web-dist/assets/useResource-BBqCoY2q.js +2 -0
- package/web-dist/assets/useResource-BBqCoY2q.js.map +1 -0
- package/web-dist/icon-192.png +0 -0
- package/web-dist/icon-512.png +0 -0
- package/web-dist/icon.svg +20 -8
- package/web-dist/index.html +7 -4
- package/web-dist/manifest.webmanifest +1 -1
- package/web-dist/maskable-512.png +0 -0
- package/web-dist/sw.js +1 -1
- package/web-dist/sw.js.map +1 -1
- package/web-dist/assets/AutomationView-GCthHkym.js +0 -2
- package/web-dist/assets/AutomationView-GCthHkym.js.map +0 -1
- package/web-dist/assets/Badge-CEMI3YyI.js +0 -2
- package/web-dist/assets/Badge-CEMI3YyI.js.map +0 -1
- package/web-dist/assets/InteractionCard-DaLqafmA.js +0 -6
- package/web-dist/assets/InteractionCard-DaLqafmA.js.map +0 -1
- package/web-dist/assets/Menu-BcKiEc6X.js +0 -2
- package/web-dist/assets/Menu-BcKiEc6X.js.map +0 -1
- package/web-dist/assets/Tabs-COH5EMql.js +0 -184
- package/web-dist/assets/Tabs-COH5EMql.js.map +0 -1
- package/web-dist/assets/TextArea-CeMEPZn4.js +0 -2
- package/web-dist/assets/TextArea-CeMEPZn4.js.map +0 -1
- package/web-dist/assets/arrow-left-C6YWM6y6.js +0 -2
- package/web-dist/assets/arrow-left-C6YWM6y6.js.map +0 -1
- package/web-dist/assets/attention-BAdea2kA.js +0 -2
- package/web-dist/assets/attention-BAdea2kA.js.map +0 -1
- package/web-dist/assets/automations-DSFUzB0w.js +0 -2
- package/web-dist/assets/automations-DSFUzB0w.js.map +0 -1
- package/web-dist/assets/board-eQ3H8yCp.js +0 -10
- package/web-dist/assets/board-eQ3H8yCp.js.map +0 -1
- package/web-dist/assets/code-D7JmYMKe.js +0 -13
- package/web-dist/assets/code-D7JmYMKe.js.map +0 -1
- package/web-dist/assets/copy-oWgGHmkS.js +0 -2
- package/web-dist/assets/copy-oWgGHmkS.js.map +0 -1
- package/web-dist/assets/describe-C1YimBXJ.js +0 -5
- package/web-dist/assets/describe-C1YimBXJ.js.map +0 -1
- package/web-dist/assets/dist-B_RpNOcK.js +0 -56
- package/web-dist/assets/dist-B_RpNOcK.js.map +0 -1
- package/web-dist/assets/enroll-1OCy5r50.js +0 -2
- package/web-dist/assets/enroll-1OCy5r50.js.map +0 -1
- package/web-dist/assets/index-BhpEXLav.js +0 -11
- package/web-dist/assets/index-BhpEXLav.js.map +0 -1
- package/web-dist/assets/index-DUeOwDZ6.css +0 -2
- package/web-dist/assets/logic-CBvFOyIo.js +0 -2
- package/web-dist/assets/logic-CBvFOyIo.js.map +0 -1
- package/web-dist/assets/more-RjVyxPaz.js +0 -2
- package/web-dist/assets/more-RjVyxPaz.js.map +0 -1
- package/web-dist/assets/now-CDjeFSLD.js +0 -2
- package/web-dist/assets/now-CDjeFSLD.js.map +0 -1
- package/web-dist/assets/plus-BLP-wIYD.js +0 -2
- package/web-dist/assets/plus-BLP-wIYD.js.map +0 -1
- package/web-dist/assets/save-DEvZPWlS.js +0 -2
- package/web-dist/assets/save-DEvZPWlS.js.map +0 -1
- package/web-dist/assets/search-C6cn5WOo.js +0 -2
- package/web-dist/assets/search-C6cn5WOo.js.map +0 -1
- package/web-dist/assets/send-BKjswHxB.js +0 -2
- package/web-dist/assets/send-BKjswHxB.js.map +0 -1
- package/web-dist/assets/server-SxFxIScj.js +0 -2
- package/web-dist/assets/server-SxFxIScj.js.map +0 -1
- package/web-dist/assets/settings-tH4UuIfJ.js +0 -7
- package/web-dist/assets/settings-tH4UuIfJ.js.map +0 -1
- package/web-dist/assets/shared-CRX6KSBm.js +0 -3
- package/web-dist/assets/shared-CRX6KSBm.js.map +0 -1
- package/web-dist/assets/sliders-horizontal-DAoirila.js +0 -2
- package/web-dist/assets/sliders-horizontal-DAoirila.js.map +0 -1
- package/web-dist/assets/states-DXozulGZ.js +0 -2
- package/web-dist/assets/states-DXozulGZ.js.map +0 -1
- package/web-dist/assets/terminal-login-CW2rE50W.js +0 -2
- package/web-dist/assets/terminal-login-CW2rE50W.js.map +0 -1
- package/web-dist/assets/trash-C6X2OLrI.js +0 -2
- package/web-dist/assets/trash-C6X2OLrI.js.map +0 -1
- package/web-dist/assets/useNow-C_B7JgMM.js +0 -2
- package/web-dist/assets/useNow-C_B7JgMM.js.map +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{_ as e,c as t,f as n,i as r,l as i,m as a,n as o,o as s,p as c,t as l,u}from"./jsx-runtime-D13aM9HY.js";import{_ as d,m as f,n as p,o as m,x as h}from"./StatusChip-BYuVxYS7.js";import{A as g,P as _,S as v,X as y,_ as b,_t as x,a as S,at as C,bt as w,c as T,d as E,dt as D,f as O,g as k,h as A,ht as j,i as M,n as N,ot as ee,p as te,pt as ne,r as re,rt as ie,s as P,st as ae,t as F,u as oe,ut as se,v as I,vt as L,x as ce,y as le,yt as ue,z as R}from"./states-C773NlHo.js";import{a as de,n as fe,s as pe}from"./auth-308hUVgi.js";import{a as me,i as he,r as z,t as B}from"./Field-Dbg_8KTt.js";import{t as ge}from"./bell-DSwa2PAb.js";import{n as _e,r as ve,t as ye}from"./Copy-D8xhl7eJ.js";import{a as be,i as xe,n as Se,o as Ce,r as we,s as Te,t as Ee}from"./repo-BDS8RBxq.js";import{t as De}from"./chevron-right-evVLS6hq.js";import{c as Oe,i as V,l as ke,n as Ae,s as je,t as Me,u as Ne}from"./useBreakpoint-BphHBrzF.js";import{n as Pe,t as Fe}from"./pencil-DI8QbCN8.js";import{t as Ie}from"./key-round-VDbE9E4X.js";import{i as Le,n as Re,r as ze,t as Be}from"./useBackTo-BIrCq3W2.js";import{n as Ve,t as He}from"./DangerZone-og55TRug.js";import{n as Ue,t as We}from"./Checkbox-rDvnQnxc.js";import{t as Ge}from"./server-BqZ-w6M8.js";import{t as Ke}from"./terminal-BOV_MXPZ.js";import{a as qe,b as Je,i as Ye,n as Xe,o as Ze,r as Qe,s as $e,t as et}from"./index-BHGZTS2e.js";import{n as tt,t as H}from"./Overlay-BNPvMjLX.js";import{n as nt,r as U}from"./TextArea-CKGHwURx.js";import{t as rt}from"./TextLink-Bub7sMxr.js";import{n as it,t as W}from"./useResource-BBqCoY2q.js";import{t as G}from"./Card-CAFxHoHd.js";import{t as K}from"./Select-C9L1HKMm.js";import{n as at}from"./Switch-DAcUcSbH.js";import{d as ot,f as st,l as ct,r as lt}from"./logic-B46fwD-8.js";var ut={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`}]]};ut.node;var dt=o(ut),ft={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`}]]};ft.node;var pt=o(ft),mt={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`}]]};mt.node;var ht=o(mt),gt={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`}]]};gt.node;var _t=o(gt),vt={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`}]]};vt.node;var yt=o(vt),bt={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`}]]};bt.node;var xt=o(bt),St={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`}]]};St.node;var Ct=o(St),wt={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`}]]};wt.node;var Tt=o(wt),Et={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`}]]};Et.node;var Dt=o(Et),Ot={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`}]]};Ot.node;var kt=o(Ot),At={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`}]]};At.node;var jt=o(At),Mt={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`}]]};Mt.node;var Nt=o(Mt),Pt={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`}]]};Pt.node;var Ft=o(Pt),q=e(a(),1),J=l(),It=[{path:`projects`,label:`Projects`,description:`Repositories, checkouts and workspaces`,icon:Ce,group:`Workspace`},{path:`profiles`,label:`Pi profiles`,description:`Provider, model and thinking presets`,icon:xe,group:`Workspace`},{path:`hosts`,label:`Hosts`,description:`Execution hosts, capabilities and versions`,icon:Ge,group:`Infrastructure`},{path:`adapters`,label:`Adapters`,description:`Extension adapters on each host`,icon:v,group:`Infrastructure`},{path:`backups`,label:`Backups`,description:`Back up and restore the coordinator`,icon:ht,group:`Infrastructure`},{path:`diagnostics`,label:`Diagnostics`,description:`Versions, migrations, events and recent problems`,icon:Ft,group:`Infrastructure`},{path:`sign-in`,label:`Sign-in`,description:`Passkeys, single sign-on and signing out`,icon:Ie,group:`Access`},{path:`devices`,label:`Devices`,description:`Signed-in browsers, apps and terminals`,icon:Dt,group:`Access`},{path:`notifications`,label:`Notifications`,description:`Push, quiet hours and previews`,icon:ge,group:`This device`},{path:`device`,label:`This device`,description:`Preferences stored on this device`,icon:xt,group:`This device`}],Lt=[`Workspace`,`Infrastructure`,`Access`,`This device`].map(e=>({label:e,sections:It.filter(t=>t.group===e)})),Y=e=>e?`/settings/${e}`:`/settings`;function X({title:e,description:t,actions:n,back:i,testId:a,children:o}){let s=Me()===`mobile`,c=i??(s?{to:Y(),label:`Settings`}:null),l=ze(c?.to??Y()),u=s&&!!c;return(0,J.jsxs)(`section`,{"data-testid":a,className:`flex w-full min-w-0 flex-col gap-4 px-4 py-4 md:px-6`,children:[u&&c?(0,J.jsxs)(`header`,{className:`sticky top-0 z-20 -mx-4 -mt-4 flex min-w-0 items-center gap-1 border-b border-border bg-surface px-1 pb-1 safe-pt-1`,children:[(0,J.jsx)(r,{to:c.to,onClick:Re(l),"aria-label":`Back to ${c.label}`,title:`Back to ${c.label}`,className:O(`ghost`,`md`,`size-11 px-0`),children:(0,J.jsx)(me,{"aria-hidden":!0,className:`size-5`})}),(0,J.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-base font-semibold`,children:e})]}):c&&(0,J.jsxs)(r,{to:c.to,onClick:Re(l),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,J.jsx)(Te,{"aria-hidden":!0,className:`size-4`}),`Back to `,c.label]}),(!u||t||n)&&(0,J.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-start gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-[1_1_15rem]`,children:[!u&&(0,J.jsx)(`h1`,{className:`break-words text-lg font-semibold`,children:e}),t&&(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:t})]}),n&&(0,J.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:n})]}),o]})}function Z({items:e}){return(0,J.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,J.jsxs)(`div`,{className:`contents`,children:[(0,J.jsx)(`dt`,{className:`text-muted`,children:e}),(0,J.jsx)(`dd`,{className:`mb-1 min-w-0 break-words sm:mb-0`,children:t})]},n))})}function Q(){return R(e=>e.hydrated)}var Rt={darwin:`macOS`,linux:`Linux`};function zt({host:e}){return e.piVersion?e.piCompatible?(0,J.jsx)(p,{icon:Ne,tone:`success`,label:`Pi ${e.piVersion} (compatible)`}):(0,J.jsx)(p,{icon:I,tone:`danger`,label:`Pi ${e.piVersion} (incompatible, needs ${y})`}):(0,J.jsx)(p,{icon:I,tone:`warning`,label:`Pi not detected (incompatible)`})}function Bt(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 Vt(e){if(typeof e!=`object`||!e)return!1;let t=e;return Array.isArray(t.passkeys)&&typeof t.passkeyAvailability==`object`}function Ht(e){return e.split(`
|
|
2
|
+
`).map(e=>e.trim()).filter(Boolean)}function Ut(e){let[t,n]=(0,q.useState)(()=>Date.now());if((0,q.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 Wt(e){let t=Math.ceil(e/1e3);return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}var Gt={active:{icon:Ne,label:`Active`,tone:`success`},disabled:{icon:d,label:`Disabled`,tone:`neutral`},error:{icon:ke,label:`Error`,tone:`danger`}};function Kt({status:e}){let t=Gt[e]??Gt.error;return(0,J.jsx)(p,{icon:t.icon,label:t.label,tone:t.tone})}var qt={project:`Project`,owner:`Owner`,plugin:`Plugin`,bundled:`Bundled`},Jt={info:{icon:je,label:`Info`,tone:`info`},warning:{icon:I,label:`Warning`,tone:`warning`},error:{icon:ke,label:`Error`,tone:`danger`}};function Yt({level:e}){let t=Jt[e]??Jt.info;return(0,J.jsx)(p,{icon:t.icon,label:t.label,tone:t.tone})}function Xt(e){let t=R(e=>e.diagnostics);return(0,q.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 Zt(){let e=Q(),t=R(e=>e.adapters),n=R(e=>e.hosts),i=it(`/api/diagnostics`,W),a=Xt(Array.isArray(i.data?.diagnostics)?i.data.diagnostics:void 0),o=(0,q.useMemo)(()=>Object.entries(t).filter(([,e])=>e.length>0).map(([e,t])=>({hostId:e,hostName:n[e]?.name??`Removed host`,adapters:[...t].sort((e,t)=>e.id.localeCompare(t.id))})).sort((e,t)=>e.hostName.localeCompare(t.hostName)),[t,n]);return(0,J.jsxs)(X,{title:`Adapters`,description:`Adapters translate Pi extensions into Switchyard cards, panels and interactions. Each host reports its own.`,children:[(0,J.jsx)(P,{}),i.error!==null&&!i.loading&&!i.fatal&&(0,J.jsx)(N,{compact:!0,title:`Could not load adapter diagnostics history`,error:i.error,onRetry:i.reload}),e?o.length===0?(0,J.jsx)(F,{icon:(0,J.jsx)(v,{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:Y(`hosts`)}}):o.map(e=>(0,J.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,J.jsx)(`h2`,{className:`text-base font-semibold`,children:(0,J.jsx)(r,{to:Y(`hosts/${encodeURIComponent(e.hostId)}`),className:`hover:underline`,children:e.hostName})}),e.adapters.map(e=>(0,J.jsx)(Qt,{adapter:e,diagnostics:a.filter(t=>t.adapterId===e.id)},e.id))]},e.hostId)):(0,J.jsx)(T,{label:`Loading adapters…`})]})}function Qt({adapter:e,diagnostics:t}){return(0,J.jsxs)(G,{title:(0,J.jsx)(`span`,{className:`break-all font-mono`,children:e.id}),actions:(0,J.jsx)(Kt,{status:e.status}),children:[(0,J.jsx)(Z,{items:[[`Version`,e.version],[`Tier`,qt[e.tier]??e.tier],[`Target extension`,(0,J.jsx)(`span`,{className:`break-all font-mono`,children:e.target.extension},`t`)],[`Version range`,(0,J.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,J.jsx)(`h3`,{className:`mt-3 mb-1 text-sm font-semibold`,children:`Recent diagnostics`}),t.length===0?(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`No diagnostics for this adapter.`}):(0,J.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:t.slice(0,10).map(e=>(0,J.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-2 text-sm`,children:[(0,J.jsx)(Yt,{level:e.level}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),(0,J.jsx)(`time`,{dateTime:e.at,className:`text-xs text-muted`,children:k(e.at)})]},`${e.at}-${e.message}`))})]})}function $t(e){return W(e)&&W(e.versions)}var en=`/api/diagnostics`,tn=`switchyard coordinator backup <file>`,nn=`switchyard coordinator restore <file>`;function rn(e){let t=e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/_/g,` `);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function an(e,t){return t==null?`None`:typeof t==`string`&&/At$|time|date/i.test(e)?k(t):typeof t==`object`?JSON.stringify(t):String(t)}function on(){let e=it(en,$t),t=e.data&&W(e.data.backup)?e.data.backup:null;return(0,J.jsxs)(X,{title:`Backups`,description:`The coordinator keeps all state in one SQLite database. Back it up from the machine that runs the coordinator.`,children:[(0,J.jsxs)(G,{title:`Back up`,children:[(0,J.jsx)(`p`,{className:`mb-2 text-sm`,children:`Writes a consistent copy of the database to a file while the coordinator keeps running.`}),(0,J.jsx)(ye,{text:tn,label:`Backup command`,copyLabel:`Copy command`})]}),(0,J.jsxs)(G,{title:`Restore`,children:[(0,J.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,J.jsx)(`code`,{className:`break-all`,children:`coordinator.db.bak-<ts>`}),`.`]}),(0,J.jsx)(ye,{text:nn,label:`Restore command`,copyLabel:`Copy command`}),(0,J.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,J.jsx)(G,{title:`Last backup`,children:e.fatal?(0,J.jsx)(re,{error:e.error}):e.error&&!e.loading&&!e.data?(0,J.jsx)(N,{compact:!0,title:`Could not load backup info`,error:e.error,onRetry:e.reload}):e.data?t&&Object.keys(t).length>0?(0,J.jsx)(Z,{items:Object.entries(t).map(([e,t])=>[rn(e),an(e,t)])}):(0,J.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,J.jsx)(T,{label:`Loading backup info…`})})]})}var sn={browser:`Browser`,pwa:`Home Screen app`,terminal:`Terminal`,cli:`CLI`},cn={granted:`allowed`,denied:`blocked`,default:`not requested`,unknown:`unknown`};function ln({kind:e}){return(0,J.jsx)(e===`pwa`?jt:e===`browser`?Ct:Ke,{"aria-hidden":!0,className:`mt-0.5 size-5 shrink-0 text-muted`})}function un(){let e=Q(),t=R(e=>e.devices);pe(e=>e.me);let n=fe(),r=(0,q.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,q.useState)(null),[o,s]=(0,q.useState)(``),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(null),[f,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(null),[y,b]=(0,q.useState)(null),S=async()=>{if(f){g(!0),v(null);try{await L(`/api/devices/${encodeURIComponent(f.id)}/revoke`),V.success(`${f.name} revoked`),m(null)}catch(e){v(e)}finally{g(!1)}}},C=async e=>{b(e.id);try{await x(`/api/devices/${encodeURIComponent(e.id)}`,{preferredMobile:!0}),V.success(`${e.name} is now the preferred mobile device`)}catch(e){V.error(`Could not set the preferred device: ${ue(e)}`)}finally{b(null)}},w=async()=>{if(!i)return;let e=o.trim();if(e){l(!0),d(null);try{await x(`/api/devices/${encodeURIComponent(i.id)}`,{name:e}),V.success(`Renamed to ${e}`),a(null)}catch(e){d(e)}finally{l(!1)}}};return(0,J.jsxs)(X,{testId:`settings-devices`,title:`Devices`,description:`Browsers, Home Screen apps and terminals signed in to this coordinator. Revoke one to sign it out.`,children:[(0,J.jsx)(P,{}),e?r.length===0?(0,J.jsx)(F,{icon:(0,J.jsx)(Dt,{className:`size-8`}),title:`No devices`,description:`Browsers and terminals appear here once they sign in.`}):(0,J.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:r.map(e=>{let t=e.id===n;return(0,J.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,J.jsx)(ln,{kind:e.kind}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.name}),t&&(0,J.jsx)(p,{icon:Ct,tone:`info`,label:`This device`}),e.preferredMobile&&(0,J.jsx)(p,{icon:Nt,tone:`success`,label:`Preferred mobile`})]}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-muted`,children:[(0,J.jsx)(`span`,{children:sn[e.kind]}),(0,J.jsxs)(`span`,{children:[`Last seen `,A(e.lastSeenAt)]}),(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e.push.subscribed?(0,J.jsx)(pt,{"aria-hidden":!0,className:`size-4 shrink-0`}):(0,J.jsx)(dt,{"aria-hidden":!0,className:`size-4 shrink-0`}),e.push.subscribed?`Push subscribed`:`No push subscription`,`, permission`,` `,cn[e.push.permission]]})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[!e.preferredMobile&&(0,J.jsx)(E,{size:`sm`,icon:(0,J.jsx)(Nt,{className:`size-4`}),busy:y===e.id,onClick:()=>C(e),children:`Set as preferred mobile device`}),(0,J.jsx)(E,{size:`sm`,variant:`ghost`,"data-testid":`device-rename`,icon:(0,J.jsx)(Fe,{className:`size-4`}),onClick:()=>{d(null),s(e.name),a(e)},children:`Rename`}),(0,J.jsx)(E,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,J.jsx)(kt,{className:`size-4`}),onClick:()=>{v(null),m(e)},children:`Revoke`})]})]},e.id)})}):(0,J.jsx)(T,{label:`Loading devices…`}),(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`The preferred mobile device receives push notifications when no desktop was recently active.`}),(0,J.jsx)(H,{open:i!==null,onClose:()=>a(null),title:`Rename device`,confirmLabel:`Save`,danger:!1,busy:c,error:u,confirmDisabled:!o.trim(),onConfirm:w,children:(0,J.jsx)(U,{"aria-label":`Device name`,maxLength:80,value:o,autoComplete:`off`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&o.trim()&&!c&&w()}})}),(0,J.jsxs)(H,{open:f!==null,onClose:()=>m(null),title:f?`Revoke ${f.name}?`:`Revoke device`,confirmLabel:`Revoke device`,busy:h,error:_,onConfirm:S,children:[(0,J.jsx)(`p`,{className:`text-sm`,children:`Its credential stops working immediately and its push subscription is removed. To use it again, sign in on it again.`}),f?.id===n&&(0,J.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 dn(){let e=Je(e=>e.sendWithEnter),t=Je(e=>e.collapseWork),n=Je(e=>e.set),r=Me(),i=Ae();pe(e=>e.me);let a=fe(),o=R(e=>a?e.devices[a]:void 0);return(0,J.jsxs)(X,{title:`This device`,description:`These preferences are stored in this browser only; your other devices keep their own.`,children:[(0,J.jsx)(G,{title:`Composer`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(at,{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=>n(`sendWithEnter`,e)}),(0,J.jsxs)(`p`,{className:`text-sm text-muted`,children:[`On mobile, Return always inserts a newline and messages are sent with the Send button.`,r===`mobile`||i?` That applies on this device now.`:``]})]})}),(0,J.jsx)(G,{title:`Transcript`,children:(0,J.jsx)(at,{label:`Fold finished turns`,description:`Collapse the tool calls and thinking of each finished turn into one line. The final reply always shows.`,checked:t,onChange:e=>n(`collapseWork`,e)})}),(0,J.jsx)(G,{title:`Identity`,children:(0,J.jsx)(Z,{items:[[`Name`,o?.name??`Unknown`],[`Kind`,o?sn[o.kind]:`Unknown`],[`Device ID`,(0,J.jsx)(`span`,{className:`break-all font-mono`,children:a??`Unknown`},`id`)]]})})]})}var $=e=>e==null||e===``?`Unknown`:String(e);function fn(){let e=it(en,$t),t=e.data,n=Xt(Array.isArray(t?.diagnostics)?t.diagnostics:void 0),r=R(e=>e.hosts),i=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(E,{icon:(0,J.jsx)(ve,{className:`size-4`}),disabled:!t,onClick:()=>t&&_e(JSON.stringify(t,null,2),`Diagnostics JSON copied`),children:`Copy diagnostics JSON`}),(0,J.jsx)(E,{busy:e.loading&&!!t,icon:(0,J.jsx)(ce,{className:`size-4`}),onClick:e.reload,children:`Refresh`})]}),a;if(e.fatal)a=(0,J.jsx)(re,{error:e.error,diagnosticsHref:`/settings/diagnostics`});else if(e.error&&!e.loading&&!t)a=(0,J.jsx)(N,{title:`Could not load diagnostics`,error:e.error,onRetry:e.reload});else if(!t)a=(0,J.jsx)(T,{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,J.jsxs)(J.Fragment,{children:[e.error&&!e.loading?(0,J.jsx)(N,{compact:!0,title:`Refresh failed`,error:e.error,onRetry:e.reload}):null,(0,J.jsx)(G,{title:`Versions`,children:(0,J.jsx)(`div`,{className:`overflow-x-auto`,children:(0,J.jsxs)(`table`,{className:`w-full min-w-0 text-left text-sm`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{className:`border-b border-border text-muted`,children:[(0,J.jsx)(`th`,{scope:`col`,className:`py-1 pr-4 font-medium`,children:`Component`}),(0,J.jsx)(`th`,{scope:`col`,className:`py-1 font-medium`,children:`Version`})]})}),(0,J.jsxs)(`tbody`,{children:[Object.entries(t.versions).map(([e,t])=>(0,J.jsxs)(`tr`,{className:`border-b border-border last:border-b-0`,children:[(0,J.jsx)(`th`,{scope:`row`,className:`py-1 pr-4 font-normal capitalize`,children:e}),(0,J.jsx)(`td`,{className:`py-1 font-mono break-all`,children:$(t)})]},e)),(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{scope:`row`,className:`py-1 pr-4 font-normal`,children:`Supported Pi`}),(0,J.jsx)(`td`,{className:`py-1 font-mono`,children:y})]})]})]})})}),(0,J.jsx)(G,{title:`Coordinator`,children:(0,J.jsx)(Z,{items:[[`Database migration`,(0,J.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`span`,{children:[`Level `,$(t.migrationLevel),` of `,$(t.latestMigration)]}),i?(0,J.jsx)(p,{icon:Ne,tone:`success`,label:`Up to date`}):(0,J.jsx)(p,{icon:I,tone:`warning`,label:`Behind latest`})]},`m`)],[`Public URL`,(0,J.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,J.jsx)(G,{title:`Hosts`,children:o.length===0?(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`No hosts enrolled.`}):(0,J.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:o.map(e=>{let t=r[e.id];return(0,J.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1 py-2 text-sm`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,J.jsx)(m,{kind:`host`,value:t?.connectivity??e.connectivity}),(0,J.jsx)(zt,{host:e})]}),(0,J.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Agent `,$(e.agentVersion),` · Last seen `,A(e.lastSeenAt)]}),e.unsupported&&e.unsupported.length>0&&(0,J.jsx)(`ul`,{className:`list-disc pl-5 text-xs text-muted`,children:e.unsupported.map(e=>(0,J.jsxs)(`li`,{className:`break-words`,children:[e.capability,`: `,e.reason]},e.capability))})]},e.id)})})}),(0,J.jsx)(G,{title:`Recent diagnostics`,children:n.length===0?(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`No diagnostics recorded.`}):(0,J.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:n.slice(0,100).map((e,t)=>(0,J.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-2 text-sm`,children:[(0,J.jsx)(Yt,{level:e.level}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[e.message,e.adapterId&&(0,J.jsxs)(`span`,{className:`block text-xs text-muted`,children:[`Adapter `,e.adapterId]})]}),(0,J.jsx)(`time`,{dateTime:e.at,className:`text-xs text-muted`,children:k(e.at)})]},`${e.at}-${t}`))})})]})}return(0,J.jsxs)(X,{title:`Diagnostics`,description:`Versions, database state, hosts and recent problems. Copy the JSON when reporting a problem.`,actions:i,children:[(0,J.jsx)(P,{}),a]})}function pn(e){return L(`/api/enrollments`,{kind:e})}function mn({expiresAt:e,onRenew:t,busy:n}){let r=Ut(e);return r!==null&&r<=0?(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,role:`status`,children:[(0,J.jsx)(I,{"aria-hidden":!0,className:`size-4 shrink-0 text-warning`}),(0,J.jsx)(`span`,{className:`font-medium`,children:`Expired: create a new link`}),(0,J.jsx)(E,{size:`sm`,busy:n,icon:(0,J.jsx)(ce,{className:`size-4`}),onClick:t,children:`Create new link`})]}):(0,J.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted`,children:[(0,J.jsx)(Oe,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,J.jsxs)(`span`,{children:[`Expires in`,` `,(0,J.jsx)(`span`,{className:`font-mono tabular-nums`,children:r===null?`unknown`:Wt(r)}),`. Single use.`]})]})}function hn({busy:e,error:t,onRetry:n}){return e?(0,J.jsx)(T,{label:`Creating a single-use link…`}):t?(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(S,{error:t}),(0,J.jsx)(E,{icon:(0,J.jsx)(ce,{className:`size-4`}),onClick:n,children:`Retry`})]}):null}function gn(e){let t=Ht(e),n=t.find(e=>!ie(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 _n(e,t=Date.now()){return e?e.state===`running`?`Scanning…`:e.state===`failed`?`Last scan failed ${A(e.finishedAt??e.startedAt,t)}: ${e.errors.at(-1)??`unknown error`}`:`Last scanned ${A(e.finishedAt,t)}: ${e.repositories} repositories, ${e.checkoutsAdded} new checkouts, ${e.projectsCreated} new projects.`:`Not scanned yet.`}function vn({host:e}){let t=(0,q.useId)(),n=(e.projectFolders??[]).join(`
|
|
3
|
+
`),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(null),d=r??n,f=r!==null&&r!==n,{folders:p,problem:m}=gn(d),h=e.projectScan,g=s||h?.state===`running`,_=e.connectivity===`connected`,v=n?_?g?`A scan is running`:null:`${e.name} is offline`:`Save a folder first`,y=async()=>{o(!0),u(null);try{await x(`/api/hosts/${encodeURIComponent(e.id)}`,{projectFolders:p}),V.success(`Project folders saved`),i(null)}catch(e){u(e)}finally{o(!1)}},b=async()=>{c(!0),u(null);try{let t=await L(`/api/hosts/${encodeURIComponent(e.id)}/scan-projects`);V.success(`Found ${t.repositories} repositories; ${t.projectsCreated} new projects`)}catch(e){u(e)}finally{c(!1)}},C=f?m:null;return(0,J.jsx)(G,{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,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,J.jsx)(B,{id:`${t}-folders`,label:`Folders on this host`,hint:`One per line: an absolute path or ~/..., e.g. ~/Projects.`,error:C,children:(0,J.jsx)(nt,{id:`${t}-folders`,value:d,onChange:e=>i(e.target.value),minRows:3,placeholder:`~/Projects`,className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,autoComplete:`off`,...z(`${t}-folders`,{hint:!0,error:C})})}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(E,{variant:`primary`,icon:(0,J.jsx)(Ve,{className:`size-4`}),busy:a,disabled:!f||!!m,onClick:y,children:`Save folders`}),(0,J.jsx)(E,{icon:(0,J.jsx)(yt,{className:`size-4`}),busy:s,disabled:!!v,title:v??void 0,onClick:b,children:`Scan now`})]}),(0,J.jsx)(`p`,{"aria-live":`polite`,className:`text-sm text-muted`,children:s?`Scanning…`:_n(h)}),h&&h.state!==`running`&&h.errors.length>0&&(0,J.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-0.5 text-xs text-muted`,children:h.errors.map(e=>(0,J.jsx)(`li`,{className:`break-words`,children:e},e))}),(0,J.jsx)(S,{error:l})]})})}var yn={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 bn(){let e=Q(),t=g(),[n,r]=(0,q.useState)(!1),i=t.filter(e=>e.connectivity!==`connected`);return(0,J.jsxs)(X,{testId:`settings-hosts`,title:`Hosts`,description:`Machines that run Pi sessions through the Switchyard host agent.`,actions:(0,J.jsx)(E,{variant:`primary`,icon:(0,J.jsx)(Le,{className:`size-4`}),onClick:()=>r(!0),children:`Add host`}),children:[(0,J.jsx)(P,{}),e?t.length===0?(0,J.jsx)(F,{icon:(0,J.jsx)(Ge,{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,J.jsxs)(J.Fragment,{children:[i.length===1&&(0,J.jsx)(M,{compact:!0,hostName:i[0].name,connectivity:i[0].connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:i[0].lastSeenAt}),i.length>1&&(0,J.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border border-border bg-danger-soft px-3 py-2 text-sm`,children:[(0,J.jsx)(le,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-danger`}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`font-medium`,children:xn(i.map(e=>e.name))}),(0,J.jsx)(`div`,{className:`text-muted`,children:`Work on them keeps its last known state; nothing is restarted elsewhere.`})]})]}),(0,J.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:t.map(e=>(0,J.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,J.jsx)(Sn,{host:e})},e.id))})]}):(0,J.jsx)(T,{label:`Loading hosts…`}),(0,J.jsx)(Tn,{open:n,onClose:()=>r(!1)})]})}function xn(e){return`${e.length} hosts are not connected: ${e.join(`, `)}`}function Sn({host:e}){return(0,J.jsxs)(r,{to:Y(`hosts/${encodeURIComponent(e.id)}`),state:Be,className:`tap flex min-w-0 items-center gap-3 px-4 py-3 hover:bg-surface-2`,children:[(0,J.jsx)(Ge,{"aria-hidden":!0,className:`size-5 shrink-0 self-center text-muted`}),(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.name}),(0,J.jsx)(`span`,{className:`text-sm text-muted`,children:Rt[e.platform]})]}),(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsx)(m,{kind:`host`,value:e.connectivity}),(0,J.jsx)(zt,{host:e}),e.connectivity!==`connected`&&(0,J.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Last seen `,A(e.lastSeenAt)]})]})]}),(0,J.jsx)(De,{"aria-hidden":!0,className:`size-4 shrink-0 self-center text-subtle`})]})}var Cn=`@spencerboucher/switchyard`;function wn(e){return[`npm install -g ${Cn}`,e,`switchyard host install-service`].join(`
|
|
4
|
+
`)}function Tn({open:e,onClose:t}){let[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(null),c=async()=>{a(!0),s(null);try{r(await pn(`host`))}catch(e){s(e)}finally{a(!1)}},l=()=>{r(null),s(null),t()};return(0,J.jsx)(tt,{open:e,onClose:l,title:`Add host`,description:`Enroll a machine that runs Pi. Provider credentials stay on that machine.`,footer:(0,J.jsx)(E,{onClick:l,children:`Done`}),children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!n&&!i&&!o&&(0,J.jsxs)(J.Fragment,{children:[(0,J.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,J.jsx)(E,{variant:`primary`,onClick:c,children:`Create enrollment command`})]}),(0,J.jsx)(hn,{busy:i,error:o,onRetry:c}),n&&!i&&(0,J.jsxs)(J.Fragment,{children:[(0,J.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,J.jsx)(ye,{text:n.command?wn(n.command):n.url,label:n.command?`Host setup commands`:`Host enrollment link`,copyLabel:`Copy commands`}),(0,J.jsx)(mn,{expiresAt:n.expiresAt,onRenew:c,busy:i})]})]})})}function En(){let{hostId:e=``}=c(),t=Q(),r=R(t=>t.hosts[e]),i=R(t=>t.adapters[e]),a=R(e=>e.checkouts),o=R(e=>e.projects),s=n(),[l,u]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),[h,g]=(0,q.useState)(null),_=(0,q.useMemo)(()=>Object.values(a).filter(t=>t.hostId===e).sort((e,t)=>e.path.localeCompare(t.path)),[a,e]),v={to:Y(`hosts`),label:`Hosts`};if(!t)return(0,J.jsx)(X,{title:`Host`,back:v,children:(0,J.jsx)(T,{label:`Loading host…`})});if(!r||r.revokedAt)return(0,J.jsx)(X,{title:`Host`,back:v,children:(0,J.jsx)(F,{icon:(0,J.jsx)(Ge,{className:`size-8`}),title:r?`This host was revoked`:`Host not found`,description:r?`${r.name} was revoked ${A(r.revokedAt)}. Add it again to use it.`:`It may have been revoked or never enrolled with this coordinator.`,action:{label:`Back to hosts`,to:Y(`hosts`)}})});let y=async()=>{p(!0),g(null);try{await L(`/api/hosts/${encodeURIComponent(r.id)}/revoke`),V.success(`Host ${r.name} revoked`),u(!1),s(Y(`hosts`))}catch(e){g(e)}finally{p(!1)}},b=r.capabilities,x=e=>b?.unsupported.find(t=>t.capability===e)?.reason,S=b?.unsupported.filter(e=>!C.includes(e.capability))??[];return(0,J.jsxs)(X,{title:r.name,description:`${Rt[r.platform]} host`,back:v,children:[(0,J.jsx)(P,{}),r.connectivity!==`connected`&&(0,J.jsx)(M,{compact:!0,hostName:r.name,connectivity:r.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:r.lastSeenAt}),(0,J.jsx)(G,{title:`Connectivity and versions`,children:(0,J.jsx)(Z,{items:[[`Status`,(0,J.jsx)(m,{kind:`host`,value:r.connectivity},`s`)],[`Last seen`,r.lastSeenAt?`${A(r.lastSeenAt)} (${k(r.lastSeenAt)})`:`Never`],[`Platform`,Rt[r.platform]],[`Agent version`,(0,J.jsx)(`span`,{className:`font-mono`,children:r.agentVersion},`a`)],[`Pi`,(0,J.jsx)(zt,{host:r},`p`)],[`Enrolled`,k(r.createdAt)]]})}),r.usage&&r.usage.length>0&&(0,J.jsx)(G,{title:`Subscription usage`,children:(0,J.jsx)(Z,{items:r.usage.map(e=>[e.provider===`anthropic`?`Claude`:`ChatGPT`,e.status===`available`?e.windows.map(e=>`${e.id===`five_hour`?`Session`:`Weekly`} ${Math.round(e.usedPct)}% used, resets ${A(e.resetsAt)}`).join(`; `)||`No limits reported`:e.message??e.status])})}),(0,J.jsx)(G,{title:`Capabilities`,description:`What Pi on this host supports. Unsupported features are hidden or explained in sessions.`,children:b?(0,J.jsxs)(`ul`,{className:`grid min-w-0 gap-2 sm:grid-cols-2`,children:[C.map(e=>{let t=b[e],n=x(e);return(0,J.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[t?(0,J.jsx)(Ne,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-success`}):(0,J.jsx)(d,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:yn[e]}),(0,J.jsxs)(`span`,{className:`text-muted`,children:[`: `,t?`Supported`:`Not supported`]}),!t&&n&&(0,J.jsx)(`span`,{className:`block break-words text-xs text-muted`,children:n})]})]},e)}),S.map(e=>(0,J.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[(0,J.jsx)(d,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`font-medium break-words`,children:e.capability}),(0,J.jsx)(`span`,{className:`text-muted`,children:`: Not supported`}),(0,J.jsx)(`span`,{className:`block break-words text-xs text-muted`,children:e.reason})]})]},e.capability))]}):(0,J.jsx)(oe,{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,J.jsx)(vn,{host:r}),(0,J.jsx)(G,{title:`Checkout mappings`,description:`Project clones on this host. Sessions and runs for a project use these paths.`,children:_.length===0?(0,J.jsx)(F,{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:Y(`projects`)}}):(0,J.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:_.map(e=>(0,J.jsxs)(`li`,{className:`min-w-0 py-2 text-sm`,children:[(0,J.jsx)(rt,{to:Y(`projects/${encodeURIComponent(e.projectId)}`),variant:`action`,children:o[e.projectId]?.name??`Unknown project`}),(0,J.jsx)(`div`,{className:`break-all font-mono text-xs`,children:e.path}),(0,J.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Default branch: `,e.defaultBranch]})]},e.id))})}),(0,J.jsx)(G,{title:`Adapters`,actions:(0,J.jsx)(rt,{to:Y(`adapters`),size:`sm`,variant:`action`,children:`All adapters`}),children:!i||i.length===0?(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`No adapters reported by this host.`}):(0,J.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:i.map(e=>(0,J.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm`,children:[(0,J.jsx)(`span`,{className:`break-all font-mono`,children:e.id}),(0,J.jsx)(`span`,{className:`text-muted`,children:e.version}),(0,J.jsx)(Kt,{status:e.status})]},e.id))})}),(0,J.jsx)(He,{description:`Revoking disconnects the host agent and invalidates its credential. Sessions on it are not moved elsewhere.`,children:(0,J.jsx)(E,{variant:`danger`,icon:(0,J.jsx)(kt,{className:`size-4`}),onClick:()=>{g(null),u(!0)},children:`Revoke host`})}),(0,J.jsx)(H,{open:l,onClose:()=>u(!1),title:`Revoke ${r.name}?`,confirmLabel:`Revoke host`,busy:f,error:h,onConfirm:y,children:(0,J.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 Dn={granted:{icon:pt,label:`Allowed`,tone:`success`,guidance:`This device can show Switchyard notifications.`},denied:{icon:dt,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:ge,label:`Not requested yet`,tone:`neutral`,guidance:`Enable notifications to hear about sessions that need input, failed, or are ready for review.`},unknown:{icon:ge,label:`Unknown`,tone:`neutral`,guidance:`The browser did not report a permission state. Try enabling notifications.`},unsupported:{icon:d,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 On(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{return`UTC`}}function kn(e){let t=W(e)&&W(e.settings)?e.settings:e;return!W(t)||typeof t.privatePreviews!=`boolean`?null:{quietHours:W(t.quietHours)?t.quietHours:null,privatePreviews:t.privatePreviews,preferredDeviceId:typeof t.preferredDeviceId==`string`?t.preferredDeviceId:null}}function An(){let[e,t]=(0,q.useState)(()=>Ye()),[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(null),c=Xe()&&!Qe();(0,q.useEffect)(()=>{let e=!0;et().then(t=>e&&r(t!==null)).catch(()=>e&&r(!1));let n=()=>{document.visibilityState===`visible`&&t(Ye())};return document.addEventListener(`visibilitychange`,n),()=>{e=!1,document.removeEventListener(`visibilitychange`,n)}},[]);let l=()=>{a(`enable`),s(null),Ze().then(e=>{t(e),e===`granted`?(r(!0),V.success(`Notifications enabled on this device`)):e===`denied`&&V.error(`Notifications were blocked. Allow them in your browser settings.`)}).catch(e=>{s(e),t(Ye())}).finally(()=>a(null))},u=async()=>{a(`disable`),s(null);try{await $e(),r(!1),V.success(`Notifications disabled on this device`)}catch(e){s(e)}finally{a(null)}},d=async()=>{a(`test`),s(null);try{await qe(),V.success(`Test notification sent. It can take a few seconds to arrive.`)}catch(e){s(e),V.error(`Test notification failed: ${ue(e)}`)}finally{a(null)}},f=Dn[e]??Dn.unknown;return(0,J.jsxs)(X,{testId:`settings-notifications`,title:`Notifications`,description:`Push notifications for sessions that need input, failed, or are ready for review.`,children:[(0,J.jsx)(G,{title:`This device`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:`Permission:`}),(0,J.jsx)(p,{icon:f.icon,label:f.label,tone:f.tone}),n!==null&&e===`granted`&&(0,J.jsx)(`span`,{className:`text-muted`,children:n?`Subscribed to push`:`Not subscribed to push`})]}),(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:f.guidance}),c&&(0,J.jsxs)(`div`,{className:`rounded-md border border-border bg-surface-2 p-3 text-sm`,children:[(0,J.jsxs)(`p`,{className:`mb-2 flex items-center gap-2 font-medium`,children:[(0,J.jsx)(jt,{"aria-hidden":!0,className:`size-4 shrink-0`}),`On iPhone and iPad, notifications need the Home Screen app`]}),(0,J.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,J.jsx)(`li`,{children:`Tap Share`}),(0,J.jsx)(`li`,{children:`Add to Home Screen`}),(0,J.jsx)(`li`,{children:`Open Switchyard from the Home Screen`}),(0,J.jsx)(`li`,{children:`Enable notifications here`})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e!==`unsupported`&&!(e===`granted`&&n)&&(0,J.jsx)(E,{variant:`primary`,icon:(0,J.jsx)(pt,{className:`size-4`}),busy:i===`enable`,disabled:i!==null&&i!==`enable`,onClick:l,children:`Enable notifications`}),n&&(0,J.jsx)(E,{icon:(0,J.jsx)(dt,{className:`size-4`}),busy:i===`disable`,disabled:i!==null&&i!==`disable`,onClick:u,children:`Disable on this device`}),(0,J.jsx)(E,{icon:(0,J.jsx)(be,{className:`size-4`}),busy:i===`test`,disabled:i!==null&&i!==`test`,onClick:d,children:`Send test notification`})]}),e===`unsupported`&&(0,J.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,J.jsx)(S,{error:o}),(0,J.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,J.jsx)(jn,{})]})}function jn(){let e=it(`/api/me/notification-settings`,e=>!!kn(e)),t=(0,q.useMemo)(()=>e.data?kn(e.data):null,[e.data]),n=e.error instanceof ne&&e.error.status===404;return(0,J.jsx)(G,{title:`Delivery preferences`,description:`Shared by all your devices. Attention items in Switchyard are unaffected.`,children:n?(0,J.jsx)(oe,{capability:`Notification settings`,reason:`This coordinator does not expose notification settings yet`}):e.fatal?(0,J.jsx)(re,{error:e.error}):e.error&&!e.loading&&!t?(0,J.jsx)(N,{compact:!0,title:`Could not load notification settings`,error:e.error,onRetry:e.reload}):t?(0,J.jsx)(Nn,{settings:t,onSaved:t=>e.setData(t)}):(0,J.jsx)(T,{label:`Loading notification settings…`})})}var Mn=/^\d{2}:\d{2}$/;function Nn({settings:e,onSaved:t}){let n=(0,q.useId)(),r=R(e=>e.devices),i=(0,q.useMemo)(()=>Object.values(r).filter(e=>e.revokedAt===null).sort((e,t)=>e.name.localeCompare(t.name)),[r]),[a,o]=(0,q.useState)(e.quietHours!==null),[s,c]=(0,q.useState)(e.quietHours?.start??`22:00`),[l,u]=(0,q.useState)(e.quietHours?.end??`07:00`),[d,f]=(0,q.useState)(e.quietHours?.timezone??On()),[p,m]=(0,q.useState)(e.privatePreviews),[h,g]=(0,q.useState)(e.preferredDeviceId??``),[_,v]=(0,q.useState)(!1),[y,b]=(0,q.useState)(null),C=a&&!Mn.test(s)?`Use a time like 22:00.`:null,w=a&&!Mn.test(l)?`Use a time like 07:00.`:null,T=a&&!d.trim()?`Enter a time zone, e.g. Europe/Berlin.`:null,D=!h||i.some(e=>e.id===h);return(0,J.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:h||null};v(!0),b(null);try{t(kn(await x(`/api/me/notification-settings`,n))??n),V.success(`Notification preferences saved`)}catch(e){b(e)}finally{v(!1)}},noValidate:!0,children:[(0,J.jsx)(at,{label:`Quiet hours`,description:`No push notifications during these hours. Attention items still collect in Switchyard.`,checked:a,onChange:o}),a&&(0,J.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-3`,children:[(0,J.jsx)(B,{id:`${n}-start`,label:`From`,error:C,children:(0,J.jsx)(U,{id:`${n}-start`,type:`time`,value:s,onChange:e=>c(e.target.value),...z(`${n}-start`,{error:C})})}),(0,J.jsx)(B,{id:`${n}-end`,label:`Until`,error:w,children:(0,J.jsx)(U,{id:`${n}-end`,type:`time`,value:l,onChange:e=>u(e.target.value),...z(`${n}-end`,{error:w})})}),(0,J.jsx)(B,{id:`${n}-tz`,label:`Time zone`,error:T,children:(0,J.jsx)(U,{id:`${n}-tz`,value:d,onChange:e=>f(e.target.value),autoCapitalize:`off`,spellCheck:!1,...z(`${n}-tz`,{error:T})})})]}),(0,J.jsx)(at,{label:`Private previews`,description:`Hide task and session text in notifications; show only the status, e.g. Needs input.`,checked:p,onChange:m}),(0,J.jsx)(B,{id:`${n}-device`,label:`Preferred device`,hint:`Receives push when no desktop was recently active.`,children:(0,J.jsxs)(K,{id:`${n}-device`,value:h,onChange:e=>g(e.target.value),...z(`${n}-device`,{hint:!0}),children:[(0,J.jsx)(`option`,{value:``,children:`Automatic (the preferred mobile device)`}),i.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.name,e.push.subscribed?``:` (no push subscription)`]},e.id)),!D&&(0,J.jsxs)(`option`,{value:h,children:[`Unknown device (`,h,`)`]})]})}),(0,J.jsx)(S,{error:y}),(0,J.jsx)(`div`,{children:(0,J.jsx)(E,{type:`submit`,variant:`primary`,busy:_,icon:(0,J.jsx)(Ve,{className:`size-4`}),children:`Save preferences`})})]})}var Pn={ask:`Ask`,approve:`Approve`,ignore:`Ignore`},Fn={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.`},In=se.options,Ln={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 Rn(e){let t=[];return e.forEach((e,n)=>{let r=ae.safeParse(e);r.success||t.push(`Line ${n+1} (${e}): ${r.error.issues[0]?.message??`invalid argument`}`)}),t}function zn(){let e=Q(),t=R(e=>e.profiles),n=R(e=>e.projects),r=(0,q.useMemo)(()=>Object.values(t).sort((e,t)=>e.name.localeCompare(t.name)),[t]),[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(null),f=async()=>{if(o){l(!0),d(null);try{await j(`/api/profiles/${encodeURIComponent(o.id)}`),V.success(`Profile ${o.name} deleted`),s(null)}catch(e){d(e)}finally{l(!1)}}},p=e=>Object.values(n).filter(t=>t.defaultProfileId===e).map(e=>e.name);return(0,J.jsxs)(X,{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,J.jsx)(E,{variant:`primary`,icon:(0,J.jsx)(Le,{className:`size-4`}),onClick:()=>a(`new`),children:`New profile`}),children:[(0,J.jsx)(P,{}),e?r.length===0?(0,J.jsx)(F,{icon:(0,J.jsx)(xe,{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,J.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:r.map(e=>{let t=p(e.id);return(0,J.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,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 text-sm`,children:[(0,J.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,J.jsxs)(`span`,{className:`break-words text-muted`,children:[e.provider??`Default provider`,` / `,e.model??`default model`,` · Thinking`,` `,e.thinking??`default`,` · Project trust `,Pn[e.projectTrust],e.resources===`vanilla`&&` · Vanilla Pi`]}),e.extraArgs.length>0&&(0,J.jsx)(`span`,{className:`break-all font-mono text-xs text-muted`,children:e.extraArgs.join(` `)}),t.length>0&&(0,J.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Default for `,t.join(`, `)]})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(E,{size:`sm`,icon:(0,J.jsx)(Fe,{className:`size-4`}),onClick:()=>a(e),children:`Edit`}),(0,J.jsx)(E,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,J.jsx)(he,{className:`size-4`}),onClick:()=>{d(null),s(e)},children:`Delete`})]})]},e.id)})}):(0,J.jsx)(T,{label:`Loading profiles…`}),i&&(0,J.jsx)(Bn,{profile:i===`new`?null:i,onClose:()=>a(null)},i===`new`?`new`:i.id),(0,J.jsx)(H,{open:o!==null,onClose:()=>s(null),title:o?`Delete ${o.name}?`:`Delete profile`,confirmLabel:`Delete profile`,busy:c,error:u,onConfirm:f,children:(0,J.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 Bn({profile:e,onClose:t}){let n=(0,q.useId)(),[r,i]=(0,q.useState)(e?.name??``),[a,o]=(0,q.useState)(e?.provider??``),[s,c]=(0,q.useState)(e?.model??``),[l,u]=(0,q.useState)(e?.thinking??``),[d,f]=(0,q.useState)(e?.projectTrust??`ask`),[p,m]=(0,q.useState)(e?.resources??`all`),[h,g]=(0,q.useState)((e?.extraArgs??[]).join(`
|
|
5
|
+
`)),[_,v]=(0,q.useState)(!1),[y,b]=(0,q.useState)(!1),[C,w]=(0,q.useState)(null),T=Ht(h),D=Rn(T),O=_&&!r.trim()?`Enter a profile name.`:null,k=D.length?D.join(`
|
|
6
|
+
`):null,A=async n=>{if(n.preventDefault(),v(!0),!r.trim()||D.length)return;let i={name:r.trim(),provider:a.trim()||null,model:s.trim()||null,thinking:l||null,projectTrust:d,resources:p,extraArgs:T};b(!0),w(null);try{e?(await x(`/api/profiles/${encodeURIComponent(e.id)}`,i),V.success(`Profile ${i.name} saved`)):(await L(`/api/profiles`,i),V.success(`Profile ${i.name} created`)),t()}catch(e){w(e)}finally{b(!1)}},j=`${n}-form`;return(0,J.jsx)(tt,{open:!0,onClose:y?()=>void 0:t,dismissOnBackdrop:!y,title:e?`Edit ${e.name}`:`New profile`,footer:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(E,{onClick:t,disabled:y,children:`Cancel`}),(0,J.jsx)(E,{type:`submit`,form:j,variant:`primary`,busy:y,children:e?`Save profile`:`Create profile`})]}),children:(0,J.jsxs)(`form`,{id:j,className:`flex min-w-0 flex-col gap-4`,onSubmit:A,noValidate:!0,children:[(0,J.jsx)(B,{id:`${n}-name`,label:`Name`,error:O,children:(0,J.jsx)(U,{id:`${n}-name`,value:r,onChange:e=>i(e.target.value),...z(`${n}-name`,{error:O})})}),(0,J.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,J.jsx)(B,{id:`${n}-provider`,label:`Provider`,hint:`Empty uses Pi's default.`,children:(0,J.jsx)(U,{id:`${n}-provider`,value:a,onChange:e=>o(e.target.value),placeholder:`anthropic`,autoCapitalize:`off`,spellCheck:!1,...z(`${n}-provider`,{hint:!0})})}),(0,J.jsx)(B,{id:`${n}-model`,label:`Model`,hint:`Empty uses Pi's default.`,children:(0,J.jsx)(U,{id:`${n}-model`,value:s,onChange:e=>c(e.target.value),autoCapitalize:`off`,spellCheck:!1,...z(`${n}-model`,{hint:!0})})})]}),(0,J.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,J.jsx)(B,{id:`${n}-thinking`,label:`Thinking`,children:(0,J.jsxs)(K,{id:`${n}-thinking`,value:l,onChange:e=>u(e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:`Default (none)`}),In.map(e=>(0,J.jsx)(`option`,{value:e,children:e},e))]})}),(0,J.jsx)(B,{id:`${n}-trust`,label:`Project trust`,hint:Fn[d],children:(0,J.jsx)(K,{id:`${n}-trust`,value:d,onChange:e=>f(e.target.value),...z(`${n}-trust`,{hint:!0}),children:Object.keys(Pn).map(e=>(0,J.jsx)(`option`,{value:e,children:Pn[e]},e))})})]}),(0,J.jsx)(B,{id:`${n}-resources`,label:`Resources`,hint:Ln[p],children:(0,J.jsxs)(K,{id:`${n}-resources`,value:p,onChange:e=>m(e.target.value),...z(`${n}-resources`,{hint:!0}),children:[(0,J.jsx)(`option`,{value:`all`,children:`Your Pi setup`}),(0,J.jsx)(`option`,{value:`vanilla`,children:`Vanilla Pi`})]})}),(0,J.jsx)(B,{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,J.jsx)(nt,{id:`${n}-extra`,value:h,minRows:3,onChange:e=>g(e.target.value),className:`font-mono`,autoCapitalize:`off`,spellCheck:!1,...z(`${n}-extra`,{hint:!0,error:k})})}),(0,J.jsx)(S,{error:C})]})})}var Vn={managed:`Managed by Switchyard`,discovered:`Discovered worktree`,main:`Main checkout`},Hn={none:{icon:h,label:`No setup`,tone:`neutral`},running:{icon:f,label:`Setup running`,tone:`info`},succeeded:{icon:Ne,label:`Setup succeeded`,tone:`success`},failed:{icon:ke,label:`Setup failed`,tone:`danger`}};function Un(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 Wn({project:e}){let t=R(e=>e.workspaces),n=R(e=>e.hosts),r=(0,q.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,q.useState)(null),[o,s]=(0,q.useState)(null),c=async e=>{s(e.id);try{await L(`/api/workspaces/${encodeURIComponent(e.id)}/refresh`),V.success(`Workspace status refreshed`)}catch(e){V.error(`Could not refresh: ${ue(e)}`)}finally{s(null)}};return(0,J.jsxs)(G,{title:`Workspaces`,description:`Worktrees where sessions and runs work. Removing one never deletes its branch.`,children:[r.length===0?(0,J.jsx)(F,{className:`py-4`,title:`No workspaces`,description:`Workspaces appear after a checkout is discovered. Use Refresh to discover them again.`}):(0,J.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=Hn[e.setup.state]??Hn.none;return(0,J.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1.5 py-3 text-sm`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsx)(Pe,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),(0,J.jsx)(`span`,{className:`min-w-0 break-all font-mono font-medium`,children:e.branch??`(detached HEAD)`}),(0,J.jsx)(`span`,{className:`text-xs text-muted`,children:Vn[e.provenance]})]}),(0,J.jsxs)(`div`,{className:`break-all font-mono text-xs text-muted`,children:[t?.name?`${t.name}: `:``,e.path]}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsx)(`span`,{children:Un(e.git)}),(0,J.jsx)(p,{icon:i.icon,label:i.label,tone:i.tone,spin:e.setup.state===`running`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(E,{size:`sm`,icon:(0,J.jsx)(ce,{className:`size-4`}),busy:o===e.id,disabled:r,onClick:()=>c(e),children:`Refresh status`}),e.provenance!==`main`&&(0,J.jsx)(E,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,J.jsx)(he,{className:`size-4`}),disabled:r,onClick:()=>a(e),children:`Remove`}),e.provenance===`main`&&(0,J.jsx)(`span`,{className:`text-xs text-muted`,children:`The main checkout cannot be removed; remove the project's checkout instead.`}),r&&(0,J.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,J.jsx)(Gn,{workspace:t[i.id]??i,onClose:()=>a(null)},i.id)]})}function Gn({workspace:e,onClose:t}){let[n,r]=(0,q.useState)(e.git.dirty),[i,a]=(0,q.useState)(e.git.unmerged),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(null),m=n&&!o||i&&!c;return(0,J.jsxs)(H,{open:!0,onClose:t,title:`Remove workspace?`,description:(0,J.jsx)(`span`,{className:`break-all font-mono`,children:e.branch??e.path}),confirmLabel:`Remove workspace`,busy:u,error:f,onConfirm:async()=>{d(!0),p(null);try{await L(`/api/workspaces/${encodeURIComponent(e.id)}/remove`,{force:{dirty:o,unmerged:c}}),V.success(`Workspace ${e.branch??e.path} removed`),t()}catch(e){w(e,`workspace_dirty`)&&r(!0),w(e,`workspace_unmerged`)&&a(!0),p(e)}finally{d(!1)}},confirmDisabled:m,disabledReason:`Check the boxes above to confirm what will be lost.`,children:[(0,J.jsxs)(`p`,{className:`text-sm`,children:[`The worktree at `,(0,J.jsx)(`span`,{className:`break-all font-mono`,children:e.path}),` is deleted from the host. The branch is kept.`]}),n&&(0,J.jsx)(We,{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,J.jsx)(We,{label:`Remove although the branch is not merged`,description:`Commits stay on the branch, but the workspace is gone.`,checked:c,onChange:l})]})}var Kn=`Inside the repository, for example .worktrees or .git/worktrees-switchyard`;function qn(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 ..).`:D.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 Jn(){let{projectId:e=``}=c(),t=Q(),n=R(t=>t.projects[e]),r=R(e=>e.hosts),i=R(e=>e.profiles),[a,o]=(0,q.useState)(!1),[s,l]=(0,q.useState)([]),u=g(),d=(0,q.useMemo)(()=>Object.values(i).sort((e,t)=>e.name.localeCompare(t.name)),[i]),f={to:Y(`projects`),label:`Projects`};return t?n?(0,J.jsxs)(X,{title:n.name,description:(0,J.jsx)(`span`,{className:`break-all`,title:n.repoIdentity,children:Se(n.repoIdentity)}),back:f,actions:(0,J.jsx)(E,{busy:a,icon:(0,J.jsx)(ce,{className:`size-4`}),onClick:async()=>{o(!0);try{let e=await L(`/api/projects/${encodeURIComponent(n.id)}/refresh`),t=Array.isArray(e?.errors)?e.errors:[];l(t),t.length?V.error(`Refreshed with ${t.length} checkout error(s)`):V.success(`Workspaces refreshed`)}catch(e){V.error(`Refresh failed: ${ue(e)}`)}finally{o(!1)}},children:`Refresh`}),children:[(0,J.jsx)(P,{}),s&&s.length>0&&(0,J.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-border bg-danger-soft px-3 py-2 text-sm`,children:[(0,J.jsx)(`p`,{className:`font-medium`,children:`Some checkouts could not be refreshed`}),(0,J.jsx)(`ul`,{className:`list-disc pl-5`,children:s.map(e=>(0,J.jsx)(`li`,{className:`break-words`,children:e.message},e.checkoutId))})]}),(0,J.jsx)(Yn,{project:n,hosts:u,profiles:d},n.id),(0,J.jsx)(Xn,{project:n,hosts:u,hostsById:r}),(0,J.jsx)(Wn,{project:n})]}):(0,J.jsx)(X,{title:`Project`,back:f,children:(0,J.jsx)(F,{icon:(0,J.jsx)(Ce,{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:Y(`projects`)}})}):(0,J.jsx)(X,{title:`Project`,back:f,children:(0,J.jsx)(T,{label:`Loading project…`})})}function Yn({project:e,hosts:t,profiles:n}){let r=(0,q.useId)(),[i,a]=(0,q.useState)(e.name),[o,s]=(0,q.useState)(e.setupCommand??``),[c,l]=(0,q.useState)(e.checks.join(`
|
|
7
|
+
`)),[u,d]=(0,q.useState)(String(e.maxConcurrentRuns)),[f,p]=(0,q.useState)(e.automationEnabled),[m,h]=(0,q.useState)(e.workspaceSharing),[g,_]=(0,q.useState)(e.defaultProfileId??``),[v,y]=(0,q.useState)(e.defaultHostId??``),[b,C]=(0,q.useState)(e.worktreeDir??`.worktrees`),[w,T]=(0,q.useState)(!1),[D,O]=(0,q.useState)(null),k=Number(u),A=i.trim()?null:`Enter a project name.`,j=Number.isInteger(k)&&k>=1&&k<=32?null:`Use a whole number from 1 to 32.`,M=qn(b),N=async t=>{if(t.preventDefault(),!(A||j||M)){T(!0),O(null);try{await x(`/api/projects/${encodeURIComponent(e.id)}`,{name:i.trim(),setupCommand:o.trim()||null,checks:Ht(c),maxConcurrentRuns:k,automationEnabled:f,workspaceSharing:m,defaultProfileId:g||null,defaultHostId:v||null,worktreeDir:b.trim()}),V.success(`Project settings saved`)}catch(e){O(e)}finally{T(!1)}}},te=!v||t.some(e=>e.id===v),ne=!g||n.some(e=>e.id===g);return(0,J.jsx)(G,{title:`Project settings`,children:(0,J.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:N,noValidate:!0,children:[(0,J.jsx)(B,{id:`${r}-name`,label:`Name`,error:A,children:(0,J.jsx)(U,{id:`${r}-name`,value:i,onChange:e=>a(e.target.value),...z(`${r}-name`,{error:A})})}),(0,J.jsx)(B,{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,J.jsx)(U,{id:`${r}-setup`,value:o,onChange:e=>s(e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,...z(`${r}-setup`,{hint:!0})})}),(0,J.jsx)(B,{id:`${r}-checks`,label:`Checks`,hint:`One command per line. Runs must pass these before review.`,children:(0,J.jsx)(nt,{id:`${r}-checks`,value:c,minRows:3,onChange:e=>l(e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,...z(`${r}-checks`,{hint:!0})})}),(0,J.jsx)(B,{id:`${r}-runs`,label:`Max concurrent runs`,hint:`Between 1 and 32.`,error:j,children:(0,J.jsx)(U,{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`,...z(`${r}-runs`,{hint:!0,error:j})})}),(0,J.jsx)(B,{id:`${r}-worktree`,label:`Worktree folder`,hint:Kn,error:M,children:(0,J.jsx)(U,{id:`${r}-worktree`,"data-testid":`project-worktree-dir`,value:b,onChange:e=>C(e.target.value),placeholder:ee,className:`font-mono`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,...z(`${r}-worktree`,{hint:!0,error:M})})}),(0,J.jsx)(at,{label:`Auto-start Ready tasks`,description:`When off, Ready tasks in this project wait instead of starting automatically.`,checked:f,onChange:p}),(0,J.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,J.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,J.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,J.jsx)(`input`,{id:`${r}-sharing-${e}`,type:`radio`,name:`${r}-sharing`,value:e,checked:m===e,onChange:()=>h(e),"aria-describedby":`${r}-sharing-${e}-desc`,className:`tap mt-0.5 size-5 shrink-0 accent-[var(--sy-accent)]`}),(0,J.jsxs)(`label`,{htmlFor:`${r}-sharing-${e}`,className:`min-w-0 text-sm`,children:[(0,J.jsx)(`span`,{className:`block font-medium`,children:t}),(0,J.jsx)(`span`,{id:`${r}-sharing-${e}-desc`,className:`block text-muted`,children:n})]})]},e))]}),(0,J.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,J.jsx)(B,{id:`${r}-profile`,label:`Default Pi profile`,children:(0,J.jsxs)(K,{id:`${r}-profile`,value:g,onChange:e=>_(e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:`None (use the coordinator default)`}),n.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.name},e.id)),!ne&&(0,J.jsx)(`option`,{value:g,children:`Removed profile`})]})}),(0,J.jsx)(B,{id:`${r}-host`,label:`Default host`,hint:`Runs start here when the task does not choose a host.`,children:(0,J.jsxs)(K,{id:`${r}-host`,value:v,onChange:e=>y(e.target.value),...z(`${r}-host`,{hint:!0}),children:[(0,J.jsx)(`option`,{value:``,children:`None (any host with a checkout)`}),t.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.name,e.connectivity===`connected`?``:` (${e.connectivity})`]},e.id)),!te&&(0,J.jsx)(`option`,{value:v,children:`Removed host`})]})})]}),(0,J.jsx)(S,{error:D}),(0,J.jsx)(`div`,{children:(0,J.jsx)(E,{type:`submit`,variant:`primary`,busy:w,icon:(0,J.jsx)(Ve,{className:`size-4`}),children:`Save project`})})]})})}function Xn({project:e,hosts:t,hostsById:n}){let r=R(e=>e.checkouts),i=(0,q.useMemo)(()=>Object.values(r).filter(t=>t.projectId===e.id).sort((e,t)=>e.createdAt.localeCompare(t.createdAt)),[r,e.id]),[a,o]=(0,q.useState)(!1);return(0,J.jsxs)(G,{title:`Checkouts`,description:`Clones of this repository. Add one per host that should run this project.`,actions:(0,J.jsx)(E,{size:`sm`,icon:(0,J.jsx)(Le,{className:`size-4`}),onClick:()=>o(!0),children:`Add checkout`}),children:[i.length===0?(0,J.jsx)(F,{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,J.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:i.map(e=>{let t=n[e.hostId];return(0,J.jsxs)(`li`,{className:`min-w-0 py-2 text-sm`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:t?.name??`Unknown host`}),t&&t.connectivity!==`connected`&&(0,J.jsxs)(`span`,{className:`text-xs text-muted`,children:[`(`,t.connectivity,`)`]})]}),(0,J.jsx)(`div`,{className:`break-all font-mono text-xs`,children:e.path}),(0,J.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Default branch: `,e.defaultBranch]})]},e.id)})}),(0,J.jsx)(Zn,{open:a,onClose:()=>o(!1),project:e,hosts:t})]})}function Zn({open:e,onClose:t,project:n,hosts:r}){let i=(0,q.useId)(),a=r.filter(e=>e.connectivity===`connected`),[o,s]=(0,q.useState)(``),[c,l]=(0,q.useState)(``),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(null),g=o||a[0]?.id||``,_=u||c?Bt(c):null,v=()=>{f||(d(!1),h(null),t())},y=async e=>{if(e.preventDefault(),d(!0),g&&!Bt(c)){p(!0),h(null);try{await L(`/api/projects/${encodeURIComponent(n.id)}/checkouts`,{hostId:g,path:c.trim()}),V.success(`Checkout added`),l(``),d(!1),t()}catch(e){h(e)}finally{p(!1)}}},b=`${i}-form`;return(0,J.jsx)(tt,{open:e,onClose:v,dismissOnBackdrop:!f,title:`Add checkout`,description:`Another clone of ${n.repoIdentity}.`,footer:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(E,{onClick:v,disabled:f,children:`Cancel`}),(0,J.jsx)(E,{type:`submit`,form:b,variant:`primary`,busy:f,disabled:a.length===0,children:`Add checkout`})]}),children:(0,J.jsxs)(`form`,{id:b,className:`flex min-w-0 flex-col gap-4`,onSubmit:y,noValidate:!0,children:[a.length===0&&(0,J.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,J.jsx)(B,{id:`${i}-host`,label:`Host`,hint:`Only connected hosts are listed.`,children:(0,J.jsxs)(K,{id:`${i}-host`,value:g,onChange:e=>s(e.target.value),disabled:a.length===0,...z(`${i}-host`,{hint:!0}),children:[a.length===0&&(0,J.jsx)(`option`,{value:``,children:`No connected hosts`}),a.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,J.jsx)(B,{id:`${i}-path`,label:`Checkout path on the host`,hint:`Absolute path of an existing clone of this repository.`,error:_,children:(0,J.jsx)(U,{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,...z(`${i}-path`,{hint:!0,error:_})})}),(0,J.jsx)(S,{error:m})]})})}var Qn=e=>Y(`projects/${encodeURIComponent(e)}`);function $n(){let e=Q(),t=_(),n=g().filter(e=>!e.revokedAt&&e.connectivity===`connected`),[i,a]=(0,q.useState)(``),o=t.filter(e=>Ee(e,i)),s=R(e=>e.checkouts),c=R(e=>e.workspaces),l=(0,q.useMemo)(()=>{let e={},t=t=>(e[t]??={checkouts:0,workspaces:0},e[t]);for(let e of Object.values(s))t(e.projectId).checkouts++;for(let e of Object.values(c))e.archivedAt||t(e.projectId).workspaces++;return e},[s,c]);return(0,J.jsxs)(X,{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,J.jsxs)(r,{to:Y(`projects/new`),state:Be,className:O(`primary`),children:[(0,J.jsx)(Le,{"aria-hidden":!0,className:`size-4`}),`New project`]}),children:[(0,J.jsx)(P,{}),n.map(e=>(0,J.jsx)(we,{host:e},e.id)),e?t.length===0?(0,J.jsx)(F,{icon:(0,J.jsx)(Ce,{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:Y(`projects/new`)}}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`relative max-w-md`,children:[(0,J.jsx)(Ue,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-subtle`}),(0,J.jsx)(U,{type:`search`,"aria-label":`Search projects`,placeholder:`Search projects by name or remote`,value:i,onChange:e=>a(e.target.value),className:`pl-8`})]}),o.length===0?(0,J.jsx)(F,{className:`py-4`,title:`No matches`,description:`No project matches "${i.trim()}".`,action:{label:`Clear search`,onClick:()=>a(``)}}):(0,J.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:o.map(e=>(0,J.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,J.jsx)(er,{project:e,counts:l[e.id]})},e.id))})]}):(0,J.jsx)(T,{label:`Loading projects…`})]})}function er({project:e,counts:t}){let n=t??{checkouts:0,workspaces:0};return(0,J.jsxs)(r,{to:Qn(e.id),state:Be,className:`tap flex min-w-0 items-center gap-3 px-4 py-2 hover:bg-surface-2`,children:[(0,J.jsx)(Ce,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,J.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),(0,J.jsx)(`span`,{className:`truncate text-xs text-muted`,title:e.repoIdentity,children:Se(e.repoIdentity)}),(0,J.jsxs)(`span`,{className:`flex flex-wrap gap-x-2 text-xs text-subtle`,children:[(0,J.jsxs)(`span`,{children:[n.checkouts,` checkout`,n.checkouts===1?``:`s`]}),(0,J.jsxs)(`span`,{children:[n.workspaces,` workspace`,n.workspaces===1?``:`s`]}),!e.automationEnabled&&(0,J.jsx)(`span`,{children:`Auto-start off`})]})]}),(0,J.jsx)(De,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})}function tr(){let e=Q(),t=g(),r=R(e=>e.profiles),i=(0,q.useMemo)(()=>Object.values(r).sort((e,t)=>e.name.localeCompare(t.name)),[r]),a=t.filter(e=>e.connectivity===`connected`),o=n(),s=(0,q.useId)(),[c,l]=(0,q.useState)(``),[u,d]=(0,q.useState)(``),[f,m]=(0,q.useState)(``),[h,_]=(0,q.useState)(``),[v,y]=(0,q.useState)(ee),[b,x]=(0,q.useState)(!1),[C,w]=(0,q.useState)(!1),[D,O]=(0,q.useState)(null),k=u||a[0]?.id||``,A=b&&!c.trim()?`Enter a project name.`:null,j=b&&!k?`Choose a connected host.`:null,M=b||f?Bt(f):null,N=qn(v),te=async e=>{if(e.preventDefault(),x(!0),c.trim()&&k&&!Bt(f)&&!N){w(!0),O(null);try{let e=await L(`/api/projects`,{name:c.trim(),hostId:k,path:f.trim(),defaultProfileId:h||null,worktreeDir:v.trim()});V.success(`Project ${c.trim()} created`),o(e?.id?Qn(e.id):Y(`projects`),{replace:!0})}catch(e){O(e)}finally{w(!1)}}},ne={to:Y(`projects`),label:`Projects`};return e?(0,J.jsxs)(X,{title:`New project`,description:`Switchyard inspects the checkout on the host, then discovers its worktrees.`,back:ne,children:[a.length===0&&(0,J.jsx)(oe,{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,J.jsx)(rt,{to:Y(`hosts`),variant:`action`,children:`Open hosts`})}),(0,J.jsx)(G,{children:(0,J.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:te,noValidate:!0,children:[(0,J.jsx)(B,{id:`${s}-name`,label:`Name`,error:A,children:(0,J.jsx)(U,{id:`${s}-name`,value:c,onChange:e=>l(e.target.value),autoComplete:`off`,...z(`${s}-name`,{error:A})})}),(0,J.jsx)(B,{id:`${s}-host`,label:`Host`,hint:`Only connected hosts are listed.`,error:j,children:(0,J.jsxs)(K,{id:`${s}-host`,value:k,onChange:e=>d(e.target.value),disabled:a.length===0,...z(`${s}-host`,{hint:!0,error:j}),children:[a.length===0&&(0,J.jsx)(`option`,{value:``,children:`No connected hosts`}),a.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,J.jsx)(B,{id:`${s}-path`,label:`Checkout path on the host`,hint:`Absolute path of an existing Git checkout, e.g. /Users/me/src/app.`,error:M,children:(0,J.jsx)(U,{id:`${s}-path`,value:f,onChange:e=>m(e.target.value),placeholder:`/Users/me/src/app`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,className:`font-mono`,...z(`${s}-path`,{hint:!0,error:M})})}),(0,J.jsx)(B,{id:`${s}-worktree`,label:`Worktree folder`,hint:Kn,error:N,children:(0,J.jsx)(U,{id:`${s}-worktree`,value:v,onChange:e=>y(e.target.value),placeholder:ee,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,className:`font-mono`,...z(`${s}-worktree`,{hint:!0,error:N})})}),(0,J.jsx)(B,{id:`${s}-profile`,label:`Default Pi profile (optional)`,children:(0,J.jsxs)(K,{id:`${s}-profile`,value:h,onChange:e=>_(e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:`None`}),i.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,J.jsx)(S,{error:D}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(E,{type:`submit`,variant:`primary`,busy:C,icon:(0,J.jsx)(_t,{className:`size-4`}),disabled:a.length===0,children:`Create project`}),a.length===0&&(0,J.jsx)(p,{icon:_t,label:`Needs a connected host`})]})]})})]}):(0,J.jsx)(X,{title:`New project`,back:ne,children:(0,J.jsx)(T,{})})}function nr(){let e=it(`/api/auth/methods`,Vt),[t,n]=(0,q.useState)(!1),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(!1),[m,h]=(0,q.useState)(null),g=async()=>{if(r){o(!0),c(null);try{await j(`/api/auth/passkeys/${encodeURIComponent(r.id)}`),V.success(`Passkey ${r.name} removed`),i(null),e.reload()}catch(e){c(e)}finally{o(!1)}}},_=async()=>{f(!0),h(null);try{await L(`/api/logout`),u(!1),de(null)}catch(e){h(e)}finally{f(!1)}},v=e.data,y=v?.passkeyAvailability,b=st(),x=v?y?.available?b?null:`This browser does not support passkeys.`:y?.reason??`Passkeys are not available on this server.`:null;return(0,J.jsxs)(X,{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,J.jsx)(P,{}),e.loading&&!v?(0,J.jsx)(T,{label:`Loading sign-in methods…`}):e.error&&!v?(0,J.jsx)(N,{title:`Could not load sign-in methods`,error:e.error,onRetry:e.reload}):v?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(G,{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,J.jsx)(E,{"data-testid":`passkey-add`,variant:`primary`,icon:(0,J.jsx)(Le,{className:`size-4`}),disabled:x!==null,onClick:()=>n(!0),children:`Add a passkey`}),children:[x&&(0,J.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,J.jsx)(I,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0`}),(0,J.jsxs)(`span`,{className:`min-w-0 break-words`,children:[`Adding a passkey is unavailable: `,x]})]}),v.passkeys.length===0?(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`No passkeys yet. Add one as a backup to single sign-on, or to sign in without it.`}):(0,J.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border`,children:v.passkeys.map(e=>(0,J.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,J.jsx)(Ie,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`div`,{className:`break-words font-medium`,children:e.name}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 text-sm text-muted`,children:[(0,J.jsxs)(`span`,{children:[`Added `,A(e.createdAt)]}),(0,J.jsxs)(`span`,{children:[`Last used `,A(e.lastUsedAt)]})]})]}),(0,J.jsx)(E,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,J.jsx)(he,{className:`size-4`}),"aria-label":`Remove passkey ${e.name}`,onClick:()=>{c(null),i(e)},children:`Remove`})]},e.id))})]}),(0,J.jsx)(G,{title:`Single sign-on`,description:`Configured on the server`,children:v.oidc?(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(Z,{items:[[`Button label`,v.oidc.label],[`Provider`,(0,J.jsx)(`span`,{className:`break-all`,children:v.oidc.issuer},`i`)],[`Allowed account`,v.oidc.ownerMatch],[`Status`,v.oidc.status===`ready`?(0,J.jsx)(p,{icon:Ne,tone:`success`,label:`Ready`},`s`):(0,J.jsx)(p,{icon:I,tone:`danger`,label:`Error`},`s`)]]}),v.oidc.status===`error`&&v.oidc.error&&(0,J.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-danger`,children:v.oidc.error})]}):(0,J.jsxs)(`p`,{"data-testid":`signin-oidc-status`,className:`text-sm text-muted`,children:[`Not configured. Set the `,(0,J.jsx)(`code`,{children:`SWITCHYARD_OIDC_*`}),` variables on the server to sign in with an identity provider.`]})})]}):null,(0,J.jsx)(G,{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,J.jsx)(E,{icon:(0,J.jsx)(Tt,{className:`size-4`}),onClick:()=>{h(null),u(!0)},children:`Sign out of this device`})}),(0,J.jsx)(rr,{open:t,onClose:()=>n(!1),onAdded:()=>{n(!1),e.reload()}}),(0,J.jsx)(H,{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,J.jsxs)(`p`,{className:`text-sm`,children:[`Devices already signed in stay signed in. This passkey can no longer sign in new devices.`,v&&v.passkeys.length===1&&!v.oidc?` It is your only passkey and no single sign-on is set up: afterwards new browsers need switchyard pair run on the server.`:``]})}),(0,J.jsx)(H,{open:l,onClose:()=>u(!1),title:`Sign out of this device?`,confirmLabel:`Sign out`,busy:d,error:m,onConfirm:_,children:(0,J.jsxs)(`p`,{className:`text-sm`,children:[`You will need single sign-on, a passkey or `,(0,J.jsx)(`code`,{children:`switchyard pair`}),` on the server to sign in here again.`]})})]})}function rr({open:e,onClose:t,onAdded:n}){let r=(0,q.useId)(),[i,a]=(0,q.useState)(()=>lt()),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(null),u=ct(),d=i.trim()?null:`Enter a name for this passkey.`,f=()=>{if(u.waiting)u.cancel();else if(o)return;l(null),t()},p=async e=>{if(e.preventDefault(),!d){s(!0),l(null);try{let{challengeId:e,options:t}=await L(`/api/auth/passkeys/register/options`),r=await u.run(()=>ot({optionsJSON:t}));if(!r.ok){s(!1);return}let a=r.value;await L(`/api/auth/passkeys/register/verify`,{challengeId:e,name:i.trim().slice(0,80),response:a}),V.success(`Passkey added`),n()}catch(e){l(e instanceof Error&&e.name===`NotAllowedError`?Error(`The passkey prompt was canceled or timed out. Try again.`):e instanceof Error?e:Error(ue(e)))}finally{s(!1)}}},m=`${r}-form`;return(0,J.jsx)(tt,{open:e,onClose:f,dismissOnBackdrop:!o||u.waiting,title:`Add a passkey`,description:`Name it after where it is stored, then confirm with your device.`,footer:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(E,{onClick:f,disabled:o&&!u.waiting,children:`Cancel`}),(0,J.jsx)(E,{type:`submit`,form:m,variant:`primary`,busy:o,children:`Create passkey`})]}),children:(0,J.jsxs)(`form`,{id:m,className:`flex min-w-0 flex-col gap-4`,onSubmit:p,noValidate:!0,children:[(0,J.jsx)(B,{id:`${r}-name`,label:`Passkey name`,error:d,children:(0,J.jsx)(U,{id:`${r}-name`,value:i,maxLength:80,autoComplete:`off`,onChange:e=>a(e.target.value),...z(`${r}-name`,{error:d})})}),u.waiting&&(0,J.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-muted`,children:[(0,J.jsx)(te,{}),` Waiting for your passkey… Cancel stops it.`]}),(0,J.jsx)(S,{error:c})]})})}function ir(){let e=Me(),n=e===`mobile`,r=(0,J.jsxs)(i,{children:[(0,J.jsx)(t,{index:!0,element:n?(0,J.jsx)(cr,{}):(0,J.jsx)(s,{to:Y(`hosts`),replace:!0})}),(0,J.jsx)(t,{path:`hosts`,element:(0,J.jsx)(bn,{})}),(0,J.jsx)(t,{path:`hosts/:hostId`,element:(0,J.jsx)(En,{})}),(0,J.jsx)(t,{path:`devices`,element:(0,J.jsx)(un,{})}),(0,J.jsx)(t,{path:`sign-in`,element:(0,J.jsx)(nr,{})}),(0,J.jsx)(t,{path:`projects`,element:(0,J.jsx)($n,{})}),(0,J.jsx)(t,{path:`projects/new`,element:(0,J.jsx)(tr,{})}),(0,J.jsx)(t,{path:`projects/:projectId`,element:(0,J.jsx)(Jn,{})}),(0,J.jsx)(t,{path:`profiles`,element:(0,J.jsx)(zn,{})}),(0,J.jsx)(t,{path:`adapters`,element:(0,J.jsx)(Zt,{})}),(0,J.jsx)(t,{path:`notifications`,element:(0,J.jsx)(An,{})}),(0,J.jsx)(t,{path:`backups`,element:(0,J.jsx)(on,{})}),(0,J.jsx)(t,{path:`diagnostics`,element:(0,J.jsx)(fn,{})}),(0,J.jsx)(t,{path:`device`,element:(0,J.jsx)(dn,{})}),(0,J.jsx)(t,{path:`*`,element:(0,J.jsx)(lr,{})})]});return n?(0,J.jsx)(`div`,{className:`min-w-0`,children:r}):(0,J.jsxs)(`div`,{className:`flex min-h-full min-w-0`,children:[(0,J.jsx)(or,{compact:e===`compact`}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1`,children:r})]})}function ar(){let{pathname:e}=u(),t=e.split(`/`),n=t.indexOf(`settings`);return n>=0&&(t[n+1]??null)||null}function or({compact:e}){let t=ar();return(0,J.jsx)(`div`,{className:b(`shrink-0 border-r border-border`,e?`w-52`:`w-60`),children:(0,J.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-testid":`settings-nav`,className:`sticky top-0 flex max-h-dvh flex-col gap-1 overflow-y-auto px-2 py-4`,children:[(0,J.jsx)(`h2`,{className:`mb-1 px-3 py-1 text-base font-semibold`,children:`Settings`}),Lt.map(e=>(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`h3`,{className:`px-3 pt-3 pb-1 text-xs font-semibold tracking-wide text-muted uppercase`,children:e.label}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.sections.map(({path:e,label:n,icon:i})=>{let a=t===e;return(0,J.jsx)(`li`,{children:(0,J.jsxs)(r,{to:Y(e),"aria-current":a?`page`:void 0,className:b(`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,J.jsx)(i,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:n})]})},e)})})]},e.label))]})})}function sr(){let e=R(e=>e.hosts),t=R(e=>e.devices),n=R(e=>e.projects),r=R(e=>e.profiles),i=R(e=>e.adapters),a=R(e=>e.hydrated);return(0,q.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 cr(){let e=sr();return(0,J.jsxs)(`div`,{className:`mx-auto flex w-full min-w-0 max-w-xl flex-col gap-3 px-4 py-4`,children:[(0,J.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Settings`}),(0,J.jsx)(P,{}),(0,J.jsx)(`nav`,{"aria-label":`Settings sections`,"data-testid":`settings-nav`,children:Lt.map(t=>(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`px-1 pt-3 pb-1 text-xs font-semibold tracking-wide text-muted uppercase`,children:t.label}),(0,J.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:t.sections.map(({path:t,label:n,description:i,icon:a})=>(0,J.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,J.jsxs)(r,{to:Y(t),state:Be,className:`tap flex min-h-14 items-center gap-3 px-4 py-2 hover:bg-surface-2`,children:[(0,J.jsx)(a,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`block font-medium`,children:n}),(0,J.jsx)(`span`,{className:`block truncate text-sm text-muted`,children:e[t]??i})]}),(0,J.jsx)(De,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})},t))})]},t.label))})]})}function lr(){return(0,J.jsx)(F,{title:`Settings page not found`,description:`This link does not match a settings section.`,action:{label:`Open Settings`,to:Y()}})}export{ir as default};
|
|
8
|
+
//# sourceMappingURL=settings-CLt7x9u8.js.map
|