meshy-node 0.8.8 → 0.8.9

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.
@@ -0,0 +1,144 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-2p61JxFR.js","assets/index-CR3C-F8v.js","assets/index-Df0Lew9J.css","assets/DashboardShared-BhuvZY0B.js","assets/file-BBv9tDe9.js","assets/PreviewTab-hE7s4Tq6.js","assets/play-D8zhWxnK.js","assets/DiffTab-DrsxsCTo.js"])))=>i.map(i=>d[i]);
2
+ import{c as fe,r as a,j as e,X as ot,B as G,S as pa,a as Wr,b as M,d as Gr,g as Yr,e as Qr,I as nt,C as Ft,f as Xr,h as fa,F as Jr,i as ss,k as xt,l as xe,D as Ht,m as Zr,n as eo,t as le,o as Se,p as Ce,q as Ie,s as Ee,u as ns,v as Qe,T as to,w as so,x as yn,y as no,z as qt,A as Kt,E as ps,G as ga,H as ba,J as Tt,K as Ps,L as ao,M as Gs,N as va,P as ro,O as Ys,Q as at,R as He,U as oo,V as rt,W as as,Y as rs,Z as os,_ as is,$ as ls,a0 as ds,a1 as cs,a2 as us,a3 as Qs,a4 as io,a5 as Xs,a6 as ja,a7 as lo,a8 as kn,a9 as Sn,aa as ts,ab as co,ac as uo,ad as mo,ae as xo,af as wa,ag as ho,ah as Na,ai as po,aj as fo,ak as go,al as ya,am as ka,an as Sa,ao as bo,ap as ms,aq as Js,ar as vo,as as jo,at as wo,au as Ca,av as Ut,aw as No,ax as Ls,ay as yo,az as ko,aA as So,aB as Co,aC as Cn,aD as Eo,aE as _o,aF as Ss,aG as To,aH as En,aI as Do,aJ as Ao,aK as Mo,aL as _n,aM as Po,aN as Lo,aO as Is,aP as Io,aQ as Bo,aR as Ea,aS as Tn,aT as _a,aU as Ro,aV as $o,aW as Oo,aX as zo,aY as Fo,aZ as Ho,a_ as Uo,a$ as Vo,b0 as qo,b1 as Ko,b2 as Wo,b3 as Go,b4 as Yo,b5 as Qo,b6 as Xo,b7 as Jo,b8 as Zo,b9 as ei,ba as ti,bb as si,bc as ni,bd as ai,be as ri,bf as oi,bg as ii,bh as li,bi as di,bj as ci,bk as ui,bl as mi,bm as xi,bn as hi}from"./index-CR3C-F8v.js";import{r as Dn,e as pi,b as Ta,t as Da,A as Zs,L as ue,g as Aa,a as fi,c as gi,d as An,f as Mn,h as bi,i as vi,C as Pn,T as Cs,D as _t,I as st,M as Bs,j as Ma,k as ji,m as Pa,l as Rs,n as wi,o as Ln,p as Ni,q as yi,s as Es,u as ki,v as Si,w as Ci}from"./DashboardShared-BhuvZY0B.js";import{P as en}from"./play-D8zhWxnK.js";/**
3
+ * @license lucide-react v1.7.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */const Ei=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],_i=fe("archive",Ei);/**
8
+ * @license lucide-react v1.7.0 - ISC
9
+ *
10
+ * This source code is licensed under the ISC license.
11
+ * See the LICENSE file in the root directory of this source tree.
12
+ */const Ti=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],In=fe("arrow-right",Ti);/**
13
+ * @license lucide-react v1.7.0 - ISC
14
+ *
15
+ * This source code is licensed under the ISC license.
16
+ * See the LICENSE file in the root directory of this source tree.
17
+ */const Di=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],La=fe("arrow-up",Di);/**
18
+ * @license lucide-react v1.7.0 - ISC
19
+ *
20
+ * This source code is licensed under the ISC license.
21
+ * See the LICENSE file in the root directory of this source tree.
22
+ */const Ai=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Mi=fe("ellipsis-vertical",Ai);/**
23
+ * @license lucide-react v1.7.0 - ISC
24
+ *
25
+ * This source code is licensed under the ISC license.
26
+ * See the LICENSE file in the root directory of this source tree.
27
+ */const Pi=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Li=fe("ellipsis",Pi);/**
28
+ * @license lucide-react v1.7.0 - ISC
29
+ *
30
+ * This source code is licensed under the ISC license.
31
+ * See the LICENSE file in the root directory of this source tree.
32
+ */const Ii=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],Bi=fe("flag",Ii);/**
33
+ * @license lucide-react v1.7.0 - ISC
34
+ *
35
+ * This source code is licensed under the ISC license.
36
+ * See the LICENSE file in the root directory of this source tree.
37
+ */const Ri=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],tn=fe("folder-open",Ri);/**
38
+ * @license lucide-react v1.7.0 - ISC
39
+ *
40
+ * This source code is licensed under the ISC license.
41
+ * See the LICENSE file in the root directory of this source tree.
42
+ */const $i=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Oi=fe("funnel",$i);/**
43
+ * @license lucide-react v1.7.0 - ISC
44
+ *
45
+ * This source code is licensed under the ISC license.
46
+ * See the LICENSE file in the root directory of this source tree.
47
+ */const zi=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],$s=fe("git-branch",zi);/**
48
+ * @license lucide-react v1.7.0 - ISC
49
+ *
50
+ * This source code is licensed under the ISC license.
51
+ * See the LICENSE file in the root directory of this source tree.
52
+ */const Fi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Hi=fe("globe",Fi);/**
53
+ * @license lucide-react v1.7.0 - ISC
54
+ *
55
+ * This source code is licensed under the ISC license.
56
+ * See the LICENSE file in the root directory of this source tree.
57
+ */const Ui=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Os=fe("history",Ui);/**
58
+ * @license lucide-react v1.7.0 - ISC
59
+ *
60
+ * This source code is licensed under the ISC license.
61
+ * See the LICENSE file in the root directory of this source tree.
62
+ */const Vi=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],zs=fe("image-plus",Vi);/**
63
+ * @license lucide-react v1.7.0 - ISC
64
+ *
65
+ * This source code is licensed under the ISC license.
66
+ * See the LICENSE file in the root directory of this source tree.
67
+ */const qi=[["path",{d:"M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z",key:"1pdavp"}],["path",{d:"M20.054 15.987H3.946",key:"14rxg9"}]],Ki=fe("laptop",qi);/**
68
+ * @license lucide-react v1.7.0 - ISC
69
+ *
70
+ * This source code is licensed under the ISC license.
71
+ * See the LICENSE file in the root directory of this source tree.
72
+ */const Wi=[["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"}]],sn=fe("link-2",Wi);/**
73
+ * @license lucide-react v1.7.0 - ISC
74
+ *
75
+ * This source code is licensed under the ISC license.
76
+ * See the LICENSE file in the root directory of this source tree.
77
+ */const Gi=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],Yi=fe("list-ordered",Gi);/**
78
+ * @license lucide-react v1.7.0 - ISC
79
+ *
80
+ * This source code is licensed under the ISC license.
81
+ * See the LICENSE file in the root directory of this source tree.
82
+ */const Qi=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],fs=fe("message-square-plus",Qi);/**
83
+ * @license lucide-react v1.7.0 - ISC
84
+ *
85
+ * This source code is licensed under the ISC license.
86
+ * See the LICENSE file in the root directory of this source tree.
87
+ */const Xi=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],Ia=fe("panel-left-close",Xi);/**
88
+ * @license lucide-react v1.7.0 - ISC
89
+ *
90
+ * This source code is licensed under the ISC license.
91
+ * See the LICENSE file in the root directory of this source tree.
92
+ */const Ji=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],Zi=fe("panel-left-open",Ji);/**
93
+ * @license lucide-react v1.7.0 - ISC
94
+ *
95
+ * This source code is licensed under the ISC license.
96
+ * See the LICENSE file in the root directory of this source tree.
97
+ */const el=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],nn=fe("panel-right-close",el);/**
98
+ * @license lucide-react v1.7.0 - ISC
99
+ *
100
+ * This source code is licensed under the ISC license.
101
+ * See the LICENSE file in the root directory of this source tree.
102
+ */const tl=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],Ba=fe("panel-right-open",tl);/**
103
+ * @license lucide-react v1.7.0 - ISC
104
+ *
105
+ * This source code is licensed under the ISC license.
106
+ * See the LICENSE file in the root directory of this source tree.
107
+ */const sl=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Lt=fe("pencil",sl);/**
108
+ * @license lucide-react v1.7.0 - ISC
109
+ *
110
+ * This source code is licensed under the ISC license.
111
+ * See the LICENSE file in the root directory of this source tree.
112
+ */const nl=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],al=fe("plus",nl);/**
113
+ * @license lucide-react v1.7.0 - ISC
114
+ *
115
+ * This source code is licensed under the ISC license.
116
+ * See the LICENSE file in the root directory of this source tree.
117
+ */const rl=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Bn=fe("rotate-ccw",rl);/**
118
+ * @license lucide-react v1.7.0 - ISC
119
+ *
120
+ * This source code is licensed under the ISC license.
121
+ * See the LICENSE file in the root directory of this source tree.
122
+ */const ol=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Ra=fe("send",ol);/**
123
+ * @license lucide-react v1.7.0 - ISC
124
+ *
125
+ * This source code is licensed under the ISC license.
126
+ * See the LICENSE file in the root directory of this source tree.
127
+ */const il=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],xs=fe("share-2",il);/**
128
+ * @license lucide-react v1.7.0 - ISC
129
+ *
130
+ * This source code is licensed under the ISC license.
131
+ * See the LICENSE file in the root directory of this source tree.
132
+ */const ll=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],dl=fe("sliders-horizontal",ll);/**
133
+ * @license lucide-react v1.7.0 - ISC
134
+ *
135
+ * This source code is licensed under the ISC license.
136
+ * See the LICENSE file in the root directory of this source tree.
137
+ */const cl=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Rn=fe("square",cl);/**
138
+ * @license lucide-react v1.7.0 - ISC
139
+ *
140
+ * This source code is licensed under the ISC license.
141
+ * See the LICENSE file in the root directory of this source tree.
142
+ */const ul=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],$a=fe("trash-2",ul),ml=new Set(["assigned","running"]);function xl(t,s){return t.reduce((n,r)=>r.assignedTo===s&&ml.has(r.status)?n+1:n,0)}function It(t){return(t==null?void 0:t.toLowerCase())==="devtunnel"}function hl(t){return t?It(t)?"DevTunnel":t.charAt(0).toUpperCase()+t.slice(1):"Direct"}function an(t,s){return It(s??t.transportType)||!!t.devtunnelEndpoint}function Oa(t,s){return!It(s??t.transportType)}function za(t,s){const n=s??t.transportType;return It(n)?"DevTunnel":t.devtunnelEndpoint?"Direct + DevTunnel":hl(n)}function $n(t,s){return!t&&!s}function pl({routeTaskId:t,creatingTask:s,internalSelectedTaskId:n,sortedTaskIds:r}){return t||(s?null:r[0]??n??null)}function fl({activeTaskId:t,routeTaskId:s,creatingTask:n,tasksLoading:r,loadedTaskIds:o}){return!t||s||n||r?!1:!o.includes(t)}function gl(t,s){return[s,...t.filter(n=>n.id!==s.id)]}function Fa(t,s){const n=t.findIndex(r=>r.id===s.id);return n===-1?[...t,s]:t.map((r,o)=>o===n?s:r)}const bl=new Set(["completed","failed","cancelled","archived"]);function vl(t,s){const n=new Set(s);return new Set(Array.from(t).filter(r=>n.has(r)))}function jl(t,s){const n=new Set(s);if(n.size===0)return!1;const r=t.filter(o=>n.has(o.id));return r.length===n.size&&r.every(o=>bl.has(o.status))}function wl(t,s){var r;const n=new Set(s);return((r=t.find(o=>!n.has(o.id)))==null?void 0:r.id)??null}function Ha(){const[t,s]=a.useState([]),[n,r]=a.useState(null),o=a.useRef(null),i=a.useCallback(()=>{var N;(N=o.current)==null||N.click()},[]),h=a.useCallback(async N=>{const u=Array.from(N.target.files??[]);if(u.length!==0)try{const l=await Dn(u);s(k=>[...k,...l]),r(null)}catch(l){r(l instanceof Error?l.message:"Failed to attach image")}finally{N.target.value=""}},[]),m=a.useCallback(async N=>{const u=pi(N.clipboardData);if(u.length!==0){N.preventDefault();try{const l=await Dn(u);s(k=>[...k,...l]),r(null)}catch(l){r(l instanceof Error?l.message:"Failed to attach image")}}},[]),v=a.useCallback(N=>{s(u=>u.filter((l,k)=>k!==N))},[]),p=a.useCallback(()=>{s([]),r(null)},[]);return{images:t,error:n,fileInputRef:o,pickImages:i,handleFileChange:h,handlePaste:m,removeImage:v,clearImages:p}}function Nl(t){const s=t.map(o=>({...o,displayValue:yl(o)})),n=s.findIndex(o=>o.label.toLowerCase()==="working dir"),r=n>=0?n:0;return{primary:s[r],secondary:s.filter((o,i)=>i!==r)}}function yl(t){return t.label.toLowerCase()==="agent"?Aa(t.value):t.value}function On(t){switch(t.toLowerCase()){case"branch":return $s;case"node":return pa;case"working dir":default:return tn}}function kl({disabled:t=!1,running:s=!1,canStop:n=!1,hasContent:r=!1}){return s&&!r?{primaryAction:"stop",primaryDisabled:t||!n}:{primaryAction:"send",primaryDisabled:t||!r}}function Sl({contentLength:t,disabled:s=!1}){return t>0&&!s}function Cl({onSend:t,disabled:s,disabledReason:n="Chat is waiting on the agent.",placeholder:r="Send a follow-up message...",contextItems:o=[],running:i=!1,onStop:h}){const[m,v]=a.useState(""),[p,N]=a.useState(0),u=a.useRef(null),{images:l,error:k,fileInputRef:_,pickImages:y,handleFileChange:A,handlePaste:g,removeImage:b,clearImages:x}=Ha(),w=a.useCallback(()=>{u.current&&(u.current.style.height="auto")},[]),S=a.useCallback(()=>{const R=Ta(m,l);Sl({contentLength:R.length,disabled:s})&&(N($=>$+1),t(R),v(""),x(),w())},[m,l,s,t,x,w]),C=a.useCallback(R=>{R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),S())},[S]),L=a.useCallback(()=>{u.current&&(u.current.style.height="auto",u.current.style.height=`${Math.min(u.current.scrollHeight,220)}px`)},[]),Y=m.trim().length>0||l.length>0,V=kl({disabled:s,running:i,canStop:i&&!!h,hasContent:Y}),I=Nl(o),J=I.primary?On(I.primary.label):tn,W=i?Y?"Enter queues this message for the next turn":h?"Task is running - type to queue, empty button stops task":"Task is running - type to queue a message":s?n:"Enter sends, Shift+Enter adds a line";return e.jsx("div",{"data-chat-input-shell":"true",className:"chat-input-shell animate-composer-settle w-full bg-background/35 px-2 pb-2 pt-0 sm:px-4 sm:pb-3",children:e.jsx("div",{"data-chat-input-column":"true",className:"mx-auto w-full max-w-[72rem]",children:e.jsxs("div",{"data-chat-input-card":"true",className:"chat-input-card overflow-hidden rounded-xl border border-border/65 bg-card/88 transition-[border-color,box-shadow] duration-200 focus-within:border-primary/50 focus-within:ring-2 focus-within:ring-primary/15 sm:rounded-xl",children:[e.jsx("input",{ref:_,type:"file",accept:"image/*",multiple:!0,onChange:A,className:"hidden"}),I.primary&&e.jsx("div",{"data-chat-input-primary-context":"true",className:"px-2.5 pt-1.5 sm:px-5 sm:pt-2",children:e.jsxs("div",{className:"-ml-1.5 inline-flex max-w-full items-center gap-1.5 rounded-sm bg-muted/45 px-1.5 py-0.5 shadow-[0_10px_28px_-18px_rgba(15,23,42,0.72)] sm:-ml-2 dark:shadow-[0_10px_28px_-18px_rgba(0,0,0,0.95)]",children:[e.jsx(J,{className:"h-2.5 w-2.5 shrink-0 text-primary/45","aria-hidden":"true"}),e.jsx("span",{className:"truncate font-mono text-[9px] leading-3 text-muted-foreground/72",title:I.primary.value,children:I.primary.displayValue})]})}),l.length>0&&e.jsx("div",{className:"px-2 pt-2.5 sm:px-5 sm:pt-4",children:e.jsx("div",{className:"flex flex-wrap gap-3",children:l.map((R,$)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:Da(R),alt:R.filename??`attachment ${$+1}`,className:"h-24 w-24 rounded-xl border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>b($),className:"absolute -top-2 -right-2 flex h-7 w-7 items-center justify-center rounded-sm border border-border/70 bg-background text-muted-foreground shadow-sm transition-all hover:-translate-y-px hover:text-foreground","aria-label":`Remove ${R.filename??`image ${$+1}`}`,children:e.jsx(ot,{className:"h-3.5 w-3.5"})})]},`${R.filename??"image"}-${$}`))})}),e.jsx("div",{className:"px-2 pb-0 pt-1 sm:px-5 sm:pt-1.5",children:e.jsx("textarea",{ref:u,"data-chat-input-textarea":"true",value:m,onChange:R=>v(R.target.value),onKeyDown:C,onPaste:g,onInput:L,placeholder:r,disabled:s,rows:1,className:"min-h-[1.35rem] w-full resize-none overflow-x-hidden overflow-y-auto bg-transparent px-0 py-0 text-[11px] leading-[1.35rem] text-foreground placeholder:text-[10px] placeholder:text-muted-foreground/65 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"})}),e.jsxs("div",{className:"flex items-end justify-between gap-2 px-2 pb-1.5 pt-0.5 sm:px-5 sm:pb-2.5",children:[I.secondary.length>0?e.jsx("div",{"data-chat-input-secondary-context":"true",className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 pb-0.5 text-[9px] leading-3 text-muted-foreground/72 sm:text-[9px]",children:I.secondary.map(R=>{const $=On(R.label),ae=R.label.toLowerCase()==="agent";return e.jsxs("span",{title:`${R.label}: ${R.value}`,className:"inline-flex min-w-0 max-w-[12rem] items-center gap-1 truncate",children:[ae?e.jsx(Zs,{agent:R.value,className:"h-2.5 w-2.5 shrink-0 text-primary/50"}):e.jsx($,{"data-chat-input-secondary-icon":"true",className:"h-2.5 w-2.5 shrink-0 text-primary/50","aria-hidden":"true"}),e.jsx("span",{className:`truncate ${R.mono?"font-mono":""}`,children:R.displayValue})]},`${R.label}:${R.value}`)})}):e.jsx("div",{className:"min-w-0 flex-1"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(G,{type:"button",variant:"ghost",onClick:y,disabled:s,className:"h-7 shrink-0 gap-1.5 rounded-sm px-2 text-[10px] text-muted-foreground hover:text-foreground sm:px-2",title:"Attach images",children:[e.jsx(zs,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Images"})]}),e.jsx("span",{title:W,children:e.jsx(G,{onClick:V.primaryAction==="stop"?h:S,disabled:V.primaryDisabled,size:"icon","data-chat-send-button":"true","aria-label":V.primaryAction==="stop"?"Stop running task":i?"Queue message":"Send message",className:"chat-send-button h-7 w-9 shrink-0 rounded-sm bg-primary/90 text-primary-foreground shadow-[0_12px_30px_-18px_hsl(var(--primary)/0.95)] transition-transform duration-150 hover:bg-primary active:scale-95",children:V.primaryAction==="stop"?e.jsx(ue,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ra,{className:`h-3.5 w-3.5 ${p>0?"animate-chat-send-flight":""}`},p)})})]})]}),k&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-2 py-2 text-[11px] text-destructive sm:px-6 sm:py-3",children:k})]})})})}var El=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_l=El.reduce((t,s)=>{const n=Wr(`Primitive.${s}`),r=a.forwardRef((o,i)=>{const{asChild:h,...m}=o,v=h?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(v,{...m,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),Tl="Label",Ua=a.forwardRef((t,s)=>e.jsx(_l.label,{...t,ref:s,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=t.onMouseDown)==null||o.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Ua.displayName=Tl;var Va=Ua;const Dl=Gr("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Fe=a.forwardRef(({className:t,...s},n)=>e.jsx(Va,{ref:n,className:M(Dl(),t),...s}));Fe.displayName=Va.displayName;function Al(t,s,n){return t!=="auto"?s.find(r=>r.id===t)??null:n.length===1?n[0]??null:null}function Ml(t){return t.trim()||"."}function Pl(t){return new Promise(s=>window.setTimeout(s,t))}function Ll(t){return!!t&&typeof t=="object"&&typeof t.createdBranch=="string"&&typeof t.currentBranch<"u"}async function Il(t){let s=t;for(let n=0;n<60;n++){if(s.status==="succeeded"){if(Ll(s.result))return s.result;throw new Error("Branch creation completed without branch details")}if(s.status==="failed")throw new Error(s.error||"Branch creation failed");await Pl(1e3),s=await Xr(s.id)}throw new Error("Timed out waiting for branch creation")}function zn({value:t,onChange:s,project:n,assignTo:r,nodes:o,assignableNodes:i,layout:h="default",chipClassName:m,chipActiveClassName:v,chipInactiveClassName:p,labelClassName:N,triggerClassName:u}){const[l,k]=a.useState(!1),[_,y]=a.useState(null),[A,g]=a.useState(""),[b,x]=a.useState(!1),[w,S]=a.useState(!1),[C,L]=a.useState(!1),[Y,q]=a.useState(null),[V,I]=a.useState(""),[J,W]=a.useState(""),[R,$]=a.useState(""),[ae,ee]=a.useState(!1),oe=a.useRef(null),te=a.useRef(0),T=a.useMemo(()=>Al(r,o,i),[r,o,i]),O=T==null?void 0:T.id,d=a.useMemo(()=>Ml(n),[n]),U=a.useMemo(()=>O?`${O}
143
+ ${d}`:"",[O,d]),f=a.useCallback(async(X=0,se=!1)=>{const de=te.current+1,Ne=U;if(te.current=de,!O){y(null),g("");return}q(null),se||g(""),se?S(!0):x(!0);try{const H=await Yr(O,{path:d,limit:20,offset:X,allowAbsolute:!0});if(de!==te.current)return;g(Ne),y(ce=>se&&ce?{...H,branches:[...ce.branches,...H.branches]}:H)}catch(H){if(de!==te.current)return;q(H instanceof Error?H.message:"Failed to load branch info"),se||(y(null),g(""))}finally{de===te.current&&(x(!1),S(!1))}},[O,U,d]);a.useEffect(()=>{if(!O){te.current+=1,y(null),g(""),q(null);return}f()},[O,d,f]),a.useEffect(()=>{const X=t.trim(),se=A===U?_:null,de=se!=null&&se.available&&se.currentBranch?se.currentBranch:"";X!==de&&s(de)},[_,U,A,s,t]),a.useEffect(()=>{if(!l)return;const X=de=>{oe.current&&(oe.current.contains(de.target)||k(!1))},se=de=>{de.key==="Escape"&&k(!1)};return document.addEventListener("mousedown",X),document.addEventListener("keydown",se),()=>{document.removeEventListener("mousedown",X),document.removeEventListener("keydown",se)}},[l]),a.useEffect(()=>{l&&(W(""),$(""),ee(!1))},[l,O,d]);const Q=a.useCallback(async()=>{if(!O)return;const X=V.trim(),se=ae?R.trim():J.trim();if(!(!X||!se)){L(!0),q(null);try{const de=await Qr(O,{path:d,branchName:X,startPoint:se,limit:20,offset:0,allowAbsolute:!0}),Ne=await Il(de);g(U),y(Ne),s(Ne.currentBranch??Ne.createdBranch),I(""),W(""),$(""),ee(!1),k(!1)}catch(de){q(de instanceof Error?de.message:"Failed to create branch")}finally{L(!1)}}},[O,U,d,ae,R,V,s,J]),E=A===U?_:null,z=a.useCallback(()=>{E!=null&&E.hasMore&&f(E.branches.length,!0)},[E,f]),j=t.trim()||(E==null?void 0:E.currentBranch)||(E&&!E.available?"No git repo":"Branch"),D=ae?R.trim():J.trim(),F=!!(E!=null&&E.available&&V.trim()&&D&&!C),ne=h==="composer"?e.jsxs(G,{type:"button",variant:"ghost",onClick:()=>k(X=>!X),title:j,"aria-label":`Branch: ${j}`,className:M(m,u,"min-w-0 max-w-full",t.trim()?v:p),children:[b&&!E?e.jsx(ue,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx($s,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:M("min-w-0 truncate",N),children:j})]}):e.jsxs(G,{type:"button",variant:"outline",onClick:()=>k(X=>!X),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:j,children:[e.jsx("span",{className:M("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:j}),e.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:T?T.name:"Manual"})]});return e.jsxs("div",{className:M("relative inline-block",h==="composer"?"min-w-0 shrink-0":"w-full"),ref:oe,children:[h==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Fe,{className:"text-sm font-medium",children:"Branch"}),ne]}):ne,l&&e.jsxs("div",{className:M("absolute z-50 mt-2 w-[240px] overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",h==="composer"?"left-0":"left-0 right-0 w-auto min-w-[240px]"),children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsx($s,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-foreground",title:E!=null&&E.repoRoot?`${E.currentBranch??j} · ${E.repoRoot}`:(E==null?void 0:E.currentBranch)??j,children:(E==null?void 0:E.currentBranch)??j}),b?e.jsx(ue,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}):null]}),T?b&&!E?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(ue,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):E&&!E.available?e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Not a git repository."}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"space-y-2 px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(nt,{value:V,onChange:X=>I(X.target.value),placeholder:"New branch name",className:"h-8 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx(G,{type:"button",size:"sm",onClick:()=>void Q(),disabled:!F,title:F?"Create branch":"Enter a name and pick a base","aria-label":"Create branch",className:"h-8 w-8 shrink-0 rounded-md p-0",children:C?e.jsx(ue,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(al,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Base from"}),!ae&&e.jsxs("button",{type:"button",onClick:()=>ee(!0),className:"flex items-center gap-1 rounded px-1 py-0.5 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:[e.jsx(Lt,{className:"h-2.5 w-2.5"}),"Manual"]})]}),ae?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(nt,{value:R,onChange:X=>$(X.target.value),placeholder:"upstream/release/1.0",className:"h-8 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>{ee(!1),$("")},className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel manual input","aria-label":"Cancel manual input",children:e.jsx(ot,{className:"h-3.5 w-3.5"})})]}):E!=null&&E.branches.length?e.jsxs("div",{className:"max-h-44 overflow-y-auto rounded-md border border-border/40 bg-background/40",children:[E.branches.map(X=>{const se=J===X.ref,de=X.branch==="main"||X.branch==="master";return e.jsxs("button",{type:"button",onClick:()=>W(X.ref),className:M("flex w-full items-center gap-2 border-b border-border/20 px-2.5 py-1.5 text-left text-[11px] last:border-b-0 hover:bg-background/60",se&&"bg-background/70"),title:X.ref,children:[e.jsx("span",{className:M("shrink-0 text-[10px]",de?"text-amber-500 dark:text-amber-400":"text-muted-foreground/60"),"aria-hidden":!0,children:de?"★":"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:X.ref}),se?e.jsx(Ft,{className:"h-3 w-3 shrink-0 text-primary"}):null]},X.ref)}),E.hasMore&&e.jsxs("button",{type:"button",onClick:z,disabled:w,className:"flex w-full items-center justify-center gap-1 border-t border-border/20 py-1 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground disabled:opacity-50",children:[w?e.jsx(ue,{className:"h-3 w-3 animate-spin"}):e.jsx(Os,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"rounded-md border border-dashed border-border/40 px-2.5 py-2 text-[11px] text-muted-foreground",children:"No remote branches found."})]})]})}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a specific node first."}),Y&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-1.5 text-[11px] text-destructive",children:Y})]})]})}const Bl=20,Rl=3,Fs="meshy-working-dir-recents-by-node";function $l(t){return t.startsWith("/")||t.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(t)}function Ol(t){const s=t.trim();return s||"."}function Hs(t){const s=[],n=new Set;for(const r of t){const o=r.trim();if(!(!o||n.has(o))&&(n.add(o),s.push(o),s.length===Rl))break}return s}function zl(t,s){const n=s.trim();return Hs(n?[n,...t]:t)}function qa(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const s={};for(const[n,r]of Object.entries(t)){if(!n||!Array.isArray(r))continue;const o=r.filter(h=>typeof h=="string"),i=Hs(o);i.length>0&&(s[n]=i)}return s}function Fl(t,s,n){if(!s)return t;const r=t[s]??[],o=zl(r,n);if(o.length===0){if(!(s in t))return t;const{[s]:i,...h}=t;return h}return{...t,[s]:o}}function Hl(t,s){var n;return s?((n=t[s])==null?void 0:n[0])??"":""}function Ka(t){if(!t||typeof window>"u")return"";try{const s=window.localStorage.getItem(Fs);return s?Hl(qa(JSON.parse(s)),t):""}catch{return""}}function Ul(t,s,n){return t!=="auto"?s.find(r=>r.id===t)??null:n.length===1?n[0]??null:null}function Vl(t,s){const n=s.trim();return n?$l(n)||!t?n:`${t.replace(/[/\\]+$/,"")}/${n}`:""}function ql(t,s){return t?t.isAbsolute?t.currentPath:t.currentPath==="."||t.currentPath===""?t.rootPath||(s==null?void 0:s.workDir)||"Node root":t.currentPath:(s==null?void 0:s.workDir)??"Node root"}function hs({value:t,onChange:s,assignTo:n,nodes:r,assignableNodes:o,layout:i="default",chipClassName:h,chipActiveClassName:m,chipInactiveClassName:v,labelClassName:p,triggerClassName:N,popoverPlacement:u="bottom",popoverAlign:l="start"}){const[k,_]=a.useState(!1),[y,A]=a.useState(null),[g,b]=a.useState(!1),[x,w]=a.useState(!1),[S,C]=a.useState(null),[L,Y]=a.useState(""),[q,V]=a.useState(!1),[I,J]=a.useState({}),W=a.useRef(null),R=a.useMemo(()=>Ul(n,r,o),[n,r,o]),$=R==null?void 0:R.id,ae=a.useMemo(()=>$?I[$]??[]:[],[I,$]),ee=a.useMemo(()=>t.trim()?Vl(R==null?void 0:R.workDir,t):"Use node default",[t,R==null?void 0:R.workDir]);a.useEffect(()=>{if(!(typeof window>"u"))try{const j=window.localStorage.getItem(Fs);if(!j)return;const D=JSON.parse(j);J(qa(D))}catch{}},[]);const oe=a.useCallback(j=>{$&&J(D=>{const F=Fl(D,$,j);if(F===D)return D;if(typeof window<"u")try{window.localStorage.setItem(Fs,JSON.stringify(F))}catch{}return F})},[$]),te=a.useCallback((j,D=!0)=>{const F=j.trim();s(F),D&&F&&oe(F),_(!1)},[s,oe]),T=a.useCallback(async(j,D=0,F=!1)=>{if($){C(null),F?w(!0):b(!0);try{const ne=await fa($,{path:j,limit:Bl,offset:D,directoriesOnly:!0,allowAbsolute:!0});A(X=>F&&X?{...ne,entries:[...X.entries,...ne.entries]}:ne)}catch(ne){C(ne instanceof Error?ne.message:"Failed to browse directories"),F||A(null)}finally{b(!1),w(!1)}}},[$]),O=a.useRef(t);O.current=t;const d=a.useRef(T);d.current=T,a.useEffect(()=>{if(!k)return;const j=O.current;Y(j),V(!1),A(null),C(null),$&&d.current(Ol(j))},[k,$]),a.useEffect(()=>{if(!k)return;const j=F=>{W.current&&(W.current.contains(F.target)||_(!1))},D=F=>{F.key==="Escape"&&_(!1)};return document.addEventListener("mousedown",j),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("keydown",D)}},[k]);const U=a.useCallback(j=>{T(j)},[T]),f=a.useCallback(()=>{y&&T(y.currentPath,y.entries.length,!0)},[y,T]),Q=i==="composer"?e.jsxs(G,{type:"button",variant:"ghost",onClick:()=>_(j=>!j),title:ee,"aria-label":`Working directory: ${ee}`,className:M(h,N,"min-w-0 max-w-full",t.trim()?m:v),children:[e.jsx(Jr,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:M("min-w-0 truncate",p),children:ee})]}):e.jsxs(G,{type:"button",variant:"outline",onClick:()=>_(j=>!j),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:ee,children:[e.jsx("span",{className:M("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:ee}),e.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:R?R.name:"Manual"})]}),E=ql(y,R),z=!!(y!=null&&y.parentPath);return e.jsxs("div",{className:M("relative inline-block",i==="composer"?"min-w-0 max-w-[60%] shrink":"w-full"),"data-workdir-popover-placement":u,"data-workdir-popover-align":l,ref:W,children:[i==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Fe,{className:"text-sm font-medium",children:"Working directory"}),Q]}):Q,k&&e.jsxs("div",{className:M("absolute z-50 flex max-h-[min(28rem,calc(100vh-5rem))] w-[240px] flex-col overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",u==="top"?"bottom-full mb-2":"top-full mt-2",i==="composer"?l==="end"?"right-0":"left-0":l==="end"?"right-0 w-auto min-w-[240px]":"left-0 right-0 w-auto min-w-[240px]"),children:[ae.length>0&&e.jsxs("div",{className:"border-b border-border/60 px-3 py-2",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1 text-[10px] text-muted-foreground",children:[e.jsx(Os,{className:"h-2.5 w-2.5"}),"Recent"]}),e.jsx("div",{className:"flex flex-col",children:ae.map(j=>e.jsx("button",{type:"button",onClick:()=>te(j),className:"truncate rounded px-1.5 py-0.5 text-left font-mono text-[11px] text-foreground hover:bg-background/60",title:j,children:j},j))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/60 px-2.5 py-1.5",children:[e.jsx("button",{type:"button",onClick:()=>(y==null?void 0:y.parentPath)&&U(y.parentPath),disabled:!z||g,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-border/60 text-muted-foreground transition-colors hover:bg-background/60 hover:text-foreground disabled:opacity-40",title:"Parent directory",children:e.jsx(La,{className:"h-3 w-3"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:E,children:E}),y&&e.jsx("button",{type:"button",onClick:()=>te(y.isAbsolute?y.currentPath:y.currentPath==="."?"":y.currentPath),className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium text-foreground hover:bg-background/60",title:"Use this folder",children:"Use"})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:[R?g?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(ue,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):y&&y.entries.length>0?e.jsxs(e.Fragment,{children:[y.entries.map(j=>e.jsxs("div",{className:"group flex items-stretch border-b border-border/30 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>te(j.path),className:"flex min-w-0 flex-1 items-center gap-2 px-2.5 py-1.5 text-left hover:bg-background/55",title:`Use ${j.path}`,children:[e.jsx(ss,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[11px] text-foreground",children:j.name})]}),e.jsx("button",{type:"button",onClick:()=>U(j.path),className:"flex w-9 shrink-0 items-center justify-center border-l border-border/30 text-muted-foreground hover:bg-background/70 hover:text-foreground",title:"Open subfolder","aria-label":`Open ${j.name}`,children:e.jsx(xt,{className:"h-3.5 w-3.5"})})]},j.path)),y.hasMore&&e.jsxs("button",{type:"button",onClick:f,disabled:x,className:"flex w-full items-center justify-center gap-1 border-t border-border/40 py-1 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground disabled:opacity-50",children:[x?e.jsx(ue,{className:"h-3 w-3 animate-spin"}):e.jsx(Os,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:S??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a node to browse."}),S&&y&&y.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[11px] text-destructive",children:S})]}),e.jsx("div",{className:"flex items-center gap-1 border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:q?e.jsxs(e.Fragment,{children:[e.jsx(nt,{value:L,onChange:j=>Y(j.target.value),onKeyDown:j=>{j.key==="Enter"&&L.trim()?(j.preventDefault(),te(L)):j.key==="Escape"&&(j.preventDefault(),V(!1),Y(t))},autoFocus:!0,placeholder:"Path (relative or absolute)",className:"h-7 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>te(L),disabled:!L.trim(),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-foreground hover:bg-background/60 disabled:opacity-40",title:"Apply","aria-label":"Apply manual path",children:e.jsx(Ft,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{V(!1),Y(t)},className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel","aria-label":"Cancel manual path",children:e.jsx(ot,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>{Y(t),V(!0)},className:"flex h-7 flex-1 items-center justify-between rounded-md px-1.5 text-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Enter a manual path",children:[e.jsx("span",{children:"Manual input"}),e.jsx(Lt,{className:"h-3 w-3"})]})})]})]})}function Wa(t,s={}){const n=t.filter(r=>r.status==="online");return s.currentNodeRole!=="follower"||!s.leaderNodeId?n:n.filter(r=>r.id!==s.leaderNodeId)}function rn({isCurrent:t}){return t?e.jsx(Ki,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):e.jsx(Hi,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function Us(t,s){return t.map(n=>{const r=!!s&&n.id===s;return e.jsx(xe,{value:n.id,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(rn,{isCurrent:r}),e.jsx("span",{className:"truncate",children:n.name}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:r?"current":"remote"})]})},n.id)})}function Kl(t){var r;const s=t.sessionId.trim(),n=t.cwd.trim();return!s||!n||!t.assignTo?null:{title:t.title.trim()||((r=t.defaultTitle)==null?void 0:r.trim())||void 0,agent:t.agent,sessionId:s,cwd:n,assignTo:t.assignTo,priority:t.priority,mode:t.mode??Ht}}function Wl(){return to.map(t=>e.jsx(xe,{value:t.value,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:t.label}),t.description&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:t.description})]})},t.value))}function Gl(t){if(!t)return"unknown time";const s=Date.parse(t);return Number.isNaN(s)?t:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(s)}function Fn(t){if(!t.updatedAt)return 0;const s=Date.parse(t.updatedAt);return Number.isNaN(s)?0:s}function Yl(t,s){return Fn(s)-Fn(t)||t.sessionId.localeCompare(s.sessionId)}function Ql(t){const s=t.trim().replace(/[\\/]+$/,"");return s?s.split(/[\\/]+/).filter(Boolean).at(-1)??s:"Unknown project"}function Xl(t){const s=new Map;for(const n of[...t].sort(Yl)){const r=s.get(n.cwd);if(r){r.push(n);continue}s.set(n.cwd,[n])}return Array.from(s.entries()).map(([n,r])=>({folderName:Ql(n),cwd:n,sessions:r}))}function Jl(t,s){const n=new Set(t);return n.has(s)?n.delete(s):n.add(s),n}function Zl({nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,onCreated:o,onCancel:i,className:h,footerClassName:m,submitLabel:v="Load session",cancelLabel:p="Cancel",autoFocus:N=!1}){const u=a.useMemo(()=>Wa(t,{currentNodeRole:s,leaderNodeId:r}),[t,s,r]),l=a.useMemo(()=>{var H;return n&&u.some(ce=>ce.id===n)?n:((H=u[0])==null?void 0:H.id)??""},[u,n]),[k,_]=a.useState(""),[y,A]=a.useState("codex"),[g,b]=a.useState(""),[x,w]=a.useState(""),[S,C]=a.useState(""),[L,Y]=a.useState(l),[q,V]=a.useState("normal"),[I,J]=a.useState(Ht),[W,R]=a.useState(!1),[$,ae]=a.useState([]),[ee,oe]=a.useState(!1),[te,T]=a.useState(null),O=a.useMemo(()=>$.find(H=>H.sessionId===g)??null,[$,g]);a.useEffect(()=>{L&&u.some(H=>H.id===L)||Y(l)},[L,u,l]),a.useEffect(()=>{b(""),w(""),C("")},[y,L]),a.useEffect(()=>{let H=!1;return L?(oe(!0),T(null),Zr(L,{agent:y,limit:50}).then(ce=>{H||ae(ce.sessions)}).catch(ce=>{H||(ae([]),T(ce instanceof Error?ce.message:"Failed to load native sessions"))}).finally(()=>{H||oe(!1)}),()=>{H=!0}):(ae([]),T(null),oe(!1),()=>{H=!0})},[y,L]),a.useEffect(()=>{O&&(w(O.sessionId),C(O.cwd))},[O]);const d=a.useCallback(async H=>{H.preventDefault();const ce=Kl({title:k,defaultTitle:O==null?void 0:O.summary,agent:y,sessionId:x,cwd:S,assignTo:L,priority:q,mode:I});if(ce){R(!0);try{const _e=await eo(ce);o(_e)}catch(_e){le.error(_e instanceof Error?_e.message:"Failed to load native session")}finally{R(!1)}}},[k,O,y,x,S,L,q,I,o]),U=!!(x.trim()&&S.trim()&&L),[f,Q]=a.useState(!1),[E,z]=a.useState(""),[j,D]=a.useState(()=>new Set),F=u.find(H=>H.id===L)??null,ne=!!(n&&(F==null?void 0:F.id)===n),X=a.useMemo(()=>{const H=E.trim().toLowerCase();return H?$.filter(ce=>ce.summary.toLowerCase().includes(H)||ce.sessionId.toLowerCase().includes(H)||ce.cwd.toLowerCase().includes(H)):$},[$,E]),se=a.useMemo(()=>Xl(X),[X]),de=a.useCallback(H=>{D(ce=>Jl(ce,H))},[]),Ne="h-9 w-auto gap-1.5 rounded-sm border-border/60 bg-background/60 px-3 text-xs shadow-none transition-colors hover:bg-background/80";return e.jsxs("form",{onSubmit:d,className:M("space-y-4",h),children:[e.jsxs("div",{className:"rounded-xl border border-border/60 bg-background/54 shadow-[0_24px_86px_-48px_rgba(15,23,42,0.55)] backdrop-blur-xl dark:shadow-[0_24px_86px_-48px_rgba(0,0,0,0.9)]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/50 px-4 py-3",children:[e.jsxs(Se,{value:L,onValueChange:Y,children:[e.jsx(Ce,{className:M(Ne),"aria-label":"Node",children:F?e.jsxs(e.Fragment,{children:[e.jsx(rn,{isCurrent:ne}),e.jsx("span",{className:"max-w-[10rem] truncate",children:F.name})]}):e.jsx(Ie,{placeholder:"Node"})}),e.jsx(Ee,{children:Us(u,n)})]}),e.jsxs(Se,{value:y,onValueChange:H=>A(H),children:[e.jsxs(Ce,{className:M(Ne),"aria-label":"Agent",children:[e.jsx(Zs,{agent:y}),e.jsx("span",{children:y})]}),e.jsx(Ee,{children:fi()})]}),e.jsxs("div",{className:"relative ml-auto min-w-0 flex-1 sm:max-w-56",children:[e.jsx(ns,{className:"pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(nt,{value:E,onChange:H=>z(H.target.value),placeholder:"Filter sessions",className:"h-9 rounded-sm border-border/60 bg-background/60 pl-9 text-xs shadow-none"})]})]}),e.jsxs("div",{className:"px-3 py-3",children:[e.jsx("div",{className:"flex items-center justify-between px-1 pb-2",children:e.jsx(Fe,{className:"text-[10px] font-medium uppercase tracking-[0.2em] text-muted-foreground",children:ee?"Loading...":`${X.length} session${X.length===1?"":"s"}`})}),e.jsxs("div",{className:"relative h-88 overflow-hidden rounded-lg",children:[ee&&e.jsx("div",{className:"absolute inset-x-0 top-0 z-10 h-0.5 overflow-hidden bg-primary/10",children:e.jsx("div",{className:"h-full w-1/3 animate-indeterminate-bar bg-primary/70"})}),e.jsxs("div",{className:"h-full space-y-1.5 overflow-y-auto pr-1",children:[!L&&e.jsx("div",{className:"rounded-lg border border-dashed border-border/60 bg-background/35 px-4 py-6 text-center text-xs text-muted-foreground",children:"Pick a node to load its recent sessions."}),L&&!ee&&X.length===0&&e.jsx("div",{className:"rounded-lg border border-dashed border-border/60 bg-background/35 px-4 py-6 text-center text-xs text-muted-foreground",children:$.length===0?"No recent sessions on this node. Use Manual session ID under More options.":"No sessions match your filter."}),se.map(H=>e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>de(H.cwd),"aria-expanded":!j.has(H.cwd),className:"sticky top-0 z-[1] flex w-full items-center gap-2 border-b border-border/50 bg-background/95 px-1 py-1.5 text-left text-[10px] text-muted-foreground backdrop-blur transition-colors hover:bg-background",children:[e.jsx(Qe,{className:M("h-3.5 w-3.5 shrink-0 transition-transform",j.has(H.cwd)&&"-rotate-90")}),e.jsx(tn,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-foreground",children:H.folderName}),e.jsxs("span",{className:"shrink-0 uppercase tracking-[0.16em]",children:[H.sessions.length," session",H.sessions.length===1?"":"s"]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-right font-mono",children:H.cwd})]}),!j.has(H.cwd)&&H.sessions.map(ce=>{const _e=ce.sessionId===g;return e.jsxs("button",{type:"button",onClick:()=>b(ce.sessionId),className:M("flex w-full flex-col gap-1 rounded-lg border px-3 py-2.5 text-left transition-all duration-200 hover:-translate-y-px",_e?"border-primary/45 bg-primary/9 shadow-[0_18px_60px_-44px_hsl(var(--primary)/0.95)]":"border-border/55 bg-background/40 hover:border-border hover:bg-background/65"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:M("h-2 w-2 shrink-0 rounded-full",_e?"bg-primary":"bg-border")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",children:ce.summary}),e.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:Gl(ce.updatedAt)})]}),e.jsxs("div",{className:"flex items-center gap-2 pl-4 text-[10px] text-muted-foreground",children:[e.jsx("span",{className:"font-mono",children:ce.sessionId.slice(0,12)}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),e.jsx("span",{className:"truncate font-mono",children:ce.cwd})]})]},ce.sessionId)})]},H.cwd))]})]}),te&&e.jsx("p",{className:"px-1 pt-2 text-[11px] text-destructive",children:te})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",onClick:()=>Q(H=>!H),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-[0.2em] text-muted-foreground transition-colors hover:text-foreground","aria-expanded":f,children:[e.jsx("span",{className:"h-px flex-1 bg-border/60","aria-hidden":!0}),e.jsx("span",{className:"shrink-0",children:f?"Less options":"More options"}),e.jsx(Qe,{className:M("h-3.5 w-3.5 shrink-0 transition-transform",f&&"rotate-180")}),e.jsx("span",{className:"h-px flex-1 bg-border/60","aria-hidden":!0})]}),f&&e.jsxs("div",{className:"space-y-4 rounded-xl border border-border/60 bg-background/35 p-4",children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Fe,{htmlFor:"native-session-id",className:"text-xs font-medium text-muted-foreground",children:"Session ID"}),e.jsx(nt,{id:"native-session-id",type:"text",value:x,onChange:H=>{b(""),w(H.target.value)},placeholder:"ses_..., thread_..., or UUID",autoFocus:N,className:"h-10 rounded-sm border-border/70 bg-background/70 font-mono text-xs"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Fe,{htmlFor:"native-session-title",className:"text-xs font-medium text-muted-foreground",children:"Task title"}),e.jsx(nt,{id:"native-session-title",type:"text",value:k,onChange:H=>_(H.target.value),placeholder:"Optional",className:"h-10 rounded-sm border-border/70 bg-background/70 text-sm"})]})]}),e.jsx(hs,{value:S,onChange:H=>{b(""),C(H)},assignTo:L,nodes:t,assignableNodes:u}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Fe,{className:"text-xs font-medium text-muted-foreground",children:"Mode"}),e.jsxs(Se,{value:I,onValueChange:H=>J(H),children:[e.jsx(Ce,{className:"h-10 rounded-sm border-border/70 bg-background/70 text-sm",children:e.jsx(Ie,{placeholder:"Select mode"})}),e.jsx(Ee,{children:Wl()})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Fe,{className:"text-xs font-medium text-muted-foreground",children:"Priority"}),e.jsxs(Se,{value:q,onValueChange:V,children:[e.jsx(Ce,{className:"h-10 rounded-sm border-border/70 bg-background/70 text-sm",children:e.jsx(Ie,{placeholder:"Select priority"})}),e.jsxs(Ee,{children:[e.jsx(xe,{value:"low",children:"Low"}),e.jsx(xe,{value:"normal",children:"Normal"}),e.jsx(xe,{value:"high",children:"High"}),e.jsx(xe,{value:"critical",children:"Critical"})]})]})]})]})]})]}),e.jsxs("div",{className:M("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",m),children:[i&&e.jsx(G,{type:"button",variant:"ghost",onClick:i,className:"rounded-sm",children:p}),e.jsx(G,{type:"submit",disabled:!U||W,className:"rounded-sm px-5",children:W?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"h-4 w-4 animate-spin"})," Loading..."]}):v})]})]})}function Ga(t,s,n=!1){const r=t.trim();if(r)return r;const o=s.trim().split(`
144
+ `).map(i=>i.trim()).find(Boolean);return o?o.length>72?`${o.slice(0,69).trimEnd()}...`:o:n?"Image task":""}function ed(t){var h;const s=t.title.trim(),n=Ga(t.title,t.description,t.images.length>0),r=t.description.trim()||n,o=t.mode??Ht,i=Ta(t.description,t.images);return!n||!r||!t.agent?null:{title:n,description:r,agent:t.agent,project:t.project.trim()||null,branch:((h=t.branch)==null?void 0:h.trim())||null,payload:{initialMessage:i,mode:o,titleSource:s?"manual":"derived"},priority:t.priority,assignTo:t.assignTo==="auto"?void 0:t.assignTo}}function td({nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,initialAssignTo:o,initialProject:i,onCreated:h,onCancel:m,className:v,footerClassName:p,submitLabel:N="Create chat",cancelLabel:u="Cancel",autoFocus:l=!1,layout:k="default"}){const[_,y]=a.useState(""),[A,g]=a.useState(""),[b,x]=a.useState(yn),[w,S]=a.useState(Ht),[C,L]=a.useState((i==null?void 0:i.trim())??""),Y=a.useRef(i!==void 0),[q,V]=a.useState(""),[I,J]=a.useState("normal"),W=a.useMemo(()=>Wa(t,{currentNodeRole:s,leaderNodeId:r}),[t,s,r]),R=a.useMemo(()=>{var re;return o&&W.some(ge=>ge.id===o)?o:n&&W.some(ge=>ge.id===n)?n:((re=W[0])==null?void 0:re.id)??""},[W,n,o]),[$,ae]=a.useState(R),[ee,oe]=a.useState(!1),[te,T]=a.useState(!1),{images:O,error:d,fileInputRef:U,pickImages:f,handleFileChange:Q,handlePaste:E,removeImage:z}=Ha(),j=a.useMemo(()=>W.find(re=>re.id===$)??null,[$,W]),D=!!(n&&(j==null?void 0:j.id)===n),F=Aa(b),ne=gi(w);a.useEffect(()=>{$&&W.some(re=>re.id===$)||ae(R)},[$,W,R]),a.useEffect(()=>{if(Y.current){Y.current=!1;return}L(Ka($)),V("")},[$]),a.useEffect(()=>{V("")},[C]);const X=a.useCallback(async re=>{re.preventDefault();const ge=ed({title:_,description:A,agent:b,project:C,branch:q,priority:I,assignTo:$,mode:w,images:O});if(ge){oe(!0);try{const Pe=await no(ge);h(Pe)}catch(Pe){le.error(Pe instanceof Error?Pe.message:"Failed to create task")}finally{oe(!1)}}},[_,A,b,C,q,I,$,w,O,h]),se=Ga(_,A,O.length>0),de=!!(se&&b&&$&&(A.trim()||O.length>0)),Ne=a.useCallback(re=>{var ge;re.nativeEvent.isComposing||re.key==="Enter"&&(re.ctrlKey||re.metaKey)&&de&&!ee&&(re.preventDefault(),(ge=re.currentTarget.form)==null||ge.requestSubmit())},[de,ee]),H=O.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3",children:O.map((re,ge)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:Da(re),alt:re.filename??`attachment ${ge+1}`,className:"h-24 w-24 rounded-2xl border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>z(ge),className:"absolute -top-2 -right-2 flex h-6 w-6 items-center justify-center rounded-sm border border-border/70 bg-background text-muted-foreground shadow-sm transition-all hover:-translate-y-px hover:text-foreground","aria-label":`Remove ${re.filename??`image ${ge+1}`}`,children:e.jsx(ot,{className:"h-3.5 w-3.5"})})]},`${re.filename??"image"}-${ge}`))}),ce=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Fe,{className:"text-sm font-medium",children:"Assign to"}),e.jsxs(Se,{value:$,onValueChange:ae,children:[e.jsx(Ce,{className:"h-11 rounded-lg border-border/70 bg-background/70",children:e.jsx(Ie,{placeholder:"Select node"})}),e.jsx(Ee,{children:Us(W,n)})]})]}),_e=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Fe,{className:"text-sm font-medium",children:"Agent"}),e.jsxs(Se,{value:b,onValueChange:x,children:[e.jsx(Ce,{className:"h-11 rounded-lg border-border/70 bg-background/70",children:e.jsx(Ie,{placeholder:"Select agent"})}),e.jsx(Ee,{children:An()})]})]}),ye=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Fe,{className:"text-sm font-medium",children:"Mode"}),e.jsxs(Se,{value:w,onValueChange:re=>S(re),children:[e.jsx(Ce,{className:"h-11 rounded-lg border-border/70 bg-background/70",children:e.jsx(Ie,{placeholder:"Select mode"})}),e.jsx(Ee,{children:Mn()})]})]}),Be=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Fe,{className:"text-sm font-medium",children:"Priority"}),e.jsxs(Se,{value:I,onValueChange:J,children:[e.jsx(Ce,{className:"h-11 rounded-lg border-border/70 bg-background/70",children:e.jsx(Ie,{placeholder:"Select priority"})}),e.jsxs(Ee,{children:[e.jsx(xe,{value:"low",children:"Low"}),e.jsx(xe,{value:"normal",children:"Normal"}),e.jsx(xe,{value:"high",children:"High"}),e.jsx(xe,{value:"critical",children:"Critical"})]})]})]}),Ge=e.jsx(hs,{value:C,onChange:L,assignTo:$,nodes:t,assignableNodes:W}),De=e.jsx(zn,{value:q,onChange:V,project:C,assignTo:$,nodes:t,assignableNodes:W});return k==="composer"?e.jsxs("form",{onSubmit:X,className:M("space-y-4",v),children:[e.jsx("input",{ref:U,type:"file",accept:"image/*",multiple:!0,onChange:Q,className:"hidden"}),(()=>{const re="chat-composer__chip h-9 w-auto gap-1.5 rounded-sm px-3.5 text-xs shadow-none transition-colors",ge="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",Pe="border-border/70 bg-background/55 text-foreground",$e=b===yn,ht=w===Ht;return e.jsxs("div",{className:"chat-composer space-y-2",children:[e.jsxs("div",{className:"rounded-xl border border-border/60 bg-background/54 shadow-[0_24px_86px_-48px_rgba(15,23,42,0.55)] backdrop-blur-xl dark:shadow-[0_24px_86px_-48px_rgba(0,0,0,0.9)]",children:[e.jsxs("div",{className:"chat-composer__header flex min-w-0 items-center justify-between gap-3 px-4 pt-3",children:[e.jsxs(Se,{value:$,onValueChange:ae,children:[e.jsx(Ce,{className:M(re,Pe,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${(j==null?void 0:j.name)??"unassigned"}`,"aria-label":`Assigned node: ${(j==null?void 0:j.name)??"unassigned"}`,children:j?e.jsxs(e.Fragment,{children:[e.jsx(rn,{isCurrent:D}),e.jsx("span",{className:"min-w-0 truncate",children:j.name}),e.jsx("span",{className:"chat-composer__header-meta shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:D?"current":"remote"})]}):e.jsx(Ie,{placeholder:"Select node"})}),e.jsx(Ee,{children:Us(W,n)})]}),te?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(nt,{id:"task-title-composer",type:"text",value:_,onChange:je=>y(je.target.value),onKeyDown:je=>{(je.key==="Enter"||je.key==="Escape")&&(je.preventDefault(),T(!1))},autoFocus:!0,placeholder:"Chat title",className:"h-8 w-48 min-w-0 rounded-sm border-border/70 bg-background/55 px-3 text-xs shadow-none"}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>T(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(Ft,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>T(!0),className:"chat-composer__title-button flex min-w-0 items-center gap-1.5 rounded-sm px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-background/55 hover:text-foreground",title:se||"Title","aria-label":se?`Edit title: ${se}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:se||"Title"}),e.jsx(Lt,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",value:A,onChange:je=>g(je.target.value),onKeyDown:Ne,onPaste:E,placeholder:"Ask anything...",rows:4,autoFocus:l,"aria-label":"Opening prompt",className:"min-h-[140px] w-full resize-none overflow-x-hidden overflow-y-auto rounded-xl bg-transparent px-5 pt-2 pb-2 text-xs leading-5 text-foreground ring-offset-background placeholder:text-muted-foreground/70 focus-visible:outline-none"}),e.jsxs("div",{className:"chat-composer__rail flex flex-nowrap items-center gap-2 px-3 pb-3",children:[e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:f,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(zs,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsxs(Se,{value:b,onValueChange:x,children:[e.jsxs(Ce,{className:M(re,"chat-composer__icon-trigger",$e?ge:Pe),title:`Agent: ${F}`,"aria-label":`Agent: ${F}`,children:[e.jsx(Zs,{agent:b}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:F})]}),e.jsx(Ee,{children:An()})]}),e.jsxs(Se,{value:w,onValueChange:je=>S(je),children:[e.jsxs(Ce,{className:M(re,"chat-composer__icon-trigger",ht?ge:Pe),title:`Mode: ${ne}`,"aria-label":`Mode: ${ne}`,children:[e.jsx(dl,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:ne})]}),e.jsx(Ee,{children:Mn()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[e.jsxs(Se,{value:I,onValueChange:J,children:[e.jsx(Ce,{"aria-label":`Priority: ${I}`,title:`Priority: ${I}`,className:M("h-9 w-9 justify-center gap-0 rounded-sm p-0 text-xs shadow-none [&>svg:last-child]:hidden",I==="normal"?"border-transparent bg-transparent text-muted-foreground hover:bg-background/40":"border-border/70 bg-background/55",I==="critical"&&"text-destructive",I==="high"&&"text-amber-600 dark:text-amber-400",I==="low"&&"text-muted-foreground"),children:e.jsx(Bi,{className:M("h-4 w-4",I==="critical"&&"fill-destructive/20")})}),e.jsxs(Ee,{children:[e.jsx(xe,{value:"low",children:"Low"}),e.jsx(xe,{value:"normal",children:"Normal"}),e.jsx(xe,{value:"high",children:"High"}),e.jsx(xe,{value:"critical",children:"Critical"})]})]}),m&&e.jsxs(G,{type:"button",variant:"ghost",size:"sm",onClick:m,"aria-label":u,className:"chat-composer__cancel h-9 rounded-sm px-4 text-xs text-muted-foreground",children:[e.jsx(ot,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:u})]}),e.jsxs(G,{type:"submit",size:"icon",disabled:!de||ee,className:"h-10 w-10 rounded-sm shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[ee?e.jsx(ue,{className:"h-4 w-4 animate-spin"}):e.jsx(Ra,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:ee?"Creating chat":N})]})]})]})]}),e.jsx("div",{className:"chat-composer__location flex flex-wrap items-center gap-2 px-1",children:(()=>{const je="border-border/40 bg-muted/40 text-foreground/80 hover:bg-muted/60 hover:text-foreground";return e.jsxs(e.Fragment,{children:[e.jsx(hs,{value:C,onChange:L,assignTo:$,nodes:t,assignableNodes:W,layout:"composer",chipClassName:re,chipActiveClassName:je,chipInactiveClassName:je,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"}),e.jsx(zn,{value:q,onChange:V,project:C,assignTo:$,nodes:t,assignableNodes:W,layout:"composer",chipClassName:re,chipActiveClassName:je,chipInactiveClassName:je,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"})]})})()})]})})(),(H||d)&&e.jsxs("div",{className:"space-y-3 rounded-lg border border-border/60 bg-background/45 p-4",children:[H,d&&e.jsx("div",{className:"text-xs text-destructive",children:d}),!d&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Paste screenshots directly into the prompt box or use the Images button."})]})]}):e.jsxs("form",{onSubmit:X,className:M("space-y-5",v),children:[e.jsx("input",{ref:U,type:"file",accept:"image/*",multiple:!0,onChange:Q,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Fe,{htmlFor:"task-description",className:"text-sm font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",value:A,onChange:re=>g(re.target.value),onKeyDown:Ne,onPaste:E,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:l,className:"flex min-h-[144px] w-full resize-none overflow-x-hidden overflow-y-auto rounded-xl border border-border/70 bg-background/70 px-4 py-3 text-sm leading-6 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(G,{type:"button",variant:"outline",onClick:f,className:"rounded-sm",children:[e.jsx(zs,{className:"h-4 w-4"}),"Add images"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Upload or paste screenshots and reference images with the opening prompt."})]}),H,d&&e.jsx("p",{className:"text-xs text-destructive",children:d})]}),e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1fr)_220px_220px]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Fe,{htmlFor:"task-title",className:"text-sm font-medium",children:"Chat title"}),e.jsx(nt,{id:"task-title",type:"text",value:_,onChange:re=>y(re.target.value),placeholder:"Optional. Leave blank to derive it from the prompt.",className:"h-11 rounded-lg border-border/70 bg-background/70"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:se?`Will appear as: ${se}`:"A title will be generated from the first line of the prompt."})]}),_e,ye]}),Ge,De,e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[Be,ce]}),e.jsxs("div",{className:M("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",p),children:[m&&e.jsx(G,{type:"button",variant:"ghost",onClick:m,className:"rounded-sm",children:u}),e.jsx(G,{type:"submit",disabled:!de||ee,className:"rounded-sm px-5",children:ee?"Creating...":N})]})]})}function sd({nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,initialAssignTo:o,initialProject:i,onCreated:h,onCancel:m,defaultMode:v="chat",mode:p,onModeChange:N,layout:u="default",className:l,footerClassName:k,autoFocus:_=!1}){const[y,A]=a.useState(v),g=p!==void 0,b=g?p:y,x=w=>{g||A(w),N==null||N(w)};return e.jsxs("div",{className:M("space-y-4",l),children:[!g&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border/60 bg-background/45 p-1",children:[e.jsxs(G,{type:"button",variant:b==="chat"?"default":"ghost",onClick:()=>x("chat"),className:"flex-1 rounded-sm",children:[e.jsx(so,{className:"h-4 w-4"}),"New chat"]}),e.jsxs(G,{type:"button",variant:b==="native"?"default":"ghost",onClick:()=>x("native"),className:"flex-1 rounded-sm",children:[e.jsx(sn,{className:"h-4 w-4"}),"Load session"]})]}),b==="chat"?e.jsx(td,{nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,initialAssignTo:o,initialProject:i,onCreated:h,onCancel:m,footerClassName:k,submitLabel:u==="composer"?"Start chat":"Create chat",cancelLabel:"Cancel",autoFocus:_,layout:u},`${o??""}:${i??""}`):e.jsx(Zl,{nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,onCreated:h,onCancel:m,footerClassName:k,autoFocus:_})]})}function nd({onClick:t,running:s}){return e.jsxs(G,{size:"icon",onClick:t,"aria-label":s?"Open composer - task running":"Open composer",title:s?"Task running - open composer":"Open composer",className:M("absolute bottom-4 right-4 z-10 h-12 w-12 overflow-visible rounded-lg shadow-lg",s&&"animate-soft-status-pulse bg-primary/90 text-primary-foreground hover:bg-primary"),children:[e.jsx(Lt,{className:"h-4 w-4"}),s&&e.jsx("span",{"aria-hidden":"true","data-running-indicator":"true",className:"pointer-events-none absolute right-1.5 top-1.5 h-2 w-2 rounded-full bg-primary-foreground shadow-[0_0_0_2px_hsl(var(--primary))]"})]})}function Hn({children:t}){return e.jsxs("div",{className:"agent-progress-banner animate-message-receive flex items-center gap-1.5 rounded-lg bg-transparent px-1 py-1 text-[11px]",children:[e.jsx("span",{className:"agent-progress-terminal-spinner h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsx("div",{className:"agent-progress-sweep-text min-w-0 leading-5",children:t})]})}function ad({hasVisibleTranscriptEvents:t,hasTranscriptProgress:s,inputCollapsed:n}){return{collapsedButtonRunning:s&&t&&n,showDockedProgress:s&&t&&!n,showInlineProgress:s&&!t}}const Dt="72f988bf-86f1-41af-91ab-2d7cd011db47",Ya=`${Dt} (MSIT)`;function rd({open:t,onOpenChange:s,onShare:n,onStopShare:r,sharing:o,stopping:i=!1,shareResult:h}){return e.jsx(qt,{open:t,onOpenChange:s,children:e.jsxs(Kt,{className:"max-w-md rounded-xl p-5",children:[e.jsx(ps,{className:"sr-only",children:"Share conversation"}),e.jsx(od,{onOpenChange:s,onShare:n,onStopShare:r,sharing:o,stopping:i,shareResult:h})]})})}function od({onOpenChange:t,onShare:s,onStopShare:n,sharing:r,stopping:o=!1,shareResult:i}){const[h,m]=a.useState((i==null?void 0:i.tenant)??Dt),[v,p]=a.useState((i==null?void 0:i.scope)??"chat"),N=i!=null&&i.url?ga(i.url):null,u=r||o;return a.useEffect(()=>{m((i==null?void 0:i.tenant)??Dt),p((i==null?void 0:i.scope)??"chat")},[i==null?void 0:i.shareId,i==null?void 0:i.tenant,i==null?void 0:i.scope]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h2",{className:"text-base font-semibold leading-none tracking-tight",children:"Share conversation"}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Create a tenant-gated link for this task."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(id,{value:h,onChange:m,disabled:u}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Access"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Un,{active:v==="chat",title:"Chat only",description:"Conversation transcript and opening prompt.",onClick:()=>p("chat")}),e.jsx(Un,{active:v==="filesPreview",title:"Chat, files and preview",description:"Transcript plus task output files and HTML preview.",onClick:()=>p("filesPreview")})]})]}),N&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Shared link"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-border/70 bg-muted/30 px-3 py-2",children:[e.jsx("input",{readOnly:!0,value:N,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none","aria-label":"Shared link"}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-sm text-muted-foreground",onClick:()=>void Tt(N,"Shared link copied"),"aria-label":"Copy shared link",title:"Copy shared link",children:e.jsx(ba,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(G,{variant:"outline",onClick:()=>t(!1),disabled:u,className:"h-8 text-xs",children:i?"Done":"Cancel"}),i&&n&&e.jsxs(G,{variant:"outline",onClick:()=>void n(),disabled:u,className:"h-8 border-destructive/30 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive",children:[o&&e.jsx(ue,{className:"h-3.5 w-3.5 animate-spin"}),"Stop share"]}),e.jsxs(G,{onClick:()=>void s({tenant:h,scope:v}),disabled:u,className:"h-8 text-xs",children:[r&&e.jsx(ue,{className:"h-3.5 w-3.5 animate-spin"}),i?"Update link":"Share link"]})]})]})}function id({value:t,onChange:s,disabled:n}){const[r,o]=a.useState(!1),[i,h]=a.useState(!1),[m,v]=a.useState(t),p=a.useRef(null);a.useEffect(()=>{v(t)},[t]),a.useEffect(()=>{if(!r)return;const u=k=>{var y;const _=k.target;_ instanceof Node&&((y=p.current)!=null&&y.contains(_)||(o(!1),h(!1)))},l=k=>{k.key==="Escape"&&(o(!1),h(!1))};return document.addEventListener("mousedown",u),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",l)}},[r]);const N=u=>{const l=u.trim();l&&(s(l),v(l),h(!1),o(!1))};return e.jsxs("div",{className:"space-y-2 text-xs",ref:p,children:[e.jsx("div",{className:"font-medium text-foreground",children:"Tenant"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>!n&&o(u=>!u),disabled:n,className:"flex h-9 w-full items-center justify-between gap-2 rounded-sm border border-border/70 bg-background/70 px-3 text-left text-xs text-foreground shadow-sm outline-none transition-colors hover:bg-background disabled:opacity-50",children:[e.jsx("span",{className:"min-w-0 truncate font-mono",children:ld(t)}),e.jsx(Qe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),r&&e.jsxs("div",{className:"absolute left-0 right-0 z-50 mt-2 overflow-hidden rounded-lg border border-border/60 bg-background/95 text-xs shadow-lg backdrop-blur",children:[e.jsxs("button",{type:"button",onClick:()=>N(Dt),className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left hover:bg-background/60",children:[e.jsx("span",{className:"min-w-0 truncate font-mono text-[11px]",children:Ya}),t===Dt&&e.jsx(Ft,{className:"h-3.5 w-3.5 shrink-0 text-primary"})]}),e.jsx("div",{className:"border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:i?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{value:m,onChange:u=>v(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),N(m))},autoFocus:!0,placeholder:"Tenant ID",className:"h-7 min-w-0 flex-1 rounded-sm border border-border/60 bg-background/70 px-2 font-mono text-[11px] outline-none focus:ring-2 focus:ring-ring"}),e.jsx("button",{type:"button",onClick:()=>N(m),className:"flex h-7 w-7 items-center justify-center rounded-sm hover:bg-background/60",children:e.jsx(Ft,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{v(t),h(!1)},className:"flex h-7 w-7 items-center justify-center rounded-sm text-muted-foreground hover:bg-background/60 hover:text-foreground",children:e.jsx(ot,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex h-7 w-full items-center justify-between rounded-sm px-1.5 text-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:[e.jsx("span",{children:"Manual tenant ID"}),e.jsx(Lt,{className:"h-3 w-3"})]})})]})]})]})}function ld(t){return t===Dt?Ya:t}function Un({active:t,title:s,description:n,onClick:r}){return e.jsxs("button",{type:"button",onClick:r,className:t?"rounded-sm border border-primary/45 bg-primary/10 px-3 py-2 text-left shadow-sm":"rounded-sm border border-border/70 bg-background px-3 py-2 text-left shadow-sm hover:bg-muted/50",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:s}),e.jsx("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:n})]})}function dd(t){const s=t.map(n=>n.type==="text"?n.text:n.type==="image"?n.filename?`Image: ${n.filename}`:"Image attachment":n.isError?`Tool result error: ${n.content}`:`Tool result: ${n.content}`).join(" ").replace(/\s+/g," ").trim();return s?s.length>160?`${s.slice(0,157)}...`:s:"Queued follow-up"}function cd({messages:t,onCancelMessage:s}){return t.length===0?null:e.jsx("div",{className:"border-t border-border/55 bg-card/30 px-3 py-2 sm:px-5",children:e.jsxs("div",{className:"mx-auto max-w-[72rem] rounded-sm border border-border/65 bg-background/58 px-3 py-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium text-foreground",children:[e.jsx(Yi,{className:"h-3.5 w-3.5 text-primary"}),"Queued messages",e.jsx("span",{className:"ml-auto rounded-sm border border-border/60 bg-muted/60 px-1.5 py-0 text-[10px] text-muted-foreground",children:t.length})]}),e.jsx("div",{className:"mt-2 space-y-1.5",children:t.map((n,r)=>e.jsxs("div",{className:"flex min-w-0 items-start gap-2 text-[11px] leading-5 text-muted-foreground",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-sm bg-primary/10 text-[10px] font-medium text-primary",children:r+1}),e.jsx("span",{className:"min-w-0 flex-1 break-words [overflow-wrap:anywhere]",children:dd(n.content)}),s&&e.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0 rounded-sm text-muted-foreground hover:text-destructive",title:"Cancel queued message","aria-label":"Cancel queued message",onClick:()=>s(n.id),children:e.jsx(ot,{className:"h-3 w-3"})})]},n.id))})]})})}const ud=30,md=1600;function xd({savedScrollTop:t,scrollHeight:s,clientHeight:n}){const r=Math.max(0,s-n);return Math.min(Math.max(0,t??r),r)}function _s(t){return t.scrollHeight-t.scrollTop-t.clientHeight<ud}function Vn({explicitBottomStickUntil:t,now:s,wasAtBottom:n}){return n||t>s}function hd({atTop:t,inputCollapseDisabled:s,scrollingUp:n}){return!s&&(n||t)}function pd({activeTab:t,activeTaskId:s,contentVersion:n,inputCollapseDisabled:r=!1,setActiveTab:o,setInputCollapsed:i}){const h=a.useRef(null),m=a.useRef(s),v=a.useRef(!1),p=a.useRef(0),N=a.useRef(new Map),u=a.useRef(0),l=a.useRef(!0),k=a.useCallback((x=m.current)=>{const w=h.current;!w||!x||(N.current.set(x,w.scrollTop),p.current=w.scrollTop,l.current=_s(w))},[]),_=a.useCallback((x=m.current)=>{const w=h.current;!w||!x||(w.scrollTop=xd({savedScrollTop:N.current.get(x),scrollHeight:w.scrollHeight,clientHeight:w.clientHeight}),p.current=w.scrollTop,l.current=_s(w))},[]),y=a.useCallback((x,w=m.current)=>{x.scrollTop=x.scrollHeight,p.current=x.scrollTop,l.current=!0,w&&N.current.set(w,x.scrollTop)},[]),A=a.useCallback((x=m.current)=>{const w=h.current;u.current=Date.now()+md,w&&(y(w,x),requestAnimationFrame(()=>{y(w,x),requestAnimationFrame(()=>y(w,x))}))},[y]),g=a.useCallback(x=>{const w=x.currentTarget,S=p.current,C=w.scrollTop<S&&S-w.scrollTop>10,L=w.scrollTop<=0;if(k(),!v.current){if(_s(w)){i(!1),v.current=!0,setTimeout(()=>{v.current=!1},300);return}(C||L)&&(u.current=0,hd({atTop:L,inputCollapseDisabled:r,scrollingUp:C})&&i(!0))}},[r,k,i]),b=a.useCallback(x=>{t==="transcript"&&k(),o(x),x==="transcript"&&requestAnimationFrame(()=>_())},[t,_,k,o]);return a.useLayoutEffect(()=>{r&&i(!1)},[r,i]),a.useLayoutEffect(()=>{const x=m.current;x&&x!==s&&k(x),m.current=s,t==="transcript"&&requestAnimationFrame(()=>_(s))},[s,t,_,k]),a.useLayoutEffect(()=>{const x=h.current;if(!x||t!=="transcript"||!s)return;Vn({explicitBottomStickUntil:u.current,now:Date.now(),wasAtBottom:l.current})&&y(x,s),k(s)},[s,t,n,k,y]),a.useLayoutEffect(()=>{const x=h.current,w=x==null?void 0:x.firstElementChild;if(!x||!w||t!=="transcript"||typeof ResizeObserver>"u")return;const S=new ResizeObserver(()=>{Vn({explicitBottomStickUntil:u.current,now:Date.now(),wasAtBottom:l.current})?y(x):k()});return S.observe(x),S.observe(w),()=>S.disconnect()},[t,s,k,y]),{handleTranscriptScroll:g,handleTranscriptTabChange:b,scrollTranscriptToBottom:A,transcriptScrollRef:h}}function Qa(t=700){const[s,n]=a.useState(!1),r=a.useRef(null),o=a.useCallback(()=>{n(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>{n(!1),r.current=null},t)},[t]);return a.useEffect(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]),{markScrollbarActive:o,scrollbarActive:s}}const on="h-6 w-6 shrink-0 rounded-sm text-muted-foreground hover:bg-muted/55 hover:text-foreground",At="h-3.5 w-3.5",fd=a.lazy(async()=>({default:(await Qs(()=>import("./FilesTab-2p61JxFR.js"),__vite__mapDeps([0,1,2,3,4]))).FilesTab})),gd=a.lazy(async()=>({default:(await Qs(()=>import("./PreviewTab-hE7s4Tq6.js"),__vite__mapDeps([5,1,2,6]))).PreviewTab})),bd=a.lazy(async()=>({default:(await Qs(()=>import("./DiffTab-DrsxsCTo.js"),__vite__mapDeps([7,1,2,4,3,6]))).DiffTab}));function vd({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:o,cluster:i,sseConnected:h,activeTab:m,setActiveTab:v,creatingTask:p,createMode:N,createDefaults:u,activeTask:l,assignedNode:k,taskLoading:_,transcriptLoading:y,taskError:A,displayEvents:g,initialPromptAlreadyInLogs:b,initialPrompt:x,supportsFollowUp:w,taskUnavailable:S,chatDisabled:C,chatDisabledReason:L,questionBypassEnabled:Y,isRunning:q,isStarting:V,hasPendingFollowUp:I,canCancel:J,canRetry:W,onRetry:R,onCancel:$,onReloadNativeTranscript:ae,onShareTask:ee,onStopShareTask:oe,onStartCreateTask:te,onCancelCreateTask:T,onCreateTask:O,onSendMessage:d,onCancelQueuedMessage:U,onQuestionBypassChange:f,onSubmitQuestionResponse:Q}){const[E,z]=a.useState(!1),[j,D]=a.useState(!1),[F,ne]=a.useState(!1),[X,se]=a.useState(!1),[de,Ne]=a.useState(!1),[H,ce]=a.useState({}),[_e,ye]=a.useState(new Set),[Be,Ge]=a.useState(new Set),[De,re]=a.useState(null),ge=(l==null?void 0:l.effectiveProjectPath)??(l==null?void 0:l.project)??"default workspace",Pe=l?(k==null?void 0:k.name)??Ps(l.assignedTo,i==null?void 0:i.nodes,l.assignedNodeName):"unassigned",$e=l!=null&&l.assignedTo?e.jsxs(e.Fragment,{children:["Connecting session on node ",e.jsx("span",{className:"font-semibold",children:Pe}),"..."]}):"Connecting session to an available node...",ht=l?[{label:"Working dir",value:ge,mono:!0},...l.branch?[{label:"Branch",value:l.branch,mono:!0}]:[],{label:"Agent",value:l.agent,mono:!0},{label:"Node",value:Pe}]:[],je=!!(x&&!b),Te=je||g.length>0,Le=q&&Te,pt=(V||I||q)&&!Le,Xe=Le?"The agent is still working on this conversation.":pt?$e:null,{collapsedButtonRunning:lt,showDockedProgress:vt,showInlineProgress:jt}=ad({hasTranscriptProgress:!!Xe,hasVisibleTranscriptEvents:Te,inputCollapsed:E}),it=(l==null?void 0:l.conversationKind)==="nativeSession",Ue=y?"Loading transcript":it?"No transcript imported":"Transcript is warming up",wt=y?"Loading transcript...":it?"Meshy could not find imported history for this native session yet.":"The opening prompt has been stored, but the agent has not emitted conversation output yet.",Ae=(l==null?void 0:l.queuedMessages)??[],dt=a.useMemo(()=>bi(g),[g]),Nt=a.useMemo(()=>vi("transcript",dt.map(ie=>ie.event)),[dt]),yt=l&&!_e.has(l.id)?H[l.id]??l.activeShare??null:null,ft=(l==null?void 0:l.id)??null,B=`${ft??"none"}:${g.length}:${Ae.length}:${je?1:0}:${y?1:0}:${jt?1:0}`,{handleTranscriptScroll:we,handleTranscriptTabChange:he,scrollTranscriptToBottom:Oe,transcriptScrollRef:Je}=pd({activeTab:m,activeTaskId:ft,contentVersion:B,inputCollapseDisabled:!!Xe,setActiveTab:v,setInputCollapsed:z}),{markScrollbarActive:kt,scrollbarActive:Me}=Qa(),Ve=a.useCallback(ie=>{kt(),we(ie)},[we,kt]),ct=a.useCallback(ie=>{re(ke=>({path:ie,requestId:((ke==null?void 0:ke.requestId)??0)+1})),he("files")},[he]),gt=a.useCallback(ie=>{Oe(),d(ie)},[d,Oe]);return a.useEffect(()=>{re(null)},[ft]),p?e.jsx(jd,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:o,cluster:i,sseConnected:h,defaultMode:N,createDefaults:u,onCancel:T,onCreated:O}):!l&&_?e.jsxs("div",{className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"dashboard-conversation-panel__header shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Vs,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:o,cluster:i,sseConnected:h})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-xl border border-primary/20 bg-primary/10 text-primary shadow-sm",children:e.jsx(ue,{className:"h-7 w-7 animate-spin"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"Loading conversation"}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx(ue,{className:"h-4 w-4 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):l?e.jsxs(Gs,{value:m,onValueChange:he,className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsxs("div",{className:"dashboard-conversation-panel__header shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Xa,{desktopTasksOpen:s,mobileTasksPanelOpen:n,onToggleTasks:t}),e.jsx("h2",{className:"min-w-0 truncate text-sm font-semibold tracking-tight text-foreground sm:text-lg",title:l.title,children:l.title}),e.jsx(va,{status:l.status,isNative:it}),l.priority!=="normal"&&e.jsx(ro,{priority:l.priority}),e.jsx(G,{variant:"ghost",size:"icon",onClick:o,title:r?"Hide cluster":"Show cluster","aria-label":r?"Hide cluster":"Show cluster",className:M("ml-auto",on),children:r?e.jsx(nn,{className:At}):e.jsx(Ba,{className:At})})]}),A&&e.jsx("div",{className:"mt-2 w-fit rounded-sm border border-destructive/25 bg-destructive/10 px-2 py-1 text-[11px] text-destructive",children:A}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsxs(Ys,{className:"h-auto max-w-full overflow-x-auto rounded-sm bg-muted/70 p-0.5",children:[e.jsx(at,{value:"transcript",className:"rounded-sm px-2 py-0.5 text-[11px] sm:px-2.5",children:"Transcript"}),e.jsx(at,{value:"files",className:"rounded-sm px-2 py-0.5 text-[11px] sm:px-2.5",children:"Files"}),e.jsx(at,{value:"preview",className:"rounded-sm px-2 py-0.5 text-[11px] sm:px-2.5",children:"Preview"}),e.jsx(at,{value:"diff",className:"rounded-sm px-2 py-0.5 text-[11px] sm:px-2.5",children:"Diff"})]}),S&&e.jsx(He,{variant:"outline",className:"hidden rounded-sm border-destructive/25 bg-destructive/10 text-destructive sm:inline-flex",children:"Unavailable"}),e.jsxs("div",{className:"ml-auto flex items-center gap-1 text-[10px] text-muted-foreground",children:[e.jsxs("span",{className:"hidden sm:inline",children:["updated ",oo(l.updatedAt)]}),e.jsx("span",{className:"font-mono",children:l.id.slice(0,8)}),W&&e.jsxs(G,{variant:"outline",size:"sm",onClick:R,className:"h-7 shrink-0 rounded-sm px-2 text-[11px]",children:[e.jsx(Bn,{className:"h-3.5 w-3.5"}),"Retry"]}),it&&ae&&e.jsx(G,{variant:"ghost",size:"icon",onClick:ae,disabled:y,title:"Reload native session transcript","aria-label":"Reload native session transcript",className:"h-6 w-6 shrink-0 rounded-sm text-muted-foreground hover:bg-muted/55 hover:text-foreground",children:e.jsx(Bn,{className:M("h-3.5 w-3.5",y&&"animate-spin")})}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",disabled:S,title:S?"Unavailable tasks cannot be shared.":"Share conversation","aria-label":S?"Unavailable tasks cannot be shared.":"Share conversation",className:"h-6 w-6 shrink-0 rounded-sm text-primary hover:bg-primary/10 hover:text-primary disabled:bg-transparent disabled:text-muted-foreground",onClick:()=>ne(!0),children:e.jsx(xs,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsx(rt,{value:"transcript",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"relative min-h-0 flex-1",children:e.jsx("div",{ref:Je,"data-transcript-scroll":"true",className:M("scrollbar-line h-full min-h-0 touch-pan-y overflow-x-hidden overflow-y-auto overscroll-x-none bg-gradient-to-b from-background/15 via-transparent to-background/35 px-3 pb-5 pt-5 sm:px-5",Me&&"scrollbar-line-active"),onScroll:Ve,children:e.jsxs("div",{"data-transcript-scroll-content":"true",className:"mx-auto flex max-w-[72rem] flex-col gap-5",children:[je&&x&&e.jsx(Pn,{event:x,agent:l.agent,taskRootPath:l.effectiveProjectPath,onOpenFilePath:ct,questionBypassEnabled:Y,onQuestionBypassChange:f,onSubmitQuestionResponse:Q,questionResponseDisabled:!w||C}),dt.map(({event:ie,subItems:ke},qe)=>e.jsx(Pn,{event:ie,agent:l.agent,subItems:ke,taskRootPath:l.effectiveProjectPath,onOpenFilePath:ct,questionBypassEnabled:Y,onQuestionBypassChange:f,onSubmitQuestionResponse:Q,questionResponseDisabled:!w||C},Nt[qe])),!Te&&!pt&&e.jsxs("div",{className:"rounded-xl border border-dashed border-border/70 bg-background/35 px-5 py-8 text-center",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:Ue}),e.jsx("div",{className:"mt-2 text-[11px] leading-6 text-muted-foreground",children:wt})]}),(!w&&l.result||l.error)&&e.jsxs("div",{className:"space-y-3",children:[!w&&l.result&&e.jsxs("div",{className:"rounded-xl border border-border/70 bg-card/80 px-3 py-3",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Stored result"}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5 text-muted-foreground",children:JSON.stringify(l.result,null,2)})]}),l.error&&!Be.has(l.id)&&e.jsxs("div",{className:"rounded-xl border border-destructive/20 bg-destructive/10 px-3 py-3 text-destructive",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em]",children:"Stored error"}),e.jsx("button",{onClick:()=>Ge(ie=>new Set(ie).add(l.id)),className:"rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(ot,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5",children:l.error})]})]}),jt&&Xe&&e.jsx(Hn,{children:Xe})]})})}),vt&&Xe&&e.jsx("div",{"data-docked-progress":"true",className:"shrink-0 bg-background/35 px-3 py-1 sm:px-5",children:e.jsx("div",{className:"mx-auto max-w-[72rem]",children:e.jsx(Hn,{children:Xe})})}),w?e.jsxs(e.Fragment,{children:[E&&e.jsx(nd,{running:lt,onClick:()=>{z(!1),Oe(),requestAnimationFrame(()=>{var ie;return(ie=document.querySelector('[data-chat-input-textarea="true"]'))==null?void 0:ie.focus()})}}),e.jsxs("div",{className:`shrink-0 ${E?"hidden":""}`,children:[e.jsx(cd,{messages:Ae,onCancelMessage:U}),e.jsx(Cl,{onSend:gt,disabled:C,disabledReason:L,contextItems:ht,placeholder:C?L:q?"Queue a message for the next turn...":"Continue the conversation...",running:q||I,onStop:J?()=>D(!0):void 0})]})]}):e.jsx("div",{className:"shrink-0 border-t border-border/60 px-3 py-3 text-[11px] text-muted-foreground sm:px-5",children:"This task does not expose follow-up chat messages. Use Files, Preview, or Diff to inspect the result."})]})}),e.jsx(rt,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:e.jsx(Cs,{label:"Loading files..."}),children:e.jsx(fd,{taskId:l.id,requestedFilePath:(De==null?void 0:De.path)??null,requestedFileRequestId:(De==null?void 0:De.requestId)??0})})}),e.jsx(rt,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:e.jsx(Cs,{label:"Loading preview..."}),children:e.jsx(gd,{taskId:l.id})})}),e.jsx(rt,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:e.jsx(Cs,{label:"Loading diff..."}),children:e.jsx(bd,{taskId:l.id})})}),e.jsx(as,{open:j,onOpenChange:D,children:e.jsxs(rs,{children:[e.jsxs(os,{children:[e.jsx(is,{children:"Stop this task?"}),e.jsx(ls,{children:"The task will stop and move to a cancelled state."})]}),e.jsxs(ds,{children:[e.jsx(cs,{children:"Keep running"}),e.jsx(us,{onClick:$,children:"Stop task"})]})]})}),e.jsx(rd,{open:F,onOpenChange:ne,sharing:X,stopping:de,shareResult:yt,onShare:async ie=>{if(!l)return null;se(!0);try{const ke=await ee(ie);return ke!=null&&ke.url&&(ce(qe=>({...qe,[l.id]:ke})),ye(qe=>{const Ze=new Set(qe);return Ze.delete(l.id),Ze})),ke}finally{se(!1)}},onStopShare:async()=>{if(!l)return!1;Ne(!0);try{const ie=await oe();return ie!==!1&&(ce(ke=>{const qe={...ke};return delete qe[l.id],qe}),ye(ke=>new Set(ke).add(l.id))),ie}finally{Ne(!1)}}})]}):e.jsxs("div",{className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"dashboard-conversation-panel__header shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Vs,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:o,cluster:i,sseConnected:h})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsxs("div",{className:"w-full max-w-2xl text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-xl border border-primary/20 bg-primary/10 text-primary shadow-sm",children:e.jsx(ao,{className:"h-7 w-7"})}),e.jsx("h2",{className:"mt-5 text-xl font-semibold tracking-tight text-foreground sm:text-3xl",children:"No chat selected"}),e.jsx("p",{className:"mx-auto mt-3 max-w-xl text-[11px] leading-6 text-muted-foreground",children:"Open a task from the left sidebar to continue the conversation, or start a new task or load a native session."}),e.jsxs(G,{onClick:()=>te(),className:"mt-6 rounded-lg px-5",children:[e.jsx(fs,{className:"h-4 w-4"}),"Start or load chat"]}),A&&e.jsx("div",{className:"mx-auto mt-4 max-w-lg rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:A})]})})]})}function jd({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:o,cluster:i,sseConnected:h,defaultMode:m,createDefaults:v,onCancel:p,onCreated:N}){var _,y,A;const[u,l]=a.useState(m??"chat");a.useEffect(()=>{m&&l(m)},[m]);const k=e.jsx("div",{className:"flex items-center gap-1 rounded-lg border border-border/60 bg-background/65 p-0.5 text-[11px] font-medium shadow-sm",children:[{value:"chat",label:"New chat",icon:fs},{value:"native",label:"Load session",icon:sn}].map(g=>{const b=g.icon,x=g.value===u;return e.jsxs("button",{type:"button",onClick:()=>l(g.value),"aria-pressed":x,className:M("flex items-center gap-1.5 rounded-sm px-2 py-1 transition-all duration-200",x?"bg-primary text-primary-foreground shadow-[0_8px_24px_-12px_hsl(var(--primary)/0.7)]":"text-muted-foreground hover:bg-background/80 hover:text-foreground"),children:[e.jsx(b,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:g.label})]},g.value)})});return e.jsxs("div",{className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"dashboard-conversation-panel__header shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Vs,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:o,cluster:i,sseConnected:h,centerSlot:k})}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsx("div",{className:"w-full max-w-2xl",children:e.jsx(sd,{nodes:(i==null?void 0:i.nodes)??[],currentNodeRole:(_=i==null?void 0:i.self)==null?void 0:_.role,currentNodeId:((y=i==null?void 0:i.self)==null?void 0:y.id)??null,leaderNodeId:((A=i==null?void 0:i.leader)==null?void 0:A.id)??null,initialAssignTo:v==null?void 0:v.assignTo,initialProject:v==null?void 0:v.project,mode:u,onModeChange:l,onCreated:N,onCancel:p,autoFocus:!0,layout:"composer"})})})]})}function Vs({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:o,centerSlot:i}){return e.jsxs("div",{className:"relative flex w-full items-center justify-between gap-1.5",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-1.5",children:e.jsx(Xa,{desktopTasksOpen:s,mobileTasksPanelOpen:n,onToggleTasks:t})}),i&&e.jsx("div",{className:"pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:e.jsx("div",{className:"pointer-events-auto",children:i})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:o,title:r?"Hide cluster":"Show cluster","aria-label":r?"Hide cluster":"Show cluster",className:on,children:r?e.jsx(nn,{className:At}):e.jsx(Ba,{className:At})})]})}function Xa({desktopTasksOpen:t,mobileTasksPanelOpen:s,onToggleTasks:n}){var o,i;const r=(i=(o=globalThis.window)==null?void 0:o.matchMedia("(min-width: 1024px)"))!=null&&i.matches?t:s;return e.jsx(G,{variant:"ghost",size:"icon",onClick:n,title:r?"Hide tasks":"Show tasks","aria-label":r?"Hide tasks":"Show tasks",className:on,children:r?e.jsx(Ia,{className:At}):e.jsx(Zi,{className:At})})}function wd({onAdded:t}){const[s,n]=a.useState(""),[r,o]=a.useState(!1),[i,h]=a.useState(null),m=a.useCallback(async v=>{if(v.preventDefault(),!!s.trim()){o(!0),h(null);try{await io({leaderEndpoint:s.trim(),transport:"devtunnel"}),t()}catch(p){h(p instanceof Error?p.message:"Failed to join node")}finally{o(!1)}}},[s,t]);return e.jsx(Kt,{className:"overflow-hidden border-border/60 bg-transparent p-0 shadow-none sm:max-w-xl",children:e.jsxs("div",{className:"overflow-hidden rounded-xl border border-border/60 bg-background/95 p-0 shadow-[0_40px_120px_-60px_rgba(0,0,0,0.88)] backdrop-blur-xl",children:[e.jsx("div",{className:"border-b border-border/60 px-6 py-5",children:e.jsxs(Xs,{className:"space-y-2 text-left",children:[e.jsx(ps,{className:"text-2xl tracking-tight",children:"Join node"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Verify the remote leader's DevTunnel endpoint, sync this node's tasks to that leader, and join the cluster as a follower."})]})}),e.jsxs("form",{onSubmit:m,className:"space-y-4 px-6 py-5",children:[i&&e.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(Fe,{htmlFor:"leader-endpoint",children:"Leader endpoint"}),e.jsx(He,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),e.jsx(nt,{id:"leader-endpoint",type:"url",value:s,onChange:v=>n(v.target.value),placeholder:"https://your-leader.devtunnels.ms",className:"h-11 rounded-lg border-border/70 bg-background/70"})]}),e.jsx("div",{className:"rounded-lg border border-border/60 bg-background/45 px-4 py-3 text-sm text-muted-foreground",children:"This does not switch the local node transport or auto-enable a local DevTunnel. Leaving later will detach this node from the remote leader and make it leader of its own cluster again."}),e.jsx(ja,{className:"border-t border-border/60 pt-4",children:e.jsx(G,{type:"submit",disabled:!s.trim()||r,className:"rounded-sm",children:r?"Joining...":"Join node"})})]})]})})}function Nd({open:t,onOpenChange:s,onAdded:n}){return e.jsx(qt,{open:t,onOpenChange:s,children:e.jsx(wd,{onAdded:()=>{s(!1),n()}})})}function Ts({className:t,label:s,orientation:n,panel:r,panelResize:o}){return e.jsx("button",{type:"button","aria-label":s,"aria-orientation":n,"data-dashboard-resize-handle":r,onPointerDown:i=>o.onPointerDown(r,i),onWheel:i=>o.onWheel(r,i),className:M("group absolute z-20 hidden touch-none rounded-sm bg-transparent outline-none transition-colors hover:bg-primary/12 focus-visible:bg-primary/12 focus-visible:ring-2 focus-visible:ring-ring/70 lg:block",t),children:e.jsx("span",{className:"pointer-events-none absolute inset-0 opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100"})})}function yd({conversationPanel:t,desktopTasksOpen:s,mobileTaskSidebar:n,mobileTasksPanelOpen:r,mobileTasksPanelRef:o,operationsOpen:i,operationsPanelRef:h,operationsSidecar:m,panelResize:v,taskSidebar:p,terminalPanel:N,onCloseOperations:u,onCloseTaskList:l}){const k={"--dashboard-tasks-width":v.sizes.tasks,"--dashboard-operations-width":v.sizes.operations,"--dashboard-terminal-height":v.sizes.terminal};return e.jsxs("div",{className:"dashboard-workspace flex h-full min-h-0 flex-col overflow-hidden",style:k,children:[e.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[e.jsx("div",{className:M("dashboard-workspace__tasks-panel relative hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",s?"lg:mr-2 lg:w-[var(--dashboard-tasks-width)]":"lg:w-0 lg:overflow-hidden"),children:s&&e.jsxs(e.Fragment,{children:[p,e.jsx(Ts,{panel:"tasks",orientation:"vertical",label:"Resize tasks panel",panelResize:v,className:"-right-1 top-0 h-full w-2 cursor-col-resize"})]})}),e.jsxs("section",{className:"dashboard-workspace__primary flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[e.jsx("div",{className:"min-h-0 flex-1",children:t}),N&&e.jsxs("div",{className:"relative h-[var(--dashboard-terminal-height)] min-h-0 shrink-0",children:[e.jsx(Ts,{panel:"terminal",orientation:"horizontal",label:"Resize terminal panel",panelResize:v,className:"-top-1 left-0 h-2 w-full cursor-row-resize"}),N]})]}),e.jsx("div",{className:M("dashboard-workspace__operations-panel relative hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",i?"xl:ml-2 xl:w-[var(--dashboard-operations-width)]":"xl:w-0 xl:overflow-hidden"),children:i&&e.jsxs(e.Fragment,{children:[e.jsx(Ts,{panel:"operations",orientation:"vertical",label:"Resize operations panel",panelResize:v,className:"-left-1 top-0 h-full w-2 cursor-col-resize"}),m]})})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:u,className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),e.jsx("div",{ref:h,className:"fixed inset-y-0 right-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 xl:hidden",children:m})]}),r&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close task list",onClick:l,className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),e.jsx("div",{ref:o,className:"fixed inset-y-0 left-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 lg:hidden",children:n})]})]})}const kd=10,bt="__all__";function Ye(t){return"session"in t}function qn(t,s){var n;return s&&t.some(r=>r.id===s)?s:((n=t[0])==null?void 0:n.id)??""}function Ds(t){return t&&(Ka(t.id)||t.workDir)||""}function Xt(t,s,n){let r=!1;const o=t.map(i=>Ye(i)&&i.session.id===n.id?(r=!0,{...i,nodeName:s,session:n}):i);return qs(r?o:[...o,{id:`session-${n.id}`,nodeName:s,session:n}])}function Ja(t,s){return t.filter(Ye).filter(n=>n.session.nodeId===s).sort((n,r)=>r.session.startedAt-n.session.startedAt)}function Sd(t){const s=t.filter(Ye).sort((n,r)=>r.session.startedAt-n.session.startedAt);return{active:s.filter(n=>n.session.status==="running"),completed:s.filter(n=>n.session.status!=="running")}}function Cd(t,s){return!!(t&&s&&!t.contains(s))}function Ed(t,s,n){var o;if(n===bt)return n;const r=Ja(t,s);return r.some(i=>i.session.id===n)?n:((o=r[0])==null?void 0:o.session.id)??bt}function _d(t,s,n){return n===bt?t.filter(r=>!Ye(r)||r.session.nodeId===s):t.filter(r=>Ye(r)&&r.session.nodeId===s&&r.session.id===n)}function qs(t){const s=t.map((r,o)=>({entry:r,index:o})).filter(({entry:r})=>Ye(r)&&r.session.status!=="running").sort((r,o)=>!Ye(r.entry)||!Ye(o.entry)?0:o.entry.session.startedAt-r.entry.session.startedAt||o.index-r.index),n=new Set(s.slice(0,kd).map(({entry:r})=>Ye(r)?r.session.id:""));return t.filter(r=>!Ye(r)||r.session.status==="running"||n.has(r.session.id))}function Ks(t){return t.status==="running"?t.pid?`running pid ${t.pid}`:"running":t.status==="exited"?`exit ${t.exitCode??0}`:t.status==="stopped"?"stopped":t.signal?`failed ${t.signal}`:`exit ${t.exitCode??"failed"}`}function Td(t){const s=t.session.command.length>48?`${t.session.command.slice(0,45)}...`:t.session.command;return`${t.nodeName} - ${Ks(t.session)} - ${s}`}function Za(t,s=48){return t.length>s?`${t.slice(0,s-3)}...`:t}function Dd(t,s){return s===bt?"All sessions":t?Za(t.session.command,34):"Command session"}function Kn(t){return t.status==="stopped"?"":t.stderr}function Ad({nodes:t,defaultNodeId:s,onClose:n,initialHistory:r=[]}){const[o,i]=a.useState(()=>qn(t,s)),h=a.useMemo(()=>t.find(f=>f.id===o)??t[0]??null,[t,o]),[m,v]=a.useState(()=>Ds(h)),[p,N]=a.useState(""),[u,l]=a.useState(()=>qs(r)),[k,_]=a.useState(bt),[y,A]=a.useState(!1),[g,b]=a.useState(!1),[x,w]=a.useState(!1),[S,C]=a.useState(!1),[L,Y]=a.useState(!1),q=a.useRef(null),V=a.useRef(null),I=a.useMemo(()=>t.find(f=>f.id===o)??t[0]??null,[t,o]),J=a.useMemo(()=>Ja(u,(I==null?void 0:I.id)??""),[u,I]),W=a.useMemo(()=>Sd(J),[J]),R=a.useMemo(()=>J.find(f=>f.session.id===k),[k,J]),$=a.useMemo(()=>_d(u,(I==null?void 0:I.id)??"",k),[u,I,k]),ae=a.useRef((I==null?void 0:I.id)??"");a.useEffect(()=>{o&&t.some(f=>f.id===o)||i(qn(t,s))},[s,t,o]),a.useEffect(()=>{const f=(I==null?void 0:I.id)??"";ae.current!==f&&(ae.current=f,v(Ds(I)))},[I]),a.useEffect(()=>{_(f=>Ed(u,(I==null?void 0:I.id)??"",y?f:""))},[u,I,y]),a.useEffect(()=>{var f;(f=q.current)==null||f.scrollTo({top:q.current.scrollHeight})},[u]),a.useEffect(()=>{let f=!1;async function Q(){const E=await Promise.allSettled(t.map(async z=>({node:z,response:await co(z.id)})));f||l(z=>E.reduce((j,D)=>D.status!=="fulfilled"?j:D.value.response.sessions.reduce((F,ne)=>Xt(F,D.value.node.name,ne),j),z))}return t.length>0&&Q(),()=>{f=!0}},[t]),a.useEffect(()=>{const f=u.filter(Ye).filter(E=>E.session.status==="running");if(f.length===0)return;const Q=window.setInterval(()=>{for(const E of f)lo(E.session.nodeId,E.session.id).then(z=>l(j=>Xt(j,E.nodeName,z))).catch(()=>{})},1e3);return()=>window.clearInterval(Q)},[u]);const ee=a.useRef(null);async function oe(f){if(f.preventDefault(),!I||!p.trim()||L)return;const Q=p.trim(),E=I.name;Y(!0),N("");try{const z=await mo(I.id,{command:Q,...m.trim()?{cwd:m.trim()}:{}});l(j=>Xt(j,E,z)),_(z.id),A(!0)}catch(z){l(j=>[...j,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,nodeName:E,command:Q,error:z instanceof Error?z.message:"Command failed"}])}finally{Y(!1)}}async function te(f,Q){f.stopPropagation();const E=await uo(Q.session.nodeId,Q.session.id);l(z=>Xt(z,Q.nodeName,E))}function T(f){_(f),A(!0),b(!1)}function O(f){g&&Cd(V.current,f.target)&&b(!1)}function d(f,Q,E,z,j){return e.jsxs("div",{className:"border-t border-border/60 py-1",children:[e.jsxs("button",{type:"button",onClick:z,"aria-label":`Toggle ${f} sessions`,"aria-expanded":!E,className:"node-terminal__small flex w-full items-center justify-between gap-2 px-2 pb-1 pt-0.5 text-left font-medium uppercase tracking-normal text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{children:f}),e.jsx(Qe,{className:M("h-3 w-3 transition-transform",E&&"-rotate-90")})]}),!E&&(Q.length>0?Q.map(U):e.jsx("div",{className:"node-terminal__control px-2 py-1 text-muted-foreground",children:j}))]})}function U(f){const Q=k===f.session.id,E=f.session.status==="running";return e.jsxs("div",{className:M("node-terminal__control group flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/65",Q&&"bg-primary/10 text-primary"),children:[e.jsxs("button",{type:"button",onClick:()=>T(f.session.id),className:"flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{className:M("flex h-4 w-4 shrink-0 items-center justify-center",E?"text-primary":f.session.status==="exited"?"text-emerald-600 dark:text-emerald-300":"text-amber-600 dark:text-amber-300"),children:E?e.jsx(ue,{className:"h-3 w-3 animate-spin"}):f.session.status==="exited"?e.jsx(Sn,{className:"h-3 w-3"}):e.jsx(ts,{className:"h-3 w-3"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-foreground",children:Za(f.session.command,44)}),e.jsxs("span",{className:"node-terminal__small block truncate text-muted-foreground",children:[f.nodeName," · ",Ks(f.session)]})]})]}),E&&e.jsx("button",{type:"button",onClick:z=>void te(z,f),"aria-label":"Stop terminal session from selector",title:"Stop terminal session",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(Rn,{className:"h-3 w-3"})})]},f.session.id)}return e.jsx("section",{className:"dashboard-panel node-terminal animate-composer-settle flex h-full min-h-0 shrink-0 overflow-visible rounded-xl","aria-label":"Node terminal",onClick:O,children:e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col overflow-visible rounded-[inherit] bg-card/72 text-card-foreground",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsxs("div",{className:"node-terminal__header flex min-w-0 items-center gap-2 font-medium",children:[n?e.jsx("button",{type:"button",onClick:n,"aria-label":"Close terminal",title:"Close terminal",className:"flex h-6 w-6 items-center justify-center rounded-md text-primary transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(ot,{className:"h-3.5 w-3.5"})}):e.jsx(kn,{className:"h-3.5 w-3.5 text-primary"}),e.jsx("span",{children:"Terminal"})]}),e.jsxs("div",{className:"ml-auto flex min-w-0 flex-wrap items-center justify-end gap-2",children:[e.jsxs("div",{ref:V,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":"Command session","aria-expanded":g,title:R?Td(R):"All sessions",onClick:()=>b(f=>!f),className:"node-terminal__control flex h-7 max-w-[14rem] list-none items-center gap-1.5 rounded-sm border border-border/70 bg-background/70 px-2 text-foreground outline-none transition-colors hover:bg-muted/65 focus-visible:ring-2 focus-visible:ring-ring/70 [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{className:"min-w-0 truncate",children:Dd(R,k)}),e.jsx(Qe,{className:M("h-3 w-3 shrink-0 text-muted-foreground transition-transform",g&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!g,className:M("absolute right-0 bottom-9 z-30 w-[19rem] overflow-hidden rounded-xl border border-border/70 bg-popover text-popover-foreground shadow-xl",!g&&"hidden"),children:e.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[e.jsxs("button",{type:"button",onClick:()=>T(bt),className:M("node-terminal__control flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",k===bt&&"bg-primary/10 text-primary"),children:[e.jsx(kn,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:"All sessions"})]}),d("Active",W.active,x,()=>w(f=>!f),"No active sessions"),d("Completed",W.completed,S,()=>C(f=>!f),"No completed sessions")]})})]}),e.jsx("select",{value:(I==null?void 0:I.id)??"",onChange:f=>{i(f.target.value),A(!1),v(Ds(t.find(Q=>Q.id===f.target.value)??null))},disabled:L||t.length===0,"aria-label":"Terminal node",className:"node-terminal__control h-7 max-w-[11rem] rounded-sm border border-border/70 bg-background/70 px-2 text-foreground outline-none transition-colors hover:bg-muted/65 disabled:opacity-50",children:t.map(f=>e.jsx("option",{value:f.id,className:"bg-background text-foreground",children:f.name},f.id))}),e.jsx(hs,{value:m,onChange:v,assignTo:(I==null?void 0:I.id)??"",nodes:t,assignableNodes:t,layout:"composer",chipClassName:"node-terminal__control h-7 max-w-[18rem] rounded-sm border border-border/70 bg-background/70 px-2 text-foreground hover:bg-muted/65",chipActiveClassName:"font-mono",chipInactiveClassName:"text-muted-foreground",labelClassName:"node-terminal__workdir",triggerClassName:"terminal-workdir-trigger",popoverPlacement:"top",popoverAlign:"end"})]})]}),e.jsxs("div",{ref:q,className:"node-terminal__body min-h-0 flex-1 overflow-y-auto bg-muted/22 px-3 py-2 font-mono cursor-text",onClick:()=>{var f;return(f=ee.current)==null?void 0:f.focus()},children:[$.length===0?e.jsx("div",{className:"text-muted-foreground mb-2",children:"Commands run on the selected node and stay visible while running or after exit."}):e.jsx("div",{className:"space-y-3 mb-2",children:$.map(f=>Ye(f)?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[e.jsxs("span",{className:"text-primary",children:[f.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:f.session.command}),e.jsxs("span",{className:M("inline-flex items-center gap-1",f.session.status==="running"||f.session.status==="exited"?"text-primary":"text-amber-600 dark:text-amber-300"),children:[f.session.status==="running"?e.jsx(ue,{className:"h-3 w-3 animate-spin"}):f.session.status==="exited"?e.jsx(Sn,{className:"h-3 w-3"}):e.jsx(ts,{className:"h-3 w-3"}),Ks(f.session)]}),f.session.status==="running"&&e.jsx("button",{type:"button",onClick:Q=>void te(Q,f),"aria-label":"Stop terminal session",title:"Stop terminal session",className:"inline-flex h-5 w-5 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted/65 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(Rn,{className:"h-3 w-3"})})]}),f.session.stdout&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-foreground",children:f.session.stdout}),Kn(f.session)&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:Kn(f.session)}),(f.session.stdoutTruncated||f.session.stderrTruncated)&&e.jsx("div",{className:"text-muted-foreground",children:"Output truncated to the latest output."})]},f.id):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[e.jsxs("span",{className:"text-primary",children:[f.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:f.command}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[e.jsx(ts,{className:"h-3 w-3"}),"error"]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:f.error})]},f.id))}),e.jsxs("form",{onSubmit:oe,className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"shrink-0 text-primary select-none",children:I?`${I.name}$`:"$"}),e.jsx("input",{ref:ee,value:p,onChange:f=>N(f.target.value),disabled:!I||L,placeholder:I?"":"No online nodes available",className:"node-terminal__input flex-1 min-w-0 bg-transparent border-none outline-none text-foreground placeholder:text-muted-foreground font-mono caret-primary disabled:opacity-50",autoComplete:"off",spellCheck:!1}),e.jsx("button",{type:"submit","aria-label":"Run",title:"Run",disabled:!I||!p.trim()||L,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-primary transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70 disabled:pointer-events-none disabled:text-muted-foreground disabled:opacity-50",children:L?e.jsx(ue,{className:"h-3 w-3 animate-spin"}):e.jsx(en,{className:"h-3 w-3"})})]})]})]})})}function ln({nodeId:t,nodeName:s,onOpenSettings:n,onOpenCapabilities:r,onOpenDevBox:o,onStartDevBox:i,showConfigureDevBox:h,showStartDevBox:m,startDevBoxPending:v,className:p}){const[N,u]=a.useState(!1),[l,k]=a.useState(null),_=a.useRef(null),y=a.useRef(null),A=v?"Starting":"Start DevBox";a.useLayoutEffect(()=>{if(!N){k(null);return}const b=()=>{const x=y.current,w=_.current;if(!x||!w)return;const S=x.getBoundingClientRect(),C=w.getBoundingClientRect();k(Pd({left:S.left,right:S.right,bottom:S.bottom,top:S.top},{width:C.width,height:C.height},{width:window.innerWidth,height:window.innerHeight},Ld()))};return b(),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),()=>{window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0)}},[N]),a.useEffect(()=>{if(!N)return;const b=w=>{var C,L;const S=w.target;S instanceof Node&&!((C=_.current)!=null&&C.contains(S))&&!((L=y.current)!=null&&L.contains(S))&&u(!1)},x=w=>{w.key==="Escape"&&u(!1)};return document.addEventListener("mousedown",b),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",x)}},[N]);const g=N?e.jsxs("div",{ref:_,"data-node-action-menu-portal":"true",role:"menu",style:Md(l),onClick:b=>b.stopPropagation(),onPointerDown:b=>b.stopPropagation(),className:"fixed z-[130] min-w-40 overflow-hidden whitespace-nowrap rounded-sm border border-border/65 bg-popover/96 p-1 normal-case tracking-normal shadow-[0_18px_48px_-28px_rgba(0,0,0,0.45)] backdrop-blur-xl",children:[e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Open ${s} settings`,title:`Open ${s} settings`,onClick:b=>{b.stopPropagation(),u(!1),n(t)},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(xo,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Settings"})]}),r&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Open ${s} capabilities`,title:`Open ${s} capabilities`,onClick:b=>{b.stopPropagation(),u(!1),r(t)},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(wa,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Capabilities"})]}),m&&i&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`${A} for ${s}`,title:`${A} for ${s}`,onClick:b=>{b.stopPropagation(),!v&&(u(!1),i(t))},disabled:v,className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80 disabled:cursor-not-allowed disabled:opacity-60",children:[v?e.jsx(ue,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-primary"}):e.jsx(en,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:A})]}),h&&o&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Configure DevBox for ${s}`,title:`Configure DevBox for ${s}`,onClick:b=>{b.stopPropagation(),u(!1),o(t)},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(ho,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Configure DevBox"})]})]}):null;return e.jsxs("div",{"data-node-action-menu":"true",className:M("relative shrink-0",N&&"z-[120]",p),onClick:b=>b.stopPropagation(),onPointerDown:b=>b.stopPropagation(),children:[e.jsx(G,{ref:y,type:"button",variant:"ghost",size:"icon","aria-label":`More actions for ${s}`,"aria-haspopup":"menu","aria-expanded":N,title:`More actions for ${s}`,onClick:b=>{b.stopPropagation(),u(x=>(x||k(null),!x))},className:M("h-6 w-6 rounded-sm text-muted-foreground hover:bg-background/70 hover:text-foreground",N&&"bg-background/80 text-primary"),children:e.jsx(Mi,{className:"h-3.5 w-3.5"})}),g&&(typeof document>"u"?g:Na.createPortal(g,document.body))]})}function Md(t){return t?{left:t.left,top:t.top}:{left:0,top:0,visibility:"hidden"}}function Pd(t,s,n,r=1){const h=s.width||160,m=s.height||0,v=Number.isFinite(r)&&r>0?r:1,p=Math.max(8,Math.min(t.right-h,n.width-h-8)),N=t.bottom+4,u=(t.top??t.bottom)-m-4,l=N+m>n.height-8&&u>=8?u:N;return{left:Math.round(p/v),top:Math.round(l/v)}}function Ld(){if(typeof window>"u"||typeof document>"u")return 1;const t=window.getComputedStyle(document.documentElement),s=t.zoom||t.getPropertyValue("--ui-zoom"),n=Number.parseFloat(s);return Number.isFinite(n)&&n>0?n:1}const Id=new Set(["deallocated","hibernate","hibernated","sleep","sleeping","stopped"]),Bd=new Set(["startinprogress","starting"]);function Mt(t){return!!(t!=null&&t.enabled&&t.name)}function Rd(t){const s=t==null?void 0:t.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(s&&Id.has(s))}function Pt(t){const s=t==null?void 0:t.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(s&&Bd.has(s))}function gs(t,s,n){return t==="offline"&&Rd(s)&&Mt(n)}function Wn(t,s){return t==="offline"&&Mt(s)}function Gn(t){return!Mt(t)}function $d({nodeStatus:t,status:s,current:n,selected:r}){const o=r??n;return o&&gs(t,s,o)?o:null}function Re(t){return t.scope||`name:${t.name??""}`}function Od({previousKey:t,baseDevBox:s,listed:n}){if(t&&n.some(i=>Re(i)===t))return t;if(!Mt(s))return n[0]?Re(n[0]):"";const r=Re(s),o=n.find(i=>Re(i)===r)??n.find(i=>i.name===s.name);return o?Re(o):r}function zd({cluster:t,systemInfo:s,nodeNameById:n,nodeBlockingTaskCounts:r,eventTypeFilter:o,onEventTypeFilterChange:i,eventTypeOptions:h,filteredEvents:m,sseConnected:v,clusterLoading:p,clusterError:N,promotePending:u,onPromote:l,onAddNode:k,leavePending:_,onLeaveCluster:y,onToggleNodeDevTunnel:A,devTunnelNodeId:g,devBoxStartNodeId:b,devBoxStartingNodeIds:x=new Set,onOpenNodeSettings:w,onOpenDevBox:S,onStartDevBox:C,onClose:L}){var ee,oe,te;const Y=((ee=t==null?void 0:t.self)==null?void 0:ee.role)==="leader",q=((oe=t==null?void 0:t.self)==null?void 0:oe.role)==="follower"&&!(t!=null&&t.leader),V=(t==null?void 0:t.self)??null,J=po((t==null?void 0:t.nodes)??[],V==null?void 0:V.id).filter(T=>T.id!==(V==null?void 0:V.id)),W=t!=null&&t.leader?t.nodes.find(T=>{var O;return T.id===((O=t.leader)==null?void 0:O.id)})??null:null,R=t!=null&&t.leader?t.leader.dashboardOrigin??(W==null?void 0:W.dashboardOrigin)??(s&&t.leader.id===(s.nodeId??s.id)?s.dashboardOrigin:void 0)??t.leader.endpoint:null,$=(V==null?void 0:V.role)==="leader"&&J.length===0,ae=(V==null?void 0:V.role)==="follower";return e.jsx("aside",{className:"dashboard-operations-sidecar dashboard-panel dashboard-panel-muted animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:e.jsxs(Gs,{defaultValue:"overview",className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"dashboard-operations-sidecar__header shrink-0 border-b border-border/55 bg-card/24 px-2.5 py-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"Operations"}),e.jsx("p",{className:"mt-px text-[9px] text-muted-foreground",children:"Node, cluster, and live events."})]}),e.jsx(G,{variant:"ghost",size:"icon",onClick:L,className:"h-6 w-6 rounded-sm",children:e.jsx(nn,{className:"h-3.5 w-3.5"})})]}),e.jsxs(Ys,{className:"mt-1.5 grid h-auto w-full grid-cols-3 rounded-sm bg-muted/55 p-0.5",children:[e.jsx(at,{value:"overview",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Overview"}),e.jsx(at,{value:"nodes",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Nodes"}),e.jsx(at,{value:"events",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Live events"})]})]}),e.jsx(rt,{value:"overview",className:"mt-0 min-h-0 flex-1",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto px-2 py-2",children:e.jsxs("div",{className:"space-y-2.5",children:[V&&e.jsx(Yn,{node:V,systemInfo:s,blockingTaskCount:r.get(V.id)??0,devTunnelNodeId:g,onToggleNodeDevTunnel:A,showActions:!1,defaultExpanded:!1,onOpenDevBox:S,devBoxStartingNodeIds:x}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-[10px] font-medium text-foreground",children:"Cluster snapshot"}),e.jsx(He,{variant:"outline",className:"rounded-sm border-border/55 bg-background/60 px-1.5 py-0 text-[9px] leading-4 shadow-none",children:v?"Connected":"Reconnecting"})]}),p&&!t?e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground",children:[e.jsx(ue,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):N&&!t?e.jsx("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-2 py-1.5 text-[10px] text-destructive shadow-none",children:N}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx(_t,{label:"Term",value:String((t==null?void 0:t.term)??0)}),e.jsx(_t,{label:"Nodes",value:String((t==null?void 0:t.nodes.length)??0)}),e.jsx(_t,{label:"Pending",value:String((t==null?void 0:t.taskSummary.pending)??0)}),e.jsx(_t,{label:"Running",value:String((t==null?void 0:t.taskSummary.running)??0)}),e.jsx(_t,{label:"Completed",value:String((t==null?void 0:t.taskSummary.completed)??0)}),e.jsx(_t,{label:"Failed",value:String((t==null?void 0:t.taskSummary.failed)??0)})]}),e.jsxs("div",{className:"space-y-1.5 rounded-sm border border-border/55 bg-background/56 px-2 py-2 shadow-none",children:[e.jsx(st,{label:"Leader",value:((te=t==null?void 0:t.leader)==null?void 0:te.name)??"None"}),e.jsx(st,{label:"Leader URL",value:R??"Unavailable",mono:!0,action:R?e.jsx(Vt,{label:"Copy leader URL",onClick:()=>void Tt(R,"Leader URL copied")}):void 0}),e.jsx(st,{label:"Feed",value:v?"Receiving live updates":"Reconnecting to event stream"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:q&&e.jsxs(G,{variant:"outline",size:"sm",onClick:l,disabled:u,className:"h-6 rounded-sm px-2 text-[10px] shadow-none",children:[u&&e.jsx(ue,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})})]})]})]})})}),e.jsx(rt,{value:"nodes",className:"mt-0 min-h-0 flex-1",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto px-2 py-2",children:e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-[10px] font-medium text-foreground",children:"This node"}),$?e.jsx(G,{variant:"outline",size:"sm",onClick:k,className:"h-6 rounded-sm px-2 text-[10px] shadow-none",children:"Join node"}):ae?e.jsxs(G,{variant:"outline",size:"sm",onClick:y,disabled:_,className:"h-6 rounded-sm px-2 text-[10px] shadow-none",children:[_&&e.jsx(ue,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),V&&e.jsx(Yn,{node:V,systemInfo:s,blockingTaskCount:r.get(V.id)??0,devTunnelNodeId:g,onToggleNodeDevTunnel:A,showActions:!0,defaultExpanded:!0,onOpenNodeSettings:Y?w:void 0,onOpenDevBox:Y?S:void 0,onStartDevBox:Y?C:void 0,devBoxStartNodeId:b,devBoxStartingNodeIds:x})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"text-[10px] font-medium text-foreground",children:["Peer nodes (",J.length,")"]}),J.length>0?e.jsx("div",{className:"space-y-1.5",children:J.map(T=>e.jsx(Fd,{node:T,isLeader:!!Y,blockingTaskCount:r.get(T.id)??0,devTunnelNodeId:g,onToggleNodeDevTunnel:A,onOpenNodeSettings:Y?w:void 0,onOpenDevBox:Y?S:void 0,onStartDevBox:Y?C:void 0,devBoxStartNodeId:b,devBoxStartingNodeIds:x},T.id))}):e.jsx("div",{className:"rounded-sm border border-border/55 bg-background/45 px-2 py-2 text-[10px] text-muted-foreground shadow-none",children:"No peer nodes are connected yet."})]})]})})}),e.jsx(rt,{value:"events",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col px-2 py-2",children:[e.jsxs("div",{className:"mb-2 space-y-1.5",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-foreground",children:[e.jsx(fo,{className:M("h-3.5 w-3.5",v?"text-emerald-500":"text-destructive")}),"Live events"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsxs(Se,{value:o,onValueChange:i,children:[e.jsx(Ce,{className:"h-6 min-w-[10rem] flex-1 rounded-sm border-border/70 bg-background/60 text-[10px] shadow-none sm:max-w-[14rem] [&>svg]:h-3 [&>svg]:w-3",children:e.jsx(Ie,{placeholder:"Event type"})}),e.jsx(Ee,{className:"shadow-none",children:h.map(T=>e.jsx(xe,{value:T,className:"py-1 pl-6 pr-1.5 text-[10px] leading-4",children:T==="all"?"All event types":T},T))})]}),e.jsx(He,{variant:"outline",className:"rounded-sm border-border/55 bg-background/60 px-1.5 py-0 text-[9px] leading-4 shadow-none",children:v?"Connected":"Reconnecting"})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(go,{events:m,maxHeight:"100%",emptyTitle:o==="all"?"No live events yet":"No matching events",emptyDescription:o==="all"?"Cluster activity appears here as it happens.":`No "${o}" events are in the current stream.`,nodeNameById:n,density:"compact"})})]})})]})})}function Yn({node:t,systemInfo:s,blockingTaskCount:n,devTunnelNodeId:r,onToggleNodeDevTunnel:o,showActions:i=!0,defaultExpanded:h=!1,onOpenNodeSettings:m,onOpenDevBox:v,onStartDevBox:p,devBoxStartNodeId:N,devBoxStartingNodeIds:u}){var C,L,Y,q;const[l,k]=a.useState(h),_=(s==null?void 0:s.dashboardOrigin)??t.dashboardOrigin,y=t.devtunnelEndpoint??t.endpoint,A=_??t.endpoint,g=(s==null?void 0:s.workDir)??t.workDir,b=za(t,s==null?void 0:s.transportType),x=an(t,s==null?void 0:s.transportType),w=x&&It((s==null?void 0:s.transportType)??t.transportType)?!0:Oa(t,s==null?void 0:s.transportType),S=n>0;return e.jsxs("section",{className:"rounded-lg border border-primary/15 bg-primary/7 shadow-none",children:[e.jsxs("div",{className:"w-full px-2.5 py-1.5 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>k(V=>!V),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[l?e.jsx(Qe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(xt,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx(ya,{status:t.status}),e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Current node"})]}),e.jsx("a",{href:A,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(ka,{className:"h-3 w-3"})}),m&&e.jsx(ln,{nodeId:t.id,nodeName:t.name,onOpenSettings:m,onOpenDevBox:v,onStartDevBox:p,showConfigureDevBox:(C=t.devbox)==null?void 0:C.enabled,showStartDevBox:gs(t.status,(L=t.devbox)==null?void 0:L.lastStatus,t.devbox)||Pt((Y=t.devbox)==null?void 0:Y.lastStatus)||u.has(t.id),startDevBoxPending:N===t.id||Pt((q=t.devbox)==null?void 0:q.lastStatus)||u.has(t.id)})]}),e.jsxs("button",{type:"button",onClick:()=>k(V=>!V),className:"mt-1 flex min-w-0 items-center gap-1 pl-5 text-left",children:[e.jsx("span",{className:"text-[10px] font-semibold tracking-tight text-foreground",children:t.name}),e.jsx(Sa,{role:t.role,size:"compact"}),e.jsx(He,{variant:"outline",className:"rounded-sm border-border/55 bg-background/60 px-1.5 py-0 text-[9px] leading-4 capitalize shadow-none",children:t.status})]})]}),l&&e.jsxs("div",{className:"space-y-2 border-t border-primary/15 px-2.5 pb-2.5 pt-1.5",children:[e.jsxs("div",{className:"space-y-1.5 rounded-sm border border-border/55 bg-background/70 px-2 py-1.5 shadow-none",children:[e.jsx(st,{label:"Node ID",value:t.id,mono:!0}),_&&e.jsx(st,{label:"Dashboard",value:_,mono:!0,action:e.jsx(Vt,{label:"Copy dashboard URL",onClick:()=>void Tt(_,"Dashboard URL copied")})}),e.jsx(st,{label:"Node URL",value:y,mono:!0,action:e.jsx(Vt,{label:"Copy node URL",onClick:()=>void Tt(y,"Node URL copied")})}),g&&e.jsx(st,{label:"Workspace",value:g,mono:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsx(Bs,{label:"Transport",value:b}),s&&e.jsx(Bs,{label:"Uptime",value:bo(s.uptime),mono:!0})]}),e.jsx(Ma,{capabilities:t.capabilities,action:i&&w?e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>o(t),disabled:r===t.id||S,className:"h-6 rounded-sm px-2 text-[10px] shadow-none",title:S?"Finish assigned or running tasks before changing remote access":void 0,children:[r===t.id&&e.jsx(ue,{className:"h-3 w-3 animate-spin"}),x?"Disable Remote Access":"Enable Remote Access"]}):void 0}),i&&w&&S&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function Fd({node:t,isLeader:s,blockingTaskCount:n,devTunnelNodeId:r,onToggleNodeDevTunnel:o,onOpenNodeSettings:i,onOpenDevBox:h,onStartDevBox:m,devBoxStartNodeId:v,devBoxStartingNodeIds:p}){var x,w,S,C;const[N,u]=a.useState(!1),l=t.dashboardOrigin,k=t.devtunnelEndpoint??t.endpoint,_=l??t.endpoint,y=za(t),A=an(t),g=Oa(t),b=n>0;return e.jsxs("div",{className:"rounded-sm border border-border/55 bg-background/54 shadow-none",children:[e.jsxs("div",{className:"w-full px-2.5 py-1.5 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>u(L=>!L),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[N?e.jsx(Qe,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):e.jsx(xt,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx(ya,{status:t.status}),e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Peer node"})]}),e.jsx("a",{href:_,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(ka,{className:"h-3 w-3"})}),s&&i&&e.jsx(ln,{nodeId:t.id,nodeName:t.name,onOpenSettings:i,onOpenDevBox:h,onStartDevBox:m,showConfigureDevBox:(x=t.devbox)==null?void 0:x.enabled,showStartDevBox:gs(t.status,(w=t.devbox)==null?void 0:w.lastStatus,t.devbox)||Pt((S=t.devbox)==null?void 0:S.lastStatus)||p.has(t.id),startDevBoxPending:v===t.id||Pt((C=t.devbox)==null?void 0:C.lastStatus)||p.has(t.id)})]}),e.jsxs("button",{type:"button",onClick:()=>u(L=>!L),className:"mt-1 flex min-w-0 items-center gap-1 pl-4 text-left",children:[e.jsx("span",{className:"text-[10px] font-semibold text-foreground",children:t.name}),e.jsx(Sa,{role:t.role,size:"compact"}),e.jsx(He,{variant:"outline",className:"rounded-sm border-border/55 bg-background/60 px-1.5 py-0 text-[9px] leading-4 capitalize shadow-none",children:t.status})]})]}),N&&e.jsxs("div",{className:"space-y-2 border-t border-border/55 px-2.5 pb-2.5 pt-1.5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(st,{label:"Node ID",value:t.id,mono:!0}),l&&e.jsx(st,{label:"Dashboard",value:l,mono:!0,action:e.jsx(Vt,{label:"Copy dashboard URL",onClick:()=>void Tt(l,"Dashboard URL copied")})}),e.jsx(st,{label:"Node URL",value:k,mono:!0,action:e.jsx(Vt,{label:"Copy node URL",onClick:()=>void Tt(k,"Node URL copied")})}),t.workDir&&e.jsx(st,{label:"Workspace",value:t.workDir,mono:!0}),e.jsx(Bs,{label:"Transport",value:y})]}),e.jsx(Ma,{capabilities:t.capabilities,action:s&&g?e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>o(t),disabled:r===t.id||b,className:"h-6 rounded-sm px-2 text-[10px] shadow-none",title:b?"Finish assigned or running tasks before changing remote access":void 0,children:[r===t.id&&e.jsx(ue,{className:"h-3 w-3 animate-spin"}),A?"Disable Remote Access":"Enable Remote Access"]}):void 0}),s&&g&&b&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function Vt({label:t,onClick:s}){return e.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0 rounded-sm text-muted-foreground",onClick:s,"aria-label":t,title:t,children:e.jsx(ba,{className:"h-3 w-3"})})}function Hd(t,s,n,r){var m,v;if(!t)return{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Select a task to continue the conversation."};const o=((m=s==null?void 0:s.self)==null?void 0:m.role)==="follower",i=t.assignedTo?((v=s==null?void 0:s.self)==null?void 0:v.id)===t.assignedTo?s.self:s==null?void 0:s.nodes.find(p=>p.id===t.assignedTo):void 0;return t.assignedTo!==null&&(i?i.status==="offline":s?t.assignedNodeAvailable===!1||!s.nodes.some(p=>p.id===t.assignedTo):t.assignedNodeAvailable===!1)?{taskUnavailable:!0,chatDisabled:!0,chatDisabledReason:`${t.assignedNodeName??"Assigned node"} is unavailable. Leave the cluster on that node or re-run the task elsewhere.`}:o?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Follower nodes are read-only. Use the leader dashboard to manage chat, or leave the cluster first."}:n?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Sending message..."}:r?{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Queue a message for the next turn..."}:ms.has(t.status)||t.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:ms.has(t.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}function Ud({dirPath:t,label:s,taskCount:n,collapsed:r,onToggle:o,onCreateTask:i,onOpenCapabilities:h}){return e.jsxs("div",{className:"group/project-row flex w-full items-stretch rounded-sm bg-muted/15 text-[9px] font-medium text-muted-foreground/70 transition-all duration-150 hover:bg-muted/30 hover:text-foreground active:scale-[0.98] active:bg-muted/40",children:[e.jsxs("button",{type:"button",onClick:o,"aria-expanded":!r,title:t,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-l-sm px-2 py-1 text-left",children:[e.jsx(xt,{className:M("h-3 w-3 shrink-0 transition-transform duration-200",!r&&"rotate-90")}),e.jsx(ss,{className:"h-3 w-3 shrink-0 text-muted-foreground/55"}),e.jsx("span",{className:"min-w-0 truncate font-mono",children:s}),e.jsx("span",{className:"ml-2 shrink-0 rounded-sm bg-background/55 px-1 py-0 tabular-nums text-[8px] font-medium leading-3 text-muted-foreground/45",children:n})]}),h&&e.jsx("button",{type:"button",onClick:h,"aria-label":`Capabilities for ${t}`,title:`Capabilities for ${t}`,className:"pointer-events-none mr-0.5 flex h-4 w-4 shrink-0 translate-y-px self-center items-center justify-center rounded-sm text-muted-foreground/50 opacity-0 transition-all hover:bg-primary/10 hover:text-primary focus-visible:pointer-events-auto focus-visible:opacity-100 group-hover/project-row:pointer-events-auto group-hover/project-row:opacity-100",children:e.jsx(wa,{className:"h-2.5 w-2.5"})}),e.jsx("button",{type:"button",onClick:i,"aria-label":`New chat in ${t}`,title:`New chat in ${t}`,className:"pointer-events-none ml-auto flex h-4 w-4 shrink-0 translate-y-px self-center items-center justify-center rounded-sm text-muted-foreground/50 opacity-0 transition-all hover:bg-primary/10 hover:text-primary focus-visible:pointer-events-auto focus-visible:opacity-100 group-hover/project-row:pointer-events-auto group-hover/project-row:opacity-100",children:e.jsx(fs,{className:"h-2.5 w-2.5"})})]})}const er="meshy-task-sidebar-tree-state";function Qn(t){return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function As(){var t;try{return((t=globalThis.window)==null?void 0:t.localStorage)??globalThis.localStorage??null}catch{return null}}function Xn(t){if(!t)return{collapsedNodes:[],collapsedDirs:[]};try{const s=t.getItem(er);if(!s)return{collapsedNodes:[],collapsedDirs:[]};const n=JSON.parse(s);return{collapsedNodes:Qn(n.collapsedNodes),collapsedDirs:Qn(n.collapsedDirs)}}catch{return{collapsedNodes:[],collapsedDirs:[]}}}function Vd(t,s){if(t)try{t.setItem(er,JSON.stringify(s))}catch{}}function Jn(t,s){if(!t.has(s))return t;const n=new Set(t);return n.delete(s),n}function qd(t,s){if(!s)return null;for(const n of t){const r=n.nodeId??"__unassigned__";for(const o of n.dirs)if(o.tasks.some(i=>i.id===s))return{nodeKey:r,dirKey:`${r}::${o.path}`}}return null}function Zn(t,s,n){return n?{collapsedNodes:Jn(t,n.nodeKey),collapsedDirs:Jn(s,n.dirKey)}:{collapsedNodes:t,collapsedDirs:s}}function Kd(t,s,n){const r=t.filter(m=>m.status==="completed"),o=new Set((s?r:[...r].sort((m,v)=>v.updatedAt-m.updatedAt).slice(0,Js)).map(m=>m.id));n&&r.some(m=>m.id===n)&&o.add(n);const i=t.filter(m=>m.status!=="completed"||o.has(m.id)),h=r.length-o.size;return{visibleTasks:i,hiddenCompletedCount:Math.max(0,h)}}const Jt="h-6 rounded-sm border-border/70 bg-background/60 px-2 py-0 text-[10px] leading-none shadow-sm [&>svg]:h-3 [&>svg]:w-3",Zt="py-1 pl-6 pr-1.5 text-[10px] leading-4 [&_svg]:h-3 [&_svg]:w-3";function ea({toolbarTasks:t,activeTaskId:s,tasksLoading:n,tasksError:r,isLeader:o,scope:i,agentFilter:h,nodeFilter:m,taskKindFilter:v,agentOptions:p,nodeOptions:N,nodeNameById:u,nodeWorkDirById:l,nodeStatusById:k,completedGroupByKey:_,devBoxNodeIds:y=new Set,devBoxStartNodeIds:A=new Set,devBoxStartingNodeIds:g=new Set,leaderNodeId:b,searchQuery:x,selectedTaskIds:w,allVisibleTasksSelected:S,someVisibleTasksSelected:C,canBatchArchive:L,onSearchChange:Y,onScopeChange:q,onAgentFilterChange:V,onNodeFilterChange:I,onTaskKindFilterChange:J,onToggleTaskSelected:W,onToggleAllVisibleTasks:R,onBatchArchive:$,onBatchDelete:ae,onCreateTask:ee,onOpenNodeSettings:oe,onOpenNodeCapabilities:te,onOpenProjectCapabilities:T,onOpenDevBox:O,onStartDevBox:d,onLoadCompletedTasks:U,onSelectTask:f,onClose:Q}){const[E,z]=a.useState(!!x),[j,D]=a.useState(!1),[F,ne]=a.useState(!1),X=a.useRef(null),se=a.useRef(null),de=a.useRef(null),[Ne,H]=a.useState(()=>w.size>0),{markScrollbarActive:ce,scrollbarActive:_e}=Qa(),ye=w.size,Be=!!(o&&(Ne||ye>0)),Ge=i!=="active"||m!=="all"||h!=="all"||v!=="all",De=x.trim().length>0,[re,ge]=a.useState(()=>new Set(Xn(As()).collapsedNodes)),[Pe,$e]=a.useState(()=>new Set(Xn(As()).collapsedDirs)),[ht,je]=a.useState(new Set),Te=a.useMemo(()=>vo(t,u,b,l),[t,u,b,l]),Le=a.useMemo(()=>qd(Te,s),[Te,s]),pt=a.useRef(null),Xe=Te.length===1,lt=Te.length>0,vt=Xe&&(Ge||De),jt=!!(o&&(Te.length>0||ye>0)),it=a.useCallback(B=>{ge(we=>{const he=new Set(we);return he.has(B)?he.delete(B):he.add(B),he})},[]),Ue=a.useCallback(B=>{$e(we=>{const he=new Set(we);return he.has(B)?he.delete(B):he.add(B),he})},[]),wt=a.useCallback(B=>{je(we=>{const he=new Set(we);return he.add(B),he})},[]);a.useEffect(()=>{Vd(As(),{collapsedNodes:Array.from(re),collapsedDirs:Array.from(Pe)})},[Pe,re]),a.useEffect(()=>{if(!Le||!s)return;const B=`${s}:${Le.nodeKey}:${Le.dirKey}`;pt.current!==B&&(pt.current=B,ge(we=>Zn(we,new Set,Le).collapsedNodes),$e(we=>Zn(new Set,we,Le).collapsedDirs))},[s,Le]);const Ae=a.useCallback(B=>{H(!0),R(B)},[R]),dt=a.useCallback(()=>{R(!1),H(!1)},[R]);a.useEffect(()=>{o||H(!1)},[o]),a.useEffect(()=>{x&&z(!0)},[x]),a.useEffect(()=>{var B;E&&((B=X.current)==null||B.focus())},[E]),a.useEffect(()=>{if(!E)return;const B=he=>{var Je;const Oe=he.target;Oe instanceof Node&&((Je=se.current)!=null&&Je.contains(Oe)||z(!1))},we=he=>{he.key==="Escape"&&z(!1)};return document.addEventListener("mousedown",B),document.addEventListener("keydown",we),()=>{document.removeEventListener("mousedown",B),document.removeEventListener("keydown",we)}},[E]),a.useEffect(()=>{if(!F)return;const B=he=>{var Je;const Oe=he.target;Oe instanceof Node&&((Je=de.current)!=null&&Je.contains(Oe)||ne(!1))},we=he=>{he.key==="Escape"&&ne(!1)};return document.addEventListener("mousedown",B),document.addEventListener("keydown",we),()=>{document.removeEventListener("mousedown",B),document.removeEventListener("keydown",we)}},[F]);const Nt=Be?e.jsxs("label",{className:"flex items-center gap-[5px] text-[9px] font-medium uppercase tracking-[0.12em] text-muted-foreground/75",children:[e.jsx(Ut,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:C&&!S?"indeterminate":S,onCheckedChange:B=>Ae(B===!0),"aria-label":"Select all visible tasks"}),e.jsx("span",{children:"Multi select"})]}):e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>H(!0),className:"h-5 rounded-sm px-1.5 text-[9px] font-medium uppercase tracking-[0.12em] text-muted-foreground/75 hover:text-foreground",children:[e.jsx(ji,{className:"h-3 w-3"}),"Multi select"]}),yt=ye>0?e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"text-[9px] font-semibold leading-3 text-foreground",children:[ye," task",ye!==1?"s":""," selected"]}),!L&&e.jsx("div",{className:"max-w-48 text-[9px] leading-3.5 text-muted-foreground",children:"Only completed, failed, cancelled, or archived tasks can be archived."})]}):null,ft=ye>0?e.jsxs("div",{className:"flex flex-wrap justify-end gap-1",children:[e.jsxs(as,{children:[e.jsx(Ls,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",disabled:!L,className:"h-5 gap-1 rounded-sm bg-muted/45 px-1.5 text-[8px] text-foreground/80 shadow-none hover:bg-muted/65 [&_svg]:size-3",children:[e.jsx(_i,{}),"Archive"]})}),e.jsxs(rs,{children:[e.jsxs(os,{children:[e.jsxs(is,{children:["Archive ",ye," task",ye!==1?"s":"","?"]}),e.jsx(ls,{children:"Archived tasks stay hidden from the default task view and can be reopened from the archived scope."})]}),e.jsxs(ds,{children:[e.jsx(cs,{children:"Cancel"}),e.jsx(us,{onClick:$,disabled:!L,children:"Archive"})]})]})]}),e.jsxs(as,{children:[e.jsx(Ls,{asChild:!0,children:e.jsxs(G,{variant:"destructive",size:"sm",className:"h-5 gap-1 rounded-sm px-1.5 text-[8px] [&_svg]:size-3",children:[e.jsx($a,{}),"Delete"]})}),e.jsxs(rs,{children:[e.jsxs(os,{children:[e.jsxs(is,{children:["Delete ",ye," task",ye!==1?"s":"","?"]}),e.jsx(ls,{children:"This removes the selected tasks and their saved logs."})]}),e.jsxs(ds,{children:[e.jsx(cs,{children:"Cancel"}),e.jsx(us,{onClick:ae,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]}):null;return e.jsxs("aside",{className:"dashboard-task-sidebar dashboard-panel dashboard-panel-muted animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsxs("div",{className:"dashboard-task-sidebar__header shrink-0 border-b border-border/55 bg-card/24 px-2.5 py-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-sm font-semibold tracking-tight text-foreground",children:"Tasks"}),e.jsx(G,{variant:"ghost",size:"icon",onClick:Q,className:"h-6 w-6 rounded-sm",children:e.jsx(Ia,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{ref:se,className:"mt-2 flex items-center gap-1.5",children:[e.jsxs("div",{ref:de,className:M("relative flex items-stretch transition-[flex] duration-200",E?"flex-[2]":"flex-1"),children:[e.jsxs(G,{onClick:()=>{ne(!1),ee("chat")},className:"h-8 flex-1 justify-start rounded-l-sm rounded-r-none px-2.5 text-left text-[11px] shadow-[0_10px_24px_-18px_hsl(var(--primary)/0.9)]",children:[e.jsx(fs,{className:"h-3.5 w-3.5"}),"New chat"]}),e.jsx(G,{onClick:()=>ne(B=>!B),"aria-label":"More chat options","aria-haspopup":"menu","aria-expanded":F,className:"h-8 w-7 rounded-l-none rounded-r-sm border-l border-primary-foreground/20 px-0 shadow-[0_10px_24px_-18px_hsl(var(--primary)/0.9)]",children:e.jsx(Qe,{className:M("h-3 w-3 transition-transform",F&&"rotate-180")})}),F&&e.jsx("div",{role:"menu",className:"absolute left-0 right-0 top-full z-20 mt-2 overflow-hidden rounded-lg border border-border/60 bg-popover/96 p-1 shadow-[0_20px_60px_-30px_rgba(0,0,0,0.45)] backdrop-blur-xl",children:e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{ne(!1),ee("native")},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-2 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(sn,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{className:"flex-1 truncate whitespace-nowrap",children:"Load session"}),e.jsx("span",{className:"shrink-0 text-[9px] uppercase tracking-[0.18em] text-muted-foreground",children:"native"})]})})]}),E?e.jsxs("div",{className:"flex min-w-0 flex-[3] items-center gap-1.5",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(ns,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(nt,{ref:X,value:x,onChange:B=>Y(B.target.value),placeholder:"Search tasks",className:"h-8 rounded-sm border-border/70 bg-background/68 pl-8 text-[11px] shadow-none"})]}),e.jsx(G,{variant:"outline",size:"icon",onClick:()=>z(!1),className:"h-8 w-8 rounded-sm border-border/70 bg-background/68 shadow-none",children:e.jsx(ts,{className:"h-3.5 w-3.5"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(G,{variant:"outline",onClick:()=>z(!0),className:M("h-8 rounded-sm border-border/70 bg-background/68 px-2.5 text-[11px] shadow-none",x&&"border-primary/40 bg-primary/8 text-primary"),children:[e.jsx(ns,{className:"h-3.5 w-3.5"}),"Search"]}),e.jsx(G,{variant:j||Ge?"secondary":"outline",size:"icon",onClick:()=>D(B=>!B),className:M("h-8 w-8 shrink-0 rounded-sm border-border/70 bg-background/68 shadow-none",Ge&&"border-primary/40 bg-primary/8 text-primary"),title:"Filters",children:e.jsx(Oi,{className:"h-3.5 w-3.5"})})]})]}),(j||Ge)&&e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-1 sm:grid-cols-2",children:[e.jsxs(Se,{value:i,onValueChange:B=>q(B),children:[e.jsx(Ce,{className:Jt,children:e.jsx(Ie,{})}),e.jsx(Ee,{children:jo.map(B=>e.jsx(xe,{value:B.value,className:Zt,children:B.label},B.value))})]}),e.jsxs(Se,{value:m,onValueChange:I,children:[e.jsx(Ce,{className:Jt,children:e.jsx(Ie,{placeholder:"Node"})}),e.jsx(Ee,{children:N.map(B=>e.jsx(xe,{value:B.value,className:Zt,children:B.label},B.value))})]}),e.jsxs(Se,{value:h,onValueChange:V,children:[e.jsx(Ce,{className:Jt,children:e.jsx(Ie,{placeholder:"Agent"})}),e.jsx(Ee,{children:p.map(B=>e.jsx(xe,{value:B,className:Zt,children:B==="all"?"All agents":B},B))})]}),e.jsxs(Se,{value:v,onValueChange:B=>J(B),children:[e.jsx(Ce,{className:Jt,children:e.jsx(Ie,{placeholder:"Type"})}),e.jsx(Ee,{children:wo.map(B=>e.jsx(xe,{value:B.value,className:Zt,children:B.label},B.value))})]})]})]}),e.jsx("div",{className:M("scrollbar-line min-h-0 flex-1 overflow-y-auto px-1.5 py-2",_e&&"scrollbar-line-active"),onScroll:ce,children:Te.length>0?e.jsx("div",{className:"space-y-1",children:Te.map(B=>{const we=B.nodeId??"__unassigned__",he=B.dirs.reduce((Me,Ve)=>Me+Ve.tasks.length,0),Oe=lt&&!vt&&re.has(we),Je=B.nodeId!==null&&k.get(B.nodeId)==="offline",kt=!!(o&&B.nodeId&&oe);return e.jsxs("div",{className:"space-y-1",children:[lt&&e.jsxs("div",{className:"flex w-full items-stretch rounded-sm bg-gradient-to-r from-primary/8 to-muted/20 text-left text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground transition-all duration-150 hover:from-primary/12 hover:to-muted/30 hover:text-foreground active:scale-[0.99] active:from-primary/15",children:[e.jsxs("button",{type:"button",onClick:()=>it(we),"aria-expanded":!Oe,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm px-2 py-1.5 text-left",children:[e.jsx(xt,{className:M("h-3.5 w-3.5 shrink-0 transition-transform duration-200",!Oe&&"rotate-90")}),e.jsx(pa,{className:"h-3 w-3 shrink-0 text-muted-foreground/55"}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:B.nodeName}),e.jsxs(He,{variant:"outline",className:"shrink-0 whitespace-nowrap rounded-sm border-transparent bg-background/55 px-1.5 py-0 text-[7px] font-semibold leading-3.5 text-muted-foreground shadow-none normal-case tracking-normal",children:[he," task",he===1?"":"s"]})]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[Je&&e.jsx(He,{variant:"outline",className:"rounded-sm border-destructive/25 bg-destructive/10 px-1 py-0 text-[8px] font-semibold leading-3 text-destructive shadow-none",children:"offline"}),B.nodeId===b&&e.jsx(He,{variant:"outline",className:"rounded-sm border-transparent bg-primary/8 px-1 py-0 text-[8px] font-medium leading-3.5 text-primary shadow-none",children:"leader"})]})]}),kt&&B.nodeId&&oe&&e.jsx("span",{className:"flex shrink-0 items-center pr-1.5",children:e.jsx(ln,{nodeId:B.nodeId,nodeName:B.nodeName,onOpenSettings:oe,onOpenCapabilities:te,onOpenDevBox:O,onStartDevBox:d,showConfigureDevBox:y.has(B.nodeId),showStartDevBox:A.has(B.nodeId)||g.has(B.nodeId),startDevBoxPending:g.has(B.nodeId)})})]}),e.jsx("div",{className:M("grid transition-[grid-template-rows] duration-300 ease-in-out",Oe?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:"overflow-hidden",children:B.dirs.map(Me=>{const Ve=`${we}::${Me.path}`,ct=Pe.has(Ve),gt=Ca(Me.path),ie=_==null?void 0:_.get(Ve),ke=ie?{visibleTasks:Me.tasks,hiddenCompletedCount:Math.max(0,ie.total-ie.returned)}:Kd(Me.tasks,ht.has(Ve),s),{visibleTasks:qe,hiddenCompletedCount:Ze}=ke;return e.jsxs("div",{className:M("space-y-0.5 rounded-xl",lt&&"pl-2.5"),children:[e.jsx(Ud,{dirPath:Me.path,label:gt,taskCount:Me.tasks.length,collapsed:ct,onToggle:()=>Ue(Ve),onCreateTask:()=>ee("chat",{assignTo:B.nodeId,project:Me.path==="default workspace"?"":Me.path}),onOpenCapabilities:B.nodeId&&T?()=>T(B.nodeId,Me.path==="default workspace"?(l==null?void 0:l.get(B.nodeId))??Me.path:Me.path):void 0}),e.jsx("div",{className:M("grid transition-[grid-template-rows] duration-300 ease-in-out",ct?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:M("overflow-hidden",lt?"pl-2":"pl-0"),children:e.jsxs("div",{className:"space-y-px py-0.5",children:[qe.map(be=>{const St=be.id===s,Ct=be.assignedTo?k.get(be.assignedTo):void 0,Ke=!!be.assignedTo&&(Ct?Ct==="offline":be.assignedNodeAvailable===!1);return e.jsxs("div",{className:M("animate-task-row-reveal relative flex items-center gap-1.5 rounded-sm px-2 py-1.5 transition-all duration-150",St?'bg-primary/10 before:absolute before:left-0 before:top-1/2 before:h-1/2 before:w-[2px] before:-translate-y-1/2 before:rounded-full before:bg-primary before:content-[""]':"hover:bg-muted/40"),children:[Be&&e.jsx("div",{className:"flex shrink-0",onClick:ze=>ze.stopPropagation(),children:e.jsx(Ut,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:w.has(be.id),onCheckedChange:ze=>W(be.id,ze===!0),"aria-label":`Select ${be.title}`})}),e.jsxs("button",{type:"button",onClick:()=>f(be.id),"aria-current":St?"page":void 0,className:"relative min-w-0 flex-1 pr-8 text-left",children:[e.jsx("div",{className:"flex items-center gap-1.5 pr-1",children:e.jsx("span",{className:M("min-w-0 flex-1 truncate text-[10px] font-medium leading-4",St?"text-foreground":"text-foreground/80"),children:be.title})}),e.jsx("span",{className:M("absolute right-0 top-0 shrink-0 tabular-nums text-[8px] leading-4",St?"text-primary/75":"text-muted-foreground/55"),children:No(be.updatedAt)}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-0.5",children:[e.jsx("span",{className:"rounded-sm bg-muted/35 px-1 py-0 font-mono text-[8px] leading-3 text-muted-foreground/65",children:be.agent}),be.activeShare&&e.jsx(He,{variant:"outline",className:"rounded-sm border-primary/25 bg-primary/8 px-1 py-0 text-[8px] leading-3 text-primary shadow-none",children:"shared"}),Ke&&e.jsx(He,{variant:"outline",className:"rounded-sm border-destructive/25 bg-destructive/8 px-1 py-0 text-[8px] leading-3 text-destructive shadow-none",children:"unavailable"})]}),e.jsx(va,{status:be.status,isNative:be.conversationKind==="nativeSession",size:"compact",className:"absolute bottom-1 right-0"})]})]},be.id)}),Ze>0&&e.jsxs("button",{type:"button",onClick:()=>{ie&&U?U(ie):wt(Ve)},className:"mt-1 flex w-full items-center justify-center gap-1 rounded-sm border border-dashed border-border/55 bg-background/35 px-2 py-1 text-[9px] font-medium text-muted-foreground transition-colors hover:border-primary/35 hover:bg-primary/8 hover:text-primary","aria-label":`Load ${Ze} more completed tasks in ${gt}`,children:[e.jsx(Qe,{className:"h-3 w-3"}),"Load ",Ze," more completed"]})]})})})]},Ve)})})})]},we)})}):n?e.jsx("div",{className:"space-y-2 px-1",children:[1,2,3].map(B=>e.jsx("div",{className:"rounded-xl border border-border/40 bg-background/30 px-3 py-3",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"mt-1 h-2.5 w-2.5 shrink-0 animate-pulse rounded-full bg-muted-foreground/20"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-2.5 animate-pulse rounded-full bg-muted-foreground/15",style:{width:`${60+B*12}%`,animationDelay:`${B*120}ms`}}),e.jsx("div",{className:"h-2 w-24 animate-pulse rounded-full bg-muted-foreground/10",style:{animationDelay:`${B*120+60}ms`}})]})]})},B))}):e.jsx("div",{className:"rounded-xl border border-dashed border-border/70 bg-background/35 px-3 py-5 text-[11px] text-muted-foreground",children:r||"No tasks match this view."})}),jt?e.jsx("div",{className:"shrink-0 px-2.5 pb-2.5 pt-1.5",children:Be&&ye>0?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[yt,e.jsx(G,{variant:"ghost",size:"sm",onClick:dt,className:"h-5 shrink-0 rounded-sm px-1.5 text-[9px]",children:"Clear"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"flex min-w-0 shrink-0 items-center",children:Nt}),ft]})]}):e.jsxs("div",{className:"flex items-end justify-between gap-2",children:[e.jsx("div",{className:"flex min-w-0 shrink-0 items-center",children:Nt}),Be&&e.jsx(G,{variant:"ghost",size:"sm",onClick:dt,className:"h-5 shrink-0 rounded-sm px-1.5 text-[9px]",children:"Done"})]})}):null]})}async function Wd(t,s){var n,r;try{const o=await yo(t,s),i={...o,url:ga(o.url)};if((r=(n=globalThis.navigator)==null?void 0:n.clipboard)!=null&&r.writeText)try{await globalThis.navigator.clipboard.writeText(i.url),le.success("Shared link copied")}catch{le.success("Shared link created")}else le.success("Shared link created");return i}catch(o){le.error(o instanceof Error?o.message:"Failed to create shared link");return}}async function Gd(t){try{return await ko(t),le.success("Shared link stopped"),!0}catch(s){return le.error(s instanceof Error?s.message:"Failed to stop shared link"),!1}}function Yd(t,s,n){const r=a.useCallback(()=>{s(),n()},[s,n]),o=a.useCallback(async h=>{if(!t)return;const m=await Wd(t.id,h);return m&&r(),m},[t,r]),i=a.useCallback(async()=>{if(!t)return!1;const h=await Gd(t.id);return h&&r(),h},[t,r]);return{handleShareTask:o,handleStopShareTask:i}}function ta(t,s,n){const r=a.useRef(s);r.current=s,a.useEffect(()=>{let h=0,m=0;const v=u=>{const l=u.touches[0];l&&(h=l.clientX,m=l.clientY)},p=u=>{var y,A,g,b;const l=u.changedTouches[0];if(!l)return;const k=l.clientX-h;Math.abs(l.clientY-m)>100||Math.abs(k)<50||(k>0?(A=(y=r.current).onSwipeRight)==null||A.call(y):(b=(g=r.current).onSwipeLeft)==null||b.call(g))},N=(t==null?void 0:t.current)??document;return N.addEventListener("touchstart",v,{passive:!0}),N.addEventListener("touchend",p,{passive:!0}),()=>{N.removeEventListener("touchstart",v),N.removeEventListener("touchend",p)}},[t,n==null?void 0:n.threshold,n==null?void 0:n.maxVertical])}const Qd="(min-width: 1024px)",Xd="(min-width: 1800px)";function sa(t){var s,n,r;return((r=(n=(s=globalThis.window)==null?void 0:s.matchMedia)==null?void 0:n.call(s,t))==null?void 0:r.matches)??!1}function Jd(){var n,r;const t=(n=globalThis.document)==null?void 0:n.documentElement;if(!t||!((r=globalThis.window)!=null&&r.getComputedStyle))return 16;const s=Number.parseFloat(globalThis.window.getComputedStyle(t).fontSize);return Number.isFinite(s)&&s>0?s:16}function Zd(){const[t,s]=a.useState(()=>So(Cn(),Co({operationsOpen:sa(Xd)}))),[n,r]=a.useState(!1),o=a.useRef(null),i=a.useRef(null),h=a.useRef(null),m=t.layout.desktopTasksOpen,v=t.layout.operationsOpen,p=t.sizes;a.useEffect(()=>{Eo(Cn(),t)},[t]);const N=a.useCallback((A,g)=>{s(b=>{const x=b.layout[A],w=typeof g=="function"?g(x):g;return w===x?b:{...b,layout:{...b.layout,[A]:w}}})},[]),u=a.useCallback(A=>{N("desktopTasksOpen",A)},[N]),l=a.useCallback(A=>{N("operationsOpen",A)},[N]);ta(i,{onSwipeLeft:()=>r(!1)}),ta(h,{onSwipeRight:()=>l(!1)});const k=a.useCallback(()=>{if(sa(Qd)){u(A=>!A);return}r(A=>!A)},[u]);a.useEffect(()=>{var b,x,w;const A=S=>{const C=o.current;if(!C)return;S.preventDefault();const L=To(C.panel,C.startSize,C.startClientX,C.startClientY,S.clientX,S.clientY,C.rootFontSize);s(Y=>({...Y,sizes:{...Y.sizes,[C.panel]:L}}))},g=()=>{o.current=null};return(b=globalThis.window)==null||b.addEventListener("pointermove",A),(x=globalThis.window)==null||x.addEventListener("pointerup",g),(w=globalThis.window)==null||w.addEventListener("pointercancel",g),()=>{var S,C,L;(S=globalThis.window)==null||S.removeEventListener("pointermove",A),(C=globalThis.window)==null||C.removeEventListener("pointerup",g),(L=globalThis.window)==null||L.removeEventListener("pointercancel",g)}},[]);const _=a.useCallback((A,g)=>{var b,x;g.preventDefault(),(x=(b=g.currentTarget).setPointerCapture)==null||x.call(b,g.pointerId),o.current={panel:A,startSize:p[A],startClientX:g.clientX,startClientY:g.clientY,rootFontSize:Jd()}},[p]),y=a.useCallback((A,g)=>{g.preventDefault(),s(b=>({...b,sizes:{...b.sizes,[A]:_o(A,b.sizes[A],g.deltaY)}}))},[]);return{desktopTasksOpen:m,mobileTasksPanelOpen:n,mobileTasksPanelRef:i,operationsOpen:v,operationsPanelRef:h,panelResize:{sizes:{tasks:Ss(p.tasks),operations:Ss(p.operations),terminal:Ss(p.terminal)},onPointerDown:_,onWheel:y},setMobileTasksPanelOpen:r,setOperationsOpen:l,toggleTasksPanel:k}}function ec(t,s){const n=s.taskId,r=s.updates;return typeof n!="string"||!r||typeof r!="object"?t:t.map(o=>o.id===n?{...o,...r}:o)}function tc({isLeader:t,selfId:s}){return{...!t&&s?{assignedTo:s}:{},completedLimitPerProject:Js}}function Ws(t){return`${t.assignedTo??"__unassigned__"}::${t.projectPath}`}function sc(t,s){const n=new Map(t.map(r=>[r.id,r]));for(const r of s)n.set(r.id,r);return Array.from(n.values())}function nc(t,s,n=new Set){return!s||n.has(s.id)||t.some(r=>r.id===s.id)?t:Fa(t,s)}function ac({isLeader:t,selfId:s,sseConnected:n,preservedTask:r,subscribe:o}){const[i,h]=a.useState([]),[m,v]=a.useState([]),[p,N]=a.useState(!0),[u,l]=a.useState(null),k=a.useRef(new Set),_=a.useRef(null),y=a.useCallback(async()=>{try{const x=await En(tc({isLeader:t,selfId:s}));h(nc(x.tasks,r,k.current)),v(x.completedGroups??[]),l(null)}catch(x){l(x instanceof Error?x.message:"Failed to load tasks")}finally{N(!1)}},[t,r,s]),A=a.useCallback(async x=>{if(!x.hasMore||!x.nextCursor)return;const w=await En({status:"completed",assignedTo:x.assignedTo??"__unassigned__",projectPath:x.projectPath,cursor:x.nextCursor,limit:Js});h(S=>sc(S,w.tasks)),v(S=>S.map(C=>Ws(C)===Ws(x)?{...C,returned:Math.min(C.total,C.returned+w.tasks.length),hasMore:w.hasMore===!0,nextCursor:w.nextCursor??null}:C))},[]),g=a.useCallback(()=>{_.current===null&&(_.current=window.setTimeout(()=>{_.current=null,y()},Do))},[y]),b=a.useCallback(x=>{const w=new Set(x);if(w.size!==0){for(const S of w)k.current.add(S);h(S=>S.filter(C=>!w.has(C.id)))}},[]);return Ao(y,Lo(n)),a.useEffect(()=>()=>{_.current!==null&&(window.clearTimeout(_.current),_.current=null)},[]),a.useEffect(()=>{const x=[o("task.updated",w=>{h(S=>ec(S,w.data))}),o("task.status",w=>{h(S=>Mo(S,w.data))}),o("node",w=>{_n(w.type)&&g()}),o("task",w=>{if(w.type==="task.deleted"){const S=w.data.taskId;typeof S=="string"&&k.current.add(S),h(C=>Po(C,w.data))}_n(w.type)&&g()})];return()=>x.forEach(w=>w())},[o,g]),{completedGroups:m,fetchTasks:y,loadCompletedTasksPage:A,removeTasksFromList:b,setTasks:h,tasks:i,tasksError:u,tasksLoading:p}}function tr(t){return t.map(s=>({...s}))}function rc(t,s){const n=s.get(t);return{logs:n?tr(n.logs):[],transcriptLoading:(n==null?void 0:n.loaded)!==!0}}function oc(t,s){return s.data.nodeId===t.self.id||s.data.name===t.self.name||s.data.endpoint===t.self.endpoint}function ic({cluster:t,subscribe:s}){a.useEffect(()=>{var n;if(((n=t==null?void 0:t.self)==null?void 0:n.role)==="leader")return s("node",r=>{const o=String(r.data.name??r.data.nodeId??"node"),i=oc(t,r);r.type==="node.joined"&&!i&&le.success(`${o} joined the cluster`),r.type==="node.left"&&!i&&le.message(`${o} left the cluster`)})},[t,s])}const lc=[0,300,1e3,2e3];function dc({task:t,getActiveTaskId:s,setLogs:n,setPendingMessages:r,setTranscriptLoading:o}){t.conversationKind==="nativeSession"&&(async()=>{try{for(const i of lc){if(i>0&&await new Promise(h=>setTimeout(h,i)),s()!==t.id)return;try{const h=await Is(t.id);if(s()!==t.id||(n(m=>Pa(m,h.logs)),r(m=>Rs(m,h.logs)),h.total>0))return}catch{}}}finally{s()===t.id&&(o==null||o(!1))}})()}function cc(t,s){return Re(t??{})===Re(s??{})}function uc(t){return t&&"status"in t&&typeof t.status=="string"?t.status:void 0}function na(t,s){return{...t,enabled:!0,alwaysOnline:s}}function sr(t){var s,n;return((s=t==null?void 0:t.status)==null?void 0:s.trim())||((n=t==null?void 0:t.lastStatus)==null?void 0:n.trim())||"Unknown"}function mc({operationStarting:t,loading:s,refreshing:n,savedStatus:r,fallbackStatus:o}){return t?"Starting":s?"Listing DevBoxes":n?"Refreshing":r??o}function aa({devbox:t,showStatus:s=!1}){return e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[e.jsx("span",{className:"font-medium",children:t.name}),t.projectName&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",t.projectName]})]}),s&&e.jsx("span",{className:"ml-auto shrink-0 rounded-full border border-border/70 bg-background/70 px-1.5 py-0.5 text-[10px] leading-none text-muted-foreground",children:sr(t)})]})}function xc({node:t,open:s,startInProgress:n=!1,onOpenChange:r,onRefresh:o}){const i=(t==null?void 0:t.id)??null,h=s&&!n&&Wn(t==null?void 0:t.status,(t==null?void 0:t.devbox)??null),[m,v]=a.useState([]),[p,N]=a.useState(()=>t!=null&&t.devbox?Re(t.devbox):""),[u,l]=a.useState(()=>(t==null?void 0:t.devbox)??null),[k,_]=a.useState(()=>Gn((t==null?void 0:t.devbox)??null)),[y,A]=a.useState(!1),[g,b]=a.useState(h),[x,w]=a.useState(!1),[S,C]=a.useState(!1),[L,Y]=a.useState(()=>{var j;return((j=t==null?void 0:t.devbox)==null?void 0:j.alwaysOnline)===!0}),q=a.useMemo(()=>{const j=m.find(D=>Re(D)===p);return j||(Mt(u)&&Re(u)===p?u:void 0)},[u,m,p]),V=uc(q??void 0),I=k?V??(u==null?void 0:u.lastStatus):(u==null?void 0:u.lastStatus)??V,J=(t==null?void 0:t.status)==="online"||(t==null?void 0:t.status)==="busy"?"Running":"Unknown",W=S||n,R=mc({operationStarting:W,loading:y,refreshing:g,savedStatus:I,fallbackStatus:J}),$=k&&!!q&&!cc(u,q),ae=(u==null?void 0:u.alwaysOnline)===!0!==L,ee=$d({nodeStatus:t==null?void 0:t.status,status:R,current:u,selected:q}),oe=!!ee,te=!!q&&($||ae)&&!oe,T=q??u,O=a.useCallback(async()=>{if(i){b(!0);try{const j=await Io(i);l(j.devbox),N(Re(j.devbox))}catch(j){le.error(j instanceof Error?j.message:"Failed to refresh DevBox status")}finally{b(!1)}}},[i]),d=a.useCallback(async j=>{A(!0);try{const D=await Bo();v(D),N(F=>Od({previousKey:F,baseDevBox:j,listed:D}))}catch(D){le.error(D instanceof Error?D.message:"Failed to load DevBoxes")}finally{A(!1)}},[]);a.useEffect(()=>{if(!s||!i)return;let j=!1;const D=(t==null?void 0:t.devbox)??null,F=Gn(D),ne=!n&&Wn(t==null?void 0:t.status,D);A(!1),b(ne),_(F),l(D),Y((D==null?void 0:D.alwaysOnline)===!0),N(Mt(D)?Re(D):""),v([]);async function X(){ne&&await O(),!j&&F&&await d(D)}return X(),()=>{j=!0}},[d,t==null?void 0:t.devbox,t==null?void 0:t.status,i,s,O,n]);async function U(){_(!0),m.length===0&&await d(u)}async function f(){if(!(!t||!q)){w(!0);try{const j=await Tn(t.id,na(q,L));l(j.node.devbox??null),j.node.devbox&&N(Re(j.node.devbox)),_(!1),le.success(`Configured DevBox for ${t.name}`),await(o==null?void 0:o())}catch(j){le.error(j instanceof Error?j.message:"Failed to configure DevBox")}finally{w(!1)}}}async function Q(){if(!(!t||!ee)){C(!0);try{if(q&&($||ae)){const D=await Tn(t.id,na(q,L));l(D.node.devbox??null),D.node.devbox&&N(Re(D.node.devbox)),_(!1)}const{operation:j}=await _a(t.id);l(D=>D&&{...D,lastStatus:"Starting",checkedAt:Date.now(),operationId:j.id}),le.success(`Start requested for ${t.name}`),await(o==null?void 0:o())}catch(j){le.error(j instanceof Error?j.message:"Failed to start DevBox")}finally{C(!1)}}}const E=y?"Loading DevBoxes...":m.length===0?"No DevBoxes available":"Select a DevBox",z=R==="Running"&&(t==null?void 0:t.status)==="offline";return e.jsx(qt,{open:s,onOpenChange:r,children:e.jsxs(Kt,{className:"max-w-md gap-4 rounded-lg p-5",children:[e.jsxs(Xs,{className:"space-y-1",children:[e.jsx(ps,{className:"text-sm",children:"Configure DevBox"}),e.jsxs(Ea,{className:"text-xs",children:["Bind ",t!=null&&t.name?e.jsx("span",{className:"font-medium text-foreground",children:t.name}):"this node"," to an Azure Dev Box. Meshy will start it when the node is offline."]})]}),e.jsxs("div",{className:"space-y-3",children:[(k||T)&&e.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-3 rounded-xl border border-border/60 bg-muted/20 px-3 py-2 text-xs",children:[e.jsx("div",{className:"min-w-0 flex-1",children:k?e.jsxs(Se,{value:p,onValueChange:N,disabled:y||x||S||m.length===0,children:[e.jsx(Ce,{className:"h-7 justify-start gap-2 rounded-none border-0 bg-transparent px-0 text-xs shadow-none focus:ring-0 focus:ring-offset-0 [&>span]:!flex [&>span]:!min-w-0 [&>span]:!flex-1 [&>span]:!items-center",children:y&&!q?e.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ue,{className:"h-3.5 w-3.5 animate-spin"}),E]}):q?e.jsx(aa,{devbox:q}):e.jsx(Ie,{placeholder:E})}),e.jsx(Ee,{children:m.map(j=>e.jsx(xe,{value:Re(j),textValue:`${j.name} ${j.projectName??""} ${sr(j)}`,className:"pl-2 pr-7 text-xs [&>span:first-child]:left-auto [&>span:first-child]:right-2 [&>span:last-child]:w-full",children:e.jsx(aa,{devbox:j,showStatus:!0})},Re(j)))})]}):T&&e.jsxs("div",{className:"min-w-0 truncate",children:[e.jsx("span",{className:"font-medium text-foreground",children:T.name}),T.projectName&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",T.projectName]})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(He,{variant:"outline",className:"rounded-full px-2 py-0.5 text-[10px]",children:[(y||g)&&e.jsx(ue,{className:"mr-1 h-2.5 w-2.5 animate-spin"}),R]}),(u==null?void 0:u.name)&&e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{U()},disabled:y||x||W||k,"aria-label":"Edit DevBox binding",title:"Edit DevBox binding",className:"h-6 w-6 rounded-full text-muted-foreground hover:text-foreground",children:y&&k?e.jsx(ue,{className:"h-3 w-3 animate-spin"}):e.jsx(Lt,{className:"h-3 w-3"})})]})]}),z&&e.jsx("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300",children:"DevBox is running, but the Meshy node is not connected yet."}),e.jsxs("label",{className:"flex min-h-9 items-start gap-2 rounded-xl border border-border/60 bg-muted/20 px-3 py-2 text-xs text-foreground",children:[e.jsx(Ut,{checked:L,onCheckedChange:j=>Y(j===!0),disabled:x||S||W,"aria-label":"Always online",className:"mt-0.5 h-3.5 w-3.5"}),e.jsxs("span",{className:"min-w-0 leading-4",children:[e.jsx("span",{className:"block",children:"Always online"}),e.jsx("span",{className:"block text-[10px] leading-3.5 text-muted-foreground",children:"Meshy will start the DevBox automatically when it is Hibernated or Stopped."})]})]})]}),e.jsxs(ja,{className:"gap-2 sm:space-x-0",children:[e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:x||S,className:"h-8 rounded-xl text-xs",children:"Close"}),oe&&e.jsxs(G,{size:"sm",onClick:Q,disabled:S,className:"h-8 rounded-xl text-xs",children:[S?e.jsx(ue,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(en,{className:"h-3.5 w-3.5"}),"Start DevBox"]}),!oe&&e.jsxs(G,{size:"sm",onClick:f,disabled:!te||x,className:"h-8 rounded-xl text-xs",children:[x&&e.jsx(ue,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})})}async function hc(t,s=Ro){if(t.length===0)return new Set;const n=new Set(t),[r,o]=await Promise.all([s({kind:"devbox.start",status:"queued"}),s({kind:"devbox.start",status:"running"})]);return new Set([...r,...o].filter(i=>n.has(i.nodeId)).map(i=>i.nodeId))}function pc({cluster:t,refresh:s}){const[n,r]=a.useState(null),[o,i]=a.useState(null),[h,m]=a.useState(()=>new Set),[v,p]=a.useState(()=>new Set),N=a.useMemo(()=>(t==null?void 0:t.nodes.find(g=>g.id===n))??null,[t==null?void 0:t.nodes,n]),u=a.useMemo(()=>new Set(((t==null?void 0:t.nodes)??[]).filter(g=>{var b;return(b=g.devbox)==null?void 0:b.enabled}).map(g=>g.id)),[t==null?void 0:t.nodes]),l=a.useMemo(()=>new Set(((t==null?void 0:t.nodes)??[]).filter(g=>{var b;return gs(g.status,(b=g.devbox)==null?void 0:b.lastStatus,g.devbox)}).map(g=>g.id)),[t==null?void 0:t.nodes]),k=a.useMemo(()=>new Set(((t==null?void 0:t.nodes)??[]).filter(g=>{var b;return Pt((b=g.devbox)==null?void 0:b.lastStatus)}).map(g=>g.id)),[t==null?void 0:t.nodes]),_=a.useMemo(()=>{const g=new Set(h);o&&g.add(o);for(const b of v)g.add(b);for(const b of k)g.add(b);return g},[v,o,h,k]);a.useEffect(()=>{let g=!1;const b=[...u];async function x(){try{const w=await hc(b);g||p(w)}catch{g||p(new Set)}}return x(),()=>{g=!0}},[u]),a.useEffect(()=>{m(g=>{var w;let b=!1;const x=new Set(g);for(const S of g){const C=t==null?void 0:t.nodes.find(L=>L.id===S);(C==null?void 0:C.status)!=="online"&&(!((w=C==null?void 0:C.devbox)!=null&&w.lastStatus)||Pt(C.devbox.lastStatus))||(x.delete(S),b=!0)}return b?x:g})},[t==null?void 0:t.nodes]);const y=a.useCallback(async g=>{const b=t==null?void 0:t.nodes.find(x=>x.id===g);if(b){i(g),m(x=>new Set(x).add(g));try{await _a(g),le.success(`Start requested for ${b.name}`),s()}catch(x){m(w=>{const S=new Set(w);return S.delete(g),S}),le.error(x instanceof Error?x.message:"Failed to start DevBox")}finally{i(null)}}},[t==null?void 0:t.nodes,s]);return{devBoxDialog:e.jsx(xc,{node:N,open:n!==null,startInProgress:N?_.has(N.id):!1,onOpenChange:g=>{g||r(null)},onRefresh:s}),devBoxNodeIds:u,devBoxStartNodeId:o,devBoxStartNodeIds:l,devBoxStartingNodeIds:_,openDevBox:r,startDevBox:y}}function fc(t){const[s,n]=a.useState(null),r=a.useCallback(i=>{t&&n(i)},[t]);return{nodeSettingsDialog:e.jsx($o,{open:s!==null,onOpenChange:i=>{i||n(null)},initialSelectedNodeId:s??void 0,showTrigger:!1}),openNodeSettings:r}}function gc({activeTaskId:t,fetchActiveTask:s,setPendingMessages:n,setTask:r,setTasks:o}){const i=a.useCallback((v,p)=>{r(N=>N&&N.id===v?{...N,queuedMessages:p}:N),o(N=>N.map(u=>u.id===v?{...u,queuedMessages:p}:u))},[r,o]),h=a.useCallback(async v=>{if(!t)return!1;const p=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`;n(N=>[...N,{id:p,content:v,timestamp:new Date().toISOString()}]);try{const N=await Oo(t,v);return N.queued&&(n(u=>u.filter(l=>l.id!==p)),N.queuedMessages&&i(t,N.queuedMessages)),s(),!0}catch(N){return n(u=>u.filter(l=>l.id!==p)),le.error(N instanceof Error?N.message:"Failed to send message"),!1}},[t,s,n,i]);return{cancelQueuedMessage:a.useCallback(async v=>{if(t)try{const p=await zo(t,v);i(t,p.queuedMessages),s()}catch(p){le.error(p instanceof Error?p.message:"Failed to cancel queued message")}},[t,s,i]),queueFollowUpMessage:h}}const ra="grid-cols-[1.5rem_5.75rem_4rem_minmax(8rem,1fr)_4rem_4rem_6rem]",bc={claudecode:{icon:"C",label:"ClaudeCode"},codex:{icon:"X",label:"Codex"},copilot:{icon:"P",label:"Copilot"}};function vc(t,s){const n=s.search.trim().toLowerCase();return t.filter(r=>s.agent!=="all"&&r.agent!==s.agent||s.kind!=="all"&&r.kind!==s.kind?!1:n?[r.name,r.description,r.source,r.version,r.agent,r.kind].some(o=>o==null?void 0:o.toLowerCase().includes(n)):!0)}function nr(t){return t.kind==="mcp"?"-":t.sizeBytes<1024?`${t.sizeBytes} B`:t.sizeBytes<1024*1024?`${Math.round(t.sizeBytes/1024)} KB`:`${(t.sizeBytes/1024/1024).toFixed(1)} MB`}function jc({items:t,selectedIds:s,activeId:n,onToggleSelected:r,onOpenDetail:o}){return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-sm border border-border/55 bg-background/40",children:[e.jsxs("div",{className:M("grid shrink-0 gap-2 border-b border-border/55 px-2 py-1.5 text-[8px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",ra),children:[e.jsx("span",{}),e.jsx("span",{children:"Agent"}),e.jsx("span",{children:"Kind"}),e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Ver"}),e.jsx("span",{children:"Size"}),e.jsx("span",{children:"Source"})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:t.length>0?t.map(i=>e.jsxs("button",{type:"button",onClick:()=>o(i),className:M("grid h-7 w-full items-center gap-2 border-b border-border/30 px-2 text-left text-[10px] transition-colors hover:bg-muted/45",ra,n===i.id&&"bg-primary/8 text-primary"),children:[e.jsx("span",{onClick:h=>h.stopPropagation(),children:e.jsx(Ut,{className:"h-3 w-3",checked:s.has(i.id),onCheckedChange:h=>r(i.id,h===!0),"aria-label":`Select ${i.name}`})}),e.jsx(wc,{agent:i.agent}),e.jsx("span",{children:i.kind}),e.jsx("span",{className:"truncate font-medium text-foreground",children:i.name}),e.jsx("span",{className:"truncate text-muted-foreground",children:i.version??"-"}),e.jsx("span",{className:"truncate text-muted-foreground",children:nr(i)}),e.jsx("span",{className:"truncate text-muted-foreground",children:i.source??"local"})]},i.id)):e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-muted-foreground",children:"No capabilities match this view."})})]})}function wc({agent:t}){const{icon:s,label:n}=bc[t];return e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 text-[9px] font-medium leading-3 text-muted-foreground",children:[e.jsx("span",{"aria-hidden":"true",className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border border-border/60 bg-muted/35 text-[7px] font-semibold text-muted-foreground/90",children:s}),e.jsx("span",{className:"truncate",children:n})]})}const oa=320,ia=560,ar=384,la=360;function Nc(t,s=ia+la){const n=Math.max(oa,Math.min(ia,s-la));return Math.min(Math.max(Math.round(t),oa),n)}function yc(t,s,n,r){return Nc(t+s-n,r)}function kc({detail:t,deleting:s=!1,onDelete:n,desktopWidth:r=ar}){const o={"--capability-detail-width":`${r}px`};if(!t)return e.jsx("aside",{style:o,className:"hidden min-h-0 shrink-0 border-l border-border/55 bg-muted/18 px-3 py-3 text-[11px] text-muted-foreground lg:block lg:w-[var(--capability-detail-width)]",children:"Select a row to inspect metadata."});const i=t.kind==="mcp"?"mcp":"files";return e.jsxs("aside",{style:o,className:"flex min-h-0 w-full shrink-0 flex-col border-t border-border/55 bg-muted/18 px-3 py-3 lg:w-[var(--capability-detail-width)] lg:border-l lg:border-t-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-[13px] font-semibold leading-5 text-foreground",children:t.name}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap gap-1",children:[e.jsx(He,{variant:"secondary",className:"rounded-sm px-1.5 py-0 text-[9px]",children:t.agent}),e.jsx(He,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[9px]",children:t.kind})]})]}),n&&e.jsxs(as,{children:[e.jsx(Ls,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-sm text-muted-foreground hover:text-destructive","aria-label":"Delete capability",title:"Delete capability",disabled:s,children:e.jsx($a,{className:"h-3.5 w-3.5"})})}),e.jsxs(rs,{className:"max-w-[22rem] gap-2 rounded-xl p-4",children:[e.jsxs(os,{className:"space-y-1",children:[e.jsxs(is,{className:"text-sm",children:["Delete ",t.name,"?"]}),e.jsxs(ls,{className:"text-[11px] leading-4",children:["This removes the selected ",t.kind," from ",t.scope.kind==="global"?"the user profile":"this project","."]})]}),e.jsxs(ds,{className:"gap-1 pt-0 sm:space-x-1",children:[e.jsx(cs,{className:"h-7 rounded-lg px-2 text-[11px]",children:"Cancel"}),e.jsx(us,{className:"h-7 rounded-lg px-2 text-[11px]",onClick:n,disabled:s,children:"Delete"})]})]})]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-1.5 text-[10px]",children:[e.jsx(es,{label:"Version",value:t.version??"-"}),e.jsx(es,{label:"Size",value:nr(t)}),e.jsx(es,{label:"Files",value:String(t.fileCount)}),e.jsx(es,{label:"Source",value:t.source??"local"})]}),e.jsxs(Gs,{defaultValue:i,className:"mt-3 flex min-h-0 flex-1 flex-col",children:[e.jsxs(Ys,{className:"grid h-auto grid-cols-2 rounded-sm bg-muted/55 p-0.5",children:[t.kind==="mcp"?e.jsx(at,{value:"mcp",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"MCP"}):e.jsx(at,{value:"files",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Files"}),e.jsx(at,{value:"readme",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"README"})]}),t.kind==="mcp"?e.jsx(rt,{value:"mcp",className:"mt-2 min-h-0 flex-1 overflow-auto",children:e.jsx(Sc,{detail:t})}):e.jsx(rt,{value:"files",className:"mt-2 min-h-0 flex-1 overflow-auto",children:e.jsx(Cc,{detail:t})}),e.jsx(rt,{value:"readme",className:"mt-2 min-h-0 flex-1 overflow-auto",children:t.readmeMarkdown?e.jsx("pre",{className:"whitespace-pre-wrap rounded-sm border border-border/55 bg-background/62 p-2 text-[10px] leading-4 text-foreground shadow-none",children:t.readmeMarkdown}):e.jsx(dn,{children:"No README content."})})]},t.id)]})}function Sc({detail:t}){const s=t.mcpPreview??[];return s.length===0?e.jsx(dn,{children:"No MCP entries."}):e.jsx("div",{className:"space-y-1.5",children:s.map(n=>e.jsxs("div",{className:"rounded-sm border border-border/55 bg-background/62 p-2 text-[10px] shadow-none",children:[e.jsx("div",{className:"font-semibold text-foreground",children:n.serverName}),e.jsx("pre",{className:"mt-1 max-h-64 overflow-auto whitespace-pre-wrap break-all font-mono text-[9px] leading-4 text-muted-foreground",children:JSON.stringify(n.config,null,2)})]},n.serverName))})}function Cc({detail:t}){const s=t.fileTree??[];return s.length===0?e.jsx(dn,{children:"No files."}):e.jsx("div",{className:"space-y-1 overflow-auto rounded-sm border border-border/55 bg-background/62 p-2 font-mono text-[9px] leading-4 text-muted-foreground shadow-none",children:s.map(n=>e.jsx("div",{children:n.relPath},n.relPath))})}function dn({children:t}){return e.jsx("div",{className:"rounded-sm bg-background/45 px-2 py-6 text-center text-[10px] text-muted-foreground",children:t})}function es({label:t,value:s}){return e.jsxs("div",{className:"rounded-sm border border-border/55 bg-background/62 px-2 py-1 shadow-none",children:[e.jsx("div",{className:"text-[8px] uppercase tracking-[0.14em] text-muted-foreground",children:t}),e.jsx("div",{className:"truncate text-[10px] font-medium text-foreground",children:s})]})}const Ec=20,_c=288,Tc=360,Dc=440;function Ac(){if(typeof window>"u"||typeof document>"u")return 1;const t=window.getComputedStyle(document.documentElement),s=t.zoom||t.getPropertyValue("--ui-zoom"),n=Number.parseFloat(s);return Number.isFinite(n)&&n>0?n:1}function Mc({triggerRect:t,targetRect:s,viewportRect:n,compact:r,browserOpen:o=!1,portalAlign:i,cssZoom:h=1}){const m=Number.isFinite(h)&&h>0?h:1,v=8,p=n.top+v,N=n.bottom-v,u=n.left+v,l=n.right-v,k=Math.max(0,N-t.bottom-4),_=Math.max(0,t.top-p-4),y=r?_<140&&k>_:k>=220||k>=_,A=y?k:_,g=Math.max(140,N-p),b=r&&o,S=Math.min(g,b?Dc:320,Math.max(b?Tc:140,A)),C=_c*m,L=i==="end"?t.right-C:t.left,q=(Math.max(u,Math.min(L,l-C))-s.left)/m;if(!y&&!b)return{left:q,bottom:(s.bottom-(t.top-4))/m,maxHeight:S/m};const V=y?t.bottom+4:t.top-S-4,I=Math.max(p,Math.min(V,N-S));return{left:q,top:(I-s.top)/m,maxHeight:S/m}}function cn(t){if(!t.workDir)return[];const s=[],n=new Set,r=o=>{!o||n.has(o)||(n.add(o),s.push(o))};r(t.workDir);for(const o of t.workDirFolders??[])r(or(o)?o:ir(t.workDir,o));return s}function Pc(t,s){if(t.kind==="global")return{nodeId:s.id,scope:{kind:"global"}};const n=cn(s),r=n.find(o=>o===t.projectPath);return r?{nodeId:s.id,scope:{kind:"project",projectPath:r}}:n[0]?{nodeId:s.id,scope:{kind:"project",projectPath:n[0]}}:{nodeId:s.id,scope:{kind:"global"}}}function Lc(t,s){return{nodeId:t,scope:s}}function da(t,s,n){const r=s.trim();return!r||r==="."?t.workDir??r:n||or(r)?r:t.workDir?ir(t.workDir,r):r}function Ic({node:t,scope:s,clusterNodes:n,onSelectionChange:r}){const o=a.useMemo(()=>$c(n,t),[n,t]),i=a.useMemo(()=>cn(t),[t]),h=a.useMemo(()=>o.map(m=>({value:m.id,label:m.name,description:`${m.role} · ${m.status}`,status:m.status})),[o]);return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-2",children:[e.jsx(Rc,{ariaLabel:"Capability node",value:t.name,description:`${t.role} · ${t.status}`,options:h,selectedValue:t.id,onSelect:m=>{const v=o.find(p=>p.id===m);v&&(r==null||r(Pc(s,v)))}}),e.jsx(rr,{node:t,projectPaths:i,selectedScope:s,onSelect:m=>r==null?void 0:r(Lc(t.id,m))}),e.jsx(Bc,{node:t})]})}function Bc({node:t}){return e.jsxs("div",{"data-capability-node-meta":"true",className:"flex min-w-0 items-center gap-1.5 border-0 bg-transparent px-1 text-[9px] leading-3 text-muted-foreground",title:`${t.role} · ${t.status}`,children:[e.jsx("span",{className:"truncate capitalize",children:t.role}),e.jsx("span",{className:M("h-1.5 w-1.5 shrink-0 rounded-full",zt(t.status))})]})}function rr({node:t,projectPaths:s,selectedScope:n,onSelect:r,compact:o=!1,portal:i=!1,portalAlign:h="start"}){const[m,v]=a.useState(!1),[p,N]=a.useState(null),[u,l]=a.useState(!1),[k,_]=a.useState(!1),[y,A]=a.useState(null),[g,b]=a.useState(!1),[x,w]=a.useState(null),S=a.useRef(null),C=a.useRef(null),L=a.useRef(null),Y=a.useMemo(()=>s.map(T=>({value:T,label:ua(T),description:T})),[s]),q=n.kind==="project"?n.projectPath:void 0,V=n.kind==="global"?"Global":ua(n.projectPath),I=n.kind==="global"?"Global":n.projectPath,J=a.useCallback(()=>{var T;return!i||typeof document>"u"?null:((T=C.current)==null?void 0:T.closest('[data-capability-share-dialog="true"]'))??document.body},[i]),W=a.useCallback(()=>{if(!i||!C.current||typeof window>"u")return;const T=C.current.getBoundingClientRect(),O=J(),d=O&&O!==document.body?O.getBoundingClientRect():{left:0,top:0,bottom:window.innerHeight};w(Mc({triggerRect:T,targetRect:d,viewportRect:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight},compact:o,browserOpen:g,portalAlign:h,cssZoom:Ac()}))},[g,o,J,i,h]);a.useEffect(()=>{m||b(!1)},[m]),a.useEffect(()=>{if(!m)return;const T=O=>{if(!(O.target instanceof Node))return;const d=O.composedPath(),U=S.current?d.includes(S.current):!1,f=L.current?d.includes(L.current):O.target instanceof Element&&!!O.target.closest('[data-capability-scope-menu="true"]');!U&&!f&&v(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[m]),a.useEffect(()=>{if(!(!m||!i))return W(),window.addEventListener("resize",W),window.addEventListener("scroll",W,!0),()=>{window.removeEventListener("resize",W),window.removeEventListener("scroll",W,!0)}},[m,i,W]);const R=async(T,O=0,d=!1)=>{if(t.workDir){A(null),d?_(!0):l(!0);try{const U=await fa(t.id,{path:T||".",limit:Ec,offset:O,directoriesOnly:!0,allowAbsolute:!0});N(f=>d&&f?{...U,entries:[...f.entries,...U.entries]}:U)}catch(U){A(U instanceof Error?U.message:"Failed to browse folders"),d||N(null)}finally{l(!1),_(!1)}}};a.useEffect(()=>{!m||!g||!t.workDir||(N(null),A(null),R(q||"."))},[g,m,t.id,t.workDir,q]);const $=(T,O=!1)=>{r({kind:"project",projectPath:da(t,T,O)}),v(!1)},ae=()=>{r({kind:"global"}),v(!1)},ee=p?da(t,p.currentPath,p.isAbsolute):q??t.workDir??"",oe=i?J():null,te=e.jsxs("div",{ref:L,"data-capability-scope-menu":"true","aria-hidden":!m,onClick:T=>T.stopPropagation(),onMouseDown:T=>T.stopPropagation(),onPointerDown:T=>T.stopPropagation(),style:i&&x?{left:x.left,top:x.top,bottom:x.bottom,height:o&&g?x.maxHeight:void 0,maxHeight:x.maxHeight}:void 0,className:M(i?"absolute z-[80] flex w-72 flex-col overflow-hidden rounded-lg border border-border/70 bg-popover text-popover-foreground shadow-none pointer-events-auto":"absolute left-0 z-50 flex max-h-[28rem] w-72 flex-col overflow-hidden rounded-lg border border-border/70 bg-popover text-popover-foreground shadow-none",!i&&(o?"top-7":"top-9"),!m&&"hidden"),children:[e.jsxs("div",{className:"shrink-0 border-b border-border/55 p-1",children:[e.jsx("div",{className:M("px-2 text-[8px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",o?"pb-0.5 pt-0.5 leading-3":"pb-1 pt-1"),children:"Scope"}),e.jsxs("div",{className:M("overflow-y-auto",o?"max-h-[4.5rem]":"max-h-28"),children:[e.jsx(ca,{label:"Global",selected:n.kind==="global",onSelect:ae,compact:o}),Y.length>0?Y.map(T=>e.jsx(ca,{label:T.label,description:T.description,selected:q===T.value,onSelect:()=>$(T.value,!0),compact:o},T.value)):e.jsx("div",{className:"px-2 py-2 text-[10px] text-muted-foreground",children:"No known projects"})]})]}),e.jsxs("div",{className:M("border-b border-border/55",g?"flex min-h-0 flex-1 flex-col":"shrink-0"),children:[e.jsxs("button",{type:"button","aria-expanded":g,onClick:()=>b(T=>!T),className:M("flex w-full items-center gap-1 px-2 text-left text-[8px] font-semibold uppercase tracking-[0.14em] text-muted-foreground transition-colors hover:bg-muted/45 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",o?"py-1 leading-3":"py-1.5"),children:[e.jsx(ss,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Browse folders"}),e.jsx(Qe,{className:M("h-3 w-3 shrink-0 transition-transform duration-200",g&&"rotate-180")})]}),g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"shrink-0 px-2 pb-1.5",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>(p==null?void 0:p.parentPath)&&void R(p.parentPath),disabled:!(p!=null&&p.parentPath)||u,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-border/60 text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground disabled:opacity-40",title:"Parent directory",children:e.jsx(La,{className:"h-3 w-3"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[10px] text-muted-foreground",title:ee,children:ee}),p&&e.jsx("button",{type:"button",onClick:()=>$(p.currentPath,p.isAbsolute),className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium text-foreground hover:bg-muted/60",title:"Use this folder",children:"Use"})]})}),e.jsxs("div",{className:M("min-h-0 flex-1 overflow-y-auto",o?"min-h-[8.25rem]":"max-h-56"),children:[t.workDir?u?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(ue,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading folders..."]}):p&&p.entries.length>0?e.jsxs(e.Fragment,{children:[p.entries.map(T=>e.jsxs("div",{className:"group flex items-stretch border-b border-border/30 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>$(T.path,p.isAbsolute),className:"flex min-w-0 flex-1 items-center gap-2 px-2.5 py-1.5 text-left hover:bg-muted/55",title:`Use ${T.path}`,children:[e.jsx(ss,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[11px] text-foreground",children:T.name})]}),e.jsx("button",{type:"button",onClick:()=>void R(T.path),className:"flex w-8 shrink-0 items-center justify-center border-l border-border/30 text-muted-foreground hover:bg-muted/65 hover:text-foreground",title:"Open subfolder","aria-label":`Open ${T.name}`,children:e.jsx(xt,{className:"h-3.5 w-3.5"})})]},T.path)),p.hasMore&&e.jsxs("button",{type:"button",onClick:()=>void R(p.currentPath,p.entries.length,!0),disabled:k,className:"flex w-full items-center justify-center gap-1 border-t border-border/40 py-1 text-[10px] text-muted-foreground hover:bg-muted/60 hover:text-foreground disabled:opacity-50",children:[k?e.jsx(ue,{className:"h-3 w-3 animate-spin"}):e.jsx(Li,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:y??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"This node has no working directory."}),y&&p&&p.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[11px] text-destructive",children:y})]})]})]})]});return e.jsxs("div",{ref:S,className:"relative min-w-0",children:[e.jsxs("button",{ref:C,type:"button","aria-label":"Capability location","aria-expanded":m,title:I,onClick:()=>v(T=>(T||(b(!1),W()),!T)),className:M("flex min-w-0 items-center gap-2 rounded-sm border border-border/65 bg-background/70 text-left shadow-none transition-colors hover:bg-muted/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",o?"h-6 w-28 max-w-32 px-2":"h-8 min-w-36 max-w-64 px-2.5"),children:[e.jsx("span",{className:"min-w-0 flex-1",children:e.jsx("span",{className:M("block truncate font-medium text-foreground",o?"text-[10px] leading-3":"text-[11px] leading-4"),children:V})}),e.jsx(Qe,{className:M(o?"h-3 w-3":"h-3.5 w-3.5","shrink-0 text-muted-foreground transition-transform",m&&"rotate-180")})]}),i&&oe?Na.createPortal(te,oe):te]})}function ca({label:t,description:s,selected:n,onSelect:r,compact:o=!1}){return e.jsx("button",{type:"button",onClick:r,className:M("flex w-full items-center gap-2 rounded-md px-2 text-left transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",o?"py-1 text-[10px] leading-3":"py-1.5 text-[11px]",n&&"bg-primary/10 text-primary"),children:e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate font-medium",children:t}),s&&e.jsx("span",{className:M("block truncate text-muted-foreground",o?"text-[8px] leading-3":"text-[9px]"),children:s})]})})}function Rc({ariaLabel:t,value:s,description:n,options:r,selectedValue:o,onSelect:i}){const[h,m]=a.useState(!1),v=a.useRef(null);return a.useEffect(()=>{if(!h)return;const p=N=>{v.current&&N.target instanceof Node&&!v.current.contains(N.target)&&m(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[h]),e.jsxs("div",{ref:v,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":t,"aria-expanded":h,title:n??s,onClick:()=>m(p=>!p),className:"flex h-8 min-w-36 max-w-64 items-center gap-2 rounded-sm border border-border/65 bg-background/70 px-2.5 text-left shadow-none transition-colors hover:bg-muted/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{className:"min-w-0 flex-1",children:e.jsx("span",{className:"block truncate text-[11px] font-medium leading-4 text-foreground",children:s})}),e.jsx(Qe,{className:M("h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform",h&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!h,className:M("absolute left-0 top-9 z-50 w-64 overflow-hidden rounded-lg border border-border/70 bg-popover text-popover-foreground shadow-none",!h&&"hidden"),children:e.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:r.length>0?r.map(p=>e.jsxs("button",{type:"button",onClick:()=>{i(p.value),m(!1)},className:M("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[11px] transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",p.value===o&&"bg-primary/10 text-primary"),children:[p.status&&e.jsx("span",{className:M("h-1.5 w-1.5 shrink-0 rounded-full",zt(p.status))}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate font-medium",children:p.label}),p.description&&e.jsx("span",{className:"block truncate text-[9px] text-muted-foreground",children:p.description})]})]},p.value)):e.jsx("div",{className:"px-2 py-2 text-[10px] text-muted-foreground",children:"No projects"})})})]})}function $c(t,s){const n=new Map;for(const r of t)n.set(r.id,r);return n.set(s.id,s),Array.from(n.values())}function zt(t){return t==="online"?"bg-emerald-500":t==="offline"?"bg-muted-foreground/45":"bg-amber-500"}function ua(t){return t.split(/[\\/]+/).filter(Boolean).at(-1)??t}function or(t){return t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t)}function ir(t,s){return`${t.replace(/[\\/]+$/,"")}/${s.replace(/^[\\/]+/,"")}`}const Oc="h-6 w-24 rounded-sm px-2 text-[10px] shadow-none",Ms="text-[10px]",lr=["claudecode","codex","copilot"],Ot={claudecode:"Claude Code",codex:"Codex",copilot:"Copilot"};function zc({open:t,sourceNode:s,targetNodes:n,selectedCapabilities:r,previewResults:o=[],embedded:i=!1,onClose:h,onPreviewTargetsChange:m,onShare:v}){const[p,N]=a.useState(()=>new Set(o.length>0?o.map(d=>tt(d.nodeId,d.targetAgent)):Hc(s.id,n,r))),[u,l]=a.useState(()=>Object.fromEntries(Uc(s.id,n,r))),[k,_]=a.useState({}),[y,A]=a.useState(!1),[g,b]=a.useState(()=>new Set),[x,w]=a.useState(()=>new Set),S=r.some(d=>d.kind==="plugin"),C=a.useMemo(()=>un(r).map(d=>({key:tt(s.id,d),nodeId:s.id,node:s,label:`Install into ${Ot[d]}`,agentLabel:Ot[d],defaultScope:cr(r),disabled:!1,targetAgent:d})),[r,s]),L=a.useMemo(()=>n.flatMap(d=>{const U={kind:"global"},f=d.status==="offline",Q=dr(r);return Q.length===0?[{key:tt(d.id),nodeId:d.id,node:d,label:d.name,defaultScope:U,disabled:f}]:Q.map(E=>({key:tt(d.id,E),nodeId:d.id,node:d,label:`${d.name} / ${Ot[E]}`,agentLabel:Ot[E],defaultScope:U,disabled:f,targetAgent:E}))}),[r,n]),Y=a.useMemo(()=>[...C,...L],[C,L]),q=a.useMemo(()=>n.map(d=>({node:d,options:L.filter(U=>U.nodeId===d.id)})).filter(d=>d.options.length>0),[n,L]),V=a.useMemo(()=>new Map(o.filter(d=>d.capabilityId).map(d=>[ma(d.nodeId,d.capabilityId,d.targetAgent),d])),[o]),I=a.useMemo(()=>new Map(o.map(d=>[tt(d.nodeId,d.targetAgent),d])),[o]),J=a.useMemo(()=>Y.filter(d=>p.has(d.key)),[p,Y]),W=a.useMemo(()=>J.map(d=>({nodeId:d.nodeId,scope:u[d.key]??d.defaultScope,...d.targetAgent?{targetAgent:d.targetAgent}:{}})),[J,u]),R=a.useMemo(()=>{const d=[],U=new Map;for(const f of J){if(!U.has(f.nodeId)){const Q=f.nodeId===s.id?s:n.find(E=>E.id===f.nodeId);U.set(f.nodeId,{nodeId:f.nodeId,node:Q,name:(Q==null?void 0:Q.name)??f.nodeId,options:[]}),d.push(f.nodeId)}U.get(f.nodeId).options.push(f)}return d.map(f=>U.get(f))},[J,s,n]),$=a.useMemo(()=>{const d=Array.from(new Set(r.map(f=>f.agent))),[U]=d;if(U)return d.length===1?Ot[U]:`${d.length} agents`},[r]),ae=q.length+1;a.useEffect(()=>{let d=!1;const U={...u};for(const f of Y)U[f.key]||(U[f.key]=f.defaultScope,d=!0);d&&l(U)},[Y,u]),a.useEffect(()=>{t&&(m==null||m(W))},[t,m,W]),a.useEffect(()=>{t&&(b(new Set),w(new Set))},[t,s.id]),a.useEffect(()=>{if(!i||!t)return;const d=U=>{U.key==="Escape"&&h()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[i,h,t]);const ee=d=>{_(Object.fromEntries(J.map(U=>[U.key,d])))},oe=async()=>{A(!0);try{await v(J.map(d=>({nodeId:d.nodeId,scope:u[d.key]??d.defaultScope,...d.targetAgent?{targetAgent:d.targetAgent}:{},conflictStrategy:k[d.key]??"overwrite"})))}finally{A(!1)}},te=d=>{const U=u[d.key]??d.defaultScope,f=`capability-share-target-${Fc(d.key)}`,Q=p.has(d.key);return e.jsxs("div",{"data-target-agent":d.targetAgent,className:"flex min-h-6 items-center gap-2 px-2 py-0.5 transition-colors hover:bg-muted/35 data-[disabled=true]:opacity-55","data-disabled":d.disabled?"true":void 0,children:[e.jsx(Ut,{id:f,disabled:d.disabled,checked:Q,onCheckedChange:E=>N(z=>{const j=new Set(z);return E===!0?j.add(d.key):j.delete(d.key),j}),"aria-label":`Select ${d.label} as a share target`,"data-share-target-checkbox":!0,className:"h-3.5 w-3.5 border-border/70 bg-background/80 shadow-none data-[state=checked]:border-primary data-[state=checked]:bg-primary [&_svg]:h-3 [&_svg]:w-3"}),e.jsx("label",{htmlFor:f,className:"min-w-0 flex-1 cursor-pointer truncate text-[10px] font-medium leading-4 text-foreground data-[disabled=true]:cursor-not-allowed","data-disabled":d.disabled?"true":void 0,children:d.agentLabel??d.label}),e.jsx("div",{className:"flex w-28 shrink-0 justify-end",children:Q&&!d.disabled&&e.jsx(rr,{node:d.node,projectPaths:cn(d.node),selectedScope:U,onSelect:E=>l(z=>({...z,[d.key]:E})),compact:!0,portal:!0,portalAlign:"end"})})]},d.key)},T=(d,U,f,Q)=>{const E=g.has(d.id),z=J.filter(j=>j.nodeId===d.id).length;return e.jsxs("div",{className:"overflow-hidden rounded-sm border border-border/45 bg-muted/15",children:[e.jsxs("button",{type:"button","aria-expanded":E,onClick:()=>b(j=>xa(j,d.id)),className:"flex w-full items-center gap-2 border-b border-border/35 bg-primary/5 px-2 py-1.5 text-left transition-colors hover:bg-primary/10",children:[e.jsx(xt,{className:M("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",E&&"rotate-90")}),e.jsx("span",{className:M("h-1.5 w-1.5 shrink-0 rounded-full",zt(d.status))}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold text-foreground",title:d.name,children:d.name}),z>0&&e.jsxs("span",{className:"shrink-0 text-[8px] font-medium text-primary",children:[z," selected"]}),e.jsx("span",{className:"shrink-0 text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:U?"this node":"remote"}),d.status==="offline"&&e.jsx(He,{variant:"outline",className:"rounded-sm px-1 py-0 text-[8px]",children:"offline"}),Q>0&&e.jsxs("span",{className:"sr-only",children:[Q," agents"]})]}),e.jsx("div",{className:M("grid transition-[grid-template-rows] duration-200 ease-out",E?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:e.jsx("div",{className:"min-h-0 overflow-hidden",children:e.jsx("div",{className:"divide-y divide-border/25",children:f})})})]},d.id)},O=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-b border-border/55 px-4 py-3 text-left",children:[e.jsxs("h2",{id:"capability-share-title",className:"flex items-center gap-2 text-sm font-semibold leading-none tracking-tight",children:[e.jsx(xs,{className:"h-4 w-4 text-primary"}),"Share ",r.length," ",r.length===1?"capability":"capabilities"]}),e.jsx("p",{id:"capability-share-description",className:"mt-1.5 text-[11px] text-muted-foreground",children:"Copies each capability into the matching agent on the selected targets. Plugins install into their matching agent."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2.5 gap-y-1 border-b border-border/55 bg-muted/15 px-4 py-2 text-[11px]",children:[e.jsx("span",{className:"text-[8px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Source"}),e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:M("h-1.5 w-1.5 shrink-0 rounded-full",zt(s.status))}),e.jsx("span",{className:"truncate font-semibold text-foreground",title:s.name,children:s.name}),$&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:["· ",$]})]}),e.jsx(In,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70"}),e.jsx("span",{className:"text-[8px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Targets"}),e.jsxs("span",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-semibold text-foreground",children:J.length})," selected · ",ae," ",ae===1?"node":"nodes"]})]}),e.jsxs("div",{className:"grid gap-4 p-4 lg:grid-cols-[17rem_minmax(0,1fr)]",children:[e.jsx("section",{className:"min-w-0",children:e.jsxs("div",{className:"max-h-[56vh] space-y-2 overflow-y-auto pr-0.5",children:[T(s,!0,S?e.jsx("div",{className:"px-2 py-2 text-[10px] text-muted-foreground",children:"Cross-agent plugin installs are not supported."}):C.length===0?e.jsx("div",{className:"px-2 py-2 text-[10px] text-muted-foreground",children:"No alternate agents available for this selection."}):C.map(te),C.length),q.map(d=>T(d.node,!1,d.options.map(te),d.options.length))]})}),e.jsxs("section",{className:"min-w-0",children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[8px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Conflict preview"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[8px] uppercase tracking-[0.12em] text-muted-foreground/70",children:"Set all"}),e.jsx("div",{className:"inline-flex items-center rounded-sm border border-border/55 bg-muted/20 p-px",children:["overwrite","skip","abort"].map(d=>e.jsx("button",{type:"button",onClick:()=>ee(d),className:"h-5 rounded-[3px] px-1.5 text-[9px] capitalize text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground",children:d},d))})]})]}),e.jsx("div",{className:"max-h-[56vh] min-h-32 overflow-y-auto rounded-sm border border-border/55 bg-background/45 p-2",children:J.length===0?e.jsx("div",{className:"py-8 text-center text-[11px] text-muted-foreground",children:"Select a target to preview conflicts."}):R.map(d=>{const U=!x.has(d.nodeId);return e.jsxs("div",{className:"mb-1.5 overflow-hidden rounded-sm border border-border/35 bg-muted/10 last:mb-0",children:[e.jsxs("button",{type:"button","aria-expanded":U,onClick:()=>w(f=>xa(f,d.nodeId)),className:"flex w-full items-center gap-1.5 border-b border-border/30 bg-primary/5 px-2 py-1 text-left transition-colors hover:bg-primary/10",children:[e.jsx(xt,{className:M("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",U&&"rotate-90")}),d.node&&e.jsx("span",{className:M("h-1.5 w-1.5 shrink-0 rounded-full",zt(d.node.status))}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[10px] font-semibold text-foreground",children:d.name}),e.jsxs("span",{className:"shrink-0 text-[8px] text-muted-foreground",children:[d.options.length," ",d.options.length===1?"agent":"agents"]})]}),e.jsx("div",{className:M("grid transition-[grid-template-rows] duration-200 ease-out",U?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:e.jsx("div",{className:"min-h-0 overflow-hidden",children:e.jsx("div",{className:"space-y-1 p-1.5",children:d.options.map(f=>{const Q=k[f.key]??"overwrite";return e.jsxs("div",{className:"rounded-sm bg-background/45 px-2 py-1",children:[e.jsxs("div",{className:"mb-0.5 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-[9px] font-medium leading-4 text-foreground",children:f.agentLabel??"Matching agent"}),e.jsxs(Se,{value:Q,onValueChange:E=>_(z=>({...z,[f.key]:E})),children:[e.jsx(Ce,{className:Oc,children:e.jsx(Ie,{})}),e.jsxs(Ee,{className:"shadow-none",children:[e.jsx(xe,{value:"overwrite",className:Ms,children:"Overwrite"}),e.jsx(xe,{value:"skip",className:Ms,children:"Skip"}),e.jsx(xe,{value:"abort",className:Ms,children:"Abort"})]})]})]}),e.jsx("div",{className:"space-y-px",children:r.map(E=>{const z=V.get(ma(f.nodeId,E.id,f.targetAgent))??(r.length===1?I.get(f.key):void 0);return e.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] leading-4",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:E.name}),e.jsx("span",{className:z!=null&&z.conflict?"text-amber-500":z?"text-emerald-500":"text-muted-foreground",children:z?z.conflict?`exists${z.currentVersion?` v${z.currentVersion}`:""}`:"new install":"checking"}),(z==null?void 0:z.sourceVersion)&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:[e.jsx(In,{className:"inline h-2.5 w-2.5"})," v",z.sourceVersion]})]},E.id)})})]},f.key)})})})})]},d.nodeId)})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-border/55 px-4 py-3",children:[e.jsx(G,{variant:"ghost",onClick:h,className:"h-7 rounded-sm px-3 text-[11px]",children:"Cancel"}),e.jsxs(G,{onClick:oe,disabled:y||J.length===0,className:"h-7 rounded-sm px-3 text-[11px]",children:[y?e.jsx(ue,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(xs,{className:"h-3.5 w-3.5"}),"Share"]})]})]});return i?t?e.jsx("div",{className:"absolute inset-0 z-[80] flex items-center justify-center bg-background/70 p-4 backdrop-blur-[2px]",onMouseDown:d=>{d.target===d.currentTarget&&h()},children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"capability-share-title","aria-describedby":"capability-share-description","data-capability-share-dialog":"true",className:"relative grid w-full max-w-3xl gap-0 overflow-visible rounded-xl border-0 bg-background text-foreground shadow-[0_34px_110px_-54px_rgba(0,0,0,0.55)]",onMouseDown:d=>d.stopPropagation(),children:[O,e.jsxs("button",{type:"button",onClick:h,className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[e.jsx(ot,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})}):null:e.jsx(qt,{open:t,onOpenChange:d=>{d||h()},children:e.jsx(Kt,{"aria-labelledby":"capability-share-title","aria-describedby":"capability-share-description","data-capability-share-dialog":"true",className:"max-w-3xl gap-0 overflow-visible rounded-xl border-0 p-0",children:O})})}function tt(t,s){return s?`agent:${t}:${s}`:`node:${t}`}function Fc(t){return t.replace(/[^a-zA-Z0-9_-]/g,"-")}function ma(t,s,n){return`${tt(t,n)}\0${s}`}function xa(t,s){const n=new Set(t);return n.has(s)?n.delete(s):n.add(s),n}function Hc(t,s,n){const r=s.find(i=>i.status!=="offline");if(r)return[tt(r.id,Vc(n))];const o=un(n)[0];return o?[tt(t,o)]:[]}function Uc(t,s,n){const r=dr(n);return[...s.flatMap(o=>r.length===0?[[tt(o.id),{kind:"global"}]]:r.map(i=>[tt(o.id,i),{kind:"global"}])),...un(n).map(o=>[tt(t,o),cr(n)])]}function dr(t){return t.length===0||t.some(s=>s.kind==="plugin")?[]:lr}function Vc(t){var s;if(!(t.length===0||t.some(n=>n.kind==="plugin")))return(s=t[0])==null?void 0:s.agent}function un(t){if(t.length===0||t.some(n=>n.kind==="plugin"))return[];const s=new Set(t.map(n=>n.agent));return lr.filter(n=>!s.has(n))}function cr(t){var s;return((s=t[0])==null?void 0:s.scope)??{kind:"global"}}const ha="h-8 rounded-sm px-2 text-[10px] leading-none shadow-none [&>svg]:h-3 [&>svg]:w-3",mt="py-1 pl-6 pr-1.5 text-[10px] leading-4 [&_svg]:h-3 [&_svg]:w-3";function qc(t,s,n,r){return n.map(o=>({sourceNodeId:t,capabilityId:o.id,sourceScope:s,targets:r.map(i=>({nodeId:i.nodeId,scope:i.scope,...i.targetAgent?{targetAgent:i.targetAgent}:{}}))}))}function Kc(t,s,n,r){return n.map(o=>({sourceNodeId:t,capabilityId:o.id,sourceScope:s,targets:r}))}function Wc({loading:t,onRefresh:s}){return e.jsxs(G,{variant:"outline",onClick:s,disabled:t,"aria-busy":t,className:"h-7 min-w-[5.75rem] rounded-sm px-2 text-[11px] shadow-none",children:[e.jsx(Vo,{className:M("h-3.5 w-3.5",t&&"animate-spin")}),t?"Refreshing":"Refresh"]})}function Gc({visible:t}){return t?e.jsx("div",{className:"absolute inset-3 z-10 flex items-center justify-center rounded-sm border border-border/60 bg-background/85 shadow-sm backdrop-blur-sm",children:e.jsxs("div",{className:"flex w-full max-w-80 flex-col items-center gap-3 px-5 text-center",children:[e.jsxs("div",{className:"relative flex h-10 w-10 items-center justify-center rounded-full border border-primary/25 bg-primary/8",children:[e.jsx("span",{className:"absolute inset-0 rounded-full border border-primary/20 animate-ping"}),e.jsx(ue,{className:"relative h-4 w-4 animate-spin text-primary"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:"Loading capabilities"}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Reading agent skills, plugins, and MCP servers for this selection."})]}),e.jsxs("div",{className:"grid w-full gap-1.5","aria-hidden":"true",children:[e.jsx("span",{className:"h-1.5 rounded-full bg-muted animate-pulse"}),e.jsx("span",{className:"mx-auto h-1.5 w-3/4 rounded-full bg-muted/70 animate-pulse"})]})]})}):null}function Yc({open:t,node:s,scope:n,clusterNodes:r,onOpenChange:o,onSelectionChange:i}){const[h,m]=a.useState([]),[v,p]=a.useState([]),[N,u]=a.useState(!1),[l,k]=a.useState(""),[_,y]=a.useState("all"),[A,g]=a.useState("all"),[b,x]=a.useState(new Set),[w,S]=a.useState(null),[C,L]=a.useState(null),[Y,q]=a.useState(null),[V,I]=a.useState(!1),[J,W]=a.useState([]),[R,$]=a.useState(ar),[ae,ee]=a.useState(null),oe=a.useMemo(()=>vc(h,{search:l,agent:_,kind:A}),[_,h,A,l]),te=a.useMemo(()=>h.filter(D=>b.has(D.id)),[h,b]),T=a.useMemo(()=>r.filter(D=>D.id!==s.id),[r,s.id]),O=n.kind==="project"?n.projectPath:"global",d=async()=>{u(!0);try{const D=await Ho(s.id,{scope:n});m(D.items),p((D.errors??[]).map(F=>`${F.agent}: ${F.message}`))}catch(D){p([D instanceof Error?D.message:"Failed to load capabilities"])}finally{u(!1)}};a.useEffect(()=>{t&&(x(new Set),S(null),L(null),W([]),m([]),p([]),d())},[t,s.id,n.kind,O]),a.useEffect(()=>{if(!ae)return;const D=ne=>{$(yc(ae.startWidth,ae.startClientX,ne.clientX,window.innerWidth))},F=()=>ee(null);return window.addEventListener("pointermove",D),window.addEventListener("pointerup",F),()=>{window.removeEventListener("pointermove",D),window.removeEventListener("pointerup",F)}},[ae]);const U=D=>{D.preventDefault(),ee({startClientX:D.clientX,startWidth:R})},f=async D=>{S(D.id);const F=await Uo(s.id,D.id,n);L(F.detail)},Q=a.useCallback(async D=>{if(te.length===0||D.length===0){W([]);return}W([]);try{const F=qc(s.id,n,te,D),ne=await Promise.all(F.map(X=>Fo(X)));W(ne.flatMap((X,se)=>X.results.map(de=>{var Ne;return{...de,capabilityId:(Ne=F[se])==null?void 0:Ne.capabilityId}})))}catch{W([])}},[s.id,n,te]),E=()=>{W([]),I(!0)},z=async D=>{const F=Kc(s.id,n,te,D);F.length!==0&&(await Promise.all(F.map(ne=>Ko(ne))),le.success(`${F.length} capability share request${F.length===1?"":"s"} completed`),I(!1))},j=async()=>{if(!(!C||Y)){q(C.id);try{const D=await qo(s.id,C.id,n);D.status==="deleted"?(le.success(`Deleted ${C.name}`),m(F=>F.filter(ne=>ne.id!==C.id)),x(F=>{const ne=new Set(F);return ne.delete(C.id),ne}),S(null),L(null),await d()):(le.info(D.message??"Capability was not found"),S(null),L(null),await d())}catch(D){le.error(D instanceof Error?D.message:"Failed to delete capability")}finally{q(null)}}};return e.jsx(e.Fragment,{children:e.jsx(qt,{open:t,onOpenChange:o,children:e.jsxs(Kt,{className:"flex h-[min(82vh,44rem)] w-[min(94vw,72rem)] max-w-[min(94vw,72rem)] flex-col gap-0 overflow-hidden rounded-xl border-0 p-0",children:[e.jsxs(Xs,{className:"border-b border-border/55 px-4 py-3 text-left",children:[e.jsx(ps,{className:"sr-only",children:"Capabilities"}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-x-4 gap-y-1 pr-10",children:[e.jsx(Ic,{node:s,scope:n,clusterNodes:r,onSelectionChange:i}),e.jsxs(Ea,{"data-capability-selection-help":"true",className:"ml-auto max-w-[min(34rem,40vw)] space-y-0.5 pt-0.5 text-right text-[10px] leading-3 text-muted-foreground",children:[e.jsx("span",{className:"block truncate whitespace-nowrap",children:"Sharing copies into selected agents on target nodes."}),n.kind==="project"&&e.jsx("span",{"data-capability-selection-path":"true",className:"block truncate font-mono text-[8px] leading-3 text-muted-foreground/80",title:n.projectPath,children:n.projectPath})]})]})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[e.jsxs("main",{className:"relative flex min-w-0 flex-1 flex-col gap-2 p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative min-w-48 flex-1",children:[e.jsx(ns,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(nt,{value:l,onChange:D=>k(D.target.value),placeholder:"Search capabilities",className:"h-8 rounded-sm pl-7 text-[11px] shadow-none"})]}),e.jsxs(Se,{value:_,onValueChange:D=>y(D),children:[e.jsx(Ce,{className:M("w-32",ha),children:e.jsx(Ie,{})}),e.jsxs(Ee,{className:"shadow-none",children:[e.jsx(xe,{value:"all",className:mt,children:"Agent: All"}),e.jsx(xe,{value:"claudecode",className:mt,children:"Claude Code"}),e.jsx(xe,{value:"codex",className:mt,children:"Codex"}),e.jsx(xe,{value:"copilot",className:mt,children:"Copilot"})]})]}),e.jsxs(Se,{value:A,onValueChange:D=>g(D),children:[e.jsx(Ce,{className:M("w-28",ha),children:e.jsx(Ie,{})}),e.jsxs(Ee,{className:"shadow-none",children:[e.jsx(xe,{value:"all",className:mt,children:"Kind: All"}),e.jsx(xe,{value:"skill",className:mt,children:"Skill"}),e.jsx(xe,{value:"plugin",className:mt,children:"Plugin"}),e.jsx(xe,{value:"mcp",className:mt,children:"MCP"})]})]})]}),v.length>0&&e.jsx("div",{className:"rounded-sm bg-amber-500/10 px-2 py-1 text-[10px] text-amber-600",children:v.join(" · ")}),e.jsx(jc,{items:oe,selectedIds:b,activeId:w,onToggleSelected:(D,F)=>x(ne=>{const X=new Set(ne);return F?X.add(D):X.delete(D),X}),onOpenDetail:f}),e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[e.jsxs("span",{children:["Selected: ",b.size]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Wc,{loading:N,onRefresh:d}),e.jsxs(G,{onClick:E,disabled:b.size===0,className:"h-7 rounded-sm px-2 text-[11px]",children:[e.jsx(xs,{className:"h-3.5 w-3.5"}),"Share"]})]})]}),e.jsx(Gc,{visible:N&&h.length===0})]}),e.jsx("div",{role:"separator","aria-label":"Resize capability detail panel","aria-orientation":"vertical",onPointerDown:U,className:"hidden w-1 shrink-0 cursor-col-resize items-center justify-center bg-border/20 transition-colors hover:bg-primary/18 lg:flex",children:e.jsx("span",{className:"h-8 w-px rounded-full bg-border/80"})}),e.jsx(kc,{detail:C,deleting:Y===(C==null?void 0:C.id),desktopWidth:R,onDelete:C?j:void 0})]}),V&&e.jsx(zc,{open:V,sourceNode:s,targetNodes:T,selectedCapabilities:te,previewResults:J,embedded:!0,onClose:()=>I(!1),onPreviewTargetsChange:Q,onShare:z})]})})})}function Qc(t){const[s,n]=a.useState(null),r=a.useMemo(()=>s?(t==null?void 0:t.nodes.find(v=>v.id===s.nodeId))??((t==null?void 0:t.self.id)===s.nodeId?t.self:null)??null:null,[t,s]),o=a.useCallback(v=>{n({nodeId:v,scope:{kind:"global"}})},[]),i=a.useCallback((v,p)=>{n({nodeId:v,scope:{kind:"project",projectPath:p}})},[]),h=a.useCallback(v=>{n(v)},[]);return{capabilitiesDialog:s&&r&&t?e.jsx(Yc,{open:!0,node:r,scope:s.scope,clusterNodes:t.nodes,onOpenChange:v=>{v||n(null)},onSelectionChange:h}):null,openNodeCapabilities:o,openProjectCapabilities:i}}function Xc(){var fn,gn,bn,vn,jn,wn;const{id:t}=Wo(),s=Go(),n=Yo(),r=Qo(),{cluster:o,systemInfo:i,events:h,sseConnected:m,subscribe:v,refresh:p,loading:N,error:u}=Xo(),l=a.useMemo(()=>Jo(s.state),[s.state]),[k,_]=a.useState(null),[y,A]=a.useState("active"),[g,b]=a.useState("all"),[x,w]=a.useState("all"),[S,C]=a.useState("all"),[L,Y]=a.useState(""),q=(r==null?void 0:r.headerSearchQuery)??L,V=(r==null?void 0:r.setHeaderSearchQuery)??Y,I=a.useDeferredValue(q),{desktopTasksOpen:J,mobileTasksPanelOpen:W,mobileTasksPanelRef:R,operationsOpen:$,operationsPanelRef:ae,panelResize:ee,setMobileTasksPanelOpen:oe,setOperationsOpen:te,toggleTasksPanel:T}=Zd(),[O,d]=a.useState(()=>!!(l!=null&&l.draftNewTask)),[U,f]=a.useState(()=>(l==null?void 0:l.createMode)??"chat"),[Q,E]=a.useState(()=>(l==null?void 0:l.createDefaults)??null),[z,j]=a.useState(()=>l!=null&&l.draftNewTask?{route:l.returnRoute??"/",taskId:l.returnTaskId??null}:null),[D,F]=a.useState(!1),[ne,X]=a.useState("transcript"),[se,de]=a.useState("all"),[Ne,H]=a.useState(!1),[ce,_e]=a.useState(null),[ye,Be]=a.useState([]),[Ge,De]=a.useState([]),[re,ge]=a.useState(!1),[Pe,$e]=a.useState(!1),[ht,je]=a.useState(null),[Te,Le]=a.useState(new Set),[pt,Xe]=a.useState(!1),[lt,vt]=a.useState(!1),[jt,it]=a.useState(null),Ue=a.useRef(null),wt=a.useRef(new Map),Ae=((fn=o==null?void 0:o.self)==null?void 0:fn.role)==="leader",dt=(gn=o==null?void 0:o.self)==null?void 0:gn.id;ic({cluster:o,subscribe:v});const{nodeSettingsDialog:Nt,openNodeSettings:yt}=fc(Ae),{capabilitiesDialog:ft,openNodeCapabilities:B,openProjectCapabilities:we}=Qc(o),{devBoxDialog:he,devBoxNodeIds:Oe,devBoxStartNodeId:Je,devBoxStartNodeIds:kt,devBoxStartingNodeIds:Me,openDevBox:Ve,startDevBox:ct}=pc({cluster:o,refresh:p}),{completedGroups:gt=[],fetchTasks:ie,loadCompletedTasksPage:ke,removeTasksFromList:qe,setTasks:Ze,tasks:be,tasksError:St,tasksLoading:Ct}=ac({isLeader:Ae,selfId:dt,sseConnected:m,preservedTask:ce,subscribe:v}),Ke=a.useMemo(()=>[...be].sort((c,P)=>P.updatedAt-c.updatedAt),[be]),ze=a.useMemo(()=>{var c;return((c=[...be].sort((P,K)=>K.createdAt-P.createdAt||K.updatedAt-P.updatedAt)[0])==null?void 0:c.id)??null},[be]),ur=a.useMemo(()=>{const c=new Map;for(const P of(o==null?void 0:o.nodes)??[]){const K=xl(Ke,P.id);K>0&&c.set(P.id,K)}return c},[o==null?void 0:o.nodes,Ke]),et=a.useMemo(()=>Ke.filter(c=>!Zo(c,o==null?void 0:o.nodes,o==null?void 0:o.self)||!ei(c,y)||g!=="all"&&c.agent!==g||!ti(c,S)||x==="unassigned"&&c.assignedTo||x!=="all"&&x!=="unassigned"&&si(c.assignedTo,o==null?void 0:o.nodes,c.assignedNodeName)!==x?!1:I.trim()?ni(c,I):!0),[Ke,o==null?void 0:o.nodes,o==null?void 0:o.self,y,g,S,x,I]);a.useEffect(()=>{Le(c=>{const P=vl(c,et.map(K=>K.id));return P.size===c.size?c:P})},[et]),a.useEffect(()=>{Ae||Le(new Set)},[Ae]);const mr=a.useMemo(()=>["all",...Array.from(new Set(Ke.map(c=>c.agent))).sort()],[Ke]),xr=a.useMemo(()=>{const P=Array.from(new Set(Ke.map(K=>K.assignedTo).filter(K=>!!K))).map(K=>{const ve=Ke.find(me=>me.assignedTo===K);return(o==null?void 0:o.nodes.find(me=>me.id===K))??{id:K,name:Ps(K,o==null?void 0:o.nodes,ve==null?void 0:ve.assignedNodeName)}}).sort((K,ve)=>K.name.localeCompare(ve.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...P.map(K=>({value:K.name.toLowerCase(),label:K.name}))]},[Ke,o==null?void 0:o.nodes]),mn=a.useMemo(()=>{const c=new Map;for(const P of(o==null?void 0:o.nodes)??[])c.set(P.id,P.name);for(const P of Ke)P.assignedTo&&P.assignedNodeName&&!c.has(P.assignedTo)&&c.set(P.assignedTo,P.assignedNodeName);return c},[o==null?void 0:o.nodes,Ke]),hr=a.useMemo(()=>{var P;const c=new Map;for(const K of(o==null?void 0:o.nodes)??[])K.workDir&&c.set(K.id,K.workDir);return(P=o==null?void 0:o.self)!=null&&P.workDir&&c.set(o.self.id,o.self.workDir),c},[o]),pr=a.useMemo(()=>{const c=new Map;for(const P of(o==null?void 0:o.nodes)??[])c.set(P.id,P.status);return o!=null&&o.self&&c.set(o.self.id,o.self.status),c},[o]),fr=a.useMemo(()=>new Map(gt.map(c=>[Ws(c),c])),[gt]),xn=a.useMemo(()=>{const c=new Map;for(const P of(o==null?void 0:o.nodes)??[])P.status!=="offline"&&c.set(P.id,P);return o!=null&&o.self&&o.self.status!=="offline"&&c.set(o.self.id,o.self),Array.from(c.values())},[o]),gr=((bn=o==null?void 0:o.self)==null?void 0:bn.id)??((vn=xn[0])==null?void 0:vn.id)??null,bs=a.useMemo(()=>["all",...Array.from(new Set(h.map(c=>c.type))).sort()],[h]),br=a.useMemo(()=>se==="all"?h:h.filter(c=>c.type===se),[h,se]),vr=et.length>0&&et.every(c=>Te.has(c.id)),jr=et.some(c=>Te.has(c.id)),wr=jl(et,Te);a.useEffect(()=>{l!=null&&l.draftNewTask&&(d(!0),f(l.createMode??"chat"),E(l.createDefaults??null),j({route:l.returnRoute??"/",taskId:l.returnTaskId??null}))},[l]),a.useEffect(()=>{se!=="all"&&!bs.includes(se)&&de("all")},[se,bs]),a.useEffect(()=>{$n(t,O)&&!k&&ze&&_(ze)},[t,O,k,ze]),a.useEffect(()=>{$n(t,O)&&(k&&be.some(c=>c.id===k)||_(ze))},[t,O,k,ze,be]);const pe=pl({routeTaskId:t,creatingTask:O,internalSelectedTaskId:k,sortedTaskIds:ze?[ze]:[]}),Et=a.useMemo(()=>be.find(c=>c.id===pe)??null,[be,pe]);a.useEffect(()=>{Ue.current=pe??null},[pe]);const ut=a.useCallback(()=>{_e(null),Be([]),De([]),je(null),$e(!1)},[]),Bt=a.useCallback((c,P,K=!0)=>{wt.current.set(c,{logs:tr(P),loaded:K})},[]),We=a.useCallback(async()=>{const c=pe;if(c)try{const P=await ai(c);if(Ue.current!==c)return;_e(P),Ze(K=>Fa(K,P)),je(null)}catch(P){if(Ue.current!==c)return;ut(),je(P instanceof Error?P.message:"Failed to load task")}finally{Ue.current===c&&ge(!1)}},[pe,ut,Ze]),Wt=a.useCallback(async()=>{const c=pe;if(c)try{const P=await Is(c);if(Ue.current!==c)return;Be(K=>{const ve=Pa(K,P.logs);return Bt(c,ve),ve}),De(K=>Rs(K,P.logs))}catch{}finally{Ue.current===c&&$e(!1)}},[pe,Bt]);a.useEffect(()=>{if(!pe){ut(),ge(!1);return}X("transcript"),_e(Et);const c=rc(pe,wt.current);Be(c.logs),De([]),je(null),ge(!0),$e(c.transcriptLoading),We(),Wt()},[pe,ut,Wt,We]),a.useEffect(()=>{if(!fl({activeTaskId:pe,routeTaskId:t,creatingTask:O,tasksLoading:Ct,loadedTaskIds:be.map(P=>P.id)}))return;const c=ze;_(c),ut(),a.startTransition(()=>{n(c?`/tasks/${c}`:"/",{state:null})})},[pe,ut,O,ze,n,t,be,Ct]),a.useEffect(()=>{Et&&_e(c=>!c||c.id!==Et.id?c:{...c,...Et})},[Et]),a.useEffect(()=>{if(pe)return v("task",c=>{const P=c.data.taskId;if(!(typeof P!="string"||P!==pe)){if(c.type==="task.output"){const K=c.data.event;if(K){Be(me=>{const $t=wi(me,K);return Bt(pe,$t),$t}),$e(!1);const ve=Ln(K);ve&&De(me=>Ni(me,ve))}}c.type==="task.updated"&&We(),c.type==="task.status"&&(We(),Wt())}})},[v,pe,We,Wt]);const Z=ce??Et,Nr=Z!=null&&Z.assignedTo?(o==null?void 0:o.nodes.find(c=>c.id===Z.assignedTo))??null:null,Rt=r==null?void 0:r.setHeaderTaskContext;a.useEffect(()=>{if(!Rt)return;if(!Z){Rt(null);return}const c=Z.effectiveProjectPath??Z.project??"default workspace";return Rt({taskId:Z.id,taskTitle:Z.title,nodeName:Ps(Z.assignedTo,o==null?void 0:o.nodes,Z.assignedNodeName),projectLabel:Ca(c),projectPath:c}),()=>Rt(null)},[Z,o==null?void 0:o.nodes,Rt]);const vs=Ge.length>0,yr=Z?ri.has(Z.agent):!1,js=(Z==null?void 0:Z.status)==="running",kr=Z?ms.has(Z.status):!1,Sr=Z?ms.has(Z.status)||oi.has(Z.status):!1,Cr=!!(Z&&Ae&&Z.status==="failed"),ws=a.useMemo(()=>Hd(Z,o,vs,!!js),[Z,o,vs,js]),Ns=a.useMemo(()=>yi([...ye,...Ge.map(c=>Es(c.content,c.timestamp))]),[ye,Ge]),Gt=a.useMemo(()=>{if(!Z||Z.conversationKind==="nativeSession")return null;const c=ki(Z);if(c.length>0)return Es(c,new Date(Z.createdAt).toISOString());if(Ns.length>0)return null;const P=Si(Z.description||Z.title);return P.length>0?Es(P,new Date(Z.createdAt).toISOString()):null},[Z,Ns]),ys=a.useMemo(()=>Gt?Ln(Gt):null,[Gt]),Er=a.useMemo(()=>ys?Ci(ye,ys):!1,[ye,ys]),ks=a.useCallback((c="chat",P)=>{const K={route:t?`/tasks/${t}`:"/",taskId:pe};j(K),f(c),E(P??null),d(!0),a.startTransition(()=>{n("/",{state:{draftNewTask:!0,returnRoute:K.route,returnTaskId:K.taskId,createMode:c,createDefaults:P}})})},[t,pe,n]),_r=a.useCallback(()=>{const c=(z==null?void 0:z.taskId)??ze;d(!1),j(null),E(null),_(c),a.startTransition(()=>{n((z==null?void 0:z.route)??"/",{state:null})})},[z,ze,n]),hn=a.useCallback(c=>{d(!1),j(null),E(null),_(c),a.startTransition(()=>{n(`/tasks/${c}`,{state:null})})},[n]),Tr=a.useCallback(c=>{Ue.current=c.id,d(!1),j(null),E(null),Ze(P=>gl(P,c)),_e(c),Be([]),De([]),je(null),ge(!1),$e(c.conversationKind==="nativeSession"),X("transcript"),_(c.id),dc({task:c,getActiveTaskId:()=>Ue.current,setLogs:Be,setPendingMessages:De,setTranscriptLoading:$e}),ie(),a.startTransition(()=>{n(`/tasks/${c.id}`,{state:null})})},[ie,n]),{cancelQueuedMessage:Dr,queueFollowUpMessage:Yt}=gc({activeTaskId:pe,fetchActiveTask:We,setPendingMessages:De,setTask:_e,setTasks:Ze}),Ar=a.useCallback(c=>{Yt(c)},[Yt]),Mr=a.useCallback(async()=>{const c=pe;if(!(!c||(Z==null?void 0:Z.conversationKind)!=="nativeSession")){$e(!0);try{const P=await Is(c);if(Ue.current!==c)return;Be(P.logs),Bt(c,P.logs),De(K=>Rs(K,P.logs))}catch(P){le.error(P instanceof Error?P.message:"Failed to reload transcript")}finally{Ue.current===c&&$e(!1)}}},[Z==null?void 0:Z.conversationKind,pe,Bt]),Pr=a.useCallback(c=>Yt(c),[Yt]),Lr=a.useCallback(async()=>{if(Z)try{await ii(Z.id),We(),ie()}catch(c){le.error(c instanceof Error?c.message:"Failed to cancel task")}},[Z,We,ie]),{handleShareTask:Ir,handleStopShareTask:Br}=Yd(Z,We,ie),Rr=a.useCallback(async()=>{if(Z)try{await li(Z.id),We(),ie()}catch(c){le.error(c instanceof Error?c.message:"Failed to retry task")}},[Z,We,ie]),Qt=a.useCallback((c,P=!1)=>{const K=wl(et,c);return _(K),(P||!K)&&ut(),a.startTransition(()=>{n(K?`/tasks/${K}`:"/",{state:null})}),K},[ut,et,n]),$r=a.useCallback((c,P)=>{Le(K=>{const ve=new Set(K);return P?ve.add(c):ve.delete(c),ve})},[]),Or=a.useCallback(c=>{if(!c){Le(new Set);return}Le(new Set(et.map(P=>P.id)))},[et]),zr=a.useCallback(async()=>{const c=Array.from(Te);if(c.length!==0)try{const{results:P}=await di(c),K=P.filter(me=>!me.ok),ve=P.filter(me=>me.ok).map(me=>me.id);pe&&ve.includes(pe)&&Qt(ve),K.length>0?le.error(`Failed to archive ${K.length} task(s): ${K.map(me=>me.error??me.id).join(", ")}`):le.success(`Archived ${ve.length} task(s)`),Le(new Set(K.map(me=>me.id))),ie()}catch(P){le.error(P instanceof Error?P.message:"Failed to archive tasks")}},[pe,ie,Qt,Te]),Fr=a.useCallback(async()=>{const c=Array.from(Te);if(c.length!==0)try{const{results:P}=await ci(c),K=P.filter(me=>!me.ok),ve=P.filter(me=>me.ok).map(me=>me.id);ve.length>0&&qe(ve),pe&&ve.includes(pe)&&Qt(ve,!0),K.length>0?le.error(`Failed to delete ${K.length} task(s): ${K.map(me=>me.error??me.id).join(", ")}`):le.success(`Deleted ${ve.length} task(s)`),Le(new Set(K.map(me=>me.id))),ie()}catch(P){le.error(P instanceof Error?P.message:"Failed to delete tasks")}},[pe,ie,Qt,qe,Te]),Hr=a.useCallback(async()=>{Xe(!0);try{await ui(),p()}catch(c){le.error(c instanceof Error?c.message:"Failed to promote node")}finally{Xe(!1)}},[p]),Ur=a.useCallback(async()=>{vt(!0);try{await mi(),le.success("This node left the remote cluster and is leading itself again."),ie(),We(),p()}catch(c){le.error(c instanceof Error?c.message:"Failed to leave cluster")}finally{vt(!1)}},[We,ie,p]),Vr=a.useCallback(async c=>{var $t;const P=!an(c),K=c.id===(($t=o==null?void 0:o.self)==null?void 0:$t.id),ve=K?(i==null?void 0:i.transportType)??c.transportType:c.transportType,me=K&&!P&&It(ve);it(c.id);try{me?await xi("direct"):await hi(c.id,P),le.success(P?`Enabled remote access on ${c.name}`:`Disabled remote access on ${c.name}`),p()}catch(Nn){le.error(Nn instanceof Error?Nn.message:"Failed to update remote access")}finally{it(null)}},[(jn=o==null?void 0:o.self)==null?void 0:jn.id,p,i==null?void 0:i.transportType]),qr=a.useCallback(c=>{ke&&ke(c).catch(P=>{le.error(P instanceof Error?P.message:"Failed to load completed tasks")})},[ke]),pn={toolbarTasks:et,activeTaskId:pe,tasksLoading:Ct,tasksError:St,isLeader:Ae,scope:y,agentFilter:g,nodeFilter:x,taskKindFilter:S,agentOptions:mr,nodeOptions:xr,nodeNameById:mn,nodeWorkDirById:hr,nodeStatusById:pr,leaderNodeId:((wn=o==null?void 0:o.leader)==null?void 0:wn.id)??null,searchQuery:q,completedGroupByKey:fr,devBoxNodeIds:Oe,devBoxStartNodeIds:kt,devBoxStartingNodeIds:Me,selectedTaskIds:Te,allVisibleTasksSelected:vr,someVisibleTasksSelected:jr,canBatchArchive:wr,onSearchChange:V,onScopeChange:A,onAgentFilterChange:b,onNodeFilterChange:w,onTaskKindFilterChange:C,onToggleTaskSelected:$r,onToggleAllVisibleTasks:Or,onBatchArchive:zr,onBatchDelete:Fr,onCreateTask:ks,onOpenNodeSettings:Ae?yt:void 0,onOpenNodeCapabilities:Ae?B:void 0,onOpenProjectCapabilities:Ae?we:void 0,onOpenDevBox:Ae?Ve:void 0,onStartDevBox:Ae?ct:void 0,onLoadCompletedTasks:qr,onSelectTask:hn,onClose:T},Kr={cluster:o,systemInfo:i,nodeNameById:mn,nodeBlockingTaskCounts:ur,eventTypeFilter:se,onEventTypeFilterChange:de,eventTypeOptions:bs,filteredEvents:br,sseConnected:m,clusterLoading:N,clusterError:u,promotePending:pt,onPromote:Hr,onAddNode:()=>F(!0),leavePending:lt,onLeaveCluster:Ur,onToggleNodeDevTunnel:Vr,devTunnelNodeId:jt,devBoxStartNodeId:Je,devBoxStartingNodeIds:Me,onOpenNodeSettings:Ae?yt:void 0,onOpenDevBox:Ae?Ve:void 0,onStartDevBox:Ae?ct:void 0,onClose:()=>te(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(yd,{desktopTasksOpen:J,mobileTasksPanelOpen:W,mobileTasksPanelRef:R,operationsOpen:$,operationsPanelRef:ae,panelResize:ee,taskSidebar:e.jsx(ea,{...pn}),operationsSidecar:e.jsx(zd,{...Kr}),terminalPanel:r!=null&&r.terminalOpen?e.jsx(Ad,{nodes:xn,defaultNodeId:gr,onClose:()=>r==null?void 0:r.setTerminalOpen(!1)}):void 0,conversationPanel:e.jsx(vd,{onToggleTasks:T,desktopTasksOpen:J,mobileTasksPanelOpen:W,operationsOpen:$,onToggleOperations:()=>te(c=>!c),cluster:o,sseConnected:m,activeTab:ne,setActiveTab:X,creatingTask:O,createMode:U,createDefaults:Q,activeTask:Z,assignedNode:Nr,taskLoading:re,transcriptLoading:Pe,taskError:ht,displayEvents:Ns,initialPromptAlreadyInLogs:Er,initialPrompt:Gt,supportsFollowUp:yr,taskUnavailable:ws.taskUnavailable,chatDisabled:ws.chatDisabled,chatDisabledReason:ws.chatDisabledReason,questionBypassEnabled:Ne,isRunning:!!js,isStarting:kr,hasPendingFollowUp:vs,canCancel:!!Sr,canRetry:!!Cr,onRetry:Rr,onCancel:Lr,onReloadNativeTranscript:Mr,onShareTask:Ir,onStopShareTask:Br,onStartCreateTask:ks,onCancelCreateTask:_r,onCreateTask:Tr,onSendMessage:Ar,onCancelQueuedMessage:Dr,onQuestionBypassChange:H,onSubmitQuestionResponse:Pr}),mobileTaskSidebar:e.jsx(ea,{...pn,onCreateTask:(c,P)=>{oe(!1),ks(c,P)},onSelectTask:c=>{oe(!1),hn(c)},onClose:()=>oe(!1)}),onCloseOperations:()=>te(!1),onCloseTaskList:()=>oe(!1)}),e.jsx(Nd,{open:D,onOpenChange:F,onAdded:p}),Nt,he,ft]})}const tu=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:Xc},Symbol.toStringTag,{value:"Module"}));export{tu as D,$s as G};