local-operator-ui 0.31.26 → 0.31.28

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 (114) hide show
  1. package/out/main/index.js +383 -42
  2. package/out/preload/index.js +37 -0
  3. package/out/renderer/assets/{_basePickBy-D0wlCvva.js → _basePickBy-D16oopNi.js} +1 -1
  4. package/out/renderer/assets/{_baseUniq-DPa_8DrG.js → _baseUniq-BYKYfwtj.js} +1 -1
  5. package/out/renderer/assets/{agent-details-page-CrARDEtK.js → agent-details-page-CpwkLhdq.js} +2 -2
  6. package/out/renderer/assets/{agent-hub-page-tj8FYJ7M.js → agent-hub-page-BYeba0zC.js} +3 -3
  7. package/out/renderer/assets/agents-page-BQdR1fgV.js +7 -0
  8. package/out/renderer/assets/arc-BYg3WIzZ.js +1 -0
  9. package/out/renderer/assets/architectureDiagram-IEHRJDOE-np6HwkQz.js +36 -0
  10. package/out/renderer/assets/{blockDiagram-JOT3LUYC-D0DwK5Ey.js → blockDiagram-JOT3LUYC-CaR7YwVl.js} +2 -2
  11. package/out/renderer/assets/{book-open-DeQc_I6g.js → book-open--g1VlVMp.js} +1 -1
  12. package/out/renderer/assets/browser-page-BPwZPQY2.js +1 -0
  13. package/out/renderer/assets/browser-webauthn-prompt-Bsk0eXNZ.js +1 -0
  14. package/out/renderer/assets/{c4Diagram-VJAJSXHY-CubzqfYr.js → c4Diagram-VJAJSXHY-DqBT3rl5.js} +4 -4
  15. package/out/renderer/assets/channel-mWTr8anL.js +1 -0
  16. package/out/renderer/assets/{chunk-4BMEZGHF-AysrzODh.js → chunk-4BMEZGHF-B7-MzFPi.js} +1 -1
  17. package/out/renderer/assets/{chunk-A2AXSNBT-DfDo-OSy.js → chunk-A2AXSNBT-B9IqNrNg.js} +1 -1
  18. package/out/renderer/assets/{chunk-AEK57VVT-5xgHbFtp.js → chunk-AEK57VVT-DFzBJNd9.js} +1 -1
  19. package/out/renderer/assets/{chunk-D6G4REZN-pYCMpQiN.js → chunk-D6G4REZN-DW-XzsAv.js} +1 -1
  20. package/out/renderer/assets/{chunk-RZ5BOZE2-C5bWxzka.js → chunk-RZ5BOZE2-C7el6yre.js} +1 -1
  21. package/out/renderer/assets/{chunk-XZIHB7SX-B4wB3iEG.js → chunk-XZIHB7SX-BGYrq1Wn.js} +1 -1
  22. package/out/renderer/assets/classDiagram-GIVACNV2-DsNAZ0y6.js +1 -0
  23. package/out/renderer/assets/classDiagram-v2-COTLJTTW-DsNAZ0y6.js +1 -0
  24. package/out/renderer/assets/clone-48M_nlg0.js +1 -0
  25. package/out/renderer/assets/{console-mirror-45f9-7QH.js → console-mirror-ffbsozOd.js} +1 -1
  26. package/out/renderer/assets/{consoleCapture-GiahzrSM.js → consoleCapture-CiApa6fi.js} +1 -1
  27. package/out/renderer/assets/conversation-input-sync-CIGg7Rga.css +1 -0
  28. package/out/renderer/assets/conversation-input-sync-DQUYkOfh.js +911 -0
  29. package/out/renderer/assets/dagre-OKDRZEBW-BVScRDvj.js +4 -0
  30. package/out/renderer/assets/diagram-SSKATNLV-B0iQ6YY1.js +43 -0
  31. package/out/renderer/assets/diagram-VNBRO52H-Co6YPtUT.js +24 -0
  32. package/out/renderer/assets/{erDiagram-Q7BY3M3F-Cpuc-IVT.js → erDiagram-Q7BY3M3F-C9XIuSQl.js} +2 -2
  33. package/out/renderer/assets/error-boundary-DH4MhqhL.js +126 -0
  34. package/out/renderer/assets/{flowDiagram-4HSFHLVR-CsO4ubSn.js → flowDiagram-4HSFHLVR-QTHrGPk1.js} +2 -2
  35. package/out/renderer/assets/{ganttDiagram-APWFNJXF-LYPPAOmY.js → ganttDiagram-APWFNJXF-qC1VnBIz.js} +4 -4
  36. package/out/renderer/assets/gitGraphDiagram-7IBYFJ6S-D7UGP8uH.js +65 -0
  37. package/out/renderer/assets/{graph-uBeiISg2.js → graph-BIUuz2bp.js} +1 -1
  38. package/out/renderer/assets/index-C5Ighs_C.css +1 -0
  39. package/out/renderer/assets/index-Ckvy9Zge.js +1 -0
  40. package/out/renderer/assets/{index-Dn3kYWFt.js → index-D-TXozHA.js} +9 -9
  41. package/out/renderer/assets/index-DHKnfVbX.css +1 -0
  42. package/out/renderer/assets/index-DTc-sJ8S.js +7 -0
  43. package/out/renderer/assets/index-vK67PDia.js +784 -0
  44. package/out/renderer/assets/infoDiagram-PH2N3AL5-DYtVGJC7.js +2 -0
  45. package/out/renderer/assets/installer-BcSiJA6N.js +1 -0
  46. package/out/renderer/assets/{journeyDiagram-U35MCT3I-B6AH0Dcn.js → journeyDiagram-U35MCT3I-vVg2sFTp.js} +6 -6
  47. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-C7dciPrH.js → kanban-definition-NDS4AKOZ-BE36wSk2.js} +4 -4
  48. package/out/renderer/assets/{layout-hxpgEDIm.js → layout-bOQrw0b8.js} +1 -1
  49. package/out/renderer/assets/{legacy-agents-page-C6kd3fjG.js → legacy-agents-page-BSKz_UrV.js} +5 -5
  50. package/out/renderer/assets/{mermaid.core-CC8CflzC.js → mermaid.core-DpvY6Bhk.js} +5 -5
  51. package/out/renderer/assets/mesh-page-9Q8Sc9J_.js +1 -0
  52. package/out/renderer/assets/mindmap-definition-ALO5MXBD-B9PPN6sb.js +95 -0
  53. package/out/renderer/assets/mini-ySULdryU.js +1 -0
  54. package/out/renderer/assets/org-surface-gate-Dl4zcl5q.js +1 -0
  55. package/out/renderer/assets/{page-header-Dt6h8jvu.js → page-header-DazB-GQz.js} +1 -1
  56. package/out/renderer/assets/pieDiagram-IB7DONF6-DkioNhQY.js +30 -0
  57. package/out/renderer/assets/projects-page-C37RiUJz.js +35 -0
  58. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-bRmQaOWY.js → quadrantDiagram-7GDLP6J5-4m3m0N6F.js} +4 -4
  59. package/out/renderer/assets/{radar-MK3ICKWK-B1I3333M.js → radar-MK3ICKWK-DS8YGAOb.js} +1 -1
  60. package/out/renderer/assets/radient-auth-buttons-DZeHRL7u.js +1 -0
  61. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-B29w6CHz.js → requirementDiagram-KVF5MWMF-DsBdUu3C.js} +3 -3
  62. package/out/renderer/assets/sankeyDiagram-QLVOVGJD-CnaPYKR6.js +10 -0
  63. package/out/renderer/assets/{schedules-page-CXz63fN5.js → schedules-page-B0dSGpXt.js} +12 -12
  64. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-D7gyUvnw.js → sequenceDiagram-X6HHIX6F-C3eja1QY.js} +2 -2
  65. package/out/renderer/assets/settings-page-CrMsVX3d.js +292 -0
  66. package/out/renderer/assets/{settings-section-DMXSpP_D.js → settings-section-BGG4XzV0.js} +1 -1
  67. package/out/renderer/assets/stateDiagram-DGXRK772-CjFKiyXn.js +1 -0
  68. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-BsbYpgkp.js +1 -0
  69. package/out/renderer/assets/{timeline-definition-BDJGKUSR-MePOCWzB.js → timeline-definition-BDJGKUSR-CAXy0nQD.js} +2 -2
  70. package/out/renderer/assets/ui-preferences-store-B6Fr0UX9.js +1 -0
  71. package/out/renderer/assets/{use-download-agent-mutation-BNAfnIa9.js → use-download-agent-mutation-LsNre_-6.js} +2 -2
  72. package/out/renderer/assets/use-memberships-query-BgiSfYgr.js +1 -0
  73. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-heZP1JY-.js → xychartDiagram-VJFVF3MP-CfNm8SWG.js} +6 -6
  74. package/out/renderer/console-capture.html +5 -5
  75. package/out/renderer/index.html +9 -9
  76. package/out/renderer/installer.html +4 -5
  77. package/out/renderer/mini.html +7 -6
  78. package/package.json +3 -4
  79. package/out/renderer/assets/agents-page-CbQN_5wE.js +0 -7
  80. package/out/renderer/assets/aida-control-BuMafqCb.js +0 -50
  81. package/out/renderer/assets/arc-BG4bHuQI.js +0 -1
  82. package/out/renderer/assets/architectureDiagram-IEHRJDOE-CkYkkIY9.js +0 -36
  83. package/out/renderer/assets/browser-page-CIhGr6vl.js +0 -1
  84. package/out/renderer/assets/browser-webauthn-prompt-CYou_6QY.js +0 -1
  85. package/out/renderer/assets/channel-B-eIVFbM.js +0 -1
  86. package/out/renderer/assets/classDiagram-GIVACNV2-BN6aG5Qf.js +0 -1
  87. package/out/renderer/assets/classDiagram-v2-COTLJTTW-BN6aG5Qf.js +0 -1
  88. package/out/renderer/assets/clone-C3CHGd7j.js +0 -1
  89. package/out/renderer/assets/dagre-OKDRZEBW-CBRdPb8k.js +0 -4
  90. package/out/renderer/assets/diagram-SSKATNLV-DyGZgIL1.js +0 -43
  91. package/out/renderer/assets/diagram-VNBRO52H-Con45RzE.js +0 -24
  92. package/out/renderer/assets/error-boundary-CdtTgj_c.js +0 -6
  93. package/out/renderer/assets/gitGraphDiagram-7IBYFJ6S-BO_dix1Z.js +0 -65
  94. package/out/renderer/assets/index-2qmFWi_F.css +0 -1
  95. package/out/renderer/assets/index-Bi4c5ZZH.js +0 -7
  96. package/out/renderer/assets/index-CIj3B-eB.js +0 -1
  97. package/out/renderer/assets/index-COUHPq03.js +0 -1533
  98. package/out/renderer/assets/index-D8ujEXbz.css +0 -1
  99. package/out/renderer/assets/infoDiagram-PH2N3AL5-BqRYyG2a.js +0 -2
  100. package/out/renderer/assets/installer-zpOWwoWQ.js +0 -1
  101. package/out/renderer/assets/mesh-page-M4Y20e0t.js +0 -2
  102. package/out/renderer/assets/mindmap-definition-ALO5MXBD-BWI1IBWM.js +0 -95
  103. package/out/renderer/assets/mini-Dtj-bCUA.js +0 -1
  104. package/out/renderer/assets/org-surface-gate-CjPxDSXP.js +0 -1
  105. package/out/renderer/assets/pieDiagram-IB7DONF6-DNymJR3P.js +0 -30
  106. package/out/renderer/assets/projects-page-C3N6NYIX.js +0 -35
  107. package/out/renderer/assets/radient-auth-buttons-CCXHTNWU.js +0 -1
  108. package/out/renderer/assets/sankeyDiagram-QLVOVGJD-BNv_qf23.js +0 -10
  109. package/out/renderer/assets/settings-page-CsCf63si.js +0 -292
  110. package/out/renderer/assets/stateDiagram-DGXRK772-Dd3BswSO.js +0 -1
  111. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-D9cOpOSm.js +0 -1
  112. package/out/renderer/assets/textarea-DsHM-W2p.js +0 -121
  113. package/out/renderer/assets/ui-preferences-store-BmAT9G_p.js +0 -1
  114. package/out/renderer/assets/use-memberships-query-PWqngUAl.js +0 -1
