local-operator-ui 0.31.16 → 0.31.18

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.
Files changed (109) hide show
  1. package/README.md +5 -0
  2. package/out/main/index.js +8390 -406
  3. package/out/preload/index.js +59 -0
  4. package/out/renderer/assets/{_basePickBy-ByW4PGoZ.js → _basePickBy-D1XXNWdy.js} +1 -1
  5. package/out/renderer/assets/{_baseUniq-BNZdLtEU.js → _baseUniq-DD_DKvaU.js} +1 -1
  6. package/out/renderer/assets/{agent-details-page-DAKGVTok.js → agent-details-page-Q8dgdQp2.js} +2 -2
  7. package/out/renderer/assets/{agent-hub-page-DCQCLvuE.js → agent-hub-page-CBHsotVj.js} +2 -2
  8. package/out/renderer/assets/agents-page-9zkhLfa8.js +2 -0
  9. package/out/renderer/assets/arc-BII0LAll.js +1 -0
  10. package/out/renderer/assets/architectureDiagram-IEHRJDOE-Yh4i0oDy.js +36 -0
  11. package/out/renderer/assets/{blockDiagram-JOT3LUYC-Dd4ZtDNT.js → blockDiagram-JOT3LUYC-BsfIO03o.js} +6 -6
  12. package/out/renderer/assets/{book-open-DORvUlzH.js → book-open-Bau36KjM.js} +1 -1
  13. package/out/renderer/assets/browser-page-CrHmmBk0.js +1 -0
  14. package/out/renderer/assets/browser-webauthn-prompt-_nNd3iSK.js +1 -0
  15. package/out/renderer/assets/{c4Diagram-VJAJSXHY-DJyy7n2t.js → c4Diagram-VJAJSXHY-CHKu8u4B.js} +4 -4
  16. package/out/renderer/assets/channel-DXiH5yDB.js +1 -0
  17. package/out/renderer/assets/{chunk-4BMEZGHF-p9QlgFQx.js → chunk-4BMEZGHF-Do_SeY3I.js} +1 -1
  18. package/out/renderer/assets/{chunk-A2AXSNBT-jc38hxTP.js → chunk-A2AXSNBT-C7_NoYUm.js} +1 -1
  19. package/out/renderer/assets/{chunk-AEK57VVT-C-Lkcz0b.js → chunk-AEK57VVT-C3I1E4qy.js} +1 -1
  20. package/out/renderer/assets/{chunk-D6G4REZN-BTNuVsq7.js → chunk-D6G4REZN-BEkTCb-4.js} +1 -1
  21. package/out/renderer/assets/{chunk-RZ5BOZE2-BeXwBs0F.js → chunk-RZ5BOZE2-Ccs-Kaym.js} +1 -1
  22. package/out/renderer/assets/{chunk-XZIHB7SX-BFoUrE4z.js → chunk-XZIHB7SX-Db28vmME.js} +1 -1
  23. package/out/renderer/assets/classDiagram-GIVACNV2-D2MG4USX.js +1 -0
  24. package/out/renderer/assets/classDiagram-v2-COTLJTTW-D2MG4USX.js +1 -0
  25. package/out/renderer/assets/clone-BDi6ICAs.js +1 -0
  26. package/out/renderer/assets/{console-mirror-gvEt6nID.js → console-mirror-CUQyeXIE.js} +14 -14
  27. package/out/renderer/assets/consoleCapture-emgU7WyW.js +1 -0
  28. package/out/renderer/assets/dagre-OKDRZEBW-k4D1AM8X.js +4 -0
  29. package/out/renderer/assets/diagram-SSKATNLV-B0DOtyf9.js +43 -0
  30. package/out/renderer/assets/diagram-VNBRO52H-BmzuI3Lr.js +24 -0
  31. package/out/renderer/assets/{erDiagram-Q7BY3M3F-DC6yLQdn.js → erDiagram-Q7BY3M3F-BYRglvp5.js} +2 -2
  32. package/out/renderer/assets/error-boundary-BFYdHP26.js +6 -0
  33. package/out/renderer/assets/{flowDiagram-4HSFHLVR-BQkDbqUO.js → flowDiagram-4HSFHLVR-C6ReCJC9.js} +2 -2
  34. package/out/renderer/assets/ganttDiagram-APWFNJXF-CMDShfzg.js +257 -0
  35. package/out/renderer/assets/gitGraphDiagram-7IBYFJ6S-pvPc8CHP.js +65 -0
  36. package/out/renderer/assets/{graph-dWQI_6He.js → graph-BK-Vf19N.js} +1 -1
  37. package/out/renderer/assets/index-B5DwqFlK.js +7 -0
  38. package/out/renderer/assets/{index-BYm582eS.js → index-BDPyvriR.js} +394 -430
  39. package/out/renderer/assets/index-DITdBETY.css +1 -0
  40. package/out/renderer/assets/index-_oyU7kmX.js +1 -0
  41. package/out/renderer/assets/infoDiagram-PH2N3AL5-COePE42k.js +2 -0
  42. package/out/renderer/assets/installer-DfFRjYBs.js +1 -0
  43. package/out/renderer/assets/{journeyDiagram-U35MCT3I-Chhmcl-w.js → journeyDiagram-U35MCT3I-CeBVrNEA.js} +6 -6
  44. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-BppAzkjD.js → kanban-definition-NDS4AKOZ-DnIH3R0V.js} +4 -4
  45. package/out/renderer/assets/{layout-DASlxn3X.js → layout-IqcTjCQI.js} +1 -1
  46. package/out/renderer/assets/{legacy-agents-page-DWRDsjtU.js → legacy-agents-page-DbLTVwq0.js} +4 -4
  47. package/out/renderer/assets/{mermaid.core-BimBLnQI.js → mermaid.core-BrRc254F.js} +5 -5
  48. package/out/renderer/assets/mesh-page-W9oV_bPF.js +2 -0
  49. package/out/renderer/assets/mindmap-definition-ALO5MXBD-BMHndK7E.js +95 -0
  50. package/out/renderer/assets/mini-CbmMlUkq.js +1 -0
  51. package/out/renderer/assets/org-surface-gate-BgtTWHt3.js +1 -0
  52. package/out/renderer/assets/{page-header-CSth8igb.js → page-header-BtO13sx8.js} +1 -1
  53. package/out/renderer/assets/pieDiagram-IB7DONF6-CnRMxjLj.js +30 -0
  54. package/out/renderer/assets/projects-page-BgRRDkEz.js +40 -0
  55. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-CYm8uvms.js → quadrantDiagram-7GDLP6J5-bRLUBm5r.js} +4 -4
  56. package/out/renderer/assets/{radar-MK3ICKWK-kR5WGC6e.js → radar-MK3ICKWK-BV3WfB2Y.js} +1 -1
  57. package/out/renderer/assets/radient-auth-buttons-Briy2cZb.js +1 -0
  58. package/out/renderer/assets/renderer-platform-RsXXlY5x.js +42 -0
  59. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-D9KpdhqG.js → requirementDiagram-KVF5MWMF-Bzqys165.js} +3 -3
  60. package/out/renderer/assets/sankeyDiagram-QLVOVGJD--IgSaXgN.js +10 -0
  61. package/out/renderer/assets/{schedules-page-sReBxwJU.js → schedules-page-CbOATI1U.js} +11 -11
  62. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-CysJg9MU.js → sequenceDiagram-X6HHIX6F-bfcEv3LN.js} +2 -2
  63. package/out/renderer/assets/{settings-page-BmCMRg0Q.js → settings-page-Bn87mGZ1.js} +67 -67
  64. package/out/renderer/assets/{settings-section-BrZkwHPu.js → settings-section-BXGO9Lv0.js} +1 -1
  65. package/out/renderer/assets/stateDiagram-DGXRK772-CDJAoYUf.js +1 -0
  66. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-Di7PMVrt.js +1 -0
  67. package/out/renderer/assets/textarea-B83uQCj2.js +121 -0
  68. package/out/renderer/assets/{timeline-definition-BDJGKUSR-Cq5I65iA.js → timeline-definition-BDJGKUSR-BlN_DgVS.js} +2 -2
  69. package/out/renderer/assets/ui-preferences-store-DzXZGWGz.js +1 -0
  70. package/out/renderer/assets/{use-download-agent-mutation-BiwTStj8.js → use-download-agent-mutation-DrENBWNa.js} +3 -3
  71. package/out/renderer/assets/use-memberships-query-C2Yus1QJ.js +1 -0
  72. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-BMgv0pD_.js → xychartDiagram-VJFVF3MP-C1DOS4ES.js} +6 -6
  73. package/out/renderer/console-capture.html +5 -4
  74. package/out/renderer/index.html +8 -5
  75. package/out/renderer/installer.html +5 -4
  76. package/out/renderer/mini.html +21 -0
  77. package/package.json +2 -2
  78. package/out/renderer/assets/agents-page-P80PpPfF.js +0 -2
  79. package/out/renderer/assets/arc-BM_dGTT0.js +0 -1
  80. package/out/renderer/assets/architectureDiagram-IEHRJDOE-CEVl1UVo.js +0 -36
  81. package/out/renderer/assets/browser-page-D8jzpIB2.js +0 -1
  82. package/out/renderer/assets/browser-webauthn-prompt-Bq-HOJkh.js +0 -1
  83. package/out/renderer/assets/channel-Dd9P9cjr.js +0 -1
  84. package/out/renderer/assets/classDiagram-GIVACNV2-CfiTqRrL.js +0 -1
  85. package/out/renderer/assets/classDiagram-v2-COTLJTTW-CfiTqRrL.js +0 -1
  86. package/out/renderer/assets/clone-DjeICEmq.js +0 -1
  87. package/out/renderer/assets/consoleCapture-BPecswCL.js +0 -1
  88. package/out/renderer/assets/dagre-OKDRZEBW-DId-VIUD.js +0 -4
  89. package/out/renderer/assets/diagram-SSKATNLV-B91xcqFD.js +0 -43
  90. package/out/renderer/assets/diagram-VNBRO52H-2FONSfG-.js +0 -24
  91. package/out/renderer/assets/error-boundary-bl9plxwd.js +0 -126
  92. package/out/renderer/assets/ganttDiagram-APWFNJXF-DuMe7srU.js +0 -257
  93. package/out/renderer/assets/gitGraphDiagram-7IBYFJ6S-IweLEul4.js +0 -65
  94. package/out/renderer/assets/index-BCLoCIgZ.js +0 -1
  95. package/out/renderer/assets/index-D7kPcQIL.css +0 -1
  96. package/out/renderer/assets/index-DThKaYgW.js +0 -7
  97. package/out/renderer/assets/infoDiagram-PH2N3AL5-DJ28BiA9.js +0 -2
  98. package/out/renderer/assets/installer-B5olEpOL.js +0 -1
  99. package/out/renderer/assets/mesh-page-DJ2Xu7WX.js +0 -2
  100. package/out/renderer/assets/mindmap-definition-ALO5MXBD-CL0_Dklo.js +0 -95
  101. package/out/renderer/assets/org-surface-gate-DBSpQaKQ.js +0 -1
  102. package/out/renderer/assets/pieDiagram-IB7DONF6-D7sMeZBn.js +0 -30
  103. package/out/renderer/assets/projects-page-BXnZiqzW.js +0 -22
  104. package/out/renderer/assets/radient-auth-buttons-D2Mlpaea.js +0 -1
  105. package/out/renderer/assets/sankeyDiagram-QLVOVGJD-CDDiu1t7.js +0 -10
  106. package/out/renderer/assets/stateDiagram-DGXRK772-DZNHqXFO.js +0 -1
  107. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-BR9bXWLS.js +0 -1
  108. package/out/renderer/assets/use-memberships-query-DBa-IUeT.js +0 -1
  109. /package/out/renderer/assets/{index-BkWL0Tso.js → index-CDaH3A1m.js} +0 -0
