local-operator-ui 0.34.17 → 0.34.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/renderer/assets/{_basePickBy-CSYZDA8f.js → _basePickBy-BTzdjeJL.js} +1 -1
- package/out/renderer/assets/{_baseUniq-Bs3_TwWU.js → _baseUniq-ClXpCJU1.js} +1 -1
- package/out/renderer/assets/{agent-details-page-C4OL25Pu.js → agent-details-page-kG7k6V7x.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-PTpuHZdq.js → agent-hub-page-DjIvJ1FF.js} +1 -1
- package/out/renderer/assets/{agents-page-D7L4OBEa.js → agents-page-D1sgdpYF.js} +3 -3
- package/out/renderer/assets/{arc-dbCmdZw9.js → arc-DoGBhEXi.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-D18BLHXX.js → architectureDiagram-IEHRJDOE-Bbq8VxR0.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-CTjZ0Him.js → blockDiagram-JOT3LUYC-CZ8-WJoR.js} +1 -1
- package/out/renderer/assets/{book-open-Gvm5L0c1.js → book-open-D5Uq3Ss3.js} +1 -1
- package/out/renderer/assets/browser-page-ajgpH-YD.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-ezxNwYGk.js → browser-webauthn-prompt-Cy1c24P5.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-Db_BIHao.js → c4Diagram-VJAJSXHY-CMg0pPCe.js} +1 -1
- package/out/renderer/assets/channel-B8kRK07j.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-Bt1vMwqw.js → chunk-4BMEZGHF-C1aHdchT.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-_ijQomYl.js → chunk-A2AXSNBT-DdMF2zEi.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-DaGLqLPF.js → chunk-AEK57VVT-eMEfSp7Z.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-B3oBz4LP.js → chunk-D6G4REZN-CL5BYgci.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-BeMhbkA_.js → chunk-RZ5BOZE2-DVhDFr2X.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-BiQptECv.js → chunk-XZIHB7SX-99MfNWQw.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-Dtu3Ytm5.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-Dtu3Ytm5.js +1 -0
- package/out/renderer/assets/clone-BR5vKGHh.js +1 -0
- package/out/renderer/assets/{console-mirror-CcyjzlT3.js → console-mirror-YquW6t3z.js} +1 -1
- package/out/renderer/assets/{consoleCapture-DHhTU7ql.js → consoleCapture-DqyTaDPv.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-DjVXTkKV.js → conversation-input-sync-ytgcWY0x.js} +246 -241
- package/out/renderer/assets/{dagre-OKDRZEBW-DFvh7crR.js → dagre-OKDRZEBW-D97-Fxhj.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-rLgNOVtV.js → diagram-SSKATNLV-D0gdhCPs.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-CFB__Yko.js → diagram-VNBRO52H-Cj4Kgnkz.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-D4CpPMC1.js → erDiagram-Q7BY3M3F-FrW2YoMW.js} +1 -1
- package/out/renderer/assets/{error-boundary-TEn-mCmZ.js → error-boundary-2xFIZZKb.js} +1 -1
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-CmdnmgbD.js → flowDiagram-4HSFHLVR-dR2dNi9y.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-DVC2I6ip.js → ganttDiagram-APWFNJXF-BTkDVSsE.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-iJ1pqJF8.js → gitGraphDiagram-7IBYFJ6S-DleM5vN1.js} +1 -1
- package/out/renderer/assets/{graph-SHQmZOY-.js → graph-B7iwaPxx.js} +1 -1
- package/out/renderer/assets/{index-C70RKdbA.js → index-B3zkDvm4.js} +1 -1
- package/out/renderer/assets/{index-cxbtyIHr.js → index-C2OZuNVF.js} +1 -1
- package/out/renderer/assets/index-CameR-2C.css +1 -0
- package/out/renderer/assets/{index-c-Fx2Vgb.js → index-DsrArruN.js} +183 -188
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-DXj2yKkd.js → infoDiagram-PH2N3AL5-BL0nyifn.js} +1 -1
- package/out/renderer/assets/{installer-DcGxctrG.js → installer-bagOSsb8.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-BJUI1b7t.js → journeyDiagram-U35MCT3I-lNLJ1ZuC.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-C6Qz0dbx.js → kanban-definition-NDS4AKOZ-BpzHqP8Z.js} +1 -1
- package/out/renderer/assets/{layout-DTXby6Ur.js → layout-vUacEXjP.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-D7cyV0VN.js → legacy-agents-page-Cj_bGt6m.js} +1 -1
- package/out/renderer/assets/{mermaid.core-1-VYQfkv.js → mermaid.core-Dcwmrtu1.js} +5 -5
- package/out/renderer/assets/{mesh-page-DSI2_FpM.js → mesh-page-BBAQoIDQ.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-CJ0ZlZTK.js → mindmap-definition-ALO5MXBD-tPXDtJa0.js} +1 -1
- package/out/renderer/assets/{mini-CaEbgnyP.js → mini-B31JTEdV.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-CoQZWBpq.js → org-surface-gate-BvMV16x5.js} +1 -1
- package/out/renderer/assets/{page-header-Bx8pMJ4O.js → page-header-DswfuZnq.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-BMWzN0vu.js → pieDiagram-IB7DONF6-DPIyLUtm.js} +1 -1
- package/out/renderer/assets/{projects-page-DaZzLkZF.js → projects-page-coS7BIa1.js} +7 -7
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-CjnPbNkC.js → quadrantDiagram-7GDLP6J5-DoUhsQI4.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-Dwtx-mmA.js → radar-MK3ICKWK-MK1j6tNt.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-Bi-DCMXV.js → radient-auth-buttons-Dk8f_aNO.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-Cg7QjWmB.js → requirementDiagram-KVF5MWMF-D0P4Ei80.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-D8ZtoGbS.js → sankeyDiagram-QLVOVGJD-CAiY39K3.js} +1 -1
- package/out/renderer/assets/{schedules-page-DgshdZJ5.js → schedules-page-DKpJUjD7.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-DtRWBoBi.js → sequenceDiagram-X6HHIX6F-J4a1sZnX.js} +1 -1
- package/out/renderer/assets/{settings-page-EWKYtjqa.js → settings-page-nCCt45Cg.js} +1 -1
- package/out/renderer/assets/{settings-section-BtQ9uJRu.js → settings-section-BNw5I-u0.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-DOV2iq0j.js → stateDiagram-DGXRK772-BrSOofJy.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-Bgv61tqv.js +1 -0
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-C5CNXEoL.js → timeline-definition-BDJGKUSR-KjOkAq4W.js} +1 -1
- package/out/renderer/assets/{ui-preferences-store-CSvw6GaV.js → ui-preferences-store-CagOssaI.js} +1 -1
- package/out/renderer/assets/{use-download-agent-mutation-DIBkVJYw.js → use-download-agent-mutation-CUCAJuKY.js} +1 -1
- package/out/renderer/assets/{use-memberships-query-BJSNqMw5.js → use-memberships-query-C7IMCmZ3.js} +1 -1
- package/out/renderer/assets/{use-session-snapshot-CsT6qPEs.js → use-session-snapshot-DffSufPj.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-Y4l-1FU7.js → xychartDiagram-VJFVF3MP-clq1vjIx.js} +1 -1
- package/out/renderer/console-capture.html +5 -5
- package/out/renderer/index.html +7 -7
- package/out/renderer/installer.html +4 -4
- package/out/renderer/mini.html +7 -7
- package/package.json +3 -2
- package/out/renderer/assets/browser-page-CvHukGeG.js +0 -1
- package/out/renderer/assets/channel-BJfrCD5R.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-vzy-gaGW.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-vzy-gaGW.js +0 -1
- package/out/renderer/assets/clone-CMOVH7h7.js +0 -1
- package/out/renderer/assets/index-FScMgTJj.css +0 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-mP6i9-kO.js +0 -1
- /package/out/renderer/assets/{index-Dj4jIPlf.js → index-S51O3g2W.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as d,j as t,c as $}from"./index-
|
|
1
|
+
import{r as d,j as t,c as $}from"./index-S51O3g2W.js";import{bV as _a,bW as Yt,bX as Ca,bY as gn,u as bn,bZ as Ea,b_ as Ra,b$ as Da,c0 as Aa,c1 as Oa,c2 as $a,c3 as Cs,c4 as Es,c5 as Pa,c6 as Ma,aH as os,aO as Oe,d as ce,c7 as Ia,aI as ls,c8 as La,c9 as Fa,ca as qa,cb as Ua,cc as Ue,cd as Ba,T as Et,ce as Rs,cf as Ds,cg as As,bH as Ya,aP as ve,ch as za,ci as $e,a as Ge,b as fe,a_ as Ha,aR as Rt,ax as ct,aV as Be,cj as Wa,ck as Ka,cl as Ga,cm as Va,cn as Qa,aX as jn,aW as yt,co as zt,b1 as Xa,as as Ja,ah as vt,bd as Za,bc as er,b9 as Os,cp as tr,cq as sr,cr as nr,cs as ar,ct as rr,cu as ir,cv as yn,aQ as or,ay as le,ag as lr,ab as cr,ac as dr,ae as ur,af as mr,ai as fr,ao as hr,cw as pr,cx as vn,bh as xr,cy as gr,aq as br,aS as jr,a$ as yr}from"./conversation-input-sync-ytgcWY0x.js";import{P as $s}from"./page-header-DswfuZnq.js";import{c as Ve,s as Ye,f as cs,t as ze,u as He,v as We,w as Te,B as U,D as kn,l as wn,S as ke,m as Nn,p as st,_ as vr,$ as kr,a0 as wr,a1 as Nr,a2 as Sr,o as Tr,j as pe,U as ds,a3 as us,W as ms,I as ne,X as Dt,C as fs,T as Sn,L as ie,y as Tn,Y as _n,A as Ht,M as _r,N as Cr,O as Er,P as Rr,e as Le}from"./error-boundary-2xFIZZKb.js";import{aM as Cn,aS as Dr,aT as En,aU as Ar,ay as Or,an as rt,aV as $r,A as Ps,aW as Ms,aX as Pr}from"./index-DsrArruN.js";import{u as Mr}from"./use-session-snapshot-DffSufPj.js";import"./ui-preferences-store-CagOssaI.js";import"./console-mirror-YquW6t3z.js";function Is(e,s){return e.filter(n=>!s.includes(n))}function Ir(e,s,n){const a=e.slice(0);return a[s]=n,a}var Lr=class extends _a{#n;#e;#a;#r;#t;#s;#i;#o;#l=[];constructor(e,s,n){super(),this.#n=e,this.#r=n,this.#a=[],this.#t=[],this.#e=[],this.setQueries(s)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(s=>{this.#m(e,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,s){this.#a=e,this.#r=s,Yt.batch(()=>{const n=this.#t,a=this.#u(this.#a);this.#l=a,a.forEach(o=>o.observer.setOptions(o.defaultedQueryOptions));const r=a.map(o=>o.observer),i=r.map(o=>o.getCurrentResult()),l=r.some((o,c)=>o!==n[c]);n.length===r.length&&!l||(this.#t=r,this.#e=i,this.hasListeners()&&(Is(n,r).forEach(o=>{o.destroy()}),Is(r,n).forEach(o=>{o.subscribe(c=>{this.#m(o,c)})}),this.#f()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,s){const n=this.#u(e),a=n.map(r=>r.observer.getOptimisticResult(r.defaultedQueryOptions));return[a,r=>this.#d(r??a,s),()=>this.#c(a,n)]}#c(e,s){return s.map((n,a)=>{const r=e[a];return n.defaultedQueryOptions.notifyOnChangeProps?r:n.observer.trackResult(r,i=>{s.forEach(l=>{l.observer.trackProp(i)})})})}#d(e,s){return s?((!this.#s||this.#e!==this.#o||s!==this.#i)&&(this.#i=s,this.#o=this.#e,this.#s=Ca(this.#s,s(e))),this.#s):e}#u(e){const s=new Map(this.#t.map(a=>[a.options.queryHash,a])),n=[];return e.forEach(a=>{const r=this.#n.defaultQueryOptions(a),i=s.get(r.queryHash);i?n.push({defaultedQueryOptions:r,observer:i}):n.push({defaultedQueryOptions:r,observer:new gn(this.#n,r)})}),n}#m(e,s){const n=this.#t.indexOf(e);n!==-1&&(this.#e=Ir(this.#e,n,s),this.#f())}#f(){if(this.hasListeners()){const e=this.#s,s=this.#c(this.#e,this.#l),n=this.#d(s,this.#r?.combine);e!==n&&Yt.batch(()=>{this.listeners.forEach(a=>{a(this.#e)})})}}};function Fr({queries:e,...s},n){const a=bn(n),r=Ea(),i=Ra(),l=d.useMemo(()=>e.map(v=>{const g=a.defaultQueryOptions(v);return g._optimisticResults=r?"isRestoring":"optimistic",g}),[e,a,r]);l.forEach(v=>{Da(v),Aa(v,i)}),Oa(i);const[o]=d.useState(()=>new Lr(a,l,s)),[c,m,u]=o.getOptimisticResult(l,s.combine),h=!r&&s.subscribed!==!1;d.useSyncExternalStore(d.useCallback(v=>h?o.subscribe(Yt.batchCalls(v)):$a,[o,h]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),d.useEffect(()=>{o.setQueries(l,s)},[l,s,o]);const f=c.some((v,g)=>Cs(l[g],v))?c.flatMap((v,g)=>{const x=l[g];if(x){const y=new gn(a,x);if(Cs(x,v))return Es(x,y,i);Pa(v,r)&&Es(x,y,i)}return[]}):[];if(f.length>0)throw Promise.all(f);const j=c.find((v,g)=>{const x=l[g];return x&&Ma({result:v,errorResetBoundary:i,throwOnError:x.throwOnError,query:a.getQueryCache().get(x.queryHash),suspense:x.suspense})});if(j?.error)throw j.error;return m(u())}/**
|
|
2
2
|
* @license lucide-react v0.507.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -13,7 +13,7 @@ import{r as d,j as t,c as $}from"./index-Dj4jIPlf.js";import{bV as _a,bW as zt,b
|
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
16
|
+
*/const Yr=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],zr=Ve("link-2",Yr);/**
|
|
17
17
|
* @license lucide-react v0.507.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
@@ -28,13 +28,13 @@ import{r as d,j as t,c as $}from"./index-Dj4jIPlf.js";import{bV as _a,bW as zt,b
|
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const Vr=[["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"}]],Qr=Ve("unlink",Vr),At={list:["desktop","projects"],detail:e=>["desktop","projects",e]};function Xr(e){return os({queryKey:At.list,enabled:e,queryFn:()=>ce({op:"projects.list"}).then(s=>s.projects),retry:ls,staleTime:1e4})}function Jr(e,s){return Fr({queries:e.map(n=>({queryKey:At.detail(n),enabled:s&&!!n,queryFn:()=>ce({op:"projects.get",key:n}),retry:ls,staleTime:1e4}))})}function Dn(e,s){return os({queryKey:At.detail(e??""),enabled:s&&!!e,queryFn:()=>ce({op:"projects.get",key:e??""}),retry:ls,staleTime:1e4})}function Pe(){const e=bn();return()=>{e.invalidateQueries({queryKey:At.list})}}function Zr(){const e=Pe();return Oe({mutationFn:s=>ce({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 An(){const e=Pe();return Oe({mutationFn:s=>ce({op:"projects.update",key:s.key,fields:s.fields,...s.forceDone===!0?{force_done:!0}:{}}),retry:Ia,onSuccess:()=>e()})}function On(){const e=Pe();return Oe({mutationFn:s=>ce({op:"projects.delete",key:s.key,confirmed_name:s.confirmedName}),onSuccess:()=>e()})}function ei(){const e=Pe();return Oe({mutationFn:s=>ce({op:"projects.link",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function ti(){const e=Pe();return Oe({mutationFn:s=>ce({op:"projects.unlink",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function si(){const e=Pe();return Oe({mutationFn:s=>ce({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 ni(){const e=Pe();return Oe({mutationFn:s=>ce({op:"projects.milestone.remove",key:s.key,name:s.name}),onSuccess:()=>e()})}const $n={planning:{label:"Planning",variant:"info"},active:{label:"Active",variant:"accent"},qa:{label:"QA",variant:"attention"},validation:{label:"Validation",variant:"warning"},done:{label:"Done",variant:"success"},paused:{label:"Paused",variant:"neutral"},archived:{label:"Archived",variant:"outline"}},Fe=Object.keys($n);function Z(e){return $n[e]??{label:e||"Unknown",variant:"neutral"}}const Pn=["planning","active","qa","validation","done","paused","archived"].map(e=>({value:e,label:Z(e).label}));function ai(e){return e==="done"}const ri={completed:{label:"Completed",variant:"success"},overdue:{label:"Overdue",variant:"warning"},upcoming:{label:"Upcoming",variant:"neutral"}};function ii(e){return ri[e]??{label:String(e),variant:"neutral"}}const kt="Stale",oi=/^(\d{4})-(\d{2})-(\d{2})$/;function _e(e,s,n=new Date){if(!e)return"";const a=oi.exec(e);if(!a)return e;const r=new Date(Number(a[1]),Number(a[2])-1,Number(a[3]));if(Number.isNaN(r.getTime()))return e;const i=La(r,{month:"short",day:"numeric"},s);return r.getFullYear()===n.getFullYear()?i:`${i}, ${r.getFullYear()}`}function dt(e,s){if(e==null)return"";const n=Math.max(0,Math.floor(s/1e3-e));return n<60?"just now":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}d`}function ut(e){return e==="just now"?"just now":`${e} ago`}function li(e){return e?`reported ${ut(e)}`:"no progress"}const Mn=/^$|^\d{4}-\d{2}-\d{2}$/;function In(e){return e?e==="operator"?"the operator":`session ${e}`:""}function ci(e,s){if(!e.progress)return"not reported yet";const n=dt(e.progress_updated_at,s),a=In(e.progress_reported_by),r=[n?`reported ${ut(n)}`:"reported"];return a&&r.push(`by ${a}`),r.join(" ")}function Ln(e,s){if(e==null)return"";const n=String(e);return s==="points"?`${n} pt`:s==="days"?`${n}d`:n}function Fn(e,s){return s<=0?"":`${e}/${s}`}function hs(e){return e<=0?"":`${e} live`}function di(e){return e<=0?"":e===1?"1 session":`${e} sessions`}function ui(e){return e===1?"1 project":`${e} projects`}function mi(e){const s=di(e.sessions);if(!s)return"";const n=hs(e.live_sessions);return n?`${s} · ${n}`:s}function fi(e){if(!e.exists)return{label:"Missing",variant:"outline"};if(e.archived)return{label:"Archived",variant:"neutral"};switch(e.runtime?.state){case"live":return{label:"Live",variant:"success"};case"wedged":return{label:"Wedged",variant:"warning"};case"stale":return{label:"Stale",variant:"warning"};case"stopped":return{label:"Stopped",variant:"neutral"};default:return{label:String(e.runtime?.state??"Unknown"),variant:"neutral"}}}function hi(e){return e?e.running>0?e.running===1?"1 subagent running":`${e.running} subagents running`:e.settled===1?"1 subagent":`${e.settled} subagents`:""}function pi(e){return e?e.total===1?"1 todo":`${e.total} todos`:""}function qn(e,s){const n=[],a=_e(e.completed_at??e.target_date,s);a&&n.push({key:e.completed_at?"completed":"target",text:e.completed_at?`completed ${a}`:`due ${a}`});const r=Ln(e.estimate,e.estimate_unit);r&&n.push({key:"estimate",text:r});const i=Fn(e.milestones_completed,e.milestones_total);i&&n.push({key:"milestones",text:`milestones ${i}`});const l=hs(e.live_sessions);return l&&n.push({key:"live",text:l}),n}const qe=864e5,xi=/^(\d{4})-(\d{2})-(\d{2})$/;function he(e){if(!e)return null;const s=xi.exec(e);if(!s)return null;const n=Number(s[1]),a=Number(s[2]),r=Number(s[3]),i=Date.UTC(n,a-1,r),l=new Date(i);return l.getUTCFullYear()!==n||l.getUTCMonth()!==a-1||l.getUTCDate()!==r?null:i}const Wt=["planning","active","qa","validation","done"],Kt=["paused","archived"],Ot=[{value:"24h",label:"Last 24 hours",phrase:"the last 24 hours",seconds:86400},{value:"7d",label:"Last 7 days",phrase:"the last 7 days",seconds:604800},{value:"30d",label:"Last 30 days",phrase:"the last 30 days",seconds:2592e3},{value:"90d",label:"Last 90 days",phrase:"the last 90 days",seconds:7776e3},{value:"all",label:"All time",phrase:null,seconds:null}],Un="7d",gi=Ot.find(e=>e.value===Un);function Bn(e){return Ot.find(s=>s.value===e)??gi}function bi(e){return Ot.some(s=>s.value===e)}function Ls(e,s,n){const a=Bn(s);return a.seconds===null?e:e.filter(r=>n/1e3-r.updated_at<=a.seconds)}function ji(e){const s=Bn(e);return s.seconds===null?null:`Nothing changed in ${s.phrase}.`}const zn="projects-board-window";function yi(){try{const e=localStorage.getItem(zn);if(e!==null&&bi(e))return e}catch{}return Un}function Fs(e){try{localStorage.setItem(zn,e)}catch{}}const Yn="projects-board-column-order";let Gt=null;function vi(){if(Gt)return[...Gt];try{const e=localStorage.getItem(Yn);if(!e)return[];const s=JSON.parse(e);if(!Array.isArray(s))return[];const n=[];for(const a of s){if(typeof a!="string"||a.length===0)return[];n.includes(a)||n.push(a)}return n}catch{return[]}}function ki(e){Gt=[...e];try{localStorage.setItem(Yn,JSON.stringify(e))}catch{}}function wi(e,s,n){const a=e.filter(i=>i!==s),r=Math.max(0,Math.min(n,a.length));return a.splice(r,0,s),a}function Ni(e,s=[]){const n=new Map;for(const o of e){const c=n.get(o.status)??[];c.push(o),n.set(o.status,c)}const a=Wt.map(o=>({status:o,projects:n.get(o)??[]}));for(const o of Kt){const c=n.get(o)??[];c.length>0&&a.push({status:o,projects:c})}for(const[o,c]of n)!Kt.includes(o)&&!Wt.includes(o)&&a.push({status:o,projects:c});if(s.length===0)return a;const r=new Map(s.map((o,c)=>[o,c])),i=a.filter(o=>r.has(o.status));i.sort((o,c)=>(r.get(o.status)??0)-(r.get(c.status)??0));const l=a.filter(o=>!r.has(o.status));return[...i,...l]}function Hn(e,s){if(e.status==="done"||e.status==="archived"||e.completed_at)return!1;const n=he(e.target_date);return n===null?!1:n<s}function G(e){return e.title||e.name}const ps="No team";function mt(e){const s=e.team?.trim();if(s)return s;const n=e.owner?.trim();return n||null}function xs(e,s){const n=new Map,a=[];for(const i of e){const l=s(i);if(l===null){a.push(i);continue}const o=n.get(l);o?o.push(i):n.set(l,[i])}const r=[...n.entries()].sort(([i],[l])=>i.localeCompare(l,void 0,{sensitivity:"base"})).map(([i,l])=>({team:i,items:l}));return a.length>0&&r.push({team:null,items:a}),r}function $t(e){return e.title||e.session_id}function Si(e){return[...e].reverse()}function Ti(e){return e<=0?"":e===1?"1 update":`${e} updates`}const qs=e=>String(e).padStart(2,"0");function Vt(e){return`${e.getFullYear()}-${qs(e.getMonth()+1)}-${qs(e.getDate())}`}function _i(e){const s=Date.parse(e);return Number.isNaN(s)?"":Vt(new Date(s))}function Ci(e,s,n=new Date){if(!e)return"";if(e===Vt(n))return"Today";const a=new Date(n.getFullYear(),n.getMonth(),n.getDate()-1);return e===Vt(a)?"Yesterday":_e(e,s,n)}function Ei(e,s){const n=Date.parse(e);return Number.isNaN(n)?"":Fa(new Date(n),{hour:"numeric",minute:"2-digit"},s)}function Ri(e,s){const n=Date.parse(e);return Number.isNaN(n)?"":ut(dt(n/1e3,s))}function Di(e,s,n=Date.now()){const a=[],r=In(e.by);r&&a.push({key:"author",text:r});const i=Ei(e.at,s);i&&a.push({key:"time",text:i});const l=Ri(e.at,n);return l&&a.push({key:"age",text:l}),a}function Ai(e,s,n=new Date){const a=[];for(const r of Si(e)){const i=_i(r.at),l=a[a.length-1];if(l&&l.key===i){l.entries.push(r);continue}a.push({key:i,label:Ci(i,s,n),entries:[r]})}return a}function Oi(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 $i(e,s){return s<=0?"":`${e} of ${s} complete`}function Pi(e){let s=0,n=0,a=!1;for(const r of e)r.todos&&(a=!0,s+=r.todos.open,n+=r.todos.total);return a?{open:s,total:n}:null}function Us(e){return`${e.open} open of ${e.total}`}function Mi(e){const s=e.filter(a=>a.exists);return(s.find(a=>a.runtime?.state==="live")??s[0])?.session_id??null}function Ii(e){const s=G(e),n=e.progress.trim()||"not reported yet";return[`Continue work on project "${s}" (${e.name}).`,`Latest progress: ${n}`,"Review the project details and continue or complete the work."].join(`
|
|
32
|
-
`)}function Li(e){return e?e.kind==="team"?`team ${e.name}`:`agent ${e.name}`:""}const Fi=/'((?:[^'\\]|\\.)*)'|"((?:[^"\\]|\\.)*)"/g;function Wn(e){const s=[];for(const n of e.matchAll(Fi))s.push((n[1]??n[2]??"").replace(/\\(.)/g,"$1"));return s}const jt=3;function gs(e){if(e.length<=jt+1)return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`;const s=e.length-jt;return`${e.slice(0,jt).join(", ")} and ${s} more`}function bs(e){return`${e} milestone${e===1?" is":"s are"}`}const Bs="complete them, or pass force_done=true to close with them open",qi="complete or remove the incomplete milestones, then mark it done",Kn=/^cannot set status 'done': (\d+) milestones? still incomplete \((.+)\) — /;function ft(e){const s=e.match(Kn);if(s){const n=Number(s[1]),a=Wn(s[2]),r=a.length>0?gs(a):s[2];return`This can't be marked done yet: ${bs(n)} still incomplete (${r}). Complete or remove the incomplete milestones, then mark it done.`}return e.includes(Bs)?e.replace(Bs,qi):e}const Ui="project_done_incomplete";function Bi(e){const s=e.message.match(Kn),n=e.code===Ui;if(!n&&!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,r=a&&a.length>0?a:s?Wn(s[2]):[];return{count:r.length>0?r.length:s?Number(s[1]):0,names:r,coded:n,message:e.message}}function zi(e){if(e.count>0){const s=gs(e.names);return`${bs(e.count)} still open${s?` (${s})`:""}.`}return ft(e.message)||"Some milestones are still open."}function Yi(e){return e.count>0&&e.names.length>0?`This can't be marked done yet: ${bs(e.count)} still incomplete (${gs(e.names)}). Complete or remove the incomplete milestones, then mark it done.`:ft(e.message)||"Milestones are still open on this project. Complete or remove them, then mark it done."}function Gn(e,s,n){if(!e||e.forced_done!==!0)return`Moved to ${n}`;const a=typeof e.milestones_total=="number"&&typeof e.milestones_completed=="number"?e.milestones_total-e.milestones_completed:s,r=a>0?a:s;return`Moved to ${n} with ${r} milestone${r===1?"":"s"} still open`}const Hi="The project was not moved. Try again, or open it to change its status.";function Vn(e){return e.trim().slice(0,qa)}const Wi={client:"Searches names, descriptions, tags, owners and teams. Update text is not searched. Clearing the search and filters restores the list.",backend:"Searches names, descriptions, tags, owners, teams and update text. Clearing the search and filters restores the list."},Ki=2,Gi=4,Vi=3,Qi=2,Xi=1,Ji=3,Re={title:3,name:2.5,description:2,tags:1.5,attribution:1.5,status:1},Zi=/[^\p{L}\p{N}]+/u,eo=/\s+/;function zs(e,s){const n=s.trim().toLowerCase();if(!n)return 0;if(n===e)return Gi;if(n.startsWith(e))return Vi;const a=n.split(Zi).filter(Boolean),r=e.split(eo).filter(Boolean);if(r.length>0&&r.every(l=>a.some(o=>o.startsWith(l))))return Qi;const i=r.join("");return i.length>=Ji&&to(i,n)?Xi:0}function to(e,s){let n=0;for(const a of e){if(n=s.indexOf(a,n),n<0)return!1;n+=1}return!0}function so(e,s){const n=s.trim().toLowerCase();if(!n)return 0;const a=[[e.title,Re.title],[e.name,Re.name],[e.description,Re.description],[e.owner,Re.attribution],[e.team,Re.attribution],[e.status,Re.status]];let r=0;for(const[i,l]of a){if(!i)continue;const o=zs(n,i)*l;o>r&&(r=o)}for(const i of e.tags){const l=zs(n,i)*Re.tags;l>r&&(r=l)}return r}function no(e,s){const n=s.trim();if(!n)return e;const a=[];for(const r of e){const i=so(r,n);i>0&&a.push({project:r,score:i})}return a.sort((r,i)=>{if(r.score!==i.score)return i.score-r.score;if(r.project.updated_at!==i.project.updated_at)return i.project.updated_at-r.project.updated_at;const l=G(r.project).localeCompare(G(i.project),void 0,{sensitivity:"base"});if(l!==0)return l;const o=r.project.name.localeCompare(i.project.name,void 0,{sensitivity:"base"});return o!==0?o:r.project.id<i.project.id?-1:r.project.id>i.project.id?1:0}),a.map(r=>r.project)}function ao(e,s){if(s.length===0)return[];const n=new Map(e.map(r=>[r.id,r])),a=[];for(const r of s){const i=n.get(r.id);i!==void 0&&a.push(i)}return a}const ro=180;function io(e,s){const n=Vn(e),a=Cn(n,ro),r=os({queryKey:["desktop","projects","search",a],enabled:s&&a.length>0,queryFn:()=>ce({op:"projects.search",q:a,limit:Ua}),retry:!1,staleTime:3e4}),i=a===n,l=i&&r.data&&r.data.query===n?r.data:null,o=i&&n.length>0&&!l&&r.isError;return{answer:l,pending:s&&n.length>0&&!l&&!o}}const Qe=["status","team","owner","tags","progress","target","estimate","milestones","live"],Ys={status:[],team:[],owner:[],tags:[],progress:[],target:[],estimate:[],milestones:[],live:[]},at={status:"Status",team:"Team",owner:"Owner",tags:"Tags",progress:"Progress",target:"Target date",estimate:"Estimate",milestones:"Milestones",live:"Live sessions"},oo=new Set(["status","progress","target","estimate","milestones","live"]),lo={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"]},co={stale:"Stale","up-to-date":"Up to date","not-reported":"Not reported",none:"No target date",overdue:"Overdue","within-7":"Due within 7 days","within-30":"Due within 30 days",points:"Points",days:"Days",incomplete:"Incomplete",complete:"Complete","has-live":"Has live sessions","no-live":"No live sessions"};function Qn(e,s){switch(e){case"status":return Z(s).label;case"team":return s===null?"No team":s;case"owner":return s===null?"No owner":s;case"tags":return s??"";case"estimate":if(s==="none")return"No estimate";break;case"milestones":if(s==="none")return"None set";break;case"target":if(s==="none")return"No target date";break}return co[s]??s??""}function uo(e,s){return e[s].length>0}function it(e){return Qe.every(s=>!uo(e,s))}function mo(e){return Qe.reduce((s,n)=>s+e[n].length,0)}function Xn(e,s,n){const a=e[s],r=a.includes(n)?a.filter(i=>i!==n):[...a,n];return{...e,[s]:r}}function Jn(e,s,n,a){switch(e){case"status":return s.status===n;case"team":return mt(s)===n;case"owner":return(s.owner?.trim()||null)===n;case"tags":return s.tags.includes(n??"");case"progress":return n==="stale"?s.progress_stale===!0:n==="up-to-date"?s.progress_stale===!1:s.progress_updated_at===null;case"target":{if(n==="none")return he(s.target_date)===null;if(n==="overdue")return Hn(s,a);const r=he(s.target_date);if(r===null)return!1;const i=(r-a)/qe;return n==="within-7"?i>=0&&i<=7:i>=0&&i<=30}case"estimate":return n==="none"?s.estimate===null:s.estimate===null?!1:n==="points"?s.estimate_unit==="points":s.estimate_unit==="days";case"milestones":return n==="none"?s.milestones_total===0:s.milestones_total===0?!1:n==="complete"?s.milestones_completed>=s.milestones_total:s.milestones_completed<s.milestones_total;case"live":return n==="has-live"?s.live_sessions>0:s.live_sessions===0}}function Zn(e,s,n,a){const r=e[s];return r.length===0?!0:r.some(i=>Jn(s,n,i,a))}function fo(e,s,n){return it(s)?e:e.filter(a=>Qe.every(r=>Zn(s,r,a,n)))}function ho(e,s,n,a){return s.filter(r=>Qe.every(i=>i===e||Zn(n,i,r,a)))}function po(e,s,n){const a=n[e];switch(e){case"status":{const i=[...new Set(s.map(o=>o.status))].filter(o=>!Fe.includes(o)).sort((o,c)=>o.localeCompare(c,void 0,{sensitivity:"base"})),l=a.filter(o=>typeof o=="string"&&!Fe.includes(o)&&!i.includes(o));return[...Fe,...i,...l]}case"team":{const r=new Set;let i=!1;for(const o of s){const c=mt(o);c===null?i=!0:r.add(c)}for(const o of a)o===null?i=!0:r.add(o);const l=[...r].sort((o,c)=>o.localeCompare(c,void 0,{sensitivity:"base"}));return i?[...l,null]:l}case"owner":{const r=new Set;let i=!1;for(const o of s){const c=o.owner?.trim();c?r.add(c):i=!0}for(const o of a)o===null?i=!0:r.add(o);const l=[...r].sort((o,c)=>o.localeCompare(c,void 0,{sensitivity:"base"}));return i?[...l,null]:l}case"tags":{const r=new Set;for(const i of s)for(const l of i.tags)r.add(l);for(const i of a)r.add(i??"");return[...r].sort((i,l)=>i.localeCompare(l,void 0,{sensitivity:"base"}))}case"progress":case"target":case"estimate":case"milestones":case"live":return lo[e]}}function ea(e,s,n,a){const r=ho(e,s,n,a),i=oo.has(e),l=[];for(const o of po(e,r,n)){const c=n[e].includes(o),m=r.reduce((u,h)=>u+(Jn(e,h,o,a)?1:0),0);!i&&m===0&&!c||l.push({value:o,label:Qn(e,o),count:m,selected:c})}return{facet:e,label:at[e],options:l}}function xo(e,s,n){return Qe.map(a=>ea(a,e,s,n))}const Qt="projects-sort",go="Default (as listed)";function bo(e){return jo.includes(e)}const jo=["name","status","target","estimate","milestones","live","progress"];function yo(){try{const e=localStorage.getItem(Qt);if(e===null)return null;const[s,n,...a]=e.split(":");if(a.length>0)return null;if(s&&bo(s)&&(n==="asc"||n==="desc"))return{key:s,direction:n}}catch{}return null}function vo(e){try{e===null?localStorage.removeItem(Qt):localStorage.setItem(Qt,`${e.key}:${e.direction}`)}catch{}}function Ke(e){switch(e){case"name":return"Project";case"status":return"Status";case"target":return"Target";case"estimate":return"Estimate";case"milestones":return"Milestones";case"live":return"Live";case"progress":return"Progress"}}function Lt(e){return e==="target"||e==="progress"?"desc":"asc"}function js(e,s){const n=s==="desc";switch(e){case"name":return n?"Z to A":"A to Z";case"status":return n?"Archived first":"Planning first";case"target":return n?"latest first":"soonest first";case"estimate":return n?"days first":"points first";case"milestones":return n?"most complete first":"least complete first";case"live":return n?"most first":"fewest first";case"progress":return n?"most recent first":"most stale first"}}function ko(e){return e===null?"Sort cleared.":`Sorted by ${Ke(e.key)}, ${js(e.key,e.direction)}.`}function wo(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 n=s.length===1?`${s[0]} cleared.`:`${s.slice(0,-1).join(", ")} and ${s[s.length-1]} cleared.`;return n.charAt(0).toUpperCase()+n.slice(1)}function Hs(e,s){switch(e){case"name":return 0;case"status":return Fe.includes(s.status)?0:1;case"target":return Xt(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 Xt(e){return he(e.completed_at??e.target_date)}function Ws(e){return e==="points"?0:e==="days"?1:2}function No(e,s,n){switch(e){case"name":return G(s).localeCompare(G(n),void 0,{sensitivity:"base"});case"status":return Fe.indexOf(s.status)-Fe.indexOf(n.status);case"target":{const a=Xt(s)??0,r=Xt(n)??0;return a-r}case"estimate":{const a=Ws(s.estimate_unit)-Ws(n.estimate_unit);return a!==0?a:(s.estimate??0)-(n.estimate??0)}case"milestones":return s.milestones_completed*n.milestones_total-n.milestones_completed*s.milestones_total;case"live":return s.live_sessions-n.live_sessions;case"progress":return(s.progress_updated_at??0)-(n.progress_updated_at??0)}}function Ks(e,s){if(e.updated_at!==s.updated_at)return s.updated_at-e.updated_at;const n=G(e).localeCompare(G(s),void 0,{sensitivity:"base"});if(n!==0)return n;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 So(e,s,n){const a=Hs(n.key,e),r=Hs(n.key,s);if(a!==r)return a-r;if(a===1)return Ks(e,s);const i=No(n.key,e,s);return i!==0?n.direction==="desc"?-i:i:Ks(e,s)}function To(e,s){return[...e].sort((n,a)=>So(n,a,s))}const Se=["day","week","month","quarter"],ys={day:24,week:9,month:3,quarter:1};function vs(e){const s=new Date(e);return Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())}function De(e,s){return Math.round((s-e)/qe)}function Gs(e,s){return De(e,s)+1}function _o(e,s){for(const n of Se)if(e*ys[n]<=s)return n;return Se[Se.length-1]}function Co(e){const{project:s}=e;return s.start_date||s.target_date||s.completed_at?!0:e.milestones.some(n=>!!n.target_date)}function Eo(e,s){const n=[s];for(const a of e){for(const r of[a.project.start_date,a.project.target_date,a.project.completed_at]){const i=he(r);i!==null&&n.push(i)}for(const r of a.milestones){const i=he(r.target_date);i!==null&&n.push(i)}}return n.length===1?null:{startMs:Math.min(...n),endMs:Math.max(...n)}}function Ro(e){const s=[],n=[];for(const a of e)(Co(a)?s:n).push(a);return{dated:s,undated:n}}function Do(e){return`${e} project${e===1?"":"s"} without dates`}function Ao(e){const{project:s}=e,n=he(s.start_date),a=he(s.target_date),r=he(s.completed_at),i=s.status==="done"&&r!==null?r:a,l=n??i,o=i??n;return l===null||o===null?null:{fromMs:Math.min(l,o),toMs:Math.max(l,o)}}function Oo(e){const s=[];for(const n of e.milestones){const a=he(n.target_date);a!==null&&s.push({name:n.name,dayMs:a,status:n.status})}return s}const bt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function de(e){const s=new Date(e);return{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),weekday:s.getUTCDay()}}function $o(e){const{year:s,month:n}=de(e);return Date.UTC(s,n-1,1)}function Po(e){const{year:s,month:n}=de(e);return n===12?Date.UTC(s+1,0,1):Date.UTC(s,n,1)}function Mo(e){const{year:s,month:n}=de(e);return Date.UTC(s,Math.floor((n-1)/3)*3,1)}function Io(e){const{year:s,month:n}=de(e),a=Math.floor((n-1)/3);return a===3?Date.UTC(s+1,0,1):Date.UTC(s,a*3+3,1)}function Lo(e){const{weekday:s}=de(e);return e-(s+6)%7*qe}const Fo=26;function qo(e,s,n){const a=[],r=(u,h,b)=>{u<e||u>s||a.push({dayMs:u,label:h,major:b})};if(n==="day"){let u=!1;for(let h=e;h<=s;h+=qe){const{day:b,month:f}=de(h);b===1?(r(h,bt[f-1],!0),u=!0):u?(r(h,"",!1),u=!1):r(h,String(b),!1)}return a}if(n==="week"){for(let u=Lo(e);u<=s;u+=7*qe){if(u<e)continue;const{day:h,month:b}=de(u);de(u-7*qe).month!==b?r(u,`${bt[b-1]} ${h}`,!0):r(u,String(h),!1)}return a}const i=n==="month"?$o:Mo,l=n==="month"?Po:Io,o=u=>{const{year:h,month:b}=de(u);if(n==="month")return b===1&&h!==de(e).year?`${bt[0]} '${String(h%100).padStart(2,"0")}`:bt[b-1];const f=Math.floor((b-1)/3)+1;return f===1&&h!==de(e).year?`Q1 '${String(h%100).padStart(2,"0")}`:`Q${f}`};r(e,o(i(e)),!0);const c=Math.ceil(Fo/ys[n]);let m=e;for(let u=l(i(e));u<=s;u=l(u))De(m,u)<c||(r(u,o(u),!0),m=u);return a}function ot(e){return e.split(",").map(s=>s.trim()).filter(s=>s.length>0)}const wt=80,Nt=80,Vs=64,Qs=8;function Jt(e){return e.trim().length>wt?`Titles are at most ${wt} characters.`:null}function ta(e){return e.length>Ue?`Keep the description within ${Ue} characters.`:null}function St(e,s){return e.trim().length>Nt?`${s==="owner"?"Owners":"Teams"} are at most ${Nt} characters.`:null}function Zt(e){return Mn.test(e)?null:"Dates are YYYY-MM-DD, or empty."}function es(e,s){return e&&s&&s<e?"The target date is before the start date.":null}function sa(e){const s=e.trim();if(s==="")return null;const n=Number(s);return!Number.isFinite(n)||!(n>0)||n>1e3?"Estimates are greater than 0 and at most 1000.":null}function ts(e){const s=ot(e);if(s.length>Qs)return{tags:s,error:`Up to ${Qs} tags.`};for(const n of s){const a=Ba(n);if(a)return{tags:s,error:a}}return{tags:s,error:null}}const Uo="project_name_exists";function Xs(e){return e.code===Uo?"A project with this key already exists.":ft(e.message)||"The project was not saved."}function Bo(e,s){if(e.unit!==s.unit)return!1;const n=e.number.trim(),a=s.number.trim();return a===""?!0:n===""?!1:Number(n)===Number(a)}function zo(e,s){const n=ot(s);return n.length!==e.length?!1:n.every((a,r)=>a===e[r])}function Yo(e,s){const n={},a=s.number.trim();if(a!==""){const r=Number(a);(e.estimate===null||e.estimate!==r)&&(n.estimate=r)}return s.unit!==e.unit&&(n.estimate_unit=s.unit),Object.keys(n).length>0?n:null}function Xe(e){return e instanceof Et?Xs({code:e.code,message:e.message}):Xs({message:e instanceof Error?e.message:""})}function na(e){return e instanceof Et&&(e.code==="project_not_found"||e.status===404)}function aa(e){return!(e instanceof Error)||!e.message?Hi:na(e)?"This project could not be found. It may have been deleted.":Xe(e)}function ra(e){if(!(e instanceof Error))return null;const s=e instanceof Et?e:null;return Bi({code:s?.code??null,message:e.message,detail:s?.detail})}async function Ho(e){try{return await e.move(),{kind:"accepted"}}catch(s){const n=ra(s);return n?.coded&&e.forceDoneOffered&&e.claimQuestion()?{kind:"question",refusal:n}:{kind:"spoken",copy:n?Yi(n):aa(s),refusal:n}}}const Wo="Shows projects last updated within this window; older ones are hidden.",Ko=({value:e,onChange:s})=>t.jsxs(ze,{value:e,onValueChange:n=>s(n),children:[t.jsx(cs,{content:e==="all"?null:Wo,side:"bottom",disableHoverableContent:!0,children:t.jsx(Ye,{"aria-label":"Projects updated within",className:$("w-36 shrink-0"),"data-tour-tag":"projects-board-window",children:t.jsx(He,{})})}),t.jsx(We,{children:Ot.map(n=>t.jsx(Te,{value:n.value,children:n.label},n.value))})]}),ss=6e4,ns=6e3,Js="Requesting updates…",Go=400,Vo="Ask the sessions linked to this project to post a progress update",Qo="linked but not yet in use — it becomes a recipient after the first message",Zs=e=>`project-request-update-${e}`,Xo=e=>`project-request-cooldown-${e}`,Jo=e=>`project-request-update-cooldown-${e}`,Ft=e=>e.length===1?e[0]:e.length===2?`${e[0]} and ${e[1]}`:`${e[0]}, ${e[1]} and ${e.length-2} more`,en=(e,s)=>e.sessions.filter(n=>n.outcome===s).map(n=>$t({session_id:n.session_id,title:n.title})),Zo=e=>e.outcome==="failed"&&e.detail===Qo;function Tt(e,s){const n=Math.max(1,Math.ceil(s/1e3));return`Update already requested ${Math.max(0,Math.ceil(ss/1e3)-n)} s ago on ${e}. Try again in ${n} s.`}function el(e){const s=G({title:e.project.title,name:e.project.key}),{delivered:n,unconfirmed:a,failed:r,total:i}=e.counts;if(e.state==="empty")return{variant:"info",title:`No linked sessions to ask. Link a session to ${s} first.`,duration:ns};if(e.state==="cooldown")return{variant:"info",title:Tt(s,Math.max(0,e.cooldown_remaining_s??0)*1e3),duration:ns};if(e.state!=="sent")return null;const l=en(e,"failed"),o=en(e,"unconfirmed");if(n>=1&&r===0&&a===0)return{variant:"success",title:n===1?`Requested an update from 1 session on ${s}.`:`Requested updates from ${n} sessions on ${s}.`};if(n>=1){let c=`Requested updates from ${n} of ${i} sessions on ${s}.`;return r>0&&(c+=` ${Ft(l)} could not be reached.`),a>0&&(c+=` Delivery to ${Ft(o)} could not be confirmed.`),{variant:"warning",title:c,duration:Number.POSITIVE_INFINITY}}if(r===0)return{variant:"warning",title:`Could not confirm delivery on ${s} — the requests may still reach its sessions.`,duration:Number.POSITIVE_INFINITY};if(a===0){const c=e.sessions.every(Zo);let m;return c?m=i===1?"The linked session has not started yet — it becomes a recipient after its first message.":`The ${i} linked sessions have not started yet — they become recipients after their first message.`:m=`Could not reach any of the ${i} linked sessions on ${s}.`,{variant:"error",title:m,duration:Number.POSITIVE_INFINITY}}return{variant:"warning",title:`Could not reach ${r} of the ${i} linked sessions on ${s}. Delivery to ${Ft(o)} could not be confirmed.`,duration:Number.POSITIVE_INFINITY}}const nt=new Map,ks=new Set,qt=new Map,as=new Set;let ia=0;const _t=()=>{ia+=1;for(const e of as)e()},tl=e=>(as.add(e),()=>{as.delete(e)}),tn=()=>ia,oa=e=>ks.has(e),la=e=>nt.get(e);function sl(e){ks.add(e),_t()}function nl(e){ks.delete(e),_t()}function sn(e,s,n){const a=Date.now();if(n<=a)return;const r=nt.get(e);if(r&&r.untilMs>=n)return;nt.set(e,{startedMs:s,untilMs:n});const i=qt.get(e);i&&clearTimeout(i);const l=setTimeout(()=>{qt.delete(e);const o=nt.get(e);o&&o.untilMs<=Date.now()&&(nt.delete(e),_t())},n-a);l.unref?.(),qt.set(e,l),_t()}const al=e=>/[.!?…]$/.test(e)?e:`${e}.`;function rl(e,s){const n=Date.now();if(s.state==="cooldown"){const a=Math.max(0,s.cooldown_remaining_s??0)*1e3;sn(e,n-(ss-a),n+a);return}s.state==="sent"&&(s.counts.delivered>=1||s.counts.unconfirmed>=1)&&sn(e,n,n+ss)}async function il(e){const s=e.id;if(oa(s)){Rs(Js,{id:Zs(s)});return}const n=Date.now(),a=la(s);if(a&&a.untilMs>n){Ds(Tt(G(e),a.untilMs-n),{id:Xo(s),duration:ns});return}sl(s);const r=Zs(s);let i=!1;const l=setTimeout(()=>{i=!0,Rs(Js,{id:r})},Go);try{const o=await ce({op:"projects.request_update",key:s});rl(s,o);const c=el(o);if(c){const m={id:r,...c.duration!==void 0?{duration:c.duration}:{}};switch(c.variant){case"success":ve(c.title,m);break;case"warning":za(c.title,m);break;case"error":As(c.title,m);break;default:Ds(c.title,m)}}else i&&Ya(r)}catch(o){const c=o instanceof Error&&o.message.trim()!==""?o.message.trim():null;As(c?`Could not request updates: ${al(c)}`:"The request could not be confirmed.",{id:r,duration:Number.POSITIVE_INFINITY})}finally{clearTimeout(l),nl(s)}}function ca(){return d.useCallback(e=>{il(e)},[])}function ol(e){d.useSyncExternalStore(tl,tn,tn);const s=oa(e),n=la(e),a=n!==void 0?n.untilMs-Date.now():0,r=a>0;return{sending:s,cooling:r,cooldownRemainingMs:r?a:null}}const nn={active:"In flight",paused:"On hold",done:"Finished"};function ll(){const[e,s]=d.useState(null);return d.useEffect(()=>{if(!e)return;const n=document.querySelector(`[data-project-menu="${e}"]`);n&&(n.focus(),s(null))}),d.useCallback(n=>s(n),[])}const cl=4,Ut="Drag the header, or press the arrow keys, to move this column.",an="board-column-move-hint",dl=({projects:e,nowMs:s,onOpen:n,onEdit:a,onDelete:r,onMove:i,movingKeys:l=[],teamLabelFor:o=c=>c})=>{const[c,m]=d.useState(vi),u=Ni(e,c),h=xs(e,mt),[b,f]=d.useState(null),[j,v]=d.useState(""),g=d.useRef(null),x=d.useRef(null),y=d.useRef(null),C=d.useRef(null),w=d.useRef(null),L=new Set(l),T=(k,N)=>{const R=wi(u.map(M=>M.status),k,N);m(R),ki(R),v(`Moved ${Z(k).label} column to position ${R.indexOf(k)+1} of ${R.length}.`)},_=(k,N)=>{const R=g.current;if(!R)return 0;let M=0;const F=R.querySelectorAll("[data-board-column]");for(const q of F){if(q.dataset.boardColumn===N)continue;const ae=q.getBoundingClientRect();k>(ae.left+ae.right)/2&&(M+=1)}return M},O=(k,N)=>{const R=u.filter(q=>q.status!==k),M=R[N-1]?.status,F=R[N]?.status;return M&&F?`between ${Z(M).label} and ${Z(F).label}`:F?`before ${Z(F).label}`:M?`after ${Z(M).label}`:"in place"},p=(k,N)=>{const R=_(k,N.status);R!==N.over&&(N.over=R,f({status:N.status,over:R}),v(`Moving ${Z(N.status).label} column; it will drop ${O(N.status,R)}.`))},A=()=>{C.current!==null&&(cancelAnimationFrame(C.current),C.current=null)},E=32,P=12,z=()=>{C.current=null;const k=w.current,N=g.current,R=y.current;if(!k?.armed||!N||R===null)return;const M=N.getBoundingClientRect(),F=N.scrollWidth-N.clientWidth;let q=0;if(R-M.left<E&&N.scrollLeft>0?q=-1:M.right-R<E&&N.scrollLeft<F&&(q=1),q!==0){const ae=N.scrollLeft;N.scrollLeft=ae+q*P,N.scrollLeft!==ae&&p(R,k)}else p(R,k);Q(k.status,k.over),C.current=requestAnimationFrame(z)};d.useEffect(()=>()=>{C.current!==null&&cancelAnimationFrame(C.current)},[]);const I=(k,N)=>{if(k.button===0){try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}w.current={pointerId:k.pointerId,status:N,startX:k.clientX,startY:k.clientY,armed:!1,over:u.findIndex(R=>R.status===N)},y.current=k.clientX}},B=k=>{const N=w.current;if(!(!N||k.pointerId!==N.pointerId)){if(y.current=k.clientX,!N.armed){if(Math.hypot(k.clientX-N.startX,k.clientY-N.startY)<cl)return;N.armed=!0,f({status:N.status,over:N.over}),v(`Moving ${Z(N.status).label} column.`),C.current===null&&(C.current=requestAnimationFrame(z))}p(k.clientX,N)}},W=k=>{const N=w.current;if(w.current=null,A(),f(null),!N?.armed)return;if(!k){v("Move cancelled.");return}const R=u.findIndex(M=>M.status===N.status);if(N.over===R){v("");return}T(N.status,N.over)},V=k=>{const N=w.current;!N||k.pointerId!==N.pointerId||W(!0)},oe=()=>{W(!1)};d.useEffect(()=>{if(!b)return;const k=N=>{N.key==="Escape"&&W(!1)};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[b!==null]);const Q=d.useCallback((k,N)=>{const R=g.current,M=x.current;if(!R||!M)return;const F=R.getBoundingClientRect(),q=[];for(const re of R.querySelectorAll("[data-board-column]"))re.dataset.boardColumn!==k&&q.push(re.getBoundingClientRect());const ae=6,Ce=N>=q.length?(q[q.length-1]?.right??F.left)+ae:(q[N]?.left??F.right)-ae,Y=R.scrollLeft,we=2,xe=Ce-F.left+Y,me=Y+1,J=Y+F.width-we-1,Ee=Math.round(Math.min(Math.max(xe,me),Math.max(me,J)));M.style.left=`${Ee}px`},[]);d.useLayoutEffect(()=>{b&&Q(b.status,b.over)},[b,Q]);const X=(k,N)=>{if(k.key==="Enter"||k.key===" "){k.preventDefault(),v(Ut);return}if(k.key!=="ArrowLeft"&&k.key!=="ArrowRight")return;k.preventDefault();const R=u.map(q=>q.status),M=R.indexOf(N),F=k.key==="ArrowLeft"?M-1:M+1;if(F<0||F>=R.length){v(`${Z(N).label} column is already ${F<0?"the first column":"the last column"}.`);return}T(N,F)};return t.jsxs("div",{className:"[container-type:size] flex min-h-0 flex-1 flex-col","data-testid":"project-board",children:[t.jsx("output",{"aria-live":"polite",className:"sr-only","data-board-column-announcement":"",children:j}),t.jsx("span",{id:an,className:"sr-only",children:Ut}),t.jsxs("div",{ref:g,"data-board-strip":"",className:$("relative flex min-h-0 flex-1 items-start overflow-auto px-6 pb-9",b&&"cursor-grabbing select-none"),children:[b&&t.jsx("div",{ref:x,"aria-hidden":"true","data-board-drop-indicator":"",className:"pointer-events-none absolute top-3 bottom-3 w-0.5 rounded-full bg-accent"}),t.jsxs("div",{className:"flex w-max flex-col",children:[t.jsx("div",{className:"sticky top-0 z-30 flex gap-3",children:u.map(k=>{const N=Z(k.status);return t.jsxs("header",{"data-board-column":k.status,"data-board-column-handle":k.status,onPointerDown:R=>I(R,k.status),onPointerMove:B,onPointerUp:V,onPointerCancel:oe,className:$("flex h-11 w-64 shrink-0 cursor-grab items-center justify-between gap-2 rounded-t-md bg-sunken px-3 active:cursor-grabbing",b?.status===k.status&&"opacity-85"),children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[t.jsx(U,{type:"button",variant:"ghost",size:"icon-sm","data-board-column-grip":k.status,"aria-label":`Move ${N.label} column`,"aria-describedby":an,title:Ut,className:"-ml-1.5 cursor-grab text-ink-muted active:cursor-grabbing",onKeyDown:R=>X(R,k.status),children:t.jsx(Ar,{"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:N.label}),nn[k.status]&&t.jsx("span",{className:"truncate text-meta text-ink-muted",children:nn[k.status]})]})]}),t.jsx("span",{className:"text-meta text-ink-muted",children:k.projects.length})]},k.status)})}),h.map(k=>t.jsxs("section",{className:"flex flex-col",children:[t.jsx("div",{"data-board-team":k.team??"",className:"sticky top-11 z-20 flex h-8 items-center bg-canvas px-3 text-meta",children:t.jsxs("span",{className:"sticky left-3 flex min-w-0 max-w-[calc(100cqw-2.25rem)] items-center gap-2",children:[t.jsx("span",{className:"truncate text-ink",children:k.team==null?ps:o(k.team)}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:k.items.length})]})}),t.jsx("div",{className:"flex gap-3 rounded-md bg-sunken py-2",children:u.map(N=>{const R=k.items.filter(M=>M.status===N.status);return t.jsx("div",{"data-board-cell":N.status,className:"flex max-h-[calc(100cqh-92px)] w-64 shrink-0 flex-col gap-2 overflow-y-auto px-2",children:R.length>0&&t.jsx("ul",{className:"flex flex-col gap-2",children:R.map(M=>t.jsx("li",{children:t.jsx(ul,{project:M,nowMs:s,busy:L.has(M.id),onOpen:()=>n(M),onEdit:()=>a(M),onDelete:()=>r(M),onMove:F=>i(M,F)})},M.id))})},N.status)})})]},k.team??""))]})]})]})},ul=({project:e,nowMs:s,busy:n,onOpen:a,onEdit:r,onDelete:i,onMove:l})=>{const o=$e(),c=qn(e,o),m=Ge(),u=ca(),h=fe(m.data,"projects_request_update"),b=G(e),f=d.useRef(null),[j,v]=d.useState(!1);d.useEffect(()=>{const w=f.current;if(!w)return;const L=()=>{w.isConnected&&v(w.scrollWidth-w.clientWidth>.5)},T=requestAnimationFrame(L),_=new ResizeObserver(L);return _.observe(w),document.fonts?.ready.then(L).catch(()=>{}),()=>{cancelAnimationFrame(T),_.disconnect()}},[b,j]);const g=Hn(e,vs(s)),x=dt(e.progress_updated_at,s),y=()=>{const w=window.getSelection();w&&!w.isCollapsed||a()},C=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":`Open ${b}`,onClick:y,onKeyDown:C,className:$("group/card flex flex-col gap-2 rounded-sm bg-surface p-3","transition-colors duration-fast ease-out-quart hover:bg-elevated",g&&"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(cs,{content:j?b:null,side:"top",disableHoverableContent:!0,children:t.jsx("span",{ref:f,"data-project-title":e.name,tabIndex:j?0:void 0,className:"block truncate text-body-sm font-medium text-ink",children:b})}),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(kn,{children:[t.jsx(wn,{"data-project-menu":e.id,"aria-label":`Actions for ${b}`,disabled:n,onClick:w=>w.stopPropagation(),className:$("shrink-0 rounded-sm p-1 text-ink-muted whitespace-nowrap","hover:bg-sunken hover:text-ink"),children:n?t.jsx(ke,{size:"xs"}):t.jsx(Ha,{className:"size-4"})}),t.jsxs(Nn,{align:"end",onClick:w=>w.stopPropagation(),children:[t.jsx(st,{onSelect:a,children:"Open"}),t.jsxs(kr,{children:[t.jsx(wr,{children:"Set status"}),t.jsx(Nr,{children:t.jsx(Sr,{value:e.status,onValueChange:l,children:[...Wt,...Kt].map(w=>t.jsx(Tr,{value:w,children:Z(w).label},w))})})]}),h&&t.jsx(st,{onSelect:()=>u(e),children:"Request update"}),t.jsx(_r,{}),t.jsx(st,{onSelect:r,children:"Edit"}),t.jsx(st,{onSelect:i,children:"Delete"})]})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[c.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)),g&&t.jsx(pe,{variant:"warning",children:"Overdue"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-meta text-ink-muted",children:li(x)}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[(e.progress_stale||!x)&&t.jsx("span",{"aria-label":kt,title:kt,className:"size-1.5 rounded-full bg-warning"}),e.sessions>0&&t.jsx(ml,{project:e})]})]})]})},ml=({project:e})=>{const[s,n]=d.useState(!1),a=Rt(),r=Dn(e.id,s),i=r.data?.links??[],l=mi(e),o=G(e);return t.jsxs(ds,{open:s,onOpenChange:n,children:[t.jsx(us,{"data-project-sessions":e.id,"aria-label":`Sessions linked to ${o}`,onClick:c=>c.stopPropagation(),className:$("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(ms,{align:"end",className:"w-64 p-2 outline-none",onClick:c=>c.stopPropagation(),children:r.isLoading?t.jsx("p",{className:"px-1 py-2 text-meta text-ink-muted",children:"Loading linked sessions…"}):r.isError?t.jsxs("div",{className:"flex flex-col items-start gap-1.5 px-1 py-2",children:[t.jsx("p",{className:"text-meta text-ink-muted",children:r.error instanceof Error&&r.error.message?r.error.message:"The linked sessions could not be read."}),t.jsx(U,{variant:"secondary",size:"sm",onClick:()=>void r.refetch(),children:"Try again"})]}):i.length===0?t.jsx("p",{className:"px-1 py-2 text-meta text-ink-muted",children:"No sessions linked yet."}):t.jsx("ul",{className:"flex flex-col",children:i.map(c=>t.jsx("li",{children:t.jsx("button",{type:"button",disabled:!c.exists,onClick:()=>{c.exists&&(n(!1),En(a,c.session_id))},className:$("flex w-full items-center gap-2 rounded-sm px-1 py-1.5 text-left text-meta",c.exists?"text-ink hover:bg-elevated":"text-ink-disabled"),children:t.jsx("span",{className:"truncate",children:c.title||c.session_id})})},c.session_id))})})]})},da=({open:e,projectName:s,onClose:n,onConfirm:a})=>{const[r,i]=d.useState(""),[l,o]=d.useState(null),[c,m]=d.useState(!1),u=d.useId();d.useEffect(()=>{e&&(i(""),o(null),m(!1))},[e]);const h=r.trim().toLowerCase()===s.trim().toLowerCase()&&s.trim().length>0,b=async()=>{m(!0),o(null);try{await a(r.trim()),n()}catch(f){o(f instanceof Error&&f.message?f.message:"The project was not deleted.")}finally{m(!1)}};return t.jsx(ct,{open:e,onClose:n,title:"Delete this project?",dataTourTag:"project-delete-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Be,{onClick:n,disabled:c,children:"Cancel"}),t.jsxs(Wa,{onClick:()=>void b(),disabled:!h||c,children:[c&&t.jsx(ke,{size:"xs"}),"Delete project"]})]}),children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"text-body-sm text-ink",children:"This deletes the project and its milestones. The sessions linked to it are not touched."}),t.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Type"," ",t.jsx("span",{className:"font-mono text-mono-sm text-ink",children:s})," ","to confirm."]}),t.jsx(ne,{id:`${u}-confirm`,value:r,onChange:f=>i(f.target.value),placeholder:s,"aria-label":"Type the project name to confirm","aria-invalid":r.length>0&&!h,autoFocus:!0}),l&&t.jsx("p",{className:"text-body-sm text-danger",children:l})]})})};function fl(e){return e==="editing"||e==="saving"||e==="error"}function hl(e,s,n=Object.is){return!n(e,s)}function pl(e,s){if(e.key==="Escape")return e.defaultPrevented===!0?null:"revert";if(e.key!=="Enter"||!s.keyboardCommit)return null;const n=e.metaKey===!0||e.ctrlKey===!0;return s.multiline?n?"accept":null:s.onEditor?"accept":null}function xl(e,s){return e==="saving"||e==="error"?!0:e==="editing"&&s}function gl(e){const{phase:s,base:n,draft:a,fresh:r,equals:i}=e;return s==="saving"||s==="saved"||i(n,r)?"none":s==="idle"||i(n,a)||i(r,a)?"adopt":"conflict"}function rn(e,s,n=Object.is){return!n(e,s)}const ws="group/inline-edit",Bt="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",bl="relative before:absolute before:-inset-1.5 before:content-['']",jl="relative before:absolute before:-top-1.5 before:-bottom-1.5 before:-left-1.5 before:right-0 before:content-['']",yl="relative before:absolute before:-top-1.5 before:-bottom-1.5 before:-right-1.5 before:left-0 before:content-['']",rs=({api:e,idle:s="affordance",className:n})=>{const{phase:a,labels:r}=e,i=a==="editing"||a==="saving"||a==="error",l=xl(a,e.dirty),o=e.acceptBlocked===!0;return t.jsx("span",{"data-inline-edit-slot":a,className:$("inline-flex shrink-0 items-center gap-0.5",n),children:l?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button","data-inline-edit-control":"cancel","aria-label":a==="saving"?r.busy:r.cancel,title:a==="saving"?r.busy:r.cancel,"aria-disabled":a==="saving"||void 0,onMouseDown:c=>c.preventDefault(),onClick:c=>{c.detail>1||a!=="saving"&&e.cancel()},className:$(Bt,jl,a==="saving"&&"cursor-default text-ink-disabled"),children:t.jsx(Dt,{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(ke,{size:"xs"})}):t.jsx("button",{type:"button","data-inline-edit-control":"accept","aria-label":a==="error"?r.retry??r.accept:r.accept,title:a==="error"?r.retry??r.accept:r.accept,"aria-disabled":o||void 0,onMouseDown:c=>c.preventDefault(),onClick:c=>{c.detail>1||o||e.accept()},className:$(Bt,yl,o&&"cursor-default text-ink-disabled"),children:t.jsx(fs,{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":r.begin,title:r.begin,onClick:c=>{c.detail>1||e.begin()},className:$(Bt,bl,"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(Ka,{className:"size-3","aria-hidden":"true"})}):null})},vl="This changed while you were editing",kl="Keep mine",wl="Use theirs",is=({api:e,className:s})=>{const{phase:n,error:a,conflict:r}=e;return n==="saved"?t.jsx("p",{"data-inline-edit-feedback":"saved",className:$("text-meta text-success",s),children:e.labels.saved}):!a&&!r?null:t.jsxs("div",{id:e.feedbackId,"data-inline-edit-feedback":a&&r?"error+conflict":a?"error":"conflict",role:"alert",className:$("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&&r===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:"Retry"}),r!==null&&t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-meta text-warning",children:vl}),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:kl}),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:wl})]})]})},ua=d.createContext(null),Nl=50,Sl=({children:e})=>{const[s,n]=d.useState(""),a=d.useMemo(()=>({current:r=>{n(""),window.setTimeout(()=>n(r),Nl)}}),[]);return t.jsxs(ua.Provider,{value:a,children:[e,t.jsx("span",{"data-inline-edit-announcement":"","aria-live":"polite",className:"sr-only",children:s})]})},Tl=1200;function _l(e){return e instanceof Error&&e.message?e.message:"The change was not saved."}function ht(e){const{value:s,multiline:n=!1,keyboardCommit:a=!0,selectAllOnBegin:r=!1,beginOnMount:i=!1,savedDwellMs:l=Tl,labels:o}=e,c=d.useRef(e.equals??Object.is);c.current=e.equals??Object.is;const m=d.useRef(e.commit);m.current=e.commit;const u=d.useRef(e.validate);u.current=e.validate;const h=d.useRef(e.errorCopy);h.current=e.errorCopy;const b=d.useRef(e.onSettle);b.current=e.onSettle;const f=d.useRef(e.onBegin);f.current=e.onBegin;const j=d.useRef(o);j.current=o;const[v,g]=d.useState(i?"editing":"idle"),[x,y]=d.useState(s),[C,w]=d.useState(s),[L,T]=d.useState(null),[_,O]=d.useState(null),p=d.useRef(v),A=d.useRef(x),E=d.useRef(C),P=d.useRef(L),z=d.useRef(s);z.current=s;const I=d.useCallback(D=>{p.current=D,g(D)},[]),B=d.useCallback(D=>{A.current=D,y(D)},[]),W=d.useCallback(D=>{E.current=D,w(D)},[]),V=d.useCallback(D=>{P.current=D,T(D)},[]),oe=d.useRef(null),Q=d.useRef(null),X=d.useRef(null),k=e.editorRef??X,N=d.useRef(k);N.current=k;const R=`${d.useId()}-inline-edit`,M=d.useContext(ua),F=d.useRef(null),q=F.current,Ce=q!==null&&(e.equals??Object.is)(s,q.previous)&&!(e.equals??Object.is)(s,q.saved)&&q!==null?q.saved:s,Y=d.useRef(Ce);Y.current=Ce,d.useEffect(()=>{const D=F.current;if(D===null)return;const te=c.current;(te(s,D.saved)||!te(s,D.previous))&&(F.current=null)},[s]);const we=d.useRef(i);d.useEffect(()=>{if(v!=="editing"||!we.current)return;we.current=!1;const D=N.current.current;D&&(D.focus(),r&&(D instanceof HTMLInputElement||D instanceof HTMLTextAreaElement)&&D.select())},[v,r]);const xe=d.useRef(!1);d.useEffect(()=>{xe.current&&(v!=="idle"&&v!=="saved"||(xe.current=!1,Q.current?.focus()))});const me=d.useRef(null),J=d.useCallback(()=>{me.current!==null&&(clearTimeout(me.current),me.current=null)},[]);d.useEffect(()=>()=>J(),[J]);const Ee=d.useRef(v);d.useEffect(()=>{const D=Ee.current;if(Ee.current=v,D==="saving"&&v==="saved"){b.current?.("saved");return}(D==="editing"||D==="error")&&v==="idle"&&b.current?.("cancelled")},[v]),d.useEffect(()=>{const D=gl({phase:p.current,base:E.current,draft:A.current,fresh:Y.current,equals:c.current});D==="adopt"?(c.current(E.current,Y.current)||W(Y.current),c.current(Y.current,A.current)||B(Y.current)):D==="conflict"&&(P.current===null||!c.current(P.current,Y.current))&&V(Y.current)},[s,v,W,B,V]);const re=d.useCallback(D=>{V(null),O(null),B(E.current),I("idle"),D&&(xe.current=!0)},[V,B,I]),Je=d.useCallback(()=>{p.current!=="saving"&&(p.current==="idle"||p.current==="saved"||(J(),re(!0)))},[J,re]),ee=d.useCallback((D,te=!0)=>{const tt=p.current;if(tt==="saving"||tt==="saved"||P.current!==null)return;const ge=D!==void 0?D:A.current;if(!rn(E.current,ge,c.current)){re(te&&tt!=="idle");return}const xt=u.current?.(ge)??null;if(xt!==null){I("error"),O(xt);return}B(ge),O(null),I("saving"),m.current(ge).then(()=>{p.current==="saving"&&(F.current={saved:ge,previous:E.current},W(ge),B(ge),te&&(xe.current=!0),I("saved"),J(),me.current=setTimeout(()=>{me.current=null,p.current==="saved"&&I("idle")},l),M?.current?.(j.current.saved))},Ie=>{p.current==="saving"&&(I("error"),O(h.current?h.current(Ie):_l(Ie)))})},[M,J,re,l,W,B,I]),Ne=d.useCallback(()=>{p.current==="editing"||p.current==="saving"||(J(),we.current=!0,B(Y.current),W(Y.current),V(null),O(null),I("editing"),f.current?.())},[J,W,V,B,I]),Me=d.useCallback(()=>{const D=P.current;D!==null&&(V(null),W(D),ee())},[ee,W,V]),Mt=d.useCallback(()=>{const D=P.current;D!==null&&(W(D),re(!0))},[re,W]),Ze=d.useCallback(D=>{const te=pl(D,{multiline:n,keyboardCommit:a,onEditor:D.target===N.current.current});if(te==="revert"){D.preventDefault(),Je();return}te==="accept"&&(D.preventDefault(),ee())},[ee,Je,a,n]),et=d.useCallback(D=>{if(p.current!=="editing")return;const te=D.relatedTarget;if(!(te!==null&&oe.current?.contains(te))&&!(te instanceof Element&&te.closest("[data-radix-popper-content-wrapper]")!==null)&&P.current===null){if(!rn(E.current,A.current,c.current)){re(!1);return}ee(void 0,!1)}},[ee,re]),pt=v==="saved"?x:Ce;return{phase:v,dirty:hl(C,x,c.current),conflict:L,error:_,draft:x,setDraft:B,displayValue:pt,editing:fl(v),begin:Ne,accept:ee,cancel:Je,keepMine:Me,useTheirs:Mt,handleKeyDown:Ze,handleBlur:et,fieldProps:{onKeyDown:Ze,onBlur:et,"aria-busy":v==="saving"?!0:void 0},editorAria:{"aria-invalid":_!==null?!0:void 0,"aria-describedby":_!==null||L!==null?R:void 0},fieldRef:oe,editorRef:k,slotRef:Q,feedbackId:R,labels:o}}const Cl=/^(https?:|mailto:)/i,El={a:({href:e,children:s})=>typeof e=="string"&&Cl.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:Va},lt=d.memo(({children:e,className:s})=>t.jsx("div",{className:$("lo-markdown",s),children:t.jsx(Ga,{remarkPlugins:[Qa],components:El,children:e})})),on=`## Summary
|
|
31
|
+
*/const Vr=[["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"}]],Qr=Ve("unlink",Vr),At={list:["desktop","projects"],detail:e=>["desktop","projects",e]};function Xr(e){return os({queryKey:At.list,enabled:e,queryFn:()=>ce({op:"projects.list"}).then(s=>s.projects),retry:ls,staleTime:1e4})}function Jr(e,s){return Fr({queries:e.map(n=>({queryKey:At.detail(n),enabled:s&&!!n,queryFn:()=>ce({op:"projects.get",key:n}),retry:ls,staleTime:1e4}))})}function Dn(e,s){return os({queryKey:At.detail(e??""),enabled:s&&!!e,queryFn:()=>ce({op:"projects.get",key:e??""}),retry:ls,staleTime:1e4})}function Pe(){const e=bn();return()=>{e.invalidateQueries({queryKey:At.list})}}function Zr(){const e=Pe();return Oe({mutationFn:s=>ce({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 An(){const e=Pe();return Oe({mutationFn:s=>ce({op:"projects.update",key:s.key,fields:s.fields,...s.forceDone===!0?{force_done:!0}:{}}),retry:Ia,onSuccess:()=>e()})}function On(){const e=Pe();return Oe({mutationFn:s=>ce({op:"projects.delete",key:s.key,confirmed_name:s.confirmedName}),onSuccess:()=>e()})}function ei(){const e=Pe();return Oe({mutationFn:s=>ce({op:"projects.link",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function ti(){const e=Pe();return Oe({mutationFn:s=>ce({op:"projects.unlink",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function si(){const e=Pe();return Oe({mutationFn:s=>ce({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 ni(){const e=Pe();return Oe({mutationFn:s=>ce({op:"projects.milestone.remove",key:s.key,name:s.name}),onSuccess:()=>e()})}const $n={planning:{label:"Planning",variant:"info"},active:{label:"Active",variant:"accent"},qa:{label:"QA",variant:"attention"},validation:{label:"Validation",variant:"warning"},done:{label:"Done",variant:"success"},paused:{label:"Paused",variant:"neutral"},archived:{label:"Archived",variant:"outline"}},Fe=Object.keys($n);function Z(e){return $n[e]??{label:e||"Unknown",variant:"neutral"}}const Pn=["planning","active","qa","validation","done","paused","archived"].map(e=>({value:e,label:Z(e).label}));function ai(e){return e==="done"}const ri={completed:{label:"Completed",variant:"success"},overdue:{label:"Overdue",variant:"warning"},upcoming:{label:"Upcoming",variant:"neutral"}};function ii(e){return ri[e]??{label:String(e),variant:"neutral"}}const kt="Stale",oi=/^(\d{4})-(\d{2})-(\d{2})$/;function _e(e,s,n=new Date){if(!e)return"";const a=oi.exec(e);if(!a)return e;const r=new Date(Number(a[1]),Number(a[2])-1,Number(a[3]));if(Number.isNaN(r.getTime()))return e;const i=La(r,{month:"short",day:"numeric"},s);return r.getFullYear()===n.getFullYear()?i:`${i}, ${r.getFullYear()}`}function dt(e,s){if(e==null)return"";const n=Math.max(0,Math.floor(s/1e3-e));return n<60?"just now":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}d`}function ut(e){return e==="just now"?"just now":`${e} ago`}function li(e){return e?`reported ${ut(e)}`:"no progress"}const Mn=/^$|^\d{4}-\d{2}-\d{2}$/;function In(e){return e?e==="operator"?"the operator":`session ${e}`:""}function ci(e,s){if(!e.progress)return"not reported yet";const n=dt(e.progress_updated_at,s),a=In(e.progress_reported_by),r=[n?`reported ${ut(n)}`:"reported"];return a&&r.push(`by ${a}`),r.join(" ")}function Ln(e,s){if(e==null)return"";const n=String(e);return s==="points"?`${n} pt`:s==="days"?`${n}d`:n}function Fn(e,s){return s<=0?"":`${e}/${s}`}function hs(e){return e<=0?"":`${e} live`}function di(e){return e<=0?"":e===1?"1 session":`${e} sessions`}function ui(e){return e===1?"1 project":`${e} projects`}function mi(e){const s=di(e.sessions);if(!s)return"";const n=hs(e.live_sessions);return n?`${s} · ${n}`:s}function fi(e){if(!e.exists)return{label:"Missing",variant:"outline"};if(e.archived)return{label:"Archived",variant:"neutral"};switch(e.runtime?.state){case"live":return{label:"Live",variant:"success"};case"wedged":return{label:"Wedged",variant:"warning"};case"stale":return{label:"Stale",variant:"warning"};case"stopped":return{label:"Stopped",variant:"neutral"};default:return{label:String(e.runtime?.state??"Unknown"),variant:"neutral"}}}function hi(e){return e?e.running>0?e.running===1?"1 subagent running":`${e.running} subagents running`:e.settled===1?"1 subagent":`${e.settled} subagents`:""}function pi(e){return e?e.total===1?"1 todo":`${e.total} todos`:""}function qn(e,s){const n=[],a=_e(e.completed_at??e.target_date,s);a&&n.push({key:e.completed_at?"completed":"target",text:e.completed_at?`completed ${a}`:`due ${a}`});const r=Ln(e.estimate,e.estimate_unit);r&&n.push({key:"estimate",text:r});const i=Fn(e.milestones_completed,e.milestones_total);i&&n.push({key:"milestones",text:`milestones ${i}`});const l=hs(e.live_sessions);return l&&n.push({key:"live",text:l}),n}const qe=864e5,xi=/^(\d{4})-(\d{2})-(\d{2})$/;function he(e){if(!e)return null;const s=xi.exec(e);if(!s)return null;const n=Number(s[1]),a=Number(s[2]),r=Number(s[3]),i=Date.UTC(n,a-1,r),l=new Date(i);return l.getUTCFullYear()!==n||l.getUTCMonth()!==a-1||l.getUTCDate()!==r?null:i}const Wt=["planning","active","qa","validation","done"],Kt=["paused","archived"],Ot=[{value:"24h",label:"Last 24 hours",phrase:"the last 24 hours",seconds:86400},{value:"7d",label:"Last 7 days",phrase:"the last 7 days",seconds:604800},{value:"30d",label:"Last 30 days",phrase:"the last 30 days",seconds:2592e3},{value:"90d",label:"Last 90 days",phrase:"the last 90 days",seconds:7776e3},{value:"all",label:"All time",phrase:null,seconds:null}],Un="7d",gi=Ot.find(e=>e.value===Un);function Bn(e){return Ot.find(s=>s.value===e)??gi}function bi(e){return Ot.some(s=>s.value===e)}function Ls(e,s,n){const a=Bn(s);return a.seconds===null?e:e.filter(r=>n/1e3-r.updated_at<=a.seconds)}function ji(e){const s=Bn(e);return s.seconds===null?null:`Nothing changed in ${s.phrase}.`}const Yn="projects-board-window";function yi(){try{const e=localStorage.getItem(Yn);if(e!==null&&bi(e))return e}catch{}return Un}function Fs(e){try{localStorage.setItem(Yn,e)}catch{}}const zn="projects-board-column-order";let Gt=null;function vi(){if(Gt)return[...Gt];try{const e=localStorage.getItem(zn);if(!e)return[];const s=JSON.parse(e);if(!Array.isArray(s))return[];const n=[];for(const a of s){if(typeof a!="string"||a.length===0)return[];n.includes(a)||n.push(a)}return n}catch{return[]}}function ki(e){Gt=[...e];try{localStorage.setItem(zn,JSON.stringify(e))}catch{}}function wi(e,s,n){const a=e.filter(i=>i!==s),r=Math.max(0,Math.min(n,a.length));return a.splice(r,0,s),a}function Ni(e,s=[]){const n=new Map;for(const o of e){const c=n.get(o.status)??[];c.push(o),n.set(o.status,c)}const a=Wt.map(o=>({status:o,projects:n.get(o)??[]}));for(const o of Kt){const c=n.get(o)??[];c.length>0&&a.push({status:o,projects:c})}for(const[o,c]of n)!Kt.includes(o)&&!Wt.includes(o)&&a.push({status:o,projects:c});if(s.length===0)return a;const r=new Map(s.map((o,c)=>[o,c])),i=a.filter(o=>r.has(o.status));i.sort((o,c)=>(r.get(o.status)??0)-(r.get(c.status)??0));const l=a.filter(o=>!r.has(o.status));return[...i,...l]}function Hn(e,s){if(e.status==="done"||e.status==="archived"||e.completed_at)return!1;const n=he(e.target_date);return n===null?!1:n<s}function G(e){return e.title||e.name}const ps="No team";function mt(e){const s=e.team?.trim();if(s)return s;const n=e.owner?.trim();return n||null}function xs(e,s){const n=new Map,a=[];for(const i of e){const l=s(i);if(l===null){a.push(i);continue}const o=n.get(l);o?o.push(i):n.set(l,[i])}const r=[...n.entries()].sort(([i],[l])=>i.localeCompare(l,void 0,{sensitivity:"base"})).map(([i,l])=>({team:i,items:l}));return a.length>0&&r.push({team:null,items:a}),r}function $t(e){return e.title||e.session_id}function Si(e){return[...e].reverse()}function Ti(e){return e<=0?"":e===1?"1 update":`${e} updates`}const qs=e=>String(e).padStart(2,"0");function Vt(e){return`${e.getFullYear()}-${qs(e.getMonth()+1)}-${qs(e.getDate())}`}function _i(e){const s=Date.parse(e);return Number.isNaN(s)?"":Vt(new Date(s))}function Ci(e,s,n=new Date){if(!e)return"";if(e===Vt(n))return"Today";const a=new Date(n.getFullYear(),n.getMonth(),n.getDate()-1);return e===Vt(a)?"Yesterday":_e(e,s,n)}function Ei(e,s){const n=Date.parse(e);return Number.isNaN(n)?"":Fa(new Date(n),{hour:"numeric",minute:"2-digit"},s)}function Ri(e,s){const n=Date.parse(e);return Number.isNaN(n)?"":ut(dt(n/1e3,s))}function Di(e,s,n=Date.now()){const a=[],r=In(e.by);r&&a.push({key:"author",text:r});const i=Ei(e.at,s);i&&a.push({key:"time",text:i});const l=Ri(e.at,n);return l&&a.push({key:"age",text:l}),a}function Ai(e,s,n=new Date){const a=[];for(const r of Si(e)){const i=_i(r.at),l=a[a.length-1];if(l&&l.key===i){l.entries.push(r);continue}a.push({key:i,label:Ci(i,s,n),entries:[r]})}return a}function Oi(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 $i(e,s){return s<=0?"":`${e} of ${s} complete`}function Pi(e){let s=0,n=0,a=!1;for(const r of e)r.todos&&(a=!0,s+=r.todos.open,n+=r.todos.total);return a?{open:s,total:n}:null}function Us(e){return`${e.open} open of ${e.total}`}function Mi(e){const s=e.filter(a=>a.exists);return(s.find(a=>a.runtime?.state==="live")??s[0])?.session_id??null}function Ii(e){const s=G(e),n=e.progress.trim()||"not reported yet";return[`Continue work on project "${s}" (${e.name}).`,`Latest progress: ${n}`,"Review the project details and continue or complete the work."].join(`
|
|
32
|
+
`)}function Li(e){return e?e.kind==="team"?`team ${e.name}`:`agent ${e.name}`:""}const Fi=/'((?:[^'\\]|\\.)*)'|"((?:[^"\\]|\\.)*)"/g;function Wn(e){const s=[];for(const n of e.matchAll(Fi))s.push((n[1]??n[2]??"").replace(/\\(.)/g,"$1"));return s}const jt=3;function gs(e){if(e.length<=jt+1)return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`;const s=e.length-jt;return`${e.slice(0,jt).join(", ")} and ${s} more`}function bs(e){return`${e} milestone${e===1?" is":"s are"}`}const Bs="complete them, or pass force_done=true to close with them open",qi="complete or remove the incomplete milestones, then mark it done",Kn=/^cannot set status 'done': (\d+) milestones? still incomplete \((.+)\) — /;function ft(e){const s=e.match(Kn);if(s){const n=Number(s[1]),a=Wn(s[2]),r=a.length>0?gs(a):s[2];return`This can't be marked done yet: ${bs(n)} still incomplete (${r}). Complete or remove the incomplete milestones, then mark it done.`}return e.includes(Bs)?e.replace(Bs,qi):e}const Ui="project_done_incomplete";function Bi(e){const s=e.message.match(Kn),n=e.code===Ui;if(!n&&!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,r=a&&a.length>0?a:s?Wn(s[2]):[];return{count:r.length>0?r.length:s?Number(s[1]):0,names:r,coded:n,message:e.message}}function Yi(e){if(e.count>0){const s=gs(e.names);return`${bs(e.count)} still open${s?` (${s})`:""}.`}return ft(e.message)||"Some milestones are still open."}function zi(e){return e.count>0&&e.names.length>0?`This can't be marked done yet: ${bs(e.count)} still incomplete (${gs(e.names)}). Complete or remove the incomplete milestones, then mark it done.`:ft(e.message)||"Milestones are still open on this project. Complete or remove them, then mark it done."}function Gn(e,s,n){if(!e||e.forced_done!==!0)return`Moved to ${n}`;const a=typeof e.milestones_total=="number"&&typeof e.milestones_completed=="number"?e.milestones_total-e.milestones_completed:s,r=a>0?a:s;return`Moved to ${n} with ${r} milestone${r===1?"":"s"} still open`}const Hi="The project was not moved. Try again, or open it to change its status.";function Vn(e){return e.trim().slice(0,qa)}const Wi={client:"Searches names, descriptions, tags, owners and teams. Update text is not searched. Clearing the search and filters restores the list.",backend:"Searches names, descriptions, tags, owners, teams and update text. Clearing the search and filters restores the list."},Ki=2,Gi=4,Vi=3,Qi=2,Xi=1,Ji=3,Re={title:3,name:2.5,description:2,tags:1.5,attribution:1.5,status:1},Zi=/[^\p{L}\p{N}]+/u,eo=/\s+/;function Ys(e,s){const n=s.trim().toLowerCase();if(!n)return 0;if(n===e)return Gi;if(n.startsWith(e))return Vi;const a=n.split(Zi).filter(Boolean),r=e.split(eo).filter(Boolean);if(r.length>0&&r.every(l=>a.some(o=>o.startsWith(l))))return Qi;const i=r.join("");return i.length>=Ji&&to(i,n)?Xi:0}function to(e,s){let n=0;for(const a of e){if(n=s.indexOf(a,n),n<0)return!1;n+=1}return!0}function so(e,s){const n=s.trim().toLowerCase();if(!n)return 0;const a=[[e.title,Re.title],[e.name,Re.name],[e.description,Re.description],[e.owner,Re.attribution],[e.team,Re.attribution],[e.status,Re.status]];let r=0;for(const[i,l]of a){if(!i)continue;const o=Ys(n,i)*l;o>r&&(r=o)}for(const i of e.tags){const l=Ys(n,i)*Re.tags;l>r&&(r=l)}return r}function no(e,s){const n=s.trim();if(!n)return e;const a=[];for(const r of e){const i=so(r,n);i>0&&a.push({project:r,score:i})}return a.sort((r,i)=>{if(r.score!==i.score)return i.score-r.score;if(r.project.updated_at!==i.project.updated_at)return i.project.updated_at-r.project.updated_at;const l=G(r.project).localeCompare(G(i.project),void 0,{sensitivity:"base"});if(l!==0)return l;const o=r.project.name.localeCompare(i.project.name,void 0,{sensitivity:"base"});return o!==0?o:r.project.id<i.project.id?-1:r.project.id>i.project.id?1:0}),a.map(r=>r.project)}function ao(e,s){if(s.length===0)return[];const n=new Map(e.map(r=>[r.id,r])),a=[];for(const r of s){const i=n.get(r.id);i!==void 0&&a.push(i)}return a}const ro=180;function io(e,s){const n=Vn(e),a=Cn(n,ro),r=os({queryKey:["desktop","projects","search",a],enabled:s&&a.length>0,queryFn:()=>ce({op:"projects.search",q:a,limit:Ua}),retry:!1,staleTime:3e4}),i=a===n,l=i&&r.data&&r.data.query===n?r.data:null,o=i&&n.length>0&&!l&&r.isError;return{answer:l,pending:s&&n.length>0&&!l&&!o}}const Qe=["status","team","owner","tags","progress","target","estimate","milestones","live"],zs={status:[],team:[],owner:[],tags:[],progress:[],target:[],estimate:[],milestones:[],live:[]},at={status:"Status",team:"Team",owner:"Owner",tags:"Tags",progress:"Progress",target:"Target date",estimate:"Estimate",milestones:"Milestones",live:"Live sessions"},oo=new Set(["status","progress","target","estimate","milestones","live"]),lo={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"]},co={stale:"Stale","up-to-date":"Up to date","not-reported":"Not reported",none:"No target date",overdue:"Overdue","within-7":"Due within 7 days","within-30":"Due within 30 days",points:"Points",days:"Days",incomplete:"Incomplete",complete:"Complete","has-live":"Has live sessions","no-live":"No live sessions"};function Qn(e,s){switch(e){case"status":return Z(s).label;case"team":return s===null?"No team":s;case"owner":return s===null?"No owner":s;case"tags":return s??"";case"estimate":if(s==="none")return"No estimate";break;case"milestones":if(s==="none")return"None set";break;case"target":if(s==="none")return"No target date";break}return co[s]??s??""}function uo(e,s){return e[s].length>0}function it(e){return Qe.every(s=>!uo(e,s))}function mo(e){return Qe.reduce((s,n)=>s+e[n].length,0)}function Xn(e,s,n){const a=e[s],r=a.includes(n)?a.filter(i=>i!==n):[...a,n];return{...e,[s]:r}}function Jn(e,s,n,a){switch(e){case"status":return s.status===n;case"team":return mt(s)===n;case"owner":return(s.owner?.trim()||null)===n;case"tags":return s.tags.includes(n??"");case"progress":return n==="stale"?s.progress_stale===!0:n==="up-to-date"?s.progress_stale===!1:s.progress_updated_at===null;case"target":{if(n==="none")return he(s.target_date)===null;if(n==="overdue")return Hn(s,a);const r=he(s.target_date);if(r===null)return!1;const i=(r-a)/qe;return n==="within-7"?i>=0&&i<=7:i>=0&&i<=30}case"estimate":return n==="none"?s.estimate===null:s.estimate===null?!1:n==="points"?s.estimate_unit==="points":s.estimate_unit==="days";case"milestones":return n==="none"?s.milestones_total===0:s.milestones_total===0?!1:n==="complete"?s.milestones_completed>=s.milestones_total:s.milestones_completed<s.milestones_total;case"live":return n==="has-live"?s.live_sessions>0:s.live_sessions===0}}function Zn(e,s,n,a){const r=e[s];return r.length===0?!0:r.some(i=>Jn(s,n,i,a))}function fo(e,s,n){return it(s)?e:e.filter(a=>Qe.every(r=>Zn(s,r,a,n)))}function ho(e,s,n,a){return s.filter(r=>Qe.every(i=>i===e||Zn(n,i,r,a)))}function po(e,s,n){const a=n[e];switch(e){case"status":{const i=[...new Set(s.map(o=>o.status))].filter(o=>!Fe.includes(o)).sort((o,c)=>o.localeCompare(c,void 0,{sensitivity:"base"})),l=a.filter(o=>typeof o=="string"&&!Fe.includes(o)&&!i.includes(o));return[...Fe,...i,...l]}case"team":{const r=new Set;let i=!1;for(const o of s){const c=mt(o);c===null?i=!0:r.add(c)}for(const o of a)o===null?i=!0:r.add(o);const l=[...r].sort((o,c)=>o.localeCompare(c,void 0,{sensitivity:"base"}));return i?[...l,null]:l}case"owner":{const r=new Set;let i=!1;for(const o of s){const c=o.owner?.trim();c?r.add(c):i=!0}for(const o of a)o===null?i=!0:r.add(o);const l=[...r].sort((o,c)=>o.localeCompare(c,void 0,{sensitivity:"base"}));return i?[...l,null]:l}case"tags":{const r=new Set;for(const i of s)for(const l of i.tags)r.add(l);for(const i of a)r.add(i??"");return[...r].sort((i,l)=>i.localeCompare(l,void 0,{sensitivity:"base"}))}case"progress":case"target":case"estimate":case"milestones":case"live":return lo[e]}}function ea(e,s,n,a){const r=ho(e,s,n,a),i=oo.has(e),l=[];for(const o of po(e,r,n)){const c=n[e].includes(o),m=r.reduce((u,h)=>u+(Jn(e,h,o,a)?1:0),0);!i&&m===0&&!c||l.push({value:o,label:Qn(e,o),count:m,selected:c})}return{facet:e,label:at[e],options:l}}function xo(e,s,n){return Qe.map(a=>ea(a,e,s,n))}const Qt="projects-sort",go="Default (as listed)";function bo(e){return jo.includes(e)}const jo=["name","status","target","estimate","milestones","live","progress"];function yo(){try{const e=localStorage.getItem(Qt);if(e===null)return null;const[s,n,...a]=e.split(":");if(a.length>0)return null;if(s&&bo(s)&&(n==="asc"||n==="desc"))return{key:s,direction:n}}catch{}return null}function vo(e){try{e===null?localStorage.removeItem(Qt):localStorage.setItem(Qt,`${e.key}:${e.direction}`)}catch{}}function Ke(e){switch(e){case"name":return"Project";case"status":return"Status";case"target":return"Target";case"estimate":return"Estimate";case"milestones":return"Milestones";case"live":return"Live";case"progress":return"Progress"}}function Lt(e){return e==="target"||e==="progress"?"desc":"asc"}function js(e,s){const n=s==="desc";switch(e){case"name":return n?"Z to A":"A to Z";case"status":return n?"Archived first":"Planning first";case"target":return n?"latest first":"soonest first";case"estimate":return n?"days first":"points first";case"milestones":return n?"most complete first":"least complete first";case"live":return n?"most first":"fewest first";case"progress":return n?"most recent first":"most stale first"}}function ko(e){return e===null?"Sort cleared.":`Sorted by ${Ke(e.key)}, ${js(e.key,e.direction)}.`}function wo(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 n=s.length===1?`${s[0]} cleared.`:`${s.slice(0,-1).join(", ")} and ${s[s.length-1]} cleared.`;return n.charAt(0).toUpperCase()+n.slice(1)}function Hs(e,s){switch(e){case"name":return 0;case"status":return Fe.includes(s.status)?0:1;case"target":return Xt(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 Xt(e){return he(e.completed_at??e.target_date)}function Ws(e){return e==="points"?0:e==="days"?1:2}function No(e,s,n){switch(e){case"name":return G(s).localeCompare(G(n),void 0,{sensitivity:"base"});case"status":return Fe.indexOf(s.status)-Fe.indexOf(n.status);case"target":{const a=Xt(s)??0,r=Xt(n)??0;return a-r}case"estimate":{const a=Ws(s.estimate_unit)-Ws(n.estimate_unit);return a!==0?a:(s.estimate??0)-(n.estimate??0)}case"milestones":return s.milestones_completed*n.milestones_total-n.milestones_completed*s.milestones_total;case"live":return s.live_sessions-n.live_sessions;case"progress":return(s.progress_updated_at??0)-(n.progress_updated_at??0)}}function Ks(e,s){if(e.updated_at!==s.updated_at)return s.updated_at-e.updated_at;const n=G(e).localeCompare(G(s),void 0,{sensitivity:"base"});if(n!==0)return n;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 So(e,s,n){const a=Hs(n.key,e),r=Hs(n.key,s);if(a!==r)return a-r;if(a===1)return Ks(e,s);const i=No(n.key,e,s);return i!==0?n.direction==="desc"?-i:i:Ks(e,s)}function To(e,s){return[...e].sort((n,a)=>So(n,a,s))}const Se=["day","week","month","quarter"],ys={day:24,week:9,month:3,quarter:1};function vs(e){const s=new Date(e);return Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())}function De(e,s){return Math.round((s-e)/qe)}function Gs(e,s){return De(e,s)+1}function _o(e,s){for(const n of Se)if(e*ys[n]<=s)return n;return Se[Se.length-1]}function Co(e){const{project:s}=e;return s.start_date||s.target_date||s.completed_at?!0:e.milestones.some(n=>!!n.target_date)}function Eo(e,s){const n=[s];for(const a of e){for(const r of[a.project.start_date,a.project.target_date,a.project.completed_at]){const i=he(r);i!==null&&n.push(i)}for(const r of a.milestones){const i=he(r.target_date);i!==null&&n.push(i)}}return n.length===1?null:{startMs:Math.min(...n),endMs:Math.max(...n)}}function Ro(e){const s=[],n=[];for(const a of e)(Co(a)?s:n).push(a);return{dated:s,undated:n}}function Do(e){return`${e} project${e===1?"":"s"} without dates`}function Ao(e){const{project:s}=e,n=he(s.start_date),a=he(s.target_date),r=he(s.completed_at),i=s.status==="done"&&r!==null?r:a,l=n??i,o=i??n;return l===null||o===null?null:{fromMs:Math.min(l,o),toMs:Math.max(l,o)}}function Oo(e){const s=[];for(const n of e.milestones){const a=he(n.target_date);a!==null&&s.push({name:n.name,dayMs:a,status:n.status})}return s}const bt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function de(e){const s=new Date(e);return{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),weekday:s.getUTCDay()}}function $o(e){const{year:s,month:n}=de(e);return Date.UTC(s,n-1,1)}function Po(e){const{year:s,month:n}=de(e);return n===12?Date.UTC(s+1,0,1):Date.UTC(s,n,1)}function Mo(e){const{year:s,month:n}=de(e);return Date.UTC(s,Math.floor((n-1)/3)*3,1)}function Io(e){const{year:s,month:n}=de(e),a=Math.floor((n-1)/3);return a===3?Date.UTC(s+1,0,1):Date.UTC(s,a*3+3,1)}function Lo(e){const{weekday:s}=de(e);return e-(s+6)%7*qe}const Fo=26;function qo(e,s,n){const a=[],r=(u,h,b)=>{u<e||u>s||a.push({dayMs:u,label:h,major:b})};if(n==="day"){let u=!1;for(let h=e;h<=s;h+=qe){const{day:b,month:f}=de(h);b===1?(r(h,bt[f-1],!0),u=!0):u?(r(h,"",!1),u=!1):r(h,String(b),!1)}return a}if(n==="week"){for(let u=Lo(e);u<=s;u+=7*qe){if(u<e)continue;const{day:h,month:b}=de(u);de(u-7*qe).month!==b?r(u,`${bt[b-1]} ${h}`,!0):r(u,String(h),!1)}return a}const i=n==="month"?$o:Mo,l=n==="month"?Po:Io,o=u=>{const{year:h,month:b}=de(u);if(n==="month")return b===1&&h!==de(e).year?`${bt[0]} '${String(h%100).padStart(2,"0")}`:bt[b-1];const f=Math.floor((b-1)/3)+1;return f===1&&h!==de(e).year?`Q1 '${String(h%100).padStart(2,"0")}`:`Q${f}`};r(e,o(i(e)),!0);const c=Math.ceil(Fo/ys[n]);let m=e;for(let u=l(i(e));u<=s;u=l(u))De(m,u)<c||(r(u,o(u),!0),m=u);return a}function ot(e){return e.split(",").map(s=>s.trim()).filter(s=>s.length>0)}const wt=80,Nt=80,Vs=64,Qs=8;function Jt(e){return e.trim().length>wt?`Titles are at most ${wt} characters.`:null}function ta(e){return e.length>Ue?`Keep the description within ${Ue} characters.`:null}function St(e,s){return e.trim().length>Nt?`${s==="owner"?"Owners":"Teams"} are at most ${Nt} characters.`:null}function Zt(e){return Mn.test(e)?null:"Dates are YYYY-MM-DD, or empty."}function es(e,s){return e&&s&&s<e?"The target date is before the start date.":null}function sa(e){const s=e.trim();if(s==="")return null;const n=Number(s);return!Number.isFinite(n)||!(n>0)||n>1e3?"Estimates are greater than 0 and at most 1000.":null}function ts(e){const s=ot(e);if(s.length>Qs)return{tags:s,error:`Up to ${Qs} tags.`};for(const n of s){const a=Ba(n);if(a)return{tags:s,error:a}}return{tags:s,error:null}}const Uo="project_name_exists";function Xs(e){return e.code===Uo?"A project with this key already exists.":ft(e.message)||"The project was not saved."}function Bo(e,s){if(e.unit!==s.unit)return!1;const n=e.number.trim(),a=s.number.trim();return a===""?!0:n===""?!1:Number(n)===Number(a)}function Yo(e,s){const n=ot(s);return n.length!==e.length?!1:n.every((a,r)=>a===e[r])}function zo(e,s){const n={},a=s.number.trim();if(a!==""){const r=Number(a);(e.estimate===null||e.estimate!==r)&&(n.estimate=r)}return s.unit!==e.unit&&(n.estimate_unit=s.unit),Object.keys(n).length>0?n:null}function Xe(e){return e instanceof Et?Xs({code:e.code,message:e.message}):Xs({message:e instanceof Error?e.message:""})}function na(e){return e instanceof Et&&(e.code==="project_not_found"||e.status===404)}function aa(e){return!(e instanceof Error)||!e.message?Hi:na(e)?"This project could not be found. It may have been deleted.":Xe(e)}function ra(e){if(!(e instanceof Error))return null;const s=e instanceof Et?e:null;return Bi({code:s?.code??null,message:e.message,detail:s?.detail})}async function Ho(e){try{return await e.move(),{kind:"accepted"}}catch(s){const n=ra(s);return n?.coded&&e.forceDoneOffered&&e.claimQuestion()?{kind:"question",refusal:n}:{kind:"spoken",copy:n?zi(n):aa(s),refusal:n}}}const Wo="Shows projects last updated within this window; older ones are hidden.",Ko=({value:e,onChange:s})=>t.jsxs(Ye,{value:e,onValueChange:n=>s(n),children:[t.jsx(cs,{content:e==="all"?null:Wo,side:"bottom",disableHoverableContent:!0,children:t.jsx(ze,{"aria-label":"Projects updated within",className:$("w-36 shrink-0"),"data-tour-tag":"projects-board-window",children:t.jsx(He,{})})}),t.jsx(We,{children:Ot.map(n=>t.jsx(Te,{value:n.value,children:n.label},n.value))})]}),ss=6e4,ns=6e3,Js="Requesting updates…",Go=400,Vo="Ask the sessions linked to this project to post a progress update",Qo="linked but not yet in use — it becomes a recipient after the first message",Zs=e=>`project-request-update-${e}`,Xo=e=>`project-request-cooldown-${e}`,Jo=e=>`project-request-update-cooldown-${e}`,Ft=e=>e.length===1?e[0]:e.length===2?`${e[0]} and ${e[1]}`:`${e[0]}, ${e[1]} and ${e.length-2} more`,en=(e,s)=>e.sessions.filter(n=>n.outcome===s).map(n=>$t({session_id:n.session_id,title:n.title})),Zo=e=>e.outcome==="failed"&&e.detail===Qo;function Tt(e,s){const n=Math.max(1,Math.ceil(s/1e3));return`Update already requested ${Math.max(0,Math.ceil(ss/1e3)-n)} s ago on ${e}. Try again in ${n} s.`}function el(e){const s=G({title:e.project.title,name:e.project.key}),{delivered:n,unconfirmed:a,failed:r,total:i}=e.counts;if(e.state==="empty")return{variant:"info",title:`No linked sessions to ask. Link a session to ${s} first.`,duration:ns};if(e.state==="cooldown")return{variant:"info",title:Tt(s,Math.max(0,e.cooldown_remaining_s??0)*1e3),duration:ns};if(e.state!=="sent")return null;const l=en(e,"failed"),o=en(e,"unconfirmed");if(n>=1&&r===0&&a===0)return{variant:"success",title:n===1?`Requested an update from 1 session on ${s}.`:`Requested updates from ${n} sessions on ${s}.`};if(n>=1){let c=`Requested updates from ${n} of ${i} sessions on ${s}.`;return r>0&&(c+=` ${Ft(l)} could not be reached.`),a>0&&(c+=` Delivery to ${Ft(o)} could not be confirmed.`),{variant:"warning",title:c,duration:Number.POSITIVE_INFINITY}}if(r===0)return{variant:"warning",title:`Could not confirm delivery on ${s} — the requests may still reach its sessions.`,duration:Number.POSITIVE_INFINITY};if(a===0){const c=e.sessions.every(Zo);let m;return c?m=i===1?"The linked session has not started yet — it becomes a recipient after its first message.":`The ${i} linked sessions have not started yet — they become recipients after their first message.`:m=`Could not reach any of the ${i} linked sessions on ${s}.`,{variant:"error",title:m,duration:Number.POSITIVE_INFINITY}}return{variant:"warning",title:`Could not reach ${r} of the ${i} linked sessions on ${s}. Delivery to ${Ft(o)} could not be confirmed.`,duration:Number.POSITIVE_INFINITY}}const nt=new Map,ks=new Set,qt=new Map,as=new Set;let ia=0;const _t=()=>{ia+=1;for(const e of as)e()},tl=e=>(as.add(e),()=>{as.delete(e)}),tn=()=>ia,oa=e=>ks.has(e),la=e=>nt.get(e);function sl(e){ks.add(e),_t()}function nl(e){ks.delete(e),_t()}function sn(e,s,n){const a=Date.now();if(n<=a)return;const r=nt.get(e);if(r&&r.untilMs>=n)return;nt.set(e,{startedMs:s,untilMs:n});const i=qt.get(e);i&&clearTimeout(i);const l=setTimeout(()=>{qt.delete(e);const o=nt.get(e);o&&o.untilMs<=Date.now()&&(nt.delete(e),_t())},n-a);l.unref?.(),qt.set(e,l),_t()}const al=e=>/[.!?…]$/.test(e)?e:`${e}.`;function rl(e,s){const n=Date.now();if(s.state==="cooldown"){const a=Math.max(0,s.cooldown_remaining_s??0)*1e3;sn(e,n-(ss-a),n+a);return}s.state==="sent"&&(s.counts.delivered>=1||s.counts.unconfirmed>=1)&&sn(e,n,n+ss)}async function il(e){const s=e.id;if(oa(s)){Rs(Js,{id:Zs(s)});return}const n=Date.now(),a=la(s);if(a&&a.untilMs>n){Ds(Tt(G(e),a.untilMs-n),{id:Xo(s),duration:ns});return}sl(s);const r=Zs(s);let i=!1;const l=setTimeout(()=>{i=!0,Rs(Js,{id:r})},Go);try{const o=await ce({op:"projects.request_update",key:s});rl(s,o);const c=el(o);if(c){const m={id:r,...c.duration!==void 0?{duration:c.duration}:{}};switch(c.variant){case"success":ve(c.title,m);break;case"warning":Ya(c.title,m);break;case"error":As(c.title,m);break;default:Ds(c.title,m)}}else i&&za(r)}catch(o){const c=o instanceof Error&&o.message.trim()!==""?o.message.trim():null;As(c?`Could not request updates: ${al(c)}`:"The request could not be confirmed.",{id:r,duration:Number.POSITIVE_INFINITY})}finally{clearTimeout(l),nl(s)}}function ca(){return d.useCallback(e=>{il(e)},[])}function ol(e){d.useSyncExternalStore(tl,tn,tn);const s=oa(e),n=la(e),a=n!==void 0?n.untilMs-Date.now():0,r=a>0;return{sending:s,cooling:r,cooldownRemainingMs:r?a:null}}const nn={active:"In flight",paused:"On hold",done:"Finished"};function ll(){const[e,s]=d.useState(null);return d.useEffect(()=>{if(!e)return;const n=document.querySelector(`[data-project-menu="${e}"]`);n&&(n.focus(),s(null))}),d.useCallback(n=>s(n),[])}const cl=4,Ut="Drag the header, or press the arrow keys, to move this column.",an="board-column-move-hint",dl=({projects:e,nowMs:s,onOpen:n,onEdit:a,onDelete:r,onMove:i,movingKeys:l=[],teamLabelFor:o=c=>c})=>{const[c,m]=d.useState(vi),u=Ni(e,c),h=xs(e,mt),[b,f]=d.useState(null),[j,v]=d.useState(""),g=d.useRef(null),x=d.useRef(null),y=d.useRef(null),C=d.useRef(null),w=d.useRef(null),L=new Set(l),T=(k,N)=>{const R=wi(u.map(M=>M.status),k,N);m(R),ki(R),v(`Moved ${Z(k).label} column to position ${R.indexOf(k)+1} of ${R.length}.`)},_=(k,N)=>{const R=g.current;if(!R)return 0;let M=0;const F=R.querySelectorAll("[data-board-column]");for(const q of F){if(q.dataset.boardColumn===N)continue;const ae=q.getBoundingClientRect();k>(ae.left+ae.right)/2&&(M+=1)}return M},O=(k,N)=>{const R=u.filter(q=>q.status!==k),M=R[N-1]?.status,F=R[N]?.status;return M&&F?`between ${Z(M).label} and ${Z(F).label}`:F?`before ${Z(F).label}`:M?`after ${Z(M).label}`:"in place"},p=(k,N)=>{const R=_(k,N.status);R!==N.over&&(N.over=R,f({status:N.status,over:R}),v(`Moving ${Z(N.status).label} column; it will drop ${O(N.status,R)}.`))},A=()=>{C.current!==null&&(cancelAnimationFrame(C.current),C.current=null)},E=32,P=12,Y=()=>{C.current=null;const k=w.current,N=g.current,R=y.current;if(!k?.armed||!N||R===null)return;const M=N.getBoundingClientRect(),F=N.scrollWidth-N.clientWidth;let q=0;if(R-M.left<E&&N.scrollLeft>0?q=-1:M.right-R<E&&N.scrollLeft<F&&(q=1),q!==0){const ae=N.scrollLeft;N.scrollLeft=ae+q*P,N.scrollLeft!==ae&&p(R,k)}else p(R,k);Q(k.status,k.over),C.current=requestAnimationFrame(Y)};d.useEffect(()=>()=>{C.current!==null&&cancelAnimationFrame(C.current)},[]);const I=(k,N)=>{if(k.button===0){try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}w.current={pointerId:k.pointerId,status:N,startX:k.clientX,startY:k.clientY,armed:!1,over:u.findIndex(R=>R.status===N)},y.current=k.clientX}},B=k=>{const N=w.current;if(!(!N||k.pointerId!==N.pointerId)){if(y.current=k.clientX,!N.armed){if(Math.hypot(k.clientX-N.startX,k.clientY-N.startY)<cl)return;N.armed=!0,f({status:N.status,over:N.over}),v(`Moving ${Z(N.status).label} column.`),C.current===null&&(C.current=requestAnimationFrame(Y))}p(k.clientX,N)}},W=k=>{const N=w.current;if(w.current=null,A(),f(null),!N?.armed)return;if(!k){v("Move cancelled.");return}const R=u.findIndex(M=>M.status===N.status);if(N.over===R){v("");return}T(N.status,N.over)},V=k=>{const N=w.current;!N||k.pointerId!==N.pointerId||W(!0)},oe=()=>{W(!1)};d.useEffect(()=>{if(!b)return;const k=N=>{N.key==="Escape"&&W(!1)};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[b!==null]);const Q=d.useCallback((k,N)=>{const R=g.current,M=x.current;if(!R||!M)return;const F=R.getBoundingClientRect(),q=[];for(const re of R.querySelectorAll("[data-board-column]"))re.dataset.boardColumn!==k&&q.push(re.getBoundingClientRect());const ae=6,Ce=N>=q.length?(q[q.length-1]?.right??F.left)+ae:(q[N]?.left??F.right)-ae,z=R.scrollLeft,we=2,xe=Ce-F.left+z,me=z+1,J=z+F.width-we-1,Ee=Math.round(Math.min(Math.max(xe,me),Math.max(me,J)));M.style.left=`${Ee}px`},[]);d.useLayoutEffect(()=>{b&&Q(b.status,b.over)},[b,Q]);const X=(k,N)=>{if(k.key==="Enter"||k.key===" "){k.preventDefault(),v(Ut);return}if(k.key!=="ArrowLeft"&&k.key!=="ArrowRight")return;k.preventDefault();const R=u.map(q=>q.status),M=R.indexOf(N),F=k.key==="ArrowLeft"?M-1:M+1;if(F<0||F>=R.length){v(`${Z(N).label} column is already ${F<0?"the first column":"the last column"}.`);return}T(N,F)};return t.jsxs("div",{className:"[container-type:size] flex min-h-0 flex-1 flex-col","data-testid":"project-board",children:[t.jsx("output",{"aria-live":"polite",className:"sr-only","data-board-column-announcement":"",children:j}),t.jsx("span",{id:an,className:"sr-only",children:Ut}),t.jsxs("div",{ref:g,"data-board-strip":"",className:$("relative flex min-h-0 flex-1 items-start overflow-auto px-6 pb-9",b&&"cursor-grabbing select-none"),children:[b&&t.jsx("div",{ref:x,"aria-hidden":"true","data-board-drop-indicator":"",className:"pointer-events-none absolute top-3 bottom-3 w-0.5 rounded-full bg-accent"}),t.jsxs("div",{className:"flex w-max flex-col",children:[t.jsx("div",{className:"sticky top-0 z-30 flex gap-3",children:u.map(k=>{const N=Z(k.status);return t.jsxs("header",{"data-board-column":k.status,"data-board-column-handle":k.status,onPointerDown:R=>I(R,k.status),onPointerMove:B,onPointerUp:V,onPointerCancel:oe,className:$("flex h-11 w-64 shrink-0 cursor-grab items-center justify-between gap-2 rounded-t-md bg-sunken px-3 active:cursor-grabbing",b?.status===k.status&&"opacity-85"),children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[t.jsx(U,{type:"button",variant:"ghost",size:"icon-sm","data-board-column-grip":k.status,"aria-label":`Move ${N.label} column`,"aria-describedby":an,title:Ut,className:"-ml-1.5 cursor-grab text-ink-muted active:cursor-grabbing",onKeyDown:R=>X(R,k.status),children:t.jsx(Dr,{"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:N.label}),nn[k.status]&&t.jsx("span",{className:"truncate text-meta text-ink-muted",children:nn[k.status]})]})]}),t.jsx("span",{className:"text-meta text-ink-muted",children:k.projects.length})]},k.status)})}),h.map(k=>t.jsxs("section",{className:"flex flex-col",children:[t.jsx("div",{"data-board-team":k.team??"",className:"sticky top-11 z-20 flex h-8 items-center bg-canvas px-3 text-meta",children:t.jsxs("span",{className:"sticky left-3 flex min-w-0 max-w-[calc(100cqw-2.25rem)] items-center gap-2",children:[t.jsx("span",{className:"truncate text-ink",children:k.team==null?ps:o(k.team)}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:k.items.length})]})}),t.jsx("div",{className:"flex gap-3 rounded-md bg-sunken py-2",children:u.map(N=>{const R=k.items.filter(M=>M.status===N.status);return t.jsx("div",{"data-board-cell":N.status,className:"flex max-h-[calc(100cqh-92px)] w-64 shrink-0 flex-col gap-2 overflow-y-auto px-2",children:R.length>0&&t.jsx("ul",{className:"flex flex-col gap-2",children:R.map(M=>t.jsx("li",{children:t.jsx(ul,{project:M,nowMs:s,busy:L.has(M.id),onOpen:()=>n(M),onEdit:()=>a(M),onDelete:()=>r(M),onMove:F=>i(M,F)})},M.id))})},N.status)})})]},k.team??""))]})]})]})},ul=({project:e,nowMs:s,busy:n,onOpen:a,onEdit:r,onDelete:i,onMove:l})=>{const o=$e(),c=qn(e,o),m=Ge(),u=ca(),h=fe(m.data,"projects_request_update"),b=G(e),f=d.useRef(null),[j,v]=d.useState(!1);d.useEffect(()=>{const w=f.current;if(!w)return;const L=()=>{w.isConnected&&v(w.scrollWidth-w.clientWidth>.5)},T=requestAnimationFrame(L),_=new ResizeObserver(L);return _.observe(w),document.fonts?.ready.then(L).catch(()=>{}),()=>{cancelAnimationFrame(T),_.disconnect()}},[b,j]);const g=Hn(e,vs(s)),x=dt(e.progress_updated_at,s),y=()=>{const w=window.getSelection();w&&!w.isCollapsed||a()},C=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":`Open ${b}`,onClick:y,onKeyDown:C,className:$("group/card flex flex-col gap-2 rounded-sm bg-surface p-3","transition-colors duration-fast ease-out-quart hover:bg-elevated",g&&"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(cs,{content:j?b:null,side:"top",disableHoverableContent:!0,children:t.jsx("span",{ref:f,"data-project-title":e.name,tabIndex:j?0:void 0,className:"block truncate text-body-sm font-medium text-ink",children:b})}),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(kn,{children:[t.jsx(wn,{"data-project-menu":e.id,"aria-label":`Actions for ${b}`,disabled:n,onClick:w=>w.stopPropagation(),className:$("shrink-0 rounded-sm p-1 text-ink-muted whitespace-nowrap","hover:bg-sunken hover:text-ink"),children:n?t.jsx(ke,{size:"xs"}):t.jsx(Ha,{className:"size-4"})}),t.jsxs(Nn,{align:"end",onClick:w=>w.stopPropagation(),children:[t.jsx(st,{onSelect:a,children:"Open"}),t.jsxs(vr,{children:[t.jsx(kr,{children:"Set status"}),t.jsx(wr,{children:t.jsx(Nr,{value:e.status,onValueChange:l,children:[...Wt,...Kt].map(w=>t.jsx(Sr,{value:w,children:Z(w).label},w))})})]}),h&&t.jsx(st,{onSelect:()=>u(e),children:"Request update"}),t.jsx(Tr,{}),t.jsx(st,{onSelect:r,children:"Edit"}),t.jsx(st,{onSelect:i,children:"Delete"})]})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[c.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)),g&&t.jsx(pe,{variant:"warning",children:"Overdue"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-meta text-ink-muted",children:li(x)}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[(e.progress_stale||!x)&&t.jsx("span",{"aria-label":kt,title:kt,className:"size-1.5 rounded-full bg-warning"}),e.sessions>0&&t.jsx(ml,{project:e})]})]})]})},ml=({project:e})=>{const[s,n]=d.useState(!1),a=Rt(),r=Dn(e.id,s),i=r.data?.links??[],l=mi(e),o=G(e);return t.jsxs(ds,{open:s,onOpenChange:n,children:[t.jsx(us,{"data-project-sessions":e.id,"aria-label":`Sessions linked to ${o}`,onClick:c=>c.stopPropagation(),className:$("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(ms,{align:"end",className:"w-64 p-2 outline-none",onClick:c=>c.stopPropagation(),children:r.isLoading?t.jsx("p",{className:"px-1 py-2 text-meta text-ink-muted",children:"Loading linked sessions…"}):r.isError?t.jsxs("div",{className:"flex flex-col items-start gap-1.5 px-1 py-2",children:[t.jsx("p",{className:"text-meta text-ink-muted",children:r.error instanceof Error&&r.error.message?r.error.message:"The linked sessions could not be read."}),t.jsx(U,{variant:"secondary",size:"sm",onClick:()=>void r.refetch(),children:"Try again"})]}):i.length===0?t.jsx("p",{className:"px-1 py-2 text-meta text-ink-muted",children:"No sessions linked yet."}):t.jsx("ul",{className:"flex flex-col",children:i.map(c=>t.jsx("li",{children:t.jsx("button",{type:"button",disabled:!c.exists,onClick:()=>{c.exists&&(n(!1),En(a,c.session_id))},className:$("flex w-full items-center gap-2 rounded-sm px-1 py-1.5 text-left text-meta",c.exists?"text-ink hover:bg-elevated":"text-ink-disabled"),children:t.jsx("span",{className:"truncate",children:c.title||c.session_id})})},c.session_id))})})]})},da=({open:e,projectName:s,onClose:n,onConfirm:a})=>{const[r,i]=d.useState(""),[l,o]=d.useState(null),[c,m]=d.useState(!1),u=d.useId();d.useEffect(()=>{e&&(i(""),o(null),m(!1))},[e]);const h=r.trim().toLowerCase()===s.trim().toLowerCase()&&s.trim().length>0,b=async()=>{m(!0),o(null);try{await a(r.trim()),n()}catch(f){o(f instanceof Error&&f.message?f.message:"The project was not deleted.")}finally{m(!1)}};return t.jsx(ct,{open:e,onClose:n,title:"Delete this project?",dataTourTag:"project-delete-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Be,{onClick:n,disabled:c,children:"Cancel"}),t.jsxs(Wa,{onClick:()=>void b(),disabled:!h||c,children:[c&&t.jsx(ke,{size:"xs"}),"Delete project"]})]}),children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"text-body-sm text-ink",children:"This deletes the project and its milestones. The sessions linked to it are not touched."}),t.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Type"," ",t.jsx("span",{className:"font-mono text-mono-sm text-ink",children:s})," ","to confirm."]}),t.jsx(ne,{id:`${u}-confirm`,value:r,onChange:f=>i(f.target.value),placeholder:s,"aria-label":"Type the project name to confirm","aria-invalid":r.length>0&&!h,autoFocus:!0}),l&&t.jsx("p",{className:"text-body-sm text-danger",children:l})]})})};function fl(e){return e==="editing"||e==="saving"||e==="error"}function hl(e,s,n=Object.is){return!n(e,s)}function pl(e,s){if(e.key==="Escape")return e.defaultPrevented===!0?null:"revert";if(e.key!=="Enter"||!s.keyboardCommit)return null;const n=e.metaKey===!0||e.ctrlKey===!0;return s.multiline?n?"accept":null:s.onEditor?"accept":null}function xl(e,s){return e==="saving"||e==="error"?!0:e==="editing"&&s}function gl(e){const{phase:s,base:n,draft:a,fresh:r,equals:i}=e;return s==="saving"||s==="saved"||i(n,r)?"none":s==="idle"||i(n,a)||i(r,a)?"adopt":"conflict"}function rn(e,s,n=Object.is){return!n(e,s)}const ws="group/inline-edit",Bt="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",bl="relative before:absolute before:-inset-1.5 before:content-['']",jl="relative before:absolute before:-top-1.5 before:-bottom-1.5 before:-left-1.5 before:right-0 before:content-['']",yl="relative before:absolute before:-top-1.5 before:-bottom-1.5 before:-right-1.5 before:left-0 before:content-['']",rs=({api:e,idle:s="affordance",className:n})=>{const{phase:a,labels:r}=e,i=a==="editing"||a==="saving"||a==="error",l=xl(a,e.dirty),o=e.acceptBlocked===!0;return t.jsx("span",{"data-inline-edit-slot":a,className:$("inline-flex shrink-0 items-center gap-0.5",n),children:l?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button","data-inline-edit-control":"cancel","aria-label":a==="saving"?r.busy:r.cancel,title:a==="saving"?r.busy:r.cancel,"aria-disabled":a==="saving"||void 0,onMouseDown:c=>c.preventDefault(),onClick:c=>{c.detail>1||a!=="saving"&&e.cancel()},className:$(Bt,jl,a==="saving"&&"cursor-default text-ink-disabled"),children:t.jsx(Dt,{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(ke,{size:"xs"})}):t.jsx("button",{type:"button","data-inline-edit-control":"accept","aria-label":a==="error"?r.retry??r.accept:r.accept,title:a==="error"?r.retry??r.accept:r.accept,"aria-disabled":o||void 0,onMouseDown:c=>c.preventDefault(),onClick:c=>{c.detail>1||o||e.accept()},className:$(Bt,yl,o&&"cursor-default text-ink-disabled"),children:t.jsx(fs,{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":r.begin,title:r.begin,onClick:c=>{c.detail>1||e.begin()},className:$(Bt,bl,"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(Ka,{className:"size-3","aria-hidden":"true"})}):null})},vl="This changed while you were editing",kl="Keep mine",wl="Use theirs",is=({api:e,className:s})=>{const{phase:n,error:a,conflict:r}=e;return n==="saved"?t.jsx("p",{"data-inline-edit-feedback":"saved",className:$("text-meta text-success",s),children:e.labels.saved}):!a&&!r?null:t.jsxs("div",{id:e.feedbackId,"data-inline-edit-feedback":a&&r?"error+conflict":a?"error":"conflict",role:"alert",className:$("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&&r===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:"Retry"}),r!==null&&t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-meta text-warning",children:vl}),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:kl}),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:wl})]})]})},ua=d.createContext(null),Nl=50,Sl=({children:e})=>{const[s,n]=d.useState(""),a=d.useMemo(()=>({current:r=>{n(""),window.setTimeout(()=>n(r),Nl)}}),[]);return t.jsxs(ua.Provider,{value:a,children:[e,t.jsx("span",{"data-inline-edit-announcement":"","aria-live":"polite",className:"sr-only",children:s})]})},Tl=1200;function _l(e){return e instanceof Error&&e.message?e.message:"The change was not saved."}function ht(e){const{value:s,multiline:n=!1,keyboardCommit:a=!0,selectAllOnBegin:r=!1,beginOnMount:i=!1,savedDwellMs:l=Tl,labels:o}=e,c=d.useRef(e.equals??Object.is);c.current=e.equals??Object.is;const m=d.useRef(e.commit);m.current=e.commit;const u=d.useRef(e.validate);u.current=e.validate;const h=d.useRef(e.errorCopy);h.current=e.errorCopy;const b=d.useRef(e.onSettle);b.current=e.onSettle;const f=d.useRef(e.onBegin);f.current=e.onBegin;const j=d.useRef(o);j.current=o;const[v,g]=d.useState(i?"editing":"idle"),[x,y]=d.useState(s),[C,w]=d.useState(s),[L,T]=d.useState(null),[_,O]=d.useState(null),p=d.useRef(v),A=d.useRef(x),E=d.useRef(C),P=d.useRef(L),Y=d.useRef(s);Y.current=s;const I=d.useCallback(D=>{p.current=D,g(D)},[]),B=d.useCallback(D=>{A.current=D,y(D)},[]),W=d.useCallback(D=>{E.current=D,w(D)},[]),V=d.useCallback(D=>{P.current=D,T(D)},[]),oe=d.useRef(null),Q=d.useRef(null),X=d.useRef(null),k=e.editorRef??X,N=d.useRef(k);N.current=k;const R=`${d.useId()}-inline-edit`,M=d.useContext(ua),F=d.useRef(null),q=F.current,Ce=q!==null&&(e.equals??Object.is)(s,q.previous)&&!(e.equals??Object.is)(s,q.saved)&&q!==null?q.saved:s,z=d.useRef(Ce);z.current=Ce,d.useEffect(()=>{const D=F.current;if(D===null)return;const te=c.current;(te(s,D.saved)||!te(s,D.previous))&&(F.current=null)},[s]);const we=d.useRef(i);d.useEffect(()=>{if(v!=="editing"||!we.current)return;we.current=!1;const D=N.current.current;D&&(D.focus(),r&&(D instanceof HTMLInputElement||D instanceof HTMLTextAreaElement)&&D.select())},[v,r]);const xe=d.useRef(!1);d.useEffect(()=>{xe.current&&(v!=="idle"&&v!=="saved"||(xe.current=!1,Q.current?.focus()))});const me=d.useRef(null),J=d.useCallback(()=>{me.current!==null&&(clearTimeout(me.current),me.current=null)},[]);d.useEffect(()=>()=>J(),[J]);const Ee=d.useRef(v);d.useEffect(()=>{const D=Ee.current;if(Ee.current=v,D==="saving"&&v==="saved"){b.current?.("saved");return}(D==="editing"||D==="error")&&v==="idle"&&b.current?.("cancelled")},[v]),d.useEffect(()=>{const D=gl({phase:p.current,base:E.current,draft:A.current,fresh:z.current,equals:c.current});D==="adopt"?(c.current(E.current,z.current)||W(z.current),c.current(z.current,A.current)||B(z.current)):D==="conflict"&&(P.current===null||!c.current(P.current,z.current))&&V(z.current)},[s,v,W,B,V]);const re=d.useCallback(D=>{V(null),O(null),B(E.current),I("idle"),D&&(xe.current=!0)},[V,B,I]),Je=d.useCallback(()=>{p.current!=="saving"&&(p.current==="idle"||p.current==="saved"||(J(),re(!0)))},[J,re]),ee=d.useCallback((D,te=!0)=>{const tt=p.current;if(tt==="saving"||tt==="saved"||P.current!==null)return;const ge=D!==void 0?D:A.current;if(!rn(E.current,ge,c.current)){re(te&&tt!=="idle");return}const xt=u.current?.(ge)??null;if(xt!==null){I("error"),O(xt);return}B(ge),O(null),I("saving"),m.current(ge).then(()=>{p.current==="saving"&&(F.current={saved:ge,previous:E.current},W(ge),B(ge),te&&(xe.current=!0),I("saved"),J(),me.current=setTimeout(()=>{me.current=null,p.current==="saved"&&I("idle")},l),M?.current?.(j.current.saved))},Ie=>{p.current==="saving"&&(I("error"),O(h.current?h.current(Ie):_l(Ie)))})},[M,J,re,l,W,B,I]),Ne=d.useCallback(()=>{p.current==="editing"||p.current==="saving"||(J(),we.current=!0,B(z.current),W(z.current),V(null),O(null),I("editing"),f.current?.())},[J,W,V,B,I]),Me=d.useCallback(()=>{const D=P.current;D!==null&&(V(null),W(D),ee())},[ee,W,V]),Mt=d.useCallback(()=>{const D=P.current;D!==null&&(W(D),re(!0))},[re,W]),Ze=d.useCallback(D=>{const te=pl(D,{multiline:n,keyboardCommit:a,onEditor:D.target===N.current.current});if(te==="revert"){D.preventDefault(),Je();return}te==="accept"&&(D.preventDefault(),ee())},[ee,Je,a,n]),et=d.useCallback(D=>{if(p.current!=="editing")return;const te=D.relatedTarget;if(!(te!==null&&oe.current?.contains(te))&&!(te instanceof Element&&te.closest("[data-radix-popper-content-wrapper]")!==null)&&P.current===null){if(!rn(E.current,A.current,c.current)){re(!1);return}ee(void 0,!1)}},[ee,re]),pt=v==="saved"?x:Ce;return{phase:v,dirty:hl(C,x,c.current),conflict:L,error:_,draft:x,setDraft:B,displayValue:pt,editing:fl(v),begin:Ne,accept:ee,cancel:Je,keepMine:Me,useTheirs:Mt,handleKeyDown:Ze,handleBlur:et,fieldProps:{onKeyDown:Ze,onBlur:et,"aria-busy":v==="saving"?!0:void 0},editorAria:{"aria-invalid":_!==null?!0:void 0,"aria-describedby":_!==null||L!==null?R:void 0},fieldRef:oe,editorRef:k,slotRef:Q,feedbackId:R,labels:o}}const Cl=/^(https?:|mailto:)/i,El={a:({href:e,children:s})=>typeof e=="string"&&Cl.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:Va},lt=d.memo(({children:e,className:s})=>t.jsx("div",{className:$("lo-markdown",s),children:t.jsx(Ga,{remarkPlugins:[Qa],components:El,children:e})})),on=`## Summary
|
|
33
33
|
|
|
34
34
|
## Goals
|
|
35
35
|
|
|
36
|
-
## Notes`,Rl=new RegExp("\\p{Mn}","gu"),Dl=/[^a-z0-9._-]+/g,Al=/[._-]{2,}/g,Ol=/^[^a-z0-9]+/,ln=/[^a-z0-9]+$/;function $l(e){return e.normalize("NFKD").replace(Rl,"").toLowerCase().replace(Dl,"-").replace(Al,"-").replace(Ol,"").replace(ln,"").slice(0,64).replace(ln,"")}const Pl=/&#x([0-9a-f]+);/gi,Ml=/&#(\d+);/g,Il=/ /g,Ll=/</g,Fl=/>/g,ql=/"/g,Ul=/'|'/g,Bl=/&/g,cn=e=>e.replace(Pl,(s,n)=>String.fromCodePoint(Number.parseInt(n,16))).replace(Ml,(s,n)=>String.fromCodePoint(Number.parseInt(n,10))).replace(Il," ").replace(Ll,"<").replace(Fl,">").replace(ql,'"').replace(Ul,"'").replace(Bl,"&"),
|
|
37
|
-
`))},c=e.match(
|
|
36
|
+
## Notes`,Rl=new RegExp("\\p{Mn}","gu"),Dl=/[^a-z0-9._-]+/g,Al=/[._-]{2,}/g,Ol=/^[^a-z0-9]+/,ln=/[^a-z0-9]+$/;function $l(e){return e.normalize("NFKD").replace(Rl,"").toLowerCase().replace(Dl,"-").replace(Al,"-").replace(Ol,"").replace(ln,"").slice(0,64).replace(ln,"")}const Pl=/&#x([0-9a-f]+);/gi,Ml=/&#(\d+);/g,Il=/ /g,Ll=/</g,Fl=/>/g,ql=/"/g,Ul=/'|'/g,Bl=/&/g,cn=e=>e.replace(Pl,(s,n)=>String.fromCodePoint(Number.parseInt(n,16))).replace(Ml,(s,n)=>String.fromCodePoint(Number.parseInt(n,10))).replace(Il," ").replace(Ll,"<").replace(Fl,">").replace(ql,'"').replace(Ul,"'").replace(Bl,"&"),Yl=/<[^>]*>|[^<]+/g,zl=/^<\//,Hl=/^<\/?\s*([a-zA-Z][a-zA-Z0-9]*)/,Wl=/\s+/g,dn=/class="[^"]*language-([\w+-]+)/,Kl=/href="([^"]*)"/,Gl=/src="([^"]*)"/,Vl=/alt="([^"]*)"/,Ql=/[ \t]+\n/g,Xl=/\n{3,}/g;function Jl(e){const s=[],n=(...m)=>{for(let u=s.length-1;u>=0;u--)if(m.includes(s[u].tag)){const[h]=s.splice(u,1);return h}},a=[],r=()=>s.some(m=>m.tag==="pre"),i=()=>s.filter(m=>m.tag==="blockquote").length;let l=!0;const o=m=>{m&&(i()>0&&l&&!r()&&a.push("> ".repeat(i())),a.push(m),l=m.endsWith(`
|
|
37
|
+
`))},c=e.match(Yl)??[];for(let m=0;m<c.length;m++){const u=c[m];if(!u.startsWith("<")){o(r()?cn(u):cn(u).replace(Wl," "));continue}const h=zl.test(u),b=(u.match(Hl)?.[1]??"").toLowerCase();if(h){switch(b){case"p":case"div":o(`
|
|
38
38
|
|
|
39
39
|
`);break;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":n(b),o(`
|
|
40
40
|
|
|
@@ -47,4 +47,4 @@ import{r as d,j as t,c as $}from"./index-Dj4jIPlf.js";import{bV as _a,bW as zt,b
|
|
|
47
47
|
`);break;case"blockquote":s.push({tag:"blockquote"});break}}return a.join("").replace(Ql,`
|
|
48
48
|
`).replace(Xl,`
|
|
49
49
|
|
|
50
|
-
`).trim()}function ma(e,s,n){const a=e.clipboardData?.getData("text/html");if(!a)return;const r=Jl(a);if(!r)return;e.preventDefault();const i=e.currentTarget,l=i.selectionStart??i.value.length,o=i.selectionEnd??l;n(i.value.slice(0,l)+r+i.value.slice(o)),requestAnimationFrame(()=>{const c=s.current;if(!c)return;const m=l+r.length;c.setSelectionRange(m,m)})}const fa=({open:e,refusal:s,projectLabel:n,onClose:a,onConfirm:r,secondaryLabel:i,onSecondary:l})=>{const[o,c]=d.useState(!1),[m,u]=d.useState(null),h=d.useRef(!1),b=d.useRef(null);d.useEffect(()=>{e&&(c(!1),u(null),h.current=!1)},[e]);const f=async()=>{if(!h.current){h.current=!0,c(!0),u(null);try{await r(),a()}catch(v){u({copy:aa(v),gone:na(v)})}finally{h.current=!1,c(!1)}}},j=s?.names??[];return t.jsx(ct,{open:e,onClose:a,title:"Mark done with open milestones?",dataTourTag:"project-done-anyway-dialog",maxWidth:"xs",dialogProps:{closeDisabled:o,onEscapeKeyDown:v=>{o&&v.preventDefault()},onInteractOutside:v=>{o&&v.preventDefault()},onOpenAutoFocus:v=>{v.preventDefault(),b.current?.focus()}},actions:t.jsxs("div",{className:"flex w-full min-w-0 flex-wrap justify-end gap-2",children:[t.jsx(Be,{ref:b,onClick:a,disabled:o,children:"Cancel"}),!m?.gone&&t.jsx(Be,{onClick:l,disabled:o,children:i}),m?.gone?t.jsx(yt,{"data-project-force-close":"",onClick:a,children:"Close"}):t.jsxs(yt,{"data-project-force-done":"","aria-disabled":o,className:"aria-disabled:pointer-events-none aria-disabled:bg-sunken aria-disabled:text-ink-disabled",onClick:()=>void f(),children:[o?t.jsx(ke,{size:"xs"}):t.jsx("span",{"aria-hidden":"true",className:"size-3.5 shrink-0"}),"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:n?`${n} moves to Done and its milestones stay open.`:"The project moves to Done and its milestones stay open."}),t.jsx("p",{className:"text-body-sm text-ink break-words",children:s?zi(s):""}),j.length>jt+1&&t.jsx("div",{className:"px-1.5",children:t.jsx(jn,{summary:`Show all ${j.length} open milestones`,children:t.jsx("ul",{"data-project-open-milestones":"",className:"flex flex-col gap-1 py-1 text-body-sm text-ink-muted",children:j.map((v,g)=>t.jsx("li",{className:"break-words",children:v},`${g}-${v}`))})})}),t.jsx("p",{role:"alert",className:"min-h-[1lh] text-body-sm text-danger break-words",children:m?.copy??""})]})})},ha=({status:e})=>{const s=Z(e);return t.jsxs(pe,{variant:s.variant,children:[ai(e)&&t.jsx(fs,{"aria-hidden":!0}),s.label]})};function ue(e,s){return{name:s,begin:`Edit ${e}`,accept:`Save ${e}`,cancel:`Discard the ${e} edit`,busy:`Saving the ${e}`,saved:`${s} saved`,retry:`Retry saving the ${e}`}}const Pt=({field:e,fieldRef:s,fieldProps:n,editing:a,label:r,bare:i=!1,display:l,editor:o,slot:c,feedback:m,controlsIdle:u="affordance",hug:h=!1,feedbackExtra:b,className:f,controlsClassName:j})=>t.jsxs("div",{ref:s,...n,"data-project-field":e,className:$(!i&&ws,"min-w-0",r!==void 0&&"flex items-start gap-3",f),children:[r!==void 0&&t.jsx("dt",{className:"w-24 shrink-0 pt-0.5 text-body-sm text-ink-muted",children:r}),t.jsxs("div",{className:$("flex min-w-0 flex-col gap-1",h&&"items-start",r!==void 0&&"flex-1"),children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("div",{className:$("min-w-0",h?"w-fit":"flex-1",!a&&"cursor-text"),onDoubleClick:a?void 0:c.begin,children:a?o:l}),t.jsx(rs,{api:c,idle:u,className:$("shrink-0",j)})]}),t.jsx("div",{className:$("min-h-[1lh] text-meta",h&&"max-w-96"),children:t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsx(is,{api:m}),b]})})]})]}),Ae=({field:e,value:s,display:n,commitFields:a,validate:r,labels:i,commit:l,placeholder:o,mono:c=!1,ramp:m="text-body-sm",label:u,bare:h=!1,autoBegin:b=!1,maxLength:f,onRetire:j,className:v,controlsClassName:g})=>{const[x,y]=d.useState(b);d.useEffect(()=>{x&&s!==""&&(y(!1),j?.("filled"))},[x,s,j]);const C=ht({value:s,commit:async w=>{await l(a(w))},equals:(w,L)=>w.trim()===L.trim(),validate:r,labels:i,selectAllOnBegin:!0,beginOnMount:b,errorCopy:Xe,onSettle:w=>{w==="cancelled"&&(y(!1),j?.("cancelled"))}});return!x&&s===""?null:t.jsx(Pt,{field:e,fieldRef:C.fieldRef,fieldProps:C.fieldProps,editing:C.editing,label:u,bare:h,display:n,slot:C,feedback:C,className:v,controlsClassName:g,editor:t.jsx(ne,{ref:C.editorRef,...C.editorAria,value:C.draft,readOnly:C.phase==="saving",maxLength:f,placeholder:o,"aria-label":i.name,onChange:w=>C.setDraft(w.target.value),spellCheck:!1,autoComplete:"off",className:$("h-8",c?"font-mono text-mono-sm":m)})})},Zl=({project:e,commit:s})=>{const n=e.title??"",[a,r]=d.useState(!1),i=d.useRef(null),l=o=>{r(!1),o==="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:$(ws,"flex min-w-0 flex-col gap-0.5"),children:[n?t.jsx(Ae,{field:"title",value:n,display:t.jsx("h1",{"data-project-title":e.name,className:"min-w-0 break-words text-display text-ink",children:n}),commitFields:o=>({title:o.trim()}),validate:o=>Jt(o),labels:ue("title","Title"),commit:s,maxLength:wt,placeholder:"A short name for the workstream",ramp:"text-body",bare:!0,controlsClassName:"self-center"}):t.jsx(Ae,{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:o=>({name:o.trim()}),validate:o=>Yt(o.trim()),labels:ue("key","Key"),commit:s,maxLength:Vs,placeholder:"project-key",ramp:"text-body",bare:!0,controlsClassName:"self-center"}),!n&&(a?t.jsx(Ae,{field:"title",value:"",display:null,commitFields:o=>({title:o.trim()}),validate:o=>Jt(o),labels:ue("title","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:()=>r(!0),className:$("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:"Add a title"}))]}),n&&t.jsx(Ae,{field:"key",value:e.name,display:t.jsx("span",{className:"font-mono text-mono-sm text-ink-muted",children:e.name}),commitFields:o=>({name:o.trim()}),validate:o=>Yt(o.trim()),labels:ue("key","Key"),commit:s,maxLength:Vs,placeholder:"project-key",mono:!0})]})},ec=({project:e,commit:s})=>{const[n,a]=d.useState(!1),r=Ge(),i=fe(r.data,"projects_force_done"),[l,o]=d.useState(null),[c,m]=d.useState(null),u=d.useRef(!1),h=d.useRef(!1),b=d.useRef(null),f=ht({value:e.status,commit:async g=>{const x=u.current;u.current=!1,o(null);try{const y=await s({status:g},x?{forceDone:!0}:void 0);x&&ve(Gn(y,l?.count??0,Z(g).label)),b.current?.resolve()}catch(y){throw o(ra(y)),b.current?.reject(y),y}finally{b.current=null}},labels:ue("status","Status"),keyboardCommit:!1,errorCopy:Xe,onBegin:()=>a(!0)}),j=i&&f.phase==="error"&&l!==null&&l.coded;d.useEffect(()=>{if(!h.current||f.phase!=="idle"&&f.phase!=="saved")return;h.current=!1;const g=document.querySelector("[data-project-milestones]");g&&(g.scrollIntoView({block:"start"}),g.querySelector("[data-project-milestones-heading]")?.focus({preventScroll:!0}))},[f.phase]);const v=()=>new Promise((g,x)=>{if(f.phase!=="error"||f.conflict!==null){x(new Error(""));return}if(!f.dirty){g();return}u.current=!0,b.current={resolve:g,reject:x},f.accept(f.draft,!0)});return t.jsx(Pt,{field:"status",fieldRef:f.fieldRef,fieldProps:f.fieldProps,editing:f.editing,display:t.jsx(ha,{status:e.status}),slot:f,feedback:f,hug:!0,feedbackExtra:t.jsxs(t.Fragment,{children:[j&&t.jsx(U,{variant:"ghost",size:"sm","data-project-force-done-door":"",onClick:()=>m(l),children:"Mark done anyway…"}),t.jsx(fa,{open:c!==null,refusal:c,projectLabel:G(e),onClose:()=>m(null),onConfirm:v,secondaryLabel:"Review milestones",onSecondary:()=>{m(null),h.current=!0,f.cancel()}})]}),editor:t.jsxs(ze,{open:n,onOpenChange:a,value:f.draft,onValueChange:g=>{a(!1),f.accept(g)},children:[t.jsx(Ye,{ref:f.editorRef,...f.editorAria,"aria-label":"Status","data-project-status":"",className:"h-7 w-fit min-w-36",children:t.jsx(He,{})}),t.jsx(We,{children:Pn.map(g=>t.jsx(Te,{value:g.value,"data-project-status-option":g.value,children:g.label},g.value))})]})})},tc=({project:e,commit:s})=>{const[n,a]=d.useState(!1),r=d.useRef(null),i=d.useRef(null),l=ht({value:e.description,commit:async m=>{await s({description:m.trim()})},equals:(m,u)=>m.trim()===u.trim(),validate:m=>ta(m),multiline:!0,labels:ue("description","Description"),errorCopy:Xe,editorRef:r,onSettle:m=>{m==="cancelled"&&!e.description.trim()&&setTimeout(()=>i.current?.focus(),0)}});d.useEffect(()=>{if(n||!l.editing)return;const m=setTimeout(()=>r.current?.focus(),0);return()=>clearTimeout(m)},[n,l.editing]);const c=(l.editing?l.draft:l.displayValue).length>Ue;return t.jsx("div",{ref:l.fieldRef,...l.fieldProps,"data-project-field":"description",className:$(ws,"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:"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":n===(m==="preview"),onClick:()=>a(m==="preview"),className:$("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink",n===(m==="preview")&&"bg-surface text-ink"),children:m==="write"?"Write":"Preview"},m))})]}),t.jsx(rs,{api:{...l,acceptBlocked:c}})]}),n?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(lt,{className:"text-body-sm",children:l.draft}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:"Nothing to preview yet."})}):t.jsx(Sn,{ref:r,...l.editorAria,"data-project-description":"",value:l.draft,readOnly:l.phase==="saving",rows:8,placeholder:"Markdown — headings, lists, code.","aria-label":l.labels.name,onChange:m=>l.setDraft(m.target.value),onPaste:m=>ma(m,r,u=>l.setDraft(u)),className:"h-40 resize-none"}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(is,{api:l}),t.jsxs("p",{className:$("shrink-0 text-meta tabular-nums",c?"text-danger":"text-ink-muted"),children:[l.draft.length,"/",Ue]})]})]}):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(lt,{className:"text-body",children:e.description??""})}),t.jsx(rs,{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:"Add description"}),t.jsx("div",{className:"min-h-[1lh] text-meta",children:t.jsx(is,{api:l})})]})})},sc=({project:e,commit:s,autoBegin:n=!1,onRetire:a})=>t.jsx(Ae,{field:"owner",value:e.owner??"",label:"Owner",display:t.jsx("span",{className:"text-body-sm text-ink",children:e.owner}),commitFields:r=>({owner:r.trim()}),validate:r=>St(r,"owner"),labels:ue("owner","Owner"),commit:s,maxLength:Nt,placeholder:"atlas",autoBegin:n,onRetire:a}),nc=({project:e,commit:s,label:n=null,autoBegin:a=!1,onRetire:r})=>t.jsx(Ae,{field:"team",value:e.team??"",label:"Team",display:t.jsx("span",{className:"text-body-sm text-ink",children:n??e.team}),commitFields:i=>({team:i.trim()}),validate:i=>St(i,"team"),labels:ue("team","Team"),commit:s,maxLength:Nt,placeholder:"platform",autoBegin:a,onRetire:r}),un=({project:e,commit:s,which:n,nowMs:a,autoBegin:r=!1,onRetire:i})=>{const l=n==="start"?e.start_date??"":e.target_date??"",o=$e(),c=_e(l,o,new Date(a)),m=n==="start"?"Start":"Target";return t.jsx(Ae,{field:n==="start"?"start-date":"target-date",value:l,label:m,display:t.jsx("span",{className:"text-body-sm text-ink",children:c}),commitFields:u=>n==="start"?{start_date:u}:{target_date:u},validate:u=>{const h=Zt(u);return h||(n==="start"?es(u,e.target_date??""):es(e.start_date??"",u))},labels:ue(`${m.toLowerCase()} date`,m),commit:s,placeholder:"YYYY-MM-DD",autoBegin:r,onRetire:i})},ac=({project:e,commit:s,autoBegin:n=!1,onRetire:a})=>{const r={estimate:e.estimate,unit:e.estimate_unit==="days"?"days":"points"},[i,l]=d.useState(n);d.useEffect(()=>{i&&e.estimate!==null&&(l(!1),a?.("filled"))},[i,e.estimate,a]);const o=ht({value:{number:e.estimate===null?"":String(e.estimate),unit:r.unit},equals:Bo,commit:async m=>{const u=Yo(r,m);u&&await s(u)},validate:m=>sa(m.number),labels:ue("estimate","Estimate"),selectAllOnBegin:!0,beginOnMount:n,errorCopy:Xe,onSettle:m=>{m==="cancelled"&&(l(!1),a?.("cancelled"))}});if(!i&&e.estimate===null)return null;const c=Ln(e.estimate,e.estimate_unit)||"—";return t.jsx(Pt,{field:"estimate",fieldRef:o.fieldRef,fieldProps:o.fieldProps,editing:o.editing,label:"Estimate",display:t.jsx("span",{className:"text-body-sm text-ink",children:c}),slot:o,feedback:o,editor:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ne,{ref:o.editorRef,...o.editorAria,"data-project-estimate":"",value:o.draft.number,readOnly:o.phase==="saving",placeholder:"13",inputMode:"decimal","aria-label":o.labels.name,onChange:m=>o.setDraft({...o.draft,number:m.target.value}),className:"h-8 max-w-24"}),t.jsxs(ze,{value:o.draft.unit,onValueChange:m=>o.setDraft({...o.draft,unit:m}),children:[t.jsx(Ye,{"data-project-estimate-unit":"","aria-label":"Estimate unit","aria-invalid":o.editorAria["aria-invalid"],className:"h-8 w-fit min-w-28",children:t.jsx(He,{})}),t.jsxs(We,{children:[t.jsx(Te,{value:"points",children:"Points"}),t.jsx(Te,{value:"days",children:"Days"})]})]})]}),o.draft.number.trim()===""&&r.estimate!==null&&t.jsx("p",{className:"text-meta text-ink-muted",children:"Clearing an estimate is not supported yet — saving keeps its current value."})]})})},rc=({project:e,commit:s,autoBegin:n=!1,onRetire:a})=>{const[r,i]=d.useState(n);d.useEffect(()=>{r&&e.tags.length>0&&(i(!1),a?.("filled"))},[r,e.tags,a]);const l=ht({value:e.tags.join(", "),equals:(c,m)=>zo(ot(c),m),commit:async c=>{const{tags:m}=ts(c);await s({tags:m})},validate:c=>ts(c).error,labels:ue("tags","Tags"),selectAllOnBegin:!0,beginOnMount:n,errorCopy:Xe,onSettle:c=>{c==="cancelled"&&(i(!1),a?.("cancelled"))}});if(!r&&e.tags.length===0)return null;const o=l.editing?ot(l.draft):e.tags;return t.jsx(Pt,{field:"tags",fieldRef:l.fieldRef,fieldProps:l.fieldProps,editing:l.editing,label:"Tags",display:t.jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:e.tags.map(c=>t.jsx(pe,{variant:"outline",children:c},c))}),slot:l,feedback:l,editor:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(ne,{ref:l.editorRef,...l.editorAria,"data-project-tags":"",value:l.draft,readOnly:l.phase==="saving",placeholder:"q4, payments","aria-label":l.labels.name,onChange:c=>l.setDraft(c.target.value),className:"h-8 max-w-72"}),t.jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:o.map(c=>t.jsx(pe,{variant:"outline",children:c},c))})]})})},ic="project-quick-send:no-target",oc=[],lc=({links:e,target:s,onTargetChange:n,onSend:a,focusTick:r})=>{const i=d.useRef(null),l=Xa(),{frontend:o,refresh:c}=Mr(),[m,u]=d.useState(!1),h=Ge(),b=s??ic;d.useEffect(()=>{s&&c(s)},[s,c]),d.useEffect(()=>{r>0&&i.current?.focusInput()},[r]);const f=e.filter(g=>g.exists),v=(f.find(g=>g.session_id===s)??null)?.runtime?.busy===!0;return t.jsxs("div",{"data-tour-tag":"project-quick-send",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:"Send to"}),t.jsxs(ze,{value:s??void 0,onValueChange:g=>n(g),children:[t.jsx(Ye,{"aria-label":"Select the session to message",className:"max-w-72",children:t.jsx(He,{placeholder:"No session selected"})}),t.jsx(We,{children:f.map(g=>t.jsx(Te,{value:g.session_id,children:$t(g)},g.session_id))})]}),m?t.jsx("span",{role:"status",className:"text-meta text-ink-muted",children:"Sending…"}):v?t.jsx("span",{className:"text-meta text-ink-muted",children:"The session is working — this message steers the running turn."}):null]}),t.jsx(Ja,{ref:i,conversationId:b,messages:oc,isLoading:!1,ownGutter:!0,transcriptless:!0,autoFocus:!1,placeholderOverride:"Message the session — paste an image to attach it",cwd:o?.cwd,cwdReadOnlyReason:"Quick send follows the conversation's directory.",sessionStatus:o&&s?{frontend:o,costChannels:fe(h.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:"Choose a session to send to."}),blocksInput:!0,placeholder:"Choose a session to send to."},onSendMessage:async(g,x)=>{if(!s)return!1;u(!0);try{return await a(s,g,v?"steer":"prompt",x)}finally{u(!1),i.current?.focusInput({preventScroll:!0})}}})]})},cc=({links:e,busy:s,onUnlink:n,onLink:a,onQuickSend:r,onStartSession:i})=>{const l=Rt(),o=vt(x=>x.sessions),[c,m]=d.useState(!1),[u,h]=d.useState(null),[b,f]=d.useState(0),j=u&&e.some(x=>x.session_id===u&&x.exists)?u:Mi(e),v=d.useMemo(()=>{const x=new Set(e.map(y=>y.session_id));return o.filter(y=>!x.has(y.session_id)).map(y=>({id:y.session_id,name:y.title||y.session_id,description:y.cwd??void 0}))},[o,e]),g=x=>{vt.getState().openSession(x).then(y=>{y&&l(`/chat/${x}`)})};return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"Linked sessions"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(U,{variant:"secondary",size:"sm",disabled:s,onClick:i,"data-tour-tag":"project-start-session",children:[t.jsx(Or,{}),"New session"]}),t.jsxs(U,{variant:"secondary",size:"sm",disabled:s,onClick:()=>m(!0),"data-tour-tag":"project-link-session",children:[t.jsx(Yr,{}),"Link session"]})]})]}),e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No sessions linked yet. Link the conversations that are working on this project so its progress stays with them."}):t.jsx("ul",{className:"flex flex-col divide-y divide-hairline rounded-md bg-surface",children:e.map(x=>{const y=fi(x),C=hi(x.subagents),w=pi(x.todos),L=x.title||x.session_id,T=x.exists;return t.jsxs("li",{className:$("flex items-center gap-2 rounded-sm px-2 py-2",T&&"hover:bg-row-hover"),children:[t.jsx("button",{type:"button",disabled:!T,onClick:()=>{T&&g(x.session_id)},className:$("flex min-w-0 flex-1 items-center gap-2 text-left",T?"cursor-pointer":"cursor-default opacity-100"),children:t.jsx("span",{className:$("min-w-0 truncate text-body-sm",x.title?"text-ink":"font-mono text-mono-sm text-ink-muted"),children:L})}),x.runtime?.busy===!0&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:"busy"}),C&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:C}),w&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:w}),t.jsx(pe,{variant:y.variant,children:y.label}),T&&t.jsx(U,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":`Message ${L}`,title:`Message ${L}`,onClick:()=>{h(x.session_id),f(_=>_+1)},children:t.jsx($r,{})}),t.jsx(U,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":`Unlink ${L}`,onClick:()=>n(x.session_id),children:t.jsx(Qr,{})})]},x.session_id)})}),e.some(x=>x.exists)&&t.jsx(lc,{links:e,target:j,onTargetChange:h,onSend:r,focusTick:b}),t.jsx(ct,{open:c,onClose:()=>m(!1),title:"Link a session",maxWidth:"sm",dataTourTag:"project-link-dialog",actions:t.jsx(Be,{onClick:()=>m(!1),children:"Close"}),children:t.jsxs("div",{className:"flex flex-col gap-2 px-1 py-1",children:[t.jsx(ie,{children:"Session"}),t.jsx(Tn,{showLabel:!1,ariaLabel:"Search sessions",busyLabel:"Loading sessions",placeholder:"Search conversations",options:v,selected:null,onSelect:x=>{m(!1),a(x.id)}}),t.jsx("p",{className:"text-meta text-ink-muted",children:"Conversations already linked to this project are not listed."})]})})]})},dc=({milestones:e,summary:s,busy:n,onToggle:a,onRemove:r,onAdd:i})=>{const[l,o]=d.useState(""),[c,m]=d.useState(""),u=$e(),h=!Mn.test(c.trim()),b=l.trim().length>0&&!h&&!n,f=()=>{b&&(i(l.trim(),c.trim()),o(""),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:"Milestones"}),s&&e.length>0&&t.jsx("span",{className:"text-meta text-ink-muted tabular-nums",children:s})]}),e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No milestones yet. Add one below to mark the dates this project is planned around."}):t.jsx("ul",{className:"flex flex-col divide-y divide-hairline rounded-md bg-surface",children:e.map(j=>{const v=ii(j.status),g=j.completed_at!==null;return t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx(_n,{checked:g,disabled:n,onCheckedChange:x=>a(j.name,x===!0),"aria-label":g?`Mark ${j.name} not complete`:`Mark ${j.name} complete`}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:j.name}),j.target_date&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:_e(j.target_date,u)}),t.jsx(pe,{variant:v.variant,children:v.label}),t.jsx(U,{variant:"ghost",size:"icon-sm",disabled:n,"aria-label":`Remove ${j.name}`,onClick:()=>r(j.name),children:t.jsx(Dt,{})})]},j.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(ie,{htmlFor:"project-milestone-name",children:"New milestone"}),t.jsx(ne,{id:"project-milestone-name",value:l,onChange:j=>o(j.target.value),placeholder:"beta cut",onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),f())}})]}),t.jsxs("div",{className:"flex w-40 flex-col gap-1.5",children:[t.jsx(ie,{htmlFor:"project-milestone-date",children:"Target date"}),t.jsx(ne,{id:"project-milestone-date",value:c,onChange:j=>m(j.target.value),placeholder:"YYYY-MM-DD","aria-invalid":h}),h&&t.jsx("p",{className:"text-meta text-danger",children:"Dates are YYYY-MM-DD, or empty."})]}),t.jsxs(U,{variant:"secondary",disabled:!b,onClick:f,"data-tour-tag":"project-milestone-add",children:[t.jsx(rt,{}),"Add"]})]})]})},uc=[{field:"owner",label:"Owner"},{field:"team",label:"Team"},{field:"start",label:"Start date"},{field:"target",label:"Target date"},{field:"estimate",label:"Estimate"},{field:"tags",label:"Tags"}],mn=({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})]}),mc=({project:e,nowMs:s,commit:n,teamLabel:a=null})=>{const r=$e(),i=new Date(s),[l,o]=d.useState(null),c=d.useRef(null),m=d.useRef(!1),u={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},h=(_,O)=>{o(p=>p===_?null:p),O==="cancelled"&&!u[_]&&setTimeout(()=>c.current?.focus(),0)},b=uc.filter(({field:_})=>!u[_]&&l!==_),f=_e(e.completed_at,r,i),j=e.updated_at>0?ut(dt(e.updated_at,s)):"",v=e.updated_at>0?new Date(e.updated_at*1e3).toLocaleString(r):"",g=u.owner||l==="owner",x=u.team||l==="team",y=u.start||l==="start",C=u.target||l==="target",w=u.estimate||l==="estimate",L=u.tags||l==="tags",T=g||x||y||C||!!f||w||L||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:"Properties"}),b.length>0&&t.jsxs(kn,{children:[t.jsx(wn,{asChild:!0,children:t.jsxs("button",{ref:c,type:"button","data-project-add-field":"",className:$("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(rt,{className:"size-3","aria-hidden":"true"}),"Add"]})}),t.jsx(Nn,{align:"end",onCloseAutoFocus:_=>{m.current&&(m.current=!1,_.preventDefault())},children:b.map(({field:_,label:O})=>t.jsx(st,{"data-project-add-option":_,onSelect:()=>{m.current=!0,o(_)},children:O},_))})]})]}),T?t.jsxs("dl",{className:"flex flex-col gap-2",children:[g&&t.jsx(sc,{project:e,commit:n,autoBegin:l==="owner",onRetire:_=>h("owner",_)}),x&&t.jsx(nc,{project:e,commit:n,label:a,autoBegin:l==="team",onRetire:_=>h("team",_)}),y&&t.jsx(un,{project:e,commit:n,which:"start",nowMs:s,autoBegin:l==="start",onRetire:_=>h("start",_)}),C&&t.jsx(un,{project:e,commit:n,which:"target",nowMs:s,autoBegin:l==="target",onRetire:_=>h("target",_)}),f&&t.jsx(mn,{label:"Completed",children:f}),w&&t.jsx(ac,{project:e,commit:n,autoBegin:l==="estimate",onRetire:_=>h("estimate",_)}),L&&t.jsx(rc,{project:e,commit:n,autoBegin:l==="tags",onRetire:_=>h("tags",_)}),e.updated_at>0&&t.jsx(mn,{label:"Updated",children:t.jsx("time",{dateTime:new Date(e.updated_at*1e3).toISOString(),title:v,children:j})})]}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No dates, estimate, tags, owner or team yet."})]})},fc=({project:e})=>{const s=Ge(),n=ca(),{sending:a,cooling:r,cooldownRemainingMs:i}=ol(e.id);if(!fe(s.data,"projects_request_update"))return null;const l=G(e),o=Jo(e.id);return t.jsxs(t.Fragment,{children:[t.jsx(cs,{content:r&&i!==null?Tt(l,i):Vo,children:t.jsxs(U,{variant:"secondary",className:"min-w-37","data-tour-tag":"project-request-update","aria-busy":a?!0:void 0,"aria-disabled":r?!0:void 0,"aria-describedby":r?o:void 0,onClick:()=>n(e),children:[a?t.jsx(ke,{size:"sm"}):r?t.jsx(fs,{}):t.jsx(Gr,{}),a?"Requesting…":r?"Requested":"Request update"]})}),r&&i!==null&&t.jsx("span",{id:o,className:"sr-only",children:Tt(l,i)})]})},pa="plain",xa=e=>`team:${e}`,ga=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 pc(e){return e.kind==="team"?xa(e.name):e.kind==="agent"?ga(e.name):pa}const fn={kind:"plain"},xc=({open:e,onClose:s,onStart:n,teamsEnabled:a,profilesEnabled:r})=>{const[i,l]=d.useState(fn),[o,c]=d.useState(null),[m,u]=d.useState(!1),h=Za(e&&a),b=er(e&&r);d.useEffect(()=>{e&&(l(fn),c(null),u(!1))},[e]);const f=d.useMemo(()=>{const y=[{id:pa,name:"Nothing in particular",description:"A plain session; assign a team or agent later.",group:"Plain"}];for(const C of h.data??[])y.push({id:xa(C.name),name:Os(C),keywords:C.name===Os(C)?void 0:[C.name],description:`Team · manager: ${C.manager}`,group:"Teams"});for(const C of(b.data??[]).filter(w=>w.source!=="builtin"))y.push({id:ga(C.name),name:C.name,description:C.description||C.kind,group:"Agents"});return y},[h.data,b.data]),j=f.find(y=>y.id===pc(i))??f[0],v=!a||!r,g=h.isLoading||b.isLoading,x=async()=>{u(!0),c(null);try{await n(i),s()}catch(y){c(y instanceof Error&&y.message?y.message:"The session could not be started.")}finally{u(!1)}};return t.jsx(ct,{open:e,onClose:s,title:"Start a session",maxWidth:"sm",dataTourTag:"project-start-session-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Be,{onClick:s,disabled:m,children:"Cancel"}),t.jsxs(yt,{onClick:()=>void x(),disabled:m,children:[m&&t.jsx(ke,{size:"xs"}),"Start session"]})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx(Tn,{label:"Work with",placeholder:"Search teams and agents",options:f,selected:j,onSelect:y=>l(hc(y.id)),busy:g,busyLabel:"Loading teams and agents"}),t.jsx("p",{className:"text-meta text-ink-muted",children:"The session starts now, links itself to this project, and opens with a prompt you can edit before sending."}),v&&t.jsx("p",{className:"text-meta text-ink-muted",children:"This server does not offer the team or agent catalogues yet, so only a plain session can be started."}),o&&t.jsx("p",{className:"text-body-sm text-danger",children:o})]})})},gc=({links:e})=>{const s=Pi(e),n=e.filter(a=>a.todos!==null);return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"To-dos"}),s&&t.jsx("span",{className:"text-meta text-ink-muted tabular-nums",children:Us(s)})]}),n.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No to-do snapshots from the linked sessions yet. A session publishes its list as it works, and it appears here once it has."}):t.jsx("ul",{className:"flex flex-col divide-y divide-hairline",children:n.map(a=>t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx("span",{className:a.title?"min-w-0 flex-1 truncate text-body-sm text-ink":"min-w-0 flex-1 truncate font-mono text-mono-sm text-ink-muted",children:$t(a)}),a.todos&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:Us(a.todos)})]},a.session_id))})]})},bc=/[/\\]/;function ba(e){if(e.name)return e.name;const s=e.path.split(bc);return s[s.length-1]||"Attachment"}const jc=({attachment:e})=>{const s=ba(e),n=Oi(e.bytes);return t.jsxs("div",{className:"flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-surface px-3 py-2",children:[t.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2.5 text-left",onClick:()=>{window.api?.openFile(e.path)},title:`Open ${s}`,children:[t.jsx(ir,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),t.jsx("span",{className:"truncate text-body-sm text-ink",children:s})]}),n&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:n}),t.jsx(or,{filePath:e.path,"aria-label":`File actions for ${s}`})]})},yc=({attachment:e})=>{const s=ba(e),n=tr(e.path,{mimeType:sr(e.name||e.path),sizeBytes:e.bytes});return n.status==="ready"?t.jsx("div",{className:"inline-block max-w-full",children:t.jsx(nr,{file:e.path,src:n.url,label:s,conversationId:""})}):n.status==="loading"?t.jsx(ar,{children:t.jsxs("span",{className:"sr-only",children:["Loading ",s]})}):t.jsx(rr,{name:s})},vc=({attachments:e})=>t.jsx("div",{className:"flex flex-wrap items-start gap-2",children:e.map(s=>s.kind==="image"?t.jsx(yc,{attachment:s},`${s.path}:${s.added_at}`):t.jsx(jc,{attachment:s},`${s.path}:${s.added_at}`))}),kc=({update:e,nowMs:s})=>{const n=$e(),a=Di(e,n,s);return t.jsxs("article",{className:"flex flex-col gap-2 rounded-sm px-2 py-3",children:[a.length>0&&t.jsx("p",{className:"flex flex-wrap items-baseline gap-x-2 text-meta text-ink-muted",children:a.map((r,i)=>t.jsxs(d.Fragment,{children:[i>0&&t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{children:r.text})]},r.key))}),e.text&&t.jsx(lt,{children:e.text}),e.attachments.length>0&&t.jsx(vc,{attachments:e.attachments})]})},wc=({updates:e,nowMs:s})=>{const n=$e(),a=Ti(e.length),r=Ai(e,n,new Date(s));return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"Updates"}),a&&t.jsx("span",{className:"text-meta text-ink-muted",children:a})]}),e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No updates yet. Progress reported by you or by the sessions working on this project is appended here."}):t.jsx("div",{className:"flex flex-col gap-4",children:r.map(i=>t.jsxs("div",{className:"flex flex-col gap-2",children:[i.label&&t.jsx("h3",{className:"text-meta text-ink-muted",children:i.label}),t.jsx("div",{className:"flex flex-col divide-y divide-hairline",children:i.entries.map((l,o)=>t.jsx(kc,{update:l,nowMs:s},`${l.at}:${l.by}:${o}`))})]},i.key||"ungrouped"))})]})},Nc="project_not_found",Sc=({projectKey:e,nowMs:s})=>{const n=Rt(),a=Ge(),r=yn(fe(a.data,"team_catalogue")),i=Dn(e,!0),l=An(),o=On(),c=si(),m=ni(),u=ei(),h=ti(),[b,f]=d.useState(!1),[j,v]=d.useState(!1),g=l.isPending||o.isPending||c.isPending||m.isPending||u.isPending||h.isPending;if(i.isLoading)return t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(ke,{label:"Loading project"})});if(i.isError||!i.data){const p=i.error instanceof Et&&(i.error.code===Nc||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:p?"This project could not be found. It may have been deleted.":i.error instanceof Error&&i.error.message?i.error.message:"The project could not be read."}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(U,{variant:"secondary",onClick:()=>void i.refetch(),children:"Try again"}),t.jsxs(U,{variant:"secondary",onClick:()=>void n("/projects"),children:[t.jsx(Ps,{}),"All projects"]})]})]})}const{project:x,links:y}=i.data,C=G(x),w=(p,A)=>l.mutateAsync({key:x.id,fields:p,...A?.forceDone===!0?{forceDone:!0}:{}}),L=x.team?r(x.team):null,T=$i(x.milestones.filter(p=>p.completed_at!==null).length,x.milestones.length),_=async(p,A,E,P)=>{const z=vt.getState(),I=cr(null,p,z.drafts);if(!I)return!1;try{const{images:B,unreadable:W,overflow:V}=await dr(P,A),oe=ur(W);if(oe)return le(oe),!1;const Q=mr(V);if(Q)return le(Q),!1;const X=fr(A,B);if(X)return le(X),!1;if(await hr(I,{text:A,attachments:P,images:B,mode:E,cwd:z.cwd},p)===null)return le("That session already has a message going out. Try again in a moment."),!1;const N=y.find(R=>R.session_id===p);return ve(`Sent to ${N?$t(N):p}`),!0}catch(B){return le(B instanceof Error&&B.message?B.message:"The message was not sent."),!1}},O=async p=>{const A=vt.getState(),E=p.kind==="plain"?void 0:{kind:p.kind,name:p.name},P=await A.createSession(A.cwd||"~",E);if(!P)throw new Error(A.error??"The session could not be started.");pr.getState().setCurrentInput(P,Ii(x));let z=null;try{await u.mutateAsync({key:x.id,sessionId:P})}catch(I){z=I instanceof Error&&I.message?I.message:"the link was refused"}if(z)le(`Session started, but linking it failed: ${z}`);else{const I=E?` with ${Li(E)}`:"";ve(`Session started${I} and linked to ${C}.`)}await En(n,P)};return t.jsx(Sl,{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 n("/projects"),className:"flex w-fit items-center gap-1.5 text-body-sm text-ink-muted hover:text-ink",children:[t.jsx(Ps,{className:"size-4"}),"All projects"]}),t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-start gap-x-3 gap-y-2",children:[t.jsx(Zl,{project:x,commit:w}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1.5",children:[t.jsx(ec,{project:x,commit:w}),x.progress_stale&&t.jsx(pe,{variant:"warning",children:kt})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(fc,{project:x}),t.jsxs(U,{variant:"secondary",onClick:()=>f(!0),"data-tour-tag":"project-delete",children:[t.jsx(lr,{}),"Delete"]})]})]})]}),t.jsx(tc,{project:x,commit:w}),t.jsx(mc,{project:x,nowMs:s,commit:w,teamLabel:L}),x.updates.length===0&&x.progress&&t.jsxs("section",{className:"flex flex-col gap-2",children:[t.jsx("h2",{className:"text-title text-ink",children:"Progress"}),t.jsx(lt,{className:"text-body",children:x.progress}),t.jsx("p",{className:"text-meta text-ink-muted",children:ci(x,s)})]}),t.jsx(dc,{milestones:x.milestones,summary:T,busy:g,onToggle:(p,A)=>{c.mutateAsync({key:x.id,name:p,completed:A}).catch(E=>{le(E instanceof Error&&E.message?E.message:"The milestone was not updated.")})},onRemove:p=>{m.mutateAsync({key:x.id,name:p}).catch(A=>{le(A instanceof Error&&A.message?A.message:"The milestone was not removed.")})},onAdd:(p,A)=>{c.mutateAsync({key:x.id,name:p,targetDate:A}).catch(E=>{le(E instanceof Error&&E.message?E.message:"The milestone was not added.")})}}),t.jsx(cc,{projectKey:x.id,links:y,busy:g,onStartSession:()=>v(!0),onQuickSend:_,onLink:p=>{u.mutateAsync({key:x.id,sessionId:p}).catch(A=>{le(A instanceof Error&&A.message?A.message:"The session was not linked.")})},onUnlink:p=>{h.mutateAsync({key:x.id,sessionId:p}).catch(A=>{le(A instanceof Error&&A.message?A.message:"The session was not unlinked.")})}}),t.jsx(gc,{links:y}),t.jsx(wc,{updates:x.updates,nowMs:s}),t.jsx(da,{open:b,projectName:x.name,onClose:()=>f(!1),onConfirm:async p=>{await o.mutateAsync({key:x.id,confirmedName:p}),ve("Project deleted"),n("/projects")}}),t.jsx(xc,{open:j,onClose:()=>v(!1),onStart:O,teamsEnabled:fe(a.data,"team_catalogue"),profilesEnabled:fe(a.data,"profile_catalogue")})]})})},hn={name:"",title:"",owner:"",team:"",description:"",status:"active",tags:"",startDate:"",targetDate:"",estimate:"",estimateUnit:"points"},Tc=({open:e,onClose:s,onSubmit:n})=>{const[a,r]=d.useState(hn),[i,l]=d.useState({}),[o,c]=d.useState(null),m=d.useRef(null),[u,h]=d.useState(!1),[b,f]=d.useState(!1),[j,v]=d.useState(!1),g=d.useId(),x=d.useRef(null);d.useEffect(()=>{e&&(r({...hn,description:on}),l({}),c(null),h(!1),f(!1),v(!1))},[e]),d.useEffect(()=>{o&&m.current?.scrollIntoView({block:"nearest"})},[o]);const y=(p,A)=>{r(E=>({...E,[p]:A}))},C=b?a.name:$l(a.title),w=p=>ma(p,x,A=>y("description",A)),L=(p,A)=>{const E={},P=Yt(A);P&&(E.name=P);const z=ta(p.description);z&&(E.description=z);const I=ts(p.tags).error;I&&(E.tags=I);const B=Zt(p.startDate);B&&(E.startDate=B);const W=Zt(p.targetDate);if(W)E.targetDate=W;else if(!B){const X=es(p.startDate,p.targetDate);X&&(E.targetDate=X)}if(p.estimate.trim()){const X=sa(p.estimate);X&&(E.estimate=X)}const V=Jt(p.title);V&&(E.title=V);const oe=St(p.owner,"owner");oe&&(E.owner=oe);const Q=St(p.team,"team");return Q&&(E.team=Q),E},T=async()=>{const p=C.trim(),A=L(a,p);if(l(A),Object.keys(A).length>0)return;h(!0),c(null);const E=ot(a.tags);try{const P={};a.title.trim()&&(P.title=a.title.trim()),a.owner.trim()&&(P.owner=a.owner.trim()),a.team.trim()&&(P.team=a.team.trim()),a.startDate&&(P.start_date=a.startDate),a.targetDate&&(P.target_date=a.targetDate),a.estimate&&(P.estimate=Number(a.estimate),P.estimate_unit=a.estimateUnit),await n({fields:{name:p,...a.description.trim()&&a.description.trim()!==on?{description:a.description.trim()}:{},status:a.status,...E.length>0?{tags:E}:{}},...Object.keys(P).length>0?{followUp:P}:{}}),s()}catch(P){const z=P instanceof Error&&P.message?P.message:"";c(ft(z)||"The project was not saved.")}finally{h(!1)}},_="New project",O=a.description.length>Ue;return t.jsx(ct,{open:e,onClose:s,title:_,fullWidth:!0,maxWidth:"md",dialogProps:{closeDisabled:u,onEscapeKeyDown:p=>{u&&p.preventDefault()},onInteractOutside:p=>{u&&p.preventDefault()}},dataTourTag:"project-create-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Be,{onClick:s,disabled:u,children:"Cancel"}),t.jsxs(yt,{"data-project-submit":"",onClick:()=>void T(),disabled:u,children:[u&&t.jsx(ke,{size:"xs"}),"Create project"]})]}),children:t.jsxs("form",{className:"flex flex-col gap-6 px-1 py-1",onSubmit:p=>{p.preventDefault(),T()},children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(ie,{htmlFor:`${g}-title`,children:"Title"}),t.jsx(ne,{id:`${g}-title`,"data-project-title":"",value:a.title,onChange:p=>y("title",p.target.value),placeholder:"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(ie,{htmlFor:`${g}-key`,className:"shrink-0 text-meta text-ink-muted",children:"Key"}),t.jsx(ne,{id:`${g}-key`,"data-project-key":"",value:C,onChange:p=>{f(!0),y("name",p.target.value)},placeholder:"payments-migration","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:b?"Letters, digits, dot, underscore or dash; no spaces.":"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(ie,{htmlFor:`${g}-description`,children:"Description"}),t.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:"Description mode"}),t.jsx("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:["write","preview"].map(p=>t.jsx("button",{type:"button","data-project-description-mode":p,"aria-pressed":j===(p==="preview"),onClick:()=>v(p==="preview"),className:$("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",j===(p==="preview")&&"bg-surface text-ink"),children:p==="write"?"Write":"Preview"},p))})]})]}),j?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(lt,{className:"text-body-sm",children:a.description}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:"Nothing to preview yet."})}):t.jsx(Sn,{ref:x,id:`${g}-description`,"data-project-description":"",value:a.description,onChange:p=>y("description",p.target.value),onPaste:w,rows:8,placeholder:"Markdown — headings, lists, code.","aria-invalid":O||!!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:$("text-meta tabular-nums",O?"text-danger":"text-ink-muted"),children:[a.description.length,"/",Ue]})]})]}),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(ie,{children:"Status"}),t.jsxs(ze,{value:a.status,onValueChange:p=>y("status",p),children:[t.jsx(Ye,{"aria-label":"Status",children:t.jsx(He,{})}),t.jsx(We,{children:Pn.map(p=>t.jsx(Te,{value:p.value,children:p.label},p.value))})]}),a.status==="done"&&t.jsx("p",{className:"text-meta text-ink-muted",children:"Moving a project to Done stamps today as its completion date."})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(ie,{htmlFor:`${g}-owner`,children:"Owner"}),t.jsx(ne,{id:`${g}-owner`,"data-project-owner":"",value:a.owner,onChange:p=>y("owner",p.target.value),placeholder:"atlas","aria-invalid":!!i.owner}),i.owner&&t.jsx("p",{className:"text-meta text-danger",children:i.owner})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(ie,{htmlFor:`${g}-team`,children:"Team"}),t.jsx(ne,{id:`${g}-team`,value:a.team,onChange:p=>y("team",p.target.value),placeholder:"platform","aria-invalid":!!i.team}),i.team&&t.jsx("p",{className:"text-meta text-danger",children:i.team})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(ie,{htmlFor:`${g}-target`,children:"Target date"}),t.jsx(ne,{id:`${g}-target`,"data-project-target":"",value:a.targetDate,onChange:p=>y("targetDate",p.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(ie,{htmlFor:`${g}-start`,children:"Start date"}),t.jsx(ne,{id:`${g}-start`,value:a.startDate,onChange:p=>y("startDate",p.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(ie,{htmlFor:`${g}-estimate`,children:"Estimate"}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ne,{id:`${g}-estimate`,value:a.estimate,onChange:p=>y("estimate",p.target.value),placeholder:"13",inputMode:"decimal","aria-invalid":!!i.estimate,className:"max-w-28"}),t.jsxs(ze,{value:a.estimateUnit,onValueChange:p=>y("estimateUnit",p),children:[t.jsx(Ye,{"aria-label":"Estimate unit",className:"max-w-32",children:t.jsx(He,{})}),t.jsxs(We,{children:[t.jsx(Te,{value:"points",children:"Points"}),t.jsx(Te,{value:"days",children:"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(ie,{htmlFor:`${g}-tags`,children:"Tags"}),t.jsx(ne,{id:`${g}-tags`,value:a.tags,onChange:p=>y("tags",p.target.value),placeholder:"q4, payments","aria-invalid":!!i.tags}),i.tags?t.jsx("p",{className:"text-meta text-danger",children:i.tags}):t.jsx("p",{className:"text-meta text-ink-muted",children:"Comma-separated, up to 8. Lowercase letters, digits, underscore or dash."})]})]}),o&&t.jsx("p",{ref:m,className:"text-body-sm text-danger",children:o})]})})},ja=({children:e})=>{const s=d.useRef(null),[n,a]=d.useState(!1),r=()=>{const i=s.current;i&&a(i.scrollTop+i.clientHeight<i.scrollHeight-1)};return d.useEffect(r),t.jsx("div",{ref:s,onScroll:r,className:$("max-h-[min(70vh,32rem)] overflow-y-auto overscroll-contain",n&&"[mask-image:linear-gradient(to_bottom,black_calc(100%-12px),transparent)]"),children:e})},_c=({label:e,count:s,selected:n,onToggle:a})=>{const r=d.useId();return t.jsxs("div",{className:"flex items-center gap-2 rounded-sm px-1 py-1 hover:bg-sunken",children:[t.jsx(_n,{id:r,checked:n,onCheckedChange:()=>a()}),t.jsx(ie,{htmlFor:r,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})]})},Cc=({column:e,spec:s,onChange:n})=>{const a=d.useId(),r=s!==null&&s.key===e,i=r?s.direction:Lt(e),l=i==="asc"?"desc":"asc",o=()=>n({key:e,direction:r?l:Lt(e)}),c=s===null?"default":r?"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:`Sort by ${Ke(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:c==="default",onChange:()=>n(null),className:"m-0 size-3.5 shrink-0 accent-[var(--color-accent)]"}),t.jsx("span",{className:$("min-w-0 flex-1 truncate",c==="default"?"text-ink":"text-ink-muted"),children:go})]}),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:c==="sorted",onChange:o,onClick:()=>{c==="sorted"&&o()},onKeyDown:m=>{c==="sorted"&&(m.key!==" "&&m.key!=="Enter"||(m.preventDefault(),o()))},className:"m-0 size-3.5 shrink-0 accent-[var(--color-accent)]"}),t.jsx("span",{className:$("min-w-0 flex-1 truncate",c==="sorted"?"text-ink":"text-ink-muted"),children:`Sort by ${Ke(e)}, ${js(e,r?i:Lt(e))}`})]})]})},Ec=({facet:e,options:s,onToggle:n})=>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:at[e]}),s.map(a=>t.jsx(_c,{label:a.label,count:a.count,selected:a.selected,onToggle:()=>n(e,a.value)},`${e}:${a.value??"none"}`))]}),ya=({projects:e,state:s,query:n,todayMs:a,onToggle:r,onClearAll:i,scope:l,sort:o})=>{const c=d.useMemo(()=>l===void 0?xo(e,s,a):l===null?[]:[ea(l,e,s,a)],[l,e,s,a]),m=!it(s)||n.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:"Filters"}),m&&t.jsx(U,{variant:"link",size:"sm",onClick:i,children:"Clear all"})]}),o&&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:`Sort by ${Ke(o.key)}`}),t.jsx(Cc,{column:o.key,spec:o.spec,onChange:o.onChange})]}),c.map(u=>t.jsx(Ec,{facet:u.facet,options:u.options,onToggle:r},u.facet))]})},Rc=({team:e,count:s,headingId:n,className:a,...r})=>t.jsxs("div",{...r,className:$("flex h-8 cursor-default items-center gap-2 bg-surface px-3 text-meta",a),children:[t.jsx("h3",{id:n,className:"truncate text-ink",children:e??ps}),t.jsx("span",{className:"shrink-0 text-ink-muted","aria-label":ui(s),children:s})]}),ye=[{key:"name",label:"Project",className:"min-w-0 flex-1",sort:"name",facet:null},{key:"status",label:"Status",className:"w-20 shrink-0",sort:"status",facet:"status"},{key:"target",label:"Target",className:"hidden w-32 shrink-0 @[40rem]:block",sort:"target",facet:"target"},{key:"estimate",label:"Estimate",className:"hidden w-16 shrink-0 @[40rem]:block",sort:"estimate",facet:"estimate"},{key:"milestones",label:"Milestones",className:"hidden w-20 shrink-0 @[34rem]:block",sort:"milestones",facet:"milestones"},{key:"live",label:"Live",className:"hidden w-14 shrink-0 @[34rem]:block",sort:"live",facet:"live"},{key:"progress",label:"Progress",className:"w-40 shrink-0",sort:"progress",facet:"progress"}];function Dc(e,s){const n=dt(e.progress_updated_at,s);return n?ut(n):"not reported"}const Ac=({direction:e})=>e==="asc"?t.jsx(Rn,{size:10,className:"shrink-0","aria-hidden":"true"}):t.jsx(vn,{size:10,className:"shrink-0","aria-hidden":"true"}),Oc=({projects:e,nowMs:s,onOpen:n,sort:a,onSortChange:r,searchPopulation:i,filters:l,query:o,todayMs:c,onToggleFilter:m,onClearFilters:u,teamLabelFor:h=b=>b})=>{const b=$e(),f=a?To(e,a):e,j=xs(f,mt),v=d.useId(),g=T=>`${v}-team-${T}`,[x,y]=d.useState(0),C=d.useRef([]),w=(T,_)=>{const O=ye.length;for(let p=1;p<=O;p+=1){const A=(T+_*p+O*O)%O,E=C.current[A];if(E&&E.offsetParent!==null){y(A),E.focus();return}}},L=T=>_=>{_.key!=="ArrowLeft"&&_.key!=="ArrowRight"||(_.preventDefault(),w(T,_.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":"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:ye.map((T,_)=>{const O=a!==null&&a.key===T.sort;return t.jsx("th",{scope:"col","aria-sort":O?a.direction==="desc"?"descending":"ascending":"none",className:$(T.className,"p-0 text-left font-normal"),children:t.jsxs(ds,{children:[t.jsx(us,{asChild:!0,children:t.jsxs("button",{type:"button",ref:p=>{C.current[_]=p},tabIndex:_===x?0:-1,"data-project-column":T.key,onFocus:()=>y(_),onKeyDown:L(_),className:$("group flex w-full min-w-0 items-center gap-1 rounded-xs text-left","transition-colors duration-fast ease-out-quart",O?"text-ink":"hover:text-ink"),children:[t.jsx("span",{className:"truncate",children:T.label}),O?t.jsx(Ac,{direction:a.direction}):t.jsx(xr,{size:10,className:"shrink-0 text-ink-dim transition-colors duration-fast ease-out-quart group-hover:text-ink","aria-hidden":"true"})]})}),t.jsx(ms,{align:"start","aria-label":`${T.label} column`,className:"w-72 p-0",children:t.jsx(ja,{children:t.jsx(ya,{projects:i,state:l,query:o,todayMs:c,onToggle:m,onClearAll:u,scope:T.facet,sort:{key:T.sort,spec:a,onChange:r}})})})]})},T.key)})})})}),t.jsx("ul",{className:"min-h-0 flex-1 overflow-y-auto px-6",children:j.map((T,_)=>t.jsxs("li",{children:[t.jsx(Rc,{team:T.team==null?null:h(T.team),count:T.items.length,headingId:g(_),className:"sticky top-0 z-10","data-project-team":T.team??""}),t.jsx("ul",{"aria-labelledby":g(_),className:"divide-y divide-hairline",children:T.items.map(O=>{const p=new Map(qn(O,b).map(P=>[P.key,P.text])),A=Fn(O.milestones_completed,O.milestones_total),E=hs(O.live_sessions);return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>n(O),"data-project-name":O.name,className:$("flex w-full items-center gap-3 px-3 py-2 text-left","transition-colors duration-fast ease-out-quart","hover:bg-elevated"),children:[t.jsx("span",{className:$(ye[0].className,"truncate text-body-sm text-ink"),children:G(O)}),t.jsx("span",{className:ye[1].className,children:t.jsx(ha,{status:O.status})}),t.jsx("span",{className:$(ye[2].className,"truncate text-meta text-ink-muted"),children:p.get("target")??p.get("completed")??""}),t.jsx("span",{className:$(ye[3].className,"truncate text-meta text-ink-muted"),children:p.get("estimate")??""}),t.jsx("span",{className:$(ye[4].className,"truncate text-meta text-ink-muted"),children:A}),t.jsx("span",{className:$(ye[5].className,"truncate text-meta text-ink-muted"),children:E}),t.jsxs("span",{className:$(ye[6].className,"flex items-center gap-2"),children:[t.jsx("span",{className:"truncate text-meta text-ink-muted",children:Dc(O,s)}),O.progress_stale&&t.jsx(pe,{variant:"warning",children:kt})]})]})},O.id)})})]},T.team??""))})]})},Ct=224,pn=36,$c={day:"Days",week:"Weeks",month:"Months",quarter:"Quarters"},Pc=({items:e,nowMs:s,onOpen:n,pendingDetails:a,failedDetails:r,onRetryDetails:i,teamLabelFor:l=o=>o})=>{const[o,c]=d.useState(null),[m,u]=d.useState(0),h=d.useRef(null),b=vs(s),f=d.useMemo(()=>Eo(e,b),[e,b]),j=d.useMemo(()=>Ro(e),[e]),v=d.useMemo(()=>xs(j.dated,T=>mt(T.project)),[j]);d.useLayoutEffect(()=>{const T=h.current;if(!T)return;const _=()=>u(T.clientWidth);if(_(),typeof ResizeObserver>"u")return;const O=new ResizeObserver(_);return O.observe(T),()=>O.disconnect()},[]);const g=Math.max(m-Ct-24,160),x=f?_o(Gs(f.startMs,f.endMs),g):"month",y=o??x,C=T=>{const _=Se.indexOf(y),O=Se[_-T];O&&c(O)},w=ys[y],L=f?Gs(f.startMs,f.endMs)*w:0;return t.jsxs("div",{ref:h,className:"flex min-h-0 flex-1 flex-col","data-testid":"project-timeline",children:[t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 px-9 py-2",children:[t.jsx("span",{className:"truncate text-meta text-ink-muted","data-timeline-note":!0,children:r>0?`Milestones could not be read for ${r} project${r===1?"":"s"}.`:`${j.dated.length} dated · ${j.undated.length} without dates${a>0?` · loading milestones for ${a}…`:""}`}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[r>0&&t.jsx(U,{variant:"secondary",size:"sm",onClick:i,children:"Try again"}),t.jsx(U,{variant:"secondary",size:"icon","aria-label":"Zoom in",title:"Zoom in (finer)",disabled:!f||y===Se[0],onClick:()=>C(1),children:t.jsx(rt,{})}),t.jsx("span",{className:"w-16 text-center text-meta text-ink-muted",children:$c[y]}),t.jsx(U,{variant:"secondary",size:"icon","aria-label":"Zoom out",title:"Zoom out (coarser)",disabled:!f||y===Se[Se.length-1],onClick:()=>C(-1),children:t.jsx(Cr,{})})]})]}),f&&j.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(Mc,{startMs:f.startMs,endMs:f.endMs,tier:y,pxPerDay:w,trackPx:L}),v.map(T=>t.jsxs("div",{children:[t.jsx("div",{className:"sticky top-0 z-20 flex items-stretch bg-canvas","data-project-team":T.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:Ct},children:[t.jsx("span",{className:"truncate text-ink",children:T.team==null?ps:l(T.team)}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:T.items.length})]})}),T.items.map(_=>t.jsx(Ic,{item:_,spanStart:f.startMs,pxPerDay:w,trackPx:L,today:b,onOpen:()=>n(_)},_.project.id))]},T.team??""))]})}):null,j.undated.length>0&&t.jsx("div",{className:"shrink-0 px-9 py-2","data-project-undated-callout":"",children:t.jsxs(jn,{defaultOpen:j.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(Br,{size:14,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),t.jsx("span",{className:"truncate text-ink",children:Do(j.undated.length)})]}),children:[j.dated.length===0&&t.jsx("p",{className:"pb-1 text-meta text-ink-muted",children:"Set a start date, a target date or a milestone date and it will appear on the timeline."}),t.jsx("ul",{className:"flex max-h-24 flex-wrap gap-x-3 gap-y-1 overflow-y-auto",children:j.undated.map(T=>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:()=>n(T),children:G(T.project)})},T.project.id))})]})})]})},Mc=({startMs:e,endMs:s,tier:n,pxPerDay:a,trackPx:r})=>{const i=qo(e,s,n);return t.jsxs("div",{className:"flex items-stretch",children:[t.jsx("span",{className:"sticky left-0 z-10 shrink-0 bg-canvas",style:{width:Ct}}),t.jsx("span",{className:"relative block h-6",style:{width:r},children:i.map(l=>t.jsxs("span",{className:"absolute top-0 h-full",style:{left:De(e,l.dayMs)*a},children:[t.jsx("span",{className:$("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))})]})},Ic=({item:e,spanStart:s,pxPerDay:n,trackPx:a,today:r,onOpen:i})=>{const{project:l}=e,o=Ao(e),c=Oo(e),m=u=>new Date(u).toISOString().slice(0,10);return t.jsxs("button",{type:"button",onClick:i,"data-project-name":l.name,className:"flex w-full items-stretch text-left transition-colors duration-fast ease-out-quart hover:bg-elevated",children:[t.jsx("span",{className:"sticky left-0 z-10 flex shrink-0 items-center gap-2 border-r border-hairline bg-canvas px-3",style:{width:Ct,height:pn},children:t.jsx("span",{className:"truncate text-body-sm text-ink",children:G(l)})}),t.jsxs("span",{className:"relative block",style:{width:a,height:pn},children:[o&&t.jsx("span",{className:"absolute top-1/2 h-1.5 -translate-y-1/2 rounded-full bg-accent/75",style:{left:De(s,o.fromMs)*n,width:(De(o.fromMs,o.toMs)+1)*n},title:`${_e(m(o.fromMs))} → ${_e(m(o.toMs))}`}),c.map(u=>t.jsx("span",{"data-milestone":u.status,className:$("absolute top-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rotate-45",u.status==="completed"&&"bg-success",u.status==="overdue"&&"bg-warning",u.status==="upcoming"&&"border-[1.5px] border-ink-muted bg-surface"),style:{left:De(s,u.dayMs)*n},title:`${u.name} · ${u.status} · ${_e(m(u.dayMs))}`},`${u.name}-${u.dayMs}`)),t.jsx("span",{className:"absolute inset-y-0 w-px bg-accent/75",style:{left:De(s,r)*n},"aria-hidden":"true"})]})]})},Lc=({projects:e,query:s,onQueryChange:n,filters:a,onFiltersChange:r,onClearAll:i,todayMs:l,resultText:o,countRevealClass:c="@[37rem]:inline",trailing:m,disabled:u=!1,searchFieldRef:h})=>{const[b,f]=d.useState(!1),j=d.useRef(!1),v=mo(a),g=Cn(o??"",300),x=s.trim()!==""||!it(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(gr,{size:16,className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim","aria-hidden":"true"}),t.jsx(ne,{ref:h,inputSize:"sm",value:s,onChange:y=>n(y.target.value),onKeyDown:y=>{y.key==="Escape"&&(s?n(""):y.currentTarget.blur())},placeholder:"Search projects","aria-label":"Search projects",autoComplete:"off",spellCheck:!1,className:"pl-9"}),s?t.jsx(U,{variant:"ghost",size:"icon-sm",className:"absolute top-1/2 right-1 -translate-y-1/2",onClick:()=>br(h.current,n),"aria-label":"Clear search",children:t.jsx(Dt,{"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(jr,{shortcut:"/"})})]}),t.jsxs(ds,{open:b,onOpenChange:f,children:[t.jsx(us,{asChild:!0,children:t.jsxs(U,{variant:"secondary",size:"sm",disabled:u,"data-project-filters-button":"",children:[t.jsx(Wr,{size:14,"aria-hidden":"true"}),"Filters",v>0&&t.jsx(pe,{variant:"neutral",children:v})]})}),t.jsx(ms,{align:"end","aria-label":"Filters",className:"w-80 p-0",onCloseAutoFocus:y=>{j.current&&(j.current=!1,y.preventDefault())},children:t.jsx(ja,{children:t.jsx(ya,{projects:e,state:a,query:s,todayMs:l,onToggle:(y,C)=>r(Xn(a,y,C)),onClearAll:()=>{i(),j.current=!0,f(!1),h.current?.focus()}})})})]}),x&&o!==null&&t.jsx("span",{className:$("hidden whitespace-nowrap text-meta text-ink-dim",c),"data-project-count":"",children:o}),t.jsx("output",{className:"sr-only","aria-live":"polite",children:g}),m]})},Fc=({filters:e,sort:s,onFiltersChange:n,onSortChange:a,onClearAll:r,hideClearAll:i=!1,searchFieldRef:l})=>{const[o,c]=d.useState(null);d.useEffect(()=>{if(!o)return;let h=null;o.kind==="search"?h=l.current:(h=document.querySelector(`[data-project-chip="${o.index}"]`),h||(h=document.querySelector("[data-project-chip]")),h||(h=document.querySelector("[data-project-filters-button]"))),h&&(h.focus(),c(null))});const m=[];for(const h of Qe){const b=e[h];if(b.length===0)continue;const f=b.map(g=>Qn(h,g)),j=f[0],v=f.length>1?`${at[h]} · ${j} +${f.length-1}`:`${at[h]} · ${j}`;m.push({kind:"facet",facet:h,label:v,ariaLabel:`Remove filter: ${at[h]} · ${f.join(", ")}`,clear:()=>n({...e,[h]:[]})})}if(s&&m.push({kind:"sort",spec:s,label:`Sort: ${Ke(s.key)}`,ariaLabel:`Remove sort: ${Ke(s.key)}, ${js(s.key,s.direction)}`,clear:()=>a(null)}),m.length===0)return null;const u=(h,b)=>{b.clear();const f=m.length-1;c(f===0?{kind:"chip",index:0}:{kind:"chip",index:Math.min(h,f-1)})};return t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[m.map((h,b)=>t.jsx(pe,{asChild:!0,variant:"neutral",className:"gap-1 pr-1 text-ink",children:t.jsxs("button",{type:"button",className:"group","data-project-chip":b,"aria-label":h.ariaLabel,onClick:()=>u(b,h),children:[h.kind==="sort"&&(h.spec.direction==="asc"?t.jsx(Rn,{size:10,className:"text-ink-muted","aria-hidden":"true"}):t.jsx(vn,{size:10,className:"text-ink-muted","aria-hidden":"true"})),t.jsx("span",{className:"truncate",children:h.label}),t.jsx(Dt,{className:$("text-ink-dim transition-colors duration-fast ease-out-quart","group-hover:text-danger"),"aria-hidden":"true"})]})},h.kind==="facet"?h.facet:"sort")),!i&&t.jsx(U,{variant:"link",size:"sm",onClick:()=>{r(),c({kind:"search"})},children:"Clear all"})]})},va="projects-view",qc=[{value:"list",label:"List"},{value:"board",label:"Board"},{value:"timeline",label:"Timeline"}];function Uc(){try{const e=localStorage.getItem(va);if(e==="board"||e==="timeline"||e==="list")return e}catch{}return"board"}function Bc(e){try{localStorage.setItem(va,e)}catch{}}const zc=({value:e,onChange:s})=>t.jsx(Er,{value:e,onValueChange:n=>s(n),children:t.jsx(Rr,{"aria-label":"Project view","data-tour-tag":"projects-view-switcher",children:qc.map(n=>t.jsx(Dr,{value:n.value,children:n.label},n.value))})}),Yc=["r1","r2","r3","r4","r5","r6"],Hc=4e3,xn={unpaired:"This app is not paired with the Local Operator server, so Projects are unavailable.","below-version":"The Local Operator server is older than this app expects, so Projects are unavailable. Update the server and try again.",unknown:"The server's capabilities could not be read, so Projects are unavailable."},ed=({nowMs:e=Date.now()})=>{const{projectId:s}=yr(),n=Rt(),a=Ge(),r=vr(a.data,"projects",1),i=r==="enabled",l=fe(a.data,"projects",Ki),o=yn(fe(a.data,"team_catalogue")),c=Xr(i),m=Zr(),u=An(),h=On(),[b,f]=d.useState(!1),[j,v]=d.useState(()=>Uc()),[g,x]=d.useState(()=>yi()),[y,C]=d.useState(null),[w,L]=d.useState(""),[T,_]=d.useState(Ys),[O,p]=d.useState(()=>yo()),[A,E]=d.useState(""),P=d.useRef(""),z=d.useRef(null),I=d.useRef(null),B=S=>{z.current!==null&&(window.cancelAnimationFrame(z.current),z.current=null),S!==""&&S===P.current?(E(""),z.current=window.requestAnimationFrame(()=>{z.current=null,E(S)})):E(S),P.current=S,I.current!==null&&window.clearTimeout(I.current),I.current=window.setTimeout(()=>{I.current=null,P.current="",E("")},Hc)},W=()=>{z.current!==null&&(window.cancelAnimationFrame(z.current),z.current=null),I.current!==null&&(window.clearTimeout(I.current),I.current=null),P.current="",E("")},V=S=>{L(S),W()},oe=S=>{_(S),W()},Q=d.useRef(null),X=ll(),k=c.data??[],N=vs(e),R=io(w,i&&l),M=Vn(w),F=d.useMemo(()=>R.answer?ao(k,R.answer.projects):null,[k,R.answer]),q=M!=="",ae=d.useMemo(()=>q?F??no(k,M):k,[k,M,q,F]),Ce=F===null?"client":"backend",Y=d.useMemo(()=>fo(ae,T,N),[ae,T,N]),we=l&&q&&R.pending,xe=q||!it(T),me=d.useMemo(()=>Ls(k,g,e),[k,g,e]),J=d.useMemo(()=>Ls(Y,g,e),[Y,g,e]),Ee=ji(g),re=j==="board"?J.length:Y.length,Je=!xe||!c.isSuccess?null:j==="board"?`${J.length} of ${me.length} in window`:`${Y.length} of ${k.length} projects`,ee=c.isSuccess&&k.length>0,Ne=ee&&xe&&re===0&&!we,Me=we&&re===0&&ee,[Mt,Ze]=d.useState(!1);d.useEffect(()=>{if(!Mt)return;const S=document.querySelector('[data-tour-tag="projects-board-window"]');S&&(S.focus(),Ze(!1))}),d.useEffect(()=>{if(!i||s)return;const S=H=>{const K=H.target;if(!K||K.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(K.tagName)||K.closest('[role="dialog"]'))return;const je=H.key==="/"&&!H.metaKey&&!H.ctrlKey&&!H.altKey,se=(H.metaKey||H.ctrlKey)&&H.key.toLowerCase()==="f";!je&&!se||(H.preventDefault(),Q.current?.focus())};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[i,s]);const et=d.useRef(null);d.useLayoutEffect(()=>{if(!s)return;const S=et.current;S!==null&&(S.scrollTop=0)},[s]);const pt=Jr(j==="timeline"?k.map(S=>S.id):[],i),D=new Map(k.map((S,H)=>[S.id,pt[H]])),te=Y.map(S=>({project:S,milestones:D.get(S.id)?.data?.project.milestones??[]})),tt=j==="timeline"?Y.filter(S=>D.get(S.id)?.isLoading).length:0,ge=j==="timeline"?Y.filter(S=>D.get(S.id)?.isError).length:0,xt=()=>{for(const S of pt)S.isError&&S.refetch()},Ie=S=>{p(S),vo(S),B(ko(S))},ka=(S,H)=>{_(K=>Xn(K,S,H)),W()},gt=()=>{const S=w.trim()!=="",H=!it(T),K=O!==null;L(""),_(Ys),O!==null&&Ie(null),B(wo({search:S,filters:H,sort:K}))},Ns=()=>{x("all"),Fs("all"),Ze(!0)},[be,Ss]=d.useState(null),It=d.useRef(!1),Ts=()=>{It.current=!1,Ss(null)},[wa,_s]=d.useState([]),Na=fe(a.data,"projects_force_done"),Sa=(S,H)=>{const K=S.id,je=Z(H).label;_s(se=>se.includes(K)?se:[...se,K]),Ho({move:()=>u.mutateAsync({key:K,fields:{status:H}}),forceDoneOffered:Na,claimQuestion:()=>It.current?!1:(It.current=!0,!0)}).then(se=>{if(se.kind==="accepted"){ve(`Moved to ${je}`),c.refetch().then(()=>X(K));return}if(se.kind==="question"){Ss({project:S,status:H,refusal:se.refusal});return}le(se.copy,se.refusal?{action:{label:"View project",onClick:()=>void n(`/projects/${K}`)}}:void 0),X(K)}).finally(()=>{_s(se=>se.filter(Ta=>Ta!==K))})};return i?s?t.jsx("div",{ref:et,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(Sc,{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($s,{title:"Projects",icon:Ms,subtitle:"Workstreams you and your agents track across sessions.",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(U,{variant:"secondary",size:"icon","aria-label":"Refresh projects",title:"Refresh projects",disabled:c.isFetching,onClick:()=>void c.refetch(),"data-tour-tag":"refresh-projects-button",children:t.jsx(Pr,{})}),t.jsxs(U,{variant:"secondary",onClick:()=>f(!0),"data-tour-tag":"create-project-button",children:[t.jsx(rt,{}),"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(zc,{value:j,onChange:S=>{v(S),Bc(S)}}),t.jsx(Lc,{projects:ae,query:w,onQueryChange:V,filters:T,onFiltersChange:oe,onClearAll:gt,todayMs:N,resultText:Je,countRevealClass:j==="board"?"@[47rem]:inline":void 0,disabled:c.isError,searchFieldRef:Q,trailing:j==="board"&&!(c.isSuccess&&c.data.length===0)?t.jsx(Ko,{value:g,onChange:S=>{x(S),Fs(S)}}):null})]}),t.jsx(Fc,{filters:T,sort:O,onFiltersChange:oe,onSortChange:Ie,onClearAll:gt,hideClearAll:Ne,searchFieldRef:Q}),t.jsx("output",{"data-project-announcement":"",className:"sr-only","aria-live":"polite",children:A})]})]}),t.jsxs("div",{className:"mt-8 flex min-h-0 flex-1 flex-col",children:[c.isLoading&&t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("output",{className:"px-9 py-2 text-meta text-ink-dim",children:"Loading projects…"}),Yc.map(S=>t.jsxs("div",{className:"flex items-center gap-3 px-9 py-2","aria-hidden":"true",children:[t.jsx(Le,{className:"h-4 min-w-0 flex-1 bg-elevated"}),t.jsx(Le,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(Le,{className:"h-4 w-32 shrink-0 bg-elevated"}),t.jsx(Le,{className:"h-4 w-16 shrink-0 bg-elevated"}),t.jsx(Le,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(Le,{className:"h-4 w-40 shrink-0 bg-elevated"})]},S))]}),c.isError&&t.jsxs("div",{className:"flex flex-col items-start gap-2 px-6",children:[t.jsx(Ht,{variant:"danger",children:c.error instanceof Error&&c.error.message?c.error.message:"The projects could not be read."}),t.jsx(U,{variant:"secondary",size:"sm",onClick:()=>void c.refetch(),children:"Try again"})]}),c.isSuccess&&c.data.length===0&&t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-4",children:[t.jsx("p",{className:"text-heading text-ink",children:"No projects yet."}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:"Create one here, or ask an agent to create one and link this session."}),t.jsxs(U,{variant:"primary",onClick:()=>f(!0),"data-tour-tag":"create-project-empty-button",children:[t.jsx(rt,{}),"New project"]})]}),Me&&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:"Searching…"})}),ee&&Ne&&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()?`No projects match "${w.trim()}".`:"No projects match."}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:w.trim()?Wi[Ce]:"Try removing a filter. Clearing the filters restores the list."}),t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(U,{variant:"secondary",onClick:()=>{gt(),Q.current?.focus()},children:"Clear all"}),j==="board"&&Y.length>0&&t.jsx(U,{variant:"secondary",onClick:Ns,children:"Show all time"})]})]}),ee&&!Ne&&!Me&&j==="list"&&t.jsx(Oc,{projects:Y,nowMs:e,onOpen:S=>void n(`/projects/${S.id}`),sort:O,onSortChange:Ie,searchPopulation:ae,filters:T,query:w,todayMs:N,onToggleFilter:ka,onClearFilters:gt,teamLabelFor:o}),ee&&!Ne&&j==="board"&&J.length>0&&t.jsx(dl,{projects:J,nowMs:e,onOpen:S=>void n(`/projects/${S.id}`),onEdit:S=>void n(`/projects/${S.id}`),onDelete:C,onMove:Sa,teamLabelFor:o,movingKeys:wa}),ee&&!Ne&&!Me&&j==="board"&&J.length===0&&Ee!==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:Ee}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:"Older projects are hidden by the window."}),t.jsx(U,{variant:"secondary",onClick:Ns,children:"Show all time"})]}),ee&&!Ne&&!Me&&j==="timeline"&&t.jsx(Pc,{items:te,nowMs:e,onOpen:S=>void n(`/projects/${S.project.id}`),pendingDetails:tt,failedDetails:ge,onRetryDetails:xt,teamLabelFor:o})]}),t.jsx(da,{open:y!==null,projectName:y?.name??"",onClose:()=>C(null),onConfirm:async S=>{y&&(await h.mutateAsync({key:y.id,confirmedName:S}),ve("Project deleted"),C(null))}}),t.jsx(fa,{open:be!==null,refusal:be?.refusal??null,projectLabel:be?G(be.project):"",onClose:()=>{be&&X(be.project.id),Ts()},onConfirm:async()=>{if(!be)return;const{project:S,status:H,refusal:K}=be,je=await u.mutateAsync({key:S.id,fields:{status:H},forceDone:!0});ve(Gn(je,K.count,Z(H).label)),c.refetch().then(()=>X(S.id))},secondaryLabel:"Open project",onSecondary:()=>{const S=be?.project.id;Ts(),S&&n(`/projects/${S}`)}}),t.jsx(Tc,{open:b,onClose:()=>f(!1),onSubmit:async S=>{const H=await m.mutateAsync(S.fields),K=S.followUp?.title??S.fields.name;if(S.followUp)try{await u.mutateAsync({key:H.id,fields:S.followUp})}catch(je){const se=je instanceof Error&&je.message?je.message:"";le(`Project ${K} was created, but the extra fields were not saved: ${ft(se)||"the server refused them."} Open the project to set them in place.`);return}ve(`Project ${K} created`)}})]}):t.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[t.jsx($s,{title:"Projects",icon:Ms}),a.isLoading?t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(ke,{label:"Checking the server's Projects support"})}):t.jsx(Ht,{variant:"warning",children:xn[r]??xn.unknown})]})};export{ed as ProjectsPage};
|
|
50
|
+
`).trim()}function ma(e,s,n){const a=e.clipboardData?.getData("text/html");if(!a)return;const r=Jl(a);if(!r)return;e.preventDefault();const i=e.currentTarget,l=i.selectionStart??i.value.length,o=i.selectionEnd??l;n(i.value.slice(0,l)+r+i.value.slice(o)),requestAnimationFrame(()=>{const c=s.current;if(!c)return;const m=l+r.length;c.setSelectionRange(m,m)})}const fa=({open:e,refusal:s,projectLabel:n,onClose:a,onConfirm:r,secondaryLabel:i,onSecondary:l})=>{const[o,c]=d.useState(!1),[m,u]=d.useState(null),h=d.useRef(!1),b=d.useRef(null);d.useEffect(()=>{e&&(c(!1),u(null),h.current=!1)},[e]);const f=async()=>{if(!h.current){h.current=!0,c(!0),u(null);try{await r(),a()}catch(v){u({copy:aa(v),gone:na(v)})}finally{h.current=!1,c(!1)}}},j=s?.names??[];return t.jsx(ct,{open:e,onClose:a,title:"Mark done with open milestones?",dataTourTag:"project-done-anyway-dialog",maxWidth:"xs",dialogProps:{closeDisabled:o,onEscapeKeyDown:v=>{o&&v.preventDefault()},onInteractOutside:v=>{o&&v.preventDefault()},onOpenAutoFocus:v=>{v.preventDefault(),b.current?.focus()}},actions:t.jsxs("div",{className:"flex w-full min-w-0 flex-wrap justify-end gap-2",children:[t.jsx(Be,{ref:b,onClick:a,disabled:o,children:"Cancel"}),!m?.gone&&t.jsx(Be,{onClick:l,disabled:o,children:i}),m?.gone?t.jsx(yt,{"data-project-force-close":"",onClick:a,children:"Close"}):t.jsxs(yt,{"data-project-force-done":"","aria-disabled":o,className:"aria-disabled:pointer-events-none aria-disabled:bg-sunken aria-disabled:text-ink-disabled",onClick:()=>void f(),children:[o?t.jsx(ke,{size:"xs"}):t.jsx("span",{"aria-hidden":"true",className:"size-3.5 shrink-0"}),"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:n?`${n} moves to Done and its milestones stay open.`:"The project moves to Done and its milestones stay open."}),t.jsx("p",{className:"text-body-sm text-ink break-words",children:s?Yi(s):""}),j.length>jt+1&&t.jsx("div",{className:"px-1.5",children:t.jsx(jn,{summary:`Show all ${j.length} open milestones`,children:t.jsx("ul",{"data-project-open-milestones":"",className:"flex flex-col gap-1 py-1 text-body-sm text-ink-muted",children:j.map((v,g)=>t.jsx("li",{className:"break-words",children:v},`${g}-${v}`))})})}),t.jsx("p",{role:"alert",className:"min-h-[1lh] text-body-sm text-danger break-words",children:m?.copy??""})]})})},ha=({status:e})=>{const s=Z(e);return t.jsxs(pe,{variant:s.variant,children:[ai(e)&&t.jsx(fs,{"aria-hidden":!0}),s.label]})};function ue(e,s){return{name:s,begin:`Edit ${e}`,accept:`Save ${e}`,cancel:`Discard the ${e} edit`,busy:`Saving the ${e}`,saved:`${s} saved`,retry:`Retry saving the ${e}`}}const Pt=({field:e,fieldRef:s,fieldProps:n,editing:a,label:r,bare:i=!1,display:l,editor:o,slot:c,feedback:m,controlsIdle:u="affordance",hug:h=!1,feedbackExtra:b,className:f,controlsClassName:j})=>t.jsxs("div",{ref:s,...n,"data-project-field":e,className:$(!i&&ws,"min-w-0",r!==void 0&&"flex items-start gap-3",f),children:[r!==void 0&&t.jsx("dt",{className:"w-24 shrink-0 pt-0.5 text-body-sm text-ink-muted",children:r}),t.jsxs("div",{className:$("flex min-w-0 flex-col gap-1",h&&"items-start",r!==void 0&&"flex-1"),children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("div",{className:$("min-w-0",h?"w-fit":"flex-1",!a&&"cursor-text"),onDoubleClick:a?void 0:c.begin,children:a?o:l}),t.jsx(rs,{api:c,idle:u,className:$("shrink-0",j)})]}),t.jsx("div",{className:$("min-h-[1lh] text-meta",h&&"max-w-96"),children:t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsx(is,{api:m}),b]})})]})]}),Ae=({field:e,value:s,display:n,commitFields:a,validate:r,labels:i,commit:l,placeholder:o,mono:c=!1,ramp:m="text-body-sm",label:u,bare:h=!1,autoBegin:b=!1,maxLength:f,onRetire:j,className:v,controlsClassName:g})=>{const[x,y]=d.useState(b);d.useEffect(()=>{x&&s!==""&&(y(!1),j?.("filled"))},[x,s,j]);const C=ht({value:s,commit:async w=>{await l(a(w))},equals:(w,L)=>w.trim()===L.trim(),validate:r,labels:i,selectAllOnBegin:!0,beginOnMount:b,errorCopy:Xe,onSettle:w=>{w==="cancelled"&&(y(!1),j?.("cancelled"))}});return!x&&s===""?null:t.jsx(Pt,{field:e,fieldRef:C.fieldRef,fieldProps:C.fieldProps,editing:C.editing,label:u,bare:h,display:n,slot:C,feedback:C,className:v,controlsClassName:g,editor:t.jsx(ne,{ref:C.editorRef,...C.editorAria,value:C.draft,readOnly:C.phase==="saving",maxLength:f,placeholder:o,"aria-label":i.name,onChange:w=>C.setDraft(w.target.value),spellCheck:!1,autoComplete:"off",className:$("h-8",c?"font-mono text-mono-sm":m)})})},Zl=({project:e,commit:s})=>{const n=e.title??"",[a,r]=d.useState(!1),i=d.useRef(null),l=o=>{r(!1),o==="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:$(ws,"flex min-w-0 flex-col gap-0.5"),children:[n?t.jsx(Ae,{field:"title",value:n,display:t.jsx("h1",{"data-project-title":e.name,className:"min-w-0 break-words text-display text-ink",children:n}),commitFields:o=>({title:o.trim()}),validate:o=>Jt(o),labels:ue("title","Title"),commit:s,maxLength:wt,placeholder:"A short name for the workstream",ramp:"text-body",bare:!0,controlsClassName:"self-center"}):t.jsx(Ae,{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:o=>({name:o.trim()}),validate:o=>zt(o.trim()),labels:ue("key","Key"),commit:s,maxLength:Vs,placeholder:"project-key",ramp:"text-body",bare:!0,controlsClassName:"self-center"}),!n&&(a?t.jsx(Ae,{field:"title",value:"",display:null,commitFields:o=>({title:o.trim()}),validate:o=>Jt(o),labels:ue("title","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:()=>r(!0),className:$("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:"Add a title"}))]}),n&&t.jsx(Ae,{field:"key",value:e.name,display:t.jsx("span",{className:"font-mono text-mono-sm text-ink-muted",children:e.name}),commitFields:o=>({name:o.trim()}),validate:o=>zt(o.trim()),labels:ue("key","Key"),commit:s,maxLength:Vs,placeholder:"project-key",mono:!0})]})},ec=({project:e,commit:s})=>{const[n,a]=d.useState(!1),r=Ge(),i=fe(r.data,"projects_force_done"),[l,o]=d.useState(null),[c,m]=d.useState(null),u=d.useRef(!1),h=d.useRef(!1),b=d.useRef(null),f=ht({value:e.status,commit:async g=>{const x=u.current;u.current=!1,o(null);try{const y=await s({status:g},x?{forceDone:!0}:void 0);x&&ve(Gn(y,l?.count??0,Z(g).label)),b.current?.resolve()}catch(y){throw o(ra(y)),b.current?.reject(y),y}finally{b.current=null}},labels:ue("status","Status"),keyboardCommit:!1,errorCopy:Xe,onBegin:()=>a(!0)}),j=i&&f.phase==="error"&&l!==null&&l.coded;d.useEffect(()=>{if(!h.current||f.phase!=="idle"&&f.phase!=="saved")return;h.current=!1;const g=document.querySelector("[data-project-milestones]");g&&(g.scrollIntoView({block:"start"}),g.querySelector("[data-project-milestones-heading]")?.focus({preventScroll:!0}))},[f.phase]);const v=()=>new Promise((g,x)=>{if(f.phase!=="error"||f.conflict!==null){x(new Error(""));return}if(!f.dirty){g();return}u.current=!0,b.current={resolve:g,reject:x},f.accept(f.draft,!0)});return t.jsx(Pt,{field:"status",fieldRef:f.fieldRef,fieldProps:f.fieldProps,editing:f.editing,display:t.jsx(ha,{status:e.status}),slot:f,feedback:f,hug:!0,feedbackExtra:t.jsxs(t.Fragment,{children:[j&&t.jsx(U,{variant:"ghost",size:"sm","data-project-force-done-door":"",onClick:()=>m(l),children:"Mark done anyway…"}),t.jsx(fa,{open:c!==null,refusal:c,projectLabel:G(e),onClose:()=>m(null),onConfirm:v,secondaryLabel:"Review milestones",onSecondary:()=>{m(null),h.current=!0,f.cancel()}})]}),editor:t.jsxs(Ye,{open:n,onOpenChange:a,value:f.draft,onValueChange:g=>{a(!1),f.accept(g)},children:[t.jsx(ze,{ref:f.editorRef,...f.editorAria,"aria-label":"Status","data-project-status":"",className:"h-7 w-fit min-w-36",children:t.jsx(He,{})}),t.jsx(We,{children:Pn.map(g=>t.jsx(Te,{value:g.value,"data-project-status-option":g.value,children:g.label},g.value))})]})})},tc=({project:e,commit:s})=>{const[n,a]=d.useState(!1),r=d.useRef(null),i=d.useRef(null),l=ht({value:e.description,commit:async m=>{await s({description:m.trim()})},equals:(m,u)=>m.trim()===u.trim(),validate:m=>ta(m),multiline:!0,labels:ue("description","Description"),errorCopy:Xe,editorRef:r,onSettle:m=>{m==="cancelled"&&!e.description.trim()&&setTimeout(()=>i.current?.focus(),0)}});d.useEffect(()=>{if(n||!l.editing)return;const m=setTimeout(()=>r.current?.focus(),0);return()=>clearTimeout(m)},[n,l.editing]);const c=(l.editing?l.draft:l.displayValue).length>Ue;return t.jsx("div",{ref:l.fieldRef,...l.fieldProps,"data-project-field":"description",className:$(ws,"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:"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":n===(m==="preview"),onClick:()=>a(m==="preview"),className:$("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink",n===(m==="preview")&&"bg-surface text-ink"),children:m==="write"?"Write":"Preview"},m))})]}),t.jsx(rs,{api:{...l,acceptBlocked:c}})]}),n?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(lt,{className:"text-body-sm",children:l.draft}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:"Nothing to preview yet."})}):t.jsx(Sn,{ref:r,...l.editorAria,"data-project-description":"",value:l.draft,readOnly:l.phase==="saving",rows:8,placeholder:"Markdown — headings, lists, code.","aria-label":l.labels.name,onChange:m=>l.setDraft(m.target.value),onPaste:m=>ma(m,r,u=>l.setDraft(u)),className:"h-40 resize-none"}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(is,{api:l}),t.jsxs("p",{className:$("shrink-0 text-meta tabular-nums",c?"text-danger":"text-ink-muted"),children:[l.draft.length,"/",Ue]})]})]}):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(lt,{className:"text-body",children:e.description??""})}),t.jsx(rs,{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:"Add description"}),t.jsx("div",{className:"min-h-[1lh] text-meta",children:t.jsx(is,{api:l})})]})})},sc=({project:e,commit:s,autoBegin:n=!1,onRetire:a})=>t.jsx(Ae,{field:"owner",value:e.owner??"",label:"Owner",display:t.jsx("span",{className:"text-body-sm text-ink",children:e.owner}),commitFields:r=>({owner:r.trim()}),validate:r=>St(r,"owner"),labels:ue("owner","Owner"),commit:s,maxLength:Nt,placeholder:"atlas",autoBegin:n,onRetire:a}),nc=({project:e,commit:s,label:n=null,autoBegin:a=!1,onRetire:r})=>t.jsx(Ae,{field:"team",value:e.team??"",label:"Team",display:t.jsx("span",{className:"text-body-sm text-ink",children:n??e.team}),commitFields:i=>({team:i.trim()}),validate:i=>St(i,"team"),labels:ue("team","Team"),commit:s,maxLength:Nt,placeholder:"platform",autoBegin:a,onRetire:r}),un=({project:e,commit:s,which:n,nowMs:a,autoBegin:r=!1,onRetire:i})=>{const l=n==="start"?e.start_date??"":e.target_date??"",o=$e(),c=_e(l,o,new Date(a)),m=n==="start"?"Start":"Target";return t.jsx(Ae,{field:n==="start"?"start-date":"target-date",value:l,label:m,display:t.jsx("span",{className:"text-body-sm text-ink",children:c}),commitFields:u=>n==="start"?{start_date:u}:{target_date:u},validate:u=>{const h=Zt(u);return h||(n==="start"?es(u,e.target_date??""):es(e.start_date??"",u))},labels:ue(`${m.toLowerCase()} date`,m),commit:s,placeholder:"YYYY-MM-DD",autoBegin:r,onRetire:i})},ac=({project:e,commit:s,autoBegin:n=!1,onRetire:a})=>{const r={estimate:e.estimate,unit:e.estimate_unit==="days"?"days":"points"},[i,l]=d.useState(n);d.useEffect(()=>{i&&e.estimate!==null&&(l(!1),a?.("filled"))},[i,e.estimate,a]);const o=ht({value:{number:e.estimate===null?"":String(e.estimate),unit:r.unit},equals:Bo,commit:async m=>{const u=zo(r,m);u&&await s(u)},validate:m=>sa(m.number),labels:ue("estimate","Estimate"),selectAllOnBegin:!0,beginOnMount:n,errorCopy:Xe,onSettle:m=>{m==="cancelled"&&(l(!1),a?.("cancelled"))}});if(!i&&e.estimate===null)return null;const c=Ln(e.estimate,e.estimate_unit)||"—";return t.jsx(Pt,{field:"estimate",fieldRef:o.fieldRef,fieldProps:o.fieldProps,editing:o.editing,label:"Estimate",display:t.jsx("span",{className:"text-body-sm text-ink",children:c}),slot:o,feedback:o,editor:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ne,{ref:o.editorRef,...o.editorAria,"data-project-estimate":"",value:o.draft.number,readOnly:o.phase==="saving",placeholder:"13",inputMode:"decimal","aria-label":o.labels.name,onChange:m=>o.setDraft({...o.draft,number:m.target.value}),className:"h-8 max-w-24"}),t.jsxs(Ye,{value:o.draft.unit,onValueChange:m=>o.setDraft({...o.draft,unit:m}),children:[t.jsx(ze,{"data-project-estimate-unit":"","aria-label":"Estimate unit","aria-invalid":o.editorAria["aria-invalid"],className:"h-8 w-fit min-w-28",children:t.jsx(He,{})}),t.jsxs(We,{children:[t.jsx(Te,{value:"points",children:"Points"}),t.jsx(Te,{value:"days",children:"Days"})]})]})]}),o.draft.number.trim()===""&&r.estimate!==null&&t.jsx("p",{className:"text-meta text-ink-muted",children:"Clearing an estimate is not supported yet — saving keeps its current value."})]})})},rc=({project:e,commit:s,autoBegin:n=!1,onRetire:a})=>{const[r,i]=d.useState(n);d.useEffect(()=>{r&&e.tags.length>0&&(i(!1),a?.("filled"))},[r,e.tags,a]);const l=ht({value:e.tags.join(", "),equals:(c,m)=>Yo(ot(c),m),commit:async c=>{const{tags:m}=ts(c);await s({tags:m})},validate:c=>ts(c).error,labels:ue("tags","Tags"),selectAllOnBegin:!0,beginOnMount:n,errorCopy:Xe,onSettle:c=>{c==="cancelled"&&(i(!1),a?.("cancelled"))}});if(!r&&e.tags.length===0)return null;const o=l.editing?ot(l.draft):e.tags;return t.jsx(Pt,{field:"tags",fieldRef:l.fieldRef,fieldProps:l.fieldProps,editing:l.editing,label:"Tags",display:t.jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:e.tags.map(c=>t.jsx(pe,{variant:"outline",children:c},c))}),slot:l,feedback:l,editor:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(ne,{ref:l.editorRef,...l.editorAria,"data-project-tags":"",value:l.draft,readOnly:l.phase==="saving",placeholder:"q4, payments","aria-label":l.labels.name,onChange:c=>l.setDraft(c.target.value),className:"h-8 max-w-72"}),t.jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:o.map(c=>t.jsx(pe,{variant:"outline",children:c},c))})]})})},ic="project-quick-send:no-target",oc=[],lc=({links:e,target:s,onTargetChange:n,onSend:a,focusTick:r})=>{const i=d.useRef(null),l=Xa(),{frontend:o,refresh:c}=Mr(),[m,u]=d.useState(!1),h=Ge(),b=s??ic;d.useEffect(()=>{s&&c(s)},[s,c]),d.useEffect(()=>{r>0&&i.current?.focusInput()},[r]);const f=e.filter(g=>g.exists),v=(f.find(g=>g.session_id===s)??null)?.runtime?.busy===!0;return t.jsxs("div",{"data-tour-tag":"project-quick-send",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:"Send to"}),t.jsxs(Ye,{value:s??void 0,onValueChange:g=>n(g),children:[t.jsx(ze,{"aria-label":"Select the session to message",className:"max-w-72",children:t.jsx(He,{placeholder:"No session selected"})}),t.jsx(We,{children:f.map(g=>t.jsx(Te,{value:g.session_id,children:$t(g)},g.session_id))})]}),m?t.jsx("span",{role:"status",className:"text-meta text-ink-muted",children:"Sending…"}):v?t.jsx("span",{className:"text-meta text-ink-muted",children:"The session is working — this message steers the running turn."}):null]}),t.jsx(Ja,{ref:i,conversationId:b,messages:oc,isLoading:!1,ownGutter:!0,transcriptless:!0,autoFocus:!1,placeholderOverride:"Message the session — paste an image to attach it",cwd:o?.cwd,cwdReadOnlyReason:"Quick send follows the conversation's directory.",sessionStatus:o&&s?{frontend:o,costChannels:fe(h.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:"Choose a session to send to."}),blocksInput:!0,placeholder:"Choose a session to send to."},onSendMessage:async(g,x)=>{if(!s)return!1;u(!0);try{return await a(s,g,v?"steer":"prompt",x)}finally{u(!1),i.current?.focusInput({preventScroll:!0})}}})]})},cc=({links:e,busy:s,onUnlink:n,onLink:a,onQuickSend:r,onStartSession:i})=>{const l=Rt(),o=vt(x=>x.sessions),[c,m]=d.useState(!1),[u,h]=d.useState(null),[b,f]=d.useState(0),j=u&&e.some(x=>x.session_id===u&&x.exists)?u:Mi(e),v=d.useMemo(()=>{const x=new Set(e.map(y=>y.session_id));return o.filter(y=>!x.has(y.session_id)).map(y=>({id:y.session_id,name:y.title||y.session_id,description:y.cwd??void 0}))},[o,e]),g=x=>{vt.getState().openSession(x).then(y=>{y&&l(`/chat/${x}`)})};return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"Linked sessions"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(U,{variant:"secondary",size:"sm",disabled:s,onClick:i,"data-tour-tag":"project-start-session",children:[t.jsx(Ar,{}),"New session"]}),t.jsxs(U,{variant:"secondary",size:"sm",disabled:s,onClick:()=>m(!0),"data-tour-tag":"project-link-session",children:[t.jsx(zr,{}),"Link session"]})]})]}),e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No sessions linked yet. Link the conversations that are working on this project so its progress stays with them."}):t.jsx("ul",{className:"flex flex-col divide-y divide-hairline rounded-md bg-surface",children:e.map(x=>{const y=fi(x),C=hi(x.subagents),w=pi(x.todos),L=x.title||x.session_id,T=x.exists;return t.jsxs("li",{className:$("flex items-center gap-2 rounded-sm px-2 py-2",T&&"hover:bg-row-hover"),children:[t.jsx("button",{type:"button",disabled:!T,onClick:()=>{T&&g(x.session_id)},className:$("flex min-w-0 flex-1 items-center gap-2 text-left",T?"cursor-pointer":"cursor-default opacity-100"),children:t.jsx("span",{className:$("min-w-0 truncate text-body-sm",x.title?"text-ink":"font-mono text-mono-sm text-ink-muted"),children:L})}),x.runtime?.busy===!0&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:"busy"}),C&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:C}),w&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:w}),t.jsx(pe,{variant:y.variant,children:y.label}),T&&t.jsx(U,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":`Message ${L}`,title:`Message ${L}`,onClick:()=>{h(x.session_id),f(_=>_+1)},children:t.jsx(Or,{})}),t.jsx(U,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":`Unlink ${L}`,onClick:()=>n(x.session_id),children:t.jsx(Qr,{})})]},x.session_id)})}),e.some(x=>x.exists)&&t.jsx(lc,{links:e,target:j,onTargetChange:h,onSend:r,focusTick:b}),t.jsx(ct,{open:c,onClose:()=>m(!1),title:"Link a session",maxWidth:"sm",dataTourTag:"project-link-dialog",actions:t.jsx(Be,{onClick:()=>m(!1),children:"Close"}),children:t.jsxs("div",{className:"flex flex-col gap-2 px-1 py-1",children:[t.jsx(ie,{children:"Session"}),t.jsx(Tn,{showLabel:!1,ariaLabel:"Search sessions",busyLabel:"Loading sessions",placeholder:"Search conversations",options:v,selected:null,onSelect:x=>{m(!1),a(x.id)}}),t.jsx("p",{className:"text-meta text-ink-muted",children:"Conversations already linked to this project are not listed."})]})})]})},dc=({milestones:e,summary:s,busy:n,onToggle:a,onRemove:r,onAdd:i})=>{const[l,o]=d.useState(""),[c,m]=d.useState(""),u=$e(),h=!Mn.test(c.trim()),b=l.trim().length>0&&!h&&!n,f=()=>{b&&(i(l.trim(),c.trim()),o(""),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:"Milestones"}),s&&e.length>0&&t.jsx("span",{className:"text-meta text-ink-muted tabular-nums",children:s})]}),e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No milestones yet. Add one below to mark the dates this project is planned around."}):t.jsx("ul",{className:"flex flex-col divide-y divide-hairline rounded-md bg-surface",children:e.map(j=>{const v=ii(j.status),g=j.completed_at!==null;return t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx(_n,{checked:g,disabled:n,onCheckedChange:x=>a(j.name,x===!0),"aria-label":g?`Mark ${j.name} not complete`:`Mark ${j.name} complete`}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:j.name}),j.target_date&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:_e(j.target_date,u)}),t.jsx(pe,{variant:v.variant,children:v.label}),t.jsx(U,{variant:"ghost",size:"icon-sm",disabled:n,"aria-label":`Remove ${j.name}`,onClick:()=>r(j.name),children:t.jsx(Dt,{})})]},j.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(ie,{htmlFor:"project-milestone-name",children:"New milestone"}),t.jsx(ne,{id:"project-milestone-name",value:l,onChange:j=>o(j.target.value),placeholder:"beta cut",onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),f())}})]}),t.jsxs("div",{className:"flex w-40 flex-col gap-1.5",children:[t.jsx(ie,{htmlFor:"project-milestone-date",children:"Target date"}),t.jsx(ne,{id:"project-milestone-date",value:c,onChange:j=>m(j.target.value),placeholder:"YYYY-MM-DD","aria-invalid":h}),h&&t.jsx("p",{className:"text-meta text-danger",children:"Dates are YYYY-MM-DD, or empty."})]}),t.jsxs(U,{variant:"secondary",disabled:!b,onClick:f,"data-tour-tag":"project-milestone-add",children:[t.jsx(rt,{}),"Add"]})]})]})},uc=[{field:"owner",label:"Owner"},{field:"team",label:"Team"},{field:"start",label:"Start date"},{field:"target",label:"Target date"},{field:"estimate",label:"Estimate"},{field:"tags",label:"Tags"}],mn=({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})]}),mc=({project:e,nowMs:s,commit:n,teamLabel:a=null})=>{const r=$e(),i=new Date(s),[l,o]=d.useState(null),c=d.useRef(null),m=d.useRef(!1),u={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},h=(_,O)=>{o(p=>p===_?null:p),O==="cancelled"&&!u[_]&&setTimeout(()=>c.current?.focus(),0)},b=uc.filter(({field:_})=>!u[_]&&l!==_),f=_e(e.completed_at,r,i),j=e.updated_at>0?ut(dt(e.updated_at,s)):"",v=e.updated_at>0?new Date(e.updated_at*1e3).toLocaleString(r):"",g=u.owner||l==="owner",x=u.team||l==="team",y=u.start||l==="start",C=u.target||l==="target",w=u.estimate||l==="estimate",L=u.tags||l==="tags",T=g||x||y||C||!!f||w||L||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:"Properties"}),b.length>0&&t.jsxs(kn,{children:[t.jsx(wn,{asChild:!0,children:t.jsxs("button",{ref:c,type:"button","data-project-add-field":"",className:$("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(rt,{className:"size-3","aria-hidden":"true"}),"Add"]})}),t.jsx(Nn,{align:"end",onCloseAutoFocus:_=>{m.current&&(m.current=!1,_.preventDefault())},children:b.map(({field:_,label:O})=>t.jsx(st,{"data-project-add-option":_,onSelect:()=>{m.current=!0,o(_)},children:O},_))})]})]}),T?t.jsxs("dl",{className:"flex flex-col gap-2",children:[g&&t.jsx(sc,{project:e,commit:n,autoBegin:l==="owner",onRetire:_=>h("owner",_)}),x&&t.jsx(nc,{project:e,commit:n,label:a,autoBegin:l==="team",onRetire:_=>h("team",_)}),y&&t.jsx(un,{project:e,commit:n,which:"start",nowMs:s,autoBegin:l==="start",onRetire:_=>h("start",_)}),C&&t.jsx(un,{project:e,commit:n,which:"target",nowMs:s,autoBegin:l==="target",onRetire:_=>h("target",_)}),f&&t.jsx(mn,{label:"Completed",children:f}),w&&t.jsx(ac,{project:e,commit:n,autoBegin:l==="estimate",onRetire:_=>h("estimate",_)}),L&&t.jsx(rc,{project:e,commit:n,autoBegin:l==="tags",onRetire:_=>h("tags",_)}),e.updated_at>0&&t.jsx(mn,{label:"Updated",children:t.jsx("time",{dateTime:new Date(e.updated_at*1e3).toISOString(),title:v,children:j})})]}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No dates, estimate, tags, owner or team yet."})]})},fc=({project:e})=>{const s=Ge(),n=ca(),{sending:a,cooling:r,cooldownRemainingMs:i}=ol(e.id);if(!fe(s.data,"projects_request_update"))return null;const l=G(e),o=Jo(e.id);return t.jsxs(t.Fragment,{children:[t.jsx(cs,{content:r&&i!==null?Tt(l,i):Vo,children:t.jsxs(U,{variant:"secondary",className:"min-w-37","data-tour-tag":"project-request-update","aria-busy":a?!0:void 0,"aria-disabled":r?!0:void 0,"aria-describedby":r?o:void 0,onClick:()=>n(e),children:[a?t.jsx(ke,{size:"sm"}):r?t.jsx(fs,{}):t.jsx(Gr,{}),a?"Requesting…":r?"Requested":"Request update"]})}),r&&i!==null&&t.jsx("span",{id:o,className:"sr-only",children:Tt(l,i)})]})},pa="plain",xa=e=>`team:${e}`,ga=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 pc(e){return e.kind==="team"?xa(e.name):e.kind==="agent"?ga(e.name):pa}const fn={kind:"plain"},xc=({open:e,onClose:s,onStart:n,teamsEnabled:a,profilesEnabled:r})=>{const[i,l]=d.useState(fn),[o,c]=d.useState(null),[m,u]=d.useState(!1),h=Za(e&&a),b=er(e&&r);d.useEffect(()=>{e&&(l(fn),c(null),u(!1))},[e]);const f=d.useMemo(()=>{const y=[{id:pa,name:"Nothing in particular",description:"A plain session; assign a team or agent later.",group:"Plain"}];for(const C of h.data??[])y.push({id:xa(C.name),name:Os(C),keywords:C.name===Os(C)?void 0:[C.name],description:`Team · manager: ${C.manager}`,group:"Teams"});for(const C of(b.data??[]).filter(w=>w.source!=="builtin"))y.push({id:ga(C.name),name:C.name,description:C.description||C.kind,group:"Agents"});return y},[h.data,b.data]),j=f.find(y=>y.id===pc(i))??f[0],v=!a||!r,g=h.isLoading||b.isLoading,x=async()=>{u(!0),c(null);try{await n(i),s()}catch(y){c(y instanceof Error&&y.message?y.message:"The session could not be started.")}finally{u(!1)}};return t.jsx(ct,{open:e,onClose:s,title:"Start a session",maxWidth:"sm",dataTourTag:"project-start-session-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Be,{onClick:s,disabled:m,children:"Cancel"}),t.jsxs(yt,{onClick:()=>void x(),disabled:m,children:[m&&t.jsx(ke,{size:"xs"}),"Start session"]})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx(Tn,{label:"Work with",placeholder:"Search teams and agents",options:f,selected:j,onSelect:y=>l(hc(y.id)),busy:g,busyLabel:"Loading teams and agents"}),t.jsx("p",{className:"text-meta text-ink-muted",children:"The session starts now, links itself to this project, and opens with a prompt you can edit before sending."}),v&&t.jsx("p",{className:"text-meta text-ink-muted",children:"This server does not offer the team or agent catalogues yet, so only a plain session can be started."}),o&&t.jsx("p",{className:"text-body-sm text-danger",children:o})]})})},gc=({links:e})=>{const s=Pi(e),n=e.filter(a=>a.todos!==null);return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"To-dos"}),s&&t.jsx("span",{className:"text-meta text-ink-muted tabular-nums",children:Us(s)})]}),n.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No to-do snapshots from the linked sessions yet. A session publishes its list as it works, and it appears here once it has."}):t.jsx("ul",{className:"flex flex-col divide-y divide-hairline",children:n.map(a=>t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx("span",{className:a.title?"min-w-0 flex-1 truncate text-body-sm text-ink":"min-w-0 flex-1 truncate font-mono text-mono-sm text-ink-muted",children:$t(a)}),a.todos&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:Us(a.todos)})]},a.session_id))})]})},bc=/[/\\]/;function ba(e){if(e.name)return e.name;const s=e.path.split(bc);return s[s.length-1]||"Attachment"}const jc=({attachment:e})=>{const s=ba(e),n=Oi(e.bytes);return t.jsxs("div",{className:"flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-surface px-3 py-2",children:[t.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2.5 text-left",onClick:()=>{window.api?.openFile(e.path)},title:`Open ${s}`,children:[t.jsx(ir,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),t.jsx("span",{className:"truncate text-body-sm text-ink",children:s})]}),n&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:n}),t.jsx($r,{filePath:e.path,"aria-label":`File actions for ${s}`})]})},yc=({attachment:e})=>{const s=ba(e),n=tr(e.path,{mimeType:sr(e.name||e.path),sizeBytes:e.bytes});return n.status==="ready"?t.jsx("div",{className:"inline-block max-w-full",children:t.jsx(nr,{file:e.path,src:n.url,label:s,conversationId:""})}):n.status==="loading"?t.jsx(ar,{children:t.jsxs("span",{className:"sr-only",children:["Loading ",s]})}):t.jsx(rr,{name:s})},vc=({attachments:e})=>t.jsx("div",{className:"flex flex-wrap items-start gap-2",children:e.map(s=>s.kind==="image"?t.jsx(yc,{attachment:s},`${s.path}:${s.added_at}`):t.jsx(jc,{attachment:s},`${s.path}:${s.added_at}`))}),kc=({update:e,nowMs:s})=>{const n=$e(),a=Di(e,n,s);return t.jsxs("article",{className:"flex flex-col gap-2 rounded-sm px-2 py-3",children:[a.length>0&&t.jsx("p",{className:"flex flex-wrap items-baseline gap-x-2 text-meta text-ink-muted",children:a.map((r,i)=>t.jsxs(d.Fragment,{children:[i>0&&t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{children:r.text})]},r.key))}),e.text&&t.jsx(lt,{children:e.text}),e.attachments.length>0&&t.jsx(vc,{attachments:e.attachments})]})},wc=({updates:e,nowMs:s})=>{const n=$e(),a=Ti(e.length),r=Ai(e,n,new Date(s));return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"Updates"}),a&&t.jsx("span",{className:"text-meta text-ink-muted",children:a})]}),e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No updates yet. Progress reported by you or by the sessions working on this project is appended here."}):t.jsx("div",{className:"flex flex-col gap-4",children:r.map(i=>t.jsxs("div",{className:"flex flex-col gap-2",children:[i.label&&t.jsx("h3",{className:"text-meta text-ink-muted",children:i.label}),t.jsx("div",{className:"flex flex-col divide-y divide-hairline",children:i.entries.map((l,o)=>t.jsx(kc,{update:l,nowMs:s},`${l.at}:${l.by}:${o}`))})]},i.key||"ungrouped"))})]})},Nc="project_not_found",Sc=({projectKey:e,nowMs:s})=>{const n=Rt(),a=Ge(),r=yn(fe(a.data,"team_catalogue")),i=Dn(e,!0),l=An(),o=On(),c=si(),m=ni(),u=ei(),h=ti(),[b,f]=d.useState(!1),[j,v]=d.useState(!1),g=l.isPending||o.isPending||c.isPending||m.isPending||u.isPending||h.isPending;if(i.isLoading)return t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(ke,{label:"Loading project"})});if(i.isError||!i.data){const p=i.error instanceof Et&&(i.error.code===Nc||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:p?"This project could not be found. It may have been deleted.":i.error instanceof Error&&i.error.message?i.error.message:"The project could not be read."}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(U,{variant:"secondary",onClick:()=>void i.refetch(),children:"Try again"}),t.jsxs(U,{variant:"secondary",onClick:()=>void n("/projects"),children:[t.jsx(Ps,{}),"All projects"]})]})]})}const{project:x,links:y}=i.data,C=G(x),w=(p,A)=>l.mutateAsync({key:x.id,fields:p,...A?.forceDone===!0?{forceDone:!0}:{}}),L=x.team?r(x.team):null,T=$i(x.milestones.filter(p=>p.completed_at!==null).length,x.milestones.length),_=async(p,A,E,P)=>{const Y=vt.getState(),I=lr(null,p,Y.drafts);if(!I)return!1;try{const{images:B,unreadable:W,overflow:V}=await cr(P,A),oe=dr(W);if(oe)return le(oe),!1;const Q=ur(V);if(Q)return le(Q),!1;const X=mr(A,B);if(X)return le(X),!1;if(await fr(I,{text:A,attachments:P,images:B,mode:E,cwd:Y.cwd},p)===null)return le("That session already has a message going out. Try again in a moment."),!1;const N=y.find(R=>R.session_id===p);return ve(`Sent to ${N?$t(N):p}`),!0}catch(B){return le(B instanceof Error&&B.message?B.message:"The message was not sent."),!1}},O=async p=>{const A=vt.getState(),E=p.kind==="plain"?void 0:{kind:p.kind,name:p.name},P=await A.createSession(A.cwd||"~",E);if(!P)throw new Error(A.error??"The session could not be started.");hr.getState().setCurrentInput(P,Ii(x));let Y=null;try{await u.mutateAsync({key:x.id,sessionId:P})}catch(I){Y=I instanceof Error&&I.message?I.message:"the link was refused"}if(Y)le(`Session started, but linking it failed: ${Y}`);else{const I=E?` with ${Li(E)}`:"";ve(`Session started${I} and linked to ${C}.`)}await En(n,P)};return t.jsx(Sl,{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 n("/projects"),className:"flex w-fit items-center gap-1.5 text-body-sm text-ink-muted hover:text-ink",children:[t.jsx(Ps,{className:"size-4"}),"All projects"]}),t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-start gap-x-3 gap-y-2",children:[t.jsx(Zl,{project:x,commit:w}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1.5",children:[t.jsx(ec,{project:x,commit:w}),x.progress_stale&&t.jsx(pe,{variant:"warning",children:kt})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(fc,{project:x}),t.jsxs(U,{variant:"secondary",onClick:()=>f(!0),"data-tour-tag":"project-delete",children:[t.jsx(or,{}),"Delete"]})]})]})]}),t.jsx(tc,{project:x,commit:w}),t.jsx(mc,{project:x,nowMs:s,commit:w,teamLabel:L}),x.updates.length===0&&x.progress&&t.jsxs("section",{className:"flex flex-col gap-2",children:[t.jsx("h2",{className:"text-title text-ink",children:"Progress"}),t.jsx(lt,{className:"text-body",children:x.progress}),t.jsx("p",{className:"text-meta text-ink-muted",children:ci(x,s)})]}),t.jsx(dc,{milestones:x.milestones,summary:T,busy:g,onToggle:(p,A)=>{c.mutateAsync({key:x.id,name:p,completed:A}).catch(E=>{le(E instanceof Error&&E.message?E.message:"The milestone was not updated.")})},onRemove:p=>{m.mutateAsync({key:x.id,name:p}).catch(A=>{le(A instanceof Error&&A.message?A.message:"The milestone was not removed.")})},onAdd:(p,A)=>{c.mutateAsync({key:x.id,name:p,targetDate:A}).catch(E=>{le(E instanceof Error&&E.message?E.message:"The milestone was not added.")})}}),t.jsx(cc,{projectKey:x.id,links:y,busy:g,onStartSession:()=>v(!0),onQuickSend:_,onLink:p=>{u.mutateAsync({key:x.id,sessionId:p}).catch(A=>{le(A instanceof Error&&A.message?A.message:"The session was not linked.")})},onUnlink:p=>{h.mutateAsync({key:x.id,sessionId:p}).catch(A=>{le(A instanceof Error&&A.message?A.message:"The session was not unlinked.")})}}),t.jsx(gc,{links:y}),t.jsx(wc,{updates:x.updates,nowMs:s}),t.jsx(da,{open:b,projectName:x.name,onClose:()=>f(!1),onConfirm:async p=>{await o.mutateAsync({key:x.id,confirmedName:p}),ve("Project deleted"),n("/projects")}}),t.jsx(xc,{open:j,onClose:()=>v(!1),onStart:O,teamsEnabled:fe(a.data,"team_catalogue"),profilesEnabled:fe(a.data,"profile_catalogue")})]})})},hn={name:"",title:"",owner:"",team:"",description:"",status:"active",tags:"",startDate:"",targetDate:"",estimate:"",estimateUnit:"points"},Tc=({open:e,onClose:s,onSubmit:n})=>{const[a,r]=d.useState(hn),[i,l]=d.useState({}),[o,c]=d.useState(null),m=d.useRef(null),[u,h]=d.useState(!1),[b,f]=d.useState(!1),[j,v]=d.useState(!1),g=d.useId(),x=d.useRef(null);d.useEffect(()=>{e&&(r({...hn,description:on}),l({}),c(null),h(!1),f(!1),v(!1))},[e]),d.useEffect(()=>{o&&m.current?.scrollIntoView({block:"nearest"})},[o]);const y=(p,A)=>{r(E=>({...E,[p]:A}))},C=b?a.name:$l(a.title),w=p=>ma(p,x,A=>y("description",A)),L=(p,A)=>{const E={},P=zt(A);P&&(E.name=P);const Y=ta(p.description);Y&&(E.description=Y);const I=ts(p.tags).error;I&&(E.tags=I);const B=Zt(p.startDate);B&&(E.startDate=B);const W=Zt(p.targetDate);if(W)E.targetDate=W;else if(!B){const X=es(p.startDate,p.targetDate);X&&(E.targetDate=X)}if(p.estimate.trim()){const X=sa(p.estimate);X&&(E.estimate=X)}const V=Jt(p.title);V&&(E.title=V);const oe=St(p.owner,"owner");oe&&(E.owner=oe);const Q=St(p.team,"team");return Q&&(E.team=Q),E},T=async()=>{const p=C.trim(),A=L(a,p);if(l(A),Object.keys(A).length>0)return;h(!0),c(null);const E=ot(a.tags);try{const P={};a.title.trim()&&(P.title=a.title.trim()),a.owner.trim()&&(P.owner=a.owner.trim()),a.team.trim()&&(P.team=a.team.trim()),a.startDate&&(P.start_date=a.startDate),a.targetDate&&(P.target_date=a.targetDate),a.estimate&&(P.estimate=Number(a.estimate),P.estimate_unit=a.estimateUnit),await n({fields:{name:p,...a.description.trim()&&a.description.trim()!==on?{description:a.description.trim()}:{},status:a.status,...E.length>0?{tags:E}:{}},...Object.keys(P).length>0?{followUp:P}:{}}),s()}catch(P){const Y=P instanceof Error&&P.message?P.message:"";c(ft(Y)||"The project was not saved.")}finally{h(!1)}},_="New project",O=a.description.length>Ue;return t.jsx(ct,{open:e,onClose:s,title:_,fullWidth:!0,maxWidth:"md",dialogProps:{closeDisabled:u,onEscapeKeyDown:p=>{u&&p.preventDefault()},onInteractOutside:p=>{u&&p.preventDefault()}},dataTourTag:"project-create-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Be,{onClick:s,disabled:u,children:"Cancel"}),t.jsxs(yt,{"data-project-submit":"",onClick:()=>void T(),disabled:u,children:[u&&t.jsx(ke,{size:"xs"}),"Create project"]})]}),children:t.jsxs("form",{className:"flex flex-col gap-6 px-1 py-1",onSubmit:p=>{p.preventDefault(),T()},children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(ie,{htmlFor:`${g}-title`,children:"Title"}),t.jsx(ne,{id:`${g}-title`,"data-project-title":"",value:a.title,onChange:p=>y("title",p.target.value),placeholder:"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(ie,{htmlFor:`${g}-key`,className:"shrink-0 text-meta text-ink-muted",children:"Key"}),t.jsx(ne,{id:`${g}-key`,"data-project-key":"",value:C,onChange:p=>{f(!0),y("name",p.target.value)},placeholder:"payments-migration","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:b?"Letters, digits, dot, underscore or dash; no spaces.":"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(ie,{htmlFor:`${g}-description`,children:"Description"}),t.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:"Description mode"}),t.jsx("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:["write","preview"].map(p=>t.jsx("button",{type:"button","data-project-description-mode":p,"aria-pressed":j===(p==="preview"),onClick:()=>v(p==="preview"),className:$("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",j===(p==="preview")&&"bg-surface text-ink"),children:p==="write"?"Write":"Preview"},p))})]})]}),j?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(lt,{className:"text-body-sm",children:a.description}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:"Nothing to preview yet."})}):t.jsx(Sn,{ref:x,id:`${g}-description`,"data-project-description":"",value:a.description,onChange:p=>y("description",p.target.value),onPaste:w,rows:8,placeholder:"Markdown — headings, lists, code.","aria-invalid":O||!!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:$("text-meta tabular-nums",O?"text-danger":"text-ink-muted"),children:[a.description.length,"/",Ue]})]})]}),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(ie,{children:"Status"}),t.jsxs(Ye,{value:a.status,onValueChange:p=>y("status",p),children:[t.jsx(ze,{"aria-label":"Status",children:t.jsx(He,{})}),t.jsx(We,{children:Pn.map(p=>t.jsx(Te,{value:p.value,children:p.label},p.value))})]}),a.status==="done"&&t.jsx("p",{className:"text-meta text-ink-muted",children:"Moving a project to Done stamps today as its completion date."})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(ie,{htmlFor:`${g}-owner`,children:"Owner"}),t.jsx(ne,{id:`${g}-owner`,"data-project-owner":"",value:a.owner,onChange:p=>y("owner",p.target.value),placeholder:"atlas","aria-invalid":!!i.owner}),i.owner&&t.jsx("p",{className:"text-meta text-danger",children:i.owner})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(ie,{htmlFor:`${g}-team`,children:"Team"}),t.jsx(ne,{id:`${g}-team`,value:a.team,onChange:p=>y("team",p.target.value),placeholder:"platform","aria-invalid":!!i.team}),i.team&&t.jsx("p",{className:"text-meta text-danger",children:i.team})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(ie,{htmlFor:`${g}-target`,children:"Target date"}),t.jsx(ne,{id:`${g}-target`,"data-project-target":"",value:a.targetDate,onChange:p=>y("targetDate",p.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(ie,{htmlFor:`${g}-start`,children:"Start date"}),t.jsx(ne,{id:`${g}-start`,value:a.startDate,onChange:p=>y("startDate",p.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(ie,{htmlFor:`${g}-estimate`,children:"Estimate"}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ne,{id:`${g}-estimate`,value:a.estimate,onChange:p=>y("estimate",p.target.value),placeholder:"13",inputMode:"decimal","aria-invalid":!!i.estimate,className:"max-w-28"}),t.jsxs(Ye,{value:a.estimateUnit,onValueChange:p=>y("estimateUnit",p),children:[t.jsx(ze,{"aria-label":"Estimate unit",className:"max-w-32",children:t.jsx(He,{})}),t.jsxs(We,{children:[t.jsx(Te,{value:"points",children:"Points"}),t.jsx(Te,{value:"days",children:"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(ie,{htmlFor:`${g}-tags`,children:"Tags"}),t.jsx(ne,{id:`${g}-tags`,value:a.tags,onChange:p=>y("tags",p.target.value),placeholder:"q4, payments","aria-invalid":!!i.tags}),i.tags?t.jsx("p",{className:"text-meta text-danger",children:i.tags}):t.jsx("p",{className:"text-meta text-ink-muted",children:"Comma-separated, up to 8. Lowercase letters, digits, underscore or dash."})]})]}),o&&t.jsx("p",{ref:m,className:"text-body-sm text-danger",children:o})]})})},ja=({children:e})=>{const s=d.useRef(null),[n,a]=d.useState(!1),r=()=>{const i=s.current;i&&a(i.scrollTop+i.clientHeight<i.scrollHeight-1)};return d.useEffect(r),t.jsx("div",{ref:s,onScroll:r,className:$("max-h-[min(70vh,32rem)] overflow-y-auto overscroll-contain",n&&"[mask-image:linear-gradient(to_bottom,black_calc(100%-12px),transparent)]"),children:e})},_c=({label:e,count:s,selected:n,onToggle:a})=>{const r=d.useId();return t.jsxs("div",{className:"flex items-center gap-2 rounded-sm px-1 py-1 hover:bg-sunken",children:[t.jsx(_n,{id:r,checked:n,onCheckedChange:()=>a()}),t.jsx(ie,{htmlFor:r,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})]})},Cc=({column:e,spec:s,onChange:n})=>{const a=d.useId(),r=s!==null&&s.key===e,i=r?s.direction:Lt(e),l=i==="asc"?"desc":"asc",o=()=>n({key:e,direction:r?l:Lt(e)}),c=s===null?"default":r?"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:`Sort by ${Ke(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:c==="default",onChange:()=>n(null),className:"m-0 size-3.5 shrink-0 accent-[var(--color-accent)]"}),t.jsx("span",{className:$("min-w-0 flex-1 truncate",c==="default"?"text-ink":"text-ink-muted"),children:go})]}),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:c==="sorted",onChange:o,onClick:()=>{c==="sorted"&&o()},onKeyDown:m=>{c==="sorted"&&(m.key!==" "&&m.key!=="Enter"||(m.preventDefault(),o()))},className:"m-0 size-3.5 shrink-0 accent-[var(--color-accent)]"}),t.jsx("span",{className:$("min-w-0 flex-1 truncate",c==="sorted"?"text-ink":"text-ink-muted"),children:`Sort by ${Ke(e)}, ${js(e,r?i:Lt(e))}`})]})]})},Ec=({facet:e,options:s,onToggle:n})=>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:at[e]}),s.map(a=>t.jsx(_c,{label:a.label,count:a.count,selected:a.selected,onToggle:()=>n(e,a.value)},`${e}:${a.value??"none"}`))]}),ya=({projects:e,state:s,query:n,todayMs:a,onToggle:r,onClearAll:i,scope:l,sort:o})=>{const c=d.useMemo(()=>l===void 0?xo(e,s,a):l===null?[]:[ea(l,e,s,a)],[l,e,s,a]),m=!it(s)||n.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:"Filters"}),m&&t.jsx(U,{variant:"link",size:"sm",onClick:i,children:"Clear all"})]}),o&&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:`Sort by ${Ke(o.key)}`}),t.jsx(Cc,{column:o.key,spec:o.spec,onChange:o.onChange})]}),c.map(u=>t.jsx(Ec,{facet:u.facet,options:u.options,onToggle:r},u.facet))]})},Rc=({team:e,count:s,headingId:n,className:a,...r})=>t.jsxs("div",{...r,className:$("flex h-8 cursor-default items-center gap-2 bg-surface px-3 text-meta",a),children:[t.jsx("h3",{id:n,className:"truncate text-ink",children:e??ps}),t.jsx("span",{className:"shrink-0 text-ink-muted","aria-label":ui(s),children:s})]}),ye=[{key:"name",label:"Project",className:"min-w-0 flex-1",sort:"name",facet:null},{key:"status",label:"Status",className:"w-20 shrink-0",sort:"status",facet:"status"},{key:"target",label:"Target",className:"hidden w-32 shrink-0 @[40rem]:block",sort:"target",facet:"target"},{key:"estimate",label:"Estimate",className:"hidden w-16 shrink-0 @[40rem]:block",sort:"estimate",facet:"estimate"},{key:"milestones",label:"Milestones",className:"hidden w-20 shrink-0 @[34rem]:block",sort:"milestones",facet:"milestones"},{key:"live",label:"Live",className:"hidden w-14 shrink-0 @[34rem]:block",sort:"live",facet:"live"},{key:"progress",label:"Progress",className:"w-40 shrink-0",sort:"progress",facet:"progress"}];function Dc(e,s){const n=dt(e.progress_updated_at,s);return n?ut(n):"not reported"}const Ac=({direction:e})=>e==="asc"?t.jsx(Rn,{size:10,className:"shrink-0","aria-hidden":"true"}):t.jsx(vn,{size:10,className:"shrink-0","aria-hidden":"true"}),Oc=({projects:e,nowMs:s,onOpen:n,sort:a,onSortChange:r,searchPopulation:i,filters:l,query:o,todayMs:c,onToggleFilter:m,onClearFilters:u,teamLabelFor:h=b=>b})=>{const b=$e(),f=a?To(e,a):e,j=xs(f,mt),v=d.useId(),g=T=>`${v}-team-${T}`,[x,y]=d.useState(0),C=d.useRef([]),w=(T,_)=>{const O=ye.length;for(let p=1;p<=O;p+=1){const A=(T+_*p+O*O)%O,E=C.current[A];if(E&&E.offsetParent!==null){y(A),E.focus();return}}},L=T=>_=>{_.key!=="ArrowLeft"&&_.key!=="ArrowRight"||(_.preventDefault(),w(T,_.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":"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:ye.map((T,_)=>{const O=a!==null&&a.key===T.sort;return t.jsx("th",{scope:"col","aria-sort":O?a.direction==="desc"?"descending":"ascending":"none",className:$(T.className,"p-0 text-left font-normal"),children:t.jsxs(ds,{children:[t.jsx(us,{asChild:!0,children:t.jsxs("button",{type:"button",ref:p=>{C.current[_]=p},tabIndex:_===x?0:-1,"data-project-column":T.key,onFocus:()=>y(_),onKeyDown:L(_),className:$("group flex w-full min-w-0 items-center gap-1 rounded-xs text-left","transition-colors duration-fast ease-out-quart",O?"text-ink":"hover:text-ink"),children:[t.jsx("span",{className:"truncate",children:T.label}),O?t.jsx(Ac,{direction:a.direction}):t.jsx(pr,{size:10,className:"shrink-0 text-ink-dim transition-colors duration-fast ease-out-quart group-hover:text-ink","aria-hidden":"true"})]})}),t.jsx(ms,{align:"start","aria-label":`${T.label} column`,className:"w-72 p-0",children:t.jsx(ja,{children:t.jsx(ya,{projects:i,state:l,query:o,todayMs:c,onToggle:m,onClearAll:u,scope:T.facet,sort:{key:T.sort,spec:a,onChange:r}})})})]})},T.key)})})})}),t.jsx("ul",{className:"min-h-0 flex-1 overflow-y-auto px-6",children:j.map((T,_)=>t.jsxs("li",{children:[t.jsx(Rc,{team:T.team==null?null:h(T.team),count:T.items.length,headingId:g(_),className:"sticky top-0 z-10","data-project-team":T.team??""}),t.jsx("ul",{"aria-labelledby":g(_),className:"divide-y divide-hairline",children:T.items.map(O=>{const p=new Map(qn(O,b).map(P=>[P.key,P.text])),A=Fn(O.milestones_completed,O.milestones_total),E=hs(O.live_sessions);return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>n(O),"data-project-name":O.name,className:$("flex w-full items-center gap-3 px-3 py-2 text-left","transition-colors duration-fast ease-out-quart","hover:bg-elevated"),children:[t.jsx("span",{className:$(ye[0].className,"truncate text-body-sm text-ink"),children:G(O)}),t.jsx("span",{className:ye[1].className,children:t.jsx(ha,{status:O.status})}),t.jsx("span",{className:$(ye[2].className,"truncate text-meta text-ink-muted"),children:p.get("target")??p.get("completed")??""}),t.jsx("span",{className:$(ye[3].className,"truncate text-meta text-ink-muted"),children:p.get("estimate")??""}),t.jsx("span",{className:$(ye[4].className,"truncate text-meta text-ink-muted"),children:A}),t.jsx("span",{className:$(ye[5].className,"truncate text-meta text-ink-muted"),children:E}),t.jsxs("span",{className:$(ye[6].className,"flex items-center gap-2"),children:[t.jsx("span",{className:"truncate text-meta text-ink-muted",children:Dc(O,s)}),O.progress_stale&&t.jsx(pe,{variant:"warning",children:kt})]})]})},O.id)})})]},T.team??""))})]})},Ct=224,pn=36,$c={day:"Days",week:"Weeks",month:"Months",quarter:"Quarters"},Pc=({items:e,nowMs:s,onOpen:n,pendingDetails:a,failedDetails:r,onRetryDetails:i,teamLabelFor:l=o=>o})=>{const[o,c]=d.useState(null),[m,u]=d.useState(0),h=d.useRef(null),b=vs(s),f=d.useMemo(()=>Eo(e,b),[e,b]),j=d.useMemo(()=>Ro(e),[e]),v=d.useMemo(()=>xs(j.dated,T=>mt(T.project)),[j]);d.useLayoutEffect(()=>{const T=h.current;if(!T)return;const _=()=>u(T.clientWidth);if(_(),typeof ResizeObserver>"u")return;const O=new ResizeObserver(_);return O.observe(T),()=>O.disconnect()},[]);const g=Math.max(m-Ct-24,160),x=f?_o(Gs(f.startMs,f.endMs),g):"month",y=o??x,C=T=>{const _=Se.indexOf(y),O=Se[_-T];O&&c(O)},w=ys[y],L=f?Gs(f.startMs,f.endMs)*w:0;return t.jsxs("div",{ref:h,className:"flex min-h-0 flex-1 flex-col","data-testid":"project-timeline",children:[t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 px-9 py-2",children:[t.jsx("span",{className:"truncate text-meta text-ink-muted","data-timeline-note":!0,children:r>0?`Milestones could not be read for ${r} project${r===1?"":"s"}.`:`${j.dated.length} dated · ${j.undated.length} without dates${a>0?` · loading milestones for ${a}…`:""}`}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[r>0&&t.jsx(U,{variant:"secondary",size:"sm",onClick:i,children:"Try again"}),t.jsx(U,{variant:"secondary",size:"icon","aria-label":"Zoom in",title:"Zoom in (finer)",disabled:!f||y===Se[0],onClick:()=>C(1),children:t.jsx(rt,{})}),t.jsx("span",{className:"w-16 text-center text-meta text-ink-muted",children:$c[y]}),t.jsx(U,{variant:"secondary",size:"icon","aria-label":"Zoom out",title:"Zoom out (coarser)",disabled:!f||y===Se[Se.length-1],onClick:()=>C(-1),children:t.jsx(_r,{})})]})]}),f&&j.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(Mc,{startMs:f.startMs,endMs:f.endMs,tier:y,pxPerDay:w,trackPx:L}),v.map(T=>t.jsxs("div",{children:[t.jsx("div",{className:"sticky top-0 z-20 flex items-stretch bg-canvas","data-project-team":T.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:Ct},children:[t.jsx("span",{className:"truncate text-ink",children:T.team==null?ps:l(T.team)}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:T.items.length})]})}),T.items.map(_=>t.jsx(Ic,{item:_,spanStart:f.startMs,pxPerDay:w,trackPx:L,today:b,onOpen:()=>n(_)},_.project.id))]},T.team??""))]})}):null,j.undated.length>0&&t.jsx("div",{className:"shrink-0 px-9 py-2","data-project-undated-callout":"",children:t.jsxs(jn,{defaultOpen:j.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(Br,{size:14,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),t.jsx("span",{className:"truncate text-ink",children:Do(j.undated.length)})]}),children:[j.dated.length===0&&t.jsx("p",{className:"pb-1 text-meta text-ink-muted",children:"Set a start date, a target date or a milestone date and it will appear on the timeline."}),t.jsx("ul",{className:"flex max-h-24 flex-wrap gap-x-3 gap-y-1 overflow-y-auto",children:j.undated.map(T=>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:()=>n(T),children:G(T.project)})},T.project.id))})]})})]})},Mc=({startMs:e,endMs:s,tier:n,pxPerDay:a,trackPx:r})=>{const i=qo(e,s,n);return t.jsxs("div",{className:"flex items-stretch",children:[t.jsx("span",{className:"sticky left-0 z-10 shrink-0 bg-canvas",style:{width:Ct}}),t.jsx("span",{className:"relative block h-6",style:{width:r},children:i.map(l=>t.jsxs("span",{className:"absolute top-0 h-full",style:{left:De(e,l.dayMs)*a},children:[t.jsx("span",{className:$("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))})]})},Ic=({item:e,spanStart:s,pxPerDay:n,trackPx:a,today:r,onOpen:i})=>{const{project:l}=e,o=Ao(e),c=Oo(e),m=u=>new Date(u).toISOString().slice(0,10);return t.jsxs("button",{type:"button",onClick:i,"data-project-name":l.name,className:"flex w-full items-stretch text-left transition-colors duration-fast ease-out-quart hover:bg-elevated",children:[t.jsx("span",{className:"sticky left-0 z-10 flex shrink-0 items-center gap-2 border-r border-hairline bg-canvas px-3",style:{width:Ct,height:pn},children:t.jsx("span",{className:"truncate text-body-sm text-ink",children:G(l)})}),t.jsxs("span",{className:"relative block",style:{width:a,height:pn},children:[o&&t.jsx("span",{className:"absolute top-1/2 h-1.5 -translate-y-1/2 rounded-full bg-accent/75",style:{left:De(s,o.fromMs)*n,width:(De(o.fromMs,o.toMs)+1)*n},title:`${_e(m(o.fromMs))} → ${_e(m(o.toMs))}`}),c.map(u=>t.jsx("span",{"data-milestone":u.status,className:$("absolute top-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rotate-45",u.status==="completed"&&"bg-success",u.status==="overdue"&&"bg-warning",u.status==="upcoming"&&"border-[1.5px] border-ink-muted bg-surface"),style:{left:De(s,u.dayMs)*n},title:`${u.name} · ${u.status} · ${_e(m(u.dayMs))}`},`${u.name}-${u.dayMs}`)),t.jsx("span",{className:"absolute inset-y-0 w-px bg-accent/75",style:{left:De(s,r)*n},"aria-hidden":"true"})]})]})},Lc=({projects:e,query:s,onQueryChange:n,filters:a,onFiltersChange:r,onClearAll:i,todayMs:l,resultText:o,countRevealClass:c="@[37rem]:inline",trailing:m,disabled:u=!1,searchFieldRef:h})=>{const[b,f]=d.useState(!1),j=d.useRef(!1),v=mo(a),g=Cn(o??"",300),x=s.trim()!==""||!it(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(xr,{size:16,className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim","aria-hidden":"true"}),t.jsx(ne,{ref:h,inputSize:"sm",value:s,onChange:y=>n(y.target.value),onKeyDown:y=>{y.key==="Escape"&&(s?n(""):y.currentTarget.blur())},placeholder:"Search projects","aria-label":"Search projects",autoComplete:"off",spellCheck:!1,className:"pl-9"}),s?t.jsx(U,{variant:"ghost",size:"icon-sm",className:"absolute top-1/2 right-1 -translate-y-1/2",onClick:()=>gr(h.current,n),"aria-label":"Clear search",children:t.jsx(Dt,{"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(br,{shortcut:"/"})})]}),t.jsxs(ds,{open:b,onOpenChange:f,children:[t.jsx(us,{asChild:!0,children:t.jsxs(U,{variant:"secondary",size:"sm",disabled:u,"data-project-filters-button":"",children:[t.jsx(Wr,{size:14,"aria-hidden":"true"}),"Filters",v>0&&t.jsx(pe,{variant:"neutral",children:v})]})}),t.jsx(ms,{align:"end","aria-label":"Filters",className:"w-80 p-0",onCloseAutoFocus:y=>{j.current&&(j.current=!1,y.preventDefault())},children:t.jsx(ja,{children:t.jsx(ya,{projects:e,state:a,query:s,todayMs:l,onToggle:(y,C)=>r(Xn(a,y,C)),onClearAll:()=>{i(),j.current=!0,f(!1),h.current?.focus()}})})})]}),x&&o!==null&&t.jsx("span",{className:$("hidden whitespace-nowrap text-meta text-ink-dim",c),"data-project-count":"",children:o}),t.jsx("output",{className:"sr-only","aria-live":"polite",children:g}),m]})},Fc=({filters:e,sort:s,onFiltersChange:n,onSortChange:a,onClearAll:r,hideClearAll:i=!1,searchFieldRef:l})=>{const[o,c]=d.useState(null);d.useEffect(()=>{if(!o)return;let h=null;o.kind==="search"?h=l.current:(h=document.querySelector(`[data-project-chip="${o.index}"]`),h||(h=document.querySelector("[data-project-chip]")),h||(h=document.querySelector("[data-project-filters-button]"))),h&&(h.focus(),c(null))});const m=[];for(const h of Qe){const b=e[h];if(b.length===0)continue;const f=b.map(g=>Qn(h,g)),j=f[0],v=f.length>1?`${at[h]} · ${j} +${f.length-1}`:`${at[h]} · ${j}`;m.push({kind:"facet",facet:h,label:v,ariaLabel:`Remove filter: ${at[h]} · ${f.join(", ")}`,clear:()=>n({...e,[h]:[]})})}if(s&&m.push({kind:"sort",spec:s,label:`Sort: ${Ke(s.key)}`,ariaLabel:`Remove sort: ${Ke(s.key)}, ${js(s.key,s.direction)}`,clear:()=>a(null)}),m.length===0)return null;const u=(h,b)=>{b.clear();const f=m.length-1;c(f===0?{kind:"chip",index:0}:{kind:"chip",index:Math.min(h,f-1)})};return t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[m.map((h,b)=>t.jsx(pe,{asChild:!0,variant:"neutral",className:"gap-1 pr-1 text-ink",children:t.jsxs("button",{type:"button",className:"group","data-project-chip":b,"aria-label":h.ariaLabel,onClick:()=>u(b,h),children:[h.kind==="sort"&&(h.spec.direction==="asc"?t.jsx(Rn,{size:10,className:"text-ink-muted","aria-hidden":"true"}):t.jsx(vn,{size:10,className:"text-ink-muted","aria-hidden":"true"})),t.jsx("span",{className:"truncate",children:h.label}),t.jsx(Dt,{className:$("text-ink-dim transition-colors duration-fast ease-out-quart","group-hover:text-danger"),"aria-hidden":"true"})]})},h.kind==="facet"?h.facet:"sort")),!i&&t.jsx(U,{variant:"link",size:"sm",onClick:()=>{r(),c({kind:"search"})},children:"Clear all"})]})},va="projects-view",qc=[{value:"list",label:"List"},{value:"board",label:"Board"},{value:"timeline",label:"Timeline"}];function Uc(){try{const e=localStorage.getItem(va);if(e==="board"||e==="timeline"||e==="list")return e}catch{}return"board"}function Bc(e){try{localStorage.setItem(va,e)}catch{}}const Yc=({value:e,onChange:s})=>t.jsx(Cr,{value:e,onValueChange:n=>s(n),children:t.jsx(Er,{"aria-label":"Project view","data-tour-tag":"projects-view-switcher",children:qc.map(n=>t.jsx(Rr,{value:n.value,children:n.label},n.value))})}),zc=["r1","r2","r3","r4","r5","r6"],Hc=4e3,xn={unpaired:"This app is not paired with the Local Operator server, so Projects are unavailable.","below-version":"The Local Operator server is older than this app expects, so Projects are unavailable. Update the server and try again.",unknown:"The server's capabilities could not be read, so Projects are unavailable."},ed=({nowMs:e=Date.now()})=>{const{projectId:s}=jr(),n=Rt(),a=Ge(),r=yr(a.data,"projects",1),i=r==="enabled",l=fe(a.data,"projects",Ki),o=yn(fe(a.data,"team_catalogue")),c=Xr(i),m=Zr(),u=An(),h=On(),[b,f]=d.useState(!1),[j,v]=d.useState(()=>Uc()),[g,x]=d.useState(()=>yi()),[y,C]=d.useState(null),[w,L]=d.useState(""),[T,_]=d.useState(zs),[O,p]=d.useState(()=>yo()),[A,E]=d.useState(""),P=d.useRef(""),Y=d.useRef(null),I=d.useRef(null),B=S=>{Y.current!==null&&(window.cancelAnimationFrame(Y.current),Y.current=null),S!==""&&S===P.current?(E(""),Y.current=window.requestAnimationFrame(()=>{Y.current=null,E(S)})):E(S),P.current=S,I.current!==null&&window.clearTimeout(I.current),I.current=window.setTimeout(()=>{I.current=null,P.current="",E("")},Hc)},W=()=>{Y.current!==null&&(window.cancelAnimationFrame(Y.current),Y.current=null),I.current!==null&&(window.clearTimeout(I.current),I.current=null),P.current="",E("")},V=S=>{L(S),W()},oe=S=>{_(S),W()},Q=d.useRef(null),X=ll(),k=c.data??[],N=vs(e),R=io(w,i&&l),M=Vn(w),F=d.useMemo(()=>R.answer?ao(k,R.answer.projects):null,[k,R.answer]),q=M!=="",ae=d.useMemo(()=>q?F??no(k,M):k,[k,M,q,F]),Ce=F===null?"client":"backend",z=d.useMemo(()=>fo(ae,T,N),[ae,T,N]),we=l&&q&&R.pending,xe=q||!it(T),me=d.useMemo(()=>Ls(k,g,e),[k,g,e]),J=d.useMemo(()=>Ls(z,g,e),[z,g,e]),Ee=ji(g),re=j==="board"?J.length:z.length,Je=!xe||!c.isSuccess?null:j==="board"?`${J.length} of ${me.length} in window`:`${z.length} of ${k.length} projects`,ee=c.isSuccess&&k.length>0,Ne=ee&&xe&&re===0&&!we,Me=we&&re===0&&ee,[Mt,Ze]=d.useState(!1);d.useEffect(()=>{if(!Mt)return;const S=document.querySelector('[data-tour-tag="projects-board-window"]');S&&(S.focus(),Ze(!1))}),d.useEffect(()=>{if(!i||s)return;const S=H=>{const K=H.target;if(!K||K.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(K.tagName)||K.closest('[role="dialog"]'))return;const je=H.key==="/"&&!H.metaKey&&!H.ctrlKey&&!H.altKey,se=(H.metaKey||H.ctrlKey)&&H.key.toLowerCase()==="f";!je&&!se||(H.preventDefault(),Q.current?.focus())};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[i,s]);const et=d.useRef(null);d.useLayoutEffect(()=>{if(!s)return;const S=et.current;S!==null&&(S.scrollTop=0)},[s]);const pt=Jr(j==="timeline"?k.map(S=>S.id):[],i),D=new Map(k.map((S,H)=>[S.id,pt[H]])),te=z.map(S=>({project:S,milestones:D.get(S.id)?.data?.project.milestones??[]})),tt=j==="timeline"?z.filter(S=>D.get(S.id)?.isLoading).length:0,ge=j==="timeline"?z.filter(S=>D.get(S.id)?.isError).length:0,xt=()=>{for(const S of pt)S.isError&&S.refetch()},Ie=S=>{p(S),vo(S),B(ko(S))},ka=(S,H)=>{_(K=>Xn(K,S,H)),W()},gt=()=>{const S=w.trim()!=="",H=!it(T),K=O!==null;L(""),_(zs),O!==null&&Ie(null),B(wo({search:S,filters:H,sort:K}))},Ns=()=>{x("all"),Fs("all"),Ze(!0)},[be,Ss]=d.useState(null),It=d.useRef(!1),Ts=()=>{It.current=!1,Ss(null)},[wa,_s]=d.useState([]),Na=fe(a.data,"projects_force_done"),Sa=(S,H)=>{const K=S.id,je=Z(H).label;_s(se=>se.includes(K)?se:[...se,K]),Ho({move:()=>u.mutateAsync({key:K,fields:{status:H}}),forceDoneOffered:Na,claimQuestion:()=>It.current?!1:(It.current=!0,!0)}).then(se=>{if(se.kind==="accepted"){ve(`Moved to ${je}`),c.refetch().then(()=>X(K));return}if(se.kind==="question"){Ss({project:S,status:H,refusal:se.refusal});return}le(se.copy,se.refusal?{action:{label:"View project",onClick:()=>void n(`/projects/${K}`)}}:void 0),X(K)}).finally(()=>{_s(se=>se.filter(Ta=>Ta!==K))})};return i?s?t.jsx("div",{ref:et,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(Sc,{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($s,{title:"Projects",icon:Ms,subtitle:"Workstreams you and your agents track across sessions.",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(U,{variant:"secondary",size:"icon","aria-label":"Refresh projects",title:"Refresh projects",disabled:c.isFetching,onClick:()=>void c.refetch(),"data-tour-tag":"refresh-projects-button",children:t.jsx(Pr,{})}),t.jsxs(U,{variant:"secondary",onClick:()=>f(!0),"data-tour-tag":"create-project-button",children:[t.jsx(rt,{}),"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(Yc,{value:j,onChange:S=>{v(S),Bc(S)}}),t.jsx(Lc,{projects:ae,query:w,onQueryChange:V,filters:T,onFiltersChange:oe,onClearAll:gt,todayMs:N,resultText:Je,countRevealClass:j==="board"?"@[47rem]:inline":void 0,disabled:c.isError,searchFieldRef:Q,trailing:j==="board"&&!(c.isSuccess&&c.data.length===0)?t.jsx(Ko,{value:g,onChange:S=>{x(S),Fs(S)}}):null})]}),t.jsx(Fc,{filters:T,sort:O,onFiltersChange:oe,onSortChange:Ie,onClearAll:gt,hideClearAll:Ne,searchFieldRef:Q}),t.jsx("output",{"data-project-announcement":"",className:"sr-only","aria-live":"polite",children:A})]})]}),t.jsxs("div",{className:"mt-8 flex min-h-0 flex-1 flex-col",children:[c.isLoading&&t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("output",{className:"px-9 py-2 text-meta text-ink-dim",children:"Loading projects…"}),zc.map(S=>t.jsxs("div",{className:"flex items-center gap-3 px-9 py-2","aria-hidden":"true",children:[t.jsx(Le,{className:"h-4 min-w-0 flex-1 bg-elevated"}),t.jsx(Le,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(Le,{className:"h-4 w-32 shrink-0 bg-elevated"}),t.jsx(Le,{className:"h-4 w-16 shrink-0 bg-elevated"}),t.jsx(Le,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(Le,{className:"h-4 w-40 shrink-0 bg-elevated"})]},S))]}),c.isError&&t.jsxs("div",{className:"flex flex-col items-start gap-2 px-6",children:[t.jsx(Ht,{variant:"danger",children:c.error instanceof Error&&c.error.message?c.error.message:"The projects could not be read."}),t.jsx(U,{variant:"secondary",size:"sm",onClick:()=>void c.refetch(),children:"Try again"})]}),c.isSuccess&&c.data.length===0&&t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-4",children:[t.jsx("p",{className:"text-heading text-ink",children:"No projects yet."}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:"Create one here, or ask an agent to create one and link this session."}),t.jsxs(U,{variant:"primary",onClick:()=>f(!0),"data-tour-tag":"create-project-empty-button",children:[t.jsx(rt,{}),"New project"]})]}),Me&&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:"Searching…"})}),ee&&Ne&&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()?`No projects match "${w.trim()}".`:"No projects match."}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:w.trim()?Wi[Ce]:"Try removing a filter. Clearing the filters restores the list."}),t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(U,{variant:"secondary",onClick:()=>{gt(),Q.current?.focus()},children:"Clear all"}),j==="board"&&z.length>0&&t.jsx(U,{variant:"secondary",onClick:Ns,children:"Show all time"})]})]}),ee&&!Ne&&!Me&&j==="list"&&t.jsx(Oc,{projects:z,nowMs:e,onOpen:S=>void n(`/projects/${S.id}`),sort:O,onSortChange:Ie,searchPopulation:ae,filters:T,query:w,todayMs:N,onToggleFilter:ka,onClearFilters:gt,teamLabelFor:o}),ee&&!Ne&&j==="board"&&J.length>0&&t.jsx(dl,{projects:J,nowMs:e,onOpen:S=>void n(`/projects/${S.id}`),onEdit:S=>void n(`/projects/${S.id}`),onDelete:C,onMove:Sa,teamLabelFor:o,movingKeys:wa}),ee&&!Ne&&!Me&&j==="board"&&J.length===0&&Ee!==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:Ee}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:"Older projects are hidden by the window."}),t.jsx(U,{variant:"secondary",onClick:Ns,children:"Show all time"})]}),ee&&!Ne&&!Me&&j==="timeline"&&t.jsx(Pc,{items:te,nowMs:e,onOpen:S=>void n(`/projects/${S.project.id}`),pendingDetails:tt,failedDetails:ge,onRetryDetails:xt,teamLabelFor:o})]}),t.jsx(da,{open:y!==null,projectName:y?.name??"",onClose:()=>C(null),onConfirm:async S=>{y&&(await h.mutateAsync({key:y.id,confirmedName:S}),ve("Project deleted"),C(null))}}),t.jsx(fa,{open:be!==null,refusal:be?.refusal??null,projectLabel:be?G(be.project):"",onClose:()=>{be&&X(be.project.id),Ts()},onConfirm:async()=>{if(!be)return;const{project:S,status:H,refusal:K}=be,je=await u.mutateAsync({key:S.id,fields:{status:H},forceDone:!0});ve(Gn(je,K.count,Z(H).label)),c.refetch().then(()=>X(S.id))},secondaryLabel:"Open project",onSecondary:()=>{const S=be?.project.id;Ts(),S&&n(`/projects/${S}`)}}),t.jsx(Tc,{open:b,onClose:()=>f(!1),onSubmit:async S=>{const H=await m.mutateAsync(S.fields),K=S.followUp?.title??S.fields.name;if(S.followUp)try{await u.mutateAsync({key:H.id,fields:S.followUp})}catch(je){const se=je instanceof Error&&je.message?je.message:"";le(`Project ${K} was created, but the extra fields were not saved: ${ft(se)||"the server refused them."} Open the project to set them in place.`);return}ve(`Project ${K} created`)}})]}):t.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[t.jsx($s,{title:"Projects",icon:Ms}),a.isLoading?t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(ke,{label:"Checking the server's Projects support"})}):t.jsx(Ht,{variant:"warning",children:xn[r]??xn.unknown})]})};export{ed as ProjectsPage};
|