local-operator-ui 0.36.8 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/out/main/index.js +2046 -19
  2. package/out/preload/index.js +34 -2
  3. package/out/renderer/assets/{_basePickBy-D11ygq2l.js → _basePickBy-Ccz_FVoP.js} +1 -1
  4. package/out/renderer/assets/{_baseUniq-_Pf0yG1r.js → _baseUniq-i6vGpLRc.js} +1 -1
  5. package/out/renderer/assets/{agent-details-page-LU973LFV.js → agent-details-page-Vg5HG_l0.js} +2 -2
  6. package/out/renderer/assets/{agent-hub-page-DegTVxlE.js → agent-hub-page-K4pCiyVg.js} +1 -1
  7. package/out/renderer/assets/{agents-page-B6Y-wB7u.js → agents-page-DO-dA64a.js} +3 -3
  8. package/out/renderer/assets/{arc-BedtwWh_.js → arc-B4AUWIOq.js} +1 -1
  9. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-DyIP0L4b.js → architectureDiagram-IEHRJDOE-B6S5IVGr.js} +1 -1
  10. package/out/renderer/assets/{arrow-up-BD8jieeb.js → arrow-up-BQ3q9CbG.js} +1 -1
  11. package/out/renderer/assets/{blockDiagram-JOT3LUYC-w5b-ZzdW.js → blockDiagram-JOT3LUYC-LpW3K6pq.js} +1 -1
  12. package/out/renderer/assets/{book-open-DxzLWerU.js → book-open-1KhbTE6j.js} +1 -1
  13. package/out/renderer/assets/browser-page-C2PcMomi.js +1 -0
  14. package/out/renderer/assets/{browser-webauthn-prompt-CbE9FFZv.js → browser-webauthn-prompt-DW_0ckOh.js} +1 -1
  15. package/out/renderer/assets/{building-2-DtOQfBQY.js → building-2-B-r5qz8T.js} +1 -1
  16. package/out/renderer/assets/{c4Diagram-VJAJSXHY-CnSFoHWb.js → c4Diagram-VJAJSXHY-CAqRIAIW.js} +1 -1
  17. package/out/renderer/assets/channel-C3p9uq-y.js +1 -0
  18. package/out/renderer/assets/{chunk-4BMEZGHF-CY0scau5.js → chunk-4BMEZGHF-xA1Nsxex.js} +1 -1
  19. package/out/renderer/assets/{chunk-A2AXSNBT-B_cWmZiK.js → chunk-A2AXSNBT-CUDzamID.js} +1 -1
  20. package/out/renderer/assets/{chunk-AEK57VVT-BRm1a_Ub.js → chunk-AEK57VVT-DlMRhXPR.js} +1 -1
  21. package/out/renderer/assets/{chunk-D6G4REZN-CmZT-cQT.js → chunk-D6G4REZN-VcBIri9Q.js} +1 -1
  22. package/out/renderer/assets/{chunk-RZ5BOZE2-Cwg1etHt.js → chunk-RZ5BOZE2-CCsj9xK4.js} +1 -1
  23. package/out/renderer/assets/{chunk-XZIHB7SX-a-OtMrnF.js → chunk-XZIHB7SX-CKTgVOcT.js} +1 -1
  24. package/out/renderer/assets/classDiagram-GIVACNV2-E64bGPOA.js +1 -0
  25. package/out/renderer/assets/classDiagram-v2-COTLJTTW-E64bGPOA.js +1 -0
  26. package/out/renderer/assets/clone-Cp6fbpqM.js +1 -0
  27. package/out/renderer/assets/{console-mirror-wrjuOlK5.js → console-mirror-rnDJat8Q.js} +1 -1
  28. package/out/renderer/assets/{consoleCapture-CGsX86Ez.js → consoleCapture-BDAHhWI6.js} +1 -1
  29. package/out/renderer/assets/{conversation-input-sync-qFePp_gf.js → conversation-input-sync-DkdrIqiD.js} +277 -277
  30. package/out/renderer/assets/{dagre-OKDRZEBW-ujAbOxN1.js → dagre-OKDRZEBW-BLJ3cLu1.js} +1 -1
  31. package/out/renderer/assets/{diagram-SSKATNLV-BGt8bOqa.js → diagram-SSKATNLV-BH0p-5Dv.js} +1 -1
  32. package/out/renderer/assets/{diagram-VNBRO52H-DGmIp--B.js → diagram-VNBRO52H-B82m2-a7.js} +1 -1
  33. package/out/renderer/assets/{erDiagram-Q7BY3M3F-Czgf2xtG.js → erDiagram-Q7BY3M3F-B49jRhsr.js} +1 -1
  34. package/out/renderer/assets/{error-boundary-CIO9VaTx.js → error-boundary-2fpGTHTH.js} +2 -2
  35. package/out/renderer/assets/{flowDiagram-4HSFHLVR-BSuzI5ul.js → flowDiagram-4HSFHLVR-OEuTrGbc.js} +1 -1
  36. package/out/renderer/assets/{ganttDiagram-APWFNJXF-DjjvFPP9.js → ganttDiagram-APWFNJXF-WrHus6zK.js} +1 -1
  37. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-qgMylPGx.js → gitGraphDiagram-7IBYFJ6S-sdpNtvIC.js} +1 -1
  38. package/out/renderer/assets/{graph-C_PIARec.js → graph-CPx4Z3cH.js} +1 -1
  39. package/out/renderer/assets/{hash-BTR-wmLC.js → hash-MswM3CQT.js} +1 -1
  40. package/out/renderer/assets/index-Bt4e_nGt.js +57 -0
  41. package/out/renderer/assets/index-CXF8GwAZ.js +825 -0
  42. package/out/renderer/assets/index-Ct_f1nHS.css +1 -0
  43. package/out/renderer/assets/{index-B5ZsvNme.js → index-D0ZcaKHz.js} +1 -1
  44. package/out/renderer/assets/{index-B9Z9fABA.js → index-bD-9hTJ5.js} +1 -1
  45. package/out/renderer/assets/{infoDiagram-PH2N3AL5-CXhZsMAw.js → infoDiagram-PH2N3AL5-CgbaZe5Z.js} +1 -1
  46. package/out/renderer/assets/{installer-DsBvKWJk.js → installer-GzNnUma-.js} +1 -1
  47. package/out/renderer/assets/{journeyDiagram-U35MCT3I-BfRBfFPi.js → journeyDiagram-U35MCT3I-CIWLEQby.js} +1 -1
  48. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-BjBPm0Wp.js → kanban-definition-NDS4AKOZ-ORj0JKQO.js} +1 -1
  49. package/out/renderer/assets/{layout-CxH8v5Lh.js → layout-5wBU4YOj.js} +1 -1
  50. package/out/renderer/assets/legacy-agents-page-ou1Xp1az.js +33 -0
  51. package/out/renderer/assets/library-page-BloF_iPE.js +157 -0
  52. package/out/renderer/assets/{mermaid.core-Bx5BMQp8.js → mermaid.core-bCTq7TEV.js} +5 -5
  53. package/out/renderer/assets/{mesh-page-DXuH0pWs.js → mesh-page-IaVtAjU1.js} +1 -1
  54. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-Cnp-gOUf.js → mindmap-definition-ALO5MXBD-Ddhl_xII.js} +1 -1
  55. package/out/renderer/assets/{mini-Cxcx9-Gz.js → mini-CwNeJTk5.js} +1 -1
  56. package/out/renderer/assets/{notebook-pen-pmBcBtK5.js → notebook-pen-BY9EwH-7.js} +1 -1
  57. package/out/renderer/assets/{org-access-BBS-iiGY.js → org-access-c2-UvVYd.js} +1 -1
  58. package/out/renderer/assets/{org-surface-gate-B9JbfoNw.js → org-surface-gate-B-MS3UYv.js} +1 -1
  59. package/out/renderer/assets/{page-header-D3rux4P9.js → page-header-CD8VERYn.js} +1 -1
  60. package/out/renderer/assets/{pieDiagram-IB7DONF6-BXGlHMJD.js → pieDiagram-IB7DONF6-STqRBD1R.js} +1 -1
  61. package/out/renderer/assets/projects-page-EY7aplWJ.js +45 -0
  62. package/out/renderer/assets/{publication-validation-Dent7Wyb.js → publication-validation-cVu_vGjF.js} +1 -1
  63. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-DTE1LofJ.js → quadrantDiagram-7GDLP6J5-D93w-jxI.js} +1 -1
  64. package/out/renderer/assets/{radar-MK3ICKWK-C5aiTbpi.js → radar-MK3ICKWK-Dh3CwqLm.js} +1 -1
  65. package/out/renderer/assets/{radient-auth-buttons-CD4FRlt9.js → radient-auth-buttons-BuUoxJkL.js} +1 -1
  66. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-B-kbiFxO.js → requirementDiagram-KVF5MWMF-pKCmrqyl.js} +1 -1
  67. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-8mSg8Gx1.js → sankeyDiagram-QLVOVGJD-Dv2syjv2.js} +1 -1
  68. package/out/renderer/assets/{schedules-page-M0NGG3zh.js → schedules-page-DJ7BtTi7.js} +1 -1
  69. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-Ctz7PqiC.js → sequenceDiagram-X6HHIX6F-D14uGazi.js} +1 -1
  70. package/out/renderer/assets/{settings-page-Cy2SAtSh.js → settings-page-BPkUfxJX.js} +7 -7
  71. package/out/renderer/assets/smartart-uE0Bdv7c.js +1 -0
  72. package/out/renderer/assets/{stateDiagram-DGXRK772-x8oSqtIw.js → stateDiagram-DGXRK772-CTKP8UrZ.js} +1 -1
  73. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-C1y1no_O.js +1 -0
  74. package/out/renderer/assets/team-bridge-page-ClnOkizZ.js +11 -0
  75. package/out/renderer/assets/{timeline-definition-BDJGKUSR-DZ5836tF.js → timeline-definition-BDJGKUSR-bs2AK5mP.js} +1 -1
  76. package/out/renderer/assets/ui-preferences-store-B5lixHt9.js +1 -0
  77. package/out/renderer/assets/{use-download-agent-mutation-Bgwi0JGB.js → use-download-agent-mutation-B3IkEPEZ.js} +3 -3
  78. package/out/renderer/assets/{use-session-snapshot-DQs7iPEs.js → use-session-snapshot-BKx6oLGB.js} +1 -1
  79. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-CQNe5VvP.js → xychartDiagram-VJFVF3MP-B8vPLffn.js} +1 -1
  80. package/out/renderer/console-capture.html +5 -5
  81. package/out/renderer/index.html +7 -7
  82. package/out/renderer/installer.html +4 -4
  83. package/out/renderer/mini.html +7 -7
  84. package/package.json +3 -2
  85. package/out/renderer/assets/browser-page-Bm5bblrV.js +0 -1
  86. package/out/renderer/assets/channel-BJPW3C83.js +0 -1
  87. package/out/renderer/assets/classDiagram-GIVACNV2-BjlJ_E71.js +0 -1
  88. package/out/renderer/assets/classDiagram-v2-COTLJTTW-BjlJ_E71.js +0 -1
  89. package/out/renderer/assets/clone-BuzQaJVT.js +0 -1
  90. package/out/renderer/assets/index-BSn66J9q.js +0 -57
  91. package/out/renderer/assets/index-BzHpKJoz.css +0 -1
  92. package/out/renderer/assets/index-U5qrTe4P.js +0 -824
  93. package/out/renderer/assets/legacy-agents-page-CiirOdbB.js +0 -33
  94. package/out/renderer/assets/library-page-CH3E7s4_.js +0 -157
  95. package/out/renderer/assets/projects-page-DjaYWghP.js +0 -40
  96. package/out/renderer/assets/smartart-DmOeXeJs.js +0 -1
  97. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CUVgaWvm.js +0 -1
  98. package/out/renderer/assets/tags-input-chips-BAP2XNbQ.js +0 -1
  99. package/out/renderer/assets/team-bridge-page-CYehSZqj.js +0 -11
  100. package/out/renderer/assets/ui-preferences-store-oc99NgQT.js +0 -1
