meshy-node 0.10.10 → 1.0.0
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-kK0-et4p.js +211 -0
- package/dashboard/assets/{DashboardShared-DihTM-xx.js → DashboardShared-B-MhNC7V.js} +23 -23
- package/dashboard/assets/{DiffTab-BuC8qgFb.js → DiffTab-xXmdkadb.js} +2 -2
- package/dashboard/assets/{FilesTab-jvuvGCqQ.js → FilesTab-tVrm_BOK.js} +2 -2
- package/dashboard/assets/{MarkdownPreviewFrame-CwXixe62.js → MarkdownPreviewFrame-Bh67Y-4b.js} +1 -1
- package/dashboard/assets/{PreviewTab-oRD3Wntx.js → PreviewTab-kRFQ5bQf.js} +5 -5
- package/dashboard/assets/SharedConversationPage-CYSWbDBC.js +2 -0
- package/dashboard/assets/{file-CoTh89vx.js → file-eGew3MDA.js} +1 -1
- package/dashboard/assets/index-DJ824ClY.css +1 -0
- package/dashboard/assets/index-rujLgCBM.js +326 -0
- package/dashboard/index.html +2 -2
- package/main.cjs +16 -4
- package/package.json +1 -1
- package/runtime-metadata.json +4 -4
- package/dashboard/assets/DashboardPage-Dr7Q3ARl.js +0 -191
- package/dashboard/assets/SharedConversationPage-Psgl27Kx.js +0 -2
- package/dashboard/assets/index-BBHpcOD3.js +0 -346
- package/dashboard/assets/index-CE-vUwSy.css +0 -1
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-jvuvGCqQ.js","assets/index-BBHpcOD3.js","assets/index-CE-vUwSy.css","assets/MarkdownPreviewFrame-CwXixe62.js","assets/DashboardShared-DihTM-xx.js","assets/file-CoTh89vx.js","assets/PreviewTab-oRD3Wntx.js","assets/DiffTab-BuC8qgFb.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{c as fe,r as o,a as Un,f as lo,m as co,j as e,X as ct,Q as qs,B as Z,L as he,S as uo,b as cl,d as F,e as dl,g as ul,h as ml,I as lt,P as hl,C as Nn,i as fl,k as mo,F as pl,l as cn,n as dt,o as Le,D as kn,p as xl,q as gl,t as ce,s as ze,u as Ue,v as Qe,w as $e,x as ho,y as tt,T as bl,z as vl,A as In,E as wl,G as ut,H as mt,J as gt,K as fo,M as po,N as An,O as ar,R as yl,U as Ot,V as jl,W as Hs,Y as Nl,Z as kl,_ as or,$ as xo,a0 as Sl,a1 as Ze,a2 as Cl,a3 as yt,a4 as Ft,a5 as zt,a6 as Ut,a7 as $t,a8 as qt,a9 as Ht,aa as Vt,ab as Kt,ac as ir,ad as Tl,ae as Tt,af as lr,ag as Al,ah as Ir,ai as Vs,aj as ls,ak as El,al as Ml,am as Dl,an as _l,ao as Pl,ap as Il,aq as go,ar as At,as as bo,at as Rl,au as Qn,av as Ll,aw as En,ax as Bl,ay as cr,az as Ol,aA as Fl,aB as zl,aC as vo,aD as dr,aE as wo,aF as Ul,aG as $n,aH as $l,aI as Rr,aJ as ur,aK as mr,aL as ql,aM as Hl,aN as Vl,aO as Kl,aP as yo,aQ as Sn,aR as Gl,aS as Ks,aT as Wl,aU as Ql,aV as Yl,aW as Jl,aX as Lr,aY as Zl,aZ as Xl,a_ as cs,a$ as ec,b0 as Br,b1 as tc,b2 as nc,b3 as sc,b4 as Or,b5 as rc,b6 as ac,b7 as Gs,b8 as oc,b9 as ic,ba as jo,bb as Fr,bc as No,bd as lc,be as zr,bf as cc,bg as dc,bh as uc,bi as mc,bj as hc,bk as fc,bl as Ur,bm as pc,bn as xc,bo as gc,bp as bc,bq as vc,br as wc,bs as yc,bt as jc,bu as Nc,bv as kc,bw as Sc,bx as Cc,by as Tc,bz as Ac,bA as Ec,bB as Mc,bC as Dc,bD as _c,bE as Pc,bF as Ic,bG as Rc,bH as Lc,bI as Bc,bJ as Oc,bK as Fc,bL as zc,bM as Uc}from"./index-BBHpcOD3.js";import{r as $r,e as $c,b as ko,g as So,a as jt,A as Ct,I as hr,c as Co,T as To,d as qc,i as Ao,f as Hc,p as Eo,h as Vc,j as qr,k as Hr,l as Kc,m as Gc,n as Wc,C as Vr,o as ds,q as fr,D as sn,s as it,M as Ws,L as Qc,t as Yc,u as Jc,v as Mo,w as Qs,x as Zc,y as us,z as Xc,B as ed,E as td}from"./DashboardShared-DihTM-xx.js";import{E as nd,M as sd}from"./MarkdownPreviewFrame-CwXixe62.js";import{P as Yn,D as Rn,g as rd,a as ad,b as od}from"./PreviewTab-oRD3Wntx.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 id=[["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"}]],Do=fe("archive",id);/**
|
|
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 ld=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Kr=fe("arrow-right",ld);/**
|
|
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 cd=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],_o=fe("arrow-up",cd);/**
|
|
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 dd=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],Po=fe("at-sign",dd);/**
|
|
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 ud=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]],Io=fe("brain-circuit",ud);/**
|
|
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 md=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],qn=fe("chevron-left",md);/**
|
|
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 hd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],Gr=fe("clock",hd);/**
|
|
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 fd=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],pd=fe("earth",fd);/**
|
|
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 xd=[["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"}]],pr=fe("ellipsis-vertical",xd);/**
|
|
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 gd=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],bd=fe("ellipsis",gd);/**
|
|
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 vd=[["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"}]],Jn=fe("folder-open",vd);/**
|
|
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 wd=[["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"}]],yd=fe("funnel",wd);/**
|
|
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 jd=[["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"}]],Hn=fe("git-branch",jd);/**
|
|
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 Nd=[["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"}]],kd=fe("globe",Nd);/**
|
|
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 Sd=[["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"}]],Vn=fe("history",Sd);/**
|
|
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 Cd=[["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"}]],Ys=fe("image-plus",Cd);/**
|
|
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 Td=[["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"}]],Ad=fe("laptop",Td);/**
|
|
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 Ed=[["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"}]],xr=fe("link-2",Ed);/**
|
|
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 Md=[["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"}]],Dd=fe("list-ordered",Md);/**
|
|
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 _d=[["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"}]],Mn=fe("message-square-plus",_d);/**
|
|
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 Pd=[["path",{d:"M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z",key:"vbtd3f"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]],Ro=fe("monitor-play",Pd);/**
|
|
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 Id=[["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"}]],Wt=fe("pencil",Id);/**
|
|
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 Rd=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],Ld=fe("pin-off",Rd);/**
|
|
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 Bd=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],Lo=fe("pin",Bd);/**
|
|
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 Od=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],Bo=fe("qr-code",Od);/**
|
|
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 Fd=[["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"}]],zd=fe("rotate-ccw",Fd);/**
|
|
133
|
-
* @license lucide-react v1.7.0 - ISC
|
|
134
|
-
*
|
|
135
|
-
* This source code is licensed under the ISC license.
|
|
136
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
137
|
-
*/const Ud=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Oo=fe("rotate-cw",Ud);/**
|
|
138
|
-
* @license lucide-react v1.7.0 - ISC
|
|
139
|
-
*
|
|
140
|
-
* This source code is licensed under the ISC license.
|
|
141
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
142
|
-
*/const $d=[["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"}]],Fo=fe("send",$d);/**
|
|
143
|
-
* @license lucide-react v1.7.0 - ISC
|
|
144
|
-
*
|
|
145
|
-
* This source code is licensed under the ISC license.
|
|
146
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
147
|
-
*/const qd=[["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"}]],Kn=fe("share-2",qd);/**
|
|
148
|
-
* @license lucide-react v1.7.0 - ISC
|
|
149
|
-
*
|
|
150
|
-
* This source code is licensed under the ISC license.
|
|
151
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
152
|
-
*/const Hd=[["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"}]],Vd=fe("sliders-horizontal",Hd);/**
|
|
153
|
-
* @license lucide-react v1.7.0 - ISC
|
|
154
|
-
*
|
|
155
|
-
* This source code is licensed under the ISC license.
|
|
156
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
157
|
-
*/const Kd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Wr=fe("square",Kd);/**
|
|
158
|
-
* @license lucide-react v1.7.0 - ISC
|
|
159
|
-
*
|
|
160
|
-
* This source code is licensed under the ISC license.
|
|
161
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
162
|
-
*/const Gd=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ms=fe("triangle-alert",Gd);/**
|
|
163
|
-
* @license lucide-react v1.7.0 - ISC
|
|
164
|
-
*
|
|
165
|
-
* This source code is licensed under the ISC license.
|
|
166
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
167
|
-
*/const Wd=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Qd=fe("user-plus",Wd);/**
|
|
168
|
-
* @license lucide-react v1.7.0 - ISC
|
|
169
|
-
*
|
|
170
|
-
* This source code is licensed under the ISC license.
|
|
171
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
172
|
-
*/const Yd=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Jd=fe("wifi",Yd);/**
|
|
173
|
-
* @license lucide-react v1.7.0 - ISC
|
|
174
|
-
*
|
|
175
|
-
* This source code is licensed under the ISC license.
|
|
176
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
177
|
-
*/const Zd=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Xd=fe("zoom-in",Zd);/**
|
|
178
|
-
* @license lucide-react v1.7.0 - ISC
|
|
179
|
-
*
|
|
180
|
-
* This source code is licensed under the ISC license.
|
|
181
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
182
|
-
*/const eu=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],tu=fe("zoom-out",eu),nu=new Set(["assigned","running"]);function su(t,n){return t.reduce((s,r)=>r.assignedTo===n&&nu.has(r.status)?s+1:s,0)}function dn(t){return t?.toLowerCase()==="devtunnel"}function ru(t){return t?dn(t)?"DevTunnel":t.charAt(0).toUpperCase()+t.slice(1):"Direct"}function gr(t,n){return dn(n??t.transportType)||!!t.devtunnelEndpoint}function zo(t,n){return!dn(n??t.transportType)}function Uo(t,n){const s=n??t.transportType;return dn(s)?"DevTunnel":t.devtunnelEndpoint?"Direct + DevTunnel":ru(s)}function Qr(t,n){return!t&&!n}function au({routeTaskId:t,creatingTask:n,internalSelectedTaskId:s,sortedTaskIds:r}){return t||(n?null:r[0]??s??null)}function ou({activeTaskId:t,routeTaskId:n,creatingTask:s,tasksLoading:r,loadedTaskIds:a}){return!t||n||s||r?!1:!a.includes(t)}function iu(t,n){return[n,...t.filter(s=>s.id!==n.id)]}function br(t,n){const s=t.findIndex(r=>r.id===n.id);return s===-1?[...t,n]:t.map((r,a)=>a===s?n:r)}const lu=new Set(["completed","failed","cancelled","archived"]);function cu(t,n){const s=new Set(n);return new Set(Array.from(t).filter(r=>s.has(r)))}function du(t,n){const s=new Set(n);if(s.size===0)return!1;const r=t.filter(a=>s.has(a.id));return r.length===s.size&&r.every(a=>lu.has(a.status))}function uu(t,n){const s=new Set(n);return t.find(r=>!s.has(r.id))?.id??null}function $o(){const[t,n]=o.useState([]),[s,r]=o.useState(null),a=o.useRef(null),i=o.useCallback(()=>{a.current?.click()},[]),l=o.useCallback(async x=>{const u=Array.from(x.target.files??[]);if(u.length!==0)try{const h=await $r(u);n(f=>[...f,...h]),r(null)}catch(h){r(h instanceof Error?h.message:"Failed to attach image")}finally{x.target.value=""}},[]),c=o.useCallback(async x=>{const u=$c(x.clipboardData);if(u.length!==0){x.preventDefault();try{const h=await $r(u);n(f=>[...f,...h]),r(null)}catch(h){r(h instanceof Error?h.message:"Failed to attach image")}}},[]),d=o.useCallback(x=>{n(u=>u.filter((h,f)=>f!==x))},[]),m=o.useCallback(()=>{n([]),r(null)},[]);return{images:t,error:s,fileInputRef:a,pickImages:i,handleFileChange:l,handlePaste:c,removeImage:d,clearImages:m}}function mu({disabled:t=!1,running:n=!1,canStop:s=!1,hasContent:r=!1}){return n&&(!r||s&&t)?{primaryAction:"stop",primaryDisabled:!s}:{primaryAction:"send",primaryDisabled:t||!r}}function hu({contentLength:t,disabled:n=!1}){return t>0&&!n}const fu=/^[a-zA-Z0-9_-]+$/,qo=/[a-zA-Z0-9_-]/,pu=176;function xu(t){const n=t.map(a=>({...a,displayValue:gu(a)})),s=n.findIndex(a=>a.label.toLowerCase()==="working dir"),r=s>=0?s:0;return{primary:n[r],secondary:n.filter((a,i)=>i!==r)}}function gu(t){return t.label.toLowerCase()==="agent"?jt(t.value):t.value}function Yr(t){switch(t.toLowerCase()){case"branch":return Hn;case"node":return uo;default:return Jn}}function bu(t){return Array.from(new Set(t.map(n=>n.trim()).filter(Boolean)))}function Ho(t,n){return Number.isFinite(n)?Math.max(0,Math.min(t.length,Math.trunc(n))):t.length}function vu(t,n){const s=Ho(t,n),a=t.slice(0,s).match(/@([a-zA-Z0-9_-]*)$/);if(!a||a.index===void 0)return;const i=a.index+1,l=t.slice(s).match(/^[a-zA-Z0-9_-]*/),c=s+(l?.[0].length??0),d=t.slice(i,c);if(!(d.length>0&&!fu.test(d)))return{query:d.toLowerCase(),range:{start:a.index,end:c}}}function wu(t,n){const s=new Map(n.map(i=>[i.toLowerCase(),i])),r=/@([a-zA-Z0-9_-]+)/g;let a;for(;(a=r.exec(t))!==null;){const i=(a[1]??"").toLowerCase(),l=s.get(i);if(!l)continue;const c=a.index+a[0].length;if(!(c<t.length&&qo.test(t[c]??"")))return{targetAgent:l,query:i,range:{start:a.index,end:c}}}}function Js(t,n){const s=t.slice(0,n.start);let r=t.slice(n.end);return s.length===0?r.trimStart():r.length===0?s.trimEnd():(/\s$/.test(s)&&/^\s/.test(r)?r=r.trimStart():!/\s$/.test(s)&&!/^\s/.test(r)&&(r=" "+r),s+r)}function Jr(t,n,s){const r=bu(n),a=typeof s=="number",i=vu(t,a?s:t.length);if(i){const c=r.filter(x=>x.toLowerCase().startsWith(i.query)),d=r.find(x=>x.toLowerCase()===i.query),m=!!d&&(i.range.end===t.length||!qo.test(t[i.range.end]??""));return{...m?{targetAgent:d}:{},query:i.query,strippedText:m?Js(t,i.range):t,matches:c,...a?{mentionRange:i.range}:{}}}const l=wu(t,r);return l?{targetAgent:l.targetAgent,query:l.query,strippedText:Js(t,l.range),matches:[l.targetAgent],...a?{mentionRange:l.range}:{}}:{strippedText:t,matches:[]}}function yu(t,n,s){if(t.length===0)return 0;const r=n?t.indexOf(n):-1;if(r>=0)return r;const a=s?t.indexOf(s):-1;return a>=0?a:0}function ju(t,n){return t.query!==void 0&&t.matches.length>0&&!t.targetAgent&&!n}function Nu(t,n){if(!n)return{value:t.replace(/^@[a-zA-Z0-9_-]*\s*/,""),cursorPosition:0};const s=Js(t,n);return{value:s,cursorPosition:Math.min(n.start,s.length)}}function ku(t,n){const s=window.getComputedStyle(t);["boxSizing","width","fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent","lineHeight","paddingTop","paddingRight","paddingBottom","paddingLeft","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth"].forEach(a=>{n.style[a]=s[a]})}function Su(t,n){if(typeof window>"u")return;const s=t.ownerDocument,r=s.createElement("div"),a=s.createElement("span"),i=Ho(t.value,n);ku(t,r),r.style.position="absolute",r.style.visibility="hidden",r.style.whiteSpace="pre-wrap",r.style.overflowWrap="break-word",r.style.overflow="hidden",r.style.top="0",r.style.left="-9999px",r.style.height="auto",r.textContent=t.value.slice(0,i),a.textContent="",r.appendChild(a),s.body.appendChild(r);const l={left:a.offsetLeft-t.scrollLeft,top:a.offsetTop-t.scrollTop};return r.remove(),l}function Cu({cardClientWidth:t,cardRectWidth:n}){const s=n/t;return Number.isFinite(s)&&s>0?s:1}function Tu({boundaryRectBottom:t,boundaryRectTop:n,cardRectTop:s,cardWidth:r,caretLeft:a,caretTop:i,cssZoom:l=1,lineHeight:c,matchCount:d,textareaOffsetLeft:m,textareaOffsetTop:x,viewportHeight:u}){const h=Number.isFinite(l)&&l>0?l:1,f=Math.min(Math.max(d,1)*28+4,220),w=f*h,g=m/h,k=x/h,v=n??0,S=t??u,y=Math.max(8,r-pu-8),p=Math.max(8,Math.min(g+a,y)),b=k+i+c+4,N=s+b*h,A=k+i-f-4,I=s+(k+i)*h,E=S-N-8,L=I-v-8,M=Math.max(8,(v-s+8)/h);if(E<w&&L>E)return{left:p,top:Math.max(M,A)};const D=Math.max(M,(S-s-w-8)/h);return{left:p,top:Math.max(M,Math.min(b,D))}}function Au(t,n,s){const r=t.closest('[data-chat-input-card="true"]'),a=Su(t,n);if(!r||!a)return;const i=t.getBoundingClientRect(),l=r.getBoundingClientRect(),c=r.closest(".dashboard-conversation-panel")?.getBoundingClientRect(),d=Number.parseFloat(window.getComputedStyle(t).lineHeight)||18;return Tu({boundaryRectBottom:c?.bottom,boundaryRectTop:c?.top,cardRectTop:l.top,cardWidth:r.clientWidth,caretLeft:a.left,caretTop:a.top,cssZoom:Cu({cardRectWidth:l.width,cardClientWidth:r.clientWidth}),lineHeight:d,matchCount:s,textareaOffsetLeft:i.left-l.left,textareaOffsetTop:i.top-l.top,viewportHeight:window.innerHeight})}function Eu({onSend:t,disabled:n,disabledReason:s="Chat is waiting on the agent.",placeholder:r="Send a follow-up message...",contextItems:a=[],agent:i,currentAgent:l,taskId:c,model:d,availableAgents:m=[],selectedTargetAgent:x,onTargetAgentChange:u,running:h=!1,onStop:f,quickChats:w=[]}){const[g,k]=o.useState(""),[v,S]=o.useState(),[y,p]=o.useState(c),[b,N]=o.useState(),[A,I]=o.useState(),[E,L]=o.useState(!1),[M,D]=o.useState(0),[P,B]=o.useState(0),[Q,te]=o.useState(0),Y=o.useRef(null),H=o.useRef(void 0),{images:ne,error:$,fileInputRef:X,pickImages:j,handleFileChange:W,handlePaste:T,removeImage:ee,clearImages:R}=$o();c!==y&&(p(c),S(void 0));const V=o.useCallback((G=Y.current)=>{G&&D(G.selectionStart??G.value.length)},[]),O=o.useCallback((G=M,ge=1)=>{Y.current&&I(Au(Y.current,G,ge))},[M]),le=o.useCallback(()=>{Y.current&&(Y.current.style.height="auto")},[]),ie=o.useCallback(()=>{Y.current&&(Y.current.style.height="auto",Y.current.style.height=Math.min(Y.current.scrollHeight,220).toString()+"px",V(Y.current))},[V]);o.useEffect(()=>{B(0)},[g,w]);const ue=x??v,J=o.useMemo(()=>Jr(g,m,M),[m,M,g]),K=ju(J,E),_=yu(J.matches,b,l),se=J.matches[_];o.useEffect(()=>{N(void 0),L(!1)},[l,J.query,J.matches.join("|")]),o.useEffect(()=>{if(!K){I(void 0);return}const G=J.mentionRange?.end??M,ge=()=>O(G,J.matches.length);if(typeof requestAnimationFrame!="function"){ge();return}const be=requestAnimationFrame(ge);return()=>cancelAnimationFrame(be)},[J.matches.length,J.mentionRange?.end,M,K,O]);const q=o.useCallback(G=>{u?u(G):S(G)},[u]),ae=o.useCallback(G=>{k(G.prompt);const ge=()=>{Y.current?.focus(),ie()};typeof requestAnimationFrame=="function"?requestAnimationFrame(ge):ge()},[ie]),ye=o.useCallback(()=>{const G=Un(g,w,P);if(G){ae(G);return}const ge=Jr(g,m,M),be=ge.targetAgent??ue,Xe=ge.targetAgent?ge.strippedText:g,De=ko(Xe,ne);hu({contentLength:De.length,disabled:n})&&(te(nt=>nt+1),t(De,be?{targetAgent:be}:void 0),k(""),q(void 0),R(),le())},[g,ne,m,M,ue,n,t,q,R,le,w,P,ae]),pe=o.useCallback((G,ge=J.mentionRange)=>{q(G),k(Xe=>{const De=Nu(Xe,ge);return H.current=De.cursorPosition,D(De.cursorPosition),De.value});const be=()=>{Y.current?.focus(),H.current!==void 0&&(Y.current?.setSelectionRange(H.current,H.current),H.current=void 0),ie()};typeof requestAnimationFrame=="function"?requestAnimationFrame(be):be()},[ie,J.mentionRange,q]),Ye=o.useCallback(G=>{if(K&&G.key==="Escape"){G.preventDefault(),L(!0);return}if(K&&(G.key==="ArrowDown"||G.key==="ArrowUp")){G.preventDefault();const be=J.matches.length;if(be===0)return;const Xe=G.key==="ArrowDown"?1:-1,De=(_+Xe+be)%be;N(J.matches[De]);return}if(K&&G.key==="Enter"&&!G.shiftKey&&se){G.preventDefault(),pe(se,J.mentionRange);return}const ge=lo(g,w);if(ge.length>0&&(G.key==="ArrowDown"||G.key==="ArrowUp")){G.preventDefault(),B(be=>co(be,ge.length,G.key==="ArrowDown"?1:-1));return}if(G.key==="Enter"&&!G.shiftKey){G.preventDefault();const be=Un(g,w,P);be?ae(be):ye()}},[pe,ae,ye,J.matches,J.mentionRange,w,P,se,_,K,g]),Te=g.trim().length>0||ne.length>0,Ie=mu({disabled:n,running:h,canStop:h&&!!f,hasContent:Te}),Me=xu(a),qe=Me.primary?Yr(Me.primary.label):Jn,He=i?So(i,d):null,je=l?jt(l):null,Re=n?s:h?Te?"Enter queues this message for the next turn":f?"Task is running - type to queue, empty button stops task":"Task is running - type to queue a message":"Enter sends, Shift+Enter adds a line";return e.jsx("div",{"data-chat-input-shell":"true",className:"chat-input-shell animate-composer-settle w-full bg-background/35 px-2 pb-2 pt-0 sm:px-4 sm:pb-3",children:e.jsx("div",{"data-chat-input-column":"true",className:"mx-auto w-full max-w-[72rem]",children:e.jsxs("div",{"data-chat-input-card":"true",className:"chat-input-card relative overflow-visible rounded-xl border border-border/65 bg-card/88 transition-[border-color,box-shadow] duration-200 focus-within:border-primary/50 focus-within:ring-2 focus-within:ring-primary/15 sm:rounded-xl",children:[e.jsx("input",{ref:X,type:"file",accept:"image/*",multiple:!0,onChange:W,className:"hidden"}),l&&je&&e.jsxs("span",{"data-current-agent":l,title:`Active agent: ${je}`,className:"absolute right-2 top-1.5 z-10 inline-flex h-4 max-w-[8.5rem] items-center gap-1 rounded-sm bg-primary/12 px-1.5 text-[8px] font-medium leading-3 text-primary sm:right-4 sm:top-2",children:[e.jsx(Ct,{agent:l,className:"h-2.5 w-2.5 shrink-0 text-primary/75"}),e.jsx("span",{className:"truncate",children:je})]}),Me.primary&&e.jsx("div",{"data-chat-input-primary-context":"true",className:`px-2.5 pt-1.5 sm:px-5 sm:pt-2 ${l?"pr-24 sm:pr-32":""}`,children:e.jsxs("div",{className:"-ml-1.5 inline-flex max-w-full items-center gap-1.5 rounded-sm bg-muted/45 px-1.5 py-0.5 shadow-[0_10px_28px_-18px_rgba(15,23,42,0.72)] sm:-ml-2 dark:shadow-[0_10px_28px_-18px_rgba(0,0,0,0.95)]",children:[e.jsx(qe,{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:Me.primary.value,children:Me.primary.displayValue})]})}),ne.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:ne.map((G,ge)=>e.jsxs("div",{className:"relative",children:[e.jsx(hr,{image:G,alt:G.filename??`attachment ${ge+1}`,thumbnailClassName:"h-24 w-24 border border-border/70",imageClassName:"h-full w-full"}),e.jsx("button",{type:"button",onClick:()=>ee(ge),className:"absolute -right-1.5 -top-1.5 flex h-5 w-5 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 ${G.filename??`image ${ge+1}`}`,children:e.jsx(ct,{className:"h-3 w-3"})})]},`${G.filename??"image"}-${ge}`))})}),e.jsx("div",{className:"px-2 pb-0 pt-1 sm:px-5 sm:pt-1.5",children:e.jsx("textarea",{ref:Y,"data-chat-input-textarea":"true",value:g,onChange:G=>{k(G.target.value),V(G.currentTarget)},onKeyDown:Ye,onKeyUp:G=>V(G.currentTarget),onClick:G=>V(G.currentTarget),onSelect:G=>V(G.currentTarget),onScroll:()=>O(M,J.matches.length),onPaste:T,onInput:ie,placeholder:r,disabled:n,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.jsx(qs,{query:g,quickChats:w,selectedIndex:P,onActiveIndexChange:B,onSelect:ae}),K&&e.jsx("div",{"data-agent-mention-menu":"true",className:"absolute z-20 flex w-44 max-w-[calc(100%-1rem)] flex-col overflow-hidden rounded-sm border border-border/60 bg-popover/95 p-0.5 text-popover-foreground shadow-[0_16px_42px_-24px_rgba(0,0,0,0.85)]",style:A?{left:A.left,top:A.top}:{left:8,top:"50%"},children:J.matches.map((G,ge)=>e.jsxs("button",{type:"button",onMouseDown:be=>be.preventDefault(),onMouseEnter:()=>N(G),onClick:()=>pe(G,J.mentionRange),className:["flex h-7 w-full items-center gap-1.5 rounded-sm px-1.5 text-left text-[10px] transition-colors hover:bg-muted/55 hover:text-foreground",ge===_?"bg-primary/10 text-primary":"text-muted-foreground"].join(" "),children:[e.jsx(Ct,{agent:G,className:"h-3 w-3 shrink-0 text-primary/60"}),e.jsx("span",{className:"truncate",children:jt(G)})]},G))}),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:[ue||Me.secondary.length>0?e.jsxs("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:[ue&&e.jsxs("span",{"data-chat-input-target-agent":ue,title:`Send to ${jt(ue)}`,className:"inline-flex h-6 max-w-[11rem] items-center gap-1.5 rounded-sm bg-primary/10 px-1.5 text-[10px] leading-3 text-primary",children:[e.jsx(Po,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx(Ct,{agent:ue,className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:jt(ue)}),e.jsx("button",{type:"button",onClick:()=>q(void 0),className:"-mr-0.5 inline-flex h-4 w-4 items-center justify-center rounded-sm text-primary/70 hover:bg-primary/15 hover:text-primary","aria-label":"Clear target agent",children:e.jsx(ct,{className:"h-2.5 w-2.5"})})]}),Me.secondary.map(G=>{const ge=Yr(G.label),be=G.label.toLowerCase()==="agent";return e.jsxs("span",{title:`${G.label}: ${G.value}`,className:"inline-flex min-w-0 max-w-[12rem] items-center gap-1 truncate",children:[be?e.jsx(Ct,{agent:G.value,className:"h-2.5 w-2.5 shrink-0 text-primary/50"}):e.jsx(ge,{"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 ${G.mono?"font-mono":""}`,children:G.displayValue})]},`${G.label}:${G.value}`)})]}):e.jsx("div",{className:"min-w-0 flex-1"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[He&&e.jsxs("span",{"data-chat-input-model-display":"true","aria-label":`Model: ${He}`,title:`Model: ${He}`,className:"inline-flex h-7 max-w-[9rem] shrink-0 items-center gap-1.5 truncate rounded-sm px-2 text-[10px] text-muted-foreground",children:[e.jsx(Io,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),He]}),e.jsxs(Z,{type:"button",variant:"ghost",onClick:j,disabled:n,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(Ys,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Images"})]}),e.jsx("span",{title:Re,children:e.jsx(Z,{onClick:Ie.primaryAction==="stop"?f:ye,disabled:Ie.primaryDisabled,size:"icon","data-chat-send-button":"true","aria-label":Ie.primaryAction==="stop"?"Stop running task":h?"Queue message":"Send message",className:"chat-send-button h-7 w-9 shrink-0 rounded-sm bg-primary/90 text-primary-foreground shadow-[0_12px_30px_-18px_hsl(var(--primary)/0.95)] transition-transform duration-150 hover:bg-primary active:scale-95",children:Ie.primaryAction==="stop"?e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Fo,{className:`h-3.5 w-3.5 ${Q>0?"animate-chat-send-flight":""}`},Q)})})]})]}),$&&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:$})]})})})}var Mu=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Du=Mu.reduce((t,n)=>{const s=cl(`Primitive.${n}`),r=o.forwardRef((a,i)=>{const{asChild:l,...c}=a,d=l?s:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(d,{...c,ref:i})});return r.displayName=`Primitive.${n}`,{...t,[n]:r}},{}),_u="Label",Vo=o.forwardRef((t,n)=>e.jsx(Du.label,{...t,ref:n,onMouseDown:s=>{s.target.closest("button, input, select, textarea")||(t.onMouseDown?.(s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));Vo.displayName=_u;var Ko=Vo;const Pu=dl("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),et=o.forwardRef(({className:t,...n},s)=>e.jsx(Ko,{ref:s,className:F(Pu(),t),...n}));et.displayName=Ko.displayName;function Zr({agent:t,query:n,onSelect:s}){const r=Co(t,n);return r?e.jsx("div",{"data-codex-goal-command":"true",className:"mx-2 mb-0.5 rounded-sm bg-background/70 p-0.5 shadow-none sm:mx-5",children:e.jsx("div",{role:"listbox","aria-label":"Codex commands",children:e.jsxs("button",{type:"button",role:"option","aria-selected":"true",onClick:s,className:"flex h-8 w-full min-w-0 items-center gap-2 rounded-sm px-2 text-left transition-colors hover:bg-muted/50 hover:text-foreground",children:[e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-primary/10 text-primary",children:e.jsx(To,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx("span",{className:"shrink-0 text-[11px] font-medium text-foreground",children:r.label}),e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:r.description})]})})}):null}function Iu(t,n,s){return t!=="auto"?n.find(r=>r.id===t)??null:s.length===1?s[0]??null:null}function Ru(t){return t.trim()||"."}function Lu(t){return new Promise(n=>window.setTimeout(n,t))}function Bu(t){return!!t&&typeof t=="object"&&typeof t.createdBranch=="string"&&typeof t.currentBranch<"u"}async function Ou(t){let n=t;for(let s=0;s<60;s++){if(n.status==="succeeded"){if(Bu(n.result))return n.result;throw new Error("Branch creation completed without branch details")}if(n.status==="failed")throw new Error(n.error||"Branch creation failed");await Lu(1e3),n=await fl(n.id)}throw new Error("Timed out waiting for branch creation")}function Xr({value:t,onChange:n,project:s,assignTo:r,nodes:a,assignableNodes:i,layout:l="default",chipClassName:c,chipActiveClassName:d,chipInactiveClassName:m,labelClassName:x,triggerClassName:u}){const[h,f]=o.useState(!1),[w,g]=o.useState(null),[k,v]=o.useState(""),[S,y]=o.useState(!1),[p,b]=o.useState(!1),[N,A]=o.useState(!1),[I,E]=o.useState(null),[L,M]=o.useState(""),[D,P]=o.useState(""),[B,Q]=o.useState(""),[te,Y]=o.useState(!1),H=o.useRef(null),ne=o.useRef(0),$=o.useMemo(()=>Iu(r,a,i),[r,a,i]),X=$?.id,j=o.useMemo(()=>Ru(s),[s]),W=o.useMemo(()=>X?`${X}
|
|
183
|
-
${j}`:"",[X,j]),T=o.useCallback(async(J=0,K=!1)=>{const _=ne.current+1,se=W;if(ne.current=_,!X){g(null),v("");return}E(null),K||v(""),K?b(!0):y(!0);try{const q=await ul(X,{path:j,limit:20,offset:J,allowAbsolute:!0});if(_!==ne.current)return;v(se),g(ae=>K&&ae?{...q,branches:[...ae.branches,...q.branches]}:q)}catch(q){if(_!==ne.current)return;E(q instanceof Error?q.message:"Failed to load branch info"),K||(g(null),v(""))}finally{_===ne.current&&(y(!1),b(!1))}},[X,W,j]);o.useEffect(()=>{if(!X){ne.current+=1,g(null),v(""),E(null);return}T()},[X,j,T]),o.useEffect(()=>{const J=t.trim(),K=k===W?w:null,_=K?.available&&K.currentBranch?K.currentBranch:"";J!==_&&n(_)},[w,W,k,n,t]),o.useEffect(()=>{if(!h)return;const J=_=>{H.current&&(H.current.contains(_.target)||f(!1))},K=_=>{_.key==="Escape"&&f(!1)};return document.addEventListener("mousedown",J),document.addEventListener("keydown",K),()=>{document.removeEventListener("mousedown",J),document.removeEventListener("keydown",K)}},[h]),o.useEffect(()=>{h&&(P(""),Q(""),Y(!1))},[h,X,j]);const ee=o.useCallback(async()=>{if(!X)return;const J=L.trim(),K=te?B.trim():D.trim();if(!(!J||!K)){A(!0),E(null);try{const _=await ml(X,{path:j,branchName:J,startPoint:K,limit:20,offset:0,allowAbsolute:!0}),se=await Ou(_);v(W),g(se),n(se.currentBranch??se.createdBranch),M(""),P(""),Q(""),Y(!1),f(!1)}catch(_){E(_ instanceof Error?_.message:"Failed to create branch")}finally{A(!1)}}},[X,W,j,te,B,L,n,D]),R=k===W?w:null,V=o.useCallback(()=>{R?.hasMore&&T(R.branches.length,!0)},[R,T]),O=t.trim()||R?.currentBranch||(R&&!R.available?"No git repo":"Branch"),le=te?B.trim():D.trim(),ie=!!(R?.available&&L.trim()&&le&&!N),ue=l==="composer"?e.jsxs(Z,{type:"button",variant:"ghost",onClick:()=>f(J=>!J),title:O,"aria-label":`Branch: ${O}`,className:F(c,u,"min-w-0 max-w-full",t.trim()?d:m),children:[S&&!R?e.jsx(he,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(Hn,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:F("min-w-0 truncate",x),children:O})]}):e.jsxs(Z,{type:"button",variant:"outline",onClick:()=>f(J=>!J),className:"h-7 w-full justify-between rounded-sm border-border/70 bg-background/70 px-2.5 text-[11px] shadow-none",title:O,children:[e.jsx("span",{className:F("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:O}),e.jsx("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground",children:$?$.name:"Manual"})]});return e.jsxs("div",{className:F("relative inline-block",l==="composer"?"min-w-0 shrink-0":"w-full"),ref:H,children:[l==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(et,{className:"text-[10px] font-medium",children:"Branch"}),ue]}):ue,h&&e.jsxs("div",{className:F("absolute z-50 mt-2 w-[240px] overflow-hidden rounded-sm border border-border/60 bg-background/95 shadow-[0_16px_48px_-34px_rgba(0,0,0,0.45)] backdrop-blur",l==="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(Hn,{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:R?.repoRoot?`${R.currentBranch??O} · ${R.repoRoot}`:R?.currentBranch??O,children:R?.currentBranch??O}),S?e.jsx(he,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}):null]}),$?S&&!R?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(he,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):R&&!R.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(lt,{value:L,onChange:J=>M(J.target.value),placeholder:"New branch name",className:"h-8 flex-1 rounded-sm border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx(Z,{type:"button",size:"sm",onClick:()=>{ee()},disabled:!ie,title:ie?"Create branch":"Enter a name and pick a base","aria-label":"Create branch",className:"h-8 w-8 shrink-0 rounded-sm p-0",children:N?e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(hl,{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"}),!te&&e.jsxs("button",{type:"button",onClick:()=>Y(!0),className:"flex items-center gap-1 rounded-sm px-1 py-0.5 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:[e.jsx(Wt,{className:"h-2.5 w-2.5"}),"Manual"]})]}),te?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(lt,{value:B,onChange:J=>Q(J.target.value),placeholder:"upstream/release/1.0",className:"h-8 flex-1 rounded-sm border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>{Y(!1),Q("")},className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel manual input","aria-label":"Cancel manual input",children:e.jsx(ct,{className:"h-3.5 w-3.5"})})]}):R?.branches.length?e.jsxs("div",{className:"max-h-44 overflow-y-auto rounded-sm border border-border/40 bg-background/40",children:[R.branches.map(J=>{const K=D===J.ref,_=J.branch==="main"||J.branch==="master";return e.jsxs("button",{type:"button",onClick:()=>P(J.ref),className:F("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",K&&"bg-background/70"),title:J.ref,children:[e.jsx("span",{className:F("shrink-0 text-[10px]",_?"text-amber-500 dark:text-amber-400":"text-muted-foreground/60"),"aria-hidden":!0,children:_?"★":"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:J.ref}),K?e.jsx(Nn,{className:"h-3 w-3 shrink-0 text-primary"}):null]},J.ref)}),R.hasMore&&e.jsxs("button",{type:"button",onClick:V,disabled:p,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:[p?e.jsx(he,{className:"h-3 w-3 animate-spin"}):e.jsx(Vn,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"rounded-sm 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."}),I&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-1.5 text-[11px] text-destructive",children:I})]})]})}function Fu({images:t,removeImage:n}){return e.jsx("div",{className:"flex flex-wrap gap-3",children:t.map((s,r)=>e.jsxs("div",{className:"relative",children:[e.jsx(hr,{image:s,alt:s.filename??`attachment ${r+1}`,thumbnailClassName:"h-20 w-20 border border-border/70",imageClassName:"h-full w-full"}),e.jsx("button",{type:"button",onClick:()=>n(r),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 ${s.filename??`image ${r+1}`}`,children:e.jsx(ct,{className:"h-3.5 w-3.5"})})]},`${s.filename??"image"}-${r}`))})}const zu=20,Uu=3,Zs="meshy-working-dir-recents-by-node";function $u(t){return t.startsWith("/")||t.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(t)}function qu(t){const n=t.trim();return n||"."}function Xs(t){const n=[],s=new Set;for(const r of t){const a=r.trim();if(!(!a||s.has(a))&&(s.add(a),n.push(a),n.length===Uu))break}return n}function Hu(t,n){const s=n.trim();return Xs(s?[s,...t]:t)}function Go(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[s,r]of Object.entries(t)){if(!s||!Array.isArray(r))continue;const a=r.filter(l=>typeof l=="string"),i=Xs(a);i.length>0&&(n[s]=i)}return n}function Vu(t,n,s){if(!n)return t;const r=t[n]??[],a=Hu(r,s);if(a.length===0){if(!(n in t))return t;const{[n]:i,...l}=t;return l}return{...t,[n]:a}}function Ku(t,n){return n?t[n]?.[0]??"":""}function Wo(t){if(!t||typeof window>"u")return"";try{const n=window.localStorage.getItem(Zs);return n?Ku(Go(JSON.parse(n)),t):""}catch{return""}}function Gu(t,n,s){return t!=="auto"?n.find(r=>r.id===t)??null:s.length===1?s[0]??null:null}function Wu(t,n){const s=n.trim();return s?$u(s)||!t?s:`${t.replace(/[/\\]+$/,"")}/${s}`:""}function Qu(t,n){return t?t.isAbsolute?t.currentPath:t.currentPath==="."||t.currentPath===""?t.rootPath||n?.workDir||"Node root":t.currentPath:n?.workDir??"Node root"}function Gn({value:t,onChange:n,assignTo:s,nodes:r,assignableNodes:a,layout:i="default",chipClassName:l,chipActiveClassName:c,chipInactiveClassName:d,labelClassName:m,triggerClassName:x,popoverPlacement:u="bottom",popoverAlign:h="start"}){const[f,w]=o.useState(!1),[g,k]=o.useState(null),[v,S]=o.useState(!1),[y,p]=o.useState(!1),[b,N]=o.useState(null),[A,I]=o.useState(""),[E,L]=o.useState(!1),[M,D]=o.useState({}),P=o.useRef(null),B=o.useMemo(()=>Gu(s,r,a),[s,r,a]),Q=B?.id,te=o.useMemo(()=>Q?M[Q]??[]:[],[M,Q]),Y=o.useMemo(()=>t.trim()?Wu(B?.workDir,t):"Use node default",[t,B?.workDir]);o.useEffect(()=>{if(!(typeof window>"u"))try{const O=window.localStorage.getItem(Zs);if(!O)return;const le=JSON.parse(O);D(Go(le))}catch{}},[]);const H=o.useCallback(O=>{Q&&D(le=>{const ie=Vu(le,Q,O);if(ie===le)return le;if(typeof window<"u")try{window.localStorage.setItem(Zs,JSON.stringify(ie))}catch{}return ie})},[Q]),ne=o.useCallback((O,le=!0)=>{const ie=O.trim();n(ie),le&&ie&&H(ie),w(!1)},[n,H]),$=o.useCallback(async(O,le=0,ie=!1)=>{if(Q){N(null),ie?p(!0):S(!0);try{const ue=await mo(Q,{path:O,limit:zu,offset:le,directoriesOnly:!0,allowAbsolute:!0});k(J=>ie&&J?{...ue,entries:[...J.entries,...ue.entries]}:ue)}catch(ue){N(ue instanceof Error?ue.message:"Failed to browse directories"),ie||k(null)}finally{S(!1),p(!1)}}},[Q]),X=o.useRef(t);X.current=t;const j=o.useRef($);j.current=$,o.useEffect(()=>{if(!f)return;const O=X.current;I(O),L(!1),k(null),N(null),Q&&j.current(qu(O))},[f,Q]),o.useEffect(()=>{if(!f)return;const O=ie=>{P.current&&(P.current.contains(ie.target)||w(!1))},le=ie=>{ie.key==="Escape"&&w(!1)};return document.addEventListener("mousedown",O),document.addEventListener("keydown",le),()=>{document.removeEventListener("mousedown",O),document.removeEventListener("keydown",le)}},[f]);const W=o.useCallback(O=>{$(O)},[$]),T=o.useCallback(()=>{g&&$(g.currentPath,g.entries.length,!0)},[g,$]),ee=i==="composer"?e.jsxs(Z,{type:"button",variant:"ghost",onClick:()=>w(O=>!O),title:Y,"aria-label":`Working directory: ${Y}`,className:F(l,x,"min-w-0 max-w-full",t.trim()?c:d),children:[e.jsx(pl,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:F("min-w-0 truncate",m),children:Y})]}):e.jsxs(Z,{type:"button",variant:"outline",onClick:()=>w(O=>!O),className:"h-7 w-full justify-between rounded-sm border-border/70 bg-background/70 px-2.5 text-[11px] shadow-none",title:Y,children:[e.jsx("span",{className:F("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:Y}),e.jsx("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground",children:B?B.name:"Manual"})]}),R=Qu(g,B),V=!!g?.parentPath;return e.jsxs("div",{className:F("relative inline-block",i==="composer"?"min-w-0 max-w-[60%] shrink":"w-full"),"data-workdir-popover-placement":u,"data-workdir-popover-align":h,ref:P,children:[i==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(et,{className:"text-[10px] font-medium",children:"Working directory"}),ee]}):ee,f&&e.jsxs("div",{className:F("absolute z-50 flex max-h-[min(28rem,calc(100vh-5rem))] w-[240px] flex-col overflow-hidden rounded-sm border border-border/60 bg-background/95 shadow-[0_16px_48px_-34px_rgba(0,0,0,0.45)] backdrop-blur",u==="top"?"bottom-full mb-2":"top-full mt-2",i==="composer"?h==="end"?"right-0":"left-0":h==="end"?"right-0 w-auto min-w-[240px]":"left-0 right-0 w-auto min-w-[240px]"),children:[te.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(Vn,{className:"h-2.5 w-2.5"}),"Recent"]}),e.jsx("div",{className:"flex flex-col",children:te.map(O=>e.jsx("button",{type:"button",onClick:()=>ne(O),className:"truncate rounded-sm px-1.5 py-0.5 text-left font-mono text-[11px] text-foreground hover:bg-background/60",title:O,children:O},O))})]}),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:()=>g?.parentPath&&W(g.parentPath),disabled:!V||v,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-sm 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(_o,{className:"h-3 w-3"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:R,children:R}),g&&e.jsx("button",{type:"button",onClick:()=>ne(g.isAbsolute?g.currentPath:g.currentPath==="."?"":g.currentPath),className:"shrink-0 rounded-sm 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:[B?v?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(he,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):g&&g.entries.length>0?e.jsxs(e.Fragment,{children:[g.entries.map(O=>e.jsxs("div",{className:"group flex items-stretch border-b border-border/30 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>ne(O.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 ${O.path}`,children:[e.jsx(cn,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[11px] text-foreground",children:O.name})]}),e.jsx("button",{type:"button",onClick:()=>W(O.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 ${O.name}`,children:e.jsx(dt,{className:"h-3.5 w-3.5"})})]},O.path)),g.hasMore&&e.jsxs("button",{type:"button",onClick:T,disabled:y,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:[y?e.jsx(he,{className:"h-3 w-3 animate-spin"}):e.jsx(Vn,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:b??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a node to browse."}),b&&g&&g.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[11px] text-destructive",children:b})]}),e.jsx("div",{className:"flex items-center gap-1 border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:E?e.jsxs(e.Fragment,{children:[e.jsx(lt,{value:A,onChange:O=>I(O.target.value),onKeyDown:O=>{O.key==="Enter"&&A.trim()?(O.preventDefault(),ne(A)):O.key==="Escape"&&(O.preventDefault(),L(!1),I(t))},autoFocus:!0,placeholder:"Path (relative or absolute)",className:"h-7 flex-1 rounded-sm border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>ne(A),disabled:!A.trim(),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-sm text-foreground hover:bg-background/60 disabled:opacity-40",title:"Apply","aria-label":"Apply manual path",children:e.jsx(Nn,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{L(!1),I(t)},className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel","aria-label":"Cancel manual path",children:e.jsx(ct,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>{I(t),L(!0)},className:"flex h-7 flex-1 items-center justify-between rounded-sm 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(Wt,{className:"h-3 w-3"})]})})]})]})}function Qo(t,n={}){const s=t.filter(r=>r.status==="online");return n.currentNodeRole!=="follower"||!n.leaderNodeId?s:s.filter(r=>r.id!==n.leaderNodeId)}function vr({isCurrent:t}){return t?e.jsx(Ad,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):e.jsx(kd,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function er(t,n){return t.map(s=>{const r=!!n&&s.id===n;return e.jsx(Le,{value:s.id,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(vr,{isCurrent:r}),e.jsx("span",{className:"truncate",children:s.name}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:r?"current":"remote"})]})},s.id)})}function Yu(t){const n=t.sessionId.trim(),s=t.cwd.trim();return!n||!s||!t.assignTo?null:{title:t.title.trim()||t.defaultTitle?.trim()||void 0,agent:t.agent,sessionId:n,cwd:s,assignTo:t.assignTo,priority:t.priority,mode:t.mode??kn}}function Ju(){return bl.map(t=>e.jsx(Le,{value:t.value,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:t.label}),t.description&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:t.description})]})},t.value))}function Zu(t){if(!t)return"unknown time";const n=Date.parse(t);return Number.isNaN(n)?t:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(n)}function ea(t){if(!t.updatedAt)return 0;const n=Date.parse(t.updatedAt);return Number.isNaN(n)?0:n}function Xu(t,n){return ea(n)-ea(t)||t.sessionId.localeCompare(n.sessionId)}function em(t){const n=t.trim().replace(/[\\/]+$/,"");return n?n.split(/[\\/]+/).filter(Boolean).at(-1)??n:"Unknown project"}function tm(t){const n=new Map;for(const s of[...t].sort(Xu)){const r=n.get(s.cwd);if(r){r.push(s);continue}n.set(s.cwd,[s])}return Array.from(n.entries()).map(([s,r])=>({folderName:em(s),cwd:s,sessions:r}))}function nm(t,n){const s=new Set(t);return s.has(n)?s.delete(n):s.add(n),s}function sm({nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,onCreated:a,onCancel:i,className:l,footerClassName:c,submitLabel:d="Load session",cancelLabel:m="Cancel",autoFocus:x=!1}){const u=o.useMemo(()=>Qo(t,{currentNodeRole:n,leaderNodeId:r}),[t,n,r]),h=o.useMemo(()=>s&&u.some(_=>_.id===s)?s:u[0]?.id??"",[u,s]),[f,w]=o.useState(""),[g,k]=o.useState("codex"),[v,S]=o.useState(""),[y,p]=o.useState(""),[b,N]=o.useState(""),[A,I]=o.useState(h),[E,L]=o.useState(kn),[M,D]=o.useState(!1),[P,B]=o.useState([]),[Q,te]=o.useState(!1),[Y,H]=o.useState(null),ne=o.useMemo(()=>P.find(_=>_.sessionId===v)??null,[P,v]);o.useEffect(()=>{A&&u.some(_=>_.id===A)||I(h)},[A,u,h]),o.useEffect(()=>{S(""),p(""),N("")},[g,A]),o.useEffect(()=>{let _=!1;return A?(te(!0),H(null),xl(A,{agent:g,limit:50}).then(se=>{_||B(se.sessions)}).catch(se=>{_||(B([]),H(se instanceof Error?se.message:"Failed to load native sessions"))}).finally(()=>{_||te(!1)}),()=>{_=!0}):(B([]),H(null),te(!1),()=>{_=!0})},[g,A]),o.useEffect(()=>{ne&&(p(ne.sessionId),N(ne.cwd))},[ne]);const $=o.useCallback(async _=>{_.preventDefault();const se=Yu({title:f,defaultTitle:ne?.summary,agent:g,sessionId:y,cwd:b,assignTo:A,priority:"normal",mode:E});if(se){D(!0);try{const q=await gl(se);a(q)}catch(q){ce.error(q instanceof Error?q.message:"Failed to load native session")}finally{D(!1)}}},[f,ne,g,y,b,A,E,a]),X=!!(y.trim()&&b.trim()&&A),[j,W]=o.useState(!1),[T,ee]=o.useState(""),[R,V]=o.useState(()=>new Set),O=u.find(_=>_.id===A)??null,le=!!(s&&O?.id===s),ie=o.useMemo(()=>{const _=T.trim().toLowerCase();return _?P.filter(se=>se.summary.toLowerCase().includes(_)||se.sessionId.toLowerCase().includes(_)||se.cwd.toLowerCase().includes(_)):P},[P,T]),ue=o.useMemo(()=>tm(ie),[ie]),J=o.useCallback(_=>{V(se=>nm(se,_))},[]),K="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:$,className:F("space-y-4",l),children:[e.jsxs("div",{className:"rounded-sm border border-border/60 bg-background/54 shadow-none backdrop-blur-xl",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/50 px-3 py-2.5",children:[e.jsxs(ze,{value:A,onValueChange:I,children:[e.jsx(Ue,{className:F(K),"aria-label":"Node",children:O?e.jsxs(e.Fragment,{children:[e.jsx(vr,{isCurrent:le}),e.jsx("span",{className:"max-w-[10rem] truncate",children:O.name})]}):e.jsx(Qe,{placeholder:"Node"})}),e.jsx($e,{children:er(u,s)})]}),e.jsxs(ze,{value:g,onValueChange:_=>k(_),children:[e.jsxs(Ue,{className:F(K),"aria-label":"Agent",children:[e.jsx(Ct,{agent:g}),e.jsx("span",{children:g})]}),e.jsx($e,{children:qc()})]}),e.jsxs("div",{className:"relative ml-auto min-w-0 flex-1 sm:max-w-56",children:[e.jsx(ho,{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(lt,{value:T,onChange:_=>ee(_.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(et,{className:"text-[10px] font-medium uppercase tracking-[0.2em] text-muted-foreground",children:Q?"Loading...":`${ie.length} session${ie.length===1?"":"s"}`})}),e.jsxs("div",{className:"relative h-88 overflow-hidden rounded-sm",children:[Q&&e.jsx("div",{className:"absolute inset-x-0 top-0 z-10 h-0.5 overflow-hidden bg-primary/10",children:e.jsx("div",{className:"h-full w-1/3 animate-indeterminate-bar bg-primary/70"})}),e.jsxs("div",{className:"h-full space-y-1.5 overflow-y-auto pr-1",children:[!A&&e.jsx("div",{className:"rounded-sm border border-dashed border-border/60 bg-background/35 px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Pick a node to load its recent sessions."}),A&&!Q&&ie.length===0&&e.jsx("div",{className:"rounded-sm border border-dashed border-border/60 bg-background/35 px-3 py-4 text-center text-[11px] text-muted-foreground",children:P.length===0?"No recent sessions on this node. Use Manual session ID under More options.":"No sessions match your filter."}),ue.map(_=>e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>J(_.cwd),"aria-expanded":!R.has(_.cwd),className:"sticky top-0 z-[1] flex w-full items-center gap-2 border-b border-border/50 bg-background/95 px-1 py-1.5 text-left text-[10px] text-muted-foreground backdrop-blur transition-colors hover:bg-background",children:[e.jsx(tt,{className:F("h-3.5 w-3.5 shrink-0 transition-transform",R.has(_.cwd)&&"-rotate-90")}),e.jsx(Jn,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-foreground",children:_.folderName}),e.jsxs("span",{className:"shrink-0 uppercase tracking-[0.16em]",children:[_.sessions.length," session",_.sessions.length===1?"":"s"]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-right font-mono",children:_.cwd})]}),!R.has(_.cwd)&&_.sessions.map(se=>{const q=se.sessionId===v;return e.jsxs("button",{type:"button",onClick:()=>S(se.sessionId),className:F("flex w-full flex-col gap-1 rounded-sm border px-2.5 py-2 text-left transition-colors duration-200",q?"border-primary/45 bg-primary/9 shadow-none":"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:F("h-2 w-2 shrink-0 rounded-full",q?"bg-primary":"bg-border")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",children:se.summary}),e.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:Zu(se.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:se.sessionId.slice(0,12)}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),e.jsx("span",{className:"truncate font-mono",children:se.cwd})]})]},se.sessionId)})]},_.cwd))]})]}),Y&&e.jsx("p",{className:"px-1 pt-2 text-[11px] text-destructive",children:Y})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>W(_=>!_),className:"inline-flex h-6 items-center gap-1.5 rounded-sm px-1.5 text-[10px] font-medium uppercase tracking-[0.16em] text-muted-foreground transition-colors hover:bg-muted/45 hover:text-foreground","aria-expanded":j,children:[e.jsx("span",{className:"shrink-0",children:j?"Less options":"More options"}),e.jsx(tt,{className:F("h-3.5 w-3.5 shrink-0 transition-transform",j&&"rotate-180")})]}),j&&e.jsxs("div",{className:"space-y-2 rounded-sm border border-border/60 bg-background/30 p-2.5",children:[e.jsxs("div",{className:"grid gap-2.5 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(et,{htmlFor:"native-session-id",className:"text-[10px] font-medium text-muted-foreground",children:"Session ID"}),e.jsx(lt,{id:"native-session-id",type:"text",value:y,onChange:_=>{S(""),p(_.target.value)},placeholder:"ses_..., thread_..., or UUID",autoFocus:x,className:"h-7 rounded-sm border-border/70 bg-background/70 font-mono text-[11px] shadow-none"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(et,{htmlFor:"native-session-title",className:"text-[10px] font-medium text-muted-foreground",children:"Task title"}),e.jsx(lt,{id:"native-session-title",type:"text",value:f,onChange:_=>w(_.target.value),placeholder:"Optional",className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px] shadow-none"})]})]}),e.jsx(Gn,{value:b,onChange:_=>{S(""),N(_)},assignTo:A,nodes:t,assignableNodes:u}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(et,{className:"text-[10px] font-medium text-muted-foreground",children:"Mode"}),e.jsxs(ze,{value:E,onValueChange:_=>L(_),children:[e.jsx(Ue,{className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px] shadow-none",children:e.jsx(Qe,{placeholder:"Select mode"})}),e.jsx($e,{children:Ju()})]})]})]})]}),e.jsxs("div",{className:F("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",c),children:[i&&e.jsx(Z,{type:"button",variant:"ghost",onClick:i,className:"rounded-sm",children:m}),e.jsx(Z,{type:"submit",disabled:!X||M,className:"rounded-sm px-5",children:M?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:"h-4 w-4 animate-spin"})," Loading..."]}):d})]})]})}const hs="__agent-default__";function Yo({agent:t,value:n,onChange:s,triggerClassName:r,contentClassName:a="max-h-80",chip:i=!1}){const l=So(t,n);return o.useEffect(()=>{n&&!Ao(t,n)&&s("")},[t,n,s]),e.jsxs(ze,{value:n||hs,onValueChange:c=>s(c===hs?"":c),children:[e.jsx(Ue,{"aria-label":`Model: ${l}`,title:`Model: ${l}`,className:r,children:i?e.jsxs(e.Fragment,{children:[e.jsx(Io,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:l})]}):e.jsx(Qe,{placeholder:"Agent default"})}),e.jsxs($e,{className:a,children:[e.jsx(Le,{value:hs,className:"py-1 text-[11px]",children:"Agent default"}),Hc(t)]})]})}function rm(t){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(et,{className:"text-[11px] font-medium",children:"Model"}),e.jsx(Yo,{...t,triggerClassName:"h-8 rounded-sm border-border/70 bg-background/70"})]})}function Jo(t,n,s=!1){const r=t.trim();if(r)return r;const a=n.trim().split(`
|
|
184
|
-
`).map(i=>i.trim()).find(Boolean);return a?a.length>72?`${a.slice(0,69).trimEnd()}...`:a:s?"Image task":""}function am(t){const n=t.title.trim(),s=Eo(t.agent,t.description),r=s.prompt,a=Jo(t.title,r,t.images.length>0),i=r.trim()||a,l=t.mode??kn,c=t.model?.trim(),d=c&&Ao(t.agent,c)?c:"",m=s.isGoal?s.commandPrompt:r,x=ko(m,t.images);return!a||!i||!t.agent?null:{title:a,description:i,agent:t.agent,project:t.project.trim()||null,branch:t.branch?.trim()||null,payload:{initialMessage:x,mode:l,...d?{model:d}:{},...s.isGoal?{goal:!0}:{},titleSource:n?"manual":"derived"},priority:t.priority,assignTo:t.assignTo==="auto"?void 0:t.assignTo}}function om({nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,className:d,footerClassName:m,submitLabel:x="Create chat",cancelLabel:u="Cancel",autoFocus:h=!1,layout:f="default",defaultTaskAgent:w,quickChats:g=[]}){const[k,v]=o.useState(""),[S,y]=o.useState(""),[p,b]=o.useState(0),[N,A]=o.useState(()=>In(w)),I=o.useRef(!1),[E,L]=o.useState(""),[M,D]=o.useState(kn),[P,B]=o.useState(i?.trim()??""),Q=o.useRef(i!==void 0),[te,Y]=o.useState(""),H=o.useMemo(()=>Qo(t,{currentNodeRole:n,leaderNodeId:r}),[t,n,r]),ne=o.useMemo(()=>a&&H.some(re=>re.id===a)?a:s&&H.some(re=>re.id===s)?s:H[0]?.id??"",[H,s,a]),[$,X]=o.useState(ne),[j,W]=o.useState(!1),[T,ee]=o.useState(!1),{images:R,error:V,fileInputRef:O,pickImages:le,handleFileChange:ie,handlePaste:ue,removeImage:J}=$o(),K=o.useRef(null),_=o.useMemo(()=>H.find(re=>re.id===$)??null,[$,H]),se=!!(s&&_?.id===s),q=jt(N),ae=Vc(M),ye=o.useMemo(()=>Eo(N,S),[N,S]),pe=o.useMemo(()=>Co(N,S),[N,S]),Ye=ye.prompt,Te=o.useMemo(()=>ye.isGoal||pe?[]:g,[ye.isGoal,pe,g]);o.useEffect(()=>{$&&H.some(re=>re.id===$)||X(ne)},[$,H,ne]),o.useEffect(()=>{I.current||A(In(w))},[w]);const ht=o.useCallback(re=>{I.current=!0,A(In(re))},[]);o.useEffect(()=>{if(Q.current){Q.current=!1;return}B(Wo($)),Y("")},[$]),o.useEffect(()=>{Y("")},[P]),o.useEffect(()=>{b(0)},[S,g,N]);const Ie=o.useCallback(re=>{y(re.prompt)},[]),Me=o.useCallback(()=>{y(pe?.value??"/goal "),b(0),!(typeof window>"u")&&window.setTimeout(()=>{const re=K.current;re?.focus();const Ne=re?.value.length??0;re?.setSelectionRange(Ne,Ne)},0)},[pe]),qe=o.useCallback(async re=>{if(re.preventDefault(),pe){Me();return}const Ne=Un(S,Te,p);if(Ne){Ie(Ne);return}const Ce=am({title:k,description:S,agent:N,model:E,project:P,branch:te,priority:"normal",assignTo:$,mode:M,images:R});if(Ce){W(!0);try{const ve=await wl(Ce);l(ve)}catch(ve){ce.error(ve instanceof Error?ve.message:"Failed to create task")}finally{W(!1)}}},[k,S,N,E,P,te,$,M,R,l,Te,p,Ie,pe,Me]),He=Jo(k,Ye,R.length>0),je=!pe&&!!(He&&N&&$&&(Ye.trim()||R.length>0)),Re=o.useCallback(re=>{if(re.nativeEvent.isComposing)return;if(pe&&(re.key==="ArrowDown"||re.key==="ArrowUp")){re.preventDefault();return}const Ne=lo(S,Te);if(Ne.length>0&&(re.key==="ArrowDown"||re.key==="ArrowUp")){re.preventDefault(),b(Ce=>co(Ce,Ne.length,re.key==="ArrowDown"?1:-1));return}if(re.key==="Enter"){if(pe&&!re.shiftKey){re.preventDefault(),Me();return}const Ce=Un(S,Te,p);if(Ce&&!re.shiftKey){re.preventDefault(),Ie(Ce);return}}re.key==="Enter"&&(re.ctrlKey||re.metaKey)&&je&&!j&&(re.preventDefault(),re.currentTarget.form?.requestSubmit())},[Me,Ie,Te,je,S,pe,p,j]),G=R.length>0?e.jsx(Fu,{images:R,removeImage:J}):null,ge=e.jsxs("div",{className:"space-y-2",children:[e.jsx(et,{className:"text-[11px] font-medium",children:"Assign to"}),e.jsxs(ze,{value:$,onValueChange:X,children:[e.jsx(Ue,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Qe,{placeholder:"Select node"})}),e.jsx($e,{children:er(H,s)})]})]}),be=e.jsxs("div",{className:"space-y-2",children:[e.jsx(et,{className:"text-[11px] font-medium",children:"Agent"}),e.jsxs(ze,{value:N,onValueChange:ht,children:[e.jsx(Ue,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Qe,{placeholder:"Select agent"})}),e.jsx($e,{children:qr()})]})]}),Xe=e.jsxs("div",{className:"space-y-2",children:[e.jsx(et,{className:"text-[11px] font-medium",children:"Mode"}),e.jsxs(ze,{value:M,onValueChange:re=>D(re),children:[e.jsx(Ue,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Qe,{placeholder:"Select mode"})}),e.jsx($e,{children:Hr()})]})]}),De=e.jsx(Gn,{value:P,onChange:B,assignTo:$,nodes:t,assignableNodes:H}),nt=e.jsx(Xr,{value:te,onChange:Y,project:P,assignTo:$,nodes:t,assignableNodes:H});return f==="composer"?e.jsxs("form",{onSubmit:qe,className:F("space-y-4",d),children:[e.jsx("input",{ref:O,type:"file",accept:"image/*",multiple:!0,onChange:ie,className:"hidden"}),(()=>{const re="chat-composer__chip h-9 min-w-0 w-auto gap-1.5 rounded-sm px-3.5 text-xs shadow-none transition-colors [&>span]:min-w-0",Ne="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",Ce="border-border/70 bg-background/55 text-foreground",ve=N===In(w),st=M===kn;return e.jsxs("div",{className:"chat-composer space-y-2",children:[e.jsxs("div",{className:"chat-composer__card rounded-sm border border-border/60 bg-background/54 shadow-none backdrop-blur-xl",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(ze,{value:$,onValueChange:X,children:[e.jsx(Ue,{className:F(re,Ce,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${_?.name??"unassigned"}`,"aria-label":`Assigned node: ${_?.name??"unassigned"}`,children:_?e.jsxs(e.Fragment,{children:[e.jsx(vr,{isCurrent:se}),e.jsx("span",{className:"min-w-0 truncate",children:_.name}),e.jsx("span",{className:"chat-composer__header-meta shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:se?"current":"remote"})]}):e.jsx(Qe,{placeholder:"Select node"})}),e.jsx($e,{children:er(H,s)})]}),T?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(lt,{id:"task-title-composer",type:"text",value:k,onChange:_e=>v(_e.target.value),onKeyDown:_e=>{(_e.key==="Enter"||_e.key==="Escape")&&(_e.preventDefault(),ee(!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(Z,{type:"button",variant:"ghost",size:"icon",onClick:()=>ee(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(Nn,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>ee(!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:He||"Title","aria-label":He?`Edit title: ${He}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:He||"Title"}),e.jsx(Wt,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",ref:K,value:S,onChange:_e=>y(_e.target.value),onKeyDown:Re,onPaste:ue,placeholder:"Ask anything...",rows:4,autoFocus:h,"aria-label":"Opening prompt",className:"min-h-[140px] w-full resize-none overflow-x-hidden overflow-y-auto rounded-sm bg-transparent px-5 pt-2 pb-2 text-xs leading-5 text-foreground ring-offset-background placeholder:text-muted-foreground/70 focus-visible:outline-none"}),e.jsx(Zr,{agent:N,query:S,onSelect:Me}),e.jsx(qs,{query:S,quickChats:Te,selectedIndex:p,onActiveIndexChange:b,onSelect:Ie}),e.jsxs("div",{className:"chat-composer__rail flex min-w-0 flex-nowrap items-center gap-2 px-3 pb-3",children:[e.jsx(Z,{type:"button",variant:"ghost",size:"icon",onClick:le,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(Ys,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsxs(ze,{value:N,onValueChange:ht,children:[e.jsxs(Ue,{className:F(re,"chat-composer__icon-trigger",ve?Ne:Ce),title:`Agent: ${q}`,"aria-label":`Agent: ${q}`,children:[e.jsx(Ct,{agent:N}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:q})]}),e.jsx($e,{children:qr()})]}),e.jsx(Yo,{agent:N,value:E,onChange:L,chip:!0,triggerClassName:F(re,"chat-composer__icon-trigger",E?Ce:Ne),contentClassName:"max-h-80 shadow-none"}),e.jsxs(ze,{value:M,onValueChange:_e=>D(_e),children:[e.jsxs(Ue,{className:F(re,"chat-composer__icon-trigger",st?Ne:Ce),title:`Mode: ${ae}`,"aria-label":`Mode: ${ae}`,children:[e.jsx(Vd,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:ae})]}),e.jsx($e,{children:Hr()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[c&&e.jsxs(Z,{type:"button",variant:"ghost",size:"sm",onClick:c,"aria-label":u,className:"chat-composer__cancel h-9 rounded-sm px-4 text-xs text-muted-foreground",children:[e.jsx(ct,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:u})]}),e.jsxs(Z,{type:"submit",size:"icon",disabled:!je||j,className:"h-10 w-10 rounded-sm shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[j?e.jsx(he,{className:"h-4 w-4 animate-spin"}):e.jsx(Fo,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:j?"Creating chat":x})]})]})]})]}),e.jsx("div",{className:"chat-composer__location flex flex-wrap items-center gap-2 px-1",children:(()=>{const _e="border-border/40 bg-muted/40 text-foreground/80 hover:bg-muted/60 hover:text-foreground";return e.jsxs(e.Fragment,{children:[e.jsx(Gn,{value:P,onChange:B,assignTo:$,nodes:t,assignableNodes:H,layout:"composer",chipClassName:re,chipActiveClassName:_e,chipInactiveClassName:_e,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"}),e.jsx(Xr,{value:te,onChange:Y,project:P,assignTo:$,nodes:t,assignableNodes:H,layout:"composer",chipClassName:re,chipActiveClassName:_e,chipInactiveClassName:_e,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"})]})})()})]})})(),(G||V)&&e.jsxs("div",{className:"space-y-2 rounded-sm border border-border/60 bg-background/45 p-2.5",children:[G,V&&e.jsx("div",{className:"text-[11px] text-destructive",children:V}),!V&&e.jsx("div",{className:"text-[11px] 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:qe,className:F("space-y-4",d),children:[e.jsx("input",{ref:O,type:"file",accept:"image/*",multiple:!0,onChange:ie,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(et,{htmlFor:"task-description",className:"text-[11px] font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",ref:K,value:S,onChange:re=>y(re.target.value),onKeyDown:Re,onPaste:ue,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:h,className:"flex min-h-[128px] w-full resize-none overflow-x-hidden overflow-y-auto rounded-sm border border-border/70 bg-background/70 px-3 py-2 text-xs leading-5 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.jsx(Zr,{agent:N,query:S,onSelect:Me}),e.jsx(qs,{query:S,quickChats:Te,selectedIndex:p,onActiveIndexChange:b,onSelect:Ie}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(Z,{type:"button",variant:"outline",onClick:le,className:"rounded-sm",children:[e.jsx(Ys,{className:"h-4 w-4"}),"Add images"]}),e.jsx("p",{className:"text-[11px] 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,V&&e.jsx("p",{className:"text-[11px] text-destructive",children:V})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_170px_190px_150px]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(et,{htmlFor:"task-title",className:"text-[11px] font-medium",children:"Chat title"}),e.jsx(lt,{id:"task-title",type:"text",value:k,onChange:re=>v(re.target.value),placeholder:"Optional. Leave blank to derive it from the prompt.",className:"h-8 rounded-sm border-border/70 bg-background/70"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:He?`Will appear as: ${He}`:"A title will be generated from the first line of the prompt."})]}),be,e.jsx(rm,{agent:N,value:E,onChange:L}),Xe]}),De,nt,ge,e.jsxs("div",{className:F("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",m),children:[c&&e.jsx(Z,{type:"button",variant:"ghost",onClick:c,className:"rounded-sm",children:u}),e.jsx(Z,{type:"submit",disabled:!je||j,className:"rounded-sm px-5",children:j?"Creating...":x})]})]})}function im({nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,defaultMode:d="chat",mode:m,onModeChange:x,layout:u="default",className:h,footerClassName:f,autoFocus:w=!1,quickChats:g=[],defaultTaskAgent:k}){const[v,S]=o.useState(d),y=m!==void 0,p=y?m:v,b=N=>{y||S(N),x?.(N)};return e.jsxs("div",{className:F("space-y-4",h),children:[!y&&e.jsxs("div",{className:"flex h-8 items-center gap-0.5 rounded-sm border border-border/60 bg-background/45 p-0.5",children:[e.jsxs(Z,{type:"button",variant:p==="chat"?"default":"ghost",onClick:()=>b("chat"),className:"h-7 flex-1 rounded-sm shadow-none",children:[e.jsx(vl,{className:"h-4 w-4"}),"New chat"]}),e.jsxs(Z,{type:"button",variant:p==="native"?"default":"ghost",onClick:()=>b("native"),className:"h-7 flex-1 rounded-sm shadow-none",children:[e.jsx(xr,{className:"h-4 w-4"}),"Load session"]})]}),p==="chat"?e.jsx(om,{nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,footerClassName:f,submitLabel:u==="composer"?"Start chat":"Create chat",cancelLabel:"Cancel",autoFocus:w,layout:u,defaultTaskAgent:k,quickChats:g},`${a??""}:${i??""}`):e.jsx(sm,{nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,onCreated:l,onCancel:c,footerClassName:f,autoFocus:w})]})}function lm({onClick:t,running:n}){return e.jsxs(Z,{size:"icon",onClick:t,"aria-label":n?"Open composer - task running":"Open composer",title:n?"Task running - open composer":"Open composer",className:F("absolute bottom-4 right-4 z-10 h-12 w-12 overflow-visible rounded-lg shadow-lg",n&&"animate-soft-status-pulse bg-primary/90 text-primary-foreground hover:bg-primary"),children:[e.jsx(Wt,{className:"h-4 w-4"}),n&&e.jsx("span",{"aria-hidden":"true","data-running-indicator":"true",className:"pointer-events-none absolute right-1.5 top-1.5 h-2 w-2 rounded-full bg-primary-foreground shadow-[0_0_0_2px_hsl(var(--primary))]"})]})}function ta({children:t}){return e.jsxs("div",{className:"agent-progress-banner animate-message-receive flex items-center gap-1.5 rounded-lg bg-transparent px-1 py-1 text-[11px]",children:[e.jsx("span",{className:"agent-progress-terminal-spinner h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsx("div",{className:"agent-progress-sweep-text min-w-0 leading-5",children:t})]})}function cm({hasVisibleTranscriptEvents:t,hasTranscriptProgress:n,inputCollapsed:s}){return{collapsedButtonRunning:n&&t&&s,showDockedProgress:n&&t&&!s,showInlineProgress:n&&!t}}const an="72f988bf-86f1-41af-91ab-2d7cd011db47",Zo=`${an} (MSIT)`;function dm({open:t,onOpenChange:n,onShare:s,onStopShare:r,sharing:a,stopping:i=!1,shareResult:l}){return e.jsx(ut,{open:t,onOpenChange:n,children:e.jsxs(mt,{className:"max-w-md rounded-sm p-4",children:[e.jsx(gt,{className:"sr-only",children:"Share conversation"}),e.jsx(um,{onOpenChange:n,onShare:s,onStopShare:r,sharing:a,stopping:i,shareResult:l})]})})}function um({onOpenChange:t,onShare:n,onStopShare:s,sharing:r,stopping:a=!1,shareResult:i}){const[l,c]=o.useState(i?.tenant??an),[d,m]=o.useState(i?.scope??"chat"),x=i?.url?fo(i.url):null,u=r||a;return o.useEffect(()=>{c(i?.tenant??an),m(i?.scope??"chat")},[i?.shareId,i?.tenant,i?.scope]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h2",{className:"text-sm 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(mm,{value:l,onChange:c,disabled:u}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Access"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(na,{active:d==="chat",title:"Chat only",description:"Conversation transcript and opening prompt.",onClick:()=>m("chat")}),e.jsx(na,{active:d==="filesPreview",title:"Chat, files and preview",description:"Transcript plus task output files and HTML preview.",onClick:()=>m("filesPreview")})]})]}),x&&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:x,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none","aria-label":"Shared link"}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-sm text-muted-foreground",onClick:()=>{An(x,"Shared link copied")},"aria-label":"Copy shared link",title:"Copy shared link",children:e.jsx(po,{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(Z,{variant:"outline",onClick:()=>t(!1),disabled:u,className:"h-8 text-xs",children:i?"Done":"Cancel"}),i&&s&&e.jsxs(Z,{variant:"outline",onClick:()=>{s()},disabled:u,className:"h-8 border-destructive/30 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive",children:[a&&e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),"Stop share"]}),e.jsxs(Z,{onClick:()=>{n({tenant:l,scope:d})},disabled:u,className:"h-8 text-xs",children:[r&&e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),i?"Update link":"Share link"]})]})]})}function mm({value:t,onChange:n,disabled:s}){const[r,a]=o.useState(!1),[i,l]=o.useState(!1),[c,d]=o.useState(t),m=o.useRef(null);o.useEffect(()=>{d(t)},[t]),o.useEffect(()=>{if(!r)return;const u=f=>{const w=f.target;w instanceof Node&&(m.current?.contains(w)||(a(!1),l(!1)))},h=f=>{f.key==="Escape"&&(a(!1),l(!1))};return document.addEventListener("mousedown",u),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",h)}},[r]);const x=u=>{const h=u.trim();h&&(n(h),d(h),l(!1),a(!1))};return e.jsxs("div",{className:"space-y-2 text-xs",ref:m,children:[e.jsx("div",{className:"font-medium text-foreground",children:"Tenant"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>!s&&a(u=>!u),disabled:s,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:hm(t)}),e.jsx(tt,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),r&&e.jsxs("div",{className:"absolute left-0 right-0 z-50 mt-2 overflow-hidden rounded-sm border border-border/60 bg-background/95 text-xs shadow-[0_16px_48px_-34px_rgba(0,0,0,0.45)] backdrop-blur",children:[e.jsxs("button",{type:"button",onClick:()=>x(an),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:Zo}),t===an&&e.jsx(Nn,{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:c,onChange:u=>d(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),x(c))},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:()=>x(c),className:"flex h-7 w-7 items-center justify-center rounded-sm hover:bg-background/60",children:e.jsx(Nn,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{d(t),l(!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(ct,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>l(!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(Wt,{className:"h-3 w-3"})]})})]})]})]})}function hm(t){return t===an?Zo:t}function na({active:t,title:n,description:s,onClick:r}){return e.jsxs("button",{type:"button",onClick:r,className:t?"rounded-sm border border-primary/45 bg-primary/10 px-3 py-2 text-left shadow-sm":"rounded-sm border border-border/70 bg-background px-3 py-2 text-left shadow-sm hover:bg-muted/50",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:n}),e.jsx("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:s})]})}function fm(t){const n=t.map(s=>s.type==="text"?s.text:s.type==="image"?s.filename?`Image: ${s.filename}`:"Image attachment":s.isError?`Tool result error: ${s.content}`:`Tool result: ${s.content}`).join(" ").replace(/\s+/g," ").trim();return n?n.length>160?`${n.slice(0,157)}...`:n:"Queued follow-up"}function pm({messages:t,onCancelMessage:n}){return t.length===0?null:e.jsx("div",{className:"border-t border-border/55 bg-card/30 px-3 py-2 sm:px-5",children:e.jsxs("div",{className:"mx-auto max-w-[72rem] rounded-sm border border-border/65 bg-background/58 px-3 py-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium text-foreground",children:[e.jsx(Dd,{className:"h-3.5 w-3.5 text-primary"}),"Queued messages",e.jsx("span",{className:"ml-auto rounded-sm border border-border/60 bg-muted/60 px-1.5 py-0 text-[10px] text-muted-foreground",children:t.length})]}),e.jsx("div",{className:"mt-2 space-y-1.5",children:t.map((s,r)=>{const a=s.content.filter(i=>i.type==="image");return e.jsxs("div",{className:"flex min-w-0 items-start gap-2 text-[11px] leading-5 text-muted-foreground",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-sm bg-primary/10 text-[10px] font-medium text-primary",children:r+1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[s.targetAgent&&e.jsxs("div",{"data-queued-message-target-agent":s.targetAgent,className:"mb-0.5 inline-flex h-5 max-w-[11rem] items-center gap-1 rounded-sm bg-primary/10 px-1.5 text-[10px] leading-3 text-primary",title:`Send to ${jt(s.targetAgent)}`,children:[e.jsx(Po,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx(Ct,{agent:s.targetAgent,className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:jt(s.targetAgent)})]}),e.jsx("div",{className:"break-words [overflow-wrap:anywhere]",children:fm(s.content)}),a.length>0&&e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:a.map((i,l)=>e.jsx(hr,{image:i,alt:i.filename??`queued attachment ${l+1}`,thumbnailClassName:"h-14 w-14 border border-border/65",imageClassName:"h-full w-full"},`${i.filename??"image"}-${l}`))})]}),n&&e.jsx(Z,{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:()=>n(s.id),children:e.jsx(ct,{className:"h-3 w-3"})})]},s.id)})})]})})}const xm="h-6 w-6 rounded-none border-b border-transparent !bg-transparent p-0 text-muted-foreground !shadow-none hover:text-foreground data-[state=active]:border-primary data-[state=active]:!bg-transparent data-[state=active]:text-primary data-[state=active]:!shadow-none",gm=[{value:"transcript",label:"Transcript",icon:yl},{value:"files",label:"Files",icon:cn,activeIcon:Jn},{value:"diff",label:"Diff",icon:Hn},{value:"preview",label:"Preview",icon:nd}];function bm({activeTab:t}){return e.jsx(ar,{className:"h-auto max-w-full justify-start gap-2 overflow-x-auto rounded-sm !bg-muted/40 !p-0.5 !shadow-none",children:gm.map(n=>{const s=n.value===t&&n.activeIcon?n.activeIcon:n.icon;return e.jsx(Ot,{value:n.value,title:n.label,"aria-label":n.label,className:xm,children:e.jsx(s,{className:"h-3.5 w-3.5","aria-hidden":"true"})},n.value)})})}const Xo="pointer-events-auto h-5 w-5 shrink-0 rounded-sm bg-muted/65 text-muted-foreground hover:bg-muted hover:text-foreground",Wn="h-3.5 w-3.5";function tr({onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,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(ei,{desktopTasksOpen:n,mobileTasksPanelOpen:s,onToggleTasks:t,className:"lg:hidden"})}),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(ti,{operationsOpen:r,onToggleOperations:a,className:"xl:hidden"})]})}function ei({className:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,onToggleTasks:r}){const a=globalThis.window?.matchMedia("(min-width: 1024px)")?.matches?n:s;return e.jsx(Z,{variant:"ghost",size:"icon",onClick:r,title:a?"Hide tasks":"Show tasks","aria-label":a?"Hide tasks":"Show tasks",className:F(Xo,t),children:a?e.jsx(qn,{className:Wn}):e.jsx(dt,{className:Wn})})}function ti({className:t,operationsOpen:n,onToggleOperations:s}){return e.jsx(Z,{variant:"ghost",size:"icon",onClick:s,title:n?"Hide cluster":"Show cluster","aria-label":n?"Hide cluster":"Show cluster",className:F(Xo,t),children:n?e.jsx(dt,{className:Wn}):e.jsx(qn,{className:Wn})})}const sa="h-7 w-7 rounded-sm border-0 bg-primary/10 text-primary backdrop-blur hover:bg-primary/20 hover:text-primary";function vm({active:t,onScrollToBottom:n,onScrollToTop:s}){return e.jsxs("div",{className:F("pointer-events-none absolute right-3 top-1/2 z-10 flex -translate-y-1/2 flex-col gap-2 opacity-0 transition-opacity duration-200 group-hover:pointer-events-auto group-hover:opacity-100",t&&"pointer-events-auto opacity-100"),children:[e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:sa,onClick:s,"aria-label":"Scroll to top",title:"Scroll to top",children:e.jsx(jl,{className:"h-4 w-4"})}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:sa,onClick:n,"aria-label":"Scroll to bottom",title:"Scroll to bottom",children:e.jsx(tt,{className:"h-4 w-4"})})]})}function wm(t){if(t.type!=="agent.handoff")return null;const n=typeof t.fromAgent=="string"&&t.fromAgent.trim()?t.fromAgent.trim():"agent",s=typeof t.toAgent=="string"&&t.toAgent.trim()?t.toAgent.trim():"";return s?{fromAgent:n,toAgent:s}:null}function ym({fromAgent:t,toAgent:n}){return e.jsx("div",{className:"flex w-full justify-center py-0.5","data-agent-handoff":n,children:e.jsxs("div",{className:"inline-flex h-6 max-w-full items-center gap-1.5 rounded-sm border border-border/45 bg-muted/22 px-2 text-[10px] leading-3 text-muted-foreground/78",children:[e.jsx(Ct,{agent:t,className:"h-3 w-3 shrink-0 text-muted-foreground/65","aria-hidden":"true"}),e.jsxs("span",{className:"truncate",children:[jt(t)," to ",jt(n)]}),e.jsx(Ct,{agent:n,className:"h-3 w-3 shrink-0 text-primary/60","aria-hidden":"true"})]})})}const ra="h-[1.625rem] rounded-sm !border-0 !bg-transparent px-2 text-[10.5px] font-medium text-primary !shadow-none hover:!bg-transparent hover:text-primary/80 focus-visible:ring-1 focus-visible:ring-ring/50 focus-visible:ring-offset-0",Bt={content:"max-w-[20rem] gap-2.5 rounded-lg border-0 p-3.5 shadow-[0_18px_70px_-44px_rgba(0,0,0,0.72)] sm:max-w-[20rem]",header:"space-y-1 text-left",title:"text-[13px] leading-4",description:"text-[11px] leading-4",footer:"gap-1 pt-0 sm:space-x-1",cancel:`${ra} mt-0`,action:ra},jm=30,Nm=1600;function km({savedScrollTop:t,scrollHeight:n,clientHeight:s}){const r=Math.max(0,n-s);return Math.min(Math.max(0,t??r),r)}function fs(t){return t.scrollHeight-t.scrollTop-t.clientHeight<jm}function aa({explicitBottomStickUntil:t,now:n,wasAtBottom:s}){return s||t>n}function ps(t,n){return!!(n&&(t===n||t.contains(n)))}function xs(t){const n=t.ownerDocument.getSelection();if(!n||n.isCollapsed||n.rangeCount===0)return!1;if(ps(t,n.anchorNode)||ps(t,n.focusNode))return!0;for(let s=0;s<n.rangeCount;s+=1)if(ps(t,n.getRangeAt(s).commonAncestorContainer))return!0;return!1}function Sm({atTop:t,inputCollapseDisabled:n,scrollingUp:s}){return!n&&(s||t)}function Cm({activeTab:t,activeTaskId:n,contentVersion:s,inputCollapseDisabled:r=!1,setActiveTab:a,setInputCollapsed:i}){const l=o.useRef(null),c=o.useRef(n),d=o.useRef(!1),m=o.useRef(0),x=o.useRef(new Map),u=o.useRef(0),h=o.useRef(!0),f=o.useCallback((p=c.current)=>{const b=l.current;!b||!p||(x.current.set(p,b.scrollTop),m.current=b.scrollTop,h.current=fs(b))},[]),w=o.useCallback((p=c.current)=>{const b=l.current;!b||!p||(b.scrollTop=km({savedScrollTop:x.current.get(p),scrollHeight:b.scrollHeight,clientHeight:b.clientHeight}),m.current=b.scrollTop,h.current=fs(b))},[]),g=o.useCallback((p,b=c.current)=>{p.scrollTop=p.scrollHeight,m.current=p.scrollTop,h.current=!0,b&&x.current.set(b,p.scrollTop)},[]),k=o.useCallback((p=c.current)=>{const b=l.current;u.current=Date.now()+Nm,b&&(g(b,p),requestAnimationFrame(()=>{g(b,p),requestAnimationFrame(()=>g(b,p))}))},[g]),v=o.useCallback((p=c.current)=>{const b=l.current;u.current=0,b&&(b.scrollTop=0,m.current=0,h.current=!1,p&&x.current.set(p,0))},[]),S=o.useCallback(p=>{const b=p.currentTarget,N=m.current,A=b.scrollTop<N&&N-b.scrollTop>10,I=b.scrollTop<=0,E=xs(b);if(f(),E){u.current=0;return}if(!d.current){if(fs(b)){i(!1),d.current=!0,setTimeout(()=>{d.current=!1},300);return}(A||I)&&(u.current=0,Sm({atTop:I,inputCollapseDisabled:r,scrollingUp:A})&&i(!0))}},[r,f,i]),y=o.useCallback(p=>{t==="transcript"&&f(),a(p),p==="transcript"&&requestAnimationFrame(()=>w())},[t,w,f,a]);return o.useLayoutEffect(()=>{r&&i(!1)},[r,i]),o.useLayoutEffect(()=>{const p=c.current;p&&p!==n&&f(p),c.current=n,t==="transcript"&&requestAnimationFrame(()=>w(n))},[n,t,w,f]),o.useLayoutEffect(()=>{const p=l.current;if(!p||t!=="transcript"||!n)return;const b=aa({explicitBottomStickUntil:u.current,now:Date.now(),wasAtBottom:h.current});if(xs(p)){u.current=0,f(n);return}b&&g(p,n),f(n)},[n,t,s,f,g]),o.useLayoutEffect(()=>{const p=l.current,b=p?.firstElementChild;if(!p||!b||t!=="transcript"||typeof ResizeObserver>"u")return;const N=new ResizeObserver(()=>{if(xs(p)){u.current=0,f();return}aa({explicitBottomStickUntil:u.current,now:Date.now(),wasAtBottom:h.current})?g(p):f()});return N.observe(p),N.observe(b),()=>N.disconnect()},[t,n,f,g]),{handleTranscriptScroll:S,handleTranscriptTabChange:y,scrollTranscriptToBottom:k,scrollTranscriptToTop:v,transcriptScrollRef:l}}function ni(t=700){const[n,s]=o.useState(!1),r=o.useRef(null),a=o.useCallback(()=>{s(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>{s(!1),r.current=null},t)},[t]);return o.useEffect(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]),{markScrollbarActive:a,scrollbarActive:n}}const Tm="harness";function Am(t){return typeof t=="object"&&t!==null}function Em(t){return typeof t=="string"&&t.trim().length>0?t.trim():""}function Mm(t){return Am(t.agentSessions)?Object.keys(t.agentSessions).map(n=>n.trim()).filter(Boolean):[]}function si(t){return Em(t.payload.activeAgent)||t.agent}function ri(t){return new Set([t.agent,si(t),...Mm(t.payload)].filter(Boolean)).size>1}function ai(t){return ri(t)?Tm:t.agent}const Dm=o.lazy(async()=>({default:(await ir(()=>import("./FilesTab-jvuvGCqQ.js"),__vite__mapDeps([0,1,2,3,4,5]))).FilesTab})),_m=o.lazy(async()=>({default:(await ir(()=>import("./PreviewTab-oRD3Wntx.js").then(n=>n.c),__vite__mapDeps([6,1,2]))).PreviewTab})),Pm=o.lazy(async()=>({default:(await ir(()=>import("./DiffTab-BuC8qgFb.js"),__vite__mapDeps([7,1,2,5,4,3,6]))).DiffTab}));function Im({onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,cluster:i,activeTab:l,setActiveTab:c,creatingTask:d,createMode:m,createDefaults:x,activeTask:u,assignedNode:h,taskLoading:f,transcriptLoading:w,taskError:g,displayEvents:k,initialPromptAlreadyInLogs:v,initialPrompt:S,supportsFollowUp:y,taskUnavailable:p,chatDisabled:b,chatDisabledReason:N,questionBypassEnabled:A,isRunning:I,isStarting:E,hasPendingFollowUp:L,canCancel:M,canRetry:D,onRetry:P,onCancel:B,onReloadNativeTranscript:Q,onShareTask:te,onStopShareTask:Y,onStartCreateTask:H,onCancelCreateTask:ne,onCreateTask:$,onSendMessage:X,onCancelQueuedMessage:j,onQuestionBypassChange:W,onSubmitQuestionResponse:T,quickChats:ee=[]}){const[R,V]=o.useState(!1),[O,le]=o.useState(!1),[ie,ue]=o.useState(!1),[J,K]=o.useState(!1),[_,se]=o.useState(!1),[q,ae]=o.useState({}),[ye,pe]=o.useState(new Set),[Ye,Te]=o.useState(new Set),[ht,Ie]=o.useState(null),[Me,qe]=o.useState(null),He=u?.effectiveProjectPath??u?.project??"default workspace",je=u?h?.name??Hs(u.assignedTo,i?.nodes,u.assignedNodeName):"unassigned",Re=u?ai(u):"",G=u?si(u):"",ge=u&&ri(u)?G:void 0,be=u?.assignedTo?e.jsxs(e.Fragment,{children:["Connecting session on node ",e.jsx("span",{className:"font-semibold",children:je}),"..."]}):"Connecting session to an available node...",Xe=u?[{label:"Working dir",value:He,mono:!0},...u.branch?[{label:"Branch",value:u.branch,mono:!0}]:[],{label:"Agent",value:Re,mono:!0},{label:"Node",value:je}]:[],De=!!(S&&!v),nt=De||k.length>0,re=I&&nt,Ne=(E||L||I)&&!re,Ce=re?"The agent is still working on this conversation.":Ne?be:null,{collapsedButtonRunning:ve,showDockedProgress:st,showInlineProgress:_e}=cm({hasTranscriptProgress:!!Ce,hasVisibleTranscriptEvents:nt,inputCollapsed:R}),Et=u?.conversationKind==="nativeSession",ft=Kc(u),un=w?"Loading transcript":Et?"No transcript imported":"Transcript is warming up",Jt=w?"Loading transcript...":Et?"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.",Nt=u?.queuedMessages??[],bt=o.useMemo(()=>Gc(k),[k]),mn=o.useMemo(()=>{let me=u?.agent??"";return bt.map(ke=>{const Ve=wm(ke.event);if(Ve)return me=Ve.toAgent,{...ke,agent:me,handoff:Ve};const Fe=typeof ke.event.agent=="string"&&ke.event.agent.trim()?ke.event.agent.trim():me;return{...ke,agent:Fe,handoff:null}})},[u?.agent,bt]),hn=o.useMemo(()=>{const me=u?.assignedTo?u.assignedTo===i?.self?.id?h?.supportedAgents??i.self.supportedAgents:h?.supportedAgents:i?.self?.supportedAgents;return Nl({nodeSupportedAgents:me,taskAgent:u?.agent,activeAgent:typeof u?.payload.activeAgent=="string"?u.payload.activeAgent:void 0})},[h?.supportedAgents,i?.self?.id,i?.self?.supportedAgents,u?.assignedTo,u?.agent,u?.payload.activeAgent]),Mt=o.useMemo(()=>bt.findIndex(({event:me})=>Rm(me)),[bt]),Rt=o.useMemo(()=>Wc("transcript",bt.map(me=>me.event)),[bt]),Zt=u&&!ye.has(u.id)?q[u.id]??u.activeShare??null:null,kt=u?.id??null,Xt=`${kt??"none"}:${k.length}:${Nt.length}:${De?1:0}:${w?1:0}:${_e?1:0}`,{handleTranscriptScroll:Be,handleTranscriptTabChange:rt,scrollTranscriptToBottom:vt,scrollTranscriptToTop:St,transcriptScrollRef:U}=Cm({activeTab:l,activeTaskId:kt,contentVersion:Xt,inputCollapseDisabled:!!Ce,setActiveTab:c,setInputCollapsed:V}),{markScrollbarActive:Oe,scrollbarActive:Pe}=ni(),Ke=o.useCallback(me=>{Oe(),Be(me)},[Be,Oe]),Ge=o.useCallback(me=>{Ie(ke=>({path:me,requestId:(ke?.requestId??0)+1})),rt("files")},[rt]),en=o.useCallback(me=>{qe(ke=>({path:me,requestId:(ke?.requestId??0)+1})),rt("preview")},[rt]),xe=o.useCallback((me,ke)=>{vt(),X(me,ke)},[X,vt]);return o.useEffect(()=>{Ie(null),qe(null)},[kt]),d?e.jsx(Lm,{onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,cluster:i,defaultMode:m,createDefaults:x,onCancel:ne,onCreated:$,quickChats:ee}):!u&&f?e.jsxs("div",{className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"dashboard-conversation-panel__header shrink-0 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(tr,{onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-4 py-6 sm:px-6",children:e.jsxs("div",{className:"space-y-3 text-center",children:[e.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-sm border border-primary/20 bg-primary/10 text-primary shadow-none",children:e.jsx(he,{className:"h-5 w-5 animate-spin"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-sm 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(he,{className:"h-3.5 w-3.5 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):u?e.jsxs(or,{value:l,onValueChange:rt,className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsxs("div",{className:"dashboard-conversation-panel__header relative shrink-0 bg-card/28 px-3 pb-0.5 pt-1 sm:px-5 sm:pt-1.5",children:[e.jsxs("div",{className:"pointer-events-none absolute left-1 right-1 top-2 flex items-center justify-between sm:left-1.5 sm:right-1.5 sm:top-2.5",children:[e.jsx(ei,{desktopTasksOpen:n,mobileTasksPanelOpen:s,onToggleTasks:t,className:"lg:hidden"}),e.jsx(ti,{operationsOpen:r,onToggleOperations:a,className:"xl:hidden"})]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 pl-5 sm:pl-6 lg:pl-0",children:[e.jsx("h2",{className:"min-w-0 truncate text-[13px] font-semibold leading-5 text-foreground sm:text-[15px]",title:u.title,children:u.title}),e.jsx(xo,{status:u.status,isNative:Et}),ft&&e.jsxs("span",{"data-task-goal-label":"true",title:"Codex goal",className:"inline-flex h-5 shrink-0 items-center gap-1 rounded-sm bg-primary/10 px-1.5 text-[9px] font-semibold uppercase tracking-[0.12em] text-primary",children:[e.jsx(To,{className:"h-3 w-3","aria-hidden":"true"}),"Goal"]}),u.priority!=="normal"&&e.jsx(Sl,{priority:u.priority})]}),g&&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:g}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 pl-5 sm:pl-6 lg:pl-0",children:[e.jsx(bm,{activeTab:l}),p&&e.jsx(Ze,{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.jsx("span",{className:"hidden rounded-sm bg-muted/65 px-1.5 py-0.5 tabular-nums sm:inline-flex",children:Cl(u.updatedAt)}),D&&e.jsxs(Z,{variant:"ghost",size:"sm",onClick:P,"aria-label":"Retry task",title:"Retry task",className:"h-7 shrink-0 rounded-sm border-0 bg-primary/10 px-2 text-[10px] text-primary shadow-none hover:bg-primary/15 hover:text-primary",children:[e.jsx(zd,{className:"h-3.5 w-3.5"}),"Retry"]}),Et&&Q&&e.jsx(Z,{variant:"ghost",size:"icon",onClick:Q,disabled:w,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(Oo,{className:F("h-3.5 w-3.5",w&&"animate-spin")})}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",disabled:p,title:p?"Unavailable tasks cannot be shared.":"Share conversation","aria-label":p?"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:()=>ue(!0),children:e.jsx(Kn,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsx(yt,{value:"transcript",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"group relative flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"relative min-h-0 flex-1",children:e.jsx("div",{ref:U,"data-transcript-scroll":"true",className:F("scrollbar-line h-full min-h-0 touch-pan-y overflow-x-hidden overflow-y-auto overscroll-x-none bg-gradient-to-b from-background/15 via-transparent to-background/35 px-3 pb-4 pt-4 sm:px-5",Pe&&"scrollbar-line-active"),onScroll:Ke,children:e.jsxs("div",{"data-transcript-scroll-content":"true",className:"mx-auto flex max-w-[72rem] flex-col gap-4",children:[De&&S&&e.jsx(Vr,{event:S,agent:u.agent,sentAsGoal:ft,taskRootPath:u.effectiveProjectPath,onOpenFilePath:Ge,questionBypassEnabled:A,onQuestionBypassChange:W,onSubmitQuestionResponse:T,questionResponseDisabled:!y||b}),mn.map(({event:me,subItems:ke,agent:Ve,handoff:Fe},Lt)=>Fe?e.jsx(ym,{fromAgent:Fe.fromAgent,toAgent:Fe.toAgent},Rt[Lt]):e.jsx(Vr,{event:me,agent:Ve,subItems:ke,sentAsGoal:ft&&!De&&Lt===Mt,taskRootPath:u.effectiveProjectPath,onOpenFilePath:Ge,questionBypassEnabled:A,onQuestionBypassChange:W,onSubmitQuestionResponse:T,questionResponseDisabled:!y||b},Rt[Lt])),!nt&&!Ne&&e.jsxs("div",{className:"rounded-sm border border-dashed border-border/70 bg-background/35 px-3 py-4 text-center",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:un}),e.jsx("div",{className:"mt-2 text-[11px] leading-6 text-muted-foreground",children:Jt})]}),(!y&&u.result||u.error)&&e.jsxs("div",{className:"space-y-3",children:[!y&&u.result&&e.jsxs("div",{className:"rounded-sm 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(u.result,null,2)})]}),u.error&&!Ye.has(u.id)&&e.jsxs("div",{className:"rounded-sm 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:()=>Te(me=>new Set(me).add(u.id)),className:"rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(ct,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5",children:u.error})]})]}),_e&&Ce&&e.jsx(ta,{children:Ce})]})})}),e.jsx(vm,{active:Pe,onScrollToBottom:()=>vt(),onScrollToTop:()=>St()}),st&&Ce&&e.jsx("div",{"data-docked-progress":"true",className:"shrink-0 bg-background/35 px-3 py-1 sm:px-5",children:e.jsx("div",{className:"mx-auto max-w-[72rem]",children:e.jsx(ta,{children:Ce})})}),y?e.jsxs(e.Fragment,{children:[R&&e.jsx(lm,{running:ve,onClick:()=>{V(!1),vt(),requestAnimationFrame(()=>document.querySelector('[data-chat-input-textarea="true"]')?.focus())}}),e.jsxs("div",{className:`shrink-0 ${R?"hidden":""}`,children:[e.jsx(pm,{messages:Nt,onCancelMessage:j}),e.jsx(Eu,{onSend:xe,disabled:b,disabledReason:N,contextItems:Xe,agent:u.agent,currentAgent:ge,taskId:u.id,availableAgents:hn,model:typeof u.payload.model=="string"?u.payload.model:null,placeholder:b?N:I?"Queue a message for the next turn...":"Continue the conversation...",running:I||E||L,onStop:M?()=>le(!0):void 0,quickChats:ee})]})]}):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(yt,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(ds,{label:"Loading files..."}),children:e.jsx(Dm,{taskId:u.id,requestedFilePath:ht?.path??null,requestedFileRequestId:ht?.requestId??0,onPreviewFile:en})})}),e.jsx(yt,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(ds,{label:"Loading preview..."}),children:e.jsx(_m,{taskId:u.id,requestedEntryPath:Me?.path??null,requestedEntryRequestId:Me?.requestId??0})})}),e.jsx(yt,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(ds,{label:"Loading diff..."}),children:e.jsx(Pm,{taskId:u.id})})}),e.jsx(Ft,{open:O,onOpenChange:le,children:e.jsxs(zt,{className:Bt.content,children:[e.jsxs(Ut,{className:Bt.header,children:[e.jsx($t,{className:Bt.title,children:"Stop this task?"}),e.jsx(qt,{className:Bt.description,children:"The task will stop and move to a cancelled state."})]}),e.jsxs(Ht,{className:Bt.footer,children:[e.jsx(Vt,{className:Bt.cancel,children:"Keep running"}),e.jsx(Kt,{className:Bt.action,onClick:B,children:"Stop task"})]})]})}),e.jsx(dm,{open:ie,onOpenChange:ue,sharing:J,stopping:_,shareResult:Zt,onShare:async me=>{if(!u)return null;K(!0);try{const ke=await te(me);return ke?.url&&(ae(Ve=>({...Ve,[u.id]:ke})),pe(Ve=>{const Fe=new Set(Ve);return Fe.delete(u.id),Fe})),ke}finally{K(!1)}},onStopShare:async()=>{if(!u)return!1;se(!0);try{const me=await Y();return me!==!1&&(ae(ke=>{const Ve={...ke};return delete Ve[u.id],Ve}),pe(ke=>new Set(ke).add(u.id))),me}finally{se(!1)}}})]}):e.jsxs("div",{className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"dashboard-conversation-panel__header shrink-0 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(tr,{onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-4 py-6 sm:px-6",children:e.jsxs("div",{className:"w-full max-w-lg text-center",children:[e.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-sm border border-primary/20 bg-primary/10 text-primary shadow-none",children:e.jsx(kl,{className:"h-5 w-5"})}),e.jsx("h2",{className:"mt-3 text-sm font-semibold tracking-tight text-foreground sm:text-[15px]",children:"No chat selected"}),e.jsx("p",{className:"mx-auto mt-2 max-w-md text-[11px] leading-5 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(Z,{onClick:()=>H(),className:"mt-4 h-8 rounded-sm px-3",children:[e.jsx(Mn,{className:"h-3.5 w-3.5"}),"Start or load chat"]}),g&&e.jsx("div",{className:"mx-auto mt-3 max-w-md rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:g})]})})]})}function Rm(t){return t.type!=="user"||t.isMeta===!0||t.isSidechain===!0?!1:!!fr(t)?.some(s=>s.type==="text"||s.type==="image")}function Lm({onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,cluster:i,defaultMode:l,createDefaults:c,onCancel:d,onCreated:m,quickChats:x}){const[u,h]=o.useState(l??"chat");o.useEffect(()=>{l&&h(l)},[l]);const f=e.jsx("div",{className:"flex h-8 items-center gap-0.5 overflow-hidden rounded-sm border border-border/60 bg-background/65 p-0.5 text-[11px] font-medium shadow-none",children:[{value:"chat",label:"New chat",icon:Mn},{value:"native",label:"Load session",icon:xr}].map(w=>{const g=w.icon,k=w.value===u;return e.jsxs("button",{type:"button",onClick:()=>h(w.value),"aria-pressed":k,className:F("flex h-7 min-w-28 items-center justify-center gap-1.5 rounded-sm border border-transparent px-2.5 transition-colors duration-150",k?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-background/80 hover:text-foreground"),children:[e.jsx(g,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:w.label})]},w.value)})});return e.jsxs("div",{className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"dashboard-conversation-panel__header shrink-0 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(tr,{onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,centerSlot:f})}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center overflow-y-auto px-4 py-6 sm:px-6",children:e.jsx("div",{className:"w-full max-w-2xl",children:e.jsx(im,{nodes:i?.nodes??[],currentNodeRole:i?.self?.role,currentNodeId:i?.self?.id??null,leaderNodeId:i?.leader?.id??null,initialAssignTo:c?.assignTo,initialProject:c?.project,mode:u,onModeChange:h,onCreated:m,onCancel:d,autoFocus:!0,layout:"composer",defaultTaskAgent:i?.self.settingsSnapshot?.defaultTaskAgent,quickChats:x})})})]})}function Bm({onAdded:t}){const[n,s]=o.useState(""),[r,a]=o.useState(!1),[i,l]=o.useState(null),c=o.useCallback(async d=>{if(d.preventDefault(),!!n.trim()){a(!0),l(null);try{await Tl({leaderEndpoint:n.trim(),transport:"devtunnel"}),t()}catch(m){l(m instanceof Error?m.message:"Failed to join node")}finally{a(!1)}}},[n,t]);return e.jsx(mt,{className:"overflow-hidden border-border/60 bg-transparent p-0 shadow-none sm:max-w-xl",children:e.jsxs("div",{className:"overflow-hidden rounded-sm border border-border/60 bg-background/95 p-0 shadow-[0_28px_90px_-58px_rgba(0,0,0,0.88)] backdrop-blur-xl",children:[e.jsx("div",{className:"border-b border-border/60 px-3.5 py-2.5",children:e.jsxs(Tt,{className:"space-y-1 text-left",children:[e.jsx(gt,{className:"text-sm tracking-tight",children:"Join node"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Verify the remote leader's DevTunnel Node URL, sync this node's tasks to that leader, and join the cluster as a follower."})]})}),e.jsxs("form",{onSubmit:c,className:"space-y-3 px-3.5 py-3",children:[i&&e.jsx("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] 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(et,{htmlFor:"leader-endpoint",children:"Leader Node URL"}),e.jsx(Ze,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),e.jsx(lt,{id:"leader-endpoint",type:"url",value:n,onChange:d=>s(d.target.value),placeholder:"https://your-leader.devtunnels.ms",className:"h-8 rounded-sm border-border/70 bg-background/70"})]}),e.jsx("div",{className:"rounded-sm border border-border/60 bg-background/45 px-3 py-2 text-[11px] 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(lr,{className:"border-t border-border/60 pt-3",children:e.jsx(Z,{type:"submit",disabled:!n.trim()||r,className:"rounded-sm",children:r?"Joining...":"Join node"})})]})]})})}function Om({open:t,onOpenChange:n,onAdded:s}){return e.jsx(ut,{open:t,onOpenChange:n,children:e.jsx(Bm,{onAdded:()=>{n(!1),s()}})})}const Fm="absolute top-1/2 z-30 hidden h-10 w-4 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground opacity-0 outline-none transition-opacity duration-150 hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/55",zm="flex h-7 w-3.5 items-center justify-center rounded-full bg-muted/85 shadow-[0_12px_24px_-20px_rgba(0,0,0,0.9)] backdrop-blur-sm transition-colors hover:bg-card hover:text-foreground",Um="h-2.5 w-2.5";function oi({className:t,label:n,orientation:s,panel:r,panelResize:a}){return e.jsx("button",{type:"button","aria-label":n,"aria-orientation":s,"data-dashboard-resize-handle":r,onPointerDown:i=>a.onPointerDown(r,i),onWheel:i=>a.onWheel(r,i),className:F("group absolute z-20 hidden touch-none rounded-sm bg-transparent outline-none transition-colors hover:bg-primary/12 focus-visible:bg-primary/12 focus-visible:ring-2 focus-visible:ring-ring/70 lg:block",t),children:e.jsx("span",{className:"pointer-events-none absolute inset-0 opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100"})})}function $m({className:t,label:n,onToggle:s,side:r,visible:a}){const i=r==="left"?a?qn:dt:a?dt:qn;return e.jsx("button",{type:"button","aria-label":n,title:n,onClick:s,className:F(Fm,t),children:e.jsx("span",{className:zm,"aria-hidden":"true",children:e.jsx(i,{className:Um,strokeWidth:2.1})})})}function oa({className:t,label:n,onToggle:s,panel:r,panelResize:a,screen:i,side:l,visible:c}){const d=i==="lg"?"lg:block":"xl:block",m=i==="lg"?"lg:flex":"xl:flex";return e.jsxs("div",{className:F("group absolute top-0 z-30 hidden h-full w-4",d,t),children:[r&&e.jsx(oi,{panel:r,orientation:"vertical",label:`Resize ${r} panel`,panelResize:a,className:"left-1/2 top-0 h-full w-2 -translate-x-1/2 cursor-col-resize"}),e.jsx($m,{side:l,visible:c,label:n,onToggle:s,className:F(m,"left-1/2 -translate-x-1/2 group-hover:opacity-100")})]})}function qm({conversationPanel:t,desktopTasksOpen:n,mobileTaskSidebar:s,mobileTasksPanelOpen:r,mobileTasksPanelRef:a,operationsOpen:i,operationsPanelRef:l,operationsSidecar:c,panelResize:d,taskSidebar:m,terminalPanel:x,onCloseOperations:u,onCloseTaskList:h,onToggleOperations:f,onToggleTasks:w}){const g={"--dashboard-tasks-width":d.sizes.tasks,"--dashboard-operations-width":d.sizes.operations,"--dashboard-terminal-height":d.sizes.terminal};return e.jsxs("div",{className:"dashboard-workspace flex h-full min-h-0 flex-col overflow-hidden",style:g,children:[e.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[e.jsx(oa,{screen:"lg",side:"left",visible:n,label:n?"Hide tasks":"Show tasks",onToggle:w,panel:n?"tasks":void 0,panelResize:d,className:n?"left-[var(--dashboard-tasks-width)] -translate-x-1/2":"left-0"}),e.jsx("div",{className:F("dashboard-workspace__tasks-panel relative hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",n?"lg:mr-2 lg:w-[var(--dashboard-tasks-width)]":"lg:w-0 lg:overflow-hidden"),children:n&&m}),e.jsxs("section",{className:"dashboard-workspace__primary flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[e.jsx("div",{className:"min-h-0 flex-1",children:t}),x&&e.jsxs("div",{className:"relative h-[var(--dashboard-terminal-height)] min-h-0 shrink-0",children:[e.jsx(oi,{panel:"terminal",orientation:"horizontal",label:"Resize terminal panel",panelResize:d,className:"-top-1 left-0 h-2 w-full cursor-row-resize"}),x]})]}),e.jsx(oa,{screen:"xl",side:"right",visible:i,label:i?"Hide cluster":"Show cluster",onToggle:f,panel:i?"operations":void 0,panelResize:d,className:i?"right-[var(--dashboard-operations-width)] translate-x-1/2":"right-0"}),e.jsx("div",{className:F("dashboard-workspace__operations-panel relative hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",i?"xl:ml-2 xl:w-[var(--dashboard-operations-width)]":"xl:w-0 xl:overflow-hidden"),children:i&&c})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:u,className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),e.jsx("div",{ref:l,className:"fixed bottom-0 right-0 top-[var(--dashboard-mobile-overlay-top)] z-40 w-full p-2 sm:max-w-sm sm:p-3 xl:hidden",children:c})]}),r&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close task list",onClick:h,className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),e.jsx("div",{ref:a,className:"fixed bottom-0 left-0 top-[var(--dashboard-mobile-overlay-top)] z-40 w-full p-2 sm:max-w-sm sm:p-3 lg:hidden",children:s})]})]})}const Hm=10,Gt="__all__";function ot(t){return"session"in t}function ia(t,n){return n&&t.some(s=>s.id===n)?n:t[0]?.id??""}function gs(t){return t&&(Wo(t.id)||t.workDir)||""}function Ln(t,n,s){let r=!1;const a=t.map(i=>ot(i)&&i.session.id===s.id?(r=!0,{...i,nodeName:n,session:s}):i);return nr(r?a:[...a,{id:`session-${s.id}`,nodeName:n,session:s}])}function ii(t,n){return t.filter(ot).filter(s=>s.session.nodeId===n).sort((s,r)=>r.session.startedAt-s.session.startedAt)}function Vm(t){const n=t.filter(ot).sort((s,r)=>r.session.startedAt-s.session.startedAt);return{active:n.filter(s=>s.session.status==="running"),completed:n.filter(s=>s.session.status!=="running")}}function Km(t,n){return!!(t&&n&&!t.contains(n))}function Gm(t,n,s){if(s===Gt)return s;const r=ii(t,n);return r.some(a=>a.session.id===s)?s:r[0]?.session.id??Gt}function Wm(t,n,s){return s===Gt?t.filter(r=>!ot(r)||r.session.nodeId===n):t.filter(r=>ot(r)&&r.session.nodeId===n&&r.session.id===s)}function nr(t){const n=t.map((r,a)=>({entry:r,index:a})).filter(({entry:r})=>ot(r)&&r.session.status!=="running").sort((r,a)=>!ot(r.entry)||!ot(a.entry)?0:a.entry.session.startedAt-r.entry.session.startedAt||a.index-r.index),s=new Set(n.slice(0,Hm).map(({entry:r})=>ot(r)?r.session.id:""));return t.filter(r=>!ot(r)||r.session.status==="running"||s.has(r.session.id))}function sr(t){return t.status==="running"?t.pid?`running pid ${t.pid}`:"running":t.status==="exited"?`exit ${t.exitCode??0}`:t.status==="stopped"?"stopped":t.signal?`failed ${t.signal}`:`exit ${t.exitCode??"failed"}`}function Qm(t){const n=t.session.command.length>48?`${t.session.command.slice(0,45)}...`:t.session.command;return`${t.nodeName} - ${sr(t.session)} - ${n}`}function li(t,n=48){return t.length>n?`${t.slice(0,n-3)}...`:t}function Ym(t,n){return n===Gt?"All sessions":t?li(t.session.command,34):"Command session"}function la(t){return t.status==="stopped"?"":t.stderr}function Jm({nodes:t,defaultNodeId:n,onClose:s,initialHistory:r=[]}){const[a,i]=o.useState(()=>ia(t,n)),l=o.useMemo(()=>t.find(T=>T.id===a)??t[0]??null,[t,a]),[c,d]=o.useState(()=>gs(l)),[m,x]=o.useState(""),[u,h]=o.useState(()=>nr(r)),[f,w]=o.useState(Gt),[g,k]=o.useState(!1),[v,S]=o.useState(!1),[y,p]=o.useState(!1),[b,N]=o.useState(!1),[A,I]=o.useState(!1),E=o.useRef(null),L=o.useRef(null),M=o.useMemo(()=>t.find(T=>T.id===a)??t[0]??null,[t,a]),D=o.useMemo(()=>ii(u,M?.id??""),[u,M]),P=o.useMemo(()=>Vm(D),[D]),B=o.useMemo(()=>D.find(T=>T.session.id===f),[f,D]),Q=o.useMemo(()=>Wm(u,M?.id??"",f),[u,M,f]),te=o.useRef(M?.id??"");o.useEffect(()=>{a&&t.some(T=>T.id===a)||i(ia(t,n))},[n,t,a]),o.useEffect(()=>{const T=M?.id??"";te.current!==T&&(te.current=T,d(gs(M)))},[M]),o.useEffect(()=>{w(T=>Gm(u,M?.id??"",g?T:""))},[u,M,g]),o.useEffect(()=>{E.current?.scrollTo({top:E.current.scrollHeight})},[u]),o.useEffect(()=>{let T=!1;async function ee(){const R=await Promise.allSettled(t.map(async V=>({node:V,response:await El(V.id)})));T||h(V=>R.reduce((O,le)=>le.status!=="fulfilled"?O:le.value.response.sessions.reduce((ie,ue)=>Ln(ie,le.value.node.name,ue),O),V))}return t.length>0&&ee(),()=>{T=!0}},[t]),o.useEffect(()=>{const T=u.filter(ot).filter(R=>R.session.status==="running");if(T.length===0)return;const ee=window.setInterval(()=>{for(const R of T)Al(R.session.nodeId,R.session.id).then(V=>h(O=>Ln(O,R.nodeName,V))).catch(()=>{})},1e3);return()=>window.clearInterval(ee)},[u]);const Y=o.useRef(null);async function H(T){if(T.preventDefault(),!M||!m.trim()||A)return;const ee=m.trim(),R=M.name;I(!0),x("");try{const V=await Dl(M.id,{command:ee,...c.trim()?{cwd:c.trim()}:{}});h(O=>Ln(O,R,V)),w(V.id),k(!0)}catch(V){h(O=>[...O,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,nodeName:R,command:ee,error:V instanceof Error?V.message:"Command failed"}])}finally{I(!1)}}async function ne(T,ee){T.stopPropagation();const R=await Ml(ee.session.nodeId,ee.session.id);h(V=>Ln(V,ee.nodeName,R))}function $(T){w(T),k(!0),S(!1)}function X(T){v&&Km(L.current,T.target)&&S(!1)}function j(T,ee,R,V,O){return e.jsxs("div",{className:"border-t border-border/60 py-1",children:[e.jsxs("button",{type:"button",onClick:V,"aria-label":`Toggle ${T} sessions`,"aria-expanded":!R,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:T}),e.jsx(tt,{className:F("h-3 w-3 transition-transform",R&&"-rotate-90")})]}),!R&&(ee.length>0?ee.map(W):e.jsx("div",{className:"node-terminal__control px-2 py-1 text-muted-foreground",children:O}))]})}function W(T){const ee=f===T.session.id,R=T.session.status==="running";return e.jsxs("div",{className:F("node-terminal__control group flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/65",ee&&"bg-primary/10 text-primary"),children:[e.jsxs("button",{type:"button",onClick:()=>$(T.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:F("flex h-4 w-4 shrink-0 items-center justify-center",R?"text-primary":T.session.status==="exited"?"text-emerald-600 dark:text-emerald-300":"text-amber-600 dark:text-amber-300"),children:R?e.jsx(he,{className:"h-3 w-3 animate-spin"}):T.session.status==="exited"?e.jsx(Vs,{className:"h-3 w-3"}):e.jsx(ls,{className:"h-3 w-3"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-foreground",children:li(T.session.command,44)}),e.jsxs("span",{className:"node-terminal__small block truncate text-muted-foreground",children:[T.nodeName," · ",sr(T.session)]})]})]}),R&&e.jsx("button",{type:"button",onClick:V=>{ne(V,T)},"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(Wr,{className:"h-3 w-3"})})]},T.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:X,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:[s?e.jsx("button",{type:"button",onClick:s,"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(ct,{className:"h-3.5 w-3.5"})}):e.jsx(Ir,{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:L,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":"Command session","aria-expanded":v,title:B?Qm(B):"All sessions",onClick:()=>S(T=>!T),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:Ym(B,f)}),e.jsx(tt,{className:F("h-3 w-3 shrink-0 text-muted-foreground transition-transform",v&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!v,className:F("absolute right-0 bottom-9 z-30 w-[19rem] overflow-hidden rounded-xl border border-border/70 bg-popover text-popover-foreground shadow-xl",!v&&"hidden"),children:e.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[e.jsxs("button",{type:"button",onClick:()=>$(Gt),className:F("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",f===Gt&&"bg-primary/10 text-primary"),children:[e.jsx(Ir,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:"All sessions"})]}),j("Active",P.active,y,()=>p(T=>!T),"No active sessions"),j("Completed",P.completed,b,()=>N(T=>!T),"No completed sessions")]})})]}),e.jsx("select",{value:M?.id??"",onChange:T=>{i(T.target.value),k(!1),d(gs(t.find(ee=>ee.id===T.target.value)??null))},disabled:A||t.length===0,"aria-label":"Terminal node",className:"node-terminal__control h-7 max-w-[11rem] rounded-sm border border-border/70 bg-background/70 px-2 text-foreground outline-none transition-colors hover:bg-muted/65 disabled:opacity-50",children:t.map(T=>e.jsx("option",{value:T.id,className:"bg-background text-foreground",children:T.name},T.id))}),e.jsx(Gn,{value:c,onChange:d,assignTo:M?.id??"",nodes:t,assignableNodes:t,layout:"composer",chipClassName:"node-terminal__control h-7 max-w-[18rem] rounded-sm border border-border/70 bg-background/70 px-2 text-foreground hover:bg-muted/65",chipActiveClassName:"font-mono",chipInactiveClassName:"text-muted-foreground",labelClassName:"node-terminal__workdir",triggerClassName:"terminal-workdir-trigger",popoverPlacement:"top",popoverAlign:"end"})]})]}),e.jsxs("div",{ref:E,className:"node-terminal__body min-h-0 flex-1 overflow-y-auto bg-muted/22 px-3 py-2 font-mono cursor-text",onClick:()=>Y.current?.focus(),children:[Q.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:Q.map(T=>ot(T)?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:[T.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:T.session.command}),e.jsxs("span",{className:F("inline-flex items-center gap-1",T.session.status==="running"||T.session.status==="exited"?"text-primary":"text-amber-600 dark:text-amber-300"),children:[T.session.status==="running"?e.jsx(he,{className:"h-3 w-3 animate-spin"}):T.session.status==="exited"?e.jsx(Vs,{className:"h-3 w-3"}):e.jsx(ls,{className:"h-3 w-3"}),sr(T.session)]}),T.session.status==="running"&&e.jsx("button",{type:"button",onClick:ee=>{ne(ee,T)},"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(Wr,{className:"h-3 w-3"})})]}),T.session.stdout&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-foreground",children:T.session.stdout}),la(T.session)&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:la(T.session)}),(T.session.stdoutTruncated||T.session.stderrTruncated)&&e.jsx("div",{className:"text-muted-foreground",children:"Output truncated to the latest output."})]},T.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:[T.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:T.command}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[e.jsx(ls,{className:"h-3 w-3"}),"error"]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:T.error})]},T.id))}),e.jsxs("form",{onSubmit:H,className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"shrink-0 text-primary select-none",children:M?`${M.name}$`:"$"}),e.jsx("input",{ref:Y,value:m,onChange:T=>x(T.target.value),disabled:!M||A,placeholder:M?"":"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:!M||!m.trim()||A,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:A?e.jsx(he,{className:"h-3 w-3 animate-spin"}):e.jsx(Yn,{className:"h-3 w-3"})})]})]})]})})}var rn={},bs,ca;function Zm(){return ca||(ca=1,bs=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),bs}var vs={},Pt={},da;function Qt(){if(da)return Pt;da=1;let t;const n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Pt.getSymbolSize=function(r){if(!r)throw new Error('"version" cannot be null or undefined');if(r<1||r>40)throw new Error('"version" should be in range from 1 to 40');return r*4+17},Pt.getSymbolTotalCodewords=function(r){return n[r]},Pt.getBCHDigit=function(s){let r=0;for(;s!==0;)r++,s>>>=1;return r},Pt.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');t=r},Pt.isKanjiModeEnabled=function(){return typeof t<"u"},Pt.toSJIS=function(r){return t(r)},Pt}var ws={},ua;function wr(){return ua||(ua=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function n(s){if(typeof s!="string")throw new Error("Param is not a string");switch(s.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+s)}}t.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},t.from=function(r,a){if(t.isValid(r))return r;try{return n(r)}catch{return a}}})(ws)),ws}var ys,ma;function Xm(){if(ma)return ys;ma=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(n){const s=Math.floor(n/8);return(this.buffer[s]>>>7-n%8&1)===1},put:function(n,s){for(let r=0;r<s;r++)this.putBit((n>>>s-r-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(n){const s=Math.floor(this.length/8);this.buffer.length<=s&&this.buffer.push(0),n&&(this.buffer[s]|=128>>>this.length%8),this.length++}},ys=t,ys}var js,ha;function eh(){if(ha)return js;ha=1;function t(n){if(!n||n<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=n,this.data=new Uint8Array(n*n),this.reservedBit=new Uint8Array(n*n)}return t.prototype.set=function(n,s,r,a){const i=n*this.size+s;this.data[i]=r,a&&(this.reservedBit[i]=!0)},t.prototype.get=function(n,s){return this.data[n*this.size+s]},t.prototype.xor=function(n,s,r){this.data[n*this.size+s]^=r},t.prototype.isReserved=function(n,s){return this.reservedBit[n*this.size+s]},js=t,js}var Ns={},fa;function th(){return fa||(fa=1,(function(t){const n=Qt().getSymbolSize;t.getRowColCoords=function(r){if(r===1)return[];const a=Math.floor(r/7)+2,i=n(r),l=i===145?26:Math.ceil((i-13)/(2*a-2))*2,c=[i-7];for(let d=1;d<a-1;d++)c[d]=c[d-1]-l;return c.push(6),c.reverse()},t.getPositions=function(r){const a=[],i=t.getRowColCoords(r),l=i.length;for(let c=0;c<l;c++)for(let d=0;d<l;d++)c===0&&d===0||c===0&&d===l-1||c===l-1&&d===0||a.push([i[c],i[d]]);return a}})(Ns)),Ns}var ks={},pa;function nh(){if(pa)return ks;pa=1;const t=Qt().getSymbolSize,n=7;return ks.getPositions=function(r){const a=t(r);return[[0,0],[a-n,0],[0,a-n]]},ks}var Ss={},xa;function sh(){return xa||(xa=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const n={N1:3,N2:3,N3:40,N4:10};t.isValid=function(a){return a!=null&&a!==""&&!isNaN(a)&&a>=0&&a<=7},t.from=function(a){return t.isValid(a)?parseInt(a,10):void 0},t.getPenaltyN1=function(a){const i=a.size;let l=0,c=0,d=0,m=null,x=null;for(let u=0;u<i;u++){c=d=0,m=x=null;for(let h=0;h<i;h++){let f=a.get(u,h);f===m?c++:(c>=5&&(l+=n.N1+(c-5)),m=f,c=1),f=a.get(h,u),f===x?d++:(d>=5&&(l+=n.N1+(d-5)),x=f,d=1)}c>=5&&(l+=n.N1+(c-5)),d>=5&&(l+=n.N1+(d-5))}return l},t.getPenaltyN2=function(a){const i=a.size;let l=0;for(let c=0;c<i-1;c++)for(let d=0;d<i-1;d++){const m=a.get(c,d)+a.get(c,d+1)+a.get(c+1,d)+a.get(c+1,d+1);(m===4||m===0)&&l++}return l*n.N2},t.getPenaltyN3=function(a){const i=a.size;let l=0,c=0,d=0;for(let m=0;m<i;m++){c=d=0;for(let x=0;x<i;x++)c=c<<1&2047|a.get(m,x),x>=10&&(c===1488||c===93)&&l++,d=d<<1&2047|a.get(x,m),x>=10&&(d===1488||d===93)&&l++}return l*n.N3},t.getPenaltyN4=function(a){let i=0;const l=a.data.length;for(let d=0;d<l;d++)i+=a.data[d];return Math.abs(Math.ceil(i*100/l/5)-10)*n.N4};function s(r,a,i){switch(r){case t.Patterns.PATTERN000:return(a+i)%2===0;case t.Patterns.PATTERN001:return a%2===0;case t.Patterns.PATTERN010:return i%3===0;case t.Patterns.PATTERN011:return(a+i)%3===0;case t.Patterns.PATTERN100:return(Math.floor(a/2)+Math.floor(i/3))%2===0;case t.Patterns.PATTERN101:return a*i%2+a*i%3===0;case t.Patterns.PATTERN110:return(a*i%2+a*i%3)%2===0;case t.Patterns.PATTERN111:return(a*i%3+(a+i)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}t.applyMask=function(a,i){const l=i.size;for(let c=0;c<l;c++)for(let d=0;d<l;d++)i.isReserved(d,c)||i.xor(d,c,s(a,d,c))},t.getBestMask=function(a,i){const l=Object.keys(t.Patterns).length;let c=0,d=1/0;for(let m=0;m<l;m++){i(m),t.applyMask(m,a);const x=t.getPenaltyN1(a)+t.getPenaltyN2(a)+t.getPenaltyN3(a)+t.getPenaltyN4(a);t.applyMask(m,a),x<d&&(d=x,c=m)}return c}})(Ss)),Ss}var Bn={},ga;function ci(){if(ga)return Bn;ga=1;const t=wr(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],s=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Bn.getBlocksCount=function(a,i){switch(i){case t.L:return n[(a-1)*4+0];case t.M:return n[(a-1)*4+1];case t.Q:return n[(a-1)*4+2];case t.H:return n[(a-1)*4+3];default:return}},Bn.getTotalCodewordsCount=function(a,i){switch(i){case t.L:return s[(a-1)*4+0];case t.M:return s[(a-1)*4+1];case t.Q:return s[(a-1)*4+2];case t.H:return s[(a-1)*4+3];default:return}},Bn}var Cs={},vn={},ba;function rh(){if(ba)return vn;ba=1;const t=new Uint8Array(512),n=new Uint8Array(256);return(function(){let r=1;for(let a=0;a<255;a++)t[a]=r,n[r]=a,r<<=1,r&256&&(r^=285);for(let a=255;a<512;a++)t[a]=t[a-255]})(),vn.log=function(r){if(r<1)throw new Error("log("+r+")");return n[r]},vn.exp=function(r){return t[r]},vn.mul=function(r,a){return r===0||a===0?0:t[n[r]+n[a]]},vn}var va;function ah(){return va||(va=1,(function(t){const n=rh();t.mul=function(r,a){const i=new Uint8Array(r.length+a.length-1);for(let l=0;l<r.length;l++)for(let c=0;c<a.length;c++)i[l+c]^=n.mul(r[l],a[c]);return i},t.mod=function(r,a){let i=new Uint8Array(r);for(;i.length-a.length>=0;){const l=i[0];for(let d=0;d<a.length;d++)i[d]^=n.mul(a[d],l);let c=0;for(;c<i.length&&i[c]===0;)c++;i=i.slice(c)}return i},t.generateECPolynomial=function(r){let a=new Uint8Array([1]);for(let i=0;i<r;i++)a=t.mul(a,new Uint8Array([1,n.exp(i)]));return a}})(Cs)),Cs}var Ts,wa;function oh(){if(wa)return Ts;wa=1;const t=ah();function n(s){this.genPoly=void 0,this.degree=s,this.degree&&this.initialize(this.degree)}return n.prototype.initialize=function(r){this.degree=r,this.genPoly=t.generateECPolynomial(this.degree)},n.prototype.encode=function(r){if(!this.genPoly)throw new Error("Encoder not initialized");const a=new Uint8Array(r.length+this.degree);a.set(r);const i=t.mod(a,this.genPoly),l=this.degree-i.length;if(l>0){const c=new Uint8Array(this.degree);return c.set(i,l),c}return i},Ts=n,Ts}var As={},Es={},Ms={},ya;function di(){return ya||(ya=1,Ms.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}),Ms}var wt={},ja;function ui(){if(ja)return wt;ja=1;const t="[0-9]+",n="[A-Z $%*+\\-./:]+";let s="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";s=s.replace(/u/g,"\\u");const r="(?:(?![A-Z0-9 $%*+\\-./:]|"+s+`)(?:.|[\r
|
|
185
|
-
]))+`;wt.KANJI=new RegExp(s,"g"),wt.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),wt.BYTE=new RegExp(r,"g"),wt.NUMERIC=new RegExp(t,"g"),wt.ALPHANUMERIC=new RegExp(n,"g");const a=new RegExp("^"+s+"$"),i=new RegExp("^"+t+"$"),l=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return wt.testKanji=function(d){return a.test(d)},wt.testNumeric=function(d){return i.test(d)},wt.testAlphanumeric=function(d){return l.test(d)},wt}var Na;function Yt(){return Na||(Na=1,(function(t){const n=di(),s=ui();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(i,l){if(!i.ccBits)throw new Error("Invalid mode: "+i);if(!n.isValid(l))throw new Error("Invalid version: "+l);return l>=1&&l<10?i.ccBits[0]:l<27?i.ccBits[1]:i.ccBits[2]},t.getBestModeForData=function(i){return s.testNumeric(i)?t.NUMERIC:s.testAlphanumeric(i)?t.ALPHANUMERIC:s.testKanji(i)?t.KANJI:t.BYTE},t.toString=function(i){if(i&&i.id)return i.id;throw new Error("Invalid mode")},t.isValid=function(i){return i&&i.bit&&i.ccBits};function r(a){if(typeof a!="string")throw new Error("Param is not a string");switch(a.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+a)}}t.from=function(i,l){if(t.isValid(i))return i;try{return r(i)}catch{return l}}})(Es)),Es}var ka;function ih(){return ka||(ka=1,(function(t){const n=Qt(),s=ci(),r=wr(),a=Yt(),i=di(),l=7973,c=n.getBCHDigit(l);function d(h,f,w){for(let g=1;g<=40;g++)if(f<=t.getCapacity(g,w,h))return g}function m(h,f){return a.getCharCountIndicator(h,f)+4}function x(h,f){let w=0;return h.forEach(function(g){const k=m(g.mode,f);w+=k+g.getBitsLength()}),w}function u(h,f){for(let w=1;w<=40;w++)if(x(h,w)<=t.getCapacity(w,f,a.MIXED))return w}t.from=function(f,w){return i.isValid(f)?parseInt(f,10):w},t.getCapacity=function(f,w,g){if(!i.isValid(f))throw new Error("Invalid QR Code version");typeof g>"u"&&(g=a.BYTE);const k=n.getSymbolTotalCodewords(f),v=s.getTotalCodewordsCount(f,w),S=(k-v)*8;if(g===a.MIXED)return S;const y=S-m(g,f);switch(g){case a.NUMERIC:return Math.floor(y/10*3);case a.ALPHANUMERIC:return Math.floor(y/11*2);case a.KANJI:return Math.floor(y/13);case a.BYTE:default:return Math.floor(y/8)}},t.getBestVersionForData=function(f,w){let g;const k=r.from(w,r.M);if(Array.isArray(f)){if(f.length>1)return u(f,k);if(f.length===0)return 1;g=f[0]}else g=f;return d(g.mode,g.getLength(),k)},t.getEncodedBits=function(f){if(!i.isValid(f)||f<7)throw new Error("Invalid QR Code version");let w=f<<12;for(;n.getBCHDigit(w)-c>=0;)w^=l<<n.getBCHDigit(w)-c;return f<<12|w}})(As)),As}var Ds={},Sa;function lh(){if(Sa)return Ds;Sa=1;const t=Qt(),n=1335,s=21522,r=t.getBCHDigit(n);return Ds.getEncodedBits=function(i,l){const c=i.bit<<3|l;let d=c<<10;for(;t.getBCHDigit(d)-r>=0;)d^=n<<t.getBCHDigit(d)-r;return(c<<10|d)^s},Ds}var _s={},Ps,Ca;function ch(){if(Ca)return Ps;Ca=1;const t=Yt();function n(s){this.mode=t.NUMERIC,this.data=s.toString()}return n.getBitsLength=function(r){return 10*Math.floor(r/3)+(r%3?r%3*3+1:0)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(r){let a,i,l;for(a=0;a+3<=this.data.length;a+=3)i=this.data.substr(a,3),l=parseInt(i,10),r.put(l,10);const c=this.data.length-a;c>0&&(i=this.data.substr(a),l=parseInt(i,10),r.put(l,c*3+1))},Ps=n,Ps}var Is,Ta;function dh(){if(Ta)return Is;Ta=1;const t=Yt(),n=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function s(r){this.mode=t.ALPHANUMERIC,this.data=r}return s.getBitsLength=function(a){return 11*Math.floor(a/2)+6*(a%2)},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(a){let i;for(i=0;i+2<=this.data.length;i+=2){let l=n.indexOf(this.data[i])*45;l+=n.indexOf(this.data[i+1]),a.put(l,11)}this.data.length%2&&a.put(n.indexOf(this.data[i]),6)},Is=s,Is}var Rs,Aa;function uh(){if(Aa)return Rs;Aa=1;const t=Yt();function n(s){this.mode=t.BYTE,typeof s=="string"?this.data=new TextEncoder().encode(s):this.data=new Uint8Array(s)}return n.getBitsLength=function(r){return r*8},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(s){for(let r=0,a=this.data.length;r<a;r++)s.put(this.data[r],8)},Rs=n,Rs}var Ls,Ea;function mh(){if(Ea)return Ls;Ea=1;const t=Yt(),n=Qt();function s(r){this.mode=t.KANJI,this.data=r}return s.getBitsLength=function(a){return a*13},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(r){let a;for(a=0;a<this.data.length;a++){let i=n.toSJIS(this.data[a]);if(i>=33088&&i<=40956)i-=33088;else if(i>=57408&&i<=60351)i-=49472;else throw new Error("Invalid SJIS character: "+this.data[a]+`
|
|
186
|
-
Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),r.put(i,13)}},Ls=s,Ls}var Bs={exports:{}},Ma;function hh(){return Ma||(Ma=1,(function(t){var n={single_source_shortest_paths:function(s,r,a){var i={},l={};l[r]=0;var c=n.PriorityQueue.make();c.push(r,0);for(var d,m,x,u,h,f,w,g,k;!c.empty();){d=c.pop(),m=d.value,u=d.cost,h=s[m]||{};for(x in h)h.hasOwnProperty(x)&&(f=h[x],w=u+f,g=l[x],k=typeof l[x]>"u",(k||g>w)&&(l[x]=w,c.push(x,w),i[x]=m))}if(typeof a<"u"&&typeof l[a]>"u"){var v=["Could not find a path from ",r," to ",a,"."].join("");throw new Error(v)}return i},extract_shortest_path_from_predecessor_list:function(s,r){for(var a=[],i=r;i;)a.push(i),s[i],i=s[i];return a.reverse(),a},find_path:function(s,r,a){var i=n.single_source_shortest_paths(s,r,a);return n.extract_shortest_path_from_predecessor_list(i,a)},PriorityQueue:{make:function(s){var r=n.PriorityQueue,a={},i;s=s||{};for(i in r)r.hasOwnProperty(i)&&(a[i]=r[i]);return a.queue=[],a.sorter=s.sorter||r.default_sorter,a},default_sorter:function(s,r){return s.cost-r.cost},push:function(s,r){var a={value:s,cost:r};this.queue.push(a),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=n})(Bs)),Bs.exports}var Da;function fh(){return Da||(Da=1,(function(t){const n=Yt(),s=ch(),r=dh(),a=uh(),i=mh(),l=ui(),c=Qt(),d=hh();function m(v){return unescape(encodeURIComponent(v)).length}function x(v,S,y){const p=[];let b;for(;(b=v.exec(y))!==null;)p.push({data:b[0],index:b.index,mode:S,length:b[0].length});return p}function u(v){const S=x(l.NUMERIC,n.NUMERIC,v),y=x(l.ALPHANUMERIC,n.ALPHANUMERIC,v);let p,b;return c.isKanjiModeEnabled()?(p=x(l.BYTE,n.BYTE,v),b=x(l.KANJI,n.KANJI,v)):(p=x(l.BYTE_KANJI,n.BYTE,v),b=[]),S.concat(y,p,b).sort(function(A,I){return A.index-I.index}).map(function(A){return{data:A.data,mode:A.mode,length:A.length}})}function h(v,S){switch(S){case n.NUMERIC:return s.getBitsLength(v);case n.ALPHANUMERIC:return r.getBitsLength(v);case n.KANJI:return i.getBitsLength(v);case n.BYTE:return a.getBitsLength(v)}}function f(v){return v.reduce(function(S,y){const p=S.length-1>=0?S[S.length-1]:null;return p&&p.mode===y.mode?(S[S.length-1].data+=y.data,S):(S.push(y),S)},[])}function w(v){const S=[];for(let y=0;y<v.length;y++){const p=v[y];switch(p.mode){case n.NUMERIC:S.push([p,{data:p.data,mode:n.ALPHANUMERIC,length:p.length},{data:p.data,mode:n.BYTE,length:p.length}]);break;case n.ALPHANUMERIC:S.push([p,{data:p.data,mode:n.BYTE,length:p.length}]);break;case n.KANJI:S.push([p,{data:p.data,mode:n.BYTE,length:m(p.data)}]);break;case n.BYTE:S.push([{data:p.data,mode:n.BYTE,length:m(p.data)}])}}return S}function g(v,S){const y={},p={start:{}};let b=["start"];for(let N=0;N<v.length;N++){const A=v[N],I=[];for(let E=0;E<A.length;E++){const L=A[E],M=""+N+E;I.push(M),y[M]={node:L,lastCount:0},p[M]={};for(let D=0;D<b.length;D++){const P=b[D];y[P]&&y[P].node.mode===L.mode?(p[P][M]=h(y[P].lastCount+L.length,L.mode)-h(y[P].lastCount,L.mode),y[P].lastCount+=L.length):(y[P]&&(y[P].lastCount=L.length),p[P][M]=h(L.length,L.mode)+4+n.getCharCountIndicator(L.mode,S))}}b=I}for(let N=0;N<b.length;N++)p[b[N]].end=0;return{map:p,table:y}}function k(v,S){let y;const p=n.getBestModeForData(v);if(y=n.from(S,p),y!==n.BYTE&&y.bit<p.bit)throw new Error('"'+v+'" cannot be encoded with mode '+n.toString(y)+`.
|
|
187
|
-
Suggested mode is: `+n.toString(p));switch(y===n.KANJI&&!c.isKanjiModeEnabled()&&(y=n.BYTE),y){case n.NUMERIC:return new s(v);case n.ALPHANUMERIC:return new r(v);case n.KANJI:return new i(v);case n.BYTE:return new a(v)}}t.fromArray=function(S){return S.reduce(function(y,p){return typeof p=="string"?y.push(k(p,null)):p.data&&y.push(k(p.data,p.mode)),y},[])},t.fromString=function(S,y){const p=u(S,c.isKanjiModeEnabled()),b=w(p),N=g(b,y),A=d.find_path(N.map,"start","end"),I=[];for(let E=1;E<A.length-1;E++)I.push(N.table[A[E]].node);return t.fromArray(f(I))},t.rawSplit=function(S){return t.fromArray(u(S,c.isKanjiModeEnabled()))}})(_s)),_s}var _a;function ph(){if(_a)return vs;_a=1;const t=Qt(),n=wr(),s=Xm(),r=eh(),a=th(),i=nh(),l=sh(),c=ci(),d=oh(),m=ih(),x=lh(),u=Yt(),h=fh();function f(N,A){const I=N.size,E=i.getPositions(A);for(let L=0;L<E.length;L++){const M=E[L][0],D=E[L][1];for(let P=-1;P<=7;P++)if(!(M+P<=-1||I<=M+P))for(let B=-1;B<=7;B++)D+B<=-1||I<=D+B||(P>=0&&P<=6&&(B===0||B===6)||B>=0&&B<=6&&(P===0||P===6)||P>=2&&P<=4&&B>=2&&B<=4?N.set(M+P,D+B,!0,!0):N.set(M+P,D+B,!1,!0))}}function w(N){const A=N.size;for(let I=8;I<A-8;I++){const E=I%2===0;N.set(I,6,E,!0),N.set(6,I,E,!0)}}function g(N,A){const I=a.getPositions(A);for(let E=0;E<I.length;E++){const L=I[E][0],M=I[E][1];for(let D=-2;D<=2;D++)for(let P=-2;P<=2;P++)D===-2||D===2||P===-2||P===2||D===0&&P===0?N.set(L+D,M+P,!0,!0):N.set(L+D,M+P,!1,!0)}}function k(N,A){const I=N.size,E=m.getEncodedBits(A);let L,M,D;for(let P=0;P<18;P++)L=Math.floor(P/3),M=P%3+I-8-3,D=(E>>P&1)===1,N.set(L,M,D,!0),N.set(M,L,D,!0)}function v(N,A,I){const E=N.size,L=x.getEncodedBits(A,I);let M,D;for(M=0;M<15;M++)D=(L>>M&1)===1,M<6?N.set(M,8,D,!0):M<8?N.set(M+1,8,D,!0):N.set(E-15+M,8,D,!0),M<8?N.set(8,E-M-1,D,!0):M<9?N.set(8,15-M-1+1,D,!0):N.set(8,15-M-1,D,!0);N.set(E-8,8,1,!0)}function S(N,A){const I=N.size;let E=-1,L=I-1,M=7,D=0;for(let P=I-1;P>0;P-=2)for(P===6&&P--;;){for(let B=0;B<2;B++)if(!N.isReserved(L,P-B)){let Q=!1;D<A.length&&(Q=(A[D]>>>M&1)===1),N.set(L,P-B,Q),M--,M===-1&&(D++,M=7)}if(L+=E,L<0||I<=L){L-=E,E=-E;break}}}function y(N,A,I){const E=new s;I.forEach(function(B){E.put(B.mode.bit,4),E.put(B.getLength(),u.getCharCountIndicator(B.mode,N)),B.write(E)});const L=t.getSymbolTotalCodewords(N),M=c.getTotalCodewordsCount(N,A),D=(L-M)*8;for(E.getLengthInBits()+4<=D&&E.put(0,4);E.getLengthInBits()%8!==0;)E.putBit(0);const P=(D-E.getLengthInBits())/8;for(let B=0;B<P;B++)E.put(B%2?17:236,8);return p(E,N,A)}function p(N,A,I){const E=t.getSymbolTotalCodewords(A),L=c.getTotalCodewordsCount(A,I),M=E-L,D=c.getBlocksCount(A,I),P=E%D,B=D-P,Q=Math.floor(E/D),te=Math.floor(M/D),Y=te+1,H=Q-te,ne=new d(H);let $=0;const X=new Array(D),j=new Array(D);let W=0;const T=new Uint8Array(N.buffer);for(let le=0;le<D;le++){const ie=le<B?te:Y;X[le]=T.slice($,$+ie),j[le]=ne.encode(X[le]),$+=ie,W=Math.max(W,ie)}const ee=new Uint8Array(E);let R=0,V,O;for(V=0;V<W;V++)for(O=0;O<D;O++)V<X[O].length&&(ee[R++]=X[O][V]);for(V=0;V<H;V++)for(O=0;O<D;O++)ee[R++]=j[O][V];return ee}function b(N,A,I,E){let L;if(Array.isArray(N))L=h.fromArray(N);else if(typeof N=="string"){let Q=A;if(!Q){const te=h.rawSplit(N);Q=m.getBestVersionForData(te,I)}L=h.fromString(N,Q||40)}else throw new Error("Invalid data");const M=m.getBestVersionForData(L,I);if(!M)throw new Error("The amount of data is too big to be stored in a QR Code");if(!A)A=M;else if(A<M)throw new Error(`
|
|
188
|
-
The chosen QR Code version cannot contain this amount of data.
|
|
189
|
-
Minimum version required to store current data is: `+M+`.
|
|
190
|
-
`);const D=y(A,I,L),P=t.getSymbolSize(A),B=new r(P);return f(B,A),w(B),g(B,A),v(B,I,0),A>=7&&k(B,A),S(B,D),isNaN(E)&&(E=l.getBestMask(B,v.bind(null,B,I))),l.applyMask(E,B),v(B,I,E),{modules:B,version:A,errorCorrectionLevel:I,maskPattern:E,segments:L}}return vs.create=function(A,I){if(typeof A>"u"||A==="")throw new Error("No input text");let E=n.M,L,M;return typeof I<"u"&&(E=n.from(I.errorCorrectionLevel,n.M),L=m.from(I.version),M=l.from(I.maskPattern),I.toSJISFunc&&t.setToSJISFunction(I.toSJISFunc)),b(A,L,E,M)},vs}var Os={},Fs={},Pa;function mi(){return Pa||(Pa=1,(function(t){function n(s){if(typeof s=="number"&&(s=s.toString()),typeof s!="string")throw new Error("Color should be defined as hex string");let r=s.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+s);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(i){return[i,i]}))),r.length===6&&r.push("F","F");const a=parseInt(r.join(""),16);return{r:a>>24&255,g:a>>16&255,b:a>>8&255,a:a&255,hex:"#"+r.slice(0,6).join("")}}t.getOptions=function(r){r||(r={}),r.color||(r.color={});const a=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,i=r.width&&r.width>=21?r.width:void 0,l=r.scale||4;return{width:i,scale:i?4:l,margin:a,color:{dark:n(r.color.dark||"#000000ff"),light:n(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},t.getScale=function(r,a){return a.width&&a.width>=r+a.margin*2?a.width/(r+a.margin*2):a.scale},t.getImageWidth=function(r,a){const i=t.getScale(r,a);return Math.floor((r+a.margin*2)*i)},t.qrToImageData=function(r,a,i){const l=a.modules.size,c=a.modules.data,d=t.getScale(l,i),m=Math.floor((l+i.margin*2)*d),x=i.margin*d,u=[i.color.light,i.color.dark];for(let h=0;h<m;h++)for(let f=0;f<m;f++){let w=(h*m+f)*4,g=i.color.light;if(h>=x&&f>=x&&h<m-x&&f<m-x){const k=Math.floor((h-x)/d),v=Math.floor((f-x)/d);g=u[c[k*l+v]?1:0]}r[w++]=g.r,r[w++]=g.g,r[w++]=g.b,r[w]=g.a}}})(Fs)),Fs}var Ia;function xh(){return Ia||(Ia=1,(function(t){const n=mi();function s(a,i,l){a.clearRect(0,0,i.width,i.height),i.style||(i.style={}),i.height=l,i.width=l,i.style.height=l+"px",i.style.width=l+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(i,l,c){let d=c,m=l;typeof d>"u"&&(!l||!l.getContext)&&(d=l,l=void 0),l||(m=r()),d=n.getOptions(d);const x=n.getImageWidth(i.modules.size,d),u=m.getContext("2d"),h=u.createImageData(x,x);return n.qrToImageData(h.data,i,d),s(u,m,x),u.putImageData(h,0,0),m},t.renderToDataURL=function(i,l,c){let d=c;typeof d>"u"&&(!l||!l.getContext)&&(d=l,l=void 0),d||(d={});const m=t.render(i,l,d),x=d.type||"image/png",u=d.rendererOpts||{};return m.toDataURL(x,u.quality)}})(Os)),Os}var zs={},Ra;function gh(){if(Ra)return zs;Ra=1;const t=mi();function n(a,i){const l=a.a/255,c=i+'="'+a.hex+'"';return l<1?c+" "+i+'-opacity="'+l.toFixed(2).slice(1)+'"':c}function s(a,i,l){let c=a+i;return typeof l<"u"&&(c+=" "+l),c}function r(a,i,l){let c="",d=0,m=!1,x=0;for(let u=0;u<a.length;u++){const h=Math.floor(u%i),f=Math.floor(u/i);!h&&!m&&(m=!0),a[u]?(x++,u>0&&h>0&&a[u-1]||(c+=m?s("M",h+l,.5+f+l):s("m",d,0),d=0,m=!1),h+1<i&&a[u+1]||(c+=s("h",x),x=0)):d++}return c}return zs.render=function(i,l,c){const d=t.getOptions(l),m=i.modules.size,x=i.modules.data,u=m+d.margin*2,h=d.color.light.a?"<path "+n(d.color.light,"fill")+' d="M0 0h'+u+"v"+u+'H0z"/>':"",f="<path "+n(d.color.dark,"stroke")+' d="'+r(x,m,d.margin)+'"/>',w='viewBox="0 0 '+u+" "+u+'"',k='<svg xmlns="http://www.w3.org/2000/svg" '+(d.width?'width="'+d.width+'" height="'+d.width+'" ':"")+w+' shape-rendering="crispEdges">'+h+f+`</svg>
|
|
191
|
-
`;return typeof c=="function"&&c(null,k),k},zs}var La;function bh(){if(La)return rn;La=1;const t=Zm(),n=ph(),s=xh(),r=gh();function a(i,l,c,d,m){const x=[].slice.call(arguments,1),u=x.length,h=typeof x[u-1]=="function";if(!h&&!t())throw new Error("Callback required as last argument");if(h){if(u<2)throw new Error("Too few arguments provided");u===2?(m=c,c=l,l=d=void 0):u===3&&(l.getContext&&typeof m>"u"?(m=d,d=void 0):(m=d,d=c,c=l,l=void 0))}else{if(u<1)throw new Error("Too few arguments provided");return u===1?(c=l,l=d=void 0):u===2&&!l.getContext&&(d=c,c=l,l=void 0),new Promise(function(f,w){try{const g=n.create(c,d);f(i(g,l,d))}catch(g){w(g)}})}try{const f=n.create(c,d);m(null,i(f,l,d))}catch(f){m(f)}}return rn.create=n.create,rn.toCanvas=a.bind(null,s.render),rn.toDataURL=a.bind(null,s.renderToDataURL),rn.toString=a.bind(null,function(i,l,c){return r.render(i,c)}),rn}var vh=bh();function hi(t){return vh.toDataURL(t,{errorCorrectionLevel:"M",margin:2,scale:8,color:{dark:"#111827ff",light:"#ffffffff"}})}function wh({title:t,description:n,triggerLabel:s,qrValue:r,displayValue:a,hint:i,imageAlt:l,copyLabel:c,copiedMessage:d}){const[m,x]=o.useState(!1),[u,h]=o.useState(null),[f,w]=o.useState(null);return o.useEffect(()=>{if(!m)return;let g=!1;return h(null),w(null),hi(r).then(k=>{g||h(k)}).catch(()=>{g||w("QR code unavailable")}),()=>{g=!0}},[m,r]),e.jsxs(ut,{open:m,onOpenChange:x,children:[e.jsx(go,{asChild:!0,children:e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"h-4 w-4 shrink-0 rounded-sm p-0 text-muted-foreground opacity-70 hover:bg-muted/45 hover:opacity-100 [&_svg]:size-2.5","aria-label":s,title:s,children:e.jsx(Bo,{className:"h-3 w-3"})})}),e.jsxs(mt,{className:"max-w-[20rem] gap-2 p-3",children:[e.jsxs(Tt,{className:"space-y-1 text-left",children:[e.jsx(gt,{className:"text-[12px]",children:t}),e.jsx(At,{children:n})]}),e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"flex h-52 w-52 items-center justify-center rounded-sm bg-white p-2 text-[10px] text-muted-foreground",children:u?e.jsx("img",{src:u,alt:l,className:"h-full w-full"}):f?e.jsx("span",{children:f}):e.jsx(he,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),e.jsx("div",{className:"w-full rounded-sm bg-primary/10 px-2 py-1 text-center text-[10px] font-medium text-foreground",children:i}),e.jsx("div",{className:"w-full rounded-sm bg-muted/45 px-2 py-1.5 font-mono text-[9px] leading-[0.95rem] text-foreground break-all",children:a}),e.jsx(Z,{type:"button",variant:"secondary",size:"sm",className:"h-6 w-full border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",onClick:()=>{An(a,d)},children:c})]})]})]})}function yh(t,n){const s=Date.parse(t)-n;if(!Number.isFinite(s)||s<=0)return"expired";const r=Math.ceil(s/1e3),a=Math.floor(r/60),i=r%60;return a>0?`${a}m ${i.toString().padStart(2,"0")}s`:`${r}s`}function jh(t,n){return t?t.invitation.status==="active"&&Date.parse(t.invitation.expiresAt)<=n?"expired":t.invitation.status:"loading"}function Nh(t){switch(t){case"active":return{label:"Active",tone:"bg-emerald-500/10 text-emerald-500",icon:Gr};case"consumed":return{label:"Paired",tone:"bg-emerald-500/10 text-emerald-500",icon:Vs};case"expired":return{label:"Expired",tone:"bg-amber-500/10 text-amber-500",icon:ms};case"cancelled":return{label:"Cancelled",tone:"bg-destructive/10 text-destructive",icon:ms};case"error":return{label:"Unavailable",tone:"bg-destructive/10 text-destructive",icon:ms};default:return{label:"Loading",tone:"bg-muted text-muted-foreground",icon:Gr}}}function kh({nodeName:t,nodeEndpoint:n}){const[s,r]=o.useState(!1),[a,i]=o.useState(null),[l,c]=o.useState(null),[d,m]=o.useState(null),[x,u]=o.useState(!1),[h,f]=o.useState(()=>Date.now()),w=`Show ${t} mobile pairing QR code`,g=o.useMemo(()=>a?_l(a.qr):null,[a]),k=d?"error":jh(a,h),v=Nh(k),S=v.icon,y=o.useCallback(async()=>{u(!0),m(null),c(null);try{const p=await Pl();i(p),f(Date.now())}catch(p){i(null),m(p instanceof Error?p.message:"Mobile pairing QR unavailable")}finally{u(!1)}},[]);return o.useEffect(()=>{s&&y()},[s,y]),o.useEffect(()=>{if(!s)return;const p=window.setInterval(()=>f(Date.now()),1e3);return()=>window.clearInterval(p)},[s]),o.useEffect(()=>{if(!s||!a||k!=="active")return;let p=!1;const b=window.setInterval(()=>{Il(a.invitation.pairingId).then(N=>{p||i(A=>A&&{...A,invitation:N.invitation})}).catch(()=>{p||m("Pairing status unavailable")})},2e3);return()=>{p=!0,window.clearInterval(b)}},[s,a?.invitation.pairingId,k]),o.useEffect(()=>{if(!s||!g)return;let p=!1;return c(null),hi(g).then(b=>{p||c(b)}).catch(()=>{p||m("QR code unavailable")}),()=>{p=!0}},[s,g]),e.jsxs(ut,{open:s,onOpenChange:r,children:[e.jsx(go,{asChild:!0,children:e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"h-4 w-4 shrink-0 rounded-sm p-0 text-muted-foreground opacity-70 hover:bg-muted/45 hover:opacity-100 [&_svg]:size-2.5","aria-label":w,title:w,children:e.jsx(Bo,{className:"h-3 w-3"})})}),e.jsxs(mt,{className:"max-w-[20rem] gap-2 p-3",children:[e.jsxs(Tt,{className:"space-y-1 text-left",children:[e.jsx(gt,{className:"text-[12px]",children:"Mobile pairing QR"}),e.jsx(At,{children:t})]}),e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsxs("div",{className:"relative flex h-52 w-52 items-center justify-center rounded-sm bg-white p-2 text-[10px] text-muted-foreground",children:[l?e.jsx("img",{src:l,alt:`${t} mobile pairing QR code`,className:"h-full w-full"}):d?e.jsx("span",{className:"px-3 text-center",children:d}):e.jsx(he,{className:"h-5 w-5 animate-spin text-muted-foreground"}),l&&k!=="active"?e.jsxs("div",{className:"absolute inset-2 flex items-center justify-center rounded-sm bg-background/85 px-3 text-center text-[10px] font-medium text-foreground",children:[v.label,". Refresh to create a new QR."]}):null]}),e.jsxs("div",{className:"grid w-full grid-cols-[1fr_auto] items-center gap-2 rounded-sm bg-muted/45 px-2 py-1.5",children:[e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx("div",{className:"truncate font-mono text-[9px] leading-3 text-foreground",children:a?.invitation.apiBaseUrl??n}),e.jsx("div",{className:"text-[9px] leading-3 text-muted-foreground",children:a?`${a.invitation.usedCount}/${a.invitation.maxUses} used - ${yh(a.invitation.expiresAt,h)}`:"Creating invitation"})]}),e.jsxs("div",{className:`flex h-5 items-center gap-1 rounded-sm px-1.5 text-[9px] font-medium ${v.tone}`,children:[e.jsx(S,{className:"h-3 w-3"}),v.label]})]}),e.jsx("div",{className:"w-full rounded-sm bg-primary/10 px-2 py-1 text-center text-[10px] font-medium text-foreground",children:"Scan with Meshy Mobile"}),e.jsxs("div",{className:"grid w-full grid-cols-2 gap-2",children:[e.jsx(Z,{type:"button",variant:"secondary",size:"sm",className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",onClick:()=>{An(a?.invitation.apiBaseUrl??n,"Node URL copied")},children:"Copy URL"}),e.jsxs(Z,{type:"button",variant:"secondary",size:"sm",className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",disabled:x,onClick:()=>{y()},children:[x?e.jsx(he,{className:"mr-1 h-3 w-3 animate-spin"}):e.jsx(bo,{className:"mr-1 h-3 w-3"}),"Refresh"]})]})]})]})]})}function Sh({nodeName:t,dashboardUrl:n}){const s=`Show ${t} dashboard QR code`;return e.jsx(wh,{title:"Dashboard URL QR",description:t,triggerLabel:s,qrValue:n,displayValue:n,hint:"Scan with Edge to view the dashboard",imageAlt:`${t} dashboard URL QR code`,copyLabel:"Copy dashboard URL",copiedMessage:"Dashboard URL copied"})}function Ch(t){return t?{left:t.left,top:t.top}:{left:0,top:0,visibility:"hidden"}}function Th(t,n,s,r=1){const l=n.width||160,c=n.height||0,d=Number.isFinite(r)&&r>0?r:1,m=t.right-t.left<1,x=t.right+4,u=m?x+l<=s.width-8?x:Math.max(8,t.left-4-l):Math.max(8,Math.min(t.right-l,s.width-l-8)),h=t.bottom+4,f=(t.top??t.bottom)-c-4,w=h+c>s.height-8&&f>=8?f:h;return{left:Math.round(u/d),top:Math.round(w/d)}}function Ah(){if(typeof window>"u"||typeof document>"u")return 1;const t=window.getComputedStyle(document.documentElement),n=t.zoom||t.getPropertyValue("--ui-zoom"),s=Number.parseFloat(n);return Number.isFinite(s)&&s>0?s:1}const yr="fixed z-[130] min-w-36 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";function jr({contextOpen:t=!1,contextPosition:n=null,defaultOpen:s=!1,onContextOpenChange:r}){const[a,i]=o.useState(s),[l,c]=o.useState(null),d=o.useRef(null),m=o.useRef(null),x=a||t,u=o.useCallback(()=>{i(!1),r?.(!1)},[r]),h=o.useCallback(()=>{i(f=>(f||c(null),r?.(!1),!f))},[r]);return o.useLayoutEffect(()=>{if(!x){c(null);return}const f=()=>{const w=d.current;if(!w)return;const g=w.getBoundingClientRect(),k=t&&n?{left:n.left,right:n.left,top:n.top,bottom:n.top}:m.current?.getBoundingClientRect();k&&c(Th({left:k.left,right:k.right,top:k.top,bottom:k.bottom},{width:g.width,height:g.height},{width:window.innerWidth,height:window.innerHeight},Ah()))};return f(),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0)}},[t,n,x]),o.useEffect(()=>{if(!x)return;const f=g=>{const k=g.target;k instanceof Node&&!d.current?.contains(k)&&!m.current?.contains(k)&&u()},w=g=>{g.key==="Escape"&&u()};return document.addEventListener("mousedown",f),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",w)}},[x,u]),{open:x,menuRef:d,triggerRef:m,menuStyle:Ch(l),closeMenu:u,toggleButton:h}}function Je({ariaLabel:t,children:n,destructive:s,disabled:r,icon:a,onClick:i,pending:l,title:c}){return e.jsxs("button",{type:"button",role:"menuitem","aria-label":t,title:c,disabled:r||l,onClick:d=>{d.stopPropagation(),!r&&!l&&i()},className:F("flex w-full items-center gap-1.5 rounded-sm px-2 py-1 text-left text-[10px] font-medium text-foreground transition-colors hover:bg-muted/80 disabled:cursor-not-allowed disabled:opacity-60",s&&"text-destructive hover:bg-destructive/10"),children:[l?e.jsx(he,{className:"h-3 w-3 animate-spin text-primary"}):a,e.jsx("span",{children:n})]})}const Eh=new Set(["completed","failed","cancelled","archived"]);function Mh(t){return typeof t=="object"&&t!==null}function fi(t){return typeof t=="string"&&t.trim().length>0?t.trim():""}function Cn(t){return typeof t!="number"||!Number.isFinite(t)?"Unavailable":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}function Dh(t){return t==="nativeSession"?"Native session":"Meshy chat"}function _h(t){return t.effectiveProjectPath??t.project??"default workspace"}function Ph(t){return Mh(t.agentSessions)?Object.keys(t.agentSessions).map(n=>n.trim()).filter(Boolean):[]}function Ih(t){const n=new Set;t.agent&&n.add(t.agent);const s=fi(t.payload.activeAgent);s&&n.add(s);for(const r of Ph(t.payload))n.add(r);return Array.from(n).join(", ")||"None"}function Rh(t){return t.status!=="running"?"None":fi(t.payload.activeAgent)||t.agent||"None"}function Lh(t){return t.assignedNodeName??t.assignedTo??"Unassigned"}function Bh(t){const n=t.reduce((s,r)=>Math.max(s,r.updatedAt),0);return n>0?Cn(n):"No task activity"}function wn(t,n){return t.filter(s=>n.has(s.status)).length}function Nr({rows:t}){return e.jsx("div",{className:"overflow-hidden rounded-sm border border-border/55 bg-background/35",children:t.map(n=>e.jsxs("div",{className:"grid grid-cols-[5.75rem_minmax(0,1fr)] gap-2 border-b border-border/45 px-2 py-1.5 last:border-b-0",children:[e.jsx("div",{className:"min-w-0 break-words text-[9px] font-semibold uppercase tracking-[0.12em] text-muted-foreground/70",children:n.label}),e.jsx("div",{className:n.mono?"min-w-0 break-all font-mono text-[10px] leading-4 text-foreground/85":"min-w-0 break-words text-[10px] leading-4 text-foreground/85",children:n.value})]},n.label))})}function Oh({task:t}){const n=Eh.has(t.status),s=[{label:"Status",value:t.status},{label:"Kind",value:Dh(t.conversationKind)},{label:"Priority",value:t.priority},{label:"Created",value:Cn(t.createdAt)},{label:n?"Finished":"Updated",value:Cn(t.updatedAt)}];return s.push({label:"Assigned node",value:Lh(t)},{label:"Workspace",value:_h(t),mono:!0}),t.branch&&s.push({label:"Branch",value:t.branch,mono:!0}),s.push({label:"Task agents",value:Ih(t)},{label:"Running agents",value:Rh(t)},{label:"Retries",value:`${t.retryCount}/${t.maxRetries}`},{label:"Created by",value:t.createdBy},{label:"Task ID",value:t.id,mono:!0}),e.jsx(Nr,{rows:s})}function Fh({dirPath:t,nodeId:n,nodeName:s,nodeStatus:r,tasks:a,unloadedCompletedCount:i=0}){const l=Math.max(0,i),c=wn(a,new Set(["completed"]))+l,d=wn(a,new Set(["failed","cancelled"])),m=wn(a,new Set(["archived"])),x=[{label:"Path",value:t,mono:!0},{label:"Node",value:s??n??"Unassigned"},{label:"Node ID",value:n??"Unassigned",mono:!!n},{label:"Node status",value:r??"unknown"},{label:"Task count",value:String(a.length+l)},{label:"Assigned",value:String(wn(a,new Set(["assigned"])))},{label:"Running",value:String(wn(a,new Set(["running"])))},{label:"Completed",value:String(c)},{label:"Failed / cancelled",value:String(d)},{label:"Archived",value:String(m)},{label:"Latest update",value:Bh(a)}];return e.jsx(Nr,{rows:x})}function zh({task:t,open:n,onOpenChange:s}){return e.jsx(ut,{open:n,onOpenChange:s,children:e.jsxs(mt,{className:"max-w-[25rem] gap-3 rounded-sm border-border/70 bg-background/96 p-4 backdrop-blur-xl",children:[e.jsxs(Tt,{className:"space-y-1",children:[e.jsx(gt,{className:"text-[13px]",children:"Task properties"}),e.jsx(At,{className:"truncate text-[10px] leading-4 text-muted-foreground",children:t.title})]}),e.jsx(Oh,{task:t})]})})}function Uh({dirPath:t,nodeId:n,nodeName:s,nodeStatus:r,tasks:a,unloadedCompletedCount:i,open:l,onOpenChange:c}){return e.jsx(ut,{open:l,onOpenChange:c,children:e.jsxs(mt,{className:"max-w-[25rem] gap-3 rounded-sm border-border/70 bg-background/96 p-4 backdrop-blur-xl",children:[e.jsxs(Tt,{className:"space-y-1",children:[e.jsx(gt,{className:"text-[13px]",children:"Project properties"}),e.jsx(At,{className:"truncate text-[10px] leading-4 text-muted-foreground",children:t})]}),e.jsx(Fh,{dirPath:t,nodeId:n,nodeName:s,nodeStatus:r,tasks:a,unloadedCompletedCount:i})]})})}function $h({nodeId:t,nodeName:n,node:s}){const r=[{label:"Name",value:s?.name??n},{label:"Node ID",value:t,mono:!0}];return s&&(r.push({label:"Role",value:s.role},{label:"Status",value:s.status},{label:"Endpoint",value:s.endpoint,mono:!0}),s.transportType&&r.push({label:"Transport",value:s.transportType}),r.push({label:"Capabilities",value:s.capabilities.length>0?s.capabilities.join(", "):"None"},{label:"Agents",value:s.supportedAgents&&s.supportedAgents.length>0?s.supportedAgents.join(", "):"None"}),s.workDir&&r.push({label:"Work dir",value:s.workDir,mono:!0}),r.push({label:"Joined",value:Cn(s.joinedAt)},{label:"Heartbeat",value:Cn(s.lastHeartbeat)})),e.jsx(Nr,{rows:r})}function qh({nodeId:t,nodeName:n,node:s,open:r,onOpenChange:a}){return e.jsx(ut,{open:r,onOpenChange:a,children:e.jsxs(mt,{className:"max-w-[25rem] gap-3 rounded-sm border-border/70 bg-background/96 p-4 backdrop-blur-xl",children:[e.jsxs(Tt,{className:"space-y-1",children:[e.jsx(gt,{className:"text-[13px]",children:"Node properties"}),e.jsx(At,{className:"truncate text-[10px] leading-4 text-muted-foreground",children:s?.name??n})]}),e.jsx($h,{nodeId:t,nodeName:n,node:s})]})})}function kr({nodeId:t,nodeName:n,node:s,contextOpen:r=!1,contextPosition:a=null,defaultOpen:i=!1,onContextOpenChange:l,onOpenSettings:c,onOpenServicePreview:d,onOpenCapabilities:m,onOpenDevBox:x,onStartDevBox:u,onToggleRemoteAccess:h,remoteAccessLabel:f,remoteAccessPending:w,remoteAccessDisabled:g,remoteAccessDisabledReason:k,showConfigureDevBox:v,showStartDevBox:S,startDevBoxPending:y,className:p}){const{open:b,menuRef:N,triggerRef:A,menuStyle:I,closeMenu:E,toggleButton:L}=jr({contextOpen:r,contextPosition:a,defaultOpen:i,onContextOpenChange:l}),[M,D]=o.useState(!1),P=y?"Starting":"Start DevBox",B=f?.startsWith("Disable")?Rl:Jd,Q=b?e.jsxs("div",{ref:N,"data-node-action-menu-portal":"true",role:"menu",style:I,onClick:te=>te.stopPropagation(),onPointerDown:te=>te.stopPropagation(),className:yr,children:[c&&e.jsx(Je,{ariaLabel:`Open ${n} settings`,title:`Open ${n} settings`,icon:e.jsx(Ll,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{E(),c(t)},children:"Settings"}),d&&e.jsx(Je,{ariaLabel:`Preview service on ${n}`,title:`Preview service on ${n}`,icon:e.jsx(Ro,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{E(),d(t)},children:"Preview service"}),m&&e.jsx(Je,{ariaLabel:`Open ${n} capabilities`,title:`Open ${n} capabilities`,icon:e.jsx(En,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{E(),m(t)},children:"Capabilities"}),f&&h&&e.jsx(Je,{ariaLabel:`${f} for ${n}`,title:k??`${f} for ${n}`,icon:e.jsx(B,{className:"h-3 w-3 shrink-0 text-primary"}),pending:w,disabled:g,onClick:()=>{E(),h()},children:f}),S&&u&&e.jsx(Je,{ariaLabel:`${P} for ${n}`,title:`${P} for ${n}`,icon:e.jsx(Yn,{className:"h-3 w-3 shrink-0 text-primary"}),pending:y,onClick:()=>{E(),u(t)},children:P}),v&&x&&e.jsx(Je,{ariaLabel:`Configure DevBox for ${n}`,title:`Configure DevBox for ${n}`,icon:e.jsx(Bl,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{E(),x(t)},children:"Configure DevBox"}),e.jsx(Je,{ariaLabel:`Properties for ${n}`,title:`Properties for ${n}`,icon:e.jsx(cr,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{E(),D(!0)},children:"Properties"})]}):null;return e.jsxs("div",{"data-node-action-menu":"true",className:F("relative shrink-0",b&&"z-[120]",p),onClick:te=>te.stopPropagation(),onPointerDown:te=>te.stopPropagation(),children:[e.jsx(Z,{ref:A,type:"button",variant:"ghost",size:"icon","aria-label":`More actions for ${n}`,"aria-haspopup":"menu","aria-expanded":b,title:`More actions for ${n}`,onClick:te=>{te.stopPropagation(),L()},className:F("h-6 w-6 rounded-sm text-muted-foreground hover:bg-background/70 hover:text-foreground",b&&"bg-background/80 text-primary"),children:e.jsx(pr,{className:"h-3.5 w-3.5"})}),Q&&(typeof document>"u"?Q:Qn.createPortal(Q,document.body)),M&&e.jsx(qh,{nodeId:t,nodeName:n,node:s,open:M,onOpenChange:D})]})}const Hh=new Set(["deallocated","hibernate","hibernated","sleep","sleeping","stopped"]),Vh=new Set(["startinprogress","starting"]);function on(t){return!!(t?.enabled&&t.name)}function Kh(t){const n=t?.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(n&&Hh.has(n))}function ln(t){const n=t?.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(n&&Vh.has(n))}function Zn(t,n,s){return t==="offline"&&Kh(n)&&on(s)}function Ba(t,n){return t==="offline"&&on(n)}function Oa(t){return!on(t)}function Gh({nodeStatus:t,status:n,current:s,selected:r}){const a=r??s;return a&&Zn(t,n,a)?a:null}function We(t){return t.scope||`name:${t.name??""}`}function Wh({previousKey:t,baseDevBox:n,listed:s}){if(t&&s.some(i=>We(i)===t))return t;if(!on(n))return s[0]?We(s[0]):"";const r=We(n),a=s.find(i=>We(i)===r)??s.find(i=>i.name===n.name);return a?We(a):r}function Qh(t){return t==="nodes"||t==="events"?t:"overview"}function Yh({cluster:t,systemInfo:n,nodeNameById:s,nodeBlockingTaskCounts:r,eventTypeFilter:a,onEventTypeFilterChange:i,eventTypeOptions:l,filteredEvents:c,sseConnected:d,clusterLoading:m,clusterError:x,promotePending:u,onPromote:h,onAddNode:f,leavePending:w,onLeaveCluster:g,onToggleNodeDevTunnel:k,devTunnelNodeId:v,devBoxStartNodeId:S,devBoxStartingNodeIds:y=new Set,activeTab:p,onTabChange:b,onOpenNodeSettings:N,onOpenNodeCapabilities:A,onOpenDevBox:I,onStartDevBox:E}){const L=t?.self?.role==="leader",M=t?.self?.role==="follower"&&!t?.leader,D=t?.self??null,B=Ol(t?.nodes??[],D?.id).filter(R=>R.id!==D?.id),Q=t?.leader?t.nodes.find(R=>R.id===t.leader?.id)??null:null,te=t?.leader?t.leader.dashboardOrigin??Q?.dashboardOrigin??(n&&t.leader.id===(n.nodeId??n.id)?n.dashboardOrigin:void 0)??t.leader.endpoint:null,Y=t?.leader?Q?.devtunnelEndpoint??t.leader.endpoint:null,H=t?.leader?.name??Q?.name??"Leader",ne=!!(t?.leader?.id&&t.leader.id===D?.id),$=D?.role==="leader"&&B.length===0,X=D?.role==="follower",[j,W]=o.useState("overview"),T=p??j;function ee(R){const V=Qh(R);W(V),b?.(V)}return e.jsx("aside",{className:"dashboard-operations-sidecar dashboard-panel dashboard-panel-muted animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:e.jsxs(or,{value:T,onValueChange:ee,className:"flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"dashboard-operations-sidecar__header shrink-0 bg-card/24 px-2.5 py-2",children:e.jsxs(ar,{className:"grid h-auto w-full grid-cols-3 rounded-sm bg-muted/55 p-0.5",children:[e.jsx(Ot,{value:"overview",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Overview"}),e.jsx(Ot,{value:"nodes",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Nodes"}),e.jsx(Ot,{value:"events",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Live events"})]})}),e.jsx(yt,{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:[D&&e.jsx(Fa,{node:D,systemInfo:n,blockingTaskCount:r.get(D.id)??0,devTunnelNodeId:v,onToggleNodeDevTunnel:k,showActions:!1,defaultExpanded:!1,onOpenDevBox:I,devBoxStartingNodeIds:y}),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(Ze,{variant:"secondary",className:"rounded-sm border-0 bg-muted/60 px-1.5 py-0 text-[9px] leading-4 shadow-none",children:d?"Connected":"Reconnecting"})]}),m&&!t?e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground",children:[e.jsx(he,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):x&&!t?e.jsx("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-2 py-1.5 text-[10px] text-destructive shadow-none",children:x}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx(sn,{label:"Term",value:String(t?.term??0)}),e.jsx(sn,{label:"Nodes",value:String(t?.nodes.length??0)}),e.jsx(sn,{label:"Pending",value:String(t?.taskSummary.pending??0)}),e.jsx(sn,{label:"Running",value:String(t?.taskSummary.running??0)}),e.jsx(sn,{label:"Completed",value:String(t?.taskSummary.completed??0)}),e.jsx(sn,{label:"Failed",value:String(t?.taskSummary.failed??0)})]}),e.jsxs("div",{className:"space-y-1.5 rounded-sm bg-muted/45 px-2 py-2 shadow-none",children:[e.jsx(it,{label:"Leader",value:t?.leader?.name??"None"}),e.jsx(it,{label:"Leader Dashboard URL",value:te??"Unavailable",mono:!0,action:te?e.jsx(Cr,{nodeName:H,dashboardUrl:te,copyLabel:"Copy leader dashboard URL",copiedMessage:"Leader Dashboard URL copied"}):void 0}),Y&&e.jsx(it,{label:"Leader Node URL",value:Y,mono:!0,action:e.jsx(Sr,{nodeName:H,nodeEndpoint:Y,copyLabel:"Copy leader node URL",copiedMessage:"Leader Node URL copied",showPairingQr:ne})}),e.jsx(it,{label:"Feed",value:d?"Receiving live updates":"Reconnecting to event stream"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:M&&e.jsxs(Z,{variant:"secondary",size:"sm",onClick:h,disabled:u,className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",children:[u&&e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})})]})]})]})})}),e.jsx(yt,{value:"nodes",className:"mt-0 min-h-0 flex-1",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto px-2 py-2",children:e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-[10px] font-medium text-foreground",children:"This node"}),$?e.jsxs(Z,{variant:"secondary",size:"sm",onClick:f,className:"h-6 border-0 bg-primary px-2 text-[10px] text-primary-foreground shadow-none hover:bg-primary/90",children:[e.jsx(Qd,{className:"h-3 w-3"}),"Join node"]}):X?e.jsxs(Z,{variant:"secondary",size:"sm",onClick:g,disabled:w,className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",children:[w&&e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),D&&e.jsx(Fa,{node:D,systemInfo:n,blockingTaskCount:r.get(D.id)??0,devTunnelNodeId:v,onToggleNodeDevTunnel:k,showActions:!0,defaultExpanded:!0,onOpenNodeSettings:L?N:void 0,onOpenNodeCapabilities:L?A:void 0,onOpenDevBox:L?I:void 0,onStartDevBox:L?E:void 0,devBoxStartNodeId:S,devBoxStartingNodeIds:y})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"text-[10px] font-medium text-foreground",children:["Peer nodes (",B.length,")"]}),B.length>0?e.jsx("div",{className:"space-y-1.5",children:B.map(R=>e.jsx(Jh,{node:R,isLeader:!!L,blockingTaskCount:r.get(R.id)??0,devTunnelNodeId:v,onToggleNodeDevTunnel:k,onOpenNodeSettings:L?N:void 0,onOpenNodeCapabilities:L?A:void 0,onOpenDevBox:L?I:void 0,onStartDevBox:L?E:void 0,devBoxStartNodeId:S,devBoxStartingNodeIds:y},R.id))}):e.jsx("div",{className:"rounded-sm bg-muted/45 px-2 py-2 text-[10px] text-muted-foreground shadow-none",children:"No peer nodes are connected yet."})]})]})})}),e.jsx(yt,{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(Fl,{className:F("h-3.5 w-3.5",d?"text-emerald-500":"text-destructive")}),"Live events"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsxs(ze,{value:a,onValueChange:i,children:[e.jsx(Ue,{className:"h-6 min-w-[10rem] flex-1 rounded-sm border-0 bg-muted/60 text-[10px] shadow-none sm:max-w-[14rem] [&>svg]:h-3 [&>svg]:w-3",children:e.jsx(Qe,{placeholder:"Event type"})}),e.jsx($e,{className:"shadow-none",children:l.map(R=>e.jsx(Le,{value:R,className:"py-1 pl-6 pr-1.5 text-[10px] leading-4",children:R==="all"?"All event types":R},R))})]}),e.jsx(Ze,{variant:"secondary",className:"rounded-sm border-0 bg-muted/60 px-1.5 py-0 text-[9px] leading-4 shadow-none",children:d?"Connected":"Reconnecting"})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(zl,{events:c,maxHeight:"100%",emptyTitle:a==="all"?"No live events yet":"No matching events",emptyDescription:a==="all"?"Cluster activity appears here as it happens.":`No "${a}" events are in the current stream.`,nodeNameById:s,density:"compact"})})]})})]})})}function Fa({node:t,systemInfo:n,blockingTaskCount:s,devTunnelNodeId:r,onToggleNodeDevTunnel:a,showActions:i=!0,defaultExpanded:l=!1,onOpenNodeSettings:c,onOpenNodeCapabilities:d,onOpenDevBox:m,onStartDevBox:x,devBoxStartNodeId:u,devBoxStartingNodeIds:h}){const[f,w]=o.useState(l),g=n?.dashboardOrigin??t.dashboardOrigin,k=t.devtunnelEndpoint??t.endpoint,v=g??t.endpoint,S=n?.workDir??t.workDir,y=Uo(t,n?.transportType),p=gr(t,n?.transportType),b=p&&dn(n?.transportType??t.transportType)?!0:zo(t,n?.transportType),N=s>0;return e.jsxs("section",{className:"dashboard-operations-node-card bg-primary/8 shadow-none",children:[e.jsxs("div",{className:"w-full px-2.5 py-1.5 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>w(A=>!A),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[f?e.jsx(tt,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(dt,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx(vo,{status:t.status}),e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Current node"})]}),e.jsx("a",{href:v,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(dr,{className:"h-3 w-3"})}),(c||d||i&&b)&&e.jsx(kr,{nodeId:t.id,nodeName:t.name,node:t,onOpenSettings:c,onOpenCapabilities:d,onOpenDevBox:m,onStartDevBox:x,onToggleRemoteAccess:i&&b?()=>a(t):void 0,remoteAccessLabel:i&&b?p?"Disable Remote Access":"Enable Remote Access":void 0,remoteAccessPending:r===t.id,remoteAccessDisabled:N,remoteAccessDisabledReason:N?"Finish assigned or running tasks before changing remote access":void 0,showConfigureDevBox:t.devbox?.enabled,showStartDevBox:Zn(t.status,t.devbox?.lastStatus,t.devbox)||ln(t.devbox?.lastStatus)||h.has(t.id),startDevBoxPending:u===t.id||ln(t.devbox?.lastStatus)||h.has(t.id)})]}),e.jsxs("button",{type:"button",onClick:()=>w(A=>!A),className:"mt-1 flex min-w-0 items-center gap-1 pl-5 text-left",children:[e.jsx("span",{className:"text-[10px] font-semibold tracking-tight text-foreground",children:t.name}),e.jsx(wo,{role:t.role,size:"compact"}),e.jsx(Ze,{variant:"secondary",className:"rounded-sm border-0 bg-background/65 px-1.5 py-0 text-[9px] leading-4 capitalize shadow-none",children:t.status})]})]}),f&&e.jsxs("div",{className:"space-y-2 bg-primary/5 px-2.5 pb-2.5 pt-1.5",children:[e.jsxs("div",{className:"space-y-1.5 rounded-sm bg-muted/45 px-2 py-1.5 shadow-none",children:[e.jsx(it,{label:"Node ID",value:t.id,mono:!0}),g&&e.jsx(it,{label:"Dashboard",value:g,mono:!0,action:e.jsx(Cr,{nodeName:t.name,dashboardUrl:g})}),e.jsx(it,{label:"Node URL",value:k,mono:!0,action:e.jsx(Sr,{nodeName:t.name,nodeEndpoint:k})}),S&&e.jsx(it,{label:"Workspace",value:S,mono:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsx(Ws,{label:"Transport",value:y}),n&&e.jsx(Ws,{label:"Uptime",value:Ul(n.uptime),mono:!0})]}),i&&d&&e.jsxs(Z,{variant:"secondary",size:"sm",onClick:()=>d(t.id),"aria-label":`Open ${t.name} capabilities`,className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",children:[e.jsx(En,{className:"h-3 w-3"}),"Capabilities"]}),i&&b&&N&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[s," active task",s===1?"":"s"," on this node."]})]})]})}function Jh({node:t,isLeader:n,blockingTaskCount:s,devTunnelNodeId:r,onToggleNodeDevTunnel:a,onOpenNodeSettings:i,onOpenNodeCapabilities:l,onOpenDevBox:c,onStartDevBox:d,devBoxStartNodeId:m,devBoxStartingNodeIds:x}){const[u,h]=o.useState(!1),f=t.dashboardOrigin,w=t.devtunnelEndpoint??t.endpoint,g=f??t.endpoint,k=Uo(t),v=gr(t),S=zo(t),y=s>0;return e.jsxs("div",{className:"dashboard-operations-node-card bg-muted/45 shadow-none",children:[e.jsxs("div",{className:"w-full px-2.5 py-1.5 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>h(p=>!p),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[u?e.jsx(tt,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):e.jsx(dt,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx(vo,{status:t.status}),e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Peer node"})]}),e.jsx("a",{href:g,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(dr,{className:"h-3 w-3"})}),n&&(i||l||S)&&e.jsx(kr,{nodeId:t.id,nodeName:t.name,node:t,onOpenSettings:i,onOpenCapabilities:l,onOpenDevBox:c,onStartDevBox:d,onToggleRemoteAccess:S?()=>a(t):void 0,remoteAccessLabel:S?v?"Disable Remote Access":"Enable Remote Access":void 0,remoteAccessPending:r===t.id,remoteAccessDisabled:y,remoteAccessDisabledReason:y?"Finish assigned or running tasks before changing remote access":void 0,showConfigureDevBox:t.devbox?.enabled,showStartDevBox:Zn(t.status,t.devbox?.lastStatus,t.devbox)||ln(t.devbox?.lastStatus)||x.has(t.id),startDevBoxPending:m===t.id||ln(t.devbox?.lastStatus)||x.has(t.id)})]}),e.jsxs("button",{type:"button",onClick:()=>h(p=>!p),className:"mt-1 flex min-w-0 items-center gap-1 pl-4 text-left",children:[e.jsx("span",{className:"text-[10px] font-semibold text-foreground",children:t.name}),e.jsx(wo,{role:t.role,size:"compact"}),e.jsx(Ze,{variant:"secondary",className:"rounded-sm border-0 bg-background/65 px-1.5 py-0 text-[9px] leading-4 capitalize shadow-none",children:t.status})]})]}),u&&e.jsxs("div",{className:"space-y-2 bg-muted/35 px-2.5 pb-2.5 pt-1.5",children:[e.jsxs("div",{className:"space-y-1.5 rounded-sm bg-background/55 px-2 py-1.5 shadow-none",children:[e.jsx(it,{label:"Node ID",value:t.id,mono:!0}),f&&e.jsx(it,{label:"Dashboard",value:f,mono:!0,action:e.jsx(Cr,{nodeName:t.name,dashboardUrl:f})}),e.jsx(it,{label:"Node URL",value:w,mono:!0,action:e.jsx(Sr,{nodeName:t.name,nodeEndpoint:w,showPairingQr:!1})}),t.workDir&&e.jsx(it,{label:"Workspace",value:t.workDir,mono:!0}),e.jsx(Ws,{label:"Transport",value:k})]}),n&&l&&e.jsxs(Z,{variant:"secondary",size:"sm",onClick:()=>l(t.id),"aria-label":`Open ${t.name} capabilities`,className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",children:[e.jsx(En,{className:"h-3 w-3"}),"Capabilities"]}),n&&S&&y&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[s," active task",s===1?"":"s"," on this node."]})]})]})}function Sr({nodeName:t,nodeEndpoint:n,copyLabel:s="Copy node URL",copiedMessage:r="Node URL copied",showPairingQr:a=!0}){return e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[a?e.jsx(kh,{nodeName:t,nodeEndpoint:n}):null,e.jsx(pi,{label:s,onClick:()=>{An(n,r)}})]})}function Cr({nodeName:t,dashboardUrl:n,copyLabel:s="Copy dashboard URL",copiedMessage:r="Dashboard URL copied"}){return e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx(Sh,{nodeName:t,dashboardUrl:n}),e.jsx(pi,{label:s,onClick:()=>{An(n,r)}})]})}function pi({label:t,onClick:n}){return e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"h-4 w-4 shrink-0 rounded-sm p-0 text-muted-foreground opacity-70 hover:bg-muted/45 hover:opacity-100 [&_svg]:size-2.5",onClick:n,"aria-label":t,title:t,children:e.jsx(po,{className:"h-3 w-3"})})}function Zh(t,n,s,r){if(!t)return{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Select a task to continue the conversation."};const a=n?.self?.role==="follower",i=t.assignedTo?n?.self?.id===t.assignedTo?n.self:n?.nodes.find(c=>c.id===t.assignedTo):void 0;return t.assignedTo!==null&&(i?i.status==="offline":n?t.assignedNodeAvailable===!1||!n.nodes.some(c=>c.id===t.assignedTo):t.assignedNodeAvailable===!1)?{taskUnavailable:!0,chatDisabled:!0,chatDisabledReason:`${t.assignedNodeName??"Assigned node"} is unavailable. Leave the cluster on that node or re-run the task elsewhere.`}:a?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Follower nodes are read-only. Use the leader dashboard to manage chat, or leave the cluster first."}:s?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Sending message..."}:r?{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Queue a message for the next turn..."}:$n.has(t.status)||t.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:$n.has(t.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}const xi=.5,gi=1.75,za=.1;function Xh({node:t,open:n,onOpenChange:s}){const[r,a]=o.useState(Rn),[i,l]=o.useState(null),[c,d]=o.useState(1),[m,x]=o.useState(!1),[u,h]=o.useState(null);o.useEffect(()=>{a(Rn),l(null),d(1),x(!1),h(null)},[t?.id,n]);const f=o.useCallback(async y=>{if(!t)return;const p=y??Number.parseInt(r.trim()||Rn,10);if(!Number.isInteger(p)||p<1||p>65535){h("Enter a port between 1 and 65535");return}x(!0),h(null);try{const b=await $l(t.id,{port:p});l(b),a(String(p)),Rr("preview.created",{result:"success",previewType:"service-port"})}catch(b){h(b instanceof Error?b.message:"Failed to create service preview"),Rr("preview.failed",{result:"failed",previewType:"service-port"})}finally{x(!1)}},[t,r]),w=o.useCallback(()=>{typeof i?.port=="number"&&f(i.port)},[i?.port,f]);o.useEffect(()=>{if(!i)return;const y=i.expiresAt-Date.now()-5e3;if(y<=0){w();return}const p=window.setTimeout(w,y);return()=>window.clearTimeout(p)},[w,i]);const g=i?rd(i):null,k=t?.name??"Node",v=ef(c),S={width:`${100/c}%`,height:`${100/c}%`,transform:`scale(${c})`,transformOrigin:"top left"};return e.jsx(ut,{open:n,onOpenChange:s,children:e.jsxs(mt,{onOpenAutoFocus:y=>y.preventDefault(),className:"flex h-[min(82vh,44rem)] max-w-[min(92vw,72rem)] flex-col gap-0 overflow-hidden p-0",children:[e.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/60 px-3 py-2 pr-9",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs(gt,{className:"flex min-w-0 items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[e.jsx(Ro,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{className:"shrink-0",children:"Preview service"}),e.jsx("span",{className:"min-w-0 truncate font-mono text-[10px] font-medium text-muted-foreground",children:k})]}),e.jsx(At,{className:"sr-only",children:"Preview a service port running on the selected node."})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs("form",{className:"flex items-center gap-1.5",onSubmit:y=>{y.preventDefault(),f()},children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:["Port",e.jsx(lt,{type:"text",min:1,max:65535,inputMode:"numeric",value:r,onChange:y=>a(y.target.value),placeholder:Rn,"aria-label":"Node service preview port",className:"h-6 w-20 rounded-sm border-0 bg-muted/55 px-2 text-[11px] shadow-none focus:bg-muted/55 focus:outline-none focus-visible:border-0 focus-visible:bg-muted/55 focus-visible:ring-0 focus-visible:ring-offset-0"})]}),e.jsxs(Z,{type:"submit",variant:"ghost",size:"sm",disabled:m,className:"h-6 rounded-sm border-0 bg-primary/10 px-2 text-[11px] text-primary shadow-none hover:bg-primary/15 hover:text-primary",children:[m?e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Yn,{className:"h-3.5 w-3.5"}),"Preview"]})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden shrink-0 text-[10px] text-muted-foreground sm:inline",children:tf(i.expiresAt)}),e.jsxs("div",{className:"flex h-6 shrink-0 items-center overflow-hidden rounded-sm border border-border/55 bg-muted/35",children:[e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-none",onClick:()=>d(y=>Ua(y,-za)),disabled:c<=xi,title:"Zoom out","aria-label":"Zoom out preview",children:e.jsx(tu,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>d(1),className:"h-6 min-w-11 border-x border-border/45 px-1.5 text-center font-mono text-[10px] text-muted-foreground transition-colors hover:bg-muted/55 hover:text-foreground",title:"Reset zoom","aria-label":"Reset preview zoom",children:v}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-none",onClick:()=>d(y=>Ua(y,za)),disabled:c>=gi,title:"Zoom in","aria-label":"Zoom in preview",children:e.jsx(Xd,{className:"h-3.5 w-3.5"})})]}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",onClick:w,title:"Refresh",children:e.jsx(bo,{className:"h-3.5 w-3.5"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:g??i.previewUrl,target:"_blank",rel:"noopener noreferrer",children:e.jsx(dr,{className:"h-3.5 w-3.5"})})})]})]})]}),u&&e.jsx("div",{className:"shrink-0 border-b border-destructive/20 bg-destructive/5 px-3 py-1.5 text-[11px] text-destructive",children:u}),e.jsx("div",{className:"min-h-0 flex-1 p-2",children:i?e.jsx("div",{className:"h-full overflow-hidden rounded-sm border border-border/60 bg-white shadow-none",children:e.jsx("iframe",{src:od(i),style:S,className:"h-full w-full border-0",sandbox:ad(i),title:`${k} Service Preview`})}):e.jsx("div",{className:"flex h-full min-h-56 items-center justify-center rounded-sm border border-dashed border-border/65 bg-background/35 px-3 text-center text-[11px] text-muted-foreground",children:"No service preview running."})})]})})}function Ua(t,n){return bi(Math.round((t+n)*100)/100)}function bi(t){return Number.isFinite(t)?Math.min(gi,Math.max(xi,t)):1}function ef(t){return`${Math.round(bi(t)*100)}%`}function tf(t){const n=Math.max(0,Math.round((t-Date.now())/1e3));if(n<60)return`${n}s`;const s=Math.floor(n/60),r=n%60;return`${s}m ${r}s`}function nf({dirPath:t,nodeId:n,nodeName:s,nodeStatus:r,tasks:a=[],unloadedCompletedCount:i,contextOpen:l=!1,contextPosition:c=null,defaultOpen:d=!1,onContextOpenChange:m,onCreateTask:x,onOpenCapabilities:u}){const{open:h,menuRef:f,triggerRef:w,menuStyle:g,closeMenu:k,toggleButton:v}=jr({contextOpen:l,contextPosition:c,defaultOpen:d,onContextOpenChange:m}),[S,y]=o.useState(!1),p=h?e.jsxs("div",{ref:f,role:"menu",style:g,onClick:b=>b.stopPropagation(),onPointerDown:b=>b.stopPropagation(),className:yr,children:[e.jsx(Je,{icon:e.jsx(Mn,{className:"h-3 w-3 text-primary"}),onClick:()=>{k(),x()},children:"New chat"}),u&&e.jsx(Je,{icon:e.jsx(En,{className:"h-3 w-3 text-primary"}),onClick:()=>{k(),u()},children:"Capabilities"}),e.jsx(Je,{icon:e.jsx(cr,{className:"h-3 w-3 text-primary"}),onClick:()=>{k(),y(!0)},children:"Properties"})]}):null;return e.jsxs("div",{className:F("relative flex shrink-0 items-center self-center pr-1",h&&"z-[120]"),onClick:b=>b.stopPropagation(),onPointerDown:b=>b.stopPropagation(),children:[e.jsx("button",{ref:w,type:"button","aria-label":`More actions for ${t}`,"aria-haspopup":"menu","aria-expanded":h,title:`More actions for ${t}`,onClick:b=>{b.stopPropagation(),v()},className:F("pointer-events-none flex h-4 w-4 shrink-0 translate-y-px items-center justify-center rounded-sm text-muted-foreground/50 opacity-0 transition-all hover:bg-primary/10 hover:text-primary focus-visible:pointer-events-auto focus-visible:opacity-100 group-hover/project-row:pointer-events-auto group-hover/project-row:opacity-100",h&&"pointer-events-auto bg-primary/10 text-primary opacity-100"),children:e.jsx(pr,{className:"h-2.5 w-2.5"})}),p&&(typeof document>"u"?p:Qn.createPortal(p,document.body)),S&&e.jsx(Uh,{dirPath:t,nodeId:n,nodeName:s,nodeStatus:r,tasks:a,unloadedCompletedCount:i,open:S,onOpenChange:y})]})}function sf({dirPath:t,label:n,taskCount:s,tasks:r,unloadedCompletedCount:a,nodeId:i,nodeName:l,nodeStatus:c,collapsed:d,onToggle:m,onCreateTask:x,onOpenCapabilities:u}){const[h,f]=o.useState(!1),[w,g]=o.useState(null);return e.jsxs("div",{className:"group/project-row flex w-full items-stretch rounded-sm bg-muted/15 text-[9px] font-medium text-muted-foreground/70 transition-all duration-150 hover:bg-muted/30 hover:text-foreground active:scale-[0.98] active:bg-muted/40",onContextMenu:k=>{k.preventDefault(),k.stopPropagation(),f(!0),g({left:k.clientX,top:k.clientY})},children:[e.jsxs("button",{type:"button",onClick:m,"aria-expanded":!d,title:t,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-l-sm px-2 py-1 text-left",children:[e.jsx(dt,{className:F("h-3 w-3 shrink-0 transition-transform duration-200",!d&&"rotate-90")}),e.jsx(cn,{className:"h-3 w-3 shrink-0 text-muted-foreground/55"}),e.jsx("span",{className:"min-w-0 truncate font-mono",children:n}),e.jsx("span",{className:"ml-2 shrink-0 rounded-sm bg-background/55 px-1 py-0 tabular-nums text-[8px] font-medium leading-3 text-muted-foreground/45",children:s})]}),u&&e.jsx("button",{type:"button",onClick:u,"aria-label":`Capabilities for ${t}`,title:`Capabilities for ${t}`,className:"pointer-events-none mr-0.5 flex h-4 w-4 shrink-0 translate-y-px self-center items-center justify-center rounded-sm text-muted-foreground/50 opacity-0 transition-all hover:bg-primary/10 hover:text-primary focus-visible:pointer-events-auto focus-visible:opacity-100 group-hover/project-row:pointer-events-auto group-hover/project-row:opacity-100",children:e.jsx(En,{className:"h-2.5 w-2.5"})}),e.jsx("button",{type:"button",onClick:x,"aria-label":`New chat in ${t}`,title:`New chat in ${t}`,className:"pointer-events-none ml-auto flex h-4 w-4 shrink-0 translate-y-px self-center items-center justify-center rounded-sm text-muted-foreground/50 opacity-0 transition-all hover:bg-primary/10 hover:text-primary focus-visible:pointer-events-auto focus-visible:opacity-100 group-hover/project-row:pointer-events-auto group-hover/project-row:opacity-100",children:e.jsx(Mn,{className:"h-2.5 w-2.5"})}),e.jsx(nf,{dirPath:t,nodeId:i,nodeName:l,nodeStatus:c,tasks:r,unloadedCompletedCount:a,contextOpen:h,contextPosition:h?w:null,onContextOpenChange:k=>{k||(f(!1),g(null))},onCreateTask:x,onOpenCapabilities:u})]})}function $a(t,n){if(!t.has(n))return t;const s=new Set(t);return s.delete(n),s}function rf(t,n){if(!n)return null;for(const s of t){const r=s.nodeId??"__unassigned__";for(const a of s.dirs)if(a.tasks.some(i=>i.id===n))return{nodeKey:r,dirKey:`${r}::${a.path}`}}return null}function qa(t,n,s){return s?{collapsedNodes:$a(t,s.nodeKey),collapsedDirs:$a(n,s.dirKey)}:{collapsedNodes:t,collapsedDirs:n}}function af(t,n,s){const r=t.filter(d=>d.status==="completed"),a=new Set(r.filter(Tn).map(d=>d.id)),i=new Set((n?r:[...r].sort((d,m)=>m.updatedAt-d.updatedAt).slice(0,ur)).map(d=>d.id));for(const d of a)i.add(d);s&&r.some(d=>d.id===s)&&i.add(s);const l=vi(t.filter(d=>d.status!=="completed"||i.has(d.id))),c=r.length-i.size;return{visibleTasks:l,hiddenCompletedCount:Math.max(0,c)}}function Tn(t){return t.pinnedOnTop===!0}function vi(t){return[...t].sort((n,s)=>{const r=Number(Tn(s))-Number(Tn(n));if(r!==0)return r;const a=s.updatedAt-n.updatedAt;if(a!==0)return a;const i=s.createdAt-n.createdAt;return i!==0?i:n.id.localeCompare(s.id)})}const of=new Set(["completed","failed","cancelled"]);function lf({task:t,contextOpen:n=!1,contextPosition:s=null,defaultOpen:r=!1,onContextOpenChange:a,onUpdateTitle:i,onDeleteTask:l,onArchiveTask:c,onTogglePinned:d}){const{open:m,menuRef:x,triggerRef:u,menuStyle:h,closeMenu:f,toggleButton:w}=jr({contextOpen:n,contextPosition:s,defaultOpen:r,onContextOpenChange:a}),[g,k]=o.useState(!1),[v,S]=o.useState(!1),[y,p]=o.useState(!1),[b,N]=o.useState(!1),[A,I]=o.useState(t.title),[E,L]=o.useState(null),M=Tn(t),D=of.has(t.status),P=t.status==="archived"?"Task is already archived":"Only completed, failed, or cancelled tasks can be archived";o.useEffect(()=>{I(t.title)},[t.id,t.title]);async function B(H,ne){if(!(!ne||E)){L(H);try{await ne(),f()}finally{L(null)}}}const Q=A.trim(),te=Q===t.title,Y=m?e.jsxs("div",{ref:x,role:"menu",style:h,onClick:H=>H.stopPropagation(),onPointerDown:H=>H.stopPropagation(),className:yr,children:[i&&e.jsx(Je,{icon:e.jsx(Wt,{className:"h-3 w-3 text-primary"}),onClick:()=>{f(),k(!0)},children:"Update title"}),d&&e.jsx(Je,{icon:M?e.jsx(Ld,{className:"h-3 w-3 text-primary"}):e.jsx(Lo,{className:"h-3 w-3 text-primary"}),pending:E==="pin",onClick:()=>B("pin",()=>d(t,!M)),children:M?"Unpin from top":"Pin on top"}),c&&e.jsx(Je,{icon:e.jsx(Do,{className:"h-3 w-3 text-primary"}),disabled:!D,pending:E==="archive",title:D?"Archive task":P,onClick:()=>{D&&(f(),p(!0))},children:"Archive"}),l&&e.jsx(Je,{destructive:!0,icon:e.jsx(mr,{className:"h-3 w-3 text-destructive"}),onClick:()=>{f(),N(!0)},children:"Delete"}),e.jsx(Je,{icon:e.jsx(cr,{className:"h-3 w-3 text-primary"}),onClick:()=>{f(),S(!0)},children:"Properties"})]}):null;return e.jsxs("div",{className:F("relative shrink-0",m&&"z-[120]"),onClick:H=>H.stopPropagation(),onPointerDown:H=>H.stopPropagation(),children:[e.jsx(Z,{ref:u,type:"button",variant:"ghost",size:"icon","aria-label":`More actions for ${t.title}`,"aria-haspopup":"menu","aria-expanded":m,title:`More actions for ${t.title}`,onClick:H=>{H.stopPropagation(),w()},className:F("h-5 w-5 rounded-sm text-muted-foreground/55 opacity-0 transition-all duration-150 pointer-events-none hover:bg-background/70 hover:text-foreground focus-visible:pointer-events-auto focus-visible:opacity-100 group-hover/task-row:pointer-events-auto group-hover/task-row:opacity-100",m&&"pointer-events-auto bg-background/80 text-primary opacity-100"),children:e.jsx(pr,{className:"h-3 w-3"})}),Y&&(typeof document>"u"?Y:Qn.createPortal(Y,document.body)),v&&e.jsx(zh,{task:t,open:v,onOpenChange:S}),g&&i&&e.jsx(ut,{open:g,onOpenChange:k,children:e.jsxs(mt,{className:"rounded-sm sm:max-w-sm",children:[e.jsxs(Tt,{children:[e.jsx(gt,{children:"Update task title"}),e.jsx(At,{children:"Rename this task in the tree and transcript header."})]}),e.jsxs("form",{className:"space-y-3",onSubmit:H=>{H.preventDefault(),B("title",async()=>{!Q||te||(await i?.(t,Q),k(!1))})},children:[e.jsx(lt,{value:A,onChange:H=>I(H.target.value),className:"h-8 rounded-sm border-border/70 text-[11px] shadow-none focus-visible:ring-1 focus-visible:ring-offset-0","aria-label":"Task title",autoFocus:!0}),e.jsxs(lr,{children:[e.jsx(Z,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-sm px-2 text-[11px]",onClick:()=>k(!1),children:"Cancel"}),e.jsxs(Z,{type:"submit",size:"sm",className:"h-7 rounded-sm px-2 text-[11px]",disabled:!Q||te||E==="title",children:[E==="title"&&e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})]})}),y&&c&&e.jsx(Ft,{open:y,onOpenChange:p,children:e.jsxs(zt,{children:[e.jsxs(Ut,{children:[e.jsx($t,{children:"Archive this task?"}),e.jsx(qt,{children:"This task leaves the default active view immediately."})]}),e.jsxs(Ht,{children:[e.jsx(Vt,{autoFocus:!0,children:"Cancel"}),e.jsx(Kt,{onClick:()=>B("archive",async()=>{await c?.(t),p(!1)}),disabled:E==="archive",children:"Archive"})]})]})}),b&&l&&e.jsx(Ft,{open:b,onOpenChange:N,children:e.jsxs(zt,{children:[e.jsxs(Ut,{children:[e.jsx($t,{children:"Delete this task and saved logs?"}),e.jsx(qt,{children:"This cannot be undone."})]}),e.jsxs(Ht,{children:[e.jsx(Vt,{autoFocus:!0,children:"Cancel"}),e.jsx(Kt,{onClick:()=>B("delete",async()=>{await l?.(t),N(!1)}),disabled:E==="delete",className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}const wi="meshy-task-sidebar-tree-state";function Ha(t){return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}function Us(){try{return globalThis.window?.localStorage??globalThis.localStorage??null}catch{return null}}function Va(t){if(!t)return{collapsedNodes:[],collapsedDirs:[]};try{const n=t.getItem(wi);if(!n)return{collapsedNodes:[],collapsedDirs:[]};const s=JSON.parse(n);return{collapsedNodes:Ha(s.collapsedNodes),collapsedDirs:Ha(s.collapsedDirs)}}catch{return{collapsedNodes:[],collapsedDirs:[]}}}function cf(t,n){if(t)try{t.setItem(wi,JSON.stringify(n))}catch{}}const On="h-6 rounded-sm border-0 bg-muted/45 px-2 py-0 text-[10px] leading-none text-foreground shadow-none hover:bg-muted/65 focus:bg-muted/65 focus:ring-0 focus:ring-offset-0 [&>svg]:h-3 [&>svg]:w-3",Fn="py-1 pl-6 pr-1.5 text-[10px] leading-4 [&_svg]:h-3 [&_svg]:w-3";function Ka({toolbarTasks:t,activeTaskId:n,tasksLoading:s,tasksError:r,isLeader:a,scope:i,agentFilter:l,nodeFilter:c,taskKindFilter:d,agentOptions:m,nodeOptions:x,nodeNameById:u,nodeWorkDirById:h,nodeStatusById:f,nodeInfoById:w,completedGroupByKey:g,devBoxNodeIds:k=new Set,devBoxStartNodeIds:v=new Set,devBoxStartingNodeIds:S=new Set,leaderNodeId:y,searchQuery:p,selectedTaskIds:b,allVisibleTasksSelected:N,someVisibleTasksSelected:A,canBatchArchive:I,onScopeChange:E,onAgentFilterChange:L,onNodeFilterChange:M,onTaskKindFilterChange:D,onToggleTaskSelected:P,onToggleAllVisibleTasks:B,onBatchArchive:Q,onBatchDelete:te,onUpdateTaskTitle:Y,onDeleteTask:H,onArchiveTask:ne,onToggleTaskPinned:$,onCreateTask:X,onOpenNodeSettings:j,onOpenNodeCapabilities:W,onOpenProjectCapabilities:T,onOpenDevBox:ee,onStartDevBox:R,onLoadCompletedTasks:V,onSelectTask:O}){const[le,ie]=o.useState(!1),[ue,J]=o.useState(()=>b.size>0),[K,_]=o.useState(!1),[se,q]=o.useState(null),[ae,ye]=o.useState(null),[pe,Ye]=o.useState(null),[Te,ht]=o.useState(null),[Ie,Me]=o.useState(null),{markScrollbarActive:qe,scrollbarActive:He}=ni(),je=b.size,Re=!!(a&&(ue||je>0)),G=i!=="active"||c!=="all"||l!=="all"||d!=="all",ge=p.trim().length>0,[be,Xe]=o.useState(()=>new Set(Va(Us()).collapsedNodes)),[De,nt]=o.useState(()=>new Set(Va(Us()).collapsedDirs)),[re,Ne]=o.useState(new Set),Ce=o.useMemo(()=>ql({nodeStatusById:f,nodeNameById:u,nodeWorkDirById:h,nodeFilter:c,searchQuery:p}),[f,u,h,c,p]),ve=o.useMemo(()=>Hl(t,u,y,h,Ce),[t,u,y,h,Ce]),st=o.useMemo(()=>rf(ve,n),[ve,n]),_e=o.useRef(null),Et=ve.length===1,ft=ve.length>0,un=Et&&(G||ge),Jt=!!(a&&(t.length>0||je>0)),Nt=!!(a&&Y&&H&&ne&&$),bt=o.useCallback(U=>{Xe(Oe=>{const Pe=new Set(Oe);return Pe.has(U)?Pe.delete(U):Pe.add(U),Pe})},[]),mn=o.useCallback(U=>{nt(Oe=>{const Pe=new Set(Oe);return Pe.has(U)?Pe.delete(U):Pe.add(U),Pe})},[]),hn=o.useCallback(U=>{Ne(Oe=>{const Pe=new Set(Oe);return Pe.add(U),Pe})},[]);o.useEffect(()=>{cf(Us(),{collapsedNodes:Array.from(be),collapsedDirs:Array.from(De)})},[De,be]),o.useEffect(()=>{if(!st||!n)return;const U=`${n}:${st.nodeKey}:${st.dirKey}`;_e.current!==U&&(_e.current=U,Xe(Oe=>qa(Oe,new Set,st).collapsedNodes),nt(Oe=>qa(new Set,Oe,st).collapsedDirs))},[n,st]);const Mt=o.useCallback(U=>{J(!0),B(U)},[B]),Rt=o.useCallback(U=>{if(U===!0&&!N){J(!0),_(!0);return}Mt(U===!0)},[N,Mt]),Zt=o.useCallback(()=>{Mt(!0),_(!1)},[Mt]),kt=o.useCallback(()=>{B(!1),J(!1),_(!1)},[B]),Xt=o.useCallback(()=>{ye(null),Ye(null)},[]),Be=o.useCallback(()=>{ht(null),Me(null)},[]);o.useEffect(()=>{a||(J(!1),_(!1))},[a]);const rt=Re?e.jsxs(Ft,{open:K,onOpenChange:_,children:[e.jsxs("label",{className:"flex items-center gap-[5px] text-[9px] font-medium uppercase tracking-[0.12em] text-muted-foreground/75",children:[e.jsx(Sn,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:A&&!N?"indeterminate":N,onCheckedChange:Rt,"aria-label":"Select all visible tasks"}),e.jsx("span",{children:"Select all"})]}),K&&e.jsxs(zt,{children:[e.jsxs(Ut,{children:[e.jsx($t,{children:"Select every visible task?"}),e.jsx(qt,{children:"This will select every task currently shown in the rail and expose bulk archive/delete actions. Cancel now unless you intend to act on all visible tasks together."})]}),e.jsxs(Ht,{children:[e.jsx(Vt,{autoFocus:!0,children:"Cancel"}),e.jsx(Kt,{onClick:Zt,children:"Select all"})]})]})]}):e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>J(!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(Qc,{className:"h-3 w-3"}),"Multi select"]}),vt=je>0?e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"text-[9px] font-semibold leading-3 text-foreground",children:[je," task",je!==1?"s":""," selected"]}),!I&&e.jsx("div",{className:"max-w-48 text-[9px] leading-3.5 text-muted-foreground",children:"Only completed, failed, cancelled, or archived tasks can be archived."})]}):null,St=je>0?e.jsxs("div",{className:"flex flex-wrap justify-end gap-1",children:[e.jsxs(Ft,{children:[e.jsx(Ks,{asChild:!0,children:e.jsxs(Z,{variant:"ghost",size:"sm",disabled:!I,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(Do,{}),"Archive"]})}),e.jsxs(zt,{children:[e.jsxs(Ut,{children:[e.jsxs($t,{children:["Archive ",je," selected task",je!==1?"s":"","?"]}),e.jsx(qt,{children:"These tasks leave the default view immediately. Cancel if any selected task still needs to stay visible in active work."})]}),e.jsxs(Ht,{children:[e.jsx(Vt,{autoFocus:!0,children:"Cancel"}),e.jsx(Kt,{onClick:Q,disabled:!I,children:"Archive"})]})]})]}),e.jsxs(Ft,{children:[e.jsx(Ks,{asChild:!0,children:e.jsxs(Z,{variant:"destructive",size:"sm",className:"h-5 gap-1 rounded-sm px-1.5 text-[8px] [&_svg]:size-3",children:[e.jsx(mr,{}),"Delete"]})}),e.jsxs(zt,{children:[e.jsxs(Ut,{children:[e.jsxs($t,{children:["Delete ",je," selected task",je!==1?"s":""," and saved logs?"]}),e.jsx(qt,{children:"This cannot be undone. Cancel unless you are certain every selected task and log should be removed now."})]}),e.jsxs(Ht,{children:[e.jsx(Vt,{autoFocus:!0,children:"Cancel"}),e.jsx(Kt,{onClick:te,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]}):null;return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:"dashboard-task-sidebar dashboard-panel dashboard-panel-muted animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsxs("div",{className:"dashboard-task-sidebar__header shrink-0 bg-card/24 px-2.5 py-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("div",{className:"flex min-w-0 items-stretch gap-1.5",children:[e.jsxs(Z,{onClick:()=>X("chat"),className:"h-8 w-[6.75rem] justify-start rounded-sm px-2.5 text-left text-[11px] shadow-[0_10px_24px_-18px_hsl(var(--primary)/0.9)]",children:[e.jsx(Mn,{className:"h-3.5 w-3.5"}),"New chat"]}),e.jsxs(Z,{variant:"outline",onClick:()=>X("native"),className:"h-8 w-[7.75rem] justify-start rounded-sm border-0 bg-muted/45 px-2.5 text-left text-[11px] text-foreground shadow-none hover:bg-muted/65 hover:text-foreground",children:[e.jsx(xr,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Load session"]})]}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>ie(U=>!U),className:F("ml-auto h-8 w-8 shrink-0 rounded-sm text-muted-foreground shadow-none hover:bg-muted/55 hover:text-foreground",(le||G)&&"bg-primary/8 text-primary hover:bg-primary/12 hover:text-primary"),title:"Filters",children:e.jsx(yd,{className:"h-3.5 w-3.5"})})]}),(le||G)&&e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-1 sm:grid-cols-2",children:[e.jsxs(ze,{value:i,onValueChange:U=>E(U),children:[e.jsx(Ue,{className:On,children:e.jsx(Qe,{})}),e.jsx($e,{children:Vl.map(U=>e.jsx(Le,{value:U.value,className:Fn,children:U.label},U.value))})]}),e.jsxs(ze,{value:c,onValueChange:M,children:[e.jsx(Ue,{className:On,children:e.jsx(Qe,{placeholder:"Node"})}),e.jsx($e,{children:x.map(U=>e.jsx(Le,{value:U.value,className:Fn,children:U.label},U.value))})]}),e.jsxs(ze,{value:l,onValueChange:L,children:[e.jsx(Ue,{className:On,children:e.jsx(Qe,{placeholder:"Agent"})}),e.jsx($e,{children:m.map(U=>e.jsx(Le,{value:U,className:Fn,children:U==="all"?"All agents":U},U))})]}),e.jsxs(ze,{value:d,onValueChange:U=>D(U),children:[e.jsx(Ue,{className:On,children:e.jsx(Qe,{placeholder:"Type"})}),e.jsx($e,{children:Kl.map(U=>e.jsx(Le,{value:U.value,className:Fn,children:U.label},U.value))})]})]})]}),e.jsx("div",{className:F("scrollbar-line min-h-0 flex-1 overflow-y-auto pl-2.5 pr-1.5 py-2",He&&"scrollbar-line-active"),onScroll:qe,children:ve.length>0?e.jsx("div",{className:"space-y-1",children:ve.map(U=>{const Oe=U.nodeId??"__unassigned__",Pe=U.dirs.reduce((xe,me)=>xe+me.tasks.length,0),Ke=ft&&!un&&be.has(Oe),Ge=U.nodeId!==null&&f.get(U.nodeId)==="offline",en=!!(a&&U.nodeId);return e.jsxs("div",{className:"space-y-1",children:[ft&&e.jsxs("div",{className:"flex w-full items-stretch rounded-sm bg-gradient-to-r from-primary/8 to-muted/20 text-left text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground transition-all duration-150 hover:from-primary/12 hover:to-muted/30 hover:text-foreground active:scale-[0.99] active:from-primary/15",onContextMenu:xe=>{!en||!U.nodeId||(xe.preventDefault(),xe.stopPropagation(),ht(U.nodeId),Me({left:xe.clientX,top:xe.clientY}))},children:[e.jsxs("button",{type:"button",onClick:()=>bt(Oe),"aria-expanded":!Ke,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm px-2 py-1.5 text-left",children:[e.jsx(dt,{className:F("h-3.5 w-3.5 shrink-0 transition-transform duration-200",!Ke&&"rotate-90")}),e.jsx(uo,{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:U.nodeName}),e.jsxs(Ze,{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:[Pe," task",Pe===1?"":"s"]})]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[Ge&&e.jsx(Ze,{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"}),U.nodeId===y&&e.jsx(Ze,{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"})]})]}),en&&U.nodeId&&e.jsx("span",{className:"flex shrink-0 items-center pr-1.5",children:e.jsx(kr,{nodeId:U.nodeId,nodeName:U.nodeName,node:U.nodeId?w?.get(U.nodeId):void 0,contextOpen:Te===U.nodeId,contextPosition:Te===U.nodeId?Ie:null,onContextOpenChange:xe=>{xe||Be()},onOpenSettings:j,onOpenServicePreview:()=>q({id:U.nodeId,name:U.nodeName}),onOpenCapabilities:W,onOpenDevBox:ee,onStartDevBox:R,showConfigureDevBox:k.has(U.nodeId),showStartDevBox:v.has(U.nodeId)||S.has(U.nodeId),startDevBoxPending:S.has(U.nodeId)})})]}),e.jsx("div",{className:F("grid transition-[grid-template-rows] duration-300 ease-in-out",Ke?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:"overflow-hidden",children:U.dirs.map(xe=>{const me=`${Oe}::${xe.path}`,ke=De.has(me),Ve=yo(xe.path),Fe=g?.get(me),Lt=Fe?{visibleTasks:vi(xe.tasks),hiddenCompletedCount:Math.max(0,Fe.total-Fe.returned)}:af(xe.tasks,re.has(me),n),{visibleTasks:Xn,hiddenCompletedCount:fn}=Lt;return e.jsxs("div",{className:F("space-y-0.5 rounded-xl",ft&&"pl-2.5"),children:[e.jsx(sf,{dirPath:xe.path,label:Ve,taskCount:xe.tasks.length,tasks:xe.tasks,unloadedCompletedCount:Fe?Math.max(0,Fe.total-Fe.returned):0,nodeId:U.nodeId,nodeName:U.nodeName,nodeStatus:U.nodeId?f.get(U.nodeId):void 0,collapsed:ke,onToggle:()=>mn(me),onCreateTask:()=>X("chat",{assignTo:U.nodeId,project:xe.path==="default workspace"?"":xe.path}),onOpenCapabilities:U.nodeId&&T?()=>T(U.nodeId,xe.path==="default workspace"?h?.get(U.nodeId)??xe.path:xe.path):void 0}),e.jsx("div",{className:F("grid transition-[grid-template-rows] duration-300 ease-in-out",ke?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:F("overflow-hidden",ft?"pl-2":"pl-0"),children:e.jsxs("div",{className:"space-y-px py-0.5",children:[Xn.map(Ae=>{const tn=Ae.id===n,Dt=Ae.assignedTo?f.get(Ae.assignedTo):void 0,pn=!!Ae.assignedTo&&(Dt?Dt==="offline":Ae.assignedNodeAvailable===!1),es=ai(Ae),ts=Tn(Ae);return e.jsxs("div",{onContextMenu:at=>{at.preventDefault(),at.stopPropagation(),ye(Ae.id),Ye({left:at.clientX,top:at.clientY})},className:F("group/task-row animate-task-row-reveal relative flex items-center gap-1.5 rounded-sm px-2 py-1.5 transition-all duration-150",tn?'bg-primary/10 before:absolute before:left-0 before:top-1/2 before:h-1/2 before:w-[2px] before:-translate-y-1/2 before:rounded-full before:bg-primary before:content-[""]':"hover:bg-muted/40"),children:[Re&&e.jsx("div",{className:"flex shrink-0",onClick:at=>at.stopPropagation(),children:e.jsx(Sn,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:b.has(Ae.id),onCheckedChange:at=>P(Ae.id,at===!0),"aria-label":`Select ${Ae.title}`})}),e.jsxs("button",{type:"button",onClick:()=>O(Ae.id),"aria-current":tn?"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:[ts&&e.jsx("span",{role:"img","aria-label":"Pinned to top",title:"Pinned to top",className:"flex shrink-0",children:e.jsx(Lo,{className:"h-2.5 w-2.5 -rotate-45 text-primary"})}),e.jsx("span",{className:F("min-w-0 flex-1 truncate text-[10px] font-medium leading-4",tn?"text-foreground":"text-foreground/80"),children:Ae.title})]}),e.jsx("span",{className:F("absolute right-0 top-0 shrink-0 tabular-nums text-[8px] leading-4",tn?"text-primary/75":"text-muted-foreground/55"),children:Gl(Ae.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:es}),Ae.activeShare&&e.jsx(Ze,{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"}),pn&&e.jsx(Ze,{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(xo,{status:Ae.status,isNative:Ae.conversationKind==="nativeSession",size:"compact",className:"absolute bottom-1 right-0"})]}),e.jsx(lf,{task:Ae,contextOpen:ae===Ae.id,contextPosition:ae===Ae.id?pe:null,onContextOpenChange:at=>{at||Xt()},onUpdateTitle:Nt?Y:void 0,onDeleteTask:Nt?H:void 0,onArchiveTask:Nt?ne:void 0,onTogglePinned:Nt?$:void 0})]},Ae.id)}),fn>0&&e.jsxs("button",{type:"button",onClick:()=>{Fe&&V?V(Fe):hn(me)},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 ${fn} more completed tasks in ${Ve}`,children:[e.jsx(tt,{className:"h-3 w-3"}),"Load ",fn," more completed"]})]})})})]},me)})})})]},Oe)})}):s?e.jsx("div",{className:"space-y-2 px-1",children:[1,2,3].map(U=>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+U*12}%`,animationDelay:`${U*120}ms`}}),e.jsx("div",{className:"h-2 w-24 animate-pulse rounded-full bg-muted-foreground/10",style:{animationDelay:`${U*120+60}ms`}})]})]})},U))}):e.jsx("div",{className:"rounded-xl border border-dashed border-border/70 bg-background/35 px-3 py-5 text-[11px] text-muted-foreground",children:r||"No tasks match this view."})}),Jt?e.jsx("div",{className:"shrink-0 px-2.5 pb-2.5 pt-1.5",children:Re&&je>0?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[vt,e.jsx(Z,{variant:"ghost",size:"sm",onClick:kt,className:"h-5 shrink-0 rounded-sm px-1.5 text-[9px]",children:"Clear"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"flex min-w-0 shrink-0 items-center",children:rt}),St]})]}):e.jsxs("div",{className:"flex items-end justify-between gap-2",children:[e.jsx("div",{className:"flex min-w-0 shrink-0 items-center",children:rt}),Re&&e.jsx(Z,{variant:"ghost",size:"sm",onClick:kt,className:"h-5 shrink-0 rounded-sm px-1.5 text-[9px]",children:"Done"})]})}):null]}),e.jsx(Xh,{node:se,open:se!==null,onOpenChange:U=>{U||q(null)}})]})}async function df(t,n){try{const s=await Wl(t,n),r={...s,url:fo(s.url)};if(globalThis.navigator?.clipboard?.writeText)try{await globalThis.navigator.clipboard.writeText(r.url),ce.success("Shared link copied")}catch{ce.success("Shared link created")}else ce.success("Shared link created");return r}catch(s){ce.error(s instanceof Error?s.message:"Failed to create shared link");return}}async function uf(t){try{return await Ql(t),ce.success("Shared link stopped"),!0}catch(n){return ce.error(n instanceof Error?n.message:"Failed to stop shared link"),!1}}function mf(t,n,s){const r=o.useCallback(()=>{n(),s()},[n,s]),a=o.useCallback(async l=>{if(!t)return;const c=await df(t.id,l);return c&&r(),c},[t,r]),i=o.useCallback(async()=>{if(!t)return!1;const l=await uf(t.id);return l&&r(),l},[t,r]);return{handleShareTask:a,handleStopShareTask:i}}function Ga(t,n,s){const r=o.useRef(n);r.current=n,o.useEffect(()=>{let l=0,c=0;const d=u=>{const h=u.touches[0];h&&(l=h.clientX,c=h.clientY)},m=u=>{const h=u.changedTouches[0];if(!h)return;const f=h.clientX-l;Math.abs(h.clientY-c)>100||Math.abs(f)<50||(f>0?r.current.onSwipeRight?.():r.current.onSwipeLeft?.())},x=t?.current??document;return x.addEventListener("touchstart",d,{passive:!0}),x.addEventListener("touchend",m,{passive:!0}),()=>{x.removeEventListener("touchstart",d),x.removeEventListener("touchend",m)}},[t,s?.threshold,s?.maxVertical])}const hf="(min-width: 1024px)",ff="(min-width: 1800px)";function Wa(t){return globalThis.window?.matchMedia?.(t)?.matches??!1}function pf(){const t=globalThis.document?.documentElement;if(!t||!globalThis.window?.getComputedStyle)return 16;const n=Number.parseFloat(globalThis.window.getComputedStyle(t).fontSize);return Number.isFinite(n)&&n>0?n:16}function xf(){const[t,n]=o.useState(()=>Yl(Lr(),Jl({operationsOpen:Wa(ff)}))),[s,r]=o.useState(!1),a=o.useRef(null),i=o.useRef(null),l=o.useRef(null),c=t.layout.desktopTasksOpen,d=t.layout.operationsOpen,m=t.sizes;o.useEffect(()=>{Zl(Lr(),t)},[t]);const x=o.useCallback((k,v)=>{n(S=>{const y=S.layout[k],p=typeof v=="function"?v(y):v;return p===y?S:{...S,layout:{...S.layout,[k]:p}}})},[]),u=o.useCallback(k=>{x("desktopTasksOpen",k)},[x]),h=o.useCallback(k=>{x("operationsOpen",k)},[x]);Ga(i,{onSwipeLeft:()=>r(!1)}),Ga(l,{onSwipeRight:()=>h(!1)});const f=o.useCallback(()=>{if(Wa(hf)){u(k=>!k);return}r(k=>!k)},[u]);o.useEffect(()=>{const k=S=>{const y=a.current;if(!y)return;S.preventDefault();const p=ec(y.panel,y.startSize,y.startClientX,y.startClientY,S.clientX,S.clientY,y.rootFontSize);n(b=>({...b,sizes:{...b.sizes,[y.panel]:p}}))},v=()=>{a.current=null};return globalThis.window?.addEventListener("pointermove",k),globalThis.window?.addEventListener("pointerup",v),globalThis.window?.addEventListener("pointercancel",v),()=>{globalThis.window?.removeEventListener("pointermove",k),globalThis.window?.removeEventListener("pointerup",v),globalThis.window?.removeEventListener("pointercancel",v)}},[]);const w=o.useCallback((k,v)=>{v.preventDefault(),v.currentTarget.setPointerCapture?.(v.pointerId),a.current={panel:k,startSize:m[k],startClientX:v.clientX,startClientY:v.clientY,rootFontSize:pf()}},[m]),g=o.useCallback((k,v)=>{v.preventDefault(),n(S=>({...S,sizes:{...S.sizes,[k]:Xl(k,S.sizes[k],v.deltaY)}}))},[]);return{desktopTasksOpen:c,mobileTasksPanelOpen:s,mobileTasksPanelRef:i,operationsOpen:d,operationsPanelRef:l,panelResize:{sizes:{tasks:cs(m.tasks),operations:cs(m.operations),terminal:cs(m.terminal)},onPointerDown:w,onWheel:g},setMobileTasksPanelOpen:r,setOperationsOpen:h,toggleTasksPanel:f}}function gf(t,n){const s=n.taskId,r=n.updates;return typeof s!="string"||!r||typeof r!="object"?t:t.map(a=>a.id===s?{...a,...r}:a)}const bf="notify_desktop_task";function vf(t=yi()){const n=t?.__TAURI__?.core?.invoke;return typeof n=="function"?n:null}async function wf(t,n=yi()){const s=vf(n);return s?(await s(bf,t),!0):!1}function yf(t,n){const s=[];for(const r of n){const a=jf(r.status);if(!a)continue;const i=t.get(r.id);!i||i.status===r.status||s.push({taskId:r.id,title:r.title.trim()||"Meshy task",status:a,assignedNodeName:r.assignedNodeName??null,projectPath:r.effectiveProjectPath??r.project??null})}return s}function jf(t){return t==="completed"||t==="failed"?t:null}function yi(){return typeof window>"u"?null:window}function Nf({isLeader:t,selfId:n}){return{...!t&&n?{assignedTo:n}:{},completedLimitPerProject:ur}}function rr(t){return`${t.assignedTo??"__unassigned__"}::${t.projectPath}`}function kf(t,n,s,r,a){if(rr(t)!==rr(n))return t;const i=new Set(s.map(c=>c.id)),l=r.filter(c=>!i.has(c.id)).length;return{...t,returned:Math.min(t.total,t.returned+l),hasMore:a.hasMore===!0,nextCursor:a.nextCursor??null}}function Sf(t,n){const s=new Map(t.map(r=>[r.id,r]));for(const r of n)s.set(r.id,r);return Array.from(s.values())}function Cf(t,n,s=new Set){return!n||s.has(n.id)||t.some(r=>r.id===n.id)?t:br(t,n)}function Tf({isLeader:t,selfId:n,sseConnected:s,preservedTask:r,subscribe:a}){const[i,l]=o.useState([]),[c,d]=o.useState([]),[m,x]=o.useState(!0),[u,h]=o.useState(null),f=o.useRef(new Set),w=o.useRef(null),g=o.useRef(null),k=o.useCallback(async()=>{try{const p=await Br(Nf({isLeader:t,selfId:n}));l(Cf(p.tasks,r,f.current)),d(p.completedGroups??[]),h(null)}catch(p){h(p instanceof Error?p.message:"Failed to load tasks")}finally{x(!1)}},[t,r,n]),v=o.useCallback(async p=>{if(!p.hasMore||!p.nextCursor)return;const b=await Br({status:"completed",assignedTo:p.assignedTo??"__unassigned__",projectPath:p.projectPath,cursor:p.nextCursor,limit:ur});l(N=>Sf(N,b.tasks)),d(N=>N.map(A=>kf(A,p,i,b.tasks,b)))},[i]),S=o.useCallback(()=>{g.current===null&&(g.current=window.setTimeout(()=>{g.current=null,k()},tc))},[k]),y=o.useCallback(p=>{const b=new Set(p);if(b.size!==0){for(const N of b)f.current.add(N);l(N=>N.filter(A=>!b.has(A.id)))}},[]);return nc(k,ac(s)),o.useEffect(()=>()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),o.useEffect(()=>{const p=w.current;if(p)for(const b of yf(p,i))wf(b).catch(()=>{});w.current=new Map(i.map(b=>[b.id,b]))},[i]),o.useEffect(()=>{const p=[a("task.updated",b=>{l(N=>gf(N,b.data))}),a("task.status",b=>{l(N=>sc(N,b.data))}),a("node",b=>{Or(b.type)&&S()}),a("task",b=>{if(b.type==="task.deleted"){const N=b.data.taskId;typeof N=="string"&&f.current.add(N),l(A=>rc(A,b.data))}Or(b.type)&&S()})];return()=>p.forEach(b=>b())},[a,S]),{completedGroups:c,fetchTasks:k,loadCompletedTasksPage:v,removeTasksFromList:y,setTasks:l,tasks:i,tasksError:u,tasksLoading:m}}function Tr(t){return t.map(n=>({...n}))}function Af(t,n){const s=n.get(t);return{logs:s?Tr(s.logs):[],transcriptLoading:s?.loaded!==!0}}function Ef(t,n){return n.data.nodeId===t.self.id||n.data.name===t.self.name||n.data.endpoint===t.self.endpoint}function Mf(t,n){const s=t.data.name;if(typeof s=="string"&&s.length>0)return s;const r=t.data.nodeId;return typeof r=="string"?n?.get(r)??r:"node"}function Df({cluster:t,subscribe:n}){o.useEffect(()=>{if(t?.self?.role!=="leader")return;const s=new Map(t.nodes.map(r=>[r.id,r.name]));return s.set(t.self.id,t.self.name),n("node",r=>{const a=Mf(r,s),i=Ef(t,r);r.type==="node.joined"&&!i&&ce.success(`${a} joined the cluster`),r.type==="node.left"&&!i&&ce.message(`${a} left the cluster`)})},[t,n])}function _f({localCount:t,checkpointTotal:n}){const s=Math.max(0,Math.floor(t));if(n===void 0)return{after:s};const r=Math.max(0,Math.floor(n));return s>=r?null:{after:s,minTotal:r}}function Pf({activeTaskId:t,cacheTranscript:n,fetchActiveLogs:s,fetchActiveTask:r,logs:a,setLogs:i,setPendingMessages:l,setTranscriptLoading:c,sseConnected:d,subscribe:m}){const x=o.useRef([]),u=o.useRef(d),h=o.useRef(!1),f=o.useRef(!1),w=o.useRef(void 0);o.useEffect(()=>{x.current=Tr(a)},[a]);const g=o.useCallback(k=>{if(h.current){f.current=!0,k!==void 0&&(w.current=Math.max(w.current??0,k));return}const v=_f({localCount:x.current.length,checkpointTotal:k});v&&(h.current=!0,s(v).finally(()=>{if(h.current=!1,!f.current)return;f.current=!1;const S=w.current;w.current=void 0,g(S)}))},[s]);o.useEffect(()=>{if(t)return m("task",k=>{const v=k.data.taskId;if(!(typeof v!="string"||v!==t)){if(k.type==="task.output"){const S=k.data.event;if(S){i(p=>{const b=Yc(p,S);return n(t,b),b}),c(!1);const y=fr(S);y&&l(p=>Jc(p,y))}}if(k.type==="task.updated"&&r(),k.type==="task.logs.ready"){const S=k.data.total;g(typeof S=="number"?S:void 0)}k.type==="task.status"&&(r(),g())}})},[t,n,s,r,g,i,l,c,m]),o.useEffect(()=>{const k=u.current;u.current=d,!k&&d&&t&&g()},[t,g,d])}const If=[0,300,1e3,2e3];function Rf({task:t,getActiveTaskId:n,setLogs:s,setPendingMessages:r,setTranscriptLoading:a}){t.conversationKind==="nativeSession"&&(async()=>{try{for(const i of If){if(i>0&&await new Promise(l=>setTimeout(l,i)),n()!==t.id)return;try{const l=await Gs(t.id);if(n()!==t.id||(s(c=>Mo(c,l.logs)),r(c=>Qs(c,l.logs)),l.total>0))return}catch{}}}finally{n()===t.id&&a?.(!1)}})()}const ji=8;function Lf(t,n){return We(t??{})===We(n??{})}function Bf(t){return t&&"status"in t&&typeof t.status=="string"?t.status:void 0}function Qa(t,n){return{...t,enabled:!0,alwaysOnline:n}}function Ni(t){return t?.status?.trim()||t?.lastStatus?.trim()||"Unknown"}function Of({operationStarting:t,loading:n,refreshing:s,savedStatus:r,fallbackStatus:a}){return t?"Starting":n?"Listing DevBoxes":s?"Refreshing":r??a}async function Ff(t,n=jo){return(await n({nodeId:t,kind:"devbox.start"})).filter(r=>r.kind==="devbox.start").sort((r,a)=>(a.updatedAt??a.createdAt)-(r.updatedAt??r.createdAt)).slice(0,ji)}function zf(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Uf(t){const n=t.completedAt??t.startedAt??t.updatedAt??t.createdAt;return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(n))}function $f(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Ya(t,n){const r=$f(t)?.[n];return typeof r=="string"&&r.trim()?r.trim():null}function qf(t){if(t.status==="failed")return t.error||"Operation failed";const n=Ya(t.result,"operationId");if(n)return`MCP operation ${n}`;const s=Ya(t.payload,"previousStatus");return s?`Previous DevBox status: ${s}`:t.status==="succeeded"?"Completed":"Waiting for completion"}function Hf(t){return t==="succeeded"?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":t==="failed"?"border-destructive/30 bg-destructive/10 text-destructive":t==="running"?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":"border-border/70 bg-muted/40 text-muted-foreground"}function Ja({devbox:t,showStatus:n=!1}){return e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[e.jsx("span",{className:"font-medium",children:t.name}),t.projectName&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",t.projectName]})]}),n&&e.jsx("span",{className:"ml-auto shrink-0 rounded-sm border border-border/70 bg-background/70 px-1.5 py-0 text-[10px] leading-none text-muted-foreground",children:Ni(t)})]})}function Vf({error:t,loading:n,onToggle:s,open:r,operations:a}){return e.jsxs("div",{className:"min-w-0 max-w-full overflow-hidden rounded-sm border border-border/60 bg-muted/20 text-xs",children:[e.jsxs("button",{type:"button",onClick:s,"aria-expanded":r,className:"flex h-8 w-full items-center gap-2 px-3 text-left text-[11px] text-foreground hover:bg-muted/30",children:[e.jsx(tt,{className:F("h-3 w-3 shrink-0 text-muted-foreground transition-transform",!r&&"-rotate-90")}),e.jsx(Vn,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Operations history"}),n&&e.jsx(he,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}),!n&&a.length>0&&e.jsx("span",{className:"shrink-0 rounded-sm border border-border/70 bg-background/60 px-1.5 py-0 text-[10px] leading-none text-muted-foreground",children:a.length})]}),r&&e.jsxs("div",{className:"max-h-44 min-w-0 max-w-full overflow-y-auto border-t border-border/50 px-2 py-1.5",children:[n&&a.length===0&&e.jsxs("div",{className:"flex h-7 items-center gap-2 px-1 text-[10px] text-muted-foreground",children:[e.jsx(he,{className:"h-3 w-3 animate-spin"}),"Loading operations"]}),t&&e.jsx("div",{className:"px-1 py-1 text-[10px] text-destructive",children:t}),!n&&!t&&a.length===0&&e.jsx("div",{className:"px-1 py-1 text-[10px] text-muted-foreground",children:"No DevBox operations yet."}),a.map(i=>{const l=qf(i);return e.jsxs("div",{className:"flex w-full min-w-0 max-w-full items-start gap-2 overflow-hidden rounded-sm px-1 py-1.5 text-[11px] hover:bg-background/40",children:[e.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-foreground",children:"Start DevBox"}),e.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:Uf(i)})]}),e.jsx("div",{className:"mt-0.5 w-full min-w-0 max-w-full overflow-x-auto whitespace-nowrap text-[10px] leading-3.5 text-muted-foreground",title:l,children:e.jsx("span",{className:"inline-block min-w-max",children:l})})]}),e.jsx("span",{className:F("shrink-0 rounded-sm border px-1.5 py-0 text-[10px] leading-4",Hf(i.status)),children:zf(i.status)})]},i.id)})]})]})}function Kf({node:t,open:n,startInProgress:s=!1,onOpenChange:r,onRefresh:a}){const i=t?.id??null,l=n&&!s&&Ba(t?.status,t?.devbox??null),[c,d]=o.useState([]),[m,x]=o.useState(()=>t?.devbox?We(t.devbox):""),[u,h]=o.useState(()=>t?.devbox??null),[f,w]=o.useState(()=>Oa(t?.devbox??null)),[g,k]=o.useState(!1),[v,S]=o.useState(l),[y,p]=o.useState(!1),[b,N]=o.useState(!1),[A,I]=o.useState(()=>t?.devbox?.alwaysOnline===!0),[E,L]=o.useState(!1),[M,D]=o.useState([]),[P,B]=o.useState(!1),[Q,te]=o.useState(null),Y=o.useMemo(()=>{const q=c.find(ae=>We(ae)===m);return q||(on(u)&&We(u)===m?u:void 0)},[u,c,m]),H=Bf(Y??void 0),ne=f?H??u?.lastStatus:u?.lastStatus??H,$=t?.status==="online"||t?.status==="busy"?"Running":"Unknown",X=b||s,j=Of({operationStarting:X,loading:g,refreshing:v,savedStatus:ne,fallbackStatus:$}),W=f&&!!Y&&!Lf(u,Y),T=u?.alwaysOnline===!0!==A,ee=Gh({nodeStatus:t?.status,status:j,current:u,selected:Y}),R=!!ee,V=!!Y&&(W||T)&&!R,O=Y??u,le=o.useCallback(async()=>{if(i){S(!0);try{const q=await oc(i);h(q.devbox),x(We(q.devbox))}catch(q){ce.error(q instanceof Error?q.message:"Failed to refresh DevBox status")}finally{S(!1)}}},[i]),ie=o.useCallback(async q=>{k(!0);try{const ae=await ic();d(ae),x(ye=>Wh({previousKey:ye,baseDevBox:q,listed:ae}))}catch(ae){ce.error(ae instanceof Error?ae.message:"Failed to load DevBoxes")}finally{k(!1)}},[]);o.useEffect(()=>{if(!n||!i)return;let q=!1;const ae=t?.devbox??null,ye=Oa(ae),pe=!s&&Ba(t?.status,ae);k(!1),S(pe),w(ye),h(ae),I(ae?.alwaysOnline===!0),L(!1),x(on(ae)?We(ae):""),d([]);async function Ye(){pe&&await le(),!q&&ye&&await ie(ae)}return Ye(),()=>{q=!0}},[ie,t?.devbox,t?.status,i,n,le,s]),o.useEffect(()=>{if(!n||!i)return;let q=!1;const ae=i;async function ye(){B(!0),te(null),D([]);try{const pe=await Ff(ae);if(q)return;D(pe)}catch(pe){if(q)return;D([]),te(pe instanceof Error?pe.message:"Failed to load operation history")}finally{q||B(!1)}}return ye(),()=>{q=!0}},[i,n]);async function ue(){w(!0),c.length===0&&await ie(u)}async function J(){if(!(!t||!Y)){p(!0);try{const q=await Fr(t.id,Qa(Y,A));h(q.node.devbox??null),q.node.devbox&&x(We(q.node.devbox)),w(!1),ce.success(`Configured DevBox for ${t.name}`),await a?.()}catch(q){ce.error(q instanceof Error?q.message:"Failed to configure DevBox")}finally{p(!1)}}}async function K(){if(!(!t||!ee)){N(!0);try{if(Y&&(W||T)){const ae=await Fr(t.id,Qa(Y,A));h(ae.node.devbox??null),ae.node.devbox&&x(We(ae.node.devbox)),w(!1)}const{operation:q}=await No(t.id);h(ae=>ae&&{...ae,lastStatus:"Starting",checkedAt:Date.now(),operationId:q.id}),D(ae=>[q,...ae.filter(ye=>ye.id!==q.id)].slice(0,ji)),ce.success(`Start requested for ${t.name}`),await a?.()}catch(q){ce.error(q instanceof Error?q.message:"Failed to start DevBox")}finally{N(!1)}}}const _=g?"Loading DevBoxes...":c.length===0?"No DevBoxes available":"Select a DevBox",se=j==="Running"&&t?.status==="offline";return e.jsx(ut,{open:n,onOpenChange:r,children:e.jsxs(mt,{className:"w-[calc(100vw-2rem)] max-w-md grid-cols-[minmax(0,1fr)] gap-3 overflow-hidden rounded-sm p-4",children:[e.jsxs(Tt,{className:"min-w-0 max-w-full space-y-1 overflow-hidden",children:[e.jsx(gt,{className:"text-sm",children:"Configure DevBox"}),e.jsxs(At,{className:"max-w-full text-xs",children:["Bind ",t?.name?e.jsx("span",{className:"font-medium text-foreground",children:t.name}):"this node"," to an Azure Dev Box. Meshy will start it when the node is offline."]})]}),e.jsxs("div",{className:"min-w-0 max-w-full space-y-3 overflow-hidden",children:[(f||O)&&e.jsxs("div",{className:"flex min-h-9 w-full min-w-0 max-w-full items-center justify-between gap-3 overflow-hidden rounded-sm border border-border/60 bg-muted/20 px-3 py-2 text-xs",children:[e.jsx("div",{className:"min-w-0 flex-1",children:f?e.jsxs(ze,{value:m,onValueChange:x,disabled:g||y||b||c.length===0,children:[e.jsx(Ue,{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:g&&!Y?e.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),_]}):Y?e.jsx(Ja,{devbox:Y}):e.jsx(Qe,{placeholder:_})}),e.jsx($e,{children:c.map(q=>e.jsx(Le,{value:We(q),textValue:`${q.name} ${q.projectName??""} ${Ni(q)}`,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(Ja,{devbox:q,showStatus:!0})},We(q)))})]}):O&&e.jsxs("div",{className:"min-w-0 truncate",children:[e.jsx("span",{className:"font-medium text-foreground",children:O.name}),O.projectName&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",O.projectName]})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(Ze,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px]",children:[(g||v)&&e.jsx(he,{className:"mr-1 h-2.5 w-2.5 animate-spin"}),j]}),u?.name&&e.jsx(Z,{type:"button",variant:"ghost",size:"icon",onClick:()=>{ue()},disabled:g||y||X||f,"aria-label":"Edit DevBox binding",title:"Edit DevBox binding",className:"h-6 w-6 rounded-sm text-muted-foreground hover:text-foreground",children:g&&f?e.jsx(he,{className:"h-3 w-3 animate-spin"}):e.jsx(Wt,{className:"h-3 w-3"})})]})]}),se&&e.jsx("div",{className:"rounded-sm 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 w-full min-w-0 max-w-full items-start gap-2 overflow-hidden rounded-sm border border-border/60 bg-muted/20 px-3 py-2 text-xs text-foreground",children:[e.jsx(Sn,{checked:A,onCheckedChange:q=>I(q===!0),disabled:y||b||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.jsx(Vf,{error:Q,loading:P,onToggle:()=>L(q=>!q),open:E,operations:M})]}),e.jsxs(lr,{className:"gap-2 sm:space-x-0",children:[e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:y||b,className:"h-8 rounded-sm text-xs",children:"Close"}),R&&e.jsxs(Z,{size:"sm",onClick:K,disabled:b,className:"h-8 rounded-sm text-xs",children:[b?e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Yn,{className:"h-3.5 w-3.5"}),"Start DevBox"]}),!R&&e.jsxs(Z,{size:"sm",onClick:J,disabled:!V||y,className:"h-8 rounded-sm text-xs",children:[y&&e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})})}async function Gf(t,n=jo){if(t.length===0)return new Set;const s=new Set(t),[r,a]=await Promise.all([n({kind:"devbox.start",status:"queued"}),n({kind:"devbox.start",status:"running"})]);return new Set([...r,...a].filter(i=>s.has(i.nodeId)).map(i=>i.nodeId))}function Wf({cluster:t,refresh:n}){const[s,r]=o.useState(null),[a,i]=o.useState(null),[l,c]=o.useState(()=>new Set),[d,m]=o.useState(()=>new Set),x=o.useMemo(()=>t?.nodes.find(v=>v.id===s)??null,[t?.nodes,s]),u=o.useMemo(()=>new Set((t?.nodes??[]).filter(v=>v.devbox?.enabled).map(v=>v.id)),[t?.nodes]),h=o.useMemo(()=>new Set((t?.nodes??[]).filter(v=>Zn(v.status,v.devbox?.lastStatus,v.devbox)).map(v=>v.id)),[t?.nodes]),f=o.useMemo(()=>new Set((t?.nodes??[]).filter(v=>ln(v.devbox?.lastStatus)).map(v=>v.id)),[t?.nodes]),w=o.useMemo(()=>{const v=new Set(l);a&&v.add(a);for(const S of d)v.add(S);for(const S of f)v.add(S);return v},[d,a,l,f]);o.useEffect(()=>{let v=!1;const S=[...u];async function y(){try{const p=await Gf(S);v||m(p)}catch{v||m(new Set)}}return y(),()=>{v=!0}},[u]),o.useEffect(()=>{c(v=>{let S=!1;const y=new Set(v);for(const p of v){const b=t?.nodes.find(N=>N.id===p);b?.status!=="online"&&(!b?.devbox?.lastStatus||ln(b.devbox.lastStatus))||(y.delete(p),S=!0)}return S?y:v})},[t?.nodes]);const g=o.useCallback(async v=>{const S=t?.nodes.find(y=>y.id===v);if(S){i(v),c(y=>new Set(y).add(v));try{await No(v),ce.success(`Start requested for ${S.name}`),n()}catch(y){c(p=>{const b=new Set(p);return b.delete(v),b}),ce.error(y instanceof Error?y.message:"Failed to start DevBox")}finally{i(null)}}},[t?.nodes,n]);return{devBoxDialog:e.jsx(Kf,{node:x,open:s!==null,startInProgress:x?w.has(x.id):!1,onOpenChange:v=>{v||r(null)},onRefresh:n}),devBoxNodeIds:u,devBoxStartNodeId:a,devBoxStartNodeIds:h,devBoxStartingNodeIds:w,openDevBox:r,startDevBox:g}}function Qf(t){const[n,s]=o.useState(null),r=o.useCallback(i=>{t&&s(i)},[t]);return{nodeSettingsDialog:e.jsx(lc,{open:n!==null,onOpenChange:i=>{i||s(null)},initialSelectedNodeId:n??void 0,showTrigger:!1}),openNodeSettings:r}}function Yf(t=!1){return!t}function Jf({activeTaskId:t,fetchActiveTask:n,isRunning:s=!1,setPendingMessages:r,setTask:a,setTasks:i}){const l=o.useCallback((m,x)=>{a(u=>u&&u.id===m?{...u,queuedMessages:x}:u),i(u=>u.map(h=>h.id===m?{...h,queuedMessages:x}:h))},[a,i]),c=o.useCallback(async(m,x={})=>{if(!t)return!1;const u=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`,h=Yf(s);h&&r(f=>[...f,{id:u,content:m,timestamp:new Date().toISOString()}]);try{const f=x.targetAgent?await zr(t,m,x.targetAgent):await zr(t,m);return f.queued&&(h&&r(w=>w.filter(g=>g.id!==u)),f.queuedMessages&&l(t,f.queuedMessages)),n(),!0}catch(f){return h&&r(w=>w.filter(g=>g.id!==u)),ce.error(f instanceof Error?f.message:"Failed to send message"),!1}},[t,n,s,r,l]);return{cancelQueuedMessage:o.useCallback(async m=>{if(t)try{const x=await cc(t,m);l(t,x.queuedMessages),n()}catch(x){ce.error(x instanceof Error?x.message:"Failed to cancel queued message")}},[t,n,l]),queueFollowUpMessage:c}}const Za="grid-cols-[1.5rem_5.25rem_4rem_minmax(8rem,1fr)_4rem_4rem_6rem]",Zf={claudecode:"Claude Code",codex:"Codex",copilot:"Copilot"};function Xf(t,n){const s=n.search.trim().toLowerCase();return t.filter(r=>n.agent!=="all"&&r.agent!==n.agent||n.kind!=="all"&&r.kind!==n.kind?!1:s?[r.name,r.description,r.source,r.version,r.agent,r.kind].some(a=>a?.toLowerCase().includes(s)):!0)}function ki(t){return t.kind==="mcp"?"-":t.sizeBytes<1024?`${t.sizeBytes} B`:t.sizeBytes<1024*1024?`${Math.round(t.sizeBytes/1024)} KB`:`${(t.sizeBytes/1024/1024).toFixed(1)} MB`}function ep({items:t,selectedIds:n,activeId:s,onToggleSelected:r,onOpenDetail:a}){return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-sm border border-border/60 bg-card/35",children:[e.jsxs("div",{className:F("grid shrink-0 gap-2 border-b border-border/55 bg-primary/6 px-2 py-1.5 text-[8px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",Za),children:[e.jsx("span",{}),e.jsx("span",{children:"Agent"}),e.jsx("span",{children:"Kind"}),e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Ver"}),e.jsx("span",{children:"Size"}),e.jsx("span",{children:"Source"})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:t.length>0?t.map(i=>e.jsxs("button",{type:"button",onClick:()=>a(i),className:F("grid h-7 w-full items-center gap-2 border-b border-border/30 px-2 text-left text-[10px] transition-colors hover:bg-primary/6",Za,s===i.id&&"bg-primary/10 text-primary shadow-[inset_2px_0_0_hsl(var(--primary))]"),children:[e.jsx("span",{onClick:l=>l.stopPropagation(),children:e.jsx(Sn,{className:"h-3 w-3",checked:n.has(i.id),onCheckedChange:l=>r(i.id,l===!0),"aria-label":`Select ${i.name}`})}),e.jsx(tp,{agent:i.agent}),e.jsx("span",{children:i.kind}),e.jsx("span",{className:"truncate font-medium text-foreground",children:i.name}),e.jsx("span",{className:"truncate text-muted-foreground",children:i.version??"-"}),e.jsx("span",{className:"truncate text-muted-foreground",children:ki(i)}),e.jsx("span",{className:"truncate text-muted-foreground",children:i.source??"local"})]},i.id)):e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-muted-foreground",children:"No capabilities match this view."})})]})}function tp({agent:t}){const n=Zf[t];return e.jsx("span",{className:"block min-w-0 truncate text-[10px] font-medium leading-3 text-muted-foreground",title:n,children:n})}const Xa=320,eo=560,Si=384,to=360;function np(t,n=eo+to){const s=Math.max(Xa,Math.min(eo,n-to));return Math.min(Math.max(Math.round(t),Xa),s)}function sp(t,n,s,r){return np(t+n-s,r)}function rp({detail:t,deleting:n=!1,onDelete:s,desktopWidth:r=Si,pending:a=!1}){const i={"--capability-detail-width":`${r}px`};if(!t)return e.jsx("aside",{"data-capability-detail-panel":"true",style:i,className:"hidden min-h-0 shrink-0 animate-panel-settle bg-gradient-to-b from-primary/6 via-card/28 to-background/60 px-3 py-3 text-[11px] text-muted-foreground lg:block lg:w-[var(--capability-detail-width)]",children:a?"Loading capability metadata...":"No capability selected."});const l=t.kind==="mcp"?"mcp":"files";return e.jsxs("aside",{"data-capability-detail-panel":"true",style:i,className:"flex min-h-0 w-full shrink-0 animate-panel-settle flex-col bg-gradient-to-b from-primary/6 via-card/28 to-background/60 px-3 py-2.5 lg:w-[var(--capability-detail-width)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("div",{className:"truncate text-[13px] font-semibold leading-5 text-foreground",children:t.name}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-1",children:[e.jsx(Ze,{variant:"secondary",className:"rounded-sm border-0 bg-card/72 px-1.5 py-0 text-[8px] text-primary",children:t.agent}),e.jsx(Ze,{variant:"outline",className:"rounded-sm border-0 bg-card/72 px-1.5 py-0 text-[8px] text-primary/90",children:t.kind})]})]}),s&&e.jsxs(Ft,{children:[e.jsx(Ks,{asChild:!0,children:e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-sm text-muted-foreground hover:text-destructive","aria-label":"Delete capability",title:"Delete capability",disabled:n,children:e.jsx(mr,{className:"h-3.5 w-3.5"})})}),e.jsxs(zt,{className:"max-w-[22rem] gap-2 rounded-xl p-4",children:[e.jsxs(Ut,{className:"space-y-1",children:[e.jsxs($t,{className:"text-sm",children:["Delete ",t.name,"?"]}),e.jsxs(qt,{className:"text-[11px] leading-4",children:["This removes the selected ",t.kind," from ",t.scope.kind==="global"?"the user profile":"this project","."]})]}),e.jsxs(Ht,{className:"gap-1 pt-0 sm:space-x-1",children:[e.jsx(Vt,{className:"h-7 rounded-lg px-2 text-[11px]",children:"Cancel"}),e.jsx(Kt,{className:"h-7 rounded-lg px-2 text-[11px]",onClick:s,disabled:n,children:"Delete"})]})]})]})]}),e.jsxs("div",{className:"mt-1 grid grid-cols-2 gap-1 text-[9px]",children:[e.jsx(zn,{label:"Version",value:t.version??"-"}),e.jsx(zn,{label:"Size",value:ki(t)}),e.jsx(zn,{label:"Files",value:String(t.fileCount)}),e.jsx(zn,{label:"Source",value:t.source??"local"})]}),e.jsxs(or,{defaultValue:l,className:"mt-2 flex min-h-0 flex-1 flex-col",children:[e.jsxs(ar,{className:"grid h-auto grid-cols-2 rounded-sm bg-primary/8 p-0.5",children:[t.kind==="mcp"?e.jsx(Ot,{value:"mcp",className:"rounded-sm px-2 py-0.5 text-[9px]",children:"MCP"}):e.jsx(Ot,{value:"files",className:"rounded-sm px-2 py-0.5 text-[9px]",children:"Files"}),e.jsx(Ot,{value:"readme",className:"rounded-sm px-2 py-0.5 text-[9px]",children:"README"})]}),t.kind==="mcp"?e.jsx(yt,{value:"mcp",className:"mt-2 min-h-0 flex-1 overflow-auto",children:e.jsx(ap,{detail:t})}):e.jsx(yt,{value:"files",className:"mt-2 min-h-0 flex-1 overflow-auto",children:e.jsx(op,{detail:t})}),e.jsx(yt,{value:"readme",className:"mt-2 min-h-0 flex-1 overflow-auto",children:t.readmeMarkdown?e.jsx(sd,{content:t.readmeMarkdown,className:"overflow-hidden rounded-sm border-0 bg-background/70 shadow-none [&>div:first-child>div]:border-0 [&>div:first-child]:border-b-0",previewClassName:"px-3 py-2 text-[11px] leading-5",rawClassName:"text-[10px] leading-4"}):e.jsx(Ar,{children:"No README content."})})]},t.id)]})}function ap({detail:t}){const n=t.mcpPreview??[];return n.length===0?e.jsx(Ar,{children:"No MCP entries."}):e.jsx("div",{className:"space-y-1.5",children:n.map(s=>e.jsxs("div",{className:"rounded-sm bg-card/72 p-2 text-[10px] shadow-none",children:[e.jsx("div",{className:"font-semibold text-foreground",children:s.serverName}),e.jsx("pre",{className:"mt-1 max-h-64 overflow-auto rounded-sm bg-background/55 px-2 py-1 whitespace-pre-wrap break-all font-mono text-[9px] leading-4 text-muted-foreground",children:JSON.stringify(s.config,null,2)})]},s.serverName))})}function op({detail:t}){const n=t.fileTree??[];return n.length===0?e.jsx(Ar,{children:"No files."}):e.jsx("div",{className:"space-y-1 overflow-auto rounded-sm bg-card/72 p-2 font-mono text-[9px] leading-4 text-muted-foreground shadow-none",children:n.map(s=>e.jsx("div",{children:s.relPath},s.relPath))})}function Ar({children:t}){return e.jsx("div",{className:"rounded-sm bg-primary/5 px-2 py-6 text-center text-[10px] text-muted-foreground",children:t})}function zn({label:t,value:n}){return e.jsxs("div",{className:"rounded-sm bg-card/72 px-2 py-0.5 shadow-none",children:[e.jsx("div",{className:"text-[7px] uppercase tracking-[0.14em] text-muted-foreground",children:t}),e.jsx("div",{className:"truncate text-[9px] font-medium text-foreground",children:n})]})}const ip=20,lp=288,cp=360,dp=440;function up(){if(typeof window>"u"||typeof document>"u")return 1;const t=window.getComputedStyle(document.documentElement),n=t.zoom||t.getPropertyValue("--ui-zoom"),s=Number.parseFloat(n);return Number.isFinite(s)&&s>0?s:1}function mp({triggerRect:t,targetRect:n,viewportRect:s,compact:r,browserOpen:a=!1,portalAlign:i,cssZoom:l=1}){const c=Number.isFinite(l)&&l>0?l:1,d=8,m=s.top+d,x=s.bottom-d,u=s.left+d,h=s.right-d,f=Math.max(0,x-t.bottom-4),w=Math.max(0,t.top-m-4),g=r?w<140&&f>w:f>=220||f>=w,k=g?f:w,v=Math.max(140,x-m),S=r&&a,b=Math.min(v,S?dp:320,Math.max(S?cp:140,k)),N=lp*c,A=i==="end"?t.right-N:t.left,E=(Math.max(u,Math.min(A,h-N))-n.left)/c;if(!g&&!S)return{left:E,bottom:(n.bottom-(t.top-4))/c,maxHeight:b/c};const L=g?t.bottom+4:t.top-b-4,M=Math.max(m,Math.min(L,x-b));return{left:E,top:(M-n.top)/c,maxHeight:b/c}}function Er(t){if(!t.workDir)return[];const n=[],s=new Set,r=a=>{!a||s.has(a)||(s.add(a),n.push(a))};r(t.workDir);for(const a of t.workDirFolders??[])r(Ti(a)?a:Ai(t.workDir,a));return n}function hp(t,n){if(t.kind==="global")return{nodeId:n.id,scope:{kind:"global"}};const s=Er(n),r=s.find(a=>a===t.projectPath);return r?{nodeId:n.id,scope:{kind:"project",projectPath:r}}:s[0]?{nodeId:n.id,scope:{kind:"project",projectPath:s[0]}}:{nodeId:n.id,scope:{kind:"global"}}}function fp(t,n){return{nodeId:t,scope:n}}function no(t,n,s){const r=n.trim();return!r||r==="."?t.workDir??r:s||Ti(r)?r:t.workDir?Ai(t.workDir,r):r}function pp({node:t,scope:n,clusterNodes:s,onSelectionChange:r}){const a=o.useMemo(()=>vp(s,t),[s,t]),i=o.useMemo(()=>Er(t),[t]),l=o.useMemo(()=>a.map(c=>({value:c.id,label:c.name,description:`${c.role} · ${c.status}`,status:c.status})),[a]);return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-2",children:[e.jsx(bp,{ariaLabel:"Capability node",value:t.name,description:`${t.role} · ${t.status}`,options:l,selectedValue:t.id,onSelect:c=>{const d=a.find(m=>m.id===c);d&&r?.(hp(n,d))}}),e.jsx(Ci,{node:t,projectPaths:i,selectedScope:n,onSelect:c=>r?.(fp(t.id,c))}),e.jsx(xp,{node:t})]})}function xp({node:t}){return e.jsxs("div",{"data-capability-node-meta":"true",className:"flex min-w-0 items-center gap-1 border-0 bg-transparent px-0.5 text-[8px] leading-3 text-muted-foreground",title:`${t.role} · ${t.status}`,children:[e.jsx("span",{className:"truncate capitalize",children:t.role}),e.jsx("span",{className:F("h-1.5 w-1.5 shrink-0 rounded-full",jn(t.status))})]})}function Ci({node:t,projectPaths:n,selectedScope:s,onSelect:r,compact:a=!1,portal:i=!1,portalAlign:l="start"}){const[c,d]=o.useState(!1),[m,x]=o.useState(null),[u,h]=o.useState(!1),[f,w]=o.useState(!1),[g,k]=o.useState(null),[v,S]=o.useState(!1),[y,p]=o.useState(null),b=o.useRef(null),N=o.useRef(null),A=o.useRef(null),I=o.useMemo(()=>n.map($=>({value:$,label:ro($),description:$})),[n]),E=s.kind==="project"?s.projectPath:void 0,L=s.kind==="global"?"Global":ro(s.projectPath),M=s.kind==="global"?"Global":s.projectPath,D=o.useCallback(()=>!i||typeof document>"u"?null:N.current?.closest('[data-capability-share-dialog="true"]')??document.body,[i]),P=o.useCallback(()=>{if(!i||!N.current||typeof window>"u")return;const $=N.current.getBoundingClientRect(),X=D(),j=X&&X!==document.body?X.getBoundingClientRect():{left:0,top:0,bottom:window.innerHeight};p(mp({triggerRect:$,targetRect:j,viewportRect:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight},compact:a,browserOpen:v,portalAlign:l,cssZoom:up()}))},[v,a,D,i,l]);o.useEffect(()=>{c||S(!1)},[c]),o.useEffect(()=>{if(!c)return;const $=X=>{if(!(X.target instanceof Node))return;const j=X.composedPath(),W=b.current?j.includes(b.current):!1,T=A.current?j.includes(A.current):X.target instanceof Element&&!!X.target.closest('[data-capability-scope-menu="true"]');!W&&!T&&d(!1)};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[c]),o.useEffect(()=>{if(!(!c||!i))return P(),window.addEventListener("resize",P),window.addEventListener("scroll",P,!0),()=>{window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}},[c,i,P]);const B=async($,X=0,j=!1)=>{if(t.workDir){k(null),j?w(!0):h(!0);try{const W=await mo(t.id,{path:$||".",limit:ip,offset:X,directoriesOnly:!0,allowAbsolute:!0});x(T=>j&&T?{...W,entries:[...T.entries,...W.entries]}:W)}catch(W){k(W instanceof Error?W.message:"Failed to browse folders"),j||x(null)}finally{h(!1),w(!1)}}};o.useEffect(()=>{!c||!v||!t.workDir||(x(null),k(null),B(E||"."))},[v,c,t.id,t.workDir,E]);const Q=($,X=!1)=>{r({kind:"project",projectPath:no(t,$,X)}),d(!1)},te=()=>{r({kind:"global"}),d(!1)},Y=m?no(t,m.currentPath,m.isAbsolute):E??t.workDir??"",H=i?D():null,ne=e.jsxs("div",{ref:A,"data-capability-scope-menu":"true","aria-hidden":!c,onClick:$=>$.stopPropagation(),onMouseDown:$=>$.stopPropagation(),onPointerDown:$=>$.stopPropagation(),style:i&&y?{left:y.left,top:y.top,bottom:y.bottom,height:a&&v?y.maxHeight:void 0,maxHeight:y.maxHeight}:void 0,className:F(i?"absolute z-[80] flex w-72 flex-col overflow-hidden rounded-lg border border-border/70 bg-popover text-popover-foreground shadow-none pointer-events-auto":"absolute left-0 z-50 flex max-h-[28rem] w-72 flex-col overflow-hidden rounded-lg border border-border/70 bg-popover text-popover-foreground shadow-none",!i&&(a?"top-7":"top-9"),!c&&"hidden"),children:[e.jsxs("div",{className:"shrink-0 border-b border-border/55 p-1",children:[e.jsx("div",{className:F("px-2 text-[8px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",a?"pb-0.5 pt-0.5 leading-3":"pb-1 pt-1"),children:"Scope"}),e.jsxs("div",{className:F("overflow-y-auto pr-0.5",a?"max-h-32":"max-h-40"),children:[e.jsx(so,{icon:"global",label:"Global",selected:s.kind==="global",onSelect:te,compact:a}),I.length>0?I.map($=>e.jsx(so,{icon:"folder",label:$.label,description:$.description,selected:E===$.value,onSelect:()=>Q($.value,!0),compact:a},$.value)):e.jsx("div",{className:F("flex items-center px-2 text-muted-foreground",a?"h-7 text-[9px]":"h-8 text-[10px]"),children:"No known projects"})]})]}),e.jsxs("div",{className:F("border-b border-border/55",v?"flex min-h-0 flex-1 flex-col":"shrink-0"),children:[e.jsxs("button",{type:"button","aria-expanded":v,onClick:()=>S($=>!$),className:F("flex w-full items-center gap-1 px-2 text-left text-[8px] font-semibold uppercase tracking-[0.14em] text-muted-foreground transition-colors hover:bg-muted/45 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",a?"py-1 leading-3":"py-1.5"),children:[e.jsx(cn,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Browse folders"}),e.jsx(tt,{className:F("h-3 w-3 shrink-0 transition-transform duration-200",v&&"rotate-180")})]}),v&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"shrink-0 px-2 pb-1.5",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>m?.parentPath&&void B(m.parentPath),disabled:!m?.parentPath||u,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground disabled:opacity-40",title:"Parent directory",children:e.jsx(_o,{className:"h-2.5 w-2.5"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[9px] text-muted-foreground",title:Y,children:Y}),m&&e.jsx("button",{type:"button",onClick:()=>Q(m.currentPath,m.isAbsolute),className:"shrink-0 rounded px-1.5 py-0.5 text-[9px] font-medium text-foreground hover:bg-muted/60",title:"Use this folder",children:"Use"})]})}),e.jsxs("div",{className:F("min-h-0 flex-1 overflow-y-auto",a?"min-h-[8.25rem]":"max-h-56"),children:[t.workDir?u?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[9px] text-muted-foreground",children:[e.jsx(he,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading folders..."]}):m&&m.entries.length>0?e.jsxs(e.Fragment,{children:[m.entries.map($=>e.jsx(gp,{entry:$,onSelect:()=>Q($.path,m.isAbsolute),onOpen:()=>{B($.path)}},$.path)),m.hasMore&&e.jsxs("button",{type:"button",onClick:()=>{B(m.currentPath,m.entries.length,!0)},disabled:f,className:"flex w-full items-center justify-center gap-1 border-t border-border/40 py-1 text-[9px] text-muted-foreground hover:bg-muted/60 hover:text-foreground disabled:opacity-50",children:[f?e.jsx(he,{className:"h-3 w-3 animate-spin"}):e.jsx(bd,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[9px] text-muted-foreground",children:g??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[9px] text-muted-foreground",children:"This node has no working directory."}),g&&m&&m.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[9px] text-destructive",children:g})]})]})]})]});return e.jsxs("div",{ref:b,className:"relative min-w-0",children:[e.jsxs("button",{ref:N,type:"button","aria-label":"Capability location","aria-expanded":c,title:M,onClick:()=>d($=>($||(S(!1),P()),!$)),className:F("flex min-w-0 items-center gap-1.5 rounded-sm border-0 bg-muted/55 text-left shadow-none transition-colors hover:bg-muted/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",a?"h-5 w-24 max-w-28 px-1.5":"h-7 min-w-32 max-w-56 px-2"),children:[e.jsx("span",{className:"min-w-0 flex-1",children:e.jsx("span",{className:F("block truncate font-medium text-foreground",a?"text-[9px] leading-3":"text-[10px] leading-4"),children:L})}),e.jsx(tt,{className:F(a?"h-2.5 w-2.5":"h-3 w-3","shrink-0 text-muted-foreground transition-transform",c&&"rotate-180")})]}),i&&H?Qn.createPortal(ne,H):ne]})}function so({icon:t,label:n,description:s,selected:r,onSelect:a,compact:i=!1}){const l=t==="global"?pd:cn;return e.jsxs("button",{type:"button",onClick:a,className:F(i?"flex h-7 w-full items-center gap-1.5 rounded-md px-2 text-left text-[9px]":"flex h-8 w-full items-center gap-1.5 rounded-md px-2 text-left text-[10px]","transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",r&&"bg-primary/10 text-primary"),children:[e.jsx(l,{className:F("shrink-0 text-muted-foreground",i?"h-2.5 w-2.5":"h-3 w-3",r&&"text-primary")}),e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col justify-center",children:[e.jsx("span",{className:"block truncate font-medium leading-3",children:n}),s&&e.jsx("span",{className:F("block truncate text-muted-foreground",i?"text-[7px] leading-3":"text-[8px] leading-3"),children:s})]})]})}function gp({entry:t,onOpen:n,onSelect:s}){return e.jsxs("div",{className:"group flex items-stretch border-b border-border/30 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:s,className:"flex min-w-0 flex-1 items-center gap-1.5 px-2 py-1 text-left text-[9px] hover:bg-muted/55",title:`Use ${t.path}`,children:[e.jsx(cn,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-foreground",children:t.name})]}),e.jsx("button",{type:"button",onClick:n,className:"flex w-7 shrink-0 items-center justify-center border-l border-border/30 text-muted-foreground hover:bg-muted/65 hover:text-foreground",title:"Open subfolder","aria-label":`Open ${t.name}`,children:e.jsx(dt,{className:"h-3 w-3"})})]})}function bp({ariaLabel:t,value:n,description:s,options:r,selectedValue:a,onSelect:i}){const[l,c]=o.useState(!1),d=o.useRef(null);return o.useEffect(()=>{if(!l)return;const m=x=>{d.current&&x.target instanceof Node&&!d.current.contains(x.target)&&c(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[l]),e.jsxs("div",{ref:d,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":t,"aria-expanded":l,title:s??n,onClick:()=>c(m=>!m),className:"flex h-7 min-w-32 max-w-56 items-center gap-1.5 rounded-sm border-0 bg-muted/55 px-2 text-left shadow-none transition-colors hover:bg-muted/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{className:"min-w-0 flex-1",children:e.jsx("span",{className:"block truncate text-[10px] font-medium leading-4 text-foreground",children:n})}),e.jsx(tt,{className:F("h-3 w-3 shrink-0 text-muted-foreground transition-transform",l&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!l,className:F("absolute left-0 top-9 z-50 w-64 overflow-hidden rounded-lg border border-border/70 bg-popover text-popover-foreground shadow-none",!l&&"hidden"),children:e.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:r.length>0?r.map(m=>e.jsxs("button",{type:"button",onClick:()=>{i(m.value),c(!1)},className:F("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[11px] transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",m.value===a&&"bg-primary/10 text-primary"),children:[m.status&&e.jsx("span",{className:F("h-1.5 w-1.5 shrink-0 rounded-full",jn(m.status))}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate font-medium",children:m.label}),m.description&&e.jsx("span",{className:"block truncate text-[9px] text-muted-foreground",children:m.description})]})]},m.value)):e.jsx("div",{className:"px-2 py-2 text-[10px] text-muted-foreground",children:"No projects"})})})]})}function vp(t,n){const s=new Map;for(const r of t)s.set(r.id,r);return s.set(n.id,n),Array.from(s.values())}function jn(t){return t==="online"?"bg-emerald-500":t==="offline"?"bg-muted-foreground/45":"bg-amber-500"}function ro(t){return t.split(/[\\/]+/).filter(Boolean).at(-1)??t}function Ti(t){return t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t)}function Ai(t,n){return`${t.replace(/[\\/]+$/,"")}/${n.replace(/^[\\/]+/,"")}`}const wp="h-6 w-24 rounded-sm px-2 text-[10px] shadow-none",$s="text-[10px]",Ei=["claudecode","codex","copilot"],yn={claudecode:"Claude Code",codex:"Codex",copilot:"Copilot"};function yp({open:t,sourceNode:n,targetNodes:s,selectedCapabilities:r,previewResults:a=[],embedded:i=!1,onClose:l,onPreviewTargetsChange:c,onShare:d}){const[m,x]=o.useState(()=>new Set(a.length>0?a.map(j=>xt(j.nodeId,j.targetAgent)):Np(n.id,s,r))),[u,h]=o.useState(()=>Object.fromEntries(kp(n.id,s,r))),[f,w]=o.useState({}),[g,k]=o.useState(!1),[v,S]=o.useState(()=>new Set),[y,p]=o.useState(()=>new Set),b=r.some(j=>j.kind==="plugin"),N=o.useMemo(()=>Mr(r).map(j=>({key:xt(n.id,j),nodeId:n.id,node:n,label:`Install into ${yn[j]}`,agentLabel:yn[j],defaultScope:Di(r),disabled:!1,targetAgent:j})),[r,n]),A=o.useMemo(()=>s.flatMap(j=>{const W={kind:"global"},T=j.status==="offline",ee=Mi(r);return ee.length===0?[{key:xt(j.id),nodeId:j.id,node:j,label:j.name,defaultScope:W,disabled:T}]:ee.map(R=>({key:xt(j.id,R),nodeId:j.id,node:j,label:`${j.name} / ${yn[R]}`,agentLabel:yn[R],defaultScope:W,disabled:T,targetAgent:R}))}),[r,s]),I=o.useMemo(()=>[...N,...A],[N,A]),E=o.useMemo(()=>s.map(j=>({node:j,options:A.filter(W=>W.nodeId===j.id)})).filter(j=>j.options.length>0),[s,A]),L=o.useMemo(()=>new Map(a.filter(j=>j.capabilityId).map(j=>[ao(j.nodeId,j.capabilityId,j.targetAgent),j])),[a]),M=o.useMemo(()=>new Map(a.map(j=>[xt(j.nodeId,j.targetAgent),j])),[a]),D=o.useMemo(()=>I.filter(j=>m.has(j.key)),[m,I]),P=o.useMemo(()=>D.map(j=>({nodeId:j.nodeId,scope:u[j.key]??j.defaultScope,...j.targetAgent?{targetAgent:j.targetAgent}:{}})),[D,u]),B=o.useMemo(()=>{const j=[],W=new Map;for(const T of D){if(!W.has(T.nodeId)){const ee=T.nodeId===n.id?n:s.find(R=>R.id===T.nodeId);W.set(T.nodeId,{nodeId:T.nodeId,node:ee,name:ee?.name??T.nodeId,options:[]}),j.push(T.nodeId)}W.get(T.nodeId).options.push(T)}return j.map(T=>W.get(T))},[D,n,s]),Q=o.useMemo(()=>{const j=Array.from(new Set(r.map(T=>T.agent))),[W]=j;if(W)return j.length===1?yn[W]:`${j.length} agents`},[r]),te=E.length+1;o.useEffect(()=>{let j=!1;const W={...u};for(const T of I)W[T.key]||(W[T.key]=T.defaultScope,j=!0);j&&h(W)},[I,u]),o.useEffect(()=>{t&&c?.(P)},[t,c,P]),o.useEffect(()=>{t&&(S(new Set),p(new Set))},[t,n.id]),o.useEffect(()=>{if(!i||!t)return;const j=W=>{W.key==="Escape"&&l()};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[i,l,t]);const Y=j=>{w(Object.fromEntries(D.map(W=>[W.key,j])))},H=async()=>{k(!0);try{await d(D.map(j=>({nodeId:j.nodeId,scope:u[j.key]??j.defaultScope,...j.targetAgent?{targetAgent:j.targetAgent}:{},conflictStrategy:f[j.key]??"overwrite"})))}finally{k(!1)}},ne=j=>{const W=u[j.key]??j.defaultScope,T=`capability-share-target-${jp(j.key)}`,ee=m.has(j.key);return e.jsxs("div",{"data-target-agent":j.targetAgent,className:"flex min-h-6 items-center gap-2 px-2 py-0.5 transition-colors hover:bg-muted/35 data-[disabled=true]:opacity-55","data-disabled":j.disabled?"true":void 0,children:[e.jsx(Sn,{id:T,disabled:j.disabled,checked:ee,onCheckedChange:R=>x(V=>{const O=new Set(V);return R===!0?O.add(j.key):O.delete(j.key),O}),"aria-label":`Select ${j.label} as a share target`,"data-share-target-checkbox":!0,className:"h-3.5 w-3.5 border-border/70 bg-background/80 shadow-none data-[state=checked]:border-primary data-[state=checked]:bg-primary [&_svg]:h-3 [&_svg]:w-3"}),e.jsx("label",{htmlFor:T,className:"min-w-0 flex-1 cursor-pointer truncate text-[10px] font-medium leading-4 text-foreground data-[disabled=true]:cursor-not-allowed","data-disabled":j.disabled?"true":void 0,children:j.agentLabel??j.label}),e.jsx("div",{className:"flex w-28 shrink-0 justify-end",children:ee&&!j.disabled&&e.jsx(Ci,{node:j.node,projectPaths:Er(j.node),selectedScope:W,onSelect:R=>h(V=>({...V,[j.key]:R})),compact:!0,portal:!0,portalAlign:"end"})})]},j.key)},$=(j,W,T,ee)=>{const R=v.has(j.id),V=D.filter(O=>O.nodeId===j.id).length;return e.jsxs("div",{className:"overflow-hidden rounded-sm border border-border/45 bg-muted/15",children:[e.jsxs("button",{type:"button","aria-expanded":R,onClick:()=>S(O=>oo(O,j.id)),className:"flex w-full items-center gap-2 border-b border-border/35 bg-primary/5 px-2 py-1.5 text-left transition-colors hover:bg-primary/10",children:[e.jsx(dt,{className:F("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",R&&"rotate-90")}),e.jsx("span",{className:F("h-1.5 w-1.5 shrink-0 rounded-full",jn(j.status))}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold text-foreground",title:j.name,children:j.name}),V>0&&e.jsxs("span",{className:"shrink-0 text-[8px] font-medium text-primary",children:[V," selected"]}),e.jsx("span",{className:"shrink-0 text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:W?"this node":"remote"}),j.status==="offline"&&e.jsx(Ze,{variant:"outline",className:"rounded-sm px-1 py-0 text-[8px]",children:"offline"}),ee>0&&e.jsxs("span",{className:"sr-only",children:[ee," agents"]})]}),e.jsx("div",{className:F("grid transition-[grid-template-rows] duration-200 ease-out",R?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:e.jsx("div",{className:"min-h-0 overflow-hidden",children:e.jsx("div",{className:"divide-y divide-border/25",children:T})})})]},j.id)},X=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-b border-border/55 px-4 py-3 text-left",children:[e.jsxs("h2",{id:"capability-share-title",className:"flex items-center gap-2 text-sm font-semibold leading-none tracking-tight",children:[e.jsx(Kn,{className:"h-4 w-4 text-primary"}),"Share ",r.length," ",r.length===1?"capability":"capabilities"]}),e.jsx("p",{id:"capability-share-description",className:"mt-1.5 text-[11px] text-muted-foreground",children:"Copies each capability into the matching agent on the selected targets. Plugins install into their matching agent."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2.5 gap-y-1 border-b border-border/55 bg-muted/15 px-4 py-2 text-[11px]",children:[e.jsx("span",{className:"text-[8px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Source"}),e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:F("h-1.5 w-1.5 shrink-0 rounded-full",jn(n.status))}),e.jsx("span",{className:"truncate font-semibold text-foreground",title:n.name,children:n.name}),Q&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:["· ",Q]})]}),e.jsx(Kr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70"}),e.jsx("span",{className:"text-[8px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Targets"}),e.jsxs("span",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-semibold text-foreground",children:D.length})," selected · ",te," ",te===1?"node":"nodes"]})]}),e.jsxs("div",{className:"grid gap-4 p-4 lg:grid-cols-[17rem_minmax(0,1fr)]",children:[e.jsx("section",{className:"min-w-0",children:e.jsxs("div",{className:"max-h-[56vh] space-y-2 overflow-y-auto pr-0.5",children:[$(n,!0,b?e.jsx("div",{className:"px-2 py-2 text-[10px] text-muted-foreground",children:"Cross-agent plugin installs are not supported."}):N.length===0?e.jsx("div",{className:"px-2 py-2 text-[10px] text-muted-foreground",children:"No alternate agents available for this selection."}):N.map(ne),N.length),E.map(j=>$(j.node,!1,j.options.map(ne),j.options.length))]})}),e.jsxs("section",{className:"min-w-0",children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[8px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Conflict preview"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[8px] uppercase tracking-[0.12em] text-muted-foreground/70",children:"Set all"}),e.jsx("div",{className:"inline-flex items-center rounded-sm border border-border/55 bg-muted/20 p-px",children:["overwrite","skip","abort"].map(j=>e.jsx("button",{type:"button",onClick:()=>Y(j),className:"h-5 rounded-[3px] px-1.5 text-[9px] capitalize text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground",children:j},j))})]})]}),e.jsx("div",{className:"max-h-[56vh] min-h-32 overflow-y-auto rounded-sm border border-border/55 bg-background/45 p-2",children:D.length===0?e.jsx("div",{className:"py-8 text-center text-[11px] text-muted-foreground",children:"Select a target to preview conflicts."}):B.map(j=>{const W=!y.has(j.nodeId);return e.jsxs("div",{className:"mb-1.5 overflow-hidden rounded-sm border border-border/35 bg-muted/10 last:mb-0",children:[e.jsxs("button",{type:"button","aria-expanded":W,onClick:()=>p(T=>oo(T,j.nodeId)),className:"flex w-full items-center gap-1.5 border-b border-border/30 bg-primary/5 px-2 py-1 text-left transition-colors hover:bg-primary/10",children:[e.jsx(dt,{className:F("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",W&&"rotate-90")}),j.node&&e.jsx("span",{className:F("h-1.5 w-1.5 shrink-0 rounded-full",jn(j.node.status))}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[10px] font-semibold text-foreground",children:j.name}),e.jsxs("span",{className:"shrink-0 text-[8px] text-muted-foreground",children:[j.options.length," ",j.options.length===1?"agent":"agents"]})]}),e.jsx("div",{className:F("grid transition-[grid-template-rows] duration-200 ease-out",W?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:e.jsx("div",{className:"min-h-0 overflow-hidden",children:e.jsx("div",{className:"space-y-1 p-1.5",children:j.options.map(T=>{const ee=f[T.key]??"overwrite";return e.jsxs("div",{className:"rounded-sm bg-background/45 px-2 py-1",children:[e.jsxs("div",{className:"mb-0.5 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-[9px] font-medium leading-4 text-foreground",children:T.agentLabel??"Matching agent"}),e.jsxs(ze,{value:ee,onValueChange:R=>w(V=>({...V,[T.key]:R})),children:[e.jsx(Ue,{className:wp,children:e.jsx(Qe,{})}),e.jsxs($e,{className:"shadow-none",children:[e.jsx(Le,{value:"overwrite",className:$s,children:"Overwrite"}),e.jsx(Le,{value:"skip",className:$s,children:"Skip"}),e.jsx(Le,{value:"abort",className:$s,children:"Abort"})]})]})]}),e.jsx("div",{className:"space-y-px",children:r.map(R=>{const V=L.get(ao(T.nodeId,R.id,T.targetAgent))??(r.length===1?M.get(T.key):void 0);return e.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] leading-4",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:R.name}),e.jsx("span",{className:V?.conflict?"text-amber-500":V?"text-emerald-500":"text-muted-foreground",children:V?V.conflict?`exists${V.currentVersion?` v${V.currentVersion}`:""}`:"new install":"checking"}),V?.sourceVersion&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:[e.jsx(Kr,{className:"inline h-2.5 w-2.5"})," v",V.sourceVersion]})]},R.id)})})]},T.key)})})})})]},j.nodeId)})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-border/55 px-4 py-3",children:[e.jsx(Z,{variant:"ghost",onClick:l,className:"h-7 rounded-sm px-3 text-[11px]",children:"Cancel"}),e.jsxs(Z,{onClick:H,disabled:g||D.length===0,className:"h-7 rounded-sm px-3 text-[11px]",children:[g?e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Kn,{className:"h-3.5 w-3.5"}),"Share"]})]})]});return i?t?e.jsx("div",{className:"absolute inset-0 z-[80] flex items-center justify-center bg-background/70 p-4 backdrop-blur-[2px]",onMouseDown:j=>{j.target===j.currentTarget&&l()},children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"capability-share-title","aria-describedby":"capability-share-description","data-capability-share-dialog":"true",className:"relative grid w-full max-w-3xl gap-0 overflow-visible rounded-xl border-0 bg-background text-foreground shadow-[0_34px_110px_-54px_rgba(0,0,0,0.55)]",onMouseDown:j=>j.stopPropagation(),children:[X,e.jsxs("button",{type:"button",onClick:l,className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[e.jsx(ct,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})}):null:e.jsx(ut,{open:t,onOpenChange:j=>{j||l()},children:e.jsx(mt,{"aria-labelledby":"capability-share-title","aria-describedby":"capability-share-description","data-capability-share-dialog":"true",className:"max-w-3xl gap-0 overflow-visible rounded-xl border-0 p-0",children:X})})}function xt(t,n){return n?`agent:${t}:${n}`:`node:${t}`}function jp(t){return t.replace(/[^a-zA-Z0-9_-]/g,"-")}function ao(t,n,s){return`${xt(t,s)}\0${n}`}function oo(t,n){const s=new Set(t);return s.has(n)?s.delete(n):s.add(n),s}function Np(t,n,s){const r=n.find(i=>i.status!=="offline");if(r)return[xt(r.id,Sp(s))];const a=Mr(s)[0];return a?[xt(t,a)]:[]}function kp(t,n,s){const r=Mi(s);return[...n.flatMap(a=>r.length===0?[[xt(a.id),{kind:"global"}]]:r.map(i=>[xt(a.id,i),{kind:"global"}])),...Mr(s).map(a=>[xt(t,a),Di(s)])]}function Mi(t){return t.length===0||t.some(n=>n.kind==="plugin")?[]:Ei}function Sp(t){if(!(t.length===0||t.some(n=>n.kind==="plugin")))return t[0]?.agent}function Mr(t){if(t.length===0||t.some(s=>s.kind==="plugin"))return[];const n=new Set(t.map(s=>s.agent));return Ei.filter(s=>!n.has(s))}function Di(t){return t[0]?.scope??{kind:"global"}}const io="h-7 rounded-sm border-0 bg-muted/55 px-2 text-[9px] leading-none shadow-none hover:bg-muted/70 [&>svg]:h-3 [&>svg]:w-3",It="py-0.5 pl-6 pr-1.5 text-[9px] leading-4 [&_svg]:h-3 [&_svg]:w-3",_i="h-5 rounded-sm bg-muted/55 px-1.5 text-[9px] font-medium text-foreground shadow-none border-0 hover:bg-muted/75 hover:text-foreground disabled:text-muted-foreground [&_svg]:size-2.5",Cp="h-5 rounded-sm bg-primary px-2 text-[9px] font-medium text-primary-foreground shadow-none border-0 hover:bg-primary/90 hover:text-primary-foreground disabled:bg-primary/45 disabled:text-primary-foreground/80 [&_svg]:size-2.5";function Tp(t,n,s,r){return s.map(a=>({sourceNodeId:t,capabilityId:a.id,sourceScope:n,targets:r.map(i=>({nodeId:i.nodeId,scope:i.scope,...i.targetAgent?{targetAgent:i.targetAgent}:{}}))}))}function Ap(t,n,s,r){return s.map(a=>({sourceNodeId:t,capabilityId:a.id,sourceScope:n,targets:r}))}function Ep({loading:t,onRefresh:n}){return e.jsxs(Z,{variant:"ghost",onClick:n,disabled:t,"aria-busy":t,className:F(_i,"min-w-[4.5rem]"),children:[e.jsx(Oo,{className:F("h-2.5 w-2.5",t&&"animate-spin")}),t?"Refreshing":"Refresh"]})}function Mp({selectedCount:t,loading:n,onClearSelection:s,onRefresh:r,onShare:a}){return e.jsxs("div",{className:"flex items-center justify-between gap-2 bg-card/15 px-0.5 pt-1.5 text-[9px] text-muted-foreground",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(Z,{type:"button",variant:"ghost",onClick:s,disabled:t===0,className:_i,children:[e.jsx(ct,{className:"h-2.5 w-2.5"}),"Selected: ",t," / Clear"]})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ep,{loading:n,onRefresh:r}),e.jsxs(Z,{type:"button",variant:"ghost",onClick:a,disabled:t===0,className:Cp,children:[e.jsx(Kn,{className:"h-2.5 w-2.5"}),"Share"]})]})]})}function Dp({onBeginResize:t,onFold:n}){const s=r=>{r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),n())};return e.jsx("div",{role:"separator","aria-label":"Fold capability detail panel","aria-orientation":"vertical",title:"Fold details",tabIndex:0,onClick:n,onKeyDown:s,onPointerDown:t,className:"hidden w-1 shrink-0 cursor-col-resize items-center justify-center bg-primary/10 transition-colors hover:bg-primary/22 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70 lg:flex",children:e.jsx("span",{className:"h-8 w-px rounded-full bg-primary/45"})})}function _p({visible:t}){return t?e.jsx("div",{className:"absolute inset-2.5 z-10 flex items-center justify-center rounded-sm border border-border/60 bg-background/85 shadow-sm backdrop-blur-sm",children:e.jsxs("div",{className:"flex w-full max-w-80 flex-col items-center gap-3 px-5 text-center",children:[e.jsxs("div",{className:"relative flex h-10 w-10 items-center justify-center rounded-full border border-primary/25 bg-primary/8",children:[e.jsx("span",{className:"absolute inset-0 rounded-full border border-primary/20 animate-ping"}),e.jsx(he,{className:"relative h-4 w-4 animate-spin text-primary"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:"Loading capabilities"}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Reading agent skills, plugins, and MCP servers for this selection."})]}),e.jsxs("div",{className:"grid w-full gap-1.5","aria-hidden":"true",children:[e.jsx("span",{className:"h-1.5 rounded-full bg-muted animate-pulse"}),e.jsx("span",{className:"mx-auto h-1.5 w-3/4 rounded-full bg-muted/70 animate-pulse"})]})]})}):null}function Pp({open:t,node:n,scope:s,clusterNodes:r,onOpenChange:a,onSelectionChange:i}){const[l,c]=o.useState([]),[d,m]=o.useState([]),[x,u]=o.useState(!1),[h,f]=o.useState(""),[w,g]=o.useState("all"),[k,v]=o.useState("all"),[S,y]=o.useState(new Set),[p,b]=o.useState(null),[N,A]=o.useState(null),[I,E]=o.useState(!1),[L,M]=o.useState(null),[D,P]=o.useState(!1),[B,Q]=o.useState([]),[te,Y]=o.useState(Si),[H,ne]=o.useState(null),$=o.useMemo(()=>Xf(l,{search:h,agent:w,kind:k}),[w,l,k,h]),X=o.useMemo(()=>l.filter(K=>S.has(K.id)),[l,S]),j=o.useMemo(()=>r.filter(K=>K.id!==n.id),[r,n.id]),W=s.kind==="project"?s.projectPath:"global",T=async()=>{u(!0);try{const K=await uc(n.id,{scope:s});c(K.items),m((K.errors??[]).map(_=>`${_.agent}: ${_.message}`))}catch(K){m([K instanceof Error?K.message:"Failed to load capabilities"])}finally{u(!1)}};o.useEffect(()=>{t&&(y(new Set),b(null),A(null),E(!1),Q([]),c([]),m([]),T())},[t,n.id,s.kind,W]),o.useEffect(()=>{if(!H)return;const K=se=>{Y(sp(H.startWidth,H.startClientX,se.clientX,window.innerWidth))},_=()=>ne(null);return window.addEventListener("pointermove",K),window.addEventListener("pointerup",_),()=>{window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",_)}},[H]);const ee=K=>{K.preventDefault(),ne({startClientX:K.clientX,startWidth:te})},R=()=>{ne(null),E(!1),b(null),A(null)},V=()=>{y(new Set),Q([])},O=async K=>{b(K.id),E(!0),A(null);const _=await mc(n.id,K.id,s);A(_.detail)},le=o.useCallback(async K=>{if(X.length===0||K.length===0){Q([]);return}Q([]);try{const _=Tp(n.id,s,X,K),se=await Promise.all(_.map(q=>dc(q)));Q(se.flatMap((q,ae)=>q.results.map(ye=>({...ye,capabilityId:_[ae]?.capabilityId}))))}catch{Q([])}},[n.id,s,X]),ie=()=>{Q([]),P(!0)},ue=async K=>{const _=Ap(n.id,s,X,K);_.length!==0&&(await Promise.all(_.map(se=>fc(se))),ce.success(`${_.length} capability share request${_.length===1?"":"s"} completed`),P(!1))},J=async()=>{if(!(!N||L)){M(N.id);try{const K=await hc(n.id,N.id,s);K.status==="deleted"?(ce.success(`Deleted ${N.name}`),c(_=>_.filter(se=>se.id!==N.id)),y(_=>{const se=new Set(_);return se.delete(N.id),se}),b(null),A(null),E(!1),await T()):(ce.info(K.message??"Capability was not found"),b(null),A(null),E(!1),await T())}catch(K){ce.error(K instanceof Error?K.message:"Failed to delete capability")}finally{M(null)}}};return e.jsx(e.Fragment,{children:e.jsx(ut,{open:t,onOpenChange:a,children:e.jsxs(mt,{className:"dashboard-panel animate-panel-settle flex h-[min(62vh,33rem)] w-[min(94vw,72rem)] max-w-[min(94vw,72rem)] flex-col gap-0 overflow-hidden rounded-xl p-0",children:[e.jsxs(Tt,{className:"border-b border-border/55 bg-card/28 px-4 py-2.5 text-left",children:[e.jsx(gt,{className:"sr-only",children:"Capabilities"}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-x-4 gap-y-1 pr-10",children:[e.jsx(pp,{node:n,scope:s,clusterNodes:r,onSelectionChange:i}),e.jsxs(At,{"data-capability-selection-help":"true",className:"ml-auto max-w-[min(32rem,38vw)] space-y-0.5 pt-0.5 text-right text-[9px] leading-[11px] text-muted-foreground",children:[e.jsx("span",{className:"block truncate whitespace-nowrap",children:"Sharing copies into selected agents on target nodes."}),s.kind==="project"&&e.jsx("span",{"data-capability-selection-path":"true",className:"block truncate font-mono text-[7px] leading-[10px] text-muted-foreground/80",title:s.projectPath,children:s.projectPath})]})]})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[e.jsxs("main",{className:"relative flex min-w-0 flex-1 flex-col gap-2 bg-gradient-to-b from-primary/4 via-background/20 to-background/40 p-2.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative min-w-44 flex-1",children:[e.jsx(ho,{className:"pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-muted-foreground"}),e.jsx(lt,{value:h,onChange:K=>f(K.target.value),placeholder:"Search capabilities",className:"h-7 rounded-sm border-0 bg-muted/55 pl-6 text-[10px] shadow-none"})]}),e.jsxs(ze,{value:w,onValueChange:K=>g(K),children:[e.jsx(Ue,{className:F("w-28",io),children:e.jsx(Qe,{})}),e.jsxs($e,{className:"shadow-none",children:[e.jsx(Le,{value:"all",className:It,children:"Agent: All"}),e.jsx(Le,{value:"claudecode",className:It,children:"Claude Code"}),e.jsx(Le,{value:"codex",className:It,children:"Codex"}),e.jsx(Le,{value:"copilot",className:It,children:"Copilot"})]})]}),e.jsxs(ze,{value:k,onValueChange:K=>v(K),children:[e.jsx(Ue,{className:F("w-24",io),children:e.jsx(Qe,{})}),e.jsxs($e,{className:"shadow-none",children:[e.jsx(Le,{value:"all",className:It,children:"Kind: All"}),e.jsx(Le,{value:"skill",className:It,children:"Skill"}),e.jsx(Le,{value:"plugin",className:It,children:"Plugin"}),e.jsx(Le,{value:"mcp",className:It,children:"MCP"})]})]})]}),d.length>0&&e.jsx("div",{className:"rounded-sm bg-amber-500/10 px-2 py-1 text-[10px] text-amber-600",children:d.join(" · ")}),e.jsx(ep,{items:$,selectedIds:S,activeId:p,onToggleSelected:(K,_)=>y(se=>{const q=new Set(se);return _?q.add(K):q.delete(K),q}),onOpenDetail:O}),e.jsx(Mp,{selectedCount:S.size,loading:x,onClearSelection:V,onRefresh:T,onShare:ie}),e.jsx(_p,{visible:x&&l.length===0})]}),I&&e.jsxs(e.Fragment,{children:[e.jsx(Dp,{onBeginResize:ee,onFold:R}),e.jsx(rp,{detail:N,deleting:L===N?.id,desktopWidth:te,onDelete:N?J:void 0,pending:!N})]})]}),D&&e.jsx(yp,{open:D,sourceNode:n,targetNodes:j,selectedCapabilities:X,previewResults:B,embedded:!0,onClose:()=>P(!1),onPreviewTargetsChange:le,onShare:ue})]})})})}function Ip(t){const[n,s]=o.useState(null),r=o.useMemo(()=>n?t?.nodes.find(d=>d.id===n.nodeId)??(t?.self.id===n.nodeId?t.self:null)??null:null,[t,n]),a=o.useCallback(d=>{s({nodeId:d,scope:{kind:"global"}})},[]),i=o.useCallback((d,m)=>{s({nodeId:d,scope:{kind:"project",projectPath:m}})},[]),l=o.useCallback(d=>{s(d)},[]);return{capabilitiesDialog:n&&r&&t?e.jsx(Pp,{open:!0,node:r,scope:n.scope,clusterNodes:t.nodes,onOpenChange:d=>{d||s(null)},onSelectionChange:l}):null,openNodeCapabilities:a,openProjectCapabilities:i}}function Rp({activeTaskId:t,fetchTasks:n,navigateToNextVisibleTask:s,removeTasksFromList:r,setTask:a,setTasks:i}){const l=o.useCallback(u=>{i(h=>br(h,u)),a(h=>h?.id===u.id?{...h,...u}:h)},[a,i]),c=o.useCallback(async(u,h)=>{try{const f=await Ur(u.id,{title:h});l(f),ce.success("Task title updated"),n()}catch(f){ce.error(f instanceof Error?f.message:"Failed to update task title")}},[n,l]),d=o.useCallback(async(u,h)=>{try{const f=await Ur(u.id,{pinnedOnTop:h});l(f),ce.success(h?"Task pinned":"Task unpinned"),n()}catch(f){ce.error(f instanceof Error?f.message:"Failed to update task pin")}},[n,l]),m=o.useCallback(async u=>{try{const h=await pc(u.id);l(h),t===u.id&&s([u.id]),ce.success("Task archived"),n()}catch(h){ce.error(h instanceof Error?h.message:"Failed to archive task")}},[t,n,s,l]),x=o.useCallback(async u=>{try{await xc(u.id),r([u.id]),t===u.id&&s([u.id],!0),ce.success("Task deleted"),n()}catch(h){ce.error(h instanceof Error?h.message:"Failed to delete task")}},[t,n,s,r]);return{handleArchiveTask:m,handleDeleteTask:x,handleToggleTaskPinned:d,handleUpdateTaskTitle:c}}function Lp(){const{id:t}=gc(),n=bc(),s=vc(),r=wc(),{cluster:a,systemInfo:i,events:l,sseConnected:c,subscribe:d,refresh:m,loading:x,error:u}=yc(),h=o.useMemo(()=>jc(n.state),[n.state]),[f,w]=o.useState(null),[g,k]=o.useState("active"),[v,S]=o.useState("all"),[y,p]=o.useState("all"),[b,N]=o.useState("all"),A=r?.headerSearchQuery??"",I=o.useDeferredValue(A),{desktopTasksOpen:E,mobileTasksPanelOpen:L,mobileTasksPanelRef:M,operationsOpen:D,operationsPanelRef:P,panelResize:B,setMobileTasksPanelOpen:Q,setOperationsOpen:te,toggleTasksPanel:Y}=xf(),[H,ne]=o.useState(()=>!!h?.draftNewTask),[$,X]=o.useState(()=>h?.createMode??"chat"),[j,W]=o.useState(()=>h?.createDefaults??null),[T,ee]=o.useState(()=>h?.draftNewTask?{route:h.returnRoute??"/",taskId:h.returnTaskId??null}:null),[R,V]=o.useState(!1),[O,le]=o.useState("transcript"),[ie,ue]=o.useState("overview"),[J,K]=o.useState("all"),[_,se]=o.useState(!1),[q,ae]=o.useState(null),[ye,pe]=o.useState([]),[Ye,Te]=o.useState([]),[ht,Ie]=o.useState(!1),[Me,qe]=o.useState(!1),[He,je]=o.useState(null),[Re,G]=o.useState(new Set),[ge,be]=o.useState(!1),[Xe,De]=o.useState(!1),[nt,re]=o.useState(null),Ne=o.useRef(null),Ce=o.useRef(new Map),ve=a?.self?.role==="leader",st=a?.self?.id,{quickChats:_e}=Nc();Df({cluster:a,subscribe:d});const{nodeSettingsDialog:Et,openNodeSettings:ft}=Qf(ve),{capabilitiesDialog:un,openNodeCapabilities:Jt,openProjectCapabilities:Nt}=Ip(a),{devBoxDialog:bt,devBoxNodeIds:mn,devBoxStartNodeId:hn,devBoxStartNodeIds:Mt,devBoxStartingNodeIds:Rt,openDevBox:Zt,startDevBox:kt}=Wf({cluster:a,refresh:m}),{completedGroups:Xt=[],fetchTasks:Be,loadCompletedTasksPage:rt,removeTasksFromList:vt,setTasks:St,tasks:U,tasksError:Oe,tasksLoading:Pe}=Tf({isLeader:ve,selfId:st,sseConnected:c,preservedTask:q,subscribe:d});o.useEffect(()=>kc(()=>{ue("events"),te(!0)}),[te]);const Ke=o.useMemo(()=>[...U].sort((C,z)=>z.updatedAt-C.updatedAt),[U]),Ge=o.useMemo(()=>[...U].sort((C,z)=>z.createdAt-C.createdAt||z.updatedAt-C.updatedAt)[0]?.id??null,[U]),en=o.useMemo(()=>{const C=new Map;for(const z of a?.nodes??[]){const oe=su(Ke,z.id);oe>0&&C.set(z.id,oe)}return C},[a?.nodes,Ke]),xe=o.useMemo(()=>Ke.filter(C=>!Sc(C,a?.nodes,a?.self)||!Cc(C,g)||v!=="all"&&C.agent!==v||!Tc(C,b)||y==="unassigned"&&C.assignedTo||y!=="all"&&y!=="unassigned"&&Ac(C.assignedTo,a?.nodes,C.assignedNodeName)!==y?!1:I.trim()?Ec(C,I):!0),[Ke,a?.nodes,a?.self,g,v,b,y,I]);o.useEffect(()=>{G(C=>{const z=cu(C,xe.map(oe=>oe.id));return z.size===C.size?C:z})},[xe]),o.useEffect(()=>{ve||G(new Set)},[ve]);const me=o.useMemo(()=>["all",...Array.from(new Set(Ke.map(C=>C.agent))).sort()],[Ke]),ke=o.useMemo(()=>{const z=Array.from(new Set(Ke.map(oe=>oe.assignedTo).filter(oe=>!!oe))).map(oe=>{const Ee=Ke.find(we=>we.assignedTo===oe);return a?.nodes.find(we=>we.id===oe)??{id:oe,name:Hs(oe,a?.nodes,Ee?.assignedNodeName)}}).sort((oe,Ee)=>oe.name.localeCompare(Ee.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...z.map(oe=>({value:oe.name.toLowerCase(),label:oe.name}))]},[Ke,a?.nodes]),Ve=o.useMemo(()=>{const C=new Map;for(const z of a?.nodes??[])C.set(z.id,z.name);for(const z of Ke)z.assignedTo&&z.assignedNodeName&&!C.has(z.assignedTo)&&C.set(z.assignedTo,z.assignedNodeName);return C},[a?.nodes,Ke]),Fe=o.useMemo(()=>{const C=new Map;for(const z of a?.nodes??[])z.workDir&&C.set(z.id,z.workDir);return a?.self?.workDir&&C.set(a.self.id,a.self.workDir),C},[a]),Lt=o.useMemo(()=>{const C=new Map;for(const z of a?.nodes??[])C.set(z.id,z.status);return a?.self&&C.set(a.self.id,a.self.status),C},[a]),Xn=o.useMemo(()=>{const C=new Map;for(const z of a?.nodes??[])C.set(z.id,z);return a?.self&&C.set(a.self.id,a.self),C},[a]),fn=o.useMemo(()=>new Map(Xt.map(C=>[rr(C),C])),[Xt]),Ae=o.useMemo(()=>{const C=new Map;for(const z of a?.nodes??[])z.status!=="offline"&&C.set(z.id,z);return a?.self&&a.self.status!=="offline"&&C.set(a.self.id,a.self),Array.from(C.values())},[a]),tn=a?.self?.id??Ae[0]?.id??null,Dt=o.useMemo(()=>l.filter(Mc),[l]),pn=o.useMemo(()=>["all",...Array.from(new Set(Dt.map(C=>C.type))).sort()],[Dt]),es=o.useMemo(()=>J==="all"?Dt:Dt.filter(C=>C.type===J),[Dt,J]),ts=xe.length>0&&xe.every(C=>Re.has(C.id)),at=xe.some(C=>Re.has(C.id)),Pi=du(xe,Re);o.useEffect(()=>{h?.draftNewTask&&(ne(!0),X(h.createMode??"chat"),W(h.createDefaults??null),ee({route:h.returnRoute??"/",taskId:h.returnTaskId??null}))},[h]),o.useEffect(()=>{J!=="all"&&!pn.includes(J)&&K("all")},[J,pn]),o.useEffect(()=>{Qr(t,H)&&!f&&Ge&&w(Ge)},[t,H,f,Ge]),o.useEffect(()=>{Qr(t,H)&&(f&&U.some(C=>C.id===f)||w(Ge))},[t,H,f,Ge,U]);const Se=au({routeTaskId:t,creatingTask:H,internalSelectedTaskId:f,sortedTaskIds:Ge?[Ge]:[]}),nn=o.useMemo(()=>U.find(C=>C.id===Se)??null,[U,Se]);o.useEffect(()=>{Ne.current=Se??null},[Se]);const _t=o.useCallback(()=>{ae(null),pe([]),Te([]),je(null),qe(!1)},[]),xn=o.useCallback((C,z,oe=!0)=>{Ce.current.set(C,{logs:Tr(z),loaded:oe})},[]),pt=o.useCallback(async()=>{const C=Se;if(C)try{const z=await Dc(C);if(Ne.current!==C)return;ae(z),St(oe=>br(oe,z)),je(null)}catch(z){if(Ne.current!==C)return;_t(),je(z instanceof Error?z.message:"Failed to load task")}finally{Ne.current===C&&Ie(!1)}},[Se,_t,St]),ns=o.useCallback(async(C={})=>{const z=Se;if(z)try{const oe=await Gs(z,C.after,{minTotal:C.minTotal});if(Ne.current!==z)return;pe(Ee=>{const we=Mo(Ee,oe.logs);return xn(z,we),we}),Te(Ee=>Qs(Ee,oe.logs))}catch{}finally{Ne.current===z&&qe(!1)}},[Se,xn]);o.useEffect(()=>{if(!Se){_t(),Ie(!1);return}le("transcript"),ae(nn);const C=Af(Se,Ce.current);pe(C.logs),Te([]),je(null),Ie(!0),qe(C.transcriptLoading),pt(),ns()},[Se,_t,ns,pt]),o.useEffect(()=>{if(!ou({activeTaskId:Se,routeTaskId:t,creatingTask:H,tasksLoading:Pe,loadedTaskIds:U.map(z=>z.id)}))return;const C=Ge;w(C),_t(),o.startTransition(()=>{s(C?`/tasks/${C}`:"/",{state:null})})},[Se,_t,H,Ge,s,t,U,Pe]),o.useEffect(()=>{nn&&ae(C=>!C||C.id!==nn.id?C:{...C,...nn})},[nn]),Pf({activeTaskId:Se,cacheTranscript:xn,fetchActiveLogs:ns,fetchActiveTask:pt,logs:ye,setLogs:pe,setPendingMessages:Te,setTranscriptLoading:qe,sseConnected:c,subscribe:d});const de=q??nn,Ii=de?.assignedTo?a?.nodes.find(C=>C.id===de.assignedTo)??null:null,gn=r?.setHeaderTaskContext;o.useEffect(()=>{if(!gn)return;if(!de){gn(null);return}const C=de.effectiveProjectPath??de.project??"default workspace";return gn({taskId:de.id,taskTitle:de.title,nodeName:Hs(de.assignedTo,a?.nodes,de.assignedNodeName),projectLabel:yo(C),projectPath:C}),()=>gn(null)},[de,a?.nodes,gn]);const ss=Ye.length>0,Ri=de?_c.has(de.agent):!1,Dn=de?.status==="running",Li=de?$n.has(de.status):!1,Bi=de?$n.has(de.status)||Pc.has(de.status):!1,Oi=!!(de&&ve&&de.status==="failed"),rs=o.useMemo(()=>Zh(de,a,ss,!!Dn),[de,a,ss,Dn]),as=o.useMemo(()=>Zc([...ye,...Ye.map(C=>us(C.content,C.timestamp))]),[ye,Ye]),_n=o.useMemo(()=>{if(!de||de.conversationKind==="nativeSession")return null;const C=Xc(de);if(C.length>0)return us(C,new Date(de.createdAt).toISOString());if(as.length>0)return null;const z=ed(de.description||de.title);return z.length>0?us(z,new Date(de.createdAt).toISOString()):null},[de,as]),os=o.useMemo(()=>_n?fr(_n):null,[_n]),Fi=o.useMemo(()=>os?td(ye,os):!1,[ye,os]),is=o.useCallback((C="chat",z)=>{const oe={route:t?`/tasks/${t}`:"/",taskId:Se};ee(oe),X(C),W(z??null),ne(!0),o.startTransition(()=>{s("/",{state:{draftNewTask:!0,returnRoute:oe.route,returnTaskId:oe.taskId,createMode:C,createDefaults:z}})})},[t,Se,s]),zi=o.useCallback(()=>{const C=T?.taskId??Ge;ne(!1),ee(null),W(null),w(C),o.startTransition(()=>{s(T?.route??"/",{state:null})})},[T,Ge,s]),Dr=o.useCallback(C=>{ne(!1),ee(null),W(null),w(C),o.startTransition(()=>{s(`/tasks/${C}`,{state:null})})},[s]),Ui=o.useCallback(C=>{Ne.current=C.id,ne(!1),ee(null),W(null),St(z=>iu(z,C)),ae(C),pe([]),Te([]),je(null),Ie(!1),qe(C.conversationKind==="nativeSession"),le("transcript"),w(C.id),Rf({task:C,getActiveTaskId:()=>Ne.current,setLogs:pe,setPendingMessages:Te,setTranscriptLoading:qe}),Be(),o.startTransition(()=>{s(`/tasks/${C.id}`,{state:null})})},[Be,s]),{cancelQueuedMessage:$i,queueFollowUpMessage:Pn}=Jf({activeTaskId:Se,fetchActiveTask:pt,isRunning:Dn,setPendingMessages:Te,setTask:ae,setTasks:St}),qi=o.useCallback((C,z)=>{Pn(C,z)},[Pn]),Hi=o.useCallback(async()=>{const C=Se;if(!(!C||de?.conversationKind!=="nativeSession")){qe(!0);try{const z=await Gs(C);if(Ne.current!==C)return;pe(z.logs),xn(C,z.logs),Te(oe=>Qs(oe,z.logs))}catch(z){ce.error(z instanceof Error?z.message:"Failed to reload transcript")}finally{Ne.current===C&&qe(!1)}}},[de?.conversationKind,Se,xn]),Vi=o.useCallback(C=>Pn(C),[Pn]),Ki=o.useCallback(async()=>{if(de)try{await Ic(de.id),pt(),Be()}catch(C){ce.error(C instanceof Error?C.message:"Failed to cancel task")}},[de,pt,Be]),{handleShareTask:Gi,handleStopShareTask:Wi}=mf(de,pt,Be),Qi=o.useCallback(async()=>{if(de)try{await Rc(de.id),pt(),Be()}catch(C){ce.error(C instanceof Error?C.message:"Failed to retry task")}},[de,pt,Be]),bn=o.useCallback((C,z=!1)=>{const oe=uu(xe,C);return w(oe),(z||!oe)&&_t(),o.startTransition(()=>{s(oe?`/tasks/${oe}`:"/",{state:null})}),oe},[_t,xe,s]),{handleArchiveTask:Yi,handleDeleteTask:Ji,handleToggleTaskPinned:Zi,handleUpdateTaskTitle:Xi}=Rp({activeTaskId:Se,fetchTasks:Be,navigateToNextVisibleTask:bn,removeTasksFromList:vt,setTask:ae,setTasks:St}),el=o.useCallback((C,z)=>{G(oe=>{const Ee=new Set(oe);return z?Ee.add(C):Ee.delete(C),Ee})},[]),tl=o.useCallback(C=>{if(!C){G(new Set);return}G(new Set(xe.map(z=>z.id)))},[xe]),nl=o.useCallback(async()=>{const C=Array.from(Re);if(C.length!==0)try{const{results:z}=await Lc(C),oe=z.filter(we=>!we.ok),Ee=z.filter(we=>we.ok).map(we=>we.id);Se&&Ee.includes(Se)&&bn(Ee),oe.length>0?ce.error(`Failed to archive ${oe.length} task(s): ${oe.map(we=>we.error??we.id).join(", ")}`):ce.success(`Archived ${Ee.length} task(s)`),G(new Set(oe.map(we=>we.id))),Be()}catch(z){ce.error(z instanceof Error?z.message:"Failed to archive tasks")}},[Se,Be,bn,Re]),sl=o.useCallback(async()=>{const C=Array.from(Re);if(C.length!==0)try{const{results:z}=await Bc(C),oe=z.filter(we=>!we.ok),Ee=z.filter(we=>we.ok).map(we=>we.id);Ee.length>0&&vt(Ee),Se&&Ee.includes(Se)&&bn(Ee,!0),oe.length>0?ce.error(`Failed to delete ${oe.length} task(s): ${oe.map(we=>we.error??we.id).join(", ")}`):ce.success(`Deleted ${Ee.length} task(s)`),G(new Set(oe.map(we=>we.id))),Be()}catch(z){ce.error(z instanceof Error?z.message:"Failed to delete tasks")}},[Se,Be,bn,vt,Re]),rl=o.useCallback(async()=>{be(!0);try{await Oc(),m()}catch(C){ce.error(C instanceof Error?C.message:"Failed to promote node")}finally{be(!1)}},[m]),al=o.useCallback(async()=>{De(!0);try{await Fc(),ce.success("This node left the remote cluster and is leading itself again."),Be(),pt(),m()}catch(C){ce.error(C instanceof Error?C.message:"Failed to leave cluster")}finally{De(!1)}},[pt,Be,m]),ol=o.useCallback(async C=>{const z=!gr(C),oe=C.id===a?.self?.id,Ee=oe?i?.transportType??C.transportType:C.transportType,we=oe&&!z&&dn(Ee);re(C.id);try{we?await zc("direct"):await Uc(C.id,z),ce.success(z?`Enabled remote access on ${C.name}`:`Disabled remote access on ${C.name}`),m()}catch(Pr){ce.error(Pr instanceof Error?Pr.message:"Failed to update remote access")}finally{re(null)}},[a?.self?.id,m,i?.transportType]),il=o.useCallback(C=>{rt&&rt(C).catch(z=>{ce.error(z instanceof Error?z.message:"Failed to load completed tasks")})},[rt]),_r={toolbarTasks:xe,activeTaskId:Se,tasksLoading:Pe,tasksError:Oe,isLeader:ve,scope:g,agentFilter:v,nodeFilter:y,taskKindFilter:b,agentOptions:me,nodeOptions:ke,nodeNameById:Ve,nodeWorkDirById:Fe,nodeStatusById:Lt,nodeInfoById:Xn,leaderNodeId:a?.leader?.id??null,searchQuery:A,completedGroupByKey:fn,devBoxNodeIds:mn,devBoxStartNodeIds:Mt,devBoxStartingNodeIds:Rt,selectedTaskIds:Re,allVisibleTasksSelected:ts,someVisibleTasksSelected:at,canBatchArchive:Pi,onScopeChange:k,onAgentFilterChange:S,onNodeFilterChange:p,onTaskKindFilterChange:N,onToggleTaskSelected:el,onToggleAllVisibleTasks:tl,onUpdateTaskTitle:Xi,onDeleteTask:Ji,onArchiveTask:Yi,onToggleTaskPinned:Zi,onBatchArchive:nl,onBatchDelete:sl,onCreateTask:is,onOpenNodeSettings:ve?ft:void 0,onOpenNodeCapabilities:ve?Jt:void 0,onOpenProjectCapabilities:ve?Nt:void 0,onOpenDevBox:ve?Zt:void 0,onStartDevBox:ve?kt:void 0,onLoadCompletedTasks:il,onSelectTask:Dr},ll={cluster:a,systemInfo:i,nodeNameById:Ve,nodeBlockingTaskCounts:en,eventTypeFilter:J,onEventTypeFilterChange:K,activeTab:ie,onTabChange:ue,eventTypeOptions:pn,filteredEvents:es,sseConnected:c,clusterLoading:x,clusterError:u,promotePending:ge,onPromote:rl,onAddNode:()=>V(!0),leavePending:Xe,onLeaveCluster:al,onToggleNodeDevTunnel:ol,devTunnelNodeId:nt,devBoxStartNodeId:hn,devBoxStartingNodeIds:Rt,onOpenNodeSettings:ve?ft:void 0,onOpenNodeCapabilities:ve?Jt:void 0,onOpenDevBox:ve?Zt:void 0,onStartDevBox:ve?kt:void 0};return e.jsxs(e.Fragment,{children:[e.jsx(qm,{desktopTasksOpen:E,mobileTasksPanelOpen:L,mobileTasksPanelRef:M,operationsOpen:D,operationsPanelRef:P,panelResize:B,taskSidebar:e.jsx(Ka,{..._r}),operationsSidecar:e.jsx(Yh,{...ll}),terminalPanel:r?.terminalOpen?e.jsx(Jm,{nodes:Ae,defaultNodeId:tn,onClose:()=>r?.setTerminalOpen(!1)}):void 0,conversationPanel:e.jsx(Im,{onToggleTasks:Y,desktopTasksOpen:E,mobileTasksPanelOpen:L,operationsOpen:D,onToggleOperations:()=>te(C=>!C),cluster:a,sseConnected:c,activeTab:O,setActiveTab:le,creatingTask:H,createMode:$,createDefaults:j,activeTask:de,assignedNode:Ii,taskLoading:ht,transcriptLoading:Me,taskError:He,displayEvents:as,initialPromptAlreadyInLogs:Fi,initialPrompt:_n,supportsFollowUp:Ri,taskUnavailable:rs.taskUnavailable,chatDisabled:rs.chatDisabled,chatDisabledReason:rs.chatDisabledReason,questionBypassEnabled:_,isRunning:!!Dn,isStarting:Li,hasPendingFollowUp:ss,canCancel:!!Bi,canRetry:!!Oi,onRetry:Qi,onCancel:Ki,onReloadNativeTranscript:Hi,onShareTask:Gi,onStopShareTask:Wi,onStartCreateTask:is,onCancelCreateTask:zi,onCreateTask:Ui,onSendMessage:qi,onCancelQueuedMessage:$i,onQuestionBypassChange:se,onSubmitQuestionResponse:Vi,quickChats:_e}),mobileTaskSidebar:e.jsx(Ka,{..._r,onCreateTask:(C,z)=>{Q(!1),is(C,z)},onSelectTask:C=>{Q(!1),Dr(C)}}),onCloseOperations:()=>te(!1),onCloseTaskList:()=>Q(!1),onToggleOperations:()=>te(C=>!C),onToggleTasks:Y}),e.jsx(Om,{open:R,onOpenChange:V,onAdded:m}),Et,bt,un]})}const Up=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:Lp},Symbol.toStringTag,{value:"Module"}));export{_o as A,Up as D,Hn as G};
|