@spencerboucher/switchyard 0.21.0 → 0.23.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 +11 -1
- package/dist/bridge/switchyard-terminal.js +2 -0
- package/dist/policies/worker.js +1335 -1235
- package/dist/switchyard.mjs +2517 -1820
- package/package.json +1 -1
- package/web-dist/assets/AutomationView-BFZ5tGrI.js +2 -0
- package/web-dist/assets/AutomationView-BFZ5tGrI.js.map +1 -0
- package/web-dist/assets/Checkbox-Bh46F55q.js +2 -0
- package/web-dist/assets/{Checkbox-BnRsg6ki.js.map → Checkbox-Bh46F55q.js.map} +1 -1
- package/web-dist/assets/DangerZone-K_oXMpbq.js +2 -0
- package/web-dist/assets/{DangerZone-BicyqXv8.js.map → DangerZone-K_oXMpbq.js.map} +1 -1
- package/web-dist/assets/Field-DRcZixOF.js +2 -0
- package/web-dist/assets/{Field-DBm2uYcg.js.map → Field-DRcZixOF.js.map} +1 -1
- package/web-dist/assets/{Markdown-BijzTpiJ.js → Markdown-BaCvc-cI.js} +7 -7
- package/web-dist/assets/{Markdown-BijzTpiJ.js.map → Markdown-BaCvc-cI.js.map} +1 -1
- package/web-dist/assets/NavigationEditor-BfNZ411c.js +2 -0
- package/web-dist/assets/NavigationEditor-BfNZ411c.js.map +1 -0
- package/web-dist/assets/Overlay-wZFuaSA5.js +2 -0
- package/web-dist/assets/Overlay-wZFuaSA5.js.map +1 -0
- package/web-dist/assets/Priority-Ce4btFLm.js +2 -0
- package/web-dist/assets/{Priority-DAhFDJ7E.js.map → Priority-Ce4btFLm.js.map} +1 -1
- package/web-dist/assets/RadioCards-DR-fWNLB.js +2 -0
- package/web-dist/assets/RadioCards-DR-fWNLB.js.map +1 -0
- package/web-dist/assets/ScopeSelect-B1RxBDV7.js +2 -0
- package/web-dist/assets/ScopeSelect-B1RxBDV7.js.map +1 -0
- package/web-dist/assets/SegmentedControl-M7WpGnaN.js +2 -0
- package/web-dist/assets/SegmentedControl-M7WpGnaN.js.map +1 -0
- package/web-dist/assets/Select-CvbSg3M1.js +2 -0
- package/web-dist/assets/{Select-CDRJ35wi.js.map → Select-CvbSg3M1.js.map} +1 -1
- package/web-dist/assets/StructuredValue-By3sh_00.js +5 -0
- package/web-dist/assets/StructuredValue-By3sh_00.js.map +1 -0
- package/web-dist/assets/Switch-B89oAK_3.js +2 -0
- package/web-dist/assets/{Switch-D5pVfZgf.js.map → Switch-B89oAK_3.js.map} +1 -1
- package/web-dist/assets/Tabs-CzGFkSHO.js +2 -0
- package/web-dist/assets/Tabs-CzGFkSHO.js.map +1 -0
- package/web-dist/assets/TextLink-irMcg7Xz.js +2 -0
- package/web-dist/assets/{TextLink-BGtYWCW9.js.map → TextLink-irMcg7Xz.js.map} +1 -1
- package/web-dist/assets/UINodeRenderer-_99GFFDS.js +4 -0
- package/web-dist/assets/UINodeRenderer-_99GFFDS.js.map +1 -0
- package/web-dist/assets/UnfilteredNote-iQIfVXkA.js +2 -0
- package/web-dist/assets/{UnfilteredNote-ddFROo9x.js.map → UnfilteredNote-iQIfVXkA.js.map} +1 -1
- package/web-dist/assets/api-CzS9UH7Q.js +2 -0
- package/web-dist/assets/api-CzS9UH7Q.js.map +1 -0
- package/web-dist/assets/{arrow-down-Dn3KG_JI.js → arrow-down-BKhm3D2d.js} +2 -2
- package/web-dist/assets/{arrow-down-Dn3KG_JI.js.map → arrow-down-BKhm3D2d.js.map} +1 -1
- package/web-dist/assets/{arrow-up-BiPtOqqy.js → arrow-up-poMxdOwI.js} +2 -2
- package/web-dist/assets/{arrow-up-BiPtOqqy.js.map → arrow-up-poMxdOwI.js.map} +1 -1
- package/web-dist/assets/attention-UZIRcx_k.js +2 -0
- package/web-dist/assets/attention-UZIRcx_k.js.map +1 -0
- package/web-dist/assets/automations-DWz_Lxch.js +2 -0
- package/web-dist/assets/{automations-ClK2gYj8.js.map → automations-DWz_Lxch.js.map} +1 -1
- package/web-dist/assets/board-BqGDwbGB.js +6 -0
- package/web-dist/assets/board-BqGDwbGB.js.map +1 -0
- package/web-dist/assets/{calendar-clock-DVlat602.js → calendar-clock-U5kMaB5u.js} +2 -2
- package/web-dist/assets/{calendar-clock-DVlat602.js.map → calendar-clock-U5kMaB5u.js.map} +1 -1
- package/web-dist/assets/chevron-right-B-aa_CvO.js +2 -0
- package/web-dist/assets/{chevron-right-BM1IJI2z.js.map → chevron-right-B-aa_CvO.js.map} +1 -1
- package/web-dist/assets/code-Di_a0pVO.js +28 -0
- package/web-dist/assets/code-Di_a0pVO.js.map +1 -0
- package/web-dist/assets/{core.esm-B2OVQjr5.js → core.esm-CHa4oRMo.js} +2 -2
- package/web-dist/assets/{core.esm-B2OVQjr5.js.map → core.esm-CHa4oRMo.js.map} +1 -1
- package/web-dist/assets/describe-C5NtR2LE.js +5 -0
- package/web-dist/assets/{describe-DBhLxCUs.js.map → describe-C5NtR2LE.js.map} +1 -1
- package/web-dist/assets/enroll-DlZYKudD.js +2 -0
- package/web-dist/assets/{enroll-JhMxQuxw.js.map → enroll-DlZYKudD.js.map} +1 -1
- package/web-dist/assets/git-branch-CltFrgh4.js +2 -0
- package/web-dist/assets/git-branch-CltFrgh4.js.map +1 -0
- package/web-dist/assets/grip-vertical-QSdwyQ9C.js +2 -0
- package/web-dist/assets/grip-vertical-QSdwyQ9C.js.map +1 -0
- package/web-dist/assets/{hand-B6lvj014.js → hand-5eeZJSl_.js} +2 -2
- package/web-dist/assets/{hand-B6lvj014.js.map → hand-5eeZJSl_.js.map} +1 -1
- package/web-dist/assets/haptics-O69vKVoK.js +2 -0
- package/web-dist/assets/haptics-O69vKVoK.js.map +1 -0
- package/web-dist/assets/index-CbdB9RE5.js +17 -0
- package/web-dist/assets/index-CbdB9RE5.js.map +1 -0
- package/web-dist/assets/index-XQGPQuFK.css +2 -0
- package/web-dist/assets/{link-2-CCq9WzMy.js → link-2-DXaJEVgz.js} +2 -2
- package/web-dist/assets/{link-2-CCq9WzMy.js.map → link-2-DXaJEVgz.js.map} +1 -1
- package/web-dist/assets/logic-4hQwsm8w.js +4 -0
- package/web-dist/assets/logic-4hQwsm8w.js.map +1 -0
- package/web-dist/assets/logic-c8AsGwGr.js +2 -0
- package/web-dist/assets/{logic-BnSIy9_P.js.map → logic-c8AsGwGr.js.map} +1 -1
- package/web-dist/assets/more-RENHRep9.js +2 -0
- package/web-dist/assets/more-RENHRep9.js.map +1 -0
- package/web-dist/assets/pencil-DvO-Zlyh.js +2 -0
- package/web-dist/assets/pencil-DvO-Zlyh.js.map +1 -0
- package/web-dist/assets/{play-NHO6U6cY.js → play-CPNEXvVs.js} +2 -2
- package/web-dist/assets/{play-NHO6U6cY.js.map → play-CPNEXvVs.js.map} +1 -1
- package/web-dist/assets/{plus-C83uJhbf.js → plus-DC4JQpXX.js} +2 -2
- package/web-dist/assets/{plus-C83uJhbf.js.map → plus-DC4JQpXX.js.map} +1 -1
- package/web-dist/assets/policyLogic-CXFbVtEs.js +2 -0
- package/web-dist/assets/{policyLogic-Btk1SjgX.js.map → policyLogic-CXFbVtEs.js.map} +1 -1
- package/web-dist/assets/prefs-BTwRvULi.js +2 -0
- package/web-dist/assets/prefs-BTwRvULi.js.map +1 -0
- package/web-dist/assets/queue-C25GCl3M.js +2 -0
- package/web-dist/assets/{queue-gs6Ez_u3.js.map → queue-C25GCl3M.js.map} +1 -1
- package/web-dist/assets/{rotate-ccw-BRrlVEAQ.js → rotate-ccw-DuLdXOxM.js} +2 -2
- package/web-dist/assets/{rotate-ccw-BRrlVEAQ.js.map → rotate-ccw-DuLdXOxM.js.map} +1 -1
- package/web-dist/assets/{search-C5H14z0D.js → search-tZdcGLqS.js} +2 -2
- package/web-dist/assets/{search-C5H14z0D.js.map → search-tZdcGLqS.js.map} +1 -1
- package/web-dist/assets/selection-BVtvp1aZ.js +9 -0
- package/web-dist/assets/selection-BVtvp1aZ.js.map +1 -0
- package/web-dist/assets/settings-BApavmGp.js +7 -0
- package/web-dist/assets/settings-BApavmGp.js.map +1 -0
- package/web-dist/assets/states-CM1Zt9qO.js +60 -0
- package/web-dist/assets/states-CM1Zt9qO.js.map +1 -0
- package/web-dist/assets/{terminal-CATQN_17.js → terminal-CEttp_7_.js} +2 -2
- package/web-dist/assets/{terminal-CATQN_17.js.map → terminal-CEttp_7_.js.map} +1 -1
- package/web-dist/assets/terminal-login-BceUiMHs.js +2 -0
- package/web-dist/assets/{terminal-login-DNyAyWlB.js.map → terminal-login-BceUiMHs.js.map} +1 -1
- package/web-dist/assets/useBreakpoint-CdYPa6z0.js +2 -0
- package/web-dist/assets/useBreakpoint-CdYPa6z0.js.map +1 -0
- package/web-dist/assets/useNow-CyygPGnv.js +2 -0
- package/web-dist/assets/{useNow-wwKWj7oX.js.map → useNow-CyygPGnv.js.map} +1 -1
- package/web-dist/assets/useResource-DQOWQ7YZ.js +2 -0
- package/web-dist/assets/useResource-DQOWQ7YZ.js.map +1 -0
- package/web-dist/assets/useSwipeTabs-CJFQTmAs.js +2 -0
- package/web-dist/assets/useSwipeTabs-CJFQTmAs.js.map +1 -0
- package/web-dist/assets/workboard-D39MZMSb.js +3 -0
- package/web-dist/assets/workboard-D39MZMSb.js.map +1 -0
- package/web-dist/index.html +7 -8
- package/web-dist/sw.js +1 -1
- package/web-dist/sw.js.map +1 -1
- package/web-dist/assets/AutomationView-8yzlARUS.js +0 -2
- package/web-dist/assets/AutomationView-8yzlARUS.js.map +0 -1
- package/web-dist/assets/Button-C7TQGuSX.js +0 -2
- package/web-dist/assets/Button-C7TQGuSX.js.map +0 -1
- package/web-dist/assets/Card-DzHrwFrv.js +0 -2
- package/web-dist/assets/Card-DzHrwFrv.js.map +0 -1
- package/web-dist/assets/Checkbox-BnRsg6ki.js +0 -2
- package/web-dist/assets/DangerZone-BicyqXv8.js +0 -2
- package/web-dist/assets/Field-DBm2uYcg.js +0 -2
- package/web-dist/assets/Menu-BCTLk6pj.js +0 -2
- package/web-dist/assets/Menu-BCTLk6pj.js.map +0 -1
- package/web-dist/assets/Priority-DAhFDJ7E.js +0 -2
- package/web-dist/assets/ScopeSelect-CMmLEwNw.js +0 -2
- package/web-dist/assets/ScopeSelect-CMmLEwNw.js.map +0 -1
- package/web-dist/assets/SegmentedControl-Cvkz7C_A.js +0 -2
- package/web-dist/assets/SegmentedControl-Cvkz7C_A.js.map +0 -1
- package/web-dist/assets/Select-CDRJ35wi.js +0 -2
- package/web-dist/assets/Switch-D5pVfZgf.js +0 -2
- package/web-dist/assets/Tabs-D1t1tQzS.js +0 -2
- package/web-dist/assets/Tabs-D1t1tQzS.js.map +0 -1
- package/web-dist/assets/TextLink-BGtYWCW9.js +0 -2
- package/web-dist/assets/UINodeRenderer-CzoNfuWZ.js +0 -4
- package/web-dist/assets/UINodeRenderer-CzoNfuWZ.js.map +0 -1
- package/web-dist/assets/UnfilteredNote-ddFROo9x.js +0 -2
- package/web-dist/assets/api-hJ_Ikv1a.js +0 -2
- package/web-dist/assets/api-hJ_Ikv1a.js.map +0 -1
- package/web-dist/assets/attention-8UbWvCkj.js +0 -2
- package/web-dist/assets/attention-8UbWvCkj.js.map +0 -1
- package/web-dist/assets/automations-ClK2gYj8.js +0 -2
- package/web-dist/assets/board-4FKGJU8D.js +0 -6
- package/web-dist/assets/board-4FKGJU8D.js.map +0 -1
- package/web-dist/assets/check-CEnbWw4D.js +0 -2
- package/web-dist/assets/check-CEnbWw4D.js.map +0 -1
- package/web-dist/assets/chevron-right-BM1IJI2z.js +0 -2
- package/web-dist/assets/code-BD2TozC7.js +0 -25
- package/web-dist/assets/code-BD2TozC7.js.map +0 -1
- package/web-dist/assets/describe-DBhLxCUs.js +0 -5
- package/web-dist/assets/enroll-JhMxQuxw.js +0 -2
- package/web-dist/assets/external-link-B3hnazCa.js +0 -2
- package/web-dist/assets/external-link-B3hnazCa.js.map +0 -1
- package/web-dist/assets/index-Bc5JWkn9.js +0 -17
- package/web-dist/assets/index-Bc5JWkn9.js.map +0 -1
- package/web-dist/assets/index-C9iuCGwg.css +0 -2
- package/web-dist/assets/keyboardLayers-4IDHV-jq.js +0 -2
- package/web-dist/assets/keyboardLayers-4IDHV-jq.js.map +0 -1
- package/web-dist/assets/logic-BnSIy9_P.js +0 -2
- package/web-dist/assets/logic-DUKcqVPg.js +0 -4
- package/web-dist/assets/logic-DUKcqVPg.js.map +0 -1
- package/web-dist/assets/more-CUfPZ6AG.js +0 -2
- package/web-dist/assets/more-CUfPZ6AG.js.map +0 -1
- package/web-dist/assets/pencil-DeML-0z2.js +0 -2
- package/web-dist/assets/pencil-DeML-0z2.js.map +0 -1
- package/web-dist/assets/policyLogic-Btk1SjgX.js +0 -2
- package/web-dist/assets/queue-gs6Ez_u3.js +0 -2
- package/web-dist/assets/repo-T2dxdBnU.js +0 -2
- package/web-dist/assets/repo-T2dxdBnU.js.map +0 -1
- package/web-dist/assets/selection-DBzwvhnW.js +0 -7
- package/web-dist/assets/selection-DBzwvhnW.js.map +0 -1
- package/web-dist/assets/settings-DpK1_7vb.js +0 -12
- package/web-dist/assets/settings-DpK1_7vb.js.map +0 -1
- package/web-dist/assets/states-DL6w2pmK.js +0 -58
- package/web-dist/assets/states-DL6w2pmK.js.map +0 -1
- package/web-dist/assets/terminal-login-DNyAyWlB.js +0 -2
- package/web-dist/assets/timer-DFrvOKOy.js +0 -2
- package/web-dist/assets/timer-DFrvOKOy.js.map +0 -1
- package/web-dist/assets/useBreakpoint-BYCN9s8X.js +0 -2
- package/web-dist/assets/useBreakpoint-BYCN9s8X.js.map +0 -1
- package/web-dist/assets/useNow-wwKWj7oX.js +0 -2
- package/web-dist/assets/useResource-D_GOVIub.js +0 -2
- package/web-dist/assets/useResource-D_GOVIub.js.map +0 -1
- package/web-dist/assets/workboard-B89WFLVO.js +0 -3
- package/web-dist/assets/workboard-B89WFLVO.js.map +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{$t as e,C as t,D as n,Jt as r,Kt as i,P as a,Qt as o,R as s,S as c,W as l,Xt as u,Yt as d,Zt as f,_ as p,_n as m,a as h,b as g,bt as _,c as v,cn as y,d as b,dt as x,en as S,f as C,fn as w,g as T,gt as E,ht as D,i as O,in as k,kt as A,ln as j,lt as M,m as ee,mn as N,n as P,on as F,p as I,pn as te,pt as L,qt as ne,r as re,s as R,t as z,tt as ie,u as ae,un as oe,v as se,xt as ce,y as le,yt as ue}from"./states-CM1Zt9qO.js";import{n as de,t as B,y as fe}from"./Overlay-wZFuaSA5.js";import{Ht as pe,jt as me,t as he}from"./selection-BVtvp1aZ.js";import{o as ge,t as _e}from"./UINodeRenderer-_99GFFDS.js";import"./SegmentedControl-M7WpGnaN.js";import{t as ve}from"./chevron-right-B-aa_CvO.js";import"./Priority-Ce4btFLm.js";import{a as ye,i as be,o as xe,r as V,t as H}from"./Field-DRcZixOF.js";import{r as Se}from"./prefs-BTwRvULi.js";import{n as Ce,t as we}from"./useResource-DQOWQ7YZ.js";import{t as Te}from"./git-branch-CltFrgh4.js";import{t as Ee}from"./pencil-DvO-Zlyh.js";import{t as De}from"./plus-DC4JQpXX.js";import{n as Oe,t as ke}from"./DangerZone-K_oXMpbq.js";import{t as Ae}from"./search-tZdcGLqS.js";import{a as je,l as Me,n as Ne,o as Pe,r as Fe,s as Ie,t as Le,u as Re}from"./StructuredValue-By3sh_00.js";import{t as ze}from"./terminal-CEttp_7_.js";import{a as Be,i as Ve,o as He,r as Ue,s as We,t as Ge}from"./policyLogic-CXFbVtEs.js";import{n as Ke,t as qe}from"./useBreakpoint-CdYPa6z0.js";import{$ as Je,A as Ye,D as Xe,Dt as Ze,E as Qe,F as $e,G as U,K as W,M as et,N as tt,O as G,P as nt,R as rt,T as it,Tt as at,W as ot,Y as K,_ as st,_t as ct,at as lt,b as ut,ct as dt,ft,g as pt,h as mt,j as q,k as ht,lt as gt,mt as _t,ot as vt,pt as yt,st as bt,t as xt,tt as St,ut as Ct,v as wt,vt as Tt,w as Et,wt as Dt,x as Ot,xt as kt,y as At,yt as jt}from"./index-CbdB9RE5.js";import{t as Mt}from"./TextLink-irMcg7Xz.js";import"./Tabs-CzGFkSHO.js";import{n as J,t as Nt}from"./RadioCards-DR-fWNLB.js";import{t as Y}from"./Select-CvbSg3M1.js";import{n as Pt,t as Ft}from"./Switch-B89oAK_3.js";import{a as It,n as Lt}from"./ScopeSelect-B1RxBDV7.js";import{t as Rt}from"./Checkbox-Bh46F55q.js";import{d as zt,f as Bt,l as Vt,r as Ht}from"./logic-c8AsGwGr.js";import{t as Ut}from"./NavigationEditor-BfNZ411c.js";var Wt={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`}]]};Wt.node;var Gt=n(Wt),Kt={name:`circle-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.35 2.69A10 10 0 0 1 21.3 15.65`,key:`1pfsoa`}],[`path`,{d:`M19.08 19.08A10 10 0 1 1 4.92 4.92`,key:`1ablyi`}]]};Kt.node;var qt=n(Kt),Jt={name:`eraser`,size:24,node:[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]};Jt.node;var Yt=n(Jt),Xt={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`}]]};Xt.node;var Zt=n(Xt),Qt={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`}]]};Qt.node;var $t=n(Qt),en={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`}]]};en.node;var tn=n(en),nn={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`}]]};nn.node;var rn=n(nn),an={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`}]]};an.node;var on=n(an),sn={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`}]]};sn.node;var cn=n(sn),ln={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`}]]};ln.node;var un=n(ln),X=m(N(),1),Z=ee(),dn=`Preview action — not sent to Pi`;function fn({initialJson:e=``}){let t=(0,X.useId)(),n=(0,X.useRef)(0),[r,i]=(0,X.useState)(()=>{try{return e?x(e):null}catch{return null}}),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)([]),d=e=>{s||u(t=>[...t.slice(-99),e])};return(0,Z.jsxs)(`details`,{className:`min-w-0 rounded-lg border border-border p-4`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer font-semibold`,children:`Portable UI preview`}),(0,Z.jsxs)(`div`,{className:`mt-3 flex min-w-0 flex-col gap-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`Developer tool. Run adapter:preview with an explicitly selected trusted adapter in a separate Node process (not a sandbox), then upload its JSON file here. This browser only renders portable UI and simulates actions. Nothing is installed, persisted or sent to Pi or the server.`}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Z.jsxs)(`label`,{htmlFor:`${t}-file`,className:`text-sm`,children:[`Upload preview file`,(0,Z.jsx)(`input`,{id:`${t}-file`,type:`file`,accept:`.json,application/json`,className:`ml-2 max-w-full`,onChange:async e=>{let t=e.target.files?.[0];e.target.value=``;let r=++n.current;if(i(null),u([]),o(null),!t)return;if(t.size>1048576){o(`Preview exceeds 1 MiB input limit`);return}let a;try{a=await t.text()}catch{r===n.current&&o(`Could not read this preview file.`);return}if(r===n.current)try{i(x(a))}catch(e){o(e instanceof SyntaxError?`This file is not valid JSON.`:e instanceof Error&&e.message===`Preview exceeds 1 MiB input limit`?`Preview exceeds 1 MiB input limit`:`This file is not a supported adapter preview.`)}}})]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked)}),`Simulate read-only / disabled`]}),(0,Z.jsx)(b,{variant:`secondary`,onClick:()=>{++n.current,i(null),u([]),o(null)},children:`Clear preview`})]}),a&&(0,Z.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-danger`,children:a}),r&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`h3`,{className:`font-medium`,children:[r.name,` · `,r.adapter.id,`@`,r.adapter.version]}),(0,Z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-4 2xl:grid-cols-[minmax(0,1fr)_390px]`,children:[(0,Z.jsx)(pn,{preview:r,phone:!1,disabled:s,onAction:d}),(0,Z.jsx)(pn,{preview:r,phone:!0,disabled:s,onAction:d})]}),(0,Z.jsxs)(`details`,{children:[(0,Z.jsx)(`summary`,{children:`Steps and diagnostics`}),(0,Z.jsxs)(`ul`,{className:`text-sm`,children:[r.steps.map(e=>(0,Z.jsxs)(`li`,{children:[e.index+1,`. `,e.kind,`: `,e.ok?`OK`:e.error]},e.index)),r.diagnostics.map((e,t)=>(0,Z.jsxs)(`li`,{children:[e.level,`: `,e.message]},`${t}-${e.at}`))]})]})]}),(0,Z.jsxs)(`section`,{"aria-label":`Preview action log`,className:`min-w-0`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-medium`,children:`Local simulated actions`}),l.length===0&&(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No preview actions yet.`}),(0,Z.jsx)(`ol`,{"aria-live":`polite`,className:`max-h-64 list-decimal overflow-auto pl-5 text-xs`,children:l.map((e,t)=>(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`p`,{children:dn}),(0,Z.jsx)(Le,{value:{Source:e.source,...e.adapterId!==void 0&&{Adapter:e.adapterId},...e.requestId!==void 0&&{Request:e.requestId},...e.actionId!==void 0&&{Action:e.actionId},...e.payload!==void 0&&{Response:e.payload}}})]},t))})]})]})]})}function pn({preview:e,phone:t,disabled:n,onAction:r}){let i=e=>{n||r(e)},a=(e,t,r=!1)=>(0,Z.jsx)(_e,{node:e,disabled:n||r,busy:!1,onRespond:e=>{r||(e.kind===`action`?i({...t,actionId:e.actionId}):i({...t,payload:e}))},onOpenFile:e=>i({source:`file`,payload:{path:e}})}),o=e=>(0,Z.jsxs)(`article`,{className:`min-w-0 rounded border border-border p-3`,children:[(0,Z.jsx)(`h4`,{className:`mb-2 text-sm font-semibold`,children:e.title}),e.node?a(e.node,{source:e.contribution?.placement??`panel`,adapterId:e.adapterId,actionId:e.contribution?.actionId}):(0,Z.jsx)(`p`,{className:`text-sm`,children:e.mobileFallback}),e.contribution?.actionId&&[`palette.item`,`slash.command`].includes(e.contribution.placement)&&e.node?.t!==`form`&&(0,Z.jsxs)(b,{disabled:n,onClick:()=>i({source:e.contribution.placement,adapterId:e.adapterId,actionId:e.contribution.actionId}),children:[`Simulate `,e.title]})]},JSON.stringify([e.adapterId,e.slot]));return(0,Z.jsx)(`section`,{"aria-label":t?`Phone preview 390px`:`Desktop preview`,className:`min-w-0 max-w-full overflow-x-auto overscroll-x-contain rounded-xl border border-border bg-surface-1 p-3`,onClickCapture:e=>{let t=e.target.closest(`a`);t&&(e.preventDefault(),e.stopPropagation(),i({source:`link`,payload:{href:t.getAttribute(`href`)}}))},children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,style:t?{width:390,maxWidth:`100%`}:void 0,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold`,children:[t?`Phone · 390px`:`Desktop · portable UI`,n?` · Read-only`:``]}),e.panels.filter(e=>!e.contribution).map(o),[`sidebar.header`,`session.panel`,`composer.tracker`,`composer.pill`,`session.badge`,`palette.item`,`slash.command`,`sidebar.footer`].map(n=>{let r=e.panels.filter(e=>e.contribution?.placement===n).sort((e,t)=>(e.contribution?.order??0)-(t.contribution?.order??0));return r.length?(0,Z.jsxs)(`section`,{"aria-label":n,className:`flex min-w-0 flex-col gap-2`,children:[(0,Z.jsx)(`h4`,{className:`text-xs text-muted`,children:t&&n.startsWith(`sidebar.`)?`Details · ${n}`:n}),r.map(o)]},n):null}),e.interactions.map(e=>(0,Z.jsxs)(`article`,{"aria-label":`Question: ${e.request.title}`,className:`min-w-0 rounded border border-border p-3`,children:[(0,Z.jsxs)(`h4`,{className:`mb-2 text-sm font-semibold`,children:[e.request.title,` · `,e.state]}),a(e.presentation,{source:`interaction`,requestId:e.request.id},e.state===`resolved`)]},e.request.id)),e.cards.map((e,t)=>(0,Z.jsx)(`article`,{className:`min-w-0 rounded border border-border p-3`,children:a(e,{source:`card`,payload:{index:t}})},`card-${t}`))]})})}function mn(e,t,n){let r=new Set,i=[];for(let a of[...e??[],...t]){let e=a.hostId??(a.sessionId?n[a.sessionId]?.hostId:void 0),t=e?{...a,hostId:e}:a,o=JSON.stringify([t.hostId??null,t.at,t.adapterId,t.sessionId,t.message]);r.has(o)||(r.add(o),i.push(t))}return i.sort((e,t)=>t.at.localeCompare(e.at))}function hn(e){return we(e)&&we(e.versions)}var gn=`/api/diagnostics`,_n={active:{icon:jt,label:`Active`,tone:`success`},disabled:{icon:_t,label:`Disabled`,tone:`neutral`},error:{icon:yt,label:`Error`,tone:`danger`}};function vn({status:e}){let t=_n[e]??_n.error;return(0,Z.jsx)(K,{icon:t.icon,label:t.label,tone:t.tone})}var yn={project:`Project`,owner:`Owner`,plugin:`Plugin`,bundled:`Bundled`},bn={info:{icon:gt,label:`Info`,tone:`info`},warning:{icon:le,label:`Warning`,tone:`warning`},error:{icon:yt,label:`Error`,tone:`danger`}};function xn({level:e}){let t=bn[e]??bn.info;return(0,Z.jsx)(K,{icon:t.icon,label:t.label,tone:t.tone})}function Sn(e){let t=l(e=>e.diagnostics),n=l(e=>e.sessions);return(0,X.useMemo)(()=>mn(e,t,n),[e,t,n])}function Cn(){let e=nt(),n=l(e=>e.adapters),r=l(e=>e.hosts),i=Ce(`/api/diagnostics`,we),a=Sn(Array.isArray(i.data?.diagnostics)?i.data.diagnostics:void 0),o=(0,X.useMemo)(()=>Object.entries(n).filter(([,e])=>e.length>0).map(([e,t])=>({hostId:e,hostName:r[e]?.name??`Removed host`,adapters:[...t].sort((e,t)=>e.id.localeCompare(t.id))})).sort((e,t)=>e.hostName.localeCompare(t.hostName)),[n,r]);return(0,Z.jsxs)(G,{title:`Adapters`,description:`Adapters translate Pi extensions into Switchyard cards, panels and interactions. Each host reports its own.`,children:[(0,Z.jsx)(R,{}),i.error!==null&&!i.loading&&!i.fatal&&(0,Z.jsx)(P,{compact:!0,title:`Could not load adapter diagnostics history`,error:i.error,onRetry:i.reload}),e?o.length===0?(0,Z.jsx)(z,{icon:(0,Z.jsx)(t,{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:q(`hosts`)}}):o.map(e=>(0,Z.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold`,children:(0,Z.jsx)(k,{to:q(`hosts/${encodeURIComponent(e.hostId)}`),className:`hover:underline`,children:e.hostName})}),e.adapters.map(t=>(0,Z.jsx)(wn,{adapter:t,diagnostics:a.filter(n=>n.adapterId===t.id&&n.hostId===e.hostId)},`${t.tier}:${t.id}`))]},e.hostId)):(0,Z.jsx)(v,{label:`Loading adapters…`}),a.some(e=>!e.hostId)&&(0,Z.jsxs)(`section`,{"aria-label":`Unscoped adapter diagnostics`,className:`flex min-w-0 flex-col gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Unscoped diagnostics`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`These events do not identify a host or a known session.`}),(0,Z.jsx)(Tn,{diagnostics:a.filter(e=>!e.hostId&&e.adapterId)})]}),(0,Z.jsx)(St,{fallback:(e,t)=>(0,Z.jsx)(P,{compact:!0,title:`Portable UI preview failed`,error:e,onRetry:t}),children:(0,Z.jsx)(fn,{})})]})}function wn({adapter:e,diagnostics:t}){return(0,Z.jsxs)(J,{title:(0,Z.jsx)(`span`,{className:`break-all font-mono`,children:e.id}),actions:(0,Z.jsx)(vn,{status:e.status}),children:[(0,Z.jsx)(Et,{items:[[`Version`,e.version],[`Tier`,yn[e.tier]??e.tier],[`Target extension`,(0,Z.jsx)(`span`,{className:`break-all font-mono`,children:e.target.extension},`t`)],[`Version range`,(0,Z.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,Z.jsx)(`h3`,{className:`mt-3 mb-1 text-sm font-semibold`,children:`Recent diagnostics`}),t.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No diagnostics for this adapter.`}):(0,Z.jsx)(Tn,{diagnostics:t})]})}function Tn({diagnostics:e}){return(0,Z.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:e.slice(0,10).map((e,t)=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-2 text-sm`,children:[(0,Z.jsx)(xn,{level:e.level}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),e.sessionId&&(0,Z.jsx)(k,{className:`text-accent hover:underline`,to:`/code/${encodeURIComponent(e.sessionId)}?tab=extensions`,children:`Session extensions`}),(0,Z.jsx)(`time`,{dateTime:e.at,className:`text-xs text-muted`,children:p(e.at)})]},`${e.at}-${t}`))})}var En=`switchyard coordinator backup <file>`,Dn=`switchyard coordinator restore <file>`;function On(e){let t=e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/_/g,` `);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function kn(e,t){return t==null?`None`:typeof t==`string`&&/At$|time|date/i.test(e)?p(t):typeof t==`object`?(0,Z.jsx)(Le,{value:t}):String(t)}function An(){let e=Ce(gn,hn),t=e.data&&we(e.data.backup)?e.data.backup:null;return(0,Z.jsxs)(G,{title:`Backups`,description:`The coordinator keeps all state in one SQLite database. Back it up from the machine that runs the coordinator.`,children:[(0,Z.jsxs)(J,{title:`Back up`,children:[(0,Z.jsx)(`p`,{className:`mb-2 text-sm`,children:`Writes a consistent copy of the database to a file while the coordinator keeps running.`}),(0,Z.jsx)(be,{text:En,label:`Backup command`,copyLabel:`Copy command`})]}),(0,Z.jsxs)(J,{title:`Restore`,children:[(0,Z.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,Z.jsx)(`code`,{className:`break-all`,children:`coordinator.db.bak-<ts>`}),`.`]}),(0,Z.jsx)(be,{text:Dn,label:`Restore command`,copyLabel:`Copy command`}),(0,Z.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,Z.jsx)(J,{title:`Last backup`,children:e.fatal?(0,Z.jsx)(re,{error:e.error}):e.error&&!e.loading&&!e.data?(0,Z.jsx)(P,{compact:!0,title:`Could not load backup info`,error:e.error,onRetry:e.reload}):e.data?t&&Object.keys(t).length>0?(0,Z.jsx)(Et,{items:Object.entries(t).map(([e,t])=>[On(e),kn(e,t)])}):(0,Z.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,Z.jsx)(v,{label:`Loading backup info…`})})]})}var jn={browser:`Browser`,pwa:`Home Screen app`,terminal:`Terminal`,cli:`CLI`},Mn={granted:`allowed`,denied:`blocked`,default:`not requested`,unknown:`unknown`};function Nn({kind:e}){return(0,Z.jsx)(e===`pwa`?cn:e===`browser`?tn:ze,{"aria-hidden":!0,className:`mt-0.5 size-5 shrink-0 text-muted`})}function Pn(e){return e.mirror===`scope`?`scope:${e.scopeId}`:e.mirror}function Fn(e){return e.startsWith(`scope:`)?{mirror:`scope`,scopeId:e.slice(6)}:{mirror:e===`all`?`all`:`none`}}function In(e,t,n=Date.now()){let r=[`on ${t.hostName||e.machine}`];if(t.device&&r.push(t.device.revokedAt===null?`signed in with ${t.device.name}`:`its device was revoked`),pe(e,n)){let t=e.shows?.length??0;t>0&&r.push(`${t} session${t===1?``:`s`} mirrored`)}else Date.parse(e.lastSeenAt)<=0?r.push(`never seen`):r.push(`last seen ${T(e.lastSeenAt,n)}`);return r}function Ln({client:t,scopes:n,device:r,hostName:i,onForget:a}){let[s,c]=(0,X.useState)(!1),l=Pn(t),u=pe(t),d=t.mirror===`scope`&&!n.some(e=>e.id===t.scopeId),f=async n=>{c(!0);try{await o(`/api/clients/${encodeURIComponent(t.id)}/binding`,Fn(n))}catch(n){W.error(`Could not change ${t.kind} ${t.name}: ${e(n)}`)}finally{c(!1)}};return(0,Z.jsxs)(`li`,{"data-testid":`client-row`,className:`flex min-w-0 flex-wrap items-center gap-x-4 gap-y-2 border-b border-border px-4 py-3 last:border-b-0`,children:[(0,Z.jsx)(Me,{"aria-hidden":!0,className:`mt-0.5 size-5 shrink-0 self-start text-muted`}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-[1_1_16rem] flex-col gap-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`span`,{"data-testid":`client-name`,className:`min-w-0 break-words font-medium`,children:[t.kind,` `,t.name]}),(0,Z.jsx)(K,{icon:u?jt:qt,tone:u?`success`:`neutral`,label:u?`Running`:`Not running`})]}),(0,Z.jsx)(`p`,{className:`min-w-0 break-words text-sm text-muted`,children:In(t,{device:r,hostName:i}).join(` · `)})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`text-muted`,children:`Mirrors`}),(0,Z.jsxs)(Y,{width:`auto`,"aria-label":`What ${t.kind} ${t.name} mirrors`,value:l,disabled:s,onChange:e=>void f(e.target.value),children:[(0,Z.jsx)(`option`,{value:`none`,children:`Nothing`}),(0,Z.jsx)(`option`,{value:`all`,children:`Everything`}),n.map(e=>(0,Z.jsxs)(`option`,{value:`scope:${e.id}`,children:[`Scope: `,e.name]},e.id)),d&&(0,Z.jsx)(`option`,{value:l,children:`Deleted scope`})]}),!u&&(0,Z.jsx)(b,{size:`sm`,variant:`ghost`,icon:(0,Z.jsx)(Yt,{className:`size-4`}),onClick:a,children:`Forget`})]})]})}function Rn(){let t=nt(),n=l(e=>e.devices),i=l(e=>e.clients),a=l(e=>e.scopes),o=l(e=>e.hosts),s=(0,X.useMemo)(()=>Object.values(a).sort((e,t)=>e.name.localeCompare(t.name)),[a]),c=(0,X.useMemo)(()=>Object.values(i).sort((e,t)=>e.machine.localeCompare(t.machine)||e.id.localeCompare(t.id)),[i]);Ze(e=>e.me);let d=Dt(),p=(0,X.useMemo)(()=>Object.values(n).filter(e=>e.revokedAt===null).sort((e,t)=>Number(t.id===d)-Number(e.id===d)||(t.lastSeenAt??``).localeCompare(e.lastSeenAt??``)),[n,d]),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(``),[y,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(null),[w,E]=(0,X.useState)(null),[D,O]=(0,X.useState)(!1),[k,A]=(0,X.useState)(null),[j,M]=(0,X.useState)(null),[ee,N]=(0,X.useState)(!1),[P,F]=(0,X.useState)(null),[I,te]=(0,X.useState)(null),L=async()=>{if(w){O(!0),A(null);try{await f(`/api/devices/${encodeURIComponent(w.id)}/revoke`),W.success(`${w.name} revoked`),E(null)}catch(e){A(e)}finally{O(!1)}}},ne=async()=>{if(j){N(!0),F(null);try{await r(`/api/clients/${encodeURIComponent(j.id)}`),W.success(`${j.kind} ${j.name} forgotten`),M(null)}catch(e){F(e)}finally{N(!1)}}},re=async t=>{te(t.id);try{await u(`/api/devices/${encodeURIComponent(t.id)}`,{preferredMobile:!0}),W.success(`${t.name} is now the preferred mobile device`)}catch(t){W.error(`Could not set the preferred device: ${e(t)}`)}finally{te(null)}},ie=async()=>{if(!m)return;let e=g.trim();if(e){x(!0),C(null);try{await u(`/api/devices/${encodeURIComponent(m.id)}`,{name:e}),W.success(`Renamed to ${e}`),h(null)}catch(e){C(e)}finally{x(!1)}}};return(0,Z.jsxs)(G,{testId:`settings-clients`,title:`Clients`,description:`What is signed in to this coordinator.`,children:[(0,Z.jsx)(R,{}),t?p.length===0&&c.length===0?(0,Z.jsx)(z,{icon:(0,Z.jsx)(vt,{className:`size-8`}),title:`No clients`,description:`Browsers and CLIs appear here once they sign in.`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold`,children:`herdr and tmux sessions`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`Each mirrors nothing, everything, or one scope, as a tab or window per active branch.`}),c.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`None yet. A session appears once the Switchyard plugin runs in it, or after switchyard clients bind.`}):(0,Z.jsx)(`ul`,{"data-testid":`client-list`,className:`overflow-hidden rounded-lg border border-border bg-surface`,children:c.map(e=>(0,Z.jsx)(Ln,{client:e,scopes:s,device:n[e.deviceId],hostName:e.hostId?o[e.hostId]?.name:void 0,onForget:()=>{F(null),M(e)}},e.id))})]}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Devices`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`Browsers, Home Screen apps and CLIs signed in here. Revoke one to sign it out. The preferred mobile device receives push notifications when no desktop was recently active.`}),(0,Z.jsx)(`ul`,{"data-testid":`device-list`,className:`overflow-hidden rounded-lg border border-border bg-surface`,children:p.map(e=>{let t=e.id===d,n=e.kind===`browser`||e.kind===`pwa`,r=c.filter(t=>t.deviceId===e.id).length;return(0,Z.jsxs)(`li`,{"data-testid":`device-row`,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,Z.jsx)(Nn,{kind:e.kind}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-[1_1_14rem] flex-col gap-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.name}),t&&(0,Z.jsx)(K,{icon:tn,tone:`info`,label:`This device`}),e.preferredMobile&&(0,Z.jsx)(K,{icon:un,tone:`success`,label:`Preferred mobile`})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-muted`,children:[(0,Z.jsx)(`span`,{children:jn[e.kind]}),(0,Z.jsxs)(`span`,{children:[`Last seen `,T(e.lastSeenAt)]}),n&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e.push.subscribed?(0,Z.jsx)(Gt,{"aria-hidden":!0,className:`size-4 shrink-0`}):(0,Z.jsx)(ge,{"aria-hidden":!0,className:`size-4 shrink-0`}),e.push.subscribed?`Push subscribed`:`No push subscription`,`, permission `,Mn[e.push.permission]]}),r>0&&(0,Z.jsxs)(`span`,{children:[r,` herdr or tmux session`,r===1?``:`s`]})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n&&!e.preferredMobile&&(0,Z.jsx)(b,{size:`sm`,icon:(0,Z.jsx)(un,{className:`size-4`}),busy:I===e.id,onClick:()=>re(e),children:`Set as preferred mobile device`}),(0,Z.jsx)(b,{size:`sm`,variant:`ghost`,"data-testid":`device-rename`,icon:(0,Z.jsx)(Ee,{className:`size-4`}),onClick:()=>{C(null),_(e.name),h(e)},children:`Rename`}),(0,Z.jsx)(b,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,Z.jsx)(on,{className:`size-4`}),onClick:()=>{A(null),E(e)},children:`Revoke`})]})]},e.id)})})]})]}):(0,Z.jsx)(v,{label:`Loading clients…`}),(0,Z.jsx)(B,{open:j!==null,onClose:()=>M(null),title:j?`Forget ${j.kind} ${j.name}?`:`Forget client`,confirmLabel:`Forget client`,busy:ee,error:P,onConfirm:ne,children:(0,Z.jsx)(`p`,{className:`text-sm`,children:`What it mirrors is no longer recorded. The session appears again once its plugin runs.`})}),(0,Z.jsx)(B,{open:m!==null,onClose:()=>h(null),title:`Rename device`,confirmLabel:`Save`,danger:!1,busy:y,error:S,confirmDisabled:!g.trim(),onConfirm:ie,children:(0,Z.jsx)(U,{"aria-label":`Device name`,maxLength:80,value:g,autoComplete:`off`,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&g.trim()&&!y&&ie()}})}),(0,Z.jsxs)(B,{open:w!==null,onClose:()=>E(null),title:w?`Revoke ${w.name}?`:`Revoke device`,confirmLabel:`Revoke device`,busy:D,error:k,onConfirm:L,children:[(0,Z.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.`}),w&&c.some(e=>e.deviceId===w.id)&&(0,Z.jsx)(`p`,{className:`text-sm`,children:`The herdr and tmux sessions signed in with it stop updating.`}),w?.id===d&&(0,Z.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 zn(){let e=Se(e=>e.sendWithEnter),t=Se(e=>e.transcriptDetail),n=Se(e=>e.followUpMode),r=Se(e=>e.set),i=qe(),a=Ke();Ze(e=>e.me);let o=Dt(),s=l(e=>o?e.devices[o]:void 0);return(0,Z.jsxs)(G,{title:`This device`,description:`These preferences are stored in this browser only; your other devices keep their own.`,children:[(0,Z.jsx)(J,{title:`Navigation`,description:`Which pages the phone's bottom bar shows, and the order of all of them.`,testId:`navigation-settings`,children:(0,Z.jsx)(Ut,{})}),(0,Z.jsx)(J,{title:`Composer`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(Pt,{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=>r(`sendWithEnter`,e)}),(0,Z.jsxs)(`p`,{className:`text-sm text-muted`,children:[`On mobile, Return always inserts a newline and messages are sent with the Send button.`,i===`mobile`||a?` That applies on this device now.`:``]}),(0,Z.jsx)(Nt,{legend:`While Pi is working`,value:n,onChange:e=>r(`followUpMode`,e),hint:`Cmd/Ctrl+Enter, or the + menu, does the other.`,options:[{value:`queue`,label:`Queue`,explanation:`Send queues your message. Pi reads it when the current turn ends.`},{value:`steer`,label:`Steer`,explanation:`Send delivers your message now, between Pi's tool calls, when the session supports it.`}]})]})}),(0,Z.jsx)(J,{title:`Transcript`,children:(0,Z.jsx)(Nt,{legend:`Tool activity`,value:t,onChange:e=>r(`transcriptDetail`,e),options:[{value:`detailed`,label:`Detailed`,explanation:`Every tool call stays visible as its own line.`},{value:`normal`,label:`Normal`,explanation:`A finished turn folds its tool calls into one line. The reply always shows.`},{value:`summary`,label:`Summary`,explanation:`A running turn folds too: one line that says what Pi is doing.`}]})}),(0,Z.jsx)(J,{title:`Identity`,children:(0,Z.jsx)(Et,{items:[[`Name`,s?.name??`Unknown`],[`Kind`,s?jn[s.kind]:`Unknown`],[`Device ID`,(0,Z.jsx)(`span`,{className:`break-all font-mono`,children:o??`Unknown`},`id`)]]})})]})}var Q=e=>e==null||e===``?`Unknown`:String(e);function Bn(){let e=Ce(gn,hn),t=e.data,n=Sn(Array.isArray(t?.diagnostics)?t.diagnostics:void 0),r=l(e=>e.hosts),i=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(b,{icon:(0,Z.jsx)(xe,{className:`size-4`}),disabled:!t,onClick:()=>t&&ye(JSON.stringify(t,null,2),`Diagnostics JSON copied`),children:`Copy diagnostics JSON`}),(0,Z.jsx)(b,{busy:e.loading&&!!t,icon:(0,Z.jsx)(c,{className:`size-4`}),onClick:e.reload,children:`Refresh`})]}),a;if(e.fatal)a=(0,Z.jsx)(re,{error:e.error,diagnosticsHref:`/settings/diagnostics`});else if(e.error&&!e.loading&&!t)a=(0,Z.jsx)(P,{title:`Could not load diagnostics`,error:e.error,onRetry:e.reload});else if(!t)a=(0,Z.jsx)(v,{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,Z.jsxs)(Z.Fragment,{children:[e.error&&!e.loading?(0,Z.jsx)(P,{compact:!0,title:`Refresh failed`,error:e.error,onRetry:e.reload}):null,(0,Z.jsx)(J,{title:`Versions`,children:(0,Z.jsx)(`div`,{className:`overflow-x-auto overscroll-x-contain`,children:(0,Z.jsxs)(`table`,{className:`w-full min-w-0 text-left text-sm`,children:[(0,Z.jsx)(`thead`,{children:(0,Z.jsxs)(`tr`,{className:`border-b border-border text-muted`,children:[(0,Z.jsx)(`th`,{scope:`col`,className:`py-1 pr-4 font-medium`,children:`Component`}),(0,Z.jsx)(`th`,{scope:`col`,className:`py-1 font-medium`,children:`Version`})]})}),(0,Z.jsxs)(`tbody`,{children:[Object.entries(t.versions).map(([e,t])=>(0,Z.jsxs)(`tr`,{className:`border-b border-border last:border-b-0`,children:[(0,Z.jsx)(`th`,{scope:`row`,className:`py-1 pr-4 font-normal capitalize`,children:e}),(0,Z.jsx)(`td`,{className:`py-1 font-mono break-all`,children:Q(t)})]},e)),(0,Z.jsxs)(`tr`,{children:[(0,Z.jsx)(`th`,{scope:`row`,className:`py-1 pr-4 font-normal`,children:`Supported Pi`}),(0,Z.jsx)(`td`,{className:`py-1 font-mono`,children:ie})]})]})]})})}),(0,Z.jsx)(J,{title:`Coordinator`,children:(0,Z.jsx)(Et,{items:[[`Database migration`,(0,Z.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`span`,{children:[`Level `,Q(t.migrationLevel),` of `,Q(t.latestMigration)]}),i?(0,Z.jsx)(K,{icon:jt,tone:`success`,label:`Up to date`}):(0,Z.jsx)(K,{icon:le,tone:`warning`,label:`Behind latest`})]},`m`)],[`Public URL`,(0,Z.jsx)(`span`,{className:`break-all`,children:Q(t.publicUrl)},`u`)],[`Events`,t.events?`Seq ${Q(t.events.minSeq)} to ${Q(t.events.maxSeq)} stored (current ${Q(t.events.currentSeq)}, oldest retained ${Q(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`}, ${Q(t.push.subscriptions)} subscription(s)`:`Unknown`],[`Connected clients`,`${Q(t.clients?.connectedDevices)} device(s)`]]})}),(0,Z.jsx)(J,{title:`Hosts`,children:o.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No hosts enrolled.`}):(0,Z.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:o.map(e=>{let t=r[e.id];return(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1 py-2 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,Z.jsx)(Je,{kind:`host`,value:t?.connectivity??e.connectivity}),(0,Z.jsx)(Qe,{host:e})]}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Agent `,Q(e.agentVersion),` · Last seen `,T(e.lastSeenAt)]}),e.unsupported&&e.unsupported.length>0&&(0,Z.jsx)(`ul`,{className:`list-disc pl-5 text-xs text-muted`,children:e.unsupported.map(e=>(0,Z.jsxs)(`li`,{className:`break-words`,children:[e.capability,`: `,e.reason]},e.capability))})]},e.id)})})}),(0,Z.jsx)(J,{title:`Recent diagnostics`,children:n.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No diagnostics recorded.`}):(0,Z.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:n.slice(0,100).map((e,t)=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-2 text-sm`,children:[(0,Z.jsx)(xn,{level:e.level}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[e.message,e.adapterId&&(0,Z.jsxs)(`span`,{className:`block text-xs text-muted`,children:[`Adapter `,e.adapterId]})]}),(0,Z.jsx)(`time`,{dateTime:e.at,className:`text-xs text-muted`,children:p(e.at)})]},`${e.at}-${t}`))})})]})}return(0,Z.jsxs)(G,{title:`Diagnostics`,description:`Versions, database state, hosts and recent problems. Copy the JSON when reporting a problem.`,actions:i,children:[(0,Z.jsx)(R,{}),a]})}function Vn(e){return f(`/api/enrollments`,{kind:e})}function Hn({expiresAt:e,onRenew:t,busy:n}){let r=tt(e);return r!==null&&r<=0?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,role:`status`,children:[(0,Z.jsx)(le,{"aria-hidden":!0,className:`size-4 shrink-0 text-warning`}),(0,Z.jsx)(`span`,{className:`font-medium`,children:`Expired: create a new link`}),(0,Z.jsx)(b,{size:`sm`,busy:n,icon:(0,Z.jsx)(c,{className:`size-4`}),onClick:t,children:`Create new link`})]}):(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted`,children:[(0,Z.jsx)(ft,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,Z.jsxs)(`span`,{children:[`Expires in`,` `,(0,Z.jsx)(`span`,{className:`font-mono tabular-nums`,children:r===null?`unknown`:ht(r)}),`. Single use.`]})]})}function Un({busy:e,error:t,onRetry:n}){return e?(0,Z.jsx)(v,{label:`Creating a single-use link…`}):t?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(h,{error:t}),(0,Z.jsx)(b,{icon:(0,Z.jsx)(c,{className:`size-4`}),onClick:n,children:`Retry`})]}):null}function Wn(e){let t=et(e),n=t.find(e=>!M(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 Gn(e,t=Date.now()){return e?e.state===`running`?`Scanning…`:e.state===`failed`?`Last scan failed ${T(e.finishedAt??e.startedAt,t)}: ${e.errors.at(-1)??`unknown error`}`:`Last scanned ${T(e.finishedAt,t)}: ${e.repositories} repositories, ${e.checkoutsAdded} new checkouts, ${e.projectsCreated} new projects.`:`Not scanned yet.`}function Kn({host:e}){let t=(0,X.useId)(),n=(e.projectFolders??[]).join(`
|
|
2
|
+
`),[r,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,d]=(0,X.useState)(null),p=r??n,m=r!==null&&r!==n,{folders:g,problem:_}=Wn(p),v=e.projectScan,y=s||v?.state===`running`,x=e.connectivity===`connected`,S=n?x?y?`A scan is running`:null:`${e.name} is offline`:`Save a folder first`,C=async()=>{o(!0),d(null);try{await u(`/api/hosts/${encodeURIComponent(e.id)}`,{projectFolders:g}),W.success(`Project folders saved`),i(null)}catch(e){d(e)}finally{o(!1)}},w=async()=>{c(!0),d(null);try{let t=await f(`/api/hosts/${encodeURIComponent(e.id)}/scan-projects`);W.success(`Found ${t.repositories} repositories; ${t.projectsCreated} new projects`)}catch(e){d(e)}finally{c(!1)}},T=m?_:null;return(0,Z.jsx)(J,{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,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Z.jsx)(H,{id:`${t}-folders`,label:`Folders on this host`,hint:`One per line: an absolute path or ~/..., e.g. ~/Projects.`,error:T,children:(0,Z.jsx)(ot,{id:`${t}-folders`,value:p,onChange:e=>i(e.target.value),minRows:3,placeholder:`~/Projects`,className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,autoComplete:`off`,...V(`${t}-folders`,{hint:!0,error:T})})}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(b,{variant:`primary`,icon:(0,Z.jsx)(Oe,{className:`size-4`}),busy:a,disabled:!m||!!_,onClick:C,children:`Save folders`}),(0,Z.jsx)(b,{icon:(0,Z.jsx)($t,{className:`size-4`}),busy:s,disabled:!!S,title:S??void 0,onClick:w,children:`Scan now`})]}),(0,Z.jsx)(`p`,{"aria-live":`polite`,className:`text-sm text-muted`,children:s?`Scanning…`:Gn(v)}),v&&v.state!==`running`&&v.errors.length>0&&(0,Z.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-0.5 text-xs text-muted`,children:v.errors.map(e=>(0,Z.jsx)(`li`,{className:`break-words`,children:e},e))}),(0,Z.jsx)(h,{error:l})]})})}var qn={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 Jn(){let e=nt(),t=a(),[n,r]=(0,X.useState)(!1),i=t.filter(e=>e.connectivity!==`connected`);return(0,Z.jsxs)(G,{testId:`settings-hosts`,title:`Hosts`,description:`Machines that run Pi sessions through the Switchyard host agent.`,actions:(0,Z.jsx)(b,{variant:`primary`,icon:(0,Z.jsx)(De,{className:`size-4`}),onClick:()=>r(!0),children:`Add host`}),children:[(0,Z.jsx)(R,{}),e?t.length===0?(0,Z.jsx)(z,{icon:(0,Z.jsx)(lt,{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,Z.jsxs)(Z.Fragment,{children:[i.length===1&&(0,Z.jsx)(O,{compact:!0,hostName:i[0].name,connectivity:i[0].connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:i[0].lastSeenAt}),i.length>1&&(0,Z.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,Z.jsx)(g,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-danger`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-medium`,children:Yn(i.map(e=>e.name))}),(0,Z.jsx)(`div`,{className:`text-muted`,children:`Work on them keeps its last known state; nothing is restarted elsewhere.`})]})]}),(0,Z.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:t.map(e=>(0,Z.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,Z.jsx)(Xn,{host:e})},e.id))})]}):(0,Z.jsx)(v,{label:`Loading hosts…`}),(0,Z.jsx)($n,{open:n,onClose:()=>r(!1)})]})}function Yn(e){return`${e.length} hosts are not connected: ${e.join(`, `)}`}function Xn({host:e}){return(0,Z.jsxs)(k,{to:q(`hosts/${encodeURIComponent(e.id)}`),state:rt,className:`tap flex min-w-0 items-center gap-3 px-4 py-3 hover:bg-surface-2`,children:[(0,Z.jsx)(lt,{"aria-hidden":!0,className:`size-5 shrink-0 self-center text-muted`}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.name}),(0,Z.jsx)(`span`,{className:`text-sm text-muted`,children:it[e.platform]})]}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(Je,{kind:`host`,value:e.connectivity}),(0,Z.jsx)(Qe,{host:e}),e.connectivity!==`connected`&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Last seen `,T(e.lastSeenAt)]})]})]}),(0,Z.jsx)(ve,{"aria-hidden":!0,className:`size-4 shrink-0 self-center text-subtle`})]})}var Zn=`@spencerboucher/switchyard`;function Qn(e){return[`npm install -g ${Zn}`,e,`switchyard host install-service`].join(`
|
|
3
|
+
`)}function $n({open:e,onClose:t}){let[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(null),c=async()=>{a(!0),s(null);try{r(await Vn(`host`))}catch(e){s(e)}finally{a(!1)}},l=()=>{r(null),s(null),t()};return(0,Z.jsx)(de,{open:e,onClose:l,title:`Add host`,description:`Enroll a machine that runs Pi. Provider credentials stay on that machine.`,footer:(0,Z.jsx)(b,{onClick:l,children:`Done`}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!n&&!i&&!o&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.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,Z.jsx)(b,{variant:`primary`,onClick:c,children:`Create enrollment command`})]}),(0,Z.jsx)(Un,{busy:i,error:o,onRetry:c}),n&&!i&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.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,Z.jsx)(be,{text:n.command?Qn(n.command):n.url,label:n.command?`Host setup commands`:`Host enrollment link`,copyLabel:`Copy commands`}),(0,Z.jsx)(Hn,{expiresAt:n.expiresAt,onRenew:c,busy:i})]})]})})}function er(){let{hostId:e=``}=te(),t=nt(),n=l(t=>t.hosts[e]),r=l(t=>t.adapters[e]),i=l(e=>e.checkouts),a=l(e=>e.projects),o=w(),[s,c]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null),g=(0,X.useMemo)(()=>Object.values(i).filter(t=>t.hostId===e).sort((e,t)=>e.path.localeCompare(t.path)),[i,e]),_={to:q(`hosts`),label:`Hosts`};if(!t)return(0,Z.jsx)(G,{title:`Host`,back:_,children:(0,Z.jsx)(v,{label:`Loading host…`})});if(!n||n.revokedAt)return(0,Z.jsx)(G,{title:`Host`,back:_,children:(0,Z.jsx)(z,{icon:(0,Z.jsx)(lt,{className:`size-8`}),title:n?`This host was revoked`:`Host not found`,description:n?`${n.name} was revoked ${T(n.revokedAt)}. Add it again to use it.`:`It may have been revoked or never enrolled with this coordinator.`,action:{label:`Back to hosts`,to:q(`hosts`)}})});let y=async()=>{d(!0),h(null);try{await f(`/api/hosts/${encodeURIComponent(n.id)}/revoke`),W.success(`Host ${n.name} revoked`),c(!1),o(q(`hosts`))}catch(e){h(e)}finally{d(!1)}},x=n.capabilities,S=e=>x?.unsupported.find(t=>t.capability===e)?.reason,C=x?.unsupported.filter(e=>!L.includes(e.capability))??[];return(0,Z.jsxs)(G,{title:n.name,description:`${it[n.platform]} host`,back:_,children:[(0,Z.jsx)(R,{}),n.connectivity!==`connected`&&(0,Z.jsx)(O,{compact:!0,hostName:n.name,connectivity:n.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:n.lastSeenAt}),(0,Z.jsx)(J,{title:`Connectivity and versions`,children:(0,Z.jsx)(Et,{items:[[`Status`,(0,Z.jsx)(Je,{kind:`host`,value:n.connectivity},`s`)],[`Last seen`,n.lastSeenAt?`${T(n.lastSeenAt)} (${p(n.lastSeenAt)})`:`Never`],[`Platform`,it[n.platform]],[`Agent version`,(0,Z.jsx)(`span`,{className:`font-mono`,children:n.agentVersion},`a`)],[`Pi`,(0,Z.jsx)(Qe,{host:n},`p`)],[`Enrolled`,p(n.createdAt)]]})}),n.usage&&n.usage.length>0&&(0,Z.jsx)(J,{title:`Subscription usage`,children:(0,Z.jsx)(Et,{items:n.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 ${T(e.resetsAt)}`).join(`; `)||`No limits reported`:e.message??e.status])})}),(0,Z.jsx)(J,{title:`Capabilities`,description:`What Pi on this host supports. Unsupported features are hidden or explained in sessions.`,children:x?(0,Z.jsxs)(`ul`,{className:`grid min-w-0 gap-2 sm:grid-cols-2`,children:[L.map(e=>{let t=x[e],n=S(e);return(0,Z.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[t?(0,Z.jsx)(jt,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-success`}):(0,Z.jsx)(_t,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:qn[e]}),(0,Z.jsxs)(`span`,{className:`text-muted`,children:[`: `,t?`Supported`:`Not supported`]}),!t&&n&&(0,Z.jsx)(`span`,{className:`block break-words text-xs text-muted`,children:n})]})]},e)}),C.map(e=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[(0,Z.jsx)(_t,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`font-medium break-words`,children:e.capability}),(0,Z.jsx)(`span`,{className:`text-muted`,children:`: Not supported`}),(0,Z.jsx)(`span`,{className:`block break-words text-xs text-muted`,children:e.reason})]})]},e.capability))]}):(0,Z.jsx)(ae,{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,Z.jsx)(Kn,{host:n}),(0,Z.jsx)(J,{title:`Checkout mappings`,description:`Project clones on this host. Sessions and runs for a project use these paths.`,children:g.length===0?(0,Z.jsx)(z,{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:q(`projects`)}}):(0,Z.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:g.map(e=>(0,Z.jsxs)(`li`,{className:`min-w-0 py-2 text-sm`,children:[(0,Z.jsx)(Mt,{to:q(`projects/${encodeURIComponent(e.projectId)}`),variant:`action`,children:a[e.projectId]?.name??`Unknown project`}),(0,Z.jsx)(`div`,{className:`break-all font-mono text-xs`,children:e.path}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Default branch: `,e.defaultBranch]})]},e.id))})}),(0,Z.jsx)(J,{title:`Adapters`,actions:(0,Z.jsx)(Mt,{to:q(`adapters`),size:`sm`,variant:`action`,children:`All adapters`}),children:!r||r.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No adapters reported by this host.`}):(0,Z.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:r.map(e=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm`,children:[(0,Z.jsx)(`span`,{className:`break-all font-mono`,children:e.id}),(0,Z.jsx)(`span`,{className:`text-muted`,children:e.version}),(0,Z.jsx)(vn,{status:e.status})]},e.id))})}),(0,Z.jsx)(ke,{description:`Revoking disconnects the host agent and invalidates its credential. Sessions on it are not moved elsewhere.`,children:(0,Z.jsx)(b,{variant:`danger`,icon:(0,Z.jsx)(on,{className:`size-4`}),onClick:()=>{h(null),c(!0)},children:`Revoke host`})}),(0,Z.jsx)(B,{open:s,onClose:()=>c(!1),title:`Revoke ${n.name}?`,confirmLabel:`Revoke host`,busy:u,error:m,onConfirm:y,children:(0,Z.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 tr={granted:{icon:Gt,label:`Allowed`,tone:`success`,guidance:`This device can show Switchyard notifications.`},denied:{icon:ge,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:kt,label:`Not requested yet`,tone:`neutral`,guidance:`Enable notifications to hear about sessions that need input, failed, or are ready for review.`},unknown:{icon:kt,label:`Unknown`,tone:`neutral`,guidance:`The browser did not report a permission state. Try enabling notifications.`},unsupported:{icon:_t,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 nr(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{return`UTC`}}function rr(e){let t=we(e)&&we(e.settings)?e.settings:e;return!we(t)||typeof t.privatePreviews!=`boolean`?null:{quietHours:we(t.quietHours)?t.quietHours:null,privatePreviews:t.privatePreviews,preferredDeviceId:typeof t.preferredDeviceId==`string`?t.preferredDeviceId:null}}function ir(){let[t,n]=(0,X.useState)(()=>wt()),[r,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(null),l=pt()&&!st();(0,X.useEffect)(()=>{let e=!0;mt().then(t=>e&&i(t!==null)).catch(()=>e&&i(!1));let t=()=>{document.visibilityState===`visible`&&n(wt())};return document.addEventListener(`visibilitychange`,t),()=>{e=!1,document.removeEventListener(`visibilitychange`,t)}},[]);let u=()=>{o(`enable`),c(null),ut().then(e=>{n(e),e===`granted`?(i(!0),W.success(`Notifications enabled on this device`)):e===`denied`&&W.error(`Notifications were blocked. Allow them in your browser settings.`)}).catch(e=>{c(e),n(wt())}).finally(()=>o(null))},d=async()=>{o(`disable`),c(null);try{await Ot(),i(!1),W.success(`Notifications disabled on this device`)}catch(e){c(e)}finally{o(null)}},f=async()=>{o(`test`),c(null);try{await At(),W.success(`Test notification sent. It can take a few seconds to arrive.`)}catch(t){c(t),W.error(`Test notification failed: ${e(t)}`)}finally{o(null)}},p=tr[t]??tr.unknown;return(0,Z.jsxs)(G,{testId:`settings-notifications`,title:`Notifications`,description:`Push notifications for sessions that need input, failed, or are ready for review.`,children:[(0,Z.jsx)(J,{title:`This device`,children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:`Permission:`}),(0,Z.jsx)(K,{icon:p.icon,label:p.label,tone:p.tone}),r!==null&&t===`granted`&&(0,Z.jsx)(`span`,{className:`text-muted`,children:r?`Subscribed to push`:`Not subscribed to push`})]}),(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:p.guidance}),l&&(0,Z.jsxs)(`div`,{className:`rounded-md border border-border bg-surface-2 p-3 text-sm`,children:[(0,Z.jsxs)(`p`,{className:`mb-2 flex items-center gap-2 font-medium`,children:[(0,Z.jsx)(cn,{"aria-hidden":!0,className:`size-4 shrink-0`}),`On iPhone and iPad, notifications need the Home Screen app`]}),(0,Z.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,Z.jsx)(`li`,{children:`Tap Share`}),(0,Z.jsx)(`li`,{children:`Add to Home Screen`}),(0,Z.jsx)(`li`,{children:`Open Switchyard from the Home Screen`}),(0,Z.jsx)(`li`,{children:`Enable notifications here`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t!==`unsupported`&&!(t===`granted`&&r)&&(0,Z.jsx)(b,{variant:`primary`,icon:(0,Z.jsx)(Gt,{className:`size-4`}),busy:a===`enable`,disabled:a!==null&&a!==`enable`,onClick:u,children:`Enable notifications`}),r&&(0,Z.jsx)(b,{icon:(0,Z.jsx)(ge,{className:`size-4`}),busy:a===`disable`,disabled:a!==null&&a!==`disable`,onClick:d,children:`Disable on this device`}),(0,Z.jsx)(b,{icon:(0,Z.jsx)(Re,{className:`size-4`}),busy:a===`test`,disabled:a!==null&&a!==`test`,onClick:f,children:`Send test notification`})]}),t===`unsupported`&&(0,Z.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,Z.jsx)(h,{error:s}),(0,Z.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,Z.jsx)(ar,{})]})}function ar(){let e=Ce(`/api/me/notification-settings`,e=>!!rr(e)),t=(0,X.useMemo)(()=>e.data?rr(e.data):null,[e.data]),n=e.error instanceof i&&e.error.status===404;return(0,Z.jsx)(J,{title:`Delivery preferences`,description:`Shared by all your devices. Attention items in Switchyard are unaffected.`,children:n?(0,Z.jsx)(ae,{capability:`Notification settings`,reason:`This coordinator does not expose notification settings yet`}):e.fatal?(0,Z.jsx)(re,{error:e.error}):e.error&&!e.loading&&!t?(0,Z.jsx)(P,{compact:!0,title:`Could not load notification settings`,error:e.error,onRetry:e.reload}):t?(0,Z.jsx)(sr,{settings:t,onSaved:t=>e.setData(t)}):(0,Z.jsx)(v,{label:`Loading notification settings…`})})}var or=/^\d{2}:\d{2}$/;function sr({settings:e,onSaved:t}){let n=(0,X.useId)(),r=l(e=>e.devices),i=(0,X.useMemo)(()=>Object.values(r).filter(e=>e.revokedAt===null).sort((e,t)=>e.name.localeCompare(t.name)),[r]),[a,o]=(0,X.useState)(e.quietHours!==null),[s,c]=(0,X.useState)(e.quietHours?.start??`22:00`),[d,f]=(0,X.useState)(e.quietHours?.end??`07:00`),[p,m]=(0,X.useState)(e.quietHours?.timezone??nr()),[g,_]=(0,X.useState)(e.privatePreviews),[v,y]=(0,X.useState)(e.preferredDeviceId??``),[x,S]=(0,X.useState)(!1),[C,w]=(0,X.useState)(null),T=a&&!or.test(s)?`Use a time like 22:00.`:null,E=a&&!or.test(d)?`Use a time like 07:00.`:null,D=a&&!p.trim()?`Enter a time zone, e.g. Europe/Berlin.`:null,O=!v||i.some(e=>e.id===v);return(0,Z.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:async e=>{if(e.preventDefault(),T||E||D)return;let n={quietHours:a?{start:s,end:d,timezone:p.trim()}:null,privatePreviews:g,preferredDeviceId:v||null};S(!0),w(null);try{t(rr(await u(`/api/me/notification-settings`,n))??n),W.success(`Notification preferences saved`)}catch(e){w(e)}finally{S(!1)}},noValidate:!0,children:[(0,Z.jsx)(Pt,{label:`Quiet hours`,description:`No push notifications during these hours. Attention items still collect in Switchyard.`,checked:a,onChange:o}),a&&(0,Z.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-3`,children:[(0,Z.jsx)(H,{id:`${n}-start`,label:`From`,error:T,children:(0,Z.jsx)(U,{id:`${n}-start`,type:`time`,value:s,onChange:e=>c(e.target.value),...V(`${n}-start`,{error:T})})}),(0,Z.jsx)(H,{id:`${n}-end`,label:`Until`,error:E,children:(0,Z.jsx)(U,{id:`${n}-end`,type:`time`,value:d,onChange:e=>f(e.target.value),...V(`${n}-end`,{error:E})})}),(0,Z.jsx)(H,{id:`${n}-tz`,label:`Time zone`,error:D,children:(0,Z.jsx)(U,{id:`${n}-tz`,value:p,onChange:e=>m(e.target.value),autoCapitalize:`off`,spellCheck:!1,...V(`${n}-tz`,{error:D})})})]}),(0,Z.jsx)(Pt,{label:`Private previews`,description:`Hide task and session text in notifications; show only the status, e.g. Needs input.`,checked:g,onChange:_}),(0,Z.jsx)(H,{id:`${n}-device`,label:`Preferred device`,hint:`Receives push when no desktop was recently active.`,children:(0,Z.jsxs)(Y,{id:`${n}-device`,value:v,onChange:e=>y(e.target.value),...V(`${n}-device`,{hint:!0}),children:[(0,Z.jsx)(`option`,{value:``,children:`Automatic (the preferred mobile device)`}),i.map(e=>(0,Z.jsxs)(`option`,{value:e.id,children:[e.name,e.push.subscribed?``:` (no push subscription)`]},e.id)),!O&&(0,Z.jsxs)(`option`,{value:v,children:[`Unknown device (`,v,`)`]})]})}),(0,Z.jsx)(h,{error:C}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(b,{type:`submit`,variant:`primary`,busy:x,icon:(0,Z.jsx)(Oe,{className:`size-4`}),children:`Save preferences`})})]})}function cr(e){return e.reduce((e,t)=>Math.max(e,t.id,`children`in t?cr(t.children):0),0)}function lr(e,t=``,n=`text`){return n===`object`||n===`list`?{id:e,key:t,kind:n,children:[]}:n===`boolean`?{id:e,key:t,kind:n,value:!1}:n===`null`?{id:e,key:t,kind:n}:{id:e,key:t,kind:n,value:``}}function ur({fields:e,onChange:t,disabled:n}){let r=(0,X.useRef)(cr(e)+1);r.current=Math.max(r.current,cr(e)+1);function i(e,t,a,o){return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[e.map((r,s)=>{let c=`${a===`argument`?`Argument`:a===`field`?`Field`:`Item`} ${s+1}`,l=n=>t(e.map(e=>e.id===r.id?n:e));return(0,Z.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-2 rounded-md border border-border p-2`,children:[(0,Z.jsx)(`legend`,{children:c}),a!==`item`&&(0,Z.jsxs)(`label`,{htmlFor:`sample-${r.id}-name`,children:[`Name`,(0,Z.jsx)(U,{id:`sample-${r.id}-name`,value:r.key,disabled:n,onChange:e=>l({...r,key:e.target.value})})]}),(0,Z.jsxs)(`label`,{htmlFor:`sample-${r.id}-type`,children:[`Type`,(0,Z.jsxs)(Y,{id:`sample-${r.id}-type`,value:r.kind,disabled:n,onChange:e=>l(lr(r.id,r.key,e.target.value)),children:[(0,Z.jsx)(`option`,{value:`text`,children:`Text`}),(0,Z.jsx)(`option`,{value:`number`,children:`Number`}),(0,Z.jsx)(`option`,{value:`boolean`,children:`Yes / No`}),(0,Z.jsx)(`option`,{value:`null`,children:`None`}),(0,Z.jsx)(`option`,{value:`object`,children:`Object`}),(0,Z.jsx)(`option`,{value:`list`,children:`List`})]})]}),r.kind===`text`&&(0,Z.jsxs)(`label`,{htmlFor:`sample-${r.id}-value`,children:[`Value`,(0,Z.jsx)(ot,{id:`sample-${r.id}-value`,value:r.value,disabled:n,onChange:e=>l({...r,value:e.target.value})})]}),r.kind===`number`&&(0,Z.jsxs)(`label`,{htmlFor:`sample-${r.id}-value`,children:[`Value`,(0,Z.jsx)(U,{id:`sample-${r.id}-value`,inputMode:`decimal`,value:r.value,disabled:n,onChange:e=>l({...r,value:e.target.value})})]}),r.kind===`boolean`&&(0,Z.jsxs)(`label`,{htmlFor:`sample-${r.id}-value`,children:[`Value`,(0,Z.jsxs)(Y,{id:`sample-${r.id}-value`,value:r.value?`yes`:`no`,disabled:n,onChange:e=>l({...r,value:e.target.value===`yes`}),children:[(0,Z.jsx)(`option`,{value:`no`,children:`No`}),(0,Z.jsx)(`option`,{value:`yes`,children:`Yes`})]})]}),(r.kind===`object`||r.kind===`list`)&&i(r.children,e=>l({...r,children:e}),r.kind===`object`?`field`:`item`,o+1),(0,Z.jsxs)(b,{disabled:n,onClick:()=>t(e.filter(e=>e.id!==r.id)),children:[`Remove `,c]})]},r.id)}),o<20&&(0,Z.jsxs)(b,{disabled:n,onClick:()=>t([...e,lr(r.current++)]),children:[`Add `,a]})]})}return(0,Z.jsxs)(`fieldset`,{className:`min-w-0`,children:[(0,Z.jsx)(`legend`,{children:`Sample arguments`}),i(e,t,`argument`,0)]})}var dr=e=>`/api/policies/${encodeURIComponent(e)}`,fr={list:()=>d(`/api/policies`),create:e=>f(`/api/policies`,e),update:(e,t)=>u(dr(e),t),remove:(e,t)=>ne(dr(e),{method:`DELETE`,query:{expectedRevision:t}}),settings:()=>d(`/api/policies/settings`),updateSettings:e=>o(`/api/policies/settings`,e),test:e=>f(`/api/policies/test`,e)},pr=new Set([`__proto__`,`prototype`,`constructor`]),mr=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function hr(e,t){function n(e,t,i){if(i>20)throw Error(`Sample arguments are nested too deeply.`);switch(e.kind){case`text`:return e.value;case`boolean`:return e.value;case`null`:return null;case`number`:{let n=Number(e.value);if(!mr.test(e.value)||!Number.isFinite(n)||Number.isInteger(n)&&!Number.isSafeInteger(n))throw Error(`Enter a valid number for ${t}.`);return n}case`object`:return r(e.children,t,i);case`list`:return e.children.map((e,r)=>n(e,`${t}[${r}]`,i+1))}}function r(e,t,r,i=[]){let a=[...i],o=new Set(a.map(([e])=>e));return e.forEach((e,i)=>{if(!e.key.trim())throw Error(`${t?`${t}: Field`:`Argument`} ${i+1} needs a name.`);let s=t?`${t}.${e.key}`:e.key;if(pr.has(e.key))throw Error(`Reserved field name: ${s}.`);if(o.has(e.key))throw Error(`Duplicate field: ${s}.`);o.add(e.key),a.push([e.key,n(e,s,r+1)])}),Object.fromEntries(a)}return r(e,``,0,t?.trim()?[[`command`,t]]:[])}var $=`w-full rounded-md border border-border bg-surface px-2 py-1 text-sm`,gr=()=>({scope:`server`,scopeId:``,name:``,priority:`0`,enabled:!0,phases:[`tool_call`],expression:``}),_r=e=>({...e,scopeId:e.scopeId??``,priority:String(e.priority)});function vr(){let t=l(e=>e.sessions),n=l(e=>e.profiles),[r,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(null),[c,u]=(0,X.useState)([]),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(gr),[h,g]=(0,X.useState)(``),[_,v]=(0,X.useState)(!1),[y,x]=(0,X.useState)(``),[S,C]=(0,X.useState)(`tool_call`),[w,T]=(0,X.useState)(`bash`),[E,D]=(0,X.useState)(``),[O,k]=(0,X.useState)([]),j=S===`tool_call`&&[`bash`,`powershell`].includes(w.trim().toLowerCase()),[M,ee]=(0,X.useState)(),[N,P]=(0,X.useState)(),[F,I]=(0,X.useState)(null),[te,L]=(0,X.useState)(``),ne=(0,X.useCallback)(async()=>{let[e,t]=await Promise.all([fr.list(),fr.settings()]);a(e),s(t),u(t.modelClassifications)},[]);(0,X.useEffect)(()=>{ne().catch(t=>g(e(t)))},[ne]);let re=async(t,n=!1)=>{v(!0),g(``),ee(void 0),n&&(L(``),P(void 0));try{await t()}catch(t){(n?L:g)(e(t)),(n?P:ee)(t instanceof i?t.details:void 0)}finally{v(!1)}};return(0,Z.jsxs)(G,{title:`Policies`,description:`Guardrails for tool calls and API requests; not an OS sandbox.`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:Ge}),h&&(0,Z.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[h,M!==void 0&&(0,Z.jsx)(Le,{value:M})]}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h2`,{className:`font-semibold`,children:`Rules`}),r.length===0&&(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No rules.`}),r.map(e=>(0,Z.jsxs)(`article`,{className:`rounded-md border border-border p-3 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`strong`,{children:e.name}),(0,Z.jsxs)(`span`,{children:[e.builtIn?`Built-in`:`Custom`,` · `,e.scope,e.scopeId?`: ${e.scopeId}`:``,` · priority `,e.priority,` ·`,` `,e.phases.map(e=>e===`tool_call`?`Tool call`:`API request`).join(`, `)]}),(0,Z.jsx)(b,{size:`sm`,onClick:()=>{f(e),m(_r(e))},children:`Edit`}),(0,Z.jsx)(b,{size:`sm`,disabled:_,onClick:()=>void re(async()=>{await fr.update(e.id,{expectedRevision:e.revision,enabled:!e.enabled}),await ne()}),children:e.enabled?`Disable`:`Enable`}),!e.builtIn&&(0,Z.jsx)(b,{size:`sm`,disabled:_,onClick:()=>{window.confirm(`Delete ${e.name}?`)&&re(async()=>{await fr.remove(e.id,e.revision),await ne()})},children:`Delete`})]}),(0,Z.jsx)(`p`,{children:e.enabled?`Enabled`:`Disabled`}),(0,Z.jsx)(`pre`,{className:`overflow-auto overscroll-contain whitespace-pre-wrap break-words`,children:e.expression})]},e.id))]}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h2`,{className:`font-semibold`,children:d?`Edit ${d.name}`:`New rule`}),(0,Z.jsxs)(`label`,{children:[`Name`,(0,Z.jsx)(`input`,{className:$,value:p.name,onChange:e=>m({...p,name:e.target.value})})]}),(0,Z.jsxs)(`label`,{children:[`Scope`,(0,Z.jsxs)(`select`,{className:$,disabled:!!d,value:p.scope,onChange:e=>m({...p,scope:e.target.value,scopeId:``}),children:[(0,Z.jsx)(`option`,{value:`server`,children:`Server`}),(0,Z.jsx)(`option`,{value:`profile`,children:`Profile`}),(0,Z.jsx)(`option`,{value:`session`,children:`Session`})]})]}),p.scope!==`server`&&(0,Z.jsxs)(`label`,{children:[p.scope===`profile`?`Profile`:`Session`,(0,Z.jsxs)(`select`,{className:$,disabled:!!d,value:p.scopeId,onChange:e=>m({...p,scopeId:e.target.value}),children:[(0,Z.jsx)(`option`,{value:``,children:`Choose…`}),p.scope===`profile`?Object.values(n).map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)):Object.values(t).map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),(0,Z.jsxs)(`label`,{children:[`Priority`,(0,Z.jsx)(`input`,{className:$,type:`number`,value:p.priority,onChange:e=>m({...p,priority:e.target.value})})]}),(0,Z.jsxs)(`label`,{children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:p.enabled,onChange:e=>m({...p,enabled:e.target.checked})}),` `,`Enabled`]}),(0,Z.jsxs)(`fieldset`,{children:[(0,Z.jsx)(`legend`,{children:`Phases`}),[[`tool_call`,`Tool call`],[`request`,`API request`]].map(([e,t])=>(0,Z.jsxs)(`label`,{className:`mr-4`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:p.phases.includes(e),onChange:t=>m({...p,phases:t.target.checked?[...p.phases,e]:p.phases.filter(t=>t!==e)})}),` `,t]},e))]}),(0,Z.jsxs)(`label`,{children:[`CEL expression`,(0,Z.jsx)(`textarea`,{className:$,rows:5,value:p.expression,onChange:e=>m({...p,expression:e.target.value})})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(b,{disabled:_,onClick:()=>re(async()=>{if(!p.priority.trim())throw Error(`Priority: enter a whole number.`);let e=Ue({...p,scopeId:p.scope===`server`?null:p.scopeId,priority:Number(p.priority)});if(!e.success)throw Error(e.error.issues.map(e=>`${e.path.join(`.`)||`Rule`}: ${e.message}`).join(`; `));if(d){let{name:t,priority:n,enabled:r,phases:i,expression:a}=e.data;await fr.update(d.id,{expectedRevision:d.revision,name:t,priority:n,enabled:r,phases:i,expression:a})}else await fr.create(e.data);f(null),m(gr()),await ne()}),children:`Save rule`}),d&&(0,Z.jsx)(b,{onClick:()=>{f(null),m(gr())},children:`Cancel`})]})]}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h2`,{className:`font-semibold`,children:`Model classification`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`Unknown models count as expensive.`}),c.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsxs)(`label`,{children:[`Provider`,(0,Z.jsx)(`input`,{className:$,value:e.provider,onChange:e=>u(c.map((n,r)=>r===t?{...n,provider:e.target.value}:n))})]}),(0,Z.jsxs)(`label`,{children:[`Model ID`,(0,Z.jsx)(`input`,{className:$,value:e.modelId,onChange:e=>u(c.map((n,r)=>r===t?{...n,modelId:e.target.value}:n))})]}),(0,Z.jsxs)(`label`,{children:[`Classification`,(0,Z.jsxs)(`select`,{className:$,value:e.classification,onChange:e=>u(c.map((n,r)=>r===t?{...n,classification:e.target.value}:n)),children:[(0,Z.jsx)(`option`,{value:`cheap`,children:`Cheap`}),(0,Z.jsx)(`option`,{value:`expensive`,children:`Expensive`})]})]}),(0,Z.jsx)(b,{onClick:()=>u(c.filter((e,n)=>t!==n)),children:`Remove`})]},`${t}-${o?.revision}`)),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(b,{onClick:()=>u([...c,{provider:``,modelId:``,classification:`expensive`}]),children:`Add model`}),(0,Z.jsx)(b,{disabled:_||!o,onClick:()=>re(async()=>{if(!o)return;let e=Ve({expectedRevision:o.revision,modelClassifications:c});if(!e.success)throw Error(e.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `));await fr.updateSettings(e.data),await ne()}),children:`Save classifications`})]})]}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h2`,{className:`font-semibold`,children:`Test rules`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`Read-only policy test. The sample command is not executed. No approval or counter update is applied; a test result is not permission to execute later.`}),te&&(0,Z.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[te,N!==void 0&&(0,Z.jsx)(Le,{value:N})]}),(0,Z.jsxs)(`label`,{children:[`Session`,(0,Z.jsxs)(`select`,{className:$,value:y,disabled:_,onChange:e=>{x(e.target.value),I(null),L(``),P(void 0)},children:[(0,Z.jsx)(`option`,{value:``,children:`Choose…`}),Object.values(t).map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),(0,Z.jsxs)(`label`,{children:[`Phase`,(0,Z.jsxs)(`select`,{className:$,value:S,disabled:_,onChange:e=>{let t=e.target.value;C(t),T(t===`tool_call`?`bash`:`task.create`),I(null),L(``),P(void 0)},children:[(0,Z.jsx)(`option`,{value:`tool_call`,children:`Tool call`}),(0,Z.jsx)(`option`,{value:`request`,children:`API request`})]})]}),S===`tool_call`?(0,Z.jsxs)(`label`,{children:[`Tool name`,(0,Z.jsx)(`input`,{className:$,disabled:_,value:w,onChange:e=>{T(e.target.value),I(null),L(``),P(void 0)}})]}):(0,Z.jsxs)(`label`,{children:[`Action`,(0,Z.jsx)(`select`,{className:$,disabled:_,value:w,onChange:e=>{T(e.target.value),I(null),L(``),P(void 0)},children:A.options.map(e=>(0,Z.jsx)(`option`,{children:e},e))})]}),j&&(0,Z.jsxs)(`label`,{children:[`Command`,(0,Z.jsx)(`textarea`,{className:$,rows:4,disabled:_,value:E,onChange:e=>D(e.target.value)})]}),(0,Z.jsx)(ur,{fields:O,onChange:k,disabled:_}),(0,Z.jsx)(b,{disabled:_,onClick:()=>re(async()=>{I(null);let e=hr(O,j?E:void 0),t=Be({sessionId:y,phase:S,tool:S===`tool_call`?{name:w,args:e}:null,request:S===`request`?{method:w,args:e}:null});if(!t.success)throw Error(t.error.issues.map(e=>`${e.path.join(`.`)||`Test`}: ${e.message}`).join(`; `));I(await fr.test(t.data))},!0),children:`Test`}),F&&(0,Z.jsxs)(`div`,{className:`rounded-md border border-border p-3 text-sm`,children:[(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`strong`,{children:He(F.verdict)}),F.reason&&`: ${F.reason}`]}),(0,Z.jsx)(`p`,{children:F.enforcement.explanation}),(0,Z.jsxs)(`p`,{children:[`Enforced phases: `,F.enforcement.phases.join(`, `)||`Not enforced`,`. Pre-provider: Not enforced.`]}),(0,Z.jsx)(`ul`,{children:F.trace.map(e=>(0,Z.jsxs)(`li`,{children:[e.ruleId,` (revision `,e.ruleRevision,`): `,He(e.verdict),e.reason&&` — ${e.reason}`,e.granted&&` · granted`,e.overridden&&` · overridden`]},e.ruleId))}),(0,Z.jsx)(`p`,{children:`Proposed updates (not applied):`}),Object.entries(F.proposedStateUpdates).filter(([,e])=>Object.keys(e).length>0).length===0?(0,Z.jsx)(`p`,{children:`No proposed updates.`}):Object.entries(F.proposedStateUpdates).filter(([,e])=>Object.keys(e).length>0).map(([e,t])=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{children:e}),(0,Z.jsx)(Le,{value:t})]},e))]})]})]})}var yr={ask:`Ask`,approve:`Approve`,ignore:`Ignore`},br={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.`},xr=ue.options,Sr={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 Cr(e){let t=[];return e.forEach((e,n)=>{let r=E.safeParse(e);r.success||t.push(`Line ${n+1} (${e}): ${r.error.issues[0]?.message??`invalid argument`}`)}),t}function wr(){let e=nt(),t=l(e=>e.profiles),n=l(e=>e.projects),i=(0,X.useMemo)(()=>Object.values(t).sort((e,t)=>e.name.localeCompare(t.name)),[t]),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(null),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(null),m=async()=>{if(s){d(!0),p(null);try{await r(`/api/profiles/${encodeURIComponent(s.id)}`),W.success(`Profile ${s.name} deleted`),c(null)}catch(e){p(e)}finally{d(!1)}}},h=e=>Object.values(n).filter(t=>t.defaultProfileId===e).map(e=>e.name);return(0,Z.jsxs)(G,{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,Z.jsx)(b,{variant:`primary`,icon:(0,Z.jsx)(De,{className:`size-4`}),onClick:()=>o(`new`),children:`New profile`}),children:[(0,Z.jsx)(R,{}),e?i.length===0?(0,Z.jsx)(z,{icon:(0,Z.jsx)(me,{className:`size-8`}),title:`No profiles`,description:`Create a profile to choose a provider and model for sessions.`,action:{label:`New profile`,onClick:()=>o(`new`)}}):(0,Z.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:i.map(e=>{let t=h(e.id);return(0,Z.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,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 text-sm`,children:[(0,Z.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,Z.jsxs)(`span`,{className:`break-words text-muted`,children:[e.provider??`Default provider`,` / `,e.model??`default model`,` · Thinking`,` `,e.thinking??`default`,` · Project trust `,yr[e.projectTrust],e.resources===`vanilla`&&` · Vanilla Pi`]}),e.extraArgs.length>0&&(0,Z.jsx)(`span`,{className:`break-all font-mono text-xs text-muted`,children:e.extraArgs.join(` `)}),t.length>0&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Default for `,t.join(`, `)]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(b,{size:`sm`,icon:(0,Z.jsx)(Ee,{className:`size-4`}),onClick:()=>o(e),children:`Edit`}),(0,Z.jsx)(b,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,Z.jsx)(We,{className:`size-4`}),onClick:()=>{p(null),c(e)},children:`Delete`})]})]},e.id)})}):(0,Z.jsx)(v,{label:`Loading profiles…`}),a&&(0,Z.jsx)(Tr,{profile:a===`new`?null:a,onClose:()=>o(null)},a===`new`?`new`:a.id),(0,Z.jsx)(B,{open:s!==null,onClose:()=>c(null),title:s?`Delete ${s.name}?`:`Delete profile`,confirmLabel:`Delete profile`,busy:u,error:f,onConfirm:m,children:(0,Z.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 Tr({profile:e,onClose:t}){let n=(0,X.useId)(),[r,i]=(0,X.useState)(e?.name??``),[a,o]=(0,X.useState)(e?.provider??``),[s,c]=(0,X.useState)(e?.model??``),[l,d]=(0,X.useState)(e?.thinking??``),[p,m]=(0,X.useState)(e?.projectTrust??`ask`),[g,_]=(0,X.useState)(e?.resources??`all`),[v,y]=(0,X.useState)((e?.extraArgs??[]).join(`
|
|
4
|
+
`)),[x,S]=(0,X.useState)(!1),[C,w]=(0,X.useState)(!1),[T,E]=(0,X.useState)(null),D=et(v),O=Cr(D),k=x&&!r.trim()?`Enter a profile name.`:null,A=O.length?O.join(`
|
|
5
|
+
`):null,j=async n=>{if(n.preventDefault(),S(!0),!r.trim()||O.length)return;let i={name:r.trim(),provider:a.trim()||null,model:s.trim()||null,thinking:l||null,projectTrust:p,resources:g,extraArgs:D};w(!0),E(null);try{e?(await u(`/api/profiles/${encodeURIComponent(e.id)}`,i),W.success(`Profile ${i.name} saved`)):(await f(`/api/profiles`,i),W.success(`Profile ${i.name} created`)),t()}catch(e){E(e)}finally{w(!1)}},M=`${n}-form`;return(0,Z.jsx)(de,{open:!0,onClose:C?()=>void 0:t,dismissOnBackdrop:!C,title:e?`Edit ${e.name}`:`New profile`,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(b,{onClick:t,disabled:C,children:`Cancel`}),(0,Z.jsx)(b,{type:`submit`,form:M,variant:`primary`,busy:C,children:e?`Save profile`:`Create profile`})]}),children:(0,Z.jsxs)(`form`,{id:M,className:`flex min-w-0 flex-col gap-4`,onSubmit:j,noValidate:!0,children:[(0,Z.jsx)(H,{id:`${n}-name`,label:`Name`,error:k,children:(0,Z.jsx)(U,{id:`${n}-name`,value:r,onChange:e=>i(e.target.value),...V(`${n}-name`,{error:k})})}),(0,Z.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(H,{id:`${n}-provider`,label:`Provider`,hint:`Empty uses Pi's default.`,children:(0,Z.jsx)(U,{id:`${n}-provider`,value:a,onChange:e=>o(e.target.value),placeholder:`anthropic`,autoCapitalize:`off`,spellCheck:!1,...V(`${n}-provider`,{hint:!0})})}),(0,Z.jsx)(H,{id:`${n}-model`,label:`Model`,hint:`Empty uses Pi's default.`,children:(0,Z.jsx)(U,{id:`${n}-model`,value:s,onChange:e=>c(e.target.value),autoCapitalize:`off`,spellCheck:!1,...V(`${n}-model`,{hint:!0})})})]}),(0,Z.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(H,{id:`${n}-thinking`,label:`Thinking`,children:(0,Z.jsxs)(Y,{id:`${n}-thinking`,value:l,onChange:e=>d(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Default (none)`}),xr.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})}),(0,Z.jsx)(H,{id:`${n}-trust`,label:`Project trust`,hint:br[p],children:(0,Z.jsx)(Y,{id:`${n}-trust`,value:p,onChange:e=>m(e.target.value),...V(`${n}-trust`,{hint:!0}),children:Object.keys(yr).map(e=>(0,Z.jsx)(`option`,{value:e,children:yr[e]},e))})})]}),(0,Z.jsx)(H,{id:`${n}-resources`,label:`Resources`,hint:Sr[g],children:(0,Z.jsxs)(Y,{id:`${n}-resources`,value:g,onChange:e=>_(e.target.value),...V(`${n}-resources`,{hint:!0}),children:[(0,Z.jsx)(`option`,{value:`all`,children:`Your Pi setup`}),(0,Z.jsx)(`option`,{value:`vanilla`,children:`Vanilla Pi`})]})}),(0,Z.jsx)(H,{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:A,children:(0,Z.jsx)(ot,{id:`${n}-extra`,value:v,minRows:3,onChange:e=>y(e.target.value),className:`font-mono`,autoCapitalize:`off`,spellCheck:!1,...V(`${n}-extra`,{hint:!0,error:A})})}),(0,Z.jsx)(h,{error:T})]})})}var Er={managed:`Managed by Switchyard`,discovered:`Discovered worktree`,main:`Main checkout`},Dr={none:{icon:Tt,label:`No setup`,tone:`neutral`},running:{icon:bt,label:`Setup running`,tone:`info`},succeeded:{icon:jt,label:`Setup succeeded`,tone:`success`},failed:{icon:yt,label:`Setup failed`,tone:`danger`}};function Or(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 kr({project:t}){let n=l(e=>e.workspaces),r=l(e=>e.hosts),i=(0,X.useMemo)(()=>Object.values(n).filter(e=>e.projectId===t.id&&e.archivedAt===null).sort((e,t)=>Number(t.provenance===`main`)-Number(e.provenance===`main`)||(e.branch??``).localeCompare(t.branch??``)),[n,t.id]),[a,o]=(0,X.useState)(null),[s,u]=(0,X.useState)(null),d=async t=>{u(t.id);try{await f(`/api/workspaces/${encodeURIComponent(t.id)}/refresh`),W.success(`Workspace status refreshed`)}catch(t){W.error(`Could not refresh: ${e(t)}`)}finally{u(null)}};return(0,Z.jsxs)(J,{title:`Workspaces`,description:`Worktrees where sessions and runs work. Removing one never deletes its branch.`,children:[i.length===0?(0,Z.jsx)(z,{className:`py-4`,title:`No workspaces`,description:`Workspaces appear after a checkout is discovered. Use Refresh to discover them again.`}):(0,Z.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:i.map(e=>{let t=r[e.hostId],n=t?.connectivity!==`connected`,i=Dr[e.setup.state]??Dr.none;return(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1.5 py-3 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(Te,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),(0,Z.jsx)(`span`,{className:`min-w-0 break-all font-mono font-medium`,children:e.branch??`(detached HEAD)`}),(0,Z.jsx)(`span`,{className:`text-xs text-muted`,children:Er[e.provenance]})]}),(0,Z.jsxs)(`div`,{className:`break-all font-mono text-xs text-muted`,children:[t?.name?`${t.name}: `:``,e.path]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{children:Or(e.git)}),(0,Z.jsx)(K,{icon:i.icon,label:i.label,tone:i.tone,spin:e.setup.state===`running`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(b,{size:`sm`,icon:(0,Z.jsx)(c,{className:`size-4`}),busy:s===e.id,disabled:n,onClick:()=>d(e),children:`Refresh status`}),e.provenance!==`main`&&(0,Z.jsx)(b,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,Z.jsx)(We,{className:`size-4`}),disabled:n,onClick:()=>o(e),children:`Remove`}),e.provenance===`main`&&(0,Z.jsx)(`span`,{className:`text-xs text-muted`,children:`The main checkout cannot be removed; remove the project's checkout instead.`}),n&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Host `,t?.name??`unknown`,` is `,t?.connectivity??`unknown`,`: refresh and removal need it online.`]})]})]},e.id)})}),a&&(0,Z.jsx)(Ar,{workspace:n[a.id]??a,onClose:()=>o(null)},a.id)]})}function Ar({workspace:e,onClose:t}){let[n,r]=(0,X.useState)(e.git.dirty),[i,a]=(0,X.useState)(e.git.unmerged),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[p,m]=(0,X.useState)(null),h=n&&!o||i&&!c;return(0,Z.jsxs)(B,{open:!0,onClose:t,title:`Remove workspace?`,description:(0,Z.jsx)(`span`,{className:`break-all font-mono`,children:e.branch??e.path}),confirmLabel:`Remove workspace`,busy:u,error:p,onConfirm:async()=>{d(!0),m(null);try{await f(`/api/workspaces/${encodeURIComponent(e.id)}/remove`,{force:{dirty:o,unmerged:c}}),W.success(`Workspace ${e.branch??e.path} removed`),t()}catch(e){S(e,`workspace_dirty`)&&r(!0),S(e,`workspace_unmerged`)&&a(!0),m(e)}finally{d(!1)}},confirmDisabled:h,disabledReason:`Check the boxes above to confirm what will be lost.`,children:[(0,Z.jsxs)(`p`,{className:`text-sm`,children:[`The worktree at `,(0,Z.jsx)(`span`,{className:`break-all font-mono`,children:e.path}),` is deleted from the host. The branch is kept.`]}),n&&(0,Z.jsx)(Rt,{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,Z.jsx)(Rt,{label:`Remove although the branch is not merged`,description:`Commits stay on the branch, but the workspace is gone.`,checked:c,onChange:l})]})}var jr=`Inside the repository, for example .worktrees or .git/worktrees-switchyard`;function Mr(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 ..).`:_.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 Nr(){let{projectId:t=``}=te(),n=nt(),r=l(e=>e.projects[t]),i=l(e=>e.hosts),o=l(e=>e.profiles),[s,u]=(0,X.useState)(!1),[d,p]=(0,X.useState)([]),m=a(),h=(0,X.useMemo)(()=>Object.values(o).sort((e,t)=>e.name.localeCompare(t.name)),[o]),g={to:q(`projects`),label:`Projects`};return n?r?(0,Z.jsxs)(G,{title:r.name,description:(0,Z.jsx)(`span`,{className:`break-all`,title:r.repoIdentity,children:Fe(r.repoIdentity)}),back:g,actions:(0,Z.jsx)(b,{busy:s,icon:(0,Z.jsx)(c,{className:`size-4`}),onClick:async()=>{u(!0);try{let e=await f(`/api/projects/${encodeURIComponent(r.id)}/refresh`),t=Array.isArray(e?.errors)?e.errors:[];p(t),t.length?W.error(`Refreshed with ${t.length} checkout error(s)`):W.success(`Workspaces refreshed`)}catch(t){W.error(`Refresh failed: ${e(t)}`)}finally{u(!1)}},children:`Refresh`}),children:[(0,Z.jsx)(R,{}),d&&d.length>0&&(0,Z.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-border bg-danger-soft px-3 py-2 text-sm`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:`Some checkouts could not be refreshed`}),(0,Z.jsx)(`ul`,{className:`list-disc pl-5`,children:d.map(e=>(0,Z.jsx)(`li`,{className:`break-words`,children:e.message},e.checkoutId))})]}),(0,Z.jsx)(Pr,{project:r,hosts:m,profiles:h},r.id),(0,Z.jsx)(Fr,{project:r,hosts:m,hostsById:i}),(0,Z.jsx)(kr,{project:r})]}):(0,Z.jsx)(G,{title:`Project`,back:g,children:(0,Z.jsx)(z,{icon:(0,Z.jsx)(Ct,{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:q(`projects`)}})}):(0,Z.jsx)(G,{title:`Project`,back:g,children:(0,Z.jsx)(v,{label:`Loading project…`})})}function Pr({project:e,hosts:t,profiles:n}){let r=(0,X.useId)(),[i,a]=(0,X.useState)(e.name),[o,s]=(0,X.useState)(e.setupCommand??``),[c,l]=(0,X.useState)(e.checks.join(`
|
|
6
|
+
`)),[d,f]=(0,X.useState)(String(e.maxConcurrentRuns)),[p,m]=(0,X.useState)(e.automationEnabled),[g,_]=(0,X.useState)(e.workspaceSharing),[v,y]=(0,X.useState)(e.ensureSessions??!1),[x,S]=(0,X.useState)(e.removeLanded??!1),[C,w]=(0,X.useState)(e.defaultProfileId??``),[T,E]=(0,X.useState)(e.defaultHostId??``),[O,k]=(0,X.useState)(e.worktreeDir??`.worktrees`),[A,j]=(0,X.useState)(!1),[M,ee]=(0,X.useState)(null),N=Number(d),P=i.trim()?null:`Enter a project name.`,F=Number.isInteger(N)&&N>=1&&N<=32?null:`Use a whole number from 1 to 32.`,I=Mr(O),te=async t=>{if(t.preventDefault(),!(P||F||I)){j(!0),ee(null);try{await u(`/api/projects/${encodeURIComponent(e.id)}`,{name:i.trim(),setupCommand:o.trim()||null,checks:et(c),maxConcurrentRuns:N,automationEnabled:p,ensureSessions:v,removeLanded:x,workspaceSharing:g,defaultProfileId:C||null,defaultHostId:T||null,worktreeDir:O.trim()}),W.success(`Project settings saved`)}catch(e){ee(e)}finally{j(!1)}}},L=!T||t.some(e=>e.id===T),ne=!C||n.some(e=>e.id===C);return(0,Z.jsx)(J,{title:`Project settings`,children:(0,Z.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:te,noValidate:!0,children:[(0,Z.jsx)(H,{id:`${r}-name`,label:`Name`,error:P,children:(0,Z.jsx)(U,{id:`${r}-name`,value:i,onChange:e=>a(e.target.value),...V(`${r}-name`,{error:P})})}),(0,Z.jsx)(H,{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,Z.jsx)(U,{id:`${r}-setup`,value:o,onChange:e=>s(e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,...V(`${r}-setup`,{hint:!0})})}),(0,Z.jsx)(H,{id:`${r}-checks`,label:`Checks`,hint:`One command per line. Runs must pass these before review.`,children:(0,Z.jsx)(ot,{id:`${r}-checks`,value:c,minRows:3,onChange:e=>l(e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,...V(`${r}-checks`,{hint:!0})})}),(0,Z.jsx)(H,{id:`${r}-runs`,label:`Max concurrent runs`,hint:`Between 1 and 32.`,error:F,children:(0,Z.jsx)(U,{id:`${r}-runs`,type:`number`,inputMode:`numeric`,min:1,max:32,step:1,value:d,onChange:e=>f(e.target.value),className:`max-w-32`,...V(`${r}-runs`,{hint:!0,error:F})})}),(0,Z.jsx)(H,{id:`${r}-worktree`,label:`Worktree folder`,hint:jr,error:I,children:(0,Z.jsx)(U,{id:`${r}-worktree`,"data-testid":`project-worktree-dir`,value:O,onChange:e=>k(e.target.value),placeholder:D,className:`font-mono`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,...V(`${r}-worktree`,{hint:!0,error:I})})}),(0,Z.jsx)(Pt,{label:`Auto-start Ready tasks`,description:`When off, Ready tasks in this project wait instead of starting automatically.`,checked:p,onChange:m}),(0,Z.jsx)(Pt,{label:`Keep a session in every worktree`,description:`When a worktree first appears without a session, start one. Closing that session does not bring it back.`,checked:v,onChange:y}),(0,Z.jsx)(Pt,{label:`Remove merged worktrees`,description:`Ten minutes after a worktree's pull request is merged, archive its sessions and remove the worktree and local branch. Skipped while a session is running or the worktree has unpushed or uncommitted changes.`,checked:x,onChange:S}),(0,Z.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Z.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:`Workspace sharing`}),[[`single_writer`,`Single writer`,`Automation runs wait while another session is live in the workspace. Safest.`],[`shared`,`Shared`,`Several sessions may write in the same workspace at once. Their changes can interleave.`]].map(([e,t,n])=>(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(`input`,{id:`${r}-sharing-${e}`,type:`radio`,name:`${r}-sharing`,value:e,checked:g===e,onChange:()=>_(e),"aria-describedby":`${r}-sharing-${e}-desc`,className:`tap mt-0.5 size-5 shrink-0 accent-[var(--sy-accent)]`}),(0,Z.jsxs)(`label`,{htmlFor:`${r}-sharing-${e}`,className:`min-w-0 text-sm`,children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:t}),(0,Z.jsx)(`span`,{id:`${r}-sharing-${e}-desc`,className:`block text-muted`,children:n})]})]},e))]}),(0,Z.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(H,{id:`${r}-profile`,label:`Default Pi profile`,children:(0,Z.jsxs)(Y,{id:`${r}-profile`,value:C,onChange:e=>w(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`None (use the coordinator default)`}),n.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)),!ne&&(0,Z.jsx)(`option`,{value:C,children:`Removed profile`})]})}),(0,Z.jsx)(H,{id:`${r}-host`,label:`Default host`,hint:`Runs start here when the task does not choose a host.`,children:(0,Z.jsxs)(Y,{id:`${r}-host`,value:T,onChange:e=>E(e.target.value),...V(`${r}-host`,{hint:!0}),children:[(0,Z.jsx)(`option`,{value:``,children:`None (any host with a checkout)`}),t.map(e=>(0,Z.jsxs)(`option`,{value:e.id,children:[e.name,e.connectivity===`connected`?``:` (${e.connectivity})`]},e.id)),!L&&(0,Z.jsx)(`option`,{value:T,children:`Removed host`})]})})]}),(0,Z.jsx)(h,{error:M}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(b,{type:`submit`,variant:`primary`,busy:A,icon:(0,Z.jsx)(Oe,{className:`size-4`}),children:`Save project`})})]})})}function Fr({project:e,hosts:t,hostsById:n}){let r=l(e=>e.checkouts),i=(0,X.useMemo)(()=>Object.values(r).filter(t=>t.projectId===e.id).sort((e,t)=>e.createdAt.localeCompare(t.createdAt)),[r,e.id]),[a,o]=(0,X.useState)(!1);return(0,Z.jsxs)(J,{title:`Checkouts`,description:`Clones of this repository. Add one per host that should run this project.`,actions:(0,Z.jsx)(b,{size:`sm`,icon:(0,Z.jsx)(De,{className:`size-4`}),onClick:()=>o(!0),children:`Add checkout`}),children:[i.length===0?(0,Z.jsx)(z,{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,Z.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:i.map(e=>{let t=n[e.hostId];return(0,Z.jsxs)(`li`,{className:`min-w-0 py-2 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:t?.name??`Unknown host`}),t&&t.connectivity!==`connected`&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted`,children:[`(`,t.connectivity,`)`]})]}),(0,Z.jsx)(`div`,{className:`break-all font-mono text-xs`,children:e.path}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Default branch: `,e.defaultBranch]})]},e.id)})}),(0,Z.jsx)(Ir,{open:a,onClose:()=>o(!1),project:e,hosts:t})]})}function Ir({open:e,onClose:t,project:n,hosts:r}){let i=(0,X.useId)(),a=r.filter(e=>e.connectivity===`connected`),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(!1),[p,m]=(0,X.useState)(!1),[g,_]=(0,X.useState)(null),v=o||a[0]?.id||``,y=u||c?$e(c):null,x=()=>{p||(d(!1),_(null),t())},S=async e=>{if(e.preventDefault(),d(!0),v&&!$e(c)){m(!0),_(null);try{await f(`/api/projects/${encodeURIComponent(n.id)}/checkouts`,{hostId:v,path:c.trim()}),W.success(`Checkout added`),l(``),d(!1),t()}catch(e){_(e)}finally{m(!1)}}},C=`${i}-form`;return(0,Z.jsx)(de,{open:e,onClose:x,dismissOnBackdrop:!p,title:`Add checkout`,description:`Another clone of ${n.repoIdentity}.`,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(b,{onClick:x,disabled:p,children:`Cancel`}),(0,Z.jsx)(b,{type:`submit`,form:C,variant:`primary`,busy:p,disabled:a.length===0,children:`Add checkout`})]}),children:(0,Z.jsxs)(`form`,{id:C,className:`flex min-w-0 flex-col gap-4`,onSubmit:S,noValidate:!0,children:[a.length===0&&(0,Z.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,Z.jsx)(H,{id:`${i}-host`,label:`Host`,hint:`Only connected hosts are listed.`,children:(0,Z.jsxs)(Y,{id:`${i}-host`,value:v,onChange:e=>s(e.target.value),disabled:a.length===0,...V(`${i}-host`,{hint:!0}),children:[a.length===0&&(0,Z.jsx)(`option`,{value:``,children:`No connected hosts`}),a.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,Z.jsx)(H,{id:`${i}-path`,label:`Checkout path on the host`,hint:`Absolute path of an existing clone of this repository.`,error:y,children:(0,Z.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,...V(`${i}-path`,{hint:!0,error:y})})}),(0,Z.jsx)(h,{error:g})]})})}var Lr=e=>q(`projects/${encodeURIComponent(e)}`);function Rr(){let e=nt(),t=s(),n=a().filter(e=>!e.revokedAt&&e.connectivity===`connected`),[r,i]=(0,X.useState)(``),o=t.filter(e=>Ne(e,r)),c=l(e=>e.checkouts),u=l(e=>e.workspaces),d=(0,X.useMemo)(()=>{let e={},t=t=>(e[t]??={checkouts:0,workspaces:0},e[t]);for(let e of Object.values(c))t(e.projectId).checkouts++;for(let e of Object.values(u))e.archivedAt||t(e.projectId).workspaces++;return e},[c,u]);return(0,Z.jsxs)(G,{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,Z.jsxs)(k,{to:q(`projects/new`),state:rt,className:C(`primary`),children:[(0,Z.jsx)(De,{"aria-hidden":!0,className:`size-4`}),`New project`]}),children:[(0,Z.jsx)(R,{}),n.map(e=>(0,Z.jsx)(je,{host:e},e.id)),e?t.length===0?(0,Z.jsx)(z,{icon:(0,Z.jsx)(Ct,{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:q(`projects/new`)}}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`relative max-w-md`,children:[(0,Z.jsx)(Ae,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-subtle`}),(0,Z.jsx)(U,{type:`search`,"aria-label":`Search projects`,placeholder:`Search projects by name or remote`,value:r,onChange:e=>i(e.target.value),className:`pl-8`})]}),o.length===0?(0,Z.jsx)(z,{className:`py-4`,title:`No matches`,description:`No project matches "${r.trim()}".`,action:{label:`Clear search`,onClick:()=>i(``)}}):(0,Z.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:o.map(e=>(0,Z.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,Z.jsx)(zr,{project:e,counts:d[e.id]})},e.id))})]}):(0,Z.jsx)(v,{label:`Loading projects…`})]})}function zr({project:e,counts:t}){let n=t??{checkouts:0,workspaces:0};return(0,Z.jsxs)(k,{to:Lr(e.id),state:rt,className:`tap flex min-w-0 items-center gap-3 px-4 py-2 hover:bg-surface-2`,children:[(0,Z.jsx)(Ct,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),(0,Z.jsx)(`span`,{className:`truncate text-xs text-muted`,title:e.repoIdentity,children:Fe(e.repoIdentity)}),(0,Z.jsxs)(`span`,{className:`flex flex-wrap gap-x-2 text-xs text-subtle`,children:[(0,Z.jsxs)(`span`,{children:[n.checkouts,` checkout`,n.checkouts===1?``:`s`]}),(0,Z.jsxs)(`span`,{children:[n.workspaces,` workspace`,n.workspaces===1?``:`s`]}),!e.automationEnabled&&(0,Z.jsx)(`span`,{children:`Auto-start off`})]})]}),(0,Z.jsx)(ve,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})}function Br(){let e=nt(),t=a(),n=l(e=>e.profiles),r=(0,X.useMemo)(()=>Object.values(n).sort((e,t)=>e.name.localeCompare(t.name)),[n]),i=t.filter(e=>e.connectivity===`connected`),o=w(),s=(0,X.useId)(),[c,u]=(0,X.useState)(``),[d,p]=(0,X.useState)(``),[m,g]=(0,X.useState)(``),[_,y]=(0,X.useState)(``),[x,S]=(0,X.useState)(D),[C,T]=(0,X.useState)(!1),[E,O]=(0,X.useState)(!1),[k,A]=(0,X.useState)(null),j=d||i[0]?.id||``,M=C&&!c.trim()?`Enter a project name.`:null,ee=C&&!j?`Choose a connected host.`:null,N=C||m?$e(m):null,P=Mr(x),F=async e=>{if(e.preventDefault(),T(!0),c.trim()&&j&&!$e(m)&&!P){O(!0),A(null);try{let e=await f(`/api/projects`,{name:c.trim(),hostId:j,path:m.trim(),defaultProfileId:_||null,worktreeDir:x.trim()});W.success(`Project ${c.trim()} created`),o(e?.id?Lr(e.id):q(`projects`),{replace:!0})}catch(e){A(e)}finally{O(!1)}}},I={to:q(`projects`),label:`Projects`};return e?(0,Z.jsxs)(G,{title:`New project`,description:`Switchyard inspects the checkout on the host, then discovers its worktrees.`,back:I,children:[i.length===0&&(0,Z.jsx)(ae,{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,Z.jsx)(Mt,{to:q(`hosts`),variant:`action`,children:`Open hosts`})}),(0,Z.jsx)(J,{children:(0,Z.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:F,noValidate:!0,children:[(0,Z.jsx)(H,{id:`${s}-name`,label:`Name`,error:M,children:(0,Z.jsx)(U,{id:`${s}-name`,value:c,onChange:e=>u(e.target.value),autoComplete:`off`,...V(`${s}-name`,{error:M})})}),(0,Z.jsx)(H,{id:`${s}-host`,label:`Host`,hint:`Only connected hosts are listed.`,error:ee,children:(0,Z.jsxs)(Y,{id:`${s}-host`,value:j,onChange:e=>p(e.target.value),disabled:i.length===0,...V(`${s}-host`,{hint:!0,error:ee}),children:[i.length===0&&(0,Z.jsx)(`option`,{value:``,children:`No connected hosts`}),i.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,Z.jsx)(H,{id:`${s}-path`,label:`Checkout path on the host`,hint:`Absolute path of an existing Git checkout, e.g. /Users/me/src/app.`,error:N,children:(0,Z.jsx)(U,{id:`${s}-path`,value:m,onChange:e=>g(e.target.value),placeholder:`/Users/me/src/app`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,className:`font-mono`,...V(`${s}-path`,{hint:!0,error:N})})}),(0,Z.jsx)(H,{id:`${s}-worktree`,label:`Worktree folder`,hint:jr,error:P,children:(0,Z.jsx)(U,{id:`${s}-worktree`,value:x,onChange:e=>S(e.target.value),placeholder:D,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,className:`font-mono`,...V(`${s}-worktree`,{hint:!0,error:P})})}),(0,Z.jsx)(H,{id:`${s}-profile`,label:`Default Pi profile (optional)`,children:(0,Z.jsxs)(Y,{id:`${s}-profile`,value:_,onChange:e=>y(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`None`}),r.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,Z.jsx)(h,{error:k}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(b,{type:`submit`,variant:`primary`,busy:E,icon:(0,Z.jsx)(Zt,{className:`size-4`}),disabled:i.length===0,children:`Create project`}),i.length===0&&(0,Z.jsx)(K,{icon:Zt,label:`Needs a connected host`})]})]})})]}):(0,Z.jsx)(G,{title:`New project`,back:I,children:(0,Z.jsx)(v,{})})}function Vr(){let[e,t]=(0,X.useState)({}),n=(0,X.useCallback)(e=>{e.source&&t(t=>({...t,[e.id]:e.source.lastSyncedAt}))},[]);return(0,X.useEffect)(()=>{let e=!0;return d(`/api/scopes`).then(n=>{e&&t(Object.fromEntries(n.filter(ce).map(e=>[e.id,e.source.lastSyncedAt])))}).catch(()=>{}),()=>{e=!1}},[]),{times:e,note:n}}function Hr(){let e=nt(),t=l(e=>e.scopes),n=(0,X.useMemo)(()=>Object.values(t),[t]),{times:i,note:a}=Vr(),[o,s]=(0,X.useState)(null),[c,u]=(0,X.useState)(null),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(null),h=async()=>{if(c){f(!0),m(null);try{await r(`/api/scopes/${encodeURIComponent(c.id)}`),W.success(`Scope ${c.name} deleted`),u(null)}catch(e){m(e)}finally{f(!1)}}},g=e=>t=>{m(null),e(t)};return(0,Z.jsxs)(G,{title:`Scopes`,description:`A scope is a named part of your work. Sessions and the Board can show one, and a herdr or tmux session can mirror one.`,testId:`scopes-section`,actions:(0,Z.jsx)(b,{variant:`primary`,icon:(0,Z.jsx)(De,{className:`size-4`}),onClick:()=>s(`new`),children:`New scope`}),children:[e?n.length===0?(0,Z.jsx)(z,{icon:(0,Z.jsx)(ct,{className:`size-8`}),title:`No scopes`,description:`Add one to group your work, or to bring your GitHub issues onto the Board.`,action:{label:`New scope`,onClick:()=>s(`new`)}}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:n.map(e=>(0,Z.jsx)(Wr,{scope:e,lastSyncedAt:e.id in i?i[e.id]:e.source?.lastSyncedAt??null,onSynced:a,onEdit:()=>s(e.id),onDelete:()=>g(u)(e)},e.id))}):(0,Z.jsx)(v,{label:`Loading scopes…`}),(0,Z.jsx)(Pe,{editing:o,onClose:()=>s(null),onSaved:()=>{}}),(0,Z.jsx)(B,{open:c!==null,onClose:()=>u(null),title:`Delete this scope?`,description:`Sessions are not affected. Clients mirroring it then mirror nothing and keep their tabs.${c?.source?` Its issues are removed from the Board.`:``}`,confirmLabel:`Delete scope`,danger:!0,busy:d,error:p,onConfirm:()=>void h()})]})}function Ur({scope:e}){let[,t]=he(),n=w(),r=r=>{t(e.id),n(r)};return(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(Mt,{onClick:()=>r(xt.code),children:`Sessions`}),(0,Z.jsx)(Mt,{onClick:()=>r(xt.board),children:`Board`})]})}function Wr({scope:t,lastSyncedAt:n,onSynced:r,onEdit:i,onDelete:a}){let o=t.source,{describe:s}=Lt(),u=l(e=>e.hosts),d=l(e=>e.clients),p=l(e=>e.projects),m=l(e=>e.issues),[h,g]=(0,X.useState)(!1),_=Object.values(m).filter(e=>e.scopeId===t.id).length,v=(0,X.useMemo)(()=>(t.projectIds??[]).map(e=>p[e]).filter(e=>!!e).sort((e,t)=>e.name.localeCompare(t.name)),[t,p]),y=t.sessionIds.length,x=async()=>{g(!0);try{let e=await f(`/api/scopes/${encodeURIComponent(t.id)}/sync`,{});r(e),e.source?.lastError?W.error(`${e.name}: ${e.source.lastError}`):W.success(`Synced ${e.name}`)}catch(t){W.error(e(t))}finally{g(!1)}};return(0,Z.jsx)(J,{testId:`scope-${t.id}`,title:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[t.name,o&&(0,Z.jsx)(fe,{tone:`neutral`,children:`GitHub`}),o&&!o.enabled&&(0,Z.jsx)(fe,{tone:`neutral`,children:`Paused`})]}),actions:(0,Z.jsxs)(Z.Fragment,{children:[o&&(0,Z.jsx)(b,{size:`sm`,icon:(0,Z.jsx)(c,{className:`size-4`}),busy:h,onClick:()=>void x(),children:`Sync now`}),(0,Z.jsx)(b,{size:`sm`,icon:(0,Z.jsx)(Ee,{className:`size-4`}),onClick:i,children:`Edit`}),(0,Z.jsx)(b,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,Z.jsx)(We,{className:`size-4`}),onClick:a,children:`Delete`})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(Et,{items:[[`Contains`,s(t)],...o?Ie(o,u[o.hostId]?.name??o.hostId):[],...o?[[`Last sync`,`${n?T(n):`Never`} · ${_} issue${_===1?``:`s`}`]]:[],...t.mode===`pinned`||y>0?[[`Pinned`,`${y} session${y===1?``:`s`}`]]:[],[`Mirrored in`,It(t,Object.values(d),u)??`No client`],[`Open`,(0,Z.jsx)(Ur,{scope:t},`open`)]]}),o?.lastError&&(0,Z.jsx)(`p`,{role:`status`,className:`rounded-md border border-border bg-danger-soft px-3 py-2 text-sm break-words`,children:o.lastError}),o&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Projects`}),v.length===0?(0,Z.jsxs)(`p`,{className:`text-sm text-muted`,children:[o.extraRepositories?.length?`No projects for this scope here yet.`:`No projects from ${o.owner} here yet.`,` `,`Add its repositories in Settings › Projects.`]}):(0,Z.jsx)(`ul`,{className:`flex flex-col divide-y divide-border`,children:v.map(e=>(0,Z.jsx)(Gr,{project:e},e.id))})]})]})})}function Gr({project:t}){let[n,r]=(0,X.useState)(null),i=async(n,i)=>{r(n);try{await u(`/api/projects/${encodeURIComponent(t.id)}`,{[n]:i})}catch(t){W.error(e(t))}finally{r(null)}};return(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 py-2`,children:[(0,Z.jsx)(k,{to:xt.settings(`projects/${t.id}`),className:`min-w-0 flex-[1_1_10rem] truncate text-sm font-medium text-accent hover:underline`,children:t.name}),(0,Z.jsx)(Ft,{label:`Keep a session in every worktree of ${t.name}`,onText:`Session per worktree`,offText:`Session per worktree`,checked:t.ensureSessions??!1,busy:n===`ensureSessions`,onChange:e=>void i(`ensureSessions`,e)}),(0,Z.jsx)(Ft,{label:`Remove merged worktrees of ${t.name}`,onText:`Remove merged`,offText:`Remove merged`,checked:t.removeLanded??!1,busy:n===`removeLanded`,onChange:e=>void i(`removeLanded`,e)})]})}function Kr(){let e=Ce(`/api/auth/methods`,Ye),[t,n]=(0,X.useState)(!1),[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(!1),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(null),_=async()=>{if(i){s(!0),l(null);try{await r(`/api/auth/passkeys/${encodeURIComponent(i.id)}`),W.success(`Passkey ${i.name} removed`),a(null),e.reload()}catch(e){l(e)}finally{s(!1)}}},y=async()=>{m(!0),g(null);try{await f(`/api/logout`),d(!1),at(null)}catch(e){g(e)}finally{m(!1)}},x=e.data,S=x?.passkeyAvailability,C=Bt(),w=x?S?.available?C?null:`This browser does not support passkeys.`:S?.reason??`Passkeys are not available on this server.`:null;return(0,Z.jsxs)(G,{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,Z.jsx)(R,{}),e.loading&&!x?(0,Z.jsx)(v,{label:`Loading sign-in methods…`}):e.error&&!x?(0,Z.jsx)(P,{title:`Could not load sign-in methods`,error:e.error,onRetry:e.reload}):x?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(J,{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,Z.jsx)(b,{"data-testid":`passkey-add`,variant:`primary`,icon:(0,Z.jsx)(De,{className:`size-4`}),disabled:w!==null,onClick:()=>n(!0),children:`Add a passkey`}),children:[w&&(0,Z.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,Z.jsx)(le,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0`}),(0,Z.jsxs)(`span`,{className:`min-w-0 break-words`,children:[`Adding a passkey is unavailable: `,w]})]}),x.passkeys.length===0?(0,Z.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,Z.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border`,children:x.passkeys.map(e=>(0,Z.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,Z.jsx)(dt,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`break-words font-medium`,children:e.name}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 text-sm text-muted`,children:[(0,Z.jsxs)(`span`,{children:[`Added `,T(e.createdAt)]}),(0,Z.jsxs)(`span`,{children:[`Last used `,T(e.lastUsedAt)]})]})]}),(0,Z.jsx)(b,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,Z.jsx)(We,{className:`size-4`}),"aria-label":`Remove passkey ${e.name}`,onClick:()=>{l(null),a(e)},children:`Remove`})]},e.id))})]}),(0,Z.jsx)(J,{title:`Single sign-on`,description:`Configured on the server`,children:x.oidc?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(Et,{items:[[`Button label`,x.oidc.label],[`Provider`,(0,Z.jsx)(`span`,{className:`break-all`,children:x.oidc.issuer},`i`)],[`Allowed account`,x.oidc.ownerMatch],[`Status`,x.oidc.status===`ready`?(0,Z.jsx)(K,{icon:jt,tone:`success`,label:`Ready`},`s`):(0,Z.jsx)(K,{icon:le,tone:`danger`,label:`Error`},`s`)]]}),x.oidc.status===`error`&&x.oidc.error&&(0,Z.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-danger`,children:x.oidc.error})]}):(0,Z.jsxs)(`p`,{"data-testid":`signin-oidc-status`,className:`text-sm text-muted`,children:[`Not configured. Set the `,(0,Z.jsx)(`code`,{children:`SWITCHYARD_OIDC_*`}),` variables on the server to sign in with an identity provider.`]})})]}):null,(0,Z.jsx)(J,{title:`This device`,description:`Signing out removes this device's credential here. Other devices stay signed in; revoke a device in Settings › Clients to cut it off.`,children:(0,Z.jsx)(b,{icon:(0,Z.jsx)(rn,{className:`size-4`}),onClick:()=>{g(null),d(!0)},children:`Sign out of this device`})}),(0,Z.jsx)(qr,{open:t,onClose:()=>n(!1),onAdded:()=>{n(!1),e.reload()}}),(0,Z.jsx)(B,{open:i!==null,onClose:()=>a(null),title:i?`Remove passkey ${i.name}?`:`Remove passkey`,confirmLabel:`Remove passkey`,busy:o,error:c,onConfirm:_,children:(0,Z.jsxs)(`p`,{className:`text-sm`,children:[`Devices already signed in stay signed in. This passkey can no longer sign in new devices.`,x&&x.passkeys.length===1&&!x.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,Z.jsx)(B,{open:u,onClose:()=>d(!1),title:`Sign out of this device?`,confirmLabel:`Sign out`,busy:p,error:h,onConfirm:y,children:(0,Z.jsxs)(`p`,{className:`text-sm`,children:[`You will need single sign-on, a passkey or `,(0,Z.jsx)(`code`,{children:`switchyard pair`}),` on the server to sign in here again.`]})})]})}function qr({open:t,onClose:n,onAdded:r}){let i=(0,X.useId)(),[a,o]=(0,X.useState)(()=>Ht()),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null),d=Vt(),p=a.trim()?null:`Enter a name for this passkey.`,m=()=>{if(d.waiting)d.cancel();else if(s)return;u(null),n()},g=async t=>{if(t.preventDefault(),!p){c(!0),u(null);try{let{challengeId:e,options:t}=await f(`/api/auth/passkeys/register/options`),n=await d.run(()=>zt({optionsJSON:t}));if(!n.ok){c(!1);return}let i=n.value;await f(`/api/auth/passkeys/register/verify`,{challengeId:e,name:a.trim().slice(0,80),response:i}),W.success(`Passkey added`),r()}catch(t){u(t instanceof Error&&t.name===`NotAllowedError`?Error(`The passkey prompt was canceled or timed out. Try again.`):t instanceof Error?t:Error(e(t)))}finally{c(!1)}}},_=`${i}-form`;return(0,Z.jsx)(de,{open:t,onClose:m,dismissOnBackdrop:!s||d.waiting,title:`Add a passkey`,description:`Name it after where it is stored, then confirm with your device.`,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(b,{onClick:m,disabled:s&&!d.waiting,children:`Cancel`}),(0,Z.jsx)(b,{type:`submit`,form:_,variant:`primary`,busy:s,children:`Create passkey`})]}),children:(0,Z.jsxs)(`form`,{id:_,className:`flex min-w-0 flex-col gap-4`,onSubmit:g,noValidate:!0,children:[(0,Z.jsx)(H,{id:`${i}-name`,label:`Passkey name`,error:p,children:(0,Z.jsx)(U,{id:`${i}-name`,value:a,maxLength:80,autoComplete:`off`,onChange:e=>o(e.target.value),...V(`${i}-name`,{error:p})})}),d.waiting&&(0,Z.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-muted`,children:[(0,Z.jsx)(I,{}),` Waiting for your passkey… Cancel stops it.`]}),(0,Z.jsx)(h,{error:l})]})})}function Jr(){let e=qe(),t=e===`mobile`,n=(0,Z.jsxs)(j,{children:[(0,Z.jsx)(y,{index:!0,element:t?(0,Z.jsx)(Qr,{}):(0,Z.jsx)(F,{to:q(`hosts`),replace:!0})}),(0,Z.jsx)(y,{path:`hosts`,element:(0,Z.jsx)(Jn,{})}),(0,Z.jsx)(y,{path:`hosts/:hostId`,element:(0,Z.jsx)(er,{})}),(0,Z.jsx)(y,{path:`clients`,element:(0,Z.jsx)(Rn,{})}),(0,Z.jsx)(y,{path:`devices`,element:(0,Z.jsx)(F,{to:q(`clients`),replace:!0})}),(0,Z.jsx)(y,{path:`terminals`,element:(0,Z.jsx)(F,{to:q(`clients`),replace:!0})}),(0,Z.jsx)(y,{path:`trackers`,element:(0,Z.jsx)(F,{to:q(`scopes`),replace:!0})}),(0,Z.jsx)(y,{path:`sign-in`,element:(0,Z.jsx)(Kr,{})}),(0,Z.jsx)(y,{path:`projects`,element:(0,Z.jsx)(Rr,{})}),(0,Z.jsx)(y,{path:`projects/new`,element:(0,Z.jsx)(Br,{})}),(0,Z.jsx)(y,{path:`projects/:projectId`,element:(0,Z.jsx)(Nr,{})}),(0,Z.jsx)(y,{path:`scopes`,element:(0,Z.jsx)(Hr,{})}),(0,Z.jsx)(y,{path:`profiles`,element:(0,Z.jsx)(wr,{})}),(0,Z.jsx)(y,{path:`policies`,element:(0,Z.jsx)(vr,{})}),(0,Z.jsx)(y,{path:`adapters`,element:(0,Z.jsx)(Cn,{})}),(0,Z.jsx)(y,{path:`notifications`,element:(0,Z.jsx)(ir,{})}),(0,Z.jsx)(y,{path:`backups`,element:(0,Z.jsx)(An,{})}),(0,Z.jsx)(y,{path:`diagnostics`,element:(0,Z.jsx)(Bn,{})}),(0,Z.jsx)(y,{path:`device`,element:(0,Z.jsx)(zn,{})}),(0,Z.jsx)(y,{path:`*`,element:(0,Z.jsx)($r,{})})]});return t?(0,Z.jsx)(`div`,{className:`min-w-0`,children:n}):(0,Z.jsxs)(`div`,{className:`flex min-h-full min-w-0`,children:[(0,Z.jsx)(Xr,{compact:e===`compact`}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:n})]})}function Yr(){let{pathname:e}=oe(),t=e.split(`/`),n=t.indexOf(`settings`);return n>=0&&(t[n+1]??null)||null}function Xr({compact:e}){let t=Yr();return(0,Z.jsx)(`div`,{className:se(`shrink-0 border-r border-border`,e?`w-52`:`w-60`),children:(0,Z.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-testid":`settings-nav`,tabIndex:-1,"data-keyboard-scope":!0,"data-keyboard-default":!0,className:`focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent sticky top-0 flex max-h-dvh flex-col gap-1 overflow-y-auto overscroll-contain px-2 py-4`,children:[(0,Z.jsx)(`h2`,{className:`mb-1 px-3 py-1 text-base font-semibold`,children:`Settings`}),Xe.map(e=>(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`h3`,{className:`px-3 pt-3 pb-1 text-xs font-semibold tracking-wide text-muted uppercase`,children:e.label}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.sections.map(({path:e,label:n,icon:r})=>{let i=t===e;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(k,{to:q(e),"data-keyboard-item":!0,"aria-current":i?`page`:void 0,className:se(`tap flex h-10 items-center gap-3 rounded-md px-3 text-sm font-medium`,i?`bg-accent-soft text-text`:`text-muted hover:bg-surface-2 hover:text-text`),children:[(0,Z.jsx)(r,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:n})]})},e)})})]},e.label))]})})}function Zr(){let e=l(e=>e.hosts),t=l(e=>e.devices),n=l(e=>e.clients),r=l(e=>e.projects),i=l(e=>e.profiles),a=l(e=>e.adapters),o=l(e=>e.hydrated);return(0,X.useMemo)(()=>{if(!o)return{};let s=Object.values(e).filter(e=>e.revokedAt===null),c=s.filter(e=>e.connectivity===`connected`).length,l=Object.values(a).reduce((e,t)=>e+t.length,0),u=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return{hosts:`${u(s.length,`host`)}, ${c} connected`,clients:u(Object.values(t).filter(e=>e.revokedAt===null).length+Object.keys(n).length,`client`),projects:u(Object.keys(r).length,`project`),profiles:u(Object.keys(i).length,`profile`),adapters:u(l,`adapter`)}},[e,t,n,r,i,a,o])}function Qr(){let e=Zr();return(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full min-w-0 max-w-xl flex-col gap-3 px-4 py-4`,children:[(0,Z.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Settings`}),(0,Z.jsx)(R,{}),(0,Z.jsx)(`nav`,{"aria-label":`Settings sections`,"data-testid":`settings-nav`,tabIndex:-1,"data-keyboard-scope":!0,"data-keyboard-default":!0,className:`focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent`,children:Xe.map(t=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`px-1 pt-3 pb-1 text-xs font-semibold tracking-wide text-muted uppercase`,children:t.label}),(0,Z.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:t.sections.map(({path:t,label:n,description:r,icon:i})=>(0,Z.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,Z.jsxs)(k,{to:q(t),state:rt,"data-keyboard-item":!0,className:`tap flex min-h-14 items-center gap-3 px-4 py-2 hover:bg-surface-2`,children:[(0,Z.jsx)(i,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:n}),(0,Z.jsx)(`span`,{className:`block truncate text-sm text-muted`,children:e[t]??r})]}),(0,Z.jsx)(ve,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})},t))})]},t.label))})]})}function $r(){return(0,Z.jsx)(z,{title:`Settings page not found`,description:`This link does not match a settings section.`,action:{label:`Open Settings`,to:q()}})}export{Jr as default};
|
|
7
|
+
//# sourceMappingURL=settings-BApavmGp.js.map
|