meshy-node 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dashboard/assets/DashboardPage-vTNa1p9t.js +172 -0
- package/dashboard/assets/{DiffTab-L7XOR2ma.js → DiffTab-Cul1vyzx.js} +4 -4
- package/dashboard/assets/{FilesTab-MiZ3rGO0.js → FilesTab-lmhjg0sO.js} +5 -5
- package/dashboard/assets/{PreviewTab-DdT_r4GF.js → PreviewTab-DPnxufTZ.js} +4 -4
- package/dashboard/assets/{file-DP1hVNzm.js → file-DOpaEqEq.js} +1 -1
- package/dashboard/assets/index-BaryQ110.css +1 -0
- package/dashboard/assets/index-BgqvdxOA.js +249 -0
- package/dashboard/index.html +2 -2
- package/main.cjs +786 -287
- package/package.json +2 -1
- package/runtime-metadata.json +31 -0
- package/dashboard/assets/DashboardPage-Bu_7sWoy.js +0 -256
- package/dashboard/assets/index-2UShBZ7T.css +0 -1
- package/dashboard/assets/index-Dc0APxmT.js +0 -115
package/README.md
CHANGED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-lmhjg0sO.js","assets/index-BgqvdxOA.js","assets/index-BaryQ110.css","assets/file-DOpaEqEq.js","assets/PreviewTab-DPnxufTZ.js","assets/DiffTab-Cul1vyzx.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as O,r as o,j as e,a as T,b as fn,d as pn,e as hn,D as gn,f as bn,g as jn,B as pe,h as yn,i as A,X as Ye,C as Me,k as Kt,l as Rs,m as Be,R as vn,T as Nn,n as Ls,P as kn,u as jt,W as wn,o as Cn,p as Lt,q as Sn,s as _n,t as Is,O as Tn,v as An,w as Os,x as Fs,y as En,F as Dn,z as Mn,A as ae,S as ye,E as ve,G as Te,H as Ne,I as me,J as Us,K as zs,L as Pn,M as Bs,N as $e,Q as Re,_ as Jt,U as $n,V as Vs,Y as qs,Z as Ws,$ as Rn,a0 as Gt,a1 as Ln,a2 as In,a3 as On,a4 as Fn,a5 as Un,a6 as zn,a7 as Bn,a8 as Vn,a9 as qn,aa as Wn,ab as Hn,ac as Kn,ad as Jn,ae as Gn,af as Yn,ag as Xn,ah as Zn,ai as Qn,aj as ea,ak as ta,al as sa,am as ra}from"./index-BgqvdxOA.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 na=[["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"}]],aa=O("archive",na);/**
|
|
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 oa=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ia=O("arrow-up",oa);/**
|
|
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 la=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],da=O("brain",la);/**
|
|
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 ca=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Xe=O("chevron-right",ca);/**
|
|
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 ua=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ma=O("circle-question-mark",ua);/**
|
|
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 xa=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],fa=O("circle",xa);/**
|
|
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 pa=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],yt=O("copy",pa);/**
|
|
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 ha=[["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"}]],ga=O("flag",ha);/**
|
|
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 ba=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],ja=O("folder",ba);/**
|
|
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 ya=[["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"}]],va=O("funnel",ya);/**
|
|
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 Na=[["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"}]],ka=O("globe",Na);/**
|
|
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 wa=[["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"}]],Ca=O("history",wa);/**
|
|
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 Sa=[["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"}]],It=O("image-plus",Sa);/**
|
|
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 _a=[["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"}]],Ta=O("laptop",_a);/**
|
|
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 Aa=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]],Ea=O("list-checks",Aa);/**
|
|
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 Da=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],he=O("loader-circle",Da);/**
|
|
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 Ma=[["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"}]],Hs=O("message-square-plus",Ma);/**
|
|
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 Pa=[["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"}]],Ks=O("panel-left-close",Pa);/**
|
|
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 $a=[["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"}]],Ra=O("panel-left-open",$a);/**
|
|
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 La=[["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"}]],Js=O("panel-right-close",La);/**
|
|
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 Ia=[["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"}]],Oa=O("panel-right-open",Ia);/**
|
|
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 Fa=[["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"}]],Yt=O("pencil",Fa);/**
|
|
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 Ua=[["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"}]],za=O("rotate-ccw",Ua);/**
|
|
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 Ba=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],bs=O("search",Ba);/**
|
|
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 Va=[["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"}]],Gs=O("send",Va);/**
|
|
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 qa=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],Wa=O("shield-alert",qa);/**
|
|
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 Ha=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ka=O("shield-check",Ha);/**
|
|
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 Ja=[["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"}]],Ga=O("sliders-horizontal",Ja);/**
|
|
143
|
+
* @license lucide-react v1.7.0 - ISC
|
|
144
|
+
*
|
|
145
|
+
* This source code is licensed under the ISC license.
|
|
146
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
147
|
+
*/const Ya=[["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"}]],Xa=O("trash-2",Ya);/**
|
|
148
|
+
* @license lucide-react v1.7.0 - ISC
|
|
149
|
+
*
|
|
150
|
+
* This source code is licensed under the ISC license.
|
|
151
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
152
|
+
*/const Za=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Qa=O("user",Za);/**
|
|
153
|
+
* @license lucide-react v1.7.0 - ISC
|
|
154
|
+
*
|
|
155
|
+
* This source code is licensed under the ISC license.
|
|
156
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
157
|
+
*/const eo=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Ys=O("wrench",eo),to=new Set(["assigned","running"]);function so(t,s){return t.reduce((r,n)=>n.assignedTo===s&&to.has(n.status)?r+1:r,0)}function We(t){return(t==null?void 0:t.toLowerCase())==="devtunnel"}function ro(t){return t?We(t)?"DevTunnel":t.charAt(0).toUpperCase()+t.slice(1):"Direct"}function Xt(t,s){return We(s??t.transportType)||!!t.devtunnelEndpoint}function Xs(t,s){return!We(s??t.transportType)}function Zs(t,s){const r=s??t.transportType;return We(r)?"DevTunnel":t.devtunnelEndpoint?"Direct + DevTunnel":ro(r)}function js(t,s){return!t&&!s}function no({routeTaskId:t,creatingTask:s,internalSelectedTaskId:r,sortedTaskIds:n}){return t||(s?null:r??n[0]??null)}function ao(t,s){return[s,...t.filter(r=>r.id!==s.id)]}const oo=new Set(["completed","failed","cancelled","archived"]);function io(t,s){const r=new Set(s);return new Set(Array.from(t).filter(n=>r.has(n)))}function lo(t,s){const r=new Set(s);if(r.size===0)return!1;const n=t.filter(a=>r.has(a.id));return n.length===r.size&&n.every(a=>oo.has(a.status))}function co(t,s){var n;const r=new Set(s);return((n=t.find(a=>!r.has(a.id)))==null?void 0:n.id)??null}function dt(t){return typeof t=="object"&&t!==null}function uo(t){if(!dt(t))return null;if(t.type==="text"&&typeof t.text=="string"){const s=t.text.trim();return s?{type:"text",text:s}:null}if(t.type==="image"&&typeof t.mediaType=="string"&&typeof t.data=="string"){const s=t.mediaType.trim(),r=t.data;return!s||!r?null:{type:"image",mediaType:s,data:r,...typeof t.filename=="string"&&t.filename.trim()?{filename:t.filename.trim()}:{}}}if(t.type==="tool_result"&&typeof t.toolUseId=="string"&&typeof t.content=="string"){const s=t.toolUseId.trim(),r=t.content.trim();return!s||!r?null:{type:"tool_result",toolUseId:s,content:r,...typeof t.isError=="boolean"?{isError:t.isError}:{}}}return null}function mo(t){if(!dt(t))return null;if(t.type==="text"&&typeof t.text=="string"){const n=t.text.trim();return n?{type:"text",text:n}:null}if(t.type!=="image"||!dt(t.source)){if(t.type==="tool_result"&&typeof t.tool_use_id=="string"&&typeof t.content=="string"){const n=t.tool_use_id.trim(),a=t.content.trim();return!n||!a?null:{type:"tool_result",toolUseId:n,content:a,...typeof t.is_error=="boolean"?{isError:t.is_error}:{}}}return null}const s=typeof t.source.media_type=="string"?t.source.media_type.trim():"",r=typeof t.source.data=="string"?t.source.data:"";return!s||!r?null:{type:"image",mediaType:s,data:r}}function Je(t){if(typeof t=="string"){const s=t.trim();return s?[{type:"text",text:s}]:[]}return Array.isArray(t)?t.map(s=>uo(s)??mo(s)).filter(s=>s!==null):[]}function Qs(t,s){const r=t.trim();return[...r?[{type:"text",text:r}]:[],...s]}function xo(t){return{role:"user",content:t.map(s=>s.type==="text"?{type:"text",text:s.text}:s.type==="tool_result"?{type:"tool_result",tool_use_id:s.toolUseId,content:s.content,...typeof s.isError=="boolean"?{is_error:s.isError}:{}}:{type:"image",source:{type:"base64",media_type:s.mediaType,data:s.data}})}}function Mt(t,s=new Date().toISOString()){return{type:"user",message:xo(t),timestamp:s}}function st(t){if(t.type!=="user"||t.isSynthetic===!0)return null;if(typeof t.message=="string"){const s=Je(t.message);return s.length>0?s:null}if(dt(t.message)&&Array.isArray(t.message.content)){const s=Je(t.message.content);return s.length>0?s:null}if(Array.isArray(t.content)){const s=Je(t.content);return s.length>0?s:null}return null}function fo(t){return Je(t.payload.initialMessage)}function Ze(t){return t.map(s=>{if(s.type==="text")return`t:${s.text}`;if(s.type==="tool_result")return`r:${s.toolUseId}:${s.isError===!0?"1":"0"}:${s.content}`;const r=s.data.slice(0,32),n=s.data.slice(-32);return`i:${s.mediaType}:${s.data.length}:${r}:${n}`}).join("|")}function po(t){return t.map(s=>s.type==="text"?s.text:s.type==="tool_result"?s.content:"").filter(Boolean).join(`
|
|
158
|
+
`)}function Zt(t){return`data:${t.mediaType};base64,${t.data}`}function ho(t){var a,i;if(!t)return[];const s=[],r=t.items;if(r)for(const d of Array.from(r)){if((d==null?void 0:d.kind)!=="file"||!((a=d.type)!=null&&a.startsWith("image/")))continue;const c=(i=d.getAsFile)==null?void 0:i.call(d);c&&c.type.startsWith("image/")&&s.push(c)}if(s.length>0)return s;const n=t.files;return n?Array.from(n).filter(d=>d.type.startsWith("image/")):[]}function go(t){return new Promise((s,r)=>{const n=new FileReader;n.onload=()=>{if(typeof n.result!="string"){r(new Error(`Failed to read ${t.name}`));return}s(n.result)},n.onerror=()=>r(n.error??new Error(`Failed to read ${t.name}`)),n.readAsDataURL(t)})}async function ys(t){return Promise.all(Array.from(t).map(async s=>{if(!s.type.startsWith("image/"))throw new Error(`${s.name} is not an image`);const r=await go(s),n=r.indexOf(",");if(n===-1)throw new Error(`Failed to parse ${s.name}`);return{type:"image",mediaType:s.type||"image/png",data:r.slice(n+1),filename:s.name}}))}function rt(t){return typeof t=="object"&&t!==null}function bo(t){return rt(t)&&typeof t.name=="string"&&t.name.toLowerCase()==="askuserquestion"}function jo(t){return!rt(t)||typeof t.label!="string"||!t.label.trim()?null:{label:t.label.trim(),description:typeof t.description=="string"?t.description.trim():""}}function yo(t){if(!rt(t)||typeof t.question!="string"||!t.question.trim())return null;const s=Array.isArray(t.options)?t.options.map(jo).filter(r=>r!==null):[];return s.length===0?null:{header:typeof t.header=="string"&&t.header.trim()?t.header.trim():void 0,question:t.question.trim(),multiSelect:t.multiSelect===!0,options:s}}function Ot(t){if(!rt(t)||!Array.isArray(t.questions))return null;const s=t.questions.map(yo).filter(r=>r!==null);return s.length===0?null:{questions:s}}function He(t){return JSON.stringify({questions:t.questions})}function vt(t){const s=Ot(t);if(s)return s;if(bo(t)){const r=rt(t.input)?t.input:void 0,n=Ot(r);return n?{...n,...typeof t.id=="string"&&t.id.trim()?{toolUseId:t.id.trim()}:{}}:null}return null}function vo(t){var a;const s=t.trim();if(!s)return[];const r=[s],n=s.matchAll(/```(?:json)?\s*([\s\S]*?)```/gi);for(const i of n){const d=(a=i[1])==null?void 0:a.trim();d&&r.push(d)}return r}function Nt(t){for(const s of vo(t))try{const r=JSON.parse(s),n=Ot(r);if(n)return n}catch{}return null}function No(t){return t.questions.map(s=>s.options.length>0?[0]:[])}function ko(t,s){return t.questions.every((r,n)=>(s[n]??[]).length>0)}function wo(t,s){const n=t.questions.map((a,i)=>{const d=[...new Set(s[i]??[])].sort((c,m)=>c-m).filter(c=>a.options[c]!==void 0);return{header:a.header??null,question:a.question,multiSelect:a.multiSelect,selectedOptions:d.map(c=>a.options[c]).filter(c=>c!==void 0)}}).map(a=>{const i=a.header??a.question,d=a.selectedOptions.map(c=>c.label).join(a.multiSelect?", ":"");return`${i}: ${d}`}).join(`
|
|
159
|
+
`);return t.toolUseId?[{type:"tool_result",toolUseId:t.toolUseId,content:n,isError:!1}]:[{type:"text",text:n}]}function Qe(t){return typeof t=="object"&&t!==null}function Co(t){if(!t)return;const s=["file_path","path","command"].map(r=>t[r]).find(r=>typeof r=="string"&&r.trim().length>0);return s==null?void 0:s.trim()}function So(t){const s=t.toLowerCase();return s.includes(" permission to write ")?"Write":s.includes(" permission to edit ")?"Edit":s.includes(" permission to run ")||s.includes(" permission to execute ")?"Bash":"Action"}function Ft(t){const s=t.trim();if(!s.startsWith("Awaiting your permission to "))return null;const r=s.match(/`([^`]+)`/);return{requests:[{toolName:So(s),target:r==null?void 0:r[1],summary:s}]}}function _o(t){if(!Array.isArray(t.permission_denials))return null;const s=[];for(const r of t.permission_denials){if(!Qe(r)||typeof r.tool_name!="string")continue;const n=Qe(r.tool_input)?r.tool_input:void 0,a=Co(n),i=typeof t.result=="string"&&t.result.trim().length>0?t.result.trim():`Awaiting your permission to use ${r.tool_name}${a?` on \`${a}\``:""}.`;s.push({toolName:r.tool_name,...typeof r.tool_use_id=="string"?{toolUseId:r.tool_use_id}:{},...a?{target:a}:{},summary:i})}return s.length>0?{requests:s}:null}function vs(t){if(!Array.isArray(t))return null;for(const s of t){if(!Qe(s)||s.type!=="text"||typeof s.text!="string")continue;const r=Ft(s.text);if(r)return r}return null}function Qt(t){if(!Qe(t))return null;const s=_o(t);if(s)return s;if(typeof t.result=="string"){const n=Ft(t.result);if(n)return n}if(typeof t.message=="string"){const n=Ft(t.message);if(n)return n}if(Qe(t.message)){const n=Qt(t.message);if(n)return n;const a=vs(t.message.content);if(a)return a}const r=vs(t.content);return r||null}function To(t){return JSON.stringify(t.requests.map(s=>({toolName:s.toolName,target:s.target??null,summary:s.summary})))}function Ao(t,s){return t.requests.map(r=>{const n=r.target?` for \`${r.target}\``:"",a=s==="approve"?`Approved. Proceed with the requested ${r.toolName} action${n}.`:`Denied. Do not proceed with the requested ${r.toolName} action${n}. Ask for another approach if needed.`;return r.toolUseId?{type:"tool_result",toolUseId:r.toolUseId,content:a,isError:s==="deny"}:s==="approve"?{type:"text",text:a}:{type:"text",text:a}})}function er(t){return st(t)!==null}function ct(t){if(t.type==="user"){const s=st(t),r=typeof t.timestamp=="string"?t.timestamp:"";if(s)return`user:${r}:${Ze(s)}`}return JSON.stringify(t)}function Ut(t){const s=vt(t);return s?`question:${He(s)}`:null}function Eo(t){const s=Qt(t);return s?`permission:${To(s)}`:null}function Ns(t){if(!Array.isArray(t))return null;const s=new Set;for(const r of t){const n=Ut(r);if(n){s.add(n);continue}if(typeof r=="object"&&r!==null&&r.type==="text"&&typeof r.text=="string"){const a=Nt(r.text);a&&s.add(He(a))}}return s.size===0?null:Array.from(s).sort().join("|")}function Do(t){const s=Ut(t);if(s)return s;if(typeof t.message=="string"){const r=Nt(t.message);return r?He(r):null}if(typeof t.message=="object"&&t.message!==null){const r=Ut(t.message);return r||Ns(t.message.content)}return Ns(t.content)}function Mo(t){return Eo(t)}function Po(t,s,r){const n=typeof s.timestamp=="string"?s.timestamp:"";return`${t}-${n}-${r}`}function $o(t,s){const r=s.map(a=>({...a})),n=new Set(r.map(ct));for(const a of t){const i=ct(a);n.has(i)||(r.push(a),n.add(i))}return r}function Ro(t,s){const r=ct(s);return t.some(n=>ct(n)===r)?t:[...t,{...s}]}function Lo(t,s){const r=new Map;for(const n of s){const a=st(n);if(!a)continue;const i=Ze(a);r.set(i,(r.get(i)??0)+1)}return t.filter(n=>{const a=Ze(n.content),i=r.get(a)??0;return i<=0?!0:(r.set(a,i-1),!1)})}function Io(t,s){const r=Ze(s),n=t.findIndex(a=>Ze(a.content)===r);return n===-1?t:t.filter((a,i)=>i!==n)}function Oo(t){return t.some(er)}function Fo(t){const s=[];let r=null;for(const n of t){if(er(n)){r=null,s.push(n);continue}const a=Mo(n)??Do(n);a&&a===r||(s.push(n),a&&(r=a))}return s}const Ve=o.forwardRef(({className:t,type:s,...r},n)=>e.jsx("input",{type:s,className:T("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:n,...r}));Ve.displayName="Input";var Uo=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],zo=Uo.reduce((t,s)=>{const r=fn(`Primitive.${s}`),n=o.forwardRef((a,i)=>{const{asChild:d,...c}=a,m=d?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...c,ref:i})});return n.displayName=`Primitive.${s}`,{...t,[s]:n}},{}),Bo="Label",tr=o.forwardRef((t,s)=>e.jsx(zo.label,{...t,ref:s,onMouseDown:r=>{var a;r.target.closest("button, input, select, textarea")||((a=t.onMouseDown)==null||a.call(t,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));tr.displayName=Bo;var sr=tr;const Vo=pn("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),_e=o.forwardRef(({className:t,...s},r)=>e.jsx(sr,{ref:r,className:T(Vo(),t),...s}));_e.displayName=sr.displayName;function qo({onAdded:t}){const[s,r]=o.useState(""),[n,a]=o.useState(!1),[i,d]=o.useState(null),c=o.useCallback(async m=>{if(m.preventDefault(),!!s.trim()){a(!0),d(null);try{await hn({leaderEndpoint:s.trim(),transport:"devtunnel"}),t()}catch(x){d(x instanceof Error?x.message:"Failed to join node")}finally{a(!1)}}},[s,t]);return e.jsx(gn,{className:"overflow-hidden border-border/60 bg-transparent p-0 shadow-none sm:max-w-xl",children:e.jsxs("div",{className:"overflow-hidden rounded-[28px] 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(bn,{className:"space-y-2 text-left",children:[e.jsx(jn,{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:c,className:"space-y-4 px-6 py-5",children:[i&&e.jsx("div",{className:"rounded-[20px] 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(_e,{htmlFor:"leader-endpoint",children:"Leader endpoint"}),e.jsx(pe,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),e.jsx(Ve,{id:"leader-endpoint",type:"url",value:s,onChange:m=>r(m.target.value),placeholder:"https://your-leader.devtunnels.ms",className:"h-11 rounded-2xl border-border/70 bg-background/70"})]}),e.jsx("div",{className:"rounded-[20px] 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(yn,{className:"border-t border-border/60 pt-4",children:e.jsx(A,{type:"submit",disabled:!s.trim()||n,className:"rounded-2xl",children:n?"Joining...":"Join node"})})]})]})})}function rr(){const[t,s]=o.useState([]),[r,n]=o.useState(null),a=o.useRef(null),i=o.useCallback(()=>{var u;(u=a.current)==null||u.click()},[]),d=o.useCallback(async u=>{const f=Array.from(u.target.files??[]);if(f.length!==0)try{const h=await ys(f);s(b=>[...b,...h]),n(null)}catch(h){n(h instanceof Error?h.message:"Failed to attach image")}finally{u.target.value=""}},[]),c=o.useCallback(async u=>{const f=ho(u.clipboardData);if(f.length!==0){u.preventDefault();try{const h=await ys(f);s(b=>[...b,...h]),n(null)}catch(h){n(h instanceof Error?h.message:"Failed to attach image")}}},[]),m=o.useCallback(u=>{s(f=>f.filter((h,b)=>b!==u))},[]),x=o.useCallback(()=>{s([]),n(null)},[]);return{images:t,error:r,fileInputRef:a,pickImages:i,handleFileChange:d,handlePaste:c,removeImage:m,clearImages:x}}function Wo({onSend:t,disabled:s,disabledReason:r="Chat is waiting on the agent.",placeholder:n="Send a follow-up message...",contextItems:a=[],running:i=!1,onStop:d}){const[c,m]=o.useState(""),x=o.useRef(null),{images:u,error:f,fileInputRef:h,pickImages:b,handleFileChange:p,handlePaste:k,removeImage:S,clearImages:j}=rr(),C=o.useCallback(()=>{x.current&&(x.current.style.height="auto")},[]),E=o.useCallback(()=>{const M=Qs(c,u);M.length===0||s||(t(M),m(""),j(),C())},[c,u,s,t,j,C]),B=o.useCallback(M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),E())},[E]),_=o.useCallback(()=>{x.current&&(x.current.style.height="auto",x.current.style.height=`${Math.min(x.current.scrollHeight,220)}px`)},[]),P=!s&&!i&&(c.trim().length>0||u.length>0),Q=i&&!!d,R=i?d?"Task is running — click to stop":"Task is running...":s?r:"Enter sends, Shift+Enter adds a line";return e.jsxs("div",{className:"border-t border-border/60 bg-background/55 px-2 py-1.5 backdrop-blur-xl sm:px-4 sm:py-2",children:[a.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-2 px-3 pb-2.5",children:a.map(M=>e.jsxs("div",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-border/60 bg-muted/40 px-3 py-1 text-xs",children:[e.jsx("span",{className:"shrink-0 text-[9px] font-medium uppercase tracking-[0.12em] text-muted-foreground/80",children:M.label}),e.jsx("span",{className:`truncate text-foreground/90 ${M.mono?"font-mono text-[11px]":""}`,children:M.value})]},`${M.label}:${M.value}`))}),e.jsxs("div",{className:"overflow-hidden rounded-3xl border border-border/65 bg-card/85 shadow-[0_28px_90px_-62px_rgba(0,0,0,var(--panel-shadow-alpha))] sm:rounded-[40px]",children:[e.jsx("input",{ref:h,type:"file",accept:"image/*",multiple:!0,onChange:p,className:"hidden"}),u.length>0&&e.jsx("div",{className:"px-3 pt-3 sm:px-6 sm:pt-6",children:e.jsx("div",{className:"flex flex-wrap gap-3",children:u.map((M,L)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:Zt(M),alt:M.filename??`attachment ${L+1}`,className:"h-24 w-24 rounded-[22px] border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>S(L),className:"absolute -top-2 -right-2 flex h-7 w-7 items-center justify-center rounded-full border border-border/70 bg-background text-muted-foreground transition-colors hover:text-foreground","aria-label":`Remove ${M.filename??`image ${L+1}`}`,children:e.jsx(Ye,{className:"h-3.5 w-3.5"})})]},`${M.filename??"image"}-${L}`))})}),e.jsxs("div",{className:"flex items-end gap-2 px-3 pt-3 pb-3 sm:px-6 sm:pt-4 sm:pb-4",children:[e.jsx("textarea",{ref:x,value:c,onChange:M=>m(M.target.value),onKeyDown:B,onPaste:k,onInput:_,placeholder:n,disabled:s,rows:1,className:"min-h-[2.5rem] flex-1 resize-none bg-transparent px-0 py-1 text-sm leading-7 text-foreground placeholder:text-muted-foreground/70 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),e.jsxs(A,{type:"button",variant:"ghost",onClick:b,disabled:s,className:"mb-0.5 h-9 shrink-0 gap-1.5 rounded-full px-2 text-xs text-muted-foreground hover:text-foreground sm:px-3",title:"Attach images",children:[e.jsx(It,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Images"})]}),e.jsx("span",{title:R,children:e.jsx(A,{onClick:i?d:E,disabled:i?!Q:!P,size:"icon","aria-label":i?"Stop running task":"Send message",className:"mb-0.5 h-9 w-9 shrink-0 rounded-full bg-primary/85 text-primary-foreground shadow-sm hover:bg-primary",children:i?e.jsx(he,{className:"h-4 w-4 animate-spin"}):e.jsx(Gs,{className:"h-4 w-4"})})})]}),f&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive sm:px-6 sm:py-3",children:f})]})]})}function et({payload:t,disabled:s=!1,bypassEnabled:r=!1,onBypassChange:n,onSubmit:a}){const[i,d]=o.useState(()=>r?No(t):t.questions.map(()=>[])),[c,m]=o.useState(!1),[x,u]=o.useState(!1);o.useEffect(()=>{r&&d(p=>p.map((k,S)=>{var j;return k.length>0?k:(j=t.questions[S])!=null&&j.options.length?[0]:[]}))},[r,t]);const f=ko(t,i)&&!s&&!c&&!x&&!!a,h=(p,k)=>{s||x||c||d(S=>S.map((j,C)=>{if(C!==p)return j;const E=t.questions[C];return E?E.multiSelect?j.includes(k)?j.filter(B=>B!==k):[...j,k].sort((B,_)=>B-_):[k]:j}))},b=async()=>{if(!f||!a)return;m(!0);const p=await a(wo(t,i));m(!1),p&&u(!0)};return e.jsxs("div",{className:"rounded-[24px] border border-primary/20 bg-primary/5 p-4 shadow-[0_24px_80px_-60px_hsl(var(--primary)/0.9)]",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-primary/20 bg-primary/10 text-primary",children:e.jsx(ma,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-primary/80",children:"Ask User Question"}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:"Select the answer you want to send back to the agent."})]})]}),e.jsxs(A,{type:"button",variant:r?"secondary":"outline",size:"sm",onClick:()=>n==null?void 0:n(!r),className:"rounded-full",children:[e.jsx(Ka,{className:"h-4 w-4"}),r?"Bypass on":"Bypass future questions"]})]}),e.jsx("div",{className:"mt-4 space-y-4",children:t.questions.map((p,k)=>{const S=i[k]??[];return e.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/75 p-4",children:[e.jsxs("div",{children:[p.header&&e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground",children:p.header}),e.jsx("div",{className:"mt-1 text-sm font-medium leading-6 text-foreground",children:p.question}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:p.multiSelect?"Select one or more options.":"Select one option."})]}),e.jsx("div",{className:"space-y-2",children:p.options.map((j,C)=>{const E=S.includes(C);return e.jsxs("button",{type:"button",onClick:()=>h(k,C),disabled:s||c||x,"aria-pressed":E,className:T("flex w-full items-start gap-3 rounded-[18px] border px-4 py-3 text-left transition-colors",E?"border-primary/50 bg-primary/10 text-foreground":"border-border/60 bg-background/80 text-foreground hover:border-primary/30 hover:bg-primary/5"),children:[e.jsx("span",{className:T("mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border",E?"border-primary bg-primary text-primary-foreground":"border-border/70 bg-background text-transparent"),children:e.jsx(Me,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium leading-5",children:j.label}),j.description&&e.jsx("span",{className:"mt-1 block text-xs leading-5 text-muted-foreground",children:j.description})]})]},`${j.label}-${C}`)})})]},`${p.header??"question"}-${k}`)})}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:r?"Bypass is enabled. New question cards will default to the first option.":"Enable bypass if you want future question cards to preselect the first option."}),e.jsx(A,{type:"button",onClick:()=>void b(),disabled:!f,className:"rounded-full px-5",children:x?"Sent":c?"Sending...":t.questions.length>1?"Send answers":"Send answer"})]})]})}function Ho({payload:t,disabled:s=!1,onSubmit:r}){const[n,a]=o.useState(null),[i,d]=o.useState(!1),c=!s&&!i&&!!r,m=async x=>{if(!c||!r)return;a(x);const u=await r(Ao(t,x));a(null),u&&d(!0)};return e.jsxs("div",{className:"rounded-[24px] border border-amber-500/25 bg-amber-500/5 p-4 shadow-[0_24px_80px_-60px_rgba(245,158,11,0.8)]",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-amber-500/25 bg-amber-500/10 text-amber-600 dark:text-amber-400",children:e.jsx(Wa,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-amber-700/80 dark:text-amber-300/80",children:"Permission Request"}),e.jsx("div",{className:"mt-1 space-y-3",children:t.requests.map((x,u)=>e.jsxs("div",{className:"rounded-[18px] border border-border/60 bg-background/75 px-4 py-3",children:[e.jsx("div",{className:"text-sm font-medium leading-6 text-foreground",children:x.summary}),(x.toolName||x.target)&&e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2 text-[11px] uppercase tracking-[0.18em] text-muted-foreground",children:[e.jsx("span",{children:x.toolName}),x.target&&e.jsx("span",{className:"font-mono normal-case tracking-normal",children:x.target})]})]},`${x.toolUseId??x.toolName}-${u}`))})]})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-end gap-2",children:[e.jsxs(A,{type:"button",variant:"outline",onClick:()=>void m("deny"),disabled:!c||n!==null,className:"rounded-full",children:[e.jsx(Ye,{className:"h-4 w-4"}),i?"Sent":n==="deny"?"Sending...":"Deny"]}),e.jsxs(A,{type:"button",onClick:()=>void m("approve"),disabled:!c||n!==null,className:"rounded-full",children:[e.jsx(Me,{className:"h-4 w-4"}),i?"Sent":n==="approve"?"Sending...":"Approve"]})]})]})}function ks({event:t,questionBypassEnabled:s=!1,onQuestionBypassChange:r,onSubmitQuestionResponse:n,questionResponseDisabled:a=!1}){const i=t.type,d=Qt(t),c=vt(t);if(d)return e.jsx(Ge,{children:e.jsx(Ho,{payload:d,onSubmit:n,disabled:a})});if(c)return e.jsx(Ge,{children:e.jsx(et,{payload:c,bypassEnabled:s,onBypassChange:r,onSubmit:n,disabled:a})});if(i==="user"){const m=Ko(t),x=m.filter(f=>f.type==="tool_result");if(x.length>0&&m.every(f=>f.type==="tool_result"))return e.jsx(Ge,{children:x.map((f,h)=>e.jsx(ar,{block:f,questionBypassEnabled:s,onQuestionBypassChange:r,onSubmitQuestionResponse:n,questionResponseDisabled:a},h))});const u=st(t);return u?e.jsx(Xo,{content:u}):null}return i==="assistant"?e.jsx(Zo,{event:t,questionBypassEnabled:s,onQuestionBypassChange:r,onSubmitQuestionResponse:n,questionResponseDisabled:a}):null}function Ko(t){const s=t.message,r=s==null?void 0:s.content;if(Array.isArray(r))return r.filter(a=>typeof a=="object"&&a!==null);const n=t.content;return Array.isArray(n)?n.filter(a=>typeof a=="object"&&a!==null):[]}function Pt(t){var r;const s=t.replace(/\r\n/g,`
|
|
160
|
+
`).split(`
|
|
161
|
+
`);for(;s.length>0&&((r=s[0])==null?void 0:r.trim())==="";)s.shift();return s.join(`
|
|
162
|
+
`)}function nr({text:t,className:s=""}){const[r,n]=o.useState(!1);if(!t)return null;const a=async i=>{i.stopPropagation();try{await navigator.clipboard.writeText(t),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return e.jsx("button",{type:"button",onClick:a,"aria-label":r?"Copied":"Copy message",className:`flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-background/80 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-opacity hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100 ${s}`,children:r?e.jsx(Me,{className:"h-3 w-3 text-emerald-500"}):e.jsx(yt,{className:"h-3 w-3"})})}async function Jo(t){let r=await(await fetch(t)).blob();r.type!=="image/png"&&(r=await Go(r)),await navigator.clipboard.write([new ClipboardItem({[r.type]:r})])}async function Go(t){const s=await createImageBitmap(t),r=document.createElement("canvas");r.width=s.width,r.height=s.height;const n=r.getContext("2d");if(!n)throw new Error("canvas 2d context unavailable");return n.drawImage(s,0,0),await new Promise((a,i)=>{r.toBlob(d=>d?a(d):i(new Error("toBlob failed")),"image/png")})}function Yo({dataUrl:t,className:s=""}){const[r,n]=o.useState(!1),a=async i=>{i.stopPropagation();try{await Jo(t),n(!0),setTimeout(()=>n(!1),1500)}catch(d){console.error("copy image failed",d)}};return e.jsx("button",{type:"button",onClick:a,"aria-label":r?"Copied":"Copy image",className:`flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-background/80 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-opacity hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100 ${s}`,children:r?e.jsx(Me,{className:"h-3 w-3 text-emerald-500"}):e.jsx(yt,{className:"h-3 w-3"})})}function Xo({content:t}){const s=po(t),r=t.filter(n=>n.type==="image");return e.jsx("div",{className:"animate-message-rise flex justify-end",children:e.jsxs("div",{className:"group relative flex max-w-[88%] items-start gap-3",children:[e.jsx(nr,{text:s,className:"absolute -left-8 top-2"}),e.jsxs("div",{className:"space-y-1 rounded-[26px] rounded-tr-md border border-primary/25 bg-primary px-4 py-3 text-[13px] leading-5 text-primary-foreground shadow-[0_20px_70px_-42px_hsl(var(--primary)/0.95)]",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.28em] text-primary-foreground/75",children:"You"}),s&&e.jsx("div",{className:"whitespace-pre-wrap",children:s}),r.length>0&&e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:r.map((n,a)=>{const i=Zt(n);return e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:i,alt:n.filename??`attachment ${a+1}`,className:"max-h-72 w-full rounded-2xl border border-primary-foreground/15 object-cover"}),e.jsx(Yo,{dataUrl:i,className:"absolute right-2 top-2"})]},`${n.filename??"image"}-${a}`)})})]}),e.jsx("div",{className:"mt-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-primary/20 bg-primary/10 text-primary",children:e.jsx(Qa,{className:"h-4 w-4"})})]})})}function Ge({children:t}){return e.jsx("div",{className:"animate-message-rise flex justify-start",children:e.jsxs("div",{className:"flex max-w-[92%] items-start gap-3",children:[e.jsx("div",{className:"mt-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-border/70 bg-muted/70 text-muted-foreground",children:e.jsx(Kt,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.28em] text-muted-foreground",children:"Agent"}),t]})]})})}function Zo({event:t,questionBypassEnabled:s,onQuestionBypassChange:r,onSubmitQuestionResponse:n,questionResponseDisabled:a}){const i=t.message;if(!i)return null;const d=vt(i);if(d)return e.jsx(Ge,{children:e.jsx(et,{payload:d,bypassEnabled:s,onBypassChange:r,onSubmit:n,disabled:a})});const c=i.content;if(!c||!Array.isArray(c))return null;const m=new Set,x=c.filter(p=>p.type==="text").map(p=>({...p,text:Pt(String(p.text??"")),questionPayload:Nt(Pt(String(p.text??"")))})).filter(p=>p.text.length>0||p.questionPayload),u=c.filter(p=>p.type==="thinking").map(p=>Pt(String(p.thinking??""))).filter(Boolean).join(`
|
|
163
|
+
|
|
164
|
+
`),f=c.filter(p=>p.type==="tool_use"),h=c.filter(p=>p.type==="tool_result");return x.length>0||u.length>0||f.length>0||h.length>0?e.jsxs(Ge,{children:[u.length>0&&e.jsx(si,{text:u}),x.map((p,k)=>{if(p.questionPayload){const S=He(p.questionPayload);return m.has(S)?null:(m.add(S),e.jsx(et,{payload:p.questionPayload,bypassEnabled:s,onBypassChange:r,onSubmit:n,disabled:a},k))}return e.jsxs("div",{className:"group relative rounded-[26px] rounded-tl-md border border-border/70 bg-card/80 px-4 py-3 text-[13px] leading-5 text-foreground shadow-[0_20px_70px_-58px_rgba(0,0,0,0.9)] backdrop-blur-sm",children:[e.jsx(nr,{text:p.text,className:"absolute right-2 top-2"}),e.jsx("div",{className:"whitespace-pre-wrap",children:p.text})]},k)}),f.map((p,k)=>e.jsx(ri,{block:p,renderedQuestionSignatures:m,questionBypassEnabled:s,onQuestionBypassChange:r,onSubmitQuestionResponse:n,questionResponseDisabled:a},k)),h.map((p,k)=>e.jsx(ar,{block:p,renderedQuestionSignatures:m,questionBypassEnabled:s,onQuestionBypassChange:r,onSubmitQuestionResponse:n,questionResponseDisabled:a},k))]}):null}function Qo(t){return t.replace(/\s+/g," ").trim()}function Ue(t,s=132){const r=Qo(t);return r?r.length>s?`${r.slice(0,s-3)}...`:r:""}function zt(t,s=84){if(typeof t=="string")return Ue(t,s);if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t)){const r=t.slice(0,3).map(n=>zt(n,28)).filter(Boolean).join(", ");return Ue(r||JSON.stringify(t),s)}if(typeof t=="object"&&t!==null){const r=Object.entries(t).slice(0,3).map(([n,a])=>`${n}: ${zt(a,32)}`).join(" · ");return Ue(r||JSON.stringify(t),s)}return""}function ei(t){if(!t)return"No input";const s=Object.entries(t).slice(0,4).map(([r,n])=>`${r}: ${zt(n,40)}`).filter(r=>r.trim().length>0).join(" · ");return Ue(s||JSON.stringify(t),156)||"No input"}function ti({expanded:t}){return e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-border/60 bg-background/70 px-2 py-1 text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:[t?"Less":"More",t?e.jsx(Rs,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})]})}function es({title:t,preview:s,icon:r,children:n,accentClassName:a,previewClassName:i="font-mono text-[11px] text-muted-foreground/90"}){const[d,c]=o.useState(!1);return e.jsxs("div",{className:`overflow-hidden rounded-[22px] border border-border/60 ${a}`,children:[e.jsxs("button",{type:"button",onClick:()=>c(m=>!m),className:"flex w-full items-start gap-3 px-4 py-3 text-left transition-colors hover:bg-background/30",children:[e.jsx("div",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-border/60 bg-background/70 text-muted-foreground",children:r}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-muted-foreground",children:t})}),e.jsx("div",{className:`mt-1 whitespace-pre-wrap break-words text-[12px] leading-5 ${i}`,children:s})]}),e.jsx(ti,{expanded:d})]}),d&&e.jsx("div",{className:"border-t border-border/60 px-4 py-3",children:n})]})}function si({text:t}){const s=Ue(t,156);return e.jsx(es,{title:"Thinking",preview:s,icon:e.jsx(da,{className:"h-3.5 w-3.5"}),accentClassName:"bg-muted/35",previewClassName:"text-[12px] leading-5 text-muted-foreground/90",children:e.jsx("div",{className:"whitespace-pre-wrap text-[13px] leading-5 text-muted-foreground/90",children:t})})}function ri({block:t,renderedQuestionSignatures:s,questionBypassEnabled:r,onQuestionBypassChange:n,onSubmitQuestionResponse:a,questionResponseDisabled:i}){const d=String(t.name??"tool"),c=t.input,m=vt(t);if(m){const u=He(m);return s!=null&&s.has(u)?null:(s==null||s.add(u),e.jsx(et,{payload:m,bypassEnabled:r,onBypassChange:n,onSubmit:a,disabled:i}))}const x=ei(c);if(d==="TodoWrite"){const u=ni(c==null?void 0:c.todos);if(u.length>0)return e.jsx(ai,{todos:u})}return e.jsx(es,{title:`Tool: ${d}`,preview:x,icon:e.jsx(Ys,{className:"h-3.5 w-3.5"}),accentClassName:"bg-muted/25",children:e.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:JSON.stringify(c??{},null,2)})})}function ar({block:t,renderedQuestionSignatures:s,questionBypassEnabled:r,onQuestionBypassChange:n,onSubmitQuestionResponse:a,questionResponseDisabled:i}){const d=t.content,c=typeof d=="string"?d:Array.isArray(d)?d.map(u=>String(u.text??"")).join(`
|
|
165
|
+
`):"";if(!c)return null;const m=Nt(c);if(m){const u=He(m);return s!=null&&s.has(u)?null:(s==null||s.add(u),e.jsx(et,{payload:m,bypassEnabled:r,onBypassChange:n,onSubmit:a,disabled:i}))}const x=Ue(c,156);return e.jsx(es,{title:"Result",preview:x,icon:e.jsx(Ys,{className:"h-3.5 w-3.5"}),accentClassName:"bg-background/65",children:e.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:c})})}function ni(t){return Array.isArray(t)?t.map(s=>{if(typeof s!="object"||s===null)return null;const r=s,n=typeof r.content=="string"?r.content:"";if(!n)return null;const a=typeof r.activeForm=="string"?r.activeForm:n,i=typeof r.status=="string"?r.status:"pending";return{content:n,activeForm:a,status:i==="completed"||i==="in_progress"?i:"pending"}}).filter(s=>s!==null):[]}function ai({todos:t}){const s=t.filter(a=>a.status==="completed").length,r=t.length,n=t.find(a=>a.status==="in_progress");return e.jsxs("div",{className:"overflow-hidden rounded-[22px] border border-border/60 bg-muted/20",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-border/50 px-4 py-3",children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-border/60 bg-background/70 text-muted-foreground",children:e.jsx(Ea,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-muted-foreground",children:"Todos"}),e.jsx("div",{className:"mt-0.5 truncate text-[12px] leading-5 text-muted-foreground/90",children:n?n.activeForm:r===0?"No items":s===r?"All complete":"Up next"})]}),e.jsxs("div",{className:"shrink-0 rounded-full border border-border/60 bg-background/70 px-2 py-0.5 font-mono text-[10px] tracking-wide text-muted-foreground",children:[s,"/",r]})]}),e.jsx("ul",{className:"divide-y divide-border/40",children:t.map((a,i)=>e.jsxs("li",{className:"flex items-start gap-3 px-4 py-2.5",children:[e.jsx(oi,{status:a.status}),e.jsx("span",{className:a.status==="completed"?"text-[13px] leading-5 text-muted-foreground line-through decoration-muted-foreground/60":a.status==="in_progress"?"text-[13px] font-medium leading-5 text-foreground":"text-[13px] leading-5 text-foreground/85",children:a.status==="in_progress"?a.activeForm:a.content})]},`${i}-${a.content}`))})]})}function oi({status:t}){return t==="completed"?e.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-emerald-500/15 text-emerald-500 dark:text-emerald-400",children:e.jsx(Me,{className:"h-3 w-3"})}):t==="in_progress"?e.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center text-primary",children:e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"})}):e.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground/60",children:e.jsx(fa,{className:"h-3 w-3"})})}var or="AlertDialog",[ii]=Os(or,[Ls]),Ae=Ls(),ir=t=>{const{__scopeAlertDialog:s,...r}=t,n=Ae(s);return e.jsx(vn,{...n,...r,modal:!0})};ir.displayName=or;var li="AlertDialogTrigger",lr=o.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=Ae(r);return e.jsx(Nn,{...a,...n,ref:s})});lr.displayName=li;var di="AlertDialogPortal",dr=t=>{const{__scopeAlertDialog:s,...r}=t,n=Ae(s);return e.jsx(kn,{...n,...r})};dr.displayName=di;var ci="AlertDialogOverlay",cr=o.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=Ae(r);return e.jsx(Tn,{...a,...n,ref:s})});cr.displayName=ci;var ze="AlertDialogContent",[ui,mi]=ii(ze),xi=An("AlertDialogContent"),ur=o.forwardRef((t,s)=>{const{__scopeAlertDialog:r,children:n,...a}=t,i=Ae(r),d=o.useRef(null),c=jt(s,d),m=o.useRef(null);return e.jsx(wn,{contentName:ze,titleName:mr,docsSlug:"alert-dialog",children:e.jsx(ui,{scope:r,cancelRef:m,children:e.jsxs(Cn,{role:"alertdialog",...i,...a,ref:c,onOpenAutoFocus:Lt(a.onOpenAutoFocus,x=>{var u;x.preventDefault(),(u=m.current)==null||u.focus({preventScroll:!0})}),onPointerDownOutside:x=>x.preventDefault(),onInteractOutside:x=>x.preventDefault(),children:[e.jsx(xi,{children:n}),e.jsx(pi,{contentRef:d})]})})})});ur.displayName=ze;var mr="AlertDialogTitle",xr=o.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=Ae(r);return e.jsx(Sn,{...a,...n,ref:s})});xr.displayName=mr;var fr="AlertDialogDescription",pr=o.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=Ae(r);return e.jsx(_n,{...a,...n,ref:s})});pr.displayName=fr;var fi="AlertDialogAction",hr=o.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=Ae(r);return e.jsx(Is,{...a,...n,ref:s})});hr.displayName=fi;var gr="AlertDialogCancel",br=o.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:a}=mi(gr,r),i=Ae(r),d=jt(s,a);return e.jsx(Is,{...i,...n,ref:d})});br.displayName=gr;var pi=({contentRef:t})=>{const s=`\`${ze}\` requires a description for the component to be accessible for screen reader users.
|
|
166
|
+
|
|
167
|
+
You can add a description to the \`${ze}\` by passing a \`${fr}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
|
|
168
|
+
|
|
169
|
+
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${ze}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
170
|
+
|
|
171
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return o.useEffect(()=>{var n;document.getElementById((n=t.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},hi=ir,gi=lr,bi=dr,jr=cr,yr=ur,vr=hr,Nr=br,kr=xr,wr=pr;const Bt=hi,ws=gi,ji=bi,Cr=o.forwardRef(({className:t,...s},r)=>e.jsx(jr,{className:T("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:r}));Cr.displayName=jr.displayName;const ut=o.forwardRef(({className:t,...s},r)=>e.jsxs(ji,{children:[e.jsx(Cr,{}),e.jsx(yr,{ref:r,className:T("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s})]}));ut.displayName=yr.displayName;const mt=({className:t,...s})=>e.jsx("div",{className:T("flex flex-col space-y-2 text-center sm:text-left",t),...s});mt.displayName="AlertDialogHeader";const xt=({className:t,...s})=>e.jsx("div",{className:T("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});xt.displayName="AlertDialogFooter";const ft=o.forwardRef(({className:t,...s},r)=>e.jsx(kr,{ref:r,className:T("text-lg font-semibold",t),...s}));ft.displayName=kr.displayName;const pt=o.forwardRef(({className:t,...s},r)=>e.jsx(wr,{ref:r,className:T("text-sm text-muted-foreground",t),...s}));pt.displayName=wr.displayName;const ht=o.forwardRef(({className:t,...s},r)=>e.jsx(vr,{ref:r,className:T(Fs(),t),...s}));ht.displayName=vr.displayName;const gt=o.forwardRef(({className:t,...s},r)=>e.jsx(Nr,{ref:r,className:T(Fs({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));gt.displayName=Nr.displayName;const Vt="bypass",ts=[{value:"claudecode",label:"claudecode",supportsFollowUp:!0},{value:"codex",label:"codex",supportsFollowUp:!0},{value:"mars",label:"mars",disabled:!0,description:"coming soon"},{value:"eureka",label:"eureka",disabled:!0,description:"coming soon"}],Sr=[{value:"bypass",label:"Bypass"},{value:"plan",label:"Plan"},{value:"edit",label:"Edit"},{value:"dangerous",label:"Dangerous"}],yi=new Set(ts.filter(t=>t.supportsFollowUp).map(t=>t.value)),vi=20,Ni=3,Cs="meshy-working-dir-recents-by-node";function ki(t){return t.startsWith("/")||t.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(t)}function wi(t){const s=t.trim();return s||"."}function qt(t){const s=[],r=new Set;for(const n of t){const a=n.trim();if(!(!a||r.has(a))&&(r.add(a),s.push(a),s.length===Ni))break}return s}function Ci(t,s){const r=s.trim();return qt(r?[r,...t]:t)}function Si(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const s={};for(const[r,n]of Object.entries(t)){if(!r||!Array.isArray(n))continue;const a=n.filter(d=>typeof d=="string"),i=qt(a);i.length>0&&(s[r]=i)}return s}function _i(t,s,r){if(!s)return t;const n=t[s]??[],a=Ci(n,r);if(a.length===0){if(!(s in t))return t;const{[s]:i,...d}=t;return d}return{...t,[s]:a}}function Ti(t,s,r){return t!=="auto"?s.find(n=>n.id===t)??null:r.length===1?r[0]??null:null}function Ai(t,s){const r=s.trim();return r?ki(r)||!t?r:`${t.replace(/[/\\]+$/,"")}/${r}`:""}function Ei(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 Ss({value:t,onChange:s,assignTo:r,nodes:n,assignableNodes:a,layout:i="default",chipClassName:d,chipActiveClassName:c,chipInactiveClassName:m,labelClassName:x,triggerClassName:u}){const[f,h]=o.useState(!1),[b,p]=o.useState(null),[k,S]=o.useState(!1),[j,C]=o.useState(!1),[E,B]=o.useState(null),[_,P]=o.useState(""),[Q,R]=o.useState(!1),[M,L]=o.useState({}),ee=o.useRef(null),D=o.useMemo(()=>Ti(r,n,a),[r,n,a]),W=D==null?void 0:D.id,xe=o.useMemo(()=>W?M[W]??[]:[],[M,W]),F=o.useMemo(()=>t.trim()?Ai(D==null?void 0:D.workDir,t):"Use node default",[t,D==null?void 0:D.workDir]);o.useEffect(()=>{if(!(typeof window>"u"))try{const y=window.localStorage.getItem(Cs);if(!y)return;const Y=JSON.parse(y);L(Si(Y))}catch{}},[]);const re=o.useCallback(y=>{W&&L(Y=>{const I=_i(Y,W,y);if(I===Y)return Y;if(typeof window<"u")try{window.localStorage.setItem(Cs,JSON.stringify(I))}catch{}return I})},[W]),H=o.useCallback((y,Y=!0)=>{const I=y.trim();s(I),Y&&I&&re(I),h(!1)},[s,re]),Z=o.useCallback(async(y,Y=0,I=!1)=>{if(W){B(null),I?C(!0):S(!0);try{const X=await En(W,{path:y,limit:vi,offset:Y,directoriesOnly:!0,allowAbsolute:!0});p(N=>I&&N?{...X,entries:[...N.entries,...X.entries]}:X)}catch(X){B(X instanceof Error?X.message:"Failed to browse directories"),I||p(null)}finally{S(!1),C(!1)}}},[W]),ue=o.useRef(t);ue.current=t;const ge=o.useRef(Z);ge.current=Z,o.useEffect(()=>{if(!f)return;const y=ue.current;P(y),R(!1),p(null),B(null),W&&ge.current(wi(y))},[f,W]),o.useEffect(()=>{if(!f)return;const y=I=>{ee.current&&(ee.current.contains(I.target)||h(!1))},Y=I=>{I.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",y),document.addEventListener("keydown",Y),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",Y)}},[f]);const oe=o.useCallback(y=>{Z(y)},[Z]),de=o.useCallback(()=>{b&&Z(b.currentPath,b.entries.length,!0)},[b,Z]),K=i==="composer"?e.jsxs(A,{type:"button",variant:"ghost",onClick:()=>h(y=>!y),title:F,"aria-label":`Working directory: ${F}`,className:T(d,u,"min-w-0 max-w-full",t.trim()?c:m),children:[e.jsx(Dn,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:T("min-w-0 truncate",x),children:F})]}):e.jsxs(A,{type:"button",variant:"outline",onClick:()=>h(y=>!y),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:F,children:[e.jsx("span",{className:T("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:F}),e.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:D?D.name:"Manual"})]}),ie=Ei(b,D),fe=!!(b!=null&&b.parentPath);return e.jsxs("div",{className:T("relative inline-block",i==="composer"?"min-w-0 flex-1":"w-full"),ref:ee,children:[i==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Working directory"}),K]}):K,f&&e.jsxs("div",{className:T("absolute z-50 mt-2 w-[360px] overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",i==="composer"?"left-0":"left-0 right-0 w-auto min-w-[320px]"),children:[xe.length>0&&e.jsxs("div",{className:"border-b border-border/60 px-3 py-2.5",children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:[e.jsx(Ca,{className:"h-3 w-3"}),"Recent"]}),e.jsx("div",{className:"flex flex-col gap-1",children:xe.map(y=>e.jsx("button",{type:"button",onClick:()=>H(y,!1),className:"truncate rounded-md px-2 py-1 text-left font-mono text-xs text-foreground hover:bg-background/60",title:y,children:y},y))})]}),e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsx("button",{type:"button",onClick:()=>(b==null?void 0:b.parentPath)&&oe(b.parentPath),disabled:!fe||k,className:"flex h-7 w-7 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(ia,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:ie,children:ie}),b&&e.jsx("button",{type:"button",onClick:()=>H(b.isAbsolute?b.currentPath:b.currentPath==="."?"":b.currentPath),className:"shrink-0 rounded-md px-2 py-1 text-[11px] font-medium text-foreground hover:bg-background/60",title:"Use this folder",children:"Use"})]}),e.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[D?k?e.jsxs("div",{className:"flex items-center justify-center px-3 py-6 text-xs text-muted-foreground",children:[e.jsx(he,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Loading..."]}):b&&b.entries.length>0?e.jsxs(e.Fragment,{children:[b.entries.map(y=>e.jsxs("div",{className:"group flex items-stretch border-b border-border/40 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>H(y.path),className:"flex min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left hover:bg-background/55",title:`Use ${y.path}`,children:[e.jsx(ja,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-sm text-foreground",children:y.name})]}),e.jsx("button",{type:"button",onClick:()=>oe(y.path),className:"flex w-16 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 ${y.name}`,children:e.jsx(Xe,{className:"h-4 w-4"})})]},y.path)),b.hasMore&&e.jsx("div",{className:"border-t border-border/60 p-2",children:e.jsxs(A,{type:"button",variant:"outline",size:"sm",onClick:de,disabled:j,className:"h-8 w-full rounded-md text-xs",children:[j?e.jsx(he,{className:"mr-1.5 h-3 w-3 animate-spin"}):null,"Load more"]})})]}):e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:E??"No subfolders."}):e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Select a specific node to browse folders."}),E&&b&&b.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-2 text-xs text-destructive",children:E})]}),e.jsx("div",{className:"flex items-center gap-1.5 border-t border-border/60 bg-background/40 px-3 py-2",children:Q?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{value:_,onChange:y=>P(y.target.value),onKeyDown:y=>{y.key==="Enter"&&_.trim()?(y.preventDefault(),H(_)):y.key==="Escape"&&(y.preventDefault(),R(!1),P(t))},autoFocus:!0,placeholder:"Path (relative or absolute)",className:"h-8 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-xs"}),e.jsx("button",{type:"button",onClick:()=>H(_),disabled:!_.trim(),className:"flex h-8 w-8 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(Me,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:()=>{R(!1),P(t)},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","aria-label":"Cancel manual path",children:e.jsx(Ye,{className:"h-4 w-4"})})]}):e.jsxs("button",{type:"button",onClick:()=>{P(t),R(!0)},className:"flex h-8 flex-1 items-center justify-between rounded-md px-2 text-xs text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Enter a manual path",children:[e.jsx("span",{children:"Manual input"}),e.jsx(Yt,{className:"h-3.5 w-3.5"})]})})]})]})}function Di(t,s={}){const r=t.filter(n=>n.status==="online");return s.currentNodeRole!=="follower"||!s.leaderNodeId?r:r.filter(n=>n.id!==s.leaderNodeId)}function _s(){return ts.map(t=>e.jsx(me,{value:t.value,disabled:t.disabled,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 Ts(){return Sr.map(t=>e.jsx(me,{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 _r({isCurrent:t}){return t?e.jsx(Ta,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):e.jsx(ka,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function As(t,s){return t.map(r=>{const n=!!s&&r.id===s;return e.jsx(me,{value:r.id,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(_r,{isCurrent:n}),e.jsx("span",{className:"truncate",children:r.name}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:n?"current":"remote"})]})},r.id)})}function Mi(t){var s;return((s=ts.find(r=>r.value===t))==null?void 0:s.label)??t}function Pi(t){var s;return((s=Sr.find(r=>r.value===t))==null?void 0:s.label)??t}function Tr(t,s,r=!1){const n=t.trim();if(n)return n;const a=s.trim().split(`
|
|
172
|
+
`).map(i=>i.trim()).find(Boolean);return a?a.length>72?`${a.slice(0,69).trimEnd()}...`:a:r?"Image task":""}function $i(t){const s=Tr(t.title,t.description,t.images.length>0),r=t.description.trim()||s,n=t.mode??Vt,a=Qs(t.description,t.images);return!s||!r||!t.agent?null:{title:s,description:r,agent:t.agent,project:t.project.trim()||null,payload:{initialMessage:a,mode:n},priority:t.priority,assignTo:t.assignTo==="auto"?void 0:t.assignTo}}function Ri({nodes:t,currentNodeRole:s,currentNodeId:r,leaderNodeId:n,onCreated:a,onCancel:i,className:d,footerClassName:c,submitLabel:m="Create chat",cancelLabel:x="Cancel",autoFocus:u=!1,layout:f="default"}){const[h,b]=o.useState(""),[p,k]=o.useState(""),[S,j]=o.useState("claudecode"),[C,E]=o.useState(Vt),[B,_]=o.useState(""),[P,Q]=o.useState("normal"),R=o.useMemo(()=>Di(t,{currentNodeRole:s,leaderNodeId:n}),[t,s,n]),M=o.useMemo(()=>{var w;return r&&R.some(U=>U.id===r)?r:((w=R[0])==null?void 0:w.id)??""},[R,r]),[L,ee]=o.useState(M),[D,W]=o.useState(!1),[xe,F]=o.useState(!1),{images:re,error:H,fileInputRef:Z,pickImages:ue,handleFileChange:ge,handlePaste:oe,removeImage:de}=rr(),K=o.useMemo(()=>R.find(w=>w.id===L)??null,[L,R]),ie=!!(r&&(K==null?void 0:K.id)===r),fe=Mi(S),y=Pi(C);o.useEffect(()=>{L&&R.some(w=>w.id===L)||ee(M)},[L,R,M]),o.useEffect(()=>{_("")},[L]);const Y=o.useCallback(async w=>{w.preventDefault();const U=$i({title:h,description:p,agent:S,project:B,priority:P,assignTo:L,mode:C,images:re});if(U){W(!0);try{const we=await Mn(U);a(we)}catch(we){ae.error(we instanceof Error?we.message:"Failed to create task")}finally{W(!1)}}},[h,p,S,B,P,L,C,re,a]),I=Tr(h,p,re.length>0),X=!!(I&&S&&L&&(p.trim()||re.length>0)),N=o.useCallback(w=>{var U;w.nativeEvent.isComposing||w.key==="Enter"&&(w.ctrlKey||w.metaKey)&&X&&!D&&(w.preventDefault(),(U=w.currentTarget.form)==null||U.requestSubmit())},[X,D]),ne=re.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3",children:re.map((w,U)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:Zt(w),alt:w.filename??`attachment ${U+1}`,className:"h-24 w-24 rounded-2xl border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>de(U),className:"absolute -top-2 -right-2 flex h-6 w-6 items-center justify-center rounded-full border border-border/70 bg-background text-muted-foreground transition-colors hover:text-foreground","aria-label":`Remove ${w.filename??`image ${U+1}`}`,children:e.jsx(Ye,{className:"h-3.5 w-3.5"})})]},`${w.filename??"image"}-${U}`))}),V=e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Assign to"}),e.jsxs(ye,{value:L,onValueChange:ee,children:[e.jsx(ve,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:e.jsx(Te,{placeholder:"Select node"})}),e.jsx(Ne,{children:As(R,r)})]})]}),J=e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Agent"}),e.jsxs(ye,{value:S,onValueChange:j,children:[e.jsx(ve,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:e.jsx(Te,{placeholder:"Select agent"})}),e.jsx(Ne,{children:_s()})]})]}),te=e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Mode"}),e.jsxs(ye,{value:C,onValueChange:w=>E(w),children:[e.jsx(ve,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:e.jsx(Te,{placeholder:"Select mode"})}),e.jsx(Ne,{children:Ts()})]})]}),be=e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Priority"}),e.jsxs(ye,{value:P,onValueChange:Q,children:[e.jsx(ve,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:e.jsx(Te,{placeholder:"Select priority"})}),e.jsxs(Ne,{children:[e.jsx(me,{value:"low",children:"Low"}),e.jsx(me,{value:"normal",children:"Normal"}),e.jsx(me,{value:"high",children:"High"}),e.jsx(me,{value:"critical",children:"Critical"})]})]})]}),ke=e.jsx(Ss,{value:B,onChange:_,assignTo:L,nodes:t,assignableNodes:R});return f==="composer"?e.jsxs("form",{onSubmit:Y,className:T("space-y-4",d),children:[e.jsx("input",{ref:Z,type:"file",accept:"image/*",multiple:!0,onChange:ge,className:"hidden"}),(()=>{const w="chat-composer__chip h-9 w-auto gap-1.5 rounded-full px-3.5 text-xs shadow-none transition-colors",U="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",we="border-border/70 bg-background/55 text-foreground",Le=S==="claudecode",wt=C===Vt;return e.jsxs("div",{className:"chat-composer relative rounded-[24px] border border-border/60 bg-background/45 shadow-[0_20px_80px_-40px_rgba(0,0,0,0.6)]",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(ye,{value:L,onValueChange:ee,children:[e.jsx(ve,{className:T(w,we,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${(K==null?void 0:K.name)??"unassigned"}`,"aria-label":`Assigned node: ${(K==null?void 0:K.name)??"unassigned"}`,children:K?e.jsxs(e.Fragment,{children:[e.jsx(_r,{isCurrent:ie}),e.jsx("span",{className:"min-w-0 truncate",children:K.name}),e.jsx("span",{className:"chat-composer__header-meta shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:ie?"current":"remote"})]}):e.jsx(Te,{placeholder:"Select node"})}),e.jsx(Ne,{children:As(R,r)})]}),xe?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ve,{id:"task-title-composer",type:"text",value:h,onChange:ce=>b(ce.target.value),onKeyDown:ce=>{(ce.key==="Enter"||ce.key==="Escape")&&(ce.preventDefault(),F(!1))},autoFocus:!0,placeholder:"Chat title",className:"h-8 w-48 min-w-0 rounded-full border-border/70 bg-background/55 px-3 text-xs shadow-none"}),e.jsx(A,{type:"button",variant:"ghost",size:"icon",onClick:()=>F(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-full text-muted-foreground hover:text-foreground",children:e.jsx(Me,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>F(!0),className:"chat-composer__title-button flex min-w-0 items-center gap-1.5 rounded-full px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-background/55 hover:text-foreground",title:I||"Title","aria-label":I?`Edit title: ${I}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:I||"Title"}),e.jsx(Yt,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",value:p,onChange:ce=>k(ce.target.value),onKeyDown:N,onPaste:oe,placeholder:"Ask anything...",rows:4,autoFocus:u,"aria-label":"Opening prompt",className:"min-h-[140px] w-full resize-none rounded-[24px] bg-transparent px-5 pt-2 pb-16 text-[15px] leading-7 text-foreground ring-offset-background placeholder:text-muted-foreground/70 focus-visible:outline-none"}),e.jsxs("div",{className:"chat-composer__rail absolute bottom-3 left-3 right-3 flex flex-nowrap items-center gap-2",children:[e.jsx(A,{type:"button",variant:"ghost",size:"icon",onClick:ue,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-full text-muted-foreground hover:text-foreground",children:e.jsx(It,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsx(Ss,{value:B,onChange:_,assignTo:L,nodes:t,assignableNodes:R,layout:"composer",chipClassName:w,chipActiveClassName:we,chipInactiveClassName:U,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__footer-label"}),e.jsxs(ye,{value:S,onValueChange:j,children:[e.jsxs(ve,{className:T(w,"chat-composer__icon-trigger",Le?U:we),title:`Agent: ${fe}`,"aria-label":`Agent: ${fe}`,children:[e.jsx(Kt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:fe})]}),e.jsx(Ne,{children:_s()})]}),e.jsxs(ye,{value:C,onValueChange:ce=>E(ce),children:[e.jsxs(ve,{className:T(w,"chat-composer__icon-trigger",wt?U:we),title:`Mode: ${y}`,"aria-label":`Mode: ${y}`,children:[e.jsx(Ga,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:y})]}),e.jsx(Ne,{children:Ts()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[e.jsxs(ye,{value:P,onValueChange:Q,children:[e.jsx(ve,{"aria-label":`Priority: ${P}`,title:`Priority: ${P}`,className:T("h-9 w-9 justify-center gap-0 rounded-full p-0 text-xs shadow-none [&>svg:last-child]:hidden",P==="normal"?"border-transparent bg-transparent text-muted-foreground hover:bg-background/40":"border-border/70 bg-background/55",P==="critical"&&"text-destructive",P==="high"&&"text-amber-600 dark:text-amber-400",P==="low"&&"text-muted-foreground"),children:e.jsx(ga,{className:T("h-4 w-4",P==="critical"&&"fill-destructive/20")})}),e.jsxs(Ne,{children:[e.jsx(me,{value:"low",children:"Low"}),e.jsx(me,{value:"normal",children:"Normal"}),e.jsx(me,{value:"high",children:"High"}),e.jsx(me,{value:"critical",children:"Critical"})]})]}),i&&e.jsxs(A,{type:"button",variant:"ghost",size:"sm",onClick:i,"aria-label":x,className:"chat-composer__cancel h-9 rounded-full px-4 text-xs text-muted-foreground",children:[e.jsx(Ye,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:x})]}),e.jsxs(A,{type:"submit",size:"icon",disabled:!X||D,className:"h-10 w-10 rounded-full shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[D?e.jsx(he,{className:"h-4 w-4 animate-spin"}):e.jsx(Gs,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:D?"Creating chat":m})]})]})]})]})})(),(ne||H)&&e.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/45 p-4",children:[ne,H&&e.jsx("div",{className:"text-xs text-destructive",children:H}),!H&&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:Y,className:T("space-y-5",d),children:[e.jsx("input",{ref:Z,type:"file",accept:"image/*",multiple:!0,onChange:ge,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"task-description",className:"text-sm font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",value:p,onChange:w=>k(w.target.value),onKeyDown:N,onPaste:oe,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:u,className:"flex min-h-[144px] w-full resize-none rounded-[22px] 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(A,{type:"button",variant:"outline",onClick:ue,className:"rounded-2xl",children:[e.jsx(It,{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."})]}),ne,H&&e.jsx("p",{className:"text-xs text-destructive",children:H})]}),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(_e,{htmlFor:"task-title",className:"text-sm font-medium",children:"Chat title"}),e.jsx(Ve,{id:"task-title",type:"text",value:h,onChange:w=>b(w.target.value),placeholder:"Optional. Leave blank to derive it from the prompt.",className:"h-11 rounded-2xl border-border/70 bg-background/70"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:I?`Will appear as: ${I}`:"A title will be generated from the first line of the prompt."})]}),J,te]}),ke,e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[be,V]}),e.jsxs("div",{className:T("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",c),children:[i&&e.jsx(A,{type:"button",variant:"ghost",onClick:i,className:"rounded-2xl",children:x}),e.jsx(A,{type:"submit",disabled:!X||D,className:"rounded-2xl px-5",children:D?"Creating...":m})]})]})}const Li=[{value:"active",label:"Active"},{value:"running",label:"Running"},{value:"waiting",label:"Waiting"},{value:"closed",label:"Closed"},{value:"archived",label:"Archived"}],bt=new Set(["pending","assigned"]),Ar=new Set(["running"]),Ii=new Set(["completed","failed","cancelled"]);function Oi(t,s){switch(s){case"running":return Ar.has(t.status);case"waiting":return bt.has(t.status);case"closed":return Ii.has(t.status);case"archived":return t.status==="archived";case"active":default:return t.status!=="archived"}}function Fi(t,s){const r=s.trim().toLowerCase();return r?[t.title,t.description,t.id,t.agent,t.assignedTo??"",t.assignedNodeName??"",t.project??"",t.effectiveProjectPath??""].some(n=>n.toLowerCase().includes(r)):!0}function ss(t,s,r){if(!t)return"unassigned";const n=s==null?void 0:s.find(a=>a.id===t);return(n==null?void 0:n.name)??r??t.slice(0,8)}function Ui(t,s,r){return ss(t,s,r).toLowerCase()}function zi(t,s){return[...t].sort((r,n)=>r.id===s?-1:n.id===s?1:r.name.localeCompare(n.name))}function Bi(t){if(!t||typeof t!="object")return null;const s=t;return{draftNewTask:s.draftNewTask===!0,returnRoute:typeof s.returnRoute=="string"?s.returnRoute:void 0,returnTaskId:typeof s.returnTaskId=="string"||s.returnTaskId===null?s.returnTaskId:void 0}}function Vi(t){switch(t){case"running":return"bg-amber-500";case"completed":return"bg-emerald-500";case"failed":return"bg-destructive";case"cancelled":case"archived":return"bg-slate-400";case"assigned":return"bg-teal-500";case"pending":default:return"bg-muted-foreground"}}function qi(t){return t==="default workspace"?t:t.replace(/\\/g,"/").split("/").filter(Boolean).at(-1)??t}function Wi(t){const s=Date.now()-t;return s<6e4?"just now":s<36e5?`${Math.floor(s/6e4)}m`:s<864e5?`${Math.floor(s/36e5)}h`:`${Math.floor(s/864e5)}d`}function Hi(t){return new Date(t).toLocaleString()}function Ki(t){const s=Math.floor(t/1e3),r=Math.floor(s/3600),n=Math.floor(s%3600/60),a=s%60;return`${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}:${String(a).padStart(2,"0")}`}async function qe(t,s="Copied to clipboard"){var r,n,a;try{if((n=(r=globalThis.navigator)==null?void 0:r.clipboard)!=null&&n.writeText)return await globalThis.navigator.clipboard.writeText(t),ae.success(s),!0;const i=globalThis.document,d=(a=i==null?void 0:i.execCommand)==null?void 0:a.bind(i);if(!(i!=null&&i.body)||typeof i.createElement!="function"||typeof d!="function")throw new Error("Clipboard access is unavailable");const c=i.createElement("textarea"),m=i.activeElement,x=m&&typeof m.focus=="function"?m:null;c.value=t,c.setAttribute("readonly","true"),c.style.position="fixed",c.style.opacity="0",c.style.pointerEvents="none",i.body.appendChild(c),c.select(),c.setSelectionRange(0,c.value.length);const u=d("copy");if(i.body.removeChild(c),x==null||x.focus(),!u)throw new Error("Clipboard access is unavailable");return ae.success(s),!0}catch(i){return ae.error(i instanceof Error?i.message:"Failed to copy"),!1}}function Ji(t,s){const r=new Map;for(const a of t){const i=a.assignedTo??null,d=i??"__unassigned__",c=i?s.get(i)??a.assignedNodeName??i.slice(0,8):"Unassigned",m=a.effectiveProjectPath??a.project??"default workspace";r.has(d)||r.set(d,{nodeId:i,nodeName:c,dirMap:new Map});const x=r.get(d);x.dirMap.has(m)||x.dirMap.set(m,[]),x.dirMap.get(m).push(a)}const n=Array.from(r.values()).map(({nodeId:a,nodeName:i,dirMap:d})=>{const c=Array.from(d.entries()).map(([m,x])=>({path:m,tasks:x})).sort((m,x)=>x.tasks.length-m.tasks.length||m.path.localeCompare(x.path));return{nodeId:a,nodeName:i,dirs:c}});return n.sort((a,i)=>a.nodeId===null?1:i.nodeId===null?-1:a.nodeName.localeCompare(i.nodeName)),n}function Fe({label:t,value:s}){return e.jsxs("div",{className:"min-w-[7.25rem] flex-1 rounded-[20px] border border-border/60 bg-background/45 px-3 py-3",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:t}),e.jsx("div",{className:"mt-1 text-lg font-semibold tracking-tight text-foreground",children:s})]})}function $t({label:t}){return e.jsx("div",{className:"flex h-64 items-center justify-center text-sm text-muted-foreground",children:t})}function Se({label:t,value:s,mono:r,action:n}){return e.jsxs("div",{className:"grid grid-cols-[5.25rem,minmax(0,1fr)] items-start gap-3",children:[e.jsx("span",{className:"pt-0.5 text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:t}),e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx("span",{className:T("min-w-0 flex-1 break-all text-sm text-foreground",r&&"font-mono text-[11px] leading-5"),children:s}),n]})]})}function Wt({label:t,value:s,mono:r}){return e.jsxs("div",{className:"rounded-[18px] border border-border/60 bg-background/60 px-3 py-3",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:t}),e.jsx("div",{className:T("mt-1 text-sm font-medium text-foreground",r&&"font-mono text-[11px]"),children:s})]})}function Er({capabilities:t,action:s}){return e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Capabilities"}),e.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:t.length>0?t.map(r=>e.jsx(pe,{variant:"secondary",className:"rounded-full",children:r},r)):e.jsx("span",{className:"text-sm text-muted-foreground",children:"None declared"})})]}),s&&e.jsx("div",{className:"shrink-0 self-start",children:s})]})}const Gi=o.lazy(async()=>({default:(await Jt(()=>import("./FilesTab-lmhjg0sO.js"),__vite__mapDeps([0,1,2,3]))).FilesTab})),Yi=o.lazy(async()=>({default:(await Jt(()=>import("./PreviewTab-DPnxufTZ.js"),__vite__mapDeps([4,1,2]))).PreviewTab})),Xi=o.lazy(async()=>({default:(await Jt(()=>import("./DiffTab-Cul1vyzx.js"),__vite__mapDeps([5,1,2,3]))).DiffTab}));function Zi({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:a,cluster:i,sseConnected:d,activeTab:c,setActiveTab:m,creatingTask:x,activeTask:u,assignedNode:f,taskLoading:h,taskError:b,displayEvents:p,hasUserMessageInLogs:k,initialPrompt:S,supportsFollowUp:j,taskUnavailable:C,chatDisabled:E,chatDisabledReason:B,questionBypassEnabled:_,isRunning:P,hasPendingFollowUp:Q,canCancel:R,canRetry:M,onRetry:L,onCancel:ee,onStartCreateTask:D,onCancelCreateTask:W,onCreateTask:xe,onSendMessage:F,onQuestionBypassChange:re,onSubmitQuestionResponse:H,messagesEndRef:Z}){const[ue,ge]=o.useState(!1),[oe,de]=o.useState(!1),[K,ie]=o.useState(!1),fe=o.useRef(0),y=o.useRef(!1),Y=o.useCallback(V=>{const J=V.currentTarget,te=fe.current;if(fe.current=J.scrollTop,y.current)return;if(J.scrollHeight-J.scrollTop-J.clientHeight<30){de(!1),y.current=!0,setTimeout(()=>{y.current=!1},300);return}J.scrollTop<te&&te-J.scrollTop>10&&de(!0),J.scrollTop<=0&&de(!0)},[]),I=(u==null?void 0:u.effectiveProjectPath)??(u==null?void 0:u.project)??"default workspace",X=u?(f==null?void 0:f.name)??ss(u.assignedTo,i==null?void 0:i.nodes,u.assignedNodeName):"unassigned",N=u?[{label:"Working dir",value:I,mono:!0},{label:"Agent",value:u.agent,mono:!0},{label:"Node",value:X}]:[],ne=u!=null&&u.description&&u.description!==u.title?u.description:null;return x?e.jsx(Qi,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:a,cluster:i,sseConnected:d,onCancel:W,onCreated:xe}):!u&&h?e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[e.jsx("div",{className:"shrink-0 border-b border-border/60 px-4 py-4 sm:px-5",children:e.jsx(lt,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:a,cluster:i,sseConnected:d})}),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-full border border-primary/20 bg-primary/10 text-primary",children:e.jsx(he,{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-3 text-sm text-muted-foreground",children:[e.jsx(he,{className:"h-4 w-4 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):u?e.jsxs(Us,{value:c,onValueChange:m,className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-4 py-2.5 sm:px-5",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(lt,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:a,cluster:i,sseConnected:d})}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("h2",{className:"min-w-0 truncate text-base font-semibold tracking-tight text-foreground sm:text-lg",title:u.title,children:u.title}),e.jsx(zs,{status:u.status}),e.jsx(Pn,{priority:u.priority}),e.jsx(A,{variant:"ghost",size:"icon",className:"ml-auto h-6 w-6 shrink-0 rounded-full text-muted-foreground",onClick:()=>ge(V=>!V),children:ue?e.jsx(Rs,{className:"h-3.5 w-3.5"}):e.jsx(Be,{className:"h-3.5 w-3.5"})})]}),ue&&e.jsxs("div",{className:"mt-2 space-y-2",children:[ne&&e.jsx("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:ne}),b&&e.jsx("div",{className:"w-fit rounded-full border border-destructive/25 bg-destructive/10 px-3 py-1 text-xs text-destructive",children:b}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-col text-xs text-muted-foreground",children:[e.jsxs("span",{children:["updated ",Hi(u.updatedAt)]}),e.jsx("span",{className:"font-mono",children:u.id.slice(0,8)})]}),e.jsx("div",{className:"flex items-center gap-2",children:M&&e.jsxs(A,{variant:"outline",size:"sm",onClick:L,className:"shrink-0 rounded-full",children:[e.jsx(za,{className:"h-3.5 w-3.5"}),"Retry"]})})]})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[e.jsxs(Bs,{className:"h-auto max-w-full overflow-x-auto rounded-full bg-muted/70 p-1",children:[e.jsx($e,{value:"transcript",className:"rounded-full px-2.5 sm:px-4",children:"Transcript"}),e.jsx($e,{value:"files",className:"rounded-full px-2.5 sm:px-4",children:"Files"}),e.jsx($e,{value:"preview",className:"rounded-full px-2.5 sm:px-4",children:"Preview"}),e.jsx($e,{value:"diff",className:"rounded-full px-2.5 sm:px-4",children:"Diff"})]}),P&&e.jsx(pe,{variant:"outline",className:"hidden rounded-full border-amber-500/30 bg-amber-500/10 text-amber-700 sm:inline-flex dark:text-amber-300",children:"Working"}),Q&&e.jsx(pe,{variant:"outline",className:"hidden rounded-full border-primary/30 bg-primary/10 text-primary sm:inline-flex",children:"Queued"}),C&&e.jsx(pe,{variant:"outline",className:"hidden rounded-full border-destructive/25 bg-destructive/10 text-destructive sm:inline-flex",children:"Unavailable"})]})]}),e.jsx(Re,{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:"min-h-0 flex-1 overflow-y-auto px-4 py-5 sm:px-5",onScroll:Y,children:e.jsxs("div",{className:"mx-auto flex max-w-[72rem] flex-col gap-5",children:[S&&!k&&e.jsx(ks,{event:S,questionBypassEnabled:_,onQuestionBypassChange:re,onSubmitQuestionResponse:H,questionResponseDisabled:!j||E}),p.map((V,J)=>e.jsx(ks,{event:V,questionBypassEnabled:_,onQuestionBypassChange:re,onSubmitQuestionResponse:H,questionResponseDisabled:!j||E},Po("transcript",V,J))),p.length===0&&e.jsxs("div",{className:"rounded-[28px] border border-dashed border-border/70 bg-background/35 px-5 py-8 text-center",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Transcript is warming up"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:h?"Fetching task output...":"The opening prompt has been stored, but the agent has not emitted conversation output yet."})]}),(!j&&u.result||u.error)&&e.jsxs("div",{className:"space-y-3",children:[!j&&u.result&&e.jsxs("div",{className:"rounded-[26px] border border-border/70 bg-card/80 px-4 py-4",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-xs leading-5 text-muted-foreground",children:JSON.stringify(u.result,null,2)})]}),u.error&&e.jsxs("div",{className:"rounded-[26px] border border-destructive/20 bg-destructive/10 px-4 py-4 text-destructive",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em]",children:"Stored error"}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-xs leading-5",children:u.error})]})]}),(P||Q)&&p.length>0&&e.jsxs("div",{className:"flex items-center gap-3 rounded-[24px] border border-border/60 bg-background/45 px-4 py-3 text-sm text-muted-foreground",children:[e.jsx(he,{className:"h-4 w-4 animate-spin"}),"The agent is still working on this conversation."]}),e.jsx("div",{ref:Z})]})}),j?oe?e.jsx(A,{size:"icon",onClick:()=>de(!1),className:"absolute bottom-4 right-4 z-10 h-12 w-12 rounded-full shadow-lg",children:e.jsx(Yt,{className:"h-5 w-5"})}):e.jsx("div",{className:"shrink-0",children:e.jsx("div",{className:"mx-auto w-full max-w-[72rem]",children:e.jsx(Wo,{onSend:F,disabled:E,disabledReason:B,contextItems:N,placeholder:E?B:"Continue the conversation...",running:P||Q,onStop:R?()=>ie(!0):void 0})})}):e.jsx("div",{className:"shrink-0 border-t border-border/60 px-4 py-4 text-sm 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(Re,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx($t,{label:"Loading files..."}),children:e.jsx(Gi,{taskId:u.id})})}),e.jsx(Re,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx($t,{label:"Loading preview..."}),children:e.jsx(Yi,{taskId:u.id})})}),e.jsx(Re,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx($t,{label:"Loading diff..."}),children:e.jsx(Xi,{taskId:u.id})})}),e.jsx(Bt,{open:K,onOpenChange:ie,children:e.jsxs(ut,{children:[e.jsxs(mt,{children:[e.jsx(ft,{children:"Stop this task?"}),e.jsx(pt,{children:"The task will stop and move to a cancelled state."})]}),e.jsxs(xt,{children:[e.jsx(gt,{children:"Keep running"}),e.jsx(ht,{onClick:ee,children:"Stop task"})]})]})})]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[e.jsx("div",{className:"shrink-0 border-b border-border/60 px-4 py-4 sm:px-5",children:e.jsx(lt,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:a,cluster:i,sseConnected:d})}),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-full border border-primary/20 bg-primary/10 text-primary",children:e.jsx(Kt,{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-sm leading-6 text-muted-foreground",children:"Open a task from the left sidebar to continue the conversation, or start a new task to create a fresh chat thread."}),e.jsxs(A,{onClick:D,className:"mt-6 rounded-full px-5",children:[e.jsx(Hs,{className:"h-4 w-4"}),"Start new chat"]}),b&&e.jsx("div",{className:"mx-auto mt-4 max-w-lg rounded-[20px] border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:b})]})})]})}function Qi({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:a,cluster:i,sseConnected:d,onCancel:c,onCreated:m}){var x,u,f;return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[e.jsx("div",{className:"shrink-0 border-b border-border/60 px-4 py-4 sm:px-5",children:e.jsx(lt,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:a,cluster:i,sseConnected:d})}),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(Ri,{nodes:(i==null?void 0:i.nodes)??[],currentNodeRole:(x=i==null?void 0:i.self)==null?void 0:x.role,currentNodeId:((u=i==null?void 0:i.self)==null?void 0:u.id)??null,leaderNodeId:((f=i==null?void 0:i.leader)==null?void 0:f.id)??null,onCreated:m,onCancel:c,submitLabel:"Start chat",autoFocus:!0,layout:"composer"})})})]})}function lt({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:a,cluster:i,sseConnected:d}){var c;return e.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.jsx(el,{desktopTasksOpen:s,mobileTasksPanelOpen:r,onToggleTasks:t}),e.jsx(pe,{variant:"outline",className:"hidden rounded-full border-border/70 bg-background/60 sm:inline-flex",children:d?"Live":"Retrying"}),((c=i==null?void 0:i.leader)==null?void 0:c.name)&&e.jsxs(pe,{variant:"outline",className:"hidden rounded-full border-border/70 bg-background/60 sm:inline-flex",children:["leader ",i.leader.name]})]}),e.jsxs(A,{variant:"outline",onClick:a,className:"shrink-0 rounded-full border-border/70 bg-background/60 px-3 sm:px-4",children:[n?e.jsx(Js,{className:"h-4 w-4"}):e.jsx(Oa,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:n?"Hide cluster":"Show cluster"})]})]})}function el({desktopTasksOpen:t,mobileTasksPanelOpen:s,onToggleTasks:r}){var a,i;const n=(i=(a=globalThis.window)==null?void 0:a.matchMedia("(min-width: 1024px)"))!=null&&i.matches?t:s;return e.jsxs(A,{variant:"outline",onClick:r,className:"rounded-full border-border/70 bg-background/60 px-3 sm:px-4",children:[n?e.jsx(Ks,{className:"h-4 w-4"}):e.jsx(Ra,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:n?"Hide tasks":"Show tasks"})]})}const tl={node:"border-teal-500/30 bg-teal-500/10 text-teal-700 dark:text-teal-300",task:"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300",election:"border-indigo-500/30 bg-indigo-500/10 text-indigo-700 dark:text-indigo-300",cluster:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"};function sl(t){return t.split(".")[0]??"unknown"}function rl(t){return new Date(t).toLocaleTimeString("en-US",{hour12:!1})}function Rt(t,s){return(s==null?void 0:s.get(t))??t}function nl(t,s){const r=t.data;switch(t.type){case"node.joined":return`${r.name} joined the cluster`;case"node.left":return`${Rt(r.nodeId,s)} left (${r.reason})`;case"node.status":return`${Rt(r.nodeId,s)} is now ${r.status}`;case"task.created":return`"${r.title}" created`;case"task.assigned":return`task assigned to ${Rt(r.nodeId,s)}`;case"task.status":return`task ${r.taskId.slice(0,8)} -> ${r.status}`;case"election.started":return`candidate ${r.candidateId.slice(0,8)} term ${r.term}`;case"election.complete":return`leader elected, term ${r.term}`;case"cluster.state":return`${r.nodeCount} nodes, term ${r.term}`;default:return JSON.stringify(r)}}function al(t){return JSON.stringify(t,null,2)}function ol({events:t,maxHeight:s="400px",emptyTitle:r="No live events yet",emptyDescription:n="Cluster activity appears here as it happens.",nodeNameById:a}){return t.length===0?e.jsx("div",{className:"flex h-28 items-center justify-center rounded-[20px] border border-dashed border-border/70 bg-background/40 text-center",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:r}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground/70",children:n})]})}):e.jsx("div",{className:"overflow-y-auto pr-1",style:{maxHeight:s},children:e.jsx("div",{className:"space-y-2",children:t.map(i=>{const d=sl(i.type);return e.jsx("div",{className:"rounded-[20px] border border-border/60 bg-background/45 px-4 py-3 transition-colors hover:border-border hover:bg-background/65",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:rl(i.timestamp)}),e.jsx(pe,{variant:"outline",className:T("w-fit text-[10px] font-medium uppercase tracking-[0.16em]",tl[d]),children:i.type})]}),e.jsx(A,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-full text-muted-foreground",onClick:()=>void qe(al(i),"Event copied"),"aria-label":`Copy ${i.type} event`,title:"Copy event",children:e.jsx(yt,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"text-sm leading-6 text-foreground/85",children:nl(i,a)})]})},i.id)})})})}function Es({cluster:t,systemInfo:s,nodeNameById:r,nodeBlockingTaskCounts:n,eventTypeFilter:a,onEventTypeFilterChange:i,eventTypeOptions:d,filteredEvents:c,sseConnected:m,clusterLoading:x,clusterError:u,promotePending:f,onPromote:h,onAddNode:b,leavePending:p,onLeaveCluster:k,onToggleNodeDevTunnel:S,devTunnelNodeId:j,onClose:C}){var L,ee,D,W,xe;const E=((L=t==null?void 0:t.self)==null?void 0:L.role)==="leader",B=((ee=t==null?void 0:t.self)==null?void 0:ee.role)==="follower"&&!(t!=null&&t.leader),_=(t==null?void 0:t.self)??null,Q=zi((t==null?void 0:t.nodes)??[],_==null?void 0:_.id).filter(F=>F.id!==(_==null?void 0:_.id)),R=(_==null?void 0:_.role)==="leader"&&Q.length===0,M=(_==null?void 0:_.role)==="follower";return e.jsx("aside",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-[32px] border border-border/60 bg-background/84 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:e.jsxs(Us,{defaultValue:"overview",className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-semibold tracking-tight",children:"Operations"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Node, cluster, and live events."})]}),e.jsx(A,{variant:"ghost",size:"icon",onClick:C,className:"rounded-full",children:e.jsx(Js,{className:"h-4 w-4"})})]}),e.jsxs(Bs,{className:"mt-4 grid h-auto w-full grid-cols-3 rounded-full bg-muted/70 p-1",children:[e.jsx($e,{value:"overview",className:"rounded-full px-3 text-xs",children:"Overview"}),e.jsx($e,{value:"nodes",className:"rounded-full px-3 text-xs",children:"Nodes"}),e.jsx($e,{value:"events",className:"rounded-full px-3 text-xs",children:"Live events"})]})]}),e.jsx(Re,{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-4 py-5",children:e.jsxs("div",{className:"space-y-7",children:[_&&e.jsx(Ds,{node:_,systemInfo:s,blockingTaskCount:n.get(_.id)??0,devTunnelNodeId:j,onToggleNodeDevTunnel:S,showActions:!1,defaultExpanded:!1}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Cluster snapshot"}),e.jsx(pe,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:m?"Connected":"Reconnecting"})]}),x&&!t?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(he,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):u&&!t?e.jsx("div",{className:"rounded-[22px] border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:u}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Fe,{label:"Term",value:String((t==null?void 0:t.term)??0)}),e.jsx(Fe,{label:"Nodes",value:String((t==null?void 0:t.nodes.length)??0)}),e.jsx(Fe,{label:"Pending",value:String((t==null?void 0:t.taskSummary.pending)??0)}),e.jsx(Fe,{label:"Running",value:String((t==null?void 0:t.taskSummary.running)??0)}),e.jsx(Fe,{label:"Completed",value:String((t==null?void 0:t.taskSummary.completed)??0)}),e.jsx(Fe,{label:"Failed",value:String((t==null?void 0:t.taskSummary.failed)??0)})]}),e.jsxs("div",{className:"space-y-3 rounded-[24px] border border-border/60 bg-background/45 px-4 py-4",children:[e.jsx(Se,{label:"Leader",value:((D=t==null?void 0:t.leader)==null?void 0:D.name)??"None"}),e.jsx(Se,{label:"Leader URL",value:((W=t==null?void 0:t.leader)==null?void 0:W.endpoint)??"Unavailable",mono:!0,action:(xe=t==null?void 0:t.leader)!=null&&xe.endpoint?e.jsx(tt,{label:"Copy leader URL",onClick:()=>{var F;return void qe(((F=t.leader)==null?void 0:F.endpoint)??"","Leader URL copied")}}):void 0}),e.jsx(Se,{label:"Feed",value:m?"Receiving live updates":"Reconnecting to event stream"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:B&&e.jsxs(A,{variant:"outline",size:"sm",onClick:h,disabled:f,className:"rounded-full",children:[f&&e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})})]})]})]})})}),e.jsx(Re,{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-4 py-5",children:e.jsxs("div",{className:"space-y-7",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"This node"}),R?e.jsx(A,{variant:"outline",size:"sm",onClick:b,className:"rounded-full",children:"Join node"}):M?e.jsxs(A,{variant:"outline",size:"sm",onClick:k,disabled:p,className:"rounded-full",children:[p&&e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),_&&e.jsx(Ds,{node:_,systemInfo:s,blockingTaskCount:n.get(_.id)??0,devTunnelNodeId:j,onToggleNodeDevTunnel:S,showActions:!0,defaultExpanded:!0})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm font-medium text-foreground",children:["Peer nodes (",Q.length,")"]}),Q.length>0?e.jsx("div",{className:"space-y-3",children:Q.map(F=>e.jsx(il,{node:F,isLeader:!!E,blockingTaskCount:n.get(F.id)??0,devTunnelNodeId:j,onToggleNodeDevTunnel:S},F.id))}):e.jsx("div",{className:"rounded-[24px] border border-dashed border-border/70 bg-background/35 px-4 py-5 text-sm text-muted-foreground",children:"No peer nodes are connected yet."})]})]})})}),e.jsx(Re,{value:"events",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col px-4 py-5",children:[e.jsxs("div",{className:"mb-4 space-y-3",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[e.jsx($n,{className:T("h-4 w-4",m?"text-emerald-500":"text-destructive")}),"Live events"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(ye,{value:a,onValueChange:i,children:[e.jsx(ve,{className:"h-9 min-w-[11rem] flex-1 rounded-full border-border/70 bg-background/55 text-[12px] sm:max-w-[15rem]",children:e.jsx(Te,{placeholder:"Event type"})}),e.jsx(Ne,{children:d.map(F=>e.jsx(me,{value:F,className:"text-[12px]",children:F==="all"?"All event types":F},F))})]}),e.jsx(pe,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:m?"Connected":"Reconnecting"})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(ol,{events:c,maxHeight:"100%",emptyTitle:a==="all"?"No live events yet":"No matching events",emptyDescription:a==="all"?"Cluster activity appears here as it happens.":`No "${a}" events are in the current stream.`,nodeNameById:r})})]})})]})})}function Ds({node:t,systemInfo:s,blockingTaskCount:r,devTunnelNodeId:n,onToggleNodeDevTunnel:a,showActions:i=!0,defaultExpanded:d=!1}){const[c,m]=o.useState(d),x=(s==null?void 0:s.dashboardOrigin)??t.dashboardOrigin,u=t.devtunnelEndpoint??t.endpoint,f=x??t.endpoint,h=(s==null?void 0:s.workDir)??t.workDir,b=Zs(t,s==null?void 0:s.transportType),p=Xt(t,s==null?void 0:s.transportType),k=p&&We((s==null?void 0:s.transportType)??t.transportType)?!0:Xs(t,s==null?void 0:s.transportType),S=r>0;return e.jsxs("section",{className:"rounded-[28px] border border-primary/20 bg-primary/8 shadow-[0_24px_80px_-60px_hsl(var(--primary)/0.9)]",children:[e.jsxs("button",{type:"button",onClick:()=>m(j=>!j),className:"w-full px-4 py-3.5 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[c?e.jsx(Be,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):e.jsx(Xe,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx(Vs,{status:t.status}),e.jsx("span",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Current node"}),e.jsx("a",{href:f,target:"_blank",rel:"noreferrer",onClick:j=>j.stopPropagation(),className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(qs,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2 pl-6",children:[e.jsx("span",{className:"text-sm font-semibold tracking-tight text-foreground",children:t.name}),e.jsx(Ws,{role:t.role}),e.jsx(pe,{variant:"outline",className:"rounded-full border-primary/30 bg-background/60 text-[10px] capitalize",children:t.status})]})]}),c&&e.jsxs("div",{className:"space-y-4 border-t border-primary/15 px-4 pb-4 pt-3",children:[e.jsxs("div",{className:"space-y-3 rounded-[20px] border border-primary/20 bg-background/72 px-3.5 py-3.5",children:[e.jsx(Se,{label:"Node ID",value:t.id,mono:!0}),x&&e.jsx(Se,{label:"Dashboard",value:x,mono:!0,action:e.jsx(tt,{label:"Copy dashboard URL",onClick:()=>void qe(x,"Dashboard URL copied")})}),e.jsx(Se,{label:"Node URL",value:u,mono:!0,action:e.jsx(tt,{label:"Copy node URL",onClick:()=>void qe(u,"Node URL copied")})}),h&&e.jsx(Se,{label:"Workspace",value:h,mono:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Wt,{label:"Transport",value:b}),s&&e.jsx(Wt,{label:"Uptime",value:Ki(s.uptime),mono:!0})]}),e.jsx(Er,{capabilities:t.capabilities,action:i&&k?e.jsxs(A,{variant:"outline",size:"sm",onClick:()=>a(t),disabled:n===t.id||S,className:"rounded-full",title:S?"Finish assigned or running tasks before changing remote access":void 0,children:[n===t.id&&e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),p?"Disable Remote Access":"Enable Remote Access"]}):void 0}),i&&k&&S&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[r," active task",r===1?"":"s"," on this node."]})]})]})}function il({node:t,isLeader:s,blockingTaskCount:r,devTunnelNodeId:n,onToggleNodeDevTunnel:a}){const[i,d]=o.useState(!1),c=t.dashboardOrigin,m=t.devtunnelEndpoint??t.endpoint,x=c??t.endpoint,u=Zs(t),f=Xt(t),h=Xs(t),b=r>0;return e.jsxs("div",{className:"rounded-[24px] border border-border/60 bg-background/45",children:[e.jsxs("button",{type:"button",onClick:()=>d(p=>!p),className:"w-full px-4 py-3 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[i?e.jsx(Be,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):e.jsx(Xe,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx(Vs,{status:t.status}),e.jsx("span",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Peer node"}),e.jsx("a",{href:x,target:"_blank",rel:"noreferrer",onClick:p=>p.stopPropagation(),className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(qs,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2 pl-6",children:[e.jsx("span",{className:"text-sm font-semibold text-foreground",children:t.name}),e.jsx(Ws,{role:t.role}),e.jsx(pe,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px] capitalize",children:t.status})]})]}),i&&e.jsxs("div",{className:"space-y-4 border-t border-border/50 px-4 pb-4 pt-3",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(Se,{label:"Node ID",value:t.id,mono:!0}),c&&e.jsx(Se,{label:"Dashboard",value:c,mono:!0,action:e.jsx(tt,{label:"Copy dashboard URL",onClick:()=>void qe(c,"Dashboard URL copied")})}),e.jsx(Se,{label:"Node URL",value:m,mono:!0,action:e.jsx(tt,{label:"Copy node URL",onClick:()=>void qe(m,"Node URL copied")})}),t.workDir&&e.jsx(Se,{label:"Workspace",value:t.workDir,mono:!0}),e.jsx(Wt,{label:"Transport",value:u})]}),e.jsx(Er,{capabilities:t.capabilities,action:s&&h?e.jsxs(A,{variant:"outline",size:"sm",onClick:()=>a(t),disabled:n===t.id||b,className:"rounded-full",title:b?"Finish assigned or running tasks before changing remote access":void 0,children:[n===t.id&&e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),f?"Disable Remote Access":"Enable Remote Access"]}):void 0}),s&&h&&b&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[r," active task",r===1?"":"s"," on this node."]})]})]})}function tt({label:t,onClick:s}){return e.jsx(A,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-full text-muted-foreground",onClick:s,"aria-label":t,title:t,children:e.jsx(yt,{className:"h-3.5 w-3.5"})})}function ll(t,s,r,n){var d;if(!t)return{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Select a task to continue the conversation."};const a=((d=s==null?void 0:s.self)==null?void 0:d.role)==="follower";return t.assignedTo!==null&&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.`}:a?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Follower nodes are read-only. Use the leader dashboard to manage chat, or leave the cluster first."}:r||n?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Waiting for the current turn to finish..."}:bt.has(t.status)||t.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:bt.has(t.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}var kt="Checkbox",[dl]=Os(kt),[cl,rs]=dl(kt);function ul(t){const{__scopeCheckbox:s,checked:r,children:n,defaultChecked:a,disabled:i,form:d,name:c,onCheckedChange:m,required:x,value:u="on",internal_do_not_use_render:f}=t,[h,b]=Ln({prop:r,defaultProp:a??!1,onChange:m,caller:kt}),[p,k]=o.useState(null),[S,j]=o.useState(null),C=o.useRef(!1),E=p?!!d||!!p.closest("form"):!0,B={checked:h,disabled:i,setChecked:b,control:p,setControl:k,name:c,form:d,value:u,hasConsumerStoppedPropagationRef:C,required:x,defaultChecked:De(a)?!1:a,isFormControl:E,bubbleInput:S,setBubbleInput:j};return e.jsx(cl,{scope:s,...B,children:ml(f)?f(B):n})}var Dr="CheckboxTrigger",Mr=o.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:r,...n},a)=>{const{control:i,value:d,disabled:c,checked:m,required:x,setControl:u,setChecked:f,hasConsumerStoppedPropagationRef:h,isFormControl:b,bubbleInput:p}=rs(Dr,t),k=jt(a,u),S=o.useRef(m);return o.useEffect(()=>{const j=i==null?void 0:i.form;if(j){const C=()=>f(S.current);return j.addEventListener("reset",C),()=>j.removeEventListener("reset",C)}},[i,f]),e.jsx(Gt.button,{type:"button",role:"checkbox","aria-checked":De(m)?"mixed":m,"aria-required":x,"data-state":Ir(m),"data-disabled":c?"":void 0,disabled:c,value:d,...n,ref:k,onKeyDown:Lt(s,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:Lt(r,j=>{f(C=>De(C)?!0:!C),p&&b&&(h.current=j.isPropagationStopped(),h.current||j.stopPropagation())})})});Mr.displayName=Dr;var ns=o.forwardRef((t,s)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:i,required:d,disabled:c,value:m,onCheckedChange:x,form:u,...f}=t;return e.jsx(ul,{__scopeCheckbox:r,checked:a,defaultChecked:i,disabled:c,required:d,onCheckedChange:x,name:n,form:u,value:m,internal_do_not_use_render:({isFormControl:h})=>e.jsxs(e.Fragment,{children:[e.jsx(Mr,{...f,ref:s,__scopeCheckbox:r}),h&&e.jsx(Lr,{__scopeCheckbox:r})]})})});ns.displayName=kt;var Pr="CheckboxIndicator",$r=o.forwardRef((t,s)=>{const{__scopeCheckbox:r,forceMount:n,...a}=t,i=rs(Pr,r);return e.jsx(Rn,{present:n||De(i.checked)||i.checked===!0,children:e.jsx(Gt.span,{"data-state":Ir(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});$r.displayName=Pr;var Rr="CheckboxBubbleInput",Lr=o.forwardRef(({__scopeCheckbox:t,...s},r)=>{const{control:n,hasConsumerStoppedPropagationRef:a,checked:i,defaultChecked:d,required:c,disabled:m,name:x,value:u,form:f,bubbleInput:h,setBubbleInput:b}=rs(Rr,t),p=jt(r,b),k=In(i),S=On(n);o.useEffect(()=>{const C=h;if(!C)return;const E=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(E,"checked").set,P=!a.current;if(k!==i&&_){const Q=new Event("click",{bubbles:P});C.indeterminate=De(i),_.call(C,De(i)?!1:i),C.dispatchEvent(Q)}},[h,k,i,a]);const j=o.useRef(De(i)?!1:i);return e.jsx(Gt.input,{type:"checkbox","aria-hidden":!0,defaultChecked:d??j.current,required:c,disabled:m,name:x,value:u,form:f,...s,tabIndex:-1,ref:p,style:{...s.style,...S,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Lr.displayName=Rr;function ml(t){return typeof t=="function"}function De(t){return t==="indeterminate"}function Ir(t){return De(t)?"indeterminate":t?"checked":"unchecked"}const Ht=o.forwardRef(({className:t,...s},r)=>e.jsx(ns,{ref:r,className:T("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...s,children:e.jsx($r,{className:T("flex items-center justify-center text-current"),children:e.jsx(Me,{className:"h-3.5 w-3.5"})})}));Ht.displayName=ns.displayName;function Ms({toolbarTasks:t,activeTaskId:s,tasksLoading:r,tasksError:n,isLeader:a,scope:i,agentFilter:d,nodeFilter:c,agentOptions:m,nodeOptions:x,nodeNameById:u,searchQuery:f,selectedTaskIds:h,allVisibleTasksSelected:b,someVisibleTasksSelected:p,canBatchArchive:k,onSearchChange:S,onScopeChange:j,onAgentFilterChange:C,onNodeFilterChange:E,onToggleTaskSelected:B,onToggleAllVisibleTasks:_,onBatchArchive:P,onBatchDelete:Q,onCreateTask:R,onSelectTask:M,onClose:L}){const[ee,D]=o.useState(!!f),[W,xe]=o.useState(!1),F=o.useRef(null),re=o.useRef(null),H=h.size,Z=i!=="active"||c!=="all"||d!=="all",ue=f.trim().length>0,[ge,oe]=o.useState(new Set),[de,K]=o.useState(new Set),ie=o.useMemo(()=>Ji(t,u),[t,u]),fe=ie.length===1,y=!fe||Z||ue,Y=fe&&(Z||ue),I=o.useCallback(N=>{oe(ne=>{const V=new Set(ne);return V.has(N)?V.delete(N):V.add(N),V})},[]),X=o.useCallback(N=>{K(ne=>{const V=new Set(ne);return V.has(N)?V.delete(N):V.add(N),V})},[]);return o.useEffect(()=>{f&&D(!0)},[f]),o.useEffect(()=>{var N;ee&&((N=F.current)==null||N.focus())},[ee]),o.useEffect(()=>{if(!ee)return;const N=V=>{var te;const J=V.target;J instanceof Node&&((te=re.current)!=null&&te.contains(J)||D(!1))},ne=V=>{V.key==="Escape"&&D(!1)};return document.addEventListener("mousedown",N),document.addEventListener("keydown",ne),()=>{document.removeEventListener("mousedown",N),document.removeEventListener("keydown",ne)}},[ee]),e.jsxs("aside",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-[32px] border border-border/60 bg-background/80 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-lg font-semibold tracking-tight text-foreground",children:"Tasks"}),e.jsx(A,{variant:"ghost",size:"icon",onClick:L,className:"rounded-full",children:e.jsx(Ks,{className:"h-4 w-4"})})]}),e.jsxs("div",{ref:re,className:"mt-4 flex items-center gap-2",children:[e.jsxs(A,{onClick:R,className:T("justify-start rounded-[22px] px-4 py-6 text-left shadow-[0_24px_60px_-32px_hsl(var(--primary)/0.95)] transition-[flex] duration-200",ee?"flex-[2]":"flex-1"),children:[e.jsx(Hs,{className:"h-4 w-4"}),"New chat"]}),ee?e.jsxs("div",{className:"flex min-w-0 flex-[3] items-center gap-2",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(bs,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Ve,{ref:F,value:f,onChange:N=>S(N.target.value),placeholder:"Search tasks",className:"h-11 rounded-full border-border/70 bg-background/60 pl-11 text-sm"})]}),e.jsx(A,{variant:"outline",size:"icon",onClick:()=>D(!1),className:"rounded-full border-border/70 bg-background/60",children:e.jsx(Fn,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(A,{variant:"outline",onClick:()=>D(!0),className:T("rounded-full border-border/70 bg-background/60 px-4 text-sm",f&&"border-primary/40 bg-primary/8 text-primary"),children:[e.jsx(bs,{className:"h-4 w-4"}),"Search"]}),e.jsx(A,{variant:W||Z?"secondary":"outline",size:"icon",onClick:()=>xe(N=>!N),className:T("shrink-0 rounded-full border-border/70 bg-background/60",Z&&"border-primary/40 bg-primary/8 text-primary"),title:"Filters",children:e.jsx(va,{className:"h-4 w-4"})})]})]}),(W||Z)&&e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3",children:[e.jsxs(ye,{value:i,onValueChange:N=>j(N),children:[e.jsx(ve,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:e.jsx(Te,{})}),e.jsx(Ne,{children:Li.map(N=>e.jsx(me,{value:N.value,className:"text-[12px]",children:N.label},N.value))})]}),e.jsxs(ye,{value:c,onValueChange:E,children:[e.jsx(ve,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:e.jsx(Te,{placeholder:"Node"})}),e.jsx(Ne,{children:x.map(N=>e.jsx(me,{value:N.value,className:"text-[12px]",children:N.label},N.value))})]}),e.jsxs(ye,{value:d,onValueChange:C,children:[e.jsx(ve,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:e.jsx(Te,{placeholder:"Agent"})}),e.jsx(Ne,{children:m.map(N=>e.jsx(me,{value:N,className:"text-[12px]",children:N==="all"?"All agents":N},N))})]})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 py-3",children:ie.length>0?e.jsxs("div",{className:"space-y-1",children:[a&&e.jsxs("div",{className:"mb-1 flex items-center justify-between px-1 py-1",children:[e.jsxs("label",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:[e.jsx(Ht,{checked:p&&!b?"indeterminate":b,onCheckedChange:N=>_(N===!0),"aria-label":"Select all visible tasks"}),e.jsx("span",{children:"Select all"})]}),H>0&&e.jsx(A,{variant:"ghost",size:"sm",onClick:()=>_(!1),className:"h-7 rounded-full px-3 text-xs",children:"Clear"})]}),ie.map(N=>{const ne=N.nodeId??"__unassigned__",V=y&&!Y&&ge.has(ne);return e.jsxs("div",{className:"space-y-1",children:[y&&e.jsxs("button",{type:"button",onClick:()=>I(ne),"aria-expanded":!V,className:"flex w-full items-center gap-1.5 rounded-xl px-2 py-1.5 text-left text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",children:[V?e.jsx(Xe,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Be,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:N.nodeName}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-muted-foreground/60",children:N.dirs.reduce((J,te)=>J+te.tasks.length,0)})]}),!V&&N.dirs.map(J=>{const te=`${ne}::${J.path}`,be=de.has(te),ke=qi(J.path);return e.jsxs("div",{className:T("space-y-1",y&&"pl-3"),children:[e.jsxs("button",{type:"button",onClick:()=>X(te),"aria-expanded":!be,title:J.path,className:"flex w-full items-center gap-1.5 rounded-xl px-2 py-1 text-left text-[11px] font-medium text-muted-foreground/80 transition-colors hover:bg-muted/40 hover:text-foreground",children:[be?e.jsx(Xe,{className:"h-3 w-3 shrink-0"}):e.jsx(Be,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate font-mono",children:ke}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-muted-foreground/50",children:J.tasks.length})]}),!be&&e.jsx("div",{className:T("space-y-2",y?"pl-2":"pl-0"),children:J.tasks.map(w=>e.jsxs("div",{className:T("flex items-start gap-3 rounded-[24px] border px-3 py-3 transition-all",w.id===s?"border-primary/45 bg-primary/9 shadow-[0_24px_80px_-54px_hsl(var(--primary)/0.95)]":"border-border/60 bg-background/40 hover:border-border hover:bg-background/60"),children:[a&&e.jsx("div",{className:"flex shrink-0 pt-1",onClick:U=>U.stopPropagation(),children:e.jsx(Ht,{checked:h.has(w.id),onCheckedChange:U=>B(w.id,U===!0),"aria-label":`Select ${w.title}`})}),e.jsx("button",{type:"button",onClick:()=>M(w.id),className:"min-w-0 flex-1 text-left",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:T("mt-1 h-2.5 w-2.5 shrink-0 rounded-full",Vi(w.status))}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:w.title}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"font-mono",children:w.agent}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),e.jsx("span",{children:Wi(w.updatedAt)})]}),e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx(zs,{status:w.status}),w.assignedNodeAvailable===!1&&e.jsx(pe,{variant:"outline",className:"border-destructive/25 bg-destructive/10 text-[10px] text-destructive",children:"unavailable"})]})]})]})})]},w.id))})]},te)})]},ne)})]}):e.jsx("div",{className:"rounded-[24px] border border-dashed border-border/70 bg-background/35 px-4 py-5 text-sm text-muted-foreground",children:r?"Loading tasks...":n||"No tasks match this view."})}),a&&H>0?e.jsxs("div",{className:"shrink-0 border-t border-border/60 px-4 py-4",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Batch actions"}),e.jsxs("div",{className:"mt-2 text-sm font-semibold text-foreground",children:[H," task",H!==1?"s":""," selected"]}),!k&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Only completed, failed, cancelled, or archived tasks can be archived."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(Bt,{children:[e.jsx(ws,{asChild:!0,children:e.jsxs(A,{variant:"outline",size:"sm",disabled:!k,className:"rounded-full",children:[e.jsx(aa,{className:"h-3.5 w-3.5"}),"Archive"]})}),e.jsxs(ut,{children:[e.jsxs(mt,{children:[e.jsxs(ft,{children:["Archive ",H," task",H!==1?"s":"","?"]}),e.jsx(pt,{children:"Archived tasks stay hidden from the default task view and can be reopened from the archived scope."})]}),e.jsxs(xt,{children:[e.jsx(gt,{children:"Cancel"}),e.jsx(ht,{onClick:P,disabled:!k,children:"Archive"})]})]})]}),e.jsxs(Bt,{children:[e.jsx(ws,{asChild:!0,children:e.jsxs(A,{variant:"destructive",size:"sm",className:"rounded-full",children:[e.jsx(Xa,{className:"h-3.5 w-3.5"}),"Delete"]})}),e.jsxs(ut,{children:[e.jsxs(mt,{children:[e.jsxs(ft,{children:["Delete ",H," task",H!==1?"s":"","?"]}),e.jsx(pt,{children:"This removes the selected tasks and their saved logs."})]}),e.jsxs(xt,{children:[e.jsx(gt,{children:"Cancel"}),e.jsx(ht,{onClick:Q,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}):null]})}function Ps(t,s,r){const n=o.useRef(s);n.current=s,o.useEffect(()=>{let d=0,c=0;const m=f=>{const h=f.touches[0];h&&(d=h.clientX,c=h.clientY)},x=f=>{var k,S,j,C;const h=f.changedTouches[0];if(!h)return;const b=h.clientX-d;Math.abs(h.clientY-c)>100||Math.abs(b)<50||(b>0?(S=(k=n.current).onSwipeRight)==null||S.call(k):(C=(j=n.current).onSwipeLeft)==null||C.call(j))},u=(t==null?void 0:t.current)??document;return u.addEventListener("touchstart",m,{passive:!0}),u.addEventListener("touchend",x,{passive:!0}),()=>{u.removeEventListener("touchstart",m),u.removeEventListener("touchend",x)}},[t,r==null?void 0:r.threshold,r==null?void 0:r.maxVertical])}const xl="(min-width: 1024px)",fl="(min-width: 1280px)";function $s(t){var s,r,n;return((n=(r=(s=globalThis.window)==null?void 0:s.matchMedia)==null?void 0:r.call(s,t))==null?void 0:n.matches)??!1}function pl(){const[t,s]=o.useState(!0),[r,n]=o.useState(!1),[a,i]=o.useState(()=>$s(fl)),d=o.useRef(null),c=o.useRef(null);Ps(d,{onSwipeLeft:()=>n(!1)}),Ps(c,{onSwipeRight:()=>i(!1)});const m=o.useCallback(()=>{if($s(xl)){s(x=>!x);return}n(x=>!x)},[]);return{desktopTasksOpen:t,mobileTasksPanelOpen:r,mobileTasksPanelRef:d,operationsOpen:a,operationsPanelRef:c,setMobileTasksPanelOpen:n,setOperationsOpen:i,toggleTasksPanel:m}}function hl(t,s){return s.data.nodeId===t.self.id||s.data.name===t.self.name||s.data.endpoint===t.self.endpoint}function gl({cluster:t,subscribe:s}){o.useEffect(()=>{var r;if(((r=t==null?void 0:t.self)==null?void 0:r.role)==="leader")return s("node",n=>{const a=String(n.data.name??n.data.nodeId??"node"),i=hl(t,n);n.type==="node.joined"&&!i&&ae.success(`${a} joined the cluster`),n.type==="node.left"&&!i&&ae.message(`${a} left the cluster`)})},[t,s])}function bl(){var xs,fs,ps;const{id:t}=Un(),s=zn(),r=Bn(),{cluster:n,systemInfo:a,events:i,sseConnected:d,subscribe:c,refresh:m,loading:x,error:u}=Vn(),f=o.useMemo(()=>Bi(s.state),[s.state]),[h,b]=o.useState([]),[p,k]=o.useState(!0),[S,j]=o.useState(null),[C,E]=o.useState(null),[B,_]=o.useState("active"),[P,Q]=o.useState("all"),[R,M]=o.useState("all"),[L,ee]=o.useState(""),D=o.useDeferredValue(L),{desktopTasksOpen:W,mobileTasksPanelOpen:xe,mobileTasksPanelRef:F,operationsOpen:re,operationsPanelRef:H,setMobileTasksPanelOpen:Z,setOperationsOpen:ue,toggleTasksPanel:ge}=pl(),[oe,de]=o.useState(()=>!!(f!=null&&f.draftNewTask)),[K,ie]=o.useState(()=>f!=null&&f.draftNewTask?{route:f.returnRoute??"/",taskId:f.returnTaskId??null}:null),[fe,y]=o.useState(!1),[Y,I]=o.useState("transcript"),[X,N]=o.useState("all"),[ne,V]=o.useState(!1),[J,te]=o.useState(null),[be,ke]=o.useState([]),[w,U]=o.useState([]),[we,Le]=o.useState(!1),[wt,ce]=o.useState(null),[Ee,Pe]=o.useState(new Set),[Or,as]=o.useState(!1),[Fr,os]=o.useState(!1),[Ur,is]=o.useState(null),ls=o.useRef(null),Ke=o.useRef(null),Ie=((xs=n==null?void 0:n.self)==null?void 0:xs.role)==="leader",Ct=(fs=n==null?void 0:n.self)==null?void 0:fs.id;gl({cluster:n,subscribe:c});const le=o.useCallback(async()=>{try{const l=await qn({assignedTo:!Ie&&Ct?Ct:void 0,limit:100});b(l),j(null)}catch(l){j(l instanceof Error?l.message:"Failed to load tasks")}finally{k(!1)}},[Ie,Ct]);Wn(le,1e4),o.useEffect(()=>{le()},[le]),o.useEffect(()=>c("task",le),[c,le]);const se=o.useMemo(()=>[...h].sort((l,g)=>g.updatedAt-l.updatedAt),[h]),zr=o.useMemo(()=>{const l=new Map;for(const g of(n==null?void 0:n.nodes)??[]){const v=so(se,g.id);v>0&&l.set(g.id,v)}return l},[n==null?void 0:n.nodes,se]),Ce=o.useMemo(()=>se.filter(l=>!Oi(l,B)||P!=="all"&&l.agent!==P||R==="unassigned"&&l.assignedTo||R!=="all"&&R!=="unassigned"&&Ui(l.assignedTo,n==null?void 0:n.nodes,l.assignedNodeName)!==R?!1:D.trim()?Fi(l,D):!0),[se,B,P,R,D]);o.useEffect(()=>{Pe(l=>{const g=io(l,Ce.map(v=>v.id));return g.size===l.size?l:g})},[Ce]),o.useEffect(()=>{Ie||Pe(new Set)},[Ie]);const Br=o.useMemo(()=>["all",...Array.from(new Set(se.map(l=>l.agent))).sort()],[se]),Vr=o.useMemo(()=>{const g=Array.from(new Set(se.map(v=>v.assignedTo).filter(v=>!!v))).map(v=>{const G=se.find($=>$.assignedTo===v);return(n==null?void 0:n.nodes.find($=>$.id===v))??{id:v,name:ss(v,n==null?void 0:n.nodes,G==null?void 0:G.assignedNodeName)}}).sort((v,G)=>v.name.localeCompare(G.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...g.map(v=>({value:v.name.toLowerCase(),label:v.name}))]},[se,n==null?void 0:n.nodes]),ds=o.useMemo(()=>{const l=new Map;for(const g of(n==null?void 0:n.nodes)??[])l.set(g.id,g.name);for(const g of se)g.assignedTo&&g.assignedNodeName&&!l.has(g.assignedTo)&&l.set(g.assignedTo,g.assignedNodeName);return l},[n==null?void 0:n.nodes,se]),St=o.useMemo(()=>["all",...Array.from(new Set(i.map(l=>l.type))).sort()],[i]),qr=o.useMemo(()=>X==="all"?i:i.filter(l=>l.type===X),[i,X]),Wr=Ce.length>0&&Ce.every(l=>Ee.has(l.id)),Hr=Ce.some(l=>Ee.has(l.id)),Kr=lo(Ce,Ee);o.useEffect(()=>{f!=null&&f.draftNewTask&&(de(!0),ie({route:f.returnRoute??"/",taskId:f.returnTaskId??null}))},[f]),o.useEffect(()=>{X!=="all"&&!St.includes(X)&&N("all")},[X,St]),o.useEffect(()=>{js(t,oe)&&!C&&se[0]&&E(se[0].id)},[t,oe,C,se]),o.useEffect(()=>{var l;js(t,oe)&&(C&&h.some(g=>g.id===C)||E(((l=se[0])==null?void 0:l.id)??null))},[t,oe,C,se,h]);const q=no({routeTaskId:t,creatingTask:oe,internalSelectedTaskId:C,sortedTaskIds:se.map(l=>l.id)}),Oe=o.useMemo(()=>h.find(l=>l.id===q)??null,[h,q]);o.useEffect(()=>{Ke.current=q??null},[q]);const nt=o.useCallback(()=>{te(null),ke([]),U([]),ce(null)},[]),je=o.useCallback(async()=>{const l=q;if(l)try{const g=await Hn(l);if(Ke.current!==l)return;te(g),ce(null)}catch(g){if(Ke.current!==l)return;te(null),ke([]),U([]),ce(g instanceof Error?g.message:"Failed to load task")}finally{Ke.current===l&&Le(!1)}},[q]),at=o.useCallback(async()=>{const l=q;if(l)try{const g=await Kn(l);if(Ke.current!==l)return;ke(v=>$o(v,g.logs)),U(v=>Lo(v,g.logs))}catch{}},[q]);o.useEffect(()=>{if(!q){te(null),ke([]),U([]),ce(null),Le(!1);return}I("transcript"),te(Oe),ke([]),U([]),ce(null),Le(!0),je(),at()},[q,at,je]),o.useEffect(()=>{var g;if(!q||oe||p||h.some(v=>v.id===q))return;const l=((g=se[0])==null?void 0:g.id)??null;E(l),nt(),o.startTransition(()=>{r(l?`/tasks/${l}`:"/",{state:null})})},[q,nt,oe,r,se,h,p]),o.useEffect(()=>{Oe&&te(l=>!l||l.id!==Oe.id?l:{...l,...Oe})},[Oe]),o.useEffect(()=>{if(q)return c("task",l=>{const g=l.data.taskId;if(!(typeof g!="string"||g!==q)){if(l.type==="task.output"){const v=l.data.event;if(v){ke($=>Ro($,v));const G=st(v);G&&U($=>Io($,G))}}l.type==="task.status"&&(je(),at())}})},[c,q,je,at]),o.useEffect(()=>{var l;Y==="transcript"&&((l=ls.current)==null||l.scrollIntoView({behavior:"smooth"}))},[be,w,Y]);const z=J??Oe,Jr=z!=null&&z.assignedTo?(n==null?void 0:n.nodes.find(l=>l.id===z.assignedTo))??null:null,_t=w.length>0,Gr=z?yi.has(z.agent):!1,Tt=(z==null?void 0:z.status)==="running",Yr=z?bt.has(z.status)||Ar.has(z.status):!1,Xr=!!(z&&Ie&&z.status==="failed"),At=o.useMemo(()=>ll(z,n,_t,!!Tt),[z,n,_t,Tt]),Zr=o.useMemo(()=>Oo(be),[be]),Et=o.useMemo(()=>Fo([...be,...w.map(l=>Mt(l.content,l.timestamp))]),[be,w]),Qr=o.useMemo(()=>{if(!z)return null;const l=fo(z);if(l.length>0)return Mt(l,new Date(z.createdAt).toISOString());if(Et.length>0)return null;const g=Je(z.description||z.title);return g.length>0?Mt(g,new Date(z.createdAt).toISOString()):null},[z,Et]),Dt=o.useCallback(()=>{const l={route:t?`/tasks/${t}`:"/",taskId:q};ie(l),de(!0),o.startTransition(()=>{r("/",{state:{draftNewTask:!0,returnRoute:l.route,returnTaskId:l.taskId}})})},[t,q,r]),en=o.useCallback(()=>{var g;const l=(K==null?void 0:K.taskId)??((g=se[0])==null?void 0:g.id)??null;de(!1),ie(null),E(l),o.startTransition(()=>{r((K==null?void 0:K.route)??"/",{state:null})})},[K,se,r]),cs=o.useCallback(l=>{de(!1),ie(null),E(l),o.startTransition(()=>{r(`/tasks/${l}`,{state:null})})},[r]),tn=o.useCallback(l=>{de(!1),ie(null),b(g=>ao(g,l)),te(l),ke([]),U([]),ce(null),Le(!1),I("transcript"),E(l.id),le(),o.startTransition(()=>{r(`/tasks/${l.id}`,{state:null})})},[le,r]),ot=o.useCallback(async l=>{if(!q)return!1;const g=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`;U(v=>[...v,{id:g,content:l,timestamp:new Date().toISOString()}]);try{return await Jn(q,l),je(),!0}catch(v){return U(G=>G.filter($=>$.id!==g)),ae.error(v instanceof Error?v.message:"Failed to send message"),!1}},[q,je]),sn=o.useCallback(l=>{ot(l)},[ot]),rn=o.useCallback(l=>ot(l),[ot]),nn=o.useCallback(async()=>{if(z)try{await Gn(z.id),je(),le()}catch(l){ae.error(l instanceof Error?l.message:"Failed to cancel task")}},[z,je,le]),an=o.useCallback(async()=>{if(z)try{await Yn(z.id),je(),le()}catch(l){ae.error(l instanceof Error?l.message:"Failed to retry task")}},[z,je,le]),it=o.useCallback((l,g=!1)=>{const v=co(Ce,l);return E(v),(g||!v)&&nt(),o.startTransition(()=>{r(v?`/tasks/${v}`:"/",{state:null})}),v},[nt,Ce,r]),on=o.useCallback((l,g)=>{Pe(v=>{const G=new Set(v);return g?G.add(l):G.delete(l),G})},[]),ln=o.useCallback(l=>{if(!l){Pe(new Set);return}Pe(new Set(Ce.map(g=>g.id)))},[Ce]),dn=o.useCallback(async()=>{const l=Array.from(Ee);if(l.length!==0)try{const{results:g}=await Xn(l),v=g.filter($=>!$.ok),G=g.filter($=>$.ok).map($=>$.id);q&&G.includes(q)&&it(G),v.length>0?ae.error(`Failed to archive ${v.length} task(s): ${v.map($=>$.error??$.id).join(", ")}`):ae.success(`Archived ${G.length} task(s)`),Pe(new Set(v.map($=>$.id))),le()}catch(g){ae.error(g instanceof Error?g.message:"Failed to archive tasks")}},[q,le,it,Ee]),cn=o.useCallback(async()=>{const l=Array.from(Ee);if(l.length!==0)try{const{results:g}=await Zn(l),v=g.filter($=>!$.ok),G=g.filter($=>$.ok).map($=>$.id);q&&G.includes(q)&&it(G,!0),v.length>0?ae.error(`Failed to delete ${v.length} task(s): ${v.map($=>$.error??$.id).join(", ")}`):ae.success(`Deleted ${G.length} task(s)`),Pe(new Set(v.map($=>$.id))),le()}catch(g){ae.error(g instanceof Error?g.message:"Failed to delete tasks")}},[q,le,it,Ee]),un=o.useCallback(async()=>{as(!0);try{await Qn(),m()}catch(l){ae.error(l instanceof Error?l.message:"Failed to promote node")}finally{as(!1)}},[m]),mn=o.useCallback(async()=>{os(!0);try{await ea(),ae.success("This node left the remote cluster and is leading itself again."),le(),je(),m()}catch(l){ae.error(l instanceof Error?l.message:"Failed to leave cluster")}finally{os(!1)}},[je,le,m]),xn=o.useCallback(async l=>{var hs;const g=!Xt(l),v=l.id===((hs=n==null?void 0:n.self)==null?void 0:hs.id),G=v?(a==null?void 0:a.transportType)??l.transportType:l.transportType,$=v&&!g&&We(G);is(l.id);try{$?await ta("direct"):await sa(l.id,g),ae.success(g?`Enabled remote access on ${l.name}`:`Disabled remote access on ${l.name}`),m()}catch(gs){ae.error(gs instanceof Error?gs.message:"Failed to update remote access")}finally{is(null)}},[(ps=n==null?void 0:n.self)==null?void 0:ps.id,m,a==null?void 0:a.transportType]),us={toolbarTasks:Ce,activeTaskId:q,tasksLoading:p,tasksError:S,isLeader:Ie,scope:B,agentFilter:P,nodeFilter:R,agentOptions:Br,nodeOptions:Vr,nodeNameById:ds,searchQuery:L,selectedTaskIds:Ee,allVisibleTasksSelected:Wr,someVisibleTasksSelected:Hr,canBatchArchive:Kr,onSearchChange:ee,onScopeChange:_,onAgentFilterChange:Q,onNodeFilterChange:M,onToggleTaskSelected:on,onToggleAllVisibleTasks:ln,onBatchArchive:dn,onBatchDelete:cn,onCreateTask:Dt,onSelectTask:cs,onClose:ge},ms={cluster:n,systemInfo:a,nodeNameById:ds,nodeBlockingTaskCounts:zr,eventTypeFilter:X,onEventTypeFilterChange:N,eventTypeOptions:St,filteredEvents:qr,sseConnected:d,clusterLoading:x,clusterError:u,promotePending:Or,onPromote:un,onAddNode:()=>y(!0),leavePending:Fr,onLeaveCluster:mn,onToggleNodeDevTunnel:xn,devTunnelNodeId:Ur,onClose:()=>ue(!1)};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden pb-2",children:[e.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[e.jsx("div",{className:T("hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",W?"lg:mr-3 lg:w-[24rem]":"lg:w-0 lg:overflow-hidden"),children:W&&e.jsx(Ms,{...us})}),e.jsx("section",{className:"min-h-0 min-w-0 flex-1",children:e.jsx(Zi,{onToggleTasks:ge,desktopTasksOpen:W,mobileTasksPanelOpen:xe,operationsOpen:re,onToggleOperations:()=>ue(l=>!l),cluster:n,sseConnected:d,activeTab:Y,setActiveTab:I,creatingTask:oe,activeTask:z,assignedNode:Jr,taskLoading:we,taskError:wt,displayEvents:Et,hasUserMessageInLogs:Zr,initialPrompt:Qr,supportsFollowUp:Gr,taskUnavailable:At.taskUnavailable,chatDisabled:At.chatDisabled,chatDisabledReason:At.chatDisabledReason,questionBypassEnabled:ne,isRunning:!!Tt,hasPendingFollowUp:_t,canCancel:!!Yr,canRetry:!!Xr,onRetry:an,onCancel:nn,onStartCreateTask:Dt,onCancelCreateTask:en,onCreateTask:tn,onSendMessage:sn,onQuestionBypassChange:V,onSubmitQuestionResponse:rn,messagesEndRef:ls})}),e.jsx("div",{className:T("hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",re?"xl:ml-3 xl:w-[26rem]":"xl:w-0 xl:overflow-hidden"),children:re&&e.jsx(Es,{...ms})})]}),re&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:()=>ue(!1),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:e.jsx(Es,{...ms})})]}),xe&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close task list",onClick:()=>Z(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),e.jsx("div",{ref:F,className:"fixed inset-y-0 left-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 lg:hidden",children:e.jsx(Ms,{...us,onCreateTask:()=>{Z(!1),Dt()},onSelectTask:l=>{Z(!1),cs(l)},onClose:()=>Z(!1)})})]}),e.jsx(ra,{open:fe,onOpenChange:y,children:e.jsx(qo,{onAdded:()=>{y(!1),m()}})})]})}const yl=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:bl},Symbol.toStringTag,{value:"Module"}));export{Xe as C,yl as D,ja as F};
|