meshy-node 0.7.12 → 0.7.13
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-2RXNOej0.js +134 -0
- package/dashboard/assets/{DashboardShared-B06oRGIL.js → DashboardShared-Btqjrg2m.js} +1 -1
- package/dashboard/assets/{DiffTab-DTCrMNo4.js → DiffTab-dDJwxCuZ.js} +1 -1
- package/dashboard/assets/FilesTab-BdrrZSEY.js +22 -0
- package/dashboard/assets/{PreviewTab-AkNVXGUv.js → PreviewTab-DS5OePrB.js} +1 -1
- package/dashboard/assets/{SharedConversationPage-DA0lmaQJ.js → SharedConversationPage-CcAmmobW.js} +3 -3
- package/dashboard/assets/{file-HNfXsNaN.js → file-3IW0g4J1.js} +1 -1
- package/dashboard/assets/index-CNJwYgC6.css +1 -0
- package/dashboard/assets/{index-Cei-Aled.js → index-DeGSlcwy.js} +2 -2
- package/dashboard/assets/{play-DBL83S4p.js → play-DCfyl9eW.js} +1 -1
- package/dashboard/index.html +2 -2
- package/main.cjs +76 -62
- package/package.json +1 -1
- package/runtime-metadata.json +4 -4
- package/dashboard/assets/DashboardPage-Buhvr58K.js +0 -134
- package/dashboard/assets/FilesTab-CpmnikP6.js +0 -22
- package/dashboard/assets/index-DagywPq_.css +0 -1
package/README.md
CHANGED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-BdrrZSEY.js","assets/index-DeGSlcwy.js","assets/index-CNJwYgC6.css","assets/file-3IW0g4J1.js","assets/DashboardShared-Btqjrg2m.js","assets/PreviewTab-DS5OePrB.js","assets/play-DCfyl9eW.js","assets/DiffTab-dDJwxCuZ.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as me,r as a,j as e,X as ns,B as I,S as La,a as tr,b as $,d as ar,g as nr,e as rr,I as Xe,C as Ts,f as or,h as ir,F as lr,i as Pa,k as As,l as Ne,D as Ms,m as dr,n as cr,t as ae,o as Ce,p as _e,q as ze,s as De,u as ot,v as rs,T as ur,w as mr,x as ea,y as xr,z as Tt,A as At,E as Mt,G as Ba,H as Ra,J as bs,K as it,L as hr,M as $a,N as Oa,P as fr,O as Fa,Q as ds,R as Ke,U as pr,V as cs,W as lt,Y as dt,Z as ct,_ as ut,$ as mt,a0 as xt,a1 as ht,a2 as ft,a3 as Lt,a4 as gr,a5 as za,a6 as Ia,a7 as br,a8 as Js,a9 as sa,aa as Is,ab as vr,ac as jr,ad as Nr,ae as wr,af as yr,ag as kr,ah as Sr,ai as Cr,aj as Va,ak as Ua,al as Ha,am as _r,an as Vs,ao as Pt,ap as Dr,aq as Er,ar as Tr,as as Ka,at as pt,au as Ar,av as ta,aw as Mr,ax as Lr,ay as Pr,az as Br,aA as aa,aB as Rr,aC as $r,aD as Zs,aE as Or,aF as na,aG as Fr,aH as zr,aI as Ir,aJ as ra,aK as Vr,aL as gt,aM as Ur,aN as Hr,aO as Kr,aP as oa,aQ as qa,aR as qr,aS as Wr,aT as Gr,aU as Qr,aV as Yr,aW as Xr,aX as Jr,aY as Zr,aZ as eo,a_ as so,a$ as to,b0 as ao,b1 as no,b2 as ro,b3 as oo,b4 as io,b5 as lo,b6 as co,b7 as uo,b8 as mo,b9 as xo,ba as ho,bb as fo,bc as po,bd as go,be as bo}from"./index-DeGSlcwy.js";import{r as ia,e as vo,b as Wa,t as Ga,A as Bt,L as ce,g as Qa,a as jo,c as No,d as la,f as da,h as wo,i as yo,C as ca,T as et,D as gs,I as Qe,M as bt,j as Ya,k as ko,m as Xa,l as vt,n as So,o as ua,p as Co,q as _o,s as st,u as Do,v as Eo,w as To}from"./DashboardShared-Btqjrg2m.js";import{P as Rt}from"./play-DCfyl9eW.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 Ao=[["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"}]],Mo=me("archive",Ao);/**
|
|
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 Lo=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Po=me("arrow-up",Lo);/**
|
|
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 Bo=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Ro=me("ellipsis-vertical",Bo);/**
|
|
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 $o=[["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"}]],Oo=me("flag",$o);/**
|
|
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 Fo=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Ja=me("folder-open",Fo);/**
|
|
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 zo=[["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"}]],Io=me("funnel",zo);/**
|
|
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 Vo=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],jt=me("git-branch",Vo);/**
|
|
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 Uo=[["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"}]],Ho=me("globe",Uo);/**
|
|
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 Ko=[["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"}]],Nt=me("history",Ko);/**
|
|
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 qo=[["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"}]],wt=me("image-plus",qo);/**
|
|
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 Wo=[["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"}]],Go=me("laptop",Wo);/**
|
|
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 Qo=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],$t=me("link-2",Qo);/**
|
|
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 Yo=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],Xo=me("list-ordered",Yo);/**
|
|
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 Jo=[["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"}]],Ot=me("message-square-plus",Jo);/**
|
|
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 Zo=[["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"}]],Za=me("panel-left-close",Zo);/**
|
|
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 ei=[["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"}]],si=me("panel-left-open",ei);/**
|
|
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 ti=[["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"}]],Ft=me("panel-right-close",ti);/**
|
|
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 ai=[["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"}]],en=me("panel-right-open",ai);/**
|
|
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 ni=[["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"}]],ws=me("pencil",ni);/**
|
|
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 ri=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],oi=me("plus",ri);/**
|
|
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 ii=[["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"}]],ma=me("rotate-ccw",ii);/**
|
|
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 li=[["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"}]],sn=me("send",li);/**
|
|
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 di=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],ci=me("share-2",di);/**
|
|
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 ui=[["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"}]],mi=me("sliders-horizontal",ui);/**
|
|
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 xi=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],xa=me("square",xi);/**
|
|
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 hi=[["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"}]],fi=me("trash-2",hi),pi=new Set(["assigned","running"]);function gi(s,t){return s.reduce((n,o)=>o.assignedTo===t&&pi.has(o.status)?n+1:n,0)}function ys(s){return(s==null?void 0:s.toLowerCase())==="devtunnel"}function bi(s){return s?ys(s)?"DevTunnel":s.charAt(0).toUpperCase()+s.slice(1):"Direct"}function zt(s,t){return ys(t??s.transportType)||!!s.devtunnelEndpoint}function tn(s,t){return!ys(t??s.transportType)}function an(s,t){const n=t??s.transportType;return ys(n)?"DevTunnel":s.devtunnelEndpoint?"Direct + DevTunnel":bi(n)}function ha(s,t){return!s&&!t}function vi({routeTaskId:s,creatingTask:t,internalSelectedTaskId:n,sortedTaskIds:o}){return s||(t?null:o[0]??n??null)}function ji({activeTaskId:s,routeTaskId:t,creatingTask:n,tasksLoading:o,loadedTaskIds:r}){return!s||t||n||o?!1:!r.includes(s)}function Ni(s,t){return[t,...s.filter(n=>n.id!==t.id)]}function nn(s,t){const n=s.findIndex(o=>o.id===t.id);return n===-1?[...s,t]:s.map((o,r)=>r===n?t:o)}const wi=new Set(["completed","failed","cancelled","archived"]);function yi(s,t){const n=new Set(t);return new Set(Array.from(s).filter(o=>n.has(o)))}function ki(s,t){const n=new Set(t);if(n.size===0)return!1;const o=s.filter(r=>n.has(r.id));return o.length===n.size&&o.every(r=>wi.has(r.status))}function Si(s,t){var o;const n=new Set(t);return((o=s.find(r=>!n.has(r.id)))==null?void 0:o.id)??null}function rn(){const[s,t]=a.useState([]),[n,o]=a.useState(null),r=a.useRef(null),i=a.useCallback(()=>{var f;(f=r.current)==null||f.click()},[]),g=a.useCallback(async f=>{const l=Array.from(f.target.files??[]);if(l.length!==0)try{const u=await ia(l);t(w=>[...w,...u]),o(null)}catch(u){o(u instanceof Error?u.message:"Failed to attach image")}finally{f.target.value=""}},[]),b=a.useCallback(async f=>{const l=vo(f.clipboardData);if(l.length!==0){f.preventDefault();try{const u=await ia(l);t(w=>[...w,...u]),o(null)}catch(u){o(u instanceof Error?u.message:"Failed to attach image")}}},[]),N=a.useCallback(f=>{t(l=>l.filter((u,w)=>w!==f))},[]),v=a.useCallback(()=>{t([]),o(null)},[]);return{images:s,error:n,fileInputRef:r,pickImages:i,handleFileChange:g,handlePaste:b,removeImage:N,clearImages:v}}function Ci(s){const t=s.map(r=>({...r,displayValue:_i(r)})),n=t.findIndex(r=>r.label.toLowerCase()==="working dir"),o=n>=0?n:0;return{primary:t[o],secondary:t.filter((r,i)=>i!==o)}}function _i(s){return s.label.toLowerCase()==="agent"?Qa(s.value):s.value}function fa(s){switch(s.toLowerCase()){case"branch":return jt;case"node":return La;case"working dir":default:return Ja}}function Di({disabled:s=!1,running:t=!1,canStop:n=!1,hasContent:o=!1}){return t&&!o?{primaryAction:"stop",primaryDisabled:s||!n}:{primaryAction:"send",primaryDisabled:s||!o}}function Ei({onSend:s,disabled:t,disabledReason:n="Chat is waiting on the agent.",placeholder:o="Send a follow-up message...",contextItems:r=[],running:i=!1,onStop:g}){const[b,N]=a.useState(""),v=a.useRef(null),{images:f,error:l,fileInputRef:u,pickImages:w,handleFileChange:C,handlePaste:x,removeImage:j,clearImages:c}=rn(),p=a.useCallback(()=>{v.current&&(v.current.style.height="auto")},[]),S=a.useCallback(()=>{const E=Wa(b,f);E.length===0||t||(s(E),N(""),c(),p())},[b,f,t,s,c,p]),A=a.useCallback(E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),S())},[S]),L=a.useCallback(()=>{v.current&&(v.current.style.height="auto",v.current.style.height=`${Math.min(v.current.scrollHeight,220)}px`)},[]),O=b.trim().length>0||f.length>0,F=Di({disabled:t,running:i,canStop:i&&!!g,hasContent:O}),V=Ci(r),M=V.primary?fa(V.primary.label):Ja,P=i?O?"Enter queues this message for the next turn":g?"Task is running - type to queue, empty button stops task":"Task is running - type to queue a message":t?n:"Enter sends, Shift+Enter adds a line";return e.jsx("div",{"data-chat-input-shell":"true",className:"animate-composer-settle w-full border-t border-border/45 bg-background/42 px-2 py-2 backdrop-blur-xl sm:px-4 sm:py-3",children:e.jsx("div",{"data-chat-input-column":"true",className:"mx-auto w-full max-w-[72rem]",children:e.jsxs("div",{"data-chat-input-card":"true",className:"overflow-hidden rounded-xl border border-border/65 bg-card/88 shadow-[0_30px_92px_-62px_rgba(15,23,42,0.55)] backdrop-blur-xl sm:rounded-xl dark:shadow-[0_30px_92px_-62px_rgba(0,0,0,0.95)]",children:[e.jsx("input",{ref:u,type:"file",accept:"image/*",multiple:!0,onChange:C,className:"hidden"}),V.primary&&e.jsx("div",{"data-chat-input-primary-context":"true",className:"px-2.5 pt-1.5 sm:px-5 sm:pt-2",children:e.jsxs("div",{className:"inline-flex max-w-full items-center gap-1.5 rounded-sm border border-border/55 bg-muted/35 px-1.5 py-0.5",children:[e.jsx(M,{className:"h-2.5 w-2.5 shrink-0 text-primary/45","aria-hidden":"true"}),e.jsx("span",{className:"truncate font-mono text-[9px] leading-3 text-muted-foreground/72",title:V.primary.value,children:V.primary.displayValue})]})}),f.length>0&&e.jsx("div",{className:"px-2 pt-2.5 sm:px-5 sm:pt-4",children:e.jsx("div",{className:"flex flex-wrap gap-3",children:f.map((E,X)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:Ga(E),alt:E.filename??`attachment ${X+1}`,className:"h-24 w-24 rounded-xl border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>j(X),className:"absolute -top-2 -right-2 flex h-7 w-7 items-center justify-center rounded-sm border border-border/70 bg-background text-muted-foreground shadow-sm transition-all hover:-translate-y-px hover:text-foreground","aria-label":`Remove ${E.filename??`image ${X+1}`}`,children:e.jsx(ns,{className:"h-3.5 w-3.5"})})]},`${E.filename??"image"}-${X}`))})}),e.jsx("div",{className:"px-2 pb-0 pt-1 sm:px-5 sm:pt-1.5",children:e.jsx("textarea",{ref:v,value:b,onChange:E=>N(E.target.value),onKeyDown:A,onPaste:x,onInput:L,placeholder:o,disabled:t,rows:1,className:"min-h-[1.35rem] w-full resize-none overflow-x-hidden overflow-y-auto bg-transparent px-0 py-0 text-[11px] leading-[1.35rem] text-foreground placeholder:text-[10px] placeholder:text-muted-foreground/65 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"})}),e.jsxs("div",{className:"flex items-end justify-between gap-2 px-2 pb-1.5 pt-0.5 sm:px-5 sm:pb-2.5",children:[V.secondary.length>0?e.jsx("div",{"data-chat-input-secondary-context":"true",className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 pb-0.5 text-[9px] leading-3 text-muted-foreground/72 sm:text-[9px]",children:V.secondary.map(E=>{const X=fa(E.label),U=E.label.toLowerCase()==="agent";return e.jsxs("span",{title:`${E.label}: ${E.value}`,className:"inline-flex min-w-0 max-w-[12rem] items-center gap-1 truncate",children:[U?e.jsx(Bt,{agent:E.value,className:"h-2.5 w-2.5 shrink-0 text-primary/50"}):e.jsx(X,{"data-chat-input-secondary-icon":"true",className:"h-2.5 w-2.5 shrink-0 text-primary/50","aria-hidden":"true"}),e.jsx("span",{className:`truncate ${E.mono?"font-mono":""}`,children:E.displayValue})]},`${E.label}:${E.value}`)})}):e.jsx("div",{className:"min-w-0 flex-1"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(I,{type:"button",variant:"ghost",onClick:w,disabled:t,className:"h-7 shrink-0 gap-1.5 rounded-sm px-2 text-[10px] text-muted-foreground hover:text-foreground sm:px-2",title:"Attach images",children:[e.jsx(wt,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Images"})]}),e.jsx("span",{title:P,children:e.jsx(I,{onClick:F.primaryAction==="stop"?g:S,disabled:F.primaryDisabled,size:"icon","aria-label":F.primaryAction==="stop"?"Stop running task":i?"Queue message":"Send message",className:"h-7 w-9 shrink-0 rounded-sm bg-primary/90 text-primary-foreground shadow-[0_12px_30px_-18px_hsl(var(--primary)/0.95)] hover:bg-primary",children:F.primaryAction==="stop"?e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(sn,{className:"h-3.5 w-3.5"})})})]})]}),l&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-2 py-2 text-[11px] text-destructive sm:px-6 sm:py-3",children:l})]})})})}var Ti=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ai=Ti.reduce((s,t)=>{const n=tr(`Primitive.${t}`),o=a.forwardRef((r,i)=>{const{asChild:g,...b}=r,N=g?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(N,{...b,ref:i})});return o.displayName=`Primitive.${t}`,{...s,[t]:o}},{}),Mi="Label",on=a.forwardRef((s,t)=>e.jsx(Ai.label,{...s,ref:t,onMouseDown:n=>{var r;n.target.closest("button, input, select, textarea")||((r=s.onMouseDown)==null||r.call(s,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));on.displayName=Mi;var ln=on;const Li=ar("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Be=a.forwardRef(({className:s,...t},n)=>e.jsx(ln,{ref:n,className:$(Li(),s),...t}));Be.displayName=ln.displayName;function Pi(s,t,n){return s!=="auto"?t.find(o=>o.id===s)??null:n.length===1?n[0]??null:null}function Bi(s){return s.trim()||"."}function Ri(s){return new Promise(t=>window.setTimeout(t,s))}function $i(s){return!!s&&typeof s=="object"&&typeof s.createdBranch=="string"&&typeof s.currentBranch<"u"}async function Oi(s){let t=s;for(let n=0;n<60;n++){if(t.status==="succeeded"){if($i(t.result))return t.result;throw new Error("Branch creation completed without branch details")}if(t.status==="failed")throw new Error(t.error||"Branch creation failed");await Ri(1e3),t=await or(t.id)}throw new Error("Timed out waiting for branch creation")}function pa({value:s,onChange:t,project:n,assignTo:o,nodes:r,assignableNodes:i,layout:g="default",chipClassName:b,chipActiveClassName:N,chipInactiveClassName:v,labelClassName:f,triggerClassName:l}){const[u,w]=a.useState(!1),[C,x]=a.useState(null),[j,c]=a.useState(""),[p,S]=a.useState(!1),[A,L]=a.useState(!1),[O,T]=a.useState(!1),[F,V]=a.useState(null),[M,P]=a.useState(""),[E,X]=a.useState(""),[U,Y]=a.useState(""),[le,ne]=a.useState(!1),Z=a.useRef(null),J=a.useRef(0),H=a.useMemo(()=>Pi(o,r,i),[o,r,i]),K=H==null?void 0:H.id,re=a.useMemo(()=>Bi(n),[n]),ue=a.useMemo(()=>K?`${K}
|
|
133
|
+
${re}`:"",[K,re]),h=a.useCallback(async(k=0,G=!1)=>{const se=J.current+1,Re=ue;if(J.current=se,!K){x(null),c("");return}V(null),G||c(""),G?L(!0):S(!0);try{const ve=await nr(K,{path:re,limit:20,offset:k,allowAbsolute:!0});if(se!==J.current)return;c(Re),x(fe=>G&&fe?{...ve,branches:[...fe.branches,...ve.branches]}:ve)}catch(ve){if(se!==J.current)return;V(ve instanceof Error?ve.message:"Failed to load branch info"),G||(x(null),c(""))}finally{se===J.current&&(S(!1),L(!1))}},[K,ue,re]);a.useEffect(()=>{if(!K){J.current+=1,x(null),c(""),V(null);return}h()},[K,re,h]),a.useEffect(()=>{const k=s.trim(),G=j===ue?C:null,se=G!=null&&G.available&&G.currentBranch?G.currentBranch:"";k!==se&&t(se)},[C,ue,j,t,s]),a.useEffect(()=>{if(!u)return;const k=se=>{Z.current&&(Z.current.contains(se.target)||w(!1))},G=se=>{se.key==="Escape"&&w(!1)};return document.addEventListener("mousedown",k),document.addEventListener("keydown",G),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",G)}},[u]),a.useEffect(()=>{u&&(X(""),Y(""),ne(!1))},[u,K,re]);const z=a.useCallback(async()=>{if(!K)return;const k=M.trim(),G=le?U.trim():E.trim();if(!(!k||!G)){T(!0),V(null);try{const se=await rr(K,{path:re,branchName:k,startPoint:G,limit:20,offset:0,allowAbsolute:!0}),Re=await Oi(se);c(ue),x(Re),t(Re.currentBranch??Re.createdBranch),P(""),X(""),Y(""),ne(!1),w(!1)}catch(se){V(se instanceof Error?se.message:"Failed to create branch")}finally{T(!1)}}},[K,ue,re,le,U,M,t,E]),_=j===ue?C:null,ee=a.useCallback(()=>{_!=null&&_.hasMore&&h(_.branches.length,!0)},[_,h]),m=s.trim()||(_==null?void 0:_.currentBranch)||(_&&!_.available?"No git repo":"Branch"),R=le?U.trim():E.trim(),q=!!(_!=null&&_.available&&M.trim()&&R&&!O),te=g==="composer"?e.jsxs(I,{type:"button",variant:"ghost",onClick:()=>w(k=>!k),title:m,"aria-label":`Branch: ${m}`,className:$(b,l,"min-w-0 max-w-full",s.trim()?N:v),children:[p&&!_?e.jsx(ce,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(jt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:$("min-w-0 truncate",f),children:m})]}):e.jsxs(I,{type:"button",variant:"outline",onClick:()=>w(k=>!k),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:m,children:[e.jsx("span",{className:$("truncate",s.trim()?"font-mono text-foreground":"text-muted-foreground"),children:m}),e.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:H?H.name:"Manual"})]});return e.jsxs("div",{className:$("relative inline-block",g==="composer"?"min-w-0 shrink-0":"w-full"),ref:Z,children:[g==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Be,{className:"text-sm font-medium",children:"Branch"}),te]}):te,u&&e.jsxs("div",{className:$("absolute z-50 mt-2 w-[240px] overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",g==="composer"?"left-0":"left-0 right-0 w-auto min-w-[240px]"),children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsx(jt,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-foreground",title:_!=null&&_.repoRoot?`${_.currentBranch??m} · ${_.repoRoot}`:(_==null?void 0:_.currentBranch)??m,children:(_==null?void 0:_.currentBranch)??m}),p?e.jsx(ce,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}):null]}),H?p&&!_?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(ce,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):_&&!_.available?e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Not a git repository."}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"space-y-2 px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Xe,{value:M,onChange:k=>P(k.target.value),placeholder:"New branch name",className:"h-8 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx(I,{type:"button",size:"sm",onClick:()=>void z(),disabled:!q,title:q?"Create branch":"Enter a name and pick a base","aria-label":"Create branch",className:"h-8 w-8 shrink-0 rounded-md p-0",children:O?e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(oi,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Base from"}),!le&&e.jsxs("button",{type:"button",onClick:()=>ne(!0),className:"flex items-center gap-1 rounded px-1 py-0.5 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:[e.jsx(ws,{className:"h-2.5 w-2.5"}),"Manual"]})]}),le?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Xe,{value:U,onChange:k=>Y(k.target.value),placeholder:"upstream/release/1.0",className:"h-8 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>{ne(!1),Y("")},className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel manual input","aria-label":"Cancel manual input",children:e.jsx(ns,{className:"h-3.5 w-3.5"})})]}):_!=null&&_.branches.length?e.jsxs("div",{className:"max-h-44 overflow-y-auto rounded-md border border-border/40 bg-background/40",children:[_.branches.map(k=>{const G=E===k.ref,se=k.branch==="main"||k.branch==="master";return e.jsxs("button",{type:"button",onClick:()=>X(k.ref),className:$("flex w-full items-center gap-2 border-b border-border/20 px-2.5 py-1.5 text-left text-[11px] last:border-b-0 hover:bg-background/60",G&&"bg-background/70"),title:k.ref,children:[e.jsx("span",{className:$("shrink-0 text-[10px]",se?"text-amber-500 dark:text-amber-400":"text-muted-foreground/60"),"aria-hidden":!0,children:se?"★":"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:k.ref}),G?e.jsx(Ts,{className:"h-3 w-3 shrink-0 text-primary"}):null]},k.ref)}),_.hasMore&&e.jsxs("button",{type:"button",onClick:ee,disabled:A,className:"flex w-full items-center justify-center gap-1 border-t border-border/20 py-1 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground disabled:opacity-50",children:[A?e.jsx(ce,{className:"h-3 w-3 animate-spin"}):e.jsx(Nt,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"rounded-md border border-dashed border-border/40 px-2.5 py-2 text-[11px] text-muted-foreground",children:"No remote branches found."})]})]})}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a specific node first."}),F&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-1.5 text-[11px] text-destructive",children:F})]})]})}const Fi=20,zi=3,yt="meshy-working-dir-recents-by-node";function Ii(s){return s.startsWith("/")||s.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(s)}function Vi(s){const t=s.trim();return t||"."}function kt(s){const t=[],n=new Set;for(const o of s){const r=o.trim();if(!(!r||n.has(r))&&(n.add(r),t.push(r),t.length===zi))break}return t}function Ui(s,t){const n=t.trim();return kt(n?[n,...s]:s)}function dn(s){if(!s||typeof s!="object"||Array.isArray(s))return{};const t={};for(const[n,o]of Object.entries(s)){if(!n||!Array.isArray(o))continue;const r=o.filter(g=>typeof g=="string"),i=kt(r);i.length>0&&(t[n]=i)}return t}function Hi(s,t,n){if(!t)return s;const o=s[t]??[],r=Ui(o,n);if(r.length===0){if(!(t in s))return s;const{[t]:i,...g}=s;return g}return{...s,[t]:r}}function Ki(s,t){var n;return t?((n=s[t])==null?void 0:n[0])??"":""}function cn(s){if(!s||typeof window>"u")return"";try{const t=window.localStorage.getItem(yt);return t?Ki(dn(JSON.parse(t)),s):""}catch{return""}}function qi(s,t,n){return s!=="auto"?t.find(o=>o.id===s)??null:n.length===1?n[0]??null:null}function Wi(s,t){const n=t.trim();return n?Ii(n)||!s?n:`${s.replace(/[/\\]+$/,"")}/${n}`:""}function Gi(s,t){return s?s.isAbsolute?s.currentPath:s.currentPath==="."||s.currentPath===""?s.rootPath||(t==null?void 0:t.workDir)||"Node root":s.currentPath:(t==null?void 0:t.workDir)??"Node root"}function Us({value:s,onChange:t,assignTo:n,nodes:o,assignableNodes:r,layout:i="default",chipClassName:g,chipActiveClassName:b,chipInactiveClassName:N,labelClassName:v,triggerClassName:f,popoverPlacement:l="bottom",popoverAlign:u="start"}){const[w,C]=a.useState(!1),[x,j]=a.useState(null),[c,p]=a.useState(!1),[S,A]=a.useState(!1),[L,O]=a.useState(null),[T,F]=a.useState(""),[V,M]=a.useState(!1),[P,E]=a.useState({}),X=a.useRef(null),U=a.useMemo(()=>qi(n,o,r),[n,o,r]),Y=U==null?void 0:U.id,le=a.useMemo(()=>Y?P[Y]??[]:[],[P,Y]),ne=a.useMemo(()=>s.trim()?Wi(U==null?void 0:U.workDir,s):"Use node default",[s,U==null?void 0:U.workDir]);a.useEffect(()=>{if(!(typeof window>"u"))try{const m=window.localStorage.getItem(yt);if(!m)return;const R=JSON.parse(m);E(dn(R))}catch{}},[]);const Z=a.useCallback(m=>{Y&&E(R=>{const q=Hi(R,Y,m);if(q===R)return R;if(typeof window<"u")try{window.localStorage.setItem(yt,JSON.stringify(q))}catch{}return q})},[Y]),J=a.useCallback((m,R=!0)=>{const q=m.trim();t(q),R&&q&&Z(q),C(!1)},[t,Z]),H=a.useCallback(async(m,R=0,q=!1)=>{if(Y){O(null),q?A(!0):p(!0);try{const te=await ir(Y,{path:m,limit:Fi,offset:R,directoriesOnly:!0,allowAbsolute:!0});j(k=>q&&k?{...te,entries:[...k.entries,...te.entries]}:te)}catch(te){O(te instanceof Error?te.message:"Failed to browse directories"),q||j(null)}finally{p(!1),A(!1)}}},[Y]),K=a.useRef(s);K.current=s;const re=a.useRef(H);re.current=H,a.useEffect(()=>{if(!w)return;const m=K.current;F(m),M(!1),j(null),O(null),Y&&re.current(Vi(m))},[w,Y]),a.useEffect(()=>{if(!w)return;const m=q=>{X.current&&(X.current.contains(q.target)||C(!1))},R=q=>{q.key==="Escape"&&C(!1)};return document.addEventListener("mousedown",m),document.addEventListener("keydown",R),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",R)}},[w]);const ue=a.useCallback(m=>{H(m)},[H]),h=a.useCallback(()=>{x&&H(x.currentPath,x.entries.length,!0)},[x,H]),z=i==="composer"?e.jsxs(I,{type:"button",variant:"ghost",onClick:()=>C(m=>!m),title:ne,"aria-label":`Working directory: ${ne}`,className:$(g,f,"min-w-0 max-w-full",s.trim()?b:N),children:[e.jsx(lr,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:$("min-w-0 truncate",v),children:ne})]}):e.jsxs(I,{type:"button",variant:"outline",onClick:()=>C(m=>!m),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:ne,children:[e.jsx("span",{className:$("truncate",s.trim()?"font-mono text-foreground":"text-muted-foreground"),children:ne}),e.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:U?U.name:"Manual"})]}),_=Gi(x,U),ee=!!(x!=null&&x.parentPath);return e.jsxs("div",{className:$("relative inline-block",i==="composer"?"min-w-0 max-w-[60%] shrink":"w-full"),"data-workdir-popover-placement":l,"data-workdir-popover-align":u,ref:X,children:[i==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Be,{className:"text-sm font-medium",children:"Working directory"}),z]}):z,w&&e.jsxs("div",{className:$("absolute z-50 flex max-h-[min(28rem,calc(100vh-5rem))] w-[240px] flex-col overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",l==="top"?"bottom-full mb-2":"top-full mt-2",i==="composer"?u==="end"?"right-0":"left-0":u==="end"?"right-0 w-auto min-w-[240px]":"left-0 right-0 w-auto min-w-[240px]"),children:[le.length>0&&e.jsxs("div",{className:"border-b border-border/60 px-3 py-2",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1 text-[10px] text-muted-foreground",children:[e.jsx(Nt,{className:"h-2.5 w-2.5"}),"Recent"]}),e.jsx("div",{className:"flex flex-col",children:le.map(m=>e.jsx("button",{type:"button",onClick:()=>J(m),className:"truncate rounded px-1.5 py-0.5 text-left font-mono text-[11px] text-foreground hover:bg-background/60",title:m,children:m},m))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/60 px-2.5 py-1.5",children:[e.jsx("button",{type:"button",onClick:()=>(x==null?void 0:x.parentPath)&&ue(x.parentPath),disabled:!ee||c,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-border/60 text-muted-foreground transition-colors hover:bg-background/60 hover:text-foreground disabled:opacity-40",title:"Parent directory",children:e.jsx(Po,{className:"h-3 w-3"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:_,children:_}),x&&e.jsx("button",{type:"button",onClick:()=>J(x.isAbsolute?x.currentPath:x.currentPath==="."?"":x.currentPath),className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium text-foreground hover:bg-background/60",title:"Use this folder",children:"Use"})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:[U?c?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(ce,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):x&&x.entries.length>0?e.jsxs(e.Fragment,{children:[x.entries.map(m=>e.jsxs("div",{className:"group flex items-stretch border-b border-border/30 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>J(m.path),className:"flex min-w-0 flex-1 items-center gap-2 px-2.5 py-1.5 text-left hover:bg-background/55",title:`Use ${m.path}`,children:[e.jsx(Pa,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[11px] text-foreground",children:m.name})]}),e.jsx("button",{type:"button",onClick:()=>ue(m.path),className:"flex w-9 shrink-0 items-center justify-center border-l border-border/30 text-muted-foreground hover:bg-background/70 hover:text-foreground",title:"Open subfolder","aria-label":`Open ${m.name}`,children:e.jsx(As,{className:"h-3.5 w-3.5"})})]},m.path)),x.hasMore&&e.jsxs("button",{type:"button",onClick:h,disabled:S,className:"flex w-full items-center justify-center gap-1 border-t border-border/40 py-1 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground disabled:opacity-50",children:[S?e.jsx(ce,{className:"h-3 w-3 animate-spin"}):e.jsx(Nt,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:L??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a node to browse."}),L&&x&&x.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[11px] text-destructive",children:L})]}),e.jsx("div",{className:"flex items-center gap-1 border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:V?e.jsxs(e.Fragment,{children:[e.jsx(Xe,{value:T,onChange:m=>F(m.target.value),onKeyDown:m=>{m.key==="Enter"&&T.trim()?(m.preventDefault(),J(T)):m.key==="Escape"&&(m.preventDefault(),M(!1),F(s))},autoFocus:!0,placeholder:"Path (relative or absolute)",className:"h-7 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>J(T),disabled:!T.trim(),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-foreground hover:bg-background/60 disabled:opacity-40",title:"Apply","aria-label":"Apply manual path",children:e.jsx(Ts,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{M(!1),F(s)},className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel","aria-label":"Cancel manual path",children:e.jsx(ns,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>{F(s),M(!0)},className:"flex h-7 flex-1 items-center justify-between rounded-md px-1.5 text-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Enter a manual path",children:[e.jsx("span",{children:"Manual input"}),e.jsx(ws,{className:"h-3 w-3"})]})})]})]})}function un(s,t={}){const n=s.filter(o=>o.status==="online");return t.currentNodeRole!=="follower"||!t.leaderNodeId?n:n.filter(o=>o.id!==t.leaderNodeId)}function It({isCurrent:s}){return s?e.jsx(Go,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):e.jsx(Ho,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function St(s,t){return s.map(n=>{const o=!!t&&n.id===t;return e.jsx(Ne,{value:n.id,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(It,{isCurrent:o}),e.jsx("span",{className:"truncate",children:n.name}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:o?"current":"remote"})]})},n.id)})}function Qi(s){var o;const t=s.sessionId.trim(),n=s.cwd.trim();return!t||!n||!s.assignTo?null:{title:s.title.trim()||((o=s.defaultTitle)==null?void 0:o.trim())||void 0,agent:s.agent,sessionId:t,cwd:n,assignTo:s.assignTo,priority:s.priority,mode:s.mode??Ms}}function Yi(){return ur.map(s=>e.jsx(Ne,{value:s.value,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:s.label}),s.description&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:s.description})]})},s.value))}function Xi(s){if(!s)return"unknown time";const t=Date.parse(s);return Number.isNaN(t)?s:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(t)}function Ji({nodes:s,currentNodeRole:t,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,className:g,footerClassName:b,submitLabel:N="Load session",cancelLabel:v="Cancel",autoFocus:f=!1}){const l=a.useMemo(()=>un(s,{currentNodeRole:t,leaderNodeId:o}),[s,t,o]),u=a.useMemo(()=>{var k;return n&&l.some(G=>G.id===n)?n:((k=l[0])==null?void 0:k.id)??""},[l,n]),[w,C]=a.useState(""),[x,j]=a.useState("codex"),[c,p]=a.useState(""),[S,A]=a.useState(""),[L,O]=a.useState(""),[T,F]=a.useState(u),[V,M]=a.useState("normal"),[P,E]=a.useState(Ms),[X,U]=a.useState(!1),[Y,le]=a.useState([]),[ne,Z]=a.useState(!1),[J,H]=a.useState(null),K=a.useMemo(()=>Y.find(k=>k.sessionId===c)??null,[Y,c]);a.useEffect(()=>{T&&l.some(k=>k.id===T)||F(u)},[T,l,u]),a.useEffect(()=>{p(""),A(""),O("")},[x,T]),a.useEffect(()=>{let k=!1;return T?(Z(!0),H(null),dr(T,{agent:x,limit:50}).then(G=>{k||le(G.sessions)}).catch(G=>{k||(le([]),H(G instanceof Error?G.message:"Failed to load native sessions"))}).finally(()=>{k||Z(!1)}),()=>{k=!0}):(le([]),H(null),Z(!1),()=>{k=!0})},[x,T]),a.useEffect(()=>{K&&(A(K.sessionId),O(K.cwd))},[K]);const re=a.useCallback(async k=>{k.preventDefault();const G=Qi({title:w,defaultTitle:K==null?void 0:K.summary,agent:x,sessionId:S,cwd:L,assignTo:T,priority:V,mode:P});if(G){U(!0);try{const se=await cr(G);r(se)}catch(se){ae.error(se instanceof Error?se.message:"Failed to load native session")}finally{U(!1)}}},[w,K,x,S,L,T,V,P,r]),ue=!!(S.trim()&&L.trim()&&T),[h,z]=a.useState(!1),[_,ee]=a.useState(""),m=l.find(k=>k.id===T)??null,R=!!(n&&(m==null?void 0:m.id)===n),q=a.useMemo(()=>{const k=_.trim().toLowerCase();return k?Y.filter(G=>G.summary.toLowerCase().includes(k)||G.sessionId.toLowerCase().includes(k)||G.cwd.toLowerCase().includes(k)):Y},[Y,_]),te="h-9 w-auto gap-1.5 rounded-sm border-border/60 bg-background/60 px-3 text-xs shadow-none transition-colors hover:bg-background/80";return e.jsxs("form",{onSubmit:re,className:$("space-y-4",g),children:[e.jsxs("div",{className:"rounded-xl border border-border/60 bg-background/54 shadow-[0_24px_86px_-48px_rgba(15,23,42,0.55)] backdrop-blur-xl dark:shadow-[0_24px_86px_-48px_rgba(0,0,0,0.9)]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/50 px-4 py-3",children:[e.jsxs(Ce,{value:T,onValueChange:F,children:[e.jsx(_e,{className:$(te),"aria-label":"Node",children:m?e.jsxs(e.Fragment,{children:[e.jsx(It,{isCurrent:R}),e.jsx("span",{className:"max-w-[10rem] truncate",children:m.name})]}):e.jsx(ze,{placeholder:"Node"})}),e.jsx(De,{children:St(l,n)})]}),e.jsxs(Ce,{value:x,onValueChange:k=>j(k),children:[e.jsxs(_e,{className:$(te),"aria-label":"Agent",children:[e.jsx(Bt,{agent:x}),e.jsx("span",{children:x})]}),e.jsx(De,{children:jo()})]}),e.jsxs("div",{className:"relative ml-auto min-w-0 flex-1 sm:max-w-56",children:[e.jsx(ot,{className:"pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(Xe,{value:_,onChange:k=>ee(k.target.value),placeholder:"Filter sessions",className:"h-9 rounded-sm border-border/60 bg-background/60 pl-9 text-xs shadow-none"})]})]}),e.jsxs("div",{className:"px-3 py-3",children:[e.jsx("div",{className:"flex items-center justify-between px-1 pb-2",children:e.jsx(Be,{className:"text-[10px] font-medium uppercase tracking-[0.2em] text-muted-foreground",children:ne?"Loading...":`${q.length} session${q.length===1?"":"s"}`})}),e.jsxs("div",{className:"relative h-88 overflow-hidden rounded-lg",children:[ne&&e.jsx("div",{className:"absolute inset-x-0 top-0 z-10 h-0.5 overflow-hidden bg-primary/10",children:e.jsx("div",{className:"h-full w-1/3 animate-indeterminate-bar bg-primary/70"})}),e.jsxs("div",{className:"h-full space-y-1.5 overflow-y-auto pr-1 pt-1",children:[!T&&e.jsx("div",{className:"rounded-lg border border-dashed border-border/60 bg-background/35 px-4 py-6 text-center text-xs text-muted-foreground",children:"Pick a node to load its recent sessions."}),T&&!ne&&q.length===0&&e.jsx("div",{className:"rounded-lg border border-dashed border-border/60 bg-background/35 px-4 py-6 text-center text-xs text-muted-foreground",children:Y.length===0?"No recent sessions on this node. Use Manual session ID under More options.":"No sessions match your filter."}),q.map(k=>{const G=k.sessionId===c;return e.jsxs("button",{type:"button",onClick:()=>p(k.sessionId),className:$("flex w-full flex-col gap-1 rounded-lg border px-3 py-2.5 text-left transition-all duration-200 hover:-translate-y-px",G?"border-primary/45 bg-primary/9 shadow-[0_18px_60px_-44px_hsl(var(--primary)/0.95)]":"border-border/55 bg-background/40 hover:border-border hover:bg-background/65"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:$("h-2 w-2 shrink-0 rounded-full",G?"bg-primary":"bg-border")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:k.summary}),e.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:Xi(k.updatedAt)})]}),e.jsxs("div",{className:"flex items-center gap-2 pl-4 text-[10px] text-muted-foreground",children:[e.jsx("span",{className:"font-mono",children:k.sessionId.slice(0,12)}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),e.jsx("span",{className:"truncate font-mono",children:k.cwd})]})]},k.sessionId)})]})]}),J&&e.jsx("p",{className:"px-1 pt-2 text-[11px] text-destructive",children:J})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",onClick:()=>z(k=>!k),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-[0.2em] text-muted-foreground transition-colors hover:text-foreground","aria-expanded":h,children:[e.jsx("span",{className:"h-px flex-1 bg-border/60","aria-hidden":!0}),e.jsx("span",{className:"shrink-0",children:h?"Less options":"More options"}),e.jsx(rs,{className:$("h-3.5 w-3.5 shrink-0 transition-transform",h&&"rotate-180")}),e.jsx("span",{className:"h-px flex-1 bg-border/60","aria-hidden":!0})]}),h&&e.jsxs("div",{className:"space-y-4 rounded-xl border border-border/60 bg-background/35 p-4",children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Be,{htmlFor:"native-session-id",className:"text-xs font-medium text-muted-foreground",children:"Session ID"}),e.jsx(Xe,{id:"native-session-id",type:"text",value:S,onChange:k=>{p(""),A(k.target.value)},placeholder:"ses_..., thread_..., or UUID",autoFocus:f,className:"h-10 rounded-sm border-border/70 bg-background/70 font-mono text-xs"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Be,{htmlFor:"native-session-title",className:"text-xs font-medium text-muted-foreground",children:"Task title"}),e.jsx(Xe,{id:"native-session-title",type:"text",value:w,onChange:k=>C(k.target.value),placeholder:"Optional",className:"h-10 rounded-sm border-border/70 bg-background/70 text-sm"})]})]}),e.jsx(Us,{value:L,onChange:k=>{p(""),O(k)},assignTo:T,nodes:s,assignableNodes:l}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Be,{className:"text-xs font-medium text-muted-foreground",children:"Mode"}),e.jsxs(Ce,{value:P,onValueChange:k=>E(k),children:[e.jsx(_e,{className:"h-10 rounded-sm border-border/70 bg-background/70 text-sm",children:e.jsx(ze,{placeholder:"Select mode"})}),e.jsx(De,{children:Yi()})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Be,{className:"text-xs font-medium text-muted-foreground",children:"Priority"}),e.jsxs(Ce,{value:V,onValueChange:M,children:[e.jsx(_e,{className:"h-10 rounded-sm border-border/70 bg-background/70 text-sm",children:e.jsx(ze,{placeholder:"Select priority"})}),e.jsxs(De,{children:[e.jsx(Ne,{value:"low",children:"Low"}),e.jsx(Ne,{value:"normal",children:"Normal"}),e.jsx(Ne,{value:"high",children:"High"}),e.jsx(Ne,{value:"critical",children:"Critical"})]})]})]})]})]})]}),e.jsxs("div",{className:$("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",b),children:[i&&e.jsx(I,{type:"button",variant:"ghost",onClick:i,className:"rounded-sm",children:v}),e.jsx(I,{type:"submit",disabled:!ue||X,className:"rounded-sm px-5",children:X?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"h-4 w-4 animate-spin"})," Loading..."]}):N})]})]})}function mn(s,t,n=!1){const o=s.trim();if(o)return o;const r=t.trim().split(`
|
|
134
|
+
`).map(i=>i.trim()).find(Boolean);return r?r.length>72?`${r.slice(0,69).trimEnd()}...`:r:n?"Image task":""}function Zi(s){var g;const t=s.title.trim(),n=mn(s.title,s.description,s.images.length>0),o=s.description.trim()||n,r=s.mode??Ms,i=Wa(s.description,s.images);return!n||!o||!s.agent?null:{title:n,description:o,agent:s.agent,project:s.project.trim()||null,branch:((g=s.branch)==null?void 0:g.trim())||null,payload:{initialMessage:i,mode:r,titleSource:t?"manual":"derived"},priority:s.priority,assignTo:s.assignTo==="auto"?void 0:s.assignTo}}function el({nodes:s,currentNodeRole:t,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,className:g,footerClassName:b,submitLabel:N="Create chat",cancelLabel:v="Cancel",autoFocus:f=!1,layout:l="default"}){const[u,w]=a.useState(""),[C,x]=a.useState(""),[j,c]=a.useState(ea),[p,S]=a.useState(Ms),[A,L]=a.useState(""),[O,T]=a.useState(""),[F,V]=a.useState("normal"),M=a.useMemo(()=>un(s,{currentNodeRole:t,leaderNodeId:o}),[s,t,o]),P=a.useMemo(()=>{var Q;return n&&M.some(pe=>pe.id===n)?n:((Q=M[0])==null?void 0:Q.id)??""},[M,n]),[E,X]=a.useState(P),[U,Y]=a.useState(!1),[le,ne]=a.useState(!1),{images:Z,error:J,fileInputRef:H,pickImages:K,handleFileChange:re,handlePaste:ue,removeImage:h}=rn(),z=a.useMemo(()=>M.find(Q=>Q.id===E)??null,[E,M]),_=!!(n&&(z==null?void 0:z.id)===n),ee=Qa(j),m=No(p);a.useEffect(()=>{E&&M.some(Q=>Q.id===E)||X(P)},[E,M,P]),a.useEffect(()=>{L(cn(E)),T("")},[E]),a.useEffect(()=>{T("")},[A]);const R=a.useCallback(async Q=>{Q.preventDefault();const pe=Zi({title:u,description:C,agent:j,project:A,branch:O,priority:F,assignTo:E,mode:p,images:Z});if(pe){Y(!0);try{const we=await xr(pe);r(we)}catch(we){ae.error(we instanceof Error?we.message:"Failed to create task")}finally{Y(!1)}}},[u,C,j,A,O,F,E,p,Z,r]),q=mn(u,C,Z.length>0),te=!!(q&&j&&E&&(C.trim()||Z.length>0)),k=a.useCallback(Q=>{var pe;Q.nativeEvent.isComposing||Q.key==="Enter"&&(Q.ctrlKey||Q.metaKey)&&te&&!U&&(Q.preventDefault(),(pe=Q.currentTarget.form)==null||pe.requestSubmit())},[te,U]),G=Z.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3",children:Z.map((Q,pe)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:Ga(Q),alt:Q.filename??`attachment ${pe+1}`,className:"h-24 w-24 rounded-2xl border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>h(pe),className:"absolute -top-2 -right-2 flex h-6 w-6 items-center justify-center rounded-sm border border-border/70 bg-background text-muted-foreground shadow-sm transition-all hover:-translate-y-px hover:text-foreground","aria-label":`Remove ${Q.filename??`image ${pe+1}`}`,children:e.jsx(ns,{className:"h-3.5 w-3.5"})})]},`${Q.filename??"image"}-${pe}`))}),se=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Be,{className:"text-sm font-medium",children:"Assign to"}),e.jsxs(Ce,{value:E,onValueChange:X,children:[e.jsx(_e,{className:"h-11 rounded-lg border-border/70 bg-background/70",children:e.jsx(ze,{placeholder:"Select node"})}),e.jsx(De,{children:St(M,n)})]})]}),Re=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Be,{className:"text-sm font-medium",children:"Agent"}),e.jsxs(Ce,{value:j,onValueChange:c,children:[e.jsx(_e,{className:"h-11 rounded-lg border-border/70 bg-background/70",children:e.jsx(ze,{placeholder:"Select agent"})}),e.jsx(De,{children:la()})]})]}),ve=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Be,{className:"text-sm font-medium",children:"Mode"}),e.jsxs(Ce,{value:p,onValueChange:Q=>S(Q),children:[e.jsx(_e,{className:"h-11 rounded-lg border-border/70 bg-background/70",children:e.jsx(ze,{placeholder:"Select mode"})}),e.jsx(De,{children:da()})]})]}),fe=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Be,{className:"text-sm font-medium",children:"Priority"}),e.jsxs(Ce,{value:F,onValueChange:V,children:[e.jsx(_e,{className:"h-11 rounded-lg border-border/70 bg-background/70",children:e.jsx(ze,{placeholder:"Select priority"})}),e.jsxs(De,{children:[e.jsx(Ne,{value:"low",children:"Low"}),e.jsx(Ne,{value:"normal",children:"Normal"}),e.jsx(Ne,{value:"high",children:"High"}),e.jsx(Ne,{value:"critical",children:"Critical"})]})]})]}),Te=e.jsx(Us,{value:A,onChange:L,assignTo:E,nodes:s,assignableNodes:M}),He=e.jsx(pa,{value:O,onChange:T,project:A,assignTo:E,nodes:s,assignableNodes:M});return l==="composer"?e.jsxs("form",{onSubmit:R,className:$("space-y-4",g),children:[e.jsx("input",{ref:H,type:"file",accept:"image/*",multiple:!0,onChange:re,className:"hidden"}),(()=>{const Q="chat-composer__chip h-9 w-auto gap-1.5 rounded-sm px-3.5 text-xs shadow-none transition-colors",pe="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",we="border-border/70 bg-background/55 text-foreground",Je=j===ea,Pe=p===Ms;return e.jsxs("div",{className:"chat-composer space-y-2",children:[e.jsxs("div",{className:"rounded-xl border border-border/60 bg-background/54 shadow-[0_24px_86px_-48px_rgba(15,23,42,0.55)] backdrop-blur-xl dark:shadow-[0_24px_86px_-48px_rgba(0,0,0,0.9)]",children:[e.jsxs("div",{className:"chat-composer__header flex min-w-0 items-center justify-between gap-3 px-4 pt-3",children:[e.jsxs(Ce,{value:E,onValueChange:X,children:[e.jsx(_e,{className:$(Q,we,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${(z==null?void 0:z.name)??"unassigned"}`,"aria-label":`Assigned node: ${(z==null?void 0:z.name)??"unassigned"}`,children:z?e.jsxs(e.Fragment,{children:[e.jsx(It,{isCurrent:_}),e.jsx("span",{className:"min-w-0 truncate",children:z.name}),e.jsx("span",{className:"chat-composer__header-meta shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:_?"current":"remote"})]}):e.jsx(ze,{placeholder:"Select node"})}),e.jsx(De,{children:St(M,n)})]}),le?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Xe,{id:"task-title-composer",type:"text",value:u,onChange:be=>w(be.target.value),onKeyDown:be=>{(be.key==="Enter"||be.key==="Escape")&&(be.preventDefault(),ne(!1))},autoFocus:!0,placeholder:"Chat title",className:"h-8 w-48 min-w-0 rounded-sm border-border/70 bg-background/55 px-3 text-xs shadow-none"}),e.jsx(I,{type:"button",variant:"ghost",size:"icon",onClick:()=>ne(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(Ts,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>ne(!0),className:"chat-composer__title-button flex min-w-0 items-center gap-1.5 rounded-sm px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-background/55 hover:text-foreground",title:q||"Title","aria-label":q?`Edit title: ${q}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:q||"Title"}),e.jsx(ws,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",value:C,onChange:be=>x(be.target.value),onKeyDown:k,onPaste:ue,placeholder:"Ask anything...",rows:4,autoFocus:f,"aria-label":"Opening prompt",className:"min-h-[140px] w-full resize-none overflow-x-hidden overflow-y-auto rounded-xl bg-transparent px-5 pt-2 pb-2 text-[15px] leading-7 text-foreground ring-offset-background placeholder:text-muted-foreground/70 focus-visible:outline-none"}),e.jsxs("div",{className:"chat-composer__rail flex flex-nowrap items-center gap-2 px-3 pb-3",children:[e.jsx(I,{type:"button",variant:"ghost",size:"icon",onClick:K,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(wt,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsxs(Ce,{value:j,onValueChange:c,children:[e.jsxs(_e,{className:$(Q,"chat-composer__icon-trigger",Je?pe:we),title:`Agent: ${ee}`,"aria-label":`Agent: ${ee}`,children:[e.jsx(Bt,{agent:j}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:ee})]}),e.jsx(De,{children:la()})]}),e.jsxs(Ce,{value:p,onValueChange:be=>S(be),children:[e.jsxs(_e,{className:$(Q,"chat-composer__icon-trigger",Pe?pe:we),title:`Mode: ${m}`,"aria-label":`Mode: ${m}`,children:[e.jsx(mi,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:m})]}),e.jsx(De,{children:da()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[e.jsxs(Ce,{value:F,onValueChange:V,children:[e.jsx(_e,{"aria-label":`Priority: ${F}`,title:`Priority: ${F}`,className:$("h-9 w-9 justify-center gap-0 rounded-sm p-0 text-xs shadow-none [&>svg:last-child]:hidden",F==="normal"?"border-transparent bg-transparent text-muted-foreground hover:bg-background/40":"border-border/70 bg-background/55",F==="critical"&&"text-destructive",F==="high"&&"text-amber-600 dark:text-amber-400",F==="low"&&"text-muted-foreground"),children:e.jsx(Oo,{className:$("h-4 w-4",F==="critical"&&"fill-destructive/20")})}),e.jsxs(De,{children:[e.jsx(Ne,{value:"low",children:"Low"}),e.jsx(Ne,{value:"normal",children:"Normal"}),e.jsx(Ne,{value:"high",children:"High"}),e.jsx(Ne,{value:"critical",children:"Critical"})]})]}),i&&e.jsxs(I,{type:"button",variant:"ghost",size:"sm",onClick:i,"aria-label":v,className:"chat-composer__cancel h-9 rounded-sm px-4 text-xs text-muted-foreground",children:[e.jsx(ns,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:v})]}),e.jsxs(I,{type:"submit",size:"icon",disabled:!te||U,className:"h-10 w-10 rounded-sm shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[U?e.jsx(ce,{className:"h-4 w-4 animate-spin"}):e.jsx(sn,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:U?"Creating chat":N})]})]})]})]}),e.jsx("div",{className:"chat-composer__location flex flex-wrap items-center gap-2 px-1",children:(()=>{const be="border-border/40 bg-muted/40 text-foreground/80 hover:bg-muted/60 hover:text-foreground";return e.jsxs(e.Fragment,{children:[e.jsx(Us,{value:A,onChange:L,assignTo:E,nodes:s,assignableNodes:M,layout:"composer",chipClassName:Q,chipActiveClassName:be,chipInactiveClassName:be,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"}),e.jsx(pa,{value:O,onChange:T,project:A,assignTo:E,nodes:s,assignableNodes:M,layout:"composer",chipClassName:Q,chipActiveClassName:be,chipInactiveClassName:be,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"})]})})()})]})})(),(G||J)&&e.jsxs("div",{className:"space-y-3 rounded-lg border border-border/60 bg-background/45 p-4",children:[G,J&&e.jsx("div",{className:"text-xs text-destructive",children:J}),!J&&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:R,className:$("space-y-5",g),children:[e.jsx("input",{ref:H,type:"file",accept:"image/*",multiple:!0,onChange:re,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Be,{htmlFor:"task-description",className:"text-sm font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",value:C,onChange:Q=>x(Q.target.value),onKeyDown:k,onPaste:ue,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:f,className:"flex min-h-[144px] w-full resize-none overflow-x-hidden overflow-y-auto rounded-xl border border-border/70 bg-background/70 px-4 py-3 text-sm leading-6 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(I,{type:"button",variant:"outline",onClick:K,className:"rounded-sm",children:[e.jsx(wt,{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."})]}),G,J&&e.jsx("p",{className:"text-xs text-destructive",children:J})]}),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(Be,{htmlFor:"task-title",className:"text-sm font-medium",children:"Chat title"}),e.jsx(Xe,{id:"task-title",type:"text",value:u,onChange:Q=>w(Q.target.value),placeholder:"Optional. Leave blank to derive it from the prompt.",className:"h-11 rounded-lg border-border/70 bg-background/70"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:q?`Will appear as: ${q}`:"A title will be generated from the first line of the prompt."})]}),Re,ve]}),Te,He,e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[fe,se]}),e.jsxs("div",{className:$("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",b),children:[i&&e.jsx(I,{type:"button",variant:"ghost",onClick:i,className:"rounded-sm",children:v}),e.jsx(I,{type:"submit",disabled:!te||U,className:"rounded-sm px-5",children:U?"Creating...":N})]})]})}function sl({nodes:s,currentNodeRole:t,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,defaultMode:g="chat",mode:b,onModeChange:N,layout:v="default",className:f,footerClassName:l,autoFocus:u=!1}){const[w,C]=a.useState(g),x=b!==void 0,j=x?b:w,c=p=>{x||C(p),N==null||N(p)};return e.jsxs("div",{className:$("space-y-4",f),children:[!x&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border/60 bg-background/45 p-1",children:[e.jsxs(I,{type:"button",variant:j==="chat"?"default":"ghost",onClick:()=>c("chat"),className:"flex-1 rounded-sm",children:[e.jsx(mr,{className:"h-4 w-4"}),"New chat"]}),e.jsxs(I,{type:"button",variant:j==="native"?"default":"ghost",onClick:()=>c("native"),className:"flex-1 rounded-sm",children:[e.jsx($t,{className:"h-4 w-4"}),"Load session"]})]}),j==="chat"?e.jsx(el,{nodes:s,currentNodeRole:t,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,footerClassName:l,submitLabel:v==="composer"?"Start chat":"Create chat",cancelLabel:"Cancel",autoFocus:u,layout:v}):e.jsx(Ji,{nodes:s,currentNodeRole:t,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,footerClassName:l,autoFocus:u})]})}const vs="72f988bf-86f1-41af-91ab-2d7cd011db47",xn=`${vs} (MSIT)`;function tl({open:s,onOpenChange:t,onShare:n,onStopShare:o,sharing:r,stopping:i=!1,shareResult:g}){return e.jsx(Tt,{open:s,onOpenChange:t,children:e.jsxs(At,{className:"max-w-md rounded-xl p-5",children:[e.jsx(Mt,{className:"sr-only",children:"Share conversation"}),e.jsx(al,{onOpenChange:t,onShare:n,onStopShare:o,sharing:r,stopping:i,shareResult:g})]})})}function al({onOpenChange:s,onShare:t,onStopShare:n,sharing:o,stopping:r=!1,shareResult:i}){const[g,b]=a.useState((i==null?void 0:i.tenant)??vs),[N,v]=a.useState((i==null?void 0:i.scope)??"chat"),f=i!=null&&i.url?Ba(i.url):null,l=o||r;return a.useEffect(()=>{b((i==null?void 0:i.tenant)??vs),v((i==null?void 0:i.scope)??"chat")},[i==null?void 0:i.shareId,i==null?void 0:i.tenant,i==null?void 0:i.scope]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h2",{className:"text-base font-semibold leading-none tracking-tight",children:"Share conversation"}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Create a tenant-gated link for this task."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(nl,{value:g,onChange:b,disabled:l}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Access"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(ga,{active:N==="chat",title:"Chat only",description:"Conversation transcript and opening prompt.",onClick:()=>v("chat")}),e.jsx(ga,{active:N==="filesPreview",title:"Chat, files and preview",description:"Transcript plus task output files and HTML preview.",onClick:()=>v("filesPreview")})]})]}),f&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Shared link"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-border/70 bg-muted/30 px-3 py-2",children:[e.jsx("input",{readOnly:!0,value:f,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none","aria-label":"Shared link"}),e.jsx(I,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-sm text-muted-foreground",onClick:()=>void bs(f,"Shared link copied"),"aria-label":"Copy shared link",title:"Copy shared link",children:e.jsx(Ra,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(I,{variant:"outline",onClick:()=>s(!1),disabled:l,className:"h-8 text-xs",children:i?"Done":"Cancel"}),i&&n&&e.jsxs(I,{variant:"outline",onClick:()=>void n(),disabled:l,className:"h-8 border-destructive/30 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive",children:[r&&e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),"Stop share"]}),e.jsxs(I,{onClick:()=>void t({tenant:g,scope:N}),disabled:l,className:"h-8 text-xs",children:[o&&e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),i?"Update link":"Share link"]})]})]})}function nl({value:s,onChange:t,disabled:n}){const[o,r]=a.useState(!1),[i,g]=a.useState(!1),[b,N]=a.useState(s),v=a.useRef(null);a.useEffect(()=>{N(s)},[s]),a.useEffect(()=>{if(!o)return;const l=w=>{var x;const C=w.target;C instanceof Node&&((x=v.current)!=null&&x.contains(C)||(r(!1),g(!1)))},u=w=>{w.key==="Escape"&&(r(!1),g(!1))};return document.addEventListener("mousedown",l),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",u)}},[o]);const f=l=>{const u=l.trim();u&&(t(u),N(u),g(!1),r(!1))};return e.jsxs("div",{className:"space-y-2 text-xs",ref:v,children:[e.jsx("div",{className:"font-medium text-foreground",children:"Tenant"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>!n&&r(l=>!l),disabled:n,className:"flex h-9 w-full items-center justify-between gap-2 rounded-sm border border-border/70 bg-background/70 px-3 text-left text-xs text-foreground shadow-sm outline-none transition-colors hover:bg-background disabled:opacity-50",children:[e.jsx("span",{className:"min-w-0 truncate font-mono",children:rl(s)}),e.jsx(rs,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),o&&e.jsxs("div",{className:"absolute left-0 right-0 z-50 mt-2 overflow-hidden rounded-lg border border-border/60 bg-background/95 text-xs shadow-lg backdrop-blur",children:[e.jsxs("button",{type:"button",onClick:()=>f(vs),className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left hover:bg-background/60",children:[e.jsx("span",{className:"min-w-0 truncate font-mono text-[11px]",children:xn}),s===vs&&e.jsx(Ts,{className:"h-3.5 w-3.5 shrink-0 text-primary"})]}),e.jsx("div",{className:"border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:i?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{value:b,onChange:l=>N(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),f(b))},autoFocus:!0,placeholder:"Tenant ID",className:"h-7 min-w-0 flex-1 rounded-sm border border-border/60 bg-background/70 px-2 font-mono text-[11px] outline-none focus:ring-2 focus:ring-ring"}),e.jsx("button",{type:"button",onClick:()=>f(b),className:"flex h-7 w-7 items-center justify-center rounded-sm hover:bg-background/60",children:e.jsx(Ts,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{N(s),g(!1)},className:"flex h-7 w-7 items-center justify-center rounded-sm text-muted-foreground hover:bg-background/60 hover:text-foreground",children:e.jsx(ns,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>g(!0),className:"flex h-7 w-full items-center justify-between rounded-sm px-1.5 text-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:[e.jsx("span",{children:"Manual tenant ID"}),e.jsx(ws,{className:"h-3 w-3"})]})})]})]})]})}function rl(s){return s===vs?xn:s}function ga({active:s,title:t,description:n,onClick:o}){return e.jsxs("button",{type:"button",onClick:o,className:s?"rounded-sm border border-primary/45 bg-primary/10 px-3 py-2 text-left shadow-sm":"rounded-sm border border-border/70 bg-background px-3 py-2 text-left shadow-sm hover:bg-muted/50",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:t}),e.jsx("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:n})]})}function ol(s){const t=s.map(n=>n.type==="text"?n.text:n.type==="image"?n.filename?`Image: ${n.filename}`:"Image attachment":n.isError?`Tool result error: ${n.content}`:`Tool result: ${n.content}`).join(" ").replace(/\s+/g," ").trim();return t?t.length>160?`${t.slice(0,157)}...`:t:"Queued follow-up"}function il({messages:s,onCancelMessage:t}){return s.length===0?null:e.jsx("div",{className:"border-t border-border/55 bg-card/30 px-3 py-2 sm:px-5",children:e.jsxs("div",{className:"mx-auto max-w-[72rem] rounded-sm border border-border/65 bg-background/58 px-3 py-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium text-foreground",children:[e.jsx(Xo,{className:"h-3.5 w-3.5 text-primary"}),"Queued messages",e.jsx("span",{className:"ml-auto rounded-sm border border-border/60 bg-muted/60 px-1.5 py-0 text-[10px] text-muted-foreground",children:s.length})]}),e.jsx("div",{className:"mt-2 space-y-1.5",children:s.map((n,o)=>e.jsxs("div",{className:"flex min-w-0 items-start gap-2 text-[11px] leading-5 text-muted-foreground",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-sm bg-primary/10 text-[10px] font-medium text-primary",children:o+1}),e.jsx("span",{className:"min-w-0 flex-1 break-words [overflow-wrap:anywhere]",children:ol(n.content)}),t&&e.jsx(I,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0 rounded-sm text-muted-foreground hover:text-destructive",title:"Cancel queued message","aria-label":"Cancel queued message",onClick:()=>t(n.id),children:e.jsx(ns,{className:"h-3 w-3"})})]},n.id))})]})})}const ll=30;function dl({savedScrollTop:s,scrollHeight:t,clientHeight:n}){const o=Math.max(0,t-n);return Math.min(Math.max(0,s??o),o)}function tt(s){return s.scrollHeight-s.scrollTop-s.clientHeight<ll}function cl({activeTab:s,activeTaskId:t,contentVersion:n,setActiveTab:o,setInputCollapsed:r}){const i=a.useRef(null),g=a.useRef(t),b=a.useRef(!1),N=a.useRef(0),v=a.useRef(new Map),f=a.useRef(!0),l=a.useCallback((x=g.current)=>{const j=i.current;!j||!x||(v.current.set(x,j.scrollTop),N.current=j.scrollTop,f.current=tt(j))},[]),u=a.useCallback((x=g.current)=>{const j=i.current;!j||!x||(j.scrollTop=dl({savedScrollTop:v.current.get(x),scrollHeight:j.scrollHeight,clientHeight:j.clientHeight}),N.current=j.scrollTop,f.current=tt(j))},[]),w=a.useCallback(x=>{const j=x.currentTarget,c=N.current;if(l(),!b.current){if(tt(j)){r(!1),b.current=!0,setTimeout(()=>{b.current=!1},300);return}j.scrollTop<c&&c-j.scrollTop>10&&r(!0),j.scrollTop<=0&&r(!0)}},[l,r]),C=a.useCallback(x=>{s==="transcript"&&l(),o(x),x==="transcript"&&requestAnimationFrame(()=>u())},[s,u,l,o]);return a.useLayoutEffect(()=>{const x=g.current;x&&x!==t&&l(x),g.current=t,s==="transcript"&&requestAnimationFrame(()=>u(t))},[t,s,u,l]),a.useLayoutEffect(()=>{const x=i.current;!x||s!=="transcript"||!t||(f.current&&(x.scrollTop=x.scrollHeight),l(t))},[t,s,n,l]),{handleTranscriptScroll:w,handleTranscriptTabChange:C,transcriptScrollRef:i}}function hn(s=700){const[t,n]=a.useState(!1),o=a.useRef(null),r=a.useCallback(()=>{n(!0),o.current!==null&&clearTimeout(o.current),o.current=setTimeout(()=>{n(!1),o.current=null},s)},[s]);return a.useEffect(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]),{markScrollbarActive:r,scrollbarActive:t}}const ul=a.lazy(async()=>({default:(await Lt(()=>import("./FilesTab-BdrrZSEY.js"),__vite__mapDeps([0,1,2,3,4]))).FilesTab})),ml=a.lazy(async()=>({default:(await Lt(()=>import("./PreviewTab-DS5OePrB.js"),__vite__mapDeps([5,1,2,6]))).PreviewTab})),xl=a.lazy(async()=>({default:(await Lt(()=>import("./DiffTab-dDJwxCuZ.js"),__vite__mapDeps([7,1,2,3,4,6]))).DiffTab}));function hl({onToggleTasks:s,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:g,activeTab:b,setActiveTab:N,creatingTask:v,createMode:f,activeTask:l,assignedNode:u,taskLoading:w,transcriptLoading:C,taskError:x,displayEvents:j,initialPromptAlreadyInLogs:c,initialPrompt:p,supportsFollowUp:S,taskUnavailable:A,chatDisabled:L,chatDisabledReason:O,questionBypassEnabled:T,isRunning:F,isStarting:V,hasPendingFollowUp:M,canCancel:P,canRetry:E,onRetry:X,onCancel:U,onReloadNativeTranscript:Y,onShareTask:le,onStopShareTask:ne,onStartCreateTask:Z,onCancelCreateTask:J,onCreateTask:H,onSendMessage:K,onCancelQueuedMessage:re,onQuestionBypassChange:ue,onSubmitQuestionResponse:h}){const[z,_]=a.useState(!1),[ee,m]=a.useState(!1),[R,q]=a.useState(!1),[te,k]=a.useState(!1),[G,se]=a.useState(!1),[Re,ve]=a.useState({}),[fe,Te]=a.useState(new Set),[He,Q]=a.useState(new Set),pe=(l==null?void 0:l.effectiveProjectPath)??(l==null?void 0:l.project)??"default workspace",we=l?(u==null?void 0:u.name)??it(l.assignedTo,i==null?void 0:i.nodes,l.assignedNodeName):"unassigned",Je=l!=null&&l.assignedTo?e.jsxs(e.Fragment,{children:["Connecting session on node ",e.jsx("span",{className:"font-semibold",children:we}),"..."]}):"Connecting session to an available node...",Pe=l?[{label:"Working dir",value:pe,mono:!0},...l.branch?[{label:"Branch",value:l.branch,mono:!0}]:[],{label:"Agent",value:l.agent,mono:!0},{label:"Node",value:we}]:[],be=!!(p&&!c),Ye=be||j.length>0,ye=F&&Ye,Ee=(V||M||F)&&!ye,Ze=(l==null?void 0:l.conversationKind)==="nativeSession",ms=C?"Loading transcript":Ze?"No transcript imported":"Transcript is warming up",ts=C?"Loading transcript...":Ze?"Meshy could not find imported history for this native session yet.":"The opening prompt has been stored, but the agent has not emitted conversation output yet.",os=(l==null?void 0:l.queuedMessages)??[],is=a.useMemo(()=>wo(j),[j]),xs=a.useMemo(()=>yo("transcript",is.map(Me=>Me.event)),[is]),$e=l&&!fe.has(l.id)?Re[l.id]??l.activeShare??null:null,ls=(l==null?void 0:l.id)??null,Ae=`${ls??"none"}:${j.length}:${os.length}:${be?1:0}:${C?1:0}`,{handleTranscriptScroll:hs,handleTranscriptTabChange:D,transcriptScrollRef:xe}=cl({activeTab:b,activeTaskId:ls,contentVersion:Ae,setActiveTab:N,setInputCollapsed:_}),{markScrollbarActive:de,scrollbarActive:Ie}=hn(),We=a.useCallback(Me=>{de(),hs(Me)},[hs,de]);return v?e.jsx(fl,{onToggleTasks:s,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:g,defaultMode:f,onCancel:J,onCreated:H}):!l&&w?e.jsxs("div",{className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Ct,{onToggleTasks:s,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:g})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-xl border border-primary/20 bg-primary/10 text-primary shadow-sm",children:e.jsx(ce,{className:"h-7 w-7 animate-spin"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"Loading conversation"}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx(ce,{className:"h-4 w-4 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):l?e.jsxs($a,{value:b,onValueChange:D,className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(fn,{desktopTasksOpen:t,mobileTasksPanelOpen:n,onToggleTasks:s}),e.jsx("h2",{className:"min-w-0 truncate text-sm font-semibold tracking-tight text-foreground sm:text-lg",title:l.title,children:l.title}),e.jsx(Oa,{status:l.status,isNative:Ze}),l.priority!=="normal"&&e.jsx(fr,{priority:l.priority}),e.jsx(I,{variant:"outline",size:"icon",onClick:r,title:o?"Hide cluster":"Show cluster","aria-label":o?"Hide cluster":"Show cluster",className:"ml-auto h-7 w-7 shrink-0 rounded-sm border-border/70 bg-background/68",children:o?e.jsx(Ft,{className:"h-4 w-4"}):e.jsx(en,{className:"h-4 w-4"})})]}),x&&e.jsx("div",{className:"mt-2 w-fit rounded-sm border border-destructive/25 bg-destructive/10 px-2 py-1 text-[11px] text-destructive",children:x}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsxs(Fa,{className:"h-auto max-w-full overflow-x-auto rounded-sm bg-muted/70 p-0.5",children:[e.jsx(ds,{value:"transcript",className:"rounded-sm px-2 py-0.5 text-[11px] sm:px-2.5",children:"Transcript"}),e.jsx(ds,{value:"files",className:"rounded-sm px-2 py-0.5 text-[11px] sm:px-2.5",children:"Files"}),e.jsx(ds,{value:"preview",className:"rounded-sm px-2 py-0.5 text-[11px] sm:px-2.5",children:"Preview"}),e.jsx(ds,{value:"diff",className:"rounded-sm px-2 py-0.5 text-[11px] sm:px-2.5",children:"Diff"})]}),A&&e.jsx(Ke,{variant:"outline",className:"hidden rounded-sm border-destructive/25 bg-destructive/10 text-destructive sm:inline-flex",children:"Unavailable"}),e.jsxs("div",{className:"ml-auto flex items-center gap-1 text-[10px] text-muted-foreground",children:[e.jsxs("span",{className:"hidden sm:inline",children:["updated ",pr(l.updatedAt)]}),e.jsx("span",{className:"font-mono",children:l.id.slice(0,8)}),E&&e.jsxs(I,{variant:"outline",size:"sm",onClick:X,className:"h-7 shrink-0 rounded-sm px-2 text-[11px]",children:[e.jsx(ma,{className:"h-3.5 w-3.5"}),"Retry"]}),Ze&&Y&&e.jsx(I,{variant:"ghost",size:"icon",onClick:Y,disabled:C,title:"Reload native session transcript","aria-label":"Reload native session transcript",className:"h-6 w-6 shrink-0 rounded-sm text-muted-foreground hover:bg-muted/55 hover:text-foreground",children:e.jsx(ma,{className:$("h-3.5 w-3.5",C&&"animate-spin")})}),e.jsx(I,{type:"button",variant:"ghost",size:"icon",disabled:A,title:A?"Unavailable tasks cannot be shared.":"Share conversation","aria-label":A?"Unavailable tasks cannot be shared.":"Share conversation",className:"h-6 w-6 shrink-0 rounded-sm text-primary hover:bg-primary/10 hover:text-primary disabled:bg-transparent disabled:text-muted-foreground",onClick:()=>q(!0),children:e.jsx(ci,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsx(cs,{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",{ref:xe,className:$("scrollbar-line min-h-0 flex-1 touch-pan-y overflow-x-hidden overflow-y-auto overscroll-x-none bg-gradient-to-b from-background/15 via-transparent to-background/35 px-3 py-5 sm:px-5",Ie&&"scrollbar-line-active"),onScroll:We,children:e.jsxs("div",{className:"mx-auto flex max-w-[72rem] flex-col gap-5",children:[be&&p&&e.jsx(ca,{event:p,agent:l.agent,questionBypassEnabled:T,onQuestionBypassChange:ue,onSubmitQuestionResponse:h,questionResponseDisabled:!S||L}),is.map(({event:Me,subItems:ge},je)=>e.jsx(ca,{event:Me,agent:l.agent,subItems:ge,questionBypassEnabled:T,onQuestionBypassChange:ue,onSubmitQuestionResponse:h,questionResponseDisabled:!S||L},xs[je])),!Ye&&!Ee&&e.jsxs("div",{className:"rounded-xl border border-dashed border-border/70 bg-background/35 px-5 py-8 text-center",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:ms}),e.jsx("div",{className:"mt-2 text-[11px] leading-6 text-muted-foreground",children:ts})]}),(!S&&l.result||l.error)&&e.jsxs("div",{className:"space-y-3",children:[!S&&l.result&&e.jsxs("div",{className:"rounded-xl border border-border/70 bg-card/80 px-3 py-3",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Stored result"}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5 text-muted-foreground",children:JSON.stringify(l.result,null,2)})]}),l.error&&!He.has(l.id)&&e.jsxs("div",{className:"rounded-xl border border-destructive/20 bg-destructive/10 px-3 py-3 text-destructive",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em]",children:"Stored error"}),e.jsx("button",{onClick:()=>Q(Me=>new Set(Me).add(l.id)),className:"rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(ns,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5",children:l.error})]})]}),Ee&&e.jsx(ba,{children:Je}),ye&&e.jsx(ba,{children:"The agent is still working on this conversation."})]})}),S?e.jsxs(e.Fragment,{children:[z&&e.jsx(I,{size:"icon",onClick:()=>_(!1),className:"absolute bottom-4 right-4 z-10 h-12 w-12 rounded-lg shadow-lg",children:e.jsx(ws,{className:"h-4 w-4"})}),e.jsxs("div",{className:`shrink-0 ${z?"hidden":""}`,children:[e.jsx(il,{messages:os,onCancelMessage:re}),e.jsx(Ei,{onSend:K,disabled:L,disabledReason:O,contextItems:Pe,placeholder:L?O:F?"Queue a message for the next turn...":"Continue the conversation...",running:F||M,onStop:P?()=>m(!0):void 0})]})]}):e.jsx("div",{className:"shrink-0 border-t border-border/60 px-3 py-3 text-[11px] text-muted-foreground sm:px-5",children:"This task does not expose follow-up chat messages. Use Files, Preview, or Diff to inspect the result."})]})}),e.jsx(cs,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:e.jsx(et,{label:"Loading files..."}),children:e.jsx(ul,{taskId:l.id})})}),e.jsx(cs,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:e.jsx(et,{label:"Loading preview..."}),children:e.jsx(ml,{taskId:l.id})})}),e.jsx(cs,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:e.jsx(et,{label:"Loading diff..."}),children:e.jsx(xl,{taskId:l.id})})}),e.jsx(lt,{open:ee,onOpenChange:m,children:e.jsxs(dt,{children:[e.jsxs(ct,{children:[e.jsx(ut,{children:"Stop this task?"}),e.jsx(mt,{children:"The task will stop and move to a cancelled state."})]}),e.jsxs(xt,{children:[e.jsx(ht,{children:"Keep running"}),e.jsx(ft,{onClick:U,children:"Stop task"})]})]})}),e.jsx(tl,{open:R,onOpenChange:q,sharing:te,stopping:G,shareResult:$e,onShare:async Me=>{if(!l)return null;k(!0);try{const ge=await le(Me);return ge!=null&&ge.url&&(ve(je=>({...je,[l.id]:ge})),Te(je=>{const es=new Set(je);return es.delete(l.id),es})),ge}finally{k(!1)}},onStopShare:async()=>{if(!l)return!1;se(!0);try{const Me=await ne();return Me!==!1&&(ve(ge=>{const je={...ge};return delete je[l.id],je}),Te(ge=>new Set(ge).add(l.id))),Me}finally{se(!1)}}})]}):e.jsxs("div",{className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Ct,{onToggleTasks:s,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:g})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsxs("div",{className:"w-full max-w-2xl text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-xl border border-primary/20 bg-primary/10 text-primary shadow-sm",children:e.jsx(hr,{className:"h-7 w-7"})}),e.jsx("h2",{className:"mt-5 text-xl font-semibold tracking-tight text-foreground sm:text-3xl",children:"No chat selected"}),e.jsx("p",{className:"mx-auto mt-3 max-w-xl text-[11px] leading-6 text-muted-foreground",children:"Open a task from the left sidebar to continue the conversation, or start a new task or load a native session."}),e.jsxs(I,{onClick:Z,className:"mt-6 rounded-lg px-5",children:[e.jsx(Ot,{className:"h-4 w-4"}),"Start or load chat"]}),x&&e.jsx("div",{className:"mx-auto mt-4 max-w-lg rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:x})]})})]})}function ba({children:s}){return e.jsxs("div",{className:"agent-progress-banner flex items-center gap-1.5 rounded-lg bg-transparent px-1 py-1 text-[11px]",children:[e.jsx("span",{className:"agent-progress-terminal-spinner h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsx("div",{className:"agent-progress-sweep-text min-w-0 leading-5",children:s})]})}function fl({onToggleTasks:s,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:g,defaultMode:b,onCancel:N,onCreated:v}){var w,C,x;const[f,l]=a.useState(b??"chat");a.useEffect(()=>{b&&l(b)},[b]);const u=e.jsx("div",{className:"flex items-center gap-1 rounded-lg border border-border/60 bg-background/65 p-0.5 text-[11px] font-medium shadow-sm",children:[{value:"chat",label:"New chat",icon:Ot},{value:"native",label:"Load session",icon:$t}].map(j=>{const c=j.icon,p=j.value===f;return e.jsxs("button",{type:"button",onClick:()=>l(j.value),"aria-pressed":p,className:$("flex items-center gap-1.5 rounded-sm px-2 py-1 transition-all duration-200",p?"bg-primary text-primary-foreground shadow-[0_8px_24px_-12px_hsl(var(--primary)/0.7)]":"text-muted-foreground hover:bg-background/80 hover:text-foreground"),children:[e.jsx(c,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:j.label})]},j.value)})});return e.jsxs("div",{className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Ct,{onToggleTasks:s,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:g,centerSlot:u})}),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(sl,{nodes:(i==null?void 0:i.nodes)??[],currentNodeRole:(w=i==null?void 0:i.self)==null?void 0:w.role,currentNodeId:((C=i==null?void 0:i.self)==null?void 0:C.id)??null,leaderNodeId:((x=i==null?void 0:i.leader)==null?void 0:x.id)??null,mode:f,onModeChange:l,onCreated:v,onCancel:N,autoFocus:!0,layout:"composer"})})})]})}function Ct({onToggleTasks:s,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,centerSlot:i}){return e.jsxs("div",{className:"relative flex w-full items-center justify-between gap-1.5",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-1.5",children:e.jsx(fn,{desktopTasksOpen:t,mobileTasksPanelOpen:n,onToggleTasks:s})}),i&&e.jsx("div",{className:"pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:e.jsx("div",{className:"pointer-events-auto",children:i})}),e.jsx(I,{variant:"outline",size:"icon",onClick:r,title:o?"Hide cluster":"Show cluster","aria-label":o?"Hide cluster":"Show cluster",className:"h-7 w-7 shrink-0 rounded-sm border-border/70 bg-background/68",children:o?e.jsx(Ft,{className:"h-4 w-4"}):e.jsx(en,{className:"h-4 w-4"})})]})}function fn({desktopTasksOpen:s,mobileTasksPanelOpen:t,onToggleTasks:n}){var r,i;const o=(i=(r=globalThis.window)==null?void 0:r.matchMedia("(min-width: 1024px)"))!=null&&i.matches?s:t;return e.jsx(I,{variant:"outline",size:"icon",onClick:n,title:o?"Hide tasks":"Show tasks","aria-label":o?"Hide tasks":"Show tasks",className:"h-7 w-7 shrink-0 rounded-sm border-border/70 bg-background/68",children:o?e.jsx(Za,{className:"h-4 w-4"}):e.jsx(si,{className:"h-4 w-4"})})}function pl({onAdded:s}){const[t,n]=a.useState(""),[o,r]=a.useState(!1),[i,g]=a.useState(null),b=a.useCallback(async N=>{if(N.preventDefault(),!!t.trim()){r(!0),g(null);try{await gr({leaderEndpoint:t.trim(),transport:"devtunnel"}),s()}catch(v){g(v instanceof Error?v.message:"Failed to join node")}finally{r(!1)}}},[t,s]);return e.jsx(At,{className:"overflow-hidden border-border/60 bg-transparent p-0 shadow-none sm:max-w-xl",children:e.jsxs("div",{className:"overflow-hidden rounded-xl border border-border/60 bg-background/95 p-0 shadow-[0_40px_120px_-60px_rgba(0,0,0,0.88)] backdrop-blur-xl",children:[e.jsx("div",{className:"border-b border-border/60 px-6 py-5",children:e.jsxs(za,{className:"space-y-2 text-left",children:[e.jsx(Mt,{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:b,className:"space-y-4 px-6 py-5",children:[i&&e.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(Be,{htmlFor:"leader-endpoint",children:"Leader endpoint"}),e.jsx(Ke,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),e.jsx(Xe,{id:"leader-endpoint",type:"url",value:t,onChange:N=>n(N.target.value),placeholder:"https://your-leader.devtunnels.ms",className:"h-11 rounded-lg border-border/70 bg-background/70"})]}),e.jsx("div",{className:"rounded-lg border border-border/60 bg-background/45 px-4 py-3 text-sm text-muted-foreground",children:"This does not switch the local node transport or auto-enable a local DevTunnel. Leaving later will detach this node from the remote leader and make it leader of its own cluster again."}),e.jsx(Ia,{className:"border-t border-border/60 pt-4",children:e.jsx(I,{type:"submit",disabled:!t.trim()||o,className:"rounded-sm",children:o?"Joining...":"Join node"})})]})]})})}function gl({open:s,onOpenChange:t,onAdded:n}){return e.jsx(Tt,{open:s,onOpenChange:t,children:e.jsx(pl,{onAdded:()=>{t(!1),n()}})})}function at({className:s,label:t,orientation:n,panel:o,panelResize:r}){return e.jsx("button",{type:"button","aria-label":t,"aria-orientation":n,"data-dashboard-resize-handle":o,onPointerDown:i=>r.onPointerDown(o,i),onWheel:i=>r.onWheel(o,i),className:$("group absolute z-20 hidden touch-none rounded-sm bg-transparent outline-none transition-colors hover:bg-primary/12 focus-visible:bg-primary/12 focus-visible:ring-2 focus-visible:ring-ring/70 lg:block",s),children:e.jsx("span",{className:"pointer-events-none absolute inset-0 opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100"})})}function bl({conversationPanel:s,desktopTasksOpen:t,mobileTaskSidebar:n,mobileTasksPanelOpen:o,mobileTasksPanelRef:r,operationsOpen:i,operationsPanelRef:g,operationsSidecar:b,panelResize:N,taskSidebar:v,terminalPanel:f,onCloseOperations:l,onCloseTaskList:u}){const w={"--dashboard-tasks-width":N.sizes.tasks,"--dashboard-operations-width":N.sizes.operations,"--dashboard-terminal-height":N.sizes.terminal};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",style:w,children:[e.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[e.jsx("div",{className:$("relative hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",t?"lg:mr-2 lg:w-[var(--dashboard-tasks-width)]":"lg:w-0 lg:overflow-hidden"),children:t&&e.jsxs(e.Fragment,{children:[v,e.jsx(at,{panel:"tasks",orientation:"vertical",label:"Resize tasks panel",panelResize:N,className:"-right-1 top-0 h-full w-2 cursor-col-resize"})]})}),e.jsxs("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[e.jsx("div",{className:"min-h-0 flex-1",children:s}),f&&e.jsxs("div",{className:"relative h-[var(--dashboard-terminal-height)] min-h-0 shrink-0",children:[e.jsx(at,{panel:"terminal",orientation:"horizontal",label:"Resize terminal panel",panelResize:N,className:"-top-1 left-0 h-2 w-full cursor-row-resize"}),f]})]}),e.jsx("div",{className:$("relative hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",i?"xl:ml-2 xl:w-[var(--dashboard-operations-width)]":"xl:w-0 xl:overflow-hidden"),children:i&&e.jsxs(e.Fragment,{children:[e.jsx(at,{panel:"operations",orientation:"vertical",label:"Resize operations panel",panelResize:N,className:"-left-1 top-0 h-full w-2 cursor-col-resize"}),b]})})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:l,className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),e.jsx("div",{ref:g,className:"fixed inset-y-0 right-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 xl:hidden",children:b})]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close task list",onClick:u,className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),e.jsx("div",{ref:r,className:"fixed inset-y-0 left-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 lg:hidden",children:n})]})]})}const vl=10,us="__all__";function qe(s){return"session"in s}function va(s,t){var n;return t&&s.some(o=>o.id===t)?t:((n=s[0])==null?void 0:n.id)??""}function nt(s){return s&&(cn(s.id)||s.workDir)||""}function Os(s,t,n){let o=!1;const r=s.map(i=>qe(i)&&i.session.id===n.id?(o=!0,{...i,nodeName:t,session:n}):i);return _t(o?r:[...r,{id:`session-${n.id}`,nodeName:t,session:n}])}function pn(s,t){return s.filter(qe).filter(n=>n.session.nodeId===t).sort((n,o)=>o.session.startedAt-n.session.startedAt)}function jl(s){const t=s.filter(qe).sort((n,o)=>o.session.startedAt-n.session.startedAt);return{active:t.filter(n=>n.session.status==="running"),completed:t.filter(n=>n.session.status!=="running")}}function Nl(s,t){return!!(s&&t&&!s.contains(t))}function wl(s,t,n){var r;if(n===us)return n;const o=pn(s,t);return o.some(i=>i.session.id===n)?n:((r=o[0])==null?void 0:r.session.id)??us}function yl(s,t,n){return n===us?s.filter(o=>!qe(o)||o.session.nodeId===t):s.filter(o=>qe(o)&&o.session.nodeId===t&&o.session.id===n)}function _t(s){const t=s.map((o,r)=>({entry:o,index:r})).filter(({entry:o})=>qe(o)&&o.session.status!=="running").sort((o,r)=>!qe(o.entry)||!qe(r.entry)?0:r.entry.session.startedAt-o.entry.session.startedAt||r.index-o.index),n=new Set(t.slice(0,vl).map(({entry:o})=>qe(o)?o.session.id:""));return s.filter(o=>!qe(o)||o.session.status==="running"||n.has(o.session.id))}function Dt(s){return s.status==="running"?s.pid?`running pid ${s.pid}`:"running":s.status==="exited"?`exit ${s.exitCode??0}`:s.status==="stopped"?"stopped":s.signal?`failed ${s.signal}`:`exit ${s.exitCode??"failed"}`}function kl(s){const t=s.session.command.length>48?`${s.session.command.slice(0,45)}...`:s.session.command;return`${s.nodeName} - ${Dt(s.session)} - ${t}`}function gn(s,t=48){return s.length>t?`${s.slice(0,t-3)}...`:s}function Sl(s,t){return t===us?"All sessions":s?gn(s.session.command,34):"Command session"}function ja(s){return s.status==="stopped"?"":s.stderr}function Cl({nodes:s,defaultNodeId:t,onClose:n,initialHistory:o=[]}){const[r,i]=a.useState(()=>va(s,t)),g=a.useMemo(()=>s.find(h=>h.id===r)??s[0]??null,[s,r]),[b,N]=a.useState(()=>nt(g)),[v,f]=a.useState(""),[l,u]=a.useState(()=>_t(o)),[w,C]=a.useState(us),[x,j]=a.useState(!1),[c,p]=a.useState(!1),[S,A]=a.useState(!1),[L,O]=a.useState(!1),[T,F]=a.useState(!1),V=a.useRef(null),M=a.useRef(null),P=a.useMemo(()=>s.find(h=>h.id===r)??s[0]??null,[s,r]),E=a.useMemo(()=>pn(l,(P==null?void 0:P.id)??""),[l,P]),X=a.useMemo(()=>jl(E),[E]),U=a.useMemo(()=>E.find(h=>h.session.id===w),[w,E]),Y=a.useMemo(()=>yl(l,(P==null?void 0:P.id)??"",w),[l,P,w]),le=a.useRef((P==null?void 0:P.id)??"");a.useEffect(()=>{r&&s.some(h=>h.id===r)||i(va(s,t))},[t,s,r]),a.useEffect(()=>{const h=(P==null?void 0:P.id)??"";le.current!==h&&(le.current=h,N(nt(P)))},[P]),a.useEffect(()=>{C(h=>wl(l,(P==null?void 0:P.id)??"",x?h:""))},[l,P,x]),a.useEffect(()=>{var h;(h=V.current)==null||h.scrollTo({top:V.current.scrollHeight})},[l]),a.useEffect(()=>{let h=!1;async function z(){const _=await Promise.allSettled(s.map(async ee=>({node:ee,response:await vr(ee.id)})));h||u(ee=>_.reduce((m,R)=>R.status!=="fulfilled"?m:R.value.response.sessions.reduce((q,te)=>Os(q,R.value.node.name,te),m),ee))}return s.length>0&&z(),()=>{h=!0}},[s]),a.useEffect(()=>{const h=l.filter(qe).filter(_=>_.session.status==="running");if(h.length===0)return;const z=window.setInterval(()=>{for(const _ of h)br(_.session.nodeId,_.session.id).then(ee=>u(m=>Os(m,_.nodeName,ee))).catch(()=>{})},1e3);return()=>window.clearInterval(z)},[l]);const ne=a.useRef(null);async function Z(h){if(h.preventDefault(),!P||!v.trim()||T)return;const z=v.trim(),_=P.name;F(!0),f("");try{const ee=await Nr(P.id,{command:z,...b.trim()?{cwd:b.trim()}:{}});u(m=>Os(m,_,ee)),C(ee.id),j(!0)}catch(ee){u(m=>[...m,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,nodeName:_,command:z,error:ee instanceof Error?ee.message:"Command failed"}])}finally{F(!1)}}async function J(h,z){h.stopPropagation();const _=await jr(z.session.nodeId,z.session.id);u(ee=>Os(ee,z.nodeName,_))}function H(h){C(h),j(!0),p(!1)}function K(h){c&&Nl(M.current,h.target)&&p(!1)}function re(h,z,_,ee,m){return e.jsxs("div",{className:"border-t border-border/60 py-1",children:[e.jsxs("button",{type:"button",onClick:ee,"aria-label":`Toggle ${h} sessions`,"aria-expanded":!_,className:"node-terminal__small flex w-full items-center justify-between gap-2 px-2 pb-1 pt-0.5 text-left font-medium uppercase tracking-normal text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{children:h}),e.jsx(rs,{className:$("h-3 w-3 transition-transform",_&&"-rotate-90")})]}),!_&&(z.length>0?z.map(ue):e.jsx("div",{className:"node-terminal__control px-2 py-1 text-muted-foreground",children:m}))]})}function ue(h){const z=w===h.session.id,_=h.session.status==="running";return e.jsxs("div",{className:$("node-terminal__control group flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/65",z&&"bg-primary/10 text-primary"),children:[e.jsxs("button",{type:"button",onClick:()=>H(h.session.id),className:"flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{className:$("flex h-4 w-4 shrink-0 items-center justify-center",_?"text-primary":h.session.status==="exited"?"text-emerald-600 dark:text-emerald-300":"text-amber-600 dark:text-amber-300"),children:_?e.jsx(ce,{className:"h-3 w-3 animate-spin"}):h.session.status==="exited"?e.jsx(sa,{className:"h-3 w-3"}):e.jsx(Is,{className:"h-3 w-3"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-foreground",children:gn(h.session.command,44)}),e.jsxs("span",{className:"node-terminal__small block truncate text-muted-foreground",children:[h.nodeName," · ",Dt(h.session)]})]})]}),_&&e.jsx("button",{type:"button",onClick:ee=>void J(ee,h),"aria-label":"Stop terminal session from selector",title:"Stop terminal session",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(xa,{className:"h-3 w-3"})})]},h.session.id)}return e.jsx("section",{className:"dashboard-panel node-terminal animate-composer-settle flex h-full min-h-0 shrink-0 overflow-visible rounded-xl","aria-label":"Node terminal",onClick:K,children:e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col overflow-visible rounded-[inherit] bg-card/72 text-card-foreground",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsxs("div",{className:"node-terminal__header flex min-w-0 items-center gap-2 font-medium",children:[n?e.jsx("button",{type:"button",onClick:n,"aria-label":"Close terminal",title:"Close terminal",className:"flex h-6 w-6 items-center justify-center rounded-md text-primary transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(Js,{className:"h-3.5 w-3.5"})}):e.jsx(Js,{className:"h-3.5 w-3.5 text-primary"}),e.jsx("span",{children:"Terminal"})]}),e.jsxs("div",{className:"ml-auto flex min-w-0 flex-wrap items-center justify-end gap-2",children:[e.jsxs("div",{ref:M,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":"Command session","aria-expanded":c,title:U?kl(U):"All sessions",onClick:()=>p(h=>!h),className:"node-terminal__control flex h-7 max-w-[14rem] list-none items-center gap-1.5 rounded-sm border border-border/70 bg-background/70 px-2 text-foreground outline-none transition-colors hover:bg-muted/65 focus-visible:ring-2 focus-visible:ring-ring/70 [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{className:"min-w-0 truncate",children:Sl(U,w)}),e.jsx(rs,{className:$("h-3 w-3 shrink-0 text-muted-foreground transition-transform",c&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!c,className:$("absolute right-0 bottom-9 z-30 w-[19rem] overflow-hidden rounded-xl border border-border/70 bg-popover text-popover-foreground shadow-xl",!c&&"hidden"),children:e.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[e.jsxs("button",{type:"button",onClick:()=>H(us),className:$("node-terminal__control flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",w===us&&"bg-primary/10 text-primary"),children:[e.jsx(Js,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:"All sessions"})]}),re("Active",X.active,S,()=>A(h=>!h),"No active sessions"),re("Completed",X.completed,L,()=>O(h=>!h),"No completed sessions")]})})]}),e.jsx("select",{value:(P==null?void 0:P.id)??"",onChange:h=>{i(h.target.value),j(!1),N(nt(s.find(z=>z.id===h.target.value)??null))},disabled:T||s.length===0,"aria-label":"Terminal node",className:"node-terminal__control h-7 max-w-[11rem] rounded-sm border border-border/70 bg-background/70 px-2 text-foreground outline-none transition-colors hover:bg-muted/65 disabled:opacity-50",children:s.map(h=>e.jsx("option",{value:h.id,className:"bg-background text-foreground",children:h.name},h.id))}),e.jsx(Us,{value:b,onChange:N,assignTo:(P==null?void 0:P.id)??"",nodes:s,assignableNodes:s,layout:"composer",chipClassName:"node-terminal__control h-7 max-w-[18rem] rounded-sm border border-border/70 bg-background/70 px-2 text-foreground hover:bg-muted/65",chipActiveClassName:"font-mono",chipInactiveClassName:"text-muted-foreground",labelClassName:"node-terminal__control",triggerClassName:"terminal-workdir-trigger",popoverPlacement:"top",popoverAlign:"end"})]})]}),e.jsxs("div",{ref:V,className:"node-terminal__body min-h-0 flex-1 overflow-y-auto bg-muted/22 px-3 py-2 font-mono cursor-text",onClick:()=>{var h;return(h=ne.current)==null?void 0:h.focus()},children:[Y.length===0?e.jsx("div",{className:"text-muted-foreground mb-2",children:"Commands run on the selected node and stay visible while running or after exit."}):e.jsx("div",{className:"space-y-3 mb-2",children:Y.map(h=>qe(h)?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[e.jsxs("span",{className:"text-primary",children:[h.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:h.session.command}),e.jsxs("span",{className:$("inline-flex items-center gap-1",h.session.status==="running"||h.session.status==="exited"?"text-primary":"text-amber-600 dark:text-amber-300"),children:[h.session.status==="running"?e.jsx(ce,{className:"h-3 w-3 animate-spin"}):h.session.status==="exited"?e.jsx(sa,{className:"h-3 w-3"}):e.jsx(Is,{className:"h-3 w-3"}),Dt(h.session)]}),h.session.status==="running"&&e.jsx("button",{type:"button",onClick:z=>void J(z,h),"aria-label":"Stop terminal session",title:"Stop terminal session",className:"inline-flex h-5 w-5 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted/65 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(xa,{className:"h-3 w-3"})})]}),h.session.stdout&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-foreground",children:h.session.stdout}),ja(h.session)&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:ja(h.session)}),(h.session.stdoutTruncated||h.session.stderrTruncated)&&e.jsx("div",{className:"text-muted-foreground",children:"Output truncated to the latest output."})]},h.id):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[e.jsxs("span",{className:"text-primary",children:[h.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:h.command}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[e.jsx(Is,{className:"h-3 w-3"}),"error"]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:h.error})]},h.id))}),e.jsxs("form",{onSubmit:Z,className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"shrink-0 text-primary select-none",children:P?`${P.name}$`:"$"}),e.jsx("input",{ref:ne,value:v,onChange:h=>f(h.target.value),disabled:!P||T,placeholder:P?"":"No online nodes available",className:"node-terminal__input flex-1 min-w-0 bg-transparent border-none outline-none text-foreground placeholder:text-muted-foreground font-mono caret-primary disabled:opacity-50",autoComplete:"off",spellCheck:!1}),e.jsx("button",{type:"submit","aria-label":"Run",title:"Run",disabled:!P||!v.trim()||T,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-primary transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70 disabled:pointer-events-none disabled:text-muted-foreground disabled:opacity-50",children:T?e.jsx(ce,{className:"h-3 w-3 animate-spin"}):e.jsx(Rt,{className:"h-3 w-3"})})]})]})]})})}function Vt({nodeId:s,nodeName:t,onOpenSettings:n,onOpenDevBox:o,onStartDevBox:r,showConfigureDevBox:i,showStartDevBox:g,startDevBoxPending:b,className:N}){const[v,f]=a.useState(!1),l=a.useRef(null),u=b?"Starting":"Start DevBox";return a.useEffect(()=>{if(!v)return;const w=x=>{var c;const j=x.target;j instanceof Node&&((c=l.current)!=null&&c.contains(j)||f(!1))},C=x=>{x.key==="Escape"&&f(!1)};return document.addEventListener("mousedown",w),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",C)}},[v]),e.jsxs("div",{ref:l,className:$("relative shrink-0",N),onClick:w=>w.stopPropagation(),children:[e.jsx(I,{type:"button",variant:"ghost",size:"icon","aria-label":`More actions for ${t}`,"aria-haspopup":"menu","aria-expanded":v,title:`More actions for ${t}`,onClick:()=>f(w=>!w),className:$("h-6 w-6 rounded-sm text-muted-foreground hover:bg-background/70 hover:text-foreground",v&&"bg-background/80 text-primary"),children:e.jsx(Ro,{className:"h-3.5 w-3.5"})}),v&&e.jsxs("div",{role:"menu",className:"absolute right-0 top-full z-30 mt-1 min-w-40 overflow-hidden whitespace-nowrap rounded-sm border border-border/65 bg-popover/96 p-1 normal-case tracking-normal shadow-[0_18px_48px_-28px_rgba(0,0,0,0.45)] backdrop-blur-xl",children:[e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Open ${t} settings`,title:`Open ${t} settings`,onClick:()=>{f(!1),n(s)},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(wr,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Settings"})]}),g&&r&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`${u} for ${t}`,title:`${u} for ${t}`,onClick:()=>{b||(f(!1),r(s))},disabled:b,className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80 disabled:cursor-not-allowed disabled:opacity-60",children:[b?e.jsx(ce,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-primary"}):e.jsx(Rt,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:u})]}),i&&o&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Configure DevBox for ${t}`,title:`Configure DevBox for ${t}`,onClick:()=>{f(!1),o(s)},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(yr,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Configure DevBox"})]})]})]})}const _l=new Set(["deallocated","hibernate","hibernated","sleep","sleeping","stopped"]),Dl=new Set(["startinprogress","starting"]);function js(s){return!!(s!=null&&s.enabled&&s.name)}function El(s){const t=s==null?void 0:s.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(t&&_l.has(t))}function Ns(s){const t=s==null?void 0:s.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(t&&Dl.has(t))}function Hs(s,t,n){return s==="offline"&&El(t)&&js(n)}function Na(s,t){return s==="offline"&&js(t)}function wa(s){return!js(s)}function Tl({nodeStatus:s,status:t,current:n,selected:o}){const r=o??n;return r&&Hs(s,t,r)?r:null}function Le(s){return s.scope||`name:${s.name??""}`}function Al({previousKey:s,baseDevBox:t,listed:n}){if(s&&n.some(i=>Le(i)===s))return s;if(!js(t))return n[0]?Le(n[0]):"";const o=Le(t),r=n.find(i=>Le(i)===o)??n.find(i=>i.name===t.name);return r?Le(r):o}function Ml({cluster:s,systemInfo:t,nodeNameById:n,nodeBlockingTaskCounts:o,eventTypeFilter:r,onEventTypeFilterChange:i,eventTypeOptions:g,filteredEvents:b,sseConnected:N,clusterLoading:v,clusterError:f,promotePending:l,onPromote:u,onAddNode:w,leavePending:C,onLeaveCluster:x,onToggleNodeDevTunnel:j,devTunnelNodeId:c,devBoxStartNodeId:p,devBoxStartingNodeIds:S=new Set,onOpenNodeSettings:A,onOpenDevBox:L,onStartDevBox:O,onClose:T}){var ne,Z,J;const F=((ne=s==null?void 0:s.self)==null?void 0:ne.role)==="leader",V=((Z=s==null?void 0:s.self)==null?void 0:Z.role)==="follower"&&!(s!=null&&s.leader),M=(s==null?void 0:s.self)??null,E=kr((s==null?void 0:s.nodes)??[],M==null?void 0:M.id).filter(H=>H.id!==(M==null?void 0:M.id)),X=s!=null&&s.leader?s.nodes.find(H=>{var K;return H.id===((K=s.leader)==null?void 0:K.id)})??null:null,U=s!=null&&s.leader?s.leader.dashboardOrigin??(X==null?void 0:X.dashboardOrigin)??(t&&s.leader.id===(t.nodeId??t.id)?t.dashboardOrigin:void 0)??s.leader.endpoint:null,Y=(M==null?void 0:M.role)==="leader"&&E.length===0,le=(M==null?void 0:M.role)==="follower";return e.jsx("aside",{className:"dashboard-panel dashboard-panel-muted animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl !border-0",children:e.jsxs($a,{defaultValue:"overview",className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"shrink-0 bg-card/24 px-2.5 py-2.5 shadow-[0_1px_0_hsl(var(--border)/0.22)]",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"Operations"}),e.jsx("p",{className:"mt-px text-[9px] text-muted-foreground",children:"Node, cluster, and live events."})]}),e.jsx(I,{variant:"ghost",size:"icon",onClick:T,className:"h-6 w-6 rounded-sm",children:e.jsx(Ft,{className:"h-3.5 w-3.5"})})]}),e.jsxs(Fa,{className:"mt-1.5 grid h-auto w-full grid-cols-3 rounded-sm bg-muted/55 p-0.5",children:[e.jsx(ds,{value:"overview",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Overview"}),e.jsx(ds,{value:"nodes",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Nodes"}),e.jsx(ds,{value:"events",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Live events"})]})]}),e.jsx(cs,{value:"overview",className:"mt-0 min-h-0 flex-1",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto px-2 py-2",children:e.jsxs("div",{className:"space-y-2.5",children:[M&&e.jsx(ya,{node:M,systemInfo:t,blockingTaskCount:o.get(M.id)??0,devTunnelNodeId:c,onToggleNodeDevTunnel:j,showActions:!1,defaultExpanded:!1,onOpenDevBox:L,devBoxStartingNodeIds:S}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-[10px] font-medium text-foreground",children:"Cluster snapshot"}),e.jsx(Ke,{variant:"outline",className:"rounded-sm border-transparent bg-background/60 px-1.5 py-0 text-[9px] leading-4 shadow-sm",children:N?"Connected":"Reconnecting"})]}),v&&!s?e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground",children:[e.jsx(ce,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):f&&!s?e.jsx("div",{className:"rounded-sm bg-destructive/10 px-2 py-1.5 text-[10px] text-destructive shadow-sm",children:f}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx(gs,{label:"Term",value:String((s==null?void 0:s.term)??0)}),e.jsx(gs,{label:"Nodes",value:String((s==null?void 0:s.nodes.length)??0)}),e.jsx(gs,{label:"Pending",value:String((s==null?void 0:s.taskSummary.pending)??0)}),e.jsx(gs,{label:"Running",value:String((s==null?void 0:s.taskSummary.running)??0)}),e.jsx(gs,{label:"Completed",value:String((s==null?void 0:s.taskSummary.completed)??0)}),e.jsx(gs,{label:"Failed",value:String((s==null?void 0:s.taskSummary.failed)??0)})]}),e.jsxs("div",{className:"space-y-1.5 rounded-sm bg-background/56 px-2 py-2 shadow-sm",children:[e.jsx(Qe,{label:"Leader",value:((J=s==null?void 0:s.leader)==null?void 0:J.name)??"None"}),e.jsx(Qe,{label:"Leader URL",value:U??"Unavailable",mono:!0,action:U?e.jsx(Ls,{label:"Copy leader URL",onClick:()=>void bs(U,"Leader URL copied")}):void 0}),e.jsx(Qe,{label:"Feed",value:N?"Receiving live updates":"Reconnecting to event stream"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:V&&e.jsxs(I,{variant:"outline",size:"sm",onClick:u,disabled:l,className:"h-6 rounded-sm px-2 text-[10px]",children:[l&&e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})})]})]})]})})}),e.jsx(cs,{value:"nodes",className:"mt-0 min-h-0 flex-1",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto px-2 py-2",children:e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-[10px] font-medium text-foreground",children:"This node"}),Y?e.jsx(I,{variant:"outline",size:"sm",onClick:w,className:"h-6 rounded-sm px-2 text-[10px]",children:"Join node"}):le?e.jsxs(I,{variant:"outline",size:"sm",onClick:x,disabled:C,className:"h-6 rounded-sm px-2 text-[10px]",children:[C&&e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),M&&e.jsx(ya,{node:M,systemInfo:t,blockingTaskCount:o.get(M.id)??0,devTunnelNodeId:c,onToggleNodeDevTunnel:j,showActions:!0,defaultExpanded:!0,onOpenNodeSettings:F?A:void 0,onOpenDevBox:F?L:void 0,onStartDevBox:F?O:void 0,devBoxStartNodeId:p,devBoxStartingNodeIds:S})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"text-[10px] font-medium text-foreground",children:["Peer nodes (",E.length,")"]}),E.length>0?e.jsx("div",{className:"space-y-1.5",children:E.map(H=>e.jsx(Ll,{node:H,isLeader:!!F,blockingTaskCount:o.get(H.id)??0,devTunnelNodeId:c,onToggleNodeDevTunnel:j,onOpenNodeSettings:F?A:void 0,onOpenDevBox:F?L:void 0,onStartDevBox:F?O:void 0,devBoxStartNodeId:p,devBoxStartingNodeIds:S},H.id))}):e.jsx("div",{className:"rounded-sm bg-background/45 px-2 py-2 text-[10px] text-muted-foreground shadow-sm",children:"No peer nodes are connected yet."})]})]})})}),e.jsx(cs,{value:"events",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col px-2 py-2",children:[e.jsxs("div",{className:"mb-2 space-y-1.5",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-foreground",children:[e.jsx(Sr,{className:$("h-3.5 w-3.5",N?"text-emerald-500":"text-destructive")}),"Live events"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsxs(Ce,{value:r,onValueChange:i,children:[e.jsx(_e,{className:"h-6 min-w-[10rem] flex-1 rounded-sm border-border/70 bg-background/60 text-[10px] sm:max-w-[14rem] [&>svg]:h-3 [&>svg]:w-3",children:e.jsx(ze,{placeholder:"Event type"})}),e.jsx(De,{children:g.map(H=>e.jsx(Ne,{value:H,className:"py-1 pl-6 pr-1.5 text-[10px] leading-4",children:H==="all"?"All event types":H},H))})]}),e.jsx(Ke,{variant:"outline",className:"rounded-sm border-transparent bg-background/60 px-1.5 py-0 text-[9px] leading-4 shadow-sm",children:N?"Connected":"Reconnecting"})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(Cr,{events:b,maxHeight:"100%",emptyTitle:r==="all"?"No live events yet":"No matching events",emptyDescription:r==="all"?"Cluster activity appears here as it happens.":`No "${r}" events are in the current stream.`,nodeNameById:n,density:"compact"})})]})})]})})}function ya({node:s,systemInfo:t,blockingTaskCount:n,devTunnelNodeId:o,onToggleNodeDevTunnel:r,showActions:i=!0,defaultExpanded:g=!1,onOpenNodeSettings:b,onOpenDevBox:N,onStartDevBox:v,devBoxStartNodeId:f,devBoxStartingNodeIds:l}){var O,T,F,V;const[u,w]=a.useState(g),C=(t==null?void 0:t.dashboardOrigin)??s.dashboardOrigin,x=s.devtunnelEndpoint??s.endpoint,j=C??s.endpoint,c=(t==null?void 0:t.workDir)??s.workDir,p=an(s,t==null?void 0:t.transportType),S=zt(s,t==null?void 0:t.transportType),A=S&&ys((t==null?void 0:t.transportType)??s.transportType)?!0:tn(s,t==null?void 0:t.transportType),L=n>0;return e.jsxs("section",{className:"rounded-lg bg-primary/7 shadow-[0_18px_56px_-42px_hsl(var(--primary)/0.85)]",children:[e.jsxs("div",{className:"w-full px-2.5 py-1.5 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>w(M=>!M),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[u?e.jsx(rs,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(As,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx(Va,{status:s.status}),e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Current node"})]}),e.jsx("a",{href:j,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(Ua,{className:"h-3 w-3"})}),b&&e.jsx(Vt,{nodeId:s.id,nodeName:s.name,onOpenSettings:b,onOpenDevBox:N,onStartDevBox:v,showConfigureDevBox:(O=s.devbox)==null?void 0:O.enabled,showStartDevBox:Hs(s.status,(T=s.devbox)==null?void 0:T.lastStatus,s.devbox)||Ns((F=s.devbox)==null?void 0:F.lastStatus)||l.has(s.id),startDevBoxPending:f===s.id||Ns((V=s.devbox)==null?void 0:V.lastStatus)||l.has(s.id)})]}),e.jsxs("button",{type:"button",onClick:()=>w(M=>!M),className:"mt-1 flex min-w-0 items-center gap-1 pl-5 text-left",children:[e.jsx("span",{className:"text-[10px] font-semibold tracking-tight text-foreground",children:s.name}),e.jsx(Ha,{role:s.role,size:"compact"}),e.jsx(Ke,{variant:"outline",className:"rounded-sm border-transparent bg-background/60 px-1.5 py-0 text-[9px] leading-4 capitalize shadow-sm",children:s.status})]})]}),u&&e.jsxs("div",{className:"space-y-2 px-2.5 pb-2.5 pt-1.5 shadow-[inset_0_1px_0_hsl(var(--primary)/0.12)]",children:[e.jsxs("div",{className:"space-y-1.5 rounded-sm bg-background/70 px-2 py-1.5 shadow-sm",children:[e.jsx(Qe,{label:"Node ID",value:s.id,mono:!0}),C&&e.jsx(Qe,{label:"Dashboard",value:C,mono:!0,action:e.jsx(Ls,{label:"Copy dashboard URL",onClick:()=>void bs(C,"Dashboard URL copied")})}),e.jsx(Qe,{label:"Node URL",value:x,mono:!0,action:e.jsx(Ls,{label:"Copy node URL",onClick:()=>void bs(x,"Node URL copied")})}),c&&e.jsx(Qe,{label:"Workspace",value:c,mono:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsx(bt,{label:"Transport",value:p}),t&&e.jsx(bt,{label:"Uptime",value:_r(t.uptime),mono:!0})]}),e.jsx(Ya,{capabilities:s.capabilities,action:i&&A?e.jsxs(I,{variant:"outline",size:"sm",onClick:()=>r(s),disabled:o===s.id||L,className:"h-6 rounded-sm px-2 text-[10px]",title:L?"Finish assigned or running tasks before changing remote access":void 0,children:[o===s.id&&e.jsx(ce,{className:"h-3 w-3 animate-spin"}),S?"Disable Remote Access":"Enable Remote Access"]}):void 0}),i&&A&&L&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function Ll({node:s,isLeader:t,blockingTaskCount:n,devTunnelNodeId:o,onToggleNodeDevTunnel:r,onOpenNodeSettings:i,onOpenDevBox:g,onStartDevBox:b,devBoxStartNodeId:N,devBoxStartingNodeIds:v}){var S,A,L,O;const[f,l]=a.useState(!1),u=s.dashboardOrigin,w=s.devtunnelEndpoint??s.endpoint,C=u??s.endpoint,x=an(s),j=zt(s),c=tn(s),p=n>0;return e.jsxs("div",{className:"rounded-sm bg-background/54 shadow-sm",children:[e.jsxs("div",{className:"w-full px-2.5 py-1.5 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>l(T=>!T),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[f?e.jsx(rs,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):e.jsx(As,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx(Va,{status:s.status}),e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Peer node"})]}),e.jsx("a",{href:C,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(Ua,{className:"h-3 w-3"})}),t&&i&&e.jsx(Vt,{nodeId:s.id,nodeName:s.name,onOpenSettings:i,onOpenDevBox:g,onStartDevBox:b,showConfigureDevBox:(S=s.devbox)==null?void 0:S.enabled,showStartDevBox:Hs(s.status,(A=s.devbox)==null?void 0:A.lastStatus,s.devbox)||Ns((L=s.devbox)==null?void 0:L.lastStatus)||v.has(s.id),startDevBoxPending:N===s.id||Ns((O=s.devbox)==null?void 0:O.lastStatus)||v.has(s.id)})]}),e.jsxs("button",{type:"button",onClick:()=>l(T=>!T),className:"mt-1 flex min-w-0 items-center gap-1 pl-4 text-left",children:[e.jsx("span",{className:"text-[10px] font-semibold text-foreground",children:s.name}),e.jsx(Ha,{role:s.role,size:"compact"}),e.jsx(Ke,{variant:"outline",className:"rounded-sm border-transparent bg-background/60 px-1.5 py-0 text-[9px] leading-4 capitalize shadow-sm",children:s.status})]})]}),f&&e.jsxs("div",{className:"space-y-2 px-2.5 pb-2.5 pt-1.5 shadow-[inset_0_1px_0_hsl(var(--border)/0.22)]",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Qe,{label:"Node ID",value:s.id,mono:!0}),u&&e.jsx(Qe,{label:"Dashboard",value:u,mono:!0,action:e.jsx(Ls,{label:"Copy dashboard URL",onClick:()=>void bs(u,"Dashboard URL copied")})}),e.jsx(Qe,{label:"Node URL",value:w,mono:!0,action:e.jsx(Ls,{label:"Copy node URL",onClick:()=>void bs(w,"Node URL copied")})}),s.workDir&&e.jsx(Qe,{label:"Workspace",value:s.workDir,mono:!0}),e.jsx(bt,{label:"Transport",value:x})]}),e.jsx(Ya,{capabilities:s.capabilities,action:t&&c?e.jsxs(I,{variant:"outline",size:"sm",onClick:()=>r(s),disabled:o===s.id||p,className:"h-6 rounded-sm px-2 text-[10px]",title:p?"Finish assigned or running tasks before changing remote access":void 0,children:[o===s.id&&e.jsx(ce,{className:"h-3 w-3 animate-spin"}),j?"Disable Remote Access":"Enable Remote Access"]}):void 0}),t&&c&&p&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function Ls({label:s,onClick:t}){return e.jsx(I,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0 rounded-sm text-muted-foreground",onClick:t,"aria-label":s,title:s,children:e.jsx(Ra,{className:"h-3 w-3"})})}function Pl(s,t,n,o){var b,N;if(!s)return{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Select a task to continue the conversation."};const r=((b=t==null?void 0:t.self)==null?void 0:b.role)==="follower",i=s.assignedTo?((N=t==null?void 0:t.self)==null?void 0:N.id)===s.assignedTo?t.self:t==null?void 0:t.nodes.find(v=>v.id===s.assignedTo):void 0;return s.assignedTo!==null&&(i?i.status==="offline":t?s.assignedNodeAvailable===!1||!t.nodes.some(v=>v.id===s.assignedTo):s.assignedNodeAvailable===!1)?{taskUnavailable:!0,chatDisabled:!0,chatDisabledReason:`${s.assignedNodeName??"Assigned node"} is unavailable. Leave the cluster on that node or re-run the task elsewhere.`}:r?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Follower nodes are read-only. Use the leader dashboard to manage chat, or leave the cluster first."}:n?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Sending message..."}:o?{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Queue a message for the next turn..."}:Vs.has(s.status)||s.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:Vs.has(s.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}const bn="meshy-task-sidebar-tree-state";function ka(s){return Array.isArray(s)?s.filter(t=>typeof t=="string"):[]}function rt(){var s;try{return((s=globalThis.window)==null?void 0:s.localStorage)??globalThis.localStorage??null}catch{return null}}function Sa(s){if(!s)return{collapsedNodes:[],collapsedDirs:[]};try{const t=s.getItem(bn);if(!t)return{collapsedNodes:[],collapsedDirs:[]};const n=JSON.parse(t);return{collapsedNodes:ka(n.collapsedNodes),collapsedDirs:ka(n.collapsedDirs)}}catch{return{collapsedNodes:[],collapsedDirs:[]}}}function Bl(s,t){if(s)try{s.setItem(bn,JSON.stringify(t))}catch{}}function Ca(s,t){if(!s.has(t))return s;const n=new Set(s);return n.delete(t),n}function Rl(s,t){if(!t)return null;for(const n of s){const o=n.nodeId??"__unassigned__";for(const r of n.dirs)if(r.tasks.some(i=>i.id===t))return{nodeKey:o,dirKey:`${o}::${r.path}`}}return null}function _a(s,t,n){return n?{collapsedNodes:Ca(s,n.nodeKey),collapsedDirs:Ca(t,n.dirKey)}:{collapsedNodes:s,collapsedDirs:t}}function $l(s,t,n){const o=s.filter(b=>b.status==="completed"),r=new Set((t?o:[...o].sort((b,N)=>N.updatedAt-b.updatedAt).slice(0,Pt)).map(b=>b.id));n&&o.some(b=>b.id===n)&&r.add(n);const i=s.filter(b=>b.status!=="completed"||r.has(b.id)),g=o.length-r.size;return{visibleTasks:i,hiddenCompletedCount:Math.max(0,g)}}const Fs="h-6 rounded-sm border-border/70 bg-background/60 px-2 py-0 text-[10px] leading-none shadow-sm [&>svg]:h-3 [&>svg]:w-3",zs="py-1 pl-6 pr-1.5 text-[10px] leading-4 [&_svg]:h-3 [&_svg]:w-3";function Da({toolbarTasks:s,activeTaskId:t,tasksLoading:n,tasksError:o,isLeader:r,scope:i,agentFilter:g,nodeFilter:b,taskKindFilter:N,agentOptions:v,nodeOptions:f,nodeNameById:l,nodeWorkDirById:u,nodeStatusById:w,completedGroupByKey:C,devBoxNodeIds:x=new Set,devBoxStartNodeIds:j=new Set,devBoxStartingNodeIds:c=new Set,leaderNodeId:p,searchQuery:S,selectedTaskIds:A,allVisibleTasksSelected:L,someVisibleTasksSelected:O,canBatchArchive:T,onSearchChange:F,onScopeChange:V,onAgentFilterChange:M,onNodeFilterChange:P,onTaskKindFilterChange:E,onToggleTaskSelected:X,onToggleAllVisibleTasks:U,onBatchArchive:Y,onBatchDelete:le,onCreateTask:ne,onOpenNodeSettings:Z,onOpenDevBox:J,onStartDevBox:H,onLoadCompletedTasks:K,onSelectTask:re,onClose:ue}){const[h,z]=a.useState(!!S),[_,ee]=a.useState(!1),[m,R]=a.useState(!1),q=a.useRef(null),te=a.useRef(null),k=a.useRef(null),[G,se]=a.useState(()=>A.size>0),{markScrollbarActive:Re,scrollbarActive:ve}=hn(),fe=A.size,Te=!!(r&&(G||fe>0)),He=i!=="active"||b!=="all"||g!=="all"||N!=="all",Q=S.trim().length>0,[pe,we]=a.useState(()=>new Set(Sa(rt()).collapsedNodes)),[Je,Pe]=a.useState(()=>new Set(Sa(rt()).collapsedDirs)),[be,Ye]=a.useState(new Set),ye=a.useMemo(()=>Dr(s,l,p,u),[s,l,p,u]),Ee=a.useMemo(()=>Rl(ye,t),[ye,t]),Ze=a.useRef(null),ms=ye.length===1,ts=ye.length>0,os=ms&&(He||Q),is=!!(r&&(ye.length>0||fe>0)),xs=a.useCallback(D=>{we(xe=>{const de=new Set(xe);return de.has(D)?de.delete(D):de.add(D),de})},[]),$e=a.useCallback(D=>{Pe(xe=>{const de=new Set(xe);return de.has(D)?de.delete(D):de.add(D),de})},[]),ls=a.useCallback(D=>{Ye(xe=>{const de=new Set(xe);return de.add(D),de})},[]);a.useEffect(()=>{Bl(rt(),{collapsedNodes:Array.from(pe),collapsedDirs:Array.from(Je)})},[Je,pe]),a.useEffect(()=>{if(!Ee||!t)return;const D=`${t}:${Ee.nodeKey}:${Ee.dirKey}`;Ze.current!==D&&(Ze.current=D,we(xe=>_a(xe,new Set,Ee).collapsedNodes),Pe(xe=>_a(new Set,xe,Ee).collapsedDirs))},[t,Ee]);const Ae=a.useCallback(D=>{se(!0),U(D)},[U]),hs=a.useCallback(()=>{U(!1),se(!1)},[U]);return a.useEffect(()=>{r||se(!1)},[r]),a.useEffect(()=>{S&&z(!0)},[S]),a.useEffect(()=>{var D;h&&((D=q.current)==null||D.focus())},[h]),a.useEffect(()=>{if(!h)return;const D=de=>{var We;const Ie=de.target;Ie instanceof Node&&((We=te.current)!=null&&We.contains(Ie)||z(!1))},xe=de=>{de.key==="Escape"&&z(!1)};return document.addEventListener("mousedown",D),document.addEventListener("keydown",xe),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",xe)}},[h]),a.useEffect(()=>{if(!m)return;const D=de=>{var We;const Ie=de.target;Ie instanceof Node&&((We=k.current)!=null&&We.contains(Ie)||R(!1))},xe=de=>{de.key==="Escape"&&R(!1)};return document.addEventListener("mousedown",D),document.addEventListener("keydown",xe),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",xe)}},[m]),e.jsxs("aside",{className:"dashboard-panel dashboard-panel-muted animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl !border-t-0",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/55 bg-card/24 px-2.5 py-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-sm font-semibold tracking-tight text-foreground",children:"Tasks"}),e.jsx(I,{variant:"ghost",size:"icon",onClick:ue,className:"h-6 w-6 rounded-sm",children:e.jsx(Za,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{ref:te,className:"mt-2 flex items-center gap-1.5",children:[e.jsxs("div",{ref:k,className:$("relative flex items-stretch transition-[flex] duration-200",h?"flex-[2]":"flex-1"),children:[e.jsxs(I,{onClick:()=>{R(!1),ne("chat")},className:"h-8 flex-1 justify-start rounded-l-sm rounded-r-none px-2.5 text-left text-[11px] shadow-[0_10px_24px_-18px_hsl(var(--primary)/0.9)]",children:[e.jsx(Ot,{className:"h-3.5 w-3.5"}),"New chat"]}),e.jsx(I,{onClick:()=>R(D=>!D),"aria-label":"More chat options","aria-haspopup":"menu","aria-expanded":m,className:"h-8 w-7 rounded-l-none rounded-r-sm border-l border-primary-foreground/20 px-0 shadow-[0_10px_24px_-18px_hsl(var(--primary)/0.9)]",children:e.jsx(rs,{className:$("h-3 w-3 transition-transform",m&&"rotate-180")})}),m&&e.jsx("div",{role:"menu",className:"absolute left-0 right-0 top-full z-20 mt-2 overflow-hidden rounded-lg border border-border/60 bg-popover/96 p-1 shadow-[0_20px_60px_-30px_rgba(0,0,0,0.45)] backdrop-blur-xl",children:e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{R(!1),ne("native")},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-2 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx($t,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{className:"flex-1 truncate whitespace-nowrap",children:"Load session"}),e.jsx("span",{className:"shrink-0 text-[9px] uppercase tracking-[0.18em] text-muted-foreground",children:"native"})]})})]}),h?e.jsxs("div",{className:"flex min-w-0 flex-[3] items-center gap-1.5",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(ot,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(Xe,{ref:q,value:S,onChange:D=>F(D.target.value),placeholder:"Search tasks",className:"h-8 rounded-sm border-border/70 bg-background/68 pl-8 text-[11px]"})]}),e.jsx(I,{variant:"outline",size:"icon",onClick:()=>z(!1),className:"h-8 w-8 rounded-sm border-border/70 bg-background/68",children:e.jsx(Is,{className:"h-3.5 w-3.5"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(I,{variant:"outline",onClick:()=>z(!0),className:$("h-8 rounded-sm border-border/70 bg-background/68 px-2.5 text-[11px]",S&&"border-primary/40 bg-primary/8 text-primary"),children:[e.jsx(ot,{className:"h-3.5 w-3.5"}),"Search"]}),e.jsx(I,{variant:_||He?"secondary":"outline",size:"icon",onClick:()=>ee(D=>!D),className:$("h-8 w-8 shrink-0 rounded-sm border-border/70 bg-background/68",He&&"border-primary/40 bg-primary/8 text-primary"),title:"Filters",children:e.jsx(Io,{className:"h-3.5 w-3.5"})})]})]}),(_||He)&&e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-1 sm:grid-cols-2",children:[e.jsxs(Ce,{value:i,onValueChange:D=>V(D),children:[e.jsx(_e,{className:Fs,children:e.jsx(ze,{})}),e.jsx(De,{children:Er.map(D=>e.jsx(Ne,{value:D.value,className:zs,children:D.label},D.value))})]}),e.jsxs(Ce,{value:b,onValueChange:P,children:[e.jsx(_e,{className:Fs,children:e.jsx(ze,{placeholder:"Node"})}),e.jsx(De,{children:f.map(D=>e.jsx(Ne,{value:D.value,className:zs,children:D.label},D.value))})]}),e.jsxs(Ce,{value:g,onValueChange:M,children:[e.jsx(_e,{className:Fs,children:e.jsx(ze,{placeholder:"Agent"})}),e.jsx(De,{children:v.map(D=>e.jsx(Ne,{value:D,className:zs,children:D==="all"?"All agents":D},D))})]}),e.jsxs(Ce,{value:N,onValueChange:D=>E(D),children:[e.jsx(_e,{className:Fs,children:e.jsx(ze,{placeholder:"Type"})}),e.jsx(De,{children:Tr.map(D=>e.jsx(Ne,{value:D.value,className:zs,children:D.label},D.value))})]})]})]}),e.jsx("div",{className:$("scrollbar-line min-h-0 flex-1 overflow-y-auto px-1.5 py-2",ve&&"scrollbar-line-active"),onScroll:Re,children:ye.length>0?e.jsx("div",{className:"space-y-1",children:ye.map(D=>{const xe=D.nodeId??"__unassigned__",de=D.dirs.reduce((ge,je)=>ge+je.tasks.length,0),Ie=ts&&!os&&pe.has(xe),We=D.nodeId!==null&&w.get(D.nodeId)==="offline",Me=!!(r&&D.nodeId&&Z);return e.jsxs("div",{className:"space-y-1",children:[ts&&e.jsxs("div",{className:"flex w-full items-center gap-1.5 rounded-sm bg-gradient-to-r from-primary/8 to-muted/20 px-2 py-1.5 text-left text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground transition-all duration-150 hover:from-primary/12 hover:to-muted/30 hover:text-foreground active:scale-[0.99] active:from-primary/15",children:[e.jsxs("button",{type:"button",onClick:()=>xs(xe),"aria-expanded":!Ie,className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[e.jsx(As,{className:$("h-3.5 w-3.5 shrink-0 transition-transform duration-200",!Ie&&"rotate-90")}),e.jsx(La,{className:"h-3 w-3 shrink-0 text-muted-foreground/55"}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:D.nodeName}),e.jsxs(Ke,{variant:"outline",className:"shrink-0 whitespace-nowrap rounded-sm border-transparent bg-background/55 px-1.5 py-0 text-[7px] font-semibold leading-3.5 text-muted-foreground shadow-none normal-case tracking-normal",children:[de," task",de===1?"":"s"]})]})]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[We&&e.jsx(Ke,{variant:"outline",className:"rounded-sm border-destructive/25 bg-destructive/10 px-1 py-0 text-[8px] font-semibold leading-3 text-destructive shadow-none",children:"offline"}),D.nodeId===p&&e.jsx(Ke,{variant:"outline",className:"rounded-sm border-transparent bg-primary/8 px-1 py-0 text-[8px] font-medium leading-3.5 text-primary shadow-none",children:"leader"}),Me&&D.nodeId&&Z&&e.jsx(Vt,{nodeId:D.nodeId,nodeName:D.nodeName,onOpenSettings:Z,onOpenDevBox:J,onStartDevBox:H,showConfigureDevBox:x.has(D.nodeId),showStartDevBox:j.has(D.nodeId)||c.has(D.nodeId),startDevBoxPending:c.has(D.nodeId)})]})]}),e.jsx("div",{className:$("grid transition-[grid-template-rows] duration-300 ease-in-out",Ie?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:"overflow-hidden",children:D.dirs.map(ge=>{const je=`${xe}::${ge.path}`,es=Je.has(je),ks=Ka(ge.path),ke=C==null?void 0:C.get(je),Ss=ke?{visibleTasks:ge.tasks,hiddenCompletedCount:Math.max(0,ke.total-ke.returned)}:$l(ge.tasks,be.has(je),t),{visibleTasks:fs,hiddenCompletedCount:Oe}=Ss;return e.jsxs("div",{className:$("space-y-0.5 rounded-xl",ts&&"pl-2.5"),children:[e.jsxs("button",{type:"button",onClick:()=>$e(je),"aria-expanded":!es,title:ge.path,className:"flex w-full items-center gap-1.5 rounded-sm bg-muted/15 px-2 py-1 text-left text-[9px] font-medium text-muted-foreground/70 transition-all duration-150 hover:bg-muted/30 hover:text-foreground active:scale-[0.98] active:bg-muted/40",children:[e.jsx(As,{className:$("h-3 w-3 shrink-0 transition-transform duration-200",!es&&"rotate-90")}),e.jsx(Pa,{className:"h-3 w-3 shrink-0 text-muted-foreground/55"}),e.jsx("span",{className:"truncate font-mono",children:ks}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-muted-foreground/40",children:ge.tasks.length})]}),e.jsx("div",{className:$("grid transition-[grid-template-rows] duration-300 ease-in-out",es?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:$("overflow-hidden",ts?"pl-2":"pl-0"),children:e.jsxs("div",{className:"space-y-px py-0.5",children:[fs.map(Se=>{const ss=Se.id===t,Fe=Se.assignedTo?w.get(Se.assignedTo):void 0,Ve=!!Se.assignedTo&&(Fe?Fe==="offline":Se.assignedNodeAvailable===!1);return e.jsxs("div",{className:$("animate-task-row-reveal flex items-center gap-1.5 rounded-sm px-2 py-1.5 transition-all duration-150",ss?"bg-primary/10":"hover:bg-muted/40"),children:[Te&&e.jsx("div",{className:"flex shrink-0",onClick:Cs=>Cs.stopPropagation(),children:e.jsx(pt,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:A.has(Se.id),onCheckedChange:Cs=>X(Se.id,Cs===!0),"aria-label":`Select ${Se.title}`})}),e.jsxs("button",{type:"button",onClick:()=>re(Se.id),"aria-current":ss?"page":void 0,className:"relative min-w-0 flex-1 pr-8 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5 pr-1",children:[e.jsx("span",{className:$("min-w-0 flex-1 truncate text-[10px] font-medium leading-4",ss?"text-foreground":"text-foreground/80"),children:Se.title}),ss&&e.jsx("span",{className:"ml-1 h-1.5 w-1.5 shrink-0 rounded-full bg-primary"})]}),e.jsx("span",{className:$("absolute right-0 top-0 shrink-0 tabular-nums text-[8px] leading-4",ss?"text-primary/75":"text-muted-foreground/55"),children:Ar(Se.updatedAt)}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-0.5",children:[e.jsx("span",{className:"rounded-sm bg-muted/35 px-1 py-0 font-mono text-[8px] leading-3 text-muted-foreground/65",children:Se.agent}),Se.activeShare&&e.jsx(Ke,{variant:"outline",className:"rounded-sm border-primary/25 bg-primary/8 px-1 py-0 text-[8px] leading-3 text-primary shadow-none",children:"shared"}),Ve&&e.jsx(Ke,{variant:"outline",className:"rounded-sm border-destructive/25 bg-destructive/8 px-1 py-0 text-[8px] leading-3 text-destructive shadow-none",children:"unavailable"})]}),e.jsx(Oa,{status:Se.status,isNative:Se.conversationKind==="nativeSession",size:"compact",className:"absolute bottom-1 right-0"})]})]},Se.id)}),Oe>0&&e.jsxs("button",{type:"button",onClick:()=>{ke&&K?K(ke):ls(je)},className:"mt-1 flex w-full items-center justify-center gap-1 rounded-sm border border-dashed border-border/55 bg-background/35 px-2 py-1 text-[9px] font-medium text-muted-foreground transition-colors hover:border-primary/35 hover:bg-primary/8 hover:text-primary","aria-label":`Load ${Oe} more completed tasks in ${ks}`,children:[e.jsx(rs,{className:"h-3 w-3"}),"Load ",Oe," more completed"]})]})})})]},je)})})})]},xe)})}):n?e.jsx("div",{className:"space-y-2 px-1",children:[1,2,3].map(D=>e.jsx("div",{className:"rounded-xl border border-border/40 bg-background/30 px-3 py-3",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"mt-1 h-2.5 w-2.5 shrink-0 animate-pulse rounded-full bg-muted-foreground/20"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-2.5 animate-pulse rounded-full bg-muted-foreground/15",style:{width:`${60+D*12}%`,animationDelay:`${D*120}ms`}}),e.jsx("div",{className:"h-2 w-24 animate-pulse rounded-full bg-muted-foreground/10",style:{animationDelay:`${D*120+60}ms`}})]})]})},D))}):e.jsx("div",{className:"rounded-xl border border-dashed border-border/70 bg-background/35 px-3 py-5 text-[11px] text-muted-foreground",children:o||"No tasks match this view."})}),is?e.jsx("div",{className:"shrink-0 px-2.5 pb-2.5 pt-1.5",children:e.jsxs("div",{className:"flex items-end justify-between gap-2",children:[e.jsx("div",{className:"flex min-w-0 items-center",children:Te?e.jsxs("label",{className:"flex items-center gap-[5px] text-[9px] font-medium uppercase tracking-[0.12em] text-muted-foreground/75",children:[e.jsx(pt,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:O&&!L?"indeterminate":L,onCheckedChange:D=>Ae(D===!0),"aria-label":"Select all visible tasks"}),e.jsx("span",{children:"Multi select"})]}):e.jsxs(I,{variant:"ghost",size:"sm",onClick:()=>se(!0),className:"h-5 rounded-sm px-1.5 text-[9px] font-medium uppercase tracking-[0.12em] text-muted-foreground/75 hover:text-foreground",children:[e.jsx(ko,{className:"h-3 w-3"}),"Multi select"]})}),Te&&e.jsxs("div",{className:"ml-auto flex w-48 max-w-[65%] flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[fe>0?e.jsxs("div",{className:"min-w-0 text-left",children:[e.jsxs("div",{className:"text-[9px] font-semibold leading-3 text-foreground",children:[fe," task",fe!==1?"s":""," selected"]}),!T&&e.jsx("div",{className:"max-w-48 text-[9px] leading-3.5 text-muted-foreground",children:"Only completed, failed, cancelled, or archived tasks can be archived."})]}):e.jsx("span",{}),e.jsx(I,{variant:"ghost",size:"sm",onClick:hs,className:"h-5 shrink-0 rounded-sm px-1.5 text-[9px]",children:fe>0?"Clear":"Done"})]}),fe>0&&e.jsxs("div",{className:"flex flex-wrap justify-end gap-1",children:[e.jsxs(lt,{children:[e.jsx(ta,{asChild:!0,children:e.jsxs(I,{variant:"ghost",size:"sm",disabled:!T,className:"h-5 gap-1 rounded-sm bg-muted/45 px-1.5 text-[8px] text-foreground/80 shadow-none hover:bg-muted/65 [&_svg]:size-3",children:[e.jsx(Mo,{}),"Archive"]})}),e.jsxs(dt,{children:[e.jsxs(ct,{children:[e.jsxs(ut,{children:["Archive ",fe," task",fe!==1?"s":"","?"]}),e.jsx(mt,{children:"Archived tasks stay hidden from the default task view and can be reopened from the archived scope."})]}),e.jsxs(xt,{children:[e.jsx(ht,{children:"Cancel"}),e.jsx(ft,{onClick:Y,disabled:!T,children:"Archive"})]})]})]}),e.jsxs(lt,{children:[e.jsx(ta,{asChild:!0,children:e.jsxs(I,{variant:"destructive",size:"sm",className:"h-5 gap-1 rounded-sm px-1.5 text-[8px] [&_svg]:size-3",children:[e.jsx(fi,{}),"Delete"]})}),e.jsxs(dt,{children:[e.jsxs(ct,{children:[e.jsxs(ut,{children:["Delete ",fe," task",fe!==1?"s":"","?"]}),e.jsx(mt,{children:"This removes the selected tasks and their saved logs."})]}),e.jsxs(xt,{children:[e.jsx(ht,{children:"Cancel"}),e.jsx(ft,{onClick:le,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]})]})}):null]})}async function Ol(s,t){var n,o;try{const r=await Mr(s,t),i={...r,url:Ba(r.url)};if((o=(n=globalThis.navigator)==null?void 0:n.clipboard)!=null&&o.writeText)try{await globalThis.navigator.clipboard.writeText(i.url),ae.success("Shared link copied")}catch{ae.success("Shared link created")}else ae.success("Shared link created");return i}catch(r){ae.error(r instanceof Error?r.message:"Failed to create shared link");return}}async function Fl(s){try{return await Lr(s),ae.success("Shared link stopped"),!0}catch(t){return ae.error(t instanceof Error?t.message:"Failed to stop shared link"),!1}}function zl(s,t,n){const o=a.useCallback(()=>{t(),n()},[t,n]),r=a.useCallback(async g=>{if(!s)return;const b=await Ol(s.id,g);return b&&o(),b},[s,o]),i=a.useCallback(async()=>{if(!s)return!1;const g=await Fl(s.id);return g&&o(),g},[s,o]);return{handleShareTask:r,handleStopShareTask:i}}function Ea(s,t,n){const o=a.useRef(t);o.current=t,a.useEffect(()=>{let g=0,b=0;const N=l=>{const u=l.touches[0];u&&(g=u.clientX,b=u.clientY)},v=l=>{var x,j,c,p;const u=l.changedTouches[0];if(!u)return;const w=u.clientX-g;Math.abs(u.clientY-b)>100||Math.abs(w)<50||(w>0?(j=(x=o.current).onSwipeRight)==null||j.call(x):(p=(c=o.current).onSwipeLeft)==null||p.call(c))},f=(s==null?void 0:s.current)??document;return f.addEventListener("touchstart",N,{passive:!0}),f.addEventListener("touchend",v,{passive:!0}),()=>{f.removeEventListener("touchstart",N),f.removeEventListener("touchend",v)}},[s,n==null?void 0:n.threshold,n==null?void 0:n.maxVertical])}const Il="(min-width: 1024px)",Vl="(min-width: 1800px)";function Ta(s){var t,n,o;return((o=(n=(t=globalThis.window)==null?void 0:t.matchMedia)==null?void 0:n.call(t,s))==null?void 0:o.matches)??!1}function Ul(){var n,o;const s=(n=globalThis.document)==null?void 0:n.documentElement;if(!s||!((o=globalThis.window)!=null&&o.getComputedStyle))return 16;const t=Number.parseFloat(globalThis.window.getComputedStyle(s).fontSize);return Number.isFinite(t)&&t>0?t:16}function Hl(){const[s,t]=a.useState(()=>Pr(aa(),Br({operationsOpen:Ta(Vl)}))),[n,o]=a.useState(!1),r=a.useRef(null),i=a.useRef(null),g=a.useRef(null),b=s.layout.desktopTasksOpen,N=s.layout.operationsOpen,v=s.sizes;a.useEffect(()=>{Rr(aa(),s)},[s]);const f=a.useCallback((j,c)=>{t(p=>{const S=p.layout[j],A=typeof c=="function"?c(S):c;return A===S?p:{...p,layout:{...p.layout,[j]:A}}})},[]),l=a.useCallback(j=>{f("desktopTasksOpen",j)},[f]),u=a.useCallback(j=>{f("operationsOpen",j)},[f]);Ea(i,{onSwipeLeft:()=>o(!1)}),Ea(g,{onSwipeRight:()=>u(!1)});const w=a.useCallback(()=>{if(Ta(Il)){l(j=>!j);return}o(j=>!j)},[l]);a.useEffect(()=>{var p,S,A;const j=L=>{const O=r.current;if(!O)return;L.preventDefault();const T=Or(O.panel,O.startSize,O.startClientX,O.startClientY,L.clientX,L.clientY,O.rootFontSize);t(F=>({...F,sizes:{...F.sizes,[O.panel]:T}}))},c=()=>{r.current=null};return(p=globalThis.window)==null||p.addEventListener("pointermove",j),(S=globalThis.window)==null||S.addEventListener("pointerup",c),(A=globalThis.window)==null||A.addEventListener("pointercancel",c),()=>{var L,O,T;(L=globalThis.window)==null||L.removeEventListener("pointermove",j),(O=globalThis.window)==null||O.removeEventListener("pointerup",c),(T=globalThis.window)==null||T.removeEventListener("pointercancel",c)}},[]);const C=a.useCallback((j,c)=>{var p,S;c.preventDefault(),(S=(p=c.currentTarget).setPointerCapture)==null||S.call(p,c.pointerId),r.current={panel:j,startSize:v[j],startClientX:c.clientX,startClientY:c.clientY,rootFontSize:Ul()}},[v]),x=a.useCallback((j,c)=>{c.preventDefault(),t(p=>({...p,sizes:{...p.sizes,[j]:$r(j,p.sizes[j],c.deltaY)}}))},[]);return{desktopTasksOpen:b,mobileTasksPanelOpen:n,mobileTasksPanelRef:i,operationsOpen:N,operationsPanelRef:g,panelResize:{sizes:{tasks:Zs(v.tasks),operations:Zs(v.operations),terminal:Zs(v.terminal)},onPointerDown:C,onWheel:x},setMobileTasksPanelOpen:o,setOperationsOpen:u,toggleTasksPanel:w}}function Kl(s,t){const n=t.taskId,o=t.updates;return typeof n!="string"||!o||typeof o!="object"?s:s.map(r=>r.id===n?{...r,...o}:r)}function ql({isLeader:s,selfId:t}){return{...!s&&t?{assignedTo:t}:{},completedLimitPerProject:Pt}}function Et(s){return`${s.assignedTo??"__unassigned__"}::${s.projectPath}`}function Wl(s,t){const n=new Map(s.map(o=>[o.id,o]));for(const o of t)n.set(o.id,o);return Array.from(n.values())}function Gl(s,t){return t?nn(s,t):s}function Ql({isLeader:s,selfId:t,sseConnected:n,preservedTask:o,subscribe:r}){const[i,g]=a.useState([]),[b,N]=a.useState([]),[v,f]=a.useState(!0),[l,u]=a.useState(null),w=a.useRef(null),C=a.useCallback(async()=>{try{const c=await na(ql({isLeader:s,selfId:t}));g(Gl(c.tasks,o)),N(c.completedGroups??[]),u(null)}catch(c){u(c instanceof Error?c.message:"Failed to load tasks")}finally{f(!1)}},[s,o,t]),x=a.useCallback(async c=>{if(!c.hasMore||!c.nextCursor)return;const p=await na({status:"completed",assignedTo:c.assignedTo??"__unassigned__",projectPath:c.projectPath,cursor:c.nextCursor,limit:Pt});g(S=>Wl(S,p.tasks)),N(S=>S.map(A=>Et(A)===Et(c)?{...A,returned:Math.min(A.total,A.returned+p.tasks.length),hasMore:p.hasMore===!0,nextCursor:p.nextCursor??null}:A))},[]),j=a.useCallback(()=>{w.current===null&&(w.current=window.setTimeout(()=>{w.current=null,C()},Fr))},[C]);return zr(C,Vr(n)),a.useEffect(()=>()=>{w.current!==null&&(window.clearTimeout(w.current),w.current=null)},[]),a.useEffect(()=>{const c=[r("task.updated",p=>{g(S=>Kl(S,p.data))}),r("task.status",p=>{g(S=>Ir(S,p.data))}),r("node",p=>{ra(p.type)&&j()}),r("task",p=>{ra(p.type)&&j()})];return()=>c.forEach(p=>p())},[r,j]),{completedGroups:b,fetchTasks:C,loadCompletedTasksPage:x,setTasks:g,tasks:i,tasksError:l,tasksLoading:v}}function vn(s){return s.map(t=>({...t}))}function Yl(s,t){const n=t.get(s);return{logs:n?vn(n.logs):[],transcriptLoading:(n==null?void 0:n.loaded)!==!0}}function Xl(s,t){return t.data.nodeId===s.self.id||t.data.name===s.self.name||t.data.endpoint===s.self.endpoint}function Jl({cluster:s,subscribe:t}){a.useEffect(()=>{var n;if(((n=s==null?void 0:s.self)==null?void 0:n.role)==="leader")return t("node",o=>{const r=String(o.data.name??o.data.nodeId??"node"),i=Xl(s,o);o.type==="node.joined"&&!i&&ae.success(`${r} joined the cluster`),o.type==="node.left"&&!i&&ae.message(`${r} left the cluster`)})},[s,t])}const Zl=[0,300,1e3,2e3];function ed({task:s,getActiveTaskId:t,setLogs:n,setPendingMessages:o,setTranscriptLoading:r}){s.conversationKind==="nativeSession"&&(async()=>{try{for(const i of Zl){if(i>0&&await new Promise(g=>setTimeout(g,i)),t()!==s.id)return;try{const g=await gt(s.id);if(t()!==s.id||(n(b=>Xa(b,g.logs)),o(b=>vt(b,g.logs)),g.total>0))return}catch{}}}finally{t()===s.id&&(r==null||r(!1))}})()}function sd(s,t){return Le(s??{})===Le(t??{})}function td(s){return s&&"status"in s&&typeof s.status=="string"?s.status:void 0}function Aa(s,t){return{...s,enabled:!0,alwaysOnline:t}}function jn(s){var t,n;return((t=s==null?void 0:s.status)==null?void 0:t.trim())||((n=s==null?void 0:s.lastStatus)==null?void 0:n.trim())||"Unknown"}function ad({operationStarting:s,loading:t,refreshing:n,savedStatus:o,fallbackStatus:r}){return s?"Starting":t?"Listing DevBoxes":n?"Refreshing":o??r}function Ma({devbox:s,showStatus:t=!1}){return e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[e.jsx("span",{className:"font-medium",children:s.name}),s.projectName&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",s.projectName]})]}),t&&e.jsx("span",{className:"ml-auto shrink-0 rounded-full border border-border/70 bg-background/70 px-1.5 py-0.5 text-[10px] leading-none text-muted-foreground",children:jn(s)})]})}function nd({node:s,open:t,startInProgress:n=!1,onOpenChange:o,onRefresh:r}){const i=(s==null?void 0:s.id)??null,g=t&&!n&&Na(s==null?void 0:s.status,(s==null?void 0:s.devbox)??null),[b,N]=a.useState([]),[v,f]=a.useState(()=>s!=null&&s.devbox?Le(s.devbox):""),[l,u]=a.useState(()=>(s==null?void 0:s.devbox)??null),[w,C]=a.useState(()=>wa((s==null?void 0:s.devbox)??null)),[x,j]=a.useState(!1),[c,p]=a.useState(g),[S,A]=a.useState(!1),[L,O]=a.useState(!1),[T,F]=a.useState(()=>{var m;return((m=s==null?void 0:s.devbox)==null?void 0:m.alwaysOnline)===!0}),V=a.useMemo(()=>{const m=b.find(R=>Le(R)===v);return m||(js(l)&&Le(l)===v?l:void 0)},[l,b,v]),M=td(V??void 0),P=w?M??(l==null?void 0:l.lastStatus):(l==null?void 0:l.lastStatus)??M,E=(s==null?void 0:s.status)==="online"||(s==null?void 0:s.status)==="busy"?"Running":"Unknown",X=L||n,U=ad({operationStarting:X,loading:x,refreshing:c,savedStatus:P,fallbackStatus:E}),Y=w&&!!V&&!sd(l,V),le=(l==null?void 0:l.alwaysOnline)===!0!==T,ne=Tl({nodeStatus:s==null?void 0:s.status,status:U,current:l,selected:V}),Z=!!ne,J=!!V&&(Y||le)&&!Z,H=V??l,K=a.useCallback(async()=>{if(i){p(!0);try{const m=await Ur(i);u(m.devbox),f(Le(m.devbox))}catch(m){ae.error(m instanceof Error?m.message:"Failed to refresh DevBox status")}finally{p(!1)}}},[i]),re=a.useCallback(async m=>{j(!0);try{const R=await Hr();N(R),f(q=>Al({previousKey:q,baseDevBox:m,listed:R}))}catch(R){ae.error(R instanceof Error?R.message:"Failed to load DevBoxes")}finally{j(!1)}},[]);a.useEffect(()=>{if(!t||!i)return;let m=!1;const R=(s==null?void 0:s.devbox)??null,q=wa(R),te=!n&&Na(s==null?void 0:s.status,R);j(!1),p(te),C(q),u(R),F((R==null?void 0:R.alwaysOnline)===!0),f(js(R)?Le(R):""),N([]);async function k(){te&&await K(),!m&&q&&await re(R)}return k(),()=>{m=!0}},[re,s==null?void 0:s.devbox,s==null?void 0:s.status,i,t,K,n]);async function ue(){C(!0),b.length===0&&await re(l)}async function h(){if(!(!s||!V)){A(!0);try{const m=await oa(s.id,Aa(V,T));u(m.node.devbox??null),m.node.devbox&&f(Le(m.node.devbox)),C(!1),ae.success(`Configured DevBox for ${s.name}`),await(r==null?void 0:r())}catch(m){ae.error(m instanceof Error?m.message:"Failed to configure DevBox")}finally{A(!1)}}}async function z(){if(!(!s||!ne)){O(!0);try{if(V&&(Y||le)){const R=await oa(s.id,Aa(V,T));u(R.node.devbox??null),R.node.devbox&&f(Le(R.node.devbox)),C(!1)}const{operation:m}=await qa(s.id);u(R=>R&&{...R,lastStatus:"Starting",checkedAt:Date.now(),operationId:m.id}),ae.success(`Start requested for ${s.name}`),await(r==null?void 0:r())}catch(m){ae.error(m instanceof Error?m.message:"Failed to start DevBox")}finally{O(!1)}}}const _=x?"Loading DevBoxes...":b.length===0?"No DevBoxes available":"Select a DevBox",ee=U==="Running"&&(s==null?void 0:s.status)==="offline";return e.jsx(Tt,{open:t,onOpenChange:o,children:e.jsxs(At,{className:"max-w-md gap-4 rounded-lg p-5",children:[e.jsxs(za,{className:"space-y-1",children:[e.jsx(Mt,{className:"text-sm",children:"Configure DevBox"}),e.jsxs(Kr,{className:"text-xs",children:["Bind ",s!=null&&s.name?e.jsx("span",{className:"font-medium text-foreground",children:s.name}):"this node"," to an Azure Dev Box. Meshy will start it when the node is offline."]})]}),e.jsxs("div",{className:"space-y-3",children:[(w||H)&&e.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-3 rounded-xl border border-border/60 bg-muted/20 px-3 py-2 text-xs",children:[e.jsx("div",{className:"min-w-0 flex-1",children:w?e.jsxs(Ce,{value:v,onValueChange:f,disabled:x||S||L||b.length===0,children:[e.jsx(_e,{className:"h-7 justify-start gap-2 rounded-none border-0 bg-transparent px-0 text-xs shadow-none focus:ring-0 focus:ring-offset-0 [&>span]:!flex [&>span]:!min-w-0 [&>span]:!flex-1 [&>span]:!items-center",children:x&&!V?e.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),_]}):V?e.jsx(Ma,{devbox:V}):e.jsx(ze,{placeholder:_})}),e.jsx(De,{children:b.map(m=>e.jsx(Ne,{value:Le(m),textValue:`${m.name} ${m.projectName??""} ${jn(m)}`,className:"pl-2 pr-7 text-xs [&>span:first-child]:left-auto [&>span:first-child]:right-2 [&>span:last-child]:w-full",children:e.jsx(Ma,{devbox:m,showStatus:!0})},Le(m)))})]}):H&&e.jsxs("div",{className:"min-w-0 truncate",children:[e.jsx("span",{className:"font-medium text-foreground",children:H.name}),H.projectName&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",H.projectName]})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(Ke,{variant:"outline",className:"rounded-full px-2 py-0.5 text-[10px]",children:[(x||c)&&e.jsx(ce,{className:"mr-1 h-2.5 w-2.5 animate-spin"}),U]}),(l==null?void 0:l.name)&&e.jsx(I,{type:"button",variant:"ghost",size:"icon",onClick:()=>{ue()},disabled:x||S||X||w,"aria-label":"Edit DevBox binding",title:"Edit DevBox binding",className:"h-6 w-6 rounded-full text-muted-foreground hover:text-foreground",children:x&&w?e.jsx(ce,{className:"h-3 w-3 animate-spin"}):e.jsx(ws,{className:"h-3 w-3"})})]})]}),ee&&e.jsx("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300",children:"DevBox is running, but the Meshy node is not connected yet."}),e.jsxs("label",{className:"flex min-h-9 items-start gap-2 rounded-xl border border-border/60 bg-muted/20 px-3 py-2 text-xs text-foreground",children:[e.jsx(pt,{checked:T,onCheckedChange:m=>F(m===!0),disabled:S||L||X,"aria-label":"Always online",className:"mt-0.5 h-3.5 w-3.5"}),e.jsxs("span",{className:"min-w-0 leading-4",children:[e.jsx("span",{className:"block",children:"Always online"}),e.jsx("span",{className:"block text-[10px] leading-3.5 text-muted-foreground",children:"Meshy will start the DevBox automatically when it is Hibernated or Stopped."})]})]})]}),e.jsxs(Ia,{className:"gap-2 sm:space-x-0",children:[e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>o(!1),disabled:S||L,className:"h-8 rounded-xl text-xs",children:"Close"}),Z&&e.jsxs(I,{size:"sm",onClick:z,disabled:L,className:"h-8 rounded-xl text-xs",children:[L?e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Rt,{className:"h-3.5 w-3.5"}),"Start DevBox"]}),!Z&&e.jsxs(I,{size:"sm",onClick:h,disabled:!J||S,className:"h-8 rounded-xl text-xs",children:[S&&e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})})}async function rd(s,t=qr){if(s.length===0)return new Set;const n=new Set(s),[o,r]=await Promise.all([t({kind:"devbox.start",status:"queued"}),t({kind:"devbox.start",status:"running"})]);return new Set([...o,...r].filter(i=>n.has(i.nodeId)).map(i=>i.nodeId))}function od({cluster:s,refresh:t}){const[n,o]=a.useState(null),[r,i]=a.useState(null),[g,b]=a.useState(()=>new Set),[N,v]=a.useState(()=>new Set),f=a.useMemo(()=>(s==null?void 0:s.nodes.find(c=>c.id===n))??null,[s==null?void 0:s.nodes,n]),l=a.useMemo(()=>new Set(((s==null?void 0:s.nodes)??[]).filter(c=>{var p;return(p=c.devbox)==null?void 0:p.enabled}).map(c=>c.id)),[s==null?void 0:s.nodes]),u=a.useMemo(()=>new Set(((s==null?void 0:s.nodes)??[]).filter(c=>{var p;return Hs(c.status,(p=c.devbox)==null?void 0:p.lastStatus,c.devbox)}).map(c=>c.id)),[s==null?void 0:s.nodes]),w=a.useMemo(()=>new Set(((s==null?void 0:s.nodes)??[]).filter(c=>{var p;return Ns((p=c.devbox)==null?void 0:p.lastStatus)}).map(c=>c.id)),[s==null?void 0:s.nodes]),C=a.useMemo(()=>{const c=new Set(g);r&&c.add(r);for(const p of N)c.add(p);for(const p of w)c.add(p);return c},[N,r,g,w]);a.useEffect(()=>{let c=!1;const p=[...l];async function S(){try{const A=await rd(p);c||v(A)}catch{c||v(new Set)}}return S(),()=>{c=!0}},[l]),a.useEffect(()=>{b(c=>{var A;let p=!1;const S=new Set(c);for(const L of c){const O=s==null?void 0:s.nodes.find(T=>T.id===L);(O==null?void 0:O.status)!=="online"&&(!((A=O==null?void 0:O.devbox)!=null&&A.lastStatus)||Ns(O.devbox.lastStatus))||(S.delete(L),p=!0)}return p?S:c})},[s==null?void 0:s.nodes]);const x=a.useCallback(async c=>{const p=s==null?void 0:s.nodes.find(S=>S.id===c);if(p){i(c),b(S=>new Set(S).add(c));try{await qa(c),ae.success(`Start requested for ${p.name}`),t()}catch(S){b(A=>{const L=new Set(A);return L.delete(c),L}),ae.error(S instanceof Error?S.message:"Failed to start DevBox")}finally{i(null)}}},[s==null?void 0:s.nodes,t]);return{devBoxDialog:e.jsx(nd,{node:f,open:n!==null,startInProgress:f?C.has(f.id):!1,onOpenChange:c=>{c||o(null)},onRefresh:t}),devBoxNodeIds:l,devBoxStartNodeId:r,devBoxStartNodeIds:u,devBoxStartingNodeIds:C,openDevBox:o,startDevBox:x}}function id(s){const[t,n]=a.useState(null),o=a.useCallback(i=>{s&&n(i)},[s]);return{nodeSettingsDialog:e.jsx(Wr,{open:t!==null,onOpenChange:i=>{i||n(null)},initialSelectedNodeId:t??void 0,showTrigger:!1}),openNodeSettings:o}}function ld({activeTaskId:s,fetchActiveTask:t,setPendingMessages:n,setTask:o,setTasks:r}){const i=a.useCallback((N,v)=>{o(f=>f&&f.id===N?{...f,queuedMessages:v}:f),r(f=>f.map(l=>l.id===N?{...l,queuedMessages:v}:l))},[o,r]),g=a.useCallback(async N=>{if(!s)return!1;const v=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`;n(f=>[...f,{id:v,content:N,timestamp:new Date().toISOString()}]);try{const f=await Gr(s,N);return f.queued&&(n(l=>l.filter(u=>u.id!==v)),f.queuedMessages&&i(s,f.queuedMessages)),t(),!0}catch(f){return n(l=>l.filter(u=>u.id!==v)),ae.error(f instanceof Error?f.message:"Failed to send message"),!1}},[s,t,n,i]);return{cancelQueuedMessage:a.useCallback(async N=>{if(s)try{const v=await Qr(s,N);i(s,v.queuedMessages),t()}catch(v){ae.error(v instanceof Error?v.message:"Failed to cancel queued message")}},[s,t,i]),queueFollowUpMessage:g}}function dd(){var Wt,Gt,Qt,Yt,Xt,Jt;const{id:s}=Yr(),t=Xr(),n=Jr(),o=Zr(),{cluster:r,systemInfo:i,events:g,sseConnected:b,subscribe:N,refresh:v,loading:f,error:l}=eo(),u=a.useMemo(()=>so(t.state),[t.state]),[w,C]=a.useState(null),[x,j]=a.useState("active"),[c,p]=a.useState("all"),[S,A]=a.useState("all"),[L,O]=a.useState("all"),[T,F]=a.useState(""),V=(o==null?void 0:o.headerSearchQuery)??T,M=(o==null?void 0:o.setHeaderSearchQuery)??F,P=a.useDeferredValue(V),{desktopTasksOpen:E,mobileTasksPanelOpen:X,mobileTasksPanelRef:U,operationsOpen:Y,operationsPanelRef:le,panelResize:ne,setMobileTasksPanelOpen:Z,setOperationsOpen:J,toggleTasksPanel:H}=Hl(),[K,re]=a.useState(()=>!!(u!=null&&u.draftNewTask)),[ue,h]=a.useState(()=>(u==null?void 0:u.createMode)??"chat"),[z,_]=a.useState(()=>u!=null&&u.draftNewTask?{route:u.returnRoute??"/",taskId:u.returnTaskId??null}:null),[ee,m]=a.useState(!1),[R,q]=a.useState("transcript"),[te,k]=a.useState("all"),[G,se]=a.useState(!1),[Re,ve]=a.useState(null),[fe,Te]=a.useState([]),[He,Q]=a.useState([]),[pe,we]=a.useState(!1),[Je,Pe]=a.useState(!1),[be,Ye]=a.useState(null),[ye,Ee]=a.useState(new Set),[Ze,ms]=a.useState(!1),[ts,os]=a.useState(!1),[is,xs]=a.useState(null),$e=a.useRef(null),ls=a.useRef(new Map),Ae=((Wt=r==null?void 0:r.self)==null?void 0:Wt.role)==="leader",hs=(Gt=r==null?void 0:r.self)==null?void 0:Gt.id;Jl({cluster:r,subscribe:N});const{nodeSettingsDialog:D,openNodeSettings:xe}=id(Ae),{devBoxDialog:de,devBoxNodeIds:Ie,devBoxStartNodeId:We,devBoxStartNodeIds:Me,devBoxStartingNodeIds:ge,openDevBox:je,startDevBox:es}=od({cluster:r,refresh:v}),{completedGroups:ks=[],fetchTasks:ke,loadCompletedTasksPage:Ss,setTasks:fs,tasks:Oe,tasksError:Se,tasksLoading:ss}=Ql({isLeader:Ae,selfId:hs,sseConnected:b,preservedTask:Re,subscribe:N}),Fe=a.useMemo(()=>[...Oe].sort((d,y)=>y.updatedAt-d.updatedAt),[Oe]),Ve=a.useMemo(()=>{var d;return((d=[...Oe].sort((y,B)=>B.createdAt-y.createdAt||B.updatedAt-y.updatedAt)[0])==null?void 0:d.id)??null},[Oe]),Cs=a.useMemo(()=>{const d=new Map;for(const y of(r==null?void 0:r.nodes)??[]){const B=gi(Fe,y.id);B>0&&d.set(y.id,B)}return d},[r==null?void 0:r.nodes,Fe]),Ge=a.useMemo(()=>Fe.filter(d=>!to(d,r==null?void 0:r.nodes,r==null?void 0:r.self)||!ao(d,x)||c!=="all"&&d.agent!==c||!no(d,L)||S==="unassigned"&&d.assignedTo||S!=="all"&&S!=="unassigned"&&ro(d.assignedTo,r==null?void 0:r.nodes,d.assignedNodeName)!==S?!1:P.trim()?oo(d,P):!0),[Fe,r==null?void 0:r.nodes,r==null?void 0:r.self,x,c,L,S,P]);a.useEffect(()=>{Ee(d=>{const y=yi(d,Ge.map(B=>B.id));return y.size===d.size?d:y})},[Ge]),a.useEffect(()=>{Ae||Ee(new Set)},[Ae]);const Nn=a.useMemo(()=>["all",...Array.from(new Set(Fe.map(d=>d.agent))).sort()],[Fe]),wn=a.useMemo(()=>{const y=Array.from(new Set(Fe.map(B=>B.assignedTo).filter(B=>!!B))).map(B=>{const he=Fe.find(oe=>oe.assignedTo===B);return(r==null?void 0:r.nodes.find(oe=>oe.id===B))??{id:B,name:it(B,r==null?void 0:r.nodes,he==null?void 0:he.assignedNodeName)}}).sort((B,he)=>B.name.localeCompare(he.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...y.map(B=>({value:B.name.toLowerCase(),label:B.name}))]},[Fe,r==null?void 0:r.nodes]),Ut=a.useMemo(()=>{const d=new Map;for(const y of(r==null?void 0:r.nodes)??[])d.set(y.id,y.name);for(const y of Fe)y.assignedTo&&y.assignedNodeName&&!d.has(y.assignedTo)&&d.set(y.assignedTo,y.assignedNodeName);return d},[r==null?void 0:r.nodes,Fe]),yn=a.useMemo(()=>{var y;const d=new Map;for(const B of(r==null?void 0:r.nodes)??[])B.workDir&&d.set(B.id,B.workDir);return(y=r==null?void 0:r.self)!=null&&y.workDir&&d.set(r.self.id,r.self.workDir),d},[r]),kn=a.useMemo(()=>{const d=new Map;for(const y of(r==null?void 0:r.nodes)??[])d.set(y.id,y.status);return r!=null&&r.self&&d.set(r.self.id,r.self.status),d},[r]),Sn=a.useMemo(()=>new Map(ks.map(d=>[Et(d),d])),[ks]),Ht=a.useMemo(()=>{const d=new Map;for(const y of(r==null?void 0:r.nodes)??[])y.status!=="offline"&&d.set(y.id,y);return r!=null&&r.self&&r.self.status!=="offline"&&d.set(r.self.id,r.self),Array.from(d.values())},[r]),Cn=((Qt=r==null?void 0:r.self)==null?void 0:Qt.id)??((Yt=Ht[0])==null?void 0:Yt.id)??null,Ks=a.useMemo(()=>["all",...Array.from(new Set(g.map(d=>d.type))).sort()],[g]),_n=a.useMemo(()=>te==="all"?g:g.filter(d=>d.type===te),[g,te]),Dn=Ge.length>0&&Ge.every(d=>ye.has(d.id)),En=Ge.some(d=>ye.has(d.id)),Tn=ki(Ge,ye);a.useEffect(()=>{u!=null&&u.draftNewTask&&(re(!0),_({route:u.returnRoute??"/",taskId:u.returnTaskId??null}))},[u]),a.useEffect(()=>{te!=="all"&&!Ks.includes(te)&&k("all")},[te,Ks]),a.useEffect(()=>{ha(s,K)&&!w&&Ve&&C(Ve)},[s,K,w,Ve]),a.useEffect(()=>{ha(s,K)&&(w&&Oe.some(d=>d.id===w)||C(Ve))},[s,K,w,Ve,Oe]);const ie=vi({routeTaskId:s,creatingTask:K,internalSelectedTaskId:w,sortedTaskIds:Ve?[Ve]:[]}),ps=a.useMemo(()=>Oe.find(d=>d.id===ie)??null,[Oe,ie]);a.useEffect(()=>{$e.current=ie??null},[ie]);const as=a.useCallback(()=>{ve(null),Te([]),Q([]),Ye(null),Pe(!1)},[]),_s=a.useCallback((d,y,B=!0)=>{ls.current.set(d,{logs:vn(y),loaded:B})},[]),Ue=a.useCallback(async()=>{const d=ie;if(d)try{const y=await io(d);if($e.current!==d)return;ve(y),fs(B=>nn(B,y)),Ye(null)}catch(y){if($e.current!==d)return;as(),Ye(y instanceof Error?y.message:"Failed to load task")}finally{$e.current===d&&we(!1)}},[ie,as,fs]),Ps=a.useCallback(async()=>{const d=ie;if(d)try{const y=await gt(d);if($e.current!==d)return;Te(B=>{const he=Xa(B,y.logs);return _s(d,he),he}),Q(B=>vt(B,y.logs))}catch{}finally{$e.current===d&&Pe(!1)}},[ie,_s]);a.useEffect(()=>{if(!ie){as(),we(!1);return}q("transcript"),ve(ps);const d=Yl(ie,ls.current);Te(d.logs),Q([]),Ye(null),we(!0),Pe(d.transcriptLoading),Ue(),Ps()},[ie,as,Ps,Ue]),a.useEffect(()=>{if(!ji({activeTaskId:ie,routeTaskId:s,creatingTask:K,tasksLoading:ss,loadedTaskIds:Oe.map(y=>y.id)}))return;const d=Ve;C(d),as(),a.startTransition(()=>{n(d?`/tasks/${d}`:"/",{state:null})})},[ie,as,K,Ve,n,s,Oe,ss]),a.useEffect(()=>{ps&&ve(d=>!d||d.id!==ps.id?d:{...d,...ps})},[ps]),a.useEffect(()=>{if(ie)return N("task",d=>{const y=d.data.taskId;if(!(typeof y!="string"||y!==ie)){if(d.type==="task.output"){const B=d.data.event;if(B){Te(oe=>{const Es=So(oe,B);return _s(ie,Es),Es}),Pe(!1);const he=ua(B);he&&Q(oe=>Co(oe,he))}}d.type==="task.updated"&&Ue(),d.type==="task.status"&&(Ue(),Ps())}})},[N,ie,Ue,Ps]);const W=Re??ps,An=W!=null&&W.assignedTo?(r==null?void 0:r.nodes.find(d=>d.id===W.assignedTo))??null:null,Ds=o==null?void 0:o.setHeaderTaskContext;a.useEffect(()=>{if(!Ds)return;if(!W){Ds(null);return}const d=W.effectiveProjectPath??W.project??"default workspace";return Ds({taskId:W.id,taskTitle:W.title,nodeName:it(W.assignedTo,r==null?void 0:r.nodes,W.assignedNodeName),projectLabel:Ka(d),projectPath:d}),()=>Ds(null)},[W,r==null?void 0:r.nodes,Ds]);const qs=He.length>0,Mn=W?lo.has(W.agent):!1,Ws=(W==null?void 0:W.status)==="running",Ln=W?Vs.has(W.status):!1,Pn=W?Vs.has(W.status)||co.has(W.status):!1,Bn=!!(W&&Ae&&W.status==="failed"),Gs=a.useMemo(()=>Pl(W,r,qs,!!Ws),[W,r,qs,Ws]),Qs=a.useMemo(()=>_o([...fe,...He.map(d=>st(d.content,d.timestamp))]),[fe,He]),Bs=a.useMemo(()=>{if(!W||W.conversationKind==="nativeSession")return null;const d=Do(W);if(d.length>0)return st(d,new Date(W.createdAt).toISOString());if(Qs.length>0)return null;const y=Eo(W.description||W.title);return y.length>0?st(y,new Date(W.createdAt).toISOString()):null},[W,Qs]),Ys=a.useMemo(()=>Bs?ua(Bs):null,[Bs]),Rn=a.useMemo(()=>Ys?To(fe,Ys):!1,[fe,Ys]),Xs=a.useCallback((d="chat")=>{const y={route:s?`/tasks/${s}`:"/",taskId:ie};_(y),h(d),re(!0),a.startTransition(()=>{n("/",{state:{draftNewTask:!0,returnRoute:y.route,returnTaskId:y.taskId,createMode:d}})})},[s,ie,n]),$n=a.useCallback(()=>{const d=(z==null?void 0:z.taskId)??Ve;re(!1),_(null),C(d),a.startTransition(()=>{n((z==null?void 0:z.route)??"/",{state:null})})},[z,Ve,n]),Kt=a.useCallback(d=>{re(!1),_(null),C(d),a.startTransition(()=>{n(`/tasks/${d}`,{state:null})})},[n]),On=a.useCallback(d=>{$e.current=d.id,re(!1),_(null),fs(y=>Ni(y,d)),ve(d),Te([]),Q([]),Ye(null),we(!1),Pe(d.conversationKind==="nativeSession"),q("transcript"),C(d.id),ed({task:d,getActiveTaskId:()=>$e.current,setLogs:Te,setPendingMessages:Q,setTranscriptLoading:Pe}),ke(),a.startTransition(()=>{n(`/tasks/${d.id}`,{state:null})})},[ke,n]),{cancelQueuedMessage:Fn,queueFollowUpMessage:Rs}=ld({activeTaskId:ie,fetchActiveTask:Ue,setPendingMessages:Q,setTask:ve,setTasks:fs}),zn=a.useCallback(d=>{Rs(d)},[Rs]),In=a.useCallback(async()=>{const d=ie;if(!(!d||(W==null?void 0:W.conversationKind)!=="nativeSession")){Pe(!0);try{const y=await gt(d);if($e.current!==d)return;Te(y.logs),_s(d,y.logs),Q(B=>vt(B,y.logs))}catch(y){ae.error(y instanceof Error?y.message:"Failed to reload transcript")}finally{$e.current===d&&Pe(!1)}}},[W==null?void 0:W.conversationKind,ie,_s]),Vn=a.useCallback(d=>Rs(d),[Rs]),Un=a.useCallback(async()=>{if(W)try{await uo(W.id),Ue(),ke()}catch(d){ae.error(d instanceof Error?d.message:"Failed to cancel task")}},[W,Ue,ke]),{handleShareTask:Hn,handleStopShareTask:Kn}=zl(W,Ue,ke),qn=a.useCallback(async()=>{if(W)try{await mo(W.id),Ue(),ke()}catch(d){ae.error(d instanceof Error?d.message:"Failed to retry task")}},[W,Ue,ke]),$s=a.useCallback((d,y=!1)=>{const B=Si(Ge,d);return C(B),(y||!B)&&as(),a.startTransition(()=>{n(B?`/tasks/${B}`:"/",{state:null})}),B},[as,Ge,n]),Wn=a.useCallback((d,y)=>{Ee(B=>{const he=new Set(B);return y?he.add(d):he.delete(d),he})},[]),Gn=a.useCallback(d=>{if(!d){Ee(new Set);return}Ee(new Set(Ge.map(y=>y.id)))},[Ge]),Qn=a.useCallback(async()=>{const d=Array.from(ye);if(d.length!==0)try{const{results:y}=await xo(d),B=y.filter(oe=>!oe.ok),he=y.filter(oe=>oe.ok).map(oe=>oe.id);ie&&he.includes(ie)&&$s(he),B.length>0?ae.error(`Failed to archive ${B.length} task(s): ${B.map(oe=>oe.error??oe.id).join(", ")}`):ae.success(`Archived ${he.length} task(s)`),Ee(new Set(B.map(oe=>oe.id))),ke()}catch(y){ae.error(y instanceof Error?y.message:"Failed to archive tasks")}},[ie,ke,$s,ye]),Yn=a.useCallback(async()=>{const d=Array.from(ye);if(d.length!==0)try{const{results:y}=await ho(d),B=y.filter(oe=>!oe.ok),he=y.filter(oe=>oe.ok).map(oe=>oe.id);ie&&he.includes(ie)&&$s(he,!0),B.length>0?ae.error(`Failed to delete ${B.length} task(s): ${B.map(oe=>oe.error??oe.id).join(", ")}`):ae.success(`Deleted ${he.length} task(s)`),Ee(new Set(B.map(oe=>oe.id))),ke()}catch(y){ae.error(y instanceof Error?y.message:"Failed to delete tasks")}},[ie,ke,$s,ye]),Xn=a.useCallback(async()=>{ms(!0);try{await fo(),v()}catch(d){ae.error(d instanceof Error?d.message:"Failed to promote node")}finally{ms(!1)}},[v]),Jn=a.useCallback(async()=>{os(!0);try{await po(),ae.success("This node left the remote cluster and is leading itself again."),ke(),Ue(),v()}catch(d){ae.error(d instanceof Error?d.message:"Failed to leave cluster")}finally{os(!1)}},[Ue,ke,v]),Zn=a.useCallback(async d=>{var Es;const y=!zt(d),B=d.id===((Es=r==null?void 0:r.self)==null?void 0:Es.id),he=B?(i==null?void 0:i.transportType)??d.transportType:d.transportType,oe=B&&!y&&ys(he);xs(d.id);try{oe?await go("direct"):await bo(d.id,y),ae.success(y?`Enabled remote access on ${d.name}`:`Disabled remote access on ${d.name}`),v()}catch(Zt){ae.error(Zt instanceof Error?Zt.message:"Failed to update remote access")}finally{xs(null)}},[(Xt=r==null?void 0:r.self)==null?void 0:Xt.id,v,i==null?void 0:i.transportType]),er=a.useCallback(d=>{Ss&&Ss(d).catch(y=>{ae.error(y instanceof Error?y.message:"Failed to load completed tasks")})},[Ss]),qt={toolbarTasks:Ge,activeTaskId:ie,tasksLoading:ss,tasksError:Se,isLeader:Ae,scope:x,agentFilter:c,nodeFilter:S,taskKindFilter:L,agentOptions:Nn,nodeOptions:wn,nodeNameById:Ut,nodeWorkDirById:yn,nodeStatusById:kn,leaderNodeId:((Jt=r==null?void 0:r.leader)==null?void 0:Jt.id)??null,searchQuery:V,completedGroupByKey:Sn,devBoxNodeIds:Ie,devBoxStartNodeIds:Me,devBoxStartingNodeIds:ge,selectedTaskIds:ye,allVisibleTasksSelected:Dn,someVisibleTasksSelected:En,canBatchArchive:Tn,onSearchChange:M,onScopeChange:j,onAgentFilterChange:p,onNodeFilterChange:A,onTaskKindFilterChange:O,onToggleTaskSelected:Wn,onToggleAllVisibleTasks:Gn,onBatchArchive:Qn,onBatchDelete:Yn,onCreateTask:Xs,onOpenNodeSettings:Ae?xe:void 0,onOpenDevBox:Ae?je:void 0,onStartDevBox:Ae?es:void 0,onLoadCompletedTasks:er,onSelectTask:Kt,onClose:H},sr={cluster:r,systemInfo:i,nodeNameById:Ut,nodeBlockingTaskCounts:Cs,eventTypeFilter:te,onEventTypeFilterChange:k,eventTypeOptions:Ks,filteredEvents:_n,sseConnected:b,clusterLoading:f,clusterError:l,promotePending:Ze,onPromote:Xn,onAddNode:()=>m(!0),leavePending:ts,onLeaveCluster:Jn,onToggleNodeDevTunnel:Zn,devTunnelNodeId:is,devBoxStartNodeId:We,devBoxStartingNodeIds:ge,onOpenNodeSettings:Ae?xe:void 0,onOpenDevBox:Ae?je:void 0,onStartDevBox:Ae?es:void 0,onClose:()=>J(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(bl,{desktopTasksOpen:E,mobileTasksPanelOpen:X,mobileTasksPanelRef:U,operationsOpen:Y,operationsPanelRef:le,panelResize:ne,taskSidebar:e.jsx(Da,{...qt}),operationsSidecar:e.jsx(Ml,{...sr}),terminalPanel:o!=null&&o.terminalOpen?e.jsx(Cl,{nodes:Ht,defaultNodeId:Cn,onClose:()=>o==null?void 0:o.setTerminalOpen(!1)}):void 0,conversationPanel:e.jsx(hl,{onToggleTasks:H,desktopTasksOpen:E,mobileTasksPanelOpen:X,operationsOpen:Y,onToggleOperations:()=>J(d=>!d),cluster:r,sseConnected:b,activeTab:R,setActiveTab:q,creatingTask:K,createMode:ue,activeTask:W,assignedNode:An,taskLoading:pe,transcriptLoading:Je,taskError:be,displayEvents:Qs,initialPromptAlreadyInLogs:Rn,initialPrompt:Bs,supportsFollowUp:Mn,taskUnavailable:Gs.taskUnavailable,chatDisabled:Gs.chatDisabled,chatDisabledReason:Gs.chatDisabledReason,questionBypassEnabled:G,isRunning:!!Ws,isStarting:Ln,hasPendingFollowUp:qs,canCancel:!!Pn,canRetry:!!Bn,onRetry:qn,onCancel:Un,onReloadNativeTranscript:In,onShareTask:Hn,onStopShareTask:Kn,onStartCreateTask:Xs,onCancelCreateTask:$n,onCreateTask:On,onSendMessage:zn,onCancelQueuedMessage:Fn,onQuestionBypassChange:se,onSubmitQuestionResponse:Vn}),mobileTaskSidebar:e.jsx(Da,{...qt,onCreateTask:d=>{Z(!1),Xs(d)},onSelectTask:d=>{Z(!1),Kt(d)},onClose:()=>Z(!1)}),onCloseOperations:()=>J(!1),onCloseTaskList:()=>Z(!1)}),e.jsx(gl,{open:ee,onOpenChange:m,onAdded:v}),D,de]})}const xd=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:dd},Symbol.toStringTag,{value:"Module"}));export{xd as D,jt as G};
|