@@ -1,35 +0,0 @@
1
- import{r as x,j as t,c as R}from"./index-Dn3kYWFt.js";import{N as ts,O as Ae,Q as ss,R as yt,u as kt,U as as,V as ns,W as rs,X as is,Y as os,Z as ls,_ as Je,$ as Ze,a0 as cs,a1 as ds,B as Nt,h as H,C as Ye,a2 as pe,a3 as us,a4 as ms,j as ge,a as wt,D as hs,d as et,p as fs,k as ps,a5 as xs,I as gs}from"./aida-control-BuMafqCb.js";import{P as tt}from"./page-header-Dt6h8jvu.js";import{c as qe,s as je,g as St,t as be,u as ve,v as ye,w as ue,B as L,D as js,j as bs,k as vs,n as Me,Q as ys,R as ks,U as Ns,V as ws,W as Ss,m as Ts,p as re,P as _s,Y as Ds,K as Cs,I as z,S as de,L as q,a as Es,y as Tt,N as Os,X as Ms,C as Ps,A as $e,M as As,z as $s,E as Rs,F as Ls,f as ce}from"./textarea-DsHM-W2p.js";import{_ as ie,c1 as Is,au as Fs,a3 as Te,c2 as _t,T as _e,aa as De,c3 as Us,c4 as Bs,c5 as Ys,c6 as qs,ab as Dt,c7 as Ws,bE as zs,aS as ke,aW as Ks,aV as Qs,c8 as Hs,c9 as Gs,ca as Vs,cb as Xs,cc as Js,cd as Zs,ce as ea,a5 as st,cf as ta,a2 as sa,U as V,$ as se,a4 as aa,cg as at,ch as na}from"./index-COUHPq03.js";import"./ui-preferences-store-BmAT9G_p.js";import"./error-boundary-CdtTgj_c.js";import"./console-mirror-45f9-7QH.js";function nt(e,s){return e.filter(a=>!s.includes(a))}function ra(e,s,a){const n=e.slice(0);return n[s]=a,n}var ia=class extends ts{#a;#e;#n;#r;#t;#s;#i;#o;#l=[];constructor(e,s,a){super(),this.#a=e,this.#r=a,this.#n=[],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.#n=e,this.#r=s,Ae.batch(()=>{const a=this.#t,n=this.#u(this.#n);this.#l=n,n.forEach(o=>o.observer.setOptions(o.defaultedQueryOptions));const r=n.map(o=>o.observer),i=r.map(o=>o.getCurrentResult()),l=r.some((o,m)=>o!==a[m]);a.length===r.length&&!l||(this.#t=r,this.#e=i,this.hasListeners()&&(nt(a,r).forEach(o=>{o.destroy()}),nt(r,a).forEach(o=>{o.subscribe(m=>{this.#m(o,m)})}),this.#h()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,s){const a=this.#u(e),n=a.map(r=>r.observer.getOptimisticResult(r.defaultedQueryOptions));return[n,r=>this.#d(r??n,s),()=>this.#c(n,a)]}#c(e,s){return s.map((a,n)=>{const r=e[n];return a.defaultedQueryOptions.notifyOnChangeProps?r:a.observer.trackResult(r,i=>{s.forEach(l=>{l.observer.trackProp(i)})})})}#d(e,s){return s?((!this.#s||this.#e!==this.#o||s!==this.#i)&&(this.#i=s,this.#o=this.#e,this.#s=ss(this.#s,s(e))),this.#s):e}#u(e){const s=new Map(this.#t.map(n=>[n.options.queryHash,n])),a=[];return e.forEach(n=>{const r=this.#a.defaultQueryOptions(n),i=s.get(r.queryHash);i?a.push({defaultedQueryOptions:r,observer:i}):a.push({defaultedQueryOptions:r,observer:new yt(this.#a,r)})}),a}#m(e,s){const a=this.#t.indexOf(e);a!==-1&&(this.#e=ra(this.#e,a,s),this.#h())}#h(){if(this.hasListeners()){const e=this.#s,s=this.#c(this.#e,this.#l),a=this.#d(s,this.#r?.combine);e!==a&&Ae.batch(()=>{this.listeners.forEach(n=>{n(this.#e)})})}}};function oa({queries:e,...s},a){const n=kt(a),r=as(),i=ns(),l=x.useMemo(()=>e.map(N=>{const g=n.defaultQueryOptions(N);return g._optimisticResults=r?"isRestoring":"optimistic",g}),[e,n,r]);l.forEach(N=>{rs(N),is(N,i)}),os(i);const[o]=x.useState(()=>new ia(n,l,s)),[m,h,d]=o.getOptimisticResult(l,s.combine),b=!r&&s.subscribed!==!1;x.useSyncExternalStore(x.useCallback(N=>b?o.subscribe(Ae.batchCalls(N)):ls,[o,b]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),x.useEffect(()=>{o.setQueries(l,s)},[l,s,o]);const u=m.some((N,g)=>Je(l[g],N))?m.flatMap((N,g)=>{const v=l[g];if(v){const c=new yt(n,v);if(Je(v,N))return Ze(v,c,i);cs(N,r)&&Ze(v,c,i)}return[]}):[];if(u.length>0)throw Promise.all(u);const w=m.find((N,g)=>{const v=l[g];return v&&ds({result:N,errorResetBoundary:i,throwOnError:v.throwOnError,query:n.getQueryCache().get(v.queryHash),suspense:v.suspense})});if(w?.error)throw w.error;return h(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 la=[["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"}]],ca=qe("link-2",la);/**
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 da=[["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"}]],ua=qe("send-horizontal",da);/**
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 ma=[["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"}]],ha=qe("unlink",ma),Ce={list:["desktop","projects"],detail:e=>["desktop","projects",e]};function fa(e){return Nt({queryKey:Ce.list,enabled:e,queryFn:()=>H({op:"projects.list"}).then(s=>s.projects),retry:Ye,staleTime:1e4})}function pa(e,s){return oa({queries:e.map(a=>({queryKey:Ce.detail(a),enabled:s&&!!a,queryFn:()=>H({op:"projects.get",key:a}),retry:Ye,staleTime:1e4}))})}function Ct(e,s){return Nt({queryKey:Ce.detail(e??""),enabled:s&&!!e,queryFn:()=>H({op:"projects.get",key:e??""}),retry:Ye,staleTime:1e4})}function oe(){const e=kt();return()=>{e.invalidateQueries({queryKey:Ce.list})}}function xa(){const e=oe();return ie({mutationFn:s=>H({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 Et(){const e=oe();return ie({mutationFn:s=>H({op:"projects.update",key:s.key,fields:s.fields}),onSuccess:()=>e()})}function Ot(){const e=oe();return ie({mutationFn:s=>H({op:"projects.delete",key:s.key,confirmed_name:s.confirmedName}),onSuccess:()=>e()})}function ga(){const e=oe();return ie({mutationFn:s=>H({op:"projects.link",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function ja(){const e=oe();return ie({mutationFn:s=>H({op:"projects.unlink",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function ba(){const e=oe();return ie({mutationFn:s=>H({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 va(){const e=oe();return ie({mutationFn:s=>H({op:"projects.milestone.remove",key:s.key,name:s.name}),onSuccess:()=>e()})}const ya={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 W(e){return ya[e]??{label:e||"Unknown",variant:"neutral"}}function ka(e){return e==="done"}const Na={completed:{label:"Completed",variant:"success"},overdue:{label:"Overdue",variant:"warning"},upcoming:{label:"Upcoming",variant:"neutral"}};function wa(e){return Na[e]??{label:String(e),variant:"neutral"}}const Ne="Stale",Sa=/^(\d{4})-(\d{2})-(\d{2})$/;function X(e,s,a=new Date){if(!e)return"";const n=Sa.exec(e);if(!n)return e;const r=new Date(Number(n[1]),Number(n[2])-1,Number(n[3]));if(Number.isNaN(r.getTime()))return e;const i=r.toLocaleDateString(s,{month:"short",day:"numeric"});return r.getFullYear()===a.getFullYear()?i:`${i}, ${r.getFullYear()}`}function he(e,s){if(e==null)return"";const a=Math.max(0,Math.floor(s/1e3-e));return a<60?"just now":a<3600?`${Math.floor(a/60)}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`}function fe(e){return e==="just now"?"just now":`${e} ago`}function Ta(e){return e?`reported ${fe(e)}`:"no progress"}const Mt=/^$|^\d{4}-\d{2}-\d{2}$/;function Pt(e){return e?e==="operator"?"the operator":`session ${e}`:""}function _a(e,s){if(!e.progress)return"not reported yet";const a=he(e.progress_updated_at,s),n=Pt(e.progress_reported_by),r=[a?`reported ${fe(a)}`:"reported"];return n&&r.push(`by ${n}`),r.join(" ")}function At(e,s){if(e==null)return"";const a=String(e);return s==="points"?`${a} pt`:s==="days"?`${a}d`:a}function $t(e,s){return s<=0?"":`${e}/${s}`}function We(e){return e<=0?"":`${e} live`}function Da(e){return e<=0?"":e===1?"1 session":`${e} sessions`}function Ca(e){const s=Da(e.sessions);if(!s)return"";const a=We(e.live_sessions);return a?`${s} · ${a}`:s}function Ea(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 Oa(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 Ma(e){return e?e.total===1?"1 todo":`${e.total} todos`:""}function Rt(e,s){const a=[],n=X(e.completed_at??e.target_date,s);n&&a.push({key:e.completed_at?"completed":"target",text:e.completed_at?`completed ${n}`:`due ${n}`});const r=At(e.estimate,e.estimate_unit);r&&a.push({key:"estimate",text:r});const i=$t(e.milestones_completed,e.milestones_total);i&&a.push({key:"milestones",text:`milestones ${i}`});const l=We(e.live_sessions);return l&&a.push({key:"live",text:l}),a}const me=864e5,Pa=/^(\d{4})-(\d{2})-(\d{2})$/;function ne(e){if(!e)return null;const s=Pa.exec(e);if(!s)return null;const a=Number(s[1]),n=Number(s[2]),r=Number(s[3]),i=Date.UTC(a,n-1,r),l=new Date(i);return l.getUTCFullYear()!==a||l.getUTCMonth()!==n-1||l.getUTCDate()!==r?null:i}const Re=["planning","active","qa","validation","done"],Le=["paused","archived"],Ee=[{value:"24h",label:"Last 24 hours",phrase:"the last 24 hours",seconds:86400},{value:"7d",label:"Last 7 days",phrase:"the last 7 days",seconds:604800},{value:"30d",label:"Last 30 days",phrase:"the last 30 days",seconds:2592e3},{value:"90d",label:"Last 90 days",phrase:"the last 90 days",seconds:7776e3},{value:"all",label:"All time",phrase:null,seconds:null}],Lt="7d",Aa=Ee.find(e=>e.value===Lt);function It(e){return Ee.find(s=>s.value===e)??Aa}function $a(e){return Ee.some(s=>s.value===e)}function Ra(e,s,a){const n=It(s);return n.seconds===null?e:e.filter(r=>a/1e3-r.updated_at<=n.seconds)}function La(e){const s=It(e);return s.seconds===null?null:`Nothing changed in ${s.phrase}.`}const Ft="projects-board-window";function Ia(){try{const e=localStorage.getItem(Ft);if(e!==null&&$a(e))return e}catch{}return Lt}function rt(e){try{localStorage.setItem(Ft,e)}catch{}}const Ut="projects-board-column-order";let Ie=null;function Fa(){if(Ie)return[...Ie];try{const e=localStorage.getItem(Ut);if(!e)return[];const s=JSON.parse(e);if(!Array.isArray(s))return[];const a=[];for(const n of s){if(typeof n!="string"||n.length===0)return[];a.includes(n)||a.push(n)}return a}catch{return[]}}function Ua(e){Ie=[...e];try{localStorage.setItem(Ut,JSON.stringify(e))}catch{}}function Ba(e,s,a){const n=e.filter(i=>i!==s),r=Math.max(0,Math.min(a,n.length));return n.splice(r,0,s),n}function Ya(e,s=[]){const a=new Map;for(const o of e){const m=a.get(o.status)??[];m.push(o),a.set(o.status,m)}const n=Re.map(o=>({status:o,projects:a.get(o)??[]}));for(const o of Le){const m=a.get(o)??[];m.length>0&&n.push({status:o,projects:m})}for(const[o,m]of a)!Le.includes(o)&&!Re.includes(o)&&n.push({status:o,projects:m});if(s.length===0)return n;const r=new Map(s.map((o,m)=>[o,m])),i=n.filter(o=>r.has(o.status));i.sort((o,m)=>(r.get(o.status)??0)-(r.get(m.status)??0));const l=n.filter(o=>!r.has(o.status));return[...i,...l]}function qa(e,s){if(e.status==="done"||e.status==="archived"||e.completed_at)return!1;const a=ne(e.target_date);return a===null?!1:a<s}function le(e){return e.title||e.name}function Wa(e,s){const a=[];for(const n of[e,s]){const r=n?.trim();r&&!a.includes(r)&&a.push(r)}return a.join(" · ")}const ze="No team";function Ke(e){const s=e.team?.trim();if(s)return s;const a=e.owner?.trim();return a||null}function Qe(e,s){const a=new Map,n=[];for(const i of e){const l=s(i);if(l===null){n.push(i);continue}const o=a.get(l);o?o.push(i):a.set(l,[i])}const r=[...a.entries()].sort(([i],[l])=>i.localeCompare(l,void 0,{sensitivity:"base"})).map(([i,l])=>({team:i,items:l}));return n.length>0&&r.push({team:null,items:n}),r}function He(e){return e.title||e.session_id}function za(e){return[...e].reverse()}function Ka(e){return e<=0?"":e===1?"1 update":`${e} updates`}const it=e=>String(e).padStart(2,"0");function Fe(e){return`${e.getFullYear()}-${it(e.getMonth()+1)}-${it(e.getDate())}`}function Qa(e){const s=Date.parse(e);return Number.isNaN(s)?"":Fe(new Date(s))}function Ha(e,s,a=new Date){if(!e)return"";if(e===Fe(a))return"Today";const n=new Date(a.getFullYear(),a.getMonth(),a.getDate()-1);return e===Fe(n)?"Yesterday":X(e,s,a)}function Ga(e,s){const a=Date.parse(e);return Number.isNaN(a)?"":new Date(a).toLocaleTimeString(s,{hour:"numeric",minute:"2-digit"})}function Va(e,s){const a=Date.parse(e);return Number.isNaN(a)?"":fe(he(a/1e3,s))}function Xa(e,s,a=Date.now()){const n=[],r=Pt(e.by);r&&n.push({key:"author",text:r});const i=Ga(e.at,s);i&&n.push({key:"time",text:i});const l=Va(e.at,a);return l&&n.push({key:"age",text:l}),n}function Ja(e,s,a=new Date){const n=[];for(const r of za(e)){const i=Qa(r.at),l=n[n.length-1];if(l&&l.key===i){l.entries.push(r);continue}n.push({key:i,label:Ha(i,s,a),entries:[r]})}return n}function Za(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 en(e,s){return s<=0?"":`${e} of ${s} complete`}function tn(e){let s=0,a=0,n=!1;for(const r of e)r.todos&&(n=!0,s+=r.todos.open,a+=r.todos.total);return n?{open:s,total:a}:null}function ot(e){return`${e.open} open of ${e.total}`}function sn(e){const s=e.filter(n=>n.exists);return(s.find(n=>n.runtime?.state==="live")??s[0])?.session_id??null}function an(e){const s=le(e),a=e.progress.trim()||"not reported yet";return[`Continue work on project "${s}" (${e.name}).`,`Latest progress: ${a}`,"Review the project details and continue or complete the work."].join(`
17
- `)}function nn(e){return e?e.kind==="team"?`team ${e.name}`:`agent ${e.name}`:""}const lt="complete them, or pass force_done=true to close with them open",rn="complete or remove the incomplete milestones, then mark it done";function Bt(e){return e.includes(lt)?e.replace(lt,rn):e}const on="Shows projects last updated within this window; older ones are hidden.",ln=({value:e,onChange:s})=>t.jsxs(je,{value:e,onValueChange:a=>s(a),children:[t.jsx(St,{content:e==="all"?null:on,side:"bottom",disableHoverableContent:!0,children:t.jsx(be,{"aria-label":"Projects updated within",className:R("w-36 shrink-0"),"data-tour-tag":"projects-board-window",children:t.jsx(ve,{})})}),t.jsx(ye,{children:Ee.map(a=>t.jsx(ue,{value:a.value,children:a.label},a.value))})]}),te=["day","week","month","quarter"],Ge={day:24,week:9,month:3,quarter:1};function Yt(e){const s=new Date(e);return Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())}function ae(e,s){return Math.round((s-e)/me)}function ct(e,s){return ae(e,s)+1}function cn(e,s){for(const a of te)if(e*Ge[a]<=s)return a;return te[te.length-1]}function dn(e){const{project:s}=e;return s.start_date||s.target_date||s.completed_at?!0:e.milestones.some(a=>!!a.target_date)}function un(e,s){const a=[s];for(const n of e){for(const r of[n.project.start_date,n.project.target_date,n.project.completed_at]){const i=ne(r);i!==null&&a.push(i)}for(const r of n.milestones){const i=ne(r.target_date);i!==null&&a.push(i)}}return a.length===1?null:{startMs:Math.min(...a),endMs:Math.max(...a)}}function mn(e){const s=[],a=[];for(const n of e)(dn(n)?s:a).push(n);return{dated:s,undated:a}}function hn(e){const{project:s}=e,a=ne(s.start_date),n=ne(s.target_date),r=ne(s.completed_at),i=s.status==="done"&&r!==null?r:n,l=a??i,o=i??a;return l===null||o===null?null:{fromMs:Math.min(l,o),toMs:Math.max(l,o)}}function fn(e){const s=[];for(const a of e.milestones){const n=ne(a.target_date);n!==null&&s.push({name:a.name,dayMs:n,status:a.status})}return s}const xe=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function K(e){const s=new Date(e);return{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),weekday:s.getUTCDay()}}function pn(e){const{year:s,month:a}=K(e);return Date.UTC(s,a-1,1)}function xn(e){const{year:s,month:a}=K(e);return a===12?Date.UTC(s+1,0,1):Date.UTC(s,a,1)}function gn(e){const{year:s,month:a}=K(e);return Date.UTC(s,Math.floor((a-1)/3)*3,1)}function jn(e){const{year:s,month:a}=K(e),n=Math.floor((a-1)/3);return n===3?Date.UTC(s+1,0,1):Date.UTC(s,n*3+3,1)}function bn(e){const{weekday:s}=K(e);return e-(s+6)%7*me}const vn=26;function yn(e,s,a){const n=[],r=(d,b,f)=>{d<e||d>s||n.push({dayMs:d,label:b,major:f})};if(a==="day"){let d=!1;for(let b=e;b<=s;b+=me){const{day:f,month:u}=K(b);f===1?(r(b,xe[u-1],!0),d=!0):d?(r(b,"",!1),d=!1):r(b,String(f),!1)}return n}if(a==="week"){for(let d=bn(e);d<=s;d+=7*me){if(d<e)continue;const{day:b,month:f}=K(d);K(d-7*me).month!==f?r(d,`${xe[f-1]} ${b}`,!0):r(d,String(b),!1)}return n}const i=a==="month"?pn:gn,l=a==="month"?xn:jn,o=d=>{const{year:b,month:f}=K(d);if(a==="month")return f===1&&b!==K(e).year?`${xe[0]} '${String(b%100).padStart(2,"0")}`:xe[f-1];const u=Math.floor((f-1)/3)+1;return u===1&&b!==K(e).year?`Q1 '${String(b%100).padStart(2,"0")}`:`Q${u}`};r(e,o(i(e)),!0);const m=Math.ceil(vn/Ge[a]);let h=e;for(let d=l(i(e));d<=s;d=l(d))ae(h,d)<m||(r(d,o(d),!0),h=d);return n}const dt={active:"In flight",paused:"On hold",done:"Finished"};function kn(){const[e,s]=x.useState(null);return x.useEffect(()=>{if(!e)return;const a=document.querySelector(`[data-project-menu="${e}"]`);a&&(a.focus(),s(null))}),x.useCallback(a=>s(a),[])}const Nn=4,Pe="Drag the header, or press the arrow keys, to move this column.",ut="board-column-move-hint",wn=({projects:e,nowMs:s,onOpen:a,onEdit:n,onDelete:r,onMove:i,movingKeys:l=[]})=>{const[o,m]=x.useState(Fa),h=Ya(e,o),d=Qe(e,Ke),[b,f]=x.useState(null),[u,w]=x.useState(""),N=x.useRef(null),g=x.useRef(null),v=x.useRef(null),c=x.useRef(null),_=x.useRef(null),P=new Set(l),D=(j,y)=>{const S=Ba(h.map(M=>M.status),j,y);m(S),Ua(S),w(`Moved ${W(j).label} column to position ${S.indexOf(j)+1} of ${S.length}.`)},A=(j,y)=>{const S=N.current;if(!S)return 0;let M=0;const I=S.querySelectorAll("[data-board-column]");for(const U of I){if(U.dataset.boardColumn===y)continue;const Z=U.getBoundingClientRect();j>(Z.left+Z.right)/2&&(M+=1)}return M},B=(j,y)=>{const S=h.filter(U=>U.status!==j),M=S[y-1]?.status,I=S[y]?.status;return M&&I?`between ${W(M).label} and ${W(I).label}`:I?`before ${W(I).label}`:M?`after ${W(M).label}`:"in place"},Q=(j,y)=>{const S=A(j,y.status);S!==y.over&&(y.over=S,f({status:y.status,over:S}),w(`Moving ${W(y.status).label} column; it will drop ${B(y.status,S)}.`))},C=()=>{c.current!==null&&(cancelAnimationFrame(c.current),c.current=null)},O=32,p=12,$=()=>{c.current=null;const j=_.current,y=N.current,S=v.current;if(!j?.armed||!y||S===null)return;const M=y.getBoundingClientRect(),I=y.scrollWidth-y.clientWidth;let U=0;if(S-M.left<O&&y.scrollLeft>0?U=-1:M.right-S<O&&y.scrollLeft<I&&(U=1),U!==0){const Z=y.scrollLeft;y.scrollLeft=Z+U*p,y.scrollLeft!==Z&&Q(S,j)}else Q(S,j);G(j.status,j.over),c.current=requestAnimationFrame($)};x.useEffect(()=>()=>{c.current!==null&&cancelAnimationFrame(c.current)},[]);const E=(j,y)=>{if(j.button===0){try{j.currentTarget.setPointerCapture(j.pointerId)}catch{}_.current={pointerId:j.pointerId,status:y,startX:j.clientX,startY:j.clientY,armed:!1,over:h.findIndex(S=>S.status===y)},v.current=j.clientX}},T=j=>{const y=_.current;if(!(!y||j.pointerId!==y.pointerId)){if(v.current=j.clientX,!y.armed){if(Math.hypot(j.clientX-y.startX,j.clientY-y.startY)<Nn)return;y.armed=!0,f({status:y.status,over:y.over}),w(`Moving ${W(y.status).label} column.`),c.current===null&&(c.current=requestAnimationFrame($))}Q(j.clientX,y)}},F=j=>{const y=_.current;if(_.current=null,C(),f(null),!y?.armed)return;if(!j){w("Move cancelled.");return}const S=h.findIndex(M=>M.status===y.status);if(y.over===S){w("");return}D(y.status,y.over)},k=j=>{const y=_.current;!y||j.pointerId!==y.pointerId||F(!0)},Y=()=>{F(!1)};x.useEffect(()=>{if(!b)return;const j=y=>{y.key==="Escape"&&F(!1)};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[b!==null]);const G=x.useCallback((j,y)=>{const S=N.current,M=g.current;if(!S||!M)return;const I=S.getBoundingClientRect(),U=[];for(const Xe of S.querySelectorAll("[data-board-column]"))Xe.dataset.boardColumn!==j&&U.push(Xe.getBoundingClientRect());const Z=6,Vt=y>=U.length?(U[U.length-1]?.right??I.left)+Z:(U[y]?.left??I.right)-Z,Oe=S.scrollLeft,Xt=2,Jt=Vt-I.left+Oe,Ve=Oe+1,Zt=Oe+I.width-Xt-1,es=Math.round(Math.min(Math.max(Jt,Ve),Math.max(Ve,Zt)));M.style.left=`${es}px`},[]);x.useLayoutEffect(()=>{b&&G(b.status,b.over)},[b,G]);const J=(j,y)=>{if(j.key==="Enter"||j.key===" "){j.preventDefault(),w(Pe);return}if(j.key!=="ArrowLeft"&&j.key!=="ArrowRight")return;j.preventDefault();const S=h.map(U=>U.status),M=S.indexOf(y),I=j.key==="ArrowLeft"?M-1:M+1;if(I<0||I>=S.length){w(`${W(y).label} column is already ${I<0?"the first column":"the last column"}.`);return}D(y,I)};return t.jsxs("div",{className:"[container-type:size] flex min-h-0 flex-1 flex-col","data-testid":"project-board",children:[t.jsx("output",{"aria-live":"polite",className:"sr-only","data-board-column-announcement":"",children:u}),t.jsx("span",{id:ut,className:"sr-only",children:Pe}),t.jsxs("div",{ref:N,"data-board-strip":"",className:R("relative flex min-h-0 flex-1 items-start overflow-auto px-9 pb-9",b&&"cursor-grabbing select-none"),children:[b&&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"}),t.jsxs("div",{className:"flex w-max flex-col",children:[t.jsx("div",{className:"sticky top-0 z-30 flex gap-3",children:h.map(j=>{const y=W(j.status);return t.jsxs("header",{"data-board-column":j.status,"data-board-column-handle":j.status,onPointerDown:S=>E(S,j.status),onPointerMove:T,onPointerUp:k,onPointerCancel:Y,className:R("flex h-11 w-64 shrink-0 cursor-grab items-center justify-between gap-2 rounded-t-md bg-sunken px-3 active:cursor-grabbing",b?.status===j.status&&"opacity-85"),children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[t.jsx(L,{type:"button",variant:"ghost",size:"icon-sm","data-board-column-grip":j.status,"aria-label":`Move ${y.label} column`,"aria-describedby":ut,title:Pe,className:"-ml-1.5 cursor-grab text-ink-muted active:cursor-grabbing",onKeyDown:S=>J(S,j.status),children:t.jsx(Is,{"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}),dt[j.status]&&t.jsx("span",{className:"truncate text-meta text-ink-muted",children:dt[j.status]})]})]}),t.jsx("span",{className:"text-meta text-ink-muted",children:j.projects.length})]},j.status)})}),d.map(j=>t.jsxs("section",{className:"flex flex-col",children:[t.jsx("div",{"data-board-team":j.team??"",className:"sticky top-11 z-20 flex h-8 items-center bg-canvas px-3 text-meta",children:t.jsxs("span",{className:"sticky left-3 flex min-w-0 max-w-[calc(100cqw-2.25rem)] items-center gap-2",children:[t.jsx("span",{className:"truncate text-ink",children:j.team??ze}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:j.items.length})]})}),t.jsx("div",{className:"flex gap-3 rounded-md bg-sunken py-2",children:h.map(y=>{const S=j.items.filter(M=>M.status===y.status);return t.jsx("div",{"data-board-cell":y.status,className:"flex max-h-[calc(100cqh-92px)] w-64 shrink-0 flex-col gap-2 overflow-y-auto px-2",children:S.length>0&&t.jsx("ul",{className:"flex flex-col gap-2",children:S.map(M=>t.jsx("li",{children:t.jsx(Sn,{project:M,nowMs:s,busy:P.has(M.id),onOpen:()=>a(M),onEdit:()=>n(M),onDelete:()=>r(M),onMove:I=>i(M,I)})},M.id))})},y.status)})})]},j.team??""))]})]})]})},Sn=({project:e,nowMs:s,busy:a,onOpen:n,onEdit:r,onDelete:i,onMove:l})=>{const o=Rt(e,typeof navigator>"u"?void 0:navigator.language),m=le(e),h=x.useRef(null),[d,b]=x.useState(!1);x.useEffect(()=>{const g=h.current;if(!g)return;const v=()=>{g.isConnected&&b(g.scrollWidth-g.clientWidth>.5)},c=requestAnimationFrame(v),_=new ResizeObserver(v);return _.observe(g),document.fonts?.ready.then(v).catch(()=>{}),()=>{cancelAnimationFrame(c),_.disconnect()}},[m,d]);const f=qa(e,Yt(s)),u=he(e.progress_updated_at,s),w=()=>{const g=window.getSelection();g&&!g.isCollapsed||n()},N=g=>{g.key!=="Enter"&&g.key!==" "||g.target===g.currentTarget&&(g.preventDefault(),n())};return t.jsxs("div",{"data-project-name":e.name,role:"button",tabIndex:0,"aria-label":`Open ${m}`,onClick:w,onKeyDown:N,className:R("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(St,{content:d?m:null,side:"top",disableHoverableContent:!0,children:t.jsx("span",{ref:h,"data-project-title":e.name,tabIndex:d?0:void 0,className:"block truncate text-body-sm font-medium text-ink",children:m})}),e.title&&t.jsx("span",{className:"mt-0.5 block truncate text-meta text-ink-muted",children:e.name}),e.description&&t.jsx("span",{className:"mt-0.5 block truncate text-meta text-ink-muted",children:e.description})]}),t.jsxs(js,{children:[t.jsx(bs,{"data-project-menu":e.id,"aria-label":`Actions for ${m}`,disabled:a,onClick:g=>g.stopPropagation(),className:R("shrink-0 rounded-sm p-1 text-ink-muted whitespace-nowrap","hover:bg-sunken hover:text-ink"),children:t.jsx(Fs,{className:"size-4"})}),t.jsxs(vs,{align:"end",onClick:g=>g.stopPropagation(),children:[t.jsx(Me,{onSelect:n,children:"Open"}),t.jsxs(ys,{children:[t.jsx(ks,{children:"Set status"}),t.jsx(Ns,{children:t.jsx(ws,{value:e.status,onValueChange:l,children:[...Re,...Le].map(g=>t.jsx(Ss,{value:g,children:W(g).label},g))})})]}),t.jsx(Ts,{}),t.jsx(Me,{onSelect:r,children:"Edit"}),t.jsx(Me,{onSelect:i,children:"Delete"})]})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[o.filter(g=>g.key!=="live").map(g=>t.jsx("span",{className:"rounded-sm bg-sunken px-1.5 py-0.5 text-meta text-ink-muted",children:g.text},g.key)),f&&t.jsx(re,{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:Ta(u)}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[(e.progress_stale||!u)&&t.jsx("span",{"aria-label":Ne,title:Ne,className:"size-1.5 rounded-full bg-warning"}),e.sessions>0&&t.jsx(Tn,{project:e})]})]})]})},Tn=({project:e})=>{const[s,a]=x.useState(!1),n=Te(),r=Ct(e.id,s),i=r.data?.links??[],l=Ca(e),o=le(e);return t.jsxs(_s,{open:s,onOpenChange:a,children:[t.jsx(Ds,{"data-project-sessions":e.id,"aria-label":`Sessions linked to ${o}`,onClick:m=>m.stopPropagation(),className:R("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(Cs,{align:"end",className:"w-64 p-2 outline-none",onClick:m=>m.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(L,{variant:"secondary",size:"sm",onClick:()=>void r.refetch(),children:"Try again"})]}):i.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:i.map(m=>t.jsx("li",{children:t.jsx("button",{type:"button",disabled:!m.exists,onClick:()=>{m.exists&&(a(!1),_t(n,m.session_id))},className:R("flex w-full items-center gap-2 rounded-sm px-1 py-1.5 text-left text-meta",m.exists?"text-ink hover:bg-elevated":"text-ink-disabled"),children:t.jsx("span",{className:"truncate",children:m.title||m.session_id})})},m.session_id))})})]})},qt=({open:e,projectName:s,onClose:a,onConfirm:n})=>{const[r,i]=x.useState(""),[l,o]=x.useState(null),[m,h]=x.useState(!1),d=x.useId();x.useEffect(()=>{e&&(i(""),o(null),h(!1))},[e]);const b=r.trim().toLowerCase()===s.trim().toLowerCase()&&s.trim().length>0,f=async()=>{h(!0),o(null);try{await n(r.trim()),a()}catch(u){o(u instanceof Error&&u.message?u.message:"The project was not deleted.")}finally{h(!1)}};return t.jsx(_e,{open:e,onClose:a,title:"Delete this project?",dataTourTag:"project-delete-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(De,{onClick:a,disabled:m,children:"Cancel"}),t.jsxs(Us,{onClick:()=>void f(),disabled:!b||m,children:[m&&t.jsx(de,{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(z,{id:`${d}-confirm`,value:r,onChange:u=>i(u.target.value),placeholder:s,"aria-label":"Type the project name to confirm","aria-invalid":r.length>0&&!b,autoFocus:!0}),l&&t.jsx("p",{className:"text-body-sm text-danger",children:l})]})})},_n=/^(https?:|mailto:)/i,Dn={a:({href:e,children:s})=>typeof e=="string"&&_n.test(e)?t.jsx("a",{href:e,target:"_blank",rel:"noreferrer",children:s}):t.jsx("span",{className:"font-mono text-mono-sm",children:s}),table:Ys},we=x.memo(({children:e,className:s})=>t.jsx("div",{className:R("lo-markdown",s),children:t.jsx(Bs,{remarkPlugins:[qs],components:Dn,children:e})})),mt=`## Summary
18
-
19
- ## Goals
20
-
21
- ## Notes`,Cn=new RegExp("\\p{Mn}","gu"),En=/[^a-z0-9._-]+/g,On=/[._-]{2,}/g,Mn=/^[^a-z0-9]+/,ht=/[^a-z0-9]+$/;function Pn(e){return e.normalize("NFKD").replace(Cn,"").toLowerCase().replace(En,"-").replace(On,"-").replace(Mn,"").replace(ht,"").slice(0,64).replace(ht,"")}const An=/&#x([0-9a-f]+);/gi,$n=/&#(\d+);/g,Rn=/&nbsp;/g,Ln=/&lt;/g,In=/&gt;/g,Fn=/&quot;/g,Un=/&#39;|&apos;/g,Bn=/&amp;/g,ft=e=>e.replace(An,(s,a)=>String.fromCodePoint(Number.parseInt(a,16))).replace($n,(s,a)=>String.fromCodePoint(Number.parseInt(a,10))).replace(Rn," ").replace(Ln,"<").replace(In,">").replace(Fn,'"').replace(Un,"'").replace(Bn,"&"),Yn=/<[^>]*>|[^<]+/g,qn=/^<\//,Wn=/^<\/?\s*([a-zA-Z][a-zA-Z0-9]*)/,zn=/\s+/g,pt=/class="[^"]*language-([\w+-]+)/,Kn=/href="([^"]*)"/,Qn=/src="([^"]*)"/,Hn=/alt="([^"]*)"/,Gn=/[ \t]+\n/g,Vn=/\n{3,}/g;function Xn(e){const s=[],a=(...h)=>{for(let d=s.length-1;d>=0;d--)if(h.includes(s[d].tag)){const[b]=s.splice(d,1);return b}},n=[],r=()=>s.some(h=>h.tag==="pre"),i=()=>s.filter(h=>h.tag==="blockquote").length;let l=!0;const o=h=>{h&&(i()>0&&l&&!r()&&n.push("> ".repeat(i())),n.push(h),l=h.endsWith(`
22
- `))},m=e.match(Yn)??[];for(let h=0;h<m.length;h++){const d=m[h];if(!d.startsWith("<")){o(r()?ft(d):ft(d).replace(zn," "));continue}const b=qn.test(d),f=(d.match(Wn)?.[1]??"").toLowerCase();if(b){switch(f){case"p":case"div":o(`
23
-
24
- `);break;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":a(f),o(`
25
-
26
- `);break;case"li":{a("li"),o(`
27
- `);const u=[...s].reverse().find(w=>w.tag==="ul"||w.tag==="ol");u?.ordered&&(u.index=(u.index??1)+1);break}case"ul":case"ol":a(f),o(`
28
- `);break;case"strong":case"b":a("strong","b")&&o("**");break;case"em":case"i":a("em","i")&&o("*");break;case"del":case"s":a("del","s")&&o("~~");break;case"code":{a("code")?.inline&&o("`");break}case"pre":a("pre")&&o("\n```\n\n");break;case"a":{const u=a("a");u?.href&&o(`](${u.href})`);break}case"blockquote":a("blockquote")&&o(`
29
- `);break}continue}switch(f){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":{const u=Number(f[1]);s.push({tag:f}),o(`${"#".repeat(u)} `);break}case"ul":case"ol":s.push({tag:f,ordered:f==="ol",index:1});break;case"li":{const u=[...s].reverse().find(w=>w.tag==="ul"||w.tag==="ol");s.push({tag:"li"}),u?.ordered?o(`${u.index??1}. `):o("- ");break}case"strong":case"b":s.push({tag:f}),o("**");break;case"em":case"i":s.push({tag:f}),o("*");break;case"del":case"s":s.push({tag:f}),o("~~");break;case"code":{const u=s[s.length-1]?.tag!=="pre";s.push({tag:"code",inline:u}),u&&o("`");break}case"pre":{const u=d.match(pt)?.[1]??m[h+1]?.match(pt)?.[1]??"";s.push({tag:"pre"}),o(`
30
- \`\`\`${u}
31
- `);break}case"a":{const u=d.match(Kn)?.[1]??"";s.push({tag:"a",href:u}),u&&o("[");break}case"img":{const u=d.match(Qn)?.[1]??"",w=d.match(Hn)?.[1]??"";u&&o(`![${w}](${u})`);break}case"br":o(`
32
- `);break;case"blockquote":s.push({tag:"blockquote"});break}}return n.join("").replace(Gn,`
33
- `).replace(Vn,`
34
-
35
- `).trim()}const Jn=[{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"}],Ue={name:"",title:"",owner:"",team:"",description:"",status:"active",tags:"",startDate:"",targetDate:"",estimate:"",estimateUnit:"points"},xt=Mt;function gt(e){return e.split(",").map(s=>s.trim()).filter(s=>s.length>0)}function Zn(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"}:Ue}const Be=({open:e,mode:s,initial:a,onClose:n,onSubmit:r})=>{const[i,l]=x.useState(Ue),[o,m]=x.useState({}),[h,d]=x.useState(null),b=x.useRef(null),[f,u]=x.useState(!1),[w,N]=x.useState(s==="edit"),[g,v]=x.useState(!1),c=x.useId(),_=x.useRef(null);x.useEffect(()=>{e&&(l(s==="create"?{...Ue,description:mt}:Zn(a)),m({}),d(null),u(!1),N(s==="edit"),v(!1))},[e]),x.useEffect(()=>{h&&b.current?.scrollIntoView({block:"nearest"})},[h]);const P=(p,$)=>{l(E=>({...E,[p]:$}))},D=s==="create"&&!w?Pn(i.title):i.name,A=p=>{const $=p.clipboardData?.getData("text/html");if(!$)return;const E=Xn($);if(!E)return;p.preventDefault();const T=p.currentTarget,F=T.selectionStart??T.value.length,k=T.selectionEnd??F,Y=T.value.slice(0,F)+E+T.value.slice(k);P("description",Y),requestAnimationFrame(()=>{const G=_.current;if(!G)return;const J=F+E.length;G.setSelectionRange(J,J)})},B=(p,$)=>{const E={},T=us($);T&&(E.name=T),p.description.length>pe&&(E.description=`Keep the description within ${pe} characters.`);const F=gt(p.tags);if(F.length>8)E.tags="At most 8 tags.";else for(const k of F){const Y=ms(k);if(Y){E.tags=Y;break}}if(xt.test(p.startDate)||(E.startDate="Dates are YYYY-MM-DD, or empty."),xt.test(p.targetDate)||(E.targetDate="Dates are YYYY-MM-DD, or empty."),!E.startDate&&!E.targetDate&&p.startDate&&p.targetDate&&p.targetDate<p.startDate&&(E.targetDate="The target date is before the start date."),p.estimate){const k=Number(p.estimate);(!Number.isFinite(k)||!(k>0)||k>1e3)&&(E.estimate="Estimates are greater than 0 and at most 1000.")}for(const k of["title","owner","team"])p[k].trim().length>80&&(E[k]=`${k==="title"?"Titles":k==="owner"?"Owners":"Teams"} are at most 80 characters.`);return E},Q=async()=>{const p=D.trim(),$=B(i,p);if(m($),Object.keys($).length>0)return;u(!0),d(null);const E=gt(i.tags);try{if(s==="create"){const T={};i.title.trim()&&(T.title=i.title.trim()),i.owner.trim()&&(T.owner=i.owner.trim()),i.team.trim()&&(T.team=i.team.trim()),i.startDate&&(T.start_date=i.startDate),i.targetDate&&(T.target_date=i.targetDate),i.estimate&&(T.estimate=Number(i.estimate),T.estimate_unit=i.estimateUnit),await r({mode:"create",fields:{name:p,...i.description.trim()&&i.description.trim()!==mt?{description:i.description.trim()}:{},status:i.status,...E.length>0?{tags:E}:{}},...Object.keys(T).length>0?{followUp:T}:{}})}else await r({mode:"edit",key:a?.key??"",fields:{name:p,description:i.description.trim(),title:i.title.trim(),owner:i.owner.trim(),team:i.team.trim(),status:i.status,tags:E,start_date:i.startDate,target_date:i.targetDate,...i.estimate?{estimate:Number(i.estimate)}:{},estimate_unit:i.estimateUnit}});n()}catch(T){const F=T instanceof Error&&T.message?T.message:"";d(Bt(F)||"The project was not saved.")}finally{u(!1)}},C=s==="create"?"New project":"Edit project",O=i.description.length>pe;return t.jsx(_e,{open:e,onClose:n,title:C,fullWidth:!0,maxWidth:"md",dialogProps:{closeDisabled:f,onEscapeKeyDown:p=>{f&&p.preventDefault()},onInteractOutside:p=>{f&&p.preventDefault()}},dataTourTag:s==="create"?"project-create-dialog":"project-edit-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(De,{onClick:n,disabled:f,children:"Cancel"}),t.jsxs(Dt,{"data-project-submit":"",onClick:()=>void Q(),disabled:f,children:[f&&t.jsx(de,{size:"xs"}),s==="create"?"Create project":"Save changes"]})]}),children:t.jsxs("form",{className:"flex flex-col gap-6 px-1 py-1",onSubmit:p=>{p.preventDefault(),Q()},children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(q,{htmlFor:`${c}-title`,children:"Title"}),t.jsx(z,{id:`${c}-title`,"data-project-title":"",value:i.title,onChange:p=>P("title",p.target.value),placeholder:"Payments migration",autoFocus:!0,className:"h-10 text-heading","aria-invalid":!!o.title}),o.title&&t.jsx("p",{className:"text-meta text-danger",children:o.title}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(q,{htmlFor:`${c}-key`,className:"shrink-0 text-meta text-ink-muted",children:"Key"}),t.jsx(z,{id:`${c}-key`,"data-project-key":"",value:D,onChange:p=>{N(!0),P("name",p.target.value)},placeholder:"payments-migration","aria-invalid":!!o.name,className:"h-7 max-w-56 font-mono text-mono-sm"}),t.jsx("span",{className:"text-meta text-ink-muted",children:s==="create"&&!w?"Derived from the title until you edit it.":"Letters, digits, dot, underscore or dash; no spaces."})]}),o.name&&t.jsx("p",{className:"text-meta text-danger",children:o.name})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(q,{htmlFor:`${c}-description`,children:"Description"}),t.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:"Description mode"}),t.jsx("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:["write","preview"].map(p=>t.jsx("button",{type:"button","data-project-description-mode":p,"aria-pressed":g===(p==="preview"),onClick:()=>v(p==="preview"),className:R("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2",g===(p==="preview")&&"bg-surface text-ink"),children:p==="write"?"Write":"Preview"},p))})]})]}),g?t.jsx("div",{"data-project-description-preview":"",className:"h-44 overflow-y-auto rounded-md border border-hairline bg-sunken px-3 py-2",children:i.description.trim()?t.jsx(we,{className:"text-body-sm",children:i.description}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:"Nothing to preview yet."})}):t.jsx(Es,{ref:_,id:`${c}-description`,"data-project-description":"",value:i.description,onChange:p=>P("description",p.target.value),onPaste:A,rows:8,placeholder:"Markdown — headings, lists, code.","aria-invalid":O||!!o.description,className:"h-44 resize-none"}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.description?t.jsx("p",{className:"text-meta text-danger",children:o.description}):t.jsx("span",{}),t.jsxs("p",{className:R("text-meta tabular-nums",O?"text-danger":"text-ink-muted"),children:[i.description.length,"/",pe]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(q,{children:"Status"}),t.jsxs(je,{value:i.status,onValueChange:p=>P("status",p),children:[t.jsx(be,{"aria-label":"Status",children:t.jsx(ve,{})}),t.jsx(ye,{children:Jn.map(p=>t.jsx(ue,{value:p.value,children:p.label},p.value))})]}),i.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(q,{htmlFor:`${c}-owner`,children:"Owner"}),t.jsx(z,{id:`${c}-owner`,"data-project-owner":"",value:i.owner,onChange:p=>P("owner",p.target.value),placeholder:"atlas","aria-invalid":!!o.owner}),o.owner&&t.jsx("p",{className:"text-meta text-danger",children:o.owner})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(q,{htmlFor:`${c}-team`,children:"Team"}),t.jsx(z,{id:`${c}-team`,value:i.team,onChange:p=>P("team",p.target.value),placeholder:"platform","aria-invalid":!!o.team}),o.team&&t.jsx("p",{className:"text-meta text-danger",children:o.team})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(q,{htmlFor:`${c}-target`,children:"Target date"}),t.jsx(z,{id:`${c}-target`,"data-project-target":"",value:i.targetDate,onChange:p=>P("targetDate",p.target.value),placeholder:"YYYY-MM-DD","aria-invalid":!!o.targetDate}),o.targetDate&&t.jsx("p",{className:"text-meta text-danger",children:o.targetDate})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(q,{htmlFor:`${c}-start`,children:"Start date"}),t.jsx(z,{id:`${c}-start`,value:i.startDate,onChange:p=>P("startDate",p.target.value),placeholder:"YYYY-MM-DD","aria-invalid":!!o.startDate}),o.startDate&&t.jsx("p",{className:"text-meta text-danger",children:o.startDate})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(q,{htmlFor:`${c}-estimate`,children:"Estimate"}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(z,{id:`${c}-estimate`,value:i.estimate,onChange:p=>P("estimate",p.target.value),placeholder:"13",inputMode:"decimal","aria-invalid":!!o.estimate,className:"max-w-28"}),t.jsxs(je,{value:i.estimateUnit,onValueChange:p=>P("estimateUnit",p),children:[t.jsx(be,{"aria-label":"Estimate unit",className:"max-w-32",children:t.jsx(ve,{})}),t.jsxs(ye,{children:[t.jsx(ue,{value:"points",children:"Points"}),t.jsx(ue,{value:"days",children:"Days"})]})]})]}),o.estimate&&t.jsx("p",{className:"text-meta text-danger",children:o.estimate}),s==="edit"&&i.estimate.trim()===""&&a?.estimate!==null&&a?.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."})]}),t.jsxs("div",{className:"col-span-2 flex flex-col gap-1.5",children:[t.jsx(q,{htmlFor:`${c}-tags`,children:"Tags"}),t.jsx(z,{id:`${c}-tags`,value:i.tags,onChange:p=>P("tags",p.target.value),placeholder:"q4, payments","aria-invalid":!!o.tags}),o.tags?t.jsx("p",{className:"text-meta text-danger",children:o.tags}):t.jsx("p",{className:"text-meta text-ink-muted",children:"Comma-separated, up to 8. Lowercase letters, digits, underscore or dash."})]})]}),h&&t.jsx("p",{ref:b,className:"text-body-sm text-danger",children:h})]})})},er=({links:e,target:s,onTargetChange:a,onSend:n,focusTick:r})=>{const[i,l]=x.useState(""),[o,m]=x.useState(!1),h=x.useRef(null);x.useEffect(()=>{r>0&&h.current?.focus()},[r]);const d=e.filter(N=>N.exists),f=(d.find(N=>N.session_id===s)??null)?.runtime?.busy===!0,u=!!s&&i.trim().length>0&&!o,w=async()=>{if(!(!u||!s)){m(!0);try{await n(s,i.trim(),f?"steer":"prompt")&&l("")}finally{m(!1),h.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(je,{value:s??void 0,onValueChange:N=>a(N),children:[t.jsx(be,{"aria-label":"Select the session to message",className:"max-w-72",children:t.jsx(ve,{placeholder:"No session selected"})}),t.jsx(ye,{children:d.map(N=>t.jsx(ue,{value:N.session_id,children:He(N)},N.session_id))})]}),f&&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(z,{ref:h,"aria-label":"Message the selected session",placeholder:"Message the session",value:i,onChange:N=>l(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),w())}}),t.jsxs(L,{variant:"secondary",disabled:!u,onClick:()=>void w(),"data-tour-tag":"project-quick-send",children:[o?t.jsx(de,{size:"xs"}):t.jsx(ua,{}),"Send"]})]})]})},tr=({links:e,busy:s,onUnlink:a,onLink:n,onQuickSend:r,onStartSession:i})=>{const l=Te(),o=ge(v=>v.sessions),[m,h]=x.useState(!1),[d,b]=x.useState(null),[f,u]=x.useState(0),w=d&&e.some(v=>v.session_id===d&&v.exists)?d:sn(e),N=x.useMemo(()=>{const v=new Set(e.map(c=>c.session_id));return o.filter(c=>!v.has(c.session_id)).map(c=>({id:c.session_id,name:c.title||c.session_id,description:c.cwd??void 0}))},[o,e]),g=v=>{ge.getState().openSession(v).then(c=>{c&&l(`/chat/${v}`)})};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(L,{variant:"secondary",size:"sm",disabled:s,onClick:i,"data-tour-tag":"project-start-session",children:[t.jsx(Ws,{}),"New session"]}),t.jsxs(L,{variant:"secondary",size:"sm",disabled:s,onClick:()=>h(!0),"data-tour-tag":"project-link-session",children:[t.jsx(ca,{}),"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(v=>{const c=Ea(v),_=Oa(v.subagents),P=Ma(v.todos),D=v.title||v.session_id,A=v.exists;return t.jsxs("li",{className:R("flex items-center gap-2 rounded-sm px-2 py-2",A&&"hover:bg-row-hover"),children:[t.jsx("button",{type:"button",disabled:!A,onClick:()=>{A&&g(v.session_id)},className:R("flex min-w-0 flex-1 items-center gap-2 text-left",A?"cursor-pointer":"cursor-default opacity-100"),children:t.jsx("span",{className:R("min-w-0 truncate text-body-sm",v.title?"text-ink":"font-mono text-mono-sm text-ink-muted"),children:D})}),v.runtime?.busy===!0&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:"busy"}),_&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:_}),P&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:P}),t.jsx(re,{variant:c.variant,children:c.label}),A&&t.jsx(L,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":`Message ${D}`,title:`Message ${D}`,onClick:()=>{b(v.session_id),u(B=>B+1)},children:t.jsx(zs,{})}),t.jsx(L,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":`Unlink ${D}`,onClick:()=>a(v.session_id),children:t.jsx(ha,{})})]},v.session_id)})}),e.length>0&&t.jsx(er,{links:e,target:w,onTargetChange:b,onSend:r,focusTick:f}),t.jsx(_e,{open:m,onClose:()=>h(!1),title:"Link a session",maxWidth:"sm",dataTourTag:"project-link-dialog",actions:t.jsx(De,{onClick:()=>h(!1),children:"Close"}),children:t.jsxs("div",{className:"flex flex-col gap-2 px-1 py-1",children:[t.jsx(q,{children:"Session"}),t.jsx(Tt,{showLabel:!1,ariaLabel:"Search sessions",busyLabel:"Loading sessions",placeholder:"Search conversations",options:N,selected:null,onSelect:v=>{h(!1),n(v.id)}}),t.jsx("p",{className:"text-meta text-ink-muted",children:"Conversations already linked to this project are not listed."})]})})]})},sr=({milestones:e,summary:s,busy:a,onToggle:n,onRemove:r,onAdd:i})=>{const[l,o]=x.useState(""),[m,h]=x.useState(""),d=!Mt.test(m.trim()),b=l.trim().length>0&&!d&&!a,f=()=>{b&&(i(l.trim(),m.trim()),o(""),h(""))};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(u=>{const w=wa(u.status),N=u.completed_at!==null;return t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx(Os,{checked:N,disabled:a,onCheckedChange:g=>n(u.name,g===!0),"aria-label":N?`Mark ${u.name} not complete`:`Mark ${u.name} complete`}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:u.name}),u.target_date&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:X(u.target_date,typeof navigator>"u"?void 0:navigator.language)}),t.jsx(re,{variant:w.variant,children:w.label}),t.jsx(L,{variant:"ghost",size:"icon-sm",disabled:a,"aria-label":`Remove ${u.name}`,onClick:()=>r(u.name),children:t.jsx(Ms,{})})]},u.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(q,{htmlFor:"project-milestone-name",children:"New milestone"}),t.jsx(z,{id:"project-milestone-name",value:l,onChange:u=>o(u.target.value),placeholder:"beta cut",onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),f())}})]}),t.jsxs("div",{className:"flex w-40 flex-col gap-1.5",children:[t.jsx(q,{htmlFor:"project-milestone-date",children:"Target date"}),t.jsx(z,{id:"project-milestone-date",value:m,onChange:u=>h(u.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(L,{variant:"secondary",disabled:!b,onClick:f,"data-tour-tag":"project-milestone-add",children:[t.jsx(ke,{}),"Add"]})]})]})},ar=({project:e,nowMs:s})=>{const a=typeof navigator>"u"?void 0:navigator.language,n=new Date(s),r=[],i=X(e.start_date,a,n);i&&r.push({label:"Start",value:i});const l=X(e.target_date,a,n);l&&r.push({label:"Target",value:l});const o=X(e.completed_at,a,n);o&&r.push({label:"Completed",value:o});const m=At(e.estimate,e.estimate_unit);if(m&&r.push({label:"Estimate",value:m}),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(h=>t.jsx(re,{variant:"outline",children:h},h))})}),e.updated_at>0){const h=fe(he(e.updated_at,s)),d=new Date(e.updated_at*1e3).toLocaleString(a);r.push({label:"Updated",value:t.jsx("time",{dateTime:new Date(e.updated_at*1e3).toISOString(),title:d,children:h})})}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(h=>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:h.label}),t.jsx("dd",{className:"min-w-0 text-body-sm text-ink",children:h.value})]},h.label))})]})},Wt="plain",zt=e=>`team:${e}`,Kt=e=>`agent:${e}`;function nr(e){return e.startsWith("team:")?{kind:"team",name:e.slice(5)}:e.startsWith("agent:")?{kind:"agent",name:e.slice(6)}:{kind:"plain"}}function rr(e){return e.kind==="team"?zt(e.name):e.kind==="agent"?Kt(e.name):Wt}const jt={kind:"plain"},ir=({open:e,onClose:s,onStart:a,teamsEnabled:n,profilesEnabled:r})=>{const[i,l]=x.useState(jt),[o,m]=x.useState(null),[h,d]=x.useState(!1),b=Ks(e&&n),f=Qs(e&&r);x.useEffect(()=>{e&&(l(jt),m(null),d(!1))},[e]);const u=x.useMemo(()=>{const c=[{id:Wt,name:"Nothing in particular",description:"A plain session; assign a team or agent later.",group:"Plain"}];for(const _ of b.data??[])c.push({id:zt(_.name),name:_.name,description:`Team · manager: ${_.manager}`,group:"Teams"});for(const _ of(f.data??[]).filter(P=>P.source!=="builtin"))c.push({id:Kt(_.name),name:_.name,description:_.description||_.kind,group:"Agents"});return c},[b.data,f.data]),w=u.find(c=>c.id===rr(i))??u[0],N=!n||!r,g=b.isLoading||f.isLoading,v=async()=>{d(!0),m(null);try{await a(i),s()}catch(c){m(c instanceof Error&&c.message?c.message:"The session could not be started.")}finally{d(!1)}};return t.jsx(_e,{open:e,onClose:s,title:"Start a session",maxWidth:"sm",dataTourTag:"project-start-session-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(De,{onClick:s,disabled:h,children:"Cancel"}),t.jsxs(Dt,{onClick:()=>void v(),disabled:h,children:[h&&t.jsx(de,{size:"xs"}),"Start session"]})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx(Tt,{label:"Work with",placeholder:"Search teams and agents",options:u,selected:w,onSelect:c=>l(nr(c.id)),busy:g,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."}),N&&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."}),o&&t.jsx("p",{className:"text-body-sm text-danger",children:o})]})})},Qt=({status:e})=>{const s=W(e);return t.jsxs(re,{variant:s.variant,children:[ka(e)&&t.jsx(Ps,{"aria-hidden":!0}),s.label]})},or=({links:e})=>{const s=tn(e),a=e.filter(n=>n.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:ot(s)})]}),a.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:a.map(n=>t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx("span",{className:n.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:He(n)}),n.todos&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:ot(n.todos)})]},n.session_id))})]})},lr=/[/\\]/;function Ht(e){if(e.name)return e.name;const s=e.path.split(lr);return s[s.length-1]||"Attachment"}const cr=({attachment:e})=>{const s=Ht(e),a=Za(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(Zs,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),t.jsx("span",{className:"truncate text-body-sm text-ink",children:s})]}),a&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:a}),t.jsx(ea,{filePath:e.path,"aria-label":`File actions for ${s}`})]})},dr=({attachment:e})=>{const s=Ht(e),a=Hs(e.path,{mimeType:Gs(e.name||e.path),sizeBytes:e.bytes});return a.status==="ready"?t.jsx("div",{className:"inline-block max-w-full",children:t.jsx(Vs,{file:e.path,src:a.url,label:s,conversationId:""})}):a.status==="loading"?t.jsx(Xs,{children:t.jsxs("span",{className:"sr-only",children:["Loading ",s]})}):t.jsx(Js,{name:s})},ur=({attachments:e})=>t.jsx("div",{className:"flex flex-wrap items-start gap-2",children:e.map(s=>s.kind==="image"?t.jsx(dr,{attachment:s},`${s.path}:${s.added_at}`):t.jsx(cr,{attachment:s},`${s.path}:${s.added_at}`))}),mr=({update:e,nowMs:s})=>{const a=typeof navigator>"u"?void 0:navigator.language,n=Xa(e,a,s);return t.jsxs("article",{className:"flex flex-col gap-2 rounded-sm px-2 py-3",children:[n.length>0&&t.jsx("p",{className:"flex flex-wrap items-baseline gap-x-2 text-meta text-ink-muted",children:n.map((r,i)=>t.jsxs(x.Fragment,{children:[i>0&&t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{children:r.text})]},r.key))}),e.text&&t.jsx(we,{children:e.text}),e.attachments.length>0&&t.jsx(ur,{attachments:e.attachments})]})},hr=({updates:e,nowMs:s})=>{const a=typeof navigator>"u"?void 0:navigator.language,n=Ka(e.length),r=Ja(e,a,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"}),n&&t.jsx("span",{className:"text-meta text-ink-muted",children:n})]}),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(i=>t.jsxs("div",{className:"flex flex-col gap-2",children:[i.label&&t.jsx("h3",{className:"text-meta text-ink-muted",children:i.label}),t.jsx("div",{className:"flex flex-col divide-y divide-hairline",children:i.entries.map((l,o)=>t.jsx(mr,{update:l,nowMs:s},`${l.at}:${l.by}:${o}`))})]},i.key||"ungrouped"))})]})},fr="project_not_found",pr=({projectKey:e,nowMs:s})=>{const a=Te(),n=wt(),r=Ct(e,!0),i=Et(),l=Ot(),o=ba(),m=va(),h=ga(),d=ja(),[b,f]=x.useState(!1),[u,w]=x.useState(!1),[N,g]=x.useState(!1),v=i.isPending||l.isPending||o.isPending||m.isPending||h.isPending||d.isPending;if(r.isLoading)return t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(de,{label:"Loading project"})});if(r.isError||!r.data){const C=r.error instanceof hs&&(r.error.code===fr||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:C?"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(L,{variant:"secondary",onClick:()=>void r.refetch(),children:"Try again"}),t.jsxs(L,{variant:"secondary",onClick:()=>void a("/projects"),children:[t.jsx(st,{}),"All projects"]})]})]})}const{project:c,links:_}=r.data,P=le(c),D=Wa(c.owner,c.team),A=en(c.milestones.filter(C=>C.completed_at!==null).length,c.milestones.length),B=async(C,O,p)=>{const $=ge.getState(),E=fs(null,C,$.drafts);if(!E)return!1;try{if(await ps(E,{text:O,attachments:[],images:[],mode:p,cwd:$.cwd},C)===null)return V("That session already has a message going out. Try again in a moment."),!1;const F=_.find(k=>k.session_id===C);return se(`Sent to ${F?He(F):C}`),!0}catch(T){return V(T instanceof Error&&T.message?T.message:"The message was not sent."),!1}},Q=async C=>{const O=ge.getState(),p=C.kind==="plain"?void 0:{kind:C.kind,name:C.name},$=await O.createSession(O.cwd||"~",p);if(!$)throw new Error(O.error??"The session could not be started.");xs.getState().setCurrentInput($,an(c));let E=null;try{await h.mutateAsync({key:c.id,sessionId:$})}catch(T){E=T instanceof Error&&T.message?T.message:"the link was refused"}if(E)V(`Session started, but linking it failed: ${E}`);else{const T=p?` with ${nn(p)}`:"";se(`Session started${T} and linked to ${P}.`)}await _t(a,$)};return t.jsxs("div",{className:"mx-auto flex w-full max-w-200 flex-col gap-8",children:[t.jsxs("header",{className:"flex flex-col gap-4",children:[t.jsxs("button",{type:"button",onClick:()=>void a("/projects"),className:"flex w-fit items-center gap-1.5 text-body-sm text-ink-muted hover:text-ink",children:[t.jsx(st,{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",{"data-project-title":c.name,className:"min-w-0 break-words text-display text-ink",children:P}),t.jsx(Qt,{status:c.status}),c.progress_stale&&t.jsx(re,{variant:"warning",children:Ne})]}),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(L,{variant:"secondary",onClick:()=>f(!0),"data-tour-tag":"project-edit",children:[t.jsx(ta,{}),"Edit"]}),t.jsxs(L,{variant:"secondary",onClick:()=>w(!0),"data-tour-tag":"project-delete",children:[t.jsx(sa,{}),"Delete"]})]})]})]}),c.description.trim()&&t.jsx(we,{className:"text-body",children:c.description}),t.jsx(ar,{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(we,{className:"text-body",children:c.progress}),t.jsx("p",{className:"text-meta text-ink-muted",children:_a(c,s)})]}),t.jsx(sr,{milestones:c.milestones,summary:A,busy:v,onToggle:(C,O)=>{o.mutateAsync({key:c.id,name:C,completed:O}).catch(p=>{V(p instanceof Error&&p.message?p.message:"The milestone was not updated.")})},onRemove:C=>{m.mutateAsync({key:c.id,name:C}).catch(O=>{V(O instanceof Error&&O.message?O.message:"The milestone was not removed.")})},onAdd:(C,O)=>{o.mutateAsync({key:c.id,name:C,targetDate:O}).catch(p=>{V(p instanceof Error&&p.message?p.message:"The milestone was not added.")})}}),t.jsx(tr,{projectKey:c.id,links:_,busy:v,onStartSession:()=>g(!0),onQuickSend:B,onLink:C=>{h.mutateAsync({key:c.id,sessionId:C}).catch(O=>{V(O instanceof Error&&O.message?O.message:"The session was not linked.")})},onUnlink:C=>{d.mutateAsync({key:c.id,sessionId:C}).catch(O=>{V(O instanceof Error&&O.message?O.message:"The session was not unlinked.")})}}),t.jsx(or,{links:_}),t.jsx(hr,{updates:c.updates,nowMs:s}),t.jsx(Be,{open:b,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:()=>f(!1),onSubmit:async C=>{C.mode==="edit"&&(await i.mutateAsync({key:C.key,fields:C.fields}),se("Project saved"))}}),t.jsx(qt,{open:u,projectName:c.name,onClose:()=>w(!1),onConfirm:async C=>{await l.mutateAsync({key:c.id,confirmedName:C}),se("Project deleted"),a("/projects")}}),t.jsx(ir,{open:N,onClose:()=>g(!1),onStart:Q,teamsEnabled:et(n.data,"team_catalogue"),profilesEnabled:et(n.data,"profile_catalogue")})]})},ee=[{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 xr(e,s){const a=he(e.progress_updated_at,s);return a?fe(a):"not reported"}const gr=({projects:e,nowMs:s,onOpen:a})=>{const n=Qe(e,Ke);return t.jsxs("div",{className:"@container flex min-h-0 flex-1 flex-col","data-testid":"project-list",children:[t.jsx("div",{className:"flex shrink-0 items-center gap-3 px-9 py-2 text-meta text-ink-muted","aria-hidden":"true",children:ee.map(r=>t.jsx("span",{className:r.className,children:r.label},r.key))}),t.jsx("ul",{className:"min-h-0 flex-1 overflow-y-auto px-6",children:n.map(r=>t.jsxs("li",{children:[t.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-2 bg-canvas px-3 py-1.5 text-meta","data-project-team":r.team??"",children:[t.jsx("span",{className:"truncate text-ink",children:r.team??ze}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:r.items.length})]}),t.jsx("ul",{className:"divide-y divide-hairline",children:r.items.map(i=>{const l=new Map(Rt(i,typeof navigator>"u"?void 0:navigator.language).map(h=>[h.key,h.text])),o=$t(i.milestones_completed,i.milestones_total),m=We(i.live_sessions);return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>a(i),"data-project-name":i.name,className:R("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:R(ee[0].className,"truncate text-body-sm text-ink"),children:le(i)}),t.jsx("span",{className:ee[1].className,children:t.jsx(Qt,{status:i.status})}),t.jsx("span",{className:R(ee[2].className,"truncate text-meta text-ink-muted"),children:l.get("target")??l.get("completed")??""}),t.jsx("span",{className:R(ee[3].className,"truncate text-meta text-ink-muted"),children:l.get("estimate")??""}),t.jsx("span",{className:R(ee[4].className,"truncate text-meta text-ink-muted"),children:o}),t.jsx("span",{className:R(ee[5].className,"truncate text-meta text-ink-muted"),children:m}),t.jsxs("span",{className:R(ee[6].className,"flex items-center gap-2"),children:[t.jsx("span",{className:"truncate text-meta text-ink-muted",children:xr(i,s)}),i.progress_stale&&t.jsx(re,{variant:"warning",children:Ne})]})]})},i.id)})})]},r.team??""))})]})},Se=224,bt=36,jr={day:"Days",week:"Weeks",month:"Months",quarter:"Quarters"},br=({items:e,nowMs:s,onOpen:a,pendingDetails:n,failedDetails:r,onRetryDetails:i})=>{const[l,o]=x.useState(null),[m,h]=x.useState(0),d=x.useRef(null),b=Yt(s),f=x.useMemo(()=>un(e,b),[e,b]),u=x.useMemo(()=>mn(e),[e]),w=x.useMemo(()=>Qe(u.dated,D=>Ke(D.project)),[u]);x.useLayoutEffect(()=>{const D=d.current;if(!D)return;const A=()=>h(D.clientWidth);if(A(),typeof ResizeObserver>"u")return;const B=new ResizeObserver(A);return B.observe(D),()=>B.disconnect()},[]);const N=Math.max(m-Se-24,160),g=f?cn(ct(f.startMs,f.endMs),N):"month",v=l??g,c=D=>{const A=te.indexOf(v),B=te[A-D];B&&o(B)},_=Ge[v],P=f?ct(f.startMs,f.endMs)*_:0;return t.jsxs("div",{ref:d,className:"flex min-h-0 flex-1 flex-col","data-testid":"project-timeline",children:[t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 px-9 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"}.`:n>0?`Loading milestones for ${n} project${n===1?"":"s"}…`:`${u.dated.length} dated · ${u.undated.length} without dates`}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[r>0&&t.jsx(L,{variant:"secondary",size:"sm",onClick:i,children:"Try again"}),t.jsx(L,{variant:"secondary",size:"icon","aria-label":"Zoom in",title:"Zoom in (finer)",disabled:!f||v===te[0],onClick:()=>c(1),children:t.jsx(ke,{})}),t.jsx("span",{className:"w-16 text-center text-meta text-ink-muted",children:jr[v]}),t.jsx(L,{variant:"secondary",size:"icon","aria-label":"Zoom out",title:"Zoom out (coarser)",disabled:!f||v===te[te.length-1],onClick:()=>c(-1),children:t.jsx(As,{})})]})]}),f&&u.dated.length>0?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-6 pb-6",children:t.jsxs("div",{className:"min-w-max",children:[t.jsx(vr,{startMs:f.startMs,endMs:f.endMs,tier:v,pxPerDay:_,trackPx:P}),w.map(D=>t.jsxs("div",{children:[t.jsx("div",{className:"sticky top-0 z-20 flex items-stretch bg-canvas","data-project-team":D.team??"",children:t.jsxs("span",{className:"sticky left-0 z-20 flex shrink-0 items-center gap-2 bg-canvas px-3 py-1 text-meta",style:{width:Se},children:[t.jsx("span",{className:"truncate text-ink",children:D.team??ze}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:D.items.length})]})}),D.items.map(A=>t.jsx(yr,{item:A,spanStart:f.startMs,pxPerDay:_,trackPx:P,today:b,onOpen:()=>a(A)},A.project.id))]},D.team??""))]})}):t.jsx("p",{className:"px-9 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."}),u.undated.length>0&&t.jsxs("div",{className:"shrink-0 px-9 py-2 text-meta text-ink-muted",children:["No dates (",u.undated.length,"):"," ",u.undated.map((D,A)=>t.jsxs("span",{children:[A>0&&", ",t.jsx("button",{type:"button",className:"text-ink hover:underline",onClick:()=>a(D),children:le(D.project)})]},D.project.id))]})]})},vr=({startMs:e,endMs:s,tier:a,pxPerDay:n,trackPx:r})=>{const i=yn(e,s,a);return t.jsxs("div",{className:"flex items-stretch",children:[t.jsx("span",{className:"sticky left-0 z-10 shrink-0 bg-canvas",style:{width:Se}}),t.jsx("span",{className:"relative block h-6",style:{width:r},children:i.map(l=>t.jsxs("span",{className:"absolute top-0 h-full",style:{left:ae(e,l.dayMs)*n},children:[t.jsx("span",{className:R("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))})]})},yr=({item:e,spanStart:s,pxPerDay:a,trackPx:n,today:r,onOpen:i})=>{const{project:l}=e,o=hn(e),m=fn(e),h=d=>new Date(d).toISOString().slice(0,10);return t.jsxs("button",{type:"button",onClick:i,"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-canvas px-3",style:{width:Se,height:bt},children:t.jsx("span",{className:"truncate text-body-sm text-ink",children:le(l)})}),t.jsxs("span",{className:"relative block",style:{width:n,height:bt},children:[o&&t.jsx("span",{className:"absolute top-1/2 h-1.5 -translate-y-1/2 rounded-full bg-accent/75",style:{left:ae(s,o.fromMs)*a,width:(ae(o.fromMs,o.toMs)+1)*a},title:`${X(h(o.fromMs))} → ${X(h(o.toMs))}`}),m.map(d=>t.jsx("span",{"data-milestone":d.status,className:R("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:ae(s,d.dayMs)*a},title:`${d.name} · ${d.status} · ${X(h(d.dayMs))}`},`${d.name}-${d.dayMs}`)),t.jsx("span",{className:"absolute inset-y-0 w-px bg-accent/75",style:{left:ae(s,r)*a},"aria-hidden":"true"})]})]})},Gt="projects-view",kr=[{value:"list",label:"List"},{value:"board",label:"Board"},{value:"timeline",label:"Timeline"}];function Nr(){try{const e=localStorage.getItem(Gt);if(e==="board"||e==="timeline"||e==="list")return e}catch{}return"list"}function wr(e){try{localStorage.setItem(Gt,e)}catch{}}const Sr=({value:e,onChange:s})=>t.jsx($s,{value:e,onValueChange:a=>s(a),children:t.jsx(Rs,{"aria-label":"Project view","data-tour-tag":"projects-view-switcher",children:kr.map(a=>t.jsx(Ls,{value:a.value,children:a.label},a.value))})}),Tr=["r1","r2","r3","r4","r5","r6"],vt={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."},$r=({nowMs:e=Date.now()})=>{const{projectId:s}=aa(),a=Te(),n=wt(),r=gs(n.data,"projects",1),i=r==="enabled",l=fa(i),o=xa(),m=Et(),h=Ot(),[d,b]=x.useState(!1),[f,u]=x.useState(()=>Nr()),[w,N]=x.useState(()=>Ia()),[g,v]=x.useState(null),[c,_]=x.useState(null),P=kn(),D=l.data??[],A=x.useMemo(()=>Ra(D,w,e),[D,w,e]),B=La(w),[Q,C]=x.useState(!1);x.useEffect(()=>{if(!Q)return;const k=document.querySelector('[data-tour-tag="projects-board-window"]');k&&(k.focus(),C(!1))});const O=pa(f==="timeline"?D.map(k=>k.id):[],i),p=D.map((k,Y)=>({project:k,milestones:O[Y]?.data?.project.milestones??[]})),$=f==="timeline"?O.filter(k=>k.isLoading).length:0,E=f==="timeline"?O.filter(k=>k.isError).length:0,T=()=>{for(const k of O)k.isError&&k.refetch()},F=(k,Y)=>{m.mutate({key:k.id,fields:{status:Y}},{onSuccess:()=>{se(`Moved to ${W(Y).label}`),l.refetch().then(()=>P(k.id))}})};return i?s?t.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto overflow-x-hidden p-6 [scrollbar-gutter:stable_both-edges]",children:t.jsx(pr,{projectKey:s,nowMs:e})}):t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"flex shrink-0 flex-col gap-8 px-6 pt-6",children:[t.jsx(tt,{title:"Projects",icon:at,subtitle:"Workstreams you and your agents track across sessions.",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(L,{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(na,{})}),t.jsxs(L,{variant:"secondary",onClick:()=>b(!0),"data-tour-tag":"create-project-button",children:[t.jsx(ke,{}),"New project"]})]})}),t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3",children:[t.jsx(Sr,{value:f,onChange:k=>{u(k),wr(k)}}),f==="board"&&!(l.isSuccess&&l.data.length===0)&&t.jsx(ln,{value:w,onChange:k=>{N(k),rt(k)}})]})]}),t.jsxs("div",{className:"mt-8 flex min-h-0 flex-1 flex-col",children:[l.isLoading&&t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("output",{className:"px-9 py-2 text-meta text-ink-dim",children:"Loading projects…"}),Tr.map(k=>t.jsxs("div",{className:"flex items-center gap-3 px-9 py-2","aria-hidden":"true",children:[t.jsx(ce,{className:"h-4 min-w-0 flex-1 bg-elevated"}),t.jsx(ce,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(ce,{className:"h-4 w-32 shrink-0 bg-elevated"}),t.jsx(ce,{className:"h-4 w-16 shrink-0 bg-elevated"}),t.jsx(ce,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(ce,{className:"h-4 w-40 shrink-0 bg-elevated"})]},k))]}),l.isError&&t.jsxs("div",{className:"flex flex-col items-start gap-2 px-6",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(L,{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",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(L,{variant:"primary",onClick:()=>b(!0),"data-tour-tag":"create-project-empty-button",children:[t.jsx(ke,{}),"New project"]})]}),l.isSuccess&&l.data.length>0&&f==="list"&&t.jsx(gr,{projects:l.data,nowMs:e,onOpen:k=>void a(`/projects/${k.id}`)}),l.isSuccess&&l.data.length>0&&f==="board"&&A.length>0&&t.jsx(wn,{projects:A,nowMs:e,onOpen:k=>void a(`/projects/${k.id}`),onEdit:v,onDelete:_,onMove:F,movingKeys:m.isPending&&m.variables?[m.variables.key]:[]}),l.isSuccess&&l.data.length>0&&f==="board"&&A.length===0&&B!==null&&t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-4",children:[t.jsx("p",{className:"text-heading text-ink",children:B}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:"Older projects are hidden by the window."}),t.jsx(L,{variant:"secondary",onClick:()=>{N("all"),rt("all"),C(!0)},children:"Show all time"})]}),l.isSuccess&&l.data.length>0&&f==="timeline"&&t.jsx(br,{items:p,nowMs:e,onOpen:k=>void a(`/projects/${k.project.id}`),pendingDetails:$,failedDetails:E,onRetryDetails:T})]}),t.jsx(Be,{open:g!==null,mode:"edit",initial:g?{key:g.id,name:g.name,title:g.title,owner:g.owner,team:g.team,description:g.description,status:g.status,tags:g.tags,start_date:g.start_date,target_date:g.target_date,estimate:g.estimate,estimate_unit:g.estimate_unit}:null,onClose:()=>v(null),onSubmit:async k=>{k.mode==="edit"&&(await m.mutateAsync({key:k.key,fields:k.fields}),se("Project saved"),v(null))}}),t.jsx(qt,{open:c!==null,projectName:c?.name??"",onClose:()=>_(null),onConfirm:async k=>{c&&(await h.mutateAsync({key:c.id,confirmedName:k}),se("Project deleted"),_(null))}}),t.jsx(Be,{open:d,mode:"create",onClose:()=>b(!1),onSubmit:async k=>{if(k.mode!=="create")return;const Y=await o.mutateAsync(k.fields),G=k.followUp?.title??k.fields.name;if(k.followUp)try{await m.mutateAsync({key:Y.id,fields:k.followUp})}catch(J){const j=J instanceof Error&&J.message?J.message:"";V(`Project ${G} was created, but the extra fields were not saved: ${Bt(j)||"the server refused them."} Open the project and use Edit to set them.`);return}se(`Project ${G} created`)}})]}):t.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[t.jsx(tt,{title:"Projects",icon:at}),n.isLoading?t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(de,{label:"Checking the server's Projects support"})}):t.jsx($e,{variant:"warning",children:vt[r]??vt.unknown})]})};export{$r as ProjectsPage};
@@ -1 +0,0 @@
1
- import{j as e}from"./index-Dn3kYWFt.js";import{P as m,r as p}from"./index-COUHPq03.js";import{u as x,a as b,d as h,b as v}from"./aida-control-BuMafqCb.js";import{A as d,S as f}from"./textarea-DsHM-W2p.js";const g="radient",D=({onSignInSuccess:o,onAfterCredentialUpdate:c,titleText:i="Sign in to Radient",descriptionText:n="Connect your Radient account to use Radient services."})=>{const l=x(),t=b(),a=h(t.data,"auth"),s=v(a),r=s.data?.find(u=>u.id===g);return t.isSuccess&&!a?e.jsx(d,{variant:"warning",children:"Signing in needs a newer Local Operator backend. Update the backend and restart the app."}):s.isLoading||t.isLoading?e.jsx("div",{className:"flex h-24 items-center justify-center",children:e.jsx(f,{size:"md",label:"Loading sign-in options"})}):r?e.jsxs("div",{className:"mx-auto w-full max-w-md",children:[i&&e.jsx("p",{className:"mb-2 text-center text-heading text-ink",children:i}),n&&e.jsx("p",{className:"mb-6 text-center text-body-sm text-ink-muted",children:n}),e.jsx(m,{provider:r,onConnected:()=>{l.invalidateQueries({queryKey:p.all}),c?.(),o?.()}})]}):e.jsx(d,{variant:"warning",children:"Radient is not available from this backend's provider registry."})};export{D as R};
@@ -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-CC8CflzC.js";import{S as At}from"./index-COUHPq03.js";import"./index-Dn3kYWFt.js";import"./aida-control-BuMafqCb.js";import"./ui-preferences-store-BmAT9G_p.js";import"./textarea-DsHM-W2p.js";import"./error-boundary-CdtTgj_c.js";import"./console-mirror-45f9-7QH.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 xe={styles:ue,parser:H,db:se,renderer:ae};export{xe as diagram};