meshy-node 1.0.2 → 1.0.4

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.
@@ -1,201 +1,196 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-By5MpB3q.js","assets/index-Cw9E6sQy.js","assets/index-DPc1_Q2V.css","assets/MarkdownPreviewFrame-C094uLQB.js","assets/DashboardShared-B6YLnjis.js","assets/file-C7Gl-F2G.js","assets/PreviewTab-C_SvaL2_.js","assets/DiffTab-B4hRGo1c.js"])))=>i.map(i=>d[i]);
2
- import{c as ue,r as o,a as Wn,f as No,m as ko,j as e,X as ut,Q as Xs,B as X,L as fe,S as ts,u as So,P as mn,b as Et,d as Co,e as Gl,g as Wl,h as To,i as Ao,k as Ql,l as Yl,n as L,o as Jl,p as Zl,q as Xl,s as ec,I as dt,t as tc,C as En,v as nc,w as Eo,F as hn,x as nt,y as Oe,D as Mn,z as sc,A as rc,E as ce,G as $e,H as qe,J as Je,K as Ve,M as Mo,N as st,T as ac,O as oc,R as Un,U as ic,V as mt,W as ht,Y as vt,Z as Do,_ as _o,$ as In,a0 as lc,a1 as Dn,a2 as cc,a3 as er,a4 as dc,a5 as Po,a6 as Io,a7 as uc,a8 as Le,a9 as mc,aa as $t,ab as qt,ac as Vt,ad as Ht,ae as Kt,af as Gt,ag as Wt,ah as Qt,ai as gr,aj as hc,ak as Mt,al as br,am as fc,an as Gr,ao as tr,ap as gs,aq as Wr,ar as pc,as as xc,at as gc,au as bc,av as vc,aw as wc,ax as Ro,ay as Dt,az as Lo,aA as yc,aB as jc,aC as jt,aD as Qr,aE as Nc,aF as Nn,aG as kc,aH as vr,aI as wr,aJ as Sc,aK as Cc,aL as ns,aM as Tc,aN as Rn,aO as Ac,aP as yr,aQ as Ec,aR as Mc,aS as jr,aT as Dc,aU as Qn,aV as _c,aW as Yr,aX as Nr,aY as kr,aZ as Pc,a_ as Ic,a$ as Rc,b0 as Lc,b1 as Bo,b2 as _n,b3 as Bc,b4 as nr,b5 as Oc,b6 as Fc,b7 as zc,b8 as Uc,b9 as Jr,ba as $c,bb as qc,bc as bs,bd as Vc,be as Zr,bf as Hc,bg as Kc,bh as Gc,bi as Xr,bj as Wc,bk as Qc,bl as sr,bm as Yc,bn as Jc,bo as Oo,bp as ea,bq as Fo,br as Zc,bs as ta,bt as Xc,bu as ed,bv as td,bw as nd,bx as sd,by as rd,bz as na,bA as ad,bB as od,bC as id,bD as ld,bE as cd,bF as dd,bG as ud,bH as md,bI as hd,bJ as fd,bK as pd,bL as xd,bM as gd,bN as bd,bO as vd,bP as wd,bQ as yd,bR as jd,bS as Nd,bT as kd,bU as Sd,bV as Cd,bW as Td,bX as Ad,bY as Ed,bZ as Md,b_ as Dd}from"./index-Cw9E6sQy.js";import{r as sa,e as _d,b as zo,g as Uo,a as kt,A as At,I as Sr,c as $o,T as qo,d as Pd,i as Vo,f as Id,p as Ho,h as Rd,j as ra,k as aa,l as Ld,m as Bd,n as Od,C as oa,o as vs,q as Cr,D as on,s as ct,M as rr,L as Fd,t as zd,u as Ud,v as Ko,w as ar,x as $d,y as ws,z as qd,B as Vd,E as Hd}from"./DashboardShared-B6YLnjis.js";import{E as Kd,M as Gd}from"./MarkdownPreviewFrame-C094uLQB.js";import{P as ss,D as $n,g as Wd,a as Qd,b as Yd}from"./PreviewTab-C_SvaL2_.js";/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-CH1lwzT9.js","assets/index-B75j0Sjk.js","assets/index-BRrkswqR.css","assets/MarkdownPreviewFrame-DEZT2HNE.js","assets/DashboardShared-Cl2J-iJd.js","assets/file-By_WHjZd.js","assets/PreviewTab-T_Y0AhqI.js","assets/DiffTab-Bf9BAMpM.js"])))=>i.map(i=>d[i]);
2
+ import{c as fe,r as o,a as Wn,f as No,m as ko,j as e,X as ut,Q as Xs,B as X,L as he,S as ts,u as So,P as mn,b as Et,d as Co,e as Gl,g as Wl,h as To,i as Ao,k as Ql,l as Yl,n as L,o as Jl,p as Zl,q as Xl,s as ec,I as dt,t as tc,C as En,v as nc,w as Eo,F as hn,x as nt,y as Oe,D as Mn,z as sc,A as rc,E as ce,G as $e,H as qe,J as Je,K as Ve,M as Mo,N as st,T as ac,O as oc,R as Un,U as ic,V as mt,W as ht,Y as vt,Z as Do,_ as _o,$ as In,a0 as lc,a1 as Dn,a2 as cc,a3 as er,a4 as dc,a5 as Po,a6 as Io,a7 as uc,a8 as Le,a9 as mc,aa as hc,ab as $t,ac as qt,ad as Vt,ae as Ht,af as Kt,ag as Gt,ah as Wt,ai as Qt,aj as gr,ak as fc,al as Mt,am as br,an as pc,ao as Gr,ap as tr,aq as gs,ar as Wr,as as xc,at as gc,au as bc,av as vc,aw as wc,ax as yc,ay as Ro,az as Dt,aA as Lo,aB as jc,aC as Nc,aD as jt,aE as Qr,aF as kc,aG as Nn,aH as Sc,aI as vr,aJ as wr,aK as Cc,aL as Tc,aM as ns,aN as Ac,aO as Rn,aP as Ec,aQ as yr,aR as Mc,aS as Dc,aT as jr,aU as _c,aV as Qn,aW as Pc,aX as Yr,aY as Nr,aZ as kr,a_ as Ic,a$ as Rc,b0 as Lc,b1 as Bc,b2 as Bo,b3 as _n,b4 as Oc,b5 as nr,b6 as Fc,b7 as zc,b8 as Uc,b9 as $c,ba as Jr,bb as qc,bc as Vc,bd as bs,be as Hc,bf as Zr,bg as Kc,bh as Gc,bi as Wc,bj as Xr,bk as Qc,bl as Yc,bm as sr,bn as Jc,bo as Zc,bp as Oo,bq as ea,br as Fo,bs as Xc,bt as ta,bu as ed,bv as td,bw as nd,bx as sd,by as rd,bz as ad,bA as na,bB as od,bC as id,bD as ld,bE as cd,bF as dd,bG as ud,bH as md,bI as hd,bJ as fd,bK as pd,bL as xd,bM as gd,bN as bd,bO as vd,bP as wd,bQ as yd,bR as jd,bS as Nd,bT as kd,bU as Sd,bV as Cd,bW as Td,bX as Ad,bY as Ed,bZ as Md,b_ as Dd,b$ as _d}from"./index-B75j0Sjk.js";import{r as sa,e as Pd,b as zo,g as Uo,a as kt,A as At,I as Sr,c as $o,T as qo,d as Id,i as Vo,f as Rd,p as Ho,h as Ld,j as ra,k as aa,l as Bd,m as Od,n as Fd,C as oa,o as vs,q as Cr,D as on,s as ct,M as rr,L as zd,t as Ud,u as $d,v as Ko,w as ar,x as qd,y as ws,z as Vd,B as Hd,E as Kd}from"./DashboardShared-Cl2J-iJd.js";import{E as Gd,M as Wd}from"./MarkdownPreviewFrame-DEZT2HNE.js";import{P as ss,D as $n,g as Qd,a as Yd,b as Jd}from"./PreviewTab-T_Y0AhqI.js";/**
3
3
  * @license lucide-react v1.7.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
6
6
  * See the LICENSE file in the root directory of this source tree.
7
- */const Jd=[["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"}]],Go=ue("archive",Jd);/**
7
+ */const Zd=[["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"}]],Go=fe("archive",Zd);/**
8
8
  * @license lucide-react v1.7.0 - ISC
9
9
  *
10
10
  * This source code is licensed under the ISC license.
11
11
  * See the LICENSE file in the root directory of this source tree.
12
- */const Zd=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],ia=ue("arrow-right",Zd);/**
12
+ */const Xd=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],ia=fe("arrow-right",Xd);/**
13
13
  * @license lucide-react v1.7.0 - ISC
14
14
  *
15
15
  * This source code is licensed under the ISC license.
16
16
  * See the LICENSE file in the root directory of this source tree.
17
- */const Xd=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Wo=ue("arrow-up",Xd);/**
17
+ */const eu=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Wo=fe("arrow-up",eu);/**
18
18
  * @license lucide-react v1.7.0 - ISC
19
19
  *
20
20
  * This source code is licensed under the ISC license.
21
21
  * See the LICENSE file in the root directory of this source tree.
22
- */const eu=[["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"}]],Qo=ue("at-sign",eu);/**
22
+ */const tu=[["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"}]],Qo=fe("at-sign",tu);/**
23
23
  * @license lucide-react v1.7.0 - ISC
24
24
  *
25
25
  * This source code is licensed under the ISC license.
26
26
  * See the LICENSE file in the root directory of this source tree.
27
- */const tu=[["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"}]],Yo=ue("brain-circuit",tu);/**
27
+ */const nu=[["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"}]],Yo=fe("brain-circuit",nu);/**
28
28
  * @license lucide-react v1.7.0 - ISC
29
29
  *
30
30
  * This source code is licensed under the ISC license.
31
31
  * See the LICENSE file in the root directory of this source tree.
32
- */const nu=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],la=ue("clock",nu);/**
32
+ */const su=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],la=fe("clock",su);/**
33
33
  * @license lucide-react v1.7.0 - ISC
34
34
  *
35
35
  * This source code is licensed under the ISC license.
36
36
  * See the LICENSE file in the root directory of this source tree.
37
- */const su=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],ru=ue("cpu",su);/**
37
+ */const ru=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],au=fe("cpu",ru);/**
38
38
  * @license lucide-react v1.7.0 - ISC
39
39
  *
40
40
  * This source code is licensed under the ISC license.
41
41
  * See the LICENSE file in the root directory of this source tree.
42
- */const au=[["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"}]],ou=ue("earth",au);/**
42
+ */const ou=[["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"}]],iu=fe("earth",ou);/**
43
43
  * @license lucide-react v1.7.0 - ISC
44
44
  *
45
45
  * This source code is licensed under the ISC license.
46
46
  * See the LICENSE file in the root directory of this source tree.
47
- */const iu=[["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"}]],Tr=ue("ellipsis-vertical",iu);/**
47
+ */const lu=[["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"}]],Tr=fe("ellipsis-vertical",lu);/**
48
48
  * @license lucide-react v1.7.0 - ISC
49
49
  *
50
50
  * This source code is licensed under the ISC license.
51
51
  * See the LICENSE file in the root directory of this source tree.
52
- */const lu=[["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"}]],cu=ue("ellipsis",lu);/**
52
+ */const cu=[["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"}]],du=fe("ellipsis",cu);/**
53
53
  * @license lucide-react v1.7.0 - ISC
54
54
  *
55
55
  * This source code is licensed under the ISC license.
56
56
  * See the LICENSE file in the root directory of this source tree.
57
- */const du=[["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"}]],rs=ue("folder-open",du);/**
57
+ */const uu=[["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"}]],rs=fe("folder-open",uu);/**
58
58
  * @license lucide-react v1.7.0 - ISC
59
59
  *
60
60
  * This source code is licensed under the ISC license.
61
61
  * See the LICENSE file in the root directory of this source tree.
62
- */const uu=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],Jo=ue("folder-tree",uu);/**
62
+ */const mu=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],Jo=fe("folder-tree",mu);/**
63
63
  * @license lucide-react v1.7.0 - ISC
64
64
  *
65
65
  * This source code is licensed under the ISC license.
66
66
  * See the LICENSE file in the root directory of this source tree.
67
- */const mu=[["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"}]],hu=ue("funnel",mu);/**
67
+ */const hu=[["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"}]],fu=fe("funnel",hu);/**
68
68
  * @license lucide-react v1.7.0 - ISC
69
69
  *
70
70
  * This source code is licensed under the ISC license.
71
71
  * See the LICENSE file in the root directory of this source tree.
72
- */const fu=[["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"}]],Yn=ue("git-branch",fu);/**
72
+ */const pu=[["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"}]],Yn=fe("git-branch",pu);/**
73
73
  * @license lucide-react v1.7.0 - ISC
74
74
  *
75
75
  * This source code is licensed under the ISC license.
76
76
  * See the LICENSE file in the root directory of this source tree.
77
- */const pu=[["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"}]],xu=ue("globe",pu);/**
77
+ */const xu=[["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"}]],gu=fe("globe",xu);/**
78
78
  * @license lucide-react v1.7.0 - ISC
79
79
  *
80
80
  * This source code is licensed under the ISC license.
81
81
  * See the LICENSE file in the root directory of this source tree.
82
- */const gu=[["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"}]],Jn=ue("history",gu);/**
82
+ */const bu=[["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"}]],Jn=fe("history",bu);/**
83
83
  * @license lucide-react v1.7.0 - ISC
84
84
  *
85
85
  * This source code is licensed under the ISC license.
86
86
  * See the LICENSE file in the root directory of this source tree.
87
- */const bu=[["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"}]],or=ue("image-plus",bu);/**
87
+ */const vu=[["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"}]],or=fe("image-plus",vu);/**
88
88
  * @license lucide-react v1.7.0 - ISC
89
89
  *
90
90
  * This source code is licensed under the ISC license.
91
91
  * See the LICENSE file in the root directory of this source tree.
92
- */const vu=[["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"}]],wu=ue("laptop",vu);/**
92
+ */const wu=[["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"}]],yu=fe("laptop",wu);/**
93
93
  * @license lucide-react v1.7.0 - ISC
94
94
  *
95
95
  * This source code is licensed under the ISC license.
96
96
  * See the LICENSE file in the root directory of this source tree.
97
- */const yu=[["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"}]],Ar=ue("link-2",yu);/**
97
+ */const ju=[["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"}]],Ar=fe("link-2",ju);/**
98
98
  * @license lucide-react v1.7.0 - ISC
99
99
  *
100
100
  * This source code is licensed under the ISC license.
101
101
  * See the LICENSE file in the root directory of this source tree.
102
- */const ju=[["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"}]],Nu=ue("list-ordered",ju);/**
102
+ */const Nu=[["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"}]],ku=fe("list-ordered",Nu);/**
103
103
  * @license lucide-react v1.7.0 - ISC
104
104
  *
105
105
  * This source code is licensed under the ISC license.
106
106
  * See the LICENSE file in the root directory of this source tree.
107
- */const ku=[["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"}]],Ln=ue("message-square-plus",ku);/**
107
+ */const Su=[["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"}]],Ln=fe("message-square-plus",Su);/**
108
108
  * @license lucide-react v1.7.0 - ISC
109
109
  *
110
110
  * This source code is licensed under the ISC license.
111
111
  * See the LICENSE file in the root directory of this source tree.
112
- */const Su=[["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"}]],Zo=ue("monitor-play",Su);/**
112
+ */const Cu=[["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"}]],Zo=fe("monitor-play",Cu);/**
113
113
  * @license lucide-react v1.7.0 - ISC
114
114
  *
115
115
  * This source code is licensed under the ISC license.
116
116
  * See the LICENSE file in the root directory of this source tree.
117
- */const Cu=[["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"}]],Jt=ue("pencil",Cu);/**
117
+ */const Tu=[["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"}]],Jt=fe("pencil",Tu);/**
118
118
  * @license lucide-react v1.7.0 - ISC
119
119
  *
120
120
  * This source code is licensed under the ISC license.
121
121
  * See the LICENSE file in the root directory of this source tree.
122
- */const Tu=[["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"}]],Au=ue("pin-off",Tu);/**
122
+ */const Au=[["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"}]],Eu=fe("pin-off",Au);/**
123
123
  * @license lucide-react v1.7.0 - ISC
124
124
  *
125
125
  * This source code is licensed under the ISC license.
126
126
  * See the LICENSE file in the root directory of this source tree.
127
- */const Eu=[["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"}]],Xo=ue("pin",Eu);/**
127
+ */const Mu=[["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"}]],Xo=fe("pin",Mu);/**
128
128
  * @license lucide-react v1.7.0 - ISC
129
129
  *
130
130
  * This source code is licensed under the ISC license.
131
131
  * See the LICENSE file in the root directory of this source tree.
132
- */const Mu=[["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"}]],ei=ue("qr-code",Mu);/**
132
+ */const Du=[["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"}]],ei=fe("qr-code",Du);/**
133
133
  * @license lucide-react v1.7.0 - ISC
134
134
  *
135
135
  * This source code is licensed under the ISC license.
136
136
  * See the LICENSE file in the root directory of this source tree.
137
- */const Du=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],ti=ue("radio",Du);/**
137
+ */const _u=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],ti=fe("radio",_u);/**
138
138
  * @license lucide-react v1.7.0 - ISC
139
139
  *
140
140
  * This source code is licensed under the ISC license.
141
141
  * See the LICENSE file in the root directory of this source tree.
142
- */const _u=[["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"}]],Pu=ue("rotate-ccw",_u);/**
142
+ */const Pu=[["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"}]],ni=fe("rotate-cw",Pu);/**
143
143
  * @license lucide-react v1.7.0 - ISC
144
144
  *
145
145
  * This source code is licensed under the ISC license.
146
146
  * See the LICENSE file in the root directory of this source tree.
147
- */const Iu=[["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"}]],ni=ue("rotate-cw",Iu);/**
147
+ */const Iu=[["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"}]],si=fe("send",Iu);/**
148
148
  * @license lucide-react v1.7.0 - ISC
149
149
  *
150
150
  * This source code is licensed under the ISC license.
151
151
  * See the LICENSE file in the root directory of this source tree.
152
- */const Ru=[["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"}]],si=ue("send",Ru);/**
152
+ */const Ru=[["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"}]],Zn=fe("share-2",Ru);/**
153
153
  * @license lucide-react v1.7.0 - ISC
154
154
  *
155
155
  * This source code is licensed under the ISC license.
156
156
  * See the LICENSE file in the root directory of this source tree.
157
- */const Lu=[["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"}]],Zn=ue("share-2",Lu);/**
157
+ */const Lu=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Bu=fe("shield",Lu);/**
158
158
  * @license lucide-react v1.7.0 - ISC
159
159
  *
160
160
  * This source code is licensed under the ISC license.
161
161
  * See the LICENSE file in the root directory of this source tree.
162
- */const Bu=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Ou=ue("shield",Bu);/**
162
+ */const Ou=[["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"}]],Fu=fe("sliders-horizontal",Ou);/**
163
163
  * @license lucide-react v1.7.0 - ISC
164
164
  *
165
165
  * This source code is licensed under the ISC license.
166
166
  * See the LICENSE file in the root directory of this source tree.
167
- */const Fu=[["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"}]],zu=ue("sliders-horizontal",Fu);/**
167
+ */const zu=[["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"}]],ys=fe("triangle-alert",zu);/**
168
168
  * @license lucide-react v1.7.0 - ISC
169
169
  *
170
170
  * This source code is licensed under the ISC license.
171
171
  * See the LICENSE file in the root directory of this source tree.
172
- */const Uu=[["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"}]],ys=ue("triangle-alert",Uu);/**
172
+ */const Uu=[["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"}]],$u=fe("user-plus",Uu);/**
173
173
  * @license lucide-react v1.7.0 - ISC
174
174
  *
175
175
  * This source code is licensed under the ISC license.
176
176
  * See the LICENSE file in the root directory of this source tree.
177
- */const $u=[["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"}]],qu=ue("user-plus",$u);/**
177
+ */const qu=[["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"}]],Vu=fe("wifi",qu);/**
178
178
  * @license lucide-react v1.7.0 - ISC
179
179
  *
180
180
  * This source code is licensed under the ISC license.
181
181
  * See the LICENSE file in the root directory of this source tree.
182
- */const Vu=[["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"}]],Hu=ue("wifi",Vu);/**
182
+ */const Hu=[["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"}]],Ku=fe("zoom-in",Hu);/**
183
183
  * @license lucide-react v1.7.0 - ISC
184
184
  *
185
185
  * This source code is licensed under the ISC license.
186
186
  * See the LICENSE file in the root directory of this source tree.
187
- */const Ku=[["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"}]],Gu=ue("zoom-in",Ku);/**
188
- * @license lucide-react v1.7.0 - ISC
189
- *
190
- * This source code is licensed under the ISC license.
191
- * See the LICENSE file in the root directory of this source tree.
192
- */const Wu=[["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"}]],Qu=ue("zoom-out",Wu),Yu=new Set(["assigned","running"]);function Ju(t,n){return t.reduce((s,r)=>r.assignedTo===n&&Yu.has(r.status)?s+1:s,0)}function fn(t){return t?.toLowerCase()==="devtunnel"}function Zu(t){return t?fn(t)?"DevTunnel":t.charAt(0).toUpperCase()+t.slice(1):"Direct"}function Er(t,n){return fn(n??t.transportType)||!!t.devtunnelEndpoint}function ri(t,n){return!fn(n??t.transportType)}function ai(t,n){const s=n??t.transportType;return fn(s)?"DevTunnel":t.devtunnelEndpoint?"Direct + DevTunnel":Zu(s)}function ca(t,n){return!t&&!n}function Xu({routeTaskId:t,creatingTask:n,internalSelectedTaskId:s,sortedTaskIds:r}){return t||(n?null:r[0]??s??null)}function em({activeTaskId:t,routeTaskId:n,creatingTask:s,tasksLoading:r,loadedTaskIds:a}){return!t||n||s||r?!1:!a.includes(t)}function tm(t,n){return[n,...t.filter(s=>s.id!==n.id)]}function Mr(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 nm=new Set(["completed","failed","cancelled","archived"]);function sm(t,n){const s=new Set(n);return new Set(Array.from(t).filter(r=>s.has(r)))}function rm(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=>nm.has(a.status))}function am(t,n){const s=new Set(n);return t.find(r=>!s.has(r.id))?.id??null}function oi(){const[t,n]=o.useState([]),[s,r]=o.useState(null),a=o.useRef(null),i=o.useCallback(()=>{a.current?.click()},[]),l=o.useCallback(async p=>{const u=Array.from(p.target.files??[]);if(u.length!==0)try{const h=await sa(u);n(f=>[...f,...h]),r(null)}catch(h){r(h instanceof Error?h.message:"Failed to attach image")}finally{p.target.value=""}},[]),c=o.useCallback(async p=>{const u=_d(p.clipboardData);if(u.length!==0){p.preventDefault();try{const h=await sa(u);n(f=>[...f,...h]),r(null)}catch(h){r(h instanceof Error?h.message:"Failed to attach image")}}},[]),d=o.useCallback(p=>{n(u=>u.filter((h,f)=>f!==p))},[]),m=o.useCallback(()=>{n([]),r(null)},[]);return{images:t,error:s,fileInputRef:a,pickImages:i,handleFileChange:l,handlePaste:c,removeImage:d,clearImages:m}}function om({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 im({contentLength:t,disabled:n=!1}){return t>0&&!n}const lm=/^[a-zA-Z0-9_-]+$/,ii=/[a-zA-Z0-9_-]/,cm=176;function dm(t){const n=t.map(a=>({...a,displayValue:um(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 um(t){return t.label.toLowerCase()==="agent"?kt(t.value):t.value}function da(t){switch(t.toLowerCase()){case"branch":return Yn;case"node":return ts;default:return rs}}function mm(t){return Array.from(new Set(t.map(n=>n.trim()).filter(Boolean)))}function li(t,n){return Number.isFinite(n)?Math.max(0,Math.min(t.length,Math.trunc(n))):t.length}function hm(t,n){const s=li(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&&!lm.test(d)))return{query:d.toLowerCase(),range:{start:a.index,end:c}}}function fm(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&&ii.test(t[c]??"")))return{targetAgent:l,query:i,range:{start:a.index,end:c}}}}function ir(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 ua(t,n,s){const r=mm(n),a=typeof s=="number",i=hm(t,a?s:t.length);if(i){const c=r.filter(p=>p.toLowerCase().startsWith(i.query)),d=r.find(p=>p.toLowerCase()===i.query),m=!!d&&(i.range.end===t.length||!ii.test(t[i.range.end]??""));return{...m?{targetAgent:d}:{},query:i.query,strippedText:m?ir(t,i.range):t,matches:c,...a?{mentionRange:i.range}:{}}}const l=fm(t,r);return l?{targetAgent:l.targetAgent,query:l.query,strippedText:ir(t,l.range),matches:[l.targetAgent],...a?{mentionRange:l.range}:{}}:{strippedText:t,matches:[]}}function pm(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 xm(t,n){return t.query!==void 0&&t.matches.length>0&&!t.targetAgent&&!n}function gm(t,n){if(!n)return{value:t.replace(/^@[a-zA-Z0-9_-]*\s*/,""),cursorPosition:0};const s=ir(t,n);return{value:s,cursorPosition:Math.min(n.start,s.length)}}function bm(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 vm(t,n){if(typeof window>"u")return;const s=t.ownerDocument,r=s.createElement("div"),a=s.createElement("span"),i=li(t.value,n);bm(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 wm({cardClientWidth:t,cardRectWidth:n}){const s=n/t;return Number.isFinite(s)&&s>0?s:1}function ym({boundaryRectBottom:t,boundaryRectTop:n,cardRectTop:s,cardWidth:r,caretLeft:a,caretTop:i,cssZoom:l=1,lineHeight:c,matchCount:d,textareaOffsetLeft:m,textareaOffsetTop:p,viewportHeight:u}){const h=Number.isFinite(l)&&l>0?l:1,f=Math.min(Math.max(d,1)*28+4,220),j=f*h,g=m/h,w=p/h,b=n??0,k=t??u,y=Math.max(8,r-cm-8),x=Math.max(8,Math.min(g+a,y)),v=w+i+c+4,N=s+v*h,A=w+i-f-4,E=s+(w+i)*h,M=k-N-8,B=E-b-8,D=Math.max(8,(b-s+8)/h);if(M<j&&B>M)return{left:x,top:Math.max(D,A)};const _=Math.max(D,(k-s-j-8)/h);return{left:x,top:Math.max(D,Math.min(v,_))}}function jm(t,n,s){const r=t.closest('[data-chat-input-card="true"]'),a=vm(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 ym({boundaryRectBottom:c?.bottom,boundaryRectTop:c?.top,cardRectTop:l.top,cardWidth:r.clientWidth,caretLeft:a.left,caretTop:a.top,cssZoom:wm({cardRectWidth:l.width,cardClientWidth:r.clientWidth}),lineHeight:d,matchCount:s,textareaOffsetLeft:i.left-l.left,textareaOffsetTop:i.top-l.top,viewportHeight:window.innerHeight})}function Nm({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:p,onTargetAgentChange:u,running:h=!1,onStop:f,quickChats:j=[]}){const[g,w]=o.useState(""),[b,k]=o.useState(),[y,x]=o.useState(c),[v,N]=o.useState(),[A,E]=o.useState(),[M,B]=o.useState(!1),[D,_]=o.useState(0),[P,O]=o.useState(0),[W,J]=o.useState(0),Y=o.useRef(null),V=o.useRef(void 0),{images:ne,error:$,fileInputRef:ee,pickImages:S,handleFileChange:Q,handlePaste:T,removeImage:te,clearImages:R}=oi();c!==y&&(x(c),k(void 0));const H=o.useCallback((G=Y.current)=>{G&&_(G.selectionStart??G.value.length)},[]),F=o.useCallback((G=D,ge=1)=>{Y.current&&E(jm(Y.current,G,ge))},[D]),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",H(Y.current))},[H]);o.useEffect(()=>{O(0)},[g,j]);const me=p??b,Z=o.useMemo(()=>ua(g,m,D),[m,D,g]),K=xm(Z,M),I=pm(Z.matches,v,l),se=Z.matches[I];o.useEffect(()=>{N(void 0),B(!1)},[l,Z.query,Z.matches.join("|")]),o.useEffect(()=>{if(!K){E(void 0);return}const G=Z.mentionRange?.end??D,ge=()=>F(G,Z.matches.length);if(typeof requestAnimationFrame!="function"){ge();return}const be=requestAnimationFrame(ge);return()=>cancelAnimationFrame(be)},[Z.matches.length,Z.mentionRange?.end,D,K,F]);const q=o.useCallback(G=>{u?u(G):k(G)},[u]),ae=o.useCallback(G=>{w(G.prompt);const ge=()=>{Y.current?.focus(),ie()};typeof requestAnimationFrame=="function"?requestAnimationFrame(ge):ge()},[ie]),ye=o.useCallback(()=>{const G=Wn(g,j,P);if(G){ae(G);return}const ge=ua(g,m,D),be=ge.targetAgent??me,et=ge.targetAgent?ge.strippedText:g,_e=zo(et,ne);im({contentLength:_e.length,disabled:n})&&(J(rt=>rt+1),t(_e,be?{targetAgent:be}:void 0),w(""),q(void 0),R(),le())},[g,ne,m,D,me,n,t,q,R,le,j,P,ae]),pe=o.useCallback((G,ge=Z.mentionRange)=>{q(G),w(et=>{const _e=gm(et,ge);return V.current=_e.cursorPosition,_(_e.cursorPosition),_e.value});const be=()=>{Y.current?.focus(),V.current!==void 0&&(Y.current?.setSelectionRange(V.current,V.current),V.current=void 0),ie()};typeof requestAnimationFrame=="function"?requestAnimationFrame(be):be()},[ie,Z.mentionRange,q]),Ze=o.useCallback(G=>{if(K&&G.key==="Escape"){G.preventDefault(),B(!0);return}if(K&&(G.key==="ArrowDown"||G.key==="ArrowUp")){G.preventDefault();const be=Z.matches.length;if(be===0)return;const et=G.key==="ArrowDown"?1:-1,_e=(I+et+be)%be;N(Z.matches[_e]);return}if(K&&G.key==="Enter"&&!G.shiftKey&&se){G.preventDefault(),pe(se,Z.mentionRange);return}const ge=No(g,j);if(ge.length>0&&(G.key==="ArrowDown"||G.key==="ArrowUp")){G.preventDefault(),O(be=>ko(be,ge.length,G.key==="ArrowDown"?1:-1));return}if(G.key==="Enter"&&!G.shiftKey){G.preventDefault();const be=Wn(g,j,P);be?ae(be):ye()}},[pe,ae,ye,Z.matches,Z.mentionRange,j,P,se,I,K,g]),Ae=g.trim().length>0||ne.length>0,Re=om({disabled:n,running:h,canStop:h&&!!f,hasContent:Ae}),De=dm(a),He=De.primary?da(De.primary.label):rs,Ke=i?Uo(i,d):null,je=l?kt(l):null,Be=n?s:h?Ae?"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:ee,type:"file",accept:"image/*",multiple:!0,onChange:Q,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(At,{agent:l,className:"h-2.5 w-2.5 shrink-0 text-primary/75"}),e.jsx("span",{className:"truncate",children:je})]}),De.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(He,{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:De.primary.value,children:De.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(Sr,{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:()=>te(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(ut,{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=>{w(G.target.value),H(G.currentTarget)},onKeyDown:Ze,onKeyUp:G=>H(G.currentTarget),onClick:G=>H(G.currentTarget),onSelect:G=>H(G.currentTarget),onScroll:()=>F(D,Z.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(Xs,{query:g,quickChats:j,selectedIndex:P,onActiveIndexChange:O,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:Z.matches.map((G,ge)=>e.jsxs("button",{type:"button",onMouseDown:be=>be.preventDefault(),onMouseEnter:()=>N(G),onClick:()=>pe(G,Z.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===I?"bg-primary/10 text-primary":"text-muted-foreground"].join(" "),children:[e.jsx(At,{agent:G,className:"h-3 w-3 shrink-0 text-primary/60"}),e.jsx("span",{className:"truncate",children:kt(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:[me||De.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:[me&&e.jsxs("span",{"data-chat-input-target-agent":me,title:`Send to ${kt(me)}`,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(Qo,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx(At,{agent:me,className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:kt(me)}),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(ut,{className:"h-2.5 w-2.5"})})]}),De.secondary.map(G=>{const ge=da(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(At,{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:[Ke&&e.jsxs("span",{"data-chat-input-model-display":"true","aria-label":`Model: ${Ke}`,title:`Model: ${Ke}`,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(Yo,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),Ke]}),e.jsxs(X,{type:"button",variant:"ghost",onClick:S,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(or,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Images"})]}),e.jsx("span",{title:Be,children:e.jsx(X,{onClick:Re.primaryAction==="stop"?f:ye,disabled:Re.primaryDisabled,size:"icon","data-chat-send-button":"true","aria-label":Re.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:Re.primaryAction==="stop"?e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(si,{className:`h-3.5 w-3.5 ${W>0?"animate-chat-send-flight":""}`},W)})})]})]}),$&&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 js="rovingFocusGroup.onEntryFocus",km={bubbles:!1,cancelable:!0},Bn="RovingFocusGroup",[lr,ci,Sm]=Gl(Bn),[Cm,di]=Co(Bn,[Sm]),[Tm,Am]=Cm(Bn),ui=o.forwardRef((t,n)=>e.jsx(lr.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(lr.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Em,{...t,ref:n})})}));ui.displayName=Bn;var Em=o.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:s,orientation:r,loop:a=!1,dir:i,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:m,preventScrollOnEntryFocus:p=!1,...u}=t,h=o.useRef(null),f=Wl(n,h),j=To(i),[g,w]=Ao({prop:l,defaultProp:c??null,onChange:d,caller:Bn}),[b,k]=o.useState(!1),y=Ql(m),x=ci(s),v=o.useRef(!1),[N,A]=o.useState(0);return o.useEffect(()=>{const E=h.current;if(E)return E.addEventListener(js,y),()=>E.removeEventListener(js,y)},[y]),e.jsx(Tm,{scope:s,orientation:r,dir:j,loop:a,currentTabStopId:g,onItemFocus:o.useCallback(E=>w(E),[w]),onItemShiftTab:o.useCallback(()=>k(!0),[]),onFocusableItemAdd:o.useCallback(()=>A(E=>E+1),[]),onFocusableItemRemove:o.useCallback(()=>A(E=>E-1),[]),children:e.jsx(mn.div,{tabIndex:b||N===0?-1:0,"data-orientation":r,...u,ref:f,style:{outline:"none",...t.style},onMouseDown:Et(t.onMouseDown,()=>{v.current=!0}),onFocus:Et(t.onFocus,E=>{const M=!v.current;if(E.target===E.currentTarget&&M&&!b){const B=new CustomEvent(js,km);if(E.currentTarget.dispatchEvent(B),!B.defaultPrevented){const D=x().filter(J=>J.focusable),_=D.find(J=>J.active),P=D.find(J=>J.id===g),W=[_,P,...D].filter(Boolean).map(J=>J.ref.current);fi(W,p)}}v.current=!1}),onBlur:Et(t.onBlur,()=>k(!1))})})}),mi="RovingFocusGroupItem",hi=o.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:s,focusable:r=!0,active:a=!1,tabStopId:i,children:l,...c}=t,d=So(),m=i||d,p=Am(mi,s),u=p.currentTabStopId===m,h=ci(s),{onFocusableItemAdd:f,onFocusableItemRemove:j,currentTabStopId:g}=p;return o.useEffect(()=>{if(r)return f(),()=>j()},[r,f,j]),e.jsx(lr.ItemSlot,{scope:s,id:m,focusable:r,active:a,children:e.jsx(mn.span,{tabIndex:u?0:-1,"data-orientation":p.orientation,...c,ref:n,onMouseDown:Et(t.onMouseDown,w=>{r?p.onItemFocus(m):w.preventDefault()}),onFocus:Et(t.onFocus,()=>p.onItemFocus(m)),onKeyDown:Et(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){p.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const b=_m(w,p.orientation,p.dir);if(b!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let y=h().filter(x=>x.focusable).map(x=>x.ref.current);if(b==="last")y.reverse();else if(b==="prev"||b==="next"){b==="prev"&&y.reverse();const x=y.indexOf(w.currentTarget);y=p.loop?Pm(y,x+1):y.slice(x+1)}setTimeout(()=>fi(y))}}),children:typeof l=="function"?l({isCurrentTabStop:u,hasTabStop:g!=null}):l})})});hi.displayName=mi;var Mm={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Dm(t,n){return n!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function _m(t,n,s){const r=Dm(t.key,s);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Mm[r]}function fi(t,n=!1){const s=document.activeElement;for(const r of t)if(r===s||(r.focus({preventScroll:n}),document.activeElement!==s))return}function Pm(t,n){return t.map((s,r)=>t[(n+r)%t.length])}var Im=ui,Rm=hi,as="Tabs",[Lm]=Co(as,[di]),pi=di(),[Bm,Dr]=Lm(as),xi=o.forwardRef((t,n)=>{const{__scopeTabs:s,value:r,onValueChange:a,defaultValue:i,orientation:l="horizontal",dir:c,activationMode:d="automatic",...m}=t,p=To(c),[u,h]=Ao({prop:r,onChange:a,defaultProp:i??"",caller:as});return e.jsx(Bm,{scope:s,baseId:So(),value:u,onValueChange:h,orientation:l,dir:p,activationMode:d,children:e.jsx(mn.div,{dir:p,"data-orientation":l,...m,ref:n})})});xi.displayName=as;var gi="TabsList",bi=o.forwardRef((t,n)=>{const{__scopeTabs:s,loop:r=!0,...a}=t,i=Dr(gi,s),l=pi(s);return e.jsx(Im,{asChild:!0,...l,orientation:i.orientation,dir:i.dir,loop:r,children:e.jsx(mn.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:n})})});bi.displayName=gi;var vi="TabsTrigger",wi=o.forwardRef((t,n)=>{const{__scopeTabs:s,value:r,disabled:a=!1,...i}=t,l=Dr(vi,s),c=pi(s),d=Ni(l.baseId,r),m=ki(l.baseId,r),p=r===l.value;return e.jsx(Rm,{asChild:!0,...c,focusable:!a,active:p,children:e.jsx(mn.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":m,"data-state":p?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:d,...i,ref:n,onMouseDown:Et(t.onMouseDown,u=>{!a&&u.button===0&&u.ctrlKey===!1?l.onValueChange(r):u.preventDefault()}),onKeyDown:Et(t.onKeyDown,u=>{[" ","Enter"].includes(u.key)&&l.onValueChange(r)}),onFocus:Et(t.onFocus,()=>{const u=l.activationMode!=="manual";!p&&!a&&u&&l.onValueChange(r)})})})});wi.displayName=vi;var yi="TabsContent",ji=o.forwardRef((t,n)=>{const{__scopeTabs:s,value:r,forceMount:a,children:i,...l}=t,c=Dr(yi,s),d=Ni(c.baseId,r),m=ki(c.baseId,r),p=r===c.value,u=o.useRef(p);return o.useEffect(()=>{const h=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(h)},[]),e.jsx(Yl,{present:a||p,children:({present:h})=>e.jsx(mn.div,{"data-state":p?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!h,id:m,tabIndex:0,...l,ref:n,style:{...t.style,animationDuration:u.current?"0s":void 0},children:h&&i})})});ji.displayName=yi;function Ni(t,n){return`${t}-trigger-${n}`}function ki(t,n){return`${t}-content-${n}`}var Om=xi,Si=bi,Ci=wi,Ti=ji;const _r=Om,os=o.forwardRef(({className:t,...n},s)=>e.jsx(Si,{ref:s,className:L("inline-flex h-8 items-center justify-center rounded-sm bg-muted/72 p-0.5 text-muted-foreground shadow-inner shadow-background/40",t),...n}));os.displayName=Si.displayName;const Ot=o.forwardRef(({className:t,...n},s)=>e.jsx(Ci,{ref:s,className:L("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-2 py-0.5 text-[11px] font-semibold ring-offset-background transition-all duration-200 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-primary/12 data-[state=active]:text-primary data-[state=active]:shadow-[0_10px_28px_-18px_hsl(var(--primary)/0.85)]",t),...n}));Ot.displayName=Ci.displayName;const bt=o.forwardRef(({className:t,...n},s)=>e.jsx(Ti,{ref:s,className:L("mt-2 ring-offset-background data-[state=inactive]:hidden focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...n}));bt.displayName=Ti.displayName;var Fm=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],zm=Fm.reduce((t,n)=>{const s=Jl(`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}},{}),Um="Label",Ai=o.forwardRef((t,n)=>e.jsx(zm.label,{...t,ref:n,onMouseDown:s=>{s.target.closest("button, input, select, textarea")||(t.onMouseDown?.(s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));Ai.displayName=Um;var Ei=Ai;const $m=Zl("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),tt=o.forwardRef(({className:t,...n},s)=>e.jsx(Ei,{ref:s,className:L($m(),t),...n}));tt.displayName=Ei.displayName;function ma({agent:t,query:n,onSelect:s}){const r=$o(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(qo,{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 qm(t,n,s){return t!=="auto"?n.find(r=>r.id===t)??null:s.length===1?s[0]??null:null}function Vm(t){return t.trim()||"."}function Hm(t){return new Promise(n=>window.setTimeout(n,t))}function Km(t){return!!t&&typeof t=="object"&&typeof t.createdBranch=="string"&&typeof t.currentBranch<"u"}async function Gm(t){let n=t;for(let s=0;s<60;s++){if(n.status==="succeeded"){if(Km(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 Hm(1e3),n=await nc(n.id)}throw new Error("Timed out waiting for branch creation")}function ha({value:t,onChange:n,project:s,assignTo:r,nodes:a,assignableNodes:i,layout:l="default",chipClassName:c,chipActiveClassName:d,chipInactiveClassName:m,labelClassName:p,triggerClassName:u}){const[h,f]=o.useState(!1),[j,g]=o.useState(null),[w,b]=o.useState(""),[k,y]=o.useState(!1),[x,v]=o.useState(!1),[N,A]=o.useState(!1),[E,M]=o.useState(null),[B,D]=o.useState(""),[_,P]=o.useState(""),[O,W]=o.useState(""),[J,Y]=o.useState(!1),V=o.useRef(null),ne=o.useRef(0),$=o.useMemo(()=>qm(r,a,i),[r,a,i]),ee=$?.id,S=o.useMemo(()=>Vm(s),[s]),Q=o.useMemo(()=>ee?`${ee}
193
- ${S}`:"",[ee,S]),T=o.useCallback(async(Z=0,K=!1)=>{const I=ne.current+1,se=Q;if(ne.current=I,!ee){g(null),b("");return}M(null),K||b(""),K?v(!0):y(!0);try{const q=await Xl(ee,{path:S,limit:20,offset:Z,allowAbsolute:!0});if(I!==ne.current)return;b(se),g(ae=>K&&ae?{...q,branches:[...ae.branches,...q.branches]}:q)}catch(q){if(I!==ne.current)return;M(q instanceof Error?q.message:"Failed to load branch info"),K||(g(null),b(""))}finally{I===ne.current&&(y(!1),v(!1))}},[ee,Q,S]);o.useEffect(()=>{if(!ee){ne.current+=1,g(null),b(""),M(null);return}T()},[ee,S,T]),o.useEffect(()=>{const Z=t.trim(),K=w===Q?j:null,I=K?.available&&K.currentBranch?K.currentBranch:"";Z!==I&&n(I)},[j,Q,w,n,t]),o.useEffect(()=>{if(!h)return;const Z=I=>{V.current&&(V.current.contains(I.target)||f(!1))},K=I=>{I.key==="Escape"&&f(!1)};return document.addEventListener("mousedown",Z),document.addEventListener("keydown",K),()=>{document.removeEventListener("mousedown",Z),document.removeEventListener("keydown",K)}},[h]),o.useEffect(()=>{h&&(P(""),W(""),Y(!1))},[h,ee,S]);const te=o.useCallback(async()=>{if(!ee)return;const Z=B.trim(),K=J?O.trim():_.trim();if(!(!Z||!K)){A(!0),M(null);try{const I=await ec(ee,{path:S,branchName:Z,startPoint:K,limit:20,offset:0,allowAbsolute:!0}),se=await Gm(I);b(Q),g(se),n(se.currentBranch??se.createdBranch),D(""),P(""),W(""),Y(!1),f(!1)}catch(I){M(I instanceof Error?I.message:"Failed to create branch")}finally{A(!1)}}},[ee,Q,S,J,O,B,n,_]),R=w===Q?j:null,H=o.useCallback(()=>{R?.hasMore&&T(R.branches.length,!0)},[R,T]),F=t.trim()||R?.currentBranch||(R&&!R.available?"No git repo":"Branch"),le=J?O.trim():_.trim(),ie=!!(R?.available&&B.trim()&&le&&!N),me=l==="composer"?e.jsxs(X,{type:"button",variant:"ghost",onClick:()=>f(Z=>!Z),title:F,"aria-label":`Branch: ${F}`,className:L(c,u,"min-w-0 max-w-full",t.trim()?d:m),children:[k&&!R?e.jsx(fe,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(Yn,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:L("min-w-0 truncate",p),children:F})]}):e.jsxs(X,{type:"button",variant:"outline",onClick:()=>f(Z=>!Z),className:"h-7 w-full justify-between rounded-sm border-border/70 bg-background/70 px-2.5 text-[11px] shadow-none",title:F,children:[e.jsx("span",{className:L("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:F}),e.jsx("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground",children:$?$.name:"Manual"})]});return e.jsxs("div",{className:L("relative inline-block",l==="composer"?"min-w-0 shrink-0":"w-full"),ref:V,children:[l==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[10px] font-medium",children:"Branch"}),me]}):me,h&&e.jsxs("div",{className:L("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(Yn,{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??F} · ${R.repoRoot}`:R?.currentBranch??F,children:R?.currentBranch??F}),k?e.jsx(fe,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}):null]}),$?k&&!R?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(fe,{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(dt,{value:B,onChange:Z=>D(Z.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(X,{type:"button",size:"sm",onClick:()=>{te()},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(fe,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(tc,{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"}),!J&&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(Jt,{className:"h-2.5 w-2.5"}),"Manual"]})]}),J?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(dt,{value:O,onChange:Z=>W(Z.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),W("")},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(ut,{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(Z=>{const K=_===Z.ref,I=Z.branch==="main"||Z.branch==="master";return e.jsxs("button",{type:"button",onClick:()=>P(Z.ref),className:L("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:Z.ref,children:[e.jsx("span",{className:L("shrink-0 text-[10px]",I?"text-amber-500 dark:text-amber-400":"text-muted-foreground/60"),"aria-hidden":!0,children:I?"★":"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:Z.ref}),K?e.jsx(En,{className:"h-3 w-3 shrink-0 text-primary"}):null]},Z.ref)}),R.hasMore&&e.jsxs("button",{type:"button",onClick:H,disabled:x,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:[x?e.jsx(fe,{className:"h-3 w-3 animate-spin"}):e.jsx(Jn,{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."}),E&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-1.5 text-[11px] text-destructive",children:E})]})]})}function Wm({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(Sr,{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(ut,{className:"h-3.5 w-3.5"})})]},`${s.filename??"image"}-${r}`))})}const Qm=20,Ym=3,cr="meshy-working-dir-recents-by-node";function Jm(t){return t.startsWith("/")||t.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(t)}function Zm(t){const n=t.trim();return n||"."}function dr(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===Ym))break}return n}function Xm(t,n){const s=n.trim();return dr(s?[s,...t]:t)}function Mi(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=dr(a);i.length>0&&(n[s]=i)}return n}function eh(t,n,s){if(!n)return t;const r=t[n]??[],a=Xm(r,s);if(a.length===0){if(!(n in t))return t;const{[n]:i,...l}=t;return l}return{...t,[n]:a}}function th(t,n){return n?t[n]?.[0]??"":""}function Di(t){if(!t||typeof window>"u")return"";try{const n=window.localStorage.getItem(cr);return n?th(Mi(JSON.parse(n)),t):""}catch{return""}}function nh(t,n,s){return t!=="auto"?n.find(r=>r.id===t)??null:s.length===1?s[0]??null:null}function sh(t,n){const s=n.trim();return s?Jm(s)||!t?s:`${t.replace(/[/\\]+$/,"")}/${s}`:""}function rh(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 Xn({value:t,onChange:n,assignTo:s,nodes:r,assignableNodes:a,layout:i="default",chipClassName:l,chipActiveClassName:c,chipInactiveClassName:d,labelClassName:m,triggerClassName:p,popoverPlacement:u="bottom",popoverAlign:h="start"}){const[f,j]=o.useState(!1),[g,w]=o.useState(null),[b,k]=o.useState(!1),[y,x]=o.useState(!1),[v,N]=o.useState(null),[A,E]=o.useState(""),[M,B]=o.useState(!1),[D,_]=o.useState({}),P=o.useRef(null),O=o.useMemo(()=>nh(s,r,a),[s,r,a]),W=O?.id,J=o.useMemo(()=>W?D[W]??[]:[],[D,W]),Y=o.useMemo(()=>t.trim()?sh(O?.workDir,t):"Use node default",[t,O?.workDir]);o.useEffect(()=>{if(!(typeof window>"u"))try{const F=window.localStorage.getItem(cr);if(!F)return;const le=JSON.parse(F);_(Mi(le))}catch{}},[]);const V=o.useCallback(F=>{W&&_(le=>{const ie=eh(le,W,F);if(ie===le)return le;if(typeof window<"u")try{window.localStorage.setItem(cr,JSON.stringify(ie))}catch{}return ie})},[W]),ne=o.useCallback((F,le=!0)=>{const ie=F.trim();n(ie),le&&ie&&V(ie),j(!1)},[n,V]),$=o.useCallback(async(F,le=0,ie=!1)=>{if(W){N(null),ie?x(!0):k(!0);try{const me=await Eo(W,{path:F,limit:Qm,offset:le,directoriesOnly:!0,allowAbsolute:!0});w(Z=>ie&&Z?{...me,entries:[...Z.entries,...me.entries]}:me)}catch(me){N(me instanceof Error?me.message:"Failed to browse directories"),ie||w(null)}finally{k(!1),x(!1)}}},[W]),ee=o.useRef(t);ee.current=t;const S=o.useRef($);S.current=$,o.useEffect(()=>{if(!f)return;const F=ee.current;E(F),B(!1),w(null),N(null),W&&S.current(Zm(F))},[f,W]),o.useEffect(()=>{if(!f)return;const F=ie=>{P.current&&(P.current.contains(ie.target)||j(!1))},le=ie=>{ie.key==="Escape"&&j(!1)};return document.addEventListener("mousedown",F),document.addEventListener("keydown",le),()=>{document.removeEventListener("mousedown",F),document.removeEventListener("keydown",le)}},[f]);const Q=o.useCallback(F=>{$(F)},[$]),T=o.useCallback(()=>{g&&$(g.currentPath,g.entries.length,!0)},[g,$]),te=i==="composer"?e.jsxs(X,{type:"button",variant:"ghost",onClick:()=>j(F=>!F),title:Y,"aria-label":`Working directory: ${Y}`,className:L(l,p,"min-w-0 max-w-full",t.trim()?c:d),children:[e.jsx(Jo,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:L("min-w-0 truncate",m),children:Y})]}):e.jsxs(X,{type:"button",variant:"outline",onClick:()=>j(F=>!F),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:L("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:O?O.name:"Manual"})]}),R=rh(g,O),H=!!g?.parentPath;return e.jsxs("div",{className:L("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(tt,{className:"text-[10px] font-medium",children:"Working directory"}),te]}):te,f&&e.jsxs("div",{className:L("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:[J.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(Jn,{className:"h-2.5 w-2.5"}),"Recent"]}),e.jsx("div",{className:"flex flex-col",children:J.map(F=>e.jsx("button",{type:"button",onClick:()=>ne(F),className:"truncate rounded-sm px-1.5 py-0.5 text-left font-mono text-[11px] text-foreground hover:bg-background/60",title:F,children:F},F))})]}),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&&Q(g.parentPath),disabled:!H||b,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(Wo,{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:[O?b?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(fe,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):g&&g.entries.length>0?e.jsxs(e.Fragment,{children:[g.entries.map(F=>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(F.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 ${F.path}`,children:[e.jsx(hn,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[11px] text-foreground",children:F.name})]}),e.jsx("button",{type:"button",onClick:()=>Q(F.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 ${F.name}`,children:e.jsx(nt,{className:"h-3.5 w-3.5"})})]},F.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(fe,{className:"h-3 w-3 animate-spin"}):e.jsx(Jn,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:v??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a node to browse."}),v&&g&&g.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[11px] text-destructive",children:v})]}),e.jsx("div",{className:"flex items-center gap-1 border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:M?e.jsxs(e.Fragment,{children:[e.jsx(dt,{value:A,onChange:F=>E(F.target.value),onKeyDown:F=>{F.key==="Enter"&&A.trim()?(F.preventDefault(),ne(A)):F.key==="Escape"&&(F.preventDefault(),B(!1),E(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(En,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{B(!1),E(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(ut,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>{E(t),B(!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(Jt,{className:"h-3 w-3"})]})})]})]})}function _i(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 Pr({isCurrent:t}){return t?e.jsx(wu,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):e.jsx(xu,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function ur(t,n){return t.map(s=>{const r=!!n&&s.id===n;return e.jsx(Oe,{value:s.id,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(Pr,{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 ah(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??Mn}}function oh(){return ac.map(t=>e.jsx(Oe,{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 ih(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 fa(t){if(!t.updatedAt)return 0;const n=Date.parse(t.updatedAt);return Number.isNaN(n)?0:n}function lh(t,n){return fa(n)-fa(t)||t.sessionId.localeCompare(n.sessionId)}function ch(t){const n=t.trim().replace(/[\\/]+$/,"");return n?n.split(/[\\/]+/).filter(Boolean).at(-1)??n:"Unknown project"}function dh(t){const n=new Map;for(const s of[...t].sort(lh)){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:ch(s),cwd:s,sessions:r}))}function uh(t,n){const s=new Set(t);return s.has(n)?s.delete(n):s.add(n),s}function mh({nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,onCreated:a,onCancel:i,className:l,footerClassName:c,submitLabel:d="Load session",cancelLabel:m="Cancel",autoFocus:p=!1}){const u=o.useMemo(()=>_i(t,{currentNodeRole:n,leaderNodeId:r}),[t,n,r]),h=o.useMemo(()=>s&&u.some(I=>I.id===s)?s:u[0]?.id??"",[u,s]),[f,j]=o.useState(""),[g,w]=o.useState("codex"),[b,k]=o.useState(""),[y,x]=o.useState(""),[v,N]=o.useState(""),[A,E]=o.useState(h),[M,B]=o.useState(Mn),[D,_]=o.useState(!1),[P,O]=o.useState([]),[W,J]=o.useState(!1),[Y,V]=o.useState(null),ne=o.useMemo(()=>P.find(I=>I.sessionId===b)??null,[P,b]);o.useEffect(()=>{A&&u.some(I=>I.id===A)||E(h)},[A,u,h]),o.useEffect(()=>{k(""),x(""),N("")},[g,A]),o.useEffect(()=>{let I=!1;return A?(J(!0),V(null),sc(A,{agent:g,limit:50}).then(se=>{I||O(se.sessions)}).catch(se=>{I||(O([]),V(se instanceof Error?se.message:"Failed to load native sessions"))}).finally(()=>{I||J(!1)}),()=>{I=!0}):(O([]),V(null),J(!1),()=>{I=!0})},[g,A]),o.useEffect(()=>{ne&&(x(ne.sessionId),N(ne.cwd))},[ne]);const $=o.useCallback(async I=>{I.preventDefault();const se=ah({title:f,defaultTitle:ne?.summary,agent:g,sessionId:y,cwd:v,assignTo:A,priority:"normal",mode:M});if(se){_(!0);try{const q=await rc(se);a(q)}catch(q){ce.error(q instanceof Error?q.message:"Failed to load native session")}finally{_(!1)}}},[f,ne,g,y,v,A,M,a]),ee=!!(y.trim()&&v.trim()&&A),[S,Q]=o.useState(!1),[T,te]=o.useState(""),[R,H]=o.useState(()=>new Set),F=u.find(I=>I.id===A)??null,le=!!(s&&F?.id===s),ie=o.useMemo(()=>{const I=T.trim().toLowerCase();return I?P.filter(se=>se.summary.toLowerCase().includes(I)||se.sessionId.toLowerCase().includes(I)||se.cwd.toLowerCase().includes(I)):P},[P,T]),me=o.useMemo(()=>dh(ie),[ie]),Z=o.useCallback(I=>{H(se=>uh(se,I))},[]),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:L("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($e,{value:A,onValueChange:E,children:[e.jsx(qe,{className:L(K),"aria-label":"Node",children:F?e.jsxs(e.Fragment,{children:[e.jsx(Pr,{isCurrent:le}),e.jsx("span",{className:"max-w-[10rem] truncate",children:F.name})]}):e.jsx(Je,{placeholder:"Node"})}),e.jsx(Ve,{children:ur(u,s)})]}),e.jsxs($e,{value:g,onValueChange:I=>w(I),children:[e.jsxs(qe,{className:L(K),"aria-label":"Agent",children:[e.jsx(At,{agent:g}),e.jsx("span",{children:g})]}),e.jsx(Ve,{children:Pd()})]}),e.jsxs("div",{className:"relative ml-auto min-w-0 flex-1 sm:max-w-56",children:[e.jsx(Mo,{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(dt,{value:T,onChange:I=>te(I.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(tt,{className:"text-[10px] font-medium uppercase tracking-[0.2em] text-muted-foreground",children:W?"Loading...":`${ie.length} session${ie.length===1?"":"s"}`})}),e.jsxs("div",{className:"relative h-88 overflow-hidden rounded-sm",children:[W&&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&&!W&&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."}),me.map(I=>e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>Z(I.cwd),"aria-expanded":!R.has(I.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(st,{className:L("h-3.5 w-3.5 shrink-0 transition-transform",R.has(I.cwd)&&"-rotate-90")}),e.jsx(rs,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-foreground",children:I.folderName}),e.jsxs("span",{className:"shrink-0 uppercase tracking-[0.16em]",children:[I.sessions.length," session",I.sessions.length===1?"":"s"]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-right font-mono",children:I.cwd})]}),!R.has(I.cwd)&&I.sessions.map(se=>{const q=se.sessionId===b;return e.jsxs("button",{type:"button",onClick:()=>k(se.sessionId),className:L("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:L("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:ih(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)})]},I.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:()=>Q(I=>!I),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":S,children:[e.jsx("span",{className:"shrink-0",children:S?"Less options":"More options"}),e.jsx(st,{className:L("h-3.5 w-3.5 shrink-0 transition-transform",S&&"rotate-180")})]}),S&&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(tt,{htmlFor:"native-session-id",className:"text-[10px] font-medium text-muted-foreground",children:"Session ID"}),e.jsx(dt,{id:"native-session-id",type:"text",value:y,onChange:I=>{k(""),x(I.target.value)},placeholder:"ses_..., thread_..., or UUID",autoFocus:p,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(tt,{htmlFor:"native-session-title",className:"text-[10px] font-medium text-muted-foreground",children:"Task title"}),e.jsx(dt,{id:"native-session-title",type:"text",value:f,onChange:I=>j(I.target.value),placeholder:"Optional",className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px] shadow-none"})]})]}),e.jsx(Xn,{value:v,onChange:I=>{k(""),N(I)},assignTo:A,nodes:t,assignableNodes:u}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(tt,{className:"text-[10px] font-medium text-muted-foreground",children:"Mode"}),e.jsxs($e,{value:M,onValueChange:I=>B(I),children:[e.jsx(qe,{className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px] shadow-none",children:e.jsx(Je,{placeholder:"Select mode"})}),e.jsx(Ve,{children:oh()})]})]})]})]}),e.jsxs("div",{className:L("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",c),children:[i&&e.jsx(X,{type:"button",variant:"ghost",onClick:i,className:"rounded-sm",children:m}),e.jsx(X,{type:"submit",disabled:!ee||D,className:"rounded-sm px-5",children:D?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"h-4 w-4 animate-spin"})," Loading..."]}):d})]})]})}const Ns="__agent-default__";function Pi({agent:t,value:n,onChange:s,triggerClassName:r,contentClassName:a="max-h-80",chip:i=!1}){const l=Uo(t,n);return o.useEffect(()=>{n&&!Vo(t,n)&&s("")},[t,n,s]),e.jsxs($e,{value:n||Ns,onValueChange:c=>s(c===Ns?"":c),children:[e.jsx(qe,{"aria-label":`Model: ${l}`,title:`Model: ${l}`,className:r,children:i?e.jsxs(e.Fragment,{children:[e.jsx(Yo,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:l})]}):e.jsx(Je,{placeholder:"Agent default"})}),e.jsxs(Ve,{className:a,children:[e.jsx(Oe,{value:Ns,className:"py-1 text-[11px]",children:"Agent default"}),Id(t)]})]})}function hh(t){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Model"}),e.jsx(Pi,{...t,triggerClassName:"h-8 rounded-sm border-border/70 bg-background/70"})]})}function Ii(t,n,s=!1){const r=t.trim();if(r)return r;const a=n.trim().split(`
194
- `).map(i=>i.trim()).find(Boolean);return a?a.length>72?`${a.slice(0,69).trimEnd()}...`:a:s?"Image task":""}function fh(t){const n=t.title.trim(),s=Ho(t.agent,t.description),r=s.prompt,a=Ii(t.title,r,t.images.length>0),i=r.trim()||a,l=t.mode??Mn,c=t.model?.trim(),d=c&&Vo(t.agent,c)?c:"",m=s.isGoal?s.commandPrompt:r,p=zo(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:p,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 ph({nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,className:d,footerClassName:m,submitLabel:p="Create chat",cancelLabel:u="Cancel",autoFocus:h=!1,layout:f="default",defaultTaskAgent:j,quickChats:g=[]}){const[w,b]=o.useState(""),[k,y]=o.useState(""),[x,v]=o.useState(0),[N,A]=o.useState(()=>Un(j)),E=o.useRef(!1),[M,B]=o.useState(""),[D,_]=o.useState(Mn),[P,O]=o.useState(i?.trim()??""),W=o.useRef(i!==void 0),[J,Y]=o.useState(""),V=o.useMemo(()=>_i(t,{currentNodeRole:n,leaderNodeId:r}),[t,n,r]),ne=o.useMemo(()=>a&&V.some(re=>re.id===a)?a:s&&V.some(re=>re.id===s)?s:V[0]?.id??"",[V,s,a]),[$,ee]=o.useState(ne),[S,Q]=o.useState(!1),[T,te]=o.useState(!1),{images:R,error:H,fileInputRef:F,pickImages:le,handleFileChange:ie,handlePaste:me,removeImage:Z}=oi(),K=o.useRef(null),I=o.useMemo(()=>V.find(re=>re.id===$)??null,[$,V]),se=!!(s&&I?.id===s),q=kt(N),ae=Rd(D),ye=o.useMemo(()=>Ho(N,k),[N,k]),pe=o.useMemo(()=>$o(N,k),[N,k]),Ze=ye.prompt,Ae=o.useMemo(()=>ye.isGoal||pe?[]:g,[ye.isGoal,pe,g]);o.useEffect(()=>{$&&V.some(re=>re.id===$)||ee(ne)},[$,V,ne]),o.useEffect(()=>{E.current||A(Un(j))},[j]);const ft=o.useCallback(re=>{E.current=!0,A(Un(re))},[]);o.useEffect(()=>{if(W.current){W.current=!1;return}O(Di($)),Y("")},[$]),o.useEffect(()=>{Y("")},[P]),o.useEffect(()=>{v(0)},[k,g,N]);const Re=o.useCallback(re=>{y(re.prompt)},[]),De=o.useCallback(()=>{y(pe?.value??"/goal "),v(0),!(typeof window>"u")&&window.setTimeout(()=>{const re=K.current;re?.focus();const Ne=re?.value.length??0;re?.setSelectionRange(Ne,Ne)},0)},[pe]),He=o.useCallback(async re=>{if(re.preventDefault(),pe){De();return}const Ne=Wn(k,Ae,x);if(Ne){Re(Ne);return}const Te=fh({title:w,description:k,agent:N,model:M,project:P,branch:J,priority:"normal",assignTo:$,mode:D,images:R});if(Te){Q(!0);try{const ve=await ic(Te);l(ve)}catch(ve){ce.error(ve instanceof Error?ve.message:"Failed to create task")}finally{Q(!1)}}},[w,k,N,M,P,J,$,D,R,l,Ae,x,Re,pe,De]),Ke=Ii(w,Ze,R.length>0),je=!pe&&!!(Ke&&N&&$&&(Ze.trim()||R.length>0)),Be=o.useCallback(re=>{if(re.nativeEvent.isComposing)return;if(pe&&(re.key==="ArrowDown"||re.key==="ArrowUp")){re.preventDefault();return}const Ne=No(k,Ae);if(Ne.length>0&&(re.key==="ArrowDown"||re.key==="ArrowUp")){re.preventDefault(),v(Te=>ko(Te,Ne.length,re.key==="ArrowDown"?1:-1));return}if(re.key==="Enter"){if(pe&&!re.shiftKey){re.preventDefault(),De();return}const Te=Wn(k,Ae,x);if(Te&&!re.shiftKey){re.preventDefault(),Re(Te);return}}re.key==="Enter"&&(re.ctrlKey||re.metaKey)&&je&&!S&&(re.preventDefault(),re.currentTarget.form?.requestSubmit())},[De,Re,Ae,je,k,pe,x,S]),G=R.length>0?e.jsx(Wm,{images:R,removeImage:Z}):null,ge=e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Assign to"}),e.jsxs($e,{value:$,onValueChange:ee,children:[e.jsx(qe,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Je,{placeholder:"Select node"})}),e.jsx(Ve,{children:ur(V,s)})]})]}),be=e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Agent"}),e.jsxs($e,{value:N,onValueChange:ft,children:[e.jsx(qe,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Je,{placeholder:"Select agent"})}),e.jsx(Ve,{children:ra()})]})]}),et=e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Mode"}),e.jsxs($e,{value:D,onValueChange:re=>_(re),children:[e.jsx(qe,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Je,{placeholder:"Select mode"})}),e.jsx(Ve,{children:aa()})]})]}),_e=e.jsx(Xn,{value:P,onChange:O,assignTo:$,nodes:t,assignableNodes:V}),rt=e.jsx(ha,{value:J,onChange:Y,project:P,assignTo:$,nodes:t,assignableNodes:V});return f==="composer"?e.jsxs("form",{onSubmit:He,className:L("space-y-4",d),children:[e.jsx("input",{ref:F,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",Te="border-border/70 bg-background/55 text-foreground",ve=N===Un(j),at=D===Mn;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($e,{value:$,onValueChange:ee,children:[e.jsx(qe,{className:L(re,Te,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${I?.name??"unassigned"}`,"aria-label":`Assigned node: ${I?.name??"unassigned"}`,children:I?e.jsxs(e.Fragment,{children:[e.jsx(Pr,{isCurrent:se}),e.jsx("span",{className:"min-w-0 truncate",children:I.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(Je,{placeholder:"Select node"})}),e.jsx(Ve,{children:ur(V,s)})]}),T?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(dt,{id:"task-title-composer",type:"text",value:w,onChange:Pe=>b(Pe.target.value),onKeyDown:Pe=>{(Pe.key==="Enter"||Pe.key==="Escape")&&(Pe.preventDefault(),te(!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(X,{type:"button",variant:"ghost",size:"icon",onClick:()=>te(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(En,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>te(!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:Ke||"Title","aria-label":Ke?`Edit title: ${Ke}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:Ke||"Title"}),e.jsx(Jt,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",ref:K,value:k,onChange:Pe=>y(Pe.target.value),onKeyDown:Be,onPaste:me,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(ma,{agent:N,query:k,onSelect:De}),e.jsx(Xs,{query:k,quickChats:Ae,selectedIndex:x,onActiveIndexChange:v,onSelect:Re}),e.jsxs("div",{className:"chat-composer__rail flex min-w-0 flex-nowrap items-center gap-2 px-3 pb-3",children:[e.jsx(X,{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(or,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsxs($e,{value:N,onValueChange:ft,children:[e.jsxs(qe,{className:L(re,"chat-composer__icon-trigger",ve?Ne:Te),title:`Agent: ${q}`,"aria-label":`Agent: ${q}`,children:[e.jsx(At,{agent:N}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:q})]}),e.jsx(Ve,{children:ra()})]}),e.jsx(Pi,{agent:N,value:M,onChange:B,chip:!0,triggerClassName:L(re,"chat-composer__icon-trigger",M?Te:Ne),contentClassName:"max-h-80 shadow-none"}),e.jsxs($e,{value:D,onValueChange:Pe=>_(Pe),children:[e.jsxs(qe,{className:L(re,"chat-composer__icon-trigger",at?Ne:Te),title:`Mode: ${ae}`,"aria-label":`Mode: ${ae}`,children:[e.jsx(zu,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:ae})]}),e.jsx(Ve,{children:aa()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[c&&e.jsxs(X,{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(ut,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:u})]}),e.jsxs(X,{type:"submit",size:"icon",disabled:!je||S,className:"h-10 w-10 rounded-sm shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[S?e.jsx(fe,{className:"h-4 w-4 animate-spin"}):e.jsx(si,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:S?"Creating chat":p})]})]})]})]}),e.jsx("div",{className:"chat-composer__location flex flex-wrap items-center gap-2 px-1",children:(()=>{const Pe="border-border/40 bg-muted/40 text-foreground/80 hover:bg-muted/60 hover:text-foreground";return e.jsxs(e.Fragment,{children:[e.jsx(Xn,{value:P,onChange:O,assignTo:$,nodes:t,assignableNodes:V,layout:"composer",chipClassName:re,chipActiveClassName:Pe,chipInactiveClassName:Pe,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"}),e.jsx(ha,{value:J,onChange:Y,project:P,assignTo:$,nodes:t,assignableNodes:V,layout:"composer",chipClassName:re,chipActiveClassName:Pe,chipInactiveClassName:Pe,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"})]})})()})]})})(),(G||H)&&e.jsxs("div",{className:"space-y-2 rounded-sm border border-border/60 bg-background/45 p-2.5",children:[G,H&&e.jsx("div",{className:"text-[11px] text-destructive",children:H}),!H&&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:He,className:L("space-y-4",d),children:[e.jsx("input",{ref:F,type:"file",accept:"image/*",multiple:!0,onChange:ie,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{htmlFor:"task-description",className:"text-[11px] font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",ref:K,value:k,onChange:re=>y(re.target.value),onKeyDown:Be,onPaste:me,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(ma,{agent:N,query:k,onSelect:De}),e.jsx(Xs,{query:k,quickChats:Ae,selectedIndex:x,onActiveIndexChange:v,onSelect:Re}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(X,{type:"button",variant:"outline",onClick:le,className:"rounded-sm",children:[e.jsx(or,{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,H&&e.jsx("p",{className:"text-[11px] text-destructive",children:H})]}),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(tt,{htmlFor:"task-title",className:"text-[11px] font-medium",children:"Chat title"}),e.jsx(dt,{id:"task-title",type:"text",value:w,onChange:re=>b(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:Ke?`Will appear as: ${Ke}`:"A title will be generated from the first line of the prompt."})]}),be,e.jsx(hh,{agent:N,value:M,onChange:B}),et]}),_e,rt,ge,e.jsxs("div",{className:L("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",m),children:[c&&e.jsx(X,{type:"button",variant:"ghost",onClick:c,className:"rounded-sm",children:u}),e.jsx(X,{type:"submit",disabled:!je||S,className:"rounded-sm px-5",children:S?"Creating...":p})]})]})}function xh({nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,defaultMode:d="chat",mode:m,onModeChange:p,layout:u="default",className:h,footerClassName:f,autoFocus:j=!1,quickChats:g=[],defaultTaskAgent:w}){const[b,k]=o.useState(d),y=m!==void 0,x=y?m:b,v=N=>{y||k(N),p?.(N)};return e.jsxs("div",{className:L("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(X,{type:"button",variant:x==="chat"?"default":"ghost",onClick:()=>v("chat"),className:"h-7 flex-1 rounded-sm shadow-none",children:[e.jsx(oc,{className:"h-4 w-4"}),"New chat"]}),e.jsxs(X,{type:"button",variant:x==="native"?"default":"ghost",onClick:()=>v("native"),className:"h-7 flex-1 rounded-sm shadow-none",children:[e.jsx(Ar,{className:"h-4 w-4"}),"Load session"]})]}),x==="chat"?e.jsx(ph,{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:j,layout:u,defaultTaskAgent:w,quickChats:g},`${a??""}:${i??""}`):e.jsx(mh,{nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,onCreated:l,onCancel:c,footerClassName:f,autoFocus:j})]})}function gh({onClick:t,running:n}){return e.jsxs(X,{size:"icon",onClick:t,"aria-label":n?"Open composer - task running":"Open composer",title:n?"Task running - open composer":"Open composer",className:L("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(Jt,{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 pa({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 bh({hasVisibleTranscriptEvents:t,hasTranscriptProgress:n,inputCollapsed:s}){return{collapsedButtonRunning:n&&t&&s,showDockedProgress:n&&t&&!s,showInlineProgress:n&&!t}}const cn="72f988bf-86f1-41af-91ab-2d7cd011db47",Ri=`${cn} (MSIT)`;function vh({open:t,onOpenChange:n,onShare:s,onStopShare:r,sharing:a,stopping:i=!1,shareResult:l}){return e.jsx(mt,{open:t,onOpenChange:n,children:e.jsxs(ht,{className:"max-w-md rounded-sm p-4",children:[e.jsx(vt,{className:"sr-only",children:"Share conversation"}),e.jsx(wh,{onOpenChange:n,onShare:s,onStopShare:r,sharing:a,stopping:i,shareResult:l})]})})}function wh({onOpenChange:t,onShare:n,onStopShare:s,sharing:r,stopping:a=!1,shareResult:i}){const[l,c]=o.useState(i?.tenant??cn),[d,m]=o.useState(i?.scope??"chat"),p=i?.url?Do(i.url):null,u=r||a;return o.useEffect(()=>{c(i?.tenant??cn),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(yh,{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(xa,{active:d==="chat",title:"Chat only",description:"Conversation transcript and opening prompt.",onClick:()=>m("chat")}),e.jsx(xa,{active:d==="filesPreview",title:"Chat, files and preview",description:"Transcript plus task output files and HTML preview.",onClick:()=>m("filesPreview")})]})]}),p&&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:p,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none","aria-label":"Shared link"}),e.jsx(X,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-sm text-muted-foreground",onClick:()=>{In(p,"Shared link copied")},"aria-label":"Copy shared link",title:"Copy shared link",children:e.jsx(_o,{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(X,{variant:"outline",onClick:()=>t(!1),disabled:u,className:"h-8 text-xs",children:i?"Done":"Cancel"}),i&&s&&e.jsxs(X,{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(fe,{className:"h-3.5 w-3.5 animate-spin"}),"Stop share"]}),e.jsxs(X,{onClick:()=>{n({tenant:l,scope:d})},disabled:u,className:"h-8 text-xs",children:[r&&e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin"}),i?"Update link":"Share link"]})]})]})}function yh({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 j=f.target;j instanceof Node&&(m.current?.contains(j)||(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 p=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:jh(t)}),e.jsx(st,{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:()=>p(cn),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:Ri}),t===cn&&e.jsx(En,{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(),p(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:()=>p(c),className:"flex h-7 w-7 items-center justify-center rounded-sm hover:bg-background/60",children:e.jsx(En,{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(ut,{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(Jt,{className:"h-3 w-3"})]})})]})]})]})}function jh(t){return t===cn?Ri:t}function xa({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 Nh(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 kh({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(Nu,{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 ${kt(s.targetAgent)}`,children:[e.jsx(Qo,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx(At,{agent:s.targetAgent,className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:kt(s.targetAgent)})]}),e.jsx("div",{className:"break-words [overflow-wrap:anywhere]",children:Nh(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(Sr,{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(X,{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(ut,{className:"h-3 w-3"})})]},s.id)})})]})})}const Sh="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",Ch=[{value:"transcript",label:"Transcript",icon:lc},{value:"files",label:"Files",icon:hn,activeIcon:rs},{value:"diff",label:"Diff",icon:Yn},{value:"preview",label:"Preview",icon:Kd}];function Th({activeTab:t}){return e.jsx(os,{className:"h-auto max-w-full justify-start gap-2 overflow-x-auto rounded-sm !bg-muted/40 !p-0.5 !shadow-none",children:Ch.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:Sh,children:e.jsx(s,{className:"h-3.5 w-3.5","aria-hidden":"true"})},n.value)})})}const Li="pointer-events-auto h-5 w-5 shrink-0 rounded-sm bg-muted/65 text-muted-foreground hover:bg-muted hover:text-foreground",es="h-3.5 w-3.5";function mr({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(Bi,{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(Oi,{operationsOpen:r,onToggleOperations:a,className:"xl:hidden"})]})}function Bi({className:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,onToggleTasks:r}){const a=globalThis.window?.matchMedia("(min-width: 1024px)")?.matches?n:s;return e.jsx(X,{variant:"ghost",size:"icon",onClick:r,title:a?"Hide tasks":"Show tasks","aria-label":a?"Hide tasks":"Show tasks",className:L(Li,t),children:a?e.jsx(Dn,{className:es}):e.jsx(nt,{className:es})})}function Oi({className:t,operationsOpen:n,onToggleOperations:s}){return e.jsx(X,{variant:"ghost",size:"icon",onClick:s,title:n?"Hide cluster":"Show cluster","aria-label":n?"Hide cluster":"Show cluster",className:L(Li,t),children:n?e.jsx(nt,{className:es}):e.jsx(Dn,{className:es})})}const ga="h-7 w-7 rounded-sm border-0 bg-primary/10 text-primary backdrop-blur hover:bg-primary/20 hover:text-primary";function Ah({active:t,onScrollToBottom:n,onScrollToTop:s}){return e.jsxs("div",{className:L("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(X,{type:"button",variant:"ghost",size:"icon",className:ga,onClick:s,"aria-label":"Scroll to top",title:"Scroll to top",children:e.jsx(cc,{className:"h-4 w-4"})}),e.jsx(X,{type:"button",variant:"ghost",size:"icon",className:ga,onClick:n,"aria-label":"Scroll to bottom",title:"Scroll to bottom",children:e.jsx(st,{className:"h-4 w-4"})})]})}function Eh(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 Mh({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(At,{agent:t,className:"h-3 w-3 shrink-0 text-muted-foreground/65","aria-hidden":"true"}),e.jsxs("span",{className:"truncate",children:[kt(t)," to ",kt(n)]}),e.jsx(At,{agent:n,className:"h-3 w-3 shrink-0 text-primary/60","aria-hidden":"true"})]})})}const ba="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",Ut={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:`${ba} mt-0`,action:ba},Dh=30,_h=1600;function Ph({savedScrollTop:t,scrollHeight:n,clientHeight:s}){const r=Math.max(0,n-s);return Math.min(Math.max(0,t??r),r)}function ks(t){return t.scrollHeight-t.scrollTop-t.clientHeight<Dh}function va({explicitBottomStickUntil:t,now:n,wasAtBottom:s}){return s||t>n}function Ss(t,n){return!!(n&&(t===n||t.contains(n)))}function Cs(t){const n=t.ownerDocument.getSelection();if(!n||n.isCollapsed||n.rangeCount===0)return!1;if(Ss(t,n.anchorNode)||Ss(t,n.focusNode))return!0;for(let s=0;s<n.rangeCount;s+=1)if(Ss(t,n.getRangeAt(s).commonAncestorContainer))return!0;return!1}function Ih({atTop:t,inputCollapseDisabled:n,scrollingUp:s}){return!n&&(s||t)}function Rh({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),p=o.useRef(new Map),u=o.useRef(0),h=o.useRef(!0),f=o.useCallback((x=c.current)=>{const v=l.current;!v||!x||(p.current.set(x,v.scrollTop),m.current=v.scrollTop,h.current=ks(v))},[]),j=o.useCallback((x=c.current)=>{const v=l.current;!v||!x||(v.scrollTop=Ph({savedScrollTop:p.current.get(x),scrollHeight:v.scrollHeight,clientHeight:v.clientHeight}),m.current=v.scrollTop,h.current=ks(v))},[]),g=o.useCallback((x,v=c.current)=>{x.scrollTop=x.scrollHeight,m.current=x.scrollTop,h.current=!0,v&&p.current.set(v,x.scrollTop)},[]),w=o.useCallback((x=c.current)=>{const v=l.current;u.current=Date.now()+_h,v&&(g(v,x),requestAnimationFrame(()=>{g(v,x),requestAnimationFrame(()=>g(v,x))}))},[g]),b=o.useCallback((x=c.current)=>{const v=l.current;u.current=0,v&&(v.scrollTop=0,m.current=0,h.current=!1,x&&p.current.set(x,0))},[]),k=o.useCallback(x=>{const v=x.currentTarget,N=m.current,A=v.scrollTop<N&&N-v.scrollTop>10,E=v.scrollTop<=0,M=Cs(v);if(f(),M){u.current=0;return}if(!d.current){if(ks(v)){i(!1),d.current=!0,setTimeout(()=>{d.current=!1},300);return}(A||E)&&(u.current=0,Ih({atTop:E,inputCollapseDisabled:r,scrollingUp:A})&&i(!0))}},[r,f,i]),y=o.useCallback(x=>{t==="transcript"&&f(),a(x),x==="transcript"&&requestAnimationFrame(()=>j())},[t,j,f,a]);return o.useLayoutEffect(()=>{r&&i(!1)},[r,i]),o.useLayoutEffect(()=>{const x=c.current;x&&x!==n&&f(x),c.current=n,t==="transcript"&&requestAnimationFrame(()=>j(n))},[n,t,j,f]),o.useLayoutEffect(()=>{const x=l.current;if(!x||t!=="transcript"||!n)return;const v=va({explicitBottomStickUntil:u.current,now:Date.now(),wasAtBottom:h.current});if(Cs(x)){u.current=0,f(n);return}v&&g(x,n),f(n)},[n,t,s,f,g]),o.useLayoutEffect(()=>{const x=l.current,v=x?.firstElementChild;if(!x||!v||t!=="transcript"||typeof ResizeObserver>"u")return;const N=new ResizeObserver(()=>{if(Cs(x)){u.current=0,f();return}va({explicitBottomStickUntil:u.current,now:Date.now(),wasAtBottom:h.current})?g(x):f()});return N.observe(x),N.observe(v),()=>N.disconnect()},[t,n,f,g]),{handleTranscriptScroll:k,handleTranscriptTabChange:y,scrollTranscriptToBottom:w,scrollTranscriptToTop:b,transcriptScrollRef:l}}function Fi(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 Lh="harness";function Bh(t){return typeof t=="object"&&t!==null}function Oh(t){return typeof t=="string"&&t.trim().length>0?t.trim():""}function Fh(t){return Bh(t.agentSessions)?Object.keys(t.agentSessions).map(n=>n.trim()).filter(Boolean):[]}function zi(t){return Oh(t.payload.activeAgent)||t.agent}function Ui(t){return new Set([t.agent,zi(t),...Fh(t.payload)].filter(Boolean)).size>1}function $i(t){return Ui(t)?Lh:t.agent}const zh=o.lazy(async()=>({default:(await gr(()=>import("./FilesTab-By5MpB3q.js"),__vite__mapDeps([0,1,2,3,4,5]))).FilesTab})),Uh=o.lazy(async()=>({default:(await gr(()=>import("./PreviewTab-C_SvaL2_.js").then(n=>n.c),__vite__mapDeps([6,1,2]))).PreviewTab})),$h=o.lazy(async()=>({default:(await gr(()=>import("./DiffTab-B4hRGo1c.js"),__vite__mapDeps([7,1,2,5,4,3,6]))).DiffTab}));function qh({onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,cluster:i,activeTab:l,setActiveTab:c,creatingTask:d,createMode:m,createDefaults:p,activeTask:u,assignedNode:h,taskLoading:f,transcriptLoading:j,taskError:g,displayEvents:w,initialPromptAlreadyInLogs:b,initialPrompt:k,supportsFollowUp:y,taskUnavailable:x,chatDisabled:v,chatDisabledReason:N,questionBypassEnabled:A,isRunning:E,isStarting:M,hasPendingFollowUp:B,canCancel:D,canRetry:_,onRetry:P,onCancel:O,onReloadNativeTranscript:W,onShareTask:J,onStopShareTask:Y,onStartCreateTask:V,onCancelCreateTask:ne,onCreateTask:$,onSendMessage:ee,onCancelQueuedMessage:S,onQuestionBypassChange:Q,onSubmitQuestionResponse:T,quickChats:te=[]}){const[R,H]=o.useState(!1),[F,le]=o.useState(!1),[ie,me]=o.useState(!1),[Z,K]=o.useState(!1),[I,se]=o.useState(!1),[q,ae]=o.useState({}),[ye,pe]=o.useState(new Set),[Ze,Ae]=o.useState(new Set),[ft,Re]=o.useState(null),[De,He]=o.useState(null),Ke=u?.effectiveProjectPath??u?.project??"default workspace",je=u?h?.name??er(u.assignedTo,i?.nodes,u.assignedNodeName):"unassigned",Be=u?$i(u):"",G=u?zi(u):"",ge=u&&Ui(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...",et=u?[{label:"Working dir",value:Ke,mono:!0},...u.branch?[{label:"Branch",value:u.branch,mono:!0}]:[],{label:"Agent",value:Be,mono:!0},{label:"Node",value:je}]:[],_e=!!(k&&!b),rt=_e||w.length>0,re=E&&rt,Ne=(M||B||E)&&!re,Te=re?"The agent is still working on this conversation.":Ne?be:null,{collapsedButtonRunning:ve,showDockedProgress:at,showInlineProgress:Pe}=bh({hasTranscriptProgress:!!Te,hasVisibleTranscriptEvents:rt,inputCollapsed:R}),_t=u?.conversationKind==="nativeSession",pt=Ld(u),pn=j?"Loading transcript":_t?"No transcript imported":"Transcript is warming up",en=j?"Loading transcript...":_t?"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.",St=u?.queuedMessages??[],wt=o.useMemo(()=>Bd(w),[w]),xn=o.useMemo(()=>{let he=u?.agent??"";return wt.map(ke=>{const Ge=Eh(ke.event);if(Ge)return he=Ge.toAgent,{...ke,agent:he,handoff:Ge};const Ue=typeof ke.event.agent=="string"&&ke.event.agent.trim()?ke.event.agent.trim():he;return{...ke,agent:Ue,handoff:null}})},[u?.agent,wt]),gn=o.useMemo(()=>{const he=u?.assignedTo?u.assignedTo===i?.self?.id?h?.supportedAgents??i.self.supportedAgents:h?.supportedAgents:i?.self?.supportedAgents;return dc({nodeSupportedAgents:he,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]),Pt=o.useMemo(()=>wt.findIndex(({event:he})=>Vh(he)),[wt]),Ft=o.useMemo(()=>Od("transcript",wt.map(he=>he.event)),[wt]),tn=u&&!ye.has(u.id)?q[u.id]??u.activeShare??null:null,Ct=u?.id??null,nn=`${Ct??"none"}:${w.length}:${St.length}:${_e?1:0}:${j?1:0}:${Pe?1:0}`,{handleTranscriptScroll:Fe,handleTranscriptTabChange:ot,scrollTranscriptToBottom:yt,scrollTranscriptToTop:Tt,transcriptScrollRef:U}=Rh({activeTab:l,activeTaskId:Ct,contentVersion:nn,inputCollapseDisabled:!!Te,setActiveTab:c,setInputCollapsed:H}),{markScrollbarActive:ze,scrollbarActive:Ie}=Fi(),We=o.useCallback(he=>{ze(),Fe(he)},[Fe,ze]),Qe=o.useCallback(he=>{Re(ke=>({path:he,requestId:(ke?.requestId??0)+1})),ot("files")},[ot]),sn=o.useCallback(he=>{He(ke=>({path:he,requestId:(ke?.requestId??0)+1})),ot("preview")},[ot]),xe=o.useCallback((he,ke)=>{yt(),ee(he,ke)},[ee,yt]);return o.useEffect(()=>{Re(null),He(null)},[Ct]),d?e.jsx(Hh,{onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,cluster:i,defaultMode:m,createDefaults:p,onCancel:ne,onCreated:$,quickChats:te}):!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(mr,{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(fe,{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(fe,{className:"h-3.5 w-3.5 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):u?e.jsxs(_r,{value:l,onValueChange:ot,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(Bi,{desktopTasksOpen:n,mobileTasksPanelOpen:s,onToggleTasks:t,className:"lg:hidden"}),e.jsx(Oi,{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(Io,{status:u.status,isNative:_t}),pt&&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(qo,{className:"h-3 w-3","aria-hidden":"true"}),"Goal"]}),u.priority!=="normal"&&e.jsx(uc,{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(Th,{activeTab:l}),x&&e.jsx(Le,{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:mc(u.updatedAt)}),_&&e.jsxs(X,{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(Pu,{className:"h-3.5 w-3.5"}),"Retry"]}),_t&&W&&e.jsx(X,{variant:"ghost",size:"icon",onClick:W,disabled:j,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(ni,{className:L("h-3.5 w-3.5",j&&"animate-spin")})}),e.jsx(X,{type:"button",variant:"ghost",size:"icon",disabled:x,title:x?"Unavailable tasks cannot be shared.":"Share conversation","aria-label":x?"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:()=>me(!0),children:e.jsx(Zn,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsx(bt,{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:L("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",Ie&&"scrollbar-line-active"),onScroll:We,children:e.jsxs("div",{"data-transcript-scroll-content":"true",className:"mx-auto flex max-w-[72rem] flex-col gap-4",children:[_e&&k&&e.jsx(oa,{event:k,agent:u.agent,sentAsGoal:pt,taskRootPath:u.effectiveProjectPath,onOpenFilePath:Qe,questionBypassEnabled:A,onQuestionBypassChange:Q,onSubmitQuestionResponse:T,questionResponseDisabled:!y||v}),xn.map(({event:he,subItems:ke,agent:Ge,handoff:Ue},zt)=>Ue?e.jsx(Mh,{fromAgent:Ue.fromAgent,toAgent:Ue.toAgent},Ft[zt]):e.jsx(oa,{event:he,agent:Ge,subItems:ke,sentAsGoal:pt&&!_e&&zt===Pt,taskRootPath:u.effectiveProjectPath,onOpenFilePath:Qe,questionBypassEnabled:A,onQuestionBypassChange:Q,onSubmitQuestionResponse:T,questionResponseDisabled:!y||v},Ft[zt])),!rt&&!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:pn}),e.jsx("div",{className:"mt-2 text-[11px] leading-6 text-muted-foreground",children:en})]}),(!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&&!Ze.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:()=>Ae(he=>new Set(he).add(u.id)),className:"rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(ut,{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})]})]}),Pe&&Te&&e.jsx(pa,{children:Te})]})})}),e.jsx(Ah,{active:Ie,onScrollToBottom:()=>yt(),onScrollToTop:()=>Tt()}),at&&Te&&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(pa,{children:Te})})}),y?e.jsxs(e.Fragment,{children:[R&&e.jsx(gh,{running:ve,onClick:()=>{H(!1),yt(),requestAnimationFrame(()=>document.querySelector('[data-chat-input-textarea="true"]')?.focus())}}),e.jsxs("div",{className:`shrink-0 ${R?"hidden":""}`,children:[e.jsx(kh,{messages:St,onCancelMessage:S}),e.jsx(Nm,{onSend:xe,disabled:v,disabledReason:N,contextItems:et,agent:u.agent,currentAgent:ge,taskId:u.id,availableAgents:gn,model:typeof u.payload.model=="string"?u.payload.model:null,placeholder:v?N:E?"Queue a message for the next turn...":"Continue the conversation...",running:E||M||B,onStop:D?()=>le(!0):void 0,quickChats:te})]})]}):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(bt,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(vs,{label:"Loading files..."}),children:e.jsx(zh,{taskId:u.id,requestedFilePath:ft?.path??null,requestedFileRequestId:ft?.requestId??0,onPreviewFile:sn})})}),e.jsx(bt,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(vs,{label:"Loading preview..."}),children:e.jsx(Uh,{taskId:u.id,requestedEntryPath:De?.path??null,requestedEntryRequestId:De?.requestId??0})})}),e.jsx(bt,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(vs,{label:"Loading diff..."}),children:e.jsx($h,{taskId:u.id})})}),e.jsx($t,{open:F,onOpenChange:le,children:e.jsxs(qt,{className:Ut.content,children:[e.jsxs(Vt,{className:Ut.header,children:[e.jsx(Ht,{className:Ut.title,children:"Stop this task?"}),e.jsx(Kt,{className:Ut.description,children:"The task will stop and move to a cancelled state."})]}),e.jsxs(Gt,{className:Ut.footer,children:[e.jsx(Wt,{className:Ut.cancel,children:"Keep running"}),e.jsx(Qt,{className:Ut.action,onClick:O,children:"Stop task"})]})]})}),e.jsx(vh,{open:ie,onOpenChange:me,sharing:Z,stopping:I,shareResult:tn,onShare:async he=>{if(!u)return null;K(!0);try{const ke=await J(he);return ke?.url&&(ae(Ge=>({...Ge,[u.id]:ke})),pe(Ge=>{const Ue=new Set(Ge);return Ue.delete(u.id),Ue})),ke}finally{K(!1)}},onStopShare:async()=>{if(!u)return!1;se(!0);try{const he=await Y();return he!==!1&&(ae(ke=>{const Ge={...ke};return delete Ge[u.id],Ge}),pe(ke=>new Set(ke).add(u.id))),he}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(mr,{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(Po,{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(X,{onClick:()=>V(),className:"mt-4 h-8 rounded-sm px-3",children:[e.jsx(Ln,{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 Vh(t){return t.type!=="user"||t.isMeta===!0||t.isSidechain===!0?!1:!!Cr(t)?.some(s=>s.type==="text"||s.type==="image")}function Hh({onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,cluster:i,defaultMode:l,createDefaults:c,onCancel:d,onCreated:m,quickChats:p}){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:Ln},{value:"native",label:"Load session",icon:Ar}].map(j=>{const g=j.icon,w=j.value===u;return e.jsxs("button",{type:"button",onClick:()=>h(j.value),"aria-pressed":w,className:L("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",w?"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:j.label})]},j.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(mr,{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(xh,{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:p})})})]})}function Kh({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 hc({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(ht,{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(Mt,{className:"space-y-1 text-left",children:[e.jsx(vt,{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(tt,{htmlFor:"leader-endpoint",children:"Leader Node URL"}),e.jsx(Le,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),e.jsx(dt,{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(br,{className:"border-t border-border/60 pt-3",children:e.jsx(X,{type:"submit",disabled:!n.trim()||r,className:"rounded-sm",children:r?"Joining...":"Join node"})})]})]})})}function Gh({open:t,onOpenChange:n,onAdded:s}){return e.jsx(mt,{open:t,onOpenChange:n,children:e.jsx(Kh,{onAdded:()=>{n(!1),s()}})})}const Wh="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",Qh="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",Yh="h-2.5 w-2.5";function qi({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:L("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 Jh({className:t,label:n,onToggle:s,side:r,visible:a}){const i=r==="left"?a?Dn:nt:a?nt:Dn;return e.jsx("button",{type:"button","aria-label":n,title:n,onClick:s,className:L(Wh,t),children:e.jsx("span",{className:Qh,"aria-hidden":"true",children:e.jsx(i,{className:Yh,strokeWidth:2.1})})})}function wa({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:L("group absolute top-0 z-30 hidden h-full w-4",d,t),children:[r&&e.jsx(qi,{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(Jh,{side:l,visible:c,label:n,onToggle:s,className:L(m,"left-1/2 -translate-x-1/2 group-hover:opacity-100")})]})}function Zh({conversationPanel:t,desktopTasksOpen:n,mobileTaskSidebar:s,mobileTasksPanelOpen:r,mobileTasksPanelRef:a,operationsOpen:i,operationsPanelRef:l,operationsSidecar:c,panelResize:d,taskSidebar:m,terminalPanel:p,onCloseOperations:u,onCloseTaskList:h,onToggleOperations:f,onToggleTasks:j}){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(wa,{screen:"lg",side:"left",visible:n,label:n?"Hide tasks":"Show tasks",onToggle:j,panel:n?"tasks":void 0,panelResize:d,className:n?"left-[var(--dashboard-tasks-width)] -translate-x-1/2":"left-0"}),e.jsx("div",{className:L("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}),p&&e.jsxs("div",{className:"relative h-[var(--dashboard-terminal-height)] min-h-0 shrink-0",children:[e.jsx(qi,{panel:"terminal",orientation:"horizontal",label:"Resize terminal panel",panelResize:d,className:"-top-1 left-0 h-2 w-full cursor-row-resize"}),p]})]}),e.jsx(wa,{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:L("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 Xh=10,Yt="__all__";function lt(t){return"session"in t}function ya(t,n){return n&&t.some(s=>s.id===n)?n:t[0]?.id??""}function Ts(t){return t&&(Di(t.id)||t.workDir)||""}function qn(t,n,s){let r=!1;const a=t.map(i=>lt(i)&&i.session.id===s.id?(r=!0,{...i,nodeName:n,session:s}):i);return hr(r?a:[...a,{id:`session-${s.id}`,nodeName:n,session:s}])}function Vi(t,n){return t.filter(lt).filter(s=>s.session.nodeId===n).sort((s,r)=>r.session.startedAt-s.session.startedAt)}function ef(t){const n=t.filter(lt).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 tf(t,n){return!!(t&&n&&!t.contains(n))}function nf(t,n,s){if(s===Yt)return s;const r=Vi(t,n);return r.some(a=>a.session.id===s)?s:r[0]?.session.id??Yt}function sf(t,n,s){return s===Yt?t.filter(r=>!lt(r)||r.session.nodeId===n):t.filter(r=>lt(r)&&r.session.nodeId===n&&r.session.id===s)}function hr(t){const n=t.map((r,a)=>({entry:r,index:a})).filter(({entry:r})=>lt(r)&&r.session.status!=="running").sort((r,a)=>!lt(r.entry)||!lt(a.entry)?0:a.entry.session.startedAt-r.entry.session.startedAt||a.index-r.index),s=new Set(n.slice(0,Xh).map(({entry:r})=>lt(r)?r.session.id:""));return t.filter(r=>!lt(r)||r.session.status==="running"||s.has(r.session.id))}function fr(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 rf(t){const n=t.session.command.length>48?`${t.session.command.slice(0,45)}...`:t.session.command;return`${t.nodeName} - ${fr(t.session)} - ${n}`}function Hi(t,n=48){return t.length>n?`${t.slice(0,n-3)}...`:t}function af(t,n){return n===Yt?"All sessions":t?Hi(t.session.command,34):"Command session"}function ja(t){return t.status==="stopped"?"":t.stderr}function of({nodes:t,defaultNodeId:n,onClose:s,initialHistory:r=[]}){const[a,i]=o.useState(()=>ya(t,n)),l=o.useMemo(()=>t.find(T=>T.id===a)??t[0]??null,[t,a]),[c,d]=o.useState(()=>Ts(l)),[m,p]=o.useState(""),[u,h]=o.useState(()=>hr(r)),[f,j]=o.useState(Yt),[g,w]=o.useState(!1),[b,k]=o.useState(!1),[y,x]=o.useState(!1),[v,N]=o.useState(!1),[A,E]=o.useState(!1),M=o.useRef(null),B=o.useRef(null),D=o.useMemo(()=>t.find(T=>T.id===a)??t[0]??null,[t,a]),_=o.useMemo(()=>Vi(u,D?.id??""),[u,D]),P=o.useMemo(()=>ef(_),[_]),O=o.useMemo(()=>_.find(T=>T.session.id===f),[f,_]),W=o.useMemo(()=>sf(u,D?.id??"",f),[u,D,f]),J=o.useRef(D?.id??"");o.useEffect(()=>{a&&t.some(T=>T.id===a)||i(ya(t,n))},[n,t,a]),o.useEffect(()=>{const T=D?.id??"";J.current!==T&&(J.current=T,d(Ts(D)))},[D]),o.useEffect(()=>{j(T=>nf(u,D?.id??"",g?T:""))},[u,D,g]),o.useEffect(()=>{M.current?.scrollTo({top:M.current.scrollHeight})},[u]),o.useEffect(()=>{let T=!1;async function te(){const R=await Promise.allSettled(t.map(async H=>({node:H,response:await pc(H.id)})));T||h(H=>R.reduce((F,le)=>le.status!=="fulfilled"?F:le.value.response.sessions.reduce((ie,me)=>qn(ie,le.value.node.name,me),F),H))}return t.length>0&&te(),()=>{T=!0}},[t]),o.useEffect(()=>{const T=u.filter(lt).filter(R=>R.session.status==="running");if(T.length===0)return;const te=window.setInterval(()=>{for(const R of T)fc(R.session.nodeId,R.session.id).then(H=>h(F=>qn(F,R.nodeName,H))).catch(()=>{})},1e3);return()=>window.clearInterval(te)},[u]);const Y=o.useRef(null);async function V(T){if(T.preventDefault(),!D||!m.trim()||A)return;const te=m.trim(),R=D.name;E(!0),p("");try{const H=await gc(D.id,{command:te,...c.trim()?{cwd:c.trim()}:{}});h(F=>qn(F,R,H)),j(H.id),w(!0)}catch(H){h(F=>[...F,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,nodeName:R,command:te,error:H instanceof Error?H.message:"Command failed"}])}finally{E(!1)}}async function ne(T,te){T.stopPropagation();const R=await xc(te.session.nodeId,te.session.id);h(H=>qn(H,te.nodeName,R))}function $(T){j(T),w(!0),k(!1)}function ee(T){b&&tf(B.current,T.target)&&k(!1)}function S(T,te,R,H,F){return e.jsxs("div",{className:"border-t border-border/60 py-1",children:[e.jsxs("button",{type:"button",onClick:H,"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(st,{className:L("h-3 w-3 transition-transform",R&&"-rotate-90")})]}),!R&&(te.length>0?te.map(Q):e.jsx("div",{className:"node-terminal__control px-2 py-1 text-muted-foreground",children:F}))]})}function Q(T){const te=f===T.session.id,R=T.session.status==="running";return e.jsxs("div",{className:L("node-terminal__control group flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/65",te&&"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:L("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(fe,{className:"h-3 w-3 animate-spin"}):T.session.status==="exited"?e.jsx(tr,{className:"h-3 w-3"}):e.jsx(gs,{className:"h-3 w-3"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-foreground",children:Hi(T.session.command,44)}),e.jsxs("span",{className:"node-terminal__small block truncate text-muted-foreground",children:[T.nodeName," · ",fr(T.session)]})]})]}),R&&e.jsx("button",{type:"button",onClick:H=>{ne(H,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:ee,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(ut,{className:"h-3.5 w-3.5"})}):e.jsx(Gr,{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:B,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":"Command session","aria-expanded":b,title:O?rf(O):"All sessions",onClick:()=>k(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:af(O,f)}),e.jsx(st,{className:L("h-3 w-3 shrink-0 text-muted-foreground transition-transform",b&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!b,className:L("absolute right-0 bottom-9 z-30 w-[19rem] overflow-hidden rounded-xl border border-border/70 bg-popover text-popover-foreground shadow-xl",!b&&"hidden"),children:e.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[e.jsxs("button",{type:"button",onClick:()=>$(Yt),className:L("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===Yt&&"bg-primary/10 text-primary"),children:[e.jsx(Gr,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:"All sessions"})]}),S("Active",P.active,y,()=>x(T=>!T),"No active sessions"),S("Completed",P.completed,v,()=>N(T=>!T),"No completed sessions")]})})]}),e.jsx("select",{value:D?.id??"",onChange:T=>{i(T.target.value),w(!1),d(Ts(t.find(te=>te.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(Xn,{value:c,onChange:d,assignTo:D?.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:M,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:[W.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:W.map(T=>lt(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:L("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(fe,{className:"h-3 w-3 animate-spin"}):T.session.status==="exited"?e.jsx(tr,{className:"h-3 w-3"}):e.jsx(gs,{className:"h-3 w-3"}),fr(T.session)]}),T.session.status==="running"&&e.jsx("button",{type:"button",onClick:te=>{ne(te,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}),ja(T.session)&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:ja(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(gs,{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:V,className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"shrink-0 text-primary select-none",children:D?`${D.name}$`:"$"}),e.jsx("input",{ref:Y,value:m,onChange:T=>p(T.target.value),disabled:!D||A,placeholder:D?"":"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:!D||!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(fe,{className:"h-3 w-3 animate-spin"}):e.jsx(ss,{className:"h-3 w-3"})})]})]})]})})}var ln={},As,Na;function lf(){return Na||(Na=1,As=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),As}var Es={},Lt={},ka;function Zt(){if(ka)return Lt;ka=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 Lt.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},Lt.getSymbolTotalCodewords=function(r){return n[r]},Lt.getBCHDigit=function(s){let r=0;for(;s!==0;)r++,s>>>=1;return r},Lt.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');t=r},Lt.isKanjiModeEnabled=function(){return typeof t<"u"},Lt.toSJIS=function(r){return t(r)},Lt}var Ms={},Sa;function Ir(){return Sa||(Sa=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}}})(Ms)),Ms}var Ds,Ca;function cf(){if(Ca)return Ds;Ca=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++}},Ds=t,Ds}var _s,Ta;function df(){if(Ta)return _s;Ta=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]},_s=t,_s}var Ps={},Aa;function uf(){return Aa||(Aa=1,(function(t){const n=Zt().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}})(Ps)),Ps}var Is={},Ea;function mf(){if(Ea)return Is;Ea=1;const t=Zt().getSymbolSize,n=7;return Is.getPositions=function(r){const a=t(r);return[[0,0],[a-n,0],[0,a-n]]},Is}var Rs={},Ma;function hf(){return Ma||(Ma=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,p=null;for(let u=0;u<i;u++){c=d=0,m=p=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===p?d++:(d>=5&&(l+=n.N1+(d-5)),p=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 p=0;p<i;p++)c=c<<1&2047|a.get(m,p),p>=10&&(c===1488||c===93)&&l++,d=d<<1&2047|a.get(p,m),p>=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 p=t.getPenaltyN1(a)+t.getPenaltyN2(a)+t.getPenaltyN3(a)+t.getPenaltyN4(a);t.applyMask(m,a),p<d&&(d=p,c=m)}return c}})(Rs)),Rs}var Vn={},Da;function Ki(){if(Da)return Vn;Da=1;const t=Ir(),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 Vn.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}},Vn.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}},Vn}var Ls={},kn={},_a;function ff(){if(_a)return kn;_a=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]})(),kn.log=function(r){if(r<1)throw new Error("log("+r+")");return n[r]},kn.exp=function(r){return t[r]},kn.mul=function(r,a){return r===0||a===0?0:t[n[r]+n[a]]},kn}var Pa;function pf(){return Pa||(Pa=1,(function(t){const n=ff();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}})(Ls)),Ls}var Bs,Ia;function xf(){if(Ia)return Bs;Ia=1;const t=pf();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},Bs=n,Bs}var Os={},Fs={},zs={},Ra;function Gi(){return Ra||(Ra=1,zs.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}),zs}var Nt={},La;function Wi(){if(La)return Nt;La=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
195
- ]))+`;Nt.KANJI=new RegExp(s,"g"),Nt.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Nt.BYTE=new RegExp(r,"g"),Nt.NUMERIC=new RegExp(t,"g"),Nt.ALPHANUMERIC=new RegExp(n,"g");const a=new RegExp("^"+s+"$"),i=new RegExp("^"+t+"$"),l=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Nt.testKanji=function(d){return a.test(d)},Nt.testNumeric=function(d){return i.test(d)},Nt.testAlphanumeric=function(d){return l.test(d)},Nt}var Ba;function Xt(){return Ba||(Ba=1,(function(t){const n=Gi(),s=Wi();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}}})(Fs)),Fs}var Oa;function gf(){return Oa||(Oa=1,(function(t){const n=Zt(),s=Ki(),r=Ir(),a=Xt(),i=Gi(),l=7973,c=n.getBCHDigit(l);function d(h,f,j){for(let g=1;g<=40;g++)if(f<=t.getCapacity(g,j,h))return g}function m(h,f){return a.getCharCountIndicator(h,f)+4}function p(h,f){let j=0;return h.forEach(function(g){const w=m(g.mode,f);j+=w+g.getBitsLength()}),j}function u(h,f){for(let j=1;j<=40;j++)if(p(h,j)<=t.getCapacity(j,f,a.MIXED))return j}t.from=function(f,j){return i.isValid(f)?parseInt(f,10):j},t.getCapacity=function(f,j,g){if(!i.isValid(f))throw new Error("Invalid QR Code version");typeof g>"u"&&(g=a.BYTE);const w=n.getSymbolTotalCodewords(f),b=s.getTotalCodewordsCount(f,j),k=(w-b)*8;if(g===a.MIXED)return k;const y=k-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,j){let g;const w=r.from(j,r.M);if(Array.isArray(f)){if(f.length>1)return u(f,w);if(f.length===0)return 1;g=f[0]}else g=f;return d(g.mode,g.getLength(),w)},t.getEncodedBits=function(f){if(!i.isValid(f)||f<7)throw new Error("Invalid QR Code version");let j=f<<12;for(;n.getBCHDigit(j)-c>=0;)j^=l<<n.getBCHDigit(j)-c;return f<<12|j}})(Os)),Os}var Us={},Fa;function bf(){if(Fa)return Us;Fa=1;const t=Zt(),n=1335,s=21522,r=t.getBCHDigit(n);return Us.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},Us}var $s={},qs,za;function vf(){if(za)return qs;za=1;const t=Xt();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))},qs=n,qs}var Vs,Ua;function wf(){if(Ua)return Vs;Ua=1;const t=Xt(),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)},Vs=s,Vs}var Hs,$a;function yf(){if($a)return Hs;$a=1;const t=Xt();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)},Hs=n,Hs}var Ks,qa;function jf(){if(qa)return Ks;qa=1;const t=Xt(),n=Zt();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]+`
196
- Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),r.put(i,13)}},Ks=s,Ks}var Gs={exports:{}},Va;function Nf(){return Va||(Va=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,p,u,h,f,j,g,w;!c.empty();){d=c.pop(),m=d.value,u=d.cost,h=s[m]||{};for(p in h)h.hasOwnProperty(p)&&(f=h[p],j=u+f,g=l[p],w=typeof l[p]>"u",(w||g>j)&&(l[p]=j,c.push(p,j),i[p]=m))}if(typeof a<"u"&&typeof l[a]>"u"){var b=["Could not find a path from ",r," to ",a,"."].join("");throw new Error(b)}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})(Gs)),Gs.exports}var Ha;function kf(){return Ha||(Ha=1,(function(t){const n=Xt(),s=vf(),r=wf(),a=yf(),i=jf(),l=Wi(),c=Zt(),d=Nf();function m(b){return unescape(encodeURIComponent(b)).length}function p(b,k,y){const x=[];let v;for(;(v=b.exec(y))!==null;)x.push({data:v[0],index:v.index,mode:k,length:v[0].length});return x}function u(b){const k=p(l.NUMERIC,n.NUMERIC,b),y=p(l.ALPHANUMERIC,n.ALPHANUMERIC,b);let x,v;return c.isKanjiModeEnabled()?(x=p(l.BYTE,n.BYTE,b),v=p(l.KANJI,n.KANJI,b)):(x=p(l.BYTE_KANJI,n.BYTE,b),v=[]),k.concat(y,x,v).sort(function(A,E){return A.index-E.index}).map(function(A){return{data:A.data,mode:A.mode,length:A.length}})}function h(b,k){switch(k){case n.NUMERIC:return s.getBitsLength(b);case n.ALPHANUMERIC:return r.getBitsLength(b);case n.KANJI:return i.getBitsLength(b);case n.BYTE:return a.getBitsLength(b)}}function f(b){return b.reduce(function(k,y){const x=k.length-1>=0?k[k.length-1]:null;return x&&x.mode===y.mode?(k[k.length-1].data+=y.data,k):(k.push(y),k)},[])}function j(b){const k=[];for(let y=0;y<b.length;y++){const x=b[y];switch(x.mode){case n.NUMERIC:k.push([x,{data:x.data,mode:n.ALPHANUMERIC,length:x.length},{data:x.data,mode:n.BYTE,length:x.length}]);break;case n.ALPHANUMERIC:k.push([x,{data:x.data,mode:n.BYTE,length:x.length}]);break;case n.KANJI:k.push([x,{data:x.data,mode:n.BYTE,length:m(x.data)}]);break;case n.BYTE:k.push([{data:x.data,mode:n.BYTE,length:m(x.data)}])}}return k}function g(b,k){const y={},x={start:{}};let v=["start"];for(let N=0;N<b.length;N++){const A=b[N],E=[];for(let M=0;M<A.length;M++){const B=A[M],D=""+N+M;E.push(D),y[D]={node:B,lastCount:0},x[D]={};for(let _=0;_<v.length;_++){const P=v[_];y[P]&&y[P].node.mode===B.mode?(x[P][D]=h(y[P].lastCount+B.length,B.mode)-h(y[P].lastCount,B.mode),y[P].lastCount+=B.length):(y[P]&&(y[P].lastCount=B.length),x[P][D]=h(B.length,B.mode)+4+n.getCharCountIndicator(B.mode,k))}}v=E}for(let N=0;N<v.length;N++)x[v[N]].end=0;return{map:x,table:y}}function w(b,k){let y;const x=n.getBestModeForData(b);if(y=n.from(k,x),y!==n.BYTE&&y.bit<x.bit)throw new Error('"'+b+'" cannot be encoded with mode '+n.toString(y)+`.
197
- Suggested mode is: `+n.toString(x));switch(y===n.KANJI&&!c.isKanjiModeEnabled()&&(y=n.BYTE),y){case n.NUMERIC:return new s(b);case n.ALPHANUMERIC:return new r(b);case n.KANJI:return new i(b);case n.BYTE:return new a(b)}}t.fromArray=function(k){return k.reduce(function(y,x){return typeof x=="string"?y.push(w(x,null)):x.data&&y.push(w(x.data,x.mode)),y},[])},t.fromString=function(k,y){const x=u(k,c.isKanjiModeEnabled()),v=j(x),N=g(v,y),A=d.find_path(N.map,"start","end"),E=[];for(let M=1;M<A.length-1;M++)E.push(N.table[A[M]].node);return t.fromArray(f(E))},t.rawSplit=function(k){return t.fromArray(u(k,c.isKanjiModeEnabled()))}})($s)),$s}var Ka;function Sf(){if(Ka)return Es;Ka=1;const t=Zt(),n=Ir(),s=cf(),r=df(),a=uf(),i=mf(),l=hf(),c=Ki(),d=xf(),m=gf(),p=bf(),u=Xt(),h=kf();function f(N,A){const E=N.size,M=i.getPositions(A);for(let B=0;B<M.length;B++){const D=M[B][0],_=M[B][1];for(let P=-1;P<=7;P++)if(!(D+P<=-1||E<=D+P))for(let O=-1;O<=7;O++)_+O<=-1||E<=_+O||(P>=0&&P<=6&&(O===0||O===6)||O>=0&&O<=6&&(P===0||P===6)||P>=2&&P<=4&&O>=2&&O<=4?N.set(D+P,_+O,!0,!0):N.set(D+P,_+O,!1,!0))}}function j(N){const A=N.size;for(let E=8;E<A-8;E++){const M=E%2===0;N.set(E,6,M,!0),N.set(6,E,M,!0)}}function g(N,A){const E=a.getPositions(A);for(let M=0;M<E.length;M++){const B=E[M][0],D=E[M][1];for(let _=-2;_<=2;_++)for(let P=-2;P<=2;P++)_===-2||_===2||P===-2||P===2||_===0&&P===0?N.set(B+_,D+P,!0,!0):N.set(B+_,D+P,!1,!0)}}function w(N,A){const E=N.size,M=m.getEncodedBits(A);let B,D,_;for(let P=0;P<18;P++)B=Math.floor(P/3),D=P%3+E-8-3,_=(M>>P&1)===1,N.set(B,D,_,!0),N.set(D,B,_,!0)}function b(N,A,E){const M=N.size,B=p.getEncodedBits(A,E);let D,_;for(D=0;D<15;D++)_=(B>>D&1)===1,D<6?N.set(D,8,_,!0):D<8?N.set(D+1,8,_,!0):N.set(M-15+D,8,_,!0),D<8?N.set(8,M-D-1,_,!0):D<9?N.set(8,15-D-1+1,_,!0):N.set(8,15-D-1,_,!0);N.set(M-8,8,1,!0)}function k(N,A){const E=N.size;let M=-1,B=E-1,D=7,_=0;for(let P=E-1;P>0;P-=2)for(P===6&&P--;;){for(let O=0;O<2;O++)if(!N.isReserved(B,P-O)){let W=!1;_<A.length&&(W=(A[_]>>>D&1)===1),N.set(B,P-O,W),D--,D===-1&&(_++,D=7)}if(B+=M,B<0||E<=B){B-=M,M=-M;break}}}function y(N,A,E){const M=new s;E.forEach(function(O){M.put(O.mode.bit,4),M.put(O.getLength(),u.getCharCountIndicator(O.mode,N)),O.write(M)});const B=t.getSymbolTotalCodewords(N),D=c.getTotalCodewordsCount(N,A),_=(B-D)*8;for(M.getLengthInBits()+4<=_&&M.put(0,4);M.getLengthInBits()%8!==0;)M.putBit(0);const P=(_-M.getLengthInBits())/8;for(let O=0;O<P;O++)M.put(O%2?17:236,8);return x(M,N,A)}function x(N,A,E){const M=t.getSymbolTotalCodewords(A),B=c.getTotalCodewordsCount(A,E),D=M-B,_=c.getBlocksCount(A,E),P=M%_,O=_-P,W=Math.floor(M/_),J=Math.floor(D/_),Y=J+1,V=W-J,ne=new d(V);let $=0;const ee=new Array(_),S=new Array(_);let Q=0;const T=new Uint8Array(N.buffer);for(let le=0;le<_;le++){const ie=le<O?J:Y;ee[le]=T.slice($,$+ie),S[le]=ne.encode(ee[le]),$+=ie,Q=Math.max(Q,ie)}const te=new Uint8Array(M);let R=0,H,F;for(H=0;H<Q;H++)for(F=0;F<_;F++)H<ee[F].length&&(te[R++]=ee[F][H]);for(H=0;H<V;H++)for(F=0;F<_;F++)te[R++]=S[F][H];return te}function v(N,A,E,M){let B;if(Array.isArray(N))B=h.fromArray(N);else if(typeof N=="string"){let W=A;if(!W){const J=h.rawSplit(N);W=m.getBestVersionForData(J,E)}B=h.fromString(N,W||40)}else throw new Error("Invalid data");const D=m.getBestVersionForData(B,E);if(!D)throw new Error("The amount of data is too big to be stored in a QR Code");if(!A)A=D;else if(A<D)throw new Error(`
187
+ */const Gu=[["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"}]],Wu=fe("zoom-out",Gu),Qu=new Set(["assigned","running"]);function Yu(t,n){return t.reduce((s,r)=>r.assignedTo===n&&Qu.has(r.status)?s+1:s,0)}function fn(t){return t?.toLowerCase()==="devtunnel"}function Ju(t){return t?fn(t)?"DevTunnel":t.charAt(0).toUpperCase()+t.slice(1):"Direct"}function Er(t,n){return fn(n??t.transportType)||!!t.devtunnelEndpoint}function ri(t,n){return!fn(n??t.transportType)}function ai(t,n){const s=n??t.transportType;return fn(s)?"DevTunnel":t.devtunnelEndpoint?"Direct + DevTunnel":Ju(s)}function ca(t,n){return!t&&!n}function Zu({routeTaskId:t,creatingTask:n,internalSelectedTaskId:s,sortedTaskIds:r}){return t||(n?null:r[0]??s??null)}function Xu({activeTaskId:t,routeTaskId:n,creatingTask:s,tasksLoading:r,loadedTaskIds:a}){return!t||n||s||r?!1:!a.includes(t)}function em(t,n){return[n,...t.filter(s=>s.id!==n.id)]}function Mr(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 tm=new Set(["completed","failed","cancelled","archived"]);function nm(t,n){const s=new Set(n);return new Set(Array.from(t).filter(r=>s.has(r)))}function sm(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=>tm.has(a.status))}function rm(t,n){const s=new Set(n);return t.find(r=>!s.has(r.id))?.id??null}function oi(){const[t,n]=o.useState([]),[s,r]=o.useState(null),a=o.useRef(null),i=o.useCallback(()=>{a.current?.click()},[]),l=o.useCallback(async p=>{const u=Array.from(p.target.files??[]);if(u.length!==0)try{const h=await sa(u);n(f=>[...f,...h]),r(null)}catch(h){r(h instanceof Error?h.message:"Failed to attach image")}finally{p.target.value=""}},[]),c=o.useCallback(async p=>{const u=Pd(p.clipboardData);if(u.length!==0){p.preventDefault();try{const h=await sa(u);n(f=>[...f,...h]),r(null)}catch(h){r(h instanceof Error?h.message:"Failed to attach image")}}},[]),d=o.useCallback(p=>{n(u=>u.filter((h,f)=>f!==p))},[]),m=o.useCallback(()=>{n([]),r(null)},[]);return{images:t,error:s,fileInputRef:a,pickImages:i,handleFileChange:l,handlePaste:c,removeImage:d,clearImages:m}}function am({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 om({contentLength:t,disabled:n=!1}){return t>0&&!n}const im=/^[a-zA-Z0-9_-]+$/,ii=/[a-zA-Z0-9_-]/,lm=176;function cm(t){const n=t.map(a=>({...a,displayValue:dm(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 dm(t){return t.label.toLowerCase()==="agent"?kt(t.value):t.value}function da(t){switch(t.toLowerCase()){case"branch":return Yn;case"node":return ts;default:return rs}}function um(t){return Array.from(new Set(t.map(n=>n.trim()).filter(Boolean)))}function li(t,n){return Number.isFinite(n)?Math.max(0,Math.min(t.length,Math.trunc(n))):t.length}function mm(t,n){const s=li(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&&!im.test(d)))return{query:d.toLowerCase(),range:{start:a.index,end:c}}}function hm(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&&ii.test(t[c]??"")))return{targetAgent:l,query:i,range:{start:a.index,end:c}}}}function ir(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 ua(t,n,s){const r=um(n),a=typeof s=="number",i=mm(t,a?s:t.length);if(i){const c=r.filter(p=>p.toLowerCase().startsWith(i.query)),d=r.find(p=>p.toLowerCase()===i.query),m=!!d&&(i.range.end===t.length||!ii.test(t[i.range.end]??""));return{...m?{targetAgent:d}:{},query:i.query,strippedText:m?ir(t,i.range):t,matches:c,...a?{mentionRange:i.range}:{}}}const l=hm(t,r);return l?{targetAgent:l.targetAgent,query:l.query,strippedText:ir(t,l.range),matches:[l.targetAgent],...a?{mentionRange:l.range}:{}}:{strippedText:t,matches:[]}}function fm(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 pm(t,n){return t.query!==void 0&&t.matches.length>0&&!t.targetAgent&&!n}function xm(t,n){if(!n)return{value:t.replace(/^@[a-zA-Z0-9_-]*\s*/,""),cursorPosition:0};const s=ir(t,n);return{value:s,cursorPosition:Math.min(n.start,s.length)}}function gm(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 bm(t,n){if(typeof window>"u")return;const s=t.ownerDocument,r=s.createElement("div"),a=s.createElement("span"),i=li(t.value,n);gm(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 vm({cardClientWidth:t,cardRectWidth:n}){const s=n/t;return Number.isFinite(s)&&s>0?s:1}function wm({boundaryRectBottom:t,boundaryRectTop:n,cardRectTop:s,cardWidth:r,caretLeft:a,caretTop:i,cssZoom:l=1,lineHeight:c,matchCount:d,textareaOffsetLeft:m,textareaOffsetTop:p,viewportHeight:u}){const h=Number.isFinite(l)&&l>0?l:1,f=Math.min(Math.max(d,1)*28+4,220),j=f*h,g=m/h,w=p/h,b=n??0,k=t??u,y=Math.max(8,r-lm-8),x=Math.max(8,Math.min(g+a,y)),v=w+i+c+4,N=s+v*h,A=w+i-f-4,E=s+(w+i)*h,M=k-N-8,B=E-b-8,D=Math.max(8,(b-s+8)/h);if(M<j&&B>M)return{left:x,top:Math.max(D,A)};const _=Math.max(D,(k-s-j-8)/h);return{left:x,top:Math.max(D,Math.min(v,_))}}function ym(t,n,s){const r=t.closest('[data-chat-input-card="true"]'),a=bm(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 wm({boundaryRectBottom:c?.bottom,boundaryRectTop:c?.top,cardRectTop:l.top,cardWidth:r.clientWidth,caretLeft:a.left,caretTop:a.top,cssZoom:vm({cardRectWidth:l.width,cardClientWidth:r.clientWidth}),lineHeight:d,matchCount:s,textareaOffsetLeft:i.left-l.left,textareaOffsetTop:i.top-l.top,viewportHeight:window.innerHeight})}function jm({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:p,onTargetAgentChange:u,running:h=!1,onStop:f,quickChats:j=[]}){const[g,w]=o.useState(""),[b,k]=o.useState(),[y,x]=o.useState(c),[v,N]=o.useState(),[A,E]=o.useState(),[M,B]=o.useState(!1),[D,_]=o.useState(0),[P,O]=o.useState(0),[W,J]=o.useState(0),Y=o.useRef(null),V=o.useRef(void 0),{images:ne,error:$,fileInputRef:ee,pickImages:S,handleFileChange:Q,handlePaste:T,removeImage:te,clearImages:R}=oi();c!==y&&(x(c),k(void 0));const H=o.useCallback((G=Y.current)=>{G&&_(G.selectionStart??G.value.length)},[]),F=o.useCallback((G=D,ge=1)=>{Y.current&&E(ym(Y.current,G,ge))},[D]),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",H(Y.current))},[H]);o.useEffect(()=>{O(0)},[g,j]);const ue=p??b,Z=o.useMemo(()=>ua(g,m,D),[m,D,g]),K=pm(Z,M),I=fm(Z.matches,v,l),se=Z.matches[I];o.useEffect(()=>{N(void 0),B(!1)},[l,Z.query,Z.matches.join("|")]),o.useEffect(()=>{if(!K){E(void 0);return}const G=Z.mentionRange?.end??D,ge=()=>F(G,Z.matches.length);if(typeof requestAnimationFrame!="function"){ge();return}const be=requestAnimationFrame(ge);return()=>cancelAnimationFrame(be)},[Z.matches.length,Z.mentionRange?.end,D,K,F]);const q=o.useCallback(G=>{u?u(G):k(G)},[u]),ae=o.useCallback(G=>{w(G.prompt);const ge=()=>{Y.current?.focus(),ie()};typeof requestAnimationFrame=="function"?requestAnimationFrame(ge):ge()},[ie]),ye=o.useCallback(()=>{const G=Wn(g,j,P);if(G){ae(G);return}const ge=ua(g,m,D),be=ge.targetAgent??ue,et=ge.targetAgent?ge.strippedText:g,_e=zo(et,ne);om({contentLength:_e.length,disabled:n})&&(J(rt=>rt+1),t(_e,be?{targetAgent:be}:void 0),w(""),q(void 0),R(),le())},[g,ne,m,D,ue,n,t,q,R,le,j,P,ae]),pe=o.useCallback((G,ge=Z.mentionRange)=>{q(G),w(et=>{const _e=xm(et,ge);return V.current=_e.cursorPosition,_(_e.cursorPosition),_e.value});const be=()=>{Y.current?.focus(),V.current!==void 0&&(Y.current?.setSelectionRange(V.current,V.current),V.current=void 0),ie()};typeof requestAnimationFrame=="function"?requestAnimationFrame(be):be()},[ie,Z.mentionRange,q]),Ze=o.useCallback(G=>{if(K&&G.key==="Escape"){G.preventDefault(),B(!0);return}if(K&&(G.key==="ArrowDown"||G.key==="ArrowUp")){G.preventDefault();const be=Z.matches.length;if(be===0)return;const et=G.key==="ArrowDown"?1:-1,_e=(I+et+be)%be;N(Z.matches[_e]);return}if(K&&G.key==="Enter"&&!G.shiftKey&&se){G.preventDefault(),pe(se,Z.mentionRange);return}const ge=No(g,j);if(ge.length>0&&(G.key==="ArrowDown"||G.key==="ArrowUp")){G.preventDefault(),O(be=>ko(be,ge.length,G.key==="ArrowDown"?1:-1));return}if(G.key==="Enter"&&!G.shiftKey){G.preventDefault();const be=Wn(g,j,P);be?ae(be):ye()}},[pe,ae,ye,Z.matches,Z.mentionRange,j,P,se,I,K,g]),Ae=g.trim().length>0||ne.length>0,Re=am({disabled:n,running:h,canStop:h&&!!f,hasContent:Ae}),De=cm(a),He=De.primary?da(De.primary.label):rs,Ke=i?Uo(i,d):null,je=l?kt(l):null,Be=n?s:h?Ae?"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:ee,type:"file",accept:"image/*",multiple:!0,onChange:Q,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(At,{agent:l,className:"h-2.5 w-2.5 shrink-0 text-primary/75"}),e.jsx("span",{className:"truncate",children:je})]}),De.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(He,{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:De.primary.value,children:De.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(Sr,{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:()=>te(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(ut,{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=>{w(G.target.value),H(G.currentTarget)},onKeyDown:Ze,onKeyUp:G=>H(G.currentTarget),onClick:G=>H(G.currentTarget),onSelect:G=>H(G.currentTarget),onScroll:()=>F(D,Z.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(Xs,{query:g,quickChats:j,selectedIndex:P,onActiveIndexChange:O,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:Z.matches.map((G,ge)=>e.jsxs("button",{type:"button",onMouseDown:be=>be.preventDefault(),onMouseEnter:()=>N(G),onClick:()=>pe(G,Z.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===I?"bg-primary/10 text-primary":"text-muted-foreground"].join(" "),children:[e.jsx(At,{agent:G,className:"h-3 w-3 shrink-0 text-primary/60"}),e.jsx("span",{className:"truncate",children:kt(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||De.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 ${kt(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(Qo,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx(At,{agent:ue,className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:kt(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(ut,{className:"h-2.5 w-2.5"})})]}),De.secondary.map(G=>{const ge=da(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(At,{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:[Ke&&e.jsxs("span",{"data-chat-input-model-display":"true","aria-label":`Model: ${Ke}`,title:`Model: ${Ke}`,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(Yo,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),Ke]}),e.jsxs(X,{type:"button",variant:"ghost",onClick:S,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(or,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Images"})]}),e.jsx("span",{title:Be,children:e.jsx(X,{onClick:Re.primaryAction==="stop"?f:ye,disabled:Re.primaryDisabled,size:"icon","data-chat-send-button":"true","aria-label":Re.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:Re.primaryAction==="stop"?e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(si,{className:`h-3.5 w-3.5 ${W>0?"animate-chat-send-flight":""}`},W)})})]})]}),$&&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 js="rovingFocusGroup.onEntryFocus",Nm={bubbles:!1,cancelable:!0},Bn="RovingFocusGroup",[lr,ci,km]=Gl(Bn),[Sm,di]=Co(Bn,[km]),[Cm,Tm]=Sm(Bn),ui=o.forwardRef((t,n)=>e.jsx(lr.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(lr.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Am,{...t,ref:n})})}));ui.displayName=Bn;var Am=o.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:s,orientation:r,loop:a=!1,dir:i,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:m,preventScrollOnEntryFocus:p=!1,...u}=t,h=o.useRef(null),f=Wl(n,h),j=To(i),[g,w]=Ao({prop:l,defaultProp:c??null,onChange:d,caller:Bn}),[b,k]=o.useState(!1),y=Ql(m),x=ci(s),v=o.useRef(!1),[N,A]=o.useState(0);return o.useEffect(()=>{const E=h.current;if(E)return E.addEventListener(js,y),()=>E.removeEventListener(js,y)},[y]),e.jsx(Cm,{scope:s,orientation:r,dir:j,loop:a,currentTabStopId:g,onItemFocus:o.useCallback(E=>w(E),[w]),onItemShiftTab:o.useCallback(()=>k(!0),[]),onFocusableItemAdd:o.useCallback(()=>A(E=>E+1),[]),onFocusableItemRemove:o.useCallback(()=>A(E=>E-1),[]),children:e.jsx(mn.div,{tabIndex:b||N===0?-1:0,"data-orientation":r,...u,ref:f,style:{outline:"none",...t.style},onMouseDown:Et(t.onMouseDown,()=>{v.current=!0}),onFocus:Et(t.onFocus,E=>{const M=!v.current;if(E.target===E.currentTarget&&M&&!b){const B=new CustomEvent(js,Nm);if(E.currentTarget.dispatchEvent(B),!B.defaultPrevented){const D=x().filter(J=>J.focusable),_=D.find(J=>J.active),P=D.find(J=>J.id===g),W=[_,P,...D].filter(Boolean).map(J=>J.ref.current);fi(W,p)}}v.current=!1}),onBlur:Et(t.onBlur,()=>k(!1))})})}),mi="RovingFocusGroupItem",hi=o.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:s,focusable:r=!0,active:a=!1,tabStopId:i,children:l,...c}=t,d=So(),m=i||d,p=Tm(mi,s),u=p.currentTabStopId===m,h=ci(s),{onFocusableItemAdd:f,onFocusableItemRemove:j,currentTabStopId:g}=p;return o.useEffect(()=>{if(r)return f(),()=>j()},[r,f,j]),e.jsx(lr.ItemSlot,{scope:s,id:m,focusable:r,active:a,children:e.jsx(mn.span,{tabIndex:u?0:-1,"data-orientation":p.orientation,...c,ref:n,onMouseDown:Et(t.onMouseDown,w=>{r?p.onItemFocus(m):w.preventDefault()}),onFocus:Et(t.onFocus,()=>p.onItemFocus(m)),onKeyDown:Et(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){p.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const b=Dm(w,p.orientation,p.dir);if(b!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let y=h().filter(x=>x.focusable).map(x=>x.ref.current);if(b==="last")y.reverse();else if(b==="prev"||b==="next"){b==="prev"&&y.reverse();const x=y.indexOf(w.currentTarget);y=p.loop?_m(y,x+1):y.slice(x+1)}setTimeout(()=>fi(y))}}),children:typeof l=="function"?l({isCurrentTabStop:u,hasTabStop:g!=null}):l})})});hi.displayName=mi;var Em={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Mm(t,n){return n!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function Dm(t,n,s){const r=Mm(t.key,s);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Em[r]}function fi(t,n=!1){const s=document.activeElement;for(const r of t)if(r===s||(r.focus({preventScroll:n}),document.activeElement!==s))return}function _m(t,n){return t.map((s,r)=>t[(n+r)%t.length])}var Pm=ui,Im=hi,as="Tabs",[Rm]=Co(as,[di]),pi=di(),[Lm,Dr]=Rm(as),xi=o.forwardRef((t,n)=>{const{__scopeTabs:s,value:r,onValueChange:a,defaultValue:i,orientation:l="horizontal",dir:c,activationMode:d="automatic",...m}=t,p=To(c),[u,h]=Ao({prop:r,onChange:a,defaultProp:i??"",caller:as});return e.jsx(Lm,{scope:s,baseId:So(),value:u,onValueChange:h,orientation:l,dir:p,activationMode:d,children:e.jsx(mn.div,{dir:p,"data-orientation":l,...m,ref:n})})});xi.displayName=as;var gi="TabsList",bi=o.forwardRef((t,n)=>{const{__scopeTabs:s,loop:r=!0,...a}=t,i=Dr(gi,s),l=pi(s);return e.jsx(Pm,{asChild:!0,...l,orientation:i.orientation,dir:i.dir,loop:r,children:e.jsx(mn.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:n})})});bi.displayName=gi;var vi="TabsTrigger",wi=o.forwardRef((t,n)=>{const{__scopeTabs:s,value:r,disabled:a=!1,...i}=t,l=Dr(vi,s),c=pi(s),d=Ni(l.baseId,r),m=ki(l.baseId,r),p=r===l.value;return e.jsx(Im,{asChild:!0,...c,focusable:!a,active:p,children:e.jsx(mn.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":m,"data-state":p?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:d,...i,ref:n,onMouseDown:Et(t.onMouseDown,u=>{!a&&u.button===0&&u.ctrlKey===!1?l.onValueChange(r):u.preventDefault()}),onKeyDown:Et(t.onKeyDown,u=>{[" ","Enter"].includes(u.key)&&l.onValueChange(r)}),onFocus:Et(t.onFocus,()=>{const u=l.activationMode!=="manual";!p&&!a&&u&&l.onValueChange(r)})})})});wi.displayName=vi;var yi="TabsContent",ji=o.forwardRef((t,n)=>{const{__scopeTabs:s,value:r,forceMount:a,children:i,...l}=t,c=Dr(yi,s),d=Ni(c.baseId,r),m=ki(c.baseId,r),p=r===c.value,u=o.useRef(p);return o.useEffect(()=>{const h=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(h)},[]),e.jsx(Yl,{present:a||p,children:({present:h})=>e.jsx(mn.div,{"data-state":p?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!h,id:m,tabIndex:0,...l,ref:n,style:{...t.style,animationDuration:u.current?"0s":void 0},children:h&&i})})});ji.displayName=yi;function Ni(t,n){return`${t}-trigger-${n}`}function ki(t,n){return`${t}-content-${n}`}var Bm=xi,Si=bi,Ci=wi,Ti=ji;const _r=Bm,os=o.forwardRef(({className:t,...n},s)=>e.jsx(Si,{ref:s,className:L("inline-flex h-8 items-center justify-center rounded-sm bg-muted/72 p-0.5 text-muted-foreground shadow-inner shadow-background/40",t),...n}));os.displayName=Si.displayName;const Ot=o.forwardRef(({className:t,...n},s)=>e.jsx(Ci,{ref:s,className:L("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-2 py-0.5 text-[11px] font-semibold ring-offset-background transition-all duration-200 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-primary/12 data-[state=active]:text-primary data-[state=active]:shadow-[0_10px_28px_-18px_hsl(var(--primary)/0.85)]",t),...n}));Ot.displayName=Ci.displayName;const bt=o.forwardRef(({className:t,...n},s)=>e.jsx(Ti,{ref:s,className:L("mt-2 ring-offset-background data-[state=inactive]:hidden focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...n}));bt.displayName=Ti.displayName;var Om=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Fm=Om.reduce((t,n)=>{const s=Jl(`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}},{}),zm="Label",Ai=o.forwardRef((t,n)=>e.jsx(Fm.label,{...t,ref:n,onMouseDown:s=>{s.target.closest("button, input, select, textarea")||(t.onMouseDown?.(s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));Ai.displayName=zm;var Ei=Ai;const Um=Zl("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),tt=o.forwardRef(({className:t,...n},s)=>e.jsx(Ei,{ref:s,className:L(Um(),t),...n}));tt.displayName=Ei.displayName;function ma({agent:t,query:n,onSelect:s}){const r=$o(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(qo,{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 $m(t,n,s){return t!=="auto"?n.find(r=>r.id===t)??null:s.length===1?s[0]??null:null}function qm(t){return t.trim()||"."}function Vm(t){return new Promise(n=>window.setTimeout(n,t))}function Hm(t){return!!t&&typeof t=="object"&&typeof t.createdBranch=="string"&&typeof t.currentBranch<"u"}async function Km(t){let n=t;for(let s=0;s<60;s++){if(n.status==="succeeded"){if(Hm(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 Vm(1e3),n=await nc(n.id)}throw new Error("Timed out waiting for branch creation")}function ha({value:t,onChange:n,project:s,assignTo:r,nodes:a,assignableNodes:i,layout:l="default",chipClassName:c,chipActiveClassName:d,chipInactiveClassName:m,labelClassName:p,triggerClassName:u}){const[h,f]=o.useState(!1),[j,g]=o.useState(null),[w,b]=o.useState(""),[k,y]=o.useState(!1),[x,v]=o.useState(!1),[N,A]=o.useState(!1),[E,M]=o.useState(null),[B,D]=o.useState(""),[_,P]=o.useState(""),[O,W]=o.useState(""),[J,Y]=o.useState(!1),V=o.useRef(null),ne=o.useRef(0),$=o.useMemo(()=>$m(r,a,i),[r,a,i]),ee=$?.id,S=o.useMemo(()=>qm(s),[s]),Q=o.useMemo(()=>ee?`${ee}
188
+ ${S}`:"",[ee,S]),T=o.useCallback(async(Z=0,K=!1)=>{const I=ne.current+1,se=Q;if(ne.current=I,!ee){g(null),b("");return}M(null),K||b(""),K?v(!0):y(!0);try{const q=await Xl(ee,{path:S,limit:20,offset:Z,allowAbsolute:!0});if(I!==ne.current)return;b(se),g(ae=>K&&ae?{...q,branches:[...ae.branches,...q.branches]}:q)}catch(q){if(I!==ne.current)return;M(q instanceof Error?q.message:"Failed to load branch info"),K||(g(null),b(""))}finally{I===ne.current&&(y(!1),v(!1))}},[ee,Q,S]);o.useEffect(()=>{if(!ee){ne.current+=1,g(null),b(""),M(null);return}T()},[ee,S,T]),o.useEffect(()=>{const Z=t.trim(),K=w===Q?j:null,I=K?.available&&K.currentBranch?K.currentBranch:"";Z!==I&&n(I)},[j,Q,w,n,t]),o.useEffect(()=>{if(!h)return;const Z=I=>{V.current&&(V.current.contains(I.target)||f(!1))},K=I=>{I.key==="Escape"&&f(!1)};return document.addEventListener("mousedown",Z),document.addEventListener("keydown",K),()=>{document.removeEventListener("mousedown",Z),document.removeEventListener("keydown",K)}},[h]),o.useEffect(()=>{h&&(P(""),W(""),Y(!1))},[h,ee,S]);const te=o.useCallback(async()=>{if(!ee)return;const Z=B.trim(),K=J?O.trim():_.trim();if(!(!Z||!K)){A(!0),M(null);try{const I=await ec(ee,{path:S,branchName:Z,startPoint:K,limit:20,offset:0,allowAbsolute:!0}),se=await Km(I);b(Q),g(se),n(se.currentBranch??se.createdBranch),D(""),P(""),W(""),Y(!1),f(!1)}catch(I){M(I instanceof Error?I.message:"Failed to create branch")}finally{A(!1)}}},[ee,Q,S,J,O,B,n,_]),R=w===Q?j:null,H=o.useCallback(()=>{R?.hasMore&&T(R.branches.length,!0)},[R,T]),F=t.trim()||R?.currentBranch||(R&&!R.available?"No git repo":"Branch"),le=J?O.trim():_.trim(),ie=!!(R?.available&&B.trim()&&le&&!N),ue=l==="composer"?e.jsxs(X,{type:"button",variant:"ghost",onClick:()=>f(Z=>!Z),title:F,"aria-label":`Branch: ${F}`,className:L(c,u,"min-w-0 max-w-full",t.trim()?d:m),children:[k&&!R?e.jsx(he,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(Yn,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:L("min-w-0 truncate",p),children:F})]}):e.jsxs(X,{type:"button",variant:"outline",onClick:()=>f(Z=>!Z),className:"h-7 w-full justify-between rounded-sm border-border/70 bg-background/70 px-2.5 text-[11px] shadow-none",title:F,children:[e.jsx("span",{className:L("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:F}),e.jsx("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground",children:$?$.name:"Manual"})]});return e.jsxs("div",{className:L("relative inline-block",l==="composer"?"min-w-0 shrink-0":"w-full"),ref:V,children:[l==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[10px] font-medium",children:"Branch"}),ue]}):ue,h&&e.jsxs("div",{className:L("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(Yn,{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??F} · ${R.repoRoot}`:R?.currentBranch??F,children:R?.currentBranch??F}),k?e.jsx(he,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}):null]}),$?k&&!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(dt,{value:B,onChange:Z=>D(Z.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(X,{type:"button",size:"sm",onClick:()=>{te()},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(tc,{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"}),!J&&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(Jt,{className:"h-2.5 w-2.5"}),"Manual"]})]}),J?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(dt,{value:O,onChange:Z=>W(Z.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),W("")},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(ut,{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(Z=>{const K=_===Z.ref,I=Z.branch==="main"||Z.branch==="master";return e.jsxs("button",{type:"button",onClick:()=>P(Z.ref),className:L("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:Z.ref,children:[e.jsx("span",{className:L("shrink-0 text-[10px]",I?"text-amber-500 dark:text-amber-400":"text-muted-foreground/60"),"aria-hidden":!0,children:I?"★":"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:Z.ref}),K?e.jsx(En,{className:"h-3 w-3 shrink-0 text-primary"}):null]},Z.ref)}),R.hasMore&&e.jsxs("button",{type:"button",onClick:H,disabled:x,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:[x?e.jsx(he,{className:"h-3 w-3 animate-spin"}):e.jsx(Jn,{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."}),E&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-1.5 text-[11px] text-destructive",children:E})]})]})}function Gm({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(Sr,{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(ut,{className:"h-3.5 w-3.5"})})]},`${s.filename??"image"}-${r}`))})}const Wm=20,Qm=3,cr="meshy-working-dir-recents-by-node";function Ym(t){return t.startsWith("/")||t.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(t)}function Jm(t){const n=t.trim();return n||"."}function dr(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===Qm))break}return n}function Zm(t,n){const s=n.trim();return dr(s?[s,...t]:t)}function Mi(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=dr(a);i.length>0&&(n[s]=i)}return n}function Xm(t,n,s){if(!n)return t;const r=t[n]??[],a=Zm(r,s);if(a.length===0){if(!(n in t))return t;const{[n]:i,...l}=t;return l}return{...t,[n]:a}}function eh(t,n){return n?t[n]?.[0]??"":""}function Di(t){if(!t||typeof window>"u")return"";try{const n=window.localStorage.getItem(cr);return n?eh(Mi(JSON.parse(n)),t):""}catch{return""}}function th(t,n,s){return t!=="auto"?n.find(r=>r.id===t)??null:s.length===1?s[0]??null:null}function nh(t,n){const s=n.trim();return s?Ym(s)||!t?s:`${t.replace(/[/\\]+$/,"")}/${s}`:""}function sh(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 Xn({value:t,onChange:n,assignTo:s,nodes:r,assignableNodes:a,layout:i="default",chipClassName:l,chipActiveClassName:c,chipInactiveClassName:d,labelClassName:m,triggerClassName:p,popoverPlacement:u="bottom",popoverAlign:h="start"}){const[f,j]=o.useState(!1),[g,w]=o.useState(null),[b,k]=o.useState(!1),[y,x]=o.useState(!1),[v,N]=o.useState(null),[A,E]=o.useState(""),[M,B]=o.useState(!1),[D,_]=o.useState({}),P=o.useRef(null),O=o.useMemo(()=>th(s,r,a),[s,r,a]),W=O?.id,J=o.useMemo(()=>W?D[W]??[]:[],[D,W]),Y=o.useMemo(()=>t.trim()?nh(O?.workDir,t):"Use node default",[t,O?.workDir]);o.useEffect(()=>{if(!(typeof window>"u"))try{const F=window.localStorage.getItem(cr);if(!F)return;const le=JSON.parse(F);_(Mi(le))}catch{}},[]);const V=o.useCallback(F=>{W&&_(le=>{const ie=Xm(le,W,F);if(ie===le)return le;if(typeof window<"u")try{window.localStorage.setItem(cr,JSON.stringify(ie))}catch{}return ie})},[W]),ne=o.useCallback((F,le=!0)=>{const ie=F.trim();n(ie),le&&ie&&V(ie),j(!1)},[n,V]),$=o.useCallback(async(F,le=0,ie=!1)=>{if(W){N(null),ie?x(!0):k(!0);try{const ue=await Eo(W,{path:F,limit:Wm,offset:le,directoriesOnly:!0,allowAbsolute:!0});w(Z=>ie&&Z?{...ue,entries:[...Z.entries,...ue.entries]}:ue)}catch(ue){N(ue instanceof Error?ue.message:"Failed to browse directories"),ie||w(null)}finally{k(!1),x(!1)}}},[W]),ee=o.useRef(t);ee.current=t;const S=o.useRef($);S.current=$,o.useEffect(()=>{if(!f)return;const F=ee.current;E(F),B(!1),w(null),N(null),W&&S.current(Jm(F))},[f,W]),o.useEffect(()=>{if(!f)return;const F=ie=>{P.current&&(P.current.contains(ie.target)||j(!1))},le=ie=>{ie.key==="Escape"&&j(!1)};return document.addEventListener("mousedown",F),document.addEventListener("keydown",le),()=>{document.removeEventListener("mousedown",F),document.removeEventListener("keydown",le)}},[f]);const Q=o.useCallback(F=>{$(F)},[$]),T=o.useCallback(()=>{g&&$(g.currentPath,g.entries.length,!0)},[g,$]),te=i==="composer"?e.jsxs(X,{type:"button",variant:"ghost",onClick:()=>j(F=>!F),title:Y,"aria-label":`Working directory: ${Y}`,className:L(l,p,"min-w-0 max-w-full",t.trim()?c:d),children:[e.jsx(Jo,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:L("min-w-0 truncate",m),children:Y})]}):e.jsxs(X,{type:"button",variant:"outline",onClick:()=>j(F=>!F),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:L("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:O?O.name:"Manual"})]}),R=sh(g,O),H=!!g?.parentPath;return e.jsxs("div",{className:L("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(tt,{className:"text-[10px] font-medium",children:"Working directory"}),te]}):te,f&&e.jsxs("div",{className:L("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:[J.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(Jn,{className:"h-2.5 w-2.5"}),"Recent"]}),e.jsx("div",{className:"flex flex-col",children:J.map(F=>e.jsx("button",{type:"button",onClick:()=>ne(F),className:"truncate rounded-sm px-1.5 py-0.5 text-left font-mono text-[11px] text-foreground hover:bg-background/60",title:F,children:F},F))})]}),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&&Q(g.parentPath),disabled:!H||b,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(Wo,{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:[O?b?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(F=>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(F.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 ${F.path}`,children:[e.jsx(hn,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[11px] text-foreground",children:F.name})]}),e.jsx("button",{type:"button",onClick:()=>Q(F.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 ${F.name}`,children:e.jsx(nt,{className:"h-3.5 w-3.5"})})]},F.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(Jn,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:v??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a node to browse."}),v&&g&&g.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[11px] text-destructive",children:v})]}),e.jsx("div",{className:"flex items-center gap-1 border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:M?e.jsxs(e.Fragment,{children:[e.jsx(dt,{value:A,onChange:F=>E(F.target.value),onKeyDown:F=>{F.key==="Enter"&&A.trim()?(F.preventDefault(),ne(A)):F.key==="Escape"&&(F.preventDefault(),B(!1),E(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(En,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{B(!1),E(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(ut,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>{E(t),B(!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(Jt,{className:"h-3 w-3"})]})})]})]})}function _i(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 Pr({isCurrent:t}){return t?e.jsx(yu,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):e.jsx(gu,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function ur(t,n){return t.map(s=>{const r=!!n&&s.id===n;return e.jsx(Oe,{value:s.id,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(Pr,{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 rh(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??Mn}}function ah(){return ac.map(t=>e.jsx(Oe,{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 oh(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 fa(t){if(!t.updatedAt)return 0;const n=Date.parse(t.updatedAt);return Number.isNaN(n)?0:n}function ih(t,n){return fa(n)-fa(t)||t.sessionId.localeCompare(n.sessionId)}function lh(t){const n=t.trim().replace(/[\\/]+$/,"");return n?n.split(/[\\/]+/).filter(Boolean).at(-1)??n:"Unknown project"}function ch(t){const n=new Map;for(const s of[...t].sort(ih)){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:lh(s),cwd:s,sessions:r}))}function dh(t,n){const s=new Set(t);return s.has(n)?s.delete(n):s.add(n),s}function uh({nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,onCreated:a,onCancel:i,className:l,footerClassName:c,submitLabel:d="Load session",cancelLabel:m="Cancel",autoFocus:p=!1}){const u=o.useMemo(()=>_i(t,{currentNodeRole:n,leaderNodeId:r}),[t,n,r]),h=o.useMemo(()=>s&&u.some(I=>I.id===s)?s:u[0]?.id??"",[u,s]),[f,j]=o.useState(""),[g,w]=o.useState("codex"),[b,k]=o.useState(""),[y,x]=o.useState(""),[v,N]=o.useState(""),[A,E]=o.useState(h),[M,B]=o.useState(Mn),[D,_]=o.useState(!1),[P,O]=o.useState([]),[W,J]=o.useState(!1),[Y,V]=o.useState(null),ne=o.useMemo(()=>P.find(I=>I.sessionId===b)??null,[P,b]);o.useEffect(()=>{A&&u.some(I=>I.id===A)||E(h)},[A,u,h]),o.useEffect(()=>{k(""),x(""),N("")},[g,A]),o.useEffect(()=>{let I=!1;return A?(J(!0),V(null),sc(A,{agent:g,limit:50}).then(se=>{I||O(se.sessions)}).catch(se=>{I||(O([]),V(se instanceof Error?se.message:"Failed to load native sessions"))}).finally(()=>{I||J(!1)}),()=>{I=!0}):(O([]),V(null),J(!1),()=>{I=!0})},[g,A]),o.useEffect(()=>{ne&&(x(ne.sessionId),N(ne.cwd))},[ne]);const $=o.useCallback(async I=>{I.preventDefault();const se=rh({title:f,defaultTitle:ne?.summary,agent:g,sessionId:y,cwd:v,assignTo:A,priority:"normal",mode:M});if(se){_(!0);try{const q=await rc(se);a(q)}catch(q){ce.error(q instanceof Error?q.message:"Failed to load native session")}finally{_(!1)}}},[f,ne,g,y,v,A,M,a]),ee=!!(y.trim()&&v.trim()&&A),[S,Q]=o.useState(!1),[T,te]=o.useState(""),[R,H]=o.useState(()=>new Set),F=u.find(I=>I.id===A)??null,le=!!(s&&F?.id===s),ie=o.useMemo(()=>{const I=T.trim().toLowerCase();return I?P.filter(se=>se.summary.toLowerCase().includes(I)||se.sessionId.toLowerCase().includes(I)||se.cwd.toLowerCase().includes(I)):P},[P,T]),ue=o.useMemo(()=>ch(ie),[ie]),Z=o.useCallback(I=>{H(se=>dh(se,I))},[]),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:L("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($e,{value:A,onValueChange:E,children:[e.jsx(qe,{className:L(K),"aria-label":"Node",children:F?e.jsxs(e.Fragment,{children:[e.jsx(Pr,{isCurrent:le}),e.jsx("span",{className:"max-w-[10rem] truncate",children:F.name})]}):e.jsx(Je,{placeholder:"Node"})}),e.jsx(Ve,{children:ur(u,s)})]}),e.jsxs($e,{value:g,onValueChange:I=>w(I),children:[e.jsxs(qe,{className:L(K),"aria-label":"Agent",children:[e.jsx(At,{agent:g}),e.jsx("span",{children:g})]}),e.jsx(Ve,{children:Id()})]}),e.jsxs("div",{className:"relative ml-auto min-w-0 flex-1 sm:max-w-56",children:[e.jsx(Mo,{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(dt,{value:T,onChange:I=>te(I.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(tt,{className:"text-[10px] font-medium uppercase tracking-[0.2em] text-muted-foreground",children:W?"Loading...":`${ie.length} session${ie.length===1?"":"s"}`})}),e.jsxs("div",{className:"relative h-88 overflow-hidden rounded-sm",children:[W&&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&&!W&&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(I=>e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>Z(I.cwd),"aria-expanded":!R.has(I.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(st,{className:L("h-3.5 w-3.5 shrink-0 transition-transform",R.has(I.cwd)&&"-rotate-90")}),e.jsx(rs,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-foreground",children:I.folderName}),e.jsxs("span",{className:"shrink-0 uppercase tracking-[0.16em]",children:[I.sessions.length," session",I.sessions.length===1?"":"s"]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-right font-mono",children:I.cwd})]}),!R.has(I.cwd)&&I.sessions.map(se=>{const q=se.sessionId===b;return e.jsxs("button",{type:"button",onClick:()=>k(se.sessionId),className:L("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:L("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:oh(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)})]},I.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:()=>Q(I=>!I),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":S,children:[e.jsx("span",{className:"shrink-0",children:S?"Less options":"More options"}),e.jsx(st,{className:L("h-3.5 w-3.5 shrink-0 transition-transform",S&&"rotate-180")})]}),S&&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(tt,{htmlFor:"native-session-id",className:"text-[10px] font-medium text-muted-foreground",children:"Session ID"}),e.jsx(dt,{id:"native-session-id",type:"text",value:y,onChange:I=>{k(""),x(I.target.value)},placeholder:"ses_..., thread_..., or UUID",autoFocus:p,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(tt,{htmlFor:"native-session-title",className:"text-[10px] font-medium text-muted-foreground",children:"Task title"}),e.jsx(dt,{id:"native-session-title",type:"text",value:f,onChange:I=>j(I.target.value),placeholder:"Optional",className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px] shadow-none"})]})]}),e.jsx(Xn,{value:v,onChange:I=>{k(""),N(I)},assignTo:A,nodes:t,assignableNodes:u}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(tt,{className:"text-[10px] font-medium text-muted-foreground",children:"Mode"}),e.jsxs($e,{value:M,onValueChange:I=>B(I),children:[e.jsx(qe,{className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px] shadow-none",children:e.jsx(Je,{placeholder:"Select mode"})}),e.jsx(Ve,{children:ah()})]})]})]})]}),e.jsxs("div",{className:L("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",c),children:[i&&e.jsx(X,{type:"button",variant:"ghost",onClick:i,className:"rounded-sm",children:m}),e.jsx(X,{type:"submit",disabled:!ee||D,className:"rounded-sm px-5",children:D?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:"h-4 w-4 animate-spin"})," Loading..."]}):d})]})]})}const Ns="__agent-default__";function Pi({agent:t,value:n,onChange:s,triggerClassName:r,contentClassName:a="max-h-80",chip:i=!1}){const l=Uo(t,n);return o.useEffect(()=>{n&&!Vo(t,n)&&s("")},[t,n,s]),e.jsxs($e,{value:n||Ns,onValueChange:c=>s(c===Ns?"":c),children:[e.jsx(qe,{"aria-label":`Model: ${l}`,title:`Model: ${l}`,className:r,children:i?e.jsxs(e.Fragment,{children:[e.jsx(Yo,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:l})]}):e.jsx(Je,{placeholder:"Agent default"})}),e.jsxs(Ve,{className:a,children:[e.jsx(Oe,{value:Ns,className:"py-1 text-[11px]",children:"Agent default"}),Rd(t)]})]})}function mh(t){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Model"}),e.jsx(Pi,{...t,triggerClassName:"h-8 rounded-sm border-border/70 bg-background/70"})]})}function Ii(t,n,s=!1){const r=t.trim();if(r)return r;const a=n.trim().split(`
189
+ `).map(i=>i.trim()).find(Boolean);return a?a.length>72?`${a.slice(0,69).trimEnd()}...`:a:s?"Image task":""}function hh(t){const n=t.title.trim(),s=Ho(t.agent,t.description),r=s.prompt,a=Ii(t.title,r,t.images.length>0),i=r.trim()||a,l=t.mode??Mn,c=t.model?.trim(),d=c&&Vo(t.agent,c)?c:"",m=s.isGoal?s.commandPrompt:r,p=zo(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:p,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 fh({nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,className:d,footerClassName:m,submitLabel:p="Create chat",cancelLabel:u="Cancel",autoFocus:h=!1,layout:f="default",defaultTaskAgent:j,quickChats:g=[]}){const[w,b]=o.useState(""),[k,y]=o.useState(""),[x,v]=o.useState(0),[N,A]=o.useState(()=>Un(j)),E=o.useRef(!1),[M,B]=o.useState(""),[D,_]=o.useState(Mn),[P,O]=o.useState(i?.trim()??""),W=o.useRef(i!==void 0),[J,Y]=o.useState(""),V=o.useMemo(()=>_i(t,{currentNodeRole:n,leaderNodeId:r}),[t,n,r]),ne=o.useMemo(()=>a&&V.some(re=>re.id===a)?a:s&&V.some(re=>re.id===s)?s:V[0]?.id??"",[V,s,a]),[$,ee]=o.useState(ne),[S,Q]=o.useState(!1),[T,te]=o.useState(!1),{images:R,error:H,fileInputRef:F,pickImages:le,handleFileChange:ie,handlePaste:ue,removeImage:Z}=oi(),K=o.useRef(null),I=o.useMemo(()=>V.find(re=>re.id===$)??null,[$,V]),se=!!(s&&I?.id===s),q=kt(N),ae=Ld(D),ye=o.useMemo(()=>Ho(N,k),[N,k]),pe=o.useMemo(()=>$o(N,k),[N,k]),Ze=ye.prompt,Ae=o.useMemo(()=>ye.isGoal||pe?[]:g,[ye.isGoal,pe,g]);o.useEffect(()=>{$&&V.some(re=>re.id===$)||ee(ne)},[$,V,ne]),o.useEffect(()=>{E.current||A(Un(j))},[j]);const ft=o.useCallback(re=>{E.current=!0,A(Un(re))},[]);o.useEffect(()=>{if(W.current){W.current=!1;return}O(Di($)),Y("")},[$]),o.useEffect(()=>{Y("")},[P]),o.useEffect(()=>{v(0)},[k,g,N]);const Re=o.useCallback(re=>{y(re.prompt)},[]),De=o.useCallback(()=>{y(pe?.value??"/goal "),v(0),!(typeof window>"u")&&window.setTimeout(()=>{const re=K.current;re?.focus();const Ne=re?.value.length??0;re?.setSelectionRange(Ne,Ne)},0)},[pe]),He=o.useCallback(async re=>{if(re.preventDefault(),pe){De();return}const Ne=Wn(k,Ae,x);if(Ne){Re(Ne);return}const Te=hh({title:w,description:k,agent:N,model:M,project:P,branch:J,priority:"normal",assignTo:$,mode:D,images:R});if(Te){Q(!0);try{const ve=await ic(Te);l(ve)}catch(ve){ce.error(ve instanceof Error?ve.message:"Failed to create task")}finally{Q(!1)}}},[w,k,N,M,P,J,$,D,R,l,Ae,x,Re,pe,De]),Ke=Ii(w,Ze,R.length>0),je=!pe&&!!(Ke&&N&&$&&(Ze.trim()||R.length>0)),Be=o.useCallback(re=>{if(re.nativeEvent.isComposing)return;if(pe&&(re.key==="ArrowDown"||re.key==="ArrowUp")){re.preventDefault();return}const Ne=No(k,Ae);if(Ne.length>0&&(re.key==="ArrowDown"||re.key==="ArrowUp")){re.preventDefault(),v(Te=>ko(Te,Ne.length,re.key==="ArrowDown"?1:-1));return}if(re.key==="Enter"){if(pe&&!re.shiftKey){re.preventDefault(),De();return}const Te=Wn(k,Ae,x);if(Te&&!re.shiftKey){re.preventDefault(),Re(Te);return}}re.key==="Enter"&&(re.ctrlKey||re.metaKey)&&je&&!S&&(re.preventDefault(),re.currentTarget.form?.requestSubmit())},[De,Re,Ae,je,k,pe,x,S]),G=R.length>0?e.jsx(Gm,{images:R,removeImage:Z}):null,ge=e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Assign to"}),e.jsxs($e,{value:$,onValueChange:ee,children:[e.jsx(qe,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Je,{placeholder:"Select node"})}),e.jsx(Ve,{children:ur(V,s)})]})]}),be=e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Agent"}),e.jsxs($e,{value:N,onValueChange:ft,children:[e.jsx(qe,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Je,{placeholder:"Select agent"})}),e.jsx(Ve,{children:ra()})]})]}),et=e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Mode"}),e.jsxs($e,{value:D,onValueChange:re=>_(re),children:[e.jsx(qe,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Je,{placeholder:"Select mode"})}),e.jsx(Ve,{children:aa()})]})]}),_e=e.jsx(Xn,{value:P,onChange:O,assignTo:$,nodes:t,assignableNodes:V}),rt=e.jsx(ha,{value:J,onChange:Y,project:P,assignTo:$,nodes:t,assignableNodes:V});return f==="composer"?e.jsxs("form",{onSubmit:He,className:L("space-y-4",d),children:[e.jsx("input",{ref:F,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",Te="border-border/70 bg-background/55 text-foreground",ve=N===Un(j),at=D===Mn;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($e,{value:$,onValueChange:ee,children:[e.jsx(qe,{className:L(re,Te,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${I?.name??"unassigned"}`,"aria-label":`Assigned node: ${I?.name??"unassigned"}`,children:I?e.jsxs(e.Fragment,{children:[e.jsx(Pr,{isCurrent:se}),e.jsx("span",{className:"min-w-0 truncate",children:I.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(Je,{placeholder:"Select node"})}),e.jsx(Ve,{children:ur(V,s)})]}),T?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(dt,{id:"task-title-composer",type:"text",value:w,onChange:Pe=>b(Pe.target.value),onKeyDown:Pe=>{(Pe.key==="Enter"||Pe.key==="Escape")&&(Pe.preventDefault(),te(!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(X,{type:"button",variant:"ghost",size:"icon",onClick:()=>te(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(En,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>te(!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:Ke||"Title","aria-label":Ke?`Edit title: ${Ke}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:Ke||"Title"}),e.jsx(Jt,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",ref:K,value:k,onChange:Pe=>y(Pe.target.value),onKeyDown:Be,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(ma,{agent:N,query:k,onSelect:De}),e.jsx(Xs,{query:k,quickChats:Ae,selectedIndex:x,onActiveIndexChange:v,onSelect:Re}),e.jsxs("div",{className:"chat-composer__rail flex min-w-0 flex-nowrap items-center gap-2 px-3 pb-3",children:[e.jsx(X,{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(or,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsxs($e,{value:N,onValueChange:ft,children:[e.jsxs(qe,{className:L(re,"chat-composer__icon-trigger",ve?Ne:Te),title:`Agent: ${q}`,"aria-label":`Agent: ${q}`,children:[e.jsx(At,{agent:N}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:q})]}),e.jsx(Ve,{children:ra()})]}),e.jsx(Pi,{agent:N,value:M,onChange:B,chip:!0,triggerClassName:L(re,"chat-composer__icon-trigger",M?Te:Ne),contentClassName:"max-h-80 shadow-none"}),e.jsxs($e,{value:D,onValueChange:Pe=>_(Pe),children:[e.jsxs(qe,{className:L(re,"chat-composer__icon-trigger",at?Ne:Te),title:`Mode: ${ae}`,"aria-label":`Mode: ${ae}`,children:[e.jsx(Fu,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:ae})]}),e.jsx(Ve,{children:aa()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[c&&e.jsxs(X,{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(ut,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:u})]}),e.jsxs(X,{type:"submit",size:"icon",disabled:!je||S,className:"h-10 w-10 rounded-sm shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[S?e.jsx(he,{className:"h-4 w-4 animate-spin"}):e.jsx(si,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:S?"Creating chat":p})]})]})]})]}),e.jsx("div",{className:"chat-composer__location flex flex-wrap items-center gap-2 px-1",children:(()=>{const Pe="border-border/40 bg-muted/40 text-foreground/80 hover:bg-muted/60 hover:text-foreground";return e.jsxs(e.Fragment,{children:[e.jsx(Xn,{value:P,onChange:O,assignTo:$,nodes:t,assignableNodes:V,layout:"composer",chipClassName:re,chipActiveClassName:Pe,chipInactiveClassName:Pe,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"}),e.jsx(ha,{value:J,onChange:Y,project:P,assignTo:$,nodes:t,assignableNodes:V,layout:"composer",chipClassName:re,chipActiveClassName:Pe,chipInactiveClassName:Pe,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"})]})})()})]})})(),(G||H)&&e.jsxs("div",{className:"space-y-2 rounded-sm border border-border/60 bg-background/45 p-2.5",children:[G,H&&e.jsx("div",{className:"text-[11px] text-destructive",children:H}),!H&&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:He,className:L("space-y-4",d),children:[e.jsx("input",{ref:F,type:"file",accept:"image/*",multiple:!0,onChange:ie,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{htmlFor:"task-description",className:"text-[11px] font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",ref:K,value:k,onChange:re=>y(re.target.value),onKeyDown:Be,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(ma,{agent:N,query:k,onSelect:De}),e.jsx(Xs,{query:k,quickChats:Ae,selectedIndex:x,onActiveIndexChange:v,onSelect:Re}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(X,{type:"button",variant:"outline",onClick:le,className:"rounded-sm",children:[e.jsx(or,{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,H&&e.jsx("p",{className:"text-[11px] text-destructive",children:H})]}),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(tt,{htmlFor:"task-title",className:"text-[11px] font-medium",children:"Chat title"}),e.jsx(dt,{id:"task-title",type:"text",value:w,onChange:re=>b(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:Ke?`Will appear as: ${Ke}`:"A title will be generated from the first line of the prompt."})]}),be,e.jsx(mh,{agent:N,value:M,onChange:B}),et]}),_e,rt,ge,e.jsxs("div",{className:L("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",m),children:[c&&e.jsx(X,{type:"button",variant:"ghost",onClick:c,className:"rounded-sm",children:u}),e.jsx(X,{type:"submit",disabled:!je||S,className:"rounded-sm px-5",children:S?"Creating...":p})]})]})}function ph({nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,defaultMode:d="chat",mode:m,onModeChange:p,layout:u="default",className:h,footerClassName:f,autoFocus:j=!1,quickChats:g=[],defaultTaskAgent:w}){const[b,k]=o.useState(d),y=m!==void 0,x=y?m:b,v=N=>{y||k(N),p?.(N)};return e.jsxs("div",{className:L("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(X,{type:"button",variant:x==="chat"?"default":"ghost",onClick:()=>v("chat"),className:"h-7 flex-1 rounded-sm shadow-none",children:[e.jsx(oc,{className:"h-4 w-4"}),"New chat"]}),e.jsxs(X,{type:"button",variant:x==="native"?"default":"ghost",onClick:()=>v("native"),className:"h-7 flex-1 rounded-sm shadow-none",children:[e.jsx(Ar,{className:"h-4 w-4"}),"Load session"]})]}),x==="chat"?e.jsx(fh,{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:j,layout:u,defaultTaskAgent:w,quickChats:g},`${a??""}:${i??""}`):e.jsx(uh,{nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,onCreated:l,onCancel:c,footerClassName:f,autoFocus:j})]})}function xh({onClick:t,running:n}){return e.jsxs(X,{size:"icon",onClick:t,"aria-label":n?"Open composer - task running":"Open composer",title:n?"Task running - open composer":"Open composer",className:L("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(Jt,{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 pa({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 gh({hasVisibleTranscriptEvents:t,hasTranscriptProgress:n,inputCollapsed:s}){return{collapsedButtonRunning:n&&t&&s,showDockedProgress:n&&t&&!s,showInlineProgress:n&&!t}}const cn="72f988bf-86f1-41af-91ab-2d7cd011db47",Ri=`${cn} (MSIT)`;function bh({open:t,onOpenChange:n,onShare:s,onStopShare:r,sharing:a,stopping:i=!1,shareResult:l}){return e.jsx(mt,{open:t,onOpenChange:n,children:e.jsxs(ht,{className:"max-w-md rounded-sm p-4",children:[e.jsx(vt,{className:"sr-only",children:"Share conversation"}),e.jsx(vh,{onOpenChange:n,onShare:s,onStopShare:r,sharing:a,stopping:i,shareResult:l})]})})}function vh({onOpenChange:t,onShare:n,onStopShare:s,sharing:r,stopping:a=!1,shareResult:i}){const[l,c]=o.useState(i?.tenant??cn),[d,m]=o.useState(i?.scope??"chat"),p=i?.url?Do(i.url):null,u=r||a;return o.useEffect(()=>{c(i?.tenant??cn),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(wh,{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(xa,{active:d==="chat",title:"Chat only",description:"Conversation transcript and opening prompt.",onClick:()=>m("chat")}),e.jsx(xa,{active:d==="filesPreview",title:"Chat, files and preview",description:"Transcript plus task output files and HTML preview.",onClick:()=>m("filesPreview")})]})]}),p&&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:p,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none","aria-label":"Shared link"}),e.jsx(X,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-sm text-muted-foreground",onClick:()=>{In(p,"Shared link copied")},"aria-label":"Copy shared link",title:"Copy shared link",children:e.jsx(_o,{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(X,{variant:"outline",onClick:()=>t(!1),disabled:u,className:"h-8 text-xs",children:i?"Done":"Cancel"}),i&&s&&e.jsxs(X,{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(X,{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 wh({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 j=f.target;j instanceof Node&&(m.current?.contains(j)||(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 p=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:yh(t)}),e.jsx(st,{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:()=>p(cn),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:Ri}),t===cn&&e.jsx(En,{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(),p(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:()=>p(c),className:"flex h-7 w-7 items-center justify-center rounded-sm hover:bg-background/60",children:e.jsx(En,{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(ut,{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(Jt,{className:"h-3 w-3"})]})})]})]})]})}function yh(t){return t===cn?Ri:t}function xa({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 jh(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 Nh({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(ku,{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 ${kt(s.targetAgent)}`,children:[e.jsx(Qo,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx(At,{agent:s.targetAgent,className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:kt(s.targetAgent)})]}),e.jsx("div",{className:"break-words [overflow-wrap:anywhere]",children:jh(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(Sr,{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(X,{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(ut,{className:"h-3 w-3"})})]},s.id)})})]})})}const kh="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",Sh=[{value:"transcript",label:"Transcript",icon:lc},{value:"files",label:"Files",icon:hn,activeIcon:rs},{value:"diff",label:"Diff",icon:Yn},{value:"preview",label:"Preview",icon:Gd}];function Ch({activeTab:t}){return e.jsx(os,{className:"h-auto max-w-full justify-start gap-2 overflow-x-auto rounded-sm !bg-muted/40 !p-0.5 !shadow-none",children:Sh.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:kh,children:e.jsx(s,{className:"h-3.5 w-3.5","aria-hidden":"true"})},n.value)})})}const Li="pointer-events-auto h-5 w-5 shrink-0 rounded-sm bg-muted/65 text-muted-foreground hover:bg-muted hover:text-foreground",es="h-3.5 w-3.5";function mr({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(Bi,{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(Oi,{operationsOpen:r,onToggleOperations:a,className:"xl:hidden"})]})}function Bi({className:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,onToggleTasks:r}){const a=globalThis.window?.matchMedia("(min-width: 1024px)")?.matches?n:s;return e.jsx(X,{variant:"ghost",size:"icon",onClick:r,title:a?"Hide tasks":"Show tasks","aria-label":a?"Hide tasks":"Show tasks",className:L(Li,t),children:a?e.jsx(Dn,{className:es}):e.jsx(nt,{className:es})})}function Oi({className:t,operationsOpen:n,onToggleOperations:s}){return e.jsx(X,{variant:"ghost",size:"icon",onClick:s,title:n?"Hide cluster":"Show cluster","aria-label":n?"Hide cluster":"Show cluster",className:L(Li,t),children:n?e.jsx(nt,{className:es}):e.jsx(Dn,{className:es})})}const ga="h-7 w-7 rounded-sm border-0 bg-primary/10 text-primary backdrop-blur hover:bg-primary/20 hover:text-primary";function Th({active:t,onScrollToBottom:n,onScrollToTop:s}){return e.jsxs("div",{className:L("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(X,{type:"button",variant:"ghost",size:"icon",className:ga,onClick:s,"aria-label":"Scroll to top",title:"Scroll to top",children:e.jsx(cc,{className:"h-4 w-4"})}),e.jsx(X,{type:"button",variant:"ghost",size:"icon",className:ga,onClick:n,"aria-label":"Scroll to bottom",title:"Scroll to bottom",children:e.jsx(st,{className:"h-4 w-4"})})]})}function Ah(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 Eh({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(At,{agent:t,className:"h-3 w-3 shrink-0 text-muted-foreground/65","aria-hidden":"true"}),e.jsxs("span",{className:"truncate",children:[kt(t)," to ",kt(n)]}),e.jsx(At,{agent:n,className:"h-3 w-3 shrink-0 text-primary/60","aria-hidden":"true"})]})})}const ba="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",Ut={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:`${ba} mt-0`,action:ba},Mh=30,Dh=1600;function _h({savedScrollTop:t,scrollHeight:n,clientHeight:s}){const r=Math.max(0,n-s);return Math.min(Math.max(0,t??r),r)}function ks(t){return t.scrollHeight-t.scrollTop-t.clientHeight<Mh}function va({explicitBottomStickUntil:t,now:n,wasAtBottom:s}){return s||t>n}function Ss(t,n){return!!(n&&(t===n||t.contains(n)))}function Cs(t){const n=t.ownerDocument.getSelection();if(!n||n.isCollapsed||n.rangeCount===0)return!1;if(Ss(t,n.anchorNode)||Ss(t,n.focusNode))return!0;for(let s=0;s<n.rangeCount;s+=1)if(Ss(t,n.getRangeAt(s).commonAncestorContainer))return!0;return!1}function Ph({atTop:t,inputCollapseDisabled:n,scrollingUp:s}){return!n&&(s||t)}function Ih({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),p=o.useRef(new Map),u=o.useRef(0),h=o.useRef(!0),f=o.useCallback((x=c.current)=>{const v=l.current;!v||!x||(p.current.set(x,v.scrollTop),m.current=v.scrollTop,h.current=ks(v))},[]),j=o.useCallback((x=c.current)=>{const v=l.current;!v||!x||(v.scrollTop=_h({savedScrollTop:p.current.get(x),scrollHeight:v.scrollHeight,clientHeight:v.clientHeight}),m.current=v.scrollTop,h.current=ks(v))},[]),g=o.useCallback((x,v=c.current)=>{x.scrollTop=x.scrollHeight,m.current=x.scrollTop,h.current=!0,v&&p.current.set(v,x.scrollTop)},[]),w=o.useCallback((x=c.current)=>{const v=l.current;u.current=Date.now()+Dh,v&&(g(v,x),requestAnimationFrame(()=>{g(v,x),requestAnimationFrame(()=>g(v,x))}))},[g]),b=o.useCallback((x=c.current)=>{const v=l.current;u.current=0,v&&(v.scrollTop=0,m.current=0,h.current=!1,x&&p.current.set(x,0))},[]),k=o.useCallback(x=>{const v=x.currentTarget,N=m.current,A=v.scrollTop<N&&N-v.scrollTop>10,E=v.scrollTop<=0,M=Cs(v);if(f(),M){u.current=0;return}if(!d.current){if(ks(v)){i(!1),d.current=!0,setTimeout(()=>{d.current=!1},300);return}(A||E)&&(u.current=0,Ph({atTop:E,inputCollapseDisabled:r,scrollingUp:A})&&i(!0))}},[r,f,i]),y=o.useCallback(x=>{t==="transcript"&&f(),a(x),x==="transcript"&&requestAnimationFrame(()=>j())},[t,j,f,a]);return o.useLayoutEffect(()=>{r&&i(!1)},[r,i]),o.useLayoutEffect(()=>{const x=c.current;x&&x!==n&&f(x),c.current=n,t==="transcript"&&requestAnimationFrame(()=>j(n))},[n,t,j,f]),o.useLayoutEffect(()=>{const x=l.current;if(!x||t!=="transcript"||!n)return;const v=va({explicitBottomStickUntil:u.current,now:Date.now(),wasAtBottom:h.current});if(Cs(x)){u.current=0,f(n);return}v&&g(x,n),f(n)},[n,t,s,f,g]),o.useLayoutEffect(()=>{const x=l.current,v=x?.firstElementChild;if(!x||!v||t!=="transcript"||typeof ResizeObserver>"u")return;const N=new ResizeObserver(()=>{if(Cs(x)){u.current=0,f();return}va({explicitBottomStickUntil:u.current,now:Date.now(),wasAtBottom:h.current})?g(x):f()});return N.observe(x),N.observe(v),()=>N.disconnect()},[t,n,f,g]),{handleTranscriptScroll:k,handleTranscriptTabChange:y,scrollTranscriptToBottom:w,scrollTranscriptToTop:b,transcriptScrollRef:l}}function Fi(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 Rh="harness";function Lh(t){return typeof t=="object"&&t!==null}function Bh(t){return typeof t=="string"&&t.trim().length>0?t.trim():""}function Oh(t){return Lh(t.agentSessions)?Object.keys(t.agentSessions).map(n=>n.trim()).filter(Boolean):[]}function zi(t){return Bh(t.payload.activeAgent)||t.agent}function Ui(t){return new Set([t.agent,zi(t),...Oh(t.payload)].filter(Boolean)).size>1}function $i(t){return Ui(t)?Rh:t.agent}const Fh=o.lazy(async()=>({default:(await gr(()=>import("./FilesTab-CH1lwzT9.js"),__vite__mapDeps([0,1,2,3,4,5]))).FilesTab})),zh=o.lazy(async()=>({default:(await gr(()=>import("./PreviewTab-T_Y0AhqI.js").then(n=>n.c),__vite__mapDeps([6,1,2]))).PreviewTab})),Uh=o.lazy(async()=>({default:(await gr(()=>import("./DiffTab-Bf9BAMpM.js"),__vite__mapDeps([7,1,2,5,4,3,6]))).DiffTab}));function $h({onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,cluster:i,activeTab:l,setActiveTab:c,creatingTask:d,createMode:m,createDefaults:p,activeTask:u,assignedNode:h,taskLoading:f,transcriptLoading:j,taskError:g,displayEvents:w,initialPromptAlreadyInLogs:b,initialPrompt:k,supportsFollowUp:y,taskUnavailable:x,chatDisabled:v,chatDisabledReason:N,questionBypassEnabled:A,isRunning:E,isStarting:M,hasPendingFollowUp:B,canCancel:D,canRetry:_,onRetry:P,onCancel:O,onReloadNativeTranscript:W,onShareTask:J,onStopShareTask:Y,onStartCreateTask:V,onCancelCreateTask:ne,onCreateTask:$,onSendMessage:ee,onCancelQueuedMessage:S,onQuestionBypassChange:Q,onSubmitQuestionResponse:T,quickChats:te=[]}){const[R,H]=o.useState(!1),[F,le]=o.useState(!1),[ie,ue]=o.useState(!1),[Z,K]=o.useState(!1),[I,se]=o.useState(!1),[q,ae]=o.useState({}),[ye,pe]=o.useState(new Set),[Ze,Ae]=o.useState(new Set),[ft,Re]=o.useState(null),[De,He]=o.useState(null),Ke=u?.effectiveProjectPath??u?.project??"default workspace",je=u?h?.name??er(u.assignedTo,i?.nodes,u.assignedNodeName):"unassigned",Be=u?$i(u):"",G=u?zi(u):"",ge=u&&Ui(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...",et=u?[{label:"Working dir",value:Ke,mono:!0},...u.branch?[{label:"Branch",value:u.branch,mono:!0}]:[],{label:"Agent",value:Be,mono:!0},{label:"Node",value:je}]:[],_e=!!(k&&!b),rt=_e||w.length>0,re=E&&rt,Ne=(M||B||E)&&!re,Te=re?"The agent is still working on this conversation.":Ne?be:null,{collapsedButtonRunning:ve,showDockedProgress:at,showInlineProgress:Pe}=gh({hasTranscriptProgress:!!Te,hasVisibleTranscriptEvents:rt,inputCollapsed:R}),_t=u?.conversationKind==="nativeSession",pt=Bd(u),pn=j?"Loading transcript":_t?"No transcript imported":"Transcript is warming up",en=j?"Loading transcript...":_t?"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.",St=u?.queuedMessages??[],wt=o.useMemo(()=>Od(w),[w]),xn=o.useMemo(()=>{let me=u?.agent??"";return wt.map(ke=>{const Ge=Ah(ke.event);if(Ge)return me=Ge.toAgent,{...ke,agent:me,handoff:Ge};const Ue=typeof ke.event.agent=="string"&&ke.event.agent.trim()?ke.event.agent.trim():me;return{...ke,agent:Ue,handoff:null}})},[u?.agent,wt]),gn=o.useMemo(()=>{const me=u?.assignedTo?u.assignedTo===i?.self?.id?h?.supportedAgents??i.self.supportedAgents:h?.supportedAgents:i?.self?.supportedAgents;return dc({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]),Pt=o.useMemo(()=>wt.findIndex(({event:me})=>qh(me)),[wt]),Ft=o.useMemo(()=>Fd("transcript",wt.map(me=>me.event)),[wt]),tn=u&&!ye.has(u.id)?q[u.id]??u.activeShare??null:null,Ct=u?.id??null,nn=`${Ct??"none"}:${w.length}:${St.length}:${_e?1:0}:${j?1:0}:${Pe?1:0}`,{handleTranscriptScroll:Fe,handleTranscriptTabChange:ot,scrollTranscriptToBottom:yt,scrollTranscriptToTop:Tt,transcriptScrollRef:U}=Ih({activeTab:l,activeTaskId:Ct,contentVersion:nn,inputCollapseDisabled:!!Te,setActiveTab:c,setInputCollapsed:H}),{markScrollbarActive:ze,scrollbarActive:Ie}=Fi(),We=o.useCallback(me=>{ze(),Fe(me)},[Fe,ze]),Qe=o.useCallback(me=>{Re(ke=>({path:me,requestId:(ke?.requestId??0)+1})),ot("files")},[ot]),sn=o.useCallback(me=>{He(ke=>({path:me,requestId:(ke?.requestId??0)+1})),ot("preview")},[ot]),xe=o.useCallback((me,ke)=>{yt(),ee(me,ke)},[ee,yt]);return o.useEffect(()=>{Re(null),He(null)},[Ct]),d?e.jsx(Vh,{onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,cluster:i,defaultMode:m,createDefaults:p,onCancel:ne,onCreated:$,quickChats:te}):!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(mr,{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(_r,{value:l,onValueChange:ot,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(Bi,{desktopTasksOpen:n,mobileTasksPanelOpen:s,onToggleTasks:t,className:"lg:hidden"}),e.jsx(Oi,{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(Io,{status:u.status,isNative:_t}),pt&&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(qo,{className:"h-3 w-3","aria-hidden":"true"}),"Goal"]}),u.priority!=="normal"&&e.jsx(uc,{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(Ch,{activeTab:l}),x&&e.jsx(Le,{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:mc(u.updatedAt)}),_&&e.jsxs(X,{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(hc,{className:"h-3.5 w-3.5"}),"Retry"]}),_t&&W&&e.jsx(X,{variant:"ghost",size:"icon",onClick:W,disabled:j,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(ni,{className:L("h-3.5 w-3.5",j&&"animate-spin")})}),e.jsx(X,{type:"button",variant:"ghost",size:"icon",disabled:x,title:x?"Unavailable tasks cannot be shared.":"Share conversation","aria-label":x?"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(Zn,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsx(bt,{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:L("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",Ie&&"scrollbar-line-active"),onScroll:We,children:e.jsxs("div",{"data-transcript-scroll-content":"true",className:"mx-auto flex max-w-[72rem] flex-col gap-4",children:[_e&&k&&e.jsx(oa,{event:k,agent:u.agent,sentAsGoal:pt,taskRootPath:u.effectiveProjectPath,onOpenFilePath:Qe,questionBypassEnabled:A,onQuestionBypassChange:Q,onSubmitQuestionResponse:T,questionResponseDisabled:!y||v}),xn.map(({event:me,subItems:ke,agent:Ge,handoff:Ue},zt)=>Ue?e.jsx(Eh,{fromAgent:Ue.fromAgent,toAgent:Ue.toAgent},Ft[zt]):e.jsx(oa,{event:me,agent:Ge,subItems:ke,sentAsGoal:pt&&!_e&&zt===Pt,taskRootPath:u.effectiveProjectPath,onOpenFilePath:Qe,questionBypassEnabled:A,onQuestionBypassChange:Q,onSubmitQuestionResponse:T,questionResponseDisabled:!y||v},Ft[zt])),!rt&&!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:pn}),e.jsx("div",{className:"mt-2 text-[11px] leading-6 text-muted-foreground",children:en})]}),(!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&&!Ze.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:()=>Ae(me=>new Set(me).add(u.id)),className:"rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(ut,{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})]})]}),Pe&&Te&&e.jsx(pa,{children:Te})]})})}),e.jsx(Th,{active:Ie,onScrollToBottom:()=>yt(),onScrollToTop:()=>Tt()}),at&&Te&&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(pa,{children:Te})})}),y?e.jsxs(e.Fragment,{children:[R&&e.jsx(xh,{running:ve,onClick:()=>{H(!1),yt(),requestAnimationFrame(()=>document.querySelector('[data-chat-input-textarea="true"]')?.focus())}}),e.jsxs("div",{className:`shrink-0 ${R?"hidden":""}`,children:[e.jsx(Nh,{messages:St,onCancelMessage:S}),e.jsx(jm,{onSend:xe,disabled:v,disabledReason:N,contextItems:et,agent:u.agent,currentAgent:ge,taskId:u.id,availableAgents:gn,model:typeof u.payload.model=="string"?u.payload.model:null,placeholder:v?N:E?"Queue a message for the next turn...":"Continue the conversation...",running:E||M||B,onStop:D?()=>le(!0):void 0,quickChats:te})]})]}):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(bt,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(vs,{label:"Loading files..."}),children:e.jsx(Fh,{taskId:u.id,requestedFilePath:ft?.path??null,requestedFileRequestId:ft?.requestId??0,onPreviewFile:sn})})}),e.jsx(bt,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(vs,{label:"Loading preview..."}),children:e.jsx(zh,{taskId:u.id,requestedEntryPath:De?.path??null,requestedEntryRequestId:De?.requestId??0})})}),e.jsx(bt,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(vs,{label:"Loading diff..."}),children:e.jsx(Uh,{taskId:u.id})})}),e.jsx($t,{open:F,onOpenChange:le,children:e.jsxs(qt,{className:Ut.content,children:[e.jsxs(Vt,{className:Ut.header,children:[e.jsx(Ht,{className:Ut.title,children:"Stop this task?"}),e.jsx(Kt,{className:Ut.description,children:"The task will stop and move to a cancelled state."})]}),e.jsxs(Gt,{className:Ut.footer,children:[e.jsx(Wt,{className:Ut.cancel,children:"Keep running"}),e.jsx(Qt,{className:Ut.action,onClick:O,children:"Stop task"})]})]})}),e.jsx(bh,{open:ie,onOpenChange:ue,sharing:Z,stopping:I,shareResult:tn,onShare:async me=>{if(!u)return null;K(!0);try{const ke=await J(me);return ke?.url&&(ae(Ge=>({...Ge,[u.id]:ke})),pe(Ge=>{const Ue=new Set(Ge);return Ue.delete(u.id),Ue})),ke}finally{K(!1)}},onStopShare:async()=>{if(!u)return!1;se(!0);try{const me=await Y();return me!==!1&&(ae(ke=>{const Ge={...ke};return delete Ge[u.id],Ge}),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(mr,{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(Po,{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(X,{onClick:()=>V(),className:"mt-4 h-8 rounded-sm px-3",children:[e.jsx(Ln,{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 qh(t){return t.type!=="user"||t.isMeta===!0||t.isSidechain===!0?!1:!!Cr(t)?.some(s=>s.type==="text"||s.type==="image")}function Vh({onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,cluster:i,defaultMode:l,createDefaults:c,onCancel:d,onCreated:m,quickChats:p}){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:Ln},{value:"native",label:"Load session",icon:Ar}].map(j=>{const g=j.icon,w=j.value===u;return e.jsxs("button",{type:"button",onClick:()=>h(j.value),"aria-pressed":w,className:L("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",w?"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:j.label})]},j.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(mr,{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(ph,{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:p})})})]})}function Hh({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 fc({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(ht,{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(Mt,{className:"space-y-1 text-left",children:[e.jsx(vt,{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(tt,{htmlFor:"leader-endpoint",children:"Leader Node URL"}),e.jsx(Le,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),e.jsx(dt,{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(br,{className:"border-t border-border/60 pt-3",children:e.jsx(X,{type:"submit",disabled:!n.trim()||r,className:"rounded-sm",children:r?"Joining...":"Join node"})})]})]})})}function Kh({open:t,onOpenChange:n,onAdded:s}){return e.jsx(mt,{open:t,onOpenChange:n,children:e.jsx(Hh,{onAdded:()=>{n(!1),s()}})})}const Gh="pointer-events-auto 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",Wh="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",Qh="h-2.5 w-2.5";function qi({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:L("pointer-events-auto 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 Yh({className:t,label:n,onToggle:s,side:r,visible:a}){const i=r==="left"?a?Dn:nt:a?nt:Dn;return e.jsx("button",{type:"button","aria-label":n,title:n,onClick:s,className:L(Gh,t),children:e.jsx("span",{className:Wh,"aria-hidden":"true",children:e.jsx(i,{className:Qh,strokeWidth:2.1})})})}function wa({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:L("group pointer-events-none absolute top-0 z-30 hidden h-full w-4",d,t),children:[r&&e.jsx(qi,{panel:r,orientation:"vertical",label:`Resize ${r} panel`,panelResize:a,className:"left-1/2 top-0 h-full w-2 cursor-col-resize"}),e.jsx(Yh,{side:l,visible:c,label:n,onToggle:s,className:L(m,"left-1/2 -translate-x-1/2 group-hover:opacity-100")})]})}function Jh({conversationPanel:t,desktopTasksOpen:n,mobileTaskSidebar:s,mobileTasksPanelOpen:r,mobileTasksPanelRef:a,operationsOpen:i,operationsPanelRef:l,operationsSidecar:c,panelResize:d,taskSidebar:m,terminalPanel:p,onCloseOperations:u,onCloseTaskList:h,onToggleOperations:f,onToggleTasks:j}){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(wa,{screen:"lg",side:"left",visible:n,label:n?"Hide tasks":"Show tasks",onToggle:j,panel:n?"tasks":void 0,panelResize:d,className:n?"left-[var(--dashboard-tasks-width)] -translate-x-1/2":"left-0"}),e.jsx("div",{className:L("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}),p&&e.jsxs("div",{className:"relative h-[var(--dashboard-terminal-height)] min-h-0 shrink-0",children:[e.jsx(qi,{panel:"terminal",orientation:"horizontal",label:"Resize terminal panel",panelResize:d,className:"-top-1 left-0 h-2 w-full cursor-row-resize"}),p]})]}),e.jsx(wa,{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:L("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 Zh=10,Yt="__all__";function lt(t){return"session"in t}function ya(t,n){return n&&t.some(s=>s.id===n)?n:t[0]?.id??""}function Ts(t){return t&&(Di(t.id)||t.workDir)||""}function qn(t,n,s){let r=!1;const a=t.map(i=>lt(i)&&i.session.id===s.id?(r=!0,{...i,nodeName:n,session:s}):i);return hr(r?a:[...a,{id:`session-${s.id}`,nodeName:n,session:s}])}function Vi(t,n){return t.filter(lt).filter(s=>s.session.nodeId===n).sort((s,r)=>r.session.startedAt-s.session.startedAt)}function Xh(t){const n=t.filter(lt).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 ef(t,n){return!!(t&&n&&!t.contains(n))}function tf(t,n,s){if(s===Yt)return s;const r=Vi(t,n);return r.some(a=>a.session.id===s)?s:r[0]?.session.id??Yt}function nf(t,n,s){return s===Yt?t.filter(r=>!lt(r)||r.session.nodeId===n):t.filter(r=>lt(r)&&r.session.nodeId===n&&r.session.id===s)}function hr(t){const n=t.map((r,a)=>({entry:r,index:a})).filter(({entry:r})=>lt(r)&&r.session.status!=="running").sort((r,a)=>!lt(r.entry)||!lt(a.entry)?0:a.entry.session.startedAt-r.entry.session.startedAt||a.index-r.index),s=new Set(n.slice(0,Zh).map(({entry:r})=>lt(r)?r.session.id:""));return t.filter(r=>!lt(r)||r.session.status==="running"||s.has(r.session.id))}function fr(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 sf(t){const n=t.session.command.length>48?`${t.session.command.slice(0,45)}...`:t.session.command;return`${t.nodeName} - ${fr(t.session)} - ${n}`}function Hi(t,n=48){return t.length>n?`${t.slice(0,n-3)}...`:t}function rf(t,n){return n===Yt?"All sessions":t?Hi(t.session.command,34):"Command session"}function ja(t){return t.status==="stopped"?"":t.stderr}function af({nodes:t,defaultNodeId:n,onClose:s,initialHistory:r=[]}){const[a,i]=o.useState(()=>ya(t,n)),l=o.useMemo(()=>t.find(T=>T.id===a)??t[0]??null,[t,a]),[c,d]=o.useState(()=>Ts(l)),[m,p]=o.useState(""),[u,h]=o.useState(()=>hr(r)),[f,j]=o.useState(Yt),[g,w]=o.useState(!1),[b,k]=o.useState(!1),[y,x]=o.useState(!1),[v,N]=o.useState(!1),[A,E]=o.useState(!1),M=o.useRef(null),B=o.useRef(null),D=o.useMemo(()=>t.find(T=>T.id===a)??t[0]??null,[t,a]),_=o.useMemo(()=>Vi(u,D?.id??""),[u,D]),P=o.useMemo(()=>Xh(_),[_]),O=o.useMemo(()=>_.find(T=>T.session.id===f),[f,_]),W=o.useMemo(()=>nf(u,D?.id??"",f),[u,D,f]),J=o.useRef(D?.id??"");o.useEffect(()=>{a&&t.some(T=>T.id===a)||i(ya(t,n))},[n,t,a]),o.useEffect(()=>{const T=D?.id??"";J.current!==T&&(J.current=T,d(Ts(D)))},[D]),o.useEffect(()=>{j(T=>tf(u,D?.id??"",g?T:""))},[u,D,g]),o.useEffect(()=>{M.current?.scrollTo({top:M.current.scrollHeight})},[u]),o.useEffect(()=>{let T=!1;async function te(){const R=await Promise.allSettled(t.map(async H=>({node:H,response:await xc(H.id)})));T||h(H=>R.reduce((F,le)=>le.status!=="fulfilled"?F:le.value.response.sessions.reduce((ie,ue)=>qn(ie,le.value.node.name,ue),F),H))}return t.length>0&&te(),()=>{T=!0}},[t]),o.useEffect(()=>{const T=u.filter(lt).filter(R=>R.session.status==="running");if(T.length===0)return;const te=window.setInterval(()=>{for(const R of T)pc(R.session.nodeId,R.session.id).then(H=>h(F=>qn(F,R.nodeName,H))).catch(()=>{})},1e3);return()=>window.clearInterval(te)},[u]);const Y=o.useRef(null);async function V(T){if(T.preventDefault(),!D||!m.trim()||A)return;const te=m.trim(),R=D.name;E(!0),p("");try{const H=await bc(D.id,{command:te,...c.trim()?{cwd:c.trim()}:{}});h(F=>qn(F,R,H)),j(H.id),w(!0)}catch(H){h(F=>[...F,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,nodeName:R,command:te,error:H instanceof Error?H.message:"Command failed"}])}finally{E(!1)}}async function ne(T,te){T.stopPropagation();const R=await gc(te.session.nodeId,te.session.id);h(H=>qn(H,te.nodeName,R))}function $(T){j(T),w(!0),k(!1)}function ee(T){b&&ef(B.current,T.target)&&k(!1)}function S(T,te,R,H,F){return e.jsxs("div",{className:"border-t border-border/60 py-1",children:[e.jsxs("button",{type:"button",onClick:H,"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(st,{className:L("h-3 w-3 transition-transform",R&&"-rotate-90")})]}),!R&&(te.length>0?te.map(Q):e.jsx("div",{className:"node-terminal__control px-2 py-1 text-muted-foreground",children:F}))]})}function Q(T){const te=f===T.session.id,R=T.session.status==="running";return e.jsxs("div",{className:L("node-terminal__control group flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/65",te&&"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:L("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(tr,{className:"h-3 w-3"}):e.jsx(gs,{className:"h-3 w-3"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-foreground",children:Hi(T.session.command,44)}),e.jsxs("span",{className:"node-terminal__small block truncate text-muted-foreground",children:[T.nodeName," · ",fr(T.session)]})]})]}),R&&e.jsx("button",{type:"button",onClick:H=>{ne(H,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:ee,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(ut,{className:"h-3.5 w-3.5"})}):e.jsx(Gr,{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:B,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":"Command session","aria-expanded":b,title:O?sf(O):"All sessions",onClick:()=>k(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:rf(O,f)}),e.jsx(st,{className:L("h-3 w-3 shrink-0 text-muted-foreground transition-transform",b&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!b,className:L("absolute right-0 bottom-9 z-30 w-[19rem] overflow-hidden rounded-xl border border-border/70 bg-popover text-popover-foreground shadow-xl",!b&&"hidden"),children:e.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[e.jsxs("button",{type:"button",onClick:()=>$(Yt),className:L("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===Yt&&"bg-primary/10 text-primary"),children:[e.jsx(Gr,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:"All sessions"})]}),S("Active",P.active,y,()=>x(T=>!T),"No active sessions"),S("Completed",P.completed,v,()=>N(T=>!T),"No completed sessions")]})})]}),e.jsx("select",{value:D?.id??"",onChange:T=>{i(T.target.value),w(!1),d(Ts(t.find(te=>te.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(Xn,{value:c,onChange:d,assignTo:D?.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:M,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:[W.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:W.map(T=>lt(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:L("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(tr,{className:"h-3 w-3"}):e.jsx(gs,{className:"h-3 w-3"}),fr(T.session)]}),T.session.status==="running"&&e.jsx("button",{type:"button",onClick:te=>{ne(te,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}),ja(T.session)&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:ja(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(gs,{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:V,className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"shrink-0 text-primary select-none",children:D?`${D.name}$`:"$"}),e.jsx("input",{ref:Y,value:m,onChange:T=>p(T.target.value),disabled:!D||A,placeholder:D?"":"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:!D||!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(ss,{className:"h-3 w-3"})})]})]})]})})}var ln={},As,Na;function of(){return Na||(Na=1,As=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),As}var Es={},Lt={},ka;function Zt(){if(ka)return Lt;ka=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 Lt.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},Lt.getSymbolTotalCodewords=function(r){return n[r]},Lt.getBCHDigit=function(s){let r=0;for(;s!==0;)r++,s>>>=1;return r},Lt.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');t=r},Lt.isKanjiModeEnabled=function(){return typeof t<"u"},Lt.toSJIS=function(r){return t(r)},Lt}var Ms={},Sa;function Ir(){return Sa||(Sa=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}}})(Ms)),Ms}var Ds,Ca;function lf(){if(Ca)return Ds;Ca=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++}},Ds=t,Ds}var _s,Ta;function cf(){if(Ta)return _s;Ta=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]},_s=t,_s}var Ps={},Aa;function df(){return Aa||(Aa=1,(function(t){const n=Zt().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}})(Ps)),Ps}var Is={},Ea;function uf(){if(Ea)return Is;Ea=1;const t=Zt().getSymbolSize,n=7;return Is.getPositions=function(r){const a=t(r);return[[0,0],[a-n,0],[0,a-n]]},Is}var Rs={},Ma;function mf(){return Ma||(Ma=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,p=null;for(let u=0;u<i;u++){c=d=0,m=p=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===p?d++:(d>=5&&(l+=n.N1+(d-5)),p=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 p=0;p<i;p++)c=c<<1&2047|a.get(m,p),p>=10&&(c===1488||c===93)&&l++,d=d<<1&2047|a.get(p,m),p>=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 p=t.getPenaltyN1(a)+t.getPenaltyN2(a)+t.getPenaltyN3(a)+t.getPenaltyN4(a);t.applyMask(m,a),p<d&&(d=p,c=m)}return c}})(Rs)),Rs}var Vn={},Da;function Ki(){if(Da)return Vn;Da=1;const t=Ir(),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 Vn.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}},Vn.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}},Vn}var Ls={},kn={},_a;function hf(){if(_a)return kn;_a=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]})(),kn.log=function(r){if(r<1)throw new Error("log("+r+")");return n[r]},kn.exp=function(r){return t[r]},kn.mul=function(r,a){return r===0||a===0?0:t[n[r]+n[a]]},kn}var Pa;function ff(){return Pa||(Pa=1,(function(t){const n=hf();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}})(Ls)),Ls}var Bs,Ia;function pf(){if(Ia)return Bs;Ia=1;const t=ff();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},Bs=n,Bs}var Os={},Fs={},zs={},Ra;function Gi(){return Ra||(Ra=1,zs.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}),zs}var Nt={},La;function Wi(){if(La)return Nt;La=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
190
+ ]))+`;Nt.KANJI=new RegExp(s,"g"),Nt.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Nt.BYTE=new RegExp(r,"g"),Nt.NUMERIC=new RegExp(t,"g"),Nt.ALPHANUMERIC=new RegExp(n,"g");const a=new RegExp("^"+s+"$"),i=new RegExp("^"+t+"$"),l=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Nt.testKanji=function(d){return a.test(d)},Nt.testNumeric=function(d){return i.test(d)},Nt.testAlphanumeric=function(d){return l.test(d)},Nt}var Ba;function Xt(){return Ba||(Ba=1,(function(t){const n=Gi(),s=Wi();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}}})(Fs)),Fs}var Oa;function xf(){return Oa||(Oa=1,(function(t){const n=Zt(),s=Ki(),r=Ir(),a=Xt(),i=Gi(),l=7973,c=n.getBCHDigit(l);function d(h,f,j){for(let g=1;g<=40;g++)if(f<=t.getCapacity(g,j,h))return g}function m(h,f){return a.getCharCountIndicator(h,f)+4}function p(h,f){let j=0;return h.forEach(function(g){const w=m(g.mode,f);j+=w+g.getBitsLength()}),j}function u(h,f){for(let j=1;j<=40;j++)if(p(h,j)<=t.getCapacity(j,f,a.MIXED))return j}t.from=function(f,j){return i.isValid(f)?parseInt(f,10):j},t.getCapacity=function(f,j,g){if(!i.isValid(f))throw new Error("Invalid QR Code version");typeof g>"u"&&(g=a.BYTE);const w=n.getSymbolTotalCodewords(f),b=s.getTotalCodewordsCount(f,j),k=(w-b)*8;if(g===a.MIXED)return k;const y=k-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,j){let g;const w=r.from(j,r.M);if(Array.isArray(f)){if(f.length>1)return u(f,w);if(f.length===0)return 1;g=f[0]}else g=f;return d(g.mode,g.getLength(),w)},t.getEncodedBits=function(f){if(!i.isValid(f)||f<7)throw new Error("Invalid QR Code version");let j=f<<12;for(;n.getBCHDigit(j)-c>=0;)j^=l<<n.getBCHDigit(j)-c;return f<<12|j}})(Os)),Os}var Us={},Fa;function gf(){if(Fa)return Us;Fa=1;const t=Zt(),n=1335,s=21522,r=t.getBCHDigit(n);return Us.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},Us}var $s={},qs,za;function bf(){if(za)return qs;za=1;const t=Xt();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))},qs=n,qs}var Vs,Ua;function vf(){if(Ua)return Vs;Ua=1;const t=Xt(),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)},Vs=s,Vs}var Hs,$a;function wf(){if($a)return Hs;$a=1;const t=Xt();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)},Hs=n,Hs}var Ks,qa;function yf(){if(qa)return Ks;qa=1;const t=Xt(),n=Zt();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]+`
191
+ Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),r.put(i,13)}},Ks=s,Ks}var Gs={exports:{}},Va;function jf(){return Va||(Va=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,p,u,h,f,j,g,w;!c.empty();){d=c.pop(),m=d.value,u=d.cost,h=s[m]||{};for(p in h)h.hasOwnProperty(p)&&(f=h[p],j=u+f,g=l[p],w=typeof l[p]>"u",(w||g>j)&&(l[p]=j,c.push(p,j),i[p]=m))}if(typeof a<"u"&&typeof l[a]>"u"){var b=["Could not find a path from ",r," to ",a,"."].join("");throw new Error(b)}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})(Gs)),Gs.exports}var Ha;function Nf(){return Ha||(Ha=1,(function(t){const n=Xt(),s=bf(),r=vf(),a=wf(),i=yf(),l=Wi(),c=Zt(),d=jf();function m(b){return unescape(encodeURIComponent(b)).length}function p(b,k,y){const x=[];let v;for(;(v=b.exec(y))!==null;)x.push({data:v[0],index:v.index,mode:k,length:v[0].length});return x}function u(b){const k=p(l.NUMERIC,n.NUMERIC,b),y=p(l.ALPHANUMERIC,n.ALPHANUMERIC,b);let x,v;return c.isKanjiModeEnabled()?(x=p(l.BYTE,n.BYTE,b),v=p(l.KANJI,n.KANJI,b)):(x=p(l.BYTE_KANJI,n.BYTE,b),v=[]),k.concat(y,x,v).sort(function(A,E){return A.index-E.index}).map(function(A){return{data:A.data,mode:A.mode,length:A.length}})}function h(b,k){switch(k){case n.NUMERIC:return s.getBitsLength(b);case n.ALPHANUMERIC:return r.getBitsLength(b);case n.KANJI:return i.getBitsLength(b);case n.BYTE:return a.getBitsLength(b)}}function f(b){return b.reduce(function(k,y){const x=k.length-1>=0?k[k.length-1]:null;return x&&x.mode===y.mode?(k[k.length-1].data+=y.data,k):(k.push(y),k)},[])}function j(b){const k=[];for(let y=0;y<b.length;y++){const x=b[y];switch(x.mode){case n.NUMERIC:k.push([x,{data:x.data,mode:n.ALPHANUMERIC,length:x.length},{data:x.data,mode:n.BYTE,length:x.length}]);break;case n.ALPHANUMERIC:k.push([x,{data:x.data,mode:n.BYTE,length:x.length}]);break;case n.KANJI:k.push([x,{data:x.data,mode:n.BYTE,length:m(x.data)}]);break;case n.BYTE:k.push([{data:x.data,mode:n.BYTE,length:m(x.data)}])}}return k}function g(b,k){const y={},x={start:{}};let v=["start"];for(let N=0;N<b.length;N++){const A=b[N],E=[];for(let M=0;M<A.length;M++){const B=A[M],D=""+N+M;E.push(D),y[D]={node:B,lastCount:0},x[D]={};for(let _=0;_<v.length;_++){const P=v[_];y[P]&&y[P].node.mode===B.mode?(x[P][D]=h(y[P].lastCount+B.length,B.mode)-h(y[P].lastCount,B.mode),y[P].lastCount+=B.length):(y[P]&&(y[P].lastCount=B.length),x[P][D]=h(B.length,B.mode)+4+n.getCharCountIndicator(B.mode,k))}}v=E}for(let N=0;N<v.length;N++)x[v[N]].end=0;return{map:x,table:y}}function w(b,k){let y;const x=n.getBestModeForData(b);if(y=n.from(k,x),y!==n.BYTE&&y.bit<x.bit)throw new Error('"'+b+'" cannot be encoded with mode '+n.toString(y)+`.
192
+ Suggested mode is: `+n.toString(x));switch(y===n.KANJI&&!c.isKanjiModeEnabled()&&(y=n.BYTE),y){case n.NUMERIC:return new s(b);case n.ALPHANUMERIC:return new r(b);case n.KANJI:return new i(b);case n.BYTE:return new a(b)}}t.fromArray=function(k){return k.reduce(function(y,x){return typeof x=="string"?y.push(w(x,null)):x.data&&y.push(w(x.data,x.mode)),y},[])},t.fromString=function(k,y){const x=u(k,c.isKanjiModeEnabled()),v=j(x),N=g(v,y),A=d.find_path(N.map,"start","end"),E=[];for(let M=1;M<A.length-1;M++)E.push(N.table[A[M]].node);return t.fromArray(f(E))},t.rawSplit=function(k){return t.fromArray(u(k,c.isKanjiModeEnabled()))}})($s)),$s}var Ka;function kf(){if(Ka)return Es;Ka=1;const t=Zt(),n=Ir(),s=lf(),r=cf(),a=df(),i=uf(),l=mf(),c=Ki(),d=pf(),m=xf(),p=gf(),u=Xt(),h=Nf();function f(N,A){const E=N.size,M=i.getPositions(A);for(let B=0;B<M.length;B++){const D=M[B][0],_=M[B][1];for(let P=-1;P<=7;P++)if(!(D+P<=-1||E<=D+P))for(let O=-1;O<=7;O++)_+O<=-1||E<=_+O||(P>=0&&P<=6&&(O===0||O===6)||O>=0&&O<=6&&(P===0||P===6)||P>=2&&P<=4&&O>=2&&O<=4?N.set(D+P,_+O,!0,!0):N.set(D+P,_+O,!1,!0))}}function j(N){const A=N.size;for(let E=8;E<A-8;E++){const M=E%2===0;N.set(E,6,M,!0),N.set(6,E,M,!0)}}function g(N,A){const E=a.getPositions(A);for(let M=0;M<E.length;M++){const B=E[M][0],D=E[M][1];for(let _=-2;_<=2;_++)for(let P=-2;P<=2;P++)_===-2||_===2||P===-2||P===2||_===0&&P===0?N.set(B+_,D+P,!0,!0):N.set(B+_,D+P,!1,!0)}}function w(N,A){const E=N.size,M=m.getEncodedBits(A);let B,D,_;for(let P=0;P<18;P++)B=Math.floor(P/3),D=P%3+E-8-3,_=(M>>P&1)===1,N.set(B,D,_,!0),N.set(D,B,_,!0)}function b(N,A,E){const M=N.size,B=p.getEncodedBits(A,E);let D,_;for(D=0;D<15;D++)_=(B>>D&1)===1,D<6?N.set(D,8,_,!0):D<8?N.set(D+1,8,_,!0):N.set(M-15+D,8,_,!0),D<8?N.set(8,M-D-1,_,!0):D<9?N.set(8,15-D-1+1,_,!0):N.set(8,15-D-1,_,!0);N.set(M-8,8,1,!0)}function k(N,A){const E=N.size;let M=-1,B=E-1,D=7,_=0;for(let P=E-1;P>0;P-=2)for(P===6&&P--;;){for(let O=0;O<2;O++)if(!N.isReserved(B,P-O)){let W=!1;_<A.length&&(W=(A[_]>>>D&1)===1),N.set(B,P-O,W),D--,D===-1&&(_++,D=7)}if(B+=M,B<0||E<=B){B-=M,M=-M;break}}}function y(N,A,E){const M=new s;E.forEach(function(O){M.put(O.mode.bit,4),M.put(O.getLength(),u.getCharCountIndicator(O.mode,N)),O.write(M)});const B=t.getSymbolTotalCodewords(N),D=c.getTotalCodewordsCount(N,A),_=(B-D)*8;for(M.getLengthInBits()+4<=_&&M.put(0,4);M.getLengthInBits()%8!==0;)M.putBit(0);const P=(_-M.getLengthInBits())/8;for(let O=0;O<P;O++)M.put(O%2?17:236,8);return x(M,N,A)}function x(N,A,E){const M=t.getSymbolTotalCodewords(A),B=c.getTotalCodewordsCount(A,E),D=M-B,_=c.getBlocksCount(A,E),P=M%_,O=_-P,W=Math.floor(M/_),J=Math.floor(D/_),Y=J+1,V=W-J,ne=new d(V);let $=0;const ee=new Array(_),S=new Array(_);let Q=0;const T=new Uint8Array(N.buffer);for(let le=0;le<_;le++){const ie=le<O?J:Y;ee[le]=T.slice($,$+ie),S[le]=ne.encode(ee[le]),$+=ie,Q=Math.max(Q,ie)}const te=new Uint8Array(M);let R=0,H,F;for(H=0;H<Q;H++)for(F=0;F<_;F++)H<ee[F].length&&(te[R++]=ee[F][H]);for(H=0;H<V;H++)for(F=0;F<_;F++)te[R++]=S[F][H];return te}function v(N,A,E,M){let B;if(Array.isArray(N))B=h.fromArray(N);else if(typeof N=="string"){let W=A;if(!W){const J=h.rawSplit(N);W=m.getBestVersionForData(J,E)}B=h.fromString(N,W||40)}else throw new Error("Invalid data");const D=m.getBestVersionForData(B,E);if(!D)throw new Error("The amount of data is too big to be stored in a QR Code");if(!A)A=D;else if(A<D)throw new Error(`
198
193
  The chosen QR Code version cannot contain this amount of data.
199
194
  Minimum version required to store current data is: `+D+`.
200
- `);const _=y(A,E,B),P=t.getSymbolSize(A),O=new r(P);return f(O,A),j(O),g(O,A),b(O,E,0),A>=7&&w(O,A),k(O,_),isNaN(M)&&(M=l.getBestMask(O,b.bind(null,O,E))),l.applyMask(M,O),b(O,E,M),{modules:O,version:A,errorCorrectionLevel:E,maskPattern:M,segments:B}}return Es.create=function(A,E){if(typeof A>"u"||A==="")throw new Error("No input text");let M=n.M,B,D;return typeof E<"u"&&(M=n.from(E.errorCorrectionLevel,n.M),B=m.from(E.version),D=l.from(E.maskPattern),E.toSJISFunc&&t.setToSJISFunction(E.toSJISFunc)),v(A,B,M,D)},Es}var Ws={},Qs={},Ga;function Qi(){return Ga||(Ga=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),p=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 j=(h*m+f)*4,g=i.color.light;if(h>=p&&f>=p&&h<m-p&&f<m-p){const w=Math.floor((h-p)/d),b=Math.floor((f-p)/d);g=u[c[w*l+b]?1:0]}r[j++]=g.r,r[j++]=g.g,r[j++]=g.b,r[j]=g.a}}})(Qs)),Qs}var Wa;function Cf(){return Wa||(Wa=1,(function(t){const n=Qi();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 p=n.getImageWidth(i.modules.size,d),u=m.getContext("2d"),h=u.createImageData(p,p);return n.qrToImageData(h.data,i,d),s(u,m,p),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),p=d.type||"image/png",u=d.rendererOpts||{};return m.toDataURL(p,u.quality)}})(Ws)),Ws}var Ys={},Qa;function Tf(){if(Qa)return Ys;Qa=1;const t=Qi();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,p=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]?(p++,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",p),p=0)):d++}return c}return Ys.render=function(i,l,c){const d=t.getOptions(l),m=i.modules.size,p=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(p,m,d.margin)+'"/>',j='viewBox="0 0 '+u+" "+u+'"',w='<svg xmlns="http://www.w3.org/2000/svg" '+(d.width?'width="'+d.width+'" height="'+d.width+'" ':"")+j+' shape-rendering="crispEdges">'+h+f+`</svg>
201
- `;return typeof c=="function"&&c(null,w),w},Ys}var Ya;function Af(){if(Ya)return ln;Ya=1;const t=lf(),n=Sf(),s=Cf(),r=Tf();function a(i,l,c,d,m){const p=[].slice.call(arguments,1),u=p.length,h=typeof p[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,j){try{const g=n.create(c,d);f(i(g,l,d))}catch(g){j(g)}})}try{const f=n.create(c,d);m(null,i(f,l,d))}catch(f){m(f)}}return ln.create=n.create,ln.toCanvas=a.bind(null,s.render),ln.toDataURL=a.bind(null,s.renderToDataURL),ln.toString=a.bind(null,function(i,l,c){return r.render(i,c)}),ln}var Ef=Af();function Yi(t){return Ef.toDataURL(t,{errorCorrectionLevel:"M",margin:2,scale:8,color:{dark:"#111827ff",light:"#ffffffff"}})}function Mf({title:t,description:n,triggerLabel:s,qrValue:r,displayValue:a,hint:i,imageAlt:l,copyLabel:c,copiedMessage:d}){const[m,p]=o.useState(!1),[u,h]=o.useState(null),[f,j]=o.useState(null);return o.useEffect(()=>{if(!m)return;let g=!1;return h(null),j(null),Yi(r).then(w=>{g||h(w)}).catch(()=>{g||j("QR code unavailable")}),()=>{g=!0}},[m,r]),e.jsxs(mt,{open:m,onOpenChange:p,children:[e.jsx(Ro,{asChild:!0,children:e.jsx(X,{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(ei,{className:"h-3 w-3"})})}),e.jsxs(ht,{className:"max-w-[20rem] gap-2 p-3",children:[e.jsxs(Mt,{className:"space-y-1 text-left",children:[e.jsx(vt,{className:"text-[12px]",children:t}),e.jsx(Dt,{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(fe,{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(X,{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:()=>{In(a,d)},children:c})]})]})]})}function Df(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 _f(t,n){return t?t.invitation.status==="active"&&Date.parse(t.invitation.expiresAt)<=n?"expired":t.invitation.status:"loading"}function Pf(t){switch(t){case"active":return{label:"Active",tone:"bg-emerald-500/10 text-emerald-500",icon:la};case"consumed":return{label:"Paired",tone:"bg-emerald-500/10 text-emerald-500",icon:tr};case"expired":return{label:"Expired",tone:"bg-amber-500/10 text-amber-500",icon:ys};case"cancelled":return{label:"Cancelled",tone:"bg-destructive/10 text-destructive",icon:ys};case"error":return{label:"Unavailable",tone:"bg-destructive/10 text-destructive",icon:ys};default:return{label:"Loading",tone:"bg-muted text-muted-foreground",icon:la}}}function If({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),[p,u]=o.useState(!1),[h,f]=o.useState(()=>Date.now()),j=`Show ${t} mobile pairing QR code`,g=o.useMemo(()=>a?bc(a.qr):null,[a]),w=d?"error":_f(a,h),b=Pf(w),k=b.icon,y=o.useCallback(async()=>{u(!0),m(null),c(null);try{const x=await vc();i(x),f(Date.now())}catch(x){i(null),m(x instanceof Error?x.message:"Mobile pairing QR unavailable")}finally{u(!1)}},[]);return o.useEffect(()=>{s&&y()},[s,y]),o.useEffect(()=>{if(!s)return;const x=window.setInterval(()=>f(Date.now()),1e3);return()=>window.clearInterval(x)},[s]),o.useEffect(()=>{if(!s||!a||w!=="active")return;let x=!1;const v=window.setInterval(()=>{wc(a.invitation.pairingId).then(N=>{x||i(A=>A&&{...A,invitation:N.invitation})}).catch(()=>{x||m("Pairing status unavailable")})},2e3);return()=>{x=!0,window.clearInterval(v)}},[s,a?.invitation.pairingId,w]),o.useEffect(()=>{if(!s||!g)return;let x=!1;return c(null),Yi(g).then(v=>{x||c(v)}).catch(()=>{x||m("QR code unavailable")}),()=>{x=!0}},[s,g]),e.jsxs(mt,{open:s,onOpenChange:r,children:[e.jsx(Ro,{asChild:!0,children:e.jsx(X,{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":j,title:j,children:e.jsx(ei,{className:"h-3 w-3"})})}),e.jsxs(ht,{className:"max-w-[20rem] gap-2 p-3",children:[e.jsxs(Mt,{className:"space-y-1 text-left",children:[e.jsx(vt,{className:"text-[12px]",children:"Mobile pairing QR"}),e.jsx(Dt,{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(fe,{className:"h-5 w-5 animate-spin text-muted-foreground"}),l&&w!=="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:[b.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 - ${Df(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 ${b.tone}`,children:[e.jsx(k,{className:"h-3 w-3"}),b.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(X,{type:"button",variant:"secondary",size:"sm",className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",onClick:()=>{In(a?.invitation.apiBaseUrl??n,"Node URL copied")},children:"Copy URL"}),e.jsxs(X,{type:"button",variant:"secondary",size:"sm",className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",disabled:p,onClick:()=>{y()},children:[p?e.jsx(fe,{className:"mr-1 h-3 w-3 animate-spin"}):e.jsx(Lo,{className:"mr-1 h-3 w-3"}),"Refresh"]})]})]})]})]})}function Rf({nodeName:t,dashboardUrl:n}){const s=`Show ${t} dashboard QR code`;return e.jsx(Mf,{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 Lf(t){return t?{left:t.left,top:t.top}:{left:0,top:0,visibility:"hidden"}}function Bf(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,p=t.right+4,u=m?p+l<=s.width-8?p: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,j=h+c>s.height-8&&f>=8?f:h;return{left:Math.round(u/d),top:Math.round(j/d)}}function Of(){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 Rr="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 Lr({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),p=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(!p){c(null);return}const f=()=>{const j=d.current;if(!j)return;const g=j.getBoundingClientRect(),w=t&&n?{left:n.left,right:n.left,top:n.top,bottom:n.top}:m.current?.getBoundingClientRect();w&&c(Bf({left:w.left,right:w.right,top:w.top,bottom:w.bottom},{width:g.width,height:g.height},{width:window.innerWidth,height:window.innerHeight},Of()))};return f(),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0)}},[t,n,p]),o.useEffect(()=>{if(!p)return;const f=g=>{const w=g.target;w instanceof Node&&!d.current?.contains(w)&&!m.current?.contains(w)&&u()},j=g=>{g.key==="Escape"&&u()};return document.addEventListener("mousedown",f),document.addEventListener("keydown",j),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",j)}},[p,u]),{open:p,menuRef:d,triggerRef:m,menuStyle:Lf(l),closeMenu:u,toggleButton:h}}function Xe({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:L("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(fe,{className:"h-3 w-3 animate-spin text-primary"}):a,e.jsx("span",{children:n})]})}function Sn({formatDateTime:t,name:n,status:s,statusVariant:r}){return e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-sm border border-border/60 bg-background/70 px-2 py-1",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-medium leading-3.5 text-foreground",children:n}),e.jsx("div",{className:"text-[9px] leading-3.5 text-muted-foreground",children:t(s?.checkedAt)})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[typeof s?.authenticated=="boolean"&&e.jsx(Le,{variant:s.authenticated?"default":"outline",className:"rounded-sm text-[9px] uppercase tracking-[0.12em]",children:s.authenticated?"auth ok":"auth required"}),e.jsx(Le,{variant:r(s?.status),className:"rounded-sm text-[9px] uppercase tracking-[0.12em]",children:s?.status??"unknown"})]})]})}function Ce({label:t,value:n,mono:s=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border/45 py-0.5 last:border-b-0 last:pb-0 first:pt-0",children:[e.jsx("span",{className:"shrink-0 text-[8px] uppercase tracking-[0.14em] text-muted-foreground/80",children:t}),e.jsx("span",{className:L("min-w-0 break-words text-right text-[10px] leading-3.5 text-foreground/90",s&&"break-all font-mono text-[9px]"),children:n})]})}function Ff({nodeId:t,nodeName:n,node:s}){const r=yc(),a=r?.cluster??null,i=r?.systemInfo??null,c=a?.nodes.find(E=>E.id===t)??null??s??null,d=c?jc(c,i):null,m=!!(i&&c&&c.id===i.nodeId),p=m||!!c?.settingsSnapshot,u=c?.name??s?.name??n,h=c?.status,f=c?.role,j=c?.transportType??d?.transportType??"direct",g=c?.capabilities??[],w=c?.supportedAgents??[],b=d?.startupRequirements?.components??d?.components??{},[k,y]=o.useState("identity"),[x,v]=o.useState(!1),N=[{id:"identity",icon:e.jsx(ts,{className:"h-3.5 w-3.5"}),title:"Identity",description:"Cluster role, endpoint, and node-scoped state.",content:e.jsxs(e.Fragment,{children:[e.jsx(Ce,{label:"Node ID",value:t,mono:!0}),e.jsx(Ce,{label:"Status",value:h??"Unavailable"}),e.jsx(Ce,{label:"Role",value:f??"Unavailable"}),e.jsx(Ce,{label:"Endpoint",value:c?.endpoint??"Unavailable",mono:!!c?.endpoint}),e.jsx(Ce,{label:"Joined",value:jt(c?.joinedAt)}),e.jsx(Ce,{label:"Heartbeat",value:jt(c?.lastHeartbeat)}),e.jsx(Ce,{label:"Capabilities",value:g.length>0?g.join(", "):"None"}),e.jsx(Ce,{label:"Agents",value:w.length>0?w.join(", "):"None"})]})},{id:"os",icon:e.jsx(ru,{className:"h-3.5 w-3.5"}),title:"OS info",description:"Host and resource details.",content:e.jsxs(e.Fragment,{children:[e.jsx(Ce,{label:"Host",value:d?.os?.hostname??"Unavailable"}),e.jsx(Ce,{label:"Platform",value:d?.os?`${d.os.platform} ${d.os.release}`:"Unavailable"}),e.jsx(Ce,{label:"Arch",value:d?.os?.arch??"Unavailable"}),e.jsx(Ce,{label:"CPU",value:d?.os?.cpuModel??"Unavailable"}),e.jsx(Ce,{label:"Cores",value:d?.os?String(d.os.cpuCount):"Unavailable"}),e.jsx(Ce,{label:"Memory",value:d?.os?`${Qr(d.os.freeMemoryBytes)} free / ${Qr(d.os.totalMemoryBytes)} total`:"Unavailable"})]})},{id:"access",icon:e.jsx(Nc,{className:"h-3.5 w-3.5"}),title:"Access surface",description:"How this node is reachable.",content:e.jsxs(e.Fragment,{children:[e.jsx(Ce,{label:"Transport",value:j}),e.jsx(Ce,{label:"Node URL",value:c?.endpoint??"Unavailable",mono:!!c?.endpoint}),e.jsx(Ce,{label:"Node tunnel",value:c?.devtunnelEndpoint??"Disabled",mono:!!c?.devtunnelEndpoint}),e.jsx(Ce,{label:"Dashboard URL",value:c?.dashboardOrigin??d?.localDashboardOrigin??"Unavailable",mono:!!(c?.dashboardOrigin||d?.localDashboardOrigin)}),e.jsx(Ce,{label:"Local dashboard",value:d?.localDashboardOrigin??"Unavailable",mono:!!d?.localDashboardOrigin})]})},{id:"auth",icon:e.jsx(Ou,{className:"h-3.5 w-3.5"}),title:"Auth",description:"Bearer-auth and trusted access posture.",content:e.jsxs(e.Fragment,{children:[e.jsx(Ce,{label:"Enabled",value:d?.auth?d.auth.enabled?"Yes":"No":"Unavailable"}),e.jsx(Ce,{label:"Same tenant",value:d?.auth?d.auth.allowSameTenant?"Allowed":"Off":"Unavailable"}),e.jsx(Ce,{label:"Allowed users",value:d?.auth?.allowedUsers.length?d.auth.allowedUsers.join(", "):"None"})]})},{id:"paths",icon:e.jsx(Jo,{className:"h-3.5 w-3.5"}),title:"Paths",description:"Workspace and runtime paths.",content:e.jsxs(e.Fragment,{children:[e.jsx(Ce,{label:"Work dir",value:d?.runtime?.workDir??c?.workDir??"Unavailable",mono:!!(d?.runtime?.workDir??c?.workDir)}),e.jsx(Ce,{label:"Storage",value:d?.runtime?.storagePath??"Unavailable",mono:!!d?.runtime?.storagePath}),e.jsx(Ce,{label:"Process cwd",value:d?.runtime?.cwd??"Unavailable",mono:!!d?.runtime?.cwd}),e.jsx(Ce,{label:"Started",value:jt(d?.runtime?.startedAt)}),e.jsx(Ce,{label:"PID",value:d?.runtime?String(d.runtime.pid):"Unavailable",mono:!!d?.runtime})]})},{id:"startup",icon:e.jsx(kc,{className:"h-3.5 w-3.5"}),title:"Startup checks",description:"Dependency preflight from node startup.",content:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2 rounded-sm border border-border/55 bg-background/65 px-2 py-1",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-[9px] text-foreground",children:[e.jsx(Po,{className:"h-2.5 w-2.5 text-primary"}),"Last checked"]}),e.jsx("span",{className:"text-[9px] text-muted-foreground",children:jt(d?.startupRequirements?.lastCheckedAt)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Sn,{formatDateTime:jt,name:"Azure CLI",status:b.az,statusVariant:Nn}),e.jsx(Sn,{formatDateTime:jt,name:"DevTunnel",status:b.devtunnel,statusVariant:Nn}),e.jsx(Sn,{formatDateTime:jt,name:"Claude Code",status:b.claude,statusVariant:Nn}),e.jsx(Sn,{formatDateTime:jt,name:"Codex",status:b.codex,statusVariant:Nn}),e.jsx(Sn,{formatDateTime:jt,name:"Copilot CLI",status:b.copilot,statusVariant:Nn})]})]})}],A=N.find(E=>E.id===k)??N[0];return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("section",{className:"relative rounded-sm border border-border/65 bg-background/75 p-2 shadow-none",children:[!m&&c?.settingsSnapshot&&e.jsxs(Le,{variant:"outline",className:"absolute right-2 top-2 rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[8px] uppercase tracking-[0.12em] whitespace-nowrap",children:["Updated ",jt(c.settingsSnapshot.collectedAt)]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsxs("span",{className:"flex items-center gap-1.5 rounded-sm border border-border/70 bg-background/75 px-1.5 py-0.5 text-[9px] text-muted-foreground",children:[h&&e.jsx(vr,{status:h}),e.jsx("span",{className:"font-medium text-foreground",children:u})]}),f&&e.jsx(wr,{role:f,size:"compact"}),e.jsx(Le,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[8px] uppercase tracking-[0.12em]",children:j}),c&&e.jsx(Le,{variant:m?"default":"outline",className:"rounded-sm px-1.5 py-0 text-[8px] uppercase tracking-[0.12em]",children:m?"Live local session":"Leader-synced snapshot"}),d&&d.uptime>0&&e.jsxs(Le,{variant:"outline",className:"gap-1 rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[8px] uppercase tracking-[0.12em]",children:[e.jsx(ti,{className:"h-2.5 w-2.5"}),"Uptime ",Sc(d.uptime)]})]})]}),!p&&c&&e.jsx("div",{className:"rounded-sm border border-dashed border-border/65 bg-muted/20 px-2 py-1.5 text-[9px] leading-3.5 text-muted-foreground",children:"This node has not synced a runtime snapshot to the leader yet. Host, access, and startup details appear after the next keepalive."}),e.jsxs("div",{"data-node-properties-layout":"menu-details",className:"flex min-h-[18rem] gap-2",children:[e.jsxs("aside",{"data-node-properties-menu-collapsed":String(x),className:L("group/node-properties-menu flex shrink-0 flex-col overflow-hidden rounded-sm border border-border/60 bg-background/70 shadow-none transition-[width] duration-150",x?"w-9":"w-36 sm:w-40"),children:[e.jsxs("div",{className:L("flex items-center gap-1.5 border-b border-border/45 py-1",x?"justify-center px-1":"justify-between px-1.5"),children:[!x&&e.jsx("span",{className:"min-w-0 truncate text-[8px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",children:"Properties"}),e.jsx("button",{type:"button",className:"node-properties-menu-toggle flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-muted/45 hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-primary/45","aria-label":x?"Expand properties menu":"Collapse properties menu",title:x?"Expand properties menu":"Collapse properties menu",onClick:()=>v(E=>!E),children:x?e.jsx(nt,{className:"h-3 w-3"}):e.jsx(Dn,{className:"h-3 w-3"})})]}),e.jsx("nav",{"aria-label":"Node properties sections",className:"space-y-1 p-1",children:N.map(E=>{const M=E.id===k;return e.jsxs("button",{type:"button","data-node-properties-menu-item":E.title,"aria-current":M?"page":void 0,"aria-label":`Show ${E.title} details`,"aria-pressed":M,title:x?E.title:void 0,onClick:()=>y(E.id),className:L("flex h-7 w-full items-center gap-1.5 rounded-sm border border-transparent px-1.5 text-[10px] leading-3.5 transition-colors hover:bg-muted/45 hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-primary/45",x&&"justify-center px-0",M?"border-primary/35 bg-primary/10 text-foreground":"text-muted-foreground"),children:[e.jsx("span",{className:"shrink-0 text-primary/90 [&_svg]:h-3 [&_svg]:w-3",children:E.icon}),e.jsx("span",{className:L("node-properties-menu-label min-w-0 flex-1 truncate text-left",x&&"hidden"),children:E.title})]},E.id)})})]}),e.jsxs("section",{"data-node-properties-details-pane":"true",className:"min-w-0 flex-1 rounded-sm border border-border/60 bg-background/70 shadow-none",children:[e.jsxs("header",{className:"border-b border-border/45 px-2 py-1.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-[10px] font-semibold leading-3.5 text-foreground",children:[e.jsx("span",{className:"shrink-0 text-primary [&_svg]:h-3 [&_svg]:w-3",children:A.icon}),e.jsx("span",{className:"min-w-0 truncate",children:A.title})]}),e.jsx("p",{className:"mt-0.5 truncate text-[8px] leading-3 text-muted-foreground",children:A.description})]}),e.jsx("div",{className:"px-2 py-1.5",children:N.map(E=>e.jsx("div",{"data-node-properties-details":E.title,hidden:E.id!==k,children:E.content},E.id))})]})]})]})}function zf({nodeId:t,nodeName:n,node:s,open:r,onOpenChange:a}){return e.jsx(mt,{open:r,onOpenChange:a,children:e.jsxs(ht,{className:"max-h-[min(82vh,40rem)] max-w-[min(88vw,44rem)] gap-3 overflow-y-auto rounded-sm border-border/70 bg-background/96 p-4 backdrop-blur-xl",children:[e.jsxs(Mt,{className:"space-y-1",children:[e.jsxs(vt,{className:"flex items-center gap-1.5 text-[13px]",children:[e.jsx(ts,{className:"h-3.5 w-3.5 text-primary"}),"Node properties"]}),e.jsxs(Dt,{className:"truncate text-[10px] leading-4 text-muted-foreground",children:["Runtime environment, connectivity, and preflight details for ",s?.name??n,"."]})]}),e.jsx(Ff,{nodeId:t,nodeName:n,node:s})]})})}function Br({nodeId:t,nodeName:n,node:s,contextOpen:r=!1,contextPosition:a=null,defaultOpen:i=!1,onContextOpenChange:l,onOpenSettings:c,onOpenServicePreview:d,onOpenCapabilities:m,onOpenDevBox:p,onStartDevBox:u,onToggleRemoteAccess:h,remoteAccessLabel:f,remoteAccessPending:j,remoteAccessDisabled:g,remoteAccessDisabledReason:w,showConfigureDevBox:b,showStartDevBox:k,startDevBoxPending:y,className:x}){const{open:v,menuRef:N,triggerRef:A,menuStyle:E,closeMenu:M,toggleButton:B}=Lr({contextOpen:r,contextPosition:a,defaultOpen:i,onContextOpenChange:l}),[D,_]=o.useState(!1),P=y?"Starting":"Start DevBox",O=f?.startsWith("Disable")?Cc:Hu,W=v?e.jsxs("div",{ref:N,"data-node-action-menu-portal":"true",role:"menu",style:E,onClick:J=>J.stopPropagation(),onPointerDown:J=>J.stopPropagation(),className:Rr,children:[c&&e.jsx(Xe,{ariaLabel:`Open ${n} settings`,title:`Open ${n} settings`,icon:e.jsx(Tc,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{M(),c(t)},children:"Settings"}),d&&e.jsx(Xe,{ariaLabel:`Preview service on ${n}`,title:`Preview service on ${n}`,icon:e.jsx(Zo,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{M(),d(t)},children:"Preview service"}),m&&e.jsx(Xe,{ariaLabel:`Open ${n} capabilities`,title:`Open ${n} capabilities`,icon:e.jsx(Rn,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{M(),m(t)},children:"Capabilities"}),f&&h&&e.jsx(Xe,{ariaLabel:`${f} for ${n}`,title:w??`${f} for ${n}`,icon:e.jsx(O,{className:"h-3 w-3 shrink-0 text-primary"}),pending:j,disabled:g,onClick:()=>{M(),h()},children:f}),k&&u&&e.jsx(Xe,{ariaLabel:`${P} for ${n}`,title:`${P} for ${n}`,icon:e.jsx(ss,{className:"h-3 w-3 shrink-0 text-primary"}),pending:y,onClick:()=>{M(),u(t)},children:P}),b&&p&&e.jsx(Xe,{ariaLabel:`Configure DevBox for ${n}`,title:`Configure DevBox for ${n}`,icon:e.jsx(Ac,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{M(),p(t)},children:"Configure DevBox"}),e.jsx(Xe,{ariaLabel:`Properties for ${n}`,title:`Properties for ${n}`,icon:e.jsx(yr,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{M(),_(!0)},children:"Properties"})]}):null;return e.jsxs("div",{"data-node-action-menu":"true",className:L("relative shrink-0",v&&"z-[120]",x),onClick:J=>J.stopPropagation(),onPointerDown:J=>J.stopPropagation(),children:[e.jsx(X,{ref:A,type:"button",variant:"ghost",size:"icon","aria-label":`More actions for ${n}`,"aria-haspopup":"menu","aria-expanded":v,title:`More actions for ${n}`,onClick:J=>{J.stopPropagation(),B()},className:L("h-6 w-6 rounded-sm text-muted-foreground hover:bg-background/70 hover:text-foreground",v&&"bg-background/80 text-primary"),children:e.jsx(Tr,{className:"h-3.5 w-3.5"})}),W&&(typeof document>"u"?W:ns.createPortal(W,document.body)),D&&e.jsx(zf,{nodeId:t,nodeName:n,node:s,open:D,onOpenChange:_})]})}const Uf=new Set(["deallocated","hibernate","hibernated","sleep","sleeping","stopped"]),$f=new Set(["startinprogress","starting"]);function dn(t){return!!(t?.enabled&&t.name)}function qf(t){const n=t?.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(n&&Uf.has(n))}function un(t){const n=t?.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(n&&$f.has(n))}function is(t,n,s){return t==="offline"&&qf(n)&&dn(s)}function Ja(t,n){return t==="offline"&&dn(n)}function Za(t){return!dn(t)}function Vf({nodeStatus:t,status:n,current:s,selected:r}){const a=r??s;return a&&is(t,n,a)?a:null}function Ye(t){return t.scope||`name:${t.name??""}`}function Hf({previousKey:t,baseDevBox:n,listed:s}){if(t&&s.some(i=>Ye(i)===t))return t;if(!dn(n))return s[0]?Ye(s[0]):"";const r=Ye(n),a=s.find(i=>Ye(i)===r)??s.find(i=>i.name===n.name);return a?Ye(a):r}function Kf(t){return t==="nodes"||t==="events"?t:"overview"}function Gf({cluster:t,systemInfo:n,nodeNameById:s,nodeBlockingTaskCounts:r,eventTypeFilter:a,onEventTypeFilterChange:i,eventTypeOptions:l,filteredEvents:c,sseConnected:d,clusterLoading:m,clusterError:p,promotePending:u,onPromote:h,onAddNode:f,leavePending:j,onLeaveCluster:g,onToggleNodeDevTunnel:w,devTunnelNodeId:b,devBoxStartNodeId:k,devBoxStartingNodeIds:y=new Set,activeTab:x,onTabChange:v,onOpenNodeSettings:N,onOpenNodeCapabilities:A,onOpenDevBox:E,onStartDevBox:M}){const B=t?.self?.role==="leader",D=t?.self?.role==="follower"&&!t?.leader,_=t?.self??null,O=Ec(t?.nodes??[],_?.id).filter(R=>R.id!==_?.id),W=t?.leader?t.nodes.find(R=>R.id===t.leader?.id)??null:null,J=t?.leader?t.leader.dashboardOrigin??W?.dashboardOrigin??(n&&t.leader.id===(n.nodeId??n.id)?n.dashboardOrigin:void 0)??t.leader.endpoint:null,Y=t?.leader?W?.devtunnelEndpoint??t.leader.endpoint:null,V=t?.leader?.name??W?.name??"Leader",ne=!!(t?.leader?.id&&t.leader.id===_?.id),$=_?.role==="leader"&&O.length===0,ee=_?.role==="follower",[S,Q]=o.useState("overview"),T=x??S;function te(R){const H=Kf(R);Q(H),v?.(H)}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(_r,{value:T,onValueChange:te,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(os,{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(bt,{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:[_&&e.jsx(Xa,{node:_,systemInfo:n,blockingTaskCount:r.get(_.id)??0,devTunnelNodeId:b,onToggleNodeDevTunnel:w,showActions:!1,defaultExpanded:!1,onOpenDevBox:E,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(Le,{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(fe,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):p&&!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:p}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx(on,{label:"Term",value:String(t?.term??0)}),e.jsx(on,{label:"Nodes",value:String(t?.nodes.length??0)}),e.jsx(on,{label:"Pending",value:String(t?.taskSummary.pending??0)}),e.jsx(on,{label:"Running",value:String(t?.taskSummary.running??0)}),e.jsx(on,{label:"Completed",value:String(t?.taskSummary.completed??0)}),e.jsx(on,{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(ct,{label:"Leader",value:t?.leader?.name??"None"}),e.jsx(ct,{label:"Leader Dashboard URL",value:J??"Unavailable",mono:!0,action:J?e.jsx(Fr,{nodeName:V,dashboardUrl:J,copyLabel:"Copy leader dashboard URL",copiedMessage:"Leader Dashboard URL copied"}):void 0}),Y&&e.jsx(ct,{label:"Leader Node URL",value:Y,mono:!0,action:e.jsx(Or,{nodeName:V,nodeEndpoint:Y,copyLabel:"Copy leader node URL",copiedMessage:"Leader Node URL copied",showPairingQr:ne})}),e.jsx(ct,{label:"Feed",value:d?"Receiving live updates":"Reconnecting to event stream"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:D&&e.jsxs(X,{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(fe,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})})]})]})]})})}),e.jsx(bt,{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(X,{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(qu,{className:"h-3 w-3"}),"Join node"]}):ee?e.jsxs(X,{variant:"secondary",size:"sm",onClick:g,disabled:j,className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",children:[j&&e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),_&&e.jsx(Xa,{node:_,systemInfo:n,blockingTaskCount:r.get(_.id)??0,devTunnelNodeId:b,onToggleNodeDevTunnel:w,showActions:!0,defaultExpanded:!0,onOpenNodeSettings:B?N:void 0,onOpenNodeCapabilities:B?A:void 0,onOpenDevBox:B?E:void 0,onStartDevBox:B?M:void 0,devBoxStartNodeId:k,devBoxStartingNodeIds:y})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"text-[10px] font-medium text-foreground",children:["Peer nodes (",O.length,")"]}),O.length>0?e.jsx("div",{className:"space-y-1.5",children:O.map(R=>e.jsx(Wf,{node:R,isLeader:!!B,blockingTaskCount:r.get(R.id)??0,devTunnelNodeId:b,onToggleNodeDevTunnel:w,onOpenNodeSettings:B?N:void 0,onOpenNodeCapabilities:B?A:void 0,onOpenDevBox:B?E:void 0,onStartDevBox:B?M:void 0,devBoxStartNodeId:k,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(bt,{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(ti,{className:L("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($e,{value:a,onValueChange:i,children:[e.jsx(qe,{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(Je,{placeholder:"Event type"})}),e.jsx(Ve,{className:"shadow-none",children:l.map(R=>e.jsx(Oe,{value:R,className:"py-1 pl-6 pr-1.5 text-[10px] leading-4",children:R==="all"?"All event types":R},R))})]}),e.jsx(Le,{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(Mc,{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 Xa({node:t,systemInfo:n,blockingTaskCount:s,devTunnelNodeId:r,onToggleNodeDevTunnel:a,showActions:i=!0,defaultExpanded:l=!1,onOpenNodeSettings:c,onOpenNodeCapabilities:d,onOpenDevBox:m,onStartDevBox:p,devBoxStartNodeId:u,devBoxStartingNodeIds:h}){const[f,j]=o.useState(l),g=n?.dashboardOrigin??t.dashboardOrigin,w=t.devtunnelEndpoint??t.endpoint,b=g??t.endpoint,k=n?.workDir??t.workDir,y=ai(t,n?.transportType),x=Er(t,n?.transportType),v=x&&fn(n?.transportType??t.transportType)?!0:ri(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:()=>j(A=>!A),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[f?e.jsx(st,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(nt,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx(vr,{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:b,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(jr,{className:"h-3 w-3"})}),(c||d||i&&v)&&e.jsx(Br,{nodeId:t.id,nodeName:t.name,node:t,onOpenSettings:c,onOpenCapabilities:d,onOpenDevBox:m,onStartDevBox:p,onToggleRemoteAccess:i&&v?()=>a(t):void 0,remoteAccessLabel:i&&v?x?"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:is(t.status,t.devbox?.lastStatus,t.devbox)||un(t.devbox?.lastStatus)||h.has(t.id),startDevBoxPending:u===t.id||un(t.devbox?.lastStatus)||h.has(t.id)})]}),e.jsxs("button",{type:"button",onClick:()=>j(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(wr,{role:t.role,size:"compact"}),e.jsx(Le,{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(ct,{label:"Node ID",value:t.id,mono:!0}),g&&e.jsx(ct,{label:"Dashboard",value:g,mono:!0,action:e.jsx(Fr,{nodeName:t.name,dashboardUrl:g})}),e.jsx(ct,{label:"Node URL",value:w,mono:!0,action:e.jsx(Or,{nodeName:t.name,nodeEndpoint:w})}),k&&e.jsx(ct,{label:"Workspace",value:k,mono:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsx(rr,{label:"Transport",value:y}),n&&e.jsx(rr,{label:"Uptime",value:Dc(n.uptime),mono:!0})]}),i&&d&&e.jsxs(X,{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(Rn,{className:"h-3 w-3"}),"Capabilities"]}),i&&v&&N&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[s," active task",s===1?"":"s"," on this node."]})]})]})}function Wf({node:t,isLeader:n,blockingTaskCount:s,devTunnelNodeId:r,onToggleNodeDevTunnel:a,onOpenNodeSettings:i,onOpenNodeCapabilities:l,onOpenDevBox:c,onStartDevBox:d,devBoxStartNodeId:m,devBoxStartingNodeIds:p}){const[u,h]=o.useState(!1),f=t.dashboardOrigin,j=t.devtunnelEndpoint??t.endpoint,g=f??t.endpoint,w=ai(t),b=Er(t),k=ri(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(x=>!x),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[u?e.jsx(st,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):e.jsx(nt,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx(vr,{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(jr,{className:"h-3 w-3"})}),n&&(i||l||k)&&e.jsx(Br,{nodeId:t.id,nodeName:t.name,node:t,onOpenSettings:i,onOpenCapabilities:l,onOpenDevBox:c,onStartDevBox:d,onToggleRemoteAccess:k?()=>a(t):void 0,remoteAccessLabel:k?b?"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:is(t.status,t.devbox?.lastStatus,t.devbox)||un(t.devbox?.lastStatus)||p.has(t.id),startDevBoxPending:m===t.id||un(t.devbox?.lastStatus)||p.has(t.id)})]}),e.jsxs("button",{type:"button",onClick:()=>h(x=>!x),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(wr,{role:t.role,size:"compact"}),e.jsx(Le,{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(ct,{label:"Node ID",value:t.id,mono:!0}),f&&e.jsx(ct,{label:"Dashboard",value:f,mono:!0,action:e.jsx(Fr,{nodeName:t.name,dashboardUrl:f})}),e.jsx(ct,{label:"Node URL",value:j,mono:!0,action:e.jsx(Or,{nodeName:t.name,nodeEndpoint:j,showPairingQr:!1})}),t.workDir&&e.jsx(ct,{label:"Workspace",value:t.workDir,mono:!0}),e.jsx(rr,{label:"Transport",value:w})]}),n&&l&&e.jsxs(X,{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(Rn,{className:"h-3 w-3"}),"Capabilities"]}),n&&k&&y&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[s," active task",s===1?"":"s"," on this node."]})]})]})}function Or({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(If,{nodeName:t,nodeEndpoint:n}):null,e.jsx(Ji,{label:s,onClick:()=>{In(n,r)}})]})}function Fr({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(Rf,{nodeName:t,dashboardUrl:n}),e.jsx(Ji,{label:s,onClick:()=>{In(n,r)}})]})}function Ji({label:t,onClick:n}){return e.jsx(X,{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(_o,{className:"h-3 w-3"})})}function Qf(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..."}:Qn.has(t.status)||t.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:Qn.has(t.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}const Zi=.5,Xi=1.75,eo=.1;function Yf({node:t,open:n,onOpenChange:s}){const[r,a]=o.useState($n),[i,l]=o.useState(null),[c,d]=o.useState(1),[m,p]=o.useState(!1),[u,h]=o.useState(null);o.useEffect(()=>{a($n),l(null),d(1),p(!1),h(null)},[t?.id,n]);const f=o.useCallback(async y=>{if(!t)return;const x=y??Number.parseInt(r.trim()||$n,10);if(!Number.isInteger(x)||x<1||x>65535){h("Enter a port between 1 and 65535");return}p(!0),h(null);try{const v=await _c(t.id,{port:x});l(v),a(String(x)),Yr("preview.created",{result:"success",previewType:"service-port"})}catch(v){h(v instanceof Error?v.message:"Failed to create service preview"),Yr("preview.failed",{result:"failed",previewType:"service-port"})}finally{p(!1)}},[t,r]),j=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){j();return}const x=window.setTimeout(j,y);return()=>window.clearTimeout(x)},[j,i]);const g=i?Wd(i):null,w=t?.name??"Node",b=Jf(c),k={width:`${100/c}%`,height:`${100/c}%`,transform:`scale(${c})`,transformOrigin:"top left"};return e.jsx(mt,{open:n,onOpenChange:s,children:e.jsxs(ht,{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(vt,{className:"flex min-w-0 items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[e.jsx(Zo,{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:w})]}),e.jsx(Dt,{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(dt,{type:"text",min:1,max:65535,inputMode:"numeric",value:r,onChange:y=>a(y.target.value),placeholder:$n,"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(X,{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(fe,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ss,{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:Zf(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(X,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-none",onClick:()=>d(y=>to(y,-eo)),disabled:c<=Zi,title:"Zoom out","aria-label":"Zoom out preview",children:e.jsx(Qu,{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:b}),e.jsx(X,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-none",onClick:()=>d(y=>to(y,eo)),disabled:c>=Xi,title:"Zoom in","aria-label":"Zoom in preview",children:e.jsx(Gu,{className:"h-3.5 w-3.5"})})]}),e.jsx(X,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",onClick:j,title:"Refresh",children:e.jsx(Lo,{className:"h-3.5 w-3.5"})}),e.jsx(X,{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(jr,{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:Yd(i),style:k,className:"h-full w-full border-0",sandbox:Qd(i),title:`${w} 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 to(t,n){return el(Math.round((t+n)*100)/100)}function el(t){return Number.isFinite(t)?Math.min(Xi,Math.max(Zi,t)):1}function Jf(t){return`${Math.round(el(t)*100)}%`}function Zf(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`}const Xf=new Set(["completed","failed","cancelled","archived"]);function ep(t){return typeof t=="object"&&t!==null}function tl(t){return typeof t=="string"&&t.trim().length>0?t.trim():""}function pr(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 tp(t){return t==="nativeSession"?"Native session":"Meshy chat"}function np(t){return t.effectiveProjectPath??t.project??"default workspace"}function sp(t){return ep(t.agentSessions)?Object.keys(t.agentSessions).map(n=>n.trim()).filter(Boolean):[]}function rp(t){const n=new Set;t.agent&&n.add(t.agent);const s=tl(t.payload.activeAgent);s&&n.add(s);for(const r of sp(t.payload))n.add(r);return Array.from(n).join(", ")||"None"}function ap(t){return t.status!=="running"?"None":tl(t.payload.activeAgent)||t.agent||"None"}function op(t){return t.assignedNodeName??t.assignedTo??"Unassigned"}function ip(t){const n=t.reduce((s,r)=>Math.max(s,r.updatedAt),0);return n>0?pr(n):"No task activity"}function Cn(t,n){return t.filter(s=>n.has(s.status)).length}function nl({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 lp({task:t}){const n=Xf.has(t.status),s=[{label:"Status",value:t.status},{label:"Kind",value:tp(t.conversationKind)},{label:"Priority",value:t.priority},{label:"Created",value:pr(t.createdAt)},{label:n?"Finished":"Updated",value:pr(t.updatedAt)}];return s.push({label:"Assigned node",value:op(t)},{label:"Workspace",value:np(t),mono:!0}),t.branch&&s.push({label:"Branch",value:t.branch,mono:!0}),s.push({label:"Task agents",value:rp(t)},{label:"Running agents",value:ap(t)},{label:"Retries",value:`${t.retryCount}/${t.maxRetries}`},{label:"Created by",value:t.createdBy},{label:"Task ID",value:t.id,mono:!0}),e.jsx(nl,{rows:s})}function cp({dirPath:t,nodeId:n,nodeName:s,nodeStatus:r,tasks:a,unloadedCompletedCount:i=0}){const l=Math.max(0,i),c=Cn(a,new Set(["completed"]))+l,d=Cn(a,new Set(["failed","cancelled"])),m=Cn(a,new Set(["archived"])),p=[{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(Cn(a,new Set(["assigned"])))},{label:"Running",value:String(Cn(a,new Set(["running"])))},{label:"Completed",value:String(c)},{label:"Failed / cancelled",value:String(d)},{label:"Archived",value:String(m)},{label:"Latest update",value:ip(a)}];return e.jsx(nl,{rows:p})}function dp({task:t,open:n,onOpenChange:s}){return e.jsx(mt,{open:n,onOpenChange:s,children:e.jsxs(ht,{className:"max-w-[25rem] gap-3 rounded-sm border-border/70 bg-background/96 p-4 backdrop-blur-xl",children:[e.jsxs(Mt,{className:"space-y-1",children:[e.jsx(vt,{className:"text-[13px]",children:"Task properties"}),e.jsx(Dt,{className:"truncate text-[10px] leading-4 text-muted-foreground",children:t.title})]}),e.jsx(lp,{task:t})]})})}function up({dirPath:t,nodeId:n,nodeName:s,nodeStatus:r,tasks:a,unloadedCompletedCount:i,open:l,onOpenChange:c}){return e.jsx(mt,{open:l,onOpenChange:c,children:e.jsxs(ht,{className:"max-w-[25rem] gap-3 rounded-sm border-border/70 bg-background/96 p-4 backdrop-blur-xl",children:[e.jsxs(Mt,{className:"space-y-1",children:[e.jsx(vt,{className:"text-[13px]",children:"Project properties"}),e.jsx(Dt,{className:"truncate text-[10px] leading-4 text-muted-foreground",children:t})]}),e.jsx(cp,{dirPath:t,nodeId:n,nodeName:s,nodeStatus:r,tasks:a,unloadedCompletedCount:i})]})})}function mp({dirPath:t,nodeId:n,nodeName:s,nodeStatus:r,tasks:a=[],unloadedCompletedCount:i,contextOpen:l=!1,contextPosition:c=null,defaultOpen:d=!1,onContextOpenChange:m,onCreateTask:p,onOpenCapabilities:u}){const{open:h,menuRef:f,triggerRef:j,menuStyle:g,closeMenu:w,toggleButton:b}=Lr({contextOpen:l,contextPosition:c,defaultOpen:d,onContextOpenChange:m}),[k,y]=o.useState(!1),x=h?e.jsxs("div",{ref:f,role:"menu",style:g,onClick:v=>v.stopPropagation(),onPointerDown:v=>v.stopPropagation(),className:Rr,children:[e.jsx(Xe,{icon:e.jsx(Ln,{className:"h-3 w-3 text-primary"}),onClick:()=>{w(),p()},children:"New chat"}),u&&e.jsx(Xe,{icon:e.jsx(Rn,{className:"h-3 w-3 text-primary"}),onClick:()=>{w(),u()},children:"Capabilities"}),e.jsx(Xe,{icon:e.jsx(yr,{className:"h-3 w-3 text-primary"}),onClick:()=>{w(),y(!0)},children:"Properties"})]}):null;return e.jsxs("div",{className:L("relative flex shrink-0 items-center self-center pr-1",h&&"z-[120]"),onClick:v=>v.stopPropagation(),onPointerDown:v=>v.stopPropagation(),children:[e.jsx("button",{ref:j,type:"button","aria-label":`More actions for ${t}`,"aria-haspopup":"menu","aria-expanded":h,title:`More actions for ${t}`,onClick:v=>{v.stopPropagation(),b()},className:L("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(Tr,{className:"h-2.5 w-2.5"})}),x&&(typeof document>"u"?x:ns.createPortal(x,document.body)),k&&e.jsx(up,{dirPath:t,nodeId:n,nodeName:s,nodeStatus:r,tasks:a,unloadedCompletedCount:i,open:k,onOpenChange:y})]})}function hp({dirPath:t,label:n,taskCount:s,tasks:r,unloadedCompletedCount:a,nodeId:i,nodeName:l,nodeStatus:c,collapsed:d,onToggle:m,onCreateTask:p,onOpenCapabilities:u}){const[h,f]=o.useState(!1),[j,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:w=>{w.preventDefault(),w.stopPropagation(),f(!0),g({left:w.clientX,top:w.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(nt,{className:L("h-3 w-3 shrink-0 transition-transform duration-200",!d&&"rotate-90")}),e.jsx(hn,{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(Rn,{className:"h-2.5 w-2.5"})}),e.jsx("button",{type:"button",onClick:p,"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(Ln,{className:"h-2.5 w-2.5"})}),e.jsx(mp,{dirPath:t,nodeId:i,nodeName:l,nodeStatus:c,tasks:r,unloadedCompletedCount:a,contextOpen:h,contextPosition:h?j:null,onContextOpenChange:w=>{w||(f(!1),g(null))},onCreateTask:p,onOpenCapabilities:u})]})}function no(t,n){if(!t.has(n))return t;const s=new Set(t);return s.delete(n),s}function fp(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 so(t,n,s){return s?{collapsedNodes:no(t,s.nodeKey),collapsedDirs:no(n,s.dirKey)}:{collapsedNodes:t,collapsedDirs:n}}function pp(t,n,s){const r=t.filter(d=>d.status==="completed"),a=new Set(r.filter(Pn).map(d=>d.id)),i=new Set((n?r:[...r].sort((d,m)=>m.updatedAt-d.updatedAt).slice(0,Nr)).map(d=>d.id));for(const d of a)i.add(d);s&&r.some(d=>d.id===s)&&i.add(s);const l=sl(t.filter(d=>d.status!=="completed"||i.has(d.id))),c=r.length-i.size;return{visibleTasks:l,hiddenCompletedCount:Math.max(0,c)}}function Pn(t){return t.pinnedOnTop===!0}function sl(t){return[...t].sort((n,s)=>{const r=Number(Pn(s))-Number(Pn(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 xp=new Set(["completed","failed","cancelled"]);function gp({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:p,triggerRef:u,menuStyle:h,closeMenu:f,toggleButton:j}=Lr({contextOpen:n,contextPosition:s,defaultOpen:r,onContextOpenChange:a}),[g,w]=o.useState(!1),[b,k]=o.useState(!1),[y,x]=o.useState(!1),[v,N]=o.useState(!1),[A,E]=o.useState(t.title),[M,B]=o.useState(null),D=Pn(t),_=xp.has(t.status),P=t.status==="archived"?"Task is already archived":"Only completed, failed, or cancelled tasks can be archived";o.useEffect(()=>{E(t.title)},[t.id,t.title]);async function O(V,ne){if(!(!ne||M)){B(V);try{await ne(),f()}finally{B(null)}}}const W=A.trim(),J=W===t.title,Y=m?e.jsxs("div",{ref:p,role:"menu",style:h,onClick:V=>V.stopPropagation(),onPointerDown:V=>V.stopPropagation(),className:Rr,children:[i&&e.jsx(Xe,{icon:e.jsx(Jt,{className:"h-3 w-3 text-primary"}),onClick:()=>{f(),w(!0)},children:"Update title"}),d&&e.jsx(Xe,{icon:D?e.jsx(Au,{className:"h-3 w-3 text-primary"}):e.jsx(Xo,{className:"h-3 w-3 text-primary"}),pending:M==="pin",onClick:()=>O("pin",()=>d(t,!D)),children:D?"Unpin from top":"Pin on top"}),c&&e.jsx(Xe,{icon:e.jsx(Go,{className:"h-3 w-3 text-primary"}),disabled:!_,pending:M==="archive",title:_?"Archive task":P,onClick:()=>{_&&(f(),x(!0))},children:"Archive"}),l&&e.jsx(Xe,{destructive:!0,icon:e.jsx(kr,{className:"h-3 w-3 text-destructive"}),onClick:()=>{f(),N(!0)},children:"Delete"}),e.jsx(Xe,{icon:e.jsx(yr,{className:"h-3 w-3 text-primary"}),onClick:()=>{f(),k(!0)},children:"Properties"})]}):null;return e.jsxs("div",{className:L("relative shrink-0",m&&"z-[120]"),onClick:V=>V.stopPropagation(),onPointerDown:V=>V.stopPropagation(),children:[e.jsx(X,{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:V=>{V.stopPropagation(),j()},className:L("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(Tr,{className:"h-3 w-3"})}),Y&&(typeof document>"u"?Y:ns.createPortal(Y,document.body)),b&&e.jsx(dp,{task:t,open:b,onOpenChange:k}),g&&i&&e.jsx(mt,{open:g,onOpenChange:w,children:e.jsxs(ht,{className:"rounded-sm sm:max-w-sm",children:[e.jsxs(Mt,{children:[e.jsx(vt,{children:"Update task title"}),e.jsx(Dt,{children:"Rename this task in the tree and transcript header."})]}),e.jsxs("form",{className:"space-y-3",onSubmit:V=>{V.preventDefault(),O("title",async()=>{!W||J||(await i?.(t,W),w(!1))})},children:[e.jsx(dt,{value:A,onChange:V=>E(V.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(br,{children:[e.jsx(X,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-sm px-2 text-[11px]",onClick:()=>w(!1),children:"Cancel"}),e.jsxs(X,{type:"submit",size:"sm",className:"h-7 rounded-sm px-2 text-[11px]",disabled:!W||J||M==="title",children:[M==="title"&&e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})]})}),y&&c&&e.jsx($t,{open:y,onOpenChange:x,children:e.jsxs(qt,{children:[e.jsxs(Vt,{children:[e.jsx(Ht,{children:"Archive this task?"}),e.jsx(Kt,{children:"This task leaves the default active view immediately."})]}),e.jsxs(Gt,{children:[e.jsx(Wt,{autoFocus:!0,children:"Cancel"}),e.jsx(Qt,{onClick:()=>O("archive",async()=>{await c?.(t),x(!1)}),disabled:M==="archive",children:"Archive"})]})]})}),v&&l&&e.jsx($t,{open:v,onOpenChange:N,children:e.jsxs(qt,{children:[e.jsxs(Vt,{children:[e.jsx(Ht,{children:"Delete this task and saved logs?"}),e.jsx(Kt,{children:"This cannot be undone."})]}),e.jsxs(Gt,{children:[e.jsx(Wt,{autoFocus:!0,children:"Cancel"}),e.jsx(Qt,{onClick:()=>O("delete",async()=>{await l?.(t),N(!1)}),disabled:M==="delete",className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}const rl="meshy-task-sidebar-tree-state";function ro(t){return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}function Js(){try{return globalThis.window?.localStorage??globalThis.localStorage??null}catch{return null}}function ao(t){if(!t)return{collapsedNodes:[],collapsedDirs:[]};try{const n=t.getItem(rl);if(!n)return{collapsedNodes:[],collapsedDirs:[]};const s=JSON.parse(n);return{collapsedNodes:ro(s.collapsedNodes),collapsedDirs:ro(s.collapsedDirs)}}catch{return{collapsedNodes:[],collapsedDirs:[]}}}function bp(t,n){if(t)try{t.setItem(rl,JSON.stringify(n))}catch{}}const Hn="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",Kn="py-1 pl-6 pr-1.5 text-[10px] leading-4 [&_svg]:h-3 [&_svg]:w-3";function oo({toolbarTasks:t,activeTaskId:n,tasksLoading:s,tasksError:r,isLeader:a,scope:i,agentFilter:l,nodeFilter:c,taskKindFilter:d,agentOptions:m,nodeOptions:p,nodeNameById:u,nodeWorkDirById:h,nodeStatusById:f,nodeInfoById:j,completedGroupByKey:g,devBoxNodeIds:w=new Set,devBoxStartNodeIds:b=new Set,devBoxStartingNodeIds:k=new Set,leaderNodeId:y,searchQuery:x,selectedTaskIds:v,allVisibleTasksSelected:N,someVisibleTasksSelected:A,canBatchArchive:E,onScopeChange:M,onAgentFilterChange:B,onNodeFilterChange:D,onTaskKindFilterChange:_,onToggleTaskSelected:P,onToggleAllVisibleTasks:O,onBatchArchive:W,onBatchDelete:J,onUpdateTaskTitle:Y,onDeleteTask:V,onArchiveTask:ne,onToggleTaskPinned:$,onCreateTask:ee,onOpenNodeSettings:S,onOpenNodeCapabilities:Q,onOpenProjectCapabilities:T,onOpenDevBox:te,onStartDevBox:R,onLoadCompletedTasks:H,onSelectTask:F}){const[le,ie]=o.useState(!1),[me,Z]=o.useState(()=>v.size>0),[K,I]=o.useState(!1),[se,q]=o.useState(null),[ae,ye]=o.useState(null),[pe,Ze]=o.useState(null),[Ae,ft]=o.useState(null),[Re,De]=o.useState(null),{markScrollbarActive:He,scrollbarActive:Ke}=Fi(),je=v.size,Be=!!(a&&(me||je>0)),G=i!=="active"||c!=="all"||l!=="all"||d!=="all",ge=x.trim().length>0,[be,et]=o.useState(()=>new Set(ao(Js()).collapsedNodes)),[_e,rt]=o.useState(()=>new Set(ao(Js()).collapsedDirs)),[re,Ne]=o.useState(new Set),Te=o.useMemo(()=>Pc({nodeStatusById:f,nodeNameById:u,nodeWorkDirById:h,nodeFilter:c,searchQuery:x}),[f,u,h,c,x]),ve=o.useMemo(()=>Ic(t,u,y,h,Te),[t,u,y,h,Te]),at=o.useMemo(()=>fp(ve,n),[ve,n]),Pe=o.useRef(null),_t=ve.length===1,pt=ve.length>0,pn=_t&&(G||ge),en=!!(a&&(t.length>0||je>0)),St=!!(a&&Y&&V&&ne&&$),wt=o.useCallback(U=>{et(ze=>{const Ie=new Set(ze);return Ie.has(U)?Ie.delete(U):Ie.add(U),Ie})},[]),xn=o.useCallback(U=>{rt(ze=>{const Ie=new Set(ze);return Ie.has(U)?Ie.delete(U):Ie.add(U),Ie})},[]),gn=o.useCallback(U=>{Ne(ze=>{const Ie=new Set(ze);return Ie.add(U),Ie})},[]);o.useEffect(()=>{bp(Js(),{collapsedNodes:Array.from(be),collapsedDirs:Array.from(_e)})},[_e,be]),o.useEffect(()=>{if(!at||!n)return;const U=`${n}:${at.nodeKey}:${at.dirKey}`;Pe.current!==U&&(Pe.current=U,et(ze=>so(ze,new Set,at).collapsedNodes),rt(ze=>so(new Set,ze,at).collapsedDirs))},[n,at]);const Pt=o.useCallback(U=>{Z(!0),O(U)},[O]),Ft=o.useCallback(U=>{if(U===!0&&!N){Z(!0),I(!0);return}Pt(U===!0)},[N,Pt]),tn=o.useCallback(()=>{Pt(!0),I(!1)},[Pt]),Ct=o.useCallback(()=>{O(!1),Z(!1),I(!1)},[O]),nn=o.useCallback(()=>{ye(null),Ze(null)},[]),Fe=o.useCallback(()=>{ft(null),De(null)},[]);o.useEffect(()=>{a||(Z(!1),I(!1))},[a]);const ot=Be?e.jsxs($t,{open:K,onOpenChange:I,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(_n,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:A&&!N?"indeterminate":N,onCheckedChange:Ft,"aria-label":"Select all visible tasks"}),e.jsx("span",{children:"Select all"})]}),K&&e.jsxs(qt,{children:[e.jsxs(Vt,{children:[e.jsx(Ht,{children:"Select every visible task?"}),e.jsx(Kt,{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(Gt,{children:[e.jsx(Wt,{autoFocus:!0,children:"Cancel"}),e.jsx(Qt,{onClick:tn,children:"Select all"})]})]})]}):e.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>Z(!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(Fd,{className:"h-3 w-3"}),"Multi select"]}),yt=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"]}),!E&&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,Tt=je>0?e.jsxs("div",{className:"flex flex-wrap justify-end gap-1",children:[e.jsxs($t,{children:[e.jsx(nr,{asChild:!0,children:e.jsxs(X,{variant:"ghost",size:"sm",disabled:!E,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(Go,{}),"Archive"]})}),e.jsxs(qt,{children:[e.jsxs(Vt,{children:[e.jsxs(Ht,{children:["Archive ",je," selected task",je!==1?"s":"","?"]}),e.jsx(Kt,{children:"These tasks leave the default view immediately. Cancel if any selected task still needs to stay visible in active work."})]}),e.jsxs(Gt,{children:[e.jsx(Wt,{autoFocus:!0,children:"Cancel"}),e.jsx(Qt,{onClick:W,disabled:!E,children:"Archive"})]})]})]}),e.jsxs($t,{children:[e.jsx(nr,{asChild:!0,children:e.jsxs(X,{variant:"destructive",size:"sm",className:"h-5 gap-1 rounded-sm px-1.5 text-[8px] [&_svg]:size-3",children:[e.jsx(kr,{}),"Delete"]})}),e.jsxs(qt,{children:[e.jsxs(Vt,{children:[e.jsxs(Ht,{children:["Delete ",je," selected task",je!==1?"s":""," and saved logs?"]}),e.jsx(Kt,{children:"This cannot be undone. Cancel unless you are certain every selected task and log should be removed now."})]}),e.jsxs(Gt,{children:[e.jsx(Wt,{autoFocus:!0,children:"Cancel"}),e.jsx(Qt,{onClick:J,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(X,{onClick:()=>ee("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(Ln,{className:"h-3.5 w-3.5"}),"New chat"]}),e.jsxs(X,{variant:"outline",onClick:()=>ee("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(Ar,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Load session"]})]}),e.jsx(X,{variant:"ghost",size:"icon",onClick:()=>ie(U=>!U),className:L("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(hu,{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($e,{value:i,onValueChange:U=>M(U),children:[e.jsx(qe,{className:Hn,children:e.jsx(Je,{})}),e.jsx(Ve,{children:Rc.map(U=>e.jsx(Oe,{value:U.value,className:Kn,children:U.label},U.value))})]}),e.jsxs($e,{value:c,onValueChange:D,children:[e.jsx(qe,{className:Hn,children:e.jsx(Je,{placeholder:"Node"})}),e.jsx(Ve,{children:p.map(U=>e.jsx(Oe,{value:U.value,className:Kn,children:U.label},U.value))})]}),e.jsxs($e,{value:l,onValueChange:B,children:[e.jsx(qe,{className:Hn,children:e.jsx(Je,{placeholder:"Agent"})}),e.jsx(Ve,{children:m.map(U=>e.jsx(Oe,{value:U,className:Kn,children:U==="all"?"All agents":U},U))})]}),e.jsxs($e,{value:d,onValueChange:U=>_(U),children:[e.jsx(qe,{className:Hn,children:e.jsx(Je,{placeholder:"Type"})}),e.jsx(Ve,{children:Lc.map(U=>e.jsx(Oe,{value:U.value,className:Kn,children:U.label},U.value))})]})]})]}),e.jsx("div",{className:L("scrollbar-line min-h-0 flex-1 overflow-y-auto pl-2.5 pr-1.5 py-2",Ke&&"scrollbar-line-active"),onScroll:He,children:ve.length>0?e.jsx("div",{className:"space-y-1",children:ve.map(U=>{const ze=U.nodeId??"__unassigned__",Ie=U.dirs.reduce((xe,he)=>xe+he.tasks.length,0),We=pt&&!pn&&be.has(ze),Qe=U.nodeId!==null&&f.get(U.nodeId)==="offline",sn=!!(a&&U.nodeId);return e.jsxs("div",{className:"space-y-1",children:[pt&&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=>{!sn||!U.nodeId||(xe.preventDefault(),xe.stopPropagation(),ft(U.nodeId),De({left:xe.clientX,top:xe.clientY}))},children:[e.jsxs("button",{type:"button",onClick:()=>wt(ze),"aria-expanded":!We,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm px-2 py-1.5 text-left",children:[e.jsx(nt,{className:L("h-3.5 w-3.5 shrink-0 transition-transform duration-200",!We&&"rotate-90")}),e.jsx(ts,{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(Le,{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:[Ie," task",Ie===1?"":"s"]})]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[Qe&&e.jsx(Le,{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(Le,{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"})]})]}),sn&&U.nodeId&&e.jsx("span",{className:"flex shrink-0 items-center pr-1.5",children:e.jsx(Br,{nodeId:U.nodeId,nodeName:U.nodeName,node:U.nodeId?j?.get(U.nodeId):void 0,contextOpen:Ae===U.nodeId,contextPosition:Ae===U.nodeId?Re:null,onContextOpenChange:xe=>{xe||Fe()},onOpenSettings:S,onOpenServicePreview:()=>q({id:U.nodeId,name:U.nodeName}),onOpenCapabilities:Q,onOpenDevBox:te,onStartDevBox:R,showConfigureDevBox:w.has(U.nodeId),showStartDevBox:b.has(U.nodeId)||k.has(U.nodeId),startDevBoxPending:k.has(U.nodeId)})})]}),e.jsx("div",{className:L("grid transition-[grid-template-rows] duration-300 ease-in-out",We?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:"overflow-hidden",children:U.dirs.map(xe=>{const he=`${ze}::${xe.path}`,ke=_e.has(he),Ge=Bo(xe.path),Ue=g?.get(he),zt=Ue?{visibleTasks:sl(xe.tasks),hiddenCompletedCount:Math.max(0,Ue.total-Ue.returned)}:pp(xe.tasks,re.has(he),n),{visibleTasks:ls,hiddenCompletedCount:bn}=zt;return e.jsxs("div",{className:L("space-y-0.5 rounded-xl",pt&&"pl-2.5"),children:[e.jsx(hp,{dirPath:xe.path,label:Ge,taskCount:xe.tasks.length,tasks:xe.tasks,unloadedCompletedCount:Ue?Math.max(0,Ue.total-Ue.returned):0,nodeId:U.nodeId,nodeName:U.nodeName,nodeStatus:U.nodeId?f.get(U.nodeId):void 0,collapsed:ke,onToggle:()=>xn(he),onCreateTask:()=>ee("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:L("grid transition-[grid-template-rows] duration-300 ease-in-out",ke?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:L("overflow-hidden",pt?"pl-2":"pl-0"),children:e.jsxs("div",{className:"space-y-px py-0.5",children:[ls.map(Ee=>{const rn=Ee.id===n,It=Ee.assignedTo?f.get(Ee.assignedTo):void 0,vn=!!Ee.assignedTo&&(It?It==="offline":Ee.assignedNodeAvailable===!1),cs=$i(Ee),ds=Pn(Ee);return e.jsxs("div",{onContextMenu:it=>{it.preventDefault(),it.stopPropagation(),ye(Ee.id),Ze({left:it.clientX,top:it.clientY})},className:L("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",rn?'bg-primary/10 before:absolute before:left-0 before:top-1/2 before:h-1/2 before:w-[2px] before:-translate-y-1/2 before:rounded-full before:bg-primary before:content-[""]':"hover:bg-muted/40"),children:[Be&&e.jsx("div",{className:"flex shrink-0",onClick:it=>it.stopPropagation(),children:e.jsx(_n,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:v.has(Ee.id),onCheckedChange:it=>P(Ee.id,it===!0),"aria-label":`Select ${Ee.title}`})}),e.jsxs("button",{type:"button",onClick:()=>F(Ee.id),"aria-current":rn?"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:[ds&&e.jsx("span",{role:"img","aria-label":"Pinned to top",title:"Pinned to top",className:"flex shrink-0",children:e.jsx(Xo,{className:"h-2.5 w-2.5 -rotate-45 text-primary"})}),e.jsx("span",{className:L("min-w-0 flex-1 truncate text-[10px] font-medium leading-4",rn?"text-foreground":"text-foreground/80"),children:Ee.title})]}),e.jsx("span",{className:L("absolute right-0 top-0 shrink-0 tabular-nums text-[8px] leading-4",rn?"text-primary/75":"text-muted-foreground/55"),children:Bc(Ee.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:cs}),Ee.activeShare&&e.jsx(Le,{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"}),vn&&e.jsx(Le,{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(Io,{status:Ee.status,isNative:Ee.conversationKind==="nativeSession",size:"compact",className:"absolute bottom-1 right-0"})]}),e.jsx(gp,{task:Ee,contextOpen:ae===Ee.id,contextPosition:ae===Ee.id?pe:null,onContextOpenChange:it=>{it||nn()},onUpdateTitle:St?Y:void 0,onDeleteTask:St?V:void 0,onArchiveTask:St?ne:void 0,onTogglePinned:St?$:void 0})]},Ee.id)}),bn>0&&e.jsxs("button",{type:"button",onClick:()=>{Ue&&H?H(Ue):gn(he)},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 ${bn} more completed tasks in ${Ge}`,children:[e.jsx(st,{className:"h-3 w-3"}),"Load ",bn," more completed"]})]})})})]},he)})})})]},ze)})}):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."})}),en?e.jsx("div",{className:"shrink-0 px-2.5 pb-2.5 pt-1.5",children:Be&&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:[yt,e.jsx(X,{variant:"ghost",size:"sm",onClick:Ct,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:ot}),Tt]})]}):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:ot}),Be&&e.jsx(X,{variant:"ghost",size:"sm",onClick:Ct,className:"h-5 shrink-0 rounded-sm px-1.5 text-[9px]",children:"Done"})]})}):null]}),e.jsx(Yf,{node:se,open:se!==null,onOpenChange:U=>{U||q(null)}})]})}async function vp(t,n){try{const s=await Oc(t,n),r={...s,url:Do(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 wp(t){try{return await Fc(t),ce.success("Shared link stopped"),!0}catch(n){return ce.error(n instanceof Error?n.message:"Failed to stop shared link"),!1}}function yp(t,n,s){const r=o.useCallback(()=>{n(),s()},[n,s]),a=o.useCallback(async l=>{if(!t)return;const c=await vp(t.id,l);return c&&r(),c},[t,r]),i=o.useCallback(async()=>{if(!t)return!1;const l=await wp(t.id);return l&&r(),l},[t,r]);return{handleShareTask:a,handleStopShareTask:i}}function io(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?.())},p=t?.current??document;return p.addEventListener("touchstart",d,{passive:!0}),p.addEventListener("touchend",m,{passive:!0}),()=>{p.removeEventListener("touchstart",d),p.removeEventListener("touchend",m)}},[t,s?.threshold,s?.maxVertical])}const jp="(min-width: 1024px)",Np="(min-width: 1800px)";function lo(t){return globalThis.window?.matchMedia?.(t)?.matches??!1}function kp(){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 Sp(){const[t,n]=o.useState(()=>zc(Jr(),Uc({operationsOpen:lo(Np)}))),[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(()=>{$c(Jr(),t)},[t]);const p=o.useCallback((w,b)=>{n(k=>{const y=k.layout[w],x=typeof b=="function"?b(y):b;return x===y?k:{...k,layout:{...k.layout,[w]:x}}})},[]),u=o.useCallback(w=>{p("desktopTasksOpen",w)},[p]),h=o.useCallback(w=>{p("operationsOpen",w)},[p]);io(i,{onSwipeLeft:()=>r(!1)}),io(l,{onSwipeRight:()=>h(!1)});const f=o.useCallback(()=>{if(lo(jp)){u(w=>!w);return}r(w=>!w)},[u]);o.useEffect(()=>{const w=k=>{const y=a.current;if(!y)return;k.preventDefault();const x=Vc(y.panel,y.startSize,y.startClientX,y.startClientY,k.clientX,k.clientY,y.rootFontSize);n(v=>({...v,sizes:{...v.sizes,[y.panel]:x}}))},b=()=>{a.current=null};return globalThis.window?.addEventListener("pointermove",w),globalThis.window?.addEventListener("pointerup",b),globalThis.window?.addEventListener("pointercancel",b),()=>{globalThis.window?.removeEventListener("pointermove",w),globalThis.window?.removeEventListener("pointerup",b),globalThis.window?.removeEventListener("pointercancel",b)}},[]);const j=o.useCallback((w,b)=>{b.preventDefault(),b.currentTarget.setPointerCapture?.(b.pointerId),a.current={panel:w,startSize:m[w],startClientX:b.clientX,startClientY:b.clientY,rootFontSize:kp()}},[m]),g=o.useCallback((w,b)=>{b.preventDefault(),n(k=>({...k,sizes:{...k.sizes,[w]:qc(w,k.sizes[w],b.deltaY)}}))},[]);return{desktopTasksOpen:c,mobileTasksPanelOpen:s,mobileTasksPanelRef:i,operationsOpen:d,operationsPanelRef:l,panelResize:{sizes:{tasks:bs(m.tasks),operations:bs(m.operations),terminal:bs(m.terminal)},onPointerDown:j,onWheel:g},setMobileTasksPanelOpen:r,setOperationsOpen:h,toggleTasksPanel:f}}function Cp(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 Tp="notify_desktop_task";function Ap(t=al()){const n=t?.__TAURI__?.core?.invoke;return typeof n=="function"?n:null}async function Ep(t,n=al()){const s=Ap(n);return s?(await s(Tp,t),!0):!1}function Mp(t,n){const s=[];for(const r of n){const a=Dp(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 Dp(t){return t==="completed"||t==="failed"?t:null}function al(){return typeof window>"u"?null:window}function _p({isLeader:t,selfId:n}){return{...!t&&n?{assignedTo:n}:{},completedLimitPerProject:Nr}}function xr(t){return`${t.assignedTo??"__unassigned__"}::${t.projectPath}`}function Pp(t,n,s,r,a){if(xr(t)!==xr(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 Ip(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 Rp(t,n,s=new Set){return!n||s.has(n.id)||t.some(r=>r.id===n.id)?t:Mr(t,n)}function Lp({isLeader:t,selfId:n,sseConnected:s,preservedTask:r,subscribe:a}){const[i,l]=o.useState([]),[c,d]=o.useState([]),[m,p]=o.useState(!0),[u,h]=o.useState(null),f=o.useRef(new Set),j=o.useRef(null),g=o.useRef(null),w=o.useCallback(async()=>{try{const x=await Zr(_p({isLeader:t,selfId:n}));l(Rp(x.tasks,r,f.current)),d(x.completedGroups??[]),h(null)}catch(x){h(x instanceof Error?x.message:"Failed to load tasks")}finally{p(!1)}},[t,r,n]),b=o.useCallback(async x=>{if(!x.hasMore||!x.nextCursor)return;const v=await Zr({status:"completed",assignedTo:x.assignedTo??"__unassigned__",projectPath:x.projectPath,cursor:x.nextCursor,limit:Nr});l(N=>Ip(N,v.tasks)),d(N=>N.map(A=>Pp(A,x,i,v.tasks,v)))},[i]),k=o.useCallback(()=>{g.current===null&&(g.current=window.setTimeout(()=>{g.current=null,w()},Hc))},[w]),y=o.useCallback(x=>{const v=new Set(x);if(v.size!==0){for(const N of v)f.current.add(N);l(N=>N.filter(A=>!v.has(A.id)))}},[]);return Kc(w,Qc(s)),o.useEffect(()=>()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),o.useEffect(()=>{const x=j.current;if(x)for(const v of Mp(x,i))Ep(v).catch(()=>{});j.current=new Map(i.map(v=>[v.id,v]))},[i]),o.useEffect(()=>{const x=[a("task.updated",v=>{l(N=>Cp(N,v.data))}),a("task.status",v=>{l(N=>Gc(N,v.data))}),a("node",v=>{Xr(v.type)&&k()}),a("task",v=>{if(v.type==="task.deleted"){const N=v.data.taskId;typeof N=="string"&&f.current.add(N),l(A=>Wc(A,v.data))}Xr(v.type)&&k()})];return()=>x.forEach(v=>v())},[a,k]),{completedGroups:c,fetchTasks:w,loadCompletedTasksPage:b,removeTasksFromList:y,setTasks:l,tasks:i,tasksError:u,tasksLoading:m}}function zr(t){return t.map(n=>({...n}))}function Bp(t,n){const s=n.get(t);return{logs:s?zr(s.logs):[],transcriptLoading:s?.loaded!==!0}}function Op(t,n){return n.data.nodeId===t.self.id||n.data.name===t.self.name||n.data.endpoint===t.self.endpoint}function Fp(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 zp({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=Fp(r,s),i=Op(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 Up({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 $p({activeTaskId:t,cacheTranscript:n,fetchActiveLogs:s,fetchActiveTask:r,logs:a,setLogs:i,setPendingMessages:l,setTranscriptLoading:c,sseConnected:d,subscribe:m}){const p=o.useRef([]),u=o.useRef(d),h=o.useRef(!1),f=o.useRef(!1),j=o.useRef(void 0);o.useEffect(()=>{p.current=zr(a)},[a]);const g=o.useCallback(w=>{if(h.current){f.current=!0,w!==void 0&&(j.current=Math.max(j.current??0,w));return}const b=Up({localCount:p.current.length,checkpointTotal:w});b&&(h.current=!0,s(b).finally(()=>{if(h.current=!1,!f.current)return;f.current=!1;const k=j.current;j.current=void 0,g(k)}))},[s]);o.useEffect(()=>{if(t)return m("task",w=>{const b=w.data.taskId;if(!(typeof b!="string"||b!==t)){if(w.type==="task.output"){const k=w.data.event;if(k){i(x=>{const v=zd(x,k);return n(t,v),v}),c(!1);const y=Cr(k);y&&l(x=>Ud(x,y))}}if(w.type==="task.updated"&&r(),w.type==="task.logs.ready"){const k=w.data.total;g(typeof k=="number"?k:void 0)}w.type==="task.status"&&(r(),g())}})},[t,n,s,r,g,i,l,c,m]),o.useEffect(()=>{const w=u.current;u.current=d,!w&&d&&t&&g()},[t,g,d])}const qp=[0,300,1e3,2e3];function Vp({task:t,getActiveTaskId:n,setLogs:s,setPendingMessages:r,setTranscriptLoading:a}){t.conversationKind==="nativeSession"&&(async()=>{try{for(const i of qp){if(i>0&&await new Promise(l=>setTimeout(l,i)),n()!==t.id)return;try{const l=await sr(t.id);if(n()!==t.id||(s(c=>Ko(c,l.logs)),r(c=>ar(c,l.logs)),l.total>0))return}catch{}}}finally{n()===t.id&&a?.(!1)}})()}const ol=8;function Hp(t,n){return Ye(t??{})===Ye(n??{})}function Kp(t){return t&&"status"in t&&typeof t.status=="string"?t.status:void 0}function co(t,n){return{...t,enabled:!0,alwaysOnline:n}}function il(t){return t?.status?.trim()||t?.lastStatus?.trim()||"Unknown"}function Gp({operationStarting:t,loading:n,refreshing:s,savedStatus:r,fallbackStatus:a}){return t?"Starting":n?"Listing DevBoxes":s?"Refreshing":r??a}async function Wp(t,n=Oo){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,ol)}function Qp(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Yp(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 Jp(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function uo(t,n){const r=Jp(t)?.[n];return typeof r=="string"&&r.trim()?r.trim():null}function Zp(t){if(t.status==="failed")return t.error||"Operation failed";const n=uo(t.result,"operationId");if(n)return`MCP operation ${n}`;const s=uo(t.payload,"previousStatus");return s?`Previous DevBox status: ${s}`:t.status==="succeeded"?"Completed":"Waiting for completion"}function Xp(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 mo({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:il(t)})]})}function ex({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(st,{className:L("h-3 w-3 shrink-0 text-muted-foreground transition-transform",!r&&"-rotate-90")}),e.jsx(Jn,{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(fe,{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(fe,{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=Zp(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:Yp(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:L("shrink-0 rounded-sm border px-1.5 py-0 text-[10px] leading-4",Xp(i.status)),children:Qp(i.status)})]},i.id)})]})]})}function tx({node:t,open:n,startInProgress:s=!1,onOpenChange:r,onRefresh:a}){const i=t?.id??null,l=n&&!s&&Ja(t?.status,t?.devbox??null),[c,d]=o.useState([]),[m,p]=o.useState(()=>t?.devbox?Ye(t.devbox):""),[u,h]=o.useState(()=>t?.devbox??null),[f,j]=o.useState(()=>Za(t?.devbox??null)),[g,w]=o.useState(!1),[b,k]=o.useState(l),[y,x]=o.useState(!1),[v,N]=o.useState(!1),[A,E]=o.useState(()=>t?.devbox?.alwaysOnline===!0),[M,B]=o.useState(!1),[D,_]=o.useState([]),[P,O]=o.useState(!1),[W,J]=o.useState(null),Y=o.useMemo(()=>{const q=c.find(ae=>Ye(ae)===m);return q||(dn(u)&&Ye(u)===m?u:void 0)},[u,c,m]),V=Kp(Y??void 0),ne=f?V??u?.lastStatus:u?.lastStatus??V,$=t?.status==="online"||t?.status==="busy"?"Running":"Unknown",ee=v||s,S=Gp({operationStarting:ee,loading:g,refreshing:b,savedStatus:ne,fallbackStatus:$}),Q=f&&!!Y&&!Hp(u,Y),T=u?.alwaysOnline===!0!==A,te=Vf({nodeStatus:t?.status,status:S,current:u,selected:Y}),R=!!te,H=!!Y&&(Q||T)&&!R,F=Y??u,le=o.useCallback(async()=>{if(i){k(!0);try{const q=await Yc(i);h(q.devbox),p(Ye(q.devbox))}catch(q){ce.error(q instanceof Error?q.message:"Failed to refresh DevBox status")}finally{k(!1)}}},[i]),ie=o.useCallback(async q=>{w(!0);try{const ae=await Jc();d(ae),p(ye=>Hf({previousKey:ye,baseDevBox:q,listed:ae}))}catch(ae){ce.error(ae instanceof Error?ae.message:"Failed to load DevBoxes")}finally{w(!1)}},[]);o.useEffect(()=>{if(!n||!i)return;let q=!1;const ae=t?.devbox??null,ye=Za(ae),pe=!s&&Ja(t?.status,ae);w(!1),k(pe),j(ye),h(ae),E(ae?.alwaysOnline===!0),B(!1),p(dn(ae)?Ye(ae):""),d([]);async function Ze(){pe&&await le(),!q&&ye&&await ie(ae)}return Ze(),()=>{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(){O(!0),J(null),_([]);try{const pe=await Wp(ae);if(q)return;_(pe)}catch(pe){if(q)return;_([]),J(pe instanceof Error?pe.message:"Failed to load operation history")}finally{q||O(!1)}}return ye(),()=>{q=!0}},[i,n]);async function me(){j(!0),c.length===0&&await ie(u)}async function Z(){if(!(!t||!Y)){x(!0);try{const q=await ea(t.id,co(Y,A));h(q.node.devbox??null),q.node.devbox&&p(Ye(q.node.devbox)),j(!1),ce.success(`Configured DevBox for ${t.name}`),await a?.()}catch(q){ce.error(q instanceof Error?q.message:"Failed to configure DevBox")}finally{x(!1)}}}async function K(){if(!(!t||!te)){N(!0);try{if(Y&&(Q||T)){const ae=await ea(t.id,co(Y,A));h(ae.node.devbox??null),ae.node.devbox&&p(Ye(ae.node.devbox)),j(!1)}const{operation:q}=await Fo(t.id);h(ae=>ae&&{...ae,lastStatus:"Starting",checkedAt:Date.now(),operationId:q.id}),_(ae=>[q,...ae.filter(ye=>ye.id!==q.id)].slice(0,ol)),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 I=g?"Loading DevBoxes...":c.length===0?"No DevBoxes available":"Select a DevBox",se=S==="Running"&&t?.status==="offline";return e.jsx(mt,{open:n,onOpenChange:r,children:e.jsxs(ht,{className:"w-[calc(100vw-2rem)] max-w-md grid-cols-[minmax(0,1fr)] gap-3 overflow-hidden rounded-sm p-4",children:[e.jsxs(Mt,{className:"min-w-0 max-w-full space-y-1 overflow-hidden",children:[e.jsx(vt,{className:"text-sm",children:"Configure DevBox"}),e.jsxs(Dt,{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||F)&&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($e,{value:m,onValueChange:p,disabled:g||y||v||c.length===0,children:[e.jsx(qe,{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(fe,{className:"h-3.5 w-3.5 animate-spin"}),I]}):Y?e.jsx(mo,{devbox:Y}):e.jsx(Je,{placeholder:I})}),e.jsx(Ve,{children:c.map(q=>e.jsx(Oe,{value:Ye(q),textValue:`${q.name} ${q.projectName??""} ${il(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(mo,{devbox:q,showStatus:!0})},Ye(q)))})]}):F&&e.jsxs("div",{className:"min-w-0 truncate",children:[e.jsx("span",{className:"font-medium text-foreground",children:F.name}),F.projectName&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",F.projectName]})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(Le,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px]",children:[(g||b)&&e.jsx(fe,{className:"mr-1 h-2.5 w-2.5 animate-spin"}),S]}),u?.name&&e.jsx(X,{type:"button",variant:"ghost",size:"icon",onClick:()=>{me()},disabled:g||y||ee||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(fe,{className:"h-3 w-3 animate-spin"}):e.jsx(Jt,{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(_n,{checked:A,onCheckedChange:q=>E(q===!0),disabled:y||v||ee,"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(ex,{error:W,loading:P,onToggle:()=>B(q=>!q),open:M,operations:D})]}),e.jsxs(br,{className:"gap-2 sm:space-x-0",children:[e.jsx(X,{variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:y||v,className:"h-8 rounded-sm text-xs",children:"Close"}),R&&e.jsxs(X,{size:"sm",onClick:K,disabled:v,className:"h-8 rounded-sm text-xs",children:[v?e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ss,{className:"h-3.5 w-3.5"}),"Start DevBox"]}),!R&&e.jsxs(X,{size:"sm",onClick:Z,disabled:!H||y,className:"h-8 rounded-sm text-xs",children:[y&&e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})})}async function nx(t,n=Oo){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 sx({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),p=o.useMemo(()=>t?.nodes.find(b=>b.id===s)??null,[t?.nodes,s]),u=o.useMemo(()=>new Set((t?.nodes??[]).filter(b=>b.devbox?.enabled).map(b=>b.id)),[t?.nodes]),h=o.useMemo(()=>new Set((t?.nodes??[]).filter(b=>is(b.status,b.devbox?.lastStatus,b.devbox)).map(b=>b.id)),[t?.nodes]),f=o.useMemo(()=>new Set((t?.nodes??[]).filter(b=>un(b.devbox?.lastStatus)).map(b=>b.id)),[t?.nodes]),j=o.useMemo(()=>{const b=new Set(l);a&&b.add(a);for(const k of d)b.add(k);for(const k of f)b.add(k);return b},[d,a,l,f]);o.useEffect(()=>{let b=!1;const k=[...u];async function y(){try{const x=await nx(k);b||m(x)}catch{b||m(new Set)}}return y(),()=>{b=!0}},[u]),o.useEffect(()=>{c(b=>{let k=!1;const y=new Set(b);for(const x of b){const v=t?.nodes.find(N=>N.id===x);v?.status!=="online"&&(!v?.devbox?.lastStatus||un(v.devbox.lastStatus))||(y.delete(x),k=!0)}return k?y:b})},[t?.nodes]);const g=o.useCallback(async b=>{const k=t?.nodes.find(y=>y.id===b);if(k){i(b),c(y=>new Set(y).add(b));try{await Fo(b),ce.success(`Start requested for ${k.name}`),n()}catch(y){c(x=>{const v=new Set(x);return v.delete(b),v}),ce.error(y instanceof Error?y.message:"Failed to start DevBox")}finally{i(null)}}},[t?.nodes,n]);return{devBoxDialog:e.jsx(tx,{node:p,open:s!==null,startInProgress:p?j.has(p.id):!1,onOpenChange:b=>{b||r(null)},onRefresh:n}),devBoxNodeIds:u,devBoxStartNodeId:a,devBoxStartNodeIds:h,devBoxStartingNodeIds:j,openDevBox:r,startDevBox:g}}function rx(t){const[n,s]=o.useState(null),r=o.useCallback(i=>{t&&s(i)},[t]);return{nodeSettingsDialog:e.jsx(Zc,{open:n!==null,onOpenChange:i=>{i||s(null)},initialSelectedNodeId:n??void 0,showTrigger:!1}),openNodeSettings:r}}function ax(t=!1){return!t}function ox({activeTaskId:t,fetchActiveTask:n,isRunning:s=!1,setPendingMessages:r,setTask:a,setTasks:i}){const l=o.useCallback((m,p)=>{a(u=>u&&u.id===m?{...u,queuedMessages:p}:u),i(u=>u.map(h=>h.id===m?{...h,queuedMessages:p}:h))},[a,i]),c=o.useCallback(async(m,p={})=>{if(!t)return!1;const u=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`,h=ax(s);h&&r(f=>[...f,{id:u,content:m,timestamp:new Date().toISOString()}]);try{const f=p.targetAgent?await ta(t,m,p.targetAgent):await ta(t,m);return f.queued&&(h&&r(j=>j.filter(g=>g.id!==u)),f.queuedMessages&&l(t,f.queuedMessages)),n(),!0}catch(f){return h&&r(j=>j.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 p=await Xc(t,m);l(t,p.queuedMessages),n()}catch(p){ce.error(p instanceof Error?p.message:"Failed to cancel queued message")}},[t,n,l]),queueFollowUpMessage:c}}const ho="grid-cols-[1.5rem_5.25rem_4rem_minmax(8rem,1fr)_4rem_4rem_6rem]",ix={claudecode:"Claude Code",codex:"Codex",copilot:"Copilot"};function lx(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 ll(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 cx({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:L("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",ho),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:L("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",ho,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(_n,{className:"h-3 w-3",checked:n.has(i.id),onCheckedChange:l=>r(i.id,l===!0),"aria-label":`Select ${i.name}`})}),e.jsx(dx,{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:ll(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 dx({agent:t}){const n=ix[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 fo=320,po=560,cl=384,xo=360;function ux(t,n=po+xo){const s=Math.max(fo,Math.min(po,n-xo));return Math.min(Math.max(Math.round(t),fo),s)}function mx(t,n,s,r){return ux(t+n-s,r)}function hx({detail:t,deleting:n=!1,onDelete:s,desktopWidth:r=cl,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(Le,{variant:"secondary",className:"rounded-sm border-0 bg-card/72 px-1.5 py-0 text-[8px] text-primary",children:t.agent}),e.jsx(Le,{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($t,{children:[e.jsx(nr,{asChild:!0,children:e.jsx(X,{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(kr,{className:"h-3.5 w-3.5"})})}),e.jsxs(qt,{className:"max-w-[22rem] gap-2 rounded-xl p-4",children:[e.jsxs(Vt,{className:"space-y-1",children:[e.jsxs(Ht,{className:"text-sm",children:["Delete ",t.name,"?"]}),e.jsxs(Kt,{className:"text-[11px] leading-4",children:["This removes the selected ",t.kind," from ",t.scope.kind==="global"?"the user profile":"this project","."]})]}),e.jsxs(Gt,{className:"gap-1 pt-0 sm:space-x-1",children:[e.jsx(Wt,{className:"h-7 rounded-lg px-2 text-[11px]",children:"Cancel"}),e.jsx(Qt,{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(Gn,{label:"Version",value:t.version??"-"}),e.jsx(Gn,{label:"Size",value:ll(t)}),e.jsx(Gn,{label:"Files",value:String(t.fileCount)}),e.jsx(Gn,{label:"Source",value:t.source??"local"})]}),e.jsxs(_r,{defaultValue:l,className:"mt-2 flex min-h-0 flex-1 flex-col",children:[e.jsxs(os,{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(bt,{value:"mcp",className:"mt-2 min-h-0 flex-1 overflow-auto",children:e.jsx(fx,{detail:t})}):e.jsx(bt,{value:"files",className:"mt-2 min-h-0 flex-1 overflow-auto",children:e.jsx(px,{detail:t})}),e.jsx(bt,{value:"readme",className:"mt-2 min-h-0 flex-1 overflow-auto",children:t.readmeMarkdown?e.jsx(Gd,{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(Ur,{children:"No README content."})})]},t.id)]})}function fx({detail:t}){const n=t.mcpPreview??[];return n.length===0?e.jsx(Ur,{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 px({detail:t}){const n=t.fileTree??[];return n.length===0?e.jsx(Ur,{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 Ur({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 Gn({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 xx=20,gx=288,bx=360,vx=440;function wx(){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 yx({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,p=s.bottom-d,u=s.left+d,h=s.right-d,f=Math.max(0,p-t.bottom-4),j=Math.max(0,t.top-m-4),g=r?j<140&&f>j:f>=220||f>=j,w=g?f:j,b=Math.max(140,p-m),k=r&&a,v=Math.min(b,k?vx:320,Math.max(k?bx:140,w)),N=gx*c,A=i==="end"?t.right-N:t.left,M=(Math.max(u,Math.min(A,h-N))-n.left)/c;if(!g&&!k)return{left:M,bottom:(n.bottom-(t.top-4))/c,maxHeight:v/c};const B=g?t.bottom+4:t.top-v-4,D=Math.max(m,Math.min(B,p-v));return{left:M,top:(D-n.top)/c,maxHeight:v/c}}function $r(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(ul(a)?a:ml(t.workDir,a));return n}function jx(t,n){if(t.kind==="global")return{nodeId:n.id,scope:{kind:"global"}};const s=$r(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 Nx(t,n){return{nodeId:t,scope:n}}function go(t,n,s){const r=n.trim();return!r||r==="."?t.workDir??r:s||ul(r)?r:t.workDir?ml(t.workDir,r):r}function kx({node:t,scope:n,clusterNodes:s,onSelectionChange:r}){const a=o.useMemo(()=>Ax(s,t),[s,t]),i=o.useMemo(()=>$r(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(Tx,{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?.(jx(n,d))}}),e.jsx(dl,{node:t,projectPaths:i,selectedScope:n,onSelect:c=>r?.(Nx(t.id,c))}),e.jsx(Sx,{node:t})]})}function Sx({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:L("h-1.5 w-1.5 shrink-0 rounded-full",An(t.status))})]})}function dl({node:t,projectPaths:n,selectedScope:s,onSelect:r,compact:a=!1,portal:i=!1,portalAlign:l="start"}){const[c,d]=o.useState(!1),[m,p]=o.useState(null),[u,h]=o.useState(!1),[f,j]=o.useState(!1),[g,w]=o.useState(null),[b,k]=o.useState(!1),[y,x]=o.useState(null),v=o.useRef(null),N=o.useRef(null),A=o.useRef(null),E=o.useMemo(()=>n.map($=>({value:$,label:vo($),description:$})),[n]),M=s.kind==="project"?s.projectPath:void 0,B=s.kind==="global"?"Global":vo(s.projectPath),D=s.kind==="global"?"Global":s.projectPath,_=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(),ee=_(),S=ee&&ee!==document.body?ee.getBoundingClientRect():{left:0,top:0,bottom:window.innerHeight};x(yx({triggerRect:$,targetRect:S,viewportRect:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight},compact:a,browserOpen:b,portalAlign:l,cssZoom:wx()}))},[b,a,_,i,l]);o.useEffect(()=>{c||k(!1)},[c]),o.useEffect(()=>{if(!c)return;const $=ee=>{if(!(ee.target instanceof Node))return;const S=ee.composedPath(),Q=v.current?S.includes(v.current):!1,T=A.current?S.includes(A.current):ee.target instanceof Element&&!!ee.target.closest('[data-capability-scope-menu="true"]');!Q&&!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 O=async($,ee=0,S=!1)=>{if(t.workDir){w(null),S?j(!0):h(!0);try{const Q=await Eo(t.id,{path:$||".",limit:xx,offset:ee,directoriesOnly:!0,allowAbsolute:!0});p(T=>S&&T?{...Q,entries:[...T.entries,...Q.entries]}:Q)}catch(Q){w(Q instanceof Error?Q.message:"Failed to browse folders"),S||p(null)}finally{h(!1),j(!1)}}};o.useEffect(()=>{!c||!b||!t.workDir||(p(null),w(null),O(M||"."))},[b,c,t.id,t.workDir,M]);const W=($,ee=!1)=>{r({kind:"project",projectPath:go(t,$,ee)}),d(!1)},J=()=>{r({kind:"global"}),d(!1)},Y=m?go(t,m.currentPath,m.isAbsolute):M??t.workDir??"",V=i?_():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&&b?y.maxHeight:void 0,maxHeight:y.maxHeight}:void 0,className:L(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:L("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:L("overflow-y-auto pr-0.5",a?"max-h-32":"max-h-40"),children:[e.jsx(bo,{icon:"global",label:"Global",selected:s.kind==="global",onSelect:J,compact:a}),E.length>0?E.map($=>e.jsx(bo,{icon:"folder",label:$.label,description:$.description,selected:M===$.value,onSelect:()=>W($.value,!0),compact:a},$.value)):e.jsx("div",{className:L("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:L("border-b border-border/55",b?"flex min-h-0 flex-1 flex-col":"shrink-0"),children:[e.jsxs("button",{type:"button","aria-expanded":b,onClick:()=>k($=>!$),className:L("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(hn,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Browse folders"}),e.jsx(st,{className:L("h-3 w-3 shrink-0 transition-transform duration-200",b&&"rotate-180")})]}),b&&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 O(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(Wo,{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:()=>W(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:L("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(fe,{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(Cx,{entry:$,onSelect:()=>W($.path,m.isAbsolute),onOpen:()=>{O($.path)}},$.path)),m.hasMore&&e.jsxs("button",{type:"button",onClick:()=>{O(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(fe,{className:"h-3 w-3 animate-spin"}):e.jsx(cu,{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:v,className:"relative min-w-0",children:[e.jsxs("button",{ref:N,type:"button","aria-label":"Capability location","aria-expanded":c,title:D,onClick:()=>d($=>($||(k(!1),P()),!$)),className:L("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:L("block truncate font-medium text-foreground",a?"text-[9px] leading-3":"text-[10px] leading-4"),children:B})}),e.jsx(st,{className:L(a?"h-2.5 w-2.5":"h-3 w-3","shrink-0 text-muted-foreground transition-transform",c&&"rotate-180")})]}),i&&V?ns.createPortal(ne,V):ne]})}function bo({icon:t,label:n,description:s,selected:r,onSelect:a,compact:i=!1}){const l=t==="global"?ou:hn;return e.jsxs("button",{type:"button",onClick:a,className:L(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:L("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:L("block truncate text-muted-foreground",i?"text-[7px] leading-3":"text-[8px] leading-3"),children:s})]})]})}function Cx({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(hn,{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(nt,{className:"h-3 w-3"})})]})}function Tx({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=p=>{d.current&&p.target instanceof Node&&!d.current.contains(p.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(st,{className:L("h-3 w-3 shrink-0 text-muted-foreground transition-transform",l&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!l,className:L("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:L("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:L("h-1.5 w-1.5 shrink-0 rounded-full",An(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 Ax(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 An(t){return t==="online"?"bg-emerald-500":t==="offline"?"bg-muted-foreground/45":"bg-amber-500"}function vo(t){return t.split(/[\\/]+/).filter(Boolean).at(-1)??t}function ul(t){return t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t)}function ml(t,n){return`${t.replace(/[\\/]+$/,"")}/${n.replace(/^[\\/]+/,"")}`}const Ex="h-6 w-24 rounded-sm px-2 text-[10px] shadow-none",Zs="text-[10px]",hl=["claudecode","codex","copilot"],Tn={claudecode:"Claude Code",codex:"Codex",copilot:"Copilot"};function Mx({open:t,sourceNode:n,targetNodes:s,selectedCapabilities:r,previewResults:a=[],embedded:i=!1,onClose:l,onPreviewTargetsChange:c,onShare:d}){const[m,p]=o.useState(()=>new Set(a.length>0?a.map(S=>gt(S.nodeId,S.targetAgent)):_x(n.id,s,r))),[u,h]=o.useState(()=>Object.fromEntries(Px(n.id,s,r))),[f,j]=o.useState({}),[g,w]=o.useState(!1),[b,k]=o.useState(()=>new Set),[y,x]=o.useState(()=>new Set),v=r.some(S=>S.kind==="plugin"),N=o.useMemo(()=>qr(r).map(S=>({key:gt(n.id,S),nodeId:n.id,node:n,label:`Install into ${Tn[S]}`,agentLabel:Tn[S],defaultScope:pl(r),disabled:!1,targetAgent:S})),[r,n]),A=o.useMemo(()=>s.flatMap(S=>{const Q={kind:"global"},T=S.status==="offline",te=fl(r);return te.length===0?[{key:gt(S.id),nodeId:S.id,node:S,label:S.name,defaultScope:Q,disabled:T}]:te.map(R=>({key:gt(S.id,R),nodeId:S.id,node:S,label:`${S.name} / ${Tn[R]}`,agentLabel:Tn[R],defaultScope:Q,disabled:T,targetAgent:R}))}),[r,s]),E=o.useMemo(()=>[...N,...A],[N,A]),M=o.useMemo(()=>s.map(S=>({node:S,options:A.filter(Q=>Q.nodeId===S.id)})).filter(S=>S.options.length>0),[s,A]),B=o.useMemo(()=>new Map(a.filter(S=>S.capabilityId).map(S=>[wo(S.nodeId,S.capabilityId,S.targetAgent),S])),[a]),D=o.useMemo(()=>new Map(a.map(S=>[gt(S.nodeId,S.targetAgent),S])),[a]),_=o.useMemo(()=>E.filter(S=>m.has(S.key)),[m,E]),P=o.useMemo(()=>_.map(S=>({nodeId:S.nodeId,scope:u[S.key]??S.defaultScope,...S.targetAgent?{targetAgent:S.targetAgent}:{}})),[_,u]),O=o.useMemo(()=>{const S=[],Q=new Map;for(const T of _){if(!Q.has(T.nodeId)){const te=T.nodeId===n.id?n:s.find(R=>R.id===T.nodeId);Q.set(T.nodeId,{nodeId:T.nodeId,node:te,name:te?.name??T.nodeId,options:[]}),S.push(T.nodeId)}Q.get(T.nodeId).options.push(T)}return S.map(T=>Q.get(T))},[_,n,s]),W=o.useMemo(()=>{const S=Array.from(new Set(r.map(T=>T.agent))),[Q]=S;if(Q)return S.length===1?Tn[Q]:`${S.length} agents`},[r]),J=M.length+1;o.useEffect(()=>{let S=!1;const Q={...u};for(const T of E)Q[T.key]||(Q[T.key]=T.defaultScope,S=!0);S&&h(Q)},[E,u]),o.useEffect(()=>{t&&c?.(P)},[t,c,P]),o.useEffect(()=>{t&&(k(new Set),x(new Set))},[t,n.id]),o.useEffect(()=>{if(!i||!t)return;const S=Q=>{Q.key==="Escape"&&l()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[i,l,t]);const Y=S=>{j(Object.fromEntries(_.map(Q=>[Q.key,S])))},V=async()=>{w(!0);try{await d(_.map(S=>({nodeId:S.nodeId,scope:u[S.key]??S.defaultScope,...S.targetAgent?{targetAgent:S.targetAgent}:{},conflictStrategy:f[S.key]??"overwrite"})))}finally{w(!1)}},ne=S=>{const Q=u[S.key]??S.defaultScope,T=`capability-share-target-${Dx(S.key)}`,te=m.has(S.key);return e.jsxs("div",{"data-target-agent":S.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":S.disabled?"true":void 0,children:[e.jsx(_n,{id:T,disabled:S.disabled,checked:te,onCheckedChange:R=>p(H=>{const F=new Set(H);return R===!0?F.add(S.key):F.delete(S.key),F}),"aria-label":`Select ${S.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":S.disabled?"true":void 0,children:S.agentLabel??S.label}),e.jsx("div",{className:"flex w-28 shrink-0 justify-end",children:te&&!S.disabled&&e.jsx(dl,{node:S.node,projectPaths:$r(S.node),selectedScope:Q,onSelect:R=>h(H=>({...H,[S.key]:R})),compact:!0,portal:!0,portalAlign:"end"})})]},S.key)},$=(S,Q,T,te)=>{const R=b.has(S.id),H=_.filter(F=>F.nodeId===S.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:()=>k(F=>yo(F,S.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(nt,{className:L("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",R&&"rotate-90")}),e.jsx("span",{className:L("h-1.5 w-1.5 shrink-0 rounded-full",An(S.status))}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold text-foreground",title:S.name,children:S.name}),H>0&&e.jsxs("span",{className:"shrink-0 text-[8px] font-medium text-primary",children:[H," selected"]}),e.jsx("span",{className:"shrink-0 text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:Q?"this node":"remote"}),S.status==="offline"&&e.jsx(Le,{variant:"outline",className:"rounded-sm px-1 py-0 text-[8px]",children:"offline"}),te>0&&e.jsxs("span",{className:"sr-only",children:[te," agents"]})]}),e.jsx("div",{className:L("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})})})]},S.id)},ee=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(Zn,{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:L("h-1.5 w-1.5 shrink-0 rounded-full",An(n.status))}),e.jsx("span",{className:"truncate font-semibold text-foreground",title:n.name,children:n.name}),W&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:["· ",W]})]}),e.jsx(ia,{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:_.length})," selected · ",J," ",J===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,v?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),M.map(S=>$(S.node,!1,S.options.map(ne),S.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(S=>e.jsx("button",{type:"button",onClick:()=>Y(S),className:"h-5 rounded-[3px] px-1.5 text-[9px] capitalize text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground",children:S},S))})]})]}),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:_.length===0?e.jsx("div",{className:"py-8 text-center text-[11px] text-muted-foreground",children:"Select a target to preview conflicts."}):O.map(S=>{const Q=!y.has(S.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":Q,onClick:()=>x(T=>yo(T,S.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(nt,{className:L("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",Q&&"rotate-90")}),S.node&&e.jsx("span",{className:L("h-1.5 w-1.5 shrink-0 rounded-full",An(S.node.status))}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[10px] font-semibold text-foreground",children:S.name}),e.jsxs("span",{className:"shrink-0 text-[8px] text-muted-foreground",children:[S.options.length," ",S.options.length===1?"agent":"agents"]})]}),e.jsx("div",{className:L("grid transition-[grid-template-rows] duration-200 ease-out",Q?"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:S.options.map(T=>{const te=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($e,{value:te,onValueChange:R=>j(H=>({...H,[T.key]:R})),children:[e.jsx(qe,{className:Ex,children:e.jsx(Je,{})}),e.jsxs(Ve,{className:"shadow-none",children:[e.jsx(Oe,{value:"overwrite",className:Zs,children:"Overwrite"}),e.jsx(Oe,{value:"skip",className:Zs,children:"Skip"}),e.jsx(Oe,{value:"abort",className:Zs,children:"Abort"})]})]})]}),e.jsx("div",{className:"space-y-px",children:r.map(R=>{const H=B.get(wo(T.nodeId,R.id,T.targetAgent))??(r.length===1?D.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:H?.conflict?"text-amber-500":H?"text-emerald-500":"text-muted-foreground",children:H?H.conflict?`exists${H.currentVersion?` v${H.currentVersion}`:""}`:"new install":"checking"}),H?.sourceVersion&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:[e.jsx(ia,{className:"inline h-2.5 w-2.5"})," v",H.sourceVersion]})]},R.id)})})]},T.key)})})})})]},S.nodeId)})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-border/55 px-4 py-3",children:[e.jsx(X,{variant:"ghost",onClick:l,className:"h-7 rounded-sm px-3 text-[11px]",children:"Cancel"}),e.jsxs(X,{onClick:V,disabled:g||_.length===0,className:"h-7 rounded-sm px-3 text-[11px]",children:[g?e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Zn,{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:S=>{S.target===S.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:S=>S.stopPropagation(),children:[ee,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(ut,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})}):null:e.jsx(mt,{open:t,onOpenChange:S=>{S||l()},children:e.jsx(ht,{"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:ee})})}function gt(t,n){return n?`agent:${t}:${n}`:`node:${t}`}function Dx(t){return t.replace(/[^a-zA-Z0-9_-]/g,"-")}function wo(t,n,s){return`${gt(t,s)}\0${n}`}function yo(t,n){const s=new Set(t);return s.has(n)?s.delete(n):s.add(n),s}function _x(t,n,s){const r=n.find(i=>i.status!=="offline");if(r)return[gt(r.id,Ix(s))];const a=qr(s)[0];return a?[gt(t,a)]:[]}function Px(t,n,s){const r=fl(s);return[...n.flatMap(a=>r.length===0?[[gt(a.id),{kind:"global"}]]:r.map(i=>[gt(a.id,i),{kind:"global"}])),...qr(s).map(a=>[gt(t,a),pl(s)])]}function fl(t){return t.length===0||t.some(n=>n.kind==="plugin")?[]:hl}function Ix(t){if(!(t.length===0||t.some(n=>n.kind==="plugin")))return t[0]?.agent}function qr(t){if(t.length===0||t.some(s=>s.kind==="plugin"))return[];const n=new Set(t.map(s=>s.agent));return hl.filter(s=>!n.has(s))}function pl(t){return t[0]?.scope??{kind:"global"}}const jo="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",Bt="py-0.5 pl-6 pr-1.5 text-[9px] leading-4 [&_svg]:h-3 [&_svg]:w-3",xl="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",Rx="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 Lx(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 Bx(t,n,s,r){return s.map(a=>({sourceNodeId:t,capabilityId:a.id,sourceScope:n,targets:r}))}function Ox({loading:t,onRefresh:n}){return e.jsxs(X,{variant:"ghost",onClick:n,disabled:t,"aria-busy":t,className:L(xl,"min-w-[4.5rem]"),children:[e.jsx(ni,{className:L("h-2.5 w-2.5",t&&"animate-spin")}),t?"Refreshing":"Refresh"]})}function Fx({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(X,{type:"button",variant:"ghost",onClick:s,disabled:t===0,className:xl,children:[e.jsx(ut,{className:"h-2.5 w-2.5"}),"Selected: ",t," / Clear"]})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ox,{loading:n,onRefresh:r}),e.jsxs(X,{type:"button",variant:"ghost",onClick:a,disabled:t===0,className:Rx,children:[e.jsx(Zn,{className:"h-2.5 w-2.5"}),"Share"]})]})]})}function zx({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 Ux({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(fe,{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 $x({open:t,node:n,scope:s,clusterNodes:r,onOpenChange:a,onSelectionChange:i}){const[l,c]=o.useState([]),[d,m]=o.useState([]),[p,u]=o.useState(!1),[h,f]=o.useState(""),[j,g]=o.useState("all"),[w,b]=o.useState("all"),[k,y]=o.useState(new Set),[x,v]=o.useState(null),[N,A]=o.useState(null),[E,M]=o.useState(!1),[B,D]=o.useState(null),[_,P]=o.useState(!1),[O,W]=o.useState([]),[J,Y]=o.useState(cl),[V,ne]=o.useState(null),$=o.useMemo(()=>lx(l,{search:h,agent:j,kind:w}),[j,l,w,h]),ee=o.useMemo(()=>l.filter(K=>k.has(K.id)),[l,k]),S=o.useMemo(()=>r.filter(K=>K.id!==n.id),[r,n.id]),Q=s.kind==="project"?s.projectPath:"global",T=async()=>{u(!0);try{const K=await td(n.id,{scope:s});c(K.items),m((K.errors??[]).map(I=>`${I.agent}: ${I.message}`))}catch(K){m([K instanceof Error?K.message:"Failed to load capabilities"])}finally{u(!1)}};o.useEffect(()=>{t&&(y(new Set),v(null),A(null),M(!1),W([]),c([]),m([]),T())},[t,n.id,s.kind,Q]),o.useEffect(()=>{if(!V)return;const K=se=>{Y(mx(V.startWidth,V.startClientX,se.clientX,window.innerWidth))},I=()=>ne(null);return window.addEventListener("pointermove",K),window.addEventListener("pointerup",I),()=>{window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",I)}},[V]);const te=K=>{K.preventDefault(),ne({startClientX:K.clientX,startWidth:J})},R=()=>{ne(null),M(!1),v(null),A(null)},H=()=>{y(new Set),W([])},F=async K=>{v(K.id),M(!0),A(null);const I=await nd(n.id,K.id,s);A(I.detail)},le=o.useCallback(async K=>{if(ee.length===0||K.length===0){W([]);return}W([]);try{const I=Lx(n.id,s,ee,K),se=await Promise.all(I.map(q=>ed(q)));W(se.flatMap((q,ae)=>q.results.map(ye=>({...ye,capabilityId:I[ae]?.capabilityId}))))}catch{W([])}},[n.id,s,ee]),ie=()=>{W([]),P(!0)},me=async K=>{const I=Bx(n.id,s,ee,K);I.length!==0&&(await Promise.all(I.map(se=>rd(se))),ce.success(`${I.length} capability share request${I.length===1?"":"s"} completed`),P(!1))},Z=async()=>{if(!(!N||B)){D(N.id);try{const K=await sd(n.id,N.id,s);K.status==="deleted"?(ce.success(`Deleted ${N.name}`),c(I=>I.filter(se=>se.id!==N.id)),y(I=>{const se=new Set(I);return se.delete(N.id),se}),v(null),A(null),M(!1),await T()):(ce.info(K.message??"Capability was not found"),v(null),A(null),M(!1),await T())}catch(K){ce.error(K instanceof Error?K.message:"Failed to delete capability")}finally{D(null)}}};return e.jsx(e.Fragment,{children:e.jsx(mt,{open:t,onOpenChange:a,children:e.jsxs(ht,{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(Mt,{className:"border-b border-border/55 bg-card/28 px-4 py-2.5 text-left",children:[e.jsx(vt,{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(kx,{node:n,scope:s,clusterNodes:r,onSelectionChange:i}),e.jsxs(Dt,{"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(Mo,{className:"pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-muted-foreground"}),e.jsx(dt,{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($e,{value:j,onValueChange:K=>g(K),children:[e.jsx(qe,{className:L("w-28",jo),children:e.jsx(Je,{})}),e.jsxs(Ve,{className:"shadow-none",children:[e.jsx(Oe,{value:"all",className:Bt,children:"Agent: All"}),e.jsx(Oe,{value:"claudecode",className:Bt,children:"Claude Code"}),e.jsx(Oe,{value:"codex",className:Bt,children:"Codex"}),e.jsx(Oe,{value:"copilot",className:Bt,children:"Copilot"})]})]}),e.jsxs($e,{value:w,onValueChange:K=>b(K),children:[e.jsx(qe,{className:L("w-24",jo),children:e.jsx(Je,{})}),e.jsxs(Ve,{className:"shadow-none",children:[e.jsx(Oe,{value:"all",className:Bt,children:"Kind: All"}),e.jsx(Oe,{value:"skill",className:Bt,children:"Skill"}),e.jsx(Oe,{value:"plugin",className:Bt,children:"Plugin"}),e.jsx(Oe,{value:"mcp",className:Bt,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(cx,{items:$,selectedIds:k,activeId:x,onToggleSelected:(K,I)=>y(se=>{const q=new Set(se);return I?q.add(K):q.delete(K),q}),onOpenDetail:F}),e.jsx(Fx,{selectedCount:k.size,loading:p,onClearSelection:H,onRefresh:T,onShare:ie}),e.jsx(Ux,{visible:p&&l.length===0})]}),E&&e.jsxs(e.Fragment,{children:[e.jsx(zx,{onBeginResize:te,onFold:R}),e.jsx(hx,{detail:N,deleting:B===N?.id,desktopWidth:J,onDelete:N?Z:void 0,pending:!N})]})]}),_&&e.jsx(Mx,{open:_,sourceNode:n,targetNodes:S,selectedCapabilities:ee,previewResults:O,embedded:!0,onClose:()=>P(!1),onPreviewTargetsChange:le,onShare:me})]})})})}function qx(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($x,{open:!0,node:r,scope:n.scope,clusterNodes:t.nodes,onOpenChange:d=>{d||s(null)},onSelectionChange:l}):null,openNodeCapabilities:a,openProjectCapabilities:i}}function Vx({activeTaskId:t,fetchTasks:n,navigateToNextVisibleTask:s,removeTasksFromList:r,setTask:a,setTasks:i}){const l=o.useCallback(u=>{i(h=>Mr(h,u)),a(h=>h?.id===u.id?{...h,...u}:h)},[a,i]),c=o.useCallback(async(u,h)=>{try{const f=await na(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 na(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 ad(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]),p=o.useCallback(async u=>{try{await od(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:p,handleToggleTaskPinned:d,handleUpdateTaskTitle:c}}function Hx(){const{id:t}=id(),n=ld(),s=cd(),r=dd(),{cluster:a,systemInfo:i,events:l,sseConnected:c,subscribe:d,refresh:m,loading:p,error:u}=ud(),h=o.useMemo(()=>md(n.state),[n.state]),[f,j]=o.useState(null),[g,w]=o.useState("active"),[b,k]=o.useState("all"),[y,x]=o.useState("all"),[v,N]=o.useState("all"),A=r?.headerSearchQuery??"",E=o.useDeferredValue(A),{desktopTasksOpen:M,mobileTasksPanelOpen:B,mobileTasksPanelRef:D,operationsOpen:_,operationsPanelRef:P,panelResize:O,setMobileTasksPanelOpen:W,setOperationsOpen:J,toggleTasksPanel:Y}=Sp(),[V,ne]=o.useState(()=>!!h?.draftNewTask),[$,ee]=o.useState(()=>h?.createMode??"chat"),[S,Q]=o.useState(()=>h?.createDefaults??null),[T,te]=o.useState(()=>h?.draftNewTask?{route:h.returnRoute??"/",taskId:h.returnTaskId??null}:null),[R,H]=o.useState(!1),[F,le]=o.useState("transcript"),[ie,me]=o.useState("overview"),[Z,K]=o.useState("all"),[I,se]=o.useState(!1),[q,ae]=o.useState(null),[ye,pe]=o.useState([]),[Ze,Ae]=o.useState([]),[ft,Re]=o.useState(!1),[De,He]=o.useState(!1),[Ke,je]=o.useState(null),[Be,G]=o.useState(new Set),[ge,be]=o.useState(!1),[et,_e]=o.useState(!1),[rt,re]=o.useState(null),Ne=o.useRef(null),Te=o.useRef(new Map),ve=a?.self?.role==="leader",at=a?.self?.id,{quickChats:Pe}=hd();zp({cluster:a,subscribe:d});const{nodeSettingsDialog:_t,openNodeSettings:pt}=rx(ve),{capabilitiesDialog:pn,openNodeCapabilities:en,openProjectCapabilities:St}=qx(a),{devBoxDialog:wt,devBoxNodeIds:xn,devBoxStartNodeId:gn,devBoxStartNodeIds:Pt,devBoxStartingNodeIds:Ft,openDevBox:tn,startDevBox:Ct}=sx({cluster:a,refresh:m}),{completedGroups:nn=[],fetchTasks:Fe,loadCompletedTasksPage:ot,removeTasksFromList:yt,setTasks:Tt,tasks:U,tasksError:ze,tasksLoading:Ie}=Lp({isLeader:ve,selfId:at,sseConnected:c,preservedTask:q,subscribe:d});o.useEffect(()=>fd(()=>{me("events"),J(!0)}),[J]);const We=o.useMemo(()=>[...U].sort((C,z)=>z.updatedAt-C.updatedAt),[U]),Qe=o.useMemo(()=>[...U].sort((C,z)=>z.createdAt-C.createdAt||z.updatedAt-C.updatedAt)[0]?.id??null,[U]),sn=o.useMemo(()=>{const C=new Map;for(const z of a?.nodes??[]){const oe=Ju(We,z.id);oe>0&&C.set(z.id,oe)}return C},[a?.nodes,We]),xe=o.useMemo(()=>We.filter(C=>!pd(C,a?.nodes,a?.self)||!xd(C,g)||b!=="all"&&C.agent!==b||!gd(C,v)||y==="unassigned"&&C.assignedTo||y!=="all"&&y!=="unassigned"&&bd(C.assignedTo,a?.nodes,C.assignedNodeName)!==y?!1:E.trim()?vd(C,E):!0),[We,a?.nodes,a?.self,g,b,v,y,E]);o.useEffect(()=>{G(C=>{const z=sm(C,xe.map(oe=>oe.id));return z.size===C.size?C:z})},[xe]),o.useEffect(()=>{ve||G(new Set)},[ve]);const he=o.useMemo(()=>["all",...Array.from(new Set(We.map(C=>C.agent))).sort()],[We]),ke=o.useMemo(()=>{const z=Array.from(new Set(We.map(oe=>oe.assignedTo).filter(oe=>!!oe))).map(oe=>{const Me=We.find(we=>we.assignedTo===oe);return a?.nodes.find(we=>we.id===oe)??{id:oe,name:er(oe,a?.nodes,Me?.assignedNodeName)}}).sort((oe,Me)=>oe.name.localeCompare(Me.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...z.map(oe=>({value:oe.name.toLowerCase(),label:oe.name}))]},[We,a?.nodes]),Ge=o.useMemo(()=>{const C=new Map;for(const z of a?.nodes??[])C.set(z.id,z.name);for(const z of We)z.assignedTo&&z.assignedNodeName&&!C.has(z.assignedTo)&&C.set(z.assignedTo,z.assignedNodeName);return C},[a?.nodes,We]),Ue=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]),zt=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]),ls=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]),bn=o.useMemo(()=>new Map(nn.map(C=>[xr(C),C])),[nn]),Ee=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]),rn=a?.self?.id??Ee[0]?.id??null,It=o.useMemo(()=>l.filter(wd),[l]),vn=o.useMemo(()=>["all",...Array.from(new Set(It.map(C=>C.type))).sort()],[It]),cs=o.useMemo(()=>Z==="all"?It:It.filter(C=>C.type===Z),[It,Z]),ds=xe.length>0&&xe.every(C=>Be.has(C.id)),it=xe.some(C=>Be.has(C.id)),gl=rm(xe,Be);o.useEffect(()=>{h?.draftNewTask&&(ne(!0),ee(h.createMode??"chat"),Q(h.createDefaults??null),te({route:h.returnRoute??"/",taskId:h.returnTaskId??null}))},[h]),o.useEffect(()=>{Z!=="all"&&!vn.includes(Z)&&K("all")},[Z,vn]),o.useEffect(()=>{ca(t,V)&&!f&&Qe&&j(Qe)},[t,V,f,Qe]),o.useEffect(()=>{ca(t,V)&&(f&&U.some(C=>C.id===f)||j(Qe))},[t,V,f,Qe,U]);const Se=Xu({routeTaskId:t,creatingTask:V,internalSelectedTaskId:f,sortedTaskIds:Qe?[Qe]:[]}),an=o.useMemo(()=>U.find(C=>C.id===Se)??null,[U,Se]);o.useEffect(()=>{Ne.current=Se??null},[Se]);const Rt=o.useCallback(()=>{ae(null),pe([]),Ae([]),je(null),He(!1)},[]),wn=o.useCallback((C,z,oe=!0)=>{Te.current.set(C,{logs:zr(z),loaded:oe})},[]),xt=o.useCallback(async()=>{const C=Se;if(C)try{const z=await yd(C);if(Ne.current!==C)return;ae(z),Tt(oe=>Mr(oe,z)),je(null)}catch(z){if(Ne.current!==C)return;Rt(),je(z instanceof Error?z.message:"Failed to load task")}finally{Ne.current===C&&Re(!1)}},[Se,Rt,Tt]),us=o.useCallback(async(C={})=>{const z=Se;if(z)try{const oe=await sr(z,C.after,{minTotal:C.minTotal});if(Ne.current!==z)return;pe(Me=>{const we=Ko(Me,oe.logs);return wn(z,we),we}),Ae(Me=>ar(Me,oe.logs))}catch{}finally{Ne.current===z&&He(!1)}},[Se,wn]);o.useEffect(()=>{if(!Se){Rt(),Re(!1);return}le("transcript"),ae(an);const C=Bp(Se,Te.current);pe(C.logs),Ae([]),je(null),Re(!0),He(C.transcriptLoading),xt(),us()},[Se,Rt,us,xt]),o.useEffect(()=>{if(!em({activeTaskId:Se,routeTaskId:t,creatingTask:V,tasksLoading:Ie,loadedTaskIds:U.map(z=>z.id)}))return;const C=Qe;j(C),Rt(),o.startTransition(()=>{s(C?`/tasks/${C}`:"/",{state:null})})},[Se,Rt,V,Qe,s,t,U,Ie]),o.useEffect(()=>{an&&ae(C=>!C||C.id!==an.id?C:{...C,...an})},[an]),$p({activeTaskId:Se,cacheTranscript:wn,fetchActiveLogs:us,fetchActiveTask:xt,logs:ye,setLogs:pe,setPendingMessages:Ae,setTranscriptLoading:He,sseConnected:c,subscribe:d});const de=q??an,bl=de?.assignedTo?a?.nodes.find(C=>C.id===de.assignedTo)??null:null,yn=r?.setHeaderTaskContext;o.useEffect(()=>{if(!yn)return;if(!de){yn(null);return}const C=de.effectiveProjectPath??de.project??"default workspace";return yn({taskId:de.id,taskTitle:de.title,nodeName:er(de.assignedTo,a?.nodes,de.assignedNodeName),projectLabel:Bo(C),projectPath:C}),()=>yn(null)},[de,a?.nodes,yn]);const ms=Ze.length>0,vl=de?jd.has(de.agent):!1,On=de?.status==="running",wl=de?Qn.has(de.status):!1,yl=de?Qn.has(de.status)||Nd.has(de.status):!1,jl=!!(de&&ve&&de.status==="failed"),hs=o.useMemo(()=>Qf(de,a,ms,!!On),[de,a,ms,On]),fs=o.useMemo(()=>$d([...ye,...Ze.map(C=>ws(C.content,C.timestamp))]),[ye,Ze]),Fn=o.useMemo(()=>{if(!de||de.conversationKind==="nativeSession")return null;const C=qd(de);if(C.length>0)return ws(C,new Date(de.createdAt).toISOString());if(fs.length>0)return null;const z=Vd(de.description||de.title);return z.length>0?ws(z,new Date(de.createdAt).toISOString()):null},[de,fs]),ps=o.useMemo(()=>Fn?Cr(Fn):null,[Fn]),Nl=o.useMemo(()=>ps?Hd(ye,ps):!1,[ye,ps]),xs=o.useCallback((C="chat",z)=>{const oe={route:t?`/tasks/${t}`:"/",taskId:Se};te(oe),ee(C),Q(z??null),ne(!0),o.startTransition(()=>{s("/",{state:{draftNewTask:!0,returnRoute:oe.route,returnTaskId:oe.taskId,createMode:C,createDefaults:z}})})},[t,Se,s]),kl=o.useCallback(()=>{const C=T?.taskId??Qe;ne(!1),te(null),Q(null),j(C),o.startTransition(()=>{s(T?.route??"/",{state:null})})},[T,Qe,s]),Vr=o.useCallback(C=>{ne(!1),te(null),Q(null),j(C),o.startTransition(()=>{s(`/tasks/${C}`,{state:null})})},[s]),Sl=o.useCallback(C=>{Ne.current=C.id,ne(!1),te(null),Q(null),Tt(z=>tm(z,C)),ae(C),pe([]),Ae([]),je(null),Re(!1),He(C.conversationKind==="nativeSession"),le("transcript"),j(C.id),Vp({task:C,getActiveTaskId:()=>Ne.current,setLogs:pe,setPendingMessages:Ae,setTranscriptLoading:He}),Fe(),o.startTransition(()=>{s(`/tasks/${C.id}`,{state:null})})},[Fe,s]),{cancelQueuedMessage:Cl,queueFollowUpMessage:zn}=ox({activeTaskId:Se,fetchActiveTask:xt,isRunning:On,setPendingMessages:Ae,setTask:ae,setTasks:Tt}),Tl=o.useCallback((C,z)=>{zn(C,z)},[zn]),Al=o.useCallback(async()=>{const C=Se;if(!(!C||de?.conversationKind!=="nativeSession")){He(!0);try{const z=await sr(C);if(Ne.current!==C)return;pe(z.logs),wn(C,z.logs),Ae(oe=>ar(oe,z.logs))}catch(z){ce.error(z instanceof Error?z.message:"Failed to reload transcript")}finally{Ne.current===C&&He(!1)}}},[de?.conversationKind,Se,wn]),El=o.useCallback(C=>zn(C),[zn]),Ml=o.useCallback(async()=>{if(de)try{await kd(de.id),xt(),Fe()}catch(C){ce.error(C instanceof Error?C.message:"Failed to cancel task")}},[de,xt,Fe]),{handleShareTask:Dl,handleStopShareTask:_l}=yp(de,xt,Fe),Pl=o.useCallback(async()=>{if(de)try{await Sd(de.id),xt(),Fe()}catch(C){ce.error(C instanceof Error?C.message:"Failed to retry task")}},[de,xt,Fe]),jn=o.useCallback((C,z=!1)=>{const oe=am(xe,C);return j(oe),(z||!oe)&&Rt(),o.startTransition(()=>{s(oe?`/tasks/${oe}`:"/",{state:null})}),oe},[Rt,xe,s]),{handleArchiveTask:Il,handleDeleteTask:Rl,handleToggleTaskPinned:Ll,handleUpdateTaskTitle:Bl}=Vx({activeTaskId:Se,fetchTasks:Fe,navigateToNextVisibleTask:jn,removeTasksFromList:yt,setTask:ae,setTasks:Tt}),Ol=o.useCallback((C,z)=>{G(oe=>{const Me=new Set(oe);return z?Me.add(C):Me.delete(C),Me})},[]),Fl=o.useCallback(C=>{if(!C){G(new Set);return}G(new Set(xe.map(z=>z.id)))},[xe]),zl=o.useCallback(async()=>{const C=Array.from(Be);if(C.length!==0)try{const{results:z}=await Cd(C),oe=z.filter(we=>!we.ok),Me=z.filter(we=>we.ok).map(we=>we.id);Se&&Me.includes(Se)&&jn(Me),oe.length>0?ce.error(`Failed to archive ${oe.length} task(s): ${oe.map(we=>we.error??we.id).join(", ")}`):ce.success(`Archived ${Me.length} task(s)`),G(new Set(oe.map(we=>we.id))),Fe()}catch(z){ce.error(z instanceof Error?z.message:"Failed to archive tasks")}},[Se,Fe,jn,Be]),Ul=o.useCallback(async()=>{const C=Array.from(Be);if(C.length!==0)try{const{results:z}=await Td(C),oe=z.filter(we=>!we.ok),Me=z.filter(we=>we.ok).map(we=>we.id);Me.length>0&&yt(Me),Se&&Me.includes(Se)&&jn(Me,!0),oe.length>0?ce.error(`Failed to delete ${oe.length} task(s): ${oe.map(we=>we.error??we.id).join(", ")}`):ce.success(`Deleted ${Me.length} task(s)`),G(new Set(oe.map(we=>we.id))),Fe()}catch(z){ce.error(z instanceof Error?z.message:"Failed to delete tasks")}},[Se,Fe,jn,yt,Be]),$l=o.useCallback(async()=>{be(!0);try{await Ad(),m()}catch(C){ce.error(C instanceof Error?C.message:"Failed to promote node")}finally{be(!1)}},[m]),ql=o.useCallback(async()=>{_e(!0);try{await Ed(),ce.success("This node left the remote cluster and is leading itself again."),Fe(),xt(),m()}catch(C){ce.error(C instanceof Error?C.message:"Failed to leave cluster")}finally{_e(!1)}},[xt,Fe,m]),Vl=o.useCallback(async C=>{const z=!Er(C),oe=C.id===a?.self?.id,Me=oe?i?.transportType??C.transportType:C.transportType,we=oe&&!z&&fn(Me);re(C.id);try{we?await Md("direct"):await Dd(C.id,z),ce.success(z?`Enabled remote access on ${C.name}`:`Disabled remote access on ${C.name}`),m()}catch(Kr){ce.error(Kr instanceof Error?Kr.message:"Failed to update remote access")}finally{re(null)}},[a?.self?.id,m,i?.transportType]),Hl=o.useCallback(C=>{ot&&ot(C).catch(z=>{ce.error(z instanceof Error?z.message:"Failed to load completed tasks")})},[ot]),Hr={toolbarTasks:xe,activeTaskId:Se,tasksLoading:Ie,tasksError:ze,isLeader:ve,scope:g,agentFilter:b,nodeFilter:y,taskKindFilter:v,agentOptions:he,nodeOptions:ke,nodeNameById:Ge,nodeWorkDirById:Ue,nodeStatusById:zt,nodeInfoById:ls,leaderNodeId:a?.leader?.id??null,searchQuery:A,completedGroupByKey:bn,devBoxNodeIds:xn,devBoxStartNodeIds:Pt,devBoxStartingNodeIds:Ft,selectedTaskIds:Be,allVisibleTasksSelected:ds,someVisibleTasksSelected:it,canBatchArchive:gl,onScopeChange:w,onAgentFilterChange:k,onNodeFilterChange:x,onTaskKindFilterChange:N,onToggleTaskSelected:Ol,onToggleAllVisibleTasks:Fl,onUpdateTaskTitle:Bl,onDeleteTask:Rl,onArchiveTask:Il,onToggleTaskPinned:Ll,onBatchArchive:zl,onBatchDelete:Ul,onCreateTask:xs,onOpenNodeSettings:ve?pt:void 0,onOpenNodeCapabilities:ve?en:void 0,onOpenProjectCapabilities:ve?St:void 0,onOpenDevBox:ve?tn:void 0,onStartDevBox:ve?Ct:void 0,onLoadCompletedTasks:Hl,onSelectTask:Vr},Kl={cluster:a,systemInfo:i,nodeNameById:Ge,nodeBlockingTaskCounts:sn,eventTypeFilter:Z,onEventTypeFilterChange:K,activeTab:ie,onTabChange:me,eventTypeOptions:vn,filteredEvents:cs,sseConnected:c,clusterLoading:p,clusterError:u,promotePending:ge,onPromote:$l,onAddNode:()=>H(!0),leavePending:et,onLeaveCluster:ql,onToggleNodeDevTunnel:Vl,devTunnelNodeId:rt,devBoxStartNodeId:gn,devBoxStartingNodeIds:Ft,onOpenNodeSettings:ve?pt:void 0,onOpenNodeCapabilities:ve?en:void 0,onOpenDevBox:ve?tn:void 0,onStartDevBox:ve?Ct:void 0};return e.jsxs(e.Fragment,{children:[e.jsx(Zh,{desktopTasksOpen:M,mobileTasksPanelOpen:B,mobileTasksPanelRef:D,operationsOpen:_,operationsPanelRef:P,panelResize:O,taskSidebar:e.jsx(oo,{...Hr}),operationsSidecar:e.jsx(Gf,{...Kl}),terminalPanel:r?.terminalOpen?e.jsx(of,{nodes:Ee,defaultNodeId:rn,onClose:()=>r?.setTerminalOpen(!1)}):void 0,conversationPanel:e.jsx(qh,{onToggleTasks:Y,desktopTasksOpen:M,mobileTasksPanelOpen:B,operationsOpen:_,onToggleOperations:()=>J(C=>!C),cluster:a,sseConnected:c,activeTab:F,setActiveTab:le,creatingTask:V,createMode:$,createDefaults:S,activeTask:de,assignedNode:bl,taskLoading:ft,transcriptLoading:De,taskError:Ke,displayEvents:fs,initialPromptAlreadyInLogs:Nl,initialPrompt:Fn,supportsFollowUp:vl,taskUnavailable:hs.taskUnavailable,chatDisabled:hs.chatDisabled,chatDisabledReason:hs.chatDisabledReason,questionBypassEnabled:I,isRunning:!!On,isStarting:wl,hasPendingFollowUp:ms,canCancel:!!yl,canRetry:!!jl,onRetry:Pl,onCancel:Ml,onReloadNativeTranscript:Al,onShareTask:Dl,onStopShareTask:_l,onStartCreateTask:xs,onCancelCreateTask:kl,onCreateTask:Sl,onSendMessage:Tl,onCancelQueuedMessage:Cl,onQuestionBypassChange:se,onSubmitQuestionResponse:El,quickChats:Pe}),mobileTaskSidebar:e.jsx(oo,{...Hr,onCreateTask:(C,z)=>{W(!1),xs(C,z)},onSelectTask:C=>{W(!1),Vr(C)}}),onCloseOperations:()=>J(!1),onCloseTaskList:()=>W(!1),onToggleOperations:()=>J(C=>!C),onToggleTasks:Y}),e.jsx(Gh,{open:R,onOpenChange:H,onAdded:m}),_t,wt,pn]})}const Yx=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:Hx},Symbol.toStringTag,{value:"Module"}));export{Wo as A,Yx as D,Yn as G};
195
+ `);const _=y(A,E,B),P=t.getSymbolSize(A),O=new r(P);return f(O,A),j(O),g(O,A),b(O,E,0),A>=7&&w(O,A),k(O,_),isNaN(M)&&(M=l.getBestMask(O,b.bind(null,O,E))),l.applyMask(M,O),b(O,E,M),{modules:O,version:A,errorCorrectionLevel:E,maskPattern:M,segments:B}}return Es.create=function(A,E){if(typeof A>"u"||A==="")throw new Error("No input text");let M=n.M,B,D;return typeof E<"u"&&(M=n.from(E.errorCorrectionLevel,n.M),B=m.from(E.version),D=l.from(E.maskPattern),E.toSJISFunc&&t.setToSJISFunction(E.toSJISFunc)),v(A,B,M,D)},Es}var Ws={},Qs={},Ga;function Qi(){return Ga||(Ga=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),p=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 j=(h*m+f)*4,g=i.color.light;if(h>=p&&f>=p&&h<m-p&&f<m-p){const w=Math.floor((h-p)/d),b=Math.floor((f-p)/d);g=u[c[w*l+b]?1:0]}r[j++]=g.r,r[j++]=g.g,r[j++]=g.b,r[j]=g.a}}})(Qs)),Qs}var Wa;function Sf(){return Wa||(Wa=1,(function(t){const n=Qi();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 p=n.getImageWidth(i.modules.size,d),u=m.getContext("2d"),h=u.createImageData(p,p);return n.qrToImageData(h.data,i,d),s(u,m,p),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),p=d.type||"image/png",u=d.rendererOpts||{};return m.toDataURL(p,u.quality)}})(Ws)),Ws}var Ys={},Qa;function Cf(){if(Qa)return Ys;Qa=1;const t=Qi();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,p=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]?(p++,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",p),p=0)):d++}return c}return Ys.render=function(i,l,c){const d=t.getOptions(l),m=i.modules.size,p=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(p,m,d.margin)+'"/>',j='viewBox="0 0 '+u+" "+u+'"',w='<svg xmlns="http://www.w3.org/2000/svg" '+(d.width?'width="'+d.width+'" height="'+d.width+'" ':"")+j+' shape-rendering="crispEdges">'+h+f+`</svg>
196
+ `;return typeof c=="function"&&c(null,w),w},Ys}var Ya;function Tf(){if(Ya)return ln;Ya=1;const t=of(),n=kf(),s=Sf(),r=Cf();function a(i,l,c,d,m){const p=[].slice.call(arguments,1),u=p.length,h=typeof p[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,j){try{const g=n.create(c,d);f(i(g,l,d))}catch(g){j(g)}})}try{const f=n.create(c,d);m(null,i(f,l,d))}catch(f){m(f)}}return ln.create=n.create,ln.toCanvas=a.bind(null,s.render),ln.toDataURL=a.bind(null,s.renderToDataURL),ln.toString=a.bind(null,function(i,l,c){return r.render(i,c)}),ln}var Af=Tf();function Yi(t){return Af.toDataURL(t,{errorCorrectionLevel:"M",margin:2,scale:8,color:{dark:"#111827ff",light:"#ffffffff"}})}function Ef({title:t,description:n,triggerLabel:s,qrValue:r,displayValue:a,hint:i,imageAlt:l,copyLabel:c,copiedMessage:d}){const[m,p]=o.useState(!1),[u,h]=o.useState(null),[f,j]=o.useState(null);return o.useEffect(()=>{if(!m)return;let g=!1;return h(null),j(null),Yi(r).then(w=>{g||h(w)}).catch(()=>{g||j("QR code unavailable")}),()=>{g=!0}},[m,r]),e.jsxs(mt,{open:m,onOpenChange:p,children:[e.jsx(Ro,{asChild:!0,children:e.jsx(X,{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(ei,{className:"h-3 w-3"})})}),e.jsxs(ht,{className:"max-w-[20rem] gap-2 p-3",children:[e.jsxs(Mt,{className:"space-y-1 text-left",children:[e.jsx(vt,{className:"text-[12px]",children:t}),e.jsx(Dt,{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(X,{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:()=>{In(a,d)},children:c})]})]})]})}function Mf(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 Df(t,n){return t?t.invitation.status==="active"&&Date.parse(t.invitation.expiresAt)<=n?"expired":t.invitation.status:"loading"}function _f(t){switch(t){case"active":return{label:"Active",tone:"bg-emerald-500/10 text-emerald-500",icon:la};case"consumed":return{label:"Paired",tone:"bg-emerald-500/10 text-emerald-500",icon:tr};case"expired":return{label:"Expired",tone:"bg-amber-500/10 text-amber-500",icon:ys};case"cancelled":return{label:"Cancelled",tone:"bg-destructive/10 text-destructive",icon:ys};case"error":return{label:"Unavailable",tone:"bg-destructive/10 text-destructive",icon:ys};default:return{label:"Loading",tone:"bg-muted text-muted-foreground",icon:la}}}function Pf({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),[p,u]=o.useState(!1),[h,f]=o.useState(()=>Date.now()),j=`Show ${t} mobile pairing QR code`,g=o.useMemo(()=>a?vc(a.qr):null,[a]),w=d?"error":Df(a,h),b=_f(w),k=b.icon,y=o.useCallback(async()=>{u(!0),m(null),c(null);try{const x=await wc();i(x),f(Date.now())}catch(x){i(null),m(x instanceof Error?x.message:"Mobile pairing QR unavailable")}finally{u(!1)}},[]);return o.useEffect(()=>{s&&y()},[s,y]),o.useEffect(()=>{if(!s)return;const x=window.setInterval(()=>f(Date.now()),1e3);return()=>window.clearInterval(x)},[s]),o.useEffect(()=>{if(!s||!a||w!=="active")return;let x=!1;const v=window.setInterval(()=>{yc(a.invitation.pairingId).then(N=>{x||i(A=>A&&{...A,invitation:N.invitation})}).catch(()=>{x||m("Pairing status unavailable")})},2e3);return()=>{x=!0,window.clearInterval(v)}},[s,a?.invitation.pairingId,w]),o.useEffect(()=>{if(!s||!g)return;let x=!1;return c(null),Yi(g).then(v=>{x||c(v)}).catch(()=>{x||m("QR code unavailable")}),()=>{x=!0}},[s,g]),e.jsxs(mt,{open:s,onOpenChange:r,children:[e.jsx(Ro,{asChild:!0,children:e.jsx(X,{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":j,title:j,children:e.jsx(ei,{className:"h-3 w-3"})})}),e.jsxs(ht,{className:"max-w-[20rem] gap-2 p-3",children:[e.jsxs(Mt,{className:"space-y-1 text-left",children:[e.jsx(vt,{className:"text-[12px]",children:"Mobile pairing QR"}),e.jsx(Dt,{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&&w!=="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:[b.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 - ${Mf(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 ${b.tone}`,children:[e.jsx(k,{className:"h-3 w-3"}),b.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(X,{type:"button",variant:"secondary",size:"sm",className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",onClick:()=>{In(a?.invitation.apiBaseUrl??n,"Node URL copied")},children:"Copy URL"}),e.jsxs(X,{type:"button",variant:"secondary",size:"sm",className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",disabled:p,onClick:()=>{y()},children:[p?e.jsx(he,{className:"mr-1 h-3 w-3 animate-spin"}):e.jsx(Lo,{className:"mr-1 h-3 w-3"}),"Refresh"]})]})]})]})]})}function If({nodeName:t,dashboardUrl:n}){const s=`Show ${t} dashboard QR code`;return e.jsx(Ef,{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 Rf(t){return t?{left:t.left,top:t.top}:{left:0,top:0,visibility:"hidden"}}function Lf(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,p=t.right+4,u=m?p+l<=s.width-8?p: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,j=h+c>s.height-8&&f>=8?f:h;return{left:Math.round(u/d),top:Math.round(j/d)}}function Bf(){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 Rr="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 Lr({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),p=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(!p){c(null);return}const f=()=>{const j=d.current;if(!j)return;const g=j.getBoundingClientRect(),w=t&&n?{left:n.left,right:n.left,top:n.top,bottom:n.top}:m.current?.getBoundingClientRect();w&&c(Lf({left:w.left,right:w.right,top:w.top,bottom:w.bottom},{width:g.width,height:g.height},{width:window.innerWidth,height:window.innerHeight},Bf()))};return f(),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0)}},[t,n,p]),o.useEffect(()=>{if(!p)return;const f=g=>{const w=g.target;w instanceof Node&&!d.current?.contains(w)&&!m.current?.contains(w)&&u()},j=g=>{g.key==="Escape"&&u()};return document.addEventListener("mousedown",f),document.addEventListener("keydown",j),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",j)}},[p,u]),{open:p,menuRef:d,triggerRef:m,menuStyle:Rf(l),closeMenu:u,toggleButton:h}}function Xe({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:L("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})]})}function Sn({formatDateTime:t,name:n,status:s,statusVariant:r}){return e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-sm border border-border/60 bg-background/70 px-2 py-1",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-medium leading-3.5 text-foreground",children:n}),e.jsx("div",{className:"text-[9px] leading-3.5 text-muted-foreground",children:t(s?.checkedAt)})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[typeof s?.authenticated=="boolean"&&e.jsx(Le,{variant:s.authenticated?"default":"outline",className:"rounded-sm text-[9px] uppercase tracking-[0.12em]",children:s.authenticated?"auth ok":"auth required"}),e.jsx(Le,{variant:r(s?.status),className:"rounded-sm text-[9px] uppercase tracking-[0.12em]",children:s?.status??"unknown"})]})]})}function Ce({label:t,value:n,mono:s=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border/45 py-0.5 last:border-b-0 last:pb-0 first:pt-0",children:[e.jsx("span",{className:"shrink-0 text-[8px] uppercase tracking-[0.14em] text-muted-foreground/80",children:t}),e.jsx("span",{className:L("min-w-0 break-words text-right text-[10px] leading-3.5 text-foreground/90",s&&"break-all font-mono text-[9px]"),children:n})]})}function Of({nodeId:t,nodeName:n,node:s}){const r=jc(),a=r?.cluster??null,i=r?.systemInfo??null,c=a?.nodes.find(E=>E.id===t)??null??s??null,d=c?Nc(c,i):null,m=!!(i&&c&&c.id===i.nodeId),p=m||!!c?.settingsSnapshot,u=c?.name??s?.name??n,h=c?.status,f=c?.role,j=c?.transportType??d?.transportType??"direct",g=c?.capabilities??[],w=c?.supportedAgents??[],b=d?.startupRequirements?.components??d?.components??{},[k,y]=o.useState("identity"),[x,v]=o.useState(!1),N=[{id:"identity",icon:e.jsx(ts,{className:"h-3.5 w-3.5"}),title:"Identity",description:"Cluster role, endpoint, and node-scoped state.",content:e.jsxs(e.Fragment,{children:[e.jsx(Ce,{label:"Node ID",value:t,mono:!0}),e.jsx(Ce,{label:"Status",value:h??"Unavailable"}),e.jsx(Ce,{label:"Role",value:f??"Unavailable"}),e.jsx(Ce,{label:"Endpoint",value:c?.endpoint??"Unavailable",mono:!!c?.endpoint}),e.jsx(Ce,{label:"Joined",value:jt(c?.joinedAt)}),e.jsx(Ce,{label:"Heartbeat",value:jt(c?.lastHeartbeat)}),e.jsx(Ce,{label:"Capabilities",value:g.length>0?g.join(", "):"None"}),e.jsx(Ce,{label:"Agents",value:w.length>0?w.join(", "):"None"})]})},{id:"os",icon:e.jsx(au,{className:"h-3.5 w-3.5"}),title:"OS info",description:"Host and resource details.",content:e.jsxs(e.Fragment,{children:[e.jsx(Ce,{label:"Host",value:d?.os?.hostname??"Unavailable"}),e.jsx(Ce,{label:"Platform",value:d?.os?`${d.os.platform} ${d.os.release}`:"Unavailable"}),e.jsx(Ce,{label:"Arch",value:d?.os?.arch??"Unavailable"}),e.jsx(Ce,{label:"CPU",value:d?.os?.cpuModel??"Unavailable"}),e.jsx(Ce,{label:"Cores",value:d?.os?String(d.os.cpuCount):"Unavailable"}),e.jsx(Ce,{label:"Memory",value:d?.os?`${Qr(d.os.freeMemoryBytes)} free / ${Qr(d.os.totalMemoryBytes)} total`:"Unavailable"})]})},{id:"access",icon:e.jsx(kc,{className:"h-3.5 w-3.5"}),title:"Access surface",description:"How this node is reachable.",content:e.jsxs(e.Fragment,{children:[e.jsx(Ce,{label:"Transport",value:j}),e.jsx(Ce,{label:"Node URL",value:c?.endpoint??"Unavailable",mono:!!c?.endpoint}),e.jsx(Ce,{label:"Node tunnel",value:c?.devtunnelEndpoint??"Disabled",mono:!!c?.devtunnelEndpoint}),e.jsx(Ce,{label:"Dashboard URL",value:c?.dashboardOrigin??d?.localDashboardOrigin??"Unavailable",mono:!!(c?.dashboardOrigin||d?.localDashboardOrigin)}),e.jsx(Ce,{label:"Local dashboard",value:d?.localDashboardOrigin??"Unavailable",mono:!!d?.localDashboardOrigin})]})},{id:"auth",icon:e.jsx(Bu,{className:"h-3.5 w-3.5"}),title:"Auth",description:"Bearer-auth and trusted access posture.",content:e.jsxs(e.Fragment,{children:[e.jsx(Ce,{label:"Enabled",value:d?.auth?d.auth.enabled?"Yes":"No":"Unavailable"}),e.jsx(Ce,{label:"Same tenant",value:d?.auth?d.auth.allowSameTenant?"Allowed":"Off":"Unavailable"}),e.jsx(Ce,{label:"Allowed users",value:d?.auth?.allowedUsers.length?d.auth.allowedUsers.join(", "):"None"})]})},{id:"paths",icon:e.jsx(Jo,{className:"h-3.5 w-3.5"}),title:"Paths",description:"Workspace and runtime paths.",content:e.jsxs(e.Fragment,{children:[e.jsx(Ce,{label:"Work dir",value:d?.runtime?.workDir??c?.workDir??"Unavailable",mono:!!(d?.runtime?.workDir??c?.workDir)}),e.jsx(Ce,{label:"Storage",value:d?.runtime?.storagePath??"Unavailable",mono:!!d?.runtime?.storagePath}),e.jsx(Ce,{label:"Process cwd",value:d?.runtime?.cwd??"Unavailable",mono:!!d?.runtime?.cwd}),e.jsx(Ce,{label:"Started",value:jt(d?.runtime?.startedAt)}),e.jsx(Ce,{label:"PID",value:d?.runtime?String(d.runtime.pid):"Unavailable",mono:!!d?.runtime})]})},{id:"startup",icon:e.jsx(Sc,{className:"h-3.5 w-3.5"}),title:"Startup checks",description:"Dependency preflight from node startup.",content:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2 rounded-sm border border-border/55 bg-background/65 px-2 py-1",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-[9px] text-foreground",children:[e.jsx(Po,{className:"h-2.5 w-2.5 text-primary"}),"Last checked"]}),e.jsx("span",{className:"text-[9px] text-muted-foreground",children:jt(d?.startupRequirements?.lastCheckedAt)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Sn,{formatDateTime:jt,name:"Azure CLI",status:b.az,statusVariant:Nn}),e.jsx(Sn,{formatDateTime:jt,name:"DevTunnel",status:b.devtunnel,statusVariant:Nn}),e.jsx(Sn,{formatDateTime:jt,name:"Claude Code",status:b.claude,statusVariant:Nn}),e.jsx(Sn,{formatDateTime:jt,name:"Codex",status:b.codex,statusVariant:Nn}),e.jsx(Sn,{formatDateTime:jt,name:"Copilot CLI",status:b.copilot,statusVariant:Nn})]})]})}],A=N.find(E=>E.id===k)??N[0];return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("section",{className:"relative rounded-sm border border-border/65 bg-background/75 p-2 shadow-none",children:[!m&&c?.settingsSnapshot&&e.jsxs(Le,{variant:"outline",className:"absolute right-2 top-2 rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[8px] uppercase tracking-[0.12em] whitespace-nowrap",children:["Updated ",jt(c.settingsSnapshot.collectedAt)]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsxs("span",{className:"flex items-center gap-1.5 rounded-sm border border-border/70 bg-background/75 px-1.5 py-0.5 text-[9px] text-muted-foreground",children:[h&&e.jsx(vr,{status:h}),e.jsx("span",{className:"font-medium text-foreground",children:u})]}),f&&e.jsx(wr,{role:f,size:"compact"}),e.jsx(Le,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[8px] uppercase tracking-[0.12em]",children:j}),c&&e.jsx(Le,{variant:m?"default":"outline",className:"rounded-sm px-1.5 py-0 text-[8px] uppercase tracking-[0.12em]",children:m?"Live local session":"Leader-synced snapshot"}),d&&d.uptime>0&&e.jsxs(Le,{variant:"outline",className:"gap-1 rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[8px] uppercase tracking-[0.12em]",children:[e.jsx(ti,{className:"h-2.5 w-2.5"}),"Uptime ",Cc(d.uptime)]})]})]}),!p&&c&&e.jsx("div",{className:"rounded-sm border border-dashed border-border/65 bg-muted/20 px-2 py-1.5 text-[9px] leading-3.5 text-muted-foreground",children:"This node has not synced a runtime snapshot to the leader yet. Host, access, and startup details appear after the next keepalive."}),e.jsxs("div",{"data-node-properties-layout":"menu-details",className:"flex min-h-[18rem] gap-2",children:[e.jsxs("aside",{"data-node-properties-menu-collapsed":String(x),className:L("group/node-properties-menu flex shrink-0 flex-col overflow-hidden rounded-sm border border-border/60 bg-background/70 shadow-none transition-[width] duration-150",x?"w-9":"w-36 sm:w-40"),children:[e.jsxs("div",{className:L("flex items-center gap-1.5 border-b border-border/45 py-1",x?"justify-center px-1":"justify-between px-1.5"),children:[!x&&e.jsx("span",{className:"min-w-0 truncate text-[8px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",children:"Properties"}),e.jsx("button",{type:"button",className:"node-properties-menu-toggle flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-muted/45 hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-primary/45","aria-label":x?"Expand properties menu":"Collapse properties menu",title:x?"Expand properties menu":"Collapse properties menu",onClick:()=>v(E=>!E),children:x?e.jsx(nt,{className:"h-3 w-3"}):e.jsx(Dn,{className:"h-3 w-3"})})]}),e.jsx("nav",{"aria-label":"Node properties sections",className:"space-y-1 p-1",children:N.map(E=>{const M=E.id===k;return e.jsxs("button",{type:"button","data-node-properties-menu-item":E.title,"aria-current":M?"page":void 0,"aria-label":`Show ${E.title} details`,"aria-pressed":M,title:x?E.title:void 0,onClick:()=>y(E.id),className:L("flex h-7 w-full items-center gap-1.5 rounded-sm border border-transparent px-1.5 text-[10px] leading-3.5 transition-colors hover:bg-muted/45 hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-primary/45",x&&"justify-center px-0",M?"border-primary/35 bg-primary/10 text-foreground":"text-muted-foreground"),children:[e.jsx("span",{className:"shrink-0 text-primary/90 [&_svg]:h-3 [&_svg]:w-3",children:E.icon}),e.jsx("span",{className:L("node-properties-menu-label min-w-0 flex-1 truncate text-left",x&&"hidden"),children:E.title})]},E.id)})})]}),e.jsxs("section",{"data-node-properties-details-pane":"true",className:"min-w-0 flex-1 rounded-sm border border-border/60 bg-background/70 shadow-none",children:[e.jsxs("header",{className:"border-b border-border/45 px-2 py-1.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-[10px] font-semibold leading-3.5 text-foreground",children:[e.jsx("span",{className:"shrink-0 text-primary [&_svg]:h-3 [&_svg]:w-3",children:A.icon}),e.jsx("span",{className:"min-w-0 truncate",children:A.title})]}),e.jsx("p",{className:"mt-0.5 truncate text-[8px] leading-3 text-muted-foreground",children:A.description})]}),e.jsx("div",{className:"px-2 py-1.5",children:N.map(E=>e.jsx("div",{"data-node-properties-details":E.title,hidden:E.id!==k,children:E.content},E.id))})]})]})]})}function Ff({nodeId:t,nodeName:n,node:s,open:r,onOpenChange:a}){return e.jsx(mt,{open:r,onOpenChange:a,children:e.jsxs(ht,{className:"max-h-[min(82vh,40rem)] max-w-[min(88vw,44rem)] gap-3 overflow-y-auto rounded-sm border-border/70 bg-background/96 p-4 backdrop-blur-xl",children:[e.jsxs(Mt,{className:"space-y-1",children:[e.jsxs(vt,{className:"flex items-center gap-1.5 text-[13px]",children:[e.jsx(ts,{className:"h-3.5 w-3.5 text-primary"}),"Node properties"]}),e.jsxs(Dt,{className:"truncate text-[10px] leading-4 text-muted-foreground",children:["Runtime environment, connectivity, and preflight details for ",s?.name??n,"."]})]}),e.jsx(Of,{nodeId:t,nodeName:n,node:s})]})})}function Br({nodeId:t,nodeName:n,node:s,contextOpen:r=!1,contextPosition:a=null,defaultOpen:i=!1,onContextOpenChange:l,onOpenSettings:c,onOpenServicePreview:d,onOpenCapabilities:m,onOpenDevBox:p,onStartDevBox:u,onToggleRemoteAccess:h,remoteAccessLabel:f,remoteAccessPending:j,remoteAccessDisabled:g,remoteAccessDisabledReason:w,showConfigureDevBox:b,showStartDevBox:k,startDevBoxPending:y,className:x}){const{open:v,menuRef:N,triggerRef:A,menuStyle:E,closeMenu:M,toggleButton:B}=Lr({contextOpen:r,contextPosition:a,defaultOpen:i,onContextOpenChange:l}),[D,_]=o.useState(!1),P=y?"Starting":"Start DevBox",O=f?.startsWith("Disable")?Tc:Vu,W=v?e.jsxs("div",{ref:N,"data-node-action-menu-portal":"true",role:"menu",style:E,onClick:J=>J.stopPropagation(),onPointerDown:J=>J.stopPropagation(),className:Rr,children:[c&&e.jsx(Xe,{ariaLabel:`Open ${n} settings`,title:`Open ${n} settings`,icon:e.jsx(Ac,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{M(),c(t)},children:"Settings"}),d&&e.jsx(Xe,{ariaLabel:`Preview service on ${n}`,title:`Preview service on ${n}`,icon:e.jsx(Zo,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{M(),d(t)},children:"Preview service"}),m&&e.jsx(Xe,{ariaLabel:`Open ${n} capabilities`,title:`Open ${n} capabilities`,icon:e.jsx(Rn,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{M(),m(t)},children:"Capabilities"}),f&&h&&e.jsx(Xe,{ariaLabel:`${f} for ${n}`,title:w??`${f} for ${n}`,icon:e.jsx(O,{className:"h-3 w-3 shrink-0 text-primary"}),pending:j,disabled:g,onClick:()=>{M(),h()},children:f}),k&&u&&e.jsx(Xe,{ariaLabel:`${P} for ${n}`,title:`${P} for ${n}`,icon:e.jsx(ss,{className:"h-3 w-3 shrink-0 text-primary"}),pending:y,onClick:()=>{M(),u(t)},children:P}),b&&p&&e.jsx(Xe,{ariaLabel:`Configure DevBox for ${n}`,title:`Configure DevBox for ${n}`,icon:e.jsx(Ec,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{M(),p(t)},children:"Configure DevBox"}),e.jsx(Xe,{ariaLabel:`Properties for ${n}`,title:`Properties for ${n}`,icon:e.jsx(yr,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{M(),_(!0)},children:"Properties"})]}):null;return e.jsxs("div",{"data-node-action-menu":"true",className:L("relative shrink-0",v&&"z-[120]",x),onClick:J=>J.stopPropagation(),onPointerDown:J=>J.stopPropagation(),children:[e.jsx(X,{ref:A,type:"button",variant:"ghost",size:"icon","aria-label":`More actions for ${n}`,"aria-haspopup":"menu","aria-expanded":v,title:`More actions for ${n}`,onClick:J=>{J.stopPropagation(),B()},className:L("h-6 w-6 rounded-sm text-muted-foreground hover:bg-background/70 hover:text-foreground",v&&"bg-background/80 text-primary"),children:e.jsx(Tr,{className:"h-3.5 w-3.5"})}),W&&(typeof document>"u"?W:ns.createPortal(W,document.body)),D&&e.jsx(Ff,{nodeId:t,nodeName:n,node:s,open:D,onOpenChange:_})]})}const zf=new Set(["deallocated","hibernate","hibernated","sleep","sleeping","stopped"]),Uf=new Set(["startinprogress","starting"]);function dn(t){return!!(t?.enabled&&t.name)}function $f(t){const n=t?.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(n&&zf.has(n))}function un(t){const n=t?.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(n&&Uf.has(n))}function is(t,n,s){return t==="offline"&&$f(n)&&dn(s)}function Ja(t,n){return t==="offline"&&dn(n)}function Za(t){return!dn(t)}function qf({nodeStatus:t,status:n,current:s,selected:r}){const a=r??s;return a&&is(t,n,a)?a:null}function Ye(t){return t.scope||`name:${t.name??""}`}function Vf({previousKey:t,baseDevBox:n,listed:s}){if(t&&s.some(i=>Ye(i)===t))return t;if(!dn(n))return s[0]?Ye(s[0]):"";const r=Ye(n),a=s.find(i=>Ye(i)===r)??s.find(i=>i.name===n.name);return a?Ye(a):r}function Hf(t){return t==="nodes"||t==="events"?t:"overview"}function Kf({cluster:t,systemInfo:n,nodeNameById:s,nodeBlockingTaskCounts:r,eventTypeFilter:a,onEventTypeFilterChange:i,eventTypeOptions:l,filteredEvents:c,sseConnected:d,clusterLoading:m,clusterError:p,promotePending:u,onPromote:h,onAddNode:f,leavePending:j,onLeaveCluster:g,onToggleNodeDevTunnel:w,devTunnelNodeId:b,devBoxStartNodeId:k,devBoxStartingNodeIds:y=new Set,activeTab:x,onTabChange:v,onOpenNodeSettings:N,onOpenNodeCapabilities:A,onOpenDevBox:E,onStartDevBox:M}){const B=t?.self?.role==="leader",D=t?.self?.role==="follower"&&!t?.leader,_=t?.self??null,O=Mc(t?.nodes??[],_?.id).filter(R=>R.id!==_?.id),W=t?.leader?t.nodes.find(R=>R.id===t.leader?.id)??null:null,J=t?.leader?t.leader.dashboardOrigin??W?.dashboardOrigin??(n&&t.leader.id===(n.nodeId??n.id)?n.dashboardOrigin:void 0)??t.leader.endpoint:null,Y=t?.leader?W?.devtunnelEndpoint??t.leader.endpoint:null,V=t?.leader?.name??W?.name??"Leader",ne=!!(t?.leader?.id&&t.leader.id===_?.id),$=_?.role==="leader"&&O.length===0,ee=_?.role==="follower",[S,Q]=o.useState("overview"),T=x??S;function te(R){const H=Hf(R);Q(H),v?.(H)}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(_r,{value:T,onValueChange:te,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(os,{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(bt,{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:[_&&e.jsx(Xa,{node:_,systemInfo:n,blockingTaskCount:r.get(_.id)??0,devTunnelNodeId:b,onToggleNodeDevTunnel:w,showActions:!1,defaultExpanded:!1,onOpenDevBox:E,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(Le,{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..."]}):p&&!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:p}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx(on,{label:"Term",value:String(t?.term??0)}),e.jsx(on,{label:"Nodes",value:String(t?.nodes.length??0)}),e.jsx(on,{label:"Pending",value:String(t?.taskSummary.pending??0)}),e.jsx(on,{label:"Running",value:String(t?.taskSummary.running??0)}),e.jsx(on,{label:"Completed",value:String(t?.taskSummary.completed??0)}),e.jsx(on,{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(ct,{label:"Leader",value:t?.leader?.name??"None"}),e.jsx(ct,{label:"Leader Dashboard URL",value:J??"Unavailable",mono:!0,action:J?e.jsx(Fr,{nodeName:V,dashboardUrl:J,copyLabel:"Copy leader dashboard URL",copiedMessage:"Leader Dashboard URL copied"}):void 0}),Y&&e.jsx(ct,{label:"Leader Node URL",value:Y,mono:!0,action:e.jsx(Or,{nodeName:V,nodeEndpoint:Y,copyLabel:"Copy leader node URL",copiedMessage:"Leader Node URL copied",showPairingQr:ne})}),e.jsx(ct,{label:"Feed",value:d?"Receiving live updates":"Reconnecting to event stream"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:D&&e.jsxs(X,{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(bt,{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(X,{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($u,{className:"h-3 w-3"}),"Join node"]}):ee?e.jsxs(X,{variant:"secondary",size:"sm",onClick:g,disabled:j,className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",children:[j&&e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),_&&e.jsx(Xa,{node:_,systemInfo:n,blockingTaskCount:r.get(_.id)??0,devTunnelNodeId:b,onToggleNodeDevTunnel:w,showActions:!0,defaultExpanded:!0,onOpenNodeSettings:B?N:void 0,onOpenNodeCapabilities:B?A:void 0,onOpenDevBox:B?E:void 0,onStartDevBox:B?M:void 0,devBoxStartNodeId:k,devBoxStartingNodeIds:y})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"text-[10px] font-medium text-foreground",children:["Peer nodes (",O.length,")"]}),O.length>0?e.jsx("div",{className:"space-y-1.5",children:O.map(R=>e.jsx(Gf,{node:R,isLeader:!!B,blockingTaskCount:r.get(R.id)??0,devTunnelNodeId:b,onToggleNodeDevTunnel:w,onOpenNodeSettings:B?N:void 0,onOpenNodeCapabilities:B?A:void 0,onOpenDevBox:B?E:void 0,onStartDevBox:B?M:void 0,devBoxStartNodeId:k,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(bt,{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(ti,{className:L("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($e,{value:a,onValueChange:i,children:[e.jsx(qe,{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(Je,{placeholder:"Event type"})}),e.jsx(Ve,{className:"shadow-none",children:l.map(R=>e.jsx(Oe,{value:R,className:"py-1 pl-6 pr-1.5 text-[10px] leading-4",children:R==="all"?"All event types":R},R))})]}),e.jsx(Le,{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(Dc,{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 Xa({node:t,systemInfo:n,blockingTaskCount:s,devTunnelNodeId:r,onToggleNodeDevTunnel:a,showActions:i=!0,defaultExpanded:l=!1,onOpenNodeSettings:c,onOpenNodeCapabilities:d,onOpenDevBox:m,onStartDevBox:p,devBoxStartNodeId:u,devBoxStartingNodeIds:h}){const[f,j]=o.useState(l),g=n?.dashboardOrigin??t.dashboardOrigin,w=t.devtunnelEndpoint??t.endpoint,b=g??t.endpoint,k=n?.workDir??t.workDir,y=ai(t,n?.transportType),x=Er(t,n?.transportType),v=x&&fn(n?.transportType??t.transportType)?!0:ri(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:()=>j(A=>!A),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[f?e.jsx(st,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(nt,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx(vr,{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:b,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(jr,{className:"h-3 w-3"})}),(c||d||i&&v)&&e.jsx(Br,{nodeId:t.id,nodeName:t.name,node:t,onOpenSettings:c,onOpenCapabilities:d,onOpenDevBox:m,onStartDevBox:p,onToggleRemoteAccess:i&&v?()=>a(t):void 0,remoteAccessLabel:i&&v?x?"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:is(t.status,t.devbox?.lastStatus,t.devbox)||un(t.devbox?.lastStatus)||h.has(t.id),startDevBoxPending:u===t.id||un(t.devbox?.lastStatus)||h.has(t.id)})]}),e.jsxs("button",{type:"button",onClick:()=>j(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(wr,{role:t.role,size:"compact"}),e.jsx(Le,{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(ct,{label:"Node ID",value:t.id,mono:!0}),g&&e.jsx(ct,{label:"Dashboard",value:g,mono:!0,action:e.jsx(Fr,{nodeName:t.name,dashboardUrl:g})}),e.jsx(ct,{label:"Node URL",value:w,mono:!0,action:e.jsx(Or,{nodeName:t.name,nodeEndpoint:w})}),k&&e.jsx(ct,{label:"Workspace",value:k,mono:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsx(rr,{label:"Transport",value:y}),n&&e.jsx(rr,{label:"Uptime",value:_c(n.uptime),mono:!0})]}),i&&d&&e.jsxs(X,{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(Rn,{className:"h-3 w-3"}),"Capabilities"]}),i&&v&&N&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[s," active task",s===1?"":"s"," on this node."]})]})]})}function Gf({node:t,isLeader:n,blockingTaskCount:s,devTunnelNodeId:r,onToggleNodeDevTunnel:a,onOpenNodeSettings:i,onOpenNodeCapabilities:l,onOpenDevBox:c,onStartDevBox:d,devBoxStartNodeId:m,devBoxStartingNodeIds:p}){const[u,h]=o.useState(!1),f=t.dashboardOrigin,j=t.devtunnelEndpoint??t.endpoint,g=f??t.endpoint,w=ai(t),b=Er(t),k=ri(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(x=>!x),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[u?e.jsx(st,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):e.jsx(nt,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx(vr,{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(jr,{className:"h-3 w-3"})}),n&&(i||l||k)&&e.jsx(Br,{nodeId:t.id,nodeName:t.name,node:t,onOpenSettings:i,onOpenCapabilities:l,onOpenDevBox:c,onStartDevBox:d,onToggleRemoteAccess:k?()=>a(t):void 0,remoteAccessLabel:k?b?"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:is(t.status,t.devbox?.lastStatus,t.devbox)||un(t.devbox?.lastStatus)||p.has(t.id),startDevBoxPending:m===t.id||un(t.devbox?.lastStatus)||p.has(t.id)})]}),e.jsxs("button",{type:"button",onClick:()=>h(x=>!x),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(wr,{role:t.role,size:"compact"}),e.jsx(Le,{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(ct,{label:"Node ID",value:t.id,mono:!0}),f&&e.jsx(ct,{label:"Dashboard",value:f,mono:!0,action:e.jsx(Fr,{nodeName:t.name,dashboardUrl:f})}),e.jsx(ct,{label:"Node URL",value:j,mono:!0,action:e.jsx(Or,{nodeName:t.name,nodeEndpoint:j,showPairingQr:!1})}),t.workDir&&e.jsx(ct,{label:"Workspace",value:t.workDir,mono:!0}),e.jsx(rr,{label:"Transport",value:w})]}),n&&l&&e.jsxs(X,{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(Rn,{className:"h-3 w-3"}),"Capabilities"]}),n&&k&&y&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[s," active task",s===1?"":"s"," on this node."]})]})]})}function Or({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(Pf,{nodeName:t,nodeEndpoint:n}):null,e.jsx(Ji,{label:s,onClick:()=>{In(n,r)}})]})}function Fr({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(If,{nodeName:t,dashboardUrl:n}),e.jsx(Ji,{label:s,onClick:()=>{In(n,r)}})]})}function Ji({label:t,onClick:n}){return e.jsx(X,{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(_o,{className:"h-3 w-3"})})}function Wf(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..."}:Qn.has(t.status)||t.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:Qn.has(t.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}const Zi=.5,Xi=1.75,eo=.1;function Qf({node:t,open:n,onOpenChange:s}){const[r,a]=o.useState($n),[i,l]=o.useState(null),[c,d]=o.useState(1),[m,p]=o.useState(!1),[u,h]=o.useState(null);o.useEffect(()=>{a($n),l(null),d(1),p(!1),h(null)},[t?.id,n]);const f=o.useCallback(async y=>{if(!t)return;const x=y??Number.parseInt(r.trim()||$n,10);if(!Number.isInteger(x)||x<1||x>65535){h("Enter a port between 1 and 65535");return}p(!0),h(null);try{const v=await Pc(t.id,{port:x});l(v),a(String(x)),Yr("preview.created",{result:"success",previewType:"service-port"})}catch(v){h(v instanceof Error?v.message:"Failed to create service preview"),Yr("preview.failed",{result:"failed",previewType:"service-port"})}finally{p(!1)}},[t,r]),j=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){j();return}const x=window.setTimeout(j,y);return()=>window.clearTimeout(x)},[j,i]);const g=i?Qd(i):null,w=t?.name??"Node",b=Yf(c),k={width:`${100/c}%`,height:`${100/c}%`,transform:`scale(${c})`,transformOrigin:"top left"};return e.jsx(mt,{open:n,onOpenChange:s,children:e.jsxs(ht,{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(vt,{className:"flex min-w-0 items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[e.jsx(Zo,{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:w})]}),e.jsx(Dt,{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(dt,{type:"text",min:1,max:65535,inputMode:"numeric",value:r,onChange:y=>a(y.target.value),placeholder:$n,"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(X,{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(ss,{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:Jf(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(X,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-none",onClick:()=>d(y=>to(y,-eo)),disabled:c<=Zi,title:"Zoom out","aria-label":"Zoom out preview",children:e.jsx(Wu,{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:b}),e.jsx(X,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-none",onClick:()=>d(y=>to(y,eo)),disabled:c>=Xi,title:"Zoom in","aria-label":"Zoom in preview",children:e.jsx(Ku,{className:"h-3.5 w-3.5"})})]}),e.jsx(X,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",onClick:j,title:"Refresh",children:e.jsx(Lo,{className:"h-3.5 w-3.5"})}),e.jsx(X,{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(jr,{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:Jd(i),style:k,className:"h-full w-full border-0",sandbox:Yd(i),title:`${w} 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 to(t,n){return el(Math.round((t+n)*100)/100)}function el(t){return Number.isFinite(t)?Math.min(Xi,Math.max(Zi,t)):1}function Yf(t){return`${Math.round(el(t)*100)}%`}function Jf(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`}const Zf=new Set(["completed","failed","cancelled","archived"]);function Xf(t){return typeof t=="object"&&t!==null}function tl(t){return typeof t=="string"&&t.trim().length>0?t.trim():""}function pr(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 ep(t){return t==="nativeSession"?"Native session":"Meshy chat"}function tp(t){return t.effectiveProjectPath??t.project??"default workspace"}function np(t){return Xf(t.agentSessions)?Object.keys(t.agentSessions).map(n=>n.trim()).filter(Boolean):[]}function sp(t){const n=new Set;t.agent&&n.add(t.agent);const s=tl(t.payload.activeAgent);s&&n.add(s);for(const r of np(t.payload))n.add(r);return Array.from(n).join(", ")||"None"}function rp(t){return t.status!=="running"?"None":tl(t.payload.activeAgent)||t.agent||"None"}function ap(t){return t.assignedNodeName??t.assignedTo??"Unassigned"}function op(t){const n=t.reduce((s,r)=>Math.max(s,r.updatedAt),0);return n>0?pr(n):"No task activity"}function Cn(t,n){return t.filter(s=>n.has(s.status)).length}function nl({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 ip({task:t}){const n=Zf.has(t.status),s=[{label:"Status",value:t.status},{label:"Kind",value:ep(t.conversationKind)},{label:"Priority",value:t.priority},{label:"Created",value:pr(t.createdAt)},{label:n?"Finished":"Updated",value:pr(t.updatedAt)}];return s.push({label:"Assigned node",value:ap(t)},{label:"Workspace",value:tp(t),mono:!0}),t.branch&&s.push({label:"Branch",value:t.branch,mono:!0}),s.push({label:"Task agents",value:sp(t)},{label:"Running agents",value:rp(t)},{label:"Retries",value:`${t.retryCount}/${t.maxRetries}`},{label:"Created by",value:t.createdBy},{label:"Task ID",value:t.id,mono:!0}),e.jsx(nl,{rows:s})}function lp({dirPath:t,nodeId:n,nodeName:s,nodeStatus:r,tasks:a,unloadedCompletedCount:i=0}){const l=Math.max(0,i),c=Cn(a,new Set(["completed"]))+l,d=Cn(a,new Set(["failed","cancelled"])),m=Cn(a,new Set(["archived"])),p=[{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(Cn(a,new Set(["assigned"])))},{label:"Running",value:String(Cn(a,new Set(["running"])))},{label:"Completed",value:String(c)},{label:"Failed / cancelled",value:String(d)},{label:"Archived",value:String(m)},{label:"Latest update",value:op(a)}];return e.jsx(nl,{rows:p})}function cp({task:t,open:n,onOpenChange:s}){return e.jsx(mt,{open:n,onOpenChange:s,children:e.jsxs(ht,{className:"max-w-[25rem] gap-3 rounded-sm border-border/70 bg-background/96 p-4 backdrop-blur-xl",children:[e.jsxs(Mt,{className:"space-y-1",children:[e.jsx(vt,{className:"text-[13px]",children:"Task properties"}),e.jsx(Dt,{className:"truncate text-[10px] leading-4 text-muted-foreground",children:t.title})]}),e.jsx(ip,{task:t})]})})}function dp({dirPath:t,nodeId:n,nodeName:s,nodeStatus:r,tasks:a,unloadedCompletedCount:i,open:l,onOpenChange:c}){return e.jsx(mt,{open:l,onOpenChange:c,children:e.jsxs(ht,{className:"max-w-[25rem] gap-3 rounded-sm border-border/70 bg-background/96 p-4 backdrop-blur-xl",children:[e.jsxs(Mt,{className:"space-y-1",children:[e.jsx(vt,{className:"text-[13px]",children:"Project properties"}),e.jsx(Dt,{className:"truncate text-[10px] leading-4 text-muted-foreground",children:t})]}),e.jsx(lp,{dirPath:t,nodeId:n,nodeName:s,nodeStatus:r,tasks:a,unloadedCompletedCount:i})]})})}function up({dirPath:t,nodeId:n,nodeName:s,nodeStatus:r,tasks:a=[],unloadedCompletedCount:i,contextOpen:l=!1,contextPosition:c=null,defaultOpen:d=!1,onContextOpenChange:m,onCreateTask:p,onOpenCapabilities:u}){const{open:h,menuRef:f,triggerRef:j,menuStyle:g,closeMenu:w,toggleButton:b}=Lr({contextOpen:l,contextPosition:c,defaultOpen:d,onContextOpenChange:m}),[k,y]=o.useState(!1),x=h?e.jsxs("div",{ref:f,role:"menu",style:g,onClick:v=>v.stopPropagation(),onPointerDown:v=>v.stopPropagation(),className:Rr,children:[e.jsx(Xe,{icon:e.jsx(Ln,{className:"h-3 w-3 text-primary"}),onClick:()=>{w(),p()},children:"New chat"}),u&&e.jsx(Xe,{icon:e.jsx(Rn,{className:"h-3 w-3 text-primary"}),onClick:()=>{w(),u()},children:"Capabilities"}),e.jsx(Xe,{icon:e.jsx(yr,{className:"h-3 w-3 text-primary"}),onClick:()=>{w(),y(!0)},children:"Properties"})]}):null;return e.jsxs("div",{className:L("relative flex shrink-0 items-center self-center pr-1",h&&"z-[120]"),onClick:v=>v.stopPropagation(),onPointerDown:v=>v.stopPropagation(),children:[e.jsx("button",{ref:j,type:"button","aria-label":`More actions for ${t}`,"aria-haspopup":"menu","aria-expanded":h,title:`More actions for ${t}`,onClick:v=>{v.stopPropagation(),b()},className:L("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(Tr,{className:"h-2.5 w-2.5"})}),x&&(typeof document>"u"?x:ns.createPortal(x,document.body)),k&&e.jsx(dp,{dirPath:t,nodeId:n,nodeName:s,nodeStatus:r,tasks:a,unloadedCompletedCount:i,open:k,onOpenChange:y})]})}function mp({dirPath:t,label:n,taskCount:s,tasks:r,unloadedCompletedCount:a,nodeId:i,nodeName:l,nodeStatus:c,collapsed:d,onToggle:m,onCreateTask:p,onOpenCapabilities:u}){const[h,f]=o.useState(!1),[j,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:w=>{w.preventDefault(),w.stopPropagation(),f(!0),g({left:w.clientX,top:w.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(nt,{className:L("h-3 w-3 shrink-0 transition-transform duration-200",!d&&"rotate-90")}),e.jsx(hn,{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(Rn,{className:"h-2.5 w-2.5"})}),e.jsx("button",{type:"button",onClick:p,"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(Ln,{className:"h-2.5 w-2.5"})}),e.jsx(up,{dirPath:t,nodeId:i,nodeName:l,nodeStatus:c,tasks:r,unloadedCompletedCount:a,contextOpen:h,contextPosition:h?j:null,onContextOpenChange:w=>{w||(f(!1),g(null))},onCreateTask:p,onOpenCapabilities:u})]})}function no(t,n){if(!t.has(n))return t;const s=new Set(t);return s.delete(n),s}function hp(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 so(t,n,s){return s?{collapsedNodes:no(t,s.nodeKey),collapsedDirs:no(n,s.dirKey)}:{collapsedNodes:t,collapsedDirs:n}}function fp(t,n,s){const r=t.filter(d=>d.status==="completed"),a=new Set(r.filter(Pn).map(d=>d.id)),i=new Set((n?r:[...r].sort((d,m)=>m.updatedAt-d.updatedAt).slice(0,Nr)).map(d=>d.id));for(const d of a)i.add(d);s&&r.some(d=>d.id===s)&&i.add(s);const l=sl(t.filter(d=>d.status!=="completed"||i.has(d.id))),c=r.length-i.size;return{visibleTasks:l,hiddenCompletedCount:Math.max(0,c)}}function Pn(t){return t.pinnedOnTop===!0}function sl(t){return[...t].sort((n,s)=>{const r=Number(Pn(s))-Number(Pn(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 pp=new Set(["completed","failed","cancelled"]);function xp({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:p,triggerRef:u,menuStyle:h,closeMenu:f,toggleButton:j}=Lr({contextOpen:n,contextPosition:s,defaultOpen:r,onContextOpenChange:a}),[g,w]=o.useState(!1),[b,k]=o.useState(!1),[y,x]=o.useState(!1),[v,N]=o.useState(!1),[A,E]=o.useState(t.title),[M,B]=o.useState(null),D=Pn(t),_=pp.has(t.status),P=t.status==="archived"?"Task is already archived":"Only completed, failed, or cancelled tasks can be archived";o.useEffect(()=>{E(t.title)},[t.id,t.title]);async function O(V,ne){if(!(!ne||M)){B(V);try{await ne(),f()}finally{B(null)}}}const W=A.trim(),J=W===t.title,Y=m?e.jsxs("div",{ref:p,role:"menu",style:h,onClick:V=>V.stopPropagation(),onPointerDown:V=>V.stopPropagation(),className:Rr,children:[i&&e.jsx(Xe,{icon:e.jsx(Jt,{className:"h-3 w-3 text-primary"}),onClick:()=>{f(),w(!0)},children:"Update title"}),d&&e.jsx(Xe,{icon:D?e.jsx(Eu,{className:"h-3 w-3 text-primary"}):e.jsx(Xo,{className:"h-3 w-3 text-primary"}),pending:M==="pin",onClick:()=>O("pin",()=>d(t,!D)),children:D?"Unpin from top":"Pin on top"}),c&&e.jsx(Xe,{icon:e.jsx(Go,{className:"h-3 w-3 text-primary"}),disabled:!_,pending:M==="archive",title:_?"Archive task":P,onClick:()=>{_&&(f(),x(!0))},children:"Archive"}),l&&e.jsx(Xe,{destructive:!0,icon:e.jsx(kr,{className:"h-3 w-3 text-destructive"}),onClick:()=>{f(),N(!0)},children:"Delete"}),e.jsx(Xe,{icon:e.jsx(yr,{className:"h-3 w-3 text-primary"}),onClick:()=>{f(),k(!0)},children:"Properties"})]}):null;return e.jsxs("div",{className:L("relative shrink-0",m&&"z-[120]"),onClick:V=>V.stopPropagation(),onPointerDown:V=>V.stopPropagation(),children:[e.jsx(X,{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:V=>{V.stopPropagation(),j()},className:L("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(Tr,{className:"h-3 w-3"})}),Y&&(typeof document>"u"?Y:ns.createPortal(Y,document.body)),b&&e.jsx(cp,{task:t,open:b,onOpenChange:k}),g&&i&&e.jsx(mt,{open:g,onOpenChange:w,children:e.jsxs(ht,{className:"rounded-sm sm:max-w-sm",children:[e.jsxs(Mt,{children:[e.jsx(vt,{children:"Update task title"}),e.jsx(Dt,{children:"Rename this task in the tree and transcript header."})]}),e.jsxs("form",{className:"space-y-3",onSubmit:V=>{V.preventDefault(),O("title",async()=>{!W||J||(await i?.(t,W),w(!1))})},children:[e.jsx(dt,{value:A,onChange:V=>E(V.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(br,{children:[e.jsx(X,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-sm px-2 text-[11px]",onClick:()=>w(!1),children:"Cancel"}),e.jsxs(X,{type:"submit",size:"sm",className:"h-7 rounded-sm px-2 text-[11px]",disabled:!W||J||M==="title",children:[M==="title"&&e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})]})}),y&&c&&e.jsx($t,{open:y,onOpenChange:x,children:e.jsxs(qt,{children:[e.jsxs(Vt,{children:[e.jsx(Ht,{children:"Archive this task?"}),e.jsx(Kt,{children:"This task leaves the default active view immediately."})]}),e.jsxs(Gt,{children:[e.jsx(Wt,{autoFocus:!0,children:"Cancel"}),e.jsx(Qt,{onClick:()=>O("archive",async()=>{await c?.(t),x(!1)}),disabled:M==="archive",children:"Archive"})]})]})}),v&&l&&e.jsx($t,{open:v,onOpenChange:N,children:e.jsxs(qt,{children:[e.jsxs(Vt,{children:[e.jsx(Ht,{children:"Delete this task and saved logs?"}),e.jsx(Kt,{children:"This cannot be undone."})]}),e.jsxs(Gt,{children:[e.jsx(Wt,{autoFocus:!0,children:"Cancel"}),e.jsx(Qt,{onClick:()=>O("delete",async()=>{await l?.(t),N(!1)}),disabled:M==="delete",className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}const rl="meshy-task-sidebar-tree-state";function ro(t){return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}function Js(){try{return globalThis.window?.localStorage??globalThis.localStorage??null}catch{return null}}function ao(t){if(!t)return{collapsedNodes:[],collapsedDirs:[]};try{const n=t.getItem(rl);if(!n)return{collapsedNodes:[],collapsedDirs:[]};const s=JSON.parse(n);return{collapsedNodes:ro(s.collapsedNodes),collapsedDirs:ro(s.collapsedDirs)}}catch{return{collapsedNodes:[],collapsedDirs:[]}}}function gp(t,n){if(t)try{t.setItem(rl,JSON.stringify(n))}catch{}}const Hn="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",Kn="py-1 pl-6 pr-1.5 text-[10px] leading-4 [&_svg]:h-3 [&_svg]:w-3";function oo({toolbarTasks:t,activeTaskId:n,tasksLoading:s,tasksError:r,isLeader:a,scope:i,agentFilter:l,nodeFilter:c,taskKindFilter:d,agentOptions:m,nodeOptions:p,nodeNameById:u,nodeWorkDirById:h,nodeStatusById:f,nodeInfoById:j,completedGroupByKey:g,devBoxNodeIds:w=new Set,devBoxStartNodeIds:b=new Set,devBoxStartingNodeIds:k=new Set,leaderNodeId:y,searchQuery:x,selectedTaskIds:v,allVisibleTasksSelected:N,someVisibleTasksSelected:A,canBatchArchive:E,onScopeChange:M,onAgentFilterChange:B,onNodeFilterChange:D,onTaskKindFilterChange:_,onToggleTaskSelected:P,onToggleAllVisibleTasks:O,onBatchArchive:W,onBatchDelete:J,onUpdateTaskTitle:Y,onDeleteTask:V,onArchiveTask:ne,onToggleTaskPinned:$,onCreateTask:ee,onOpenNodeSettings:S,onOpenNodeCapabilities:Q,onOpenProjectCapabilities:T,onOpenDevBox:te,onStartDevBox:R,onLoadCompletedTasks:H,onSelectTask:F}){const[le,ie]=o.useState(!1),[ue,Z]=o.useState(()=>v.size>0),[K,I]=o.useState(!1),[se,q]=o.useState(null),[ae,ye]=o.useState(null),[pe,Ze]=o.useState(null),[Ae,ft]=o.useState(null),[Re,De]=o.useState(null),{markScrollbarActive:He,scrollbarActive:Ke}=Fi(),je=v.size,Be=!!(a&&(ue||je>0)),G=i!=="active"||c!=="all"||l!=="all"||d!=="all",ge=x.trim().length>0,[be,et]=o.useState(()=>new Set(ao(Js()).collapsedNodes)),[_e,rt]=o.useState(()=>new Set(ao(Js()).collapsedDirs)),[re,Ne]=o.useState(new Set),Te=o.useMemo(()=>Ic({nodeStatusById:f,nodeNameById:u,nodeWorkDirById:h,nodeFilter:c,searchQuery:x}),[f,u,h,c,x]),ve=o.useMemo(()=>Rc(t,u,y,h,Te),[t,u,y,h,Te]),at=o.useMemo(()=>hp(ve,n),[ve,n]),Pe=o.useRef(null),_t=ve.length===1,pt=ve.length>0,pn=_t&&(G||ge),en=!!(a&&(t.length>0||je>0)),St=!!(a&&Y&&V&&ne&&$),wt=o.useCallback(U=>{et(ze=>{const Ie=new Set(ze);return Ie.has(U)?Ie.delete(U):Ie.add(U),Ie})},[]),xn=o.useCallback(U=>{rt(ze=>{const Ie=new Set(ze);return Ie.has(U)?Ie.delete(U):Ie.add(U),Ie})},[]),gn=o.useCallback(U=>{Ne(ze=>{const Ie=new Set(ze);return Ie.add(U),Ie})},[]);o.useEffect(()=>{gp(Js(),{collapsedNodes:Array.from(be),collapsedDirs:Array.from(_e)})},[_e,be]),o.useEffect(()=>{if(!at||!n)return;const U=`${n}:${at.nodeKey}:${at.dirKey}`;Pe.current!==U&&(Pe.current=U,et(ze=>so(ze,new Set,at).collapsedNodes),rt(ze=>so(new Set,ze,at).collapsedDirs))},[n,at]);const Pt=o.useCallback(U=>{Z(!0),O(U)},[O]),Ft=o.useCallback(U=>{if(U===!0&&!N){Z(!0),I(!0);return}Pt(U===!0)},[N,Pt]),tn=o.useCallback(()=>{Pt(!0),I(!1)},[Pt]),Ct=o.useCallback(()=>{O(!1),Z(!1),I(!1)},[O]),nn=o.useCallback(()=>{ye(null),Ze(null)},[]),Fe=o.useCallback(()=>{ft(null),De(null)},[]);o.useEffect(()=>{a||(Z(!1),I(!1))},[a]);const ot=Be?e.jsxs($t,{open:K,onOpenChange:I,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(_n,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:A&&!N?"indeterminate":N,onCheckedChange:Ft,"aria-label":"Select all visible tasks"}),e.jsx("span",{children:"Select all"})]}),K&&e.jsxs(qt,{children:[e.jsxs(Vt,{children:[e.jsx(Ht,{children:"Select every visible task?"}),e.jsx(Kt,{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(Gt,{children:[e.jsx(Wt,{autoFocus:!0,children:"Cancel"}),e.jsx(Qt,{onClick:tn,children:"Select all"})]})]})]}):e.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>Z(!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(zd,{className:"h-3 w-3"}),"Multi select"]}),yt=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"]}),!E&&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,Tt=je>0?e.jsxs("div",{className:"flex flex-wrap justify-end gap-1",children:[e.jsxs($t,{children:[e.jsx(nr,{asChild:!0,children:e.jsxs(X,{variant:"ghost",size:"sm",disabled:!E,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(Go,{}),"Archive"]})}),e.jsxs(qt,{children:[e.jsxs(Vt,{children:[e.jsxs(Ht,{children:["Archive ",je," selected task",je!==1?"s":"","?"]}),e.jsx(Kt,{children:"These tasks leave the default view immediately. Cancel if any selected task still needs to stay visible in active work."})]}),e.jsxs(Gt,{children:[e.jsx(Wt,{autoFocus:!0,children:"Cancel"}),e.jsx(Qt,{onClick:W,disabled:!E,children:"Archive"})]})]})]}),e.jsxs($t,{children:[e.jsx(nr,{asChild:!0,children:e.jsxs(X,{variant:"destructive",size:"sm",className:"h-5 gap-1 rounded-sm px-1.5 text-[8px] [&_svg]:size-3",children:[e.jsx(kr,{}),"Delete"]})}),e.jsxs(qt,{children:[e.jsxs(Vt,{children:[e.jsxs(Ht,{children:["Delete ",je," selected task",je!==1?"s":""," and saved logs?"]}),e.jsx(Kt,{children:"This cannot be undone. Cancel unless you are certain every selected task and log should be removed now."})]}),e.jsxs(Gt,{children:[e.jsx(Wt,{autoFocus:!0,children:"Cancel"}),e.jsx(Qt,{onClick:J,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(X,{onClick:()=>ee("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(Ln,{className:"h-3.5 w-3.5"}),"New chat"]}),e.jsxs(X,{variant:"outline",onClick:()=>ee("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(Ar,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Load session"]})]}),e.jsx(X,{variant:"ghost",size:"icon",onClick:()=>ie(U=>!U),className:L("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(fu,{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($e,{value:i,onValueChange:U=>M(U),children:[e.jsx(qe,{className:Hn,children:e.jsx(Je,{})}),e.jsx(Ve,{children:Lc.map(U=>e.jsx(Oe,{value:U.value,className:Kn,children:U.label},U.value))})]}),e.jsxs($e,{value:c,onValueChange:D,children:[e.jsx(qe,{className:Hn,children:e.jsx(Je,{placeholder:"Node"})}),e.jsx(Ve,{children:p.map(U=>e.jsx(Oe,{value:U.value,className:Kn,children:U.label},U.value))})]}),e.jsxs($e,{value:l,onValueChange:B,children:[e.jsx(qe,{className:Hn,children:e.jsx(Je,{placeholder:"Agent"})}),e.jsx(Ve,{children:m.map(U=>e.jsx(Oe,{value:U,className:Kn,children:U==="all"?"All agents":U},U))})]}),e.jsxs($e,{value:d,onValueChange:U=>_(U),children:[e.jsx(qe,{className:Hn,children:e.jsx(Je,{placeholder:"Type"})}),e.jsx(Ve,{children:Bc.map(U=>e.jsx(Oe,{value:U.value,className:Kn,children:U.label},U.value))})]})]})]}),e.jsx("div",{className:L("scrollbar-line min-h-0 flex-1 overflow-y-auto pl-2.5 pr-1.5 py-2",Ke&&"scrollbar-line-active"),onScroll:He,children:ve.length>0?e.jsx("div",{className:"space-y-1",children:ve.map(U=>{const ze=U.nodeId??"__unassigned__",Ie=U.dirs.reduce((xe,me)=>xe+me.tasks.length,0),We=pt&&!pn&&be.has(ze),Qe=U.nodeId!==null&&f.get(U.nodeId)==="offline",sn=!!(a&&U.nodeId);return e.jsxs("div",{className:"space-y-1",children:[pt&&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=>{!sn||!U.nodeId||(xe.preventDefault(),xe.stopPropagation(),ft(U.nodeId),De({left:xe.clientX,top:xe.clientY}))},children:[e.jsxs("button",{type:"button",onClick:()=>wt(ze),"aria-expanded":!We,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm px-2 py-1.5 text-left",children:[e.jsx(nt,{className:L("h-3.5 w-3.5 shrink-0 transition-transform duration-200",!We&&"rotate-90")}),e.jsx(ts,{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(Le,{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:[Ie," task",Ie===1?"":"s"]})]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[Qe&&e.jsx(Le,{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(Le,{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"})]})]}),sn&&U.nodeId&&e.jsx("span",{className:"flex shrink-0 items-center pr-1.5",children:e.jsx(Br,{nodeId:U.nodeId,nodeName:U.nodeName,node:U.nodeId?j?.get(U.nodeId):void 0,contextOpen:Ae===U.nodeId,contextPosition:Ae===U.nodeId?Re:null,onContextOpenChange:xe=>{xe||Fe()},onOpenSettings:S,onOpenServicePreview:()=>q({id:U.nodeId,name:U.nodeName}),onOpenCapabilities:Q,onOpenDevBox:te,onStartDevBox:R,showConfigureDevBox:w.has(U.nodeId),showStartDevBox:b.has(U.nodeId)||k.has(U.nodeId),startDevBoxPending:k.has(U.nodeId)})})]}),e.jsx("div",{className:L("grid transition-[grid-template-rows] duration-300 ease-in-out",We?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:"overflow-hidden",children:U.dirs.map(xe=>{const me=`${ze}::${xe.path}`,ke=_e.has(me),Ge=Bo(xe.path),Ue=g?.get(me),zt=Ue?{visibleTasks:sl(xe.tasks),hiddenCompletedCount:Math.max(0,Ue.total-Ue.returned)}:fp(xe.tasks,re.has(me),n),{visibleTasks:ls,hiddenCompletedCount:bn}=zt;return e.jsxs("div",{className:L("space-y-0.5 rounded-xl",pt&&"pl-2.5"),children:[e.jsx(mp,{dirPath:xe.path,label:Ge,taskCount:xe.tasks.length,tasks:xe.tasks,unloadedCompletedCount:Ue?Math.max(0,Ue.total-Ue.returned):0,nodeId:U.nodeId,nodeName:U.nodeName,nodeStatus:U.nodeId?f.get(U.nodeId):void 0,collapsed:ke,onToggle:()=>xn(me),onCreateTask:()=>ee("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:L("grid transition-[grid-template-rows] duration-300 ease-in-out",ke?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:L("overflow-hidden",pt?"pl-2":"pl-0"),children:e.jsxs("div",{className:"space-y-px py-0.5",children:[ls.map(Ee=>{const rn=Ee.id===n,It=Ee.assignedTo?f.get(Ee.assignedTo):void 0,vn=!!Ee.assignedTo&&(It?It==="offline":Ee.assignedNodeAvailable===!1),cs=$i(Ee),ds=Pn(Ee);return e.jsxs("div",{onContextMenu:it=>{it.preventDefault(),it.stopPropagation(),ye(Ee.id),Ze({left:it.clientX,top:it.clientY})},className:L("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",rn?'bg-primary/10 before:absolute before:left-0 before:top-1/2 before:h-1/2 before:w-[2px] before:-translate-y-1/2 before:rounded-full before:bg-primary before:content-[""]':"hover:bg-muted/40"),children:[Be&&e.jsx("div",{className:"flex shrink-0",onClick:it=>it.stopPropagation(),children:e.jsx(_n,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:v.has(Ee.id),onCheckedChange:it=>P(Ee.id,it===!0),"aria-label":`Select ${Ee.title}`})}),e.jsxs("button",{type:"button",onClick:()=>F(Ee.id),"aria-current":rn?"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:[ds&&e.jsx("span",{role:"img","aria-label":"Pinned to top",title:"Pinned to top",className:"flex shrink-0",children:e.jsx(Xo,{className:"h-2.5 w-2.5 -rotate-45 text-primary"})}),e.jsx("span",{className:L("min-w-0 flex-1 truncate text-[10px] font-medium leading-4",rn?"text-foreground":"text-foreground/80"),children:Ee.title})]}),e.jsx("span",{className:L("absolute right-0 top-0 shrink-0 tabular-nums text-[8px] leading-4",rn?"text-primary/75":"text-muted-foreground/55"),children:Oc(Ee.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:cs}),Ee.activeShare&&e.jsx(Le,{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"}),vn&&e.jsx(Le,{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(Io,{status:Ee.status,isNative:Ee.conversationKind==="nativeSession",size:"compact",className:"absolute bottom-1 right-0"})]}),e.jsx(xp,{task:Ee,contextOpen:ae===Ee.id,contextPosition:ae===Ee.id?pe:null,onContextOpenChange:it=>{it||nn()},onUpdateTitle:St?Y:void 0,onDeleteTask:St?V:void 0,onArchiveTask:St?ne:void 0,onTogglePinned:St?$:void 0})]},Ee.id)}),bn>0&&e.jsxs("button",{type:"button",onClick:()=>{Ue&&H?H(Ue):gn(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 ${bn} more completed tasks in ${Ge}`,children:[e.jsx(st,{className:"h-3 w-3"}),"Load ",bn," more completed"]})]})})})]},me)})})})]},ze)})}):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."})}),en?e.jsx("div",{className:"shrink-0 px-2.5 pb-2.5 pt-1.5",children:Be&&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:[yt,e.jsx(X,{variant:"ghost",size:"sm",onClick:Ct,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:ot}),Tt]})]}):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:ot}),Be&&e.jsx(X,{variant:"ghost",size:"sm",onClick:Ct,className:"h-5 shrink-0 rounded-sm px-1.5 text-[9px]",children:"Done"})]})}):null]}),e.jsx(Qf,{node:se,open:se!==null,onOpenChange:U=>{U||q(null)}})]})}async function bp(t,n){try{const s=await Fc(t,n),r={...s,url:Do(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 vp(t){try{return await zc(t),ce.success("Shared link stopped"),!0}catch(n){return ce.error(n instanceof Error?n.message:"Failed to stop shared link"),!1}}function wp(t,n,s){const r=o.useCallback(()=>{n(),s()},[n,s]),a=o.useCallback(async l=>{if(!t)return;const c=await bp(t.id,l);return c&&r(),c},[t,r]),i=o.useCallback(async()=>{if(!t)return!1;const l=await vp(t.id);return l&&r(),l},[t,r]);return{handleShareTask:a,handleStopShareTask:i}}function io(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?.())},p=t?.current??document;return p.addEventListener("touchstart",d,{passive:!0}),p.addEventListener("touchend",m,{passive:!0}),()=>{p.removeEventListener("touchstart",d),p.removeEventListener("touchend",m)}},[t,s?.threshold,s?.maxVertical])}const yp="(min-width: 1024px)",jp="(min-width: 1800px)";function lo(t){return globalThis.window?.matchMedia?.(t)?.matches??!1}function Np(){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 kp(){const[t,n]=o.useState(()=>Uc(Jr(),$c({operationsOpen:lo(jp)}))),[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(()=>{qc(Jr(),t)},[t]);const p=o.useCallback((w,b)=>{n(k=>{const y=k.layout[w],x=typeof b=="function"?b(y):b;return x===y?k:{...k,layout:{...k.layout,[w]:x}}})},[]),u=o.useCallback(w=>{p("desktopTasksOpen",w)},[p]),h=o.useCallback(w=>{p("operationsOpen",w)},[p]);io(i,{onSwipeLeft:()=>r(!1)}),io(l,{onSwipeRight:()=>h(!1)});const f=o.useCallback(()=>{if(lo(yp)){u(w=>!w);return}r(w=>!w)},[u]);o.useEffect(()=>{const w=k=>{const y=a.current;if(!y)return;k.preventDefault();const x=Hc(y.panel,y.startSize,y.startClientX,y.startClientY,k.clientX,k.clientY,y.rootFontSize);n(v=>({...v,sizes:{...v.sizes,[y.panel]:x}}))},b=()=>{a.current=null};return globalThis.window?.addEventListener("pointermove",w),globalThis.window?.addEventListener("pointerup",b),globalThis.window?.addEventListener("pointercancel",b),()=>{globalThis.window?.removeEventListener("pointermove",w),globalThis.window?.removeEventListener("pointerup",b),globalThis.window?.removeEventListener("pointercancel",b)}},[]);const j=o.useCallback((w,b)=>{b.preventDefault(),b.currentTarget.setPointerCapture?.(b.pointerId),a.current={panel:w,startSize:m[w],startClientX:b.clientX,startClientY:b.clientY,rootFontSize:Np()}},[m]),g=o.useCallback((w,b)=>{b.preventDefault(),n(k=>({...k,sizes:{...k.sizes,[w]:Vc(w,k.sizes[w],b.deltaY)}}))},[]);return{desktopTasksOpen:c,mobileTasksPanelOpen:s,mobileTasksPanelRef:i,operationsOpen:d,operationsPanelRef:l,panelResize:{sizes:{tasks:bs(m.tasks),operations:bs(m.operations),terminal:bs(m.terminal)},onPointerDown:j,onWheel:g},setMobileTasksPanelOpen:r,setOperationsOpen:h,toggleTasksPanel:f}}function Sp(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 Cp="notify_desktop_task";function Tp(t=al()){const n=t?.__TAURI__?.core?.invoke;return typeof n=="function"?n:null}async function Ap(t,n=al()){const s=Tp(n);return s?(await s(Cp,t),!0):!1}function Ep(t,n){const s=[];for(const r of n){const a=Mp(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 Mp(t){return t==="completed"||t==="failed"?t:null}function al(){return typeof window>"u"?null:window}function Dp({isLeader:t,selfId:n}){return{...!t&&n?{assignedTo:n}:{},completedLimitPerProject:Nr}}function xr(t){return`${t.assignedTo??"__unassigned__"}::${t.projectPath}`}function _p(t,n,s,r,a){if(xr(t)!==xr(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 Pp(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 Ip(t,n,s=new Set){return!n||s.has(n.id)||t.some(r=>r.id===n.id)?t:Mr(t,n)}function Rp({isLeader:t,selfId:n,sseConnected:s,preservedTask:r,subscribe:a}){const[i,l]=o.useState([]),[c,d]=o.useState([]),[m,p]=o.useState(!0),[u,h]=o.useState(null),f=o.useRef(new Set),j=o.useRef(null),g=o.useRef(null),w=o.useCallback(async()=>{try{const x=await Zr(Dp({isLeader:t,selfId:n}));l(Ip(x.tasks,r,f.current)),d(x.completedGroups??[]),h(null)}catch(x){h(x instanceof Error?x.message:"Failed to load tasks")}finally{p(!1)}},[t,r,n]),b=o.useCallback(async x=>{if(!x.hasMore||!x.nextCursor)return;const v=await Zr({status:"completed",assignedTo:x.assignedTo??"__unassigned__",projectPath:x.projectPath,cursor:x.nextCursor,limit:Nr});l(N=>Pp(N,v.tasks)),d(N=>N.map(A=>_p(A,x,i,v.tasks,v)))},[i]),k=o.useCallback(()=>{g.current===null&&(g.current=window.setTimeout(()=>{g.current=null,w()},Kc))},[w]),y=o.useCallback(x=>{const v=new Set(x);if(v.size!==0){for(const N of v)f.current.add(N);l(N=>N.filter(A=>!v.has(A.id)))}},[]);return Gc(w,Yc(s)),o.useEffect(()=>()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),o.useEffect(()=>{const x=j.current;if(x)for(const v of Ep(x,i))Ap(v).catch(()=>{});j.current=new Map(i.map(v=>[v.id,v]))},[i]),o.useEffect(()=>{const x=[a("task.updated",v=>{l(N=>Sp(N,v.data))}),a("task.status",v=>{l(N=>Wc(N,v.data))}),a("node",v=>{Xr(v.type)&&k()}),a("task",v=>{if(v.type==="task.deleted"){const N=v.data.taskId;typeof N=="string"&&f.current.add(N),l(A=>Qc(A,v.data))}Xr(v.type)&&k()})];return()=>x.forEach(v=>v())},[a,k]),{completedGroups:c,fetchTasks:w,loadCompletedTasksPage:b,removeTasksFromList:y,setTasks:l,tasks:i,tasksError:u,tasksLoading:m}}function zr(t){return t.map(n=>({...n}))}function Lp(t,n){const s=n.get(t);return{logs:s?zr(s.logs):[],transcriptLoading:s?.loaded!==!0}}function Bp(t,n){return n.data.nodeId===t.self.id||n.data.name===t.self.name||n.data.endpoint===t.self.endpoint}function Op(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 Fp({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=Op(r,s),i=Bp(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 zp({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 Up({activeTaskId:t,cacheTranscript:n,fetchActiveLogs:s,fetchActiveTask:r,logs:a,setLogs:i,setPendingMessages:l,setTranscriptLoading:c,sseConnected:d,subscribe:m}){const p=o.useRef([]),u=o.useRef(d),h=o.useRef(!1),f=o.useRef(!1),j=o.useRef(void 0);o.useEffect(()=>{p.current=zr(a)},[a]);const g=o.useCallback(w=>{if(h.current){f.current=!0,w!==void 0&&(j.current=Math.max(j.current??0,w));return}const b=zp({localCount:p.current.length,checkpointTotal:w});b&&(h.current=!0,s(b).finally(()=>{if(h.current=!1,!f.current)return;f.current=!1;const k=j.current;j.current=void 0,g(k)}))},[s]);o.useEffect(()=>{if(t)return m("task",w=>{const b=w.data.taskId;if(!(typeof b!="string"||b!==t)){if(w.type==="task.output"){const k=w.data.event;if(k){i(x=>{const v=Ud(x,k);return n(t,v),v}),c(!1);const y=Cr(k);y&&l(x=>$d(x,y))}}if(w.type==="task.updated"&&r(),w.type==="task.logs.ready"){const k=w.data.total;g(typeof k=="number"?k:void 0)}w.type==="task.status"&&(r(),g())}})},[t,n,s,r,g,i,l,c,m]),o.useEffect(()=>{const w=u.current;u.current=d,!w&&d&&t&&g()},[t,g,d])}const $p=[0,300,1e3,2e3];function qp({task:t,getActiveTaskId:n,setLogs:s,setPendingMessages:r,setTranscriptLoading:a}){t.conversationKind==="nativeSession"&&(async()=>{try{for(const i of $p){if(i>0&&await new Promise(l=>setTimeout(l,i)),n()!==t.id)return;try{const l=await sr(t.id);if(n()!==t.id||(s(c=>Ko(c,l.logs)),r(c=>ar(c,l.logs)),l.total>0))return}catch{}}}finally{n()===t.id&&a?.(!1)}})()}const ol=8;function Vp(t,n){return Ye(t??{})===Ye(n??{})}function Hp(t){return t&&"status"in t&&typeof t.status=="string"?t.status:void 0}function co(t,n){return{...t,enabled:!0,alwaysOnline:n}}function il(t){return t?.status?.trim()||t?.lastStatus?.trim()||"Unknown"}function Kp({operationStarting:t,loading:n,refreshing:s,savedStatus:r,fallbackStatus:a}){return t?"Starting":n?"Listing DevBoxes":s?"Refreshing":r??a}async function Gp(t,n=Oo){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,ol)}function Wp(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Qp(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 Yp(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function uo(t,n){const r=Yp(t)?.[n];return typeof r=="string"&&r.trim()?r.trim():null}function Jp(t){if(t.status==="failed")return t.error||"Operation failed";const n=uo(t.result,"operationId");if(n)return`MCP operation ${n}`;const s=uo(t.payload,"previousStatus");return s?`Previous DevBox status: ${s}`:t.status==="succeeded"?"Completed":"Waiting for completion"}function Zp(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 mo({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:il(t)})]})}function Xp({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(st,{className:L("h-3 w-3 shrink-0 text-muted-foreground transition-transform",!r&&"-rotate-90")}),e.jsx(Jn,{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=Jp(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:Qp(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:L("shrink-0 rounded-sm border px-1.5 py-0 text-[10px] leading-4",Zp(i.status)),children:Wp(i.status)})]},i.id)})]})]})}function ex({node:t,open:n,startInProgress:s=!1,onOpenChange:r,onRefresh:a}){const i=t?.id??null,l=n&&!s&&Ja(t?.status,t?.devbox??null),[c,d]=o.useState([]),[m,p]=o.useState(()=>t?.devbox?Ye(t.devbox):""),[u,h]=o.useState(()=>t?.devbox??null),[f,j]=o.useState(()=>Za(t?.devbox??null)),[g,w]=o.useState(!1),[b,k]=o.useState(l),[y,x]=o.useState(!1),[v,N]=o.useState(!1),[A,E]=o.useState(()=>t?.devbox?.alwaysOnline===!0),[M,B]=o.useState(!1),[D,_]=o.useState([]),[P,O]=o.useState(!1),[W,J]=o.useState(null),Y=o.useMemo(()=>{const q=c.find(ae=>Ye(ae)===m);return q||(dn(u)&&Ye(u)===m?u:void 0)},[u,c,m]),V=Hp(Y??void 0),ne=f?V??u?.lastStatus:u?.lastStatus??V,$=t?.status==="online"||t?.status==="busy"?"Running":"Unknown",ee=v||s,S=Kp({operationStarting:ee,loading:g,refreshing:b,savedStatus:ne,fallbackStatus:$}),Q=f&&!!Y&&!Vp(u,Y),T=u?.alwaysOnline===!0!==A,te=qf({nodeStatus:t?.status,status:S,current:u,selected:Y}),R=!!te,H=!!Y&&(Q||T)&&!R,F=Y??u,le=o.useCallback(async()=>{if(i){k(!0);try{const q=await Jc(i);h(q.devbox),p(Ye(q.devbox))}catch(q){ce.error(q instanceof Error?q.message:"Failed to refresh DevBox status")}finally{k(!1)}}},[i]),ie=o.useCallback(async q=>{w(!0);try{const ae=await Zc();d(ae),p(ye=>Vf({previousKey:ye,baseDevBox:q,listed:ae}))}catch(ae){ce.error(ae instanceof Error?ae.message:"Failed to load DevBoxes")}finally{w(!1)}},[]);o.useEffect(()=>{if(!n||!i)return;let q=!1;const ae=t?.devbox??null,ye=Za(ae),pe=!s&&Ja(t?.status,ae);w(!1),k(pe),j(ye),h(ae),E(ae?.alwaysOnline===!0),B(!1),p(dn(ae)?Ye(ae):""),d([]);async function Ze(){pe&&await le(),!q&&ye&&await ie(ae)}return Ze(),()=>{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(){O(!0),J(null),_([]);try{const pe=await Gp(ae);if(q)return;_(pe)}catch(pe){if(q)return;_([]),J(pe instanceof Error?pe.message:"Failed to load operation history")}finally{q||O(!1)}}return ye(),()=>{q=!0}},[i,n]);async function ue(){j(!0),c.length===0&&await ie(u)}async function Z(){if(!(!t||!Y)){x(!0);try{const q=await ea(t.id,co(Y,A));h(q.node.devbox??null),q.node.devbox&&p(Ye(q.node.devbox)),j(!1),ce.success(`Configured DevBox for ${t.name}`),await a?.()}catch(q){ce.error(q instanceof Error?q.message:"Failed to configure DevBox")}finally{x(!1)}}}async function K(){if(!(!t||!te)){N(!0);try{if(Y&&(Q||T)){const ae=await ea(t.id,co(Y,A));h(ae.node.devbox??null),ae.node.devbox&&p(Ye(ae.node.devbox)),j(!1)}const{operation:q}=await Fo(t.id);h(ae=>ae&&{...ae,lastStatus:"Starting",checkedAt:Date.now(),operationId:q.id}),_(ae=>[q,...ae.filter(ye=>ye.id!==q.id)].slice(0,ol)),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 I=g?"Loading DevBoxes...":c.length===0?"No DevBoxes available":"Select a DevBox",se=S==="Running"&&t?.status==="offline";return e.jsx(mt,{open:n,onOpenChange:r,children:e.jsxs(ht,{className:"w-[calc(100vw-2rem)] max-w-md grid-cols-[minmax(0,1fr)] gap-3 overflow-hidden rounded-sm p-4",children:[e.jsxs(Mt,{className:"min-w-0 max-w-full space-y-1 overflow-hidden",children:[e.jsx(vt,{className:"text-sm",children:"Configure DevBox"}),e.jsxs(Dt,{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||F)&&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($e,{value:m,onValueChange:p,disabled:g||y||v||c.length===0,children:[e.jsx(qe,{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"}),I]}):Y?e.jsx(mo,{devbox:Y}):e.jsx(Je,{placeholder:I})}),e.jsx(Ve,{children:c.map(q=>e.jsx(Oe,{value:Ye(q),textValue:`${q.name} ${q.projectName??""} ${il(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(mo,{devbox:q,showStatus:!0})},Ye(q)))})]}):F&&e.jsxs("div",{className:"min-w-0 truncate",children:[e.jsx("span",{className:"font-medium text-foreground",children:F.name}),F.projectName&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",F.projectName]})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(Le,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px]",children:[(g||b)&&e.jsx(he,{className:"mr-1 h-2.5 w-2.5 animate-spin"}),S]}),u?.name&&e.jsx(X,{type:"button",variant:"ghost",size:"icon",onClick:()=>{ue()},disabled:g||y||ee||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(Jt,{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(_n,{checked:A,onCheckedChange:q=>E(q===!0),disabled:y||v||ee,"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(Xp,{error:W,loading:P,onToggle:()=>B(q=>!q),open:M,operations:D})]}),e.jsxs(br,{className:"gap-2 sm:space-x-0",children:[e.jsx(X,{variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:y||v,className:"h-8 rounded-sm text-xs",children:"Close"}),R&&e.jsxs(X,{size:"sm",onClick:K,disabled:v,className:"h-8 rounded-sm text-xs",children:[v?e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ss,{className:"h-3.5 w-3.5"}),"Start DevBox"]}),!R&&e.jsxs(X,{size:"sm",onClick:Z,disabled:!H||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 tx(t,n=Oo){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 nx({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),p=o.useMemo(()=>t?.nodes.find(b=>b.id===s)??null,[t?.nodes,s]),u=o.useMemo(()=>new Set((t?.nodes??[]).filter(b=>b.devbox?.enabled).map(b=>b.id)),[t?.nodes]),h=o.useMemo(()=>new Set((t?.nodes??[]).filter(b=>is(b.status,b.devbox?.lastStatus,b.devbox)).map(b=>b.id)),[t?.nodes]),f=o.useMemo(()=>new Set((t?.nodes??[]).filter(b=>un(b.devbox?.lastStatus)).map(b=>b.id)),[t?.nodes]),j=o.useMemo(()=>{const b=new Set(l);a&&b.add(a);for(const k of d)b.add(k);for(const k of f)b.add(k);return b},[d,a,l,f]);o.useEffect(()=>{let b=!1;const k=[...u];async function y(){try{const x=await tx(k);b||m(x)}catch{b||m(new Set)}}return y(),()=>{b=!0}},[u]),o.useEffect(()=>{c(b=>{let k=!1;const y=new Set(b);for(const x of b){const v=t?.nodes.find(N=>N.id===x);v?.status!=="online"&&(!v?.devbox?.lastStatus||un(v.devbox.lastStatus))||(y.delete(x),k=!0)}return k?y:b})},[t?.nodes]);const g=o.useCallback(async b=>{const k=t?.nodes.find(y=>y.id===b);if(k){i(b),c(y=>new Set(y).add(b));try{await Fo(b),ce.success(`Start requested for ${k.name}`),n()}catch(y){c(x=>{const v=new Set(x);return v.delete(b),v}),ce.error(y instanceof Error?y.message:"Failed to start DevBox")}finally{i(null)}}},[t?.nodes,n]);return{devBoxDialog:e.jsx(ex,{node:p,open:s!==null,startInProgress:p?j.has(p.id):!1,onOpenChange:b=>{b||r(null)},onRefresh:n}),devBoxNodeIds:u,devBoxStartNodeId:a,devBoxStartNodeIds:h,devBoxStartingNodeIds:j,openDevBox:r,startDevBox:g}}function sx(t){const[n,s]=o.useState(null),r=o.useCallback(i=>{t&&s(i)},[t]);return{nodeSettingsDialog:e.jsx(Xc,{open:n!==null,onOpenChange:i=>{i||s(null)},initialSelectedNodeId:n??void 0,showTrigger:!1}),openNodeSettings:r}}function rx(t=!1){return!t}function ax({activeTaskId:t,fetchActiveTask:n,isRunning:s=!1,setPendingMessages:r,setTask:a,setTasks:i}){const l=o.useCallback((m,p)=>{a(u=>u&&u.id===m?{...u,queuedMessages:p}:u),i(u=>u.map(h=>h.id===m?{...h,queuedMessages:p}:h))},[a,i]),c=o.useCallback(async(m,p={})=>{if(!t)return!1;const u=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`,h=rx(s);h&&r(f=>[...f,{id:u,content:m,timestamp:new Date().toISOString()}]);try{const f=p.targetAgent?await ta(t,m,p.targetAgent):await ta(t,m);return f.queued&&(h&&r(j=>j.filter(g=>g.id!==u)),f.queuedMessages&&l(t,f.queuedMessages)),n(),!0}catch(f){return h&&r(j=>j.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 p=await ed(t,m);l(t,p.queuedMessages),n()}catch(p){ce.error(p instanceof Error?p.message:"Failed to cancel queued message")}},[t,n,l]),queueFollowUpMessage:c}}const ho="grid-cols-[1.5rem_5.25rem_4rem_minmax(8rem,1fr)_4rem_4rem_6rem]",ox={claudecode:"Claude Code",codex:"Codex",copilot:"Copilot"};function ix(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 ll(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 lx({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:L("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",ho),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:L("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",ho,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(_n,{className:"h-3 w-3",checked:n.has(i.id),onCheckedChange:l=>r(i.id,l===!0),"aria-label":`Select ${i.name}`})}),e.jsx(cx,{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:ll(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 cx({agent:t}){const n=ox[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 fo=320,po=560,cl=384,xo=360;function dx(t,n=po+xo){const s=Math.max(fo,Math.min(po,n-xo));return Math.min(Math.max(Math.round(t),fo),s)}function ux(t,n,s,r){return dx(t+n-s,r)}function mx({detail:t,deleting:n=!1,onDelete:s,desktopWidth:r=cl,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(Le,{variant:"secondary",className:"rounded-sm border-0 bg-card/72 px-1.5 py-0 text-[8px] text-primary",children:t.agent}),e.jsx(Le,{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($t,{children:[e.jsx(nr,{asChild:!0,children:e.jsx(X,{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(kr,{className:"h-3.5 w-3.5"})})}),e.jsxs(qt,{className:"max-w-[22rem] gap-2 rounded-xl p-4",children:[e.jsxs(Vt,{className:"space-y-1",children:[e.jsxs(Ht,{className:"text-sm",children:["Delete ",t.name,"?"]}),e.jsxs(Kt,{className:"text-[11px] leading-4",children:["This removes the selected ",t.kind," from ",t.scope.kind==="global"?"the user profile":"this project","."]})]}),e.jsxs(Gt,{className:"gap-1 pt-0 sm:space-x-1",children:[e.jsx(Wt,{className:"h-7 rounded-lg px-2 text-[11px]",children:"Cancel"}),e.jsx(Qt,{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(Gn,{label:"Version",value:t.version??"-"}),e.jsx(Gn,{label:"Size",value:ll(t)}),e.jsx(Gn,{label:"Files",value:String(t.fileCount)}),e.jsx(Gn,{label:"Source",value:t.source??"local"})]}),e.jsxs(_r,{defaultValue:l,className:"mt-2 flex min-h-0 flex-1 flex-col",children:[e.jsxs(os,{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(bt,{value:"mcp",className:"mt-2 min-h-0 flex-1 overflow-auto",children:e.jsx(hx,{detail:t})}):e.jsx(bt,{value:"files",className:"mt-2 min-h-0 flex-1 overflow-auto",children:e.jsx(fx,{detail:t})}),e.jsx(bt,{value:"readme",className:"mt-2 min-h-0 flex-1 overflow-auto",children:t.readmeMarkdown?e.jsx(Wd,{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(Ur,{children:"No README content."})})]},t.id)]})}function hx({detail:t}){const n=t.mcpPreview??[];return n.length===0?e.jsx(Ur,{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 fx({detail:t}){const n=t.fileTree??[];return n.length===0?e.jsx(Ur,{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 Ur({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 Gn({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 px=20,xx=288,gx=360,bx=440;function vx(){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 wx({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,p=s.bottom-d,u=s.left+d,h=s.right-d,f=Math.max(0,p-t.bottom-4),j=Math.max(0,t.top-m-4),g=r?j<140&&f>j:f>=220||f>=j,w=g?f:j,b=Math.max(140,p-m),k=r&&a,v=Math.min(b,k?bx:320,Math.max(k?gx:140,w)),N=xx*c,A=i==="end"?t.right-N:t.left,M=(Math.max(u,Math.min(A,h-N))-n.left)/c;if(!g&&!k)return{left:M,bottom:(n.bottom-(t.top-4))/c,maxHeight:v/c};const B=g?t.bottom+4:t.top-v-4,D=Math.max(m,Math.min(B,p-v));return{left:M,top:(D-n.top)/c,maxHeight:v/c}}function $r(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(ul(a)?a:ml(t.workDir,a));return n}function yx(t,n){if(t.kind==="global")return{nodeId:n.id,scope:{kind:"global"}};const s=$r(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 jx(t,n){return{nodeId:t,scope:n}}function go(t,n,s){const r=n.trim();return!r||r==="."?t.workDir??r:s||ul(r)?r:t.workDir?ml(t.workDir,r):r}function Nx({node:t,scope:n,clusterNodes:s,onSelectionChange:r}){const a=o.useMemo(()=>Tx(s,t),[s,t]),i=o.useMemo(()=>$r(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(Cx,{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?.(yx(n,d))}}),e.jsx(dl,{node:t,projectPaths:i,selectedScope:n,onSelect:c=>r?.(jx(t.id,c))}),e.jsx(kx,{node:t})]})}function kx({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:L("h-1.5 w-1.5 shrink-0 rounded-full",An(t.status))})]})}function dl({node:t,projectPaths:n,selectedScope:s,onSelect:r,compact:a=!1,portal:i=!1,portalAlign:l="start"}){const[c,d]=o.useState(!1),[m,p]=o.useState(null),[u,h]=o.useState(!1),[f,j]=o.useState(!1),[g,w]=o.useState(null),[b,k]=o.useState(!1),[y,x]=o.useState(null),v=o.useRef(null),N=o.useRef(null),A=o.useRef(null),E=o.useMemo(()=>n.map($=>({value:$,label:vo($),description:$})),[n]),M=s.kind==="project"?s.projectPath:void 0,B=s.kind==="global"?"Global":vo(s.projectPath),D=s.kind==="global"?"Global":s.projectPath,_=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(),ee=_(),S=ee&&ee!==document.body?ee.getBoundingClientRect():{left:0,top:0,bottom:window.innerHeight};x(wx({triggerRect:$,targetRect:S,viewportRect:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight},compact:a,browserOpen:b,portalAlign:l,cssZoom:vx()}))},[b,a,_,i,l]);o.useEffect(()=>{c||k(!1)},[c]),o.useEffect(()=>{if(!c)return;const $=ee=>{if(!(ee.target instanceof Node))return;const S=ee.composedPath(),Q=v.current?S.includes(v.current):!1,T=A.current?S.includes(A.current):ee.target instanceof Element&&!!ee.target.closest('[data-capability-scope-menu="true"]');!Q&&!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 O=async($,ee=0,S=!1)=>{if(t.workDir){w(null),S?j(!0):h(!0);try{const Q=await Eo(t.id,{path:$||".",limit:px,offset:ee,directoriesOnly:!0,allowAbsolute:!0});p(T=>S&&T?{...Q,entries:[...T.entries,...Q.entries]}:Q)}catch(Q){w(Q instanceof Error?Q.message:"Failed to browse folders"),S||p(null)}finally{h(!1),j(!1)}}};o.useEffect(()=>{!c||!b||!t.workDir||(p(null),w(null),O(M||"."))},[b,c,t.id,t.workDir,M]);const W=($,ee=!1)=>{r({kind:"project",projectPath:go(t,$,ee)}),d(!1)},J=()=>{r({kind:"global"}),d(!1)},Y=m?go(t,m.currentPath,m.isAbsolute):M??t.workDir??"",V=i?_():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&&b?y.maxHeight:void 0,maxHeight:y.maxHeight}:void 0,className:L(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:L("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:L("overflow-y-auto pr-0.5",a?"max-h-32":"max-h-40"),children:[e.jsx(bo,{icon:"global",label:"Global",selected:s.kind==="global",onSelect:J,compact:a}),E.length>0?E.map($=>e.jsx(bo,{icon:"folder",label:$.label,description:$.description,selected:M===$.value,onSelect:()=>W($.value,!0),compact:a},$.value)):e.jsx("div",{className:L("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:L("border-b border-border/55",b?"flex min-h-0 flex-1 flex-col":"shrink-0"),children:[e.jsxs("button",{type:"button","aria-expanded":b,onClick:()=>k($=>!$),className:L("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(hn,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Browse folders"}),e.jsx(st,{className:L("h-3 w-3 shrink-0 transition-transform duration-200",b&&"rotate-180")})]}),b&&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 O(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(Wo,{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:()=>W(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:L("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(Sx,{entry:$,onSelect:()=>W($.path,m.isAbsolute),onOpen:()=>{O($.path)}},$.path)),m.hasMore&&e.jsxs("button",{type:"button",onClick:()=>{O(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(du,{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:v,className:"relative min-w-0",children:[e.jsxs("button",{ref:N,type:"button","aria-label":"Capability location","aria-expanded":c,title:D,onClick:()=>d($=>($||(k(!1),P()),!$)),className:L("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:L("block truncate font-medium text-foreground",a?"text-[9px] leading-3":"text-[10px] leading-4"),children:B})}),e.jsx(st,{className:L(a?"h-2.5 w-2.5":"h-3 w-3","shrink-0 text-muted-foreground transition-transform",c&&"rotate-180")})]}),i&&V?ns.createPortal(ne,V):ne]})}function bo({icon:t,label:n,description:s,selected:r,onSelect:a,compact:i=!1}){const l=t==="global"?iu:hn;return e.jsxs("button",{type:"button",onClick:a,className:L(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:L("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:L("block truncate text-muted-foreground",i?"text-[7px] leading-3":"text-[8px] leading-3"),children:s})]})]})}function Sx({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(hn,{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(nt,{className:"h-3 w-3"})})]})}function Cx({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=p=>{d.current&&p.target instanceof Node&&!d.current.contains(p.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(st,{className:L("h-3 w-3 shrink-0 text-muted-foreground transition-transform",l&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!l,className:L("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:L("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:L("h-1.5 w-1.5 shrink-0 rounded-full",An(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 Tx(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 An(t){return t==="online"?"bg-emerald-500":t==="offline"?"bg-muted-foreground/45":"bg-amber-500"}function vo(t){return t.split(/[\\/]+/).filter(Boolean).at(-1)??t}function ul(t){return t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t)}function ml(t,n){return`${t.replace(/[\\/]+$/,"")}/${n.replace(/^[\\/]+/,"")}`}const Ax="h-6 w-24 rounded-sm px-2 text-[10px] shadow-none",Zs="text-[10px]",hl=["claudecode","codex","copilot"],Tn={claudecode:"Claude Code",codex:"Codex",copilot:"Copilot"};function Ex({open:t,sourceNode:n,targetNodes:s,selectedCapabilities:r,previewResults:a=[],embedded:i=!1,onClose:l,onPreviewTargetsChange:c,onShare:d}){const[m,p]=o.useState(()=>new Set(a.length>0?a.map(S=>gt(S.nodeId,S.targetAgent)):Dx(n.id,s,r))),[u,h]=o.useState(()=>Object.fromEntries(_x(n.id,s,r))),[f,j]=o.useState({}),[g,w]=o.useState(!1),[b,k]=o.useState(()=>new Set),[y,x]=o.useState(()=>new Set),v=r.some(S=>S.kind==="plugin"),N=o.useMemo(()=>qr(r).map(S=>({key:gt(n.id,S),nodeId:n.id,node:n,label:`Install into ${Tn[S]}`,agentLabel:Tn[S],defaultScope:pl(r),disabled:!1,targetAgent:S})),[r,n]),A=o.useMemo(()=>s.flatMap(S=>{const Q={kind:"global"},T=S.status==="offline",te=fl(r);return te.length===0?[{key:gt(S.id),nodeId:S.id,node:S,label:S.name,defaultScope:Q,disabled:T}]:te.map(R=>({key:gt(S.id,R),nodeId:S.id,node:S,label:`${S.name} / ${Tn[R]}`,agentLabel:Tn[R],defaultScope:Q,disabled:T,targetAgent:R}))}),[r,s]),E=o.useMemo(()=>[...N,...A],[N,A]),M=o.useMemo(()=>s.map(S=>({node:S,options:A.filter(Q=>Q.nodeId===S.id)})).filter(S=>S.options.length>0),[s,A]),B=o.useMemo(()=>new Map(a.filter(S=>S.capabilityId).map(S=>[wo(S.nodeId,S.capabilityId,S.targetAgent),S])),[a]),D=o.useMemo(()=>new Map(a.map(S=>[gt(S.nodeId,S.targetAgent),S])),[a]),_=o.useMemo(()=>E.filter(S=>m.has(S.key)),[m,E]),P=o.useMemo(()=>_.map(S=>({nodeId:S.nodeId,scope:u[S.key]??S.defaultScope,...S.targetAgent?{targetAgent:S.targetAgent}:{}})),[_,u]),O=o.useMemo(()=>{const S=[],Q=new Map;for(const T of _){if(!Q.has(T.nodeId)){const te=T.nodeId===n.id?n:s.find(R=>R.id===T.nodeId);Q.set(T.nodeId,{nodeId:T.nodeId,node:te,name:te?.name??T.nodeId,options:[]}),S.push(T.nodeId)}Q.get(T.nodeId).options.push(T)}return S.map(T=>Q.get(T))},[_,n,s]),W=o.useMemo(()=>{const S=Array.from(new Set(r.map(T=>T.agent))),[Q]=S;if(Q)return S.length===1?Tn[Q]:`${S.length} agents`},[r]),J=M.length+1;o.useEffect(()=>{let S=!1;const Q={...u};for(const T of E)Q[T.key]||(Q[T.key]=T.defaultScope,S=!0);S&&h(Q)},[E,u]),o.useEffect(()=>{t&&c?.(P)},[t,c,P]),o.useEffect(()=>{t&&(k(new Set),x(new Set))},[t,n.id]),o.useEffect(()=>{if(!i||!t)return;const S=Q=>{Q.key==="Escape"&&l()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[i,l,t]);const Y=S=>{j(Object.fromEntries(_.map(Q=>[Q.key,S])))},V=async()=>{w(!0);try{await d(_.map(S=>({nodeId:S.nodeId,scope:u[S.key]??S.defaultScope,...S.targetAgent?{targetAgent:S.targetAgent}:{},conflictStrategy:f[S.key]??"overwrite"})))}finally{w(!1)}},ne=S=>{const Q=u[S.key]??S.defaultScope,T=`capability-share-target-${Mx(S.key)}`,te=m.has(S.key);return e.jsxs("div",{"data-target-agent":S.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":S.disabled?"true":void 0,children:[e.jsx(_n,{id:T,disabled:S.disabled,checked:te,onCheckedChange:R=>p(H=>{const F=new Set(H);return R===!0?F.add(S.key):F.delete(S.key),F}),"aria-label":`Select ${S.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":S.disabled?"true":void 0,children:S.agentLabel??S.label}),e.jsx("div",{className:"flex w-28 shrink-0 justify-end",children:te&&!S.disabled&&e.jsx(dl,{node:S.node,projectPaths:$r(S.node),selectedScope:Q,onSelect:R=>h(H=>({...H,[S.key]:R})),compact:!0,portal:!0,portalAlign:"end"})})]},S.key)},$=(S,Q,T,te)=>{const R=b.has(S.id),H=_.filter(F=>F.nodeId===S.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:()=>k(F=>yo(F,S.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(nt,{className:L("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",R&&"rotate-90")}),e.jsx("span",{className:L("h-1.5 w-1.5 shrink-0 rounded-full",An(S.status))}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold text-foreground",title:S.name,children:S.name}),H>0&&e.jsxs("span",{className:"shrink-0 text-[8px] font-medium text-primary",children:[H," selected"]}),e.jsx("span",{className:"shrink-0 text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:Q?"this node":"remote"}),S.status==="offline"&&e.jsx(Le,{variant:"outline",className:"rounded-sm px-1 py-0 text-[8px]",children:"offline"}),te>0&&e.jsxs("span",{className:"sr-only",children:[te," agents"]})]}),e.jsx("div",{className:L("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})})})]},S.id)},ee=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(Zn,{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:L("h-1.5 w-1.5 shrink-0 rounded-full",An(n.status))}),e.jsx("span",{className:"truncate font-semibold text-foreground",title:n.name,children:n.name}),W&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:["· ",W]})]}),e.jsx(ia,{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:_.length})," selected · ",J," ",J===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,v?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),M.map(S=>$(S.node,!1,S.options.map(ne),S.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(S=>e.jsx("button",{type:"button",onClick:()=>Y(S),className:"h-5 rounded-[3px] px-1.5 text-[9px] capitalize text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground",children:S},S))})]})]}),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:_.length===0?e.jsx("div",{className:"py-8 text-center text-[11px] text-muted-foreground",children:"Select a target to preview conflicts."}):O.map(S=>{const Q=!y.has(S.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":Q,onClick:()=>x(T=>yo(T,S.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(nt,{className:L("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",Q&&"rotate-90")}),S.node&&e.jsx("span",{className:L("h-1.5 w-1.5 shrink-0 rounded-full",An(S.node.status))}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[10px] font-semibold text-foreground",children:S.name}),e.jsxs("span",{className:"shrink-0 text-[8px] text-muted-foreground",children:[S.options.length," ",S.options.length===1?"agent":"agents"]})]}),e.jsx("div",{className:L("grid transition-[grid-template-rows] duration-200 ease-out",Q?"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:S.options.map(T=>{const te=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($e,{value:te,onValueChange:R=>j(H=>({...H,[T.key]:R})),children:[e.jsx(qe,{className:Ax,children:e.jsx(Je,{})}),e.jsxs(Ve,{className:"shadow-none",children:[e.jsx(Oe,{value:"overwrite",className:Zs,children:"Overwrite"}),e.jsx(Oe,{value:"skip",className:Zs,children:"Skip"}),e.jsx(Oe,{value:"abort",className:Zs,children:"Abort"})]})]})]}),e.jsx("div",{className:"space-y-px",children:r.map(R=>{const H=B.get(wo(T.nodeId,R.id,T.targetAgent))??(r.length===1?D.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:H?.conflict?"text-amber-500":H?"text-emerald-500":"text-muted-foreground",children:H?H.conflict?`exists${H.currentVersion?` v${H.currentVersion}`:""}`:"new install":"checking"}),H?.sourceVersion&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:[e.jsx(ia,{className:"inline h-2.5 w-2.5"})," v",H.sourceVersion]})]},R.id)})})]},T.key)})})})})]},S.nodeId)})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-border/55 px-4 py-3",children:[e.jsx(X,{variant:"ghost",onClick:l,className:"h-7 rounded-sm px-3 text-[11px]",children:"Cancel"}),e.jsxs(X,{onClick:V,disabled:g||_.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(Zn,{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:S=>{S.target===S.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:S=>S.stopPropagation(),children:[ee,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(ut,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})}):null:e.jsx(mt,{open:t,onOpenChange:S=>{S||l()},children:e.jsx(ht,{"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:ee})})}function gt(t,n){return n?`agent:${t}:${n}`:`node:${t}`}function Mx(t){return t.replace(/[^a-zA-Z0-9_-]/g,"-")}function wo(t,n,s){return`${gt(t,s)}\0${n}`}function yo(t,n){const s=new Set(t);return s.has(n)?s.delete(n):s.add(n),s}function Dx(t,n,s){const r=n.find(i=>i.status!=="offline");if(r)return[gt(r.id,Px(s))];const a=qr(s)[0];return a?[gt(t,a)]:[]}function _x(t,n,s){const r=fl(s);return[...n.flatMap(a=>r.length===0?[[gt(a.id),{kind:"global"}]]:r.map(i=>[gt(a.id,i),{kind:"global"}])),...qr(s).map(a=>[gt(t,a),pl(s)])]}function fl(t){return t.length===0||t.some(n=>n.kind==="plugin")?[]:hl}function Px(t){if(!(t.length===0||t.some(n=>n.kind==="plugin")))return t[0]?.agent}function qr(t){if(t.length===0||t.some(s=>s.kind==="plugin"))return[];const n=new Set(t.map(s=>s.agent));return hl.filter(s=>!n.has(s))}function pl(t){return t[0]?.scope??{kind:"global"}}const jo="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",Bt="py-0.5 pl-6 pr-1.5 text-[9px] leading-4 [&_svg]:h-3 [&_svg]:w-3",xl="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",Ix="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 Rx(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 Lx(t,n,s,r){return s.map(a=>({sourceNodeId:t,capabilityId:a.id,sourceScope:n,targets:r}))}function Bx({loading:t,onRefresh:n}){return e.jsxs(X,{variant:"ghost",onClick:n,disabled:t,"aria-busy":t,className:L(xl,"min-w-[4.5rem]"),children:[e.jsx(ni,{className:L("h-2.5 w-2.5",t&&"animate-spin")}),t?"Refreshing":"Refresh"]})}function Ox({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(X,{type:"button",variant:"ghost",onClick:s,disabled:t===0,className:xl,children:[e.jsx(ut,{className:"h-2.5 w-2.5"}),"Selected: ",t," / Clear"]})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Bx,{loading:n,onRefresh:r}),e.jsxs(X,{type:"button",variant:"ghost",onClick:a,disabled:t===0,className:Ix,children:[e.jsx(Zn,{className:"h-2.5 w-2.5"}),"Share"]})]})]})}function Fx({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 zx({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 Ux({open:t,node:n,scope:s,clusterNodes:r,onOpenChange:a,onSelectionChange:i}){const[l,c]=o.useState([]),[d,m]=o.useState([]),[p,u]=o.useState(!1),[h,f]=o.useState(""),[j,g]=o.useState("all"),[w,b]=o.useState("all"),[k,y]=o.useState(new Set),[x,v]=o.useState(null),[N,A]=o.useState(null),[E,M]=o.useState(!1),[B,D]=o.useState(null),[_,P]=o.useState(!1),[O,W]=o.useState([]),[J,Y]=o.useState(cl),[V,ne]=o.useState(null),$=o.useMemo(()=>ix(l,{search:h,agent:j,kind:w}),[j,l,w,h]),ee=o.useMemo(()=>l.filter(K=>k.has(K.id)),[l,k]),S=o.useMemo(()=>r.filter(K=>K.id!==n.id),[r,n.id]),Q=s.kind==="project"?s.projectPath:"global",T=async()=>{u(!0);try{const K=await nd(n.id,{scope:s});c(K.items),m((K.errors??[]).map(I=>`${I.agent}: ${I.message}`))}catch(K){m([K instanceof Error?K.message:"Failed to load capabilities"])}finally{u(!1)}};o.useEffect(()=>{t&&(y(new Set),v(null),A(null),M(!1),W([]),c([]),m([]),T())},[t,n.id,s.kind,Q]),o.useEffect(()=>{if(!V)return;const K=se=>{Y(ux(V.startWidth,V.startClientX,se.clientX,window.innerWidth))},I=()=>ne(null);return window.addEventListener("pointermove",K),window.addEventListener("pointerup",I),()=>{window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",I)}},[V]);const te=K=>{K.preventDefault(),ne({startClientX:K.clientX,startWidth:J})},R=()=>{ne(null),M(!1),v(null),A(null)},H=()=>{y(new Set),W([])},F=async K=>{v(K.id),M(!0),A(null);const I=await sd(n.id,K.id,s);A(I.detail)},le=o.useCallback(async K=>{if(ee.length===0||K.length===0){W([]);return}W([]);try{const I=Rx(n.id,s,ee,K),se=await Promise.all(I.map(q=>td(q)));W(se.flatMap((q,ae)=>q.results.map(ye=>({...ye,capabilityId:I[ae]?.capabilityId}))))}catch{W([])}},[n.id,s,ee]),ie=()=>{W([]),P(!0)},ue=async K=>{const I=Lx(n.id,s,ee,K);I.length!==0&&(await Promise.all(I.map(se=>ad(se))),ce.success(`${I.length} capability share request${I.length===1?"":"s"} completed`),P(!1))},Z=async()=>{if(!(!N||B)){D(N.id);try{const K=await rd(n.id,N.id,s);K.status==="deleted"?(ce.success(`Deleted ${N.name}`),c(I=>I.filter(se=>se.id!==N.id)),y(I=>{const se=new Set(I);return se.delete(N.id),se}),v(null),A(null),M(!1),await T()):(ce.info(K.message??"Capability was not found"),v(null),A(null),M(!1),await T())}catch(K){ce.error(K instanceof Error?K.message:"Failed to delete capability")}finally{D(null)}}};return e.jsx(e.Fragment,{children:e.jsx(mt,{open:t,onOpenChange:a,children:e.jsxs(ht,{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(Mt,{className:"border-b border-border/55 bg-card/28 px-4 py-2.5 text-left",children:[e.jsx(vt,{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(Nx,{node:n,scope:s,clusterNodes:r,onSelectionChange:i}),e.jsxs(Dt,{"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(Mo,{className:"pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-muted-foreground"}),e.jsx(dt,{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($e,{value:j,onValueChange:K=>g(K),children:[e.jsx(qe,{className:L("w-28",jo),children:e.jsx(Je,{})}),e.jsxs(Ve,{className:"shadow-none",children:[e.jsx(Oe,{value:"all",className:Bt,children:"Agent: All"}),e.jsx(Oe,{value:"claudecode",className:Bt,children:"Claude Code"}),e.jsx(Oe,{value:"codex",className:Bt,children:"Codex"}),e.jsx(Oe,{value:"copilot",className:Bt,children:"Copilot"})]})]}),e.jsxs($e,{value:w,onValueChange:K=>b(K),children:[e.jsx(qe,{className:L("w-24",jo),children:e.jsx(Je,{})}),e.jsxs(Ve,{className:"shadow-none",children:[e.jsx(Oe,{value:"all",className:Bt,children:"Kind: All"}),e.jsx(Oe,{value:"skill",className:Bt,children:"Skill"}),e.jsx(Oe,{value:"plugin",className:Bt,children:"Plugin"}),e.jsx(Oe,{value:"mcp",className:Bt,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(lx,{items:$,selectedIds:k,activeId:x,onToggleSelected:(K,I)=>y(se=>{const q=new Set(se);return I?q.add(K):q.delete(K),q}),onOpenDetail:F}),e.jsx(Ox,{selectedCount:k.size,loading:p,onClearSelection:H,onRefresh:T,onShare:ie}),e.jsx(zx,{visible:p&&l.length===0})]}),E&&e.jsxs(e.Fragment,{children:[e.jsx(Fx,{onBeginResize:te,onFold:R}),e.jsx(mx,{detail:N,deleting:B===N?.id,desktopWidth:J,onDelete:N?Z:void 0,pending:!N})]})]}),_&&e.jsx(Ex,{open:_,sourceNode:n,targetNodes:S,selectedCapabilities:ee,previewResults:O,embedded:!0,onClose:()=>P(!1),onPreviewTargetsChange:le,onShare:ue})]})})})}function $x(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(Ux,{open:!0,node:r,scope:n.scope,clusterNodes:t.nodes,onOpenChange:d=>{d||s(null)},onSelectionChange:l}):null,openNodeCapabilities:a,openProjectCapabilities:i}}function qx({activeTaskId:t,fetchTasks:n,navigateToNextVisibleTask:s,removeTasksFromList:r,setTask:a,setTasks:i}){const l=o.useCallback(u=>{i(h=>Mr(h,u)),a(h=>h?.id===u.id?{...h,...u}:h)},[a,i]),c=o.useCallback(async(u,h)=>{try{const f=await na(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 na(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 od(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]),p=o.useCallback(async u=>{try{await id(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:p,handleToggleTaskPinned:d,handleUpdateTaskTitle:c}}function Vx(){const{id:t}=ld(),n=cd(),s=dd(),r=ud(),{cluster:a,systemInfo:i,events:l,sseConnected:c,subscribe:d,refresh:m,loading:p,error:u}=md(),h=o.useMemo(()=>hd(n.state),[n.state]),[f,j]=o.useState(null),[g,w]=o.useState("active"),[b,k]=o.useState("all"),[y,x]=o.useState("all"),[v,N]=o.useState("all"),A=r?.headerSearchQuery??"",E=o.useDeferredValue(A),{desktopTasksOpen:M,mobileTasksPanelOpen:B,mobileTasksPanelRef:D,operationsOpen:_,operationsPanelRef:P,panelResize:O,setMobileTasksPanelOpen:W,setOperationsOpen:J,toggleTasksPanel:Y}=kp(),[V,ne]=o.useState(()=>!!h?.draftNewTask),[$,ee]=o.useState(()=>h?.createMode??"chat"),[S,Q]=o.useState(()=>h?.createDefaults??null),[T,te]=o.useState(()=>h?.draftNewTask?{route:h.returnRoute??"/",taskId:h.returnTaskId??null}:null),[R,H]=o.useState(!1),[F,le]=o.useState("transcript"),[ie,ue]=o.useState("overview"),[Z,K]=o.useState("all"),[I,se]=o.useState(!1),[q,ae]=o.useState(null),[ye,pe]=o.useState([]),[Ze,Ae]=o.useState([]),[ft,Re]=o.useState(!1),[De,He]=o.useState(!1),[Ke,je]=o.useState(null),[Be,G]=o.useState(new Set),[ge,be]=o.useState(!1),[et,_e]=o.useState(!1),[rt,re]=o.useState(null),Ne=o.useRef(null),Te=o.useRef(new Map),ve=a?.self?.role==="leader",at=a?.self?.id,{quickChats:Pe}=fd();Fp({cluster:a,subscribe:d});const{nodeSettingsDialog:_t,openNodeSettings:pt}=sx(ve),{capabilitiesDialog:pn,openNodeCapabilities:en,openProjectCapabilities:St}=$x(a),{devBoxDialog:wt,devBoxNodeIds:xn,devBoxStartNodeId:gn,devBoxStartNodeIds:Pt,devBoxStartingNodeIds:Ft,openDevBox:tn,startDevBox:Ct}=nx({cluster:a,refresh:m}),{completedGroups:nn=[],fetchTasks:Fe,loadCompletedTasksPage:ot,removeTasksFromList:yt,setTasks:Tt,tasks:U,tasksError:ze,tasksLoading:Ie}=Rp({isLeader:ve,selfId:at,sseConnected:c,preservedTask:q,subscribe:d});o.useEffect(()=>pd(()=>{ue("events"),J(!0)}),[J]);const We=o.useMemo(()=>[...U].sort((C,z)=>z.updatedAt-C.updatedAt),[U]),Qe=o.useMemo(()=>[...U].sort((C,z)=>z.createdAt-C.createdAt||z.updatedAt-C.updatedAt)[0]?.id??null,[U]),sn=o.useMemo(()=>{const C=new Map;for(const z of a?.nodes??[]){const oe=Yu(We,z.id);oe>0&&C.set(z.id,oe)}return C},[a?.nodes,We]),xe=o.useMemo(()=>We.filter(C=>!xd(C,a?.nodes,a?.self)||!gd(C,g)||b!=="all"&&C.agent!==b||!bd(C,v)||y==="unassigned"&&C.assignedTo||y!=="all"&&y!=="unassigned"&&vd(C.assignedTo,a?.nodes,C.assignedNodeName)!==y?!1:E.trim()?wd(C,E):!0),[We,a?.nodes,a?.self,g,b,v,y,E]);o.useEffect(()=>{G(C=>{const z=nm(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(We.map(C=>C.agent))).sort()],[We]),ke=o.useMemo(()=>{const z=Array.from(new Set(We.map(oe=>oe.assignedTo).filter(oe=>!!oe))).map(oe=>{const Me=We.find(we=>we.assignedTo===oe);return a?.nodes.find(we=>we.id===oe)??{id:oe,name:er(oe,a?.nodes,Me?.assignedNodeName)}}).sort((oe,Me)=>oe.name.localeCompare(Me.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...z.map(oe=>({value:oe.name.toLowerCase(),label:oe.name}))]},[We,a?.nodes]),Ge=o.useMemo(()=>{const C=new Map;for(const z of a?.nodes??[])C.set(z.id,z.name);for(const z of We)z.assignedTo&&z.assignedNodeName&&!C.has(z.assignedTo)&&C.set(z.assignedTo,z.assignedNodeName);return C},[a?.nodes,We]),Ue=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]),zt=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]),ls=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]),bn=o.useMemo(()=>new Map(nn.map(C=>[xr(C),C])),[nn]),Ee=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]),rn=a?.self?.id??Ee[0]?.id??null,It=o.useMemo(()=>l.filter(yd),[l]),vn=o.useMemo(()=>["all",...Array.from(new Set(It.map(C=>C.type))).sort()],[It]),cs=o.useMemo(()=>Z==="all"?It:It.filter(C=>C.type===Z),[It,Z]),ds=xe.length>0&&xe.every(C=>Be.has(C.id)),it=xe.some(C=>Be.has(C.id)),gl=sm(xe,Be);o.useEffect(()=>{h?.draftNewTask&&(ne(!0),ee(h.createMode??"chat"),Q(h.createDefaults??null),te({route:h.returnRoute??"/",taskId:h.returnTaskId??null}))},[h]),o.useEffect(()=>{Z!=="all"&&!vn.includes(Z)&&K("all")},[Z,vn]),o.useEffect(()=>{ca(t,V)&&!f&&Qe&&j(Qe)},[t,V,f,Qe]),o.useEffect(()=>{ca(t,V)&&(f&&U.some(C=>C.id===f)||j(Qe))},[t,V,f,Qe,U]);const Se=Zu({routeTaskId:t,creatingTask:V,internalSelectedTaskId:f,sortedTaskIds:Qe?[Qe]:[]}),an=o.useMemo(()=>U.find(C=>C.id===Se)??null,[U,Se]);o.useEffect(()=>{Ne.current=Se??null},[Se]);const Rt=o.useCallback(()=>{ae(null),pe([]),Ae([]),je(null),He(!1)},[]),wn=o.useCallback((C,z,oe=!0)=>{Te.current.set(C,{logs:zr(z),loaded:oe})},[]),xt=o.useCallback(async()=>{const C=Se;if(C)try{const z=await jd(C);if(Ne.current!==C)return;ae(z),Tt(oe=>Mr(oe,z)),je(null)}catch(z){if(Ne.current!==C)return;Rt(),je(z instanceof Error?z.message:"Failed to load task")}finally{Ne.current===C&&Re(!1)}},[Se,Rt,Tt]),us=o.useCallback(async(C={})=>{const z=Se;if(z)try{const oe=await sr(z,C.after,{minTotal:C.minTotal});if(Ne.current!==z)return;pe(Me=>{const we=Ko(Me,oe.logs);return wn(z,we),we}),Ae(Me=>ar(Me,oe.logs))}catch{}finally{Ne.current===z&&He(!1)}},[Se,wn]);o.useEffect(()=>{if(!Se){Rt(),Re(!1);return}le("transcript"),ae(an);const C=Lp(Se,Te.current);pe(C.logs),Ae([]),je(null),Re(!0),He(C.transcriptLoading),xt(),us()},[Se,Rt,us,xt]),o.useEffect(()=>{if(!Xu({activeTaskId:Se,routeTaskId:t,creatingTask:V,tasksLoading:Ie,loadedTaskIds:U.map(z=>z.id)}))return;const C=Qe;j(C),Rt(),o.startTransition(()=>{s(C?`/tasks/${C}`:"/",{state:null})})},[Se,Rt,V,Qe,s,t,U,Ie]),o.useEffect(()=>{an&&ae(C=>!C||C.id!==an.id?C:{...C,...an})},[an]),Up({activeTaskId:Se,cacheTranscript:wn,fetchActiveLogs:us,fetchActiveTask:xt,logs:ye,setLogs:pe,setPendingMessages:Ae,setTranscriptLoading:He,sseConnected:c,subscribe:d});const de=q??an,bl=de?.assignedTo?a?.nodes.find(C=>C.id===de.assignedTo)??null:null,yn=r?.setHeaderTaskContext;o.useEffect(()=>{if(!yn)return;if(!de){yn(null);return}const C=de.effectiveProjectPath??de.project??"default workspace";return yn({taskId:de.id,taskTitle:de.title,nodeName:er(de.assignedTo,a?.nodes,de.assignedNodeName),projectLabel:Bo(C),projectPath:C}),()=>yn(null)},[de,a?.nodes,yn]);const ms=Ze.length>0,vl=de?Nd.has(de.agent):!1,On=de?.status==="running",wl=de?Qn.has(de.status):!1,yl=de?Qn.has(de.status)||kd.has(de.status):!1,jl=!!(de&&ve&&de.status==="failed"),hs=o.useMemo(()=>Wf(de,a,ms,!!On),[de,a,ms,On]),fs=o.useMemo(()=>qd([...ye,...Ze.map(C=>ws(C.content,C.timestamp))]),[ye,Ze]),Fn=o.useMemo(()=>{if(!de||de.conversationKind==="nativeSession")return null;const C=Vd(de);if(C.length>0)return ws(C,new Date(de.createdAt).toISOString());if(fs.length>0)return null;const z=Hd(de.description||de.title);return z.length>0?ws(z,new Date(de.createdAt).toISOString()):null},[de,fs]),ps=o.useMemo(()=>Fn?Cr(Fn):null,[Fn]),Nl=o.useMemo(()=>ps?Kd(ye,ps):!1,[ye,ps]),xs=o.useCallback((C="chat",z)=>{const oe={route:t?`/tasks/${t}`:"/",taskId:Se};te(oe),ee(C),Q(z??null),ne(!0),o.startTransition(()=>{s("/",{state:{draftNewTask:!0,returnRoute:oe.route,returnTaskId:oe.taskId,createMode:C,createDefaults:z}})})},[t,Se,s]),kl=o.useCallback(()=>{const C=T?.taskId??Qe;ne(!1),te(null),Q(null),j(C),o.startTransition(()=>{s(T?.route??"/",{state:null})})},[T,Qe,s]),Vr=o.useCallback(C=>{ne(!1),te(null),Q(null),j(C),o.startTransition(()=>{s(`/tasks/${C}`,{state:null})})},[s]),Sl=o.useCallback(C=>{Ne.current=C.id,ne(!1),te(null),Q(null),Tt(z=>em(z,C)),ae(C),pe([]),Ae([]),je(null),Re(!1),He(C.conversationKind==="nativeSession"),le("transcript"),j(C.id),qp({task:C,getActiveTaskId:()=>Ne.current,setLogs:pe,setPendingMessages:Ae,setTranscriptLoading:He}),Fe(),o.startTransition(()=>{s(`/tasks/${C.id}`,{state:null})})},[Fe,s]),{cancelQueuedMessage:Cl,queueFollowUpMessage:zn}=ax({activeTaskId:Se,fetchActiveTask:xt,isRunning:On,setPendingMessages:Ae,setTask:ae,setTasks:Tt}),Tl=o.useCallback((C,z)=>{zn(C,z)},[zn]),Al=o.useCallback(async()=>{const C=Se;if(!(!C||de?.conversationKind!=="nativeSession")){He(!0);try{const z=await sr(C);if(Ne.current!==C)return;pe(z.logs),wn(C,z.logs),Ae(oe=>ar(oe,z.logs))}catch(z){ce.error(z instanceof Error?z.message:"Failed to reload transcript")}finally{Ne.current===C&&He(!1)}}},[de?.conversationKind,Se,wn]),El=o.useCallback(C=>zn(C),[zn]),Ml=o.useCallback(async()=>{if(de)try{await Sd(de.id),xt(),Fe()}catch(C){ce.error(C instanceof Error?C.message:"Failed to cancel task")}},[de,xt,Fe]),{handleShareTask:Dl,handleStopShareTask:_l}=wp(de,xt,Fe),Pl=o.useCallback(async()=>{if(de)try{await Cd(de.id),xt(),Fe()}catch(C){ce.error(C instanceof Error?C.message:"Failed to retry task")}},[de,xt,Fe]),jn=o.useCallback((C,z=!1)=>{const oe=rm(xe,C);return j(oe),(z||!oe)&&Rt(),o.startTransition(()=>{s(oe?`/tasks/${oe}`:"/",{state:null})}),oe},[Rt,xe,s]),{handleArchiveTask:Il,handleDeleteTask:Rl,handleToggleTaskPinned:Ll,handleUpdateTaskTitle:Bl}=qx({activeTaskId:Se,fetchTasks:Fe,navigateToNextVisibleTask:jn,removeTasksFromList:yt,setTask:ae,setTasks:Tt}),Ol=o.useCallback((C,z)=>{G(oe=>{const Me=new Set(oe);return z?Me.add(C):Me.delete(C),Me})},[]),Fl=o.useCallback(C=>{if(!C){G(new Set);return}G(new Set(xe.map(z=>z.id)))},[xe]),zl=o.useCallback(async()=>{const C=Array.from(Be);if(C.length!==0)try{const{results:z}=await Td(C),oe=z.filter(we=>!we.ok),Me=z.filter(we=>we.ok).map(we=>we.id);Se&&Me.includes(Se)&&jn(Me),oe.length>0?ce.error(`Failed to archive ${oe.length} task(s): ${oe.map(we=>we.error??we.id).join(", ")}`):ce.success(`Archived ${Me.length} task(s)`),G(new Set(oe.map(we=>we.id))),Fe()}catch(z){ce.error(z instanceof Error?z.message:"Failed to archive tasks")}},[Se,Fe,jn,Be]),Ul=o.useCallback(async()=>{const C=Array.from(Be);if(C.length!==0)try{const{results:z}=await Ad(C),oe=z.filter(we=>!we.ok),Me=z.filter(we=>we.ok).map(we=>we.id);Me.length>0&&yt(Me),Se&&Me.includes(Se)&&jn(Me,!0),oe.length>0?ce.error(`Failed to delete ${oe.length} task(s): ${oe.map(we=>we.error??we.id).join(", ")}`):ce.success(`Deleted ${Me.length} task(s)`),G(new Set(oe.map(we=>we.id))),Fe()}catch(z){ce.error(z instanceof Error?z.message:"Failed to delete tasks")}},[Se,Fe,jn,yt,Be]),$l=o.useCallback(async()=>{be(!0);try{await Ed(),m()}catch(C){ce.error(C instanceof Error?C.message:"Failed to promote node")}finally{be(!1)}},[m]),ql=o.useCallback(async()=>{_e(!0);try{await Md(),ce.success("This node left the remote cluster and is leading itself again."),Fe(),xt(),m()}catch(C){ce.error(C instanceof Error?C.message:"Failed to leave cluster")}finally{_e(!1)}},[xt,Fe,m]),Vl=o.useCallback(async C=>{const z=!Er(C),oe=C.id===a?.self?.id,Me=oe?i?.transportType??C.transportType:C.transportType,we=oe&&!z&&fn(Me);re(C.id);try{we?await Dd("direct"):await _d(C.id,z),ce.success(z?`Enabled remote access on ${C.name}`:`Disabled remote access on ${C.name}`),m()}catch(Kr){ce.error(Kr instanceof Error?Kr.message:"Failed to update remote access")}finally{re(null)}},[a?.self?.id,m,i?.transportType]),Hl=o.useCallback(C=>{ot&&ot(C).catch(z=>{ce.error(z instanceof Error?z.message:"Failed to load completed tasks")})},[ot]),Hr={toolbarTasks:xe,activeTaskId:Se,tasksLoading:Ie,tasksError:ze,isLeader:ve,scope:g,agentFilter:b,nodeFilter:y,taskKindFilter:v,agentOptions:me,nodeOptions:ke,nodeNameById:Ge,nodeWorkDirById:Ue,nodeStatusById:zt,nodeInfoById:ls,leaderNodeId:a?.leader?.id??null,searchQuery:A,completedGroupByKey:bn,devBoxNodeIds:xn,devBoxStartNodeIds:Pt,devBoxStartingNodeIds:Ft,selectedTaskIds:Be,allVisibleTasksSelected:ds,someVisibleTasksSelected:it,canBatchArchive:gl,onScopeChange:w,onAgentFilterChange:k,onNodeFilterChange:x,onTaskKindFilterChange:N,onToggleTaskSelected:Ol,onToggleAllVisibleTasks:Fl,onUpdateTaskTitle:Bl,onDeleteTask:Rl,onArchiveTask:Il,onToggleTaskPinned:Ll,onBatchArchive:zl,onBatchDelete:Ul,onCreateTask:xs,onOpenNodeSettings:ve?pt:void 0,onOpenNodeCapabilities:ve?en:void 0,onOpenProjectCapabilities:ve?St:void 0,onOpenDevBox:ve?tn:void 0,onStartDevBox:ve?Ct:void 0,onLoadCompletedTasks:Hl,onSelectTask:Vr},Kl={cluster:a,systemInfo:i,nodeNameById:Ge,nodeBlockingTaskCounts:sn,eventTypeFilter:Z,onEventTypeFilterChange:K,activeTab:ie,onTabChange:ue,eventTypeOptions:vn,filteredEvents:cs,sseConnected:c,clusterLoading:p,clusterError:u,promotePending:ge,onPromote:$l,onAddNode:()=>H(!0),leavePending:et,onLeaveCluster:ql,onToggleNodeDevTunnel:Vl,devTunnelNodeId:rt,devBoxStartNodeId:gn,devBoxStartingNodeIds:Ft,onOpenNodeSettings:ve?pt:void 0,onOpenNodeCapabilities:ve?en:void 0,onOpenDevBox:ve?tn:void 0,onStartDevBox:ve?Ct:void 0};return e.jsxs(e.Fragment,{children:[e.jsx(Jh,{desktopTasksOpen:M,mobileTasksPanelOpen:B,mobileTasksPanelRef:D,operationsOpen:_,operationsPanelRef:P,panelResize:O,taskSidebar:e.jsx(oo,{...Hr}),operationsSidecar:e.jsx(Kf,{...Kl}),terminalPanel:r?.terminalOpen?e.jsx(af,{nodes:Ee,defaultNodeId:rn,onClose:()=>r?.setTerminalOpen(!1)}):void 0,conversationPanel:e.jsx($h,{onToggleTasks:Y,desktopTasksOpen:M,mobileTasksPanelOpen:B,operationsOpen:_,onToggleOperations:()=>J(C=>!C),cluster:a,sseConnected:c,activeTab:F,setActiveTab:le,creatingTask:V,createMode:$,createDefaults:S,activeTask:de,assignedNode:bl,taskLoading:ft,transcriptLoading:De,taskError:Ke,displayEvents:fs,initialPromptAlreadyInLogs:Nl,initialPrompt:Fn,supportsFollowUp:vl,taskUnavailable:hs.taskUnavailable,chatDisabled:hs.chatDisabled,chatDisabledReason:hs.chatDisabledReason,questionBypassEnabled:I,isRunning:!!On,isStarting:wl,hasPendingFollowUp:ms,canCancel:!!yl,canRetry:!!jl,onRetry:Pl,onCancel:Ml,onReloadNativeTranscript:Al,onShareTask:Dl,onStopShareTask:_l,onStartCreateTask:xs,onCancelCreateTask:kl,onCreateTask:Sl,onSendMessage:Tl,onCancelQueuedMessage:Cl,onQuestionBypassChange:se,onSubmitQuestionResponse:El,quickChats:Pe}),mobileTaskSidebar:e.jsx(oo,{...Hr,onCreateTask:(C,z)=>{W(!1),xs(C,z)},onSelectTask:C=>{W(!1),Vr(C)}}),onCloseOperations:()=>J(!1),onCloseTaskList:()=>W(!1),onToggleOperations:()=>J(C=>!C),onToggleTasks:Y}),e.jsx(Kh,{open:R,onOpenChange:H,onAdded:m}),_t,wt,pn]})}const Qx=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:Vx},Symbol.toStringTag,{value:"Module"}));export{Wo as A,Qx as D,Yn as G};