local-operator-ui 0.31.30 → 0.31.32
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/main/index.js +121 -15
- package/out/preload/index.js +9 -0
- package/out/renderer/assets/{_basePickBy-Y9GC34gi.js → _basePickBy-BzFdg-GF.js} +1 -1
- package/out/renderer/assets/{_baseUniq-B0peOdjF.js → _baseUniq-Bm2KnnbI.js} +1 -1
- package/out/renderer/assets/{agent-details-page-DVzsvKvr.js → agent-details-page-BMiohCvb.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-Dp8llcze.js → agent-hub-page-CAJMRlDU.js} +1 -1
- package/out/renderer/assets/agents-page-GLKOnCr6.js +7 -0
- package/out/renderer/assets/{arc-DQzRvMGZ.js → arc-CcekKWMM.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-BHLUr3Vi.js → architectureDiagram-IEHRJDOE-8foMClj9.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-CVK0U-3j.js → blockDiagram-JOT3LUYC-DhfZvGTr.js} +1 -1
- package/out/renderer/assets/{book-open-j4JS3yvI.js → book-open-CueO0nwZ.js} +1 -1
- package/out/renderer/assets/browser-page-MbQ-dd2e.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-nwdqBWnv.js → browser-webauthn-prompt-DrMpnMBW.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-BqLTGVHe.js → c4Diagram-VJAJSXHY-BtAFjDFO.js} +1 -1
- package/out/renderer/assets/channel-er9Isqc8.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-BSPZPecM.js → chunk-4BMEZGHF-hEpjTUlR.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-CEEG3uIi.js → chunk-A2AXSNBT-BQE33qQV.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-CvyIUWUR.js → chunk-AEK57VVT-Bfv-VOfu.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-D4lVOdW7.js → chunk-D6G4REZN-CDEQDet7.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-znegx9P6.js → chunk-RZ5BOZE2-BHPvStD5.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-DPz_D8Nf.js → chunk-XZIHB7SX-DOAEvfwX.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-CiL29Sc-.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-CiL29Sc-.js +1 -0
- package/out/renderer/assets/clone-Bsk4HvnO.js +1 -0
- package/out/renderer/assets/{console-mirror-GUGtzmyW.js → console-mirror-CiDuCMfE.js} +1 -1
- package/out/renderer/assets/{consoleCapture-D8nStIVt.js → consoleCapture-PlJxiaGX.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-CGaXAqah.js → conversation-input-sync-zDEtF-9C.js} +237 -237
- package/out/renderer/assets/{dagre-OKDRZEBW-ByuMXl-x.js → dagre-OKDRZEBW-DY30NVKc.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-DrN1Clbm.js → diagram-SSKATNLV-Cj6GWkPW.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-BU95qC98.js → diagram-VNBRO52H-B1BnbNGr.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-CLttNK5z.js → erDiagram-Q7BY3M3F-Dt2TZzKY.js} +1 -1
- package/out/renderer/assets/error-boundary-BCN3_4Dn.js +126 -0
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-BCsFW1Gf.js → flowDiagram-4HSFHLVR-B0y5c9qz.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-Cdg1Q_-7.js → ganttDiagram-APWFNJXF-twBGRDsR.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-0tWQBOZl.js → gitGraphDiagram-7IBYFJ6S-vi21DxCt.js} +1 -1
- package/out/renderer/assets/{graph-BOvjqm1y.js → graph-BVnn4QNL.js} +1 -1
- package/out/renderer/assets/index-B4ItTI5Q.css +1 -0
- package/out/renderer/assets/{index-Bbr0EFhm.js → index-D94pB35A.js} +1 -1
- package/out/renderer/assets/{index-DbuNRNvX.js → index-Dwxu7UOq.js} +1 -1
- package/out/renderer/assets/index-QVureTEn.js +784 -0
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-cyj8Lve1.js → infoDiagram-PH2N3AL5-B-Ch65yi.js} +1 -1
- package/out/renderer/assets/{installer-DDGjYv9v.js → installer-DovMkJto.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-DWBKDniU.js → journeyDiagram-U35MCT3I-Bp6eVPe6.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-Cl5Gtazo.js → kanban-definition-NDS4AKOZ-D6I-GN7U.js} +1 -1
- package/out/renderer/assets/{layout-CxuQX-mj.js → layout-DFC3HVFP.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-EmhBvGX8.js → legacy-agents-page-Dfrz_ZCe.js} +2 -2
- package/out/renderer/assets/{mermaid.core-eIMT1oSc.js → mermaid.core-DKfPxzKU.js} +5 -5
- package/out/renderer/assets/mesh-page-DoKTWh-X.js +1 -0
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-zPRivaIU.js → mindmap-definition-ALO5MXBD-kM4s__rt.js} +1 -1
- package/out/renderer/assets/{mini-D6nPFjTs.js → mini-D0On64Oc.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-BeX5voGq.js → org-surface-gate-DArMk6ID.js} +1 -1
- package/out/renderer/assets/{page-header-BLBgjVqc.js → page-header-ouA0fPx9.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-CUTT0oqK.js → pieDiagram-IB7DONF6-DM1JhBgg.js} +1 -1
- package/out/renderer/assets/projects-page-Bb200mtz.js +55 -0
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-B6ksoL9Y.js → quadrantDiagram-7GDLP6J5-B8T16HnV.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-BpDoqWc2.js → radar-MK3ICKWK-DnM_Vl89.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-Ep1e0Z5I.js → radient-auth-buttons-Doso02jc.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-DQwmYS7R.js → requirementDiagram-KVF5MWMF-M7JjuiAa.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-Dc8VJLoV.js → sankeyDiagram-QLVOVGJD-pZ0w_k-t.js} +1 -1
- package/out/renderer/assets/{schedules-page-DyMkIr1h.js → schedules-page-OVNdDci6.js} +10 -10
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-SsVDN37O.js → sequenceDiagram-X6HHIX6F-B7YWpV3i.js} +1 -1
- package/out/renderer/assets/{settings-page-C_1ja3uN.js → settings-page-CrOBuOHy.js} +6 -6
- package/out/renderer/assets/{settings-section-BLUoPALO.js → settings-section-8d2ITQC3.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-vwQ-TB_f.js → stateDiagram-DGXRK772-DwDArxIb.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CEqnEMuN.js +1 -0
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-CQ_pAZms.js → timeline-definition-BDJGKUSR-COfMTtoJ.js} +1 -1
- package/out/renderer/assets/{ui-preferences-store-CxJfZcpf.js → ui-preferences-store-BaXpFsZf.js} +1 -1
- package/out/renderer/assets/{use-download-agent-mutation-DIujvdLj.js → use-download-agent-mutation-fP7MSQui.js} +2 -2
- package/out/renderer/assets/{use-memberships-query-BhO5nUlo.js → use-memberships-query-B_qwJ7_k.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-Cs3B-KEl.js → xychartDiagram-VJFVF3MP-COiK9nJs.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 +6 -6
- package/package.json +8 -3
- package/out/renderer/assets/agents-page-DlN3w0Rq.js +0 -7
- package/out/renderer/assets/browser-page-BI7a4ZtV.js +0 -1
- package/out/renderer/assets/channel-BP8e6HYH.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-DVXt0ycE.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-DVXt0ycE.js +0 -1
- package/out/renderer/assets/clone-D0eJwRGh.js +0 -1
- package/out/renderer/assets/error-boundary-BR1z8pWF.js +0 -126
- package/out/renderer/assets/index-Cy3MjKxd.css +0 -1
- package/out/renderer/assets/index-D09I1LXM.js +0 -784
- package/out/renderer/assets/mesh-page-B8pGIWvO.js +0 -1
- package/out/renderer/assets/projects-page-D60z6cvI.js +0 -55
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-D30uaRbQ.js +0 -1
- /package/out/renderer/assets/{index-CSNQxVPq.js → index-DvjcW_EJ.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t,c as P,r as h}from"./index-CSNQxVPq.js";import{aV as ke,aW as Ue,aX as Le,a as Ve,aY as ye,ag as Xe,aZ as Ke}from"./conversation-input-sync-CGaXAqah.js";import{P as qe}from"./page-header-BLBgjVqc.js";import{B as J,j as Ze,a as te,D as Je,k as Qe,l as et,m as tt,n as Ne,o as Ie,e as Ce,A as fe}from"./error-boundary-BR1z8pWF.js";import{e as st,N as nt,d as ve,f as it,g as le,D as rt,h as at,r as lt,i as we,j as ge,R as ot,k as oe,l as Te,m as Oe,s as dt,n as ue,o as xe,p as ct,q as ut,t as me,u as Se,v as mt,w as ht,z as pe,K as ft,x as We,y as xt,C as ze,E as pt,F as bt,G as gt,M as kt,H as vt,I as wt,J as jt,L as yt,O as Nt,Q as It,T as Ct,U as St,V as Mt,W as Dt,X as Et,Y as _t,Z as ae}from"./index-D09I1LXM.js";import"./ui-preferences-store-CxJfZcpf.js";import"./console-mirror-GUGtzmyW.js";const $t=4,he={kind:"idle"};function Rt(e){switch(e.kind){case"dragging":case"settling":return e.payload.session.id;case"pressing":return null;default:return null}}function Z(e,s){switch(s.kind){case"press":return e.kind!=="idle"?e:{kind:"pressing",payload:s.payload,originX:s.x,originY:s.y,pointerId:s.pointerId};case"move":return e.kind==="pressing"?Math.max(Math.abs(s.x-e.originX),Math.abs(s.y-e.originY))<$t?e:{kind:"dragging",payload:e.payload,x:s.x,y:s.y,target:s.target,pointerId:e.pointerId}:e.kind==="dragging"?{...e,x:s.x,y:s.y,target:s.target}:e;case"release":return e.kind==="dragging"?{kind:"settling",payload:e.payload,target:e.target}:e.kind==="pressing"?he:e;case"cancel":case"settled":return he;default:return e}}const Pt=({edges:e,geometry:s,selectedDeviceId:r})=>t.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0 overflow-visible",width:s.bounds.width,height:s.bounds.height,children:e.map(i=>{const o=s.networks.get(i.networkId),c=s.devices.get(i.deviceId);if(!o||!c)return null;const f=r!==null&&i.deviceId===r;return t.jsx("path",{"data-mesh-edge":i.key,d:st(o,c),fill:"none",strokeWidth:f?2:1.5,strokeDasharray:i.active?void 0:"4 4",className:f?"stroke-ink":"stroke-ink-dim"},i.key)})}),At={self:"border-l-hairline",reached:"border-l-hairline",unanswered:"border-l-warning","not-attempted":"border-l-hairline",unknown:"border-l-hairline"};function Lt(e){return e.suspect?"border-l-danger":At[le(e)]}const Tt={self:"ring-2 ring-accent",reachable:null,unreachable:null,suspect:null},Ot={accept:"border-accent bg-accent-wash",refuse:"border-warning"};function Wt(e,s,r){return[e.label,Oe(e,s),r].filter(Boolean).join(", ")}function se(e){return e.name.trim()||e.id.slice(-6)}function He(e,s,r){if(r!=="reached"&&r!=="self"){const i=oe(r);return e.unreachable_reason?`${i} (${e.unreachable_reason})`:i}return e.live_state.trim()?e.live_state.trim():e.locality==="local"?"on this device":`on ${s}`}const zt={resting:"border-l-2 border-l-hairline",attention:"border-l-2 border-l-warning"},Ht=({network:e,x:s,y:r,refused:i})=>t.jsxs("li",{"data-mesh-network":e.id,"data-mesh-network-refused":i?"true":void 0,className:P("absolute flex items-center gap-2 rounded-md border bg-elevated px-3",i?"border-warning":"border-hairline"),style:{left:s,top:r,width:ve,height:nt},children:[t.jsx(ke,{"aria-hidden":"true",className:"size-4 shrink-0 text-ink-muted"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-body-sm text-ink",children:e.label}),t.jsxs("span",{title:`epoch ${e.epoch}`,className:"block truncate text-meta text-ink-dim",children:[e.memberCount," ",e.memberCount===1?"device":"devices",e.revokedCount>0?` · ${e.revokedCount} revoked`:""]})]})]}),Bt=({device:e,x:s,y:r,nowSeconds:i,selected:o,sessions:c,sessionTotal:f,dropState:a,movingSessionId:b,draggedSessionId:j,onOpen:N,onChipPointerDown:S,onChipClick:C,onShowAllSessions:l})=>{const{activity:d}=it(e,c.rows),m=d==="working",w=Wt(e,i,m?"working":null),g=le(e);return t.jsxs("li",{"data-mesh-device":e.id,"data-mesh-state":e.state,"data-mesh-drop":a??void 0,"aria-current":o?"true":void 0,className:P("absolute flex flex-col rounded-md border border-l-4 border-control bg-elevated","hover:bg-row-hover",o&&"border-y-ink border-r-ink bg-row-selected",Lt(e),Tt[e.state],a&&Ot[a]),style:{left:s,top:r,width:ve,height:rt},children:[t.jsxs("button",{type:"button","data-mesh-device-open":e.id,"data-mesh-reach":g,"aria-label":w,title:lt(e),onClick:()=>N(e.id),className:P("flex w-full flex-col justify-between rounded-t-[5px] px-3 pt-2 pb-2 text-left","cursor-pointer","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-[-2px]"),style:{height:at},children:[t.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[t.jsx(Ue,{"aria-hidden":"true",className:"size-4 shrink-0 text-ink-muted"}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:e.label}),e.suspect&&t.jsx(we,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"})]}),t.jsxs("span",{className:"flex w-full min-w-0 items-baseline gap-1",children:[t.jsx("span",{className:"w-3 shrink-0 font-mono text-body-sm text-ink tabular-nums",children:e.sessionCount??"–"}),t.jsx("span",{className:P("min-w-0 truncate text-meta",e.sessionCount===null?"text-ink-dim":"text-ink-muted"),children:ge(e.sessionCount)})]}),t.jsxs("span",{"data-mesh-state-line":"",className:"flex w-full min-w-0 items-baseline gap-1.5 text-meta",children:[t.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-ink-dim",children:ot[g]}),t.jsx("span",{className:P("shrink-0",Te[g]),children:oe(g)}),m&&t.jsx("span",{"data-mesh-working":"",className:"shrink-0 text-info",children:"working"}),e.memberships.length>1&&t.jsxs("span",{className:"min-w-0 truncate text-ink-dim",children:["· ",e.memberships.length," networks"]})]})]}),t.jsxs("ul",{"aria-label":`Conversations on ${e.label}`,className:P("m-0 flex h-6 list-none items-center gap-1 overflow-hidden px-3",a==="accept"&&"opacity-40"),children:[c.shown.map(x=>t.jsx(Yt,{session:x,ownerLabel:e.label,ownerReach:g,ownerReachable:e.reachable,moving:b===x.id,dragging:j===x.id,onPointerDown:S,onClick:()=>C(x)},x.id)),c.hidden>0&&t.jsx("li",{className:"shrink-0",children:t.jsxs("button",{type:"button","data-mesh-more":e.id,onClick:()=>l(e.id),className:P("flex min-h-6 items-center rounded-sm px-1.5 text-meta text-ink-dim","hover:bg-row-hover hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),title:`Showing ${c.shown.length} of ${f} conversations`,"aria-label":`Show all ${f} conversations`,children:["+",c.hidden]})})]})]})},Yt=({session:e,ownerLabel:s,ownerReach:r,ownerReachable:i,moving:o,dragging:c,onPointerDown:f,onClick:a})=>{const b=He(e,s,r);return o?t.jsx("li",{role:"status","data-mesh-session":e.id,"data-mesh-moving":"true",children:t.jsx("span",{className:"flex min-h-6 items-center rounded-sm bg-sunken px-1.5 text-meta text-ink-muted",children:"moving…"})}):t.jsx("li",{className:"min-w-0 flex-1","data-mesh-session-item":e.id,"data-mesh-dragging":c?"true":void 0,children:t.jsx("button",{type:"button","data-mesh-session":e.id,style:{touchAction:"none"},title:`${se(e)} · ${b}`,"aria-label":`${se(e)}, ${b}. Opens ${s}.`,onPointerDown:j=>f(j,e),onClick:()=>a(e),className:P("flex min-h-6 w-full max-w-32 items-center rounded-sm border border-hairline bg-surface px-1.5 text-left text-meta text-ink-muted","cursor-grab active:cursor-grabbing","hover:text-ink",zt[dt(e,i)],c&&"opacity-60","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),children:t.jsx("span",{className:"min-w-0 flex-1 truncate [direction:rtl]",children:se(e)})})})};function Me(e){const s=e.trim();if(!s)return null;if(s.startsWith("[")){const i=s.indexOf("]");if(i<=1)return null;const o=s.slice(1,i),c=s.slice(i+1);if(!c)return{host:o,port:null};if(!c.startsWith(":"))return null;const f=Number(c.slice(1));return{host:o,port:Number.isInteger(f)?f:null}}const r=s.lastIndexOf(":");if(r>0){const i=s.slice(r+1);if(/^\d+$/.test(i))return{host:s.slice(0,r),port:Number(i)}}return{host:s,port:null}}function De(e){const s=e.trim().split(".");if(s.length!==4)return null;for(const r of s)if(!/^\d{1,3}$/.test(r)||Number(r)>255)return null;return`${s[0]}.${s[1]}.${s[2]}`}function Ft(e){return`${e}.x`}function Gt(e){const s=new Map;for(const i of e.values())for(const o of i)s.set(o,(s.get(o)??0)+1);const r=new Set;for(const[i,o]of s)o>1&&r.add(i);return r}function be(e){return new Set(e.endpoints.map(s=>s.trim()).filter(Boolean))}function Ut(e,s){const r=e.filter(l=>l.id!==s),i=e.find(l=>l.id===s)??null,o=new Map;for(const l of e)o.set(l.id,be(l));const c=Gt(o),f=new Set;for(const l of i?be(i):[]){if(c.has(l))continue;const d=Me(l),m=d?De(d.host):null;m&&f.add(m)}const a=l=>{const d=new Set;for(const m of be(l)){if(c.has(m))continue;const w=Me(m),g=w?De(w.host):null;g&&d.add(g)}return d},b=new Map,j=new Map;for(const l of r){const d=Vt(l);if(d){b.set(d,[...b.get(d)??[],l.id]);continue}for(const m of a(l))j.set(m,[...j.get(m)??[],l.id])}const N=new Map(e.map((l,d)=>[l.id,d])),S=l=>[...l].sort((d,m)=>(N.get(d)??0)-(N.get(m)??0)),C=[];for(const[l,d]of b)C.push({prefix:l,tier:"declared",deviceIds:S(d),words:"declared"});for(const[l,d]of j)f.has(l)?C.push({prefix:l,tier:"shared",deviceIds:S(d),words:"shared with this device"}):d.length>1&&C.push({prefix:l,tier:"probable",deviceIds:S(d),words:"same prefix"});return C.sort((l,d)=>l.tier.localeCompare(d.tier)||l.prefix.localeCompare(d.prefix))}function Vt(e){for(const s of e.memberships){const r=s.scope.trim();if(r)return r}return""}const Ee={declared:0,shared:1,probable:2};function Xt(e,s){const r=new Map;for(const o of e){let c=null;for(const a of o.deviceIds){const b=s.get(a);b!==void 0&&(c===null||b<c.slot)&&(c={id:a,slot:b})}if(c===null)continue;const f=r.get(c.id);f===void 0?r.set(c.id,{slot:c.slot,groups:[o]}):f.groups.push(o)}const i=o=>{let c=-1;for(const f of o.deviceIds){const a=s.get(f);a!==void 0&&a>c&&(c=a)}return c};return[...r.entries()].sort((o,c)=>o[1].slot-c[1].slot).map(([o,c])=>({deviceId:o,groups:c.groups.sort((f,a)=>i(a)-i(f)||Ee[f.tier]-Ee[a.tier]||f.prefix.localeCompare(a.prefix))}))}function Kt(e){return new Map(e.map(s=>[s.deviceId,s.groups.length]))}function qt(e){return`${e.tier==="declared"?e.prefix:Ft(e.prefix)} · ${e.words}`}const _e=(e,s)=>e.deviceIds.map(r=>s.devices.get(r)).filter(r=>r!==void 0),Zt=({stacks:e,geometry:s})=>t.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0",children:e.map(r=>{const i=r.groups.length,o=new Array(i).fill(0);let c=null;for(let a=i-1;a>=0;a-=1){const b=_e(r.groups[a],s),j=(b.length===0?0:Math.max(...b.map(N=>N.y+N.height)))+ue;c=c===null?j:Math.max(j,c+xe),o[a]=c}const f=s.devices.get(r.deviceId);return r.groups.map((a,b)=>{const j=_e(a,s);if(j.length===0)return null;const N=i-1-b,S=Math.min(...j.map(g=>g.x)),C=Math.max(...j.map(g=>g.x)),d=(f?.y??Math.min(...j.map(g=>g.y)))-ue-ct*N,m=a.tier==="declared",w=qt(a);return t.jsx("div",{"data-mesh-scope":`${a.tier}:${a.prefix}`,"data-mesh-scope-level":b,className:P("absolute rounded-lg",a.tier==="probable"?"border border-dashed border-hairline-strong":"border border-control"),style:{left:S-ue-xe*N,top:d,width:C+ve-S+(ue+xe*N)*2,height:o[b]-d},children:t.jsx("span",{"data-mesh-scope-label":"",className:P("absolute bottom-full left-1 mb-0.5 whitespace-nowrap text-meta",a.tier==="probable"?"text-ink-dim":"text-ink-muted",m&&"font-medium"),children:w})},`${a.tier}:${a.prefix}`)})})}),$e=48,Re=1.25,Jt=.0015,Qt=({graph:e,slots:s,nowSeconds:r,selectedDeviceId:i,sessions:o,sessionTotals:c,movingSessionId:f,canMove:a,onOpenDevice:b,onAskMove:j,onDropRefused:N,onShowAllSessions:S,summaryId:C})=>{const l=h.useRef(null),[d,m]=h.useState({width:0,height:0,clipWidth:0,clipHeight:0,left:0,top:0}),[w,g]=h.useState({k:1,tx:0,ty:0}),x=h.useRef(!1),D=h.useRef(!1),A=h.useRef(null),L=h.useMemo(()=>Ut(e.devices,e.selfDeviceId),[e.devices,e.selfDeviceId]),M=h.useMemo(()=>Xt(L,s.devices),[L,s]),I=h.useMemo(()=>ut(s,Kt(M)),[s,M]),B=h.useMemo(()=>({selfDeviceId:e.selfDeviceId,devices:new Map(e.devices.map(n=>[n.id,n])),networks:new Map(e.networks.map(n=>[n.id,n]))}),[e]),[k,W]=h.useState(he),ne=h.useRef({kind:"ground"}),U=h.useCallback((n,u)=>{const p=document.elementFromPoint(n,u),R=p?.closest("[data-mesh-device]");if(R){const E=R.getAttribute("data-mesh-device");if(E)return{kind:"device",deviceId:E}}const Y=p?.closest("[data-mesh-network]");if(Y){const E=Y.getAttribute("data-mesh-network");if(E)return{kind:"network",networkId:E}}return{kind:"ground"}},[]),T=h.useMemo(()=>k.kind!=="dragging"&&k.kind!=="settling"?null:me(k.payload,k.target,B),[k,B]),ie=h.useCallback(n=>{if(!T)return null;if(T.kind==="plan"){const u=k.kind==="dragging"||k.kind==="settling"?k.target:null;return u&&u.kind==="device"&&u.deviceId===n?"accept":null}if(T.kind==="refused"){const u=k.kind==="dragging"||k.kind==="settling"?k.target:null;return u&&u.kind==="device"&&u.deviceId===n?"refuse":null}return null},[T,k]),re=h.useCallback((n,u)=>{if(!a||n.button!==0)return;D.current=!1;const p=u.locality==="local"?e.selfDeviceId??"":u.owner_device,R=B.devices.get(p),Y={session:u,ownerDeviceId:p,ownerLabel:R?.label??u.owner_device_name};try{n.currentTarget.setPointerCapture(n.pointerId)}catch{}W(E=>Z(E,{kind:"press",payload:Y,x:n.clientX,y:n.clientY,pointerId:n.pointerId}))},[a,B,e.selfDeviceId]),v=n=>{if(k.kind==="pressing"||k.kind==="dragging"){const u=U(n.clientX,n.clientY);ne.current=u,W(p=>Z(p,{kind:"move",x:n.clientX,y:n.clientY,target:u}));return}Q(n)},O=n=>{if(q(n),k.kind!=="pressing"&&k.kind!=="dragging")return;if(k.kind==="pressing"){W(p=>Z(p,{kind:"cancel"}));return}const u=me(k.payload,k.target,B);D.current=!0,W(p=>Z(p,{kind:"release"})),u.kind==="plan"?j({plan:u.plan,alternatives:u.alternatives,risky:u.risky}):u.kind==="refused"&&N({code:u.code,sentence:u.sentence,remedy:u.remedy,plan:u.plan??null}),W(p=>Z(p,{kind:"settled"}))};h.useEffect(()=>()=>W(he),[]);const z=h.useCallback(()=>{g(Se(I.bounds,d))},[I.bounds,d]);h.useEffect(()=>{const n=l.current;if(!n)return;const u=()=>{const R=n.getBoundingClientRect();m({width:R.width,height:R.height,clipWidth:n.clientWidth,clipHeight:n.clientHeight,left:R.left,top:R.top})};u();const p=new ResizeObserver(u);return p.observe(n),()=>p.disconnect()},[]),h.useEffect(()=>{x.current||d.width<=0||d.height<=0||(x.current=!0,g(Se(I.bounds,d)))},[d,I.bounds]),h.useEffect(()=>{const n=A.current;if(A.current={width:d.width,height:d.height},!n||!x.current||d.width<=0||d.height<=0||d.width>=n.width&&d.height>=n.height||!i)return;const u=I.devices.get(i);u&&g(p=>{const R={width:d.clipWidth,height:d.clipHeight},Y=Math.max(0,Math.min(R.width-I.bounds.width*p.k,R.height-I.bounds.height*p.k));return mt(p,u,R,Math.min(ft,Y))})},[d,i,I]);const _=k.kind==="dragging"?{x:k.x-d.left+12,y:k.y-d.top+12}:{x:0,y:0},$=T?ht(T):null,H=h.useRef(null),V=h.useRef(null),K=h.useRef(null),X=h.useRef(null),de=h.useCallback(()=>{K.current=null;const n=H.current,u=V.current;if(H.current=null,V.current=null,n){const p=X.current;if(!p)return;g({k:p.transform.k,tx:p.transform.tx+(n.x-p.x),ty:p.transform.ty+(n.y-p.y)});return}u&&g(p=>pe(p,{x:u.x,y:u.y},p.k*Math.exp(-u.deltaY*Jt)))},[]),F=h.useCallback(()=>{K.current===null&&(K.current=requestAnimationFrame(de))},[de]);h.useEffect(()=>()=>{K.current!==null&&cancelAnimationFrame(K.current)},[]);const ce=n=>{!(n.target===n.currentTarget)&&n.button!==1||n.button!==0&&n.button!==1||(X.current={x:n.clientX,y:n.clientY,transform:w},n.currentTarget.setPointerCapture(n.pointerId),n.preventDefault())},Q=n=>{X.current&&(H.current={x:n.clientX,y:n.clientY},F())},q=n=>{X.current&&(X.current=null,H.current=null,n.currentTarget.hasPointerCapture(n.pointerId)&&n.currentTarget.releasePointerCapture(n.pointerId))},ee=h.useCallback(n=>{if(n.deltaY===0)return;n.preventDefault();const u=n.currentTarget.getBoundingClientRect();V.current={x:n.clientX-u.left,y:n.clientY-u.top,deltaY:n.deltaY},F()},[F]);h.useEffect(()=>{const n=l.current;if(n)return n.addEventListener("wheel",ee,{passive:!1}),()=>n.removeEventListener("wheel",ee)},[ee]);const y=n=>{const u=n.shiftKey?$e*4:$e;switch(n.key){case"Escape":if(k.kind!=="pressing"&&k.kind!=="dragging")return;n.preventDefault(),k.kind==="dragging"&&(D.current=!0),W(p=>Z(p,{kind:"cancel"}));return;case"0":n.preventDefault(),z();return;case"+":case"=":n.preventDefault(),g(p=>pe(p,{x:d.width/2,y:d.height/2},p.k*Re));return;case"-":case"_":n.preventDefault(),g(p=>pe(p,{x:d.width/2,y:d.height/2},p.k/Re));return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{n.preventDefault();const p=n.key==="ArrowLeft"?u:n.key==="ArrowRight"?-u:0,R=n.key==="ArrowUp"?u:n.key==="ArrowDown"?-u:0;g(Y=>({...Y,tx:Y.tx+p,ty:Y.ty+R}));return}}};return t.jsxs("div",{ref:l,"data-mesh-canvas":"",role:"group","aria-labelledby":C,tabIndex:0,onPointerDown:ce,onPointerMove:v,onPointerUp:O,onPointerCancel:n=>{k.kind==="dragging"&&(D.current=!0),W(u=>Z(u,{kind:"cancel"})),q(n)},"data-mesh-gesture":k.kind,onKeyDown:y,onDoubleClick:n=>{n.target===n.currentTarget&&z()},className:P("relative min-h-0 flex-1 overflow-hidden rounded-lg border border-hairline bg-sunken","[touch-action:none]","cursor-grab active:cursor-grabbing","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-[-2px]"),children:[t.jsx("div",{"data-mesh-ground":"","aria-hidden":"true",className:"mesh-ground pointer-events-none absolute inset-0",style:{backgroundPosition:`${w.tx}px ${w.ty}px`}}),t.jsxs("div",{"data-mesh-world":"",className:"absolute top-0 left-0",style:{transform:`translate3d(${w.tx}px, ${w.ty}px, 0) scale(${w.k})`,transformOrigin:"0 0",width:I.bounds.width,height:I.bounds.height},children:[t.jsx(Zt,{stacks:M,geometry:I}),t.jsx(Pt,{edges:e.edges,geometry:I,selectedDeviceId:i}),t.jsx("ul",{"aria-label":"Networks",className:"m-0 list-none p-0",children:e.networks.map(n=>{const u=I.networks.get(n.id);return u?t.jsx(Ht,{network:n,x:u.x,y:u.y,refused:T?.kind==="refused"&&k.kind==="dragging"&&k.target.kind==="network"&&k.target.networkId===n.id},n.id):null})}),t.jsx("ul",{"aria-label":"Devices",className:"m-0 list-none p-0",children:e.devices.map(n=>{const u=I.devices.get(n.id);return u?t.jsx(Bt,{device:n,x:u.x,y:u.y,nowSeconds:r,selected:n.id===i,sessions:o.get(n.id)??{rows:[],shown:[],hidden:0},sessionTotal:c.get(n.id)??n.sessionCount??0,dropState:ie(n.id),movingSessionId:f,draggedSessionId:Rt(k),onOpen:b,onChipPointerDown:re,onChipClick:()=>{if(D.current){D.current=!1;return}b(n.id)},onShowAllSessions:S},n.id):null})})]}),k.kind==="dragging"&&t.jsx("div",{"data-mesh-ghost":"","aria-hidden":"true",className:"pointer-events-none absolute z-10 max-w-40 truncate rounded-sm border border-ink-dim bg-surface px-1.5 py-0.5 text-meta text-ink",style:{left:_.x,top:_.y},children:k.payload.session.name||"untitled"}),k.kind==="dragging"&&$&&t.jsx("div",{"data-mesh-indicator":"",className:P("pointer-events-none absolute z-10 rounded-sm border bg-surface px-2 py-1 text-meta",T?.kind==="refused"?"border-warning text-warning":"border-control text-ink"),style:{left:_.x,maxWidth:Math.max(160,d.width-_.x-12),..._.y>d.height*.6?{bottom:Math.max(12,d.height-_.y+8)}:{top:_.y+24}},children:$})]})};function es(e,s,r,i){const o=r.locality==="local"?s:r.owner_device,c=[];for(const f of e)if(f.id!==o){if(f.id===s){c.push({deviceId:f.id,label:i,verb:"Recall to this device",keepVerb:"Copy here, leave it there"});continue}c.push({deviceId:f.id,label:f.label,verb:`Move to ${f.label}`,keepVerb:`Copy to ${f.label}`})}return c}function ts(e,s,r){return es(e.devices,e.selfDeviceId,s,r)}function Be(e,s,r){const i=ts(e,s,r),o={selfDeviceId:e.selfDeviceId,devices:new Map(e.devices.map(a=>[a.id,a])),networks:new Map(e.networks.map(a=>[a.id,a]))},c=s.locality==="local"?e.selfDeviceId??"":s.owner_device,f=o.devices.get(c);return i.map(a=>{const b=me({session:s,ownerDeviceId:c,ownerLabel:f?.label??s.owner_device_name},{kind:"device",deviceId:a.deviceId},o);return{...a,refused:b.kind==="refused"&&b.code!=="busy"?b.sentence:null}})}const Ye=({session:e,destinations:s,disabled:r,onChoose:i,onOpenChange:o,trigger:c,triggerLabel:f})=>t.jsxs(Je,{onOpenChange:o,children:[t.jsx(Qe,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":f,"data-mesh-session-menu":e.id,disabled:r||s.length===0,className:"rounded-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2 disabled:text-ink-disabled",children:c})}),t.jsxs(et,{align:"start",className:"min-w-56",children:[t.jsx(tt,{children:se(e)}),t.jsx(Ne,{}),s.map(a=>t.jsx(Ie,{"data-mesh-move-to":a.deviceId,disabled:!!a.refused,title:a.refused??void 0,onSelect:()=>i(a,!1),children:a.verb},a.deviceId)),t.jsx(Ne,{}),s.map(a=>t.jsx(Ie,{"data-mesh-copy-to":a.deviceId,disabled:!!a.refused,title:a.refused??void 0,onSelect:()=>i(a,!0),children:a.keepVerb},`keep-${a.deviceId}`))]})]}),ss=({device:e,sessions:s,sessionTotal:r,nowSeconds:i,destinationsFor:o,movingSessionId:c,canMove:f,canInvite:a,onClose:b,onMove:j,onShowInList:N,onInvite:S,onRemoveMember:C})=>{const l=le(e);h.useEffect(()=>{const x=D=>{D.key!=="Escape"||D.defaultPrevented||D.target?.closest('[role="menu"],[role="dialog"]')||(document.querySelector(`[data-mesh-device-open="${e.id}"]`)?.focus(),b())};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[e.id,b]);const d=e.memberships.every(x=>!x.active),m=e.sessionCount===null?ge(null):`${e.sessionCount} ${ge(e.sessionCount)}`,w=e.suspect?We:[d?"revoked membership":m,oe(l)].filter(Boolean).join(" · "),g=r>s.rows.length?`${s.rows.length} of ${r}`:`${s.rows.length}`;return t.jsxs("aside",{"aria-label":`${e.label} details`,"data-mesh-panel":e.id,className:"flex w-80 shrink-0 flex-col gap-3 overflow-y-auto rounded-md border border-hairline bg-surface p-4",children:[t.jsxs("header",{className:"flex flex-col gap-1",children:[t.jsx(J,{size:"sm",variant:"ghost",className:"w-fit self-end","data-mesh-panel-close":"",onClick:b,children:"Close"}),t.jsx("h2",{className:"text-body-sm text-ink",children:e.label}),t.jsxs("p",{className:"flex items-center gap-1.5 text-meta text-ink-muted",children:[e.suspect&&t.jsx(we,{"aria-hidden":"true",className:"size-3.5 text-danger"}),!e.suspect&&l==="unanswered"&&t.jsx(Ze,{"aria-hidden":"true",className:"size-3.5 text-warning"}),w]})]}),t.jsx(te,{}),t.jsxs("section",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"text-meta text-ink-dim",children:"Memberships"}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:e.memberships.map(x=>t.jsxs("li",{className:"flex flex-col gap-1",children:[t.jsxs("span",{className:"flex items-center gap-2 text-body-sm text-ink",children:[t.jsx(ke,{"aria-hidden":"true",className:"size-3.5 text-ink-muted"}),x.networkName]}),t.jsxs("span",{className:"text-meta text-ink-dim",children:[x.role||"member",x.capabilities.length>0?` · ${x.capabilities.join(", ")}`:"",x.active?"":" · revoked"]}),a&&x.active&&t.jsxs(J,{size:"sm",variant:"ghost",className:"w-fit","data-mesh-remove-member":`${x.networkId}:${e.id}`,onClick:()=>C(e,x.networkId),children:["Remove from ",x.networkName,"…"]})]},x.networkId))}),a&&t.jsx(J,{size:"sm",variant:"secondary",className:"w-fit","data-mesh-invite":e.id,onClick:()=>S(e),children:"Invite to a network…"})]}),t.jsx(te,{}),t.jsxs("section",{className:"flex min-h-0 flex-col gap-2",children:[t.jsxs("h3",{className:"text-meta text-ink-dim",children:["Conversations ",t.jsxs("span",{className:"text-ink-disabled",children:["(",g,")"]})]}),s.rows.length===0?t.jsx("p",{className:"text-meta text-ink-dim",children:e.sessionCount===null?"This device did not report its conversations.":"No conversations here."}):t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:s.rows.map(x=>t.jsxs("li",{"data-mesh-panel-session":x.id,className:P("flex items-center gap-2 rounded-sm px-2 py-1","border border-hairline bg-elevated",c===x.id&&"border-control"),children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:se(x)}),t.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:He(x,e.label,le(e))}),c===x.id?t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:"moving…"}):t.jsx(Ye,{session:x,destinations:o(x),disabled:!f,onChoose:(D,A)=>j(x,D,A),trigger:t.jsx(Le,{"aria-hidden":"true",className:"size-4"}),triggerLabel:`Move ${se(x)}`})]},x.id))})]}),t.jsx(te,{}),t.jsxs("section",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"text-meta text-ink-dim",children:"Network addresses"}),e.endpoints.length===0?t.jsx("p",{className:"text-meta text-ink-dim",children:"No address published."}):t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:e.endpoints.map(x=>t.jsxs("li",{className:"flex items-baseline justify-between gap-2",children:[t.jsx("span",{className:"min-w-0 truncate font-mono text-body-sm text-ink",children:x}),t.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:"advertised"})]},x))})]}),t.jsx(te,{}),t.jsxs("section",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"text-meta text-ink-dim",children:"Status"}),t.jsxs("dl",{className:"m-0 flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[t.jsx("dt",{className:"text-meta text-ink-dim",children:"Reach"}),t.jsx("dd",{className:"m-0 text-body-sm text-ink",children:oe(l)})]}),t.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[t.jsx("dt",{className:"text-meta text-ink-dim",children:"Last status frame"}),t.jsx("dd",{className:"m-0 text-body-sm text-ink",children:e.lastSeenAt===null?"never":xt(i-e.lastSeenAt)})]})]}),e.reason&&t.jsx("p",{className:"text-meta text-warning",children:e.reason})]}),t.jsx(te,{}),t.jsx(J,{size:"sm",variant:"ghost",className:"w-fit","data-mesh-show-in-list":e.id,onClick:()=>N(e.id),children:"Show in list"})]})},ns=["name","chats","state"],is={name:"Name",chats:"Conversations",state:"State"},Pe={suspect:0,unreachable:1,self:2,reachable:3};function rs(e,s){const r=[...e];switch(s){case"chats":return r.sort((i,o)=>(o.sessionCount??-1)-(i.sessionCount??-1)||i.label.localeCompare(o.label)),r;case"state":return r.sort((i,o)=>Pe[i.state]-Pe[o.state]||i.label.localeCompare(o.label)),r;default:return r.sort((i,o)=>i.label.localeCompare(o.label))}}const Ae=8;function as(e,s){if(e.locality==="local")return e.live_state||"here";const r=e.owner_device_name||s,i=e.live_state?` · ${e.live_state}`:"";return e.reachable?`on ${r}${i}`:`on ${r} (not answering)`}const ls=({graph:e,nowSeconds:s,selectedDeviceId:r,sessions:i,selfLabel:o,canMove:c,onSelect:f,onMove:a,onInvite:b,onRemove:j})=>{const[N,S]=h.useState("name"),C=h.useMemo(()=>e.networks.map(l=>({network:l,members:rs(e.devices.filter(d=>d.memberships.some(m=>m.networkId===l.id)),N)})),[e,N]);return t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto pr-1",children:[t.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:"Sort devices by"}),t.jsx("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:ns.map(l=>t.jsx("button",{type:"button","aria-pressed":N===l,onClick:()=>S(l),className:P("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",N===l&&"bg-surface text-ink"),children:is[l]},l))})]}),C.map(({network:l,members:d})=>t.jsxs("section",{"data-mesh-network-group":l.id,className:"flex flex-col gap-2",children:[t.jsxs("h2",{className:"flex flex-wrap items-baseline gap-2 text-body-sm text-ink",title:`epoch ${l.epoch}`,children:[l.label,t.jsxs("span",{className:"text-meta text-ink-dim",children:[l.trust," · ",l.memberCount," ",l.memberCount===1?"device":"devices",l.revokedCount>0?` · ${l.revokedCount} revoked`:""]})]}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:d.map(m=>{const w=m.memberships.find(M=>M.networkId===l.id),g=m.id===r,x=i.get(m.id),D=x?.rows??[],A=x?ze(x,m.sessionCount):m.sessionCount??0,L=le(m);return t.jsxs("li",{"data-mesh-device-row":m.id,"data-mesh-state":m.state,"aria-current":g?"true":void 0,className:P("flex flex-col gap-1 rounded-md px-3 py-2","border border-hairline bg-surface",g&&"border-ink bg-row-selected"),children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1",children:[t.jsx("button",{type:"button","data-mesh-device-open":m.id,onClick:()=>f(m.id),className:P("min-w-0 flex-1 truncate text-left text-body-sm text-ink","hover:text-ink-muted","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),children:m.label}),t.jsxs("span",{className:P("flex shrink-0 items-center gap-1 text-meta",Te[L]),"data-mesh-reach":L,children:[m.suspect&&t.jsx(we,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"}),m.suspect?oe(L):Oe(m,s),m.suspect&&t.jsx("span",{className:"shrink-0 rounded-sm border border-danger px-1 text-danger",children:We})]}),t.jsxs("span",{className:"shrink-0 text-meta text-ink-dim",children:[w?.role?`${w.role} · `:"",w&&!w.active?"revoked":"member"]})]}),D.length>0?t.jsxs(t.Fragment,{children:[t.jsx(te,{className:"my-1"}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-0.5 p-0",children:D.slice(0,Ae).map(M=>t.jsxs("li",{"data-mesh-row-session":M.id,className:"flex items-center gap-2 py-0.5",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-meta text-ink-muted",children:M.name||M.id}),t.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:as(M,o)}),t.jsx(Ye,{session:M,destinations:Be(e,M,o),disabled:!c,onChoose:(I,B)=>a(M,I,B),trigger:t.jsx(Le,{"aria-hidden":"true",className:"size-3.5"}),triggerLabel:`Move ${M.name||M.id}`})]},M.id))}),A>D.slice(0,Ae).length&&t.jsx("button",{type:"button",onClick:()=>f(m.id),className:"w-fit text-meta text-ink-dim hover:text-ink",children:`show all ${A} in the panel`})]}):t.jsx("span",{className:"text-meta text-ink-dim",children:A===0?"no conversations":A===1?"1 conversation":`${A} conversations`}),(w?.active||m.state!=="self")&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[t.jsx(J,{size:"sm",variant:"ghost","data-mesh-invite":m.id,onClick:()=>b({deviceId:m.id,deviceLabel:m.label}),children:"Invite to a network…"}),w?.active&&t.jsxs(J,{size:"sm",variant:"ghost","data-mesh-remove-member":`${l.id}:${m.id}`,onClick:()=>j({networkId:l.id,networkLabel:l.label,deviceId:m.id,deviceLabel:m.label}),children:["Remove from ",l.label,"…"]})]})]},m.id)})})]},l.id)),e.unmatchedPeers.length>0&&t.jsxs("p",{className:"text-meta text-warning",children:[e.unmatchedPeers.length," ",e.unmatchedPeers.length===1?"device":"devices"," answered the peer read but is in no network this app can name."]})]})},os=["canvas","list"],ds={canvas:"Canvas",list:"List"},cs=({state:e,graph:s,nowSeconds:r,checking:i,staleError:o,onRetry:c,sessions:f,sessionError:a,selfLabel:b,movingSessionId:j,canMove:N,pendingMove:S,onAskMove:C,onDropRefused:l,onChooseMove:d,onCancelMove:m,moveBusy:w,moveReport:g,onDismissReport:x,onWaitForIdle:D,onUndoCopy:A,invite:L,onOpenInvite:M,onInvite:I,onCloseInvite:B,inviteBusy:k,inviteReceipt:W,inviteRefusal:ne,remove:U,onOpenRemove:T,onRemove:ie,onCloseRemove:re,removeBusy:v,removeRefusal:O,removed:z})=>{const[_,$]=h.useState("canvas"),[H,V]=h.useState(null),K=s?pt(s):"",X="mesh-summary",de=bt(s),F=gt(s,f,s?.selfDeviceId??null),ce=h.useMemo(()=>{const y=new Map;for(const n of s?.devices??[]){const u=F.byDevice.get(n.id);y.set(n.id,u?ze(u,n.sessionCount):n.sessionCount??0)}return y},[s,F]),Q=h.useCallback(y=>{V(y)},[]),q=s?s.devices.find(y=>y.id===H)??null:null,ee=h.useCallback((y,n,u)=>{if(!s)return null;const p={selfDeviceId:s.selfDeviceId,devices:new Map(s.devices.map(G=>[G.id,G])),networks:new Map(s.networks.map(G=>[G.id,G]))},R=y.locality==="local"?s.selfDeviceId??"":y.owner_device,Y=p.devices.get(R),E=me({session:y,ownerDeviceId:R,ownerLabel:Y?.label??y.owner_device_name},{kind:"device",deviceId:n.deviceId},p);if(E.kind==="refused")return l({code:E.code,sentence:E.sentence,remedy:E.remedy,plan:E.plan??null}),null;if(E.kind==="none")return null;const je=u?E.alternatives.find(G=>G.keep)??E.plan:E.plan,Fe=[E.plan,...E.alternatives].filter(G=>G.keep!==je.keep),Ge={plan:je,alternatives:Fe,risky:E.risky};C(Ge)},[s,C,l]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-6 p-6",children:[t.jsx(qe,{title:"Mesh",icon:ke,subtitle:"Devices this app is paired with, and the networks that hold them.",children:t.jsxs("div",{className:"flex items-center gap-4",children:[i&&t.jsx("output",{className:"text-meta text-ink-dim",children:"checking…"}),(e.kind==="ready"||e.kind==="loading")&&t.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:"Presentation"}),t.jsx("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:os.map(y=>t.jsx("button",{type:"button","aria-pressed":_===y,disabled:e.kind!=="ready",onClick:()=>$(y),className:P("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","disabled:text-ink-dim disabled:hover:text-ink-dim",_===y&&"bg-surface text-ink"),children:ds[y]},y))})]})]})}),e.kind==="loading"&&t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[t.jsx(Ce,{className:"h-4 w-64"}),t.jsx(Ce,{className:"min-h-40 w-full flex-1"})]}),e.kind==="error"&&t.jsxs(fe,{variant:"warning",className:"flex-col items-start gap-2",children:[t.jsx("p",{children:e.message}),t.jsx(J,{variant:"secondary",size:"sm",onClick:c,className:"w-fit",children:"Ask again"})]}),e.kind==="empty"&&t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center rounded-lg border border-hairline bg-surface p-6",children:t.jsxs("div",{className:"flex flex-col items-start gap-3",children:[t.jsx("h2",{className:"text-heading text-ink",children:"No network on this device"}),t.jsx("p",{className:"max-w-140 text-body-sm text-ink-muted",children:"This device is not in any network, so there is no mesh to draw. Create one on this machine:"}),t.jsx("code",{className:"rounded-sm bg-sunken px-2 py-1 font-mono text-meta text-ink",children:"lop network init <name>"}),t.jsx("p",{className:"text-meta text-ink-dim",children:"A network appears here once this device has joined one."})]})}),e.kind==="ready"&&s&&t.jsxs("div",{className:"flex min-h-0 flex-1 gap-4",children:[t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[t.jsx("p",{id:X,className:"text-meta text-ink-muted","data-mesh-summary":"",children:K}),o&&t.jsx(fe,{variant:"warning",children:t.jsx("p",{children:o})}),a&&t.jsx(fe,{variant:"warning",children:t.jsx("p",{children:a})}),g&&t.jsx(kt,{receipt:g.kind==="moved"?{verb:g.verb,detail:g.detail,undo:g.undo}:null,refusal:g.kind==="refused"?g.refusal:null,canWait:g.kind==="refused"&&g.plan!==null,onWait:D,onRecheck:c,onUndo:A,onDismiss:x,pending:w}),_==="canvas"?t.jsx(Qt,{graph:s,slots:de,nowSeconds:r,selectedDeviceId:H,sessions:F.byDevice,sessionTotals:ce,movingSessionId:j,canMove:N,onOpenDevice:Q,onAskMove:C,onDropRefused:l,onShowAllSessions:Q,summaryId:X}):t.jsx(ls,{graph:s,nowSeconds:r,selectedDeviceId:H,sessions:F.byDevice,selfLabel:b,canMove:N,onSelect:Q,onMove:ee,onInvite:M,onRemove:T})]}),q&&t.jsx(ss,{device:q,sessions:F.byDevice.get(q.id)??{rows:[],shown:[],hidden:0},sessionTotal:ce.get(q.id)??0,nowSeconds:r,canMove:N,canInvite:e.kind==="ready",movingSessionId:j,destinationsFor:y=>Be(s,y,b),onClose:()=>V(null),onMove:ee,onInvite:y=>M({deviceId:y.id,deviceLabel:y.label}),onRemoveMember:(y,n)=>{const u=s.networks.find(p=>p.id===n);T({networkId:n,networkLabel:u?.label??n,deviceId:y.id,deviceLabel:y.label})},onShowInList:y=>{Q(y),$("list")}})]}),t.jsx(vt,{open:S!==null,plan:S?.plan??us,alternatives:S?.alternatives??[],risky:S?.risky??!1,busy:w,onCancel:m,onChoose:d}),L&&t.jsx(wt,{open:L.open,options:L.options,deviceId:L.deviceId,deviceLabel:L.deviceLabel,onClose:B,onInvite:I,pending:k,receipt:W,refusal:ne}),U&&t.jsx(jt,{open:U.open,networkLabel:U.networkLabel,deviceLabel:U.deviceLabel,onClose:re,onConfirm:ie,pending:v,refusal:O,removed:z})]})},us={sessionId:"",to:"",keep:!1,verb:"",waitS:0,lost:null},vs=()=>{const e=Ve(),s=ye(e.data,"peers")==="enabled",r=ye(e.data,"session_transfer")==="enabled",i=yt(s),o=Nt(s),c=It(s),f=h.useMemo(()=>({peers:i,networks:o}),[i,o]),a=Ct(f),b=St(f),j=Mt(),N=Xe(v=>v.settlePlacement),S=Dt(),C=Et(),[l,d]=h.useState(null),[m,w]=h.useState(null),[g,x]=h.useState(null),[D,A]=h.useState(null),[L,M]=h.useState(null),[I,B]=h.useState(null),[k,W]=h.useState(null),ne=h.useMemo(()=>{const v=Math.max(i.dataUpdatedAt,o.dataUpdatedAt);return Math.floor((v||Date.now())/1e3)},[i.dataUpdatedAt,o.dataUpdatedAt]),U=h.useCallback(()=>{i.refetch(),o.refetch(),c.refetch()},[i,o,c]),T=h.useCallback((v,O)=>{d(null);const z={sessionId:v.sessionId,to:v.to,keep:v.keep,waitS:O??v.waitS};j.mutate(z,{onSuccess:_=>{if(_.kind==="moved"){const{receipt:$}=_;N(v.sessionId,$);const H=$.locality==="local"?"this device":b?.devices.find(V=>V.id===$.owner_device)?.label??$.owner_device;w({kind:"moved",verb:$.mode==="keep"?"Copied":"Moved",detail:$.mode==="keep"?`${H} holds a copy as ${$.new_session_id.slice(-6)}; the original is still here.`:`${H} holds it now${$.source_retired?"; the copy here is gone":""}.`,undo:$.mode==="keep"?{sessionId:$.new_session_id,to:"local",keep:!1,verb:`Bring the copy back from ${H}`,waitS:0,lost:_t(H,"this device")}:null});return}w({kind:"refused",refusal:_.refusal,plan:v})},onError:()=>{w({kind:"refused",refusal:{code:"move_failed",sentence:"The move could not be sent. Nothing here changed; the list has been read again.",status:null,unconfirmed:!1},plan:v})}})},[b,j,N]),ie=h.useMemo(()=>{if(!b)return[];const v=g?.deviceId,O=v?b.devices.find(z=>z.id===v):void 0;return b.networks.filter(z=>{if(!O)return!0;const _=O.memberships.find($=>$.networkId===z.id);return!_||!_.active}).map(z=>({id:z.id,label:z.label}))},[b,g]);if(!s)return t.jsx(Ke,{to:"/chat",replace:!0});const re=a.kind==="ready"?i.error?ae(i.error):o.error?ae(o.error):null:null;return t.jsx(cs,{state:a,graph:b,nowSeconds:ne,checking:i.isFetching||o.isFetching,staleError:re,onRetry:U,sessions:c.data??[],movingSessionId:j.isPending?j.variables?.sessionId??null:null,sessionError:c.isError?ae(c.error):null,selfLabel:b?.devices.find(v=>v.state==="self")?.label??"this device",canMove:r,pendingMove:l,onAskMove:d,onDropRefused:v=>w({kind:"refused",refusal:{code:v.code,sentence:v.sentence,status:null,unconfirmed:!1},plan:v.plan}),onChooseMove:v=>T(v),onCancelMove:()=>d(null),moveBusy:j.isPending,moveReport:m,onDismissReport:()=>w(null),onWaitForIdle:()=>{m?.kind!=="refused"||!m.plan||T(m.plan,ms)},onUndoCopy:()=>{m?.kind!=="moved"||!m.undo||d({plan:m.undo,alternatives:[],risky:!1})},invite:g===null?null:{open:!0,deviceId:g.deviceId,deviceLabel:g.deviceLabel,options:ie},onOpenInvite:v=>{A(null),M(null),x(v)},onInvite:v=>{S.mutate(v,{onSuccess:O=>A(O),onError:O=>M({code:"invite_refused",sentence:ae(O),status:null,unconfirmed:!1})})},onCloseInvite:()=>x(null),inviteBusy:S.isPending,inviteReceipt:D,inviteRefusal:L,remove:I===null?null:{open:!0,networkId:I.networkId,networkLabel:I.networkLabel,deviceId:I.deviceId,deviceLabel:I.deviceLabel},onOpenRemove:v=>{W(null),B(v)},onRemove:v=>{I&&C.mutate({networkId:I.networkId,deviceId:I.deviceId,confirm:v},{onSuccess:O=>W(O)})},onCloseRemove:()=>B(null),removeBusy:C.isPending,removeRefusal:C.isError?{code:"remove_refused",sentence:ae(C.error),status:null,unconfirmed:!1}:null,removed:k})},ms=300;export{vs as MeshPage,cs as MeshSurface,vs as default};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import{r as f,j as t,c as M}from"./index-CSNQxVPq.js";import{bN as yn,bO as ht,bP as kn,bQ as Ns,u as ws,bR as Nn,bS as wn,bT as Sn,bU as _n,bV as Tn,bW as Cn,bX as Ut,bY as qt,bZ as Dn,b_ as En,aF as Ss,aM as me,X as Z,aG as _t,b$ as Bt,c0 as Yt,c1 as zt,bc as An,aN as re,c2 as Rn,a as Xe,d as be,aX as $n,aP as Je,av as Ze,aT as et,c3 as On,c4 as Pn,c5 as Mn,c6 as Ln,c7 as Le,aU as _s,c8 as In,c9 as Fn,ag as Ue,b6 as Un,b5 as qn,b2 as Wt,ca as Bn,cb as Yn,cc as zn,cd as Wn,ce as Hn,cf as Kn,cg as Ts,S as Qn,ch as Vn,aO as Gn,aw as ae,af as Xn,ah as Jn,an as Zn,ci as ea,cj as Cs,b1 as ta,ba as sa,ck as na,ap as aa,aQ as ra,aY as ia}from"./conversation-input-sync-CGaXAqah.js";import{P as Ht}from"./page-header-BLBgjVqc.js";import{c as he,s as qe,f as Tt,t as Be,u as Ye,v as ze,w as Ce,B as I,D as oa,k as la,l as ca,o as Ie,R as da,U as ua,V as ma,W as ha,Y as fa,n as pa,p as oe,P as Ct,Z as Dt,N as Et,I as V,S as fe,L as K,T as xa,y as Ds,O as Es,X as At,C as As,A as ft,M as ga,z as ja,F as ba,G as va,e as je}from"./error-boundary-BR1z8pWF.js";import{aC as ya,aD as Rs,aE as ka,ai as Na,a7 as We,aF as wa,A as Kt,aw as Sa,aG as Qt,aH as _a}from"./index-D09I1LXM.js";import"./ui-preferences-store-CxJfZcpf.js";import"./console-mirror-GUGtzmyW.js";function Vt(e,s){return e.filter(n=>!s.includes(n))}function Ta(e,s,n){const a=e.slice(0);return a[s]=n,a}var Ca=class extends yn{#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,ht.batch(()=>{const n=this.#t,a=this.#u(this.#a);this.#l=a,a.forEach(o=>o.observer.setOptions(o.defaultedQueryOptions));const i=a.map(o=>o.observer),r=i.map(o=>o.getCurrentResult()),l=i.some((o,c)=>o!==n[c]);n.length===i.length&&!l||(this.#t=i,this.#e=r,this.hasListeners()&&(Vt(n,i).forEach(o=>{o.destroy()}),Vt(i,n).forEach(o=>{o.subscribe(c=>{this.#m(o,c)})}),this.#h()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,s){const n=this.#u(e),a=n.map(i=>i.observer.getOptimisticResult(i.defaultedQueryOptions));return[a,i=>this.#d(i??a,s),()=>this.#c(a,n)]}#c(e,s){return s.map((n,a)=>{const i=e[a];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,r=>{s.forEach(l=>{l.observer.trackProp(r)})})})}#d(e,s){return s?((!this.#s||this.#e!==this.#o||s!==this.#i)&&(this.#i=s,this.#o=this.#e,this.#s=kn(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 i=this.#n.defaultQueryOptions(a),r=s.get(i.queryHash);r?n.push({defaultedQueryOptions:i,observer:r}):n.push({defaultedQueryOptions:i,observer:new Ns(this.#n,i)})}),n}#m(e,s){const n=this.#t.indexOf(e);n!==-1&&(this.#e=Ta(this.#e,n,s),this.#h())}#h(){if(this.hasListeners()){const e=this.#s,s=this.#c(this.#e,this.#l),n=this.#d(s,this.#r?.combine);e!==n&&ht.batch(()=>{this.listeners.forEach(a=>{a(this.#e)})})}}};function Da({queries:e,...s},n){const a=ws(n),i=Nn(),r=wn(),l=f.useMemo(()=>e.map(v=>{const $=a.defaultQueryOptions(v);return $._optimisticResults=i?"isRestoring":"optimistic",$}),[e,a,i]);l.forEach(v=>{Sn(v),_n(v,r)}),Tn(r);const[o]=f.useState(()=>new Ca(a,l,s)),[c,h,m]=o.getOptimisticResult(l,s.combine),p=!i&&s.subscribed!==!1;f.useSyncExternalStore(f.useCallback(v=>p?o.subscribe(ht.batchCalls(v)):Cn,[o,p]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),f.useEffect(()=>{o.setQueries(l,s)},[l,s,o]);const d=c.some((v,$)=>Ut(l[$],v))?c.flatMap((v,$)=>{const y=l[$];if(y){const j=new Ns(a,y);if(Ut(y,v))return qt(y,j,r);Dn(v,i)&&qt(y,j,r)}return[]}):[];if(d.length>0)throw Promise.all(d);const S=c.find((v,$)=>{const y=l[$];return y&&En({result:v,errorResetBoundary:r,throwOnError:y.throwOnError,query:a.getQueryCache().get(y.queryHash),suspense:y.suspense})});if(S?.error)throw S.error;return h(m())}/**
|
|
2
|
-
* @license lucide-react v0.507.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Ea=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],$s=he("arrow-up",Ea);/**
|
|
7
|
-
* @license lucide-react v0.507.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Aa=[["path",{d:"M4.2 4.2A2 2 0 0 0 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 1.82-1.18",key:"16swn3"}],["path",{d:"M21 15.5V6a2 2 0 0 0-2-2H9.5",key:"yhw86o"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h7",key:"1wap6i"}],["path",{d:"M21 10h-5.5",key:"quycpq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Ra=he("calendar-off",Aa);/**
|
|
12
|
-
* @license lucide-react v0.507.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const $a=[["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"}]],Oa=he("link-2",$a);/**
|
|
17
|
-
* @license lucide-react v0.507.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const Pa=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]],Ma=he("list-filter",Pa);/**
|
|
22
|
-
* @license lucide-react v0.507.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const La=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M16 10h.01",key:"1m94wz"}]],Ia=he("message-square-more",La);/**
|
|
27
|
-
* @license lucide-react v0.507.0 - ISC
|
|
28
|
-
*
|
|
29
|
-
* This source code is licensed under the ISC license.
|
|
30
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const Fa=[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]],Ua=he("send-horizontal",Fa);/**
|
|
32
|
-
* @license lucide-react v0.507.0 - ISC
|
|
33
|
-
*
|
|
34
|
-
* This source code is licensed under the ISC license.
|
|
35
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const qa=[["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"}]],Ba=he("unlink",qa),tt={list:["desktop","projects"],detail:e=>["desktop","projects",e]};function Ya(e){return Ss({queryKey:tt.list,enabled:e,queryFn:()=>Z({op:"projects.list"}).then(s=>s.projects),retry:_t,staleTime:1e4})}function za(e,s){return Da({queries:e.map(n=>({queryKey:tt.detail(n),enabled:s&&!!n,queryFn:()=>Z({op:"projects.get",key:n}),retry:_t,staleTime:1e4}))})}function Os(e,s){return Ss({queryKey:tt.detail(e??""),enabled:s&&!!e,queryFn:()=>Z({op:"projects.get",key:e??""}),retry:_t,staleTime:1e4})}function pe(){const e=ws();return()=>{e.invalidateQueries({queryKey:tt.list})}}function Wa(){const e=pe();return me({mutationFn:s=>Z({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 Ps(){const e=pe();return me({mutationFn:s=>Z({op:"projects.update",key:s.key,fields:s.fields}),onSuccess:()=>e()})}function Ms(){const e=pe();return me({mutationFn:s=>Z({op:"projects.delete",key:s.key,confirmed_name:s.confirmedName}),onSuccess:()=>e()})}function Ha(){const e=pe();return me({mutationFn:s=>Z({op:"projects.link",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function Ka(){const e=pe();return me({mutationFn:s=>Z({op:"projects.unlink",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function Qa(){const e=pe();return me({mutationFn:s=>Z({op:"projects.milestone",key:s.key,name:s.name,...s.targetDate!==void 0?{targetDate:s.targetDate}:{},...s.completed!==void 0?{completed:s.completed}:{}}),onSuccess:()=>e()})}function Va(){const e=pe();return me({mutationFn:s=>Z({op:"projects.milestone.remove",key:s.key,name:s.name}),onSuccess:()=>e()})}const Ls={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"}},ve=Object.keys(Ls);function Q(e){return Ls[e]??{label:e||"Unknown",variant:"neutral"}}function Ga(e){return e==="done"}const Xa={completed:{label:"Completed",variant:"success"},overdue:{label:"Overdue",variant:"warning"},upcoming:{label:"Upcoming",variant:"neutral"}};function Ja(e){return Xa[e]??{label:String(e),variant:"neutral"}}const He="Stale",Za=/^(\d{4})-(\d{2})-(\d{2})$/;function ie(e,s,n=new Date){if(!e)return"";const a=Za.exec(e);if(!a)return e;const i=new Date(Number(a[1]),Number(a[2])-1,Number(a[3]));if(Number.isNaN(i.getTime()))return e;const r=i.toLocaleDateString(s,{month:"short",day:"numeric"});return i.getFullYear()===n.getFullYear()?r:`${r}, ${i.getFullYear()}`}function Ae(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 Re(e){return e==="just now"?"just now":`${e} ago`}function er(e){return e?`reported ${Re(e)}`:"no progress"}const Is=/^$|^\d{4}-\d{2}-\d{2}$/;function Fs(e){return e?e==="operator"?"the operator":`session ${e}`:""}function tr(e,s){if(!e.progress)return"not reported yet";const n=Ae(e.progress_updated_at,s),a=Fs(e.progress_reported_by),i=[n?`reported ${Re(n)}`:"reported"];return a&&i.push(`by ${a}`),i.join(" ")}function Us(e,s){if(e==null)return"";const n=String(e);return s==="points"?`${n} pt`:s==="days"?`${n}d`:n}function qs(e,s){return s<=0?"":`${e}/${s}`}function Rt(e){return e<=0?"":`${e} live`}function sr(e){return e<=0?"":e===1?"1 session":`${e} sessions`}function nr(e){return e===1?"1 project":`${e} projects`}function ar(e){const s=sr(e.sessions);if(!s)return"";const n=Rt(e.live_sessions);return n?`${s} · ${n}`:s}function rr(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 ir(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 or(e){return e?e.total===1?"1 todo":`${e.total} todos`:""}function Bs(e,s){const n=[],a=ie(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 i=Us(e.estimate,e.estimate_unit);i&&n.push({key:"estimate",text:i});const r=qs(e.milestones_completed,e.milestones_total);r&&n.push({key:"milestones",text:`milestones ${r}`});const l=Rt(e.live_sessions);return l&&n.push({key:"live",text:l}),n}const ye=864e5,lr=/^(\d{4})-(\d{2})-(\d{2})$/;function ee(e){if(!e)return null;const s=lr.exec(e);if(!s)return null;const n=Number(s[1]),a=Number(s[2]),i=Number(s[3]),r=Date.UTC(n,a-1,i),l=new Date(r);return l.getUTCFullYear()!==n||l.getUTCMonth()!==a-1||l.getUTCDate()!==i?null:r}const pt=["planning","active","qa","validation","done"],xt=["paused","archived"],st=[{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}],Ys="7d",cr=st.find(e=>e.value===Ys);function zs(e){return st.find(s=>s.value===e)??cr}function dr(e){return st.some(s=>s.value===e)}function Gt(e,s,n){const a=zs(s);return a.seconds===null?e:e.filter(i=>n/1e3-i.updated_at<=a.seconds)}function ur(e){const s=zs(e);return s.seconds===null?null:`Nothing changed in ${s.phrase}.`}const Ws="projects-board-window";function mr(){try{const e=localStorage.getItem(Ws);if(e!==null&&dr(e))return e}catch{}return Ys}function Xt(e){try{localStorage.setItem(Ws,e)}catch{}}const Hs="projects-board-column-order";let gt=null;function hr(){if(gt)return[...gt];try{const e=localStorage.getItem(Hs);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 fr(e){gt=[...e];try{localStorage.setItem(Hs,JSON.stringify(e))}catch{}}function pr(e,s,n){const a=e.filter(r=>r!==s),i=Math.max(0,Math.min(n,a.length));return a.splice(i,0,s),a}function xr(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=pt.map(o=>({status:o,projects:n.get(o)??[]}));for(const o of xt){const c=n.get(o)??[];c.length>0&&a.push({status:o,projects:c})}for(const[o,c]of n)!xt.includes(o)&&!pt.includes(o)&&a.push({status:o,projects:c});if(s.length===0)return a;const i=new Map(s.map((o,c)=>[o,c])),r=a.filter(o=>i.has(o.status));r.sort((o,c)=>(i.get(o.status)??0)-(i.get(c.status)??0));const l=a.filter(o=>!i.has(o.status));return[...r,...l]}function Ks(e,s){if(e.status==="done"||e.status==="archived"||e.completed_at)return!1;const n=ee(e.target_date);return n===null?!1:n<s}function W(e){return e.title||e.name}function gr(e,s){const n=[];for(const a of[e,s]){const i=a?.trim();i&&!n.includes(i)&&n.push(i)}return n.join(" · ")}const $t="No team";function $e(e){const s=e.team?.trim();if(s)return s;const n=e.owner?.trim();return n||null}function Ot(e,s){const n=new Map,a=[];for(const r of e){const l=s(r);if(l===null){a.push(r);continue}const o=n.get(l);o?o.push(r):n.set(l,[r])}const i=[...n.entries()].sort(([r],[l])=>r.localeCompare(l,void 0,{sensitivity:"base"})).map(([r,l])=>({team:r,items:l}));return a.length>0&&i.push({team:null,items:a}),i}function nt(e){return e.title||e.session_id}function jr(e){return[...e].reverse()}function br(e){return e<=0?"":e===1?"1 update":`${e} updates`}const Jt=e=>String(e).padStart(2,"0");function jt(e){return`${e.getFullYear()}-${Jt(e.getMonth()+1)}-${Jt(e.getDate())}`}function vr(e){const s=Date.parse(e);return Number.isNaN(s)?"":jt(new Date(s))}function yr(e,s,n=new Date){if(!e)return"";if(e===jt(n))return"Today";const a=new Date(n.getFullYear(),n.getMonth(),n.getDate()-1);return e===jt(a)?"Yesterday":ie(e,s,n)}function kr(e,s){const n=Date.parse(e);return Number.isNaN(n)?"":new Date(n).toLocaleTimeString(s,{hour:"numeric",minute:"2-digit"})}function Nr(e,s){const n=Date.parse(e);return Number.isNaN(n)?"":Re(Ae(n/1e3,s))}function wr(e,s,n=Date.now()){const a=[],i=Fs(e.by);i&&a.push({key:"author",text:i});const r=kr(e.at,s);r&&a.push({key:"time",text:r});const l=Nr(e.at,n);return l&&a.push({key:"age",text:l}),a}function Sr(e,s,n=new Date){const a=[];for(const i of jr(e)){const r=vr(i.at),l=a[a.length-1];if(l&&l.key===r){l.entries.push(i);continue}a.push({key:r,label:yr(r,s,n),entries:[i]})}return a}function _r(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 Tr(e,s){return s<=0?"":`${e} of ${s} complete`}function Cr(e){let s=0,n=0,a=!1;for(const i of e)i.todos&&(a=!0,s+=i.todos.open,n+=i.todos.total);return a?{open:s,total:n}:null}function Zt(e){return`${e.open} open of ${e.total}`}function Dr(e){const s=e.filter(a=>a.exists);return(s.find(a=>a.runtime?.state==="live")??s[0])?.session_id??null}function Er(e){const s=W(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(`
|
|
37
|
-
`)}function Ar(e){return e?e.kind==="team"?`team ${e.name}`:`agent ${e.name}`:""}const es="complete them, or pass force_done=true to close with them open",Rr="complete or remove the incomplete milestones, then mark it done";function Qs(e){return e.includes(es)?e.replace(es,Rr):e}const $r=4,Or=3,Pr=2,Mr=1,Lr=3,de={title:3,name:2.5,description:2,tags:1.5,attribution:1.5,status:1},Ir=/[^\p{L}\p{N}]+/u,Fr=/\s+/;function ts(e,s){const n=s.trim().toLowerCase();if(!n)return 0;if(n===e)return $r;if(n.startsWith(e))return Or;const a=n.split(Ir).filter(Boolean),i=e.split(Fr).filter(Boolean);if(i.length>0&&i.every(l=>a.some(o=>o.startsWith(l))))return Pr;const r=i.join("");return r.length>=Lr&&Ur(r,n)?Mr:0}function Ur(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 Vs(e,s){const n=s.trim().toLowerCase();if(!n)return 0;const a=[[e.title,de.title],[e.name,de.name],[e.description,de.description],[e.owner,de.attribution],[e.team,de.attribution],[e.status,de.status]];let i=0;for(const[r,l]of a){if(!r)continue;const o=ts(n,r)*l;o>i&&(i=o)}for(const r of e.tags){const l=ts(n,r)*de.tags;l>i&&(i=l)}return i}function qr(e,s){const n=s.trim();if(!n)return e;const a=[];for(const i of e){const r=Vs(i,n);r>0&&a.push({project:i,score:r})}return a.sort((i,r)=>{if(i.score!==r.score)return r.score-i.score;if(i.project.updated_at!==r.project.updated_at)return r.project.updated_at-i.project.updated_at;const l=W(i.project).localeCompare(W(r.project),void 0,{sensitivity:"base"});if(l!==0)return l;const o=i.project.name.localeCompare(r.project.name,void 0,{sensitivity:"base"});return o!==0?o:i.project.id<r.project.id?-1:i.project.id>r.project.id?1:0}),a.map(i=>i.project)}const Ne=["status","team","owner","tags","progress","target","estimate","milestones","live"],ss={status:[],team:[],owner:[],tags:[],progress:[],target:[],estimate:[],milestones:[],live:[]},De={status:"Status",team:"Team",owner:"Owner",tags:"Tags",progress:"Progress",target:"Target date",estimate:"Estimate",milestones:"Milestones",live:"Live sessions"},Br=new Set(["status","progress","target","estimate","milestones","live"]),Yr={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"]},zr={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 Gs(e,s){switch(e){case"status":return Q(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 zr[s]??s??""}function Wr(e,s){return e[s].length>0}function Ee(e){return Ne.every(s=>!Wr(e,s))}function Hr(e){return Ne.reduce((s,n)=>s+e[n].length,0)}function Xs(e,s,n){const a=e[s],i=a.includes(n)?a.filter(r=>r!==n):[...a,n];return{...e,[s]:i}}function Js(e,s,n,a){switch(e){case"status":return s.status===n;case"team":return $e(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 ee(s.target_date)===null;if(n==="overdue")return Ks(s,a);const i=ee(s.target_date);if(i===null)return!1;const r=(i-a)/ye;return n==="within-7"?r>=0&&r<=7:r>=0&&r<=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 Zs(e,s,n,a){const i=e[s];return i.length===0?!0:i.some(r=>Js(s,n,r,a))}function Kr(e,s,n){return Ee(s)?e:e.filter(a=>Ne.every(i=>Zs(s,i,a,n)))}function Qr(e,s,n,a,i){const r=i.trim();return s.filter(l=>r&&Vs(l,r)===0?!1:Ne.every(o=>o===e||Zs(n,o,l,a)))}function Vr(e,s,n){const a=n[e];switch(e){case"status":{const r=[...new Set(s.map(o=>o.status))].filter(o=>!ve.includes(o)).sort((o,c)=>o.localeCompare(c,void 0,{sensitivity:"base"})),l=a.filter(o=>typeof o=="string"&&!ve.includes(o)&&!r.includes(o));return[...ve,...r,...l]}case"team":{const i=new Set;let r=!1;for(const o of s){const c=$e(o);c===null?r=!0:i.add(c)}for(const o of a)o===null?r=!0:i.add(o);const l=[...i].sort((o,c)=>o.localeCompare(c,void 0,{sensitivity:"base"}));return r?[...l,null]:l}case"owner":{const i=new Set;let r=!1;for(const o of s){const c=o.owner?.trim();c?i.add(c):r=!0}for(const o of a)o===null?r=!0:i.add(o);const l=[...i].sort((o,c)=>o.localeCompare(c,void 0,{sensitivity:"base"}));return r?[...l,null]:l}case"tags":{const i=new Set;for(const r of s)for(const l of r.tags)i.add(l);for(const r of a)i.add(r??"");return[...i].sort((r,l)=>r.localeCompare(l,void 0,{sensitivity:"base"}))}case"progress":case"target":case"estimate":case"milestones":case"live":return Yr[e]}}function en(e,s,n,a,i){const r=Qr(e,s,n,a,i),l=Br.has(e),o=[];for(const c of Vr(e,r,n)){const h=n[e].includes(c),m=r.reduce((p,g)=>p+(Js(e,g,c,a)?1:0),0);!l&&m===0&&!h||o.push({value:c,label:Gs(e,c),count:m,selected:h})}return{facet:e,label:De[e],options:o}}function Gr(e,s,n,a){return Ne.map(i=>en(i,e,s,n,a))}const bt="projects-sort",Xr="Default (as listed)";function Jr(e){return Zr.includes(e)}const Zr=["name","status","target","estimate","milestones","live","progress"];function ei(){try{const e=localStorage.getItem(bt);if(e===null)return null;const[s,n,...a]=e.split(":");if(a.length>0)return null;if(s&&Jr(s)&&(n==="asc"||n==="desc"))return{key:s,direction:n}}catch{}return null}function ti(e){try{e===null?localStorage.removeItem(bt):localStorage.setItem(bt,`${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 ct(e){return e==="target"||e==="progress"?"desc":"asc"}function Pt(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 si(e){return e===null?"Sort cleared.":`Sorted by ${ke(e.key)}, ${Pt(e.key,e.direction)}.`}function ni(e){const s=[e.search?"search":null,e.filters?"filters":null,e.sort?"sort":null].filter(a=>a!==null);if(s.length===0)return"";const 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 ns(e,s){switch(e){case"name":return 0;case"status":return ve.includes(s.status)?0:1;case"target":return vt(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 vt(e){return ee(e.completed_at??e.target_date)}function as(e){return e==="points"?0:e==="days"?1:2}function ai(e,s,n){switch(e){case"name":return W(s).localeCompare(W(n),void 0,{sensitivity:"base"});case"status":return ve.indexOf(s.status)-ve.indexOf(n.status);case"target":{const a=vt(s)??0,i=vt(n)??0;return a-i}case"estimate":{const a=as(s.estimate_unit)-as(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 rs(e,s){if(e.updated_at!==s.updated_at)return s.updated_at-e.updated_at;const n=W(e).localeCompare(W(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 ri(e,s,n){const a=ns(n.key,e),i=ns(n.key,s);if(a!==i)return a-i;if(a===1)return rs(e,s);const r=ai(n.key,e,s);return r!==0?n.direction==="desc"?-r:r:rs(e,s)}function ii(e,s){return[...e].sort((n,a)=>ri(n,a,s))}const ce=["day","week","month","quarter"],Mt={day:24,week:9,month:3,quarter:1};function Lt(e){const s=new Date(e);return Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())}function ue(e,s){return Math.round((s-e)/ye)}function is(e,s){return ue(e,s)+1}function oi(e,s){for(const n of ce)if(e*Mt[n]<=s)return n;return ce[ce.length-1]}function li(e){const{project:s}=e;return s.start_date||s.target_date||s.completed_at?!0:e.milestones.some(n=>!!n.target_date)}function ci(e,s){const n=[s];for(const a of e){for(const i of[a.project.start_date,a.project.target_date,a.project.completed_at]){const r=ee(i);r!==null&&n.push(r)}for(const i of a.milestones){const r=ee(i.target_date);r!==null&&n.push(r)}}return n.length===1?null:{startMs:Math.min(...n),endMs:Math.max(...n)}}function di(e){const s=[],n=[];for(const a of e)(li(a)?s:n).push(a);return{dated:s,undated:n}}function ui(e){return`${e} project${e===1?"":"s"} without dates`}function mi(e){const{project:s}=e,n=ee(s.start_date),a=ee(s.target_date),i=ee(s.completed_at),r=s.status==="done"&&i!==null?i:a,l=n??r,o=r??n;return l===null||o===null?null:{fromMs:Math.min(l,o),toMs:Math.max(l,o)}}function hi(e){const s=[];for(const n of e.milestones){const a=ee(n.target_date);a!==null&&s.push({name:n.name,dayMs:a,status:n.status})}return s}const Fe=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function J(e){const s=new Date(e);return{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),weekday:s.getUTCDay()}}function fi(e){const{year:s,month:n}=J(e);return Date.UTC(s,n-1,1)}function pi(e){const{year:s,month:n}=J(e);return n===12?Date.UTC(s+1,0,1):Date.UTC(s,n,1)}function xi(e){const{year:s,month:n}=J(e);return Date.UTC(s,Math.floor((n-1)/3)*3,1)}function gi(e){const{year:s,month:n}=J(e),a=Math.floor((n-1)/3);return a===3?Date.UTC(s+1,0,1):Date.UTC(s,a*3+3,1)}function ji(e){const{weekday:s}=J(e);return e-(s+6)%7*ye}const bi=26;function vi(e,s,n){const a=[],i=(m,p,g)=>{m<e||m>s||a.push({dayMs:m,label:p,major:g})};if(n==="day"){let m=!1;for(let p=e;p<=s;p+=ye){const{day:g,month:d}=J(p);g===1?(i(p,Fe[d-1],!0),m=!0):m?(i(p,"",!1),m=!1):i(p,String(g),!1)}return a}if(n==="week"){for(let m=ji(e);m<=s;m+=7*ye){if(m<e)continue;const{day:p,month:g}=J(m);J(m-7*ye).month!==g?i(m,`${Fe[g-1]} ${p}`,!0):i(m,String(p),!1)}return a}const r=n==="month"?fi:xi,l=n==="month"?pi:gi,o=m=>{const{year:p,month:g}=J(m);if(n==="month")return g===1&&p!==J(e).year?`${Fe[0]} '${String(p%100).padStart(2,"0")}`:Fe[g-1];const d=Math.floor((g-1)/3)+1;return d===1&&p!==J(e).year?`Q1 '${String(p%100).padStart(2,"0")}`:`Q${d}`};i(e,o(r(e)),!0);const c=Math.ceil(bi/Mt[n]);let h=e;for(let m=l(r(e));m<=s;m=l(m))ue(h,m)<c||(i(m,o(m),!0),h=m);return a}const yi="Shows projects last updated within this window; older ones are hidden.",ki=({value:e,onChange:s})=>t.jsxs(qe,{value:e,onValueChange:n=>s(n),children:[t.jsx(Tt,{content:e==="all"?null:yi,side:"bottom",disableHoverableContent:!0,children:t.jsx(Be,{"aria-label":"Projects updated within",className:M("w-36 shrink-0"),"data-tour-tag":"projects-board-window",children:t.jsx(Ye,{})})}),t.jsx(ze,{children:st.map(n=>t.jsx(Ce,{value:n.value,children:n.label},n.value))})]}),yt=6e4,kt=6e3,os="Requesting updates…",Ni=400,wi="Ask the sessions linked to this project to post a progress update",Si="linked but not yet in use — it becomes a recipient after the first message",ls=e=>`project-request-update-${e}`,_i=e=>`project-request-cooldown-${e}`,Ti=e=>`project-request-update-cooldown-${e}`,dt=e=>e.length===1?e[0]:e.length===2?`${e[0]} and ${e[1]}`:`${e[0]}, ${e[1]} and ${e.length-2} more`,cs=(e,s)=>e.sessions.filter(n=>n.outcome===s).map(n=>nt({session_id:n.session_id,title:n.title})),Ci=e=>e.outcome==="failed"&&e.detail===Si;function Ke(e,s){const n=Math.max(1,Math.ceil(s/1e3));return`Update already requested ${Math.max(0,Math.ceil(yt/1e3)-n)} s ago on ${e}. Try again in ${n} s.`}function Di(e){const s=W({title:e.project.title,name:e.project.key}),{delivered:n,unconfirmed:a,failed:i,total:r}=e.counts;if(e.state==="empty")return{variant:"info",title:`No linked sessions to ask. Link a session to ${s} first.`,duration:kt};if(e.state==="cooldown")return{variant:"info",title:Ke(s,Math.max(0,e.cooldown_remaining_s??0)*1e3),duration:kt};if(e.state!=="sent")return null;const l=cs(e,"failed"),o=cs(e,"unconfirmed");if(n>=1&&i===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 ${r} sessions on ${s}.`;return i>0&&(c+=` ${dt(l)} could not be reached.`),a>0&&(c+=` Delivery to ${dt(o)} could not be confirmed.`),{variant:"warning",title:c,duration:Number.POSITIVE_INFINITY}}if(i===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(Ci);let h;return c?h=r===1?"The linked session has not started yet — it becomes a recipient after its first message.":`The ${r} linked sessions have not started yet — they become recipients after their first message.`:h=`Could not reach any of the ${r} linked sessions on ${s}.`,{variant:"error",title:h,duration:Number.POSITIVE_INFINITY}}return{variant:"warning",title:`Could not reach ${i} of the ${r} linked sessions on ${s}. Delivery to ${dt(o)} could not be confirmed.`,duration:Number.POSITIVE_INFINITY}}const Te=new Map,It=new Set,ut=new Map,Nt=new Set;let tn=0;const Qe=()=>{tn+=1;for(const e of Nt)e()},Ei=e=>(Nt.add(e),()=>{Nt.delete(e)}),ds=()=>tn,sn=e=>It.has(e),nn=e=>Te.get(e);function Ai(e){It.add(e),Qe()}function Ri(e){It.delete(e),Qe()}function us(e,s,n){const a=Date.now();if(n<=a)return;const i=Te.get(e);if(i&&i.untilMs>=n)return;Te.set(e,{startedMs:s,untilMs:n});const r=ut.get(e);r&&clearTimeout(r);const l=setTimeout(()=>{ut.delete(e);const o=Te.get(e);o&&o.untilMs<=Date.now()&&(Te.delete(e),Qe())},n-a);l.unref?.(),ut.set(e,l),Qe()}const $i=e=>/[.!?…]$/.test(e)?e:`${e}.`;function Oi(e,s){const n=Date.now();if(s.state==="cooldown"){const a=Math.max(0,s.cooldown_remaining_s??0)*1e3;us(e,n-(yt-a),n+a);return}s.state==="sent"&&(s.counts.delivered>=1||s.counts.unconfirmed>=1)&&us(e,n,n+yt)}async function Pi(e){const s=e.id;if(sn(s)){Bt(os,{id:ls(s)});return}const n=Date.now(),a=nn(s);if(a&&a.untilMs>n){Yt(Ke(W(e),a.untilMs-n),{id:_i(s),duration:kt});return}Ai(s);const i=ls(s);let r=!1;const l=setTimeout(()=>{r=!0,Bt(os,{id:i})},Ni);try{const o=await Z({op:"projects.request_update",key:s});Oi(s,o);const c=Di(o);if(c){const h={id:i,...c.duration!==void 0?{duration:c.duration}:{}};switch(c.variant){case"success":re(c.title,h);break;case"warning":An(c.title,h);break;case"error":zt(c.title,h);break;default:Yt(c.title,h)}}else r&&Rn(i)}catch(o){const c=o instanceof Error&&o.message.trim()!==""?o.message.trim():null;zt(c?`Could not request updates: ${$i(c)}`:"The request could not be confirmed.",{id:i,duration:Number.POSITIVE_INFINITY})}finally{clearTimeout(l),Ri(s)}}function an(){return f.useCallback(e=>{Pi(e)},[])}function Mi(e){f.useSyncExternalStore(Ei,ds,ds);const s=sn(e),n=nn(e),a=n!==void 0?n.untilMs-Date.now():0,i=a>0;return{sending:s,cooling:i,cooldownRemainingMs:i?a:null}}const ms={active:"In flight",paused:"On hold",done:"Finished"};function Li(){const[e,s]=f.useState(null);return f.useEffect(()=>{if(!e)return;const n=document.querySelector(`[data-project-menu="${e}"]`);n&&(n.focus(),s(null))}),f.useCallback(n=>s(n),[])}const Ii=4,mt="Drag the header, or press the arrow keys, to move this column.",hs="board-column-move-hint",Fi=({projects:e,nowMs:s,onOpen:n,onEdit:a,onDelete:i,onMove:r,movingKeys:l=[],teamLabelFor:o=c=>c})=>{const[c,h]=f.useState(hr),m=xr(e,c),p=Ot(e,$e),[g,d]=f.useState(null),[S,v]=f.useState(""),$=f.useRef(null),y=f.useRef(null),j=f.useRef(null),u=f.useRef(null),D=f.useRef(null),_=new Set(l),w=(k,b)=>{const T=pr(m.map(R=>R.status),k,b);h(T),fr(T),v(`Moved ${Q(k).label} column to position ${T.indexOf(k)+1} of ${T.length}.`)},C=(k,b)=>{const T=$.current;if(!T)return 0;let R=0;const U=T.querySelectorAll("[data-board-column]");for(const Y of U){if(Y.dataset.boardColumn===b)continue;const H=Y.getBoundingClientRect();k>(H.left+H.right)/2&&(R+=1)}return R},F=(k,b)=>{const T=m.filter(Y=>Y.status!==k),R=T[b-1]?.status,U=T[b]?.status;return R&&U?`between ${Q(R).label} and ${Q(U).label}`:U?`before ${Q(U).label}`:R?`after ${Q(R).label}`:"in place"},z=(k,b)=>{const T=C(k,b.status);T!==b.over&&(b.over=T,d({status:b.status,over:T}),v(`Moving ${Q(b.status).label} column; it will drop ${F(b.status,T)}.`))},E=()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)},x=32,P=12,O=()=>{u.current=null;const k=D.current,b=$.current,T=j.current;if(!k?.armed||!b||T===null)return;const R=b.getBoundingClientRect(),U=b.scrollWidth-b.clientWidth;let Y=0;if(T-R.left<x&&b.scrollLeft>0?Y=-1:R.right-T<x&&b.scrollLeft<U&&(Y=1),Y!==0){const H=b.scrollLeft;b.scrollLeft=H+Y*P,b.scrollLeft!==H&&z(T,k)}else z(T,k);te(k.status,k.over),u.current=requestAnimationFrame(O)};f.useEffect(()=>()=>{u.current!==null&&cancelAnimationFrame(u.current)},[]);const A=(k,b)=>{if(k.button===0){try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}D.current={pointerId:k.pointerId,status:b,startX:k.clientX,startY:k.clientY,armed:!1,over:m.findIndex(T=>T.status===b)},j.current=k.clientX}},L=k=>{const b=D.current;if(!(!b||k.pointerId!==b.pointerId)){if(j.current=k.clientX,!b.armed){if(Math.hypot(k.clientX-b.startX,k.clientY-b.startY)<Ii)return;b.armed=!0,d({status:b.status,over:b.over}),v(`Moving ${Q(b.status).label} column.`),u.current===null&&(u.current=requestAnimationFrame(O))}z(k.clientX,b)}},q=k=>{const b=D.current;if(D.current=null,E(),d(null),!b?.armed)return;if(!k){v("Move cancelled.");return}const T=m.findIndex(R=>R.status===b.status);if(b.over===T){v("");return}w(b.status,b.over)},G=k=>{const b=D.current;!b||k.pointerId!==b.pointerId||q(!0)},xe=()=>{q(!1)};f.useEffect(()=>{if(!g)return;const k=b=>{b.key==="Escape"&&q(!1)};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[g!==null]);const te=f.useCallback((k,b)=>{const T=$.current,R=y.current;if(!T||!R)return;const U=T.getBoundingClientRect(),Y=[];for(const Se of T.querySelectorAll("[data-board-column]"))Se.dataset.boardColumn!==k&&Y.push(Se.getBoundingClientRect());const H=6,Oe=b>=Y.length?(Y[Y.length-1]?.right??U.left)+H:(Y[b]?.left??U.right)-H,we=T.scrollLeft,at=2,le=Oe-U.left+we,se=we+1,rt=we+U.width-at-1,Pe=Math.round(Math.min(Math.max(le,se),Math.max(se,rt)));R.style.left=`${Pe}px`},[]);f.useLayoutEffect(()=>{g&&te(g.status,g.over)},[g,te]);const ge=(k,b)=>{if(k.key==="Enter"||k.key===" "){k.preventDefault(),v(mt);return}if(k.key!=="ArrowLeft"&&k.key!=="ArrowRight")return;k.preventDefault();const T=m.map(Y=>Y.status),R=T.indexOf(b),U=k.key==="ArrowLeft"?R-1:R+1;if(U<0||U>=T.length){v(`${Q(b).label} column is already ${U<0?"the first column":"the last column"}.`);return}w(b,U)};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:S}),t.jsx("span",{id:hs,className:"sr-only",children:mt}),t.jsxs("div",{ref:$,"data-board-strip":"",className:M("relative flex min-h-0 flex-1 items-start overflow-auto px-6 pb-9",g&&"cursor-grabbing select-none"),children:[g&&t.jsx("div",{ref:y,"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:m.map(k=>{const b=Q(k.status);return t.jsxs("header",{"data-board-column":k.status,"data-board-column-handle":k.status,onPointerDown:T=>A(T,k.status),onPointerMove:L,onPointerUp:G,onPointerCancel:xe,className:M("flex h-11 w-64 shrink-0 cursor-grab items-center justify-between gap-2 rounded-t-md bg-sunken px-3 active:cursor-grabbing",g?.status===k.status&&"opacity-85"),children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[t.jsx(I,{type:"button",variant:"ghost",size:"icon-sm","data-board-column-grip":k.status,"aria-label":`Move ${b.label} column`,"aria-describedby":hs,title:mt,className:"-ml-1.5 cursor-grab text-ink-muted active:cursor-grabbing",onKeyDown:T=>ge(T,k.status),children:t.jsx(ya,{"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:b.label}),ms[k.status]&&t.jsx("span",{className:"truncate text-meta text-ink-muted",children:ms[k.status]})]})]}),t.jsx("span",{className:"text-meta text-ink-muted",children:k.projects.length})]},k.status)})}),p.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?$t: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:m.map(b=>{const T=k.items.filter(R=>R.status===b.status);return t.jsx("div",{"data-board-cell":b.status,className:"flex max-h-[calc(100cqh-92px)] w-64 shrink-0 flex-col gap-2 overflow-y-auto px-2",children:T.length>0&&t.jsx("ul",{className:"flex flex-col gap-2",children:T.map(R=>t.jsx("li",{children:t.jsx(Ui,{project:R,nowMs:s,busy:_.has(R.id),onOpen:()=>n(R),onEdit:()=>a(R),onDelete:()=>i(R),onMove:U=>r(R,U)})},R.id))})},b.status)})})]},k.team??""))]})]})]})},Ui=({project:e,nowMs:s,busy:n,onOpen:a,onEdit:i,onDelete:r,onMove:l})=>{const o=Bs(e,typeof navigator>"u"?void 0:navigator.language),c=Xe(),h=an(),m=be(c.data,"projects_request_update"),p=W(e),g=f.useRef(null),[d,S]=f.useState(!1);f.useEffect(()=>{const u=g.current;if(!u)return;const D=()=>{u.isConnected&&S(u.scrollWidth-u.clientWidth>.5)},_=requestAnimationFrame(D),w=new ResizeObserver(D);return w.observe(u),document.fonts?.ready.then(D).catch(()=>{}),()=>{cancelAnimationFrame(_),w.disconnect()}},[p,d]);const v=Ks(e,Lt(s)),$=Ae(e.progress_updated_at,s),y=()=>{const u=window.getSelection();u&&!u.isCollapsed||a()},j=u=>{u.key!=="Enter"&&u.key!==" "||u.target===u.currentTarget&&(u.preventDefault(),a())};return t.jsxs("div",{"data-project-name":e.name,role:"button",tabIndex:0,"aria-label":`Open ${p}`,onClick:y,onKeyDown:j,className:M("group/card flex flex-col gap-2 rounded-sm bg-surface p-3","transition-colors duration-fast ease-out-quart hover:bg-elevated",v&&"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(Tt,{content:d?p:null,side:"top",disableHoverableContent:!0,children:t.jsx("span",{ref:g,"data-project-title":e.name,tabIndex:d?0:void 0,className:"block truncate text-body-sm font-medium text-ink",children:p})}),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(oa,{children:[t.jsx(la,{"data-project-menu":e.id,"aria-label":`Actions for ${p}`,disabled:n,onClick:u=>u.stopPropagation(),className:M("shrink-0 rounded-sm p-1 text-ink-muted whitespace-nowrap","hover:bg-sunken hover:text-ink"),children:t.jsx($n,{className:"size-4"})}),t.jsxs(ca,{align:"end",onClick:u=>u.stopPropagation(),children:[t.jsx(Ie,{onSelect:a,children:"Open"}),t.jsxs(da,{children:[t.jsx(ua,{children:"Set status"}),t.jsx(ma,{children:t.jsx(ha,{value:e.status,onValueChange:l,children:[...pt,...xt].map(u=>t.jsx(fa,{value:u,children:Q(u).label},u))})})]}),m&&t.jsx(Ie,{onSelect:()=>h(e),children:"Request update"}),t.jsx(pa,{}),t.jsx(Ie,{onSelect:i,children:"Edit"}),t.jsx(Ie,{onSelect:r,children:"Delete"})]})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[o.filter(u=>u.key!=="live").map(u=>t.jsx("span",{className:"rounded-sm bg-sunken px-1.5 py-0.5 text-meta text-ink-muted",children:u.text},u.key)),v&&t.jsx(oe,{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:er($)}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[(e.progress_stale||!$)&&t.jsx("span",{"aria-label":He,title:He,className:"size-1.5 rounded-full bg-warning"}),e.sessions>0&&t.jsx(qi,{project:e})]})]})]})},qi=({project:e})=>{const[s,n]=f.useState(!1),a=Je(),i=Os(e.id,s),r=i.data?.links??[],l=ar(e),o=W(e);return t.jsxs(Ct,{open:s,onOpenChange:n,children:[t.jsx(Dt,{"data-project-sessions":e.id,"aria-label":`Sessions linked to ${o}`,onClick:c=>c.stopPropagation(),className:M("rounded-sm px-1 text-meta whitespace-nowrap",e.live_sessions>0?"text-success hover:bg-sunken":"text-ink-muted hover:bg-sunken"),children:l}),t.jsx(Et,{align:"end",className:"w-64 p-2 outline-none",onClick:c=>c.stopPropagation(),children:i.isLoading?t.jsx("p",{className:"px-1 py-2 text-meta text-ink-muted",children:"Loading linked sessions…"}):i.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:i.error instanceof Error&&i.error.message?i.error.message:"The linked sessions could not be read."}),t.jsx(I,{variant:"secondary",size:"sm",onClick:()=>void i.refetch(),children:"Try again"})]}):r.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:r.map(c=>t.jsx("li",{children:t.jsx("button",{type:"button",disabled:!c.exists,onClick:()=>{c.exists&&(n(!1),Rs(a,c.session_id))},className:M("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))})})]})},rn=({open:e,projectName:s,onClose:n,onConfirm:a})=>{const[i,r]=f.useState(""),[l,o]=f.useState(null),[c,h]=f.useState(!1),m=f.useId();f.useEffect(()=>{e&&(r(""),o(null),h(!1))},[e]);const p=i.trim().toLowerCase()===s.trim().toLowerCase()&&s.trim().length>0,g=async()=>{h(!0),o(null);try{await a(i.trim()),n()}catch(d){o(d instanceof Error&&d.message?d.message:"The project was not deleted.")}finally{h(!1)}};return t.jsx(Ze,{open:e,onClose:n,title:"Delete this project?",dataTourTag:"project-delete-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(et,{onClick:n,disabled:c,children:"Cancel"}),t.jsxs(On,{onClick:()=>void g(),disabled:!p||c,children:[c&&t.jsx(fe,{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(V,{id:`${m}-confirm`,value:i,onChange:d=>r(d.target.value),placeholder:s,"aria-label":"Type the project name to confirm","aria-invalid":i.length>0&&!p,autoFocus:!0}),l&&t.jsx("p",{className:"text-body-sm text-danger",children:l})]})})},Bi=/^(https?:|mailto:)/i,Yi={a:({href:e,children:s})=>typeof e=="string"&&Bi.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:Mn},Ve=f.memo(({children:e,className:s})=>t.jsx("div",{className:M("lo-markdown",s),children:t.jsx(Pn,{remarkPlugins:[Ln],components:Yi,children:e})})),fs=`## Summary
|
|
38
|
-
|
|
39
|
-
## Goals
|
|
40
|
-
|
|
41
|
-
## Notes`,zi=new RegExp("\\p{Mn}","gu"),Wi=/[^a-z0-9._-]+/g,Hi=/[._-]{2,}/g,Ki=/^[^a-z0-9]+/,ps=/[^a-z0-9]+$/;function Qi(e){return e.normalize("NFKD").replace(zi,"").toLowerCase().replace(Wi,"-").replace(Hi,"-").replace(Ki,"").replace(ps,"").slice(0,64).replace(ps,"")}const Vi=/&#x([0-9a-f]+);/gi,Gi=/&#(\d+);/g,Xi=/ /g,Ji=/</g,Zi=/>/g,eo=/"/g,to=/'|'/g,so=/&/g,xs=e=>e.replace(Vi,(s,n)=>String.fromCodePoint(Number.parseInt(n,16))).replace(Gi,(s,n)=>String.fromCodePoint(Number.parseInt(n,10))).replace(Xi," ").replace(Ji,"<").replace(Zi,">").replace(eo,'"').replace(to,"'").replace(so,"&"),no=/<[^>]*>|[^<]+/g,ao=/^<\//,ro=/^<\/?\s*([a-zA-Z][a-zA-Z0-9]*)/,io=/\s+/g,gs=/class="[^"]*language-([\w+-]+)/,oo=/href="([^"]*)"/,lo=/src="([^"]*)"/,co=/alt="([^"]*)"/,uo=/[ \t]+\n/g,mo=/\n{3,}/g;function ho(e){const s=[],n=(...h)=>{for(let m=s.length-1;m>=0;m--)if(h.includes(s[m].tag)){const[p]=s.splice(m,1);return p}},a=[],i=()=>s.some(h=>h.tag==="pre"),r=()=>s.filter(h=>h.tag==="blockquote").length;let l=!0;const o=h=>{h&&(r()>0&&l&&!i()&&a.push("> ".repeat(r())),a.push(h),l=h.endsWith(`
|
|
42
|
-
`))},c=e.match(no)??[];for(let h=0;h<c.length;h++){const m=c[h];if(!m.startsWith("<")){o(i()?xs(m):xs(m).replace(io," "));continue}const p=ao.test(m),g=(m.match(ro)?.[1]??"").toLowerCase();if(p){switch(g){case"p":case"div":o(`
|
|
43
|
-
|
|
44
|
-
`);break;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":n(g),o(`
|
|
45
|
-
|
|
46
|
-
`);break;case"li":{n("li"),o(`
|
|
47
|
-
`);const d=[...s].reverse().find(S=>S.tag==="ul"||S.tag==="ol");d?.ordered&&(d.index=(d.index??1)+1);break}case"ul":case"ol":n(g),o(`
|
|
48
|
-
`);break;case"strong":case"b":n("strong","b")&&o("**");break;case"em":case"i":n("em","i")&&o("*");break;case"del":case"s":n("del","s")&&o("~~");break;case"code":{n("code")?.inline&&o("`");break}case"pre":n("pre")&&o("\n```\n\n");break;case"a":{const d=n("a");d?.href&&o(`](${d.href})`);break}case"blockquote":n("blockquote")&&o(`
|
|
49
|
-
`);break}continue}switch(g){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":{const d=Number(g[1]);s.push({tag:g}),o(`${"#".repeat(d)} `);break}case"ul":case"ol":s.push({tag:g,ordered:g==="ol",index:1});break;case"li":{const d=[...s].reverse().find(S=>S.tag==="ul"||S.tag==="ol");s.push({tag:"li"}),d?.ordered?o(`${d.index??1}. `):o("- ");break}case"strong":case"b":s.push({tag:g}),o("**");break;case"em":case"i":s.push({tag:g}),o("*");break;case"del":case"s":s.push({tag:g}),o("~~");break;case"code":{const d=s[s.length-1]?.tag!=="pre";s.push({tag:"code",inline:d}),d&&o("`");break}case"pre":{const d=m.match(gs)?.[1]??c[h+1]?.match(gs)?.[1]??"";s.push({tag:"pre"}),o(`
|
|
50
|
-
\`\`\`${d}
|
|
51
|
-
`);break}case"a":{const d=m.match(oo)?.[1]??"";s.push({tag:"a",href:d}),d&&o("[");break}case"img":{const d=m.match(lo)?.[1]??"",S=m.match(co)?.[1]??"";d&&o(``);break}case"br":o(`
|
|
52
|
-
`);break;case"blockquote":s.push({tag:"blockquote"});break}}return a.join("").replace(uo,`
|
|
53
|
-
`).replace(mo,`
|
|
54
|
-
|
|
55
|
-
`).trim()}const fo=[{value:"planning",label:"Planning"},{value:"active",label:"Active"},{value:"qa",label:"QA"},{value:"validation",label:"Validation"},{value:"done",label:"Done"},{value:"paused",label:"Paused"},{value:"archived",label:"Archived"}],wt={name:"",title:"",owner:"",team:"",description:"",status:"active",tags:"",startDate:"",targetDate:"",estimate:"",estimateUnit:"points"},js=Is;function bs(e){return e.split(",").map(s=>s.trim()).filter(s=>s.length>0)}function po(e){return e?{name:e.name,title:e.title??"",owner:e.owner??"",team:e.team??"",description:e.description,status:e.status,tags:e.tags.join(", "),startDate:e.start_date??"",targetDate:e.target_date??"",estimate:e.estimate===null||e.estimate===void 0?"":String(e.estimate),estimateUnit:e.estimate_unit||"points"}:wt}const St=({open:e,mode:s,initial:n,onClose:a,onSubmit:i})=>{const[r,l]=f.useState(wt),[o,c]=f.useState({}),[h,m]=f.useState(null),p=f.useRef(null),[g,d]=f.useState(!1),[S,v]=f.useState(s==="edit"),[$,y]=f.useState(!1),j=f.useId(),u=f.useRef(null);f.useEffect(()=>{e&&(l(s==="create"?{...wt,description:fs}:po(n)),c({}),m(null),d(!1),v(s==="edit"),y(!1))},[e]),f.useEffect(()=>{h&&p.current?.scrollIntoView({block:"nearest"})},[h]);const D=(x,P)=>{l(O=>({...O,[x]:P}))},_=s==="create"&&!S?Qi(r.title):r.name,w=x=>{const P=x.clipboardData?.getData("text/html");if(!P)return;const O=ho(P);if(!O)return;x.preventDefault();const A=x.currentTarget,L=A.selectionStart??A.value.length,q=A.selectionEnd??L,G=A.value.slice(0,L)+O+A.value.slice(q);D("description",G),requestAnimationFrame(()=>{const xe=u.current;if(!xe)return;const te=L+O.length;xe.setSelectionRange(te,te)})},C=(x,P)=>{const O={},A=In(P);A&&(O.name=A),x.description.length>Le&&(O.description=`Keep the description within ${Le} characters.`);const L=bs(x.tags);if(L.length>8)O.tags="At most 8 tags.";else for(const q of L){const G=Fn(q);if(G){O.tags=G;break}}if(js.test(x.startDate)||(O.startDate="Dates are YYYY-MM-DD, or empty."),js.test(x.targetDate)||(O.targetDate="Dates are YYYY-MM-DD, or empty."),!O.startDate&&!O.targetDate&&x.startDate&&x.targetDate&&x.targetDate<x.startDate&&(O.targetDate="The target date is before the start date."),x.estimate){const q=Number(x.estimate);(!Number.isFinite(q)||!(q>0)||q>1e3)&&(O.estimate="Estimates are greater than 0 and at most 1000.")}for(const q of["title","owner","team"])x[q].trim().length>80&&(O[q]=`${q==="title"?"Titles":q==="owner"?"Owners":"Teams"} are at most 80 characters.`);return O},F=async()=>{const x=_.trim(),P=C(r,x);if(c(P),Object.keys(P).length>0)return;d(!0),m(null);const O=bs(r.tags);try{if(s==="create"){const A={};r.title.trim()&&(A.title=r.title.trim()),r.owner.trim()&&(A.owner=r.owner.trim()),r.team.trim()&&(A.team=r.team.trim()),r.startDate&&(A.start_date=r.startDate),r.targetDate&&(A.target_date=r.targetDate),r.estimate&&(A.estimate=Number(r.estimate),A.estimate_unit=r.estimateUnit),await i({mode:"create",fields:{name:x,...r.description.trim()&&r.description.trim()!==fs?{description:r.description.trim()}:{},status:r.status,...O.length>0?{tags:O}:{}},...Object.keys(A).length>0?{followUp:A}:{}})}else await i({mode:"edit",key:n?.key??"",fields:{name:x,description:r.description.trim(),title:r.title.trim(),owner:r.owner.trim(),team:r.team.trim(),status:r.status,tags:O,start_date:r.startDate,target_date:r.targetDate,...r.estimate?{estimate:Number(r.estimate)}:{},estimate_unit:r.estimateUnit}});a()}catch(A){const L=A instanceof Error&&A.message?A.message:"";m(Qs(L)||"The project was not saved.")}finally{d(!1)}},z=s==="create"?"New project":"Edit project",E=r.description.length>Le;return t.jsx(Ze,{open:e,onClose:a,title:z,fullWidth:!0,maxWidth:"md",dialogProps:{closeDisabled:g,onEscapeKeyDown:x=>{g&&x.preventDefault()},onInteractOutside:x=>{g&&x.preventDefault()}},dataTourTag:s==="create"?"project-create-dialog":"project-edit-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(et,{onClick:a,disabled:g,children:"Cancel"}),t.jsxs(_s,{"data-project-submit":"",onClick:()=>void F(),disabled:g,children:[g&&t.jsx(fe,{size:"xs"}),s==="create"?"Create project":"Save changes"]})]}),children:t.jsxs("form",{className:"flex flex-col gap-6 px-1 py-1",onSubmit:x=>{x.preventDefault(),F()},children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(K,{htmlFor:`${j}-title`,children:"Title"}),t.jsx(V,{id:`${j}-title`,"data-project-title":"",value:r.title,onChange:x=>D("title",x.target.value),placeholder:"Payments migration",autoFocus:!0,className:"h-10 text-heading","aria-invalid":!!o.title}),o.title&&t.jsx("p",{className:"text-meta text-danger",children:o.title}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(K,{htmlFor:`${j}-key`,className:"shrink-0 text-meta text-ink-muted",children:"Key"}),t.jsx(V,{id:`${j}-key`,"data-project-key":"",value:_,onChange:x=>{v(!0),D("name",x.target.value)},placeholder:"payments-migration","aria-invalid":!!o.name,className:"h-7 max-w-56 font-mono text-mono-sm"}),t.jsx("span",{className:"text-meta text-ink-muted",children:s==="create"&&!S?"Derived from the title until you edit it.":"Letters, digits, dot, underscore or dash; no spaces."})]}),o.name&&t.jsx("p",{className:"text-meta text-danger",children:o.name})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(K,{htmlFor:`${j}-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(x=>t.jsx("button",{type:"button","data-project-description-mode":x,"aria-pressed":$===(x==="preview"),onClick:()=>y(x==="preview"),className:M("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2",$===(x==="preview")&&"bg-surface text-ink"),children:x==="write"?"Write":"Preview"},x))})]})]}),$?t.jsx("div",{"data-project-description-preview":"",className:"h-44 overflow-y-auto rounded-md border border-hairline bg-sunken px-3 py-2",children:r.description.trim()?t.jsx(Ve,{className:"text-body-sm",children:r.description}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:"Nothing to preview yet."})}):t.jsx(xa,{ref:u,id:`${j}-description`,"data-project-description":"",value:r.description,onChange:x=>D("description",x.target.value),onPaste:w,rows:8,placeholder:"Markdown — headings, lists, code.","aria-invalid":E||!!o.description,className:"h-44 resize-none"}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.description?t.jsx("p",{className:"text-meta text-danger",children:o.description}):t.jsx("span",{}),t.jsxs("p",{className:M("text-meta tabular-nums",E?"text-danger":"text-ink-muted"),children:[r.description.length,"/",Le]})]})]}),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(K,{children:"Status"}),t.jsxs(qe,{value:r.status,onValueChange:x=>D("status",x),children:[t.jsx(Be,{"aria-label":"Status",children:t.jsx(Ye,{})}),t.jsx(ze,{children:fo.map(x=>t.jsx(Ce,{value:x.value,children:x.label},x.value))})]}),r.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(K,{htmlFor:`${j}-owner`,children:"Owner"}),t.jsx(V,{id:`${j}-owner`,"data-project-owner":"",value:r.owner,onChange:x=>D("owner",x.target.value),placeholder:"atlas","aria-invalid":!!o.owner}),o.owner&&t.jsx("p",{className:"text-meta text-danger",children:o.owner})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(K,{htmlFor:`${j}-team`,children:"Team"}),t.jsx(V,{id:`${j}-team`,value:r.team,onChange:x=>D("team",x.target.value),placeholder:"platform","aria-invalid":!!o.team}),o.team&&t.jsx("p",{className:"text-meta text-danger",children:o.team})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(K,{htmlFor:`${j}-target`,children:"Target date"}),t.jsx(V,{id:`${j}-target`,"data-project-target":"",value:r.targetDate,onChange:x=>D("targetDate",x.target.value),placeholder:"YYYY-MM-DD","aria-invalid":!!o.targetDate}),o.targetDate&&t.jsx("p",{className:"text-meta text-danger",children:o.targetDate})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(K,{htmlFor:`${j}-start`,children:"Start date"}),t.jsx(V,{id:`${j}-start`,value:r.startDate,onChange:x=>D("startDate",x.target.value),placeholder:"YYYY-MM-DD","aria-invalid":!!o.startDate}),o.startDate&&t.jsx("p",{className:"text-meta text-danger",children:o.startDate})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(K,{htmlFor:`${j}-estimate`,children:"Estimate"}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(V,{id:`${j}-estimate`,value:r.estimate,onChange:x=>D("estimate",x.target.value),placeholder:"13",inputMode:"decimal","aria-invalid":!!o.estimate,className:"max-w-28"}),t.jsxs(qe,{value:r.estimateUnit,onValueChange:x=>D("estimateUnit",x),children:[t.jsx(Be,{"aria-label":"Estimate unit",className:"max-w-32",children:t.jsx(Ye,{})}),t.jsxs(ze,{children:[t.jsx(Ce,{value:"points",children:"Points"}),t.jsx(Ce,{value:"days",children:"Days"})]})]})]}),o.estimate&&t.jsx("p",{className:"text-meta text-danger",children:o.estimate}),s==="edit"&&r.estimate.trim()===""&&n?.estimate!==null&&n?.estimate!==void 0&&t.jsx("p",{className:"text-meta text-ink-muted",children:"Clearing an estimate is not supported yet — saving keeps its current value."})]}),t.jsxs("div",{className:"col-span-2 flex flex-col gap-1.5",children:[t.jsx(K,{htmlFor:`${j}-tags`,children:"Tags"}),t.jsx(V,{id:`${j}-tags`,value:r.tags,onChange:x=>D("tags",x.target.value),placeholder:"q4, payments","aria-invalid":!!o.tags}),o.tags?t.jsx("p",{className:"text-meta text-danger",children:o.tags}):t.jsx("p",{className:"text-meta text-ink-muted",children:"Comma-separated, up to 8. Lowercase letters, digits, underscore or dash."})]})]}),h&&t.jsx("p",{ref:p,className:"text-body-sm text-danger",children:h})]})})},xo=({links:e,target:s,onTargetChange:n,onSend:a,focusTick:i})=>{const[r,l]=f.useState(""),[o,c]=f.useState(!1),h=f.useRef(null);f.useEffect(()=>{i>0&&h.current?.focus()},[i]);const m=e.filter(v=>v.exists),g=(m.find(v=>v.session_id===s)??null)?.runtime?.busy===!0,d=!!s&&r.trim().length>0&&!o,S=async()=>{if(!(!d||!s)){c(!0);try{await a(s,r.trim(),g?"steer":"prompt")&&l("")}finally{c(!1),h.current?.focus()}}};return t.jsxs("div",{className:"flex flex-col gap-2 rounded-md bg-elevated p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-meta text-ink-muted",children:"Send to"}),t.jsxs(qe,{value:s??void 0,onValueChange:v=>n(v),children:[t.jsx(Be,{"aria-label":"Select the session to message",className:"max-w-72",children:t.jsx(Ye,{placeholder:"No session selected"})}),t.jsx(ze,{children:m.map(v=>t.jsx(Ce,{value:v.session_id,children:nt(v)},v.session_id))})]}),g&&t.jsx("span",{className:"text-meta text-ink-muted",children:"The session is working — this message steers the running turn."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(V,{ref:h,"aria-label":"Message the selected session",placeholder:"Message the session",value:r,onChange:v=>l(v.target.value),onKeyDown:v=>{v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),S())}}),t.jsxs(I,{variant:"secondary",disabled:!d,onClick:()=>void S(),"data-tour-tag":"project-quick-send",children:[o?t.jsx(fe,{size:"xs"}):t.jsx(Ua,{}),"Send"]})]})]})},go=({links:e,busy:s,onUnlink:n,onLink:a,onQuickSend:i,onStartSession:r})=>{const l=Je(),o=Ue(y=>y.sessions),[c,h]=f.useState(!1),[m,p]=f.useState(null),[g,d]=f.useState(0),S=m&&e.some(y=>y.session_id===m&&y.exists)?m:Dr(e),v=f.useMemo(()=>{const y=new Set(e.map(j=>j.session_id));return o.filter(j=>!y.has(j.session_id)).map(j=>({id:j.session_id,name:j.title||j.session_id,description:j.cwd??void 0}))},[o,e]),$=y=>{Ue.getState().openSession(y).then(j=>{j&&l(`/chat/${y}`)})};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(I,{variant:"secondary",size:"sm",disabled:s,onClick:r,"data-tour-tag":"project-start-session",children:[t.jsx(ka,{}),"New session"]}),t.jsxs(I,{variant:"secondary",size:"sm",disabled:s,onClick:()=>h(!0),"data-tour-tag":"project-link-session",children:[t.jsx(Oa,{}),"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(y=>{const j=rr(y),u=ir(y.subagents),D=or(y.todos),_=y.title||y.session_id,w=y.exists;return t.jsxs("li",{className:M("flex items-center gap-2 rounded-sm px-2 py-2",w&&"hover:bg-row-hover"),children:[t.jsx("button",{type:"button",disabled:!w,onClick:()=>{w&&$(y.session_id)},className:M("flex min-w-0 flex-1 items-center gap-2 text-left",w?"cursor-pointer":"cursor-default opacity-100"),children:t.jsx("span",{className:M("min-w-0 truncate text-body-sm",y.title?"text-ink":"font-mono text-mono-sm text-ink-muted"),children:_})}),y.runtime?.busy===!0&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:"busy"}),u&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:u}),D&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:D}),t.jsx(oe,{variant:j.variant,children:j.label}),w&&t.jsx(I,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":`Message ${_}`,title:`Message ${_}`,onClick:()=>{p(y.session_id),d(C=>C+1)},children:t.jsx(Na,{})}),t.jsx(I,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":`Unlink ${_}`,onClick:()=>n(y.session_id),children:t.jsx(Ba,{})})]},y.session_id)})}),e.length>0&&t.jsx(xo,{links:e,target:S,onTargetChange:p,onSend:i,focusTick:g}),t.jsx(Ze,{open:c,onClose:()=>h(!1),title:"Link a session",maxWidth:"sm",dataTourTag:"project-link-dialog",actions:t.jsx(et,{onClick:()=>h(!1),children:"Close"}),children:t.jsxs("div",{className:"flex flex-col gap-2 px-1 py-1",children:[t.jsx(K,{children:"Session"}),t.jsx(Ds,{showLabel:!1,ariaLabel:"Search sessions",busyLabel:"Loading sessions",placeholder:"Search conversations",options:v,selected:null,onSelect:y=>{h(!1),a(y.id)}}),t.jsx("p",{className:"text-meta text-ink-muted",children:"Conversations already linked to this project are not listed."})]})})]})},jo=({milestones:e,summary:s,busy:n,onToggle:a,onRemove:i,onAdd:r})=>{const[l,o]=f.useState(""),[c,h]=f.useState(""),m=!Is.test(c.trim()),p=l.trim().length>0&&!m&&!n,g=()=>{p&&(r(l.trim(),c.trim()),o(""),h(""))};return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"Milestones"}),s&&e.length>0&&t.jsx("span",{className:"text-meta text-ink-muted tabular-nums",children:s})]}),e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No milestones yet. Add one below to mark the dates this project is planned around."}):t.jsx("ul",{className:"flex flex-col divide-y divide-hairline rounded-md bg-surface",children:e.map(d=>{const S=Ja(d.status),v=d.completed_at!==null;return t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx(Es,{checked:v,disabled:n,onCheckedChange:$=>a(d.name,$===!0),"aria-label":v?`Mark ${d.name} not complete`:`Mark ${d.name} complete`}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:d.name}),d.target_date&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:ie(d.target_date,typeof navigator>"u"?void 0:navigator.language)}),t.jsx(oe,{variant:S.variant,children:S.label}),t.jsx(I,{variant:"ghost",size:"icon-sm",disabled:n,"aria-label":`Remove ${d.name}`,onClick:()=>i(d.name),children:t.jsx(At,{})})]},d.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(K,{htmlFor:"project-milestone-name",children:"New milestone"}),t.jsx(V,{id:"project-milestone-name",value:l,onChange:d=>o(d.target.value),placeholder:"beta cut",onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),g())}})]}),t.jsxs("div",{className:"flex w-40 flex-col gap-1.5",children:[t.jsx(K,{htmlFor:"project-milestone-date",children:"Target date"}),t.jsx(V,{id:"project-milestone-date",value:c,onChange:d=>h(d.target.value),placeholder:"YYYY-MM-DD","aria-invalid":m}),m&&t.jsx("p",{className:"text-meta text-danger",children:"Dates are YYYY-MM-DD, or empty."})]}),t.jsxs(I,{variant:"secondary",disabled:!p,onClick:g,"data-tour-tag":"project-milestone-add",children:[t.jsx(We,{}),"Add"]})]})]})},bo=({project:e,nowMs:s})=>{const n=typeof navigator>"u"?void 0:navigator.language,a=new Date(s),i=[],r=ie(e.start_date,n,a);r&&i.push({label:"Start",value:r});const l=ie(e.target_date,n,a);l&&i.push({label:"Target",value:l});const o=ie(e.completed_at,n,a);o&&i.push({label:"Completed",value:o});const c=Us(e.estimate,e.estimate_unit);if(c&&i.push({label:"Estimate",value:c}),e.tags.length>0&&i.push({label:"Tags",value:t.jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:e.tags.map(h=>t.jsx(oe,{variant:"outline",children:h},h))})}),e.updated_at>0){const h=Re(Ae(e.updated_at,s)),m=new Date(e.updated_at*1e3).toLocaleString(n);i.push({label:"Updated",value:t.jsx("time",{dateTime:new Date(e.updated_at*1e3).toISOString(),title:m,children:h})})}return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"Properties"}),i.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No dates, estimate or tags yet."}):t.jsx("dl",{className:"flex flex-col gap-2",children:i.map(h=>t.jsxs("div",{className:"flex items-baseline gap-3",children:[t.jsx("dt",{className:"w-24 shrink-0 text-body-sm text-ink-muted",children:h.label}),t.jsx("dd",{className:"min-w-0 text-body-sm text-ink",children:h.value})]},h.label))})]})},vo=({project:e})=>{const s=Xe(),n=an(),{sending:a,cooling:i,cooldownRemainingMs:r}=Mi(e.id);if(!be(s.data,"projects_request_update"))return null;const l=W(e),o=Ti(e.id);return t.jsxs(t.Fragment,{children:[t.jsx(Tt,{content:i&&r!==null?Ke(l,r):wi,children:t.jsxs(I,{variant:"secondary",className:"min-w-37","data-tour-tag":"project-request-update","aria-busy":a?!0:void 0,"aria-disabled":i?!0:void 0,"aria-describedby":i?o:void 0,onClick:()=>n(e),children:[a?t.jsx(fe,{size:"sm"}):i?t.jsx(As,{}):t.jsx(Ia,{}),a?"Requesting…":i?"Requested":"Request update"]})}),i&&r!==null&&t.jsx("span",{id:o,className:"sr-only",children:Ke(l,r)})]})},on="plain",ln=e=>`team:${e}`,cn=e=>`agent:${e}`;function yo(e){return e.startsWith("team:")?{kind:"team",name:e.slice(5)}:e.startsWith("agent:")?{kind:"agent",name:e.slice(6)}:{kind:"plain"}}function ko(e){return e.kind==="team"?ln(e.name):e.kind==="agent"?cn(e.name):on}const vs={kind:"plain"},No=({open:e,onClose:s,onStart:n,teamsEnabled:a,profilesEnabled:i})=>{const[r,l]=f.useState(vs),[o,c]=f.useState(null),[h,m]=f.useState(!1),p=Un(e&&a),g=qn(e&&i);f.useEffect(()=>{e&&(l(vs),c(null),m(!1))},[e]);const d=f.useMemo(()=>{const j=[{id:on,name:"Nothing in particular",description:"A plain session; assign a team or agent later.",group:"Plain"}];for(const u of p.data??[])j.push({id:ln(u.name),name:Wt(u),keywords:u.name===Wt(u)?void 0:[u.name],description:`Team · manager: ${u.manager}`,group:"Teams"});for(const u of(g.data??[]).filter(D=>D.source!=="builtin"))j.push({id:cn(u.name),name:u.name,description:u.description||u.kind,group:"Agents"});return j},[p.data,g.data]),S=d.find(j=>j.id===ko(r))??d[0],v=!a||!i,$=p.isLoading||g.isLoading,y=async()=>{m(!0),c(null);try{await n(r),s()}catch(j){c(j instanceof Error&&j.message?j.message:"The session could not be started.")}finally{m(!1)}};return t.jsx(Ze,{open:e,onClose:s,title:"Start a session",maxWidth:"sm",dataTourTag:"project-start-session-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(et,{onClick:s,disabled:h,children:"Cancel"}),t.jsxs(_s,{onClick:()=>void y(),disabled:h,children:[h&&t.jsx(fe,{size:"xs"}),"Start session"]})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx(Ds,{label:"Work with",placeholder:"Search teams and agents",options:d,selected:S,onSelect:j=>l(yo(j.id)),busy:$,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})]})})},dn=({status:e})=>{const s=Q(e);return t.jsxs(oe,{variant:s.variant,children:[Ga(e)&&t.jsx(As,{"aria-hidden":!0}),s.label]})},wo=({links:e})=>{const s=Cr(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:Zt(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:nt(a)}),a.todos&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:Zt(a.todos)})]},a.session_id))})]})},So=/[/\\]/;function un(e){if(e.name)return e.name;const s=e.path.split(So);return s[s.length-1]||"Attachment"}const _o=({attachment:e})=>{const s=un(e),n=_r(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(Hn,{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(Kn,{filePath:e.path,"aria-label":`File actions for ${s}`})]})},To=({attachment:e})=>{const s=un(e),n=wa(e.path,{mimeType:Bn(e.name||e.path),sizeBytes:e.bytes});return n.status==="ready"?t.jsx("div",{className:"inline-block max-w-full",children:t.jsx(Yn,{file:e.path,src:n.url,label:s,conversationId:""})}):n.status==="loading"?t.jsx(zn,{children:t.jsxs("span",{className:"sr-only",children:["Loading ",s]})}):t.jsx(Wn,{name:s})},Co=({attachments:e})=>t.jsx("div",{className:"flex flex-wrap items-start gap-2",children:e.map(s=>s.kind==="image"?t.jsx(To,{attachment:s},`${s.path}:${s.added_at}`):t.jsx(_o,{attachment:s},`${s.path}:${s.added_at}`))}),Do=({update:e,nowMs:s})=>{const n=typeof navigator>"u"?void 0:navigator.language,a=wr(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((i,r)=>t.jsxs(f.Fragment,{children:[r>0&&t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{children:i.text})]},i.key))}),e.text&&t.jsx(Ve,{children:e.text}),e.attachments.length>0&&t.jsx(Co,{attachments:e.attachments})]})},Eo=({updates:e,nowMs:s})=>{const n=typeof navigator>"u"?void 0:navigator.language,a=br(e.length),i=Sr(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:i.map(r=>t.jsxs("div",{className:"flex flex-col gap-2",children:[r.label&&t.jsx("h3",{className:"text-meta text-ink-muted",children:r.label}),t.jsx("div",{className:"flex flex-col divide-y divide-hairline",children:r.entries.map((l,o)=>t.jsx(Do,{update:l,nowMs:s},`${l.at}:${l.by}:${o}`))})]},r.key||"ungrouped"))})]})},Ao="project_not_found",Ro=({projectKey:e,nowMs:s})=>{const n=Je(),a=Xe(),i=Ts(be(a.data,"team_catalogue")),r=Os(e,!0),l=Ps(),o=Ms(),c=Qa(),h=Va(),m=Ha(),p=Ka(),[g,d]=f.useState(!1),[S,v]=f.useState(!1),[$,y]=f.useState(!1),j=l.isPending||o.isPending||c.isPending||h.isPending||m.isPending||p.isPending;if(r.isLoading)return t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(fe,{label:"Loading project"})});if(r.isError||!r.data){const E=r.error instanceof Qn&&(r.error.code===Ao||r.error.status===404);return t.jsxs("div",{className:"mx-auto flex w-full max-w-200 flex-col items-start gap-4",children:[t.jsx(ft,{variant:"danger",className:"w-full",children:E?"This project could not be found. It may have been deleted.":r.error instanceof Error&&r.error.message?r.error.message:"The project could not be read."}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(I,{variant:"secondary",onClick:()=>void r.refetch(),children:"Try again"}),t.jsxs(I,{variant:"secondary",onClick:()=>void n("/projects"),children:[t.jsx(Kt,{}),"All projects"]})]})]})}const{project:u,links:D}=r.data,_=W(u),w=gr(u.owner,u.team?i(u.team):u.team),C=Tr(u.milestones.filter(E=>E.completed_at!==null).length,u.milestones.length),F=async(E,x,P)=>{const O=Ue.getState(),A=Xn(null,E,O.drafts);if(!A)return!1;try{if(await Jn(A,{text:x,attachments:[],images:[],mode:P,cwd:O.cwd},E)===null)return ae("That session already has a message going out. Try again in a moment."),!1;const q=D.find(G=>G.session_id===E);return re(`Sent to ${q?nt(q):E}`),!0}catch(L){return ae(L instanceof Error&&L.message?L.message:"The message was not sent."),!1}},z=async E=>{const x=Ue.getState(),P=E.kind==="plain"?void 0:{kind:E.kind,name:E.name},O=await x.createSession(x.cwd||"~",P);if(!O)throw new Error(x.error??"The session could not be started.");Zn.getState().setCurrentInput(O,Er(u));let A=null;try{await m.mutateAsync({key:u.id,sessionId:O})}catch(L){A=L instanceof Error&&L.message?L.message:"the link was refused"}if(A)ae(`Session started, but linking it failed: ${A}`);else{const L=P?` with ${Ar(P)}`:"";re(`Session started${L} and linked to ${_}.`)}await Rs(n,O)};return t.jsxs("div",{className:"mx-auto flex w-full max-w-200 flex-col gap-8",children:[t.jsxs("header",{className:"flex flex-col gap-4",children:[t.jsxs("button",{type:"button",onClick:()=>void n("/projects"),className:"flex w-fit items-center gap-1.5 text-body-sm text-ink-muted hover:text-ink",children:[t.jsx(Kt,{className:"size-4"}),"All projects"]}),t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("h1",{"data-project-title":u.name,className:"min-w-0 break-words text-display text-ink",children:_}),t.jsx(dn,{status:u.status}),u.progress_stale&&t.jsx(oe,{variant:"warning",children:He})]}),u.title&&t.jsx("p",{className:"font-mono text-mono-sm text-ink-muted",children:u.name}),w&&t.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Managed by ",w]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(vo,{project:u}),t.jsxs(I,{variant:"secondary",onClick:()=>d(!0),"data-tour-tag":"project-edit",children:[t.jsx(Vn,{}),"Edit"]}),t.jsxs(I,{variant:"secondary",onClick:()=>v(!0),"data-tour-tag":"project-delete",children:[t.jsx(Gn,{}),"Delete"]})]})]})]}),u.description.trim()&&t.jsx(Ve,{className:"text-body",children:u.description}),t.jsx(bo,{project:u,nowMs:s}),u.updates.length===0&&u.progress&&t.jsxs("section",{className:"flex flex-col gap-2",children:[t.jsx("h2",{className:"text-title text-ink",children:"Progress"}),t.jsx(Ve,{className:"text-body",children:u.progress}),t.jsx("p",{className:"text-meta text-ink-muted",children:tr(u,s)})]}),t.jsx(jo,{milestones:u.milestones,summary:C,busy:j,onToggle:(E,x)=>{c.mutateAsync({key:u.id,name:E,completed:x}).catch(P=>{ae(P instanceof Error&&P.message?P.message:"The milestone was not updated.")})},onRemove:E=>{h.mutateAsync({key:u.id,name:E}).catch(x=>{ae(x instanceof Error&&x.message?x.message:"The milestone was not removed.")})},onAdd:(E,x)=>{c.mutateAsync({key:u.id,name:E,targetDate:x}).catch(P=>{ae(P instanceof Error&&P.message?P.message:"The milestone was not added.")})}}),t.jsx(go,{projectKey:u.id,links:D,busy:j,onStartSession:()=>y(!0),onQuickSend:F,onLink:E=>{m.mutateAsync({key:u.id,sessionId:E}).catch(x=>{ae(x instanceof Error&&x.message?x.message:"The session was not linked.")})},onUnlink:E=>{p.mutateAsync({key:u.id,sessionId:E}).catch(x=>{ae(x instanceof Error&&x.message?x.message:"The session was not unlinked.")})}}),t.jsx(wo,{links:D}),t.jsx(Eo,{updates:u.updates,nowMs:s}),t.jsx(St,{open:g,mode:"edit",initial:{key:u.id,name:u.name,title:u.title,owner:u.owner,team:u.team,description:u.description,status:u.status,tags:u.tags,start_date:u.start_date,target_date:u.target_date,estimate:u.estimate,estimate_unit:u.estimate_unit},onClose:()=>d(!1),onSubmit:async E=>{E.mode==="edit"&&(await l.mutateAsync({key:E.key,fields:E.fields}),re("Project saved"))}}),t.jsx(rn,{open:S,projectName:u.name,onClose:()=>v(!1),onConfirm:async E=>{await o.mutateAsync({key:u.id,confirmedName:E}),re("Project deleted"),n("/projects")}}),t.jsx(No,{open:$,onClose:()=>y(!1),onStart:z,teamsEnabled:be(a.data,"team_catalogue"),profilesEnabled:be(a.data,"profile_catalogue")})]})},mn=({children:e})=>{const s=f.useRef(null),[n,a]=f.useState(!1),i=()=>{const r=s.current;r&&a(r.scrollTop+r.clientHeight<r.scrollHeight-1)};return f.useEffect(i),t.jsx("div",{ref:s,onScroll:i,className:M("max-h-[min(70vh,32rem)] overflow-y-auto overscroll-contain",n&&"[mask-image:linear-gradient(to_bottom,black_calc(100%-12px),transparent)]"),children:e})},$o=({label:e,count:s,selected:n,onToggle:a})=>{const i=f.useId();return t.jsxs("div",{className:"flex items-center gap-2 rounded-sm px-1 py-1 hover:bg-sunken",children:[t.jsx(Es,{id:i,checked:n,onCheckedChange:()=>a()}),t.jsx(K,{htmlFor:i,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})]})},Oo=({column:e,spec:s,onChange:n})=>{const a=f.useId(),i=s!==null&&s.key===e,r=i?s.direction:ct(e),l=r==="asc"?"desc":"asc",o=()=>n({key:e,direction:i?l:ct(e)}),c=s===null?"default":i?"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:M("min-w-0 flex-1 truncate",c==="default"?"text-ink":"text-ink-muted"),children:Xr})]}),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:h=>{c==="sorted"&&(h.key!==" "&&h.key!=="Enter"||(h.preventDefault(),o()))},className:"m-0 size-3.5 shrink-0 accent-[var(--color-accent)]"}),t.jsx("span",{className:M("min-w-0 flex-1 truncate",c==="sorted"?"text-ink":"text-ink-muted"),children:`Sort by ${ke(e)}, ${Pt(e,i?r:ct(e))}`})]})]})},Po=({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:De[e]}),s.map(a=>t.jsx($o,{label:a.label,count:a.count,selected:a.selected,onToggle:()=>n(e,a.value)},`${e}:${a.value??"none"}`))]}),hn=({projects:e,state:s,query:n,todayMs:a,onToggle:i,onClearAll:r,scope:l,sort:o})=>{const c=f.useMemo(()=>l===void 0?Gr(e,s,a,n):l===null?[]:[en(l,e,s,a,n)],[l,e,s,a,n]),h=!Ee(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"}),h&&t.jsx(I,{variant:"link",size:"sm",onClick:r,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(Oo,{column:o.key,spec:o.spec,onChange:o.onChange})]}),c.map(m=>t.jsx(Po,{facet:m.facet,options:m.options,onToggle:i},m.facet))]})},Mo=({team:e,count:s,headingId:n,className:a,...i})=>t.jsxs("div",{...i,className:M("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??$t}),t.jsx("span",{className:"shrink-0 text-ink-muted","aria-label":nr(s),children:s})]}),ne=[{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 Lo(e,s){const n=Ae(e.progress_updated_at,s);return n?Re(n):"not reported"}const Io=({direction:e})=>e==="asc"?t.jsx($s,{size:10,className:"shrink-0","aria-hidden":"true"}):t.jsx(Cs,{size:10,className:"shrink-0","aria-hidden":"true"}),Fo=({projects:e,nowMs:s,onOpen:n,sort:a,onSortChange:i,allProjects:r,filters:l,query:o,todayMs:c,onToggleFilter:h,onClearFilters:m,teamLabelFor:p=g=>g})=>{const g=a?ii(e,a):e,d=Ot(g,$e),S=f.useId(),v=_=>`${S}-team-${_}`,[$,y]=f.useState(0),j=f.useRef([]),u=(_,w)=>{const C=ne.length;for(let F=1;F<=C;F+=1){const z=(_+w*F+C*C)%C,E=j.current[z];if(E&&E.offsetParent!==null){y(z),E.focus();return}}},D=_=>w=>{w.key!=="ArrowLeft"&&w.key!=="ArrowRight"||(w.preventDefault(),u(_,w.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:ne.map((_,w)=>{const C=a!==null&&a.key===_.sort;return t.jsx("th",{scope:"col","aria-sort":C?a.direction==="desc"?"descending":"ascending":"none",className:M(_.className,"p-0 text-left font-normal"),children:t.jsxs(Ct,{children:[t.jsx(Dt,{asChild:!0,children:t.jsxs("button",{type:"button",ref:F=>{j.current[w]=F},tabIndex:w===$?0:-1,"data-project-column":_.key,onFocus:()=>y(w),onKeyDown:D(w),className:M("group flex w-full min-w-0 items-center gap-1 rounded-xs text-left","transition-colors duration-fast ease-out-quart",C?"text-ink":"hover:text-ink"),children:[t.jsx("span",{className:"truncate",children:_.label}),C?t.jsx(Io,{direction:a.direction}):t.jsx(ea,{size:10,className:"shrink-0 text-ink-dim transition-colors duration-fast ease-out-quart group-hover:text-ink","aria-hidden":"true"})]})}),t.jsx(Et,{align:"start","aria-label":`${_.label} column`,className:"w-72 p-0",children:t.jsx(mn,{children:t.jsx(hn,{projects:r,state:l,query:o,todayMs:c,onToggle:h,onClearAll:m,scope:_.facet,sort:{key:_.sort,spec:a,onChange:i}})})})]})},_.key)})})})}),t.jsx("ul",{className:"min-h-0 flex-1 overflow-y-auto px-6",children:d.map((_,w)=>t.jsxs("li",{children:[t.jsx(Mo,{team:_.team==null?null:p(_.team),count:_.items.length,headingId:v(w),className:"sticky top-0 z-10","data-project-team":_.team??""}),t.jsx("ul",{"aria-labelledby":v(w),className:"divide-y divide-hairline",children:_.items.map(C=>{const F=new Map(Bs(C,typeof navigator>"u"?void 0:navigator.language).map(x=>[x.key,x.text])),z=qs(C.milestones_completed,C.milestones_total),E=Rt(C.live_sessions);return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>n(C),"data-project-name":C.name,className:M("flex w-full items-center gap-3 px-3 py-2 text-left","transition-colors duration-fast ease-out-quart","hover:bg-elevated"),children:[t.jsx("span",{className:M(ne[0].className,"truncate text-body-sm text-ink"),children:W(C)}),t.jsx("span",{className:ne[1].className,children:t.jsx(dn,{status:C.status})}),t.jsx("span",{className:M(ne[2].className,"truncate text-meta text-ink-muted"),children:F.get("target")??F.get("completed")??""}),t.jsx("span",{className:M(ne[3].className,"truncate text-meta text-ink-muted"),children:F.get("estimate")??""}),t.jsx("span",{className:M(ne[4].className,"truncate text-meta text-ink-muted"),children:z}),t.jsx("span",{className:M(ne[5].className,"truncate text-meta text-ink-muted"),children:E}),t.jsxs("span",{className:M(ne[6].className,"flex items-center gap-2"),children:[t.jsx("span",{className:"truncate text-meta text-ink-muted",children:Lo(C,s)}),C.progress_stale&&t.jsx(oe,{variant:"warning",children:He})]})]})},C.id)})})]},_.team??""))})]})},Ge=224,ys=36,Uo={day:"Days",week:"Weeks",month:"Months",quarter:"Quarters"},qo=({items:e,nowMs:s,onOpen:n,pendingDetails:a,failedDetails:i,onRetryDetails:r,teamLabelFor:l=o=>o})=>{const[o,c]=f.useState(null),[h,m]=f.useState(0),p=f.useRef(null),g=Lt(s),d=f.useMemo(()=>ci(e,g),[e,g]),S=f.useMemo(()=>di(e),[e]),v=f.useMemo(()=>Ot(S.dated,w=>$e(w.project)),[S]);f.useLayoutEffect(()=>{const w=p.current;if(!w)return;const C=()=>m(w.clientWidth);if(C(),typeof ResizeObserver>"u")return;const F=new ResizeObserver(C);return F.observe(w),()=>F.disconnect()},[]);const $=Math.max(h-Ge-24,160),y=d?oi(is(d.startMs,d.endMs),$):"month",j=o??y,u=w=>{const C=ce.indexOf(j),F=ce[C-w];F&&c(F)},D=Mt[j],_=d?is(d.startMs,d.endMs)*D:0;return t.jsxs("div",{ref:p,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:i>0?`Milestones could not be read for ${i} project${i===1?"":"s"}.`:`${S.dated.length} dated · ${S.undated.length} without dates${a>0?` · loading milestones for ${a}…`:""}`}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[i>0&&t.jsx(I,{variant:"secondary",size:"sm",onClick:r,children:"Try again"}),t.jsx(I,{variant:"secondary",size:"icon","aria-label":"Zoom in",title:"Zoom in (finer)",disabled:!d||j===ce[0],onClick:()=>u(1),children:t.jsx(We,{})}),t.jsx("span",{className:"w-16 text-center text-meta text-ink-muted",children:Uo[j]}),t.jsx(I,{variant:"secondary",size:"icon","aria-label":"Zoom out",title:"Zoom out (coarser)",disabled:!d||j===ce[ce.length-1],onClick:()=>u(-1),children:t.jsx(ga,{})})]})]}),d&&S.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(Bo,{startMs:d.startMs,endMs:d.endMs,tier:j,pxPerDay:D,trackPx:_}),v.map(w=>t.jsxs("div",{children:[t.jsx("div",{className:"sticky top-0 z-20 flex items-stretch bg-canvas","data-project-team":w.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:Ge},children:[t.jsx("span",{className:"truncate text-ink",children:w.team==null?$t:l(w.team)}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:w.items.length})]})}),w.items.map(C=>t.jsx(Yo,{item:C,spanStart:d.startMs,pxPerDay:D,trackPx:_,today:g,onOpen:()=>n(C)},C.project.id))]},w.team??""))]})}):null,S.undated.length>0&&t.jsx("div",{className:"shrink-0 px-9 py-2","data-project-undated-callout":"",children:t.jsxs(ta,{defaultOpen:S.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(Ra,{size:14,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),t.jsx("span",{className:"truncate text-ink",children:ui(S.undated.length)})]}),children:[S.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:S.undated.map(w=>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(w),children:W(w.project)})},w.project.id))})]})})]})},Bo=({startMs:e,endMs:s,tier:n,pxPerDay:a,trackPx:i})=>{const r=vi(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:Ge}}),t.jsx("span",{className:"relative block h-6",style:{width:i},children:r.map(l=>t.jsxs("span",{className:"absolute top-0 h-full",style:{left:ue(e,l.dayMs)*a},children:[t.jsx("span",{className:M("absolute top-0 h-full w-px",l.major?"bg-hairline":"bg-hairline/60"),"aria-hidden":"true"}),t.jsx("span",{className:"absolute top-1/2 left-1 -translate-y-1/2 whitespace-nowrap text-meta text-ink-muted",children:l.label})]},l.dayMs))})]})},Yo=({item:e,spanStart:s,pxPerDay:n,trackPx:a,today:i,onOpen:r})=>{const{project:l}=e,o=mi(e),c=hi(e),h=m=>new Date(m).toISOString().slice(0,10);return t.jsxs("button",{type:"button",onClick:r,"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:Ge,height:ys},children:t.jsx("span",{className:"truncate text-body-sm text-ink",children:W(l)})}),t.jsxs("span",{className:"relative block",style:{width:a,height:ys},children:[o&&t.jsx("span",{className:"absolute top-1/2 h-1.5 -translate-y-1/2 rounded-full bg-accent/75",style:{left:ue(s,o.fromMs)*n,width:(ue(o.fromMs,o.toMs)+1)*n},title:`${ie(h(o.fromMs))} → ${ie(h(o.toMs))}`}),c.map(m=>t.jsx("span",{"data-milestone":m.status,className:M("absolute top-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rotate-45",m.status==="completed"&&"bg-success",m.status==="overdue"&&"bg-warning",m.status==="upcoming"&&"border-[1.5px] border-ink-muted bg-surface"),style:{left:ue(s,m.dayMs)*n},title:`${m.name} · ${m.status} · ${ie(h(m.dayMs))}`},`${m.name}-${m.dayMs}`)),t.jsx("span",{className:"absolute inset-y-0 w-px bg-accent/75",style:{left:ue(s,i)*n},"aria-hidden":"true"})]})]})},zo=({projects:e,query:s,onQueryChange:n,filters:a,onFiltersChange:i,onClearAll:r,todayMs:l,resultText:o,countRevealClass:c="@[37rem]:inline",trailing:h,disabled:m=!1,searchFieldRef:p})=>{const[g,d]=f.useState(!1),S=f.useRef(!1),v=Hr(a),$=Sa(o??"",300),y=s.trim()!==""||!Ee(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(sa,{size:16,className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim","aria-hidden":"true"}),t.jsx(V,{ref:p,inputSize:"sm",value:s,onChange:j=>n(j.target.value),onKeyDown:j=>{j.key==="Escape"&&(s?n(""):j.currentTarget.blur())},placeholder:"Search projects","aria-label":"Search projects",autoComplete:"off",spellCheck:!1,className:"pl-9"}),s?t.jsx(I,{variant:"ghost",size:"icon-sm",className:"absolute top-1/2 right-1 -translate-y-1/2",onClick:()=>na(p.current,n),"aria-label":"Clear search",children:t.jsx(At,{"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(aa,{shortcut:"/"})})]}),t.jsxs(Ct,{open:g,onOpenChange:d,children:[t.jsx(Dt,{asChild:!0,children:t.jsxs(I,{variant:"secondary",size:"sm",disabled:m,"data-project-filters-button":"",children:[t.jsx(Ma,{size:14,"aria-hidden":"true"}),"Filters",v>0&&t.jsx(oe,{variant:"neutral",children:v})]})}),t.jsx(Et,{align:"end","aria-label":"Filters",className:"w-80 p-0",onCloseAutoFocus:j=>{S.current&&(S.current=!1,j.preventDefault())},children:t.jsx(mn,{children:t.jsx(hn,{projects:e,state:a,query:s,todayMs:l,onToggle:(j,u)=>i(Xs(a,j,u)),onClearAll:()=>{r(),S.current=!0,d(!1),p.current?.focus()}})})})]}),y&&o!==null&&t.jsx("span",{className:M("hidden whitespace-nowrap text-meta text-ink-dim",c),"data-project-count":"",children:o}),t.jsx("output",{className:"sr-only","aria-live":"polite",children:$}),h]})},Wo=({filters:e,sort:s,onFiltersChange:n,onSortChange:a,onClearAll:i,hideClearAll:r=!1,searchFieldRef:l})=>{const[o,c]=f.useState(null);f.useEffect(()=>{if(!o)return;let p=null;o.kind==="search"?p=l.current:(p=document.querySelector(`[data-project-chip="${o.index}"]`),p||(p=document.querySelector("[data-project-chip]")),p||(p=document.querySelector("[data-project-filters-button]"))),p&&(p.focus(),c(null))});const h=[];for(const p of Ne){const g=e[p];if(g.length===0)continue;const d=g.map($=>Gs(p,$)),S=d[0],v=d.length>1?`${De[p]} · ${S} +${d.length-1}`:`${De[p]} · ${S}`;h.push({kind:"facet",facet:p,label:v,ariaLabel:`Remove filter: ${De[p]} · ${d.join(", ")}`,clear:()=>n({...e,[p]:[]})})}if(s&&h.push({kind:"sort",spec:s,label:`Sort: ${ke(s.key)}`,ariaLabel:`Remove sort: ${ke(s.key)}, ${Pt(s.key,s.direction)}`,clear:()=>a(null)}),h.length===0)return null;const m=(p,g)=>{g.clear();const d=h.length-1;c(d===0?{kind:"chip",index:0}:{kind:"chip",index:Math.min(p,d-1)})};return t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.map((p,g)=>t.jsx(oe,{asChild:!0,variant:"neutral",className:"gap-1 pr-1 text-ink",children:t.jsxs("button",{type:"button",className:"group","data-project-chip":g,"aria-label":p.ariaLabel,onClick:()=>m(g,p),children:[p.kind==="sort"&&(p.spec.direction==="asc"?t.jsx($s,{size:10,className:"text-ink-muted","aria-hidden":"true"}):t.jsx(Cs,{size:10,className:"text-ink-muted","aria-hidden":"true"})),t.jsx("span",{className:"truncate",children:p.label}),t.jsx(At,{className:M("text-ink-dim transition-colors duration-fast ease-out-quart","group-hover:text-danger"),"aria-hidden":"true"})]})},p.kind==="facet"?p.facet:"sort")),!r&&t.jsx(I,{variant:"link",size:"sm",onClick:()=>{i(),c({kind:"search"})},children:"Clear all"})]})},fn="projects-view",Ho=[{value:"list",label:"List"},{value:"board",label:"Board"},{value:"timeline",label:"Timeline"}];function Ko(){try{const e=localStorage.getItem(fn);if(e==="board"||e==="timeline"||e==="list")return e}catch{}return"board"}function Qo(e){try{localStorage.setItem(fn,e)}catch{}}const Vo=({value:e,onChange:s})=>t.jsx(ja,{value:e,onValueChange:n=>s(n),children:t.jsx(ba,{"aria-label":"Project view","data-tour-tag":"projects-view-switcher",children:Ho.map(n=>t.jsx(va,{value:n.value,children:n.label},n.value))})}),Go=["r1","r2","r3","r4","r5","r6"],Xo=4e3,ks={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."},rl=({nowMs:e=Date.now()})=>{const{projectId:s}=ra(),n=Je(),a=Xe(),i=ia(a.data,"projects",1),r=i==="enabled",l=Ts(be(a.data,"team_catalogue")),o=Ya(r),c=Wa(),h=Ps(),m=Ms(),[p,g]=f.useState(!1),[d,S]=f.useState(()=>Ko()),[v,$]=f.useState(()=>mr()),[y,j]=f.useState(null),[u,D]=f.useState(null),[_,w]=f.useState(""),[C,F]=f.useState(ss),[z,E]=f.useState(()=>ei()),[x,P]=f.useState(""),O=f.useRef(""),A=f.useRef(null),L=f.useRef(null),q=N=>{A.current!==null&&(window.cancelAnimationFrame(A.current),A.current=null),N!==""&&N===O.current?(P(""),A.current=window.requestAnimationFrame(()=>{A.current=null,P(N)})):P(N),O.current=N,L.current!==null&&window.clearTimeout(L.current),L.current=window.setTimeout(()=>{L.current=null,O.current="",P("")},Xo)},G=()=>{A.current!==null&&(window.cancelAnimationFrame(A.current),A.current=null),L.current!==null&&(window.clearTimeout(L.current),L.current=null),O.current="",P("")},xe=N=>{w(N),G()},te=N=>{F(N),G()},ge=f.useRef(null),k=Li(),b=o.data??[],T=Lt(e),R=f.useMemo(()=>Kr(qr(b,_),C,T),[b,_,C,T]),U=_.trim()!==""||!Ee(C),Y=f.useMemo(()=>Gt(b,v,e),[b,v,e]),H=f.useMemo(()=>Gt(R,v,e),[R,v,e]),Oe=ur(v),we=d==="board"?H.length:R.length,at=!U||!o.isSuccess?null:d==="board"?`${H.length} of ${Y.length} in window`:`${R.length} of ${b.length} projects`,le=o.isSuccess&&b.length>0,se=le&&U&&we===0,[rt,Pe]=f.useState(!1);f.useEffect(()=>{if(!rt)return;const N=document.querySelector('[data-tour-tag="projects-board-window"]');N&&(N.focus(),Pe(!1))}),f.useEffect(()=>{if(!r||s)return;const N=B=>{const X=B.target;if(!X||X.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(X.tagName)||X.closest('[role="dialog"]'))return;const _e=B.key==="/"&&!B.metaKey&&!B.ctrlKey&&!B.altKey,lt=(B.metaKey||B.ctrlKey)&&B.key.toLowerCase()==="f";!_e&&!lt||(B.preventDefault(),ge.current?.focus())};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[r,s]);const Se=za(d==="timeline"?b.map(N=>N.id):[],r),it=new Map(b.map((N,B)=>[N.id,Se[B]])),pn=R.map(N=>({project:N,milestones:it.get(N.id)?.data?.project.milestones??[]})),xn=d==="timeline"?R.filter(N=>it.get(N.id)?.isLoading).length:0,gn=d==="timeline"?R.filter(N=>it.get(N.id)?.isError).length:0,jn=()=>{for(const N of Se)N.isError&&N.refetch()},ot=N=>{E(N),ti(N),q(si(N))},bn=(N,B)=>{F(X=>Xs(X,N,B)),G()},Me=()=>{const N=_.trim()!=="",B=!Ee(C),X=z!==null;w(""),F(ss),z!==null&&ot(null),q(ni({search:N,filters:B,sort:X}))},Ft=()=>{$("all"),Xt("all"),Pe(!0)},vn=(N,B)=>{h.mutate({key:N.id,fields:{status:B}},{onSuccess:()=>{re(`Moved to ${Q(B).label}`),o.refetch().then(()=>k(N.id))}})};return r?s?t.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto overflow-x-hidden p-6 [scrollbar-gutter:stable_both-edges]",children:t.jsx(Ro,{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(Ht,{title:"Projects",icon:Qt,subtitle:"Workstreams you and your agents track across sessions.",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(I,{variant:"secondary",size:"icon","aria-label":"Refresh projects",title:"Refresh projects",disabled:o.isFetching,onClick:()=>void o.refetch(),"data-tour-tag":"refresh-projects-button",children:t.jsx(_a,{})}),t.jsxs(I,{variant:"secondary",onClick:()=>g(!0),"data-tour-tag":"create-project-button",children:[t.jsx(We,{}),"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(Vo,{value:d,onChange:N=>{S(N),Qo(N)}}),t.jsx(zo,{projects:b,query:_,onQueryChange:xe,filters:C,onFiltersChange:te,onClearAll:Me,todayMs:T,resultText:at,countRevealClass:d==="board"?"@[47rem]:inline":void 0,disabled:o.isError,searchFieldRef:ge,trailing:d==="board"&&!(o.isSuccess&&o.data.length===0)?t.jsx(ki,{value:v,onChange:N=>{$(N),Xt(N)}}):null})]}),t.jsx(Wo,{filters:C,sort:z,onFiltersChange:te,onSortChange:ot,onClearAll:Me,hideClearAll:se,searchFieldRef:ge}),t.jsx("output",{"data-project-announcement":"",className:"sr-only","aria-live":"polite",children:x})]})]}),t.jsxs("div",{className:"mt-8 flex min-h-0 flex-1 flex-col",children:[o.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…"}),Go.map(N=>t.jsxs("div",{className:"flex items-center gap-3 px-9 py-2","aria-hidden":"true",children:[t.jsx(je,{className:"h-4 min-w-0 flex-1 bg-elevated"}),t.jsx(je,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(je,{className:"h-4 w-32 shrink-0 bg-elevated"}),t.jsx(je,{className:"h-4 w-16 shrink-0 bg-elevated"}),t.jsx(je,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(je,{className:"h-4 w-40 shrink-0 bg-elevated"})]},N))]}),o.isError&&t.jsxs("div",{className:"flex flex-col items-start gap-2 px-6",children:[t.jsx(ft,{variant:"danger",children:o.error instanceof Error&&o.error.message?o.error.message:"The projects could not be read."}),t.jsx(I,{variant:"secondary",size:"sm",onClick:()=>void o.refetch(),children:"Try again"})]}),o.isSuccess&&o.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(I,{variant:"primary",onClick:()=>g(!0),"data-tour-tag":"create-project-empty-button",children:[t.jsx(We,{}),"New project"]})]}),le&&se&&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:_.trim()?`No projects match "${_.trim()}".`:"No projects match."}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:_.trim()?"Searches names, descriptions, tags, owners and teams. Update text is not searched. Clearing the search and filters restores the list.":"Try removing a filter. Clearing the filters restores the list."}),t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(I,{variant:"secondary",onClick:()=>{Me(),ge.current?.focus()},children:"Clear all"}),d==="board"&&R.length>0&&t.jsx(I,{variant:"secondary",onClick:Ft,children:"Show all time"})]})]}),le&&!se&&d==="list"&&t.jsx(Fo,{projects:R,nowMs:e,onOpen:N=>void n(`/projects/${N.id}`),sort:z,onSortChange:ot,allProjects:b,filters:C,query:_,todayMs:T,onToggleFilter:bn,onClearFilters:Me,teamLabelFor:l}),le&&!se&&d==="board"&&H.length>0&&t.jsx(Fi,{projects:H,nowMs:e,onOpen:N=>void n(`/projects/${N.id}`),onEdit:j,onDelete:D,onMove:vn,teamLabelFor:l,movingKeys:h.isPending&&h.variables?[h.variables.key]:[]}),le&&!se&&d==="board"&&H.length===0&&Oe!==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:Oe}),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(I,{variant:"secondary",onClick:Ft,children:"Show all time"})]}),le&&!se&&d==="timeline"&&t.jsx(qo,{items:pn,nowMs:e,onOpen:N=>void n(`/projects/${N.project.id}`),pendingDetails:xn,failedDetails:gn,onRetryDetails:jn,teamLabelFor:l})]}),t.jsx(St,{open:y!==null,mode:"edit",initial:y?{key:y.id,name:y.name,title:y.title,owner:y.owner,team:y.team,description:y.description,status:y.status,tags:y.tags,start_date:y.start_date,target_date:y.target_date,estimate:y.estimate,estimate_unit:y.estimate_unit}:null,onClose:()=>j(null),onSubmit:async N=>{N.mode==="edit"&&(await h.mutateAsync({key:N.key,fields:N.fields}),re("Project saved"),j(null))}}),t.jsx(rn,{open:u!==null,projectName:u?.name??"",onClose:()=>D(null),onConfirm:async N=>{u&&(await m.mutateAsync({key:u.id,confirmedName:N}),re("Project deleted"),D(null))}}),t.jsx(St,{open:p,mode:"create",onClose:()=>g(!1),onSubmit:async N=>{if(N.mode!=="create")return;const B=await c.mutateAsync(N.fields),X=N.followUp?.title??N.fields.name;if(N.followUp)try{await h.mutateAsync({key:B.id,fields:N.followUp})}catch(_e){const lt=_e instanceof Error&&_e.message?_e.message:"";ae(`Project ${X} was created, but the extra fields were not saved: ${Qs(lt)||"the server refused them."} Open the project and use Edit to set them.`);return}re(`Project ${X} created`)}})]}):t.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[t.jsx(Ht,{title:"Projects",icon:Qt}),a.isLoading?t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(fe,{label:"Checking the server's Projects support"})}):t.jsx(ft,{variant:"warning",children:ks[i]??ks.unknown})]})};export{rl as ProjectsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as r,b as e,a,S as s}from"./chunk-AEK57VVT-CvyIUWUR.js";import{_ as i}from"./mermaid.core-eIMT1oSc.js";import"./chunk-RZ5BOZE2-znegx9P6.js";import"./conversation-input-sync-CGaXAqah.js";import"./ui-preferences-store-CxJfZcpf.js";import"./index-CSNQxVPq.js";import"./error-boundary-BR1z8pWF.js";var n={parser:a,get db(){return new s(2)},renderer:e,styles:r,init:i(t=>{t.state||(t.state={}),t.state.arrowMarkerAbsolute=t.arrowMarkerAbsolute},"init")};export{n as diagram};
|
|
File without changes
|