@@ -1,22 +0,0 @@
1
- import{r as x,j as t,c as O}from"./index-BkWL0Tso.js";import{cb as Ft,cc as we,cd as Ut,ce as ot,g as lt,cf as Bt,cg as Yt,ch as qt,ci as zt,cj as Qt,ck as Ht,cl as qe,cm as ze,cn as Kt,co as Vt,h as ct,as as te,k as Y,am as Re,aY as Wt,i as he,cp as dt,ac as xe,aB as fe,cq as Xt,cr as Gt,cs as Jt,ct as ve,aC as ut,cu as Zt,cv as es,j as de,cw as ts,bM as ss,P as ue,f as ns,e as as,cx as rs,cy as is,cz as os,cA as ls,cB as cs,cC as ds,cD as us,c as mt,a8 as ms,ax as Qe,cE as hs,aw as xs,ad as V,at as G,d as He,cF as fs,cG as ps,cH as gs,a as js,b1 as bs,cI as Ke,cJ as ys}from"./index-BYm582eS.js";import{P as Ve}from"./page-header-CSth8igb.js";import{c as pe,B as $,v as vs,w as ks,x as Ns,F as ke,Q as ws,R as Ss,U as Cs,V as Ts,W as Ds,z as _s,G as se,P as Ms,Y as Es,M as Ps,I as U,S as ee,L as I,T as $s,p as Se,q as Ce,r as Te,s as De,t as ce,Z as ht,N as Os,X as As,i as Rs,A as _e,_ as Ls,$ as Is,a0 as Fs,a1 as Us}from"./error-boundary-bl9plxwd.js";import"./console-mirror-gvEt6nID.js";function We(e,s){return e.filter(n=>!s.includes(n))}function Bs(e,s,n){const a=e.slice(0);return a[s]=n,a}var Ys=class extends Ft{#n;#e;#a;#r;#t;#s;#i;#o;#l=[];constructor(e,s,n){super(),this.#n=e,this.#r=n,this.#a=[],this.#t=[],this.#e=[],this.setQueries(s)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(s=>{this.#m(e,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,s){this.#a=e,this.#r=s,we.batch(()=>{const n=this.#t,a=this.#u(this.#a);this.#l=a,a.forEach(i=>i.observer.setOptions(i.defaultedQueryOptions));const r=a.map(i=>i.observer),o=r.map(i=>i.getCurrentResult()),l=r.some((i,f)=>i!==n[f]);n.length===r.length&&!l||(this.#t=r,this.#e=o,this.hasListeners()&&(We(n,r).forEach(i=>{i.destroy()}),We(r,n).forEach(i=>{i.subscribe(f=>{this.#m(i,f)})}),this.#h()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,s){const n=this.#u(e),a=n.map(r=>r.observer.getOptimisticResult(r.defaultedQueryOptions));return[a,r=>this.#d(r??a,s),()=>this.#c(a,n)]}#c(e,s){return s.map((n,a)=>{const r=e[a];return n.defaultedQueryOptions.notifyOnChangeProps?r:n.observer.trackResult(r,o=>{s.forEach(l=>{l.observer.trackProp(o)})})})}#d(e,s){return s?((!this.#s||this.#e!==this.#o||s!==this.#i)&&(this.#i=s,this.#o=this.#e,this.#s=Ut(this.#s,s(e))),this.#s):e}#u(e){const s=new Map(this.#t.map(a=>[a.options.queryHash,a])),n=[];return e.forEach(a=>{const r=this.#n.defaultQueryOptions(a),o=s.get(r.queryHash);o?n.push({defaultedQueryOptions:r,observer:o}):n.push({defaultedQueryOptions:r,observer:new ot(this.#n,r)})}),n}#m(e,s){const n=this.#t.indexOf(e);n!==-1&&(this.#e=Bs(this.#e,n,s),this.#h())}#h(){if(this.hasListeners()){const e=this.#s,s=this.#c(this.#e,this.#l),n=this.#d(s,this.#r?.combine);e!==n&&we.batch(()=>{this.listeners.forEach(a=>{a(this.#e)})})}}};function qs({queries:e,...s},n){const a=lt(),r=Bt(),o=Yt(),l=x.useMemo(()=>e.map(g=>{const C=a.defaultQueryOptions(g);return C._optimisticResults=r?"isRestoring":"optimistic",C}),[e,a,r]);l.forEach(g=>{qt(g),zt(g,o)}),Qt(o);const[i]=x.useState(()=>new Ys(a,l,s)),[f,p,d]=i.getOptimisticResult(l,s.combine),N=!r&&s.subscribed!==!1;x.useSyncExternalStore(x.useCallback(g=>N?i.subscribe(we.batchCalls(g)):Ht,[i,N]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),x.useEffect(()=>{i.setQueries(l,s)},[l,s,i]);const h=f.some((g,C)=>qe(l[C],g))?f.flatMap((g,C)=>{const j=l[C];if(j){const c=new ot(a,j);if(qe(j,g))return ze(j,c,o);Kt(g,r)&&ze(j,c,o)}return[]}):[];if(h.length>0)throw Promise.all(h);const v=f.find((g,C)=>{const j=l[C];return j&&Vt({result:g,errorResetBoundary:o,throwOnError:j.throwOnError,query:a.getQueryCache().get(j.queryHash),suspense:j.suspense})});if(v?.error)throw v.error;return p(d())}/**
2
- * @license lucide-react v0.507.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const zs=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Qs=pe("grip-vertical",zs);/**
7
- * @license lucide-react v0.507.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const Hs=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Ks=pe("link-2",Hs);/**
12
- * @license lucide-react v0.507.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const Vs=[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]],Ws=pe("send-horizontal",Vs);/**
17
- * @license lucide-react v0.507.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const Xs=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],Gs=pe("unlink",Xs),ge={list:["desktop","projects"],detail:e=>["desktop","projects",e]};function Js(e){return ct({queryKey:ge.list,enabled:e,queryFn:()=>Y({op:"projects.list"}).then(s=>s.projects),retry:Re,staleTime:1e4})}function Zs(e,s){return qs({queries:e.map(n=>({queryKey:ge.detail(n),enabled:s&&!!n,queryFn:()=>Y({op:"projects.get",key:n}),retry:Re,staleTime:1e4}))})}function xt(e,s){return ct({queryKey:ge.detail(e??""),enabled:s&&!!e,queryFn:()=>Y({op:"projects.get",key:e??""}),retry:Re,staleTime:1e4})}function ne(){const e=lt();return()=>{e.invalidateQueries({queryKey:ge.list})}}function en(){const e=ne();return te({mutationFn:s=>Y({op:"projects.create",name:s.name,...s.description!==void 0?{description:s.description}:{},...s.status!==void 0?{status:s.status}:{},...s.tags!==void 0?{tags:s.tags}:{}}),onSuccess:()=>e()})}function ft(){const e=ne();return te({mutationFn:s=>Y({op:"projects.update",key:s.key,fields:s.fields}),onSuccess:()=>e()})}function pt(){const e=ne();return te({mutationFn:s=>Y({op:"projects.delete",key:s.key,confirmed_name:s.confirmedName}),onSuccess:()=>e()})}function tn(){const e=ne();return te({mutationFn:s=>Y({op:"projects.link",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function sn(){const e=ne();return te({mutationFn:s=>Y({op:"projects.unlink",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function nn(){const e=ne();return te({mutationFn:s=>Y({op:"projects.milestone",key:s.key,name:s.name,...s.targetDate!==void 0?{targetDate:s.targetDate}:{},...s.completed!==void 0?{completed:s.completed}:{}}),onSuccess:()=>e()})}function an(){const e=ne();return te({mutationFn:s=>Y({op:"projects.milestone.remove",key:s.key,name:s.name}),onSuccess:()=>e()})}const rn={planning:{label:"Planning",variant:"info"},active:{label:"Active",variant:"accent"},qa:{label:"QA",variant:"attention"},validation:{label:"Validation",variant:"warning"},done:{label:"Done",variant:"success"},paused:{label:"Paused",variant:"neutral"},archived:{label:"Archived",variant:"outline"}};function F(e){return rn[e]??{label:e||"Unknown",variant:"neutral"}}function on(e){return e==="done"}const ln={completed:{label:"Completed",variant:"success"},overdue:{label:"Overdue",variant:"warning"},upcoming:{label:"Upcoming",variant:"neutral"}};function cn(e){return ln[e]??{label:String(e),variant:"neutral"}}const me="Stale",dn=/^(\d{4})-(\d{2})-(\d{2})$/;function z(e,s,n=new Date){if(!e)return"";const a=dn.exec(e);if(!a)return e;const r=new Date(Number(a[1]),Number(a[2])-1,Number(a[3]));if(Number.isNaN(r.getTime()))return e;const o=r.toLocaleDateString(s,{month:"short",day:"numeric"});return r.getFullYear()===n.getFullYear()?o:`${o}, ${r.getFullYear()}`}function re(e,s){if(e==null)return"";const n=Math.max(0,Math.floor(s/1e3-e));return n<60?"just now":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}d`}function ie(e){return e==="just now"?"just now":`${e} ago`}function un(e){return e?`reported ${ie(e)}`:"no progress"}const gt=/^$|^\d{4}-\d{2}-\d{2}$/;function jt(e){return e?e==="operator"?"the operator":`session ${e}`:""}function mn(e,s){if(!e.progress)return"not reported yet";const n=re(e.progress_updated_at,s),a=jt(e.progress_reported_by),r=[n?`reported ${ie(n)}`:"reported"];return a&&r.push(`by ${a}`),r.join(" ")}function bt(e,s){if(e==null)return"";const n=String(e);return s==="points"?`${n} pt`:s==="days"?`${n}d`:n}function yt(e,s){return s<=0?"":`${e}/${s}`}function Le(e){return e<=0?"":`${e} live`}function hn(e){return e<=0?"":e===1?"1 session":`${e} sessions`}function xn(e){const s=hn(e.sessions);if(!s)return"";const n=Le(e.live_sessions);return n?`${s} · ${n}`:s}function fn(e){if(!e.exists)return{label:"Missing",variant:"outline"};if(e.archived)return{label:"Archived",variant:"neutral"};switch(e.runtime?.state){case"live":return{label:"Live",variant:"success"};case"wedged":return{label:"Wedged",variant:"warning"};case"stale":return{label:"Stale",variant:"warning"};case"stopped":return{label:"Stopped",variant:"neutral"};default:return{label:String(e.runtime?.state??"Unknown"),variant:"neutral"}}}function pn(e){return e?e.running>0?e.running===1?"1 subagent running":`${e.running} subagents running`:e.settled===1?"1 subagent":`${e.settled} subagents`:""}function gn(e){return e?e.total===1?"1 todo":`${e.total} todos`:""}function vt(e,s){const n=[],a=z(e.completed_at??e.target_date,s);a&&n.push({key:e.completed_at?"completed":"target",text:e.completed_at?`completed ${a}`:`due ${a}`});const r=bt(e.estimate,e.estimate_unit);r&&n.push({key:"estimate",text:r});const o=yt(e.milestones_completed,e.milestones_total);o&&n.push({key:"milestones",text:`milestones ${o}`});const l=Le(e.live_sessions);return l&&n.push({key:"live",text:l}),n}const ae=864e5,jn=/^(\d{4})-(\d{2})-(\d{2})$/;function Z(e){if(!e)return null;const s=jn.exec(e);if(!s)return null;const n=Number(s[1]),a=Number(s[2]),r=Number(s[3]),o=Date.UTC(n,a-1,r),l=new Date(o);return l.getUTCFullYear()!==n||l.getUTCMonth()!==a-1||l.getUTCDate()!==r?null:o}const Me=["planning","active","qa","validation","done"],Ee=["paused","archived"],kt="projects-board-column-order";let Pe=null;function bn(){if(Pe)return[...Pe];try{const e=localStorage.getItem(kt);if(!e)return[];const s=JSON.parse(e);if(!Array.isArray(s))return[];const n=[];for(const a of s){if(typeof a!="string"||a.length===0)return[];n.includes(a)||n.push(a)}return n}catch{return[]}}function yn(e){Pe=[...e];try{localStorage.setItem(kt,JSON.stringify(e))}catch{}}function vn(e,s,n){const a=e.filter(o=>o!==s),r=Math.max(0,Math.min(n,a.length));return a.splice(r,0,s),a}function kn(e,s=[]){const n=new Map;for(const i of e){const f=n.get(i.status)??[];f.push(i),n.set(i.status,f)}const a=Me.map(i=>({status:i,projects:n.get(i)??[]}));for(const i of Ee){const f=n.get(i)??[];f.length>0&&a.push({status:i,projects:f})}for(const[i,f]of n)!Ee.includes(i)&&!Me.includes(i)&&a.push({status:i,projects:f});if(s.length===0)return a;const r=new Map(s.map((i,f)=>[i,f])),o=a.filter(i=>r.has(i.status));o.sort((i,f)=>(r.get(i.status)??0)-(r.get(f.status)??0));const l=a.filter(i=>!r.has(i.status));return[...o,...l]}function Nn(e,s){if(e.status==="done"||e.status==="archived"||e.completed_at)return!1;const n=Z(e.target_date);return n===null?!1:n<s}function Nt(e){return e.title||e.name}function wn(e,s){const n=[];for(const a of[e,s]){const r=a?.trim();r&&!n.includes(r)&&n.push(r)}return n.join(" · ")}function Ie(e){return e.title||e.session_id}function Sn(e){return[...e].reverse()}function Cn(e){return e<=0?"":e===1?"1 update":`${e} updates`}const Xe=e=>String(e).padStart(2,"0");function $e(e){return`${e.getFullYear()}-${Xe(e.getMonth()+1)}-${Xe(e.getDate())}`}function Tn(e){const s=Date.parse(e);return Number.isNaN(s)?"":$e(new Date(s))}function Dn(e,s,n=new Date){if(!e)return"";if(e===$e(n))return"Today";const a=new Date(n.getFullYear(),n.getMonth(),n.getDate()-1);return e===$e(a)?"Yesterday":z(e,s,n)}function _n(e,s){const n=Date.parse(e);return Number.isNaN(n)?"":new Date(n).toLocaleTimeString(s,{hour:"numeric",minute:"2-digit"})}function Mn(e,s){const n=Date.parse(e);return Number.isNaN(n)?"":ie(re(n/1e3,s))}function En(e,s,n=Date.now()){const a=[],r=jt(e.by);r&&a.push({key:"author",text:r});const o=_n(e.at,s);o&&a.push({key:"time",text:o});const l=Mn(e.at,n);return l&&a.push({key:"age",text:l}),a}function Pn(e,s,n=new Date){const a=[];for(const r of Sn(e)){const o=Tn(r.at),l=a[a.length-1];if(l&&l.key===o){l.entries.push(r);continue}a.push({key:o,label:Dn(o,s,n),entries:[r]})}return a}function $n(e){return!Number.isFinite(e)||e<0?"":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function On(e,s){return s<=0?"":`${e} of ${s} complete`}function An(e){let s=0,n=0,a=!1;for(const r of e)r.todos&&(a=!0,s+=r.todos.open,n+=r.todos.total);return a?{open:s,total:n}:null}function Ge(e){return`${e.open} open of ${e.total}`}function Rn(e){const s=e.filter(a=>a.exists);return(s.find(a=>a.runtime?.state==="live")??s[0])?.session_id??null}function Ln(e){const s=Nt(e),n=e.progress.trim()||"not reported yet";return[`Continue work on project "${s}" (${e.name}).`,`Latest progress: ${n}`,"Review the project details and continue or complete the work."].join(`
22
- `)}function In(e){return e?e.kind==="team"?`team ${e.name}`:`agent ${e.name}`:""}const Je="complete them, or pass force_done=true to close with them open",Fn="complete or remove the incomplete milestones, then mark it done";function Un(e){return e.includes(Je)?e.replace(Je,Fn):e}const X=["day","week","month","quarter"],Fe={day:24,week:9,month:3,quarter:1};function wt(e){const s=new Date(e);return Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())}function J(e,s){return Math.round((s-e)/ae)}function Ze(e,s){return J(e,s)+1}function Bn(e,s){for(const n of X)if(e*Fe[n]<=s)return n;return X[X.length-1]}function Yn(e){const{project:s}=e;return s.start_date||s.target_date||s.completed_at?!0:e.milestones.some(n=>!!n.target_date)}function qn(e,s){const n=[s];for(const a of e){for(const r of[a.project.start_date,a.project.target_date,a.project.completed_at]){const o=Z(r);o!==null&&n.push(o)}for(const r of a.milestones){const o=Z(r.target_date);o!==null&&n.push(o)}}return n.length===1?null:{startMs:Math.min(...n),endMs:Math.max(...n)}}function zn(e){const s=[],n=[];for(const a of e)(Yn(a)?s:n).push(a);return{dated:s,undated:n}}function Qn(e){const{project:s}=e,n=Z(s.start_date),a=Z(s.target_date),r=Z(s.completed_at),o=s.status==="done"&&r!==null?r:a,l=n??o,i=o??n;return l===null||i===null?null:{fromMs:Math.min(l,i),toMs:Math.max(l,i)}}function Hn(e){const s=[];for(const n of e.milestones){const a=Z(n.target_date);a!==null&&s.push({name:n.name,dayMs:a,status:n.status})}return s}const le=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function B(e){const s=new Date(e);return{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),weekday:s.getUTCDay()}}function Kn(e){const{year:s,month:n}=B(e);return Date.UTC(s,n-1,1)}function Vn(e){const{year:s,month:n}=B(e);return n===12?Date.UTC(s+1,0,1):Date.UTC(s,n,1)}function Wn(e){const{year:s,month:n}=B(e);return Date.UTC(s,Math.floor((n-1)/3)*3,1)}function Xn(e){const{year:s,month:n}=B(e),a=Math.floor((n-1)/3);return a===3?Date.UTC(s+1,0,1):Date.UTC(s,a*3+3,1)}function Gn(e){const{weekday:s}=B(e);return e-(s+6)%7*ae}const Jn=26;function Zn(e,s,n){const a=[],r=(d,N,u)=>{d<e||d>s||a.push({dayMs:d,label:N,major:u})};if(n==="day"){let d=!1;for(let N=e;N<=s;N+=ae){const{day:u,month:h}=B(N);u===1?(r(N,le[h-1],!0),d=!0):d?(r(N,"",!1),d=!1):r(N,String(u),!1)}return a}if(n==="week"){for(let d=Gn(e);d<=s;d+=7*ae){if(d<e)continue;const{day:N,month:u}=B(d);B(d-7*ae).month!==u?r(d,`${le[u-1]} ${N}`,!0):r(d,String(N),!1)}return a}const o=n==="month"?Kn:Wn,l=n==="month"?Vn:Xn,i=d=>{const{year:N,month:u}=B(d);if(n==="month")return u===1&&N!==B(e).year?`${le[0]} '${String(N%100).padStart(2,"0")}`:le[u-1];const h=Math.floor((u-1)/3)+1;return h===1&&N!==B(e).year?`Q1 '${String(N%100).padStart(2,"0")}`:`Q${h}`};r(e,i(o(e)),!0);const f=Math.ceil(Jn/Fe[n]);let p=e;for(let d=l(o(e));d<=s;d=l(d))J(p,d)<f||(r(d,i(d),!0),p=d);return a}const et={active:"In flight",paused:"On hold",done:"Finished"};function ea(){const[e,s]=x.useState(null);return x.useEffect(()=>{if(!e)return;const n=document.querySelector(`[data-project-menu="${e}"]`);n&&(n.focus(),s(null))}),x.useCallback(n=>s(n),[])}const ta=4,Ne="Drag the header, or press the arrow keys, to move this column.",tt="board-column-move-hint",sa=({projects:e,nowMs:s,onOpen:n,onEdit:a,onDelete:r,onMove:o,movingKeys:l=[]})=>{const[i,f]=x.useState(bn),p=kn(e,i),[d,N]=x.useState(null),[u,h]=x.useState(""),v=x.useRef(null),g=x.useRef(null),C=x.useRef(null),j=x.useRef(null),c=x.useRef(null),m=new Set(l),w=(b,y)=>{const S=vn(p.map(M=>M.status),b,y);f(S),yn(S),h(`Moved ${F(b).label} column to position ${S.indexOf(b)+1} of ${S.length}.`)},D=(b,y)=>{const S=v.current;if(!S)return 0;let M=0;const A=S.querySelectorAll("[data-board-column]");for(const R of A){if(R.dataset.boardColumn===y)continue;const K=R.getBoundingClientRect();b>(K.left+K.right)/2&&(M+=1)}return M},_=(b,y)=>{const S=p.filter(R=>R.status!==b),M=S[y-1]?.status,A=S[y]?.status;return M&&A?`between ${F(M).label} and ${F(A).label}`:A?`before ${F(A).label}`:M?`after ${F(M).label}`:"in place"},P=(b,y)=>{const S=D(b,y.status);S!==y.over&&(y.over=S,N({status:y.status,over:S}),h(`Moving ${F(y.status).label} column; it will drop ${_(y.status,S)}.`))},Q=()=>{j.current!==null&&(cancelAnimationFrame(j.current),j.current=null)},T=32,k=12,E=()=>{j.current=null;const b=c.current,y=v.current,S=C.current;if(!b?.armed||!y||S===null)return;const M=y.getBoundingClientRect(),A=y.scrollWidth-y.clientWidth;let R=0;if(S-M.left<T&&y.scrollLeft>0?R=-1:M.right-S<T&&y.scrollLeft<A&&(R=1),R!==0){const K=y.scrollLeft;y.scrollLeft=K+R*k,y.scrollLeft!==K&&P(S,b)}else P(S,b);be(b.status,b.over),j.current=requestAnimationFrame(E)};x.useEffect(()=>()=>{j.current!==null&&cancelAnimationFrame(j.current)},[]);const q=(b,y)=>{if(b.button===0){try{b.currentTarget.setPointerCapture(b.pointerId)}catch{}c.current={pointerId:b.pointerId,status:y,startX:b.clientX,startY:b.clientY,armed:!1,over:p.findIndex(S=>S.status===y)},C.current=b.clientX}},H=b=>{const y=c.current;if(!(!y||b.pointerId!==y.pointerId)){if(C.current=b.clientX,!y.armed){if(Math.hypot(b.clientX-y.startX,b.clientY-y.startY)<ta)return;y.armed=!0,N({status:y.status,over:y.over}),h(`Moving ${F(y.status).label} column.`),j.current===null&&(j.current=requestAnimationFrame(E))}P(b.clientX,y)}},L=b=>{const y=c.current;if(c.current=null,Q(),N(null),!y?.armed)return;if(!b){h("Move cancelled.");return}const S=p.findIndex(M=>M.status===y.status);if(y.over===S){h("");return}w(y.status,y.over)},oe=b=>{const y=c.current;!y||b.pointerId!==y.pointerId||L(!0)},je=()=>{L(!1)};x.useEffect(()=>{if(!d)return;const b=y=>{y.key==="Escape"&&L(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[d!==null]);const be=x.useCallback((b,y)=>{const S=v.current,M=g.current;if(!S||!M)return;const A=S.getBoundingClientRect(),R=[];for(const Ye of S.querySelectorAll("[data-board-column]"))Ye.dataset.boardColumn!==b&&R.push(Ye.getBoundingClientRect());const K=6,Ot=y>=R.length?(R[R.length-1]?.right??A.left)+K:(R[y]?.left??A.right)-K,ye=S.scrollLeft,At=2,Rt=Ot-A.left+ye,Be=ye+1,Lt=ye+A.width-At-1,It=Math.round(Math.min(Math.max(Rt,Be),Math.max(Be,Lt)));M.style.left=`${It}px`},[]);x.useLayoutEffect(()=>{d&&be(d.status,d.over)},[d,be]);const $t=(b,y)=>{if(b.key==="Enter"||b.key===" "){b.preventDefault(),h(Ne);return}if(b.key!=="ArrowLeft"&&b.key!=="ArrowRight")return;b.preventDefault();const S=p.map(R=>R.status),M=S.indexOf(y),A=b.key==="ArrowLeft"?M-1:M+1;if(A<0||A>=S.length){h(`${F(y).label} column is already ${A<0?"the first column":"the last column"}.`);return}w(y,A)};return t.jsxs("div",{className:"@container flex min-h-0 flex-1 flex-col overflow-hidden rounded-md bg-surface","data-testid":"project-board",children:[t.jsx("output",{"aria-live":"polite",className:"sr-only","data-board-column-announcement":"",children:u}),t.jsx("span",{id:tt,className:"sr-only",children:Ne}),t.jsxs("div",{ref:v,className:O("relative flex min-h-0 flex-1 items-stretch gap-3 overflow-x-auto p-3",d&&"cursor-grabbing select-none"),children:[d&&t.jsx("div",{ref:g,"aria-hidden":"true","data-board-drop-indicator":"",className:"pointer-events-none absolute top-3 bottom-3 w-0.5 rounded-full bg-accent"}),p.map(b=>{const y=F(b.status);return t.jsxs("section",{"data-board-column":b.status,className:"flex w-64 shrink-0 flex-col overflow-hidden rounded-md bg-sunken",children:[t.jsxs("header",{"data-board-column-handle":b.status,onPointerDown:S=>q(S,b.status),onPointerMove:H,onPointerUp:oe,onPointerCancel:je,className:O("flex shrink-0 cursor-grab items-center justify-between gap-2 border-b border-hairline px-3 py-2 active:cursor-grabbing",d?.status===b.status&&"opacity-85"),children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[t.jsx($,{type:"button",variant:"ghost",size:"icon-sm","data-board-column-grip":b.status,"aria-label":`Move ${y.label} column`,"aria-describedby":tt,title:Ne,className:"-ml-1.5 cursor-grab text-ink-muted active:cursor-grabbing",onKeyDown:S=>$t(S,b.status),children:t.jsx(Qs,{"aria-hidden":"true"})}),t.jsxs("span",{className:"flex min-w-0 items-baseline gap-2",children:[t.jsx("span",{className:"truncate text-body-sm font-medium text-ink",children:y.label}),et[b.status]&&t.jsx("span",{className:"truncate text-meta text-ink-muted",children:et[b.status]})]})]}),t.jsx("span",{className:"text-meta text-ink-muted",children:b.projects.length})]}),b.projects.length===0?t.jsx("p",{className:"px-3 py-4 text-meta text-ink-muted",children:"No projects here."}):t.jsx("ul",{className:"flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto p-2",children:b.projects.map(S=>t.jsx("li",{children:t.jsx(na,{project:S,nowMs:s,busy:m.has(S.id),onOpen:()=>n(S),onEdit:()=>a(S),onDelete:()=>r(S),onMove:M=>o(S,M)})},S.id))})]},b.status)})]})]})},na=({project:e,nowMs:s,busy:n,onOpen:a,onEdit:r,onDelete:o,onMove:l})=>{const i=vt(e,typeof navigator>"u"?void 0:navigator.language),f=Nn(e,wt(s)),p=re(e.progress_updated_at,s),d=()=>{const u=window.getSelection();u&&!u.isCollapsed||a()},N=u=>{u.key!=="Enter"&&u.key!==" "||u.target===u.currentTarget&&(u.preventDefault(),a())};return t.jsxs("div",{"data-project-name":e.name,role:"button",tabIndex:0,"aria-label":`Open ${e.name}`,onClick:d,onKeyDown:N,className:O("group/card flex flex-col gap-2 rounded-sm bg-surface p-3","transition-colors duration-fast ease-out-quart hover:bg-elevated",f&&"border border-warning-border"),children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-body-sm font-medium text-ink",children:e.name}),e.description&&t.jsx("span",{className:"mt-0.5 block truncate text-meta text-ink-muted",children:e.description})]}),t.jsxs(vs,{children:[t.jsx(ks,{"data-project-menu":e.id,"aria-label":`Actions for ${e.name}`,disabled:n,onClick:u=>u.stopPropagation(),className:O("shrink-0 rounded-sm p-1 text-ink-muted whitespace-nowrap","hover:bg-sunken hover:text-ink"),children:t.jsx(Wt,{className:"size-4"})}),t.jsxs(Ns,{align:"end",onClick:u=>u.stopPropagation(),children:[t.jsx(ke,{onSelect:a,children:"Open"}),t.jsxs(ws,{children:[t.jsx(Ss,{children:"Set status"}),t.jsx(Cs,{children:t.jsx(Ts,{value:e.status,onValueChange:l,children:[...Me,...Ee].map(u=>t.jsx(Ds,{value:u,children:F(u).label},u))})})]}),t.jsx(_s,{}),t.jsx(ke,{onSelect:r,children:"Edit"}),t.jsx(ke,{onSelect:o,children:"Delete"})]})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[i.filter(u=>u.key!=="live").map(u=>t.jsx("span",{className:"rounded-sm bg-sunken px-1.5 py-0.5 text-meta text-ink-muted",children:u.text},u.key)),f&&t.jsx(se,{variant:"warning",children:"Overdue"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-meta text-ink-muted",children:un(p)}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[(e.progress_stale||!p)&&t.jsx("span",{"aria-label":me,title:me,className:"size-1.5 rounded-full bg-warning"}),e.sessions>0&&t.jsx(aa,{project:e})]})]})]})},aa=({project:e})=>{const[s,n]=x.useState(!1),a=he(),r=xt(e.id,s),o=r.data?.links??[],l=xn(e);return t.jsxs(Ms,{open:s,onOpenChange:n,children:[t.jsx(Es,{"data-project-sessions":e.id,"aria-label":`Sessions linked to ${e.name}`,onClick:i=>i.stopPropagation(),className:O("rounded-sm px-1 text-meta whitespace-nowrap",e.live_sessions>0?"text-success hover:bg-sunken":"text-ink-muted hover:bg-sunken"),children:l}),t.jsx(Ps,{align:"end",className:"w-64 p-2 outline-none",onClick:i=>i.stopPropagation(),children:r.isLoading?t.jsx("p",{className:"px-1 py-2 text-meta text-ink-muted",children:"Loading linked sessions…"}):r.isError?t.jsxs("div",{className:"flex flex-col items-start gap-1.5 px-1 py-2",children:[t.jsx("p",{className:"text-meta text-ink-muted",children:r.error instanceof Error&&r.error.message?r.error.message:"The linked sessions could not be read."}),t.jsx($,{variant:"secondary",size:"sm",onClick:()=>void r.refetch(),children:"Try again"})]}):o.length===0?t.jsx("p",{className:"px-1 py-2 text-meta text-ink-muted",children:"No sessions linked yet."}):t.jsx("ul",{className:"flex flex-col",children:o.map(i=>t.jsx("li",{children:t.jsx("button",{type:"button",disabled:!i.exists,onClick:()=>{i.exists&&(n(!1),dt(a,i.session_id))},className:O("flex w-full items-center gap-2 rounded-sm px-1 py-1.5 text-left text-meta",i.exists?"text-ink hover:bg-elevated":"text-ink-disabled"),children:t.jsx("span",{className:"truncate",children:i.title||i.session_id})})},i.session_id))})})]})},St=({open:e,projectName:s,onClose:n,onConfirm:a})=>{const[r,o]=x.useState(""),[l,i]=x.useState(null),[f,p]=x.useState(!1),d=x.useId();x.useEffect(()=>{e&&(o(""),i(null),p(!1))},[e]);const N=r.trim().toLowerCase()===s.trim().toLowerCase()&&s.trim().length>0,u=async()=>{p(!0),i(null);try{await a(r.trim()),n()}catch(h){i(h instanceof Error&&h.message?h.message:"The project was not deleted.")}finally{p(!1)}};return t.jsx(xe,{open:e,onClose:n,title:"Delete this project?",dataTourTag:"project-delete-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(fe,{onClick:n,disabled:f,children:"Cancel"}),t.jsxs(Xt,{onClick:()=>void u(),disabled:!N||f,children:[f&&t.jsx(ee,{size:"xs"}),"Delete project"]})]}),children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"text-body-sm text-ink",children:"This deletes the project and its milestones. The sessions linked to it are not touched."}),t.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Type"," ",t.jsx("span",{className:"font-mono text-mono-sm text-ink",children:s})," ","to confirm."]}),t.jsx(U,{id:`${d}-confirm`,value:r,onChange:h=>o(h.target.value),placeholder:s,"aria-label":"Type the project name to confirm","aria-invalid":r.length>0&&!N,autoFocus:!0}),l&&t.jsx("p",{className:"text-body-sm text-danger",children:l})]})})},ra=/^(https?:|mailto:)/i,ia={a:({href:e,children:s})=>typeof e=="string"&&ra.test(e)?t.jsx("a",{href:e,target:"_blank",rel:"noreferrer",children:s}):t.jsx("span",{className:"font-mono text-mono-sm",children:s})},Oe=x.memo(({children:e,className:s})=>t.jsx("div",{className:O("lo-markdown",s),children:t.jsx(Gt,{remarkPlugins:[Jt],components:ia,children:e})})),oa=[{value:"planning",label:"Planning"},{value:"active",label:"Active"},{value:"qa",label:"QA"},{value:"validation",label:"Validation"},{value:"done",label:"Done"},{value:"paused",label:"Paused"},{value:"archived",label:"Archived"}],Ct={name:"",title:"",owner:"",team:"",description:"",status:"active",tags:"",startDate:"",targetDate:"",estimate:"",estimateUnit:"points"},st=gt;function nt(e){return e.split(",").map(s=>s.trim()).filter(s=>s.length>0)}function la(e){return e?{name:e.name,title:e.title??"",owner:e.owner??"",team:e.team??"",description:e.description,status:e.status,tags:e.tags.join(", "),startDate:e.start_date??"",targetDate:e.target_date??"",estimate:e.estimate===null||e.estimate===void 0?"":String(e.estimate),estimateUnit:e.estimate_unit||"points"}:Ct}const Ae=({open:e,mode:s,initial:n,onClose:a,onSubmit:r})=>{const[o,l]=x.useState(Ct),[i,f]=x.useState({}),[p,d]=x.useState(null),N=x.useRef(null),[u,h]=x.useState(!1),v=x.useId();x.useEffect(()=>{e&&(l(la(n)),f({}),d(null),h(!1))},[e]),x.useEffect(()=>{p&&N.current?.scrollIntoView({block:"nearest"})},[p]);const g=(m,w)=>{l(D=>({...D,[m]:w}))},C=m=>{const w={},D=Zt(m.name.trim());D&&(w.name=D),m.description.length>ve&&(w.description=`Keep the description within ${ve} characters.`);const _=nt(m.tags);if(_.length>8)w.tags="At most 8 tags.";else for(const P of _){const Q=es(P);if(Q){w.tags=Q;break}}if(s==="edit"){if(st.test(m.startDate)||(w.startDate="Dates are YYYY-MM-DD, or empty."),st.test(m.targetDate)||(w.targetDate="Dates are YYYY-MM-DD, or empty."),!w.startDate&&!w.targetDate&&m.startDate&&m.targetDate&&m.targetDate<m.startDate&&(w.targetDate="The target date is before the start date."),m.estimate){const P=Number(m.estimate);(!Number.isFinite(P)||!(P>0)||P>1e3)&&(w.estimate="Estimates are greater than 0 and at most 1000.")}for(const P of["title","owner","team"])m[P].trim().length>80&&(w[P]=`${P==="title"?"Titles":P==="owner"?"Owners":"Teams"} are at most 80 characters.`)}return w},j=async()=>{const m=C(o);if(f(m),Object.keys(m).length>0)return;h(!0),d(null);const w=nt(o.tags);try{s==="create"?await r({mode:"create",fields:{name:o.name.trim(),...o.description.trim()?{description:o.description.trim()}:{},status:o.status,...w.length>0?{tags:w}:{}}}):await r({mode:"edit",key:n?.key??"",fields:{name:o.name.trim(),description:o.description.trim(),title:o.title.trim(),owner:o.owner.trim(),team:o.team.trim(),status:o.status,tags:w,start_date:o.startDate,target_date:o.targetDate,...o.estimate?{estimate:Number(o.estimate)}:{},estimate_unit:o.estimateUnit}}),a()}catch(D){const _=D instanceof Error&&D.message?D.message:"";d(Un(_)||"The project was not saved.")}finally{h(!1)}},c=s==="create"?"New project":"Edit project";return t.jsx(xe,{open:e,onClose:a,title:c,maxWidth:"sm",dataTourTag:s==="create"?"project-create-dialog":"project-edit-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(fe,{onClick:a,disabled:u,children:"Cancel"}),t.jsxs(ut,{onClick:()=>void j(),disabled:u,children:[u&&t.jsx(ee,{size:"xs"}),s==="create"?"Create project":"Save changes"]})]}),children:t.jsxs("form",{className:"flex flex-col gap-4 px-1 py-1",onSubmit:m=>{m.preventDefault(),j()},children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(I,{htmlFor:`${v}-name`,children:"Name"}),t.jsx(U,{id:`${v}-name`,value:o.name,onChange:m=>g("name",m.target.value),placeholder:"payments-migration",autoFocus:!0,"aria-invalid":!!i.name}),i.name?t.jsx("p",{className:"text-meta text-danger",children:i.name}):t.jsx("p",{className:"text-meta text-ink-muted",children:"Letters, digits, dot, underscore or dash; no spaces."})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(I,{htmlFor:`${v}-description`,children:"Description"}),t.jsx($s,{id:`${v}-description`,value:o.description,onChange:m=>g("description",m.target.value),rows:2,"aria-invalid":!!i.description}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.description?t.jsx("p",{className:"text-meta text-danger",children:i.description}):t.jsx("span",{}),t.jsxs("p",{className:"text-meta text-ink-muted tabular-nums",children:[o.description.length,"/",ve]})]})]}),s==="edit"&&t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(I,{htmlFor:`${v}-title`,children:"Display title"}),t.jsx(U,{id:`${v}-title`,value:o.title,onChange:m=>g("title",m.target.value),placeholder:"Payments migration","aria-invalid":!!i.title}),i.title?t.jsx("p",{className:"text-meta text-danger",children:i.title}):t.jsx("p",{className:"text-meta text-ink-muted",children:"Shown instead of the name; the name stays the key everything is addressed by."})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(I,{children:"Status"}),t.jsxs(Se,{value:o.status,onValueChange:m=>g("status",m),children:[t.jsx(Ce,{"aria-label":"Status",children:t.jsx(Te,{})}),t.jsx(De,{children:oa.map(m=>t.jsx(ce,{value:m.value,children:m.label},m.value))})]}),o.status==="done"&&t.jsx("p",{className:"text-meta text-ink-muted",children:"Moving a project to Done stamps today as its completion date."})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(I,{htmlFor:`${v}-tags`,children:"Tags"}),t.jsx(U,{id:`${v}-tags`,value:o.tags,onChange:m=>g("tags",m.target.value),placeholder:"q4, payments","aria-invalid":!!i.tags}),i.tags?t.jsx("p",{className:"text-meta text-danger",children:i.tags}):t.jsx("p",{className:"text-meta text-ink-muted",children:"Comma-separated, up to 8. Lowercase letters, digits, underscore or dash."})]}),s==="edit"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(I,{htmlFor:`${v}-start`,children:"Start date"}),t.jsx(U,{id:`${v}-start`,value:o.startDate,onChange:m=>g("startDate",m.target.value),placeholder:"YYYY-MM-DD","aria-invalid":!!i.startDate}),i.startDate&&t.jsx("p",{className:"text-meta text-danger",children:i.startDate})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(I,{htmlFor:`${v}-target`,children:"Target date"}),t.jsx(U,{id:`${v}-target`,value:o.targetDate,onChange:m=>g("targetDate",m.target.value),placeholder:"YYYY-MM-DD","aria-invalid":!!i.targetDate}),i.targetDate&&t.jsx("p",{className:"text-meta text-danger",children:i.targetDate})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(I,{htmlFor:`${v}-owner`,children:"Owner"}),t.jsx(U,{id:`${v}-owner`,value:o.owner,onChange:m=>g("owner",m.target.value),placeholder:"atlas","aria-invalid":!!i.owner}),i.owner&&t.jsx("p",{className:"text-meta text-danger",children:i.owner})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(I,{htmlFor:`${v}-team`,children:"Team"}),t.jsx(U,{id:`${v}-team`,value:o.team,onChange:m=>g("team",m.target.value),placeholder:"platform","aria-invalid":!!i.team}),i.team&&t.jsx("p",{className:"text-meta text-danger",children:i.team})]})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(I,{htmlFor:`${v}-estimate`,children:"Estimate"}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(U,{id:`${v}-estimate`,value:o.estimate,onChange:m=>g("estimate",m.target.value),placeholder:"13",inputMode:"decimal","aria-invalid":!!i.estimate,className:"max-w-28"}),t.jsxs(Se,{value:o.estimateUnit,onValueChange:m=>g("estimateUnit",m),children:[t.jsx(Ce,{"aria-label":"Estimate unit",className:"max-w-32",children:t.jsx(Te,{})}),t.jsxs(De,{children:[t.jsx(ce,{value:"points",children:"Points"}),t.jsx(ce,{value:"days",children:"Days"})]})]})]}),i.estimate&&t.jsx("p",{className:"text-meta text-danger",children:i.estimate}),s==="edit"&&o.estimate.trim()===""&&n?.estimate!==null&&n?.estimate!==void 0&&t.jsx("p",{className:"text-meta text-ink-muted",children:"Clearing an estimate is not supported yet — saving keeps its current value."})]})]}),p&&t.jsx("p",{ref:N,className:"text-body-sm text-danger",children:p})]})})},ca=({links:e,target:s,onTargetChange:n,onSend:a,focusTick:r})=>{const[o,l]=x.useState(""),[i,f]=x.useState(!1),p=x.useRef(null);x.useEffect(()=>{r>0&&p.current?.focus()},[r]);const d=e.filter(g=>g.exists),u=(d.find(g=>g.session_id===s)??null)?.runtime?.busy===!0,h=!!s&&o.trim().length>0&&!i,v=async()=>{if(!(!h||!s)){f(!0);try{await a(s,o.trim(),u?"steer":"prompt")&&l("")}finally{f(!1),p.current?.focus()}}};return t.jsxs("div",{className:"flex flex-col gap-2 rounded-md bg-elevated p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-meta text-ink-muted",children:"Send to"}),t.jsxs(Se,{value:s??void 0,onValueChange:g=>n(g),children:[t.jsx(Ce,{"aria-label":"Select the session to message",className:"max-w-72",children:t.jsx(Te,{placeholder:"No session selected"})}),t.jsx(De,{children:d.map(g=>t.jsx(ce,{value:g.session_id,children:Ie(g)},g.session_id))})]}),u&&t.jsx("span",{className:"text-meta text-ink-muted",children:"The session is working — this message steers the running turn."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(U,{ref:p,"aria-label":"Message the selected session",placeholder:"Message the session",value:o,onChange:g=>l(g.target.value),onKeyDown:g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),v())}}),t.jsxs($,{variant:"secondary",disabled:!h,onClick:()=>void v(),"data-tour-tag":"project-quick-send",children:[i?t.jsx(ee,{size:"xs"}):t.jsx(Ws,{}),"Send"]})]})]})},da=({links:e,busy:s,onUnlink:n,onLink:a,onQuickSend:r,onStartSession:o})=>{const l=he(),i=de(j=>j.sessions),[f,p]=x.useState(!1),[d,N]=x.useState(null),[u,h]=x.useState(0),v=d&&e.some(j=>j.session_id===d&&j.exists)?d:Rn(e),g=x.useMemo(()=>{const j=new Set(e.map(c=>c.session_id));return i.filter(c=>!j.has(c.session_id)).map(c=>({id:c.session_id,name:c.title||c.session_id,description:c.cwd??void 0}))},[i,e]),C=j=>{de.getState().openSession(j).then(c=>{c&&l(`/chat/${j}`)})};return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"Linked sessions"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs($,{variant:"secondary",size:"sm",disabled:s,onClick:o,"data-tour-tag":"project-start-session",children:[t.jsx(ts,{}),"New session"]}),t.jsxs($,{variant:"secondary",size:"sm",disabled:s,onClick:()=>p(!0),"data-tour-tag":"project-link-session",children:[t.jsx(Ks,{}),"Link session"]})]})]}),e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No sessions linked yet. Link the conversations that are working on this project so its progress stays with them."}):t.jsx("ul",{className:"flex flex-col divide-y divide-hairline rounded-md bg-surface",children:e.map(j=>{const c=fn(j),m=pn(j.subagents),w=gn(j.todos),D=j.title||j.session_id,_=j.exists;return t.jsxs("li",{className:O("flex items-center gap-2 rounded-sm px-2 py-2",_&&"hover:bg-row-hover"),children:[t.jsx("button",{type:"button",disabled:!_,onClick:()=>{_&&C(j.session_id)},className:O("flex min-w-0 flex-1 items-center gap-2 text-left",_?"cursor-pointer":"cursor-default opacity-100"),children:t.jsx("span",{className:O("min-w-0 truncate text-body-sm",j.title?"text-ink":"font-mono text-mono-sm text-ink-muted"),children:D})}),j.runtime?.busy===!0&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:"busy"}),m&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:m}),w&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:w}),t.jsx(se,{variant:c.variant,children:c.label}),_&&t.jsx($,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":`Message ${D}`,title:`Message ${D}`,onClick:()=>{N(j.session_id),h(P=>P+1)},children:t.jsx(ss,{})}),t.jsx($,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":`Unlink ${D}`,onClick:()=>n(j.session_id),children:t.jsx(Gs,{})})]},j.session_id)})}),e.length>0&&t.jsx(ca,{links:e,target:v,onTargetChange:N,onSend:r,focusTick:u}),t.jsx(xe,{open:f,onClose:()=>p(!1),title:"Link a session",maxWidth:"sm",dataTourTag:"project-link-dialog",actions:t.jsx(fe,{onClick:()=>p(!1),children:"Close"}),children:t.jsxs("div",{className:"flex flex-col gap-2 px-1 py-1",children:[t.jsx(I,{children:"Session"}),t.jsx(ht,{showLabel:!1,ariaLabel:"Search sessions",busyLabel:"Loading sessions",placeholder:"Search conversations",options:g,selected:null,onSelect:j=>{p(!1),a(j.id)}}),t.jsx("p",{className:"text-meta text-ink-muted",children:"Conversations already linked to this project are not listed."})]})})]})},ua=({milestones:e,summary:s,busy:n,onToggle:a,onRemove:r,onAdd:o})=>{const[l,i]=x.useState(""),[f,p]=x.useState(""),d=!gt.test(f.trim()),N=l.trim().length>0&&!d&&!n,u=()=>{N&&(o(l.trim(),f.trim()),i(""),p(""))};return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"Milestones"}),s&&e.length>0&&t.jsx("span",{className:"text-meta text-ink-muted tabular-nums",children:s})]}),e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No milestones yet. Add one below to mark the dates this project is planned around."}):t.jsx("ul",{className:"flex flex-col divide-y divide-hairline rounded-md bg-surface",children:e.map(h=>{const v=cn(h.status),g=h.completed_at!==null;return t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx(Os,{checked:g,disabled:n,onCheckedChange:C=>a(h.name,C===!0),"aria-label":g?`Mark ${h.name} not complete`:`Mark ${h.name} complete`}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:h.name}),h.target_date&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:z(h.target_date,typeof navigator>"u"?void 0:navigator.language)}),t.jsx(se,{variant:v.variant,children:v.label}),t.jsx($,{variant:"ghost",size:"icon-sm",disabled:n,"aria-label":`Remove ${h.name}`,onClick:()=>r(h.name),children:t.jsx(As,{})})]},h.name)})}),t.jsxs("div",{className:"flex items-end gap-3",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[t.jsx(I,{htmlFor:"project-milestone-name",children:"New milestone"}),t.jsx(U,{id:"project-milestone-name",value:l,onChange:h=>i(h.target.value),placeholder:"beta cut",onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),u())}})]}),t.jsxs("div",{className:"flex w-40 flex-col gap-1.5",children:[t.jsx(I,{htmlFor:"project-milestone-date",children:"Target date"}),t.jsx(U,{id:"project-milestone-date",value:f,onChange:h=>p(h.target.value),placeholder:"YYYY-MM-DD","aria-invalid":d}),d&&t.jsx("p",{className:"text-meta text-danger",children:"Dates are YYYY-MM-DD, or empty."})]}),t.jsxs($,{variant:"secondary",disabled:!N,onClick:u,"data-tour-tag":"project-milestone-add",children:[t.jsx(ue,{}),"Add"]})]})]})},ma=({project:e,nowMs:s})=>{const n=typeof navigator>"u"?void 0:navigator.language,a=new Date(s),r=[],o=z(e.start_date,n,a);o&&r.push({label:"Start",value:o});const l=z(e.target_date,n,a);l&&r.push({label:"Target",value:l});const i=z(e.completed_at,n,a);i&&r.push({label:"Completed",value:i});const f=bt(e.estimate,e.estimate_unit);if(f&&r.push({label:"Estimate",value:f}),e.tags.length>0&&r.push({label:"Tags",value:t.jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:e.tags.map(p=>t.jsx(se,{variant:"outline",children:p},p))})}),e.updated_at>0){const p=ie(re(e.updated_at,s)),d=new Date(e.updated_at*1e3).toLocaleString(n);r.push({label:"Updated",value:t.jsx("time",{dateTime:new Date(e.updated_at*1e3).toISOString(),title:d,children:p})})}return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"Properties"}),r.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No dates, estimate or tags yet."}):t.jsx("dl",{className:"flex flex-col gap-2",children:r.map(p=>t.jsxs("div",{className:"flex items-baseline gap-3",children:[t.jsx("dt",{className:"w-24 shrink-0 text-body-sm text-ink-muted",children:p.label}),t.jsx("dd",{className:"min-w-0 text-body-sm text-ink",children:p.value})]},p.label))})]})},Tt="plain",Dt=e=>`team:${e}`,_t=e=>`agent:${e}`;function ha(e){return e.startsWith("team:")?{kind:"team",name:e.slice(5)}:e.startsWith("agent:")?{kind:"agent",name:e.slice(6)}:{kind:"plain"}}function xa(e){return e.kind==="team"?Dt(e.name):e.kind==="agent"?_t(e.name):Tt}const at={kind:"plain"},fa=({open:e,onClose:s,onStart:n,teamsEnabled:a,profilesEnabled:r})=>{const[o,l]=x.useState(at),[i,f]=x.useState(null),[p,d]=x.useState(!1),N=ns(e&&a),u=as(e&&r);x.useEffect(()=>{e&&(l(at),f(null),d(!1))},[e]);const h=x.useMemo(()=>{const c=[{id:Tt,name:"Nothing in particular",description:"A plain session; assign a team or agent later.",group:"Plain"}];for(const m of N.data??[])c.push({id:Dt(m.name),name:m.name,description:`Team · manager: ${m.manager}`,group:"Teams"});for(const m of(u.data??[]).filter(w=>w.source!=="builtin"))c.push({id:_t(m.name),name:m.name,description:m.description||m.kind,group:"Agents"});return c},[N.data,u.data]),v=h.find(c=>c.id===xa(o))??h[0],g=!a||!r,C=N.isLoading||u.isLoading,j=async()=>{d(!0),f(null);try{await n(o),s()}catch(c){f(c instanceof Error&&c.message?c.message:"The session could not be started.")}finally{d(!1)}};return t.jsx(xe,{open:e,onClose:s,title:"Start a session",maxWidth:"sm",dataTourTag:"project-start-session-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(fe,{onClick:s,disabled:p,children:"Cancel"}),t.jsxs(ut,{onClick:()=>void j(),disabled:p,children:[p&&t.jsx(ee,{size:"xs"}),"Start session"]})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx(ht,{label:"Work with",placeholder:"Search teams and agents",options:h,selected:v,onSelect:c=>l(ha(c.id)),busy:C,busyLabel:"Loading teams and agents"}),t.jsx("p",{className:"text-meta text-ink-muted",children:"The session starts now, links itself to this project, and opens with a prompt you can edit before sending."}),g&&t.jsx("p",{className:"text-meta text-ink-muted",children:"This server does not offer the team or agent catalogues yet, so only a plain session can be started."}),i&&t.jsx("p",{className:"text-body-sm text-danger",children:i})]})})},Mt=({status:e})=>{const s=F(e);return t.jsxs(se,{variant:s.variant,children:[on(e)&&t.jsx(Rs,{"aria-hidden":!0}),s.label]})},pa=({links:e})=>{const s=An(e),n=e.filter(a=>a.todos!==null);return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"To-dos"}),s&&t.jsx("span",{className:"text-meta text-ink-muted tabular-nums",children:Ge(s)})]}),n.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No to-do snapshots from the linked sessions yet. A session publishes its list as it works, and it appears here once it has."}):t.jsx("ul",{className:"flex flex-col divide-y divide-hairline",children:n.map(a=>t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx("span",{className:a.title?"min-w-0 flex-1 truncate text-body-sm text-ink":"min-w-0 flex-1 truncate font-mono text-mono-sm text-ink-muted",children:Ie(a)}),a.todos&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:Ge(a.todos)})]},a.session_id))})]})},ga=/[/\\]/;function Et(e){if(e.name)return e.name;const s=e.path.split(ga);return s[s.length-1]||"Attachment"}const ja=({attachment:e})=>{const s=Et(e),n=$n(e.bytes);return t.jsxs("div",{className:"flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-surface px-3 py-2",children:[t.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2.5 text-left",onClick:()=>{window.api?.openFile(e.path)},title:`Open ${s}`,children:[t.jsx(ds,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),t.jsx("span",{className:"truncate text-body-sm text-ink",children:s})]}),n&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:n}),t.jsx(us,{filePath:e.path,"aria-label":`File actions for ${s}`})]})},ba=({attachment:e})=>{const s=Et(e),n=rs(e.path,{mimeType:is(e.name||e.path),sizeBytes:e.bytes});return n.status==="ready"?t.jsx("div",{className:"inline-block max-w-full",children:t.jsx(os,{file:e.path,src:n.url,label:s,conversationId:""})}):n.status==="loading"?t.jsx(ls,{children:t.jsxs("span",{className:"sr-only",children:["Loading ",s]})}):t.jsx(cs,{name:s})},ya=({attachments:e})=>t.jsx("div",{className:"flex flex-wrap items-start gap-2",children:e.map(s=>s.kind==="image"?t.jsx(ba,{attachment:s},`${s.path}:${s.added_at}`):t.jsx(ja,{attachment:s},`${s.path}:${s.added_at}`))}),va=({update:e,nowMs:s})=>{const n=typeof navigator>"u"?void 0:navigator.language,a=En(e,n,s);return t.jsxs("article",{className:"flex flex-col gap-2 rounded-sm px-2 py-3",children:[a.length>0&&t.jsx("p",{className:"flex flex-wrap items-baseline gap-x-2 text-meta text-ink-muted",children:a.map((r,o)=>t.jsxs(x.Fragment,{children:[o>0&&t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{children:r.text})]},r.key))}),e.text&&t.jsx(Oe,{children:e.text}),e.attachments.length>0&&t.jsx(ya,{attachments:e.attachments})]})},ka=({updates:e,nowMs:s})=>{const n=typeof navigator>"u"?void 0:navigator.language,a=Cn(e.length),r=Pn(e,n,new Date(s));return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"Updates"}),a&&t.jsx("span",{className:"text-meta text-ink-muted",children:a})]}),e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No updates yet. Progress reported by you or by the sessions working on this project is appended here."}):t.jsx("div",{className:"flex flex-col gap-4",children:r.map(o=>t.jsxs("div",{className:"flex flex-col gap-2",children:[o.label&&t.jsx("h3",{className:"text-meta text-ink-muted",children:o.label}),t.jsx("div",{className:"flex flex-col divide-y divide-hairline",children:o.entries.map((l,i)=>t.jsx(va,{update:l,nowMs:s},`${l.at}:${l.by}:${i}`))})]},o.key||"ungrouped"))})]})},Na="project_not_found",wa=({projectKey:e,nowMs:s})=>{const n=he(),a=mt(),r=xt(e,!0),o=ft(),l=pt(),i=nn(),f=an(),p=tn(),d=sn(),[N,u]=x.useState(!1),[h,v]=x.useState(!1),[g,C]=x.useState(!1),j=o.isPending||l.isPending||i.isPending||f.isPending||p.isPending||d.isPending;if(r.isLoading)return t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(ee,{label:"Loading project"})});if(r.isError||!r.data){const T=r.error instanceof ms&&(r.error.code===Na||r.error.status===404);return t.jsxs("div",{className:"mx-auto flex w-full max-w-200 flex-col items-start gap-4",children:[t.jsx(_e,{variant:"danger",className:"w-full",children:T?"This project could not be found. It may have been deleted.":r.error instanceof Error&&r.error.message?r.error.message:"The project could not be read."}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx($,{variant:"secondary",onClick:()=>void r.refetch(),children:"Try again"}),t.jsxs($,{variant:"secondary",onClick:()=>void n("/projects"),children:[t.jsx(Qe,{}),"All projects"]})]})]})}const{project:c,links:m}=r.data,w=Nt(c),D=wn(c.owner,c.team),_=On(c.milestones.filter(T=>T.completed_at!==null).length,c.milestones.length),P=async(T,k,E)=>{const q=de.getState(),H=fs(null,T,q.drafts);if(!H)return!1;try{if(await ps(H,{text:k,attachments:[],images:[],mode:E,cwd:q.cwd},T)===null)return V("That session already has a message going out. Try again in a moment."),!1;const oe=m.find(je=>je.session_id===T);return G(`Sent to ${oe?Ie(oe):T}`),!0}catch(L){return V(L instanceof Error&&L.message?L.message:"The message was not sent."),!1}},Q=async T=>{const k=de.getState(),E=T.kind==="plain"?void 0:{kind:T.kind,name:T.name},q=await k.createSession(k.cwd||"~",E);if(!q)throw new Error(k.error??"The session could not be started.");gs.getState().setCurrentInput(q,Ln(c));let H=null;try{await p.mutateAsync({key:c.id,sessionId:q})}catch(L){H=L instanceof Error&&L.message?L.message:"the link was refused"}if(H)V(`Session started, but linking it failed: ${H}`);else{const L=E?` with ${In(E)}`:"";G(`Session started${L} and linked to ${w}.`)}await dt(n,q)};return t.jsxs("div",{className:"mx-auto flex min-h-0 w-full max-w-200 flex-1 flex-col gap-8 overflow-y-auto",children:[t.jsxs("header",{className:"flex flex-col gap-4",children:[t.jsxs("button",{type:"button",onClick:()=>void n("/projects"),className:"flex w-fit items-center gap-1.5 text-body-sm text-ink-muted hover:text-ink",children:[t.jsx(Qe,{className:"size-4"}),"All projects"]}),t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("h1",{className:"min-w-0 truncate text-display text-ink",children:w}),t.jsx(Mt,{status:c.status}),c.progress_stale&&t.jsx(se,{variant:"warning",children:me})]}),c.title&&t.jsx("p",{className:"font-mono text-mono-sm text-ink-muted",children:c.name}),D&&t.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Managed by ",D]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs($,{variant:"secondary",onClick:()=>u(!0),"data-tour-tag":"project-edit",children:[t.jsx(hs,{}),"Edit"]}),t.jsxs($,{variant:"secondary",onClick:()=>v(!0),"data-tour-tag":"project-delete",children:[t.jsx(xs,{}),"Delete"]})]})]})]}),c.description.trim()&&t.jsx(Oe,{className:"text-body",children:c.description}),t.jsx(ma,{project:c,nowMs:s}),c.updates.length===0&&c.progress&&t.jsxs("section",{className:"flex flex-col gap-2",children:[t.jsx("h2",{className:"text-title text-ink",children:"Progress"}),t.jsx(Oe,{className:"text-body",children:c.progress}),t.jsx("p",{className:"text-meta text-ink-muted",children:mn(c,s)})]}),t.jsx(ua,{milestones:c.milestones,summary:_,busy:j,onToggle:(T,k)=>{i.mutateAsync({key:c.id,name:T,completed:k}).catch(E=>{V(E instanceof Error&&E.message?E.message:"The milestone was not updated.")})},onRemove:T=>{f.mutateAsync({key:c.id,name:T}).catch(k=>{V(k instanceof Error&&k.message?k.message:"The milestone was not removed.")})},onAdd:(T,k)=>{i.mutateAsync({key:c.id,name:T,targetDate:k}).catch(E=>{V(E instanceof Error&&E.message?E.message:"The milestone was not added.")})}}),t.jsx(da,{projectKey:c.id,links:m,busy:j,onStartSession:()=>C(!0),onQuickSend:P,onLink:T=>{p.mutateAsync({key:c.id,sessionId:T}).catch(k=>{V(k instanceof Error&&k.message?k.message:"The session was not linked.")})},onUnlink:T=>{d.mutateAsync({key:c.id,sessionId:T}).catch(k=>{V(k instanceof Error&&k.message?k.message:"The session was not unlinked.")})}}),t.jsx(pa,{links:m}),t.jsx(ka,{updates:c.updates,nowMs:s}),t.jsx(Ae,{open:N,mode:"edit",initial:{key:c.id,name:c.name,title:c.title,owner:c.owner,team:c.team,description:c.description,status:c.status,tags:c.tags,start_date:c.start_date,target_date:c.target_date,estimate:c.estimate,estimate_unit:c.estimate_unit},onClose:()=>u(!1),onSubmit:async T=>{T.mode==="edit"&&(await o.mutateAsync({key:T.key,fields:T.fields}),G("Project saved"))}}),t.jsx(St,{open:h,projectName:c.name,onClose:()=>v(!1),onConfirm:async T=>{await l.mutateAsync({key:c.id,confirmedName:T}),G("Project deleted"),n("/projects")}}),t.jsx(fa,{open:g,onClose:()=>C(!1),onStart:Q,teamsEnabled:He(a.data,"team_catalogue"),profilesEnabled:He(a.data,"profile_catalogue")})]})},W=[{key:"name",label:"Project",className:"min-w-0 flex-1"},{key:"status",label:"Status",className:"w-20 shrink-0"},{key:"target",label:"Target",className:"hidden w-32 shrink-0 @[40rem]:block"},{key:"estimate",label:"Estimate",className:"hidden w-16 shrink-0 @[40rem]:block"},{key:"milestones",label:"Milestones",className:"hidden w-20 shrink-0 @[34rem]:block"},{key:"live",label:"Live",className:"hidden w-14 shrink-0 @[34rem]:block"},{key:"progress",label:"Progress",className:"w-40 shrink-0"}];function Sa(e,s){const n=re(e.progress_updated_at,s);return n?ie(n):"not reported"}const Ca=({projects:e,nowMs:s,onOpen:n})=>t.jsxs("div",{className:"@container flex min-h-0 flex-1 flex-col overflow-hidden rounded-md bg-surface","data-testid":"project-list",children:[t.jsx("div",{className:"flex shrink-0 items-center gap-3 border-b border-hairline px-3 py-2 text-meta text-ink-muted","aria-hidden":"true",children:W.map(a=>t.jsx("span",{className:a.className,children:a.label},a.key))}),t.jsx("ul",{className:"min-h-0 flex-1 divide-y divide-hairline overflow-y-auto",children:e.map(a=>{const r=new Map(vt(a,typeof navigator>"u"?void 0:navigator.language).map(i=>[i.key,i.text])),o=yt(a.milestones_completed,a.milestones_total),l=Le(a.live_sessions);return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>n(a),"data-project-name":a.name,className:O("flex w-full items-center gap-3 px-3 py-2 text-left","transition-colors duration-fast ease-out-quart","hover:bg-elevated"),children:[t.jsx("span",{className:O(W[0].className,"truncate text-body-sm text-ink"),children:a.name}),t.jsx("span",{className:W[1].className,children:t.jsx(Mt,{status:a.status})}),t.jsx("span",{className:O(W[2].className,"truncate text-meta text-ink-muted"),children:r.get("target")??r.get("completed")??""}),t.jsx("span",{className:O(W[3].className,"truncate text-meta text-ink-muted"),children:r.get("estimate")??""}),t.jsx("span",{className:O(W[4].className,"truncate text-meta text-ink-muted"),children:o}),t.jsx("span",{className:O(W[5].className,"truncate text-meta text-ink-muted"),children:l}),t.jsxs("span",{className:O(W[6].className,"flex items-center gap-2"),children:[t.jsx("span",{className:"truncate text-meta text-ink-muted",children:Sa(a,s)}),a.progress_stale&&t.jsx(se,{variant:"warning",children:me})]})]})},a.id)})})]}),Ue=224,rt=36,Ta={day:"Days",week:"Weeks",month:"Months",quarter:"Quarters"},Da=({items:e,nowMs:s,onOpen:n,pendingDetails:a,failedDetails:r,onRetryDetails:o})=>{const[l,i]=x.useState(null),[f,p]=x.useState(0),d=x.useRef(null),N=wt(s),u=x.useMemo(()=>qn(e,N),[e,N]),h=x.useMemo(()=>zn(e),[e]);x.useLayoutEffect(()=>{const w=d.current;if(!w)return;const D=()=>p(w.clientWidth);if(D(),typeof ResizeObserver>"u")return;const _=new ResizeObserver(D);return _.observe(w),()=>_.disconnect()},[]);const v=Math.max(f-Ue-24,160),g=u?Bn(Ze(u.startMs,u.endMs),v):"month",C=l??g,j=w=>{const D=X.indexOf(C),_=X[D-w];_&&i(_)},c=Fe[C],m=u?Ze(u.startMs,u.endMs)*c:0;return t.jsxs("div",{ref:d,className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-md bg-surface","data-testid":"project-timeline",children:[t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-hairline px-3 py-2",children:[t.jsx("span",{className:"truncate text-meta text-ink-muted","data-timeline-note":!0,children:r>0?`Milestones could not be read for ${r} project${r===1?"":"s"}.`:a>0?`Loading milestones for ${a} project${a===1?"":"s"}…`:`${h.dated.length} dated · ${h.undated.length} without dates`}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[r>0&&t.jsx($,{variant:"secondary",size:"sm",onClick:o,children:"Try again"}),t.jsx($,{variant:"secondary",size:"icon","aria-label":"Zoom in",title:"Zoom in (finer)",disabled:!u||C===X[0],onClick:()=>j(1),children:t.jsx(ue,{})}),t.jsx("span",{className:"w-16 text-center text-meta text-ink-muted",children:Ta[C]}),t.jsx($,{variant:"secondary",size:"icon","aria-label":"Zoom out",title:"Zoom out (coarser)",disabled:!u||C===X[X.length-1],onClick:()=>j(-1),children:t.jsx(Ls,{})})]})]}),u&&h.dated.length>0?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsxs("div",{className:"min-w-max",children:[t.jsx(_a,{startMs:u.startMs,endMs:u.endMs,tier:C,pxPerDay:c,trackPx:m}),h.dated.map(w=>t.jsx(Ma,{item:w,spanStart:u.startMs,pxPerDay:c,trackPx:m,today:N,onOpen:()=>n(w)},w.project.id))]})}):t.jsx("p",{className:"px-3 py-6 text-body-sm text-ink-muted",children:"No dates on any project yet. Set a start date, a target date or a milestone date and it will appear on the timeline."}),h.undated.length>0&&t.jsxs("div",{className:"shrink-0 border-t border-hairline px-3 py-2 text-meta text-ink-muted",children:["No dates (",h.undated.length,"):"," ",h.undated.map((w,D)=>t.jsxs("span",{children:[D>0&&", ",t.jsx("button",{type:"button",className:"text-ink hover:underline",onClick:()=>n(w),children:w.project.name})]},w.project.id))]})]})},_a=({startMs:e,endMs:s,tier:n,pxPerDay:a,trackPx:r})=>{const o=Zn(e,s,n);return t.jsxs("div",{className:"flex items-stretch border-b border-hairline",children:[t.jsx("span",{className:"sticky left-0 z-10 shrink-0 bg-surface",style:{width:Ue}}),t.jsx("span",{className:"relative block h-6",style:{width:r},children:o.map(l=>t.jsxs("span",{className:"absolute top-0 h-full",style:{left:J(e,l.dayMs)*a},children:[t.jsx("span",{className:O("absolute top-0 h-full w-px",l.major?"bg-hairline":"bg-hairline/60"),"aria-hidden":"true"}),t.jsx("span",{className:"absolute top-1/2 left-1 -translate-y-1/2 whitespace-nowrap text-meta text-ink-muted",children:l.label})]},l.dayMs))})]})},Ma=({item:e,spanStart:s,pxPerDay:n,trackPx:a,today:r,onOpen:o})=>{const{project:l}=e,i=Qn(e),f=Hn(e),p=d=>new Date(d).toISOString().slice(0,10);return t.jsxs("button",{type:"button",onClick:o,"data-project-name":l.name,className:"flex w-full items-stretch text-left transition-colors duration-fast ease-out-quart hover:bg-elevated",children:[t.jsx("span",{className:"sticky left-0 z-10 flex shrink-0 items-center gap-2 border-r border-hairline bg-surface px-3",style:{width:Ue,height:rt},children:t.jsx("span",{className:"truncate text-body-sm text-ink",children:l.name})}),t.jsxs("span",{className:"relative block",style:{width:a,height:rt},children:[i&&t.jsx("span",{className:"absolute top-1/2 h-1.5 -translate-y-1/2 rounded-full bg-accent/75",style:{left:J(s,i.fromMs)*n,width:(J(i.fromMs,i.toMs)+1)*n},title:`${z(p(i.fromMs))} → ${z(p(i.toMs))}`}),f.map(d=>t.jsx("span",{"data-milestone":d.status,className:O("absolute top-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rotate-45",d.status==="completed"&&"bg-success",d.status==="overdue"&&"bg-warning",d.status==="upcoming"&&"border-[1.5px] border-ink-muted bg-surface"),style:{left:J(s,d.dayMs)*n},title:`${d.name} · ${d.status} · ${z(p(d.dayMs))}`},`${d.name}-${d.dayMs}`)),t.jsx("span",{className:"absolute inset-y-0 w-px bg-accent/75",style:{left:J(s,r)*n},"aria-hidden":"true"})]})]})},Pt="projects-view",Ea=[{value:"list",label:"List"},{value:"board",label:"Board"},{value:"timeline",label:"Timeline"}];function Pa(){try{const e=localStorage.getItem(Pt);if(e==="board"||e==="timeline"||e==="list")return e}catch{}return"list"}function $a(e){try{localStorage.setItem(Pt,e)}catch{}}const Oa=({value:e,onChange:s})=>t.jsx(Is,{value:e,onValueChange:n=>s(n),children:t.jsx(Fs,{"aria-label":"Project view","data-tour-tag":"projects-view-switcher",children:Ea.map(n=>t.jsx(Us,{value:n.value,children:n.label},n.value))})}),it={unpaired:"This app is not paired with the Local Operator server, so Projects are unavailable.","below-version":"The Local Operator server is older than this app expects, so Projects are unavailable. Update the server and try again.",unknown:"The server's capabilities could not be read, so Projects are unavailable."},Ua=({nowMs:e=Date.now()})=>{const{projectId:s}=js(),n=he(),a=mt(),r=bs(a.data,"projects",1),o=r==="enabled",l=Js(o),i=en(),f=ft(),p=pt(),[d,N]=x.useState(!1),[u,h]=x.useState(()=>Pa()),[v,g]=x.useState(null),[C,j]=x.useState(null),c=ea(),m=l.data??[],w=Zs(u==="timeline"?m.map(k=>k.id):[],o),D=m.map((k,E)=>({project:k,milestones:w[E]?.data?.project.milestones??[]})),_=u==="timeline"?w.filter(k=>k.isLoading).length:0,P=u==="timeline"?w.filter(k=>k.isError).length:0,Q=()=>{for(const k of w)k.isError&&k.refetch()},T=(k,E)=>{f.mutate({key:k.id,fields:{status:E}},{onSuccess:()=>{G(`Moved to ${F(E).label}`),l.refetch().then(()=>c(k.id))}})};return o?s?t.jsx("div",{className:"flex h-full min-h-0 flex-col gap-8 p-6",children:t.jsx(wa,{projectKey:s,nowMs:e})}):t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-8 p-6",children:[t.jsx(Ve,{title:"Projects",icon:Ke,subtitle:"Workstreams you and your agents track across sessions.",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx($,{variant:"secondary",size:"icon","aria-label":"Refresh projects",title:"Refresh projects",disabled:l.isFetching,onClick:()=>void l.refetch(),"data-tour-tag":"refresh-projects-button",children:t.jsx(ys,{})}),t.jsxs($,{variant:"secondary",onClick:()=>N(!0),"data-tour-tag":"create-project-button",children:[t.jsx(ue,{}),"New project"]})]})}),t.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3",children:t.jsx(Oa,{value:u,onChange:k=>{h(k),$a(k)}})}),l.isLoading&&t.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-md bg-surface",children:t.jsx("div",{className:"flex flex-1 items-center justify-center",children:t.jsx(ee,{label:"Loading projects"})})}),l.isError&&t.jsxs("div",{className:"flex flex-col items-start gap-2",children:[t.jsx(_e,{variant:"danger",children:l.error instanceof Error&&l.error.message?l.error.message:"The projects could not be read."}),t.jsx($,{variant:"secondary",size:"sm",onClick:()=>void l.refetch(),children:"Try again"})]}),l.isSuccess&&l.data.length===0&&t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-4 overflow-hidden rounded-md bg-surface",children:[t.jsx("p",{className:"text-heading text-ink",children:"No projects yet."}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:"Create one here, or ask an agent to create one and link this session."}),t.jsxs($,{variant:"primary",onClick:()=>N(!0),"data-tour-tag":"create-project-empty-button",children:[t.jsx(ue,{}),"New project"]})]}),l.isSuccess&&l.data.length>0&&u==="list"&&t.jsx(Ca,{projects:l.data,nowMs:e,onOpen:k=>void n(`/projects/${k.id}`)}),l.isSuccess&&l.data.length>0&&u==="board"&&t.jsx(sa,{projects:m,nowMs:e,onOpen:k=>void n(`/projects/${k.id}`),onEdit:g,onDelete:j,onMove:T,movingKeys:f.isPending&&f.variables?[f.variables.key]:[]}),l.isSuccess&&l.data.length>0&&u==="timeline"&&t.jsx(Da,{items:D,nowMs:e,onOpen:k=>void n(`/projects/${k.project.id}`),pendingDetails:_,failedDetails:P,onRetryDetails:Q}),t.jsx(Ae,{open:v!==null,mode:"edit",initial:v?{key:v.id,name:v.name,title:v.title,owner:v.owner,team:v.team,description:v.description,status:v.status,tags:v.tags,start_date:v.start_date,target_date:v.target_date,estimate:v.estimate,estimate_unit:v.estimate_unit}:null,onClose:()=>g(null),onSubmit:async k=>{k.mode==="edit"&&(await f.mutateAsync({key:k.key,fields:k.fields}),G("Project saved"),g(null))}}),t.jsx(St,{open:C!==null,projectName:C?.name??"",onClose:()=>j(null),onConfirm:async k=>{C&&(await p.mutateAsync({key:C.id,confirmedName:k}),G("Project deleted"),j(null))}}),t.jsx(Ae,{open:d,mode:"create",onClose:()=>N(!1),onSubmit:async k=>{k.mode==="create"&&(await i.mutateAsync(k.fields),G(`Project ${k.fields.name} created`))}})]}):t.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[t.jsx(Ve,{title:"Projects",icon:Ke}),a.isLoading?t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(ee,{label:"Checking the server's Projects support"})}):t.jsx(_e,{variant:"warning",children:it[r]??it.unknown})]})};export{Ua as ProjectsPage};
@@ -1 +0,0 @@
1
- import{r as u,j as e}from"./index-BkWL0Tso.js";import{g as m,c as f,d as x,a4 as g,a5 as v,a6 as b}from"./index-BYm582eS.js";import{A as l,S as h}from"./error-boundary-bl9plxwd.js";function S(){const[o,d]=u.useState(null);return u.useEffect(()=>{const t=window.api?.backend;if(!t?.getStatus)return;let n=!0;const i=async()=>{try{const r=await t.getStatus();if(!n)return;const a=r?.pairing;d(a&&!a.available?a.cause??"unpaired":null)}catch{}};i();const s=t.onStatusChange?.(()=>void i());return()=>{n=!1,s?.()}},[]),o}const j="radient",w=({onSignInSuccess:o,onAfterCredentialUpdate:d,titleText:t="Sign in to Radient",descriptionText:n="Connect your Radient account to use Radient services."})=>{const i=m(),s=f(),r=x(s.data,"auth"),a=g(r),c=a.data?.find(p=>p.id===j);return s.isSuccess&&!r?e.jsx(l,{variant:"warning",children:"Signing in needs a newer Local Operator backend. Update the backend and restart the app."}):a.isLoading||s.isLoading?e.jsx("div",{className:"flex h-24 items-center justify-center",children:e.jsx(h,{size:"md",label:"Loading sign-in options"})}):c?e.jsxs("div",{className:"mx-auto w-full max-w-md",children:[t&&e.jsx("p",{className:"mb-2 text-center text-heading text-ink",children:t}),n&&e.jsx("p",{className:"mb-6 text-center text-body-sm text-ink-muted",children:n}),e.jsx(v,{provider:c,onConnected:()=>{i.invalidateQueries({queryKey:b.all}),d?.(),o?.()}})]}):e.jsx(l,{variant:"warning",children:"Radient is not available from this backend's provider registry."})};export{w as R,S as u};
@@ -1,10 +0,0 @@
1
- import{_ as g,q as mt,t as kt,s as _t,g as xt,b as vt,a as bt,c as ot,A as wt,d as G,V as St,z as Lt,k as Et}from"./mermaid.core-BimBLnQI.js";import{ab as At}from"./index-BYm582eS.js";import"./index-BkWL0Tso.js";import"./console-mirror-gvEt6nID.js";import"./error-boundary-bl9plxwd.js";function Tt(t){for(var n=t.length/6|0,i=new Array(n),a=0;a<n;)i[a]="#"+t.slice(a*6,++a*6);return i}const Mt=Tt("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab");function at(t,n){let i;if(n===void 0)for(const a of t)a!=null&&(i<a||i===void 0&&a>=a)&&(i=a);else{let a=-1;for(let h of t)(h=n(h,++a,t))!=null&&(i<h||i===void 0&&h>=h)&&(i=h)}return i}function dt(t,n){let i;if(n===void 0)for(const a of t)a!=null&&(i>a||i===void 0&&a>=a)&&(i=a);else{let a=-1;for(let h of t)(h=n(h,++a,t))!=null&&(i>h||i===void 0&&h>=h)&&(i=h)}return i}function J(t,n){let i=0;if(n===void 0)for(let a of t)(a=+a)&&(i+=a);else{let a=-1;for(let h of t)(h=+n(h,++a,t))&&(i+=h)}return i}function Nt(t){return t.target.depth}function It(t){return t.depth}function Pt(t,n){return n-1-t.height}function gt(t,n){return t.sourceLinks.length?t.depth:n-1}function Ct(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?dt(t.sourceLinks,Nt)-1:0}function Y(t){return function(){return t}}function lt(t,n){return q(t.source,n.source)||t.index-n.index}function ct(t,n){return q(t.target,n.target)||t.index-n.index}function q(t,n){return t.y0-n.y0}function tt(t){return t.value}function Ot(t){return t.index}function zt(t){return t.nodes}function Dt(t){return t.links}function ut(t,n){const i=t.get(n);if(!i)throw new Error("missing: "+n);return i}function ht({nodes:t}){for(const n of t){let i=n.y0,a=i;for(const h of n.sourceLinks)h.y0=i+h.width/2,i+=h.width;for(const h of n.targetLinks)h.y1=a+h.width/2,a+=h.width}}function $t(){let t=0,n=0,i=1,a=1,h=24,b=8,p,k=Ot,s=gt,o,l,_=zt,x=Dt,y=6;function v(){const e={nodes:_.apply(null,arguments),links:x.apply(null,arguments)};return M(e),T(e),N(e),C(e),S(e),ht(e),e}v.update=function(e){return ht(e),e},v.nodeId=function(e){return arguments.length?(k=typeof e=="function"?e:Y(e),v):k},v.nodeAlign=function(e){return arguments.length?(s=typeof e=="function"?e:Y(e),v):s},v.nodeSort=function(e){return arguments.length?(o=e,v):o},v.nodeWidth=function(e){return arguments.length?(h=+e,v):h},v.nodePadding=function(e){return arguments.length?(b=p=+e,v):b},v.nodes=function(e){return arguments.length?(_=typeof e=="function"?e:Y(e),v):_},v.links=function(e){return arguments.length?(x=typeof e=="function"?e:Y(e),v):x},v.linkSort=function(e){return arguments.length?(l=e,v):l},v.size=function(e){return arguments.length?(t=n=0,i=+e[0],a=+e[1],v):[i-t,a-n]},v.extent=function(e){return arguments.length?(t=+e[0][0],i=+e[1][0],n=+e[0][1],a=+e[1][1],v):[[t,n],[i,a]]},v.iterations=function(e){return arguments.length?(y=+e,v):y};function M({nodes:e,links:f}){for(const[c,r]of e.entries())r.index=c,r.sourceLinks=[],r.targetLinks=[];const u=new Map(e.map((c,r)=>[k(c,r,e),c]));for(const[c,r]of f.entries()){r.index=c;let{source:m,target:w}=r;typeof m!="object"&&(m=r.source=ut(u,m)),typeof w!="object"&&(w=r.target=ut(u,w)),m.sourceLinks.push(r),w.targetLinks.push(r)}if(l!=null)for(const{sourceLinks:c,targetLinks:r}of e)c.sort(l),r.sort(l)}function T({nodes:e}){for(const f of e)f.value=f.fixedValue===void 0?Math.max(J(f.sourceLinks,tt),J(f.targetLinks,tt)):f.fixedValue}function N({nodes:e}){const f=e.length;let u=new Set(e),c=new Set,r=0;for(;u.size;){for(const m of u){m.depth=r;for(const{target:w}of m.sourceLinks)c.add(w)}if(++r>f)throw new Error("circular link");u=c,c=new Set}}function C({nodes:e}){const f=e.length;let u=new Set(e),c=new Set,r=0;for(;u.size;){for(const m of u){m.height=r;for(const{source:w}of m.targetLinks)c.add(w)}if(++r>f)throw new Error("circular link");u=c,c=new Set}}function D({nodes:e}){const f=at(e,r=>r.depth)+1,u=(i-t-h)/(f-1),c=new Array(f);for(const r of e){const m=Math.max(0,Math.min(f-1,Math.floor(s.call(null,r,f))));r.layer=m,r.x0=t+m*u,r.x1=r.x0+h,c[m]?c[m].push(r):c[m]=[r]}if(o)for(const r of c)r.sort(o);return c}function B(e){const f=dt(e,u=>(a-n-(u.length-1)*p)/J(u,tt));for(const u of e){let c=n;for(const r of u){r.y0=c,r.y1=c+r.value*f,c=r.y1+p;for(const m of r.sourceLinks)m.width=m.value*f}c=(a-c+p)/(u.length+1);for(let r=0;r<u.length;++r){const m=u[r];m.y0+=c*(r+1),m.y1+=c*(r+1)}A(u)}}function S(e){const f=D(e);p=Math.min(b,(a-n)/(at(f,u=>u.length)-1)),B(f);for(let u=0;u<y;++u){const c=Math.pow(.99,u),r=Math.max(1-c,(u+1)/y);j(f,c,r),P(f,c,r)}}function P(e,f,u){for(let c=1,r=e.length;c<r;++c){const m=e[c];for(const w of m){let L=0,R=0;for(const{source:U,value:Z}of w.targetLinks){let W=Z*(w.layer-U.layer);L+=$(U,w)*W,R+=W}if(!(R>0))continue;let F=(L/R-w.y0)*f;w.y0+=F,w.y1+=F,E(w)}o===void 0&&m.sort(q),O(m,u)}}function j(e,f,u){for(let c=e.length,r=c-2;r>=0;--r){const m=e[r];for(const w of m){let L=0,R=0;for(const{target:U,value:Z}of w.sourceLinks){let W=Z*(U.layer-w.layer);L+=I(w,U)*W,R+=W}if(!(R>0))continue;let F=(L/R-w.y0)*f;w.y0+=F,w.y1+=F,E(w)}o===void 0&&m.sort(q),O(m,u)}}function O(e,f){const u=e.length>>1,c=e[u];d(e,c.y0-p,u-1,f),z(e,c.y1+p,u+1,f),d(e,a,e.length-1,f),z(e,n,0,f)}function z(e,f,u,c){for(;u<e.length;++u){const r=e[u],m=(f-r.y0)*c;m>1e-6&&(r.y0+=m,r.y1+=m),f=r.y1+p}}function d(e,f,u,c){for(;u>=0;--u){const r=e[u],m=(r.y1-f)*c;m>1e-6&&(r.y0-=m,r.y1-=m),f=r.y0-p}}function E({sourceLinks:e,targetLinks:f}){if(l===void 0){for(const{source:{sourceLinks:u}}of f)u.sort(ct);for(const{target:{targetLinks:u}}of e)u.sort(lt)}}function A(e){if(l===void 0)for(const{sourceLinks:f,targetLinks:u}of e)f.sort(ct),u.sort(lt)}function $(e,f){let u=e.y0-(e.sourceLinks.length-1)*p/2;for(const{target:c,width:r}of e.sourceLinks){if(c===f)break;u+=r+p}for(const{source:c,width:r}of f.targetLinks){if(c===e)break;u-=r}return u}function I(e,f){let u=f.y0-(f.targetLinks.length-1)*p/2;for(const{source:c,width:r}of f.targetLinks){if(c===e)break;u+=r+p}for(const{target:c,width:r}of e.sourceLinks){if(c===f)break;u-=r}return u}return v}var et=Math.PI,nt=2*et,V=1e-6,jt=nt-V;function it(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function pt(){return new it}it.prototype=pt.prototype={constructor:it,moveTo:function(t,n){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+n)},closePath:function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(t,n){this._+="L"+(this._x1=+t)+","+(this._y1=+n)},quadraticCurveTo:function(t,n,i,a){this._+="Q"+ +t+","+ +n+","+(this._x1=+i)+","+(this._y1=+a)},bezierCurveTo:function(t,n,i,a,h,b){this._+="C"+ +t+","+ +n+","+ +i+","+ +a+","+(this._x1=+h)+","+(this._y1=+b)},arcTo:function(t,n,i,a,h){t=+t,n=+n,i=+i,a=+a,h=+h;var b=this._x1,p=this._y1,k=i-t,s=a-n,o=b-t,l=p-n,_=o*o+l*l;if(h<0)throw new Error("negative radius: "+h);if(this._x1===null)this._+="M"+(this._x1=t)+","+(this._y1=n);else if(_>V)if(!(Math.abs(l*k-s*o)>V)||!h)this._+="L"+(this._x1=t)+","+(this._y1=n);else{var x=i-b,y=a-p,v=k*k+s*s,M=x*x+y*y,T=Math.sqrt(v),N=Math.sqrt(_),C=h*Math.tan((et-Math.acos((v+_-M)/(2*T*N)))/2),D=C/N,B=C/T;Math.abs(D-1)>V&&(this._+="L"+(t+D*o)+","+(n+D*l)),this._+="A"+h+","+h+",0,0,"+ +(l*x>o*y)+","+(this._x1=t+B*k)+","+(this._y1=n+B*s)}},arc:function(t,n,i,a,h,b){t=+t,n=+n,i=+i,b=!!b;var p=i*Math.cos(a),k=i*Math.sin(a),s=t+p,o=n+k,l=1^b,_=b?a-h:h-a;if(i<0)throw new Error("negative radius: "+i);this._x1===null?this._+="M"+s+","+o:(Math.abs(this._x1-s)>V||Math.abs(this._y1-o)>V)&&(this._+="L"+s+","+o),i&&(_<0&&(_=_%nt+nt),_>jt?this._+="A"+i+","+i+",0,1,"+l+","+(t-p)+","+(n-k)+"A"+i+","+i+",0,1,"+l+","+(this._x1=s)+","+(this._y1=o):_>V&&(this._+="A"+i+","+i+",0,"+ +(_>=et)+","+l+","+(this._x1=t+i*Math.cos(h))+","+(this._y1=n+i*Math.sin(h))))},rect:function(t,n,i,a){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+n)+"h"+ +i+"v"+ +a+"h"+-i+"Z"},toString:function(){return this._}};function ft(t){return function(){return t}}function Bt(t){return t[0]}function Rt(t){return t[1]}var Vt=Array.prototype.slice;function Ft(t){return t.source}function Ut(t){return t.target}function Wt(t){var n=Ft,i=Ut,a=Bt,h=Rt,b=null;function p(){var k,s=Vt.call(arguments),o=n.apply(this,s),l=i.apply(this,s);if(b||(b=k=pt()),t(b,+a.apply(this,(s[0]=o,s)),+h.apply(this,s),+a.apply(this,(s[0]=l,s)),+h.apply(this,s)),k)return b=null,k+""||null}return p.source=function(k){return arguments.length?(n=k,p):n},p.target=function(k){return arguments.length?(i=k,p):i},p.x=function(k){return arguments.length?(a=typeof k=="function"?k:ft(+k),p):a},p.y=function(k){return arguments.length?(h=typeof k=="function"?k:ft(+k),p):h},p.context=function(k){return arguments.length?(b=k??null,p):b},p}function Gt(t,n,i,a,h){t.moveTo(n,i),t.bezierCurveTo(n=(n+a)/2,i,n,h,a,h)}function Yt(){return Wt(Gt)}function qt(t){return[t.source.x1,t.y0]}function Ht(t){return[t.target.x0,t.y1]}function Xt(){return Yt().source(qt).target(Ht)}var st=function(){var t=g(function(k,s,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=s);return o},"o"),n=[1,9],i=[1,10],a=[1,5,10,12],h={trace:g(function(){},"trace"),yy:{},symbols_:{error:2,start:3,SANKEY:4,NEWLINE:5,csv:6,opt_eof:7,record:8,csv_tail:9,EOF:10,"field[source]":11,COMMA:12,"field[target]":13,"field[value]":14,field:15,escaped:16,non_escaped:17,DQUOTE:18,ESCAPED_TEXT:19,NON_ESCAPED_TEXT:20,$accept:0,$end:1},terminals_:{2:"error",4:"SANKEY",5:"NEWLINE",10:"EOF",11:"field[source]",12:"COMMA",13:"field[target]",14:"field[value]",18:"DQUOTE",19:"ESCAPED_TEXT",20:"NON_ESCAPED_TEXT"},productions_:[0,[3,4],[6,2],[9,2],[9,0],[7,1],[7,0],[8,5],[15,1],[15,1],[16,3],[17,1]],performAction:g(function(s,o,l,_,x,y,v){var M=y.length-1;switch(x){case 7:const T=_.findOrCreateNode(y[M-4].trim().replaceAll('""','"')),N=_.findOrCreateNode(y[M-2].trim().replaceAll('""','"')),C=parseFloat(y[M].trim());_.addLink(T,N,C);break;case 8:case 9:case 11:this.$=y[M];break;case 10:this.$=y[M-1];break}},"anonymous"),table:[{3:1,4:[1,2]},{1:[3]},{5:[1,3]},{6:4,8:5,15:6,16:7,17:8,18:n,20:i},{1:[2,6],7:11,10:[1,12]},t(i,[2,4],{9:13,5:[1,14]}),{12:[1,15]},t(a,[2,8]),t(a,[2,9]),{19:[1,16]},t(a,[2,11]),{1:[2,1]},{1:[2,5]},t(i,[2,2]),{6:17,8:5,15:6,16:7,17:8,18:n,20:i},{15:18,16:7,17:8,18:n,20:i},{18:[1,19]},t(i,[2,3]),{12:[1,20]},t(a,[2,10]),{15:21,16:7,17:8,18:n,20:i},t([1,5,10],[2,7])],defaultActions:{11:[2,1],12:[2,5]},parseError:g(function(s,o){if(o.recoverable)this.trace(s);else{var l=new Error(s);throw l.hash=o,l}},"parseError"),parse:g(function(s){var o=this,l=[0],_=[],x=[null],y=[],v=this.table,M="",T=0,N=0,C=2,D=1,B=y.slice.call(arguments,1),S=Object.create(this.lexer),P={yy:{}};for(var j in this.yy)Object.prototype.hasOwnProperty.call(this.yy,j)&&(P.yy[j]=this.yy[j]);S.setInput(s,P.yy),P.yy.lexer=S,P.yy.parser=this,typeof S.yylloc>"u"&&(S.yylloc={});var O=S.yylloc;y.push(O);var z=S.options&&S.options.ranges;typeof P.yy.parseError=="function"?this.parseError=P.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function d(L){l.length=l.length-2*L,x.length=x.length-L,y.length=y.length-L}g(d,"popStack");function E(){var L;return L=_.pop()||S.lex()||D,typeof L!="number"&&(L instanceof Array&&(_=L,L=_.pop()),L=o.symbols_[L]||L),L}g(E,"lex");for(var A,$,I,e,f={},u,c,r,m;;){if($=l[l.length-1],this.defaultActions[$]?I=this.defaultActions[$]:((A===null||typeof A>"u")&&(A=E()),I=v[$]&&v[$][A]),typeof I>"u"||!I.length||!I[0]){var w="";m=[];for(u in v[$])this.terminals_[u]&&u>C&&m.push("'"+this.terminals_[u]+"'");S.showPosition?w="Parse error on line "+(T+1)+`:
2
- `+S.showPosition()+`
3
- Expecting `+m.join(", ")+", got '"+(this.terminals_[A]||A)+"'":w="Parse error on line "+(T+1)+": Unexpected "+(A==D?"end of input":"'"+(this.terminals_[A]||A)+"'"),this.parseError(w,{text:S.match,token:this.terminals_[A]||A,line:S.yylineno,loc:O,expected:m})}if(I[0]instanceof Array&&I.length>1)throw new Error("Parse Error: multiple actions possible at state: "+$+", token: "+A);switch(I[0]){case 1:l.push(A),x.push(S.yytext),y.push(S.yylloc),l.push(I[1]),A=null,N=S.yyleng,M=S.yytext,T=S.yylineno,O=S.yylloc;break;case 2:if(c=this.productions_[I[1]][1],f.$=x[x.length-c],f._$={first_line:y[y.length-(c||1)].first_line,last_line:y[y.length-1].last_line,first_column:y[y.length-(c||1)].first_column,last_column:y[y.length-1].last_column},z&&(f._$.range=[y[y.length-(c||1)].range[0],y[y.length-1].range[1]]),e=this.performAction.apply(f,[M,N,T,P.yy,I[1],x,y].concat(B)),typeof e<"u")return e;c&&(l=l.slice(0,-1*c*2),x=x.slice(0,-1*c),y=y.slice(0,-1*c)),l.push(this.productions_[I[1]][0]),x.push(f.$),y.push(f._$),r=v[l[l.length-2]][l[l.length-1]],l.push(r);break;case 3:return!0}}return!0},"parse")},b=function(){var k={EOF:1,parseError:g(function(o,l){if(this.yy.parser)this.yy.parser.parseError(o,l);else throw new Error(o)},"parseError"),setInput:g(function(s,o){return this.yy=o||this.yy||{},this._input=s,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:g(function(){var s=this._input[0];this.yytext+=s,this.yyleng++,this.offset++,this.match+=s,this.matched+=s;var o=s.match(/(?:\r\n?|\n).*/g);return o?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),s},"input"),unput:g(function(s){var o=s.length,l=s.split(/(?:\r\n?|\n)/g);this._input=s+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-o),this.offset-=o;var _=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),l.length-1&&(this.yylineno-=l.length-1);var x=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:l?(l.length===_.length?this.yylloc.first_column:0)+_[_.length-l.length].length-l[0].length:this.yylloc.first_column-o},this.options.ranges&&(this.yylloc.range=[x[0],x[0]+this.yyleng-o]),this.yyleng=this.yytext.length,this},"unput"),more:g(function(){return this._more=!0,this},"more"),reject:g(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
- `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:g(function(s){this.unput(this.match.slice(s))},"less"),pastInput:g(function(){var s=this.matched.substr(0,this.matched.length-this.match.length);return(s.length>20?"...":"")+s.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:g(function(){var s=this.match;return s.length<20&&(s+=this._input.substr(0,20-s.length)),(s.substr(0,20)+(s.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:g(function(){var s=this.pastInput(),o=new Array(s.length+1).join("-");return s+this.upcomingInput()+`
5
- `+o+"^"},"showPosition"),test_match:g(function(s,o){var l,_,x;if(this.options.backtrack_lexer&&(x={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(x.yylloc.range=this.yylloc.range.slice(0))),_=s[0].match(/(?:\r\n?|\n).*/g),_&&(this.yylineno+=_.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:_?_[_.length-1].length-_[_.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+s[0].length},this.yytext+=s[0],this.match+=s[0],this.matches=s,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(s[0].length),this.matched+=s[0],l=this.performAction.call(this,this.yy,this,o,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),l)return l;if(this._backtrack){for(var y in x)this[y]=x[y];return!1}return!1},"test_match"),next:g(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var s,o,l,_;this._more||(this.yytext="",this.match="");for(var x=this._currentRules(),y=0;y<x.length;y++)if(l=this._input.match(this.rules[x[y]]),l&&(!o||l[0].length>o[0].length)){if(o=l,_=y,this.options.backtrack_lexer){if(s=this.test_match(l,x[y]),s!==!1)return s;if(this._backtrack){o=!1;continue}else return!1}else if(!this.options.flex)break}return o?(s=this.test_match(o,x[_]),s!==!1?s:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
6
- `+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:g(function(){var o=this.next();return o||this.lex()},"lex"),begin:g(function(o){this.conditionStack.push(o)},"begin"),popState:g(function(){var o=this.conditionStack.length-1;return o>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:g(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:g(function(o){return o=this.conditionStack.length-1-Math.abs(o||0),o>=0?this.conditionStack[o]:"INITIAL"},"topState"),pushState:g(function(o){this.begin(o)},"pushState"),stateStackSize:g(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:g(function(o,l,_,x){switch(_){case 0:return this.pushState("csv"),4;case 1:return 10;case 2:return 5;case 3:return 12;case 4:return this.pushState("escaped_text"),18;case 5:return 20;case 6:return this.popState("escaped_text"),18;case 7:return 19}},"anonymous"),rules:[/^(?:sankey-beta\b)/i,/^(?:$)/i,/^(?:((\u000D\u000A)|(\u000A)))/i,/^(?:(\u002C))/i,/^(?:(\u0022))/i,/^(?:([\u0020-\u0021\u0023-\u002B\u002D-\u007E])*)/i,/^(?:(\u0022)(?!(\u0022)))/i,/^(?:(([\u0020-\u0021\u0023-\u002B\u002D-\u007E])|(\u002C)|(\u000D)|(\u000A)|(\u0022)(\u0022))*)/i],conditions:{csv:{rules:[1,2,3,4,5,6,7],inclusive:!1},escaped_text:{rules:[6,7],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7],inclusive:!0}}};return k}();h.lexer=b;function p(){this.yy={}}return g(p,"Parser"),p.prototype=h,h.Parser=p,new p}();st.parser=st;var H=st,Q=[],K=[],X=new Map,Qt=g(()=>{Q=[],K=[],X=new Map,Lt()},"clear"),Kt=class{constructor(t,n,i=0){this.source=t,this.target=n,this.value=i}static{g(this,"SankeyLink")}},Zt=g((t,n,i)=>{Q.push(new Kt(t,n,i))},"addLink"),Jt=class{constructor(t){this.ID=t}static{g(this,"SankeyNode")}},te=g(t=>{t=Et.sanitizeText(t,ot());let n=X.get(t);return n===void 0&&(n=new Jt(t),X.set(t,n),K.push(n)),n},"findOrCreateNode"),ee=g(()=>K,"getNodes"),ne=g(()=>Q,"getLinks"),ie=g(()=>({nodes:K.map(t=>({id:t.ID})),links:Q.map(t=>({source:t.source.ID,target:t.target.ID,value:t.value}))}),"getGraph"),se={nodesMap:X,getConfig:g(()=>ot().sankey,"getConfig"),getNodes:ee,getLinks:ne,getGraph:ie,addLink:Zt,findOrCreateNode:te,getAccTitle:bt,setAccTitle:vt,getAccDescription:xt,setAccDescription:_t,getDiagramTitle:kt,setDiagramTitle:mt,clear:Qt},yt=class rt{static{g(this,"Uid")}static{this.count=0}static next(n){return new rt(n+ ++rt.count)}constructor(n){this.id=n,this.href=`#${n}`}toString(){return"url("+this.href+")"}},re={left:It,right:Pt,center:Ct,justify:gt},oe=g(function(t,n,i,a){const{securityLevel:h,sankey:b}=ot(),p=wt.sankey;let k;h==="sandbox"&&(k=G("#i"+n));const s=h==="sandbox"?G(k.nodes()[0].contentDocument.body):G("body"),o=h==="sandbox"?s.select(`[id="${n}"]`):G(`[id="${n}"]`),l=b?.width??p.width,_=b?.height??p.width,x=b?.useMaxWidth??p.useMaxWidth,y=b?.nodeAlignment??p.nodeAlignment,v=b?.prefix??p.prefix,M=b?.suffix??p.suffix,T=b?.showValues??p.showValues,N=a.db.getGraph(),C=re[y];$t().nodeId(d=>d.id).nodeWidth(10).nodePadding(10+(T?15:0)).nodeAlign(C).extent([[0,0],[l,_]])(N);const S=At(Mt);o.append("g").attr("class","nodes").selectAll(".node").data(N.nodes).join("g").attr("class","node").attr("id",d=>(d.uid=yt.next("node-")).id).attr("transform",function(d){return"translate("+d.x0+","+d.y0+")"}).attr("x",d=>d.x0).attr("y",d=>d.y0).append("rect").attr("height",d=>d.y1-d.y0).attr("width",d=>d.x1-d.x0).attr("fill",d=>S(d.id));const P=g(({id:d,value:E})=>T?`${d}
7
- ${v}${Math.round(E*100)/100}${M}`:d,"getText");o.append("g").attr("class","node-labels").attr("font-size",14).selectAll("text").data(N.nodes).join("text").attr("x",d=>d.x0<l/2?d.x1+6:d.x0-6).attr("y",d=>(d.y1+d.y0)/2).attr("dy",`${T?"0":"0.35"}em`).attr("text-anchor",d=>d.x0<l/2?"start":"end").text(P);const j=o.append("g").attr("class","links").attr("fill","none").attr("stroke-opacity",.5).selectAll(".link").data(N.links).join("g").attr("class","link").style("mix-blend-mode","multiply"),O=b?.linkColor??"gradient";if(O==="gradient"){const d=j.append("linearGradient").attr("id",E=>(E.uid=yt.next("linearGradient-")).id).attr("gradientUnits","userSpaceOnUse").attr("x1",E=>E.source.x1).attr("x2",E=>E.target.x0);d.append("stop").attr("offset","0%").attr("stop-color",E=>S(E.source.id)),d.append("stop").attr("offset","100%").attr("stop-color",E=>S(E.target.id))}let z;switch(O){case"gradient":z=g(d=>d.uid,"coloring");break;case"source":z=g(d=>S(d.source.id),"coloring");break;case"target":z=g(d=>S(d.target.id),"coloring");break;default:z=O}j.append("path").attr("d",Xt()).attr("stroke",z).attr("stroke-width",d=>Math.max(1,d.width)),St(void 0,o,0,x)},"draw"),ae={draw:oe},le=g(t=>t.replaceAll(/^[^\S\n\r]+|[^\S\n\r]+$/g,"").replaceAll(/([\n\r])+/g,`
8
- `).trim(),"prepareTextForParsing"),ce=g(t=>`.label {
9
- font-family: ${t.fontFamily};
10
- }`,"getStyles"),ue=ce,he=H.parse.bind(H);H.parse=t=>he(le(t));var me={styles:ue,parser:H,db:se,renderer:ae};export{me as diagram};
@@ -1 +0,0 @@
1
- import{s as W,a as P,S as N}from"./chunk-AEK57VVT-C-Lkcz0b.js";import{_ as u,c as t,d as H,l as S,e as C,k as z,u as U}from"./mermaid.core-BimBLnQI.js";import{G as F}from"./graph-dWQI_6He.js";import{l as O}from"./layout-DASlxn3X.js";import{G as J,H as X}from"./index-BYm582eS.js";import"./chunk-RZ5BOZE2-BeXwBs0F.js";import"./index-BkWL0Tso.js";import"./_baseUniq-BNZdLtEU.js";import"./_basePickBy-ByW4PGoZ.js";import"./console-mirror-gvEt6nID.js";import"./error-boundary-bl9plxwd.js";var L={},D=u((e,i)=>{L[e]=i},"set"),Y=u(e=>L[e],"get"),A=u(()=>Object.keys(L),"keys"),I=u(()=>A().length,"size"),$={get:Y,set:D,keys:A,size:I},j=u(e=>e.append("circle").attr("class","start-state").attr("r",t().state.sizeUnit).attr("cx",t().state.padding+t().state.sizeUnit).attr("cy",t().state.padding+t().state.sizeUnit),"drawStartState"),q=u(e=>e.append("line").style("stroke","grey").style("stroke-dasharray","3").attr("x1",t().state.textHeight).attr("class","divider").attr("x2",t().state.textHeight*2).attr("y1",0).attr("y2",0),"drawDivider"),Z=u((e,i)=>{const d=e.append("text").attr("x",2*t().state.padding).attr("y",t().state.textHeight+2*t().state.padding).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.id),o=d.node().getBBox();return e.insert("rect",":first-child").attr("x",t().state.padding).attr("y",t().state.padding).attr("width",o.width+2*t().state.padding).attr("height",o.height+2*t().state.padding).attr("rx",t().state.radius),d},"drawSimpleState"),K=u((e,i)=>{const d=u(function(l,B,m){const k=l.append("tspan").attr("x",2*t().state.padding).text(B);m||k.attr("dy",t().state.textHeight)},"addTspan"),n=e.append("text").attr("x",2*t().state.padding).attr("y",t().state.textHeight+1.3*t().state.padding).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.descriptions[0]).node().getBBox(),g=n.height,x=e.append("text").attr("x",t().state.padding).attr("y",g+t().state.padding*.4+t().state.dividerMargin+t().state.textHeight).attr("class","state-description");let a=!0,s=!0;i.descriptions.forEach(function(l){a||(d(x,l,s),s=!1),a=!1});const y=e.append("line").attr("x1",t().state.padding).attr("y1",t().state.padding+g+t().state.dividerMargin/2).attr("y2",t().state.padding+g+t().state.dividerMargin/2).attr("class","descr-divider"),p=x.node().getBBox(),c=Math.max(p.width,n.width);return y.attr("x2",c+3*t().state.padding),e.insert("rect",":first-child").attr("x",t().state.padding).attr("y",t().state.padding).attr("width",c+2*t().state.padding).attr("height",p.height+g+2*t().state.padding).attr("rx",t().state.radius),e},"drawDescrState"),Q=u((e,i,d)=>{const o=t().state.padding,n=2*t().state.padding,g=e.node().getBBox(),x=g.width,a=g.x,s=e.append("text").attr("x",0).attr("y",t().state.titleShift).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.id),p=s.node().getBBox().width+n;let c=Math.max(p,x);c===x&&(c=c+n);let l;const B=e.node().getBBox();i.doc,l=a-o,p>x&&(l=(x-c)/2+o),Math.abs(a-B.x)<o&&p>x&&(l=a-(p-x)/2);const m=1-t().state.textHeight;return e.insert("rect",":first-child").attr("x",l).attr("y",m).attr("class",d?"alt-composit":"composit").attr("width",c).attr("height",B.height+t().state.textHeight+t().state.titleShift+1).attr("rx","0"),s.attr("x",l+o),p<=x&&s.attr("x",a+(c-n)/2-p/2+o),e.insert("rect",":first-child").attr("x",l).attr("y",t().state.titleShift-t().state.textHeight-t().state.padding).attr("width",c).attr("height",t().state.textHeight*3).attr("rx",t().state.radius),e.insert("rect",":first-child").attr("x",l).attr("y",t().state.titleShift-t().state.textHeight-t().state.padding).attr("width",c).attr("height",B.height+3+2*t().state.textHeight).attr("rx",t().state.radius),e},"addTitleAndBox"),V=u(e=>(e.append("circle").attr("class","end-state-outer").attr("r",t().state.sizeUnit+t().state.miniPadding).attr("cx",t().state.padding+t().state.sizeUnit+t().state.miniPadding).attr("cy",t().state.padding+t().state.sizeUnit+t().state.miniPadding),e.append("circle").attr("class","end-state-inner").attr("r",t().state.sizeUnit).attr("cx",t().state.padding+t().state.sizeUnit+2).attr("cy",t().state.padding+t().state.sizeUnit+2)),"drawEndState"),tt=u((e,i)=>{let d=t().state.forkWidth,o=t().state.forkHeight;if(i.parentId){let n=d;d=o,o=n}return e.append("rect").style("stroke","black").style("fill","black").attr("width",d).attr("height",o).attr("x",t().state.padding).attr("y",t().state.padding)},"drawForkJoinState"),et=u((e,i,d,o)=>{let n=0;const g=o.append("text");g.style("text-anchor","start"),g.attr("class","noteText");let x=e.replace(/\r\n/g,"<br/>");x=x.replace(/\n/g,"<br/>");const a=x.split(z.lineBreakRegex);let s=1.25*t().state.noteMargin;for(const y of a){const p=y.trim();if(p.length>0){const c=g.append("tspan");if(c.text(p),s===0){const l=c.node().getBBox();s+=l.height}n+=s,c.attr("x",i+t().state.noteMargin),c.attr("y",d+n+1.25*t().state.noteMargin)}}return{textWidth:g.node().getBBox().width,textHeight:n}},"_drawLongText"),at=u((e,i)=>{i.attr("class","state-note");const d=i.append("rect").attr("x",0).attr("y",t().state.padding),o=i.append("g"),{textWidth:n,textHeight:g}=et(e,0,0,o);return d.attr("height",g+2*t().state.noteMargin),d.attr("width",n+t().state.noteMargin*2),d},"drawNote"),G=u(function(e,i){const d=i.id,o={id:d,label:i.id,width:0,height:0},n=e.append("g").attr("id",d).attr("class","stateGroup");i.type==="start"&&j(n),i.type==="end"&&V(n),(i.type==="fork"||i.type==="join")&&tt(n,i),i.type==="note"&&at(i.note.text,n),i.type==="divider"&&q(n),i.type==="default"&&i.descriptions.length===0&&Z(n,i),i.type==="default"&&i.descriptions.length>0&&K(n,i);const g=n.node().getBBox();return o.width=g.width+2*t().state.padding,o.height=g.height+2*t().state.padding,$.set(d,o),o},"drawState"),_=0,it=u(function(e,i,d){const o=u(function(s){switch(s){case N.relationType.AGGREGATION:return"aggregation";case N.relationType.EXTENSION:return"extension";case N.relationType.COMPOSITION:return"composition";case N.relationType.DEPENDENCY:return"dependency"}},"getRelationType");i.points=i.points.filter(s=>!Number.isNaN(s.y));const n=i.points,g=J().x(function(s){return s.x}).y(function(s){return s.y}).curve(X),x=e.append("path").attr("d",g(n)).attr("id","edge"+_).attr("class","transition");let a="";if(t().state.arrowMarkerAbsolute&&(a=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,a=a.replace(/\(/g,"\\("),a=a.replace(/\)/g,"\\)")),x.attr("marker-end","url("+a+"#"+o(N.relationType.DEPENDENCY)+"End)"),d.title!==void 0){const s=e.append("g").attr("class","stateLabel"),{x:y,y:p}=U.calcLabelPosition(i.points),c=z.getRows(d.title);let l=0;const B=[];let m=0,k=0;for(let f=0;f<=c.length;f++){const h=s.append("text").attr("text-anchor","middle").text(c[f]).attr("x",y).attr("y",p+l),w=h.node().getBBox();m=Math.max(m,w.width),k=Math.min(k,w.x),S.info(w.x,y,p+l),l===0&&(l=h.node().getBBox().height,S.info("Title height",l,p)),B.push(h)}let E=l*c.length;if(c.length>1){const f=(c.length-1)*l*.5;B.forEach((h,w)=>h.attr("y",p+w*l-f)),E=l*c.length}const r=s.node().getBBox();s.insert("rect",":first-child").attr("class","box").attr("x",y-m/2-t().state.padding/2).attr("y",p-E/2-t().state.padding/2-3.5).attr("width",m+t().state.padding).attr("height",E+t().state.padding),S.info(r)}_++},"drawEdge"),b,T={},rt=u(function(){},"setConf"),nt=u(function(e){e.append("defs").append("marker").attr("id","dependencyEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 19,7 L9,13 L14,7 L9,1 Z")},"insertMarkers"),st=u(function(e,i,d,o){b=t().state;const n=t().securityLevel;let g;n==="sandbox"&&(g=H("#i"+i));const x=n==="sandbox"?H(g.nodes()[0].contentDocument.body):H("body"),a=n==="sandbox"?g.nodes()[0].contentDocument:document;S.debug("Rendering diagram "+e);const s=x.select(`[id='${i}']`);nt(s);const y=o.db.getRootDoc();R(y,s,void 0,!1,x,a,o);const p=b.padding,c=s.node().getBBox(),l=c.width+p*2,B=c.height+p*2,m=l*1.75;C(s,B,m,b.useMaxWidth),s.attr("viewBox",`${c.x-b.padding} ${c.y-b.padding} `+l+" "+B)},"draw"),dt=u(e=>e?e.length*b.fontSizeFactor:1,"getLabelWidth"),R=u((e,i,d,o,n,g,x)=>{const a=new F({compound:!0,multigraph:!0});let s,y=!0;for(s=0;s<e.length;s++)if(e[s].stmt==="relation"){y=!1;break}d?a.setGraph({rankdir:"LR",multigraph:!0,compound:!0,ranker:"tight-tree",ranksep:y?1:b.edgeLengthFactor,nodeSep:y?1:50,isMultiGraph:!0}):a.setGraph({rankdir:"TB",multigraph:!0,compound:!0,ranksep:y?1:b.edgeLengthFactor,nodeSep:y?1:50,ranker:"tight-tree",isMultiGraph:!0}),a.setDefaultEdgeLabel(function(){return{}});const p=x.db.getStates(),c=x.db.getRelations(),l=Object.keys(p);for(const r of l){const f=p[r];d&&(f.parentId=d);let h;if(f.doc){let w=i.append("g").attr("id",f.id).attr("class","stateGroup");h=R(f.doc,w,f.id,!o,n,g,x);{w=Q(w,f,o);let v=w.node().getBBox();h.width=v.width,h.height=v.height+b.padding/2,T[f.id]={y:b.compositTitleSize}}}else h=G(i,f,a);if(f.note){const w={descriptions:[],id:f.id+"-note",note:f.note,type:"note"},v=G(i,w,a);f.note.position==="left of"?(a.setNode(h.id+"-note",v),a.setNode(h.id,h)):(a.setNode(h.id,h),a.setNode(h.id+"-note",v)),a.setParent(h.id,h.id+"-group"),a.setParent(h.id+"-note",h.id+"-group")}else a.setNode(h.id,h)}S.debug("Count=",a.nodeCount(),a);let B=0;c.forEach(function(r){B++,S.debug("Setting edge",r),a.setEdge(r.id1,r.id2,{relation:r,width:dt(r.title),height:b.labelHeight*z.getRows(r.title).length,labelpos:"c"},"id"+B)}),O(a),S.debug("Graph after layout",a.nodes());const m=i.node();a.nodes().forEach(function(r){r!==void 0&&a.node(r)!==void 0?(S.warn("Node "+r+": "+JSON.stringify(a.node(r))),n.select("#"+m.id+" #"+r).attr("transform","translate("+(a.node(r).x-a.node(r).width/2)+","+(a.node(r).y+(T[r]?T[r].y:0)-a.node(r).height/2)+" )"),n.select("#"+m.id+" #"+r).attr("data-x-shift",a.node(r).x-a.node(r).width/2),g.querySelectorAll("#"+m.id+" #"+r+" .divider").forEach(h=>{const w=h.parentElement;let v=0,M=0;w&&(w.parentElement&&(v=w.parentElement.getBBox().width),M=parseInt(w.getAttribute("data-x-shift"),10),Number.isNaN(M)&&(M=0)),h.setAttribute("x1",0-M+8),h.setAttribute("x2",v-M-8)})):S.debug("No Node "+r+": "+JSON.stringify(a.node(r)))});let k=m.getBBox();a.edges().forEach(function(r){r!==void 0&&a.edge(r)!==void 0&&(S.debug("Edge "+r.v+" -> "+r.w+": "+JSON.stringify(a.edge(r))),it(i,a.edge(r),a.edge(r).relation))}),k=m.getBBox();const E={id:d||"root",label:d||"root",width:0,height:0};return E.width=k.width+2*b.padding,E.height=k.height+2*b.padding,S.debug("Doc rendered",E,a),E},"renderDoc"),ot={setConf:rt,draw:st},Bt={parser:P,get db(){return new N(1)},renderer:ot,styles:W,init:u(e=>{e.state||(e.state={}),e.state.arrowMarkerAbsolute=e.arrowMarkerAbsolute},"init")};export{Bt as diagram};
@@ -1 +0,0 @@
1
- import{s as r,b as e,a,S as s}from"./chunk-AEK57VVT-C-Lkcz0b.js";import{_ as i}from"./mermaid.core-BimBLnQI.js";import"./chunk-RZ5BOZE2-BeXwBs0F.js";import"./index-BYm582eS.js";import"./index-BkWL0Tso.js";import"./console-mirror-gvEt6nID.js";import"./error-boundary-bl9plxwd.js";var n={parser:a,get db(){return new s(2)},renderer:e,styles:r,init:i(t=>{t.state||(t.state={}),t.state.arrowMarkerAbsolute=t.arrowMarkerAbsolute},"init")};export{n as diagram};
@@ -1 +0,0 @@
1
- import{ae as v,af as A,ag as $,ah as I,ai as h,aj as R,ak as q,al as r,h as _,am as w,an as L,ao as k,ap as N,aq as P,ar as S}from"./index-BYm582eS.js";const f={malware_or_exploitation:"Instructions to build or spread malware, or to attack systems you do not own, cannot be published.",credential_theft:"Instructions to obtain someone else's credentials or tokens cannot be published.",fraud_or_deception:"Instructions to deceive or defraud people cannot be published.",harassment_or_hate:"Instructions to harass, threaten or target people cannot be published.",sexual_content_minors:"This agent cannot be published. If you believe this is a mistake, contact support.",sexual_content:"Explicit sexual content cannot be published.",violence_or_weapons:"Instructions to build weapons or to injure people cannot be published.",drugs_or_controlled_substances:"Instructions to make or traffic illegal drugs cannot be published.",self_harm:"This agent cannot be published. If you believe this is a mistake, contact support.",mass_surveillance_or_privacy_abuse:"Instructions to surveil or profile people without their consent cannot be published.",evasion_or_abuse_tooling:"Instructions to evade or defeat safety and anti-abuse systems cannot be published.",prompt_injection:"This instruction set tries to instruct the reviewer rather than describe an agent, so it cannot be published.",unclear_dual_use:"We could not tell whether this is aimed at your own systems or someone else's. Add a sentence stating the scope and target, then publish again.",other_harmful:"This agent was rejected because its instructions would cause harm."},E=e=>{const n=e.trim();return n.length>12&&/\s/.test(n)&&!/^(not found|bad request|unauthorized|error|internal server error)\.?$/i.test(n)};function O(e){const n=e?.categories?.[0];return n&&q(n)?f[n]:f.other_harmful}function C(e,n){const t=n?.rule?` ${n.rule}`:"";switch(n?.field){case"name":return{body:`Name${t||" is not acceptable"}.`,field:"name"};case"instructions":return{body:t?`The instruction body${t}.`:`The instruction body must be between 1 and ${R} characters.`,field:"instructions"};case"description":return{body:`Description${t}.`,field:"description"};case"tools":return{body:`Tools${t}.`,field:"tools"};case"when_to_use":return{body:`When to use${t}.`,field:"when_to_use"};case"categories":return{body:`Categories${t}.`,field:"categories"};case"tags":return{body:`Tags${t}.`,field:"tags"};default:return{body:e,field:null}}}function Z(e,n){const t=n.surface==="pull",a=t?"Nothing was pulled.":"Nothing was published.",o=t?"pull again":"publish again",i=n.name.trim()||(t?"this team":"this agent");switch(e.code){case"name_taken":return e.details?.owned_by_caller===!0?{variant:"danger",headline:"You already published this agent",body:`You published "${i}" already. Update that listing instead of publishing a second one.`,note:null,actions:e.details?.existing_agent_id||n.hubAgentId?["update-listing","focus-name"]:["focus-name"]}:{variant:"danger",headline:"That name is taken",body:`"${i}" is already published on the hub by another account. Agent names are unique across the hub.`,note:null,actions:["focus-name"]};case"name_claim_in_flight":return{variant:"warning",headline:"That name is being published right now",body:`Someone is publishing an agent called "${i}" at this moment. It is not claimed — try again in a moment.`,note:null,actions:["retry"]};case"name_reserved_builtin":{const s=e.details?.builtin_name,d=s?h(s)===h(i):!1;return{variant:"danger",headline:"That name is reserved",body:s&&!d?`"${i}" is reserved by the built-in agent "${s}". Built-in names cannot be published to the hub.`:`"${s??i}" is the name of a built-in agent. Built-in names cannot be published to the hub.`,note:null,actions:["focus-name","install-builtin"]}}case"moderation_rejected":return{variant:"danger",headline:"This agent was not accepted",body:e.details?.reason?.trim()||e.message,note:O(e.details),actions:["edit-instructions"]};case"moderation_unavailable":return{variant:"warning",headline:"Review is temporarily unavailable",body:"We could not review this agent just now. Nothing was published. Try again in a minute.",note:null,actions:["retry"]};case"invalid_instruction_set":{const{body:s,field:d}=C(e.message,e.details);return{variant:"danger",headline:"The agent document is not valid",body:s,note:null,actions:d==="name"?["focus-name"]:d==="instructions"?["edit-instructions"]:["edit-agent"]}}case"payload_too_large":{const s=e.details?.limit_bytes;return{variant:"danger",headline:"This agent is too large to publish",body:s?`The instruction set is larger than ${Math.round(s/1024)} KiB. Shorten the instructions.`:"The instruction set is larger than the hub accepts. Shorten the instructions.",note:null,actions:["edit-instructions"]}}case"not_owner":return{variant:"danger",headline:"You cannot update this listing",body:"This listing belongs to another account.",note:null,actions:["publish-as-new"]};case"agent_not_found":return{variant:"danger",headline:"That listing no longer exists",body:"It may have been delisted.",note:null,actions:["publish-as-new","refresh-hub"]};case"hub_unauthorized":return{variant:"danger",headline:"The hub refused this machine's sign-in",body:`${a} Sign in to Radient again to replace the credential the hub refused, then ${o}.`,note:null,actions:["sign-in"]};case"hub_unavailable":return{variant:"warning",headline:t?"The pull did not go through":"The publication did not go through",body:E(e.message)?e.message:`${a} Try again in a moment, or update the backend if the hub has moved.`,note:null,actions:["retry"]};case"local_failure":return{variant:"warning",headline:t?"The team could not be pulled from this machine":"The agent could not be published from this machine",body:e.message,note:null,actions:["retry"]};case"team_plan_required":return{variant:"warning",headline:"That organization needs an active Team plan",body:t?"Reading an organization's teams is part of the Team plan. Ask an owner of the organization to activate it in the Radient console, then pull again.":"Sharing agents inside an organization is part of the Team plan. Ask an owner of the organization to activate it in the Radient console, then publish again.",note:null,actions:["retry"]};case"not_a_member":return{variant:"danger",headline:"You are not a member of that organization",body:`${a} Ask an owner of the organization to invite you, then ${o}.`,note:null,actions:[]};case"insufficient_role":{const s=e.details?.required;return{variant:"danger",headline:"Your organization role does not allow this",body:s?`${t?"Reading an organization's teams needs":"Publishing into an organization needs"} the ${s} role. Ask an owner of the organization to change your role, then ${o}.`:`${t?"Reading an organization's teams needs":"Publishing into an organization needs"} a higher role than yours. Ask an owner of the organization to change your role, then ${o}.`,note:null,actions:[]}}case"team_not_found":return{variant:"danger",headline:"That team is no longer published",body:"It may have been delisted since this page was loaded.",note:null,actions:["refresh-hub"]};default:return{variant:"danger",headline:"The agent could not be published",body:e.message,note:null,actions:["retry"]}}}const z=[/^(?:Download agent from Radient failed: )?(?:Error downloading agent from Radient: )?\s*/,/^Failed to download agent(?: [^\s]+)? from Radient Agent Hub(?: due to a requests error)?:\s*/,/^[A-Za-z_][\w.]*\([^)]*\):\s*/],U=/^(\d{3})\b/,j=new Set([404,410]),F=["read timed out","connection timed out","connection refused","connection aborted","connection reset","connectionerror","connecttimeout","remote end closed connection","max retries exceeded","temporary failure in name resolution","name or service not known","no route to host"],x=e=>{const n=e.toLowerCase();return F.some(t=>n.includes(t))||I(e)},B=(e,n)=>{const t=n.trim()?`"${n.trim()}"`:"That agent";if(A(e))switch(e.code){case"agent_not_found":return`${t} is no longer on the hub, so nothing was downloaded.`;case"hub_unavailable":return`The hub did not complete the download, so ${t} was not downloaded.`;default:return`${t} was not downloaded: ${e.message}`}const a=z.reduce((i,s)=>i.replace(s,""),$(e,"").trim()).trim();if(!a)return`${t} could not be downloaded.`;const o=Number(U.exec(a)?.[1]??Number.NaN);return j.has(o)?`${t} is no longer on the hub, so nothing was downloaded.`:x(a)||o===408?`The hub could not be reached, so ${t} was not downloaded.`:o===429?`The hub is busy, so ${t} was not downloaded. Try again in a moment.`:o===401||o===403?`The hub refused this machine's sign-in, so ${t} was not downloaded.`:o>=500?`The hub could not complete the download, so ${t} was not downloaded. Try again in a moment.`:o>=400?`The hub refused the download, so ${t} is not here.`:`${t} was not downloaded: ${a}`},D="The action did not complete.",J=(e,n,t)=>e==="download"?B(n,t):v(D,n),V={"focus-name":"Choose another name","update-listing":"Update the existing listing","install-builtin":"Install the built-in instead",retry:"Try again","edit-instructions":"Edit the instructions","edit-agent":"Edit the agent","publish-as-new":"Publish as a new listing","sign-in":"Sign in again","refresh-hub":"Refresh the hub"};function c(){return crypto.randomUUID()}async function K(e=1,n=20,t){const a={page:e,per_page:n};if(t)for(const[o,i]of Object.entries(t))i&&(a[o]=i);return r({operation:"agents.list",query:a})}async function ee(e){return r({operation:"agents.get",agentId:e})}async function ne(e){return r({operation:"agents.delete",agentId:e,requestId:c(),confirmed:!0})}async function te(e){return r({operation:"agents.like",agentId:e,requestId:c()})}async function ae(e){return r({operation:"agents.unlike",agentId:e,requestId:c(),confirmed:!0})}async function oe(e){return r({operation:"agents.favourite",agentId:e,requestId:c()})}async function se(e){return r({operation:"agents.unfavourite",agentId:e,requestId:c(),confirmed:!0})}async function ie(e,n){return r({operation:"comments.create",agentId:e,payload:n,requestId:c()})}async function re(e,n=1,t=20){return r({operation:"comments.list",agentId:e,query:{page:n,per_page:t}})}async function ue(e,n,t){return r({operation:"comments.update",agentId:e,commentId:n,payload:t,requestId:c()})}async function le(e,n){return r({operation:"comments.delete",agentId:e,commentId:n,requestId:c(),confirmed:!0})}async function ce(e){return r({operation:"agents.statuses",query:{agent_ids:e.join(",")}})}async function M(){return r({operation:"memberships.list"})}async function Q(e,n=1,t=20,a){const o={page:n,per_page:t};if(a)for(const[i,s]of Object.entries(a))s&&(o[i]=s);return r({operation:"org_agents.list",tenantId:e,query:o})}async function de(e){return r({operation:"org_teams.list",tenantId:e})}const W="download_count",b={all:["public-agents"],list:e=>[...b.all,"list",{page:e.page,perPage:e.perPage,categories:e.categories?.join(",")??void 0,name:e.name??void 0,description:e.description??void 0,sort:e.sort,order:e.order}]},m={all:["org-agents"],list:(e,n)=>[...m.all,"list",e,{page:n.page,perPage:n.perPage,categories:n.categories?.join(",")??void 0,name:n.name??void 0,description:n.description??void 0,sort:n.sort,order:n.order}]},Y=e=>e&&e[0]===m.all[0]?String(e[2]??""):null,he=e=>e.invalidateQueries({queryKey:b.all}),ge=(e,n)=>e.invalidateQueries({queryKey:n?[...m.all,"list",n]:m.all}),me=({page:e=1,perPage:n=20,enabled:t=!0,categories:a,name:o,description:i,sort:s=W,order:d="desc",tenantId:g}={})=>{const p={page:e,perPage:n,categories:a,name:o,description:i,sort:s,order:d},T=g?m.list(g,p):b.list(p),l=_({queryKey:T,queryFn:async()=>{const u={};return a&&a.length>0&&(u.categories=a.join(",")),o&&(u.name=o),i&&(u.description=i),u.sort=s,u.order=d,g?await Q(g,e,n,u):await K(e,n,u)},select:u=>u.result,enabled:t,retry:w,staleTime:5*60*1e3,gcTime:10*60*1e3,refetchOnWindowFocus:!1,placeholderData:(u,y)=>Y(y?.queryKey)===(g??null)?u:void 0});return{...l,agents:l.data?.records,isRefreshing:l.isFetching&&l.data!==void 0,pagination:l.data?{page:l.data.page,perPage:l.data.per_page,totalPages:l.data.total_pages,totalRecords:l.data.total_records}:void 0}},H={name:"Name",description:"Description",instructions:"The instruction body",tools:"Tools"};function be(e){const n=[],t=(a,o)=>{o&&n.push({field:a,message:`${H[a]} ${o}.`})};return t("name",L(e.name)),t("description",k(e.description)),e.instructions!==null&&t("instructions",N(e.instructions)),t("tools",P(e.tools??[])),n}function pe(e,n){const t=h(e);return n.some(a=>h(a)===t)}function ye(e){for(const n of e??[]){const t=n.indexOf(":");if(t<0||n.slice(0,t).trim().toLowerCase()!=="tools")continue;const a=n.slice(t+1).split(",").map(o=>o.trim()).filter(Boolean);return a.length>0?a:null}return null}function fe(e,n){const t=h(e);return n.find(a=>h(a)===t)??null}const G={all:["memberships"]},_e=({enabled:e=!0}={})=>{const{isAuthenticated:n}=S(),t=_({queryKey:G.all,queryFn:async()=>(await M()).result??{memberships:[]},enabled:e&&n,staleTime:5*60*1e3,gcTime:10*60*1e3,refetchOnWindowFocus:!1,retry:w});return{...t,memberships:t.data?.memberships??[]}};export{V as P,ne as a,_e as b,ie as c,le as d,J as e,de as f,ee as g,me as h,he as i,ce as j,b as k,re as l,se as m,oe as n,ae as o,Z as p,te as q,fe as r,ge as s,pe as t,ue as u,be as v,ye as w};