@@ -1,40 +0,0 @@
1
- import{t as n,d as Fe,j as t,c as M,r as d}from"./index-BSn66J9q.js";import{$ as ls,aO as qe,d as fe,c8 as kn,a0 as us,u as wn,cr as V,cs as yt,ct as Nn,V as Rt,cu as Ds,cv as As,cw as Os,bT as Sn,aP as be,cx as Cn,a as Ze,c as ye,aI as fr,aR as Dt,a1 as dt,aV as He,cy as En,cb as Tn,cn as Rn,cz as Dn,co as An,aX as jr,aW as vt,bx as On,az as Pn,ap as kt,bF as Mn,bL as In,bK as Ln,bI as Ps,cq as Fn,cd as hr,ca as qn,cc as Un,a2 as de,cA as Bn,cB as $n,cC as zn,cD as Gn,cE as Yn,cF as gr,aQ as Hn,ao as Wn,aj as Kn,ak as Vn,am as Xn,an as Jn,aq as Qn,aw as Zn,cG as ea,cH as xr,bO as ta,cI as sa,ay as ra,aS as na,b7 as aa}from"./conversation-input-sync-qFePp_gf.js";import{c as At,u as F,K as We,y as Ot,M as Ke,N as Ve,O as Xe,P as Ae,a as G,i as ds,j as ps,S as Te,k as ms,l as Ee,a9 as oa,aa as ia,ab as ca,o as la,p as ua,m as da,B as ke,a5 as _s,af as fs,a7 as js,I as ue,X as Pt,h as hs,T as br,L as pe,R as yr,C as vr,A as Ht,U as pa,a0 as ma,a1 as _a,a2 as fa,x as ze}from"./error-boundary-CIO9VaTx.js";import{P as Ms}from"./page-header-D3rux4P9.js";import{c6 as ja,bO as kr,c7 as ha,bW as wr,c8 as ga,bX as xa,by as ba,a as it,$ as Is,c9 as Ls,c5 as ya}from"./index-U5qrTe4P.js";import{h as va,j as ka,k as Je,l as wa,m as Wt}from"./ui-preferences-store-oc99NgQT.js";import{u as Na}from"./use-session-snapshot-DQs7iPEs.js";import{A as Nr}from"./arrow-up-BD8jieeb.js";import"./console-mirror-wrjuOlK5.js";/**
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 Sa=[["path",{d:"M4.2 4.2A2 2 0 0 0 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 1.82-1.18",key:"16swn3"}],["path",{d:"M21 15.5V6a2 2 0 0 0-2-2H9.5",key:"yhw86o"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h7",key:"1wap6i"}],["path",{d:"M21 10h-5.5",key:"quycpq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Ca=At("calendar-off",Sa);/**
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 Ea=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]],Ta=At("list-filter",Ea);/**
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 Ra=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M16 10h.01",key:"1m94wz"}]],Da=At("message-square-more",Ra);/**
17
- * @license lucide-react v0.507.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const Aa=[["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"}]],Oa=At("unlink",Aa),Mt={list:["desktop","projects"],detail:e=>["desktop","projects",e]};function Pa(e){return ls({queryKey:Mt.list,enabled:e,queryFn:()=>fe({op:"projects.list"}).then(s=>s.projects),retry:us,staleTime:1e4})}function Ma(e,s){return ja({queries:e.map(r=>({queryKey:Mt.detail(r),enabled:s&&!!r,queryFn:()=>fe({op:"projects.get",key:r}),retry:us,staleTime:1e4}))})}function Sr(e,s){return ls({queryKey:Mt.detail(e??""),enabled:s&&!!e,queryFn:()=>fe({op:"projects.get",key:e??""}),retry:us,staleTime:1e4})}function Ue(){const e=wn();return()=>{e.invalidateQueries({queryKey:Mt.list})}}function Ia(){const e=Ue();return qe({mutationFn:s=>fe({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 Cr(){const e=Ue();return qe({mutationFn:s=>fe({op:"projects.update",key:s.key,fields:s.fields,...s.forceDone===!0?{force_done:!0}:{}}),retry:kn,onSuccess:()=>e()})}function Er(){const e=Ue();return qe({mutationFn:s=>fe({op:"projects.delete",key:s.key,confirmed_name:s.confirmedName}),onSuccess:()=>e()})}function La(){const e=Ue();return qe({mutationFn:s=>fe({op:"projects.link",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function Fa(){const e=Ue();return qe({mutationFn:s=>fe({op:"projects.unlink",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function qa(){const e=Ue();return qe({mutationFn:s=>fe({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 Ua(){const e=Ue();return qe({mutationFn:s=>fe({op:"projects.milestone.remove",key:s.key,name:s.name}),onSuccess:()=>e()})}const Tr={planning:{get label(){return n("ui.projects.project_model.planning")},variant:"info"},active:{get label(){return n("ui.projects.project_model.active")},variant:"accent"},qa:{get label(){return n("ui.projects.project_model.qa")},variant:"attention"},validation:{get label(){return n("ui.projects.project_model.validation")},variant:"warning"},done:{get label(){return n("ui.projects.project_model.done")},variant:"success"},paused:{get label(){return n("ui.projects.project_model.paused")},variant:"neutral"},archived:{get label(){return n("ui.projects.project_model.archived")},variant:"outline"}},Ge=Object.keys(Tr);function ae(e){return Tr[e]??{label:e||n("ui.projects.project_model.unknown"),variant:"neutral"}}const Rr=["planning","active","qa","validation","done","paused","archived"].map(e=>({value:e,label:ae(e).label}));function Ba(e){return e==="done"}const $a={completed:{get label(){return n("ui.projects.project_model.completed")},variant:"success"},overdue:{get label(){return n("ui.projects.project_model.overdue")},variant:"warning"},upcoming:{get label(){return n("ui.projects.project_model.upcoming")},variant:"neutral"}};function za(e){return $a[e]??{label:String(e),variant:"neutral"}}Fe["ui.projects.project_model.stale"];const Ga=/^(\d{4})-(\d{2})-(\d{2})$/;function Oe(e,s,r=new Date){if(!e)return"";const a=Ga.exec(e);if(!a)return e;const o=new Date(Number(a[1]),Number(a[2])-1,Number(a[3]));if(Number.isNaN(o.getTime()))return e;const i=yt(o,{month:"short",day:"numeric"},s);return o.getFullYear()===r.getFullYear()?i:yt(o,{month:"short",day:"numeric",year:"numeric"},s)}function pt(e,s){if(e==null)return"";const r=Math.max(0,Math.floor(s/1e3-e));return r<60?n("ui.projects.project_model.just_now"):r<3600?`${V(Math.floor(r/60),{useGrouping:!1})}m`:r<86400?`${V(Math.floor(r/3600),{useGrouping:!1})}h`:`${V(Math.floor(r/86400),{useGrouping:!1})}d`}function mt(e){return e===n("ui.projects.project_model.just_now")?n("ui.projects.project_model.just_now"):n("ui.projects.project_model.age_ago",{age:String(e)})}function Ya(e){return e?n("ui.projects.project_model.reported_progressagephrase_age",{progressAgePhrase_age:String(mt(e))}):n("ui.projects.project_model.no_progress")}const Dr=/^$|^\d{4}-\d{2}-\d{2}$/;function Ar(e){return e?e==="operator"?n("ui.projects.project_model.the_operator"):n("ui.projects.project_model.session_reportedby",{reportedBy:String(e)}):""}function Ha(e,s){if(!e.progress)return n("ui.projects.project_model.not_reported_yet");const r=pt(e.progress_updated_at,s),a=Ar(e.progress_reported_by),o=[r?n("ui.projects.project_model.reported_progressagephrase_age",{progressAgePhrase_age:String(mt(r))}):"reported"];return a&&o.push(n("ui.projects.project_model.by_reporter",{reporter:String(a)})),o.join(" ")}function Or(e,s){if(e==null)return"";const r=V(e,{useGrouping:!1,maximumFractionDigits:20});return s==="points"?n("ui.projects.project_model.value_pt",{value:String(r)}):s==="days"?n("ui.projects.project_model.value_d",{value:String(r)}):r}function Pr(e,s){return s<=0?"":n("ui.projects.project_model.completed_total",{completed:V(e,{useGrouping:!1}),total:V(s,{useGrouping:!1})})}function gs(e){return e<=0?"":n("ui.projects.project_model.live_live",{live:e})}function Wa(e){return e<=0?"":n("ui.projects.count.session",{count:e})}function Ka(e){return n("ui.projects.count.project",{count:e})}function Va(e){const s=Wa(e.sessions);if(!s)return"";const r=gs(e.live_sessions);return r?n("ui.projects.project_model.count_live",{count:String(s),live:String(r)}):s}function Xa(e){if(!e.exists)return{get label(){return n("ui.projects.project_model.missing")},variant:"outline"};if(e.archived)return{get label(){return n("ui.projects.project_model.archived")},variant:"neutral"};switch(e.runtime?.state){case"live":return{get label(){return n("ui.projects.project_model.live")},variant:"success"};case"wedged":return{get label(){return n("ui.projects.project_model.wedged")},variant:"warning"};case"stale":return{get label(){return n("ui.projects.project_model.stale")},variant:"warning"};case"stopped":return{get label(){return n("ui.projects.project_model.stopped")},variant:"neutral"};default:return{label:String(e.runtime?.state??n("ui.projects.project_model.unknown")),variant:"neutral"}}}function Ja(e){return e?e.running>0?n("ui.projects.count.subagent_running",{count:e.running}):n("ui.projects.count.subagent",{count:e.settled}):""}function Qa(e){return e?n("ui.projects.count.todo",{count:e.total}):""}function Mr(e,s){const r=[],a=Oe(e.completed_at??e.target_date,s);a&&r.push({key:e.completed_at?"completed":"target",text:e.completed_at?n("ui.projects.project_model.completed_day",{day:String(a)}):n("ui.projects.project_model.due_day",{day:String(a)})});const o=Or(e.estimate,e.estimate_unit);o&&r.push({key:"estimate",text:o});const i=Pr(e.milestones_completed,e.milestones_total);i&&r.push({key:"milestones",text:n("ui.projects.project_model.milestones_milestones",{milestones:String(i)})});const l=gs(e.live_sessions);return l&&r.push({key:"live",text:l}),r}const Ye=864e5,Za=/^(\d{4})-(\d{2})-(\d{2})$/;function ve(e){if(!e)return null;const s=Za.exec(e);if(!s)return null;const r=Number(s[1]),a=Number(s[2]),o=Number(s[3]),i=Date.UTC(r,a-1,o),l=new Date(i);return l.getUTCFullYear()!==r||l.getUTCMonth()!==a-1||l.getUTCDate()!==o?null:i}const Kt=["planning","active","qa","validation","done"],Vt=["paused","archived"],It=[{value:"24h",get label(){return n("ui.projects.project_model.last_24_hours")},get phrase(){return n("ui.projects.project_model.the_last_24_hours")},seconds:86400},{value:"7d",get label(){return n("ui.projects.project_model.last_7_days")},get phrase(){return n("ui.projects.project_model.the_last_7_days")},seconds:604800},{value:"30d",get label(){return n("ui.projects.project_model.last_30_days")},get phrase(){return n("ui.projects.project_model.the_last_30_days")},seconds:2592e3},{value:"90d",get label(){return n("ui.projects.project_model.last_90_days")},get phrase(){return n("ui.projects.project_model.the_last_90_days")},seconds:7776e3},{value:"all",get label(){return n("ui.projects.project_model.all_time")},phrase:null,seconds:null}],Ir="7d",eo=It.find(e=>e.value===Ir);function Lr(e){return It.find(s=>s.value===e)??eo}function to(e){return It.some(s=>s.value===e)}function Fs(e,s,r){const a=Lr(s);return a.seconds===null?e:e.filter(o=>r/1e3-o.updated_at<=a.seconds)}function so(e){const s=Lr(e);return s.seconds===null?null:n("ui.projects.project_model.nothing_changed_in_phrase",{phrase:String(s.phrase)})}const Fr="projects-board-window";function ro(){try{const e=localStorage.getItem(Fr);if(e!==null&&to(e))return e}catch{}return Ir}function qs(e){try{localStorage.setItem(Fr,e)}catch{}}const qr="projects-board-column-order";let Xt=null;function no(){if(Xt)return[...Xt];try{const e=localStorage.getItem(qr);if(!e)return[];const s=JSON.parse(e);if(!Array.isArray(s))return[];const r=[];for(const a of s){if(typeof a!="string"||a.length===0)return[];r.includes(a)||r.push(a)}return r}catch{return[]}}function ao(e){Xt=[...e];try{localStorage.setItem(qr,JSON.stringify(e))}catch{}}function oo(e,s,r){const a=e.filter(i=>i!==s),o=Math.max(0,Math.min(r,a.length));return a.splice(o,0,s),a}function io(e,s=[]){const r=new Map;for(const c of e){const u=r.get(c.status)??[];u.push(c),r.set(c.status,u)}const a=Kt.map(c=>({status:c,projects:r.get(c)??[]}));for(const c of Vt){const u=r.get(c)??[];u.length>0&&a.push({status:c,projects:u})}for(const[c,u]of r)!Vt.includes(c)&&!Kt.includes(c)&&a.push({status:c,projects:u});if(s.length===0)return a;const o=new Map(s.map((c,u)=>[c,u])),i=a.filter(c=>o.has(c.status));i.sort((c,u)=>(o.get(c.status)??0)-(o.get(u.status)??0));const l=a.filter(c=>!o.has(c.status));return[...i,...l]}function Ur(e,s){if(e.status==="done"||e.status==="archived"||e.completed_at)return!1;const r=ve(e.target_date);return r===null?!1:r<s}function ne(e){return e.title||e.name}Fe["ui.projects.project_model.no_team"];function _t(e){const s=e.team?.trim();if(s)return s;const r=e.owner?.trim();return r||null}function xs(e,s){const r=new Map,a=[];for(const i of e){const l=s(i);if(l===null){a.push(i);continue}const c=r.get(l);c?c.push(i):r.set(l,[i])}const o=[...r.entries()].sort(([i],[l])=>i.localeCompare(l,void 0,{sensitivity:"base"})).map(([i,l])=>({team:i,items:l}));return a.length>0&&o.push({team:null,items:a}),o}function Lt(e){return e.title||e.session_id}function co(e){return[...e].reverse()}function lo(e){return e<=0?"":n("ui.projects.count.update",{count:e})}const Us=e=>String(e).padStart(2,"0");function Jt(e){return`${e.getFullYear()}-${Us(e.getMonth()+1)}-${Us(e.getDate())}`}function uo(e){const s=Date.parse(e);return Number.isNaN(s)?"":Jt(new Date(s))}function po(e,s,r=new Date){if(!e)return"";if(e===Jt(r))return n("ui.projects.project_model.today");const a=new Date(r.getFullYear(),r.getMonth(),r.getDate()-1);return e===Jt(a)?n("ui.projects.project_model.yesterday"):Oe(e,s,r)}function mo(e,s){const r=Date.parse(e);return Number.isNaN(r)?"":Nn(new Date(r),{hour:"numeric",minute:"2-digit"},s)}function _o(e,s){const r=Date.parse(e);return Number.isNaN(r)?"":mt(pt(r/1e3,s))}function fo(e,s,r=Date.now()){const a=[],o=Ar(e.by);o&&a.push({key:"author",text:o});const i=mo(e.at,s);i&&a.push({key:"time",text:i});const l=_o(e.at,r);return l&&a.push({key:"age",text:l}),a}function jo(e,s,r=new Date){const a=[];for(const o of co(e)){const i=uo(o.at),l=a[a.length-1];if(l&&l.key===i){l.entries.push(o);continue}a.push({key:i,label:po(i,s,r),entries:[o]})}return a}function ho(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 go(e,s){return s<=0?"":`${e} of ${s} complete`}function xo(e){let s=0,r=0,a=!1;for(const o of e)o.todos&&(a=!0,s+=o.todos.open,r+=o.todos.total);return a?{open:s,total:r}:null}function Bs(e){return`${e.open} open of ${e.total}`}function bo(e){const s=e.filter(a=>a.exists);return(s.find(a=>a.runtime?.state==="live")??s[0])?.session_id??null}function yo(e){const s=ne(e),r=e.progress.trim()||"not reported yet";return[`Continue work on project "${s}" (${e.name}).`,`Latest progress: ${r}`,"Review the project details and continue or complete the work."].join(`
22
- `)}function vo(e){return e?e.kind==="team"?n("ui.projects.project_model.team_name",{name:String(e.name)}):n("ui.projects.project_model.agent_name",{name:String(e.name)}):""}const ko=/'((?:[^'\\]|\\.)*)'|"((?:[^"\\]|\\.)*)"/g;function Br(e){const s=[];for(const r of e.matchAll(ko))s.push((r[1]??r[2]??"").replace(/\\(.)/g,"$1"));return s}const bt=3;function bs(e){if(e.length<=bt+1)return e.length<=1?e.join(""):n("ui.projects.project_model.join_and_length_1",{join:String(e.slice(0,-1).join(", ")),length___1:String(e[e.length-1])});const s=e.length-bt;return n("ui.projects.project_model.join_and_hidden_more",{join:String(e.slice(0,bt).join(", ")),hidden:V(s,{useGrouping:!1})})}function ys(e){return n("ui.projects.count.milestones_are",{count:e})}const $s="complete them, or pass force_done=true to close with them open",wo="complete or remove the incomplete milestones, then mark it done",$r=/^cannot set status 'done': (\d+) milestones? still incomplete \((.+)\) — /;function ft(e){const s=e.match($r);if(s){const r=Number(s[1]),a=Br(s[2]),o=a.length>0?bs(a):s[2];return n("ui.projects.project_model.this_can_t_be_marked_done_yet_milestonesare_count_still_incomplet",{milestonesAre_count:String(ys(r)),clause:String(o)})}return e.includes($s)?e.replace($s,wo):e}const No="project_done_incomplete";function So(e){const s=e.message.match($r),r=e.code===No;if(!r&&!s)return null;const a=typeof e.detail=="object"&&e.detail!==null&&Array.isArray(e.detail.incomplete)?e.detail.incomplete.filter(l=>typeof l=="string"):null,o=a&&a.length>0?a:s?Br(s[2]):[];return{count:o.length>0?o.length:s?Number(s[1]):0,names:o,coded:r,message:e.message}}function Co(e){if(e.count>0){const s=bs(e.names);return n("ui.projects.project_model.count_still_open_clause_clause",{count:String(ys(e.count)),clause________clause:String(s?n("ui.projects.project_model.clause",{clause:String(s)}):"")})}return ft(e.message)||n("ui.projects.project_model.some_milestones_are_still_open")}function Eo(e){return e.count>0&&e.names.length>0?n("ui.projects.project_model.this_can_t_be_marked_done_yet_count_still_incomplete_names_comple",{count:String(ys(e.count)),names:String(bs(e.names))}):ft(e.message)||n("ui.projects.project_model.milestones_are_still_open_on_this_project_complete_or_remove_them")}function zr(e,s,r){if(!e||e.forced_done!==!0)return n("ui.projects.project_model.moved_to_statuslabel",{statusLabel:String(r)});const a=typeof e.milestones_total=="number"&&typeof e.milestones_completed=="number"?e.milestones_total-e.milestones_completed:s,o=a>0?a:s;return n("ui.projects.count.moved_open",{status:r,open:o})}Fe["ui.projects.project_model.the_project_was_not_moved_try_again_or_open_it_to_change_its_stat"];function Gr(e){return e.trim().slice(0,va)}const To={get client(){return n("ui.projects.project_search.searches_names_descriptions_tags_owners_and_teams_update_text_is")},get backend(){return n("ui.projects.project_search.searches_names_descriptions_tags_owners_teams_and_update_text_cle")}},Ro=2,Do=4,Ao=3,Oo=2,Po=1,Mo=3,Me={title:3,name:2.5,description:2,tags:1.5,attribution:1.5,status:1},Io=/[^\p{L}\p{N}]+/u,Lo=/\s+/;function zs(e,s){const r=s.trim().toLowerCase();if(!r)return 0;if(r===e)return Do;if(r.startsWith(e))return Ao;const a=r.split(Io).filter(Boolean),o=e.split(Lo).filter(Boolean);if(o.length>0&&o.every(l=>a.some(c=>c.startsWith(l))))return Oo;const i=o.join("");return i.length>=Mo&&Fo(i,r)?Po:0}function Fo(e,s){let r=0;for(const a of e){if(r=s.indexOf(a,r),r<0)return!1;r+=1}return!0}function qo(e,s){const r=s.trim().toLowerCase();if(!r)return 0;const a=[[e.title,Me.title],[e.name,Me.name],[e.description,Me.description],[e.owner,Me.attribution],[e.team,Me.attribution],[e.status,Me.status]];let o=0;for(const[i,l]of a){if(!i)continue;const c=zs(r,i)*l;c>o&&(o=c)}for(const i of e.tags){const l=zs(r,i)*Me.tags;l>o&&(o=l)}return o}function Uo(e,s){const r=s.trim();if(!r)return e;const a=[];for(const o of e){const i=qo(o,r);i>0&&a.push({project:o,score:i})}return a.sort((o,i)=>{if(o.score!==i.score)return i.score-o.score;if(o.project.updated_at!==i.project.updated_at)return i.project.updated_at-o.project.updated_at;const l=ne(o.project).localeCompare(ne(i.project),void 0,{sensitivity:"base"});if(l!==0)return l;const c=o.project.name.localeCompare(i.project.name,void 0,{sensitivity:"base"});return c!==0?c:o.project.id<i.project.id?-1:o.project.id>i.project.id?1:0}),a.map(o=>o.project)}function Bo(e,s){if(s.length===0)return[];const r=new Map(e.map(o=>[o.id,o])),a=[];for(const o of s){const i=r.get(o.id);i!==void 0&&a.push(i)}return a}const $o=180;function zo(e,s){const r=Gr(e),a=kr(r,$o),o=ls({queryKey:["desktop","projects","search",a],enabled:s&&a.length>0,queryFn:()=>fe({op:"projects.search",q:a,limit:ka}),retry:!1,staleTime:3e4}),i=a===r,l=i&&o.data&&o.data.query===r?o.data:null,c=i&&r.length>0&&!l&&o.isError;return{answer:l,pending:s&&r.length>0&&!l&&!c}}const et=["status","team","owner","tags","progress","target","estimate","milestones","live"],Gs={status:[],team:[],owner:[],tags:[],progress:[],target:[],estimate:[],milestones:[],live:[]},ot={get status(){return n("ui.projects.project_filters.status")},get team(){return n("ui.projects.project_filters.team")},get owner(){return n("ui.projects.project_filters.owner")},get tags(){return n("ui.projects.project_filters.tags")},get progress(){return n("ui.projects.project_filters.progress")},get target(){return n("ui.projects.project_filters.target_date")},get estimate(){return n("ui.projects.project_filters.estimate")},get milestones(){return n("ui.projects.project_filters.milestones")},get live(){return n("ui.projects.project_filters.live_sessions")}},Go=new Set(["status","progress","target","estimate","milestones","live"]),Yo={progress:["stale","up-to-date","not-reported"],target:["none","overdue","within-7","within-30"],estimate:["none","points","days"],milestones:["none","incomplete","complete"],live:["has-live","no-live"]},Ho={get stale(){return n("ui.projects.project_filters.stale")},get"up-to-date"(){return n("ui.projects.project_filters.up_to_date")},get"not-reported"(){return n("ui.projects.project_filters.not_reported")},get none(){return n("ui.projects.project_filters.no_target_date")},get overdue(){return n("ui.projects.project_filters.overdue")},get"within-7"(){return n("ui.projects.project_filters.due_within_7_days")},get"within-30"(){return n("ui.projects.project_filters.due_within_30_days")},get points(){return n("ui.projects.project_filters.points")},get days(){return n("ui.projects.project_filters.days")},get incomplete(){return n("ui.projects.project_filters.incomplete")},get complete(){return n("ui.projects.project_filters.complete")},get"has-live"(){return n("ui.projects.project_filters.has_live_sessions")},get"no-live"(){return n("ui.projects.project_filters.no_live_sessions")}};function Yr(e,s){switch(e){case"status":return ae(s).label;case"team":return s===null?n("ui.projects.project_filters.no_team"):s;case"owner":return s===null?n("ui.projects.project_filters.no_owner"):s;case"tags":return s??"";case"estimate":if(s==="none")return n("ui.projects.project_filters.no_estimate");break;case"milestones":if(s==="none")return n("ui.projects.project_filters.none_set");break;case"target":if(s==="none")return n("ui.projects.project_filters.no_target_date");break}return Ho[s]??s??""}function Wo(e,s){return e[s].length>0}function ct(e){return et.every(s=>!Wo(e,s))}function Ko(e){return et.reduce((s,r)=>s+e[r].length,0)}function Hr(e,s,r){const a=e[s],o=a.includes(r)?a.filter(i=>i!==r):[...a,r];return{...e,[s]:o}}function Wr(e,s,r,a){switch(e){case"status":return s.status===r;case"team":return _t(s)===r;case"owner":return(s.owner?.trim()||null)===r;case"tags":return s.tags.includes(r??"");case"progress":return r==="stale"?s.progress_stale===!0:r==="up-to-date"?s.progress_stale===!1:s.progress_updated_at===null;case"target":{if(r==="none")return ve(s.target_date)===null;if(r==="overdue")return Ur(s,a);const o=ve(s.target_date);if(o===null)return!1;const i=(o-a)/Ye;return r==="within-7"?i>=0&&i<=7:i>=0&&i<=30}case"estimate":return r==="none"?s.estimate===null:s.estimate===null?!1:r==="points"?s.estimate_unit==="points":s.estimate_unit==="days";case"milestones":return r==="none"?s.milestones_total===0:s.milestones_total===0?!1:r==="complete"?s.milestones_completed>=s.milestones_total:s.milestones_completed<s.milestones_total;case"live":return r==="has-live"?s.live_sessions>0:s.live_sessions===0}}function Kr(e,s,r,a){const o=e[s];return o.length===0?!0:o.some(i=>Wr(s,r,i,a))}function Vo(e,s,r){return ct(s)?e:e.filter(a=>et.every(o=>Kr(s,o,a,r)))}function Xo(e,s,r,a){return s.filter(o=>et.every(i=>i===e||Kr(r,i,o,a)))}function Jo(e,s,r){const a=r[e];switch(e){case"status":{const i=[...new Set(s.map(c=>c.status))].filter(c=>!Ge.includes(c)).sort((c,u)=>c.localeCompare(u,void 0,{sensitivity:"base"})),l=a.filter(c=>typeof c=="string"&&!Ge.includes(c)&&!i.includes(c));return[...Ge,...i,...l]}case"team":{const o=new Set;let i=!1;for(const c of s){const u=_t(c);u===null?i=!0:o.add(u)}for(const c of a)c===null?i=!0:o.add(c);const l=[...o].sort((c,u)=>c.localeCompare(u,void 0,{sensitivity:"base"}));return i?[...l,null]:l}case"owner":{const o=new Set;let i=!1;for(const c of s){const u=c.owner?.trim();u?o.add(u):i=!0}for(const c of a)c===null?i=!0:o.add(c);const l=[...o].sort((c,u)=>c.localeCompare(u,void 0,{sensitivity:"base"}));return i?[...l,null]:l}case"tags":{const o=new Set;for(const i of s)for(const l of i.tags)o.add(l);for(const i of a)o.add(i??"");return[...o].sort((i,l)=>i.localeCompare(l,void 0,{sensitivity:"base"}))}case"progress":case"target":case"estimate":case"milestones":case"live":return Yo[e]}}function Vr(e,s,r,a){const o=Xo(e,s,r,a),i=Go.has(e),l=[];for(const c of Jo(e,o,r)){const u=r[e].includes(c),m=o.reduce((p,f)=>p+(Wr(e,f,c,a)?1:0),0);!i&&m===0&&!u||l.push({value:c,label:Yr(e,c),count:m,selected:u})}return{facet:e,label:ot[e],options:l}}function Qo(e,s,r){return et.map(a=>Vr(a,e,s,r))}const Qt="projects-sort";Fe["ui.projects.project_sort.default_as_listed"];function Zo(e){return ei.includes(e)}const ei=["name","status","target","estimate","milestones","live","progress"];function ti(){try{const e=localStorage.getItem(Qt);if(e===null)return null;const[s,r,...a]=e.split(":");if(a.length>0)return null;if(s&&Zo(s)&&(r==="asc"||r==="desc"))return{key:s,direction:r}}catch{}return null}function si(e){try{e===null?localStorage.removeItem(Qt):localStorage.setItem(Qt,`${e.key}:${e.direction}`)}catch{}}function Qe(e){switch(e){case"name":return n("ui.projects.project_sort.project");case"status":return n("ui.projects.project_sort.status");case"target":return n("ui.projects.project_sort.target");case"estimate":return n("ui.projects.project_sort.estimate");case"milestones":return n("ui.projects.project_sort.milestones");case"live":return n("ui.projects.project_sort.live");case"progress":return n("ui.projects.project_sort.progress")}}function Bt(e){return e==="target"||e==="progress"?"desc":"asc"}function vs(e,s){const r=s==="desc";switch(e){case"name":return r?n("ui.projects.project_sort.z_to_a"):n("ui.projects.project_sort.a_to_z");case"status":return r?n("ui.projects.project_sort.archived_first"):n("ui.projects.project_sort.planning_first");case"target":return r?n("ui.projects.project_sort.latest_first"):n("ui.projects.project_sort.soonest_first");case"estimate":return r?n("ui.projects.project_sort.days_first"):n("ui.projects.project_sort.points_first");case"milestones":return r?n("ui.projects.project_sort.most_complete_first"):n("ui.projects.project_sort.least_complete_first");case"live":return r?n("ui.projects.project_sort.most_first"):n("ui.projects.project_sort.fewest_first");case"progress":return r?n("ui.projects.project_sort.most_recent_first"):n("ui.projects.project_sort.most_stale_first")}}function ri(e){return e===null?n("ui.projects.project_sort.sort_cleared"):n("ui.projects.project_sort.sorted_by_key_direction",{key:String(Qe(e.key)),direction:String(vs(e.key,e.direction))})}function ni(e){const s=[e.search?"search":null,e.filters?"filters":null,e.sort?"sort":null].filter(a=>a!==null);if(s.length===0)return"";const r=s.length===1?n("ui.projects.project_sort.parts_0_cleared",{parts_0:String(s[0])}):n("ui.projects.project_sort.join_and_length_1_cleared",{join:String(s.slice(0,-1).join(", ")),length___1:String(s[s.length-1])});return r.charAt(0).toUpperCase()+r.slice(1)}function Ys(e,s){switch(e){case"name":return 0;case"status":return Ge.includes(s.status)?0:1;case"target":return Zt(s)===null?1:0;case"estimate":return s.estimate===null?1:0;case"milestones":return s.milestones_total===0?1:0;case"live":return 0;case"progress":return s.progress_updated_at===null?1:0}}function Zt(e){return ve(e.completed_at??e.target_date)}function Hs(e){return e==="points"?0:e==="days"?1:2}function ai(e,s,r){switch(e){case"name":return ne(s).localeCompare(ne(r),void 0,{sensitivity:"base"});case"status":return Ge.indexOf(s.status)-Ge.indexOf(r.status);case"target":{const a=Zt(s)??0,o=Zt(r)??0;return a-o}case"estimate":{const a=Hs(s.estimate_unit)-Hs(r.estimate_unit);return a!==0?a:(s.estimate??0)-(r.estimate??0)}case"milestones":return s.milestones_completed*r.milestones_total-r.milestones_completed*s.milestones_total;case"live":return s.live_sessions-r.live_sessions;case"progress":return(s.progress_updated_at??0)-(r.progress_updated_at??0)}}function Ws(e,s){if(e.updated_at!==s.updated_at)return s.updated_at-e.updated_at;const r=ne(e).localeCompare(ne(s),void 0,{sensitivity:"base"});if(r!==0)return r;const a=e.name.localeCompare(s.name,void 0,{sensitivity:"base"});return a!==0?a:e.id<s.id?-1:e.id>s.id?1:0}function oi(e,s,r){const a=Ys(r.key,e),o=Ys(r.key,s);if(a!==o)return a-o;if(a===1)return Ws(e,s);const i=ai(r.key,e,s);return i!==0?r.direction==="desc"?-i:i:Ws(e,s)}function ii(e,s){return[...e].sort((r,a)=>oi(r,a,s))}const De=["day","week","month","quarter"],ks={day:24,week:9,month:3,quarter:1};function ws(e){const s=new Date(e);return Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())}function Ie(e,s){return Math.round((s-e)/Ye)}function Ks(e,s){return Ie(e,s)+1}function ci(e,s){for(const r of De)if(e*ks[r]<=s)return r;return De[De.length-1]}function li(e){const{project:s}=e;return s.start_date||s.target_date||s.completed_at?!0:e.milestones.some(r=>!!r.target_date)}function ui(e,s){const r=[s];for(const a of e){for(const o of[a.project.start_date,a.project.target_date,a.project.completed_at]){const i=ve(o);i!==null&&r.push(i)}for(const o of a.milestones){const i=ve(o.target_date);i!==null&&r.push(i)}}return r.length===1?null:{startMs:Math.min(...r),endMs:Math.max(...r)}}function di(e){const s=[],r=[];for(const a of e)(li(a)?s:r).push(a);return{dated:s,undated:r}}function pi(e){return n("ui.projects.count.undated",{count:e})}function mi(e){const{project:s}=e,r=ve(s.start_date),a=ve(s.target_date),o=ve(s.completed_at),i=s.status==="done"&&o!==null?o:a,l=r??i,c=i??r;return l===null||c===null?null:{fromMs:Math.min(l,c),toMs:Math.max(l,c)}}function _i(e){const s=[];for(const r of e.milestones){const a=ve(r.target_date);a!==null&&s.push({name:r.name,dayMs:a,status:r.status})}return s}const $t=e=>yt(new Date(e),{month:"short",timeZone:"UTC"});function he(e){const s=new Date(e);return{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),weekday:s.getUTCDay()}}function fi(e){const{year:s,month:r}=he(e);return Date.UTC(s,r-1,1)}function ji(e){const{year:s,month:r}=he(e);return r===12?Date.UTC(s+1,0,1):Date.UTC(s,r,1)}function hi(e){const{year:s,month:r}=he(e);return Date.UTC(s,Math.floor((r-1)/3)*3,1)}function gi(e){const{year:s,month:r}=he(e),a=Math.floor((r-1)/3);return a===3?Date.UTC(s+1,0,1):Date.UTC(s,a*3+3,1)}function xi(e){const{weekday:s}=he(e);return e-(s+6)%7*Ye}const bi=26;function yi(e,s,r){const a=[],o=(p,f,g)=>{p<e||p>s||a.push({dayMs:p,label:f,major:g})};if(r==="day"){let p=!1;for(let f=e;f<=s;f+=Ye){const{day:g}=he(f);g===1?(o(f,$t(f),!0),p=!0):p?(o(f,"",!1),p=!1):o(f,V(g,{useGrouping:!1}),!1)}return a}if(r==="week"){for(let p=xi(e);p<=s;p+=7*Ye){if(p<e)continue;const{day:f,month:g}=he(p);he(p-7*Ye).month!==g?o(p,yt(new Date(p),{month:"short",day:"numeric",timeZone:"UTC"}),!0):o(p,V(f,{useGrouping:!1}),!1)}return a}const i=r==="month"?fi:hi,l=r==="month"?ji:gi,c=p=>{const{year:f,month:g}=he(p);if(r==="month")return g===1&&f!==he(e).year?`${$t(p)} '${V(f%100,{minimumIntegerDigits:2,useGrouping:!1})}`:$t(p);const _=Math.floor((g-1)/3)+1;return _===1&&f!==he(e).year?`Q1 '${String(f%100).padStart(2,"0")}`:`Q${_}`};o(e,c(i(e)),!0);const u=Math.ceil(bi/ks[r]);let m=e;for(let p=l(i(e));p<=s;p=l(p))Ie(m,p)<u||(o(p,c(p),!0),m=p);return a}function lt(e){return e.split(",").map(s=>s.trim()).filter(s=>s.length>0)}const wt=80,Nt=80,Vs=64,Xs=8;function es(e){return e.trim().length>wt?n("ui.projects.project_edit_model.titles_are_at_most_value1_characters",{value1:wt}):null}function Xr(e){return e.length>Je?n("ui.projects.project_edit_model.keep_the_description_within_value1_characters",{value1:Je}):null}function St(e,s){return e.trim().length>Nt?n("ui.projects.project_edit_model.teams_are_at_most_value2_characters",{teams:String(s==="owner"?n("ui.projects.project_edit_model.owners"):n("ui.projects.project_edit_model.teams")),value2:Nt}):null}function ts(e){return Dr.test(e)?null:n("ui.projects.project_edit_model.dates_are_yyyy_mm_dd_or_empty")}function ss(e,s){return e&&s&&s<e?n("ui.projects.project_edit_model.the_target_date_is_before_the_start_date"):null}function Jr(e){const s=e.trim();if(s==="")return null;const r=Number(s);return!Number.isFinite(r)||!(r>0)||r>1e3?n("ui.projects.project_edit_model.estimates_are_greater_than_0_and_at_most_1000"):null}function rs(e){const s=lt(e);if(s.length>Xs)return{tags:s,error:n("ui.projects.project_edit_model.up_to_project_tags_max_tags",{PROJECT_TAGS_MAX:Xs})};for(const r of s){const a=wa(r);if(a)return{tags:s,error:a}}return{tags:s,error:null}}const vi="project_name_exists";function Js(e){return e.code===vi?n("ui.projects.project_edit_model.a_project_with_this_key_already_exists"):ft(e.message)||n("ui.projects.project_edit_model.the_project_was_not_saved")}function ki(e,s){if(e.unit!==s.unit)return!1;const r=e.number.trim(),a=s.number.trim();return a===""?!0:r===""?!1:Number(r)===Number(a)}function wi(e,s){const r=lt(s);return r.length!==e.length?!1:r.every((a,o)=>a===e[o])}function Ni(e,s){const r={},a=s.number.trim();if(a!==""){const o=Number(a);(e.estimate===null||e.estimate!==o)&&(r.estimate=o)}return s.unit!==e.unit&&(r.estimate_unit=s.unit),Object.keys(r).length>0?r:null}function tt(e){return e instanceof Rt?Js({code:e.code,message:e.message}):Js({message:e instanceof Error?e.message:""})}function Qr(e){return e instanceof Rt&&(e.code==="project_not_found"||e.status===404)}function Zr(e){return!(e instanceof Error)||!e.message?n("ui.projects.project_model.the_project_was_not_moved_try_again_or_open_it_to_change_its_stat"):Qr(e)?n("ui.projects.project_refusals.this_project_could_not_be_found_it_may_have_been_deleted"):tt(e)}function en(e){if(!(e instanceof Error))return null;const s=e instanceof Rt?e:null;return So({code:s?.code??null,message:e.message,detail:s?.detail})}async function Si(e){try{return await e.move(),{kind:"accepted"}}catch(s){const r=en(s);return r?.coded&&e.forceDoneOffered&&e.claimQuestion()?{kind:"question",refusal:r}:{kind:"spoken",copy:r?Eo(r):Zr(s),refusal:r}}}Fe["ui.projects.board_window_select.shows_projects_last_updated_within_this_window_older_ones_are_hid"];const Ci=({value:e,onChange:s})=>(F(),t.jsxs(We,{value:e,onValueChange:r=>s(r),children:[t.jsx(Ot,{content:e==="all"?null:n("ui.projects.board_window_select.shows_projects_last_updated_within_this_window_older_ones_are_hid"),side:"bottom",disableHoverableContent:!0,children:t.jsx(Ke,{"aria-label":n("ui.projects.board_window_select.projects_updated_within"),className:M("w-36 shrink-0"),"data-tour-tag":"projects-board-window",children:t.jsx(Ve,{})})}),t.jsx(Xe,{children:It.map(r=>t.jsx(Ae,{value:r.value,children:r.label},r.value))})]})),ns=6e4,as=6e3;Fe["ui.projects.request_update.requesting_updates"];const Ei=400;Fe["ui.projects.request_update.ask_the_sessions_linked_to_this_project_to_post_a_progress_update"];const Ti="linked but not yet in use — it becomes a recipient after the first message",Qs=e=>`project-request-update-${e}`,Ri=e=>`project-request-cooldown-${e}`,Di=e=>`project-request-update-cooldown-${e}`,zt=e=>e.length===1?e[0]:e.length===2?n("ui.projects.request_update.names_0_and_names_1",{names_0:String(e[0]),names_1:String(e[1])}):n("ui.projects.request_update.names_0_names_1_and_length_2_more",{names_0:String(e[0]),names_1:String(e[1]),length___2:V(e.length-2,{useGrouping:!1})}),Zs=(e,s)=>e.sessions.filter(r=>r.outcome===s).map(r=>Lt({session_id:r.session_id,title:r.title})),Ai=e=>e.outcome==="failed"&&e.detail===Ti;function Ct(e,s){const r=Math.max(1,Math.ceil(s/1e3)),a=Math.max(0,Math.ceil(ns/1e3)-r);return n("ui.projects.request_update.update_already_requested_ago_s_ago_on_display_try_again_in_left_s",{ago:V(a,{useGrouping:!1}),display:String(e),left:V(r,{useGrouping:!1})})}function Oi(e){const s=ne({title:e.project.title,name:e.project.key}),{delivered:r,unconfirmed:a,failed:o,total:i}=e.counts;if(e.state==="empty")return{variant:"info",title:n("ui.projects.request_update.no_linked_sessions_to_ask_link_a_session_to_display_first",{display:String(s)}),duration:as};if(e.state==="cooldown")return{variant:"info",title:Ct(s,Math.max(0,e.cooldown_remaining_s??0)*1e3),duration:as};if(e.state!=="sent")return null;const l=Zs(e,"failed"),c=Zs(e,"unconfirmed");if(r>=1&&o===0&&a===0)return{variant:"success",title:n("ui.projects.request_update.delivered",{delivered:r,display:s})};if(r>=1){let u=n("ui.projects.request_update.requested_updates_from_delivered_of_total_sessions_on_display",{delivered:V(r,{useGrouping:!1}),total:i,display:String(s)});return o>0&&(u+=n("ui.projects.request_update.value1_could_not_be_reached",{value1:String(zt(l))})),a>0&&(u+=n("ui.projects.request_update.delivery_to_value1_could_not_be_confirmed",{value1:String(zt(c))})),{variant:"warning",title:u,duration:Number.POSITIVE_INFINITY}}if(o===0)return{variant:"warning",title:n("ui.projects.request_update.could_not_confirm_delivery_on_display_the_requests_may_still_reac",{display:String(s)}),duration:Number.POSITIVE_INFINITY};if(a===0){const u=e.sessions.every(Ai);let m;return u?m=n("ui.projects.request_update.never_started",{total:i}):m=n("ui.projects.request_update.could_not_reach_any_of_the_total_linked_sessions_on_display",{total:i,display:String(s)}),{variant:"error",title:m,duration:Number.POSITIVE_INFINITY}}return{variant:"warning",title:n("ui.projects.request_update.could_not_reach_failed_of_the_total_linked_sessions_on_display_de",{failed:V(o,{useGrouping:!1}),total:i,display:String(s),value4:String(zt(c))}),duration:Number.POSITIVE_INFINITY}}const at=new Map,Ns=new Set,Gt=new Map,os=new Set;let tn=0;const Et=()=>{tn+=1;for(const e of os)e()},Pi=e=>(os.add(e),()=>{os.delete(e)}),er=()=>tn,sn=e=>Ns.has(e),rn=e=>at.get(e);function Mi(e){Ns.add(e),Et()}function Ii(e){Ns.delete(e),Et()}function tr(e,s,r){const a=Date.now();if(r<=a)return;const o=at.get(e);if(o&&o.untilMs>=r)return;at.set(e,{startedMs:s,untilMs:r});const i=Gt.get(e);i&&clearTimeout(i);const l=setTimeout(()=>{Gt.delete(e);const c=at.get(e);c&&c.untilMs<=Date.now()&&(at.delete(e),Et())},r-a);l.unref?.(),Gt.set(e,l),Et()}const Li=e=>/[.!?…]$/.test(e)?e:`${e}.`;function Fi(e,s){const r=Date.now();if(s.state==="cooldown"){const a=Math.max(0,s.cooldown_remaining_s??0)*1e3;tr(e,r-(ns-a),r+a);return}s.state==="sent"&&(s.counts.delivered>=1||s.counts.unconfirmed>=1)&&tr(e,r,r+ns)}async function qi(e){const s=e.id;if(sn(s)){Ds(n("ui.projects.request_update.requesting_updates"),{id:Qs(s)});return}const r=Date.now(),a=rn(s);if(a&&a.untilMs>r){As(Ct(ne(e),a.untilMs-r),{id:Ri(s),duration:as});return}Mi(s);const o=Qs(s);let i=!1;const l=setTimeout(()=>{i=!0,Ds(n("ui.projects.request_update.requesting_updates"),{id:o})},Ei);try{const c=await fe({op:"projects.request_update",key:s});Fi(s,c);const u=Oi(c);if(u){const m={id:o,...u.duration!==void 0?{duration:u.duration}:{}};switch(u.variant){case"success":be(u.title,m);break;case"warning":Sn(u.title,m);break;case"error":Os(u.title,m);break;default:As(u.title,m)}}else i&&Cn(o)}catch(c){const u=c instanceof Error&&c.message.trim()!==""?c.message.trim():null;Os(u?n("ui.projects.use_request_update.could_not_request_updates_endedsentence_message",{endedSentence_message:String(Li(u))}):n("ui.projects.use_request_update.the_request_could_not_be_confirmed"),{id:o,duration:Number.POSITIVE_INFINITY})}finally{clearTimeout(l),Ii(s)}}function nn(){return d.useCallback(e=>{qi(e)},[])}function Ui(e){d.useSyncExternalStore(Pi,er,er);const s=sn(e),r=rn(e),a=r!==void 0?r.untilMs-Date.now():0,o=a>0;return{sending:s,cooling:o,cooldownRemainingMs:o?a:null}}const sr={get active(){return n("ui.projects.project_board.in_flight")},get paused(){return n("ui.projects.project_board.on_hold")},get done(){return n("ui.projects.project_board.finished")}};function Bi(){const[e,s]=d.useState(null);return d.useEffect(()=>{if(!e)return;const r=document.querySelector(`[data-project-menu="${e}"]`);r&&(r.focus(),s(null))}),d.useCallback(r=>s(r),[])}const $i=4,rr="board-column-move-hint",zi=({projects:e,nowMs:s,onOpen:r,onEdit:a,onDelete:o,onMove:i,movingKeys:l=[],teamLabelFor:c=u=>u})=>{F();const[u,m]=d.useState(no),p=io(e,u),f=xs(e,_t),[g,_]=d.useState(null),[x,S]=d.useState(""),b=d.useRef(null),h=d.useRef(null),k=d.useRef(null);d.useEffect(()=>{const y=b.current,v=h.current;if(!y||!v)return;const O=v.firstElementChild;let I=-1;const U=()=>{const z=v.offsetWidth-v.clientWidth;z!==I&&(I=z,y.style.paddingRight=z>0?`${z}px`:"")};let H=-1;const X=()=>{const z=v.scrollLeft;Math.abs(y.scrollLeft-z)>.5&&(y.scrollLeft=z),H=z},$=()=>{Math.abs(y.scrollLeft-H)<=.5||(Math.abs(v.scrollLeft-y.scrollLeft)>.5&&(v.scrollLeft=y.scrollLeft),H=y.scrollLeft)},je=z=>{const se=z.deltaMode===1?16:z.deltaMode===2?v.clientWidth:1,xe=z.deltaMode===1?16:z.deltaMode===2?v.clientHeight:1;Math.abs(z.deltaX)>Math.abs(z.deltaY)?v.scrollLeft+=z.deltaX*se:v.scrollTop+=z.deltaY*xe,z.preventDefault()};U(),X(),y.addEventListener("wheel",je,{passive:!1}),y.addEventListener("scroll",$,{passive:!0}),v.addEventListener("scroll",X,{passive:!0});const ie=new ResizeObserver(()=>{U(),X()});return ie.observe(v),O&&ie.observe(O),window.addEventListener("resize",U),()=>{y.removeEventListener("wheel",je),y.removeEventListener("scroll",$),v.removeEventListener("scroll",X),ie.disconnect(),window.removeEventListener("resize",U)}},[]);const T=d.useRef(null),w=d.useRef(null),q=d.useRef(null),C=new Set(l),E=(y,v)=>{const O=oo(p.map(I=>I.status),y,v);m(O),ao(O),S(n("ui.projects.project_board.moved_label_column_to_position_indexof_status_1_of_length",{label:String(ae(y).label),indexOf_status____1:String(O.indexOf(y)+1),length:V(O.length,{useGrouping:!1})}))},P=(y,v)=>{const O=b.current;if(!O)return 0;let I=0;const U=O.querySelectorAll("[data-board-column]");for(const H of U){if(H.dataset.boardColumn===v)continue;const X=H.getBoundingClientRect();y>(X.left+X.right)/2&&(I+=1)}return I},j=(y,v)=>{const O=p.filter(H=>H.status!==y),I=O[v-1]?.status,U=O[v]?.status;return I&&U?n("ui.projects.project_board.between_label_and_label_2",{label:String(ae(I).label),label_2:String(ae(U).label)}):U?n("ui.projects.project_board.before_label",{label:String(ae(U).label)}):I?n("ui.projects.project_board.after_label",{label:String(ae(I).label)}):n("ui.projects.project_board.in_place")},D=(y,v)=>{const O=P(y,v.status);O!==v.over&&(v.over=O,_({status:v.status,over:O}),S(n("ui.projects.project_board.moving_label_column_it_will_drop_status_over",{label:String(ae(v.status).label),status__over:String(j(v.status,O))})))},R=()=>{w.current!==null&&(cancelAnimationFrame(w.current),w.current=null)},L=32,W=12,B=()=>{w.current=null;const y=q.current,v=h.current,O=T.current;if(!y?.armed||!v||O===null)return;const I=v.getBoundingClientRect(),U=v.scrollWidth-v.clientWidth;let H=0;if(O-I.left<L&&v.scrollLeft>0?H=-1:I.right-O<L&&v.scrollLeft<U&&(H=1),H!==0){const X=v.scrollLeft;if(v.scrollLeft=X+H*W,v.scrollLeft!==X){const $=b.current;$&&($.scrollLeft=v.scrollLeft),D(O,y)}}else D(O,y);ee(y.status,y.over),w.current=requestAnimationFrame(B)};d.useEffect(()=>()=>{w.current!==null&&cancelAnimationFrame(w.current)},[]);const Y=(y,v)=>{if(y.button===0){try{y.currentTarget.setPointerCapture(y.pointerId)}catch{}q.current={pointerId:y.pointerId,status:v,startX:y.clientX,startY:y.clientY,armed:!1,over:p.findIndex(O=>O.status===v)},T.current=y.clientX}},J=y=>{const v=q.current;if(!(!v||y.pointerId!==v.pointerId)){if(T.current=y.clientX,!v.armed){if(Math.hypot(y.clientX-v.startX,y.clientY-v.startY)<$i)return;v.armed=!0,_({status:v.status,over:v.over}),S(n("ui.projects.project_board.moving_label_column",{label:String(ae(v.status).label)})),w.current===null&&(w.current=requestAnimationFrame(B))}D(y.clientX,v)}},Z=y=>{const v=q.current;if(q.current=null,R(),_(null),!v?.armed)return;if(!y){S(n("ui.projects.project_board.move_cancelled"));return}const O=p.findIndex(I=>I.status===v.status);if(v.over===O){S("");return}E(v.status,v.over)},me=y=>{const v=q.current;!v||y.pointerId!==v.pointerId||Z(!0)},oe=()=>{Z(!1)};d.useEffect(()=>{if(!g)return;const y=v=>{v.key==="Escape"&&Z(!1)};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[g!==null]);const ee=d.useCallback((y,v)=>{const O=b.current,I=h.current,U=k.current;if(!O||!I||!U)return;const H=I.getBoundingClientRect(),X=[];for(const re of O.querySelectorAll("[data-board-column]"))re.dataset.boardColumn!==y&&X.push(re.getBoundingClientRect());const $=6,je=v>=X.length?(X[X.length-1]?.right??H.left)+$:(X[v]?.left??H.right)-$,ie=I.scrollLeft,z=2,se=je-H.left+ie,xe=ie+1,_e=ie+I.clientWidth-z-1,Pe=Math.round(Math.min(Math.max(se,xe),Math.max(xe,_e)));U.style.left=`${Pe}px`},[]);d.useLayoutEffect(()=>{g&&ee(g.status,g.over)},[g,ee]);const te=(y,v)=>{if(y.key==="Enter"||y.key===" "){y.preventDefault(),S(n("ui.projects.project_board.drag_the_header_or_press_the_arrow_keys_to_move_this_column"));return}if(y.key!=="ArrowLeft"&&y.key!=="ArrowRight")return;y.preventDefault();const O=p.map(H=>H.status),I=O.indexOf(v),U=y.key==="ArrowLeft"?I-1:I+1;if(U<0||U>=O.length){S(n("ui.projects.project_board.label_column_is_already_the_last_column",{label:String(ae(v).label),the_last_column:String(U<0?n("ui.projects.project_board.the_first_column"):n("ui.projects.project_board.the_last_column"))}));return}E(v,U)};return t.jsxs("div",{className:M("[container-type:size] flex min-h-0 flex-1 flex-col",g&&"cursor-grabbing select-none"),"data-testid":"project-board",children:[t.jsx("output",{"aria-live":"polite",className:"sr-only","data-board-column-announcement":"",children:x}),t.jsx("span",{id:rr,className:"sr-only",children:n("ui.projects.project_board.drag_the_header_or_press_the_arrow_keys_to_move_this_column")}),t.jsx("div",{ref:b,"data-board-header-viewport":"",className:"h-11 shrink-0 overflow-hidden",children:t.jsx("div",{"data-board-column-row":"",className:"flex h-11 w-max gap-3 px-6",children:p.map(y=>{const v=ae(y.status);return t.jsxs("header",{"data-board-column":y.status,"data-board-column-handle":y.status,onPointerDown:O=>Y(O,y.status),onPointerMove:J,onPointerUp:me,onPointerCancel:oe,className:M("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",g?.status===y.status&&"opacity-85"),children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[t.jsx(G,{type:"button",variant:"ghost",size:"icon-sm","data-board-column-grip":y.status,"aria-label":n("ui.projects.project_board.move_label_column",{label:String(v.label)}),"aria-describedby":rr,title:n("ui.projects.project_board.drag_the_header_or_press_the_arrow_keys_to_move_this_column"),className:"-ml-1.5 cursor-grab text-ink-muted active:cursor-grabbing",onKeyDown:O=>te(O,y.status),children:t.jsx(ha,{"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:v.label}),sr[y.status]&&t.jsx("span",{className:"truncate text-meta text-ink-muted",children:sr[y.status]})]})]}),t.jsx("span",{className:"text-meta text-ink-muted",children:y.projects.length})]},y.status)})})}),t.jsxs("div",{ref:h,"data-board-strip":"",className:"relative min-h-0 flex-1 overflow-auto px-6 pb-9",children:[g&&t.jsx("div",{ref:k,"aria-hidden":"true","data-board-drop-indicator":"",className:"pointer-events-none absolute top-3 bottom-3 w-0.5 rounded-full bg-accent"}),t.jsx("div",{className:"flex w-max flex-col",children:f.map(y=>t.jsxs("section",{className:"flex flex-col",children:[t.jsx("div",{"data-board-team":y.team??"",className:"sticky top-0 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:y.team==null?n("ui.projects.project_model.no_team"):c(y.team)}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:y.items.length})]})}),t.jsx("div",{"data-glass-lane":"",className:"flex gap-3 rounded-md bg-sunken py-2",children:p.map(v=>{const O=y.items.filter(I=>I.status===v.status);return t.jsx("div",{"data-board-cell":v.status,className:"flex max-h-[calc(100cqh-92px)] w-64 shrink-0 flex-col gap-2 overflow-y-auto px-2",children:O.length>0&&t.jsx("ul",{className:"flex flex-col gap-2",children:O.map(I=>t.jsx("li",{children:t.jsx(Gi,{project:I,nowMs:s,busy:C.has(I.id),onOpen:()=>r(I),onEdit:()=>a(I),onDelete:()=>o(I),onMove:U=>i(I,U)})},I.id))})},v.status)})})]},y.team??""))})]})]})},Gi=({project:e,nowMs:s,busy:r,onOpen:a,onEdit:o,onDelete:i,onMove:l})=>{const c=F(),u=Mr(e,c),m=Ze(),p=nn(),f=ye(m.data,"projects_request_update"),g=ne(e),_=d.useRef(null),[x,S]=d.useState(!1);d.useEffect(()=>{const w=_.current;if(!w)return;const q=()=>{w.isConnected&&S(w.scrollWidth-w.clientWidth>.5)},C=requestAnimationFrame(q),E=new ResizeObserver(q);return E.observe(w),document.fonts?.ready.then(q).catch(()=>{}),()=>{cancelAnimationFrame(C),E.disconnect()}},[g,x]);const b=Ur(e,ws(s)),h=pt(e.progress_updated_at,s),k=()=>{const w=window.getSelection();w&&!w.isCollapsed||a()},T=w=>{w.key!=="Enter"&&w.key!==" "||w.target===w.currentTarget&&(w.preventDefault(),a())};return t.jsxs("div",{"data-project-name":e.name,role:"button",tabIndex:0,"aria-label":n("ui.projects.project_board.open_displayname",{displayName:String(g)}),onClick:k,onKeyDown:T,"data-glass-block":"",className:M("group/card flex flex-col gap-2 rounded-sm bg-surface p-3","transition-colors duration-fast ease-out-quart hover:bg-elevated",b&&"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(Ot,{content:x?g:null,side:"top",disableHoverableContent:!0,children:t.jsx("span",{ref:_,"data-project-title":e.name,tabIndex:x?0:void 0,className:"block truncate text-body-sm font-medium text-ink",children:g})}),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(ds,{children:[t.jsx(ps,{"data-project-menu":e.id,"aria-label":n("ui.projects.project_board.actions_for_displayname",{displayName:String(g)}),disabled:r,onClick:w=>w.stopPropagation(),className:M("shrink-0 rounded-sm p-1 text-ink-muted whitespace-nowrap","hover:bg-sunken hover:text-ink"),children:r?t.jsx(Te,{size:"xs"}):t.jsx(fr,{className:"size-4"})}),t.jsxs(ms,{align:"end",onClick:w=>w.stopPropagation(),children:[t.jsx(Ee,{onSelect:a,children:n("ui.projects.project_board.open")}),t.jsxs(oa,{children:[t.jsx(ia,{children:n("ui.projects.project_board.set_status")}),t.jsx(ca,{children:t.jsx(la,{value:e.status,onValueChange:l,children:[...Kt,...Vt].map(w=>t.jsx(ua,{value:w,children:ae(w).label},w))})})]}),f&&t.jsx(Ee,{onSelect:()=>p(e),children:n("ui.projects.project_board.request_update")}),t.jsx(da,{}),t.jsx(Ee,{onSelect:o,children:n("ui.projects.project_board.edit")}),t.jsx(Ee,{onSelect:i,children:n("ui.projects.project_board.delete")})]})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[u.filter(w=>w.key!=="live").map(w=>t.jsx("span",{className:"rounded-sm bg-sunken px-1.5 py-0.5 text-meta text-ink-muted",children:w.text},w.key)),b&&t.jsx(ke,{variant:"warning",children:n("ui.projects.project_board.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:Ya(h)}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[(e.progress_stale||!h)&&t.jsx("span",{"aria-label":n("ui.projects.project_model.stale"),title:n("ui.projects.project_model.stale"),className:"size-1.5 rounded-full bg-warning"}),e.sessions>0&&t.jsx(Yi,{project:e})]})]})]})},Yi=({project:e})=>{F();const[s,r]=d.useState(!1),a=Dt(),o=Sr(e.id,s),i=o.data?.links??[],l=Va(e),c=ne(e);return t.jsxs(_s,{open:s,onOpenChange:r,children:[t.jsx(fs,{"data-project-sessions":e.id,"aria-label":n("ui.projects.project_board.sessions_linked_to_displayname",{displayName:String(c)}),onClick:u=>u.stopPropagation(),className:M("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(js,{align:"end",className:"w-64 p-2 outline-none",onClick:u=>u.stopPropagation(),children:o.isLoading?t.jsx("p",{className:"px-1 py-2 text-meta text-ink-muted",children:n("ui.projects.project_board.loading_linked_sessions")}):o.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:o.error instanceof Error&&o.error.message?o.error.message:n("ui.projects.project_board.the_linked_sessions_could_not_be_read")}),t.jsx(G,{variant:"secondary",size:"sm",onClick:()=>void o.refetch(),children:n("ui.projects.project_board.try_again")})]}):i.length===0?t.jsx("p",{className:"px-1 py-2 text-meta text-ink-muted",children:n("ui.projects.project_board.no_sessions_linked_yet")}):t.jsx("ul",{className:"flex flex-col",children:i.map(u=>t.jsx("li",{children:t.jsx("button",{type:"button",disabled:!u.exists,onClick:()=>{u.exists&&(r(!1),wr(a,u.session_id))},className:M("flex w-full items-center gap-2 rounded-sm px-1 py-1.5 text-left text-meta",u.exists?"text-ink hover:bg-elevated":"text-ink-disabled"),children:t.jsx("span",{className:"truncate",children:u.title||u.session_id})})},u.session_id))})})]})},an=({open:e,projectName:s,onClose:r,onConfirm:a})=>{F();const[o,i]=d.useState(""),[l,c]=d.useState(null),[u,m]=d.useState(!1),p=d.useId();d.useEffect(()=>{e&&(i(""),c(null),m(!1))},[e]);const f=o.trim().toLowerCase()===s.trim().toLowerCase()&&s.trim().length>0,g=async()=>{m(!0),c(null);try{await a(o.trim()),r()}catch(_){c(_ instanceof Error&&_.message?_.message:n("ui.projects.project_delete_dialog.the_project_was_not_deleted"))}finally{m(!1)}};return t.jsx(dt,{open:e,onClose:r,title:n("ui.projects.project_delete_dialog.delete_this_project"),dataTourTag:"project-delete-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(He,{onClick:r,disabled:u,children:n("ui.projects.project_delete_dialog.cancel")}),t.jsxs(En,{onClick:()=>void g(),disabled:!f||u,children:[u&&t.jsx(Te,{size:"xs"}),n("ui.projects.project_delete_dialog.delete_project")]})]}),children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"text-body-sm text-ink",children:n("ui.projects.project_delete_dialog.this_deletes_the_project_and_its_milestones_the_sessions_linked_t")}),t.jsxs("p",{className:"text-body-sm text-ink-muted",children:[n("ui.projects.project_delete_dialog.type")," ",t.jsx("span",{className:"font-mono text-mono-sm text-ink",children:s})," ",n("ui.projects.project_delete_dialog.to_confirm")]}),t.jsx(ue,{id:`${p}-confirm`,value:o,onChange:_=>i(_.target.value),placeholder:s,"aria-label":n("ui.projects.project_delete_dialog.type_the_project_name_to_confirm"),"aria-invalid":o.length>0&&!f,autoFocus:!0}),l&&t.jsx("p",{className:"text-body-sm text-danger",children:l})]})})};function Hi(e){return e==="editing"||e==="saving"||e==="error"}function Wi(e,s,r=Object.is){return!r(e,s)}function Ki(e,s){if(e.key==="Escape")return e.defaultPrevented===!0?null:"revert";if(e.key!=="Enter"||!s.keyboardCommit)return null;const r=e.metaKey===!0||e.ctrlKey===!0;return s.multiline?r?"accept":null:s.onEditor?"accept":null}function Vi(e,s){return e==="saving"||e==="error"?!0:e==="editing"&&s}function Xi(e){const{phase:s,base:r,draft:a,fresh:o,equals:i}=e;return s==="saving"||s==="saved"||i(r,o)?"none":s==="idle"||i(r,a)||i(o,a)?"adopt":"conflict"}function nr(e,s,r=Object.is){return!r(e,s)}const Ss="group/inline-edit",Yt="inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-xs text-ink-dim transition-colors duration-fast ease-out-quart hover:text-ink-muted",Ji="relative before:absolute before:-inset-1.5 before:content-['']",Qi="relative before:absolute before:-top-1.5 before:-bottom-1.5 before:-left-1.5 before:right-0 before:content-['']",Zi="relative before:absolute before:-top-1.5 before:-bottom-1.5 before:-right-1.5 before:left-0 before:content-['']",is=({api:e,idle:s="affordance",className:r})=>{const{phase:a,labels:o}=e,i=a==="editing"||a==="saving"||a==="error",l=Vi(a,e.dirty),c=e.acceptBlocked===!0;return t.jsx("span",{"data-inline-edit-slot":a,className:M("inline-flex shrink-0 items-center gap-0.5",r),children:l?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button","data-inline-edit-control":"cancel","aria-label":a==="saving"?o.busy:o.cancel,title:a==="saving"?o.busy:o.cancel,"aria-disabled":a==="saving"||void 0,onMouseDown:u=>u.preventDefault(),onClick:u=>{u.detail>1||a!=="saving"&&e.cancel()},className:M(Yt,Qi,a==="saving"&&"cursor-default text-ink-disabled"),children:t.jsx(Pt,{className:"size-3","aria-hidden":"true"})}),a==="saving"?t.jsx("span",{"data-inline-edit-control":"busy",className:"inline-flex size-5 shrink-0 items-center justify-center",children:t.jsx(Te,{size:"xs"})}):t.jsx("button",{type:"button","data-inline-edit-control":"accept","aria-label":a==="error"?o.retry??o.accept:o.accept,title:a==="error"?o.retry??o.accept:o.accept,"aria-disabled":c||void 0,onMouseDown:u=>u.preventDefault(),onClick:u=>{u.detail>1||c||e.accept()},className:M(Yt,Zi,c&&"cursor-default text-ink-disabled"),children:t.jsx(hs,{className:"size-3","aria-hidden":"true"})})]}):i?null:s==="affordance"?t.jsx("button",{ref:e.slotRef,type:"button","data-inline-edit-control":"begin","aria-label":o.begin,title:o.begin,onClick:u=>{u.detail>1||e.begin()},className:M(Yt,Ji,"opacity-0 transition-opacity duration-base ease-out-quart","group-hover/inline-edit:opacity-100 group-hover/inline-edit:duration-fast","group-focus-within/inline-edit:opacity-100 group-focus-within/inline-edit:duration-fast","focus-visible:opacity-100"),children:t.jsx(Tn,{className:"size-3","aria-hidden":"true"})}):null})},cs=({api:e,className:s})=>{F();const{phase:r,error:a,conflict:o}=e;return r==="saved"?t.jsx("p",{"data-inline-edit-feedback":"saved",className:M("text-meta text-success",s),children:e.labels.saved}):!a&&!o?null:t.jsxs("div",{id:e.feedbackId,"data-inline-edit-feedback":a&&o?"error+conflict":a?"error":"conflict",role:"alert",className:M("flex flex-wrap items-center gap-x-3 gap-y-1",s),children:[a&&t.jsx("p",{className:"text-meta text-danger",children:a}),a&&o===null&&t.jsx("button",{type:"button","data-inline-edit-control":"retry",onClick:()=>e.accept(),className:"cursor-pointer text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink",children:n("ui.common.actions.retry")}),o!==null&&t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-meta text-warning",children:n("ui.common.editing.conflict")}),t.jsx("button",{type:"button","data-inline-edit-control":"keep-mine",onClick:e.keepMine,className:"cursor-pointer text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink",children:n("ui.common.editing.keep_mine")}),t.jsx("button",{type:"button","data-inline-edit-control":"use-theirs",onClick:e.useTheirs,className:"cursor-pointer text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink",children:n("ui.common.editing.use_theirs")})]})]})},on=d.createContext(null),ec=50,tc=({children:e})=>{const[s,r]=d.useState(""),a=d.useMemo(()=>({current:o=>{r(""),window.setTimeout(()=>r(o),ec)}}),[]);return t.jsxs(on.Provider,{value:a,children:[e,t.jsx("span",{"data-inline-edit-announcement":"","aria-live":"polite",className:"sr-only",children:s})]})},sc=1200;function rc(e){return e instanceof Error&&e.message?e.message:"The change was not saved."}function jt(e){const{value:s,multiline:r=!1,keyboardCommit:a=!0,selectAllOnBegin:o=!1,beginOnMount:i=!1,savedDwellMs:l=sc,labels:c}=e,u=d.useRef(e.equals??Object.is);u.current=e.equals??Object.is;const m=d.useRef(e.commit);m.current=e.commit;const p=d.useRef(e.validate);p.current=e.validate;const f=d.useRef(e.errorCopy);f.current=e.errorCopy;const g=d.useRef(e.onSettle);g.current=e.onSettle;const _=d.useRef(e.onBegin);_.current=e.onBegin;const x=d.useRef(c);x.current=c;const[S,b]=d.useState(i?"editing":"idle"),[h,k]=d.useState(s),[T,w]=d.useState(s),[q,C]=d.useState(null),[E,P]=d.useState(null),j=d.useRef(S),D=d.useRef(h),R=d.useRef(T),L=d.useRef(q),W=d.useRef(s);W.current=s;const B=d.useCallback(A=>{j.current=A,b(A)},[]),Y=d.useCallback(A=>{D.current=A,k(A)},[]),J=d.useCallback(A=>{R.current=A,w(A)},[]),Z=d.useCallback(A=>{L.current=A,C(A)},[]),me=d.useRef(null),oe=d.useRef(null),ee=d.useRef(null),te=e.editorRef??ee,y=d.useRef(te);y.current=te;const v=`${d.useId()}-inline-edit`,O=d.useContext(on),I=d.useRef(null),U=I.current,X=U!==null&&(e.equals??Object.is)(s,U.previous)&&!(e.equals??Object.is)(s,U.saved)&&U!==null?U.saved:s,$=d.useRef(X);$.current=X,d.useEffect(()=>{const A=I.current;if(A===null)return;const ce=u.current;(ce(s,A.saved)||!ce(s,A.previous))&&(I.current=null)},[s]);const je=d.useRef(i);d.useEffect(()=>{if(S!=="editing"||!je.current)return;je.current=!1;const A=y.current.current;A&&(A.focus(),o&&(A instanceof HTMLInputElement||A instanceof HTMLTextAreaElement)&&A.select())},[S,o]);const ie=d.useRef(!1);d.useEffect(()=>{ie.current&&(S!=="idle"&&S!=="saved"||(ie.current=!1,oe.current?.focus()))});const z=d.useRef(null),se=d.useCallback(()=>{z.current!==null&&(clearTimeout(z.current),z.current=null)},[]);d.useEffect(()=>()=>se(),[se]);const xe=d.useRef(S);d.useEffect(()=>{const A=xe.current;if(xe.current=S,A==="saving"&&S==="saved"){g.current?.("saved");return}(A==="editing"||A==="error")&&S==="idle"&&g.current?.("cancelled")},[S]),d.useEffect(()=>{const A=Xi({phase:j.current,base:R.current,draft:D.current,fresh:$.current,equals:u.current});A==="adopt"?(u.current(R.current,$.current)||J($.current),u.current($.current,D.current)||Y($.current)):A==="conflict"&&(L.current===null||!u.current(L.current,$.current))&&Z($.current)},[s,S,J,Y,Z]);const _e=d.useCallback(A=>{Z(null),P(null),Y(R.current),B("idle"),A&&(ie.current=!0)},[Z,Y,B]),Pe=d.useCallback(()=>{j.current!=="saving"&&(j.current==="idle"||j.current==="saved"||(se(),_e(!0)))},[se,_e]),re=d.useCallback((A,ce=!0)=>{const nt=j.current;if(nt==="saving"||nt==="saved"||L.current!==null)return;const we=A!==void 0?A:D.current;if(!nr(R.current,we,u.current)){_e(ce&&nt!=="idle");return}const gt=p.current?.(we)??null;if(gt!==null){B("error"),P(gt);return}Y(we),P(null),B("saving"),m.current(we).then(()=>{j.current==="saving"&&(I.current={saved:we,previous:R.current},J(we),Y(we),ce&&(ie.current=!0),B("saved"),se(),z.current=setTimeout(()=>{z.current=null,j.current==="saved"&&B("idle")},l),O?.current?.(x.current.saved))},$e=>{j.current==="saving"&&(B("error"),P(f.current?f.current($e):rc($e)))})},[O,se,_e,l,J,Y,B]),Re=d.useCallback(()=>{j.current==="editing"||j.current==="saving"||(se(),je.current=!0,Y($.current),J($.current),Z(null),P(null),B("editing"),_.current?.())},[se,J,Z,Y,B]),Be=d.useCallback(()=>{const A=L.current;A!==null&&(Z(null),J(A),re())},[re,J,Z]),qt=d.useCallback(()=>{const A=L.current;A!==null&&(J(A),_e(!0))},[_e,J]),st=d.useCallback(A=>{const ce=Ki(A,{multiline:r,keyboardCommit:a,onEditor:A.target===y.current.current});if(ce==="revert"){A.preventDefault(),Pe();return}ce==="accept"&&(A.preventDefault(),re())},[re,Pe,a,r]),rt=d.useCallback(A=>{if(j.current!=="editing")return;const ce=A.relatedTarget;if(!(ce!==null&&me.current?.contains(ce))&&!(ce instanceof Element&&ce.closest("[data-radix-popper-content-wrapper]")!==null)&&L.current===null){if(!nr(R.current,D.current,u.current)){_e(!1);return}re(void 0,!1)}},[re,_e]),ht=S==="saved"?h:X;return{phase:S,dirty:Wi(T,h,u.current),conflict:q,error:E,draft:h,setDraft:Y,displayValue:ht,editing:Hi(S),begin:Re,accept:re,cancel:Pe,keepMine:Be,useTheirs:qt,handleKeyDown:st,handleBlur:rt,fieldProps:{onKeyDown:st,onBlur:rt,"aria-busy":S==="saving"?!0:void 0},editorAria:{"aria-invalid":E!==null?!0:void 0,"aria-describedby":E!==null||q!==null?v:void 0},fieldRef:me,editorRef:te,slotRef:oe,feedbackId:v,labels:c}}const nc=/^(https?:|mailto:)/i,ac={a:({href:e,children:s})=>typeof e=="string"&&nc.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:Dn},ut=d.memo(({children:e,className:s})=>t.jsx("div",{className:M("lo-markdown",s),children:t.jsx(Rn,{remarkPlugins:[An],components:ac,children:e})})),ar=`## Summary
23
-
24
- ## Goals
25
-
26
- ## Notes`,oc=new RegExp("\\p{Mn}","gu"),ic=/[^a-z0-9._-]+/g,cc=/[._-]{2,}/g,lc=/^[^a-z0-9]+/,or=/[^a-z0-9]+$/;function uc(e){return e.normalize("NFKD").replace(oc,"").toLowerCase().replace(ic,"-").replace(cc,"-").replace(lc,"").replace(or,"").slice(0,64).replace(or,"")}const dc=/&#x([0-9a-f]+);/gi,pc=/&#(\d+);/g,mc=/&nbsp;/g,_c=/&lt;/g,fc=/&gt;/g,jc=/&quot;/g,hc=/&#39;|&apos;/g,gc=/&amp;/g,ir=e=>e.replace(dc,(s,r)=>String.fromCodePoint(Number.parseInt(r,16))).replace(pc,(s,r)=>String.fromCodePoint(Number.parseInt(r,10))).replace(mc," ").replace(_c,"<").replace(fc,">").replace(jc,'"').replace(hc,"'").replace(gc,"&"),xc=/<[^>]*>|[^<]+/g,bc=/^<\//,yc=/^<\/?\s*([a-zA-Z][a-zA-Z0-9]*)/,vc=/\s+/g,cr=/class="[^"]*language-([\w+-]+)/,kc=/href="([^"]*)"/,wc=/src="([^"]*)"/,Nc=/alt="([^"]*)"/,Sc=/[ \t]+\n/g,Cc=/\n{3,}/g;function Ec(e){const s=[],r=(...m)=>{for(let p=s.length-1;p>=0;p--)if(m.includes(s[p].tag)){const[f]=s.splice(p,1);return f}},a=[],o=()=>s.some(m=>m.tag==="pre"),i=()=>s.filter(m=>m.tag==="blockquote").length;let l=!0;const c=m=>{m&&(i()>0&&l&&!o()&&a.push("> ".repeat(i())),a.push(m),l=m.endsWith(`
27
- `))},u=e.match(xc)??[];for(let m=0;m<u.length;m++){const p=u[m];if(!p.startsWith("<")){c(o()?ir(p):ir(p).replace(vc," "));continue}const f=bc.test(p),g=(p.match(yc)?.[1]??"").toLowerCase();if(f){switch(g){case"p":case"div":c(`
28
-
29
- `);break;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":r(g),c(`
30
-
31
- `);break;case"li":{r("li"),c(`
32
- `);const _=[...s].reverse().find(x=>x.tag==="ul"||x.tag==="ol");_?.ordered&&(_.index=(_.index??1)+1);break}case"ul":case"ol":r(g),c(`
33
- `);break;case"strong":case"b":r("strong","b")&&c("**");break;case"em":case"i":r("em","i")&&c("*");break;case"del":case"s":r("del","s")&&c("~~");break;case"code":{r("code")?.inline&&c("`");break}case"pre":r("pre")&&c("\n```\n\n");break;case"a":{const _=r("a");_?.href&&c(`](${_.href})`);break}case"blockquote":r("blockquote")&&c(`
34
- `);break}continue}switch(g){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":{const _=Number(g[1]);s.push({tag:g}),c(`${"#".repeat(_)} `);break}case"ul":case"ol":s.push({tag:g,ordered:g==="ol",index:1});break;case"li":{const _=[...s].reverse().find(x=>x.tag==="ul"||x.tag==="ol");s.push({tag:"li"}),_?.ordered?c(`${_.index??1}. `):c("- ");break}case"strong":case"b":s.push({tag:g}),c("**");break;case"em":case"i":s.push({tag:g}),c("*");break;case"del":case"s":s.push({tag:g}),c("~~");break;case"code":{const _=s[s.length-1]?.tag!=="pre";s.push({tag:"code",inline:_}),_&&c("`");break}case"pre":{const _=p.match(cr)?.[1]??u[m+1]?.match(cr)?.[1]??"";s.push({tag:"pre"}),c(`
35
- \`\`\`${_}
36
- `);break}case"a":{const _=p.match(kc)?.[1]??"";s.push({tag:"a",href:_}),_&&c("[");break}case"img":{const _=p.match(wc)?.[1]??"",x=p.match(Nc)?.[1]??"";_&&c(`![${x}](${_})`);break}case"br":c(`
37
- `);break;case"blockquote":s.push({tag:"blockquote"});break}}return a.join("").replace(Sc,`
38
- `).replace(Cc,`
39
-
40
- `).trim()}function cn(e,s,r){const a=e.clipboardData?.getData("text/html");if(!a)return;const o=Ec(a);if(!o)return;e.preventDefault();const i=e.currentTarget,l=i.selectionStart??i.value.length,c=i.selectionEnd??l;r(i.value.slice(0,l)+o+i.value.slice(c)),requestAnimationFrame(()=>{const u=s.current;if(!u)return;const m=l+o.length;u.setSelectionRange(m,m)})}const ln=({open:e,refusal:s,projectLabel:r,onClose:a,onConfirm:o,secondaryLabel:i,onSecondary:l})=>{F();const[c,u]=d.useState(!1),[m,p]=d.useState(null),f=d.useRef(!1),g=d.useRef(null);d.useEffect(()=>{e&&(u(!1),p(null),f.current=!1)},[e]);const _=async()=>{if(!f.current){f.current=!0,u(!0),p(null);try{await o(),a()}catch(S){p({copy:Zr(S),gone:Qr(S)})}finally{f.current=!1,u(!1)}}},x=s?.names??[];return t.jsx(dt,{open:e,onClose:a,title:n("ui.projects.project_done_anyway_dialog.mark_done_with_open_milestones"),dataTourTag:"project-done-anyway-dialog",maxWidth:"xs",dialogProps:{closeDisabled:c,onEscapeKeyDown:S=>{c&&S.preventDefault()},onInteractOutside:S=>{c&&S.preventDefault()},onOpenAutoFocus:S=>{S.preventDefault(),g.current?.focus()}},actions:t.jsxs("div",{className:"flex w-full min-w-0 flex-wrap justify-end gap-2",children:[t.jsx(He,{ref:g,onClick:a,disabled:c,children:n("ui.projects.project_done_anyway_dialog.cancel")}),!m?.gone&&t.jsx(He,{onClick:l,disabled:c,children:i}),m?.gone?t.jsx(vt,{"data-project-force-close":"",onClick:a,children:n("ui.projects.project_done_anyway_dialog.close")}):t.jsxs(vt,{"data-project-force-done":"","aria-disabled":c,className:"aria-disabled:pointer-events-none aria-disabled:bg-sunken aria-disabled:text-ink-disabled",onClick:()=>void _(),children:[c?t.jsx(Te,{size:"xs"}):t.jsx("span",{"aria-hidden":"true",className:"size-3.5 shrink-0"}),n("ui.projects.project_done_anyway_dialog.mark_done_anyway")]})]}),children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"text-body-sm text-ink break-words",children:r?n("ui.projects.project_done_anyway_dialog.projectlabel_moves_to_done_and_its_milestones_stay_open",{projectLabel:String(r)}):n("ui.projects.project_done_anyway_dialog.the_project_moves_to_done_and_its_milestones_stay_open")}),t.jsx("p",{className:"text-body-sm text-ink break-words",children:s?Co(s):""}),x.length>bt+1&&t.jsx("div",{className:"px-1.5",children:t.jsx(jr,{summary:n("ui.projects.project_done_anyway_dialog.show_all_length_open_milestones",{length:x.length}),children:t.jsx("ul",{"data-project-open-milestones":"",className:"flex flex-col gap-1 py-1 text-body-sm text-ink-muted",children:x.map((S,b)=>t.jsx("li",{className:"break-words",children:S},`${b}-${S}`))})})}),t.jsx("p",{role:"alert",className:"min-h-[1lh] text-body-sm text-danger break-words",children:m?.copy??""})]})})},un=({status:e})=>{const s=ae(e);return t.jsxs(ke,{variant:s.variant,children:[Ba(e)&&t.jsx(hs,{"aria-hidden":!0}),s.label]})},Tc="project-key",Rc="project-key";function ge(e,s){return{name:s,begin:n("ui.projects.project_editors.edit_field",{field:String(e)}),accept:n("ui.projects.project_editors.save_field",{field:String(e)}),cancel:n("ui.projects.project_editors.discard_the_field_edit",{field:String(e)}),busy:n("ui.projects.project_editors.saving_the_field",{field:String(e)}),saved:n("ui.projects.project_editors.display_saved",{display:String(s)}),retry:n("ui.projects.project_editors.retry_saving_the_field",{field:String(e)})}}const Ft=({field:e,fieldRef:s,fieldProps:r,editing:a,label:o,bare:i=!1,display:l,editor:c,slot:u,feedback:m,controlsIdle:p="affordance",hug:f=!1,feedbackExtra:g,className:_,controlsClassName:x})=>t.jsxs("div",{ref:s,...r,"data-project-field":e,className:M(!i&&Ss,"min-w-0",o!==void 0&&"flex items-start gap-3",_),children:[o!==void 0&&t.jsx("dt",{className:"w-24 shrink-0 pt-0.5 text-body-sm text-ink-muted",children:o}),t.jsxs("div",{className:M("flex min-w-0 flex-col gap-1",f&&"items-start",o!==void 0&&"flex-1"),children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("div",{className:M("min-w-0",f?"w-fit":"flex-1",!a&&"cursor-text"),onDoubleClick:a?void 0:u.begin,children:a?c:l}),t.jsx(is,{api:u,idle:p,className:M("shrink-0",x)})]}),t.jsx("div",{className:M("min-h-[1lh] text-meta",f&&"max-w-96"),children:t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsx(cs,{api:m}),g]})})]})]}),Le=({field:e,value:s,display:r,commitFields:a,validate:o,labels:i,commit:l,placeholder:c,mono:u=!1,ramp:m="text-body-sm",label:p,bare:f=!1,autoBegin:g=!1,maxLength:_,onRetire:x,className:S,controlsClassName:b})=>{const[h,k]=d.useState(g);d.useEffect(()=>{h&&s!==""&&(k(!1),x?.("filled"))},[h,s,x]);const T=jt({value:s,commit:async w=>{await l(a(w))},equals:(w,q)=>w.trim()===q.trim(),validate:o,labels:i,selectAllOnBegin:!0,beginOnMount:g,errorCopy:tt,onSettle:w=>{w==="cancelled"&&(k(!1),x?.("cancelled"))}});return!h&&s===""?null:t.jsx(Ft,{field:e,fieldRef:T.fieldRef,fieldProps:T.fieldProps,editing:T.editing,label:p,bare:f,display:r,slot:T,feedback:T,className:S,controlsClassName:b,editor:t.jsx(ue,{ref:T.editorRef,...T.editorAria,value:T.draft,readOnly:T.phase==="saving",maxLength:_,placeholder:c,"aria-label":i.name,onChange:w=>T.setDraft(w.target.value),spellCheck:!1,autoComplete:"off",className:M("h-8",u?"font-mono text-mono-sm":m)})})},Dc=({project:e,commit:s})=>{F();const r=e.title??"",[a,o]=d.useState(!1),i=d.useRef(null),l=c=>{o(!1),c==="cancelled"&&setTimeout(()=>i.current?.focus(),0)};return t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[t.jsxs("div",{className:M(Ss,"flex min-w-0 flex-col gap-0.5"),children:[r?t.jsx(Le,{field:"title",value:r,display:t.jsx("h1",{"data-project-title":e.name,className:"min-w-0 break-words text-display text-ink",children:r}),commitFields:c=>({title:c.trim()}),validate:c=>es(c),labels:ge("title",n("ui.projects.project_editors.title")),commit:s,maxLength:wt,placeholder:n("ui.projects.project_editors.a_short_name_for_the_workstream"),ramp:"text-body",bare:!0,controlsClassName:"self-center"}):t.jsx(Le,{field:"key",value:e.name,display:t.jsx("h1",{"data-project-title":e.name,className:"min-w-0 break-words text-display text-ink",children:e.name}),commitFields:c=>({name:c.trim()}),validate:c=>Wt(c.trim()),labels:ge("key",n("ui.projects.project_editors.key")),commit:s,maxLength:Vs,placeholder:Tc,ramp:"text-body",bare:!0,controlsClassName:"self-center"}),!r&&(a?t.jsx(Le,{field:"title",value:"",display:null,commitFields:c=>({title:c.trim()}),validate:c=>es(c),labels:ge("title",n("ui.projects.project_editors.title")),commit:s,maxLength:wt,placeholder:e.name,ramp:"text-body-sm",bare:!0,autoBegin:!0,onRetire:l}):t.jsx("button",{ref:i,type:"button","data-project-add-title":"",onClick:()=>o(!0),className:M("w-fit cursor-pointer text-meta text-ink-dim","opacity-0 transition-opacity duration-base ease-out-quart","group-hover/inline-edit:opacity-100 group-hover/inline-edit:duration-fast","group-focus-within/inline-edit:opacity-100 group-focus-within/inline-edit:duration-fast","hover:text-ink"),children:n("ui.projects.project_editors.add_a_title")}))]}),r&&t.jsx(Le,{field:"key",value:e.name,display:t.jsx("span",{className:"font-mono text-mono-sm text-ink-muted",children:e.name}),commitFields:c=>({name:c.trim()}),validate:c=>Wt(c.trim()),labels:ge("key",n("ui.projects.project_editors.key")),commit:s,maxLength:Vs,placeholder:Rc,mono:!0})]})},Ac=({project:e,commit:s})=>{F();const[r,a]=d.useState(!1),o=Ze(),i=ye(o.data,"projects_force_done"),[l,c]=d.useState(null),[u,m]=d.useState(null),p=d.useRef(!1),f=d.useRef(!1),g=d.useRef(null),_=jt({value:e.status,commit:async b=>{const h=p.current;p.current=!1,c(null);try{const k=await s({status:b},h?{forceDone:!0}:void 0);h&&be(zr(k,l?.count??0,ae(b).label)),g.current?.resolve()}catch(k){throw c(en(k)),g.current?.reject(k),k}finally{g.current=null}},labels:ge("status",n("ui.projects.project_editors.status")),keyboardCommit:!1,errorCopy:tt,onBegin:()=>a(!0)}),x=i&&_.phase==="error"&&l!==null&&l.coded;d.useEffect(()=>{if(!f.current||_.phase!=="idle"&&_.phase!=="saved")return;f.current=!1;const b=document.querySelector("[data-project-milestones]");b&&(b.scrollIntoView({block:"start"}),b.querySelector("[data-project-milestones-heading]")?.focus({preventScroll:!0}))},[_.phase]);const S=()=>new Promise((b,h)=>{if(_.phase!=="error"||_.conflict!==null){h(new Error(""));return}if(!_.dirty){b();return}p.current=!0,g.current={resolve:b,reject:h},_.accept(_.draft,!0)});return t.jsx(Ft,{field:"status",fieldRef:_.fieldRef,fieldProps:_.fieldProps,editing:_.editing,display:t.jsx(un,{status:e.status}),slot:_,feedback:_,hug:!0,feedbackExtra:t.jsxs(t.Fragment,{children:[x&&t.jsx(G,{variant:"ghost",size:"sm","data-project-force-done-door":"",onClick:()=>m(l),children:n("ui.projects.project_editors.mark_done_anyway")}),t.jsx(ln,{open:u!==null,refusal:u,projectLabel:ne(e),onClose:()=>m(null),onConfirm:S,secondaryLabel:n("ui.projects.project_editors.review_milestones"),onSecondary:()=>{m(null),f.current=!0,_.cancel()}})]}),editor:t.jsxs(We,{open:r,onOpenChange:a,value:_.draft,onValueChange:b=>{a(!1),_.accept(b)},children:[t.jsx(Ke,{ref:_.editorRef,..._.editorAria,"aria-label":n("ui.projects.project_editors.status"),"data-project-status":"",className:"h-7 w-fit min-w-36",children:t.jsx(Ve,{})}),t.jsx(Xe,{children:Rr.map(b=>t.jsx(Ae,{value:b.value,"data-project-status-option":b.value,children:b.label},b.value))})]})})},Oc=({project:e,commit:s})=>{F();const[r,a]=d.useState(!1),o=d.useRef(null),i=d.useRef(null),l=jt({value:e.description,commit:async m=>{await s({description:m.trim()})},equals:(m,p)=>m.trim()===p.trim(),validate:m=>Xr(m),multiline:!0,labels:ge("description",n("ui.projects.project_editors.description")),errorCopy:tt,editorRef:o,onSettle:m=>{m==="cancelled"&&!e.description.trim()&&setTimeout(()=>i.current?.focus(),0)}});d.useEffect(()=>{if(r||!l.editing)return;const m=setTimeout(()=>o.current?.focus(),0);return()=>clearTimeout(m)},[r,l.editing]);const u=(l.editing?l.draft:l.displayValue).length>Je;return t.jsx("div",{ref:l.fieldRef,...l.fieldProps,"data-project-field":"description",className:M(Ss,"min-w-0"),children:l.editing?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:n("ui.projects.project_editors.description_mode")}),t.jsx("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:["write","preview"].map(m=>t.jsx("button",{type:"button","data-project-description-mode":m,"aria-pressed":r===(m==="preview"),onClick:()=>a(m==="preview"),className:M("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink",r===(m==="preview")&&"bg-surface text-ink"),children:m==="write"?n("ui.projects.project_editors.write"):n("ui.projects.project_editors.preview")},m))})]}),t.jsx(is,{api:{...l,acceptBlocked:u}})]}),r?t.jsx("div",{"data-project-description-preview":"",className:"h-40 overflow-y-auto rounded-md border border-hairline bg-sunken px-3 py-2",children:l.draft.trim()?t.jsx(ut,{className:"text-body-sm",children:l.draft}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_editors.nothing_to_preview_yet")})}):t.jsx(br,{ref:o,...l.editorAria,"data-project-description":"",value:l.draft,readOnly:l.phase==="saving",rows:8,placeholder:n("ui.projects.project_editors.markdown_headings_lists_code"),"aria-label":l.labels.name,onChange:m=>l.setDraft(m.target.value),onPaste:m=>cn(m,o,p=>l.setDraft(p)),className:"h-40 resize-none"}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(cs,{api:l}),t.jsxs("p",{className:M("shrink-0 text-meta tabular-nums",u?"text-danger":"text-ink-muted"),children:[l.draft.length,"/",Je]})]})]}):t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[(e.description??"").trim()?t.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[t.jsx("div",{className:"min-w-0 flex-1 cursor-text",onDoubleClick:l.begin,children:t.jsx(ut,{className:"text-body",children:e.description??""})}),t.jsx(is,{api:l})]}):t.jsx("button",{ref:i,type:"button","data-project-add-description":"",onClick:l.begin,className:"w-fit cursor-pointer text-body-sm text-ink-dim transition-colors duration-fast ease-out-quart hover:text-ink",children:n("ui.projects.project_editors.add_description")}),t.jsx("div",{className:"min-h-[1lh] text-meta",children:t.jsx(cs,{api:l})})]})})},Pc=({project:e,commit:s,autoBegin:r=!1,onRetire:a})=>(F(),t.jsx(Le,{field:"owner",value:e.owner??"",label:n("ui.projects.project_editors.owner"),display:t.jsx("span",{className:"text-body-sm text-ink",children:e.owner}),commitFields:o=>({owner:o.trim()}),validate:o=>St(o,"owner"),labels:ge("owner",n("ui.projects.project_editors.owner")),commit:s,maxLength:Nt,placeholder:n("ui.projects.examples.owner"),autoBegin:r,onRetire:a})),Mc=({project:e,commit:s,label:r=null,autoBegin:a=!1,onRetire:o})=>(F(),t.jsx(Le,{field:"team",value:e.team??"",label:n("ui.projects.project_editors.team"),display:t.jsx("span",{className:"text-body-sm text-ink",children:r??e.team}),commitFields:i=>({team:i.trim()}),validate:i=>St(i,"team"),labels:ge("team",n("ui.projects.project_editors.team")),commit:s,maxLength:Nt,placeholder:n("ui.projects.examples.team"),autoBegin:a,onRetire:o})),lr=({project:e,commit:s,which:r,nowMs:a,autoBegin:o=!1,onRetire:i})=>{const l=r==="start"?e.start_date??"":e.target_date??"",c=F(),u=Oe(l,c,new Date(a)),m=r==="start"?n("ui.projects.project_editors.start"):n("ui.projects.project_editors.target");return t.jsx(Le,{field:r==="start"?"start-date":"target-date",value:l,label:m,display:t.jsx("span",{className:"text-body-sm text-ink",children:u}),commitFields:p=>r==="start"?{start_date:p}:{target_date:p},validate:p=>{const f=ts(p);return f||(r==="start"?ss(p,e.target_date??""):ss(e.start_date??"",p))},labels:ge(n("ui.projects.project_editors.tolowercase_date",{toLowerCase:String(m.toLowerCase())}),m),commit:s,placeholder:"YYYY-MM-DD",autoBegin:o,onRetire:i})},Ic=({project:e,commit:s,autoBegin:r=!1,onRetire:a})=>{F();const o={estimate:e.estimate,unit:e.estimate_unit==="days"?"days":"points"},[i,l]=d.useState(r);d.useEffect(()=>{i&&e.estimate!==null&&(l(!1),a?.("filled"))},[i,e.estimate,a]);const c=jt({value:{number:e.estimate===null?"":String(e.estimate),unit:o.unit},equals:ki,commit:async m=>{const p=Ni(o,m);p&&await s(p)},validate:m=>Jr(m.number),labels:ge("estimate",n("ui.projects.project_editors.estimate")),selectAllOnBegin:!0,beginOnMount:r,errorCopy:tt,onSettle:m=>{m==="cancelled"&&(l(!1),a?.("cancelled"))}});if(!i&&e.estimate===null)return null;const u=Or(e.estimate,e.estimate_unit)||"—";return t.jsx(Ft,{field:"estimate",fieldRef:c.fieldRef,fieldProps:c.fieldProps,editing:c.editing,label:n("ui.projects.project_editors.estimate"),display:t.jsx("span",{className:"text-body-sm text-ink",children:u}),slot:c,feedback:c,editor:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ue,{ref:c.editorRef,...c.editorAria,"data-project-estimate":"",value:c.draft.number,readOnly:c.phase==="saving",placeholder:"13",inputMode:"decimal","aria-label":c.labels.name,onChange:m=>c.setDraft({...c.draft,number:m.target.value}),className:"h-8 max-w-24"}),t.jsxs(We,{value:c.draft.unit,onValueChange:m=>c.setDraft({...c.draft,unit:m}),children:[t.jsx(Ke,{"data-project-estimate-unit":"","aria-label":n("ui.projects.project_editors.estimate_unit"),"aria-invalid":c.editorAria["aria-invalid"],className:"h-8 w-fit min-w-28",children:t.jsx(Ve,{})}),t.jsxs(Xe,{children:[t.jsx(Ae,{value:"points",children:n("ui.projects.project_editors.points")}),t.jsx(Ae,{value:"days",children:n("ui.projects.project_editors.days")})]})]})]}),c.draft.number.trim()===""&&o.estimate!==null&&t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.projects.project_editors.clearing_an_estimate_is_not_supported_yet_saving_keeps_its_curren")})]})})},Lc=({project:e,commit:s,autoBegin:r=!1,onRetire:a})=>{F();const[o,i]=d.useState(r);d.useEffect(()=>{o&&e.tags.length>0&&(i(!1),a?.("filled"))},[o,e.tags,a]);const l=jt({value:e.tags.join(", "),equals:(u,m)=>wi(lt(u),m),commit:async u=>{const{tags:m}=rs(u);await s({tags:m})},validate:u=>rs(u).error,labels:ge("tags",n("ui.projects.project_editors.tags")),selectAllOnBegin:!0,beginOnMount:r,errorCopy:tt,onSettle:u=>{u==="cancelled"&&(i(!1),a?.("cancelled"))}});if(!o&&e.tags.length===0)return null;const c=l.editing?lt(l.draft):e.tags;return t.jsx(Ft,{field:"tags",fieldRef:l.fieldRef,fieldProps:l.fieldProps,editing:l.editing,label:n("ui.projects.project_editors.tags"),display:t.jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:e.tags.map(u=>t.jsx(ke,{variant:"outline",children:u},u))}),slot:l,feedback:l,editor:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(ue,{ref:l.editorRef,...l.editorAria,"data-project-tags":"",value:l.draft,readOnly:l.phase==="saving",placeholder:n("ui.projects.project_editors.q4_payments"),"aria-label":l.labels.name,onChange:u=>l.setDraft(u.target.value),className:"h-8 max-w-72"}),t.jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:c.map(u=>t.jsx(ke,{variant:"outline",children:u},u))})]})})},Fc="project-quick-send:no-target",qc=[],Uc=({links:e,target:s,onTargetChange:r,onSend:a,focusTick:o})=>{F();const i=d.useRef(null),l=On(),{frontend:c,refresh:u}=Na(),[m,p]=d.useState(!1),f=Ze(),g=s??Fc;d.useEffect(()=>{s&&u(s)},[s,u]),d.useEffect(()=>{o>0&&i.current?.focusInput()},[o]);const _=e.filter(b=>b.exists),S=(_.find(b=>b.session_id===s)??null)?.runtime?.busy===!0;return t.jsxs("div",{"data-tour-tag":"project-quick-send","data-glass-block":"",className:"flex flex-col gap-2 rounded-md bg-surface 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:n("ui.projects.project_quick_send.send_to")}),t.jsxs(We,{value:s??void 0,onValueChange:b=>r(b),children:[t.jsx(Ke,{"aria-label":n("ui.projects.project_quick_send.select_the_session_to_message"),className:"max-w-72",children:t.jsx(Ve,{placeholder:n("ui.projects.project_quick_send.no_session_selected")})}),t.jsx(Xe,{children:_.map(b=>t.jsx(Ae,{value:b.session_id,children:Lt(b)},b.session_id))})]}),m?t.jsx("span",{role:"status",className:"text-meta text-ink-muted",children:n("ui.projects.project_quick_send.sending")}):S?t.jsx("span",{className:"text-meta text-ink-muted",children:n("ui.projects.project_quick_send.the_session_is_working_this_message_steers_the_running_turn")}):null]}),t.jsx(Pn,{ref:i,conversationId:g,messages:qc,isLoading:!1,ownGutter:!0,transcriptless:!0,autoFocus:!1,placeholderOverride:n("ui.projects.project_quick_send.message_the_session_paste_an_image_to_attach_it"),cwd:c?.cwd,cwdReadOnlyReason:n("ui.projects.project_quick_send.quick_send_follows_the_conversation_s_directory"),sessionStatus:c&&s?{frontend:c,costChannels:ye(f.data,"cost_channels")}:void 0,recordingProbe:l,hostNotice:s?void 0:{id:"project-quick-send-no-target",node:t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.projects.project_quick_send.choose_a_session_to_send_to")}),blocksInput:!0,get placeholder(){return n("ui.projects.project_quick_send.choose_a_session_to_send_to")}},onSendMessage:async(b,h)=>{if(!s)return!1;p(!0);try{return await a(s,b,S?"steer":"prompt",h)}finally{p(!1),i.current?.focusInput({preventScroll:!0})}}})]})},Bc=({links:e,busy:s,onUnlink:r,onLink:a,onQuickSend:o,onStartSession:i})=>{F();const l=Dt(),c=kt(h=>h.sessions),[u,m]=d.useState(!1),[p,f]=d.useState(null),[g,_]=d.useState(0),x=p&&e.some(h=>h.session_id===p&&h.exists)?p:bo(e),S=d.useMemo(()=>{const h=new Set(e.map(k=>k.session_id));return c.filter(k=>!h.has(k.session_id)).map(k=>({id:k.session_id,name:k.title||k.session_id,description:k.cwd??void 0}))},[c,e]),b=h=>{kt.getState().openSession(h).then(k=>{k&&l(`/chat/${h}`)})};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:n("ui.projects.project_links.linked_sessions")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(G,{variant:"secondary",size:"sm",disabled:s,onClick:i,"data-tour-tag":"project-start-session",children:[t.jsx(ga,{}),n("ui.projects.project_links.new_session")]}),t.jsxs(G,{variant:"secondary",size:"sm",disabled:s,onClick:()=>m(!0),"data-tour-tag":"project-link-session",children:[t.jsx(xa,{}),n("ui.projects.project_links.link_session")]})]})]}),e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_links.no_sessions_linked_yet_link_the_conversations_that_are_working_on")}):t.jsx("ul",{"data-glass-block":"",className:"flex flex-col divide-y divide-hairline rounded-md bg-surface",children:e.map(h=>{const k=Xa(h),T=Ja(h.subagents),w=Qa(h.todos),q=h.title||h.session_id,C=h.exists;return t.jsxs("li",{"data-glass-block-row":"",className:M("flex items-center gap-2 rounded-sm px-2 py-2",C&&"hover:bg-row-hover"),children:[t.jsx("button",{type:"button",disabled:!C,onClick:()=>{C&&b(h.session_id)},className:M("flex min-w-0 flex-1 items-center gap-2 text-left",C?"cursor-pointer":"cursor-default opacity-100"),children:t.jsx("span",{"data-glass-block-row-label":"",className:M("min-w-0 truncate text-body-sm",h.title?"text-ink":"font-mono text-mono-sm text-ink-muted"),children:q})}),h.runtime?.busy===!0&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:n("ui.projects.project_links.busy")}),T&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:T}),w&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:w}),t.jsx(ke,{variant:k.variant,children:k.label}),C&&t.jsx(G,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":n("ui.projects.project_links.message_title",{title:String(q)}),title:n("ui.projects.project_links.message_title",{title:String(q)}),onClick:()=>{f(h.session_id),_(E=>E+1)},children:t.jsx(ba,{})}),t.jsx(G,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":n("ui.projects.project_links.unlink_title",{title:String(q)}),onClick:()=>r(h.session_id),children:t.jsx(Oa,{})})]},h.session_id)})}),e.some(h=>h.exists)&&t.jsx(Uc,{links:e,target:x,onTargetChange:f,onSend:o,focusTick:g}),t.jsx(dt,{open:u,onClose:()=>m(!1),title:n("ui.projects.project_links.link_a_session"),maxWidth:"sm",dataTourTag:"project-link-dialog",actions:t.jsx(He,{onClick:()=>m(!1),children:n("ui.projects.project_links.close")}),children:t.jsxs("div",{className:"flex flex-col gap-2 px-1 py-1",children:[t.jsx(pe,{children:n("ui.projects.project_links.session")}),t.jsx(yr,{showLabel:!1,ariaLabel:n("ui.projects.project_links.search_sessions"),busyLabel:n("ui.projects.project_links.loading_sessions"),placeholder:n("ui.projects.project_links.search_conversations"),options:S,selected:null,onSelect:h=>{m(!1),a(h.id)}}),t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.projects.project_links.conversations_already_linked_to_this_project_are_not_listed")})]})})]})},$c=({milestones:e,summary:s,busy:r,onToggle:a,onRemove:o,onAdd:i})=>{const[l,c]=d.useState(""),[u,m]=d.useState(""),p=F(),f=!Dr.test(u.trim()),g=l.trim().length>0&&!f&&!r,_=()=>{g&&(i(l.trim(),u.trim()),c(""),m(""))};return t.jsxs("section",{"data-project-milestones":"",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",tabIndex:-1,"data-project-milestones-heading":"",children:n("ui.projects.project_milestones.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:n("ui.projects.project_milestones.no_milestones_yet_add_one_below_to_mark_the_dates_this_project_is")}):t.jsx("ul",{"data-glass-block":"",className:"flex flex-col divide-y divide-hairline rounded-md bg-surface",children:e.map(x=>{const S=za(x.status),b=x.completed_at!==null;return t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx(vr,{checked:b,disabled:r,onCheckedChange:h=>a(x.name,h===!0),"aria-label":b?n("ui.projects.project_milestones.mark_name_not_complete",{name:String(x.name)}):n("ui.projects.project_milestones.mark_name_complete",{name:String(x.name)})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:x.name}),x.target_date&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:Oe(x.target_date,p)}),t.jsx(ke,{variant:S.variant,children:S.label}),t.jsx(G,{variant:"ghost",size:"icon-sm",disabled:r,"aria-label":n("ui.projects.project_milestones.remove_name",{name:String(x.name)}),onClick:()=>o(x.name),children:t.jsx(Pt,{})})]},x.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(pe,{htmlFor:"project-milestone-name",children:n("ui.projects.project_milestones.new_milestone")}),t.jsx(ue,{id:"project-milestone-name",value:l,onChange:x=>c(x.target.value),placeholder:n("ui.projects.project_milestones.beta_cut"),onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),_())}})]}),t.jsxs("div",{className:"flex w-40 flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:"project-milestone-date",children:n("ui.projects.project_milestones.target_date")}),t.jsx(ue,{id:"project-milestone-date",value:u,onChange:x=>m(x.target.value),placeholder:"YYYY-MM-DD","aria-invalid":f}),f&&t.jsx("p",{className:"text-meta text-danger",children:n("ui.projects.project_milestones.dates_are_yyyy_mm_dd_or_empty")})]}),t.jsxs(G,{variant:"secondary",disabled:!g,onClick:_,"data-tour-tag":"project-milestone-add",children:[t.jsx(it,{}),n("ui.projects.project_milestones.add")]})]})]})},zc=[{field:"owner",get label(){return n("ui.projects.project_properties.owner")}},{field:"team",get label(){return n("ui.projects.project_properties.team")}},{field:"start",get label(){return n("ui.projects.project_properties.start_date")}},{field:"target",get label(){return n("ui.projects.project_properties.target_date")}},{field:"estimate",get label(){return n("ui.projects.project_properties.estimate")}},{field:"tags",get label(){return n("ui.projects.project_properties.tags")}}],ur=({label:e,children:s})=>t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("dt",{className:"w-24 shrink-0 pt-0.5 text-body-sm text-ink-muted",children:e}),t.jsx("dd",{className:"min-w-0 flex-1 text-body-sm text-ink",children:s})]}),Gc=({project:e,nowMs:s,commit:r,teamLabel:a=null})=>{const o=F(),i=new Date(s),[l,c]=d.useState(null),u=d.useRef(null),m=d.useRef(!1),p={owner:e.owner!==null,team:e.team!==null,start:e.start_date!==null,target:e.target_date!==null,estimate:e.estimate!==null,tags:e.tags.length>0},f=(E,P)=>{c(j=>j===E?null:j),P==="cancelled"&&!p[E]&&setTimeout(()=>u.current?.focus(),0)},g=zc.filter(({field:E})=>!p[E]&&l!==E),_=Oe(e.completed_at,o,i),x=e.updated_at>0?mt(pt(e.updated_at,s)):"",S=e.updated_at>0?Mn(new Date(e.updated_at*1e3),{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"},o):"",b=p.owner||l==="owner",h=p.team||l==="team",k=p.start||l==="start",T=p.target||l==="target",w=p.estimate||l==="estimate",q=p.tags||l==="tags",C=b||h||k||T||!!_||w||q||e.updated_at>0;return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:n("ui.projects.project_properties.properties")}),g.length>0&&t.jsxs(ds,{children:[t.jsx(ps,{asChild:!0,children:t.jsxs("button",{ref:u,type:"button","data-project-add-field":"",className:M("flex shrink-0 cursor-pointer items-center gap-1 rounded-xs text-meta text-ink-dim","transition-colors duration-fast ease-out-quart hover:text-ink"),children:[t.jsx(it,{className:"size-3","aria-hidden":"true"}),n("ui.projects.project_properties.add")]})}),t.jsx(ms,{align:"end",onCloseAutoFocus:E=>{m.current&&(m.current=!1,E.preventDefault())},children:g.map(({field:E,label:P})=>t.jsx(Ee,{"data-project-add-option":E,onSelect:()=>{m.current=!0,c(E)},children:P},E))})]})]}),C?t.jsxs("dl",{className:"flex flex-col gap-2",children:[b&&t.jsx(Pc,{project:e,commit:r,autoBegin:l==="owner",onRetire:E=>f("owner",E)}),h&&t.jsx(Mc,{project:e,commit:r,label:a,autoBegin:l==="team",onRetire:E=>f("team",E)}),k&&t.jsx(lr,{project:e,commit:r,which:"start",nowMs:s,autoBegin:l==="start",onRetire:E=>f("start",E)}),T&&t.jsx(lr,{project:e,commit:r,which:"target",nowMs:s,autoBegin:l==="target",onRetire:E=>f("target",E)}),_&&t.jsx(ur,{label:n("ui.projects.project_properties.completed"),children:_}),w&&t.jsx(Ic,{project:e,commit:r,autoBegin:l==="estimate",onRetire:E=>f("estimate",E)}),q&&t.jsx(Lc,{project:e,commit:r,autoBegin:l==="tags",onRetire:E=>f("tags",E)}),e.updated_at>0&&t.jsx(ur,{label:n("ui.projects.project_properties.updated"),children:t.jsx("time",{dateTime:new Date(e.updated_at*1e3).toISOString(),title:S,children:x})})]}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_properties.no_dates_estimate_tags_owner_or_team_yet")})]})},Yc=({project:e})=>{F();const s=Ze(),r=nn(),{sending:a,cooling:o,cooldownRemainingMs:i}=Ui(e.id);if(!ye(s.data,"projects_request_update"))return null;const l=ne(e),c=Di(e.id);return t.jsxs(t.Fragment,{children:[t.jsx(Ot,{content:o&&i!==null?Ct(l,i):n("ui.projects.request_update.ask_the_sessions_linked_to_this_project_to_post_a_progress_update"),children:t.jsxs(G,{variant:"secondary",className:"min-w-37","data-tour-tag":"project-request-update","aria-busy":a?!0:void 0,"aria-disabled":o?!0:void 0,"aria-describedby":o?c:void 0,onClick:()=>r(e),children:[a?t.jsx(Te,{size:"sm"}):o?t.jsx(hs,{}):t.jsx(Da,{}),a?n("ui.projects.project_request_update_button.requesting"):o?n("ui.projects.project_request_update_button.requested"):n("ui.projects.project_request_update_button.request_update")]})}),o&&i!==null&&t.jsx("span",{id:c,className:"sr-only",children:Ct(l,i)})]})},dn="plain",pn=e=>`team:${e}`,mn=e=>`agent:${e}`;function Hc(e){return e.startsWith("team:")?{kind:"team",name:e.slice(5)}:e.startsWith("agent:")?{kind:"agent",name:e.slice(6)}:{kind:"plain"}}function Wc(e){return e.kind==="team"?pn(e.name):e.kind==="agent"?mn(e.name):dn}const dr={kind:"plain"},Kc=({open:e,onClose:s,onStart:r,teamsEnabled:a,profilesEnabled:o})=>{F();const[i,l]=d.useState(dr),[c,u]=d.useState(null),[m,p]=d.useState(!1),f=In(e&&a),g=Ln(e&&o);d.useEffect(()=>{e&&(l(dr),u(null),p(!1))},[e]);const _=d.useMemo(()=>{const k=[{id:dn,get name(){return n("ui.projects.project_start_session.nothing_in_particular")},get description(){return n("ui.projects.project_start_session.a_plain_session_assign_a_team_or_agent_later")},get group(){return n("ui.projects.project_start_session.plain")}}];for(const T of f.data??[])k.push({id:pn(T.name),name:Ps(T),keywords:T.name===Ps(T)?void 0:[T.name],description:n("ui.projects.project_start_session.team_manager_manager",{manager:String(T.manager)}),get group(){return n("ui.projects.project_start_session.teams")}});for(const T of(g.data??[]).filter(w=>w.source!=="builtin"))k.push({id:mn(T.name),name:T.name,description:T.description||T.kind,get group(){return n("ui.projects.project_start_session.agents")}});return k},[f.data,g.data]),x=_.find(k=>k.id===Wc(i))??_[0],S=!a||!o,b=f.isLoading||g.isLoading,h=async()=>{p(!0),u(null);try{await r(i),s()}catch(k){u(k instanceof Error&&k.message?k.message:n("ui.projects.project_start_session.the_session_could_not_be_started"))}finally{p(!1)}};return t.jsx(dt,{open:e,onClose:s,title:n("ui.projects.project_start_session.start_a_session"),maxWidth:"sm",dataTourTag:"project-start-session-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(He,{onClick:s,disabled:m,children:n("ui.projects.project_start_session.cancel")}),t.jsxs(vt,{onClick:()=>void h(),disabled:m,children:[m&&t.jsx(Te,{size:"xs"}),n("ui.projects.project_start_session.start_session")]})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx(yr,{label:n("ui.projects.project_start_session.work_with"),placeholder:n("ui.projects.project_start_session.search_teams_and_agents"),options:_,selected:x,onSelect:k=>l(Hc(k.id)),busy:b,busyLabel:n("ui.projects.project_start_session.loading_teams_and_agents")}),t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.projects.project_start_session.the_session_starts_now_links_itself_to_this_project_and_opens_wit")}),S&&t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.projects.project_start_session.this_server_does_not_offer_the_team_or_agent_catalogues_yet_so_on")}),c&&t.jsx("p",{className:"text-body-sm text-danger",children:c})]})})},Vc=({links:e})=>{F();const s=xo(e),r=e.filter(a=>a.todos!==null);return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:n("ui.projects.project_todos.to_dos")}),s&&t.jsx("span",{className:"text-meta text-ink-muted tabular-nums",children:Bs(s)})]}),r.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_todos.no_to_do_snapshots_from_the_linked_sessions_yet_a_session_publish")}):t.jsx("ul",{className:"flex flex-col divide-y divide-hairline",children:r.map(a=>t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx("span",{className:a.title?"min-w-0 flex-1 truncate text-body-sm text-ink":"min-w-0 flex-1 truncate font-mono text-mono-sm text-ink-muted",children:Lt(a)}),a.todos&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:Bs(a.todos)})]},a.session_id))})]})},Xc=({filePath:e,tooltip:s="File actions",icon:r,"aria-label":a="File actions",onShowInCanvas:o})=>{const i=async()=>{if(e)try{await navigator.clipboard.writeText(e),be("File path copied to clipboard")}catch(c){console.error("Failed to copy file path: ",c),de("Failed to copy file path")}},l=()=>{e&&window.api.openFile(e)};return t.jsxs(ds,{children:[t.jsx(Ot,{content:s,children:t.jsx(ps,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"icon-sm","aria-label":a,onClick:c=>c.stopPropagation(),children:r??t.jsx(fr,{"aria-hidden":"true"})})})}),t.jsxs(ms,{align:"end",className:"min-w-45",onClick:c=>c.stopPropagation(),children:[o&&t.jsxs(Ee,{onSelect:o,children:[t.jsx(Fn,{"aria-hidden":"true"}),t.jsx("span",{children:"Show in canvas"})]}),t.jsxs(Ee,{onSelect:l,children:[t.jsx(hr,{"aria-hidden":"true"}),t.jsx("span",{children:"Open file"})]}),t.jsxs(Ee,{onSelect:()=>window.api.showItemInFolder(e),children:[t.jsx(qn,{"aria-hidden":"true"}),t.jsx("span",{children:"Open folder"})]}),t.jsxs(Ee,{onSelect:i,children:[t.jsx(Un,{"aria-hidden":"true"}),t.jsx("span",{children:"Copy file path"})]})]})]})},Jc=/[/\\]/;function _n(e){if(e.name)return e.name;const s=e.path.split(Jc);return s[s.length-1]||n("ui.projects.project_updates.attachment")}const Qc=({attachment:e})=>{F();const s=_n(e),r=ho(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:n("ui.projects.project_updates.open_name",{name:String(s)}),children:[t.jsx(hr,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),t.jsx("span",{className:"truncate text-body-sm text-ink",children:s})]}),r&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:r}),t.jsx(Xc,{filePath:e.path,"aria-label":n("ui.projects.project_updates.file_actions_for_name",{name:String(s)})})]})},Zc=({attachment:e})=>{F();const s=_n(e),r=Bn(e.path,{mimeType:$n(e.name||e.path),sizeBytes:e.bytes});return r.status==="ready"?t.jsx("div",{className:"inline-block max-w-full",children:t.jsx(zn,{file:e.path,src:r.url,label:s,conversationId:""})}):r.status==="loading"?t.jsx(Gn,{children:t.jsxs("span",{className:"sr-only",children:[n("ui.projects.project_updates.loading"),s]})}):t.jsx(Yn,{name:s})},el=({attachments:e})=>t.jsx("div",{className:"flex flex-wrap items-start gap-2",children:e.map(s=>s.kind==="image"?t.jsx(Zc,{attachment:s},`${s.path}:${s.added_at}`):t.jsx(Qc,{attachment:s},`${s.path}:${s.added_at}`))}),tl=({update:e,nowMs:s})=>{const r=F(),a=fo(e,r,s);return t.jsxs("article",{className:"flex flex-col gap-2 rounded-sm px-2 py-3",children:[a.length>0&&t.jsx("p",{className:"flex flex-wrap items-baseline gap-x-2 text-meta text-ink-muted",children:a.map((o,i)=>t.jsxs(d.Fragment,{children:[i>0&&t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{children:o.text})]},o.key))}),e.text&&t.jsx(ut,{children:e.text}),e.attachments.length>0&&t.jsx(el,{attachments:e.attachments})]})},sl=({updates:e,nowMs:s})=>{const r=F(),a=lo(e.length),o=jo(e,r,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:n("ui.projects.project_updates.updates")}),a&&t.jsx("span",{className:"text-meta text-ink-muted",children:a})]}),e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_updates.no_updates_yet_progress_reported_by_you_or_by_the_sessions_workin")}):t.jsx("div",{className:"flex flex-col gap-4",children:o.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,c)=>t.jsx(tl,{update:l,nowMs:s},`${l.at}:${l.by}:${c}`))})]},i.key||"ungrouped"))})]})},rl="project_not_found",nl=({projectKey:e,nowMs:s})=>{F();const r=Dt(),a=Ze(),o=gr(ye(a.data,"team_catalogue")),i=Sr(e,!0),l=Cr(),c=Er(),u=qa(),m=Ua(),p=La(),f=Fa(),[g,_]=d.useState(!1),[x,S]=d.useState(!1),b=l.isPending||c.isPending||u.isPending||m.isPending||p.isPending||f.isPending;if(i.isLoading)return t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(Te,{label:n("ui.projects.project_detail.loading_project")})});if(i.isError||!i.data){const j=i.error instanceof Rt&&(i.error.code===rl||i.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(Ht,{variant:"danger",className:"w-full",children:j?n("ui.projects.project_detail.this_project_could_not_be_found_it_may_have_been_deleted"):i.error instanceof Error&&i.error.message?i.error.message:n("ui.projects.project_detail.the_project_could_not_be_read")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(G,{variant:"secondary",onClick:()=>void i.refetch(),children:n("ui.projects.project_detail.try_again")}),t.jsxs(G,{variant:"secondary",onClick:()=>void r("/projects"),children:[t.jsx(Is,{}),n("ui.projects.project_detail.all_projects")]})]})]})}const{project:h,links:k}=i.data,T=ne(h),w=(j,D)=>l.mutateAsync({key:h.id,fields:j,...D?.forceDone===!0?{forceDone:!0}:{}}),q=h.team?o(h.team):null,C=go(h.milestones.filter(j=>j.completed_at!==null).length,h.milestones.length),E=async(j,D,R,L)=>{const W=kt.getState(),B=Wn(null,j,W.drafts);if(!B)return!1;try{const{images:Y,unreadable:J,overflow:Z}=await Kn(L,D),me=Vn(J);if(me)return de(me),!1;const oe=Xn(Z);if(oe)return de(oe),!1;const ee=Jn(D,Y);if(ee)return de(ee),!1;if(await Qn(B,{text:D,attachments:L,images:Y,mode:R,cwd:W.cwd},j)===null)return de(n("ui.projects.project_detail.that_session_already_has_a_message_going_out_try_again_in_a_momen")),!1;const y=k.find(v=>v.session_id===j);return be(n("ui.projects.project_detail.sent_to_value1",{value1:String(y?Lt(y):j)})),!0}catch(Y){return de(Y instanceof Error&&Y.message?Y.message:n("ui.projects.project_detail.the_message_was_not_sent")),!1}},P=async j=>{const D=kt.getState(),R=j.kind==="plain"?void 0:{kind:j.kind,name:j.name},L=await D.createSession(D.cwd||"~",R);if(!L)throw new Error(D.error??n("ui.projects.project_detail.the_session_could_not_be_started"));Zn.getState().setCurrentInput(L,yo(h));let W=null;try{await p.mutateAsync({key:h.id,sessionId:L})}catch(B){W=B instanceof Error&&B.message?B.message:n("ui.projects.project_detail.the_link_was_refused")}if(W)de(n("ui.projects.project_detail.session_started_but_linking_it_failed_linkfailure",{linkFailure:String(W)}));else{const B=R?n("ui.projects.project_detail.with_value1",{value1:String(vo(R))}):"";be(n("ui.projects.project_detail.session_started_withtarget_and_linked_to_displayname",{withTarget:String(B),displayName:String(T)}))}await wr(r,L)};return t.jsx(tc,{children: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 r("/projects"),className:"flex w-fit items-center gap-1.5 text-body-sm text-ink-muted hover:text-ink",children:[t.jsx(Is,{className:"size-4"}),n("ui.projects.project_detail.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-1 flex-wrap items-start gap-x-3 gap-y-2",children:[t.jsx(Dc,{project:h,commit:w}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1.5",children:[t.jsx(Ac,{project:h,commit:w}),h.progress_stale&&t.jsx(ke,{variant:"warning",children:n("ui.projects.project_model.stale")})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(Yc,{project:h}),t.jsxs(G,{variant:"secondary",onClick:()=>_(!0),"data-tour-tag":"project-delete",children:[t.jsx(Hn,{}),n("ui.projects.project_detail.delete")]})]})]})]}),t.jsx(Oc,{project:h,commit:w}),t.jsx(Gc,{project:h,nowMs:s,commit:w,teamLabel:q}),h.updates.length===0&&h.progress&&t.jsxs("section",{className:"flex flex-col gap-2",children:[t.jsx("h2",{className:"text-title text-ink",children:n("ui.projects.project_detail.progress")}),t.jsx(ut,{className:"text-body",children:h.progress}),t.jsx("p",{className:"text-meta text-ink-muted",children:Ha(h,s)})]}),t.jsx($c,{milestones:h.milestones,summary:C,busy:b,onToggle:(j,D)=>{u.mutateAsync({key:h.id,name:j,completed:D}).catch(R=>{de(R instanceof Error&&R.message?R.message:n("ui.projects.project_detail.the_milestone_was_not_updated"))})},onRemove:j=>{m.mutateAsync({key:h.id,name:j}).catch(D=>{de(D instanceof Error&&D.message?D.message:n("ui.projects.project_detail.the_milestone_was_not_removed"))})},onAdd:(j,D)=>{u.mutateAsync({key:h.id,name:j,targetDate:D}).catch(R=>{de(R instanceof Error&&R.message?R.message:n("ui.projects.project_detail.the_milestone_was_not_added"))})}}),t.jsx(Bc,{projectKey:h.id,links:k,busy:b,onStartSession:()=>S(!0),onQuickSend:E,onLink:j=>{p.mutateAsync({key:h.id,sessionId:j}).catch(D=>{de(D instanceof Error&&D.message?D.message:n("ui.projects.project_detail.the_session_was_not_linked"))})},onUnlink:j=>{f.mutateAsync({key:h.id,sessionId:j}).catch(D=>{de(D instanceof Error&&D.message?D.message:n("ui.projects.project_detail.the_session_was_not_unlinked"))})}}),t.jsx(Vc,{links:k}),t.jsx(sl,{updates:h.updates,nowMs:s}),t.jsx(an,{open:g,projectName:h.name,onClose:()=>_(!1),onConfirm:async j=>{await c.mutateAsync({key:h.id,confirmedName:j}),be(n("ui.projects.project_detail.project_deleted")),r("/projects")}}),t.jsx(Kc,{open:x,onClose:()=>S(!1),onStart:P,teamsEnabled:ye(a.data,"team_catalogue"),profilesEnabled:ye(a.data,"profile_catalogue")})]})})},al="payments-migration",pr={name:"",title:"",owner:"",team:"",description:"",status:"active",tags:"",startDate:"",targetDate:"",estimate:"",estimateUnit:"points"},ol=({open:e,onClose:s,onSubmit:r})=>{F();const[a,o]=d.useState(pr),[i,l]=d.useState({}),[c,u]=d.useState(null),m=d.useRef(null),[p,f]=d.useState(!1),[g,_]=d.useState(!1),[x,S]=d.useState(!1),b=d.useId(),h=d.useRef(null);d.useEffect(()=>{e&&(o({...pr,description:ar}),l({}),u(null),f(!1),_(!1),S(!1))},[e]),d.useEffect(()=>{c&&m.current?.scrollIntoView({block:"nearest"})},[c]);const k=(j,D)=>{o(R=>({...R,[j]:D}))},T=g?a.name:uc(a.title),w=j=>cn(j,h,D=>k("description",D)),q=(j,D)=>{const R={},L=Wt(D);L&&(R.name=L);const W=Xr(j.description);W&&(R.description=W);const B=rs(j.tags).error;B&&(R.tags=B);const Y=ts(j.startDate);Y&&(R.startDate=Y);const J=ts(j.targetDate);if(J)R.targetDate=J;else if(!Y){const ee=ss(j.startDate,j.targetDate);ee&&(R.targetDate=ee)}if(j.estimate.trim()){const ee=Jr(j.estimate);ee&&(R.estimate=ee)}const Z=es(j.title);Z&&(R.title=Z);const me=St(j.owner,"owner");me&&(R.owner=me);const oe=St(j.team,"team");return oe&&(R.team=oe),R},C=async()=>{const j=T.trim(),D=q(a,j);if(l(D),Object.keys(D).length>0)return;f(!0),u(null);const R=lt(a.tags);try{const L={};a.title.trim()&&(L.title=a.title.trim()),a.owner.trim()&&(L.owner=a.owner.trim()),a.team.trim()&&(L.team=a.team.trim()),a.startDate&&(L.start_date=a.startDate),a.targetDate&&(L.target_date=a.targetDate),a.estimate&&(L.estimate=Number(a.estimate),L.estimate_unit=a.estimateUnit),await r({fields:{name:j,...a.description.trim()&&a.description.trim()!==ar?{description:a.description.trim()}:{},status:a.status,...R.length>0?{tags:R}:{}},...Object.keys(L).length>0?{followUp:L}:{}}),s()}catch(L){const W=L instanceof Error&&L.message?L.message:"";u(ft(W)||n("ui.projects.project_form_dialog.the_project_was_not_saved"))}finally{f(!1)}},E=n("ui.projects.project_form_dialog.new_project"),P=a.description.length>Je;return t.jsx(dt,{open:e,onClose:s,title:E,fullWidth:!0,maxWidth:"md",dialogProps:{closeDisabled:p,onEscapeKeyDown:j=>{p&&j.preventDefault()},onInteractOutside:j=>{p&&j.preventDefault()}},dataTourTag:"project-create-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(He,{onClick:s,disabled:p,children:n("ui.projects.project_form_dialog.cancel")}),t.jsxs(vt,{"data-project-submit":"",onClick:()=>void C(),disabled:p,children:[p&&t.jsx(Te,{size:"xs"}),n("ui.projects.project_form_dialog.create_project")]})]}),children:t.jsxs("form",{className:"flex flex-col gap-6 px-1 py-1",onSubmit:j=>{j.preventDefault(),C()},children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:`${b}-title`,children:n("ui.projects.project_form_dialog.title")}),t.jsx(ue,{id:`${b}-title`,"data-project-title":"",value:a.title,onChange:j=>k("title",j.target.value),placeholder:n("ui.projects.project_form_dialog.payments_migration"),autoFocus:!0,className:"h-10 text-heading","aria-invalid":!!i.title}),i.title&&t.jsx("p",{className:"text-meta text-danger",children:i.title}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(pe,{htmlFor:`${b}-key`,className:"shrink-0 text-meta text-ink-muted",children:n("ui.projects.project_form_dialog.key")}),t.jsx(ue,{id:`${b}-key`,"data-project-key":"",value:T,onChange:j=>{_(!0),k("name",j.target.value)},placeholder:al,"aria-invalid":!!i.name,className:"h-7 max-w-56 font-mono text-mono-sm"}),t.jsx("span",{className:"text-meta text-ink-muted",children:g?n("ui.projects.project_form_dialog.letters_digits_dot_underscore_or_dash_no_spaces"):n("ui.projects.project_form_dialog.derived_from_the_title_until_you_edit_it")})]}),i.name&&t.jsx("p",{className:"text-meta text-danger",children:i.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(pe,{htmlFor:`${b}-description`,children:n("ui.projects.project_form_dialog.description")}),t.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:n("ui.projects.project_form_dialog.description_mode")}),t.jsx("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:["write","preview"].map(j=>t.jsx("button",{type:"button","data-project-description-mode":j,"aria-pressed":x===(j==="preview"),onClick:()=>S(j==="preview"),className:M("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",x===(j==="preview")&&"bg-surface text-ink"),children:j==="write"?n("ui.projects.project_form_dialog.write"):n("ui.projects.project_form_dialog.preview")},j))})]})]}),x?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:a.description.trim()?t.jsx(ut,{className:"text-body-sm",children:a.description}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_form_dialog.nothing_to_preview_yet")})}):t.jsx(br,{ref:h,id:`${b}-description`,"data-project-description":"",value:a.description,onChange:j=>k("description",j.target.value),onPaste:w,rows:8,placeholder:n("ui.projects.project_form_dialog.markdown_headings_lists_code"),"aria-invalid":P||!!i.description,className:"h-44 resize-none"}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.description?t.jsx("p",{className:"text-meta text-danger",children:i.description}):t.jsx("span",{}),t.jsxs("p",{className:M("text-meta tabular-nums",P?"text-danger":"text-ink-muted"),children:[a.description.length,"/",Je]})]})]}),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(pe,{children:n("ui.projects.project_form_dialog.status")}),t.jsxs(We,{value:a.status,onValueChange:j=>k("status",j),children:[t.jsx(Ke,{"aria-label":n("ui.projects.project_form_dialog.status"),children:t.jsx(Ve,{})}),t.jsx(Xe,{children:Rr.map(j=>t.jsx(Ae,{value:j.value,children:j.label},j.value))})]}),a.status==="done"&&t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.projects.project_form_dialog.moving_a_project_to_done_stamps_today_as_its_completion_date")})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:`${b}-owner`,children:n("ui.projects.project_form_dialog.owner")}),t.jsx(ue,{id:`${b}-owner`,"data-project-owner":"",value:a.owner,onChange:j=>k("owner",j.target.value),placeholder:n("ui.projects.examples.owner"),"aria-invalid":!!i.owner}),i.owner&&t.jsx("p",{className:"text-meta text-danger",children:i.owner})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:`${b}-team`,children:n("ui.projects.project_form_dialog.team")}),t.jsx(ue,{id:`${b}-team`,value:a.team,onChange:j=>k("team",j.target.value),placeholder:n("ui.projects.examples.team"),"aria-invalid":!!i.team}),i.team&&t.jsx("p",{className:"text-meta text-danger",children:i.team})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:`${b}-target`,children:n("ui.projects.project_form_dialog.target_date")}),t.jsx(ue,{id:`${b}-target`,"data-project-target":"",value:a.targetDate,onChange:j=>k("targetDate",j.target.value),placeholder:"YYYY-MM-DD","aria-invalid":!!i.targetDate}),i.targetDate&&t.jsx("p",{className:"text-meta text-danger",children:i.targetDate})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:`${b}-start`,children:n("ui.projects.project_form_dialog.start_date")}),t.jsx(ue,{id:`${b}-start`,value:a.startDate,onChange:j=>k("startDate",j.target.value),placeholder:"YYYY-MM-DD","aria-invalid":!!i.startDate}),i.startDate&&t.jsx("p",{className:"text-meta text-danger",children:i.startDate})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:`${b}-estimate`,children:n("ui.projects.project_form_dialog.estimate")}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ue,{id:`${b}-estimate`,value:a.estimate,onChange:j=>k("estimate",j.target.value),placeholder:"13",inputMode:"decimal","aria-invalid":!!i.estimate,className:"max-w-28"}),t.jsxs(We,{value:a.estimateUnit,onValueChange:j=>k("estimateUnit",j),children:[t.jsx(Ke,{"aria-label":n("ui.projects.project_form_dialog.estimate_unit"),className:"max-w-32",children:t.jsx(Ve,{})}),t.jsxs(Xe,{children:[t.jsx(Ae,{value:"points",children:n("ui.projects.project_form_dialog.points")}),t.jsx(Ae,{value:"days",children:n("ui.projects.project_form_dialog.days")})]})]})]}),i.estimate&&t.jsx("p",{className:"text-meta text-danger",children:i.estimate})]}),t.jsxs("div",{className:"col-span-2 flex flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:`${b}-tags`,children:n("ui.projects.project_form_dialog.tags")}),t.jsx(ue,{id:`${b}-tags`,value:a.tags,onChange:j=>k("tags",j.target.value),placeholder:n("ui.projects.project_form_dialog.q4_payments"),"aria-invalid":!!i.tags}),i.tags?t.jsx("p",{className:"text-meta text-danger",children:i.tags}):t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.projects.project_form_dialog.comma_separated_up_to_8_lowercase_letters_digits_underscore_or_da")})]})]}),c&&t.jsx("p",{ref:m,className:"text-body-sm text-danger",children:c})]})})},fn=({children:e})=>{const s=d.useRef(null),[r,a]=d.useState(!1),o=()=>{const i=s.current;i&&a(i.scrollTop+i.clientHeight<i.scrollHeight-1)};return d.useEffect(o),t.jsx("div",{ref:s,onScroll:o,className:M("max-h-[min(70vh,32rem)] overflow-y-auto overscroll-contain",r&&"[mask-image:linear-gradient(to_bottom,black_calc(100%-12px),transparent)]"),children:e})},il=({label:e,count:s,selected:r,onToggle:a})=>{const o=d.useId();return t.jsxs("div",{className:"flex items-center gap-2 rounded-sm px-1 py-1 hover:bg-sunken",children:[t.jsx(vr,{id:o,checked:r,onCheckedChange:()=>a()}),t.jsx(pe,{htmlFor:o,className:"min-w-0 flex-1 cursor-pointer truncate font-normal text-body-sm text-ink",children:e}),t.jsx("span",{className:"text-meta text-ink-dim tabular-nums",children:s})]})},cl=({column:e,spec:s,onChange:r})=>{F();const a=d.useId(),o=s!==null&&s.key===e,i=o?s.direction:Bt(e),l=i==="asc"?"desc":"asc",c=()=>r({key:e,direction:o?l:Bt(e)}),u=s===null?"default":o?"sorted":"other";return t.jsxs("fieldset",{className:"m-0 flex flex-col gap-0.5 border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:n("ui.projects.project_filters_panel.sort_by_sortcolumnlabel_column",{sortColumnLabel_column:String(Qe(e))})}),t.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-sm px-1 py-1 text-body-sm hover:bg-sunken",children:[t.jsx("input",{type:"radio",name:a,checked:u==="default",onChange:()=>r(null),className:"m-0 size-3.5 shrink-0 accent-[var(--color-accent)]"}),t.jsx("span",{className:M("min-w-0 flex-1 truncate",u==="default"?"text-ink":"text-ink-muted"),children:n("ui.projects.project_sort.default_as_listed")})]}),t.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-sm px-1 py-1 text-body-sm hover:bg-sunken",children:[t.jsx("input",{type:"radio",name:a,checked:u==="sorted",onChange:c,onClick:()=>{u==="sorted"&&c()},onKeyDown:m=>{u==="sorted"&&(m.key!==" "&&m.key!=="Enter"||(m.preventDefault(),c()))},className:"m-0 size-3.5 shrink-0 accent-[var(--color-accent)]"}),t.jsx("span",{className:M("min-w-0 flex-1 truncate",u==="sorted"?"text-ink":"text-ink-muted"),children:n("ui.projects.project_filters_panel.sort_by_sortcolumnlabel_column_value2",{sortColumnLabel_column:String(Qe(e)),value2:String(vs(e,o?i:Bt(e)))})})]})]})},ll=({facet:e,options:s,onToggle:r})=>(F(),t.jsxs("div",{className:"flex flex-col gap-0.5 border-b border-hairline px-3 py-2 last:border-b-0",children:[t.jsx("span",{className:"px-1 text-meta text-ink-muted",children:ot[e]}),s.map(a=>t.jsx(il,{label:a.label,count:a.count,selected:a.selected,onToggle:()=>r(e,a.value)},`${e}:${a.value??"none"}`))]})),jn=({projects:e,state:s,query:r,todayMs:a,onToggle:o,onClearAll:i,scope:l,sort:c})=>{F();const u=l===void 0?Qo(e,s,a):l===null?[]:[Vr(l,e,s,a)],m=!ct(s)||r.trim()!=="";return t.jsxs("div",{className:"flex flex-col",children:[l===void 0&&t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-hairline px-3 py-2",children:[t.jsx("span",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_filters_panel.filters")}),m&&t.jsx(G,{variant:"link",size:"sm",onClick:i,children:n("ui.projects.project_filters_panel.clear_all")})]}),c&&t.jsxs("div",{className:"flex flex-col gap-0.5 border-b border-hairline px-3 py-2",children:[t.jsx("span",{className:"px-1 text-meta text-ink-muted",children:n("ui.projects.project_filters_panel.sort_by_key",{key:String(Qe(c.key))})}),t.jsx(cl,{column:c.key,spec:c.spec,onChange:c.onChange})]}),u.map(p=>t.jsx(ll,{facet:p.facet,options:p.options,onToggle:o},p.facet))]})},ul=({team:e,count:s,headingId:r,className:a,...o})=>(F(),t.jsxs("div",{...o,"data-glass-well":"",className:M("flex h-8 cursor-default items-center gap-2 bg-surface px-3 text-meta",a),children:[t.jsx("h3",{id:r,className:"truncate text-ink",children:e??n("ui.projects.project_model.no_team")}),t.jsx("span",{className:"shrink-0 text-ink-muted","aria-label":Ka(s),children:s})]})),Ce=[{key:"name",get label(){return n("ui.projects.project_list.project")},className:"min-w-0 flex-1",sort:"name",facet:null},{key:"status",get label(){return n("ui.projects.project_list.status")},className:"w-20 shrink-0",sort:"status",facet:"status"},{key:"target",get label(){return n("ui.projects.project_list.target")},className:"hidden w-32 shrink-0 @[40rem]:block",sort:"target",facet:"target"},{key:"estimate",get label(){return n("ui.projects.project_list.estimate")},className:"hidden w-16 shrink-0 @[40rem]:block",sort:"estimate",facet:"estimate"},{key:"milestones",get label(){return n("ui.projects.project_list.milestones")},className:"hidden w-20 shrink-0 @[34rem]:block",sort:"milestones",facet:"milestones"},{key:"live",get label(){return n("ui.projects.project_list.live")},className:"hidden w-14 shrink-0 @[34rem]:block",sort:"live",facet:"live"},{key:"progress",get label(){return n("ui.projects.project_list.progress")},className:"w-40 shrink-0",sort:"progress",facet:"progress"}];function dl(e,s){const r=pt(e.progress_updated_at,s);return r?mt(r):n("ui.projects.project_list.not_reported")}const pl=({direction:e})=>e==="asc"?t.jsx(Nr,{size:10,className:"shrink-0","aria-hidden":"true"}):t.jsx(xr,{size:10,className:"shrink-0","aria-hidden":"true"}),ml=({projects:e,nowMs:s,onOpen:r,sort:a,onSortChange:o,searchPopulation:i,filters:l,query:c,todayMs:u,onToggleFilter:m,onClearFilters:p,teamLabelFor:f=g=>g})=>{const g=F(),_=a?ii(e,a):e,x=xs(_,_t),S=d.useId(),b=C=>`${S}-team-${C}`,[h,k]=d.useState(0),T=d.useRef([]),w=(C,E)=>{const P=Ce.length;for(let j=1;j<=P;j+=1){const D=(C+E*j+P*P)%P,R=T.current[D];if(R&&R.offsetParent!==null){k(D),R.focus();return}}},q=C=>E=>{E.key!=="ArrowLeft"&&E.key!=="ArrowRight"||(E.preventDefault(),w(C,E.key==="ArrowRight"?1:-1))};return t.jsxs("div",{className:"@container flex min-h-0 flex-1 flex-col","data-testid":"project-list",children:[t.jsx("table",{className:"block shrink-0","aria-label":n("ui.projects.project_list.project_columns"),children:t.jsx("thead",{className:"block",children:t.jsx("tr",{className:"flex items-center gap-3 px-9 py-2 text-meta text-ink-muted",children:Ce.map((C,E)=>{const P=a!==null&&a.key===C.sort;return t.jsx("th",{scope:"col","aria-sort":P?a.direction==="desc"?"descending":"ascending":"none",className:M(C.className,"p-0 text-left font-normal"),children:t.jsxs(_s,{children:[t.jsx(fs,{asChild:!0,children:t.jsxs("button",{type:"button",ref:j=>{T.current[E]=j},tabIndex:E===h?0:-1,"data-project-column":C.key,onFocus:()=>k(E),onKeyDown:q(E),className:M("group flex w-full min-w-0 items-center gap-1 rounded-xs text-left","transition-colors duration-fast ease-out-quart",P?"text-ink":"hover:text-ink"),children:[t.jsx("span",{className:"truncate",children:C.label}),P?t.jsx(pl,{direction:a.direction}):t.jsx(ea,{size:10,className:"shrink-0 text-ink-dim transition-colors duration-fast ease-out-quart group-hover:text-ink","aria-hidden":"true"})]})}),t.jsx(js,{align:"start","aria-label":n("ui.projects.project_list.label_column",{label:String(C.label)}),className:"w-72 p-0",children:t.jsx(fn,{children:t.jsx(jn,{projects:i,state:l,query:c,todayMs:u,onToggle:m,onClearAll:p,scope:C.facet,sort:{key:C.sort,spec:a,onChange:o}})})})]})},C.key)})})})}),t.jsx("ul",{className:"min-h-0 flex-1 overflow-y-auto px-6",children:x.map((C,E)=>t.jsxs("li",{children:[t.jsx(ul,{team:C.team==null?null:f(C.team),count:C.items.length,headingId:b(E),className:"sticky top-0 z-10","data-project-team":C.team??""}),t.jsx("ul",{"aria-labelledby":b(E),className:"divide-y divide-hairline",children:C.items.map(P=>{const j=new Map(Mr(P,g).map(L=>[L.key,L.text])),D=Pr(P.milestones_completed,P.milestones_total),R=gs(P.live_sessions);return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>r(P),"data-project-name":P.name,className:M("flex w-full items-center gap-3 px-3 py-2 text-left","transition-colors duration-fast ease-out-quart","hover:bg-row-hover"),children:[t.jsx("span",{className:M(Ce[0].className,"truncate text-body-sm text-ink"),children:ne(P)}),t.jsx("span",{className:Ce[1].className,children:t.jsx(un,{status:P.status})}),t.jsx("span",{className:M(Ce[2].className,"truncate text-meta text-ink-muted"),children:j.get("target")??j.get("completed")??""}),t.jsx("span",{className:M(Ce[3].className,"truncate text-meta text-ink-muted"),children:j.get("estimate")??""}),t.jsx("span",{className:M(Ce[4].className,"truncate text-meta text-ink-muted"),children:D}),t.jsx("span",{className:M(Ce[5].className,"truncate text-meta text-ink-muted"),children:R}),t.jsxs("span",{className:M(Ce[6].className,"flex items-center gap-2"),children:[t.jsx("span",{className:"truncate text-meta text-ink-muted",children:dl(P,s)}),P.progress_stale&&t.jsx(ke,{variant:"warning",children:n("ui.projects.project_model.stale")})]})]})},P.id)})})]},C.team??""))})]})},Tt=224,mr=36,_l={get day(){return n("ui.projects.project_timeline.days")},get week(){return n("ui.projects.project_timeline.weeks")},get month(){return n("ui.projects.project_timeline.months")},get quarter(){return n("ui.projects.project_timeline.quarters")}},fl=({items:e,nowMs:s,onOpen:r,pendingDetails:a,failedDetails:o,onRetryDetails:i,teamLabelFor:l=c=>c})=>{F();const[c,u]=d.useState(null),[m,p]=d.useState(0),f=d.useRef(null),g=ws(s),_=d.useMemo(()=>ui(e,g),[e,g]),x=d.useMemo(()=>di(e),[e]),S=d.useMemo(()=>xs(x.dated,C=>_t(C.project)),[x]);d.useLayoutEffect(()=>{const C=f.current;if(!C)return;const E=()=>p(C.clientWidth);if(E(),typeof ResizeObserver>"u")return;const P=new ResizeObserver(E);return P.observe(C),()=>P.disconnect()},[]);const b=Math.max(m-Tt-24,160),h=_?ci(Ks(_.startMs,_.endMs),b):"month",k=c??h,T=C=>{const E=De.indexOf(k),P=De[E-C];P&&u(P)},w=ks[k],q=_?Ks(_.startMs,_.endMs)*w:0;return t.jsxs("div",{ref:f,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:o>0?n("ui.projects.timeline.read_failed",{count:o}):n("ui.projects.project_timeline.length_dated_length_2_without_dates_value3",{length:V(x.dated.length,{useGrouping:!1}),length_2:V(x.undated.length,{useGrouping:!1}),value3:String(a>0?n("ui.projects.project_timeline.loading_milestones_for_pendingdetails",{pendingDetails:V(a,{useGrouping:!1})}):"")})}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[o>0&&t.jsx(G,{variant:"secondary",size:"sm",onClick:i,children:n("ui.projects.project_timeline.try_again")}),t.jsx(G,{variant:"secondary",size:"icon","aria-label":n("ui.projects.project_timeline.zoom_in"),title:n("ui.projects.project_timeline.zoom_in_finer"),disabled:!_||k===De[0],onClick:()=>T(1),children:t.jsx(it,{})}),t.jsx("span",{className:"w-16 text-center text-meta text-ink-muted",children:_l[k]}),t.jsx(G,{variant:"secondary",size:"icon","aria-label":n("ui.projects.project_timeline.zoom_out"),title:n("ui.projects.project_timeline.zoom_out_coarser"),disabled:!_||k===De[De.length-1],onClick:()=>T(-1),children:t.jsx(pa,{})})]})]}),_&&x.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(jl,{startMs:_.startMs,endMs:_.endMs,tier:k,pxPerDay:w,trackPx:q}),S.map(C=>t.jsxs("div",{children:[t.jsx("div",{className:"sticky top-0 z-20 flex items-stretch bg-canvas","data-project-team":C.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:Tt},children:[t.jsx("span",{className:"truncate text-ink",children:C.team==null?n("ui.projects.project_model.no_team"):l(C.team)}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:C.items.length})]})}),C.items.map(E=>t.jsx(hl,{item:E,spanStart:_.startMs,pxPerDay:w,trackPx:q,today:g,onOpen:()=>r(E)},E.project.id))]},C.team??""))]})}):null,x.undated.length>0&&t.jsx("div",{className:"shrink-0 px-9 py-2","data-project-undated-callout":"",children:t.jsxs(jr,{defaultOpen:x.dated.length===0,triggerClassName:"text-ink hover:bg-row-hover hover:text-ink",chevronClassName:"text-ink-dim",rowClassName:"min-h-8 py-0",summary:t.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-meta",children:[t.jsx(Ca,{size:14,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),t.jsx("span",{className:"truncate text-ink",children:pi(x.undated.length)})]}),children:[x.dated.length===0&&t.jsx("p",{className:"pb-1 text-meta text-ink-muted",children:n("ui.projects.project_timeline.set_a_start_date_a_target_date_or_a_milestone_date_and_it_will_ap")}),t.jsx("ul",{className:"flex max-h-24 flex-wrap gap-x-3 gap-y-1 overflow-y-auto",children:x.undated.map(C=>t.jsx("li",{children:t.jsx("button",{type:"button",className:"rounded-sm text-meta text-ink hover:bg-row-hover focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent",onClick:()=>r(C),children:ne(C.project)})},C.project.id))})]})})]})},jl=({startMs:e,endMs:s,tier:r,pxPerDay:a,trackPx:o})=>{const i=yi(e,s,r);return t.jsxs("div",{className:"flex items-stretch",children:[t.jsx("span",{className:"sticky left-0 z-10 shrink-0 bg-canvas",style:{width:Tt}}),t.jsx("span",{className:"relative block h-6",style:{width:o},children:i.map(l=>t.jsxs("span",{className:"absolute top-0 h-full",style:{left:Ie(e,l.dayMs)*a},children:[t.jsx("span",{className:M("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))})]})},hl=({item:e,spanStart:s,pxPerDay:r,trackPx:a,today:o,onOpen:i})=>{const{project:l}=e,c=mi(e),u=_i(e),m=p=>new Date(p).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-row-hover",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:Tt,height:mr},children:t.jsx("span",{className:"truncate text-body-sm text-ink",children:ne(l)})}),t.jsxs("span",{className:"relative block",style:{width:a,height:mr},children:[c&&t.jsx("span",{className:"absolute top-1/2 h-1.5 -translate-y-1/2 rounded-full bg-accent/75",style:{left:Ie(s,c.fromMs)*r,width:(Ie(c.fromMs,c.toMs)+1)*r},title:`${Oe(m(c.fromMs))} → ${Oe(m(c.toMs))}`}),u.map(p=>t.jsx("span",{"data-milestone":p.status,className:M("absolute top-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rotate-45",p.status==="completed"&&"bg-success",p.status==="overdue"&&"bg-warning",p.status==="upcoming"&&"border-[1.5px] border-ink-muted bg-surface"),style:{left:Ie(s,p.dayMs)*r},title:`${p.name} · ${p.status} · ${Oe(m(p.dayMs))}`},`${p.name}-${p.dayMs}`)),t.jsx("span",{className:"absolute inset-y-0 w-px bg-accent/75",style:{left:Ie(s,o)*r},"aria-hidden":"true"})]})]})},gl=({projects:e,query:s,onQueryChange:r,filters:a,onFiltersChange:o,onClearAll:i,todayMs:l,resultText:c,countRevealClass:u="@[37rem]:inline",trailing:m,disabled:p=!1,searchFieldRef:f})=>{F();const[g,_]=d.useState(!1),x=d.useRef(!1),S=Ko(a),b=kr(c??"",300),h=s.trim()!==""||!ct(a);return t.jsxs("div",{className:"ml-auto flex min-w-0 items-center gap-3",children:[t.jsxs("div",{className:"relative w-full min-w-0 max-w-[400px]",children:[t.jsx(ta,{size:16,className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim","aria-hidden":"true"}),t.jsx(ue,{ref:f,inputSize:"sm",value:s,onChange:k=>r(k.target.value),onKeyDown:k=>{k.key==="Escape"&&(s?r(""):k.currentTarget.blur())},placeholder:n("ui.projects.projects_toolbar.search_projects"),"aria-label":n("ui.projects.projects_toolbar.search_projects"),autoComplete:"off",spellCheck:!1,className:"pl-9"}),s?t.jsx(G,{variant:"ghost",size:"icon-sm",className:"absolute top-1/2 right-1 -translate-y-1/2",onClick:()=>sa(f.current,r),"aria-label":n("ui.projects.projects_toolbar.clear_search"),children:t.jsx(Pt,{"aria-hidden":"true"})}):t.jsx("span",{className:"pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 text-ink-dim",children:t.jsx(ra,{shortcut:"/"})})]}),t.jsxs(_s,{open:g,onOpenChange:_,children:[t.jsx(fs,{asChild:!0,children:t.jsxs(G,{variant:"secondary",size:"sm",disabled:p,"data-project-filters-button":"",children:[t.jsx(Ta,{size:14,"aria-hidden":"true"}),n("ui.projects.projects_toolbar.filters"),S>0&&t.jsx(ke,{variant:"neutral",children:S})]})}),t.jsx(js,{align:"end","aria-label":n("ui.projects.projects_toolbar.filters"),className:"w-80 p-0",onCloseAutoFocus:k=>{x.current&&(x.current=!1,k.preventDefault())},children:t.jsx(fn,{children:t.jsx(jn,{projects:e,state:a,query:s,todayMs:l,onToggle:(k,T)=>o(Hr(a,k,T)),onClearAll:()=>{i(),x.current=!0,_(!1),f.current?.focus()}})})})]}),h&&c!==null&&t.jsx("span",{className:M("hidden whitespace-nowrap text-meta text-ink-dim",u),"data-project-count":"",children:c}),t.jsx("output",{className:"sr-only","aria-live":"polite",children:b}),m]})},xl=({filters:e,sort:s,onFiltersChange:r,onSortChange:a,onClearAll:o,hideClearAll:i=!1,searchFieldRef:l})=>{F();const[c,u]=d.useState(null);d.useEffect(()=>{if(!c)return;let f=null;c.kind==="search"?f=l.current:(f=document.querySelector(`[data-project-chip="${c.index}"]`),f||(f=document.querySelector("[data-project-chip]")),f||(f=document.querySelector("[data-project-filters-button]"))),f&&(f.focus(),u(null))});const m=[];for(const f of et){const g=e[f];if(g.length===0)continue;const _=g.map(b=>Yr(f,b)),x=_[0],S=_.length>1?n("ui.projects.projects_toolbar.facet_labels_facet_first_length_1",{FACET_LABELS_facet:String(ot[f]),first:String(x),length___1:V(_.length-1,{useGrouping:!1})}):n("ui.projects.projects_toolbar.facet_labels_facet_first",{FACET_LABELS_facet:String(ot[f]),first:String(x)});m.push({kind:"facet",facet:f,label:S,ariaLabel:n("ui.projects.projects_toolbar.remove_filter_facet_labels_facet_join",{FACET_LABELS_facet:String(ot[f]),join:String(_.join(", "))}),clear:()=>r({...e,[f]:[]})})}if(s&&m.push({kind:"sort",spec:s,label:n("ui.projects.projects_toolbar.sort_key",{key:String(Qe(s.key))}),ariaLabel:n("ui.projects.projects_toolbar.remove_sort_key_direction",{key:String(Qe(s.key)),direction:String(vs(s.key,s.direction))}),clear:()=>a(null)}),m.length===0)return null;const p=(f,g)=>{g.clear();const _=m.length-1;u(_===0?{kind:"chip",index:0}:{kind:"chip",index:Math.min(f,_-1)})};return t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[m.map((f,g)=>t.jsx(ke,{asChild:!0,variant:"neutral",className:"gap-1 pr-1 text-ink",children:t.jsxs("button",{type:"button",className:"group","data-project-chip":g,"aria-label":f.ariaLabel,onClick:()=>p(g,f),children:[f.kind==="sort"&&(f.spec.direction==="asc"?t.jsx(Nr,{size:10,className:"text-ink-muted","aria-hidden":"true"}):t.jsx(xr,{size:10,className:"text-ink-muted","aria-hidden":"true"})),t.jsx("span",{className:"truncate",children:f.label}),t.jsx(Pt,{className:M("text-ink-dim transition-colors duration-fast ease-out-quart","group-hover:text-danger"),"aria-hidden":"true"})]})},f.kind==="facet"?f.facet:"sort")),!i&&t.jsx(G,{variant:"link",size:"sm",onClick:()=>{o(),u({kind:"search"})},children:n("ui.projects.projects_toolbar.clear_all")})]})},hn="projects-view",bl=[{value:"list",get label(){return n("ui.projects.projects_view_switcher.list")}},{value:"board",get label(){return n("ui.projects.projects_view_switcher.board")}},{value:"timeline",get label(){return n("ui.projects.projects_view_switcher.timeline")}}];function yl(){try{const e=localStorage.getItem(hn);if(e==="board"||e==="timeline"||e==="list")return e}catch{}return"board"}function vl(e){try{localStorage.setItem(hn,e)}catch{}}const kl=({value:e,onChange:s})=>(F(),t.jsx(ma,{value:e,onValueChange:r=>s(r),children:t.jsx(_a,{"aria-label":n("ui.projects.projects_view_switcher.project_view"),"data-tour-tag":"projects-view-switcher",children:bl.map(r=>t.jsx(fa,{value:r.value,children:r.label},r.value))})})),wl=["r1","r2","r3","r4","r5","r6"],Nl=4e3,_r={get unpaired(){return n("ui.projects.projects_page.this_app_is_not_paired_with_the_local_operator_server_so_projects")},get"below-version"(){return n("ui.projects.projects_page.the_local_operator_server_is_older_than_this_app_expects_so_proje")},get unknown(){return n("ui.projects.projects_page.the_server_s_capabilities_could_not_be_read_so_projects_are_unava")}},Ml=({nowMs:e=Date.now()})=>{F();const{projectId:s}=na(),r=Dt(),a=Ze(),o=aa(a.data,"projects",1),i=o==="enabled",l=ye(a.data,"projects",Ro),c=gr(ye(a.data,"team_catalogue")),u=Pa(i),m=Ia(),p=Cr(),f=Er(),[g,_]=d.useState(!1),[x,S]=d.useState(()=>yl()),[b,h]=d.useState(()=>ro()),[k,T]=d.useState(null),[w,q]=d.useState(""),[C,E]=d.useState(Gs),[P,j]=d.useState(()=>ti()),[D,R]=d.useState(""),L=d.useRef(""),W=d.useRef(null),B=d.useRef(null),Y=N=>{W.current!==null&&(window.cancelAnimationFrame(W.current),W.current=null),N!==""&&N===L.current?(R(""),W.current=window.requestAnimationFrame(()=>{W.current=null,R(N)})):R(N),L.current=N,B.current!==null&&window.clearTimeout(B.current),B.current=window.setTimeout(()=>{B.current=null,L.current="",R("")},Nl)},J=()=>{W.current!==null&&(window.cancelAnimationFrame(W.current),W.current=null),B.current!==null&&(window.clearTimeout(B.current),B.current=null),L.current="",R("")},Z=N=>{q(N),J()},me=N=>{E(N),J()},oe=d.useRef(null),ee=Bi(),te=u.data??[],y=ws(e),v=zo(w,i&&l),O=Gr(w),I=d.useMemo(()=>v.answer?Bo(te,v.answer.projects):null,[te,v.answer]),U=O!=="",H=d.useMemo(()=>U?I??Uo(te,O):te,[te,O,U,I]),X=I===null?"client":"backend",$=d.useMemo(()=>Vo(H,C,y),[H,C,y]),je=l&&U&&v.pending,ie=U||!ct(C),z=d.useMemo(()=>Fs(te,b,e),[te,b,e]),se=d.useMemo(()=>Fs($,b,e),[$,b,e]),xe=so(b),_e=x==="board"?se.length:$.length,Pe=!ie||!u.isSuccess?null:x==="board"?n("ui.projects.projects_page.length_of_length_2_in_window",{length:V(se.length,{useGrouping:!1}),length_2:V(z.length,{useGrouping:!1})}):n("ui.projects.projects_page.length_of_length_2_projects",{length:V($.length,{useGrouping:!1}),length_2:te.length}),re=u.isSuccess&&te.length>0,Re=re&&ie&&_e===0&&!je,Be=je&&_e===0&&re,[qt,st]=d.useState(!1);d.useEffect(()=>{if(!qt)return;const N=document.querySelector('[data-tour-tag="projects-board-window"]');N&&(N.focus(),st(!1))}),d.useEffect(()=>{if(!i||s)return;const N=K=>{const Q=K.target;if(!Q||Q.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(Q.tagName)||Q.closest('[role="dialog"]'))return;const Se=K.key==="/"&&!K.metaKey&&!K.ctrlKey&&!K.altKey,le=(K.metaKey||K.ctrlKey)&&K.key.toLowerCase()==="f";!Se&&!le||(K.preventDefault(),oe.current?.focus())};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[i,s]);const rt=d.useRef(null);d.useLayoutEffect(()=>{if(!s)return;const N=rt.current;N!==null&&(N.scrollTop=0)},[s]);const ht=Ma(x==="timeline"?te.map(N=>N.id):[],i),A=new Map(te.map((N,K)=>[N.id,ht[K]])),ce=$.map(N=>({project:N,milestones:A.get(N.id)?.data?.project.milestones??[]})),nt=x==="timeline"?$.filter(N=>A.get(N.id)?.isLoading).length:0,we=x==="timeline"?$.filter(N=>A.get(N.id)?.isError).length:0,gt=()=>{for(const N of ht)N.isError&&N.refetch()},$e=N=>{j(N),si(N),Y(ri(N))},gn=(N,K)=>{E(Q=>Hr(Q,N,K)),J()},xt=()=>{const N=w.trim()!=="",K=!ct(C),Q=P!==null;q(""),E(Gs),P!==null&&$e(null),Y(ni({search:N,filters:K,sort:Q}))},Cs=()=>{h("all"),qs("all"),st(!0)},[Ne,Es]=d.useState(null),Ut=d.useRef(!1),Ts=()=>{Ut.current=!1,Es(null)},[xn,Rs]=d.useState([]),bn=ye(a.data,"projects_force_done"),yn=(N,K)=>{const Q=N.id,Se=ae(K).label;Rs(le=>le.includes(Q)?le:[...le,Q]),Si({move:()=>p.mutateAsync({key:Q,fields:{status:K}}),forceDoneOffered:bn,claimQuestion:()=>Ut.current?!1:(Ut.current=!0,!0)}).then(le=>{if(le.kind==="accepted"){be(n("ui.projects.projects_page.moved_to_label",{label:String(Se)})),u.refetch().then(()=>ee(Q));return}if(le.kind==="question"){Es({project:N,status:K,refusal:le.refusal});return}de(le.copy,le.refusal?{action:{get label(){return n("ui.projects.projects_page.view_project")},onClick:()=>void r(`/projects/${Q}`)}}:void 0),ee(Q)}).finally(()=>{Rs(le=>le.filter(vn=>vn!==Q))})};return i?s?t.jsx("div",{ref:rt,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(nl,{projectKey:s,nowMs:e})}):t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"@container flex shrink-0 flex-col gap-8 px-6 pt-6",children:[t.jsx(Ms,{title:n("ui.projects.projects_page.projects"),icon:Ls,subtitle:n("ui.projects.projects_page.workstreams_you_and_your_agents_track_across_sessions"),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(G,{variant:"secondary",size:"icon","aria-label":n("ui.projects.projects_page.refresh_projects"),title:n("ui.projects.projects_page.refresh_projects"),disabled:u.isFetching,onClick:()=>void u.refetch(),"data-tour-tag":"refresh-projects-button",children:t.jsx(ya,{})}),t.jsxs(G,{variant:"secondary",onClick:()=>_(!0),"data-tour-tag":"create-project-button",children:[t.jsx(it,{}),n("ui.projects.projects_page.new_project")]})]})}),t.jsxs("div",{className:"flex shrink-0 flex-col gap-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3","data-project-search-row":"",children:[t.jsx(kl,{value:x,onChange:N=>{S(N),vl(N)}}),t.jsx(gl,{projects:H,query:w,onQueryChange:Z,filters:C,onFiltersChange:me,onClearAll:xt,todayMs:y,resultText:Pe,countRevealClass:x==="board"?"@[47rem]:inline":void 0,disabled:u.isError,searchFieldRef:oe,trailing:x==="board"&&!(u.isSuccess&&u.data.length===0)?t.jsx(Ci,{value:b,onChange:N=>{h(N),qs(N)}}):null})]}),t.jsx(xl,{filters:C,sort:P,onFiltersChange:me,onSortChange:$e,onClearAll:xt,hideClearAll:Re,searchFieldRef:oe}),t.jsx("output",{"data-project-announcement":"",className:"sr-only","aria-live":"polite",children:D})]})]}),t.jsxs("div",{className:"mt-8 flex min-h-0 flex-1 flex-col",children:[u.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:n("ui.projects.projects_page.loading_projects")}),wl.map(N=>t.jsxs("div",{className:"flex items-center gap-3 px-9 py-2","aria-hidden":"true",children:[t.jsx(ze,{className:"h-4 min-w-0 flex-1 bg-elevated"}),t.jsx(ze,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(ze,{className:"h-4 w-32 shrink-0 bg-elevated"}),t.jsx(ze,{className:"h-4 w-16 shrink-0 bg-elevated"}),t.jsx(ze,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(ze,{className:"h-4 w-40 shrink-0 bg-elevated"})]},N))]}),u.isError&&t.jsxs("div",{className:"flex flex-col items-start gap-2 px-6",children:[t.jsx(Ht,{variant:"danger",children:u.error instanceof Error&&u.error.message?u.error.message:n("ui.projects.projects_page.the_projects_could_not_be_read")}),t.jsx(G,{variant:"secondary",size:"sm",onClick:()=>void u.refetch(),children:n("ui.projects.projects_page.try_again")})]}),u.isSuccess&&u.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:n("ui.projects.projects_page.no_projects_yet")}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:n("ui.projects.projects_page.create_one_here_or_ask_an_agent_to_create_one_and_link_this_sessi")}),t.jsxs(G,{variant:"primary",onClick:()=>_(!0),"data-tour-tag":"create-project-empty-button",children:[t.jsx(it,{}),n("ui.projects.projects_page.new_project")]})]}),Be&&t.jsx("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:n("ui.projects.projects_page.searching")})}),re&&Re&&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:w.trim()?n("ui.projects.projects_page.no_projects_match_trim",{trim:String(w.trim())}):n("ui.projects.projects_page.no_projects_match")}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:w.trim()?To[X]:n("ui.projects.projects_page.try_removing_a_filter_clearing_the_filters_restores_the_list")}),t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(G,{variant:"secondary",onClick:()=>{xt(),oe.current?.focus()},children:n("ui.projects.projects_page.clear_all")}),x==="board"&&$.length>0&&t.jsx(G,{variant:"secondary",onClick:Cs,children:n("ui.projects.projects_page.show_all_time")})]})]}),re&&!Re&&!Be&&x==="list"&&t.jsx(ml,{projects:$,nowMs:e,onOpen:N=>void r(`/projects/${N.id}`),sort:P,onSortChange:$e,searchPopulation:H,filters:C,query:w,todayMs:y,onToggleFilter:gn,onClearFilters:xt,teamLabelFor:c}),re&&!Re&&x==="board"&&se.length>0&&t.jsx(zi,{projects:se,nowMs:e,onOpen:N=>void r(`/projects/${N.id}`),onEdit:N=>void r(`/projects/${N.id}`),onDelete:T,onMove:yn,teamLabelFor:c,movingKeys:xn}),re&&!Re&&!Be&&x==="board"&&se.length===0&&xe!==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:xe}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:n("ui.projects.projects_page.older_projects_are_hidden_by_the_window")}),t.jsx(G,{variant:"secondary",onClick:Cs,children:n("ui.projects.projects_page.show_all_time")})]}),re&&!Re&&!Be&&x==="timeline"&&t.jsx(fl,{items:ce,nowMs:e,onOpen:N=>void r(`/projects/${N.project.id}`),pendingDetails:nt,failedDetails:we,onRetryDetails:gt,teamLabelFor:c})]}),t.jsx(an,{open:k!==null,projectName:k?.name??"",onClose:()=>T(null),onConfirm:async N=>{k&&(await f.mutateAsync({key:k.id,confirmedName:N}),be(n("ui.projects.projects_page.project_deleted")),T(null))}}),t.jsx(ln,{open:Ne!==null,refusal:Ne?.refusal??null,projectLabel:Ne?ne(Ne.project):"",onClose:()=>{Ne&&ee(Ne.project.id),Ts()},onConfirm:async()=>{if(!Ne)return;const{project:N,status:K,refusal:Q}=Ne,Se=await p.mutateAsync({key:N.id,fields:{status:K},forceDone:!0});be(zr(Se,Q.count,ae(K).label)),u.refetch().then(()=>ee(N.id))},secondaryLabel:n("ui.projects.projects_page.open_project"),onSecondary:()=>{const N=Ne?.project.id;Ts(),N&&r(`/projects/${N}`)}}),t.jsx(ol,{open:g,onClose:()=>_(!1),onSubmit:async N=>{const K=await m.mutateAsync(N.fields),Q=N.followUp?.title??N.fields.name;if(N.followUp)try{await p.mutateAsync({key:K.id,fields:N.followUp})}catch(Se){const le=Se instanceof Error&&Se.message?Se.message:"";de(n("ui.projects.projects_page.project_label_was_created_but_the_extra_fields_were_not_saved_val",{label:String(Q),value2:String(ft(le)||n("ui.projects.projects_page.the_server_refused_them"))}));return}be(n("ui.projects.projects_page.project_label_created",{label:String(Q)}))}})]}):t.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[t.jsx(Ms,{title:n("ui.projects.projects_page.projects"),icon:Ls}),a.isLoading?t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(Te,{label:n("ui.projects.projects_page.checking_the_server_s_projects_support")})}):t.jsx(Ht,{variant:"warning",children:_r[o]??_r.unknown})]})};export{Ml as ProjectsPage};
@@ -1 +0,0 @@
1
- import{g as Y,a as E,b as F}from"./library-page-CH3E7s4_.js";import"./index-BSn66J9q.js";import"./index-U5qrTe4P.js";import"./conversation-input-sync-qFePp_gf.js";import"./ui-preferences-store-oc99NgQT.js";import"./error-boundary-CIO9VaTx.js";import"./console-mirror-wrjuOlK5.js";import"./page-header-D3rux4P9.js";import"./hash-BTR-wmLC.js";import"./tags-input-chips-BAP2XNbQ.js";import"./arrow-up-BD8jieeb.js";const B=["#4472C4","#ED7D31","#A9D18E","#FF0000","#FFC000","#5B9BD5","#70AD47","#C00000","#7030A0","#00B0F0"];function W(n,t){const c=`accent${n%6+1}`;return t[c]?"#"+t[c]:B[n%B.length]}function j(n,t=.45){const c=parseInt(n.slice(1,3),16),s=parseInt(n.slice(3,5),16),a=parseInt(n.slice(5,7),16),p=Math.round(c+(255-c)*t),M=Math.round(s+(255-s)*t),o=Math.round(a+(255-a)*t);return`rgb(${p},${M},${o})`}function G(n){const t=[];for(const c of E(n,"t")){const s=c.textContent.trim();s&&t.push(s)}return t.join(" ")}function V(n){if(!n)return[];const t=Y(n,"ptLst");if(!t)return[];const c=[];for(const s of E(t,"pt")){const a=F(s,"type","node");if(a==="parTrans"||a==="sibTrans")continue;const p=G(s);(p||a==="node")&&c.push({id:F(s,"modelId",""),type:a,text:p})}return c.filter(s=>s.text)}function z(n){if(!n)return"list";const t=Y(n,"layoutDef")||n,s=(F(t,"uniqueId","")||F(t,"defStyle","")||"").toLowerCase();return s.includes("chevron")||s.includes("arrowprocess")||s.includes("process")?"process":s.includes("cycle")||s.includes("continuouscycle")?"cycle":s.includes("hierarchy")||s.includes("orgchart")||s.includes("org")?"hierarchy":s.includes("radial")||s.includes("diverging")?"radial":s.includes("pyramid")||s.includes("invertedpyramid")?"pyramid":s.includes("funnel")?"funnel":s.includes("venn")?"venn":s.includes("matrix")?"matrix":s.includes("list")||s.includes("bullet")?"list":s.includes("relationship")||s.includes("balance")?"relationship":"list"}function $(n,t,c,s,a,p,M,o="#fff",f="center"){if(!t)return;n.save(),n.fillStyle=o,n.textAlign=f,n.textBaseline="middle";const l=t.split(" "),g=M*1.3;let h=[],r="";for(const u of l){const y=r?r+" "+u:u;n.measureText(y).width>a-4&&r?(h.push(r),r=u):r=y}r&&h.push(r);const i=Math.max(1,Math.floor(p/g));h.length>i&&(h=h.slice(0,i));const e=s-(h.length-1)*g/2;for(let u=0;u<h.length;u++)n.fillText(h[u],c,e+u*g);n.restore()}function I(n,t,c,s=14){const a=Math.floor(t/(s*.55)),p=n.split(" "),M=Math.ceil(p.join(" ").length/Math.max(a,1)),o=c/(M*1.4);return Math.max(8,Math.min(s,o))}function L(n,t,c,s,a,p,M,o){n.save(),n.beginPath(),p=Math.min(p,s/2,a/2),n.moveTo(t+p,c),n.arcTo(t+s,c,t+s,c+a,p),n.arcTo(t+s,c+a,t,c+a,p),n.arcTo(t,c+a,t,c,p),n.arcTo(t,c,t+s,c,p),n.closePath(),M&&(n.fillStyle=M,n.fill()),n.restore()}function X(n,t,c,s,a,p,M=1.5){const o=Math.atan2(a-c,s-t),f=8;n.save(),n.strokeStyle=p,n.fillStyle=p,n.lineWidth=M,n.beginPath(),n.moveTo(t,c),n.lineTo(s,a),n.stroke(),n.beginPath(),n.moveTo(s,a),n.lineTo(s-f*Math.cos(o-.4),a-f*Math.sin(o-.4)),n.lineTo(s-f*Math.cos(o+.4),a-f*Math.sin(o+.4)),n.closePath(),n.fill(),n.restore()}function J(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t.length,l=a/f,g=Math.min(l*.08,10*o),h=Math.min(l*.12,18*o),r=l-h-g,i=p*.7,e=s+(p-i)/2;for(let u=0;u<f;u++){const y=W(u,M),d=c+l*u+g/2,b=u===f-1;n.save(),n.beginPath();const P=d+r+(b?0:h);n.moveTo(d,e),n.lineTo(d+r,e),b||n.lineTo(P,e+i/2),n.lineTo(d+r,e+i),n.lineTo(d,e+i),u>0&&n.lineTo(d+h,e+i/2),n.closePath(),n.fillStyle=y,n.fill(),n.restore();const m=I(t[u].text,r-h,i)*o;n.font=`${m}px sans-serif`;const T=d+(r+(u>0?h:0))/2;$(n,t[u].text,T,e+i/2,r,i,m)}}function K(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t.length,l=c+a/2,g=s+p/2,h=Math.min(a,p)*.33,r=Math.min(h*.32,40*o);n.save(),n.strokeStyle="#ccc",n.lineWidth=2*o,n.setLineDash([4*o,4*o]),n.beginPath(),n.arc(l,g,h,0,Math.PI*2),n.stroke(),n.setLineDash([]),n.restore();for(let i=0;i<f;i++){const e=i/f*Math.PI*2-Math.PI/2,u=l+h*Math.cos(e),y=g+h*Math.sin(e),d=W(i,M);if(n.save(),n.beginPath(),n.arc(u,y,r,0,Math.PI*2),n.fillStyle=d,n.fill(),n.restore(),f>1){const P=(i+1)/f*Math.PI*2-Math.PI/2,m=(e+P)/2,T=l+h*Math.cos(e+.15),v=g+h*Math.sin(e+.15),k=l+h*Math.cos(P-.15),S=g+h*Math.sin(P-.15);n.save(),n.strokeStyle=d+"99",n.lineWidth=1.5*o,n.beginPath(),n.moveTo(T,v),n.quadraticCurveTo(l+h*1.1*Math.cos(m),g+h*1.1*Math.sin(m),k,S),n.stroke(),n.restore()}const b=I(t[i].text,r*1.7,r*1.2)*o;n.font=`${b}px sans-serif`,$(n,t[i].text,u,y,r*2,r*1.8,b)}}function O(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t[0],l=t.slice(1),g=Math.max(l.length,1),h=p/(l.length>0?2.8:1.2),r=h*.75,i=Math.min(a*.3,160*o),e=r,u=c+(a-i)/2,y=s+(h-e)/2,d=W(0,M);L(n,u,y,i,e,6*o,d);const b=I(f.text,i-10*o,e)*o;if(n.font=`bold ${b}px sans-serif`,$(n,f.text,u+i/2,y+e/2,i-10,e,b),!l.length)return;const P=(a-20*o)/g,m=s+h*1.5,T=y+e,v=m-4*o;n.save(),n.strokeStyle="#999",n.lineWidth=1.5*o,n.beginPath(),n.moveTo(u+i/2,T),n.lineTo(u+i/2,(T+v)/2),n.lineTo(c+10*o,(T+v)/2),n.lineTo(c+a-10*o,(T+v)/2),n.stroke(),n.restore();for(let k=0;k<l.length;k++){const S=c+P*k+8*o,R=m,A=P-16*o,H=r,N=W(k+1,M);n.save(),n.strokeStyle="#999",n.lineWidth=1.5*o,n.beginPath(),n.moveTo(S+A/2,(T+v)/2),n.lineTo(S+A/2,R),n.stroke(),n.restore(),L(n,S,R,A,H,5*o,N);const D=I(l[k].text,A-8*o,H)*o;n.font=`${D}px sans-serif`,$(n,l[k].text,S+A/2,R+H/2,A-8,H,D)}}function Q(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t[0],l=t.slice(1),g=c+a/2,h=s+p/2,r=Math.min(a,p)*.18,i=Math.min(a,p)*.36,e=Math.min(i*.28,38*o),u=l.length||1,y=W(0,M);n.save(),n.beginPath(),n.arc(g,h,r,0,Math.PI*2),n.fillStyle=y,n.fill(),n.restore();const d=I(f.text,r*1.6,r*1.2)*o;n.font=`bold ${d}px sans-serif`,$(n,f.text,g,h,r*2,r*2,d);for(let b=0;b<u;b++){const P=b/u*Math.PI*2-Math.PI/2,m=g+i*Math.cos(P),T=h+i*Math.sin(P),v=W(b+1,M),k=g+r*Math.cos(P),S=h+r*Math.sin(P),R=m-e*Math.cos(P),A=T-e*Math.sin(P);X(n,k,S,R,A,v+"99",1.5*o),n.save(),n.beginPath(),n.arc(m,T,e,0,Math.PI*2),n.fillStyle=v,n.fill(),n.restore();const H=I(l[b].text,e*1.7,e*1.2)*o;n.font=`${H}px sans-serif`,$(n,l[b].text,m,T,e*2,e*1.8,H)}}function U(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t.length,l=p/f;for(let g=0;g<f;g++){const h=(f-g)/f,r=a*h,i=c+(a-r)/2,e=s+g*l,u=W(g,M);n.save(),n.beginPath(),n.moveTo(i,e+l),n.lineTo(i+r,e+l);const y=a*((f-g-1)/f);n.lineTo(c+(a+y)/2,e),n.lineTo(c+(a-y)/2,e),n.closePath(),n.fillStyle=u,n.strokeStyle="#fff",n.lineWidth=2*o,n.fill(),n.stroke(),n.restore();const d=I(t[g].text,r*.6,l*.7)*o;n.font=`${d}px sans-serif`,$(n,t[g].text,c+a/2,e+l/2,r*.6,l*.7,d)}}function Z(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t.length,l=p/f;for(let g=0;g<f;g++){const h=1-g/f*.55,r=1-(g+1)/f*.55,i=a*h,e=a*r,u=c+(a-i)/2,y=c+(a-e)/2,d=s+g*l,b=W(g,M);n.save(),n.beginPath(),n.moveTo(u,d),n.lineTo(u+i,d),n.lineTo(y+e,d+l),n.lineTo(y,d+l),n.closePath(),n.fillStyle=b,n.strokeStyle="#fff",n.lineWidth=2*o,n.fill(),n.stroke(),n.restore();const P=(i+e)/2,m=I(t[g].text,P*.8,l*.7)*o;n.font=`${m}px sans-serif`,$(n,t[g].text,c+a/2,d+l/2,P*.8,l*.7,m)}}function _(n,t,c,s,a,p,M,o){if(!t.length)return;const f=Math.min(t.length,4),l=c+a/2,g=s+p/2,h=Math.min(a,p)*(f<=2?.32:.28),r=h*.65,i=[];for(let e=0;e<f;e++)i.push(e/f*Math.PI*2-Math.PI/2);for(let e=0;e<f;e++){const u=f>1?l+r*Math.cos(i[e]):l,y=f>1?g+r*Math.sin(i[e]):g,d=W(e,M);n.save(),n.globalAlpha=.55,n.beginPath(),n.arc(u,y,h,0,Math.PI*2),n.fillStyle=d,n.fill(),n.globalAlpha=1,n.strokeStyle="#fff",n.lineWidth=1.5*o,n.stroke(),n.restore();const b=f>1?l+(r+h*.45)*Math.cos(i[e]):l,P=f>1?g+(r+h*.45)*Math.sin(i[e]):g,m=I(t[e].text,h*1.2,h*.7)*o;n.font=`${m}px sans-serif`,$(n,t[e].text,b,P,h*1.2,h*.7,m,"#333")}}function w(n,t,c,s,a,p,M,o){const f=[t[0]||{text:""},t[1]||{text:""},t[2]||{text:""},t[3]||{text:""}],l=a/2,g=p/2,h=8*o;for(let r=0;r<2;r++)for(let i=0;i<2;i++){const e=r*2+i,u=c+i*l+h,y=s+r*g+h,d=l-h*2,b=g-h*2,P=W(e,M);L(n,u,y,d,b,8*o,P);const m=I(f[e].text,d-10,b)*o;n.font=`${m}px sans-serif`,$(n,f[e].text,u+d/2,y+b/2,d-10,b,m)}}function q(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t.length,l=p/f,g=Math.min(l*.2,14*o),h=g*3;for(let r=0;r<f;r++){const i=s+r*l,e=i+l/2,u=W(r,M);n.save(),n.beginPath(),n.arc(c+g,e,g,0,Math.PI*2),n.fillStyle=u,n.fill(),n.restore(),L(n,c+h,i+l*.1,a-h-4*o,l*.8,4*o,u+"22");const y=I(t[r].text,a-h-20*o,l*.7)*o;n.font=`${y}px sans-serif`,n.fillStyle="#333",n.textAlign="left",n.textBaseline="middle",n.fillText(t[r].text,c+h+8*o,e)}}function C(n,t,c,s,a,p,M,o){if(t.length<2){q(n,t,c,s,a,p,M,o);return}const f=t[Math.floor(t.length/2)],l=t.slice(0,Math.floor(t.length/2)),g=t.slice(Math.floor(t.length/2)+1),h=c+a/2,r=s+p/2,i=Math.min(a*.14,p*.25),e=W(Math.floor(t.length/2),M);n.save(),n.beginPath(),n.arc(h,r,i,0,Math.PI*2),n.fillStyle=e,n.fill(),n.restore();const u=I(f.text,i*1.6,i*1.2)*o;n.font=`bold ${u}px sans-serif`,$(n,f.text,h,r,i*2,i*1.8,u);const y=p/Math.max(l.length,g.length,1),d=a*.3,b=y*.7,P=(m,T)=>{const v=T==="left"?c:c+a-d,k=T==="left"?h-i:h+i;for(let S=0;S<m.length;S++){const R=s+y*S+(y-b)/2,A=W(S+(T==="right"?l.length+1:0),M);L(n,v,R,d,b,5*o,A);const H=I(m[S].text,d-8,b)*o;n.font=`${H}px sans-serif`,$(n,m[S].text,v+d/2,R+b/2,d-8,b,H);const N=T==="left"?v+d:v;X(n,N,R+b/2,k,r,A+"88",1.5*o)}};P(l,"left"),P(g,"right")}function x(n,t,c,s,a,p,M,o){const f=t.length;if(!f)return;const l=Math.ceil(Math.sqrt(f)),g=Math.ceil(f/l),h=a/l,r=p/g,i=Math.min(h,r)*.1;for(let e=0;e<f;e++){const u=e%l,y=Math.floor(e/l),d=c+u*h+i,b=s+y*r+i,P=h-i*2,m=r-i*2,T=W(e,M);L(n,d,b,P,m,8*o,T),j(T),n.save();const v=n.createLinearGradient(d,b,d,b+m*.5);v.addColorStop(0,"rgba(255,255,255,0.18)"),v.addColorStop(1,"rgba(255,255,255,0)"),n.fillStyle=v,n.beginPath(),n.roundRect?.(d,b,P,m,8*o),n.fill(),n.restore();const k=I(t[e].text,P-12*o,m)*o;n.font=`${k}px sans-serif`,$(n,t[e].text,d+P/2,b+m/2,P-12*o,m,k)}}function un(n,t,c,s,a,p,M,o,f){const l=V(t),g=z(c),h=16*f;n.save(),n.fillStyle="#f7f9fc",n.strokeStyle="#e0e4ec",n.lineWidth=1,n.beginPath(),n.roundRect?.(s,a,p,M,6*f)||n.rect(s,a,p,M),n.fill(),n.stroke();const r=s+h,i=a+h,e=p-h*2,u=M-h*2;if(!l.length){n.fillStyle="#aaa",n.font=`${12*f}px sans-serif`,n.textAlign="center",n.textBaseline="middle",n.fillText("SmartArt Diagram",s+p/2,a+M/2),n.restore();return}switch(g){case"process":J(n,l,r,i,e,u,o,f);break;case"cycle":K(n,l,r,i,e,u,o,f);break;case"hierarchy":O(n,l,r,i,e,u,o,f);break;case"radial":Q(n,l,r,i,e,u,o,f);break;case"pyramid":U(n,l,r,i,e,u,o,f);break;case"funnel":Z(n,l,r,i,e,u,o,f);break;case"venn":_(n,l,r,i,e,u,o,f);break;case"matrix":w(n,l,r,i,e,u,o,f);break;case"list":q(n,l,r,i,e,u,o,f);break;case"relationship":C(n,l,r,i,e,u,o,f);break;default:x(n,l,r,i,e,u,o,f)}n.restore()}export{un as renderSmartArt};
@@ -1 +0,0 @@
1
- import{s as r,b as e,a,S as s}from"./chunk-AEK57VVT-BRm1a_Ub.js";import{_ as i}from"./mermaid.core-Bx5BMQp8.js";import"./chunk-RZ5BOZE2-Cwg1etHt.js";import"./conversation-input-sync-qFePp_gf.js";import"./index-BSn66J9q.js";import"./ui-preferences-store-oc99NgQT.js";import"./error-boundary-CIO9VaTx.js";var n={parser:a,get db(){return new s(2)},renderer:e,styles:r,init:i(t=>{t.state||(t.state={}),t.state.arrowMarkerAbsolute=t.arrowMarkerAbsolute},"init")};export{n as diagram};
@@ -1 +0,0 @@
1
- import{r as o,j as t,c as r}from"./index-BSn66J9q.js";import{L as g,B as j,X as y,a as N}from"./error-boundary-CIO9VaTx.js";import{a as v}from"./index-U5qrTe4P.js";const C=({value:s,label:l,onChange:a,placeholder:p="Add tag...",disabled:i=!1,icon:x})=>{const[n,c]=o.useState(""),d=o.useRef(null),u=o.useId(),f=e=>{c(e.target.value)},m=()=>{const e=n.trim().toLowerCase();e&&!s.includes(e)&&a([...s,e]),c("")},h=e=>{e.key==="Enter"&&n.trim()?(e.preventDefault(),m()):e.key==="Backspace"&&!n&&s.length>0&&a(s.slice(0,-1))},b=e=>{a(s.filter(k=>k!==e))};return t.jsxs("div",{children:[t.jsxs(g,{htmlFor:u,className:"mb-1.5 flex items-center gap-2 text-ink-muted",children:[x,l]}),t.jsxs("div",{className:r("flex min-h-11 flex-wrap items-center gap-2 rounded-sm border border-control bg-surface p-2","has-[input:focus-visible]:outline-solid has-[input:focus-visible]:outline-2","has-[input:focus-visible]:outline-accent has-[input:focus-visible]:outline-offset-2",i&&"border-hairline bg-sunken"),children:[s.map(e=>t.jsxs(j,{className:"gap-1 pr-1 text-ink",children:[e,t.jsx("button",{type:"button","aria-label":`Remove tag ${e}`,disabled:i,onClick:()=>b(e),className:r("rounded-xs text-ink-dim","transition-colors duration-fast ease-out-quart","hover:text-danger disabled:text-ink-disabled"),children:t.jsx(y,{})})]},e)),t.jsx("input",{id:u,ref:d,type:"text",value:n,onChange:f,onKeyDown:h,placeholder:p,disabled:i,"aria-label":l,className:r("min-w-20 flex-1 bg-transparent px-1 py-0.5 outline-none","text-body-sm text-ink placeholder:text-ink-dim","disabled:text-ink-disabled disabled:placeholder:text-ink-disabled")}),n.trim()&&t.jsx(N,{variant:"ghost",size:"icon-sm","aria-label":"Add tag",disabled:i,onClick:()=>{m(),d.current?.focus()},className:"text-accent hover:text-accent",children:t.jsx(v,{})})]}),s.length===0&&!n&&t.jsx("span",{className:"mt-1 ml-1 block text-ink-dim text-meta",children:"No tags added"})]})};export{C as T};
@@ -1,11 +0,0 @@
1
- import{j as e,t as a,r as p,c as k}from"./index-BSn66J9q.js";import{g as ye,t as Ne,T as Be,h as ke,a as $,o as we,i as I,j as _e,k as Ce,m as W,v as oe,p as re,q as me,s as Me,x as Te,y as ue,z as le,A as Se,C as Ie,D as De,E as ze,F as Ee,G as Re,H as Pe,I as Oe,J as Fe,K as Le,L as qe,M as Ae,N as Ve,O as Ue,Q as Ge,R as He}from"./index-U5qrTe4P.js";import{c as xe,u as R,i as pe,j as he,a as y,k as ge,l as fe,m as je,n as L,o as ve,p as X,D as Ke,b as Qe,e as Je,f as $e,I as Q,X as Xe,q as Ye,B as q,r as Y,s as de,S as ce}from"./error-boundary-CIO9VaTx.js";import{aI as We,aJ as Ze,aK as ea,aL as aa,aM as J}from"./conversation-input-sync-qFePp_gf.js";import"./ui-preferences-store-oc99NgQT.js";import{B as ta}from"./building-2-DtOQfBQY.js";import{H as sa}from"./hash-BTR-wmLC.js";import"./console-mirror-wrjuOlK5.js";/**
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 ia=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]],be=xe("bell-off",ia);/**
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 na=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],ra=xe("bell",na),la=({conversation:t,onNotifyChange:d,defaultOpen:m=!1})=>{R();const s=ye(t),n=s==="mute";return e.jsxs(pe,{defaultOpen:m,children:[e.jsx(he,{asChild:!0,children:e.jsx(y,{type:"button",size:"icon-sm",variant:"ghost","aria-label":a("ui.teamBridge.menu.label"),title:a("ui.teamBridge.menu.label"),children:e.jsx(We,{size:16,"aria-hidden":"true"})})}),e.jsxs(ge,{align:"end",className:"w-60",children:[e.jsxs(fe,{onSelect:()=>d(Ne(s)),children:[n?e.jsx(ra,{size:16,"aria-hidden":"true"}):e.jsx(be,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:n?a("ui.teamBridge.menu.unmute"):a("ui.teamBridge.menu.mute")})]}),e.jsx(je,{}),e.jsx(L,{children:a("ui.teamBridge.notify.label")}),e.jsx(ve,{value:s,"aria-label":a("ui.teamBridge.notify.label"),onValueChange:c=>d(ke(c)),children:Be.map(c=>e.jsx(X,{value:c.value,children:e.jsx("span",{className:"min-w-0 flex-1 truncate",children:a(c.labelKey)})},c.value))})]})]})},da=({open:t,onClose:d,onCreate:m,pending:s=!1,error:n})=>{R();const[c,g]=p.useState("dm"),[x,v]=p.useState(""),[h,o]=p.useState([{account_id:"",kind:"human",display_label:"",rowId:crypto.randomUUID()}]),w=(i,f)=>{o(j=>j.map((b,N)=>N===i?{...b,...f}:b))},M=h.some(i=>i.account_id.trim()&&i.display_label.trim())&&(c==="dm"||x.trim().length>0||c==="group");return e.jsx(Ke,{open:t,onOpenChange:i=>{i||d()},children:e.jsxs(Qe,{className:"gap-4",children:[e.jsx(Je,{children:a("ui.teamBridge.create.title")}),e.jsx($e,{className:"sr-only",children:a("ui.teamBridge.page.subtitle")}),e.jsxs("fieldset",{className:"flex gap-1",children:[e.jsx("legend",{className:"sr-only",children:a("ui.teamBridge.create.title")}),["dm","group","channel"].map(i=>e.jsx(y,{type:"button",size:"sm",variant:c===i?"primary":"ghost",onClick:()=>g(i),children:a(`ui.teamBridge.kind.${i}`)},i))]}),c!=="dm"&&e.jsxs("span",{className:"flex flex-col gap-1 text-[13px] text-ink-muted",children:[a("ui.teamBridge.create.name"),e.jsx(Q,{value:x,onChange:i=>v(i.target.value),"aria-label":a("ui.teamBridge.create.name"),maxLength:128})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[13px] text-ink-muted",children:a("ui.teamBridge.create.members")}),h.map((i,f)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{value:i.account_id,onChange:j=>w(f,{account_id:j.target.value}),placeholder:a("ui.teamBridge.create.account_placeholder"),"aria-label":a("ui.teamBridge.create.member_account"),className:"flex-1"}),e.jsx(Q,{value:i.display_label,onChange:j=>w(f,{display_label:j.target.value}),placeholder:a("ui.teamBridge.create.member_name"),"aria-label":a("ui.teamBridge.create.member_name"),maxLength:64,className:"flex-1"}),e.jsxs("select",{value:i.kind,onChange:j=>w(f,{kind:j.target.value}),"aria-label":a("ui.teamBridge.create.member_kind"),className:"h-8 rounded-md border border-hairline bg-surface px-1 text-[13px]",children:[e.jsx("option",{value:"human",children:a("ui.teamBridge.create.member_person")}),e.jsx("option",{value:"agent",children:a("ui.teamBridge.create.member_agent")})]}),e.jsx(y,{type:"button",size:"icon-sm",variant:"ghost","aria-label":a("ui.teamBridge.create.remove_member"),onClick:()=>o(j=>j.filter((b,N)=>N!==f)),children:e.jsx(Xe,{size:14})})]},i.rowId)),e.jsxs(y,{type:"button",size:"sm",variant:"ghost",onClick:()=>o(i=>[...i,{account_id:"",kind:"human",display_label:"",rowId:crypto.randomUUID()}]),children:[e.jsx($,{size:14}),a("ui.teamBridge.create.add_member")]})]}),n&&e.jsx("p",{role:"alert",className:"text-[13px] text-danger",children:n}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{type:"button",variant:"ghost",onClick:d,children:a("ui.teamBridge.create.cancel")}),e.jsx(y,{type:"button",variant:"primary",disabled:!M||s,onClick:()=>m({kind:c,...x.trim()?{name:x.trim()}:{},visibility:c==="channel"?"tenant":"private",agentCapable:h.some(i=>i.kind==="agent"),members:h.filter(i=>i.account_id.trim()&&i.display_label.trim())}),children:a("ui.teamBridge.create.confirm")})]})]})})},ca=({organizations:t,scope:d,onScopeChange:m,totalUnread:s,membershipsLoading:n=!1,organizationsFailed:c=!1,defaultOpen:g=!1,onRetry:x})=>{R();const v=we(t,d),h=d===I?a("ui.teamBridge.scope.all"):v?.name??a("ui.teamBridge.scope.unknown");return e.jsxs(pe,{defaultOpen:g,children:[e.jsx(he,{asChild:!0,children:e.jsxs("button",{type:"button","aria-label":a("ui.teamBridge.scope.trigger",{name:h}),title:h,className:k("group flex h-[30px] min-w-0 flex-1 items-center gap-2 rounded-md px-2","text-left text-[13px] text-ink transition-colors duration-fast","hover:bg-row-hover data-[state=open]:bg-row-hover"),children:[e.jsx(ta,{size:16,"aria-hidden":"true",className:"shrink-0 text-ink-muted"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:h}),e.jsx(Ye,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim"})]})}),e.jsxs(ge,{align:"start",className:"w-64",children:[e.jsx(L,{children:a("ui.teamBridge.scope.label")}),e.jsxs(ve,{value:d,onValueChange:o=>m(_e(o)),children:[e.jsxs(X,{value:I,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:a("ui.teamBridge.scope.all")}),s>0&&e.jsx(q,{variant:"attentionQuiet",size:"count","aria-label":a("ui.teamBridge.unread.count",{count:s}),title:a("ui.teamBridge.unread.count",{count:s}),children:Y(s,99)})]}),t.length>0&&e.jsx(je,{}),t.map(o=>e.jsxs(X,{value:o.tenantId,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:o.name}),e.jsx("span",{className:"shrink-0 text-meta-sm text-ink-dim capitalize",children:o.role}),o.unread>0&&e.jsx(q,{variant:"attentionQuiet",size:"count","aria-label":a("ui.teamBridge.unread.count",{count:o.unread}),title:a("ui.teamBridge.unread.count",{count:o.unread}),children:Y(o.unread,99)})]},o.tenantId))]}),n&&e.jsx(L,{children:a("ui.teamBridge.scope.loading")}),!n&&c&&e.jsxs(e.Fragment,{children:[e.jsx(L,{children:a("ui.teamBridge.scope.error")}),x&&e.jsx(fe,{onSelect:()=>x(),children:a("ui.teamBridge.list.retry")})]}),!n&&!c&&t.length===0&&e.jsx(L,{children:a("ui.teamBridge.scope.empty")})]})]})},oa=({conversation:t,selected:d,selfAccountId:m,organizationName:s,showOrganization:n,onSelect:c})=>{const g=R(),x=Ue(t),v=x==="hash"?sa:x==="users"?aa:He,h=me(t,m)??a("ui.teamBridge.list.untitled"),o=t.unread_count,w=W(t),M=Ge(t),i=t.last_message_at?ma(t.last_message_at,g):"";return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:c,"aria-current":d?"page":void 0,"data-conversation-id":t.id,"data-conversation-tenant":t.tenant_id,className:k("flex w-full items-center gap-2 rounded-md px-2 text-left","transition-colors duration-fast ease-out-quart",n?"min-h-[38px] py-1":"h-[30px]",d?"bg-row-selected text-ink":"text-ink-muted hover:bg-row-hover hover:text-ink"),children:[e.jsx(v,{size:16,"aria-hidden":"true",className:"shrink-0"}),e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px]",children:h}),w&&e.jsx(q,{variant:"attentionQuiet",className:"shrink-0",children:a("ui.teamBridge.preview.chip")}),M&&e.jsxs("span",{className:"shrink-0 text-ink-dim",title:a("ui.teamBridge.notify.muted"),children:[e.jsx(be,{size:12,"aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:a("ui.teamBridge.notify.muted")})]}),i&&!n&&e.jsx("span",{className:"min-w-0 truncate text-meta-sm text-ink-dim",children:i}),o>0&&e.jsx("span",{className:"ml-1 inline-flex shrink-0",children:e.jsx(q,{variant:"attentionQuiet",shape:"pill",size:"count","aria-label":a("ui.teamBridge.unread.count",{count:o}),children:Y(o,99)})})]}),n&&e.jsxs("span",{className:"mt-0.5 flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"truncate rounded-sm border border-control bg-elevated px-1 text-meta-sm text-ink-dim",children:s??a("ui.teamBridge.scope.unknown")}),i&&e.jsx("span",{className:"shrink-0 text-meta-sm text-ink-dim",children:i})]})]})]})})};function ma(t,d){const m=Date.parse(t);if(Number.isNaN(m))return"";const s=Math.round((m-Date.now())/6e4);if(Math.abs(s)<60)return J(s,"minute",{numeric:"auto"},d);const n=Math.round(s/60);return Math.abs(n)<24?J(n,"hour",{numeric:"auto"},d):J(Math.round(n/24),"day",{numeric:"auto"},d)}const ua=({message:t,selfAccountId:d})=>{const m=t.sender.account_id===d,s=t.sender.kind==="agent",n=new Date(t.created_at);return e.jsxs("li",{className:k("flex gap-2 px-1",m&&"flex-row-reverse text-right"),children:[e.jsx("span",{className:k("mt-0.5 flex size-6 shrink-0 items-center justify-center rounded-full",s?"bg-accent-wash text-accent":"bg-sunken text-ink-muted"),"aria-hidden":"true",children:s?e.jsx(ue,{size:14}):t.sender.display_label[0]??"?"}),e.jsxs("div",{className:k("min-w-0 max-w-[min(72ch,80%)]",m&&"items-end"),children:[e.jsxs("div",{className:k("flex items-baseline gap-2 text-[12px] text-ink-dim",m&&"justify-end"),children:[e.jsx("span",{className:"truncate font-medium text-ink-muted",children:t.sender.display_label}),s&&e.jsx(q,{variant:"accent",shape:"pill",size:"count",children:a("ui.teamBridge.member.agent")}),e.jsx("time",{dateTime:t.created_at,children:Number.isNaN(n.getTime())?"":n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})})]}),e.jsx("p",{className:k("mt-0.5 whitespace-pre-wrap break-words rounded-md text-[13px] leading-relaxed",m?"bg-accent-wash px-2.5 py-1.5 text-ink":"text-ink"),children:t.body??e.jsx("span",{className:"text-ink-dim italic",children:a("ui.teamBridge.thread.withheld")})})]})]})},xa=({listState:t,messageState:d,conversations:m,selected:s,messages:n,organizations:c,scope:g,totalUnread:x,membershipsLoading:v=!1,organizationsFailed:h=!1,selfAccountId:o,sending:w=!1,sendFailed:M=!1,joining:i=!1,joinFailed:f=!1,notifyFailed:j=!1,onJoin:b,onNotifyChange:N,defaultMenuOpen:A=!1,initialDraft:G="",onSelect:D,onSend:u,onNewConversation:V,onRetry:T,onScopeChange:z,onRetryMemberships:P})=>{R();const[O,S]=p.useState(G),E=p.useRef(null),_=p.useMemo(()=>Ce(n),[n]),r=g===I,B=s!==null&&W(s),C=p.useMemo(()=>oe(m,g,c),[m,g,c]),H=s?re(s,c):null,K=r&&s!==null&&H===null,U="team-bridge-create-hint",Z=r;p.useEffect(()=>{E.current?.scrollIntoView({block:"end"})},[s?.id,_.length]);const F=p.useRef(null),ee=()=>{const l=O.trim();if(!l||w)return;const ae=F.current?.body===l?F.current.clientRef:crypto.randomUUID(),te={body:l,clientRef:ae};F.current=te;const se=u(l,ae),ie=()=>{F.current===te&&(F.current=null),S(ne=>ne.trim()===l?"":ne)};se instanceof Promise?se.then(ie).catch(()=>{}):ie()};return e.jsxs("div",{"data-glass-region":"canvas",className:"flex h-full min-h-0 w-full overflow-hidden",children:[e.jsxs("aside",{"data-glass-region":"page-sidebar",className:"flex w-72 shrink-0 flex-col",children:[e.jsx("h1",{className:"sr-only",children:a("ui.teamBridge.page.title")}),e.jsxs("header",{className:"flex h-11 shrink-0 items-center gap-2 px-3",children:[e.jsx(ca,{organizations:c,scope:g,onScopeChange:z,totalUnread:x,membershipsLoading:v,organizationsFailed:h,onRetry:P}),e.jsx(y,{size:"icon-sm",variant:"ghost","aria-label":a("ui.teamBridge.page.new_conversation"),"aria-disabled":r||void 0,"aria-describedby":Z?U:void 0,className:r?"text-ink-disabled hover:bg-transparent":void 0,onClick:()=>{r||V()},children:e.jsx($,{size:16})})]}),r&&(C.length>0||t!=="ready")&&e.jsx("p",{id:U,className:"px-3 pb-2 text-[12px] text-ink-dim",children:a("ui.teamBridge.scope.create_needs_org")}),e.jsxs(de,{className:"min-h-0 flex-1",children:[t==="loading"&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ce,{size:"sm",label:a("ui.teamBridge.list.loading")})}),t==="error"&&e.jsxs("div",{className:"flex flex-col items-start gap-2 px-3 py-6",children:[e.jsx("p",{className:"text-[13px] text-ink-muted",children:a("ui.teamBridge.list.error")}),T&&e.jsx(y,{size:"sm",variant:"outline",onClick:T,children:a("ui.teamBridge.list.retry")})]}),t==="ready"&&C.length>0&&e.jsx("ul",{className:"flex flex-col gap-0.5 px-1 pb-2",children:C.map(l=>e.jsx(oa,{conversation:l,selected:s?.id===l.id,selfAccountId:o,showOrganization:r,organizationName:r?re(l,c):void 0,onSelect:()=>D(l.id)},l.id))})]})]}),e.jsx("section",{className:"flex min-w-0 flex-1 flex-col bg-surface",children:s===null?t==="ready"?e.jsx("div",{className:"flex flex-1 items-center justify-center px-6",children:e.jsxs("div",{className:"max-w-sm text-center",children:[e.jsx("p",{className:"font-medium text-[13px] text-ink",children:a("ui.teamBridge.list.empty.title")}),e.jsx("p",{id:r&&t==="ready"&&C.length===0?U:void 0,className:"mt-1 text-[13px] text-ink-muted",children:r&&t==="ready"&&C.length===0?a("ui.teamBridge.scope.create_needs_org"):a("ui.teamBridge.list.empty.body")}),e.jsxs(y,{size:"sm",variant:"primary",className:r?"mt-3 opacity-60":"mt-3","aria-disabled":r||void 0,"aria-describedby":Z?U:void 0,onClick:()=>{r||V()},children:[e.jsx($,{size:14}),a("ui.teamBridge.page.new_conversation")]})]})}):null:e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"flex h-11 shrink-0 items-center gap-2 px-3",children:[e.jsx("h2",{className:"min-w-0 truncate font-medium text-[13px] text-ink",children:me(s,o)??a("ui.teamBridge.list.untitled")}),r&&H&&e.jsx("span",{className:"shrink-0 rounded-sm bg-elevated px-1.5 py-0.5 text-meta-sm text-ink-dim",children:H}),e.jsx("span",{className:"shrink-0 text-meta-sm text-ink-dim",children:a("ui.teamBridge.member.count",{count:Me(s)})}),e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[Te(s).filter(l=>l.state==="active").slice(0,6).map(l=>e.jsx("span",{className:k("flex size-5 items-center justify-center rounded-full text-[10px]",l.kind==="agent"?"bg-accent-wash text-accent":"bg-sunken text-ink-muted"),title:l.display_label,children:l.kind==="agent"?e.jsx(ue,{size:12,"aria-hidden":"true"}):l.display_label[0]??"?"},`${l.kind}:${l.account_id}`)),!B&&N&&e.jsx(la,{conversation:s,onNotifyChange:N,defaultOpen:A})]})]}),j&&e.jsx("p",{role:"alert",className:"px-3 pb-1 text-[12px] text-danger",children:a("ui.teamBridge.notify.error")}),e.jsx(de,{className:"min-h-0 flex-1 [&_[data-radix-scroll-area-viewport]>div]:block [&_[data-radix-scroll-area-viewport]>div]:h-full",children:e.jsx("div",{className:"flex h-full flex-col",children:B?e.jsx(pa,{joining:i,joinFailed:f,onJoin:b}):e.jsxs(e.Fragment,{children:[d==="loading"&&e.jsx("div",{className:"flex items-center justify-center py-10",children:e.jsx(ce,{size:"sm",label:a("ui.teamBridge.thread.loading")})}),d==="error"&&e.jsx("p",{className:"px-4 py-8 text-[13px] text-ink-muted",children:a("ui.teamBridge.thread.error")}),K&&e.jsx("p",{className:"px-4 py-8 text-[13px] text-ink-muted",children:a("ui.teamBridge.scope.thread_unknown")}),!K&&d==="ready"&&_.length===0&&e.jsx("p",{className:"px-4 py-10 text-center text-[13px] text-ink-muted",children:a("ui.teamBridge.thread.empty")}),!K&&d==="ready"&&_.length>0&&e.jsxs("ul",{className:"mt-auto flex flex-col gap-3 px-4 py-4",children:[_.map(l=>e.jsx(ua,{message:l,selfAccountId:o},l.id)),e.jsx("div",{ref:E})]})]})})}),!B&&e.jsxs("div",{className:"shrink-0 px-3 pb-3",children:[M&&e.jsx("p",{role:"alert",className:"px-2 pb-1 text-[12px] text-danger",children:a("ui.teamBridge.composer.error")}),e.jsxs("div",{className:k("rounded-xl bg-elevated","transition-colors duration-fast ease-out-quart","has-[textarea:focus-visible]:outline-solid has-[textarea:focus-visible]:outline-2","has-[textarea:focus-visible]:outline-accent has-[textarea:focus-visible]:outline-offset-2"),children:[e.jsx("textarea",{value:O,onChange:l=>S(l.target.value),onKeyDown:l=>{l.key==="Enter"&&!l.shiftKey&&!l.nativeEvent.isComposing&&(l.preventDefault(),ee())},rows:1,placeholder:a("ui.teamBridge.composer.placeholder"),"aria-label":a("ui.teamBridge.composer.placeholder"),className:k("block max-h-40 min-h-9 w-full resize-none bg-transparent px-3 pt-2.5 pb-1","text-[13px] text-ink placeholder:text-ink-dim","outline-none")}),e.jsxs("div",{className:"flex items-center gap-2 px-2 pb-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate pl-1 text-meta-sm text-ink-dim",children:a("ui.teamBridge.composer.hint")}),e.jsx(y,{size:"icon-sm",variant:"primary",className:"rounded-full",disabled:!O.trim()||w,"aria-label":a("ui.teamBridge.composer.send"),onClick:ee,children:e.jsx(Ze,{size:16})})]})]})]})]})})]})},pa=({joining:t=!1,joinFailed:d=!1,onJoin:m})=>(R(),e.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-10",children:e.jsxs("div",{className:"flex max-w-md flex-col items-center gap-3 text-center",children:[e.jsx("p",{className:"text-[13px] text-ink",children:a("ui.teamBridge.preview.banner")}),d&&e.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:a("ui.teamBridge.preview.join_error")}),e.jsx(y,{type:"button",size:"sm",variant:"primary",disabled:t,onClick:m,children:a("ui.teamBridge.preview.join")})]})})),Ba=()=>{const[t,d]=ea(),m=t.get("conversation"),s=t.get("tenant"),[n,c]=p.useState(()=>s?le(s):I),g=p.useRef(!!s),x=Se(),v=Ie(!0,I),h=p.useMemo(()=>De(x.memberships,v.data?.organizations),[x.memberships,v.data]),o=ze(n),M=Ee().data??void 0,[i,f]=p.useState(()=>m),[j,b]=p.useState(!1),N=o.data?.conversations??[],A=n===I;p.useEffect(()=>{!m||!s||(g.current=!0,c(le(s)),f(m),b(!1),d({},{replace:!0}))},[m,s,d]);const G=r=>{g.current=!0,c(r),f(null),b(!1)};p.useEffect(()=>{c(r=>Re(h,r,g.current))},[h]);const D=p.useMemo(()=>oe(N,n,h),[N,n,h]);p.useEffect(()=>{i===null&&D.length>0&&f(D[0].id)},[D,i]);const u=D.find(r=>r.id===i)??null,V=u!==null&&W(u),T=Pe(V?null:u?.id??null,u?.tenant_id),z=Oe(u?.id??"",u?.tenant_id),P=Fe(n===I?void 0:n),O=Le(u?.id??"",u?.tenant_id),S=qe(u?.id??"",u?.tenant_id),E=Ae();p.useEffect(()=>{z.reset(),S.reset(),E.reset()},[u?.id]);const _=T.data?.messages.reduce((r,B)=>r===void 0||B.seq>r?B.seq:r,void 0);return p.useEffect(()=>{u===null||_===void 0||_<=u.last_read_seq||O.mutate({seq:_})},[u?.id,_]),e.jsxs(e.Fragment,{children:[e.jsx(xa,{listState:o.isPending||A&&x.isLoading?"loading":o.isError||A&&x.isError?"error":"ready",messageState:u===null?"idle":T.isPending?"loading":T.isError?"error":"ready",conversations:N,selected:u,messages:T.data?.messages??[],organizations:h,scope:n,totalUnread:v.data?.total??0,membershipsLoading:x.isLoading,organizationsFailed:x.isError,selfAccountId:M,sending:z.isPending,sendFailed:z.isError,joining:S.isPending,joinFailed:S.isError,notifyFailed:Ve(E,u?.id??null),onJoin:()=>S.mutate(),onNotifyChange:r=>{u!==null&&E.mutate({conversationId:u.id,tenantId:u.tenant_id,notify:r})},onSelect:f,onSend:(r,B)=>{if(u!==null)return z.mutateAsync({clientRef:B,body:r})},onNewConversation:()=>b(!0),onRetry:()=>{o.refetch(),x.isError&&x.refetch()},onScopeChange:G,onRetryMemberships:()=>{x.refetch()}}),e.jsx(da,{open:j,pending:P.isPending,error:P.isError?a("ui.teamBridge.create.error"):void 0,onClose:()=>b(!1),onCreate:r=>{P.mutate(r,{onSuccess:B=>{b(!1);const C=B;C.id&&f(C.id)}})}})]})};export{Ba as TeamBridgePage,xa as TeamBridgePageView,pa as TeamBridgePreviewBanner};