meshy-node 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dashboard/assets/DashboardPage-DqRPTnH6.js +119 -0
- package/dashboard/assets/DashboardShared-CGZZTe4C.js +54 -0
- package/dashboard/assets/{DiffTab-BPE2fUnK.js → DiffTab-DoG4Hq6_.js} +3 -3
- package/dashboard/assets/{FilesTab-CLLyWXEv.js → FilesTab-BX-UYwna.js} +1 -1
- package/dashboard/assets/{PreviewTab-C1SWykXF.js → PreviewTab-DnhQ_cTw.js} +2 -2
- package/dashboard/assets/{SharedConversationPage-CDFyo1wW.js → SharedConversationPage--7Zq1FFl.js} +3 -3
- package/dashboard/assets/{file-YGIDkO7j.js → file-CFaB5QBp.js} +1 -1
- package/dashboard/assets/{folder-BNfC8Y62.js → folder-DhIVX8_W.js} +1 -1
- package/dashboard/assets/index-Bb1MuUmE.js +271 -0
- package/dashboard/assets/index-CmW82hgD.css +1 -0
- package/dashboard/assets/input-CgtqVNV3.js +1 -0
- package/dashboard/index.html +2 -2
- package/package.json +1 -1
- package/runtime-metadata.json +5 -5
- package/dashboard/assets/DashboardPage-DQjLt2wn.js +0 -124
- package/dashboard/assets/DashboardShared-B4I_eZZK.js +0 -54
- package/dashboard/assets/index-Cpz4J5-T.js +0 -266
- package/dashboard/assets/index-DvQBsfbb.css +0 -1
- package/dashboard/assets/input-BRIa-GWn.js +0 -1
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-CLLyWXEv.js","assets/index-Cpz4J5-T.js","assets/index-DvQBsfbb.css","assets/folder-BNfC8Y62.js","assets/file-YGIDkO7j.js","assets/PreviewTab-C1SWykXF.js","assets/input-BRIa-GWn.js","assets/DiffTab-BPE2fUnK.js","assets/DashboardShared-B4I_eZZK.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{c as he,r as s,j as e,a as Ia,b as P,d as $a,e as Ba,D as ys,f as Oa,g as ws,B as Pe,h as za,i as A,X as Ve,k as Ua,l as Va,C as We,m as Ka,n as qa,F as Ha,S as me,o as et,p as Wa,q as Ga,t as xe,s as ye,u as we,v as Te,w as Ce,x as Ot,y as Ue,T as zt,z as Cs,A as Ja,E as Ss,G as _s,H as Ge,I as Es,J as Ts,K as Ds,P as Ya,L as Ms,M as Oe,N as Xa,O as ze,Q as Nt,R as yt,U as wt,V as Ct,W as St,Y as _t,Z as Et,_ as Tt,$ as Ut,a0 as Qa,a1 as Za,a2 as er,a3 as As,a4 as Ls,a5 as Ps,a6 as tr,a7 as ct,a8 as sr,a9 as Vt,aa as ar,ab as Rs,ac as os,ad as rr,ae as nr,af as or,ag as lr,ah as ir,ai as dr,aj as cr,ak as ur,al as xr,am as hr,an as ls,ao as mr,ap as pr,aq as fr,ar as br,as as Fs,at as gr,au as vr,av as jr,aw as kr,ax as Nr,ay as yr,az as wr,aA as Cr,aB as Sr,aC as _r,aD as Er,aE as Tr,aF as Dr,aG as Mr,aH as Ar,aI as Lr,aJ as Pr,aK as Rr,aL as Fr,aM as Ir,aN as $r}from"./index-Cpz4J5-T.js";import{r as is,e as Br,b as Is,t as $s,L as ve,C as ds,a as Or,T as jt,D as He,I as Le,M as Dt,c as Bs,m as Os,d as zs,f as zr,g as cs,h as Ur,i as Vr,j as kt,k as Kr,n as qr,l as Hr}from"./DashboardShared-B4I_eZZK.js";import{I as Ie}from"./input-BRIa-GWn.js";import{F as Wr,C as tt}from"./folder-BNfC8Y62.js";/**
|
|
3
|
-
* @license lucide-react v1.7.0 - ISC
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the ISC license.
|
|
6
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const Gr=[["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"}]],Jr=he("archive",Gr);/**
|
|
8
|
-
* @license lucide-react v1.7.0 - ISC
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the ISC license.
|
|
11
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/const Yr=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Xr=he("arrow-up",Yr);/**
|
|
13
|
-
* @license lucide-react v1.7.0 - ISC
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the ISC license.
|
|
16
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/const Qr=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],Zr=he("flag",Qr);/**
|
|
18
|
-
* @license lucide-react v1.7.0 - ISC
|
|
19
|
-
*
|
|
20
|
-
* This source code is licensed under the ISC license.
|
|
21
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
-
*/const en=[["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"}]],tn=he("funnel",en);/**
|
|
23
|
-
* @license lucide-react v1.7.0 - ISC
|
|
24
|
-
*
|
|
25
|
-
* This source code is licensed under the ISC license.
|
|
26
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
-
*/const sn=[["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"}]],us=he("git-branch",sn);/**
|
|
28
|
-
* @license lucide-react v1.7.0 - ISC
|
|
29
|
-
*
|
|
30
|
-
* This source code is licensed under the ISC license.
|
|
31
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
-
*/const an=[["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"}]],rn=he("globe",an);/**
|
|
33
|
-
* @license lucide-react v1.7.0 - ISC
|
|
34
|
-
*
|
|
35
|
-
* This source code is licensed under the ISC license.
|
|
36
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
-
*/const nn=[["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"}]],Mt=he("history",nn);/**
|
|
38
|
-
* @license lucide-react v1.7.0 - ISC
|
|
39
|
-
*
|
|
40
|
-
* This source code is licensed under the ISC license.
|
|
41
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
-
*/const on=[["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"}]],At=he("image-plus",on);/**
|
|
43
|
-
* @license lucide-react v1.7.0 - ISC
|
|
44
|
-
*
|
|
45
|
-
* This source code is licensed under the ISC license.
|
|
46
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
-
*/const ln=[["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"}]],dn=he("laptop",ln);/**
|
|
48
|
-
* @license lucide-react v1.7.0 - ISC
|
|
49
|
-
*
|
|
50
|
-
* This source code is licensed under the ISC license.
|
|
51
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
52
|
-
*/const cn=[["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"}]],Kt=he("link-2",cn);/**
|
|
53
|
-
* @license lucide-react v1.7.0 - ISC
|
|
54
|
-
*
|
|
55
|
-
* This source code is licensed under the ISC license.
|
|
56
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
57
|
-
*/const un=[["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"}]],qt=he("message-square-plus",un);/**
|
|
58
|
-
* @license lucide-react v1.7.0 - ISC
|
|
59
|
-
*
|
|
60
|
-
* This source code is licensed under the ISC license.
|
|
61
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
-
*/const xn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],Us=he("panel-left-close",xn);/**
|
|
63
|
-
* @license lucide-react v1.7.0 - ISC
|
|
64
|
-
*
|
|
65
|
-
* This source code is licensed under the ISC license.
|
|
66
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
-
*/const hn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],mn=he("panel-left-open",hn);/**
|
|
68
|
-
* @license lucide-react v1.7.0 - ISC
|
|
69
|
-
*
|
|
70
|
-
* This source code is licensed under the ISC license.
|
|
71
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
72
|
-
*/const pn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],Ht=he("panel-right-close",pn);/**
|
|
73
|
-
* @license lucide-react v1.7.0 - ISC
|
|
74
|
-
*
|
|
75
|
-
* This source code is licensed under the ISC license.
|
|
76
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
77
|
-
*/const fn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],Vs=he("panel-right-open",fn);/**
|
|
78
|
-
* @license lucide-react v1.7.0 - ISC
|
|
79
|
-
*
|
|
80
|
-
* This source code is licensed under the ISC license.
|
|
81
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
82
|
-
*/const bn=[["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"}]],at=he("pencil",bn);/**
|
|
83
|
-
* @license lucide-react v1.7.0 - ISC
|
|
84
|
-
*
|
|
85
|
-
* This source code is licensed under the ISC license.
|
|
86
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
87
|
-
*/const gn=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],vn=he("plus",gn);/**
|
|
88
|
-
* @license lucide-react v1.7.0 - ISC
|
|
89
|
-
*
|
|
90
|
-
* This source code is licensed under the ISC license.
|
|
91
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
92
|
-
*/const jn=[["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"}]],kn=he("rotate-ccw",jn);/**
|
|
93
|
-
* @license lucide-react v1.7.0 - ISC
|
|
94
|
-
*
|
|
95
|
-
* This source code is licensed under the ISC license.
|
|
96
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
97
|
-
*/const Nn=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Lt=he("search",Nn);/**
|
|
98
|
-
* @license lucide-react v1.7.0 - ISC
|
|
99
|
-
*
|
|
100
|
-
* This source code is licensed under the ISC license.
|
|
101
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
102
|
-
*/const yn=[["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"}]],Ks=he("send",yn);/**
|
|
103
|
-
* @license lucide-react v1.7.0 - ISC
|
|
104
|
-
*
|
|
105
|
-
* This source code is licensed under the ISC license.
|
|
106
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
107
|
-
*/const wn=[["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"}]],Cn=he("share-2",wn);/**
|
|
108
|
-
* @license lucide-react v1.7.0 - ISC
|
|
109
|
-
*
|
|
110
|
-
* This source code is licensed under the ISC license.
|
|
111
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
112
|
-
*/const Sn=[["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"}]],_n=he("sliders-horizontal",Sn);/**
|
|
113
|
-
* @license lucide-react v1.7.0 - ISC
|
|
114
|
-
*
|
|
115
|
-
* This source code is licensed under the ISC license.
|
|
116
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
117
|
-
*/const En=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Tn=he("sparkles",En);/**
|
|
118
|
-
* @license lucide-react v1.7.0 - ISC
|
|
119
|
-
*
|
|
120
|
-
* This source code is licensed under the ISC license.
|
|
121
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
122
|
-
*/const Dn=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Mn=he("trash-2",Dn),An=new Set(["assigned","running"]);function Ln(t,a){return t.reduce((r,n)=>n.assignedTo===a&&An.has(n.status)?r+1:r,0)}function Ye(t){return(t==null?void 0:t.toLowerCase())==="devtunnel"}function Pn(t){return t?Ye(t)?"DevTunnel":t.charAt(0).toUpperCase()+t.slice(1):"Direct"}function Wt(t,a){return Ye(a??t.transportType)||!!t.devtunnelEndpoint}function qs(t,a){return!Ye(a??t.transportType)}function Hs(t,a){const r=a??t.transportType;return Ye(r)?"DevTunnel":t.devtunnelEndpoint?"Direct + DevTunnel":Pn(r)}function xs(t,a){return!t&&!a}function Rn({routeTaskId:t,creatingTask:a,internalSelectedTaskId:r,sortedTaskIds:n}){return t||(a?null:r??n[0]??null)}function Fn(t,a){return[a,...t.filter(r=>r.id!==a.id)]}function In(t,a){const r=a.taskId,n=a.updates;return typeof r!="string"||!n||typeof n!="object"?t:t.map(d=>d.id===r?{...d,...n}:d)}const $n=new Set(["completed","failed","cancelled","archived"]);function Bn(t,a){const r=new Set(a);return new Set(Array.from(t).filter(n=>r.has(n)))}function On(t,a){const r=new Set(a);if(r.size===0)return!1;const n=t.filter(d=>r.has(d.id));return n.length===r.size&&n.every(d=>$n.has(d.status))}function zn(t,a){var n;const r=new Set(a);return((n=t.find(d=>!r.has(d.id)))==null?void 0:n.id)??null}var Un=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Vn=Un.reduce((t,a)=>{const r=Ia(`Primitive.${a}`),n=s.forwardRef((d,o)=>{const{asChild:u,...f}=d,p=u?r:a;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(p,{...f,ref:o})});return n.displayName=`Primitive.${a}`,{...t,[a]:n}},{}),Kn="Label",Ws=s.forwardRef((t,a)=>e.jsx(Vn.label,{...t,ref:a,onMouseDown:r=>{var d;r.target.closest("button, input, select, textarea")||((d=t.onMouseDown)==null||d.call(t,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));Ws.displayName=Kn;var Gs=Ws;const qn=$a("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Se=s.forwardRef(({className:t,...a},r)=>e.jsx(Gs,{ref:r,className:P(qn(),t),...a}));Se.displayName=Gs.displayName;function Hn({onAdded:t}){const[a,r]=s.useState(""),[n,d]=s.useState(!1),[o,u]=s.useState(null),f=s.useCallback(async p=>{if(p.preventDefault(),!!a.trim()){d(!0),u(null);try{await Ba({leaderEndpoint:a.trim(),transport:"devtunnel"}),t()}catch(g){u(g instanceof Error?g.message:"Failed to join node")}finally{d(!1)}}},[a,t]);return e.jsx(ys,{className:"overflow-hidden border-border/60 bg-transparent p-0 shadow-none sm:max-w-xl",children:e.jsxs("div",{className:"overflow-hidden rounded-[28px] border border-border/60 bg-background/95 p-0 shadow-[0_40px_120px_-60px_rgba(0,0,0,0.88)] backdrop-blur-xl",children:[e.jsx("div",{className:"border-b border-border/60 px-6 py-5",children:e.jsxs(Oa,{className:"space-y-2 text-left",children:[e.jsx(ws,{className:"text-2xl tracking-tight",children:"Join node"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Verify the remote leader's DevTunnel endpoint, sync this node's tasks to that leader, and join the cluster as a follower."})]})}),e.jsxs("form",{onSubmit:f,className:"space-y-4 px-6 py-5",children:[o&&e.jsx("div",{className:"rounded-[20px] border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:o}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(Se,{htmlFor:"leader-endpoint",children:"Leader endpoint"}),e.jsx(Pe,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),e.jsx(Ie,{id:"leader-endpoint",type:"url",value:a,onChange:p=>r(p.target.value),placeholder:"https://your-leader.devtunnels.ms",className:"h-11 rounded-2xl border-border/70 bg-background/70"})]}),e.jsx("div",{className:"rounded-[20px] border border-border/60 bg-background/45 px-4 py-3 text-sm text-muted-foreground",children:"This does not switch the local node transport or auto-enable a local DevTunnel. Leaving later will detach this node from the remote leader and make it leader of its own cluster again."}),e.jsx(za,{className:"border-t border-border/60 pt-4",children:e.jsx(A,{type:"submit",disabled:!a.trim()||n,className:"rounded-2xl",children:n?"Joining...":"Join node"})})]})]})})}function Js(){const[t,a]=s.useState([]),[r,n]=s.useState(null),d=s.useRef(null),o=s.useCallback(()=>{var v;(v=d.current)==null||v.click()},[]),u=s.useCallback(async v=>{const l=Array.from(v.target.files??[]);if(l.length!==0)try{const c=await is(l);a(m=>[...m,...c]),n(null)}catch(c){n(c instanceof Error?c.message:"Failed to attach image")}finally{v.target.value=""}},[]),f=s.useCallback(async v=>{const l=Br(v.clipboardData);if(l.length!==0){v.preventDefault();try{const c=await is(l);a(m=>[...m,...c]),n(null)}catch(c){n(c instanceof Error?c.message:"Failed to attach image")}}},[]),p=s.useCallback(v=>{a(l=>l.filter((c,m)=>m!==v))},[]),g=s.useCallback(()=>{a([]),n(null)},[]);return{images:t,error:r,fileInputRef:d,pickImages:o,handleFileChange:u,handlePaste:f,removeImage:p,clearImages:g}}function Wn({onSend:t,disabled:a,disabledReason:r="Chat is waiting on the agent.",placeholder:n="Send a follow-up message...",contextItems:d=[],running:o=!1,onStop:u}){const[f,p]=s.useState(""),g=s.useRef(null),{images:v,error:l,fileInputRef:c,pickImages:m,handleFileChange:N,handlePaste:S,removeImage:w,clearImages:y}=Js(),k=s.useCallback(()=>{g.current&&(g.current.style.height="auto")},[]),X=s.useCallback(()=>{const D=Is(f,v);D.length===0||a||(t(D),p(""),y(),k())},[f,v,a,t,y,k]),O=s.useCallback(D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),X())},[X]),T=s.useCallback(()=>{g.current&&(g.current.style.height="auto",g.current.style.height=`${Math.min(g.current.scrollHeight,220)}px`)},[]),ee=!a&&!o&&(f.trim().length>0||v.length>0),L=o&&!!u,U=o?u?"Task is running — click to stop":"Task is running...":a?r:"Enter sends, Shift+Enter adds a line";return e.jsxs("div",{className:"border-t border-border/60 bg-background/55 px-2 py-1.5 backdrop-blur-xl sm:px-4 sm:py-2",children:[d.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 px-2 pb-2.5",children:d.map(D=>e.jsxs("div",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-border/60 bg-muted/40 px-2 py-1 text-[11px]",children:[e.jsx("span",{className:"shrink-0 text-[9px] font-medium uppercase tracking-[0.12em] text-muted-foreground/80",children:D.label}),e.jsx("span",{className:`truncate text-foreground/90 ${D.mono?"font-mono text-[11px]":""}`,children:D.value})]},`${D.label}:${D.value}`))}),e.jsxs("div",{className:"overflow-hidden rounded-3xl border border-border/65 bg-card/85 shadow-[0_28px_90px_-62px_rgba(0,0,0,var(--panel-shadow-alpha))] sm:rounded-[40px]",children:[e.jsx("input",{ref:c,type:"file",accept:"image/*",multiple:!0,onChange:N,className:"hidden"}),v.length>0&&e.jsx("div",{className:"px-2 pt-3 sm:px-6 sm:pt-6",children:e.jsx("div",{className:"flex flex-wrap gap-3",children:v.map((D,B)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:$s(D),alt:D.filename??`attachment ${B+1}`,className:"h-24 w-24 rounded-[22px] border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>w(B),className:"absolute -top-2 -right-2 flex h-7 w-7 items-center justify-center rounded-full border border-border/70 bg-background text-muted-foreground transition-colors hover:text-foreground","aria-label":`Remove ${D.filename??`image ${B+1}`}`,children:e.jsx(Ve,{className:"h-3.5 w-3.5"})})]},`${D.filename??"image"}-${B}`))})}),e.jsxs("div",{className:"flex items-end gap-1.5 px-2 pt-3 pb-3 sm:px-6 sm:pt-4 sm:pb-4",children:[e.jsx("textarea",{ref:g,value:f,onChange:D=>p(D.target.value),onKeyDown:O,onPaste:S,onInput:T,placeholder:n,disabled:a,rows:1,className:"min-h-[2.5rem] flex-1 resize-none bg-transparent px-0 py-1 text-[11px] leading-7 text-foreground placeholder:text-muted-foreground/70 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),e.jsxs(A,{type:"button",variant:"ghost",onClick:m,disabled:a,className:"mb-0.5 h-7 shrink-0 gap-1.5 rounded-full px-2 text-[11px] text-muted-foreground hover:text-foreground sm:px-2",title:"Attach images",children:[e.jsx(At,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Images"})]}),e.jsx("span",{title:U,children:e.jsx(A,{onClick:o?u:X,disabled:o?!L:!ee,size:"icon","aria-label":o?"Stop running task":"Send message",className:"mb-0.5 h-7 w-9 shrink-0 rounded-full bg-primary/85 text-primary-foreground shadow-sm hover:bg-primary",children:o?e.jsx(ve,{className:"h-4 w-4 animate-spin"}):e.jsx(Ks,{className:"h-4 w-4"})})})]}),l&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-2 py-2 text-[11px] text-destructive sm:px-6 sm:py-3",children:l})]})]})}function Gn(t,a,r){return t!=="auto"?a.find(n=>n.id===t)??null:r.length===1?r[0]??null:null}function Jn(t){return t.trim()||"."}function Yn(t){return new Promise(a=>window.setTimeout(a,t))}function Xn(t){return!!t&&typeof t=="object"&&typeof t.createdBranch=="string"&&typeof t.currentBranch<"u"}async function Qn(t){let a=t;for(let r=0;r<60;r++){if(a.status==="succeeded"){if(Xn(a.result))return a.result;throw new Error("Branch creation completed without branch details")}if(a.status==="failed")throw new Error(a.error||"Branch creation failed");await Yn(1e3),a=await Ka(a.id)}throw new Error("Timed out waiting for branch creation")}function hs({value:t,onChange:a,project:r,assignTo:n,nodes:d,assignableNodes:o,layout:u="default",chipClassName:f,chipActiveClassName:p,chipInactiveClassName:g,labelClassName:v,triggerClassName:l}){const[c,m]=s.useState(!1),[N,S]=s.useState(null),[w,y]=s.useState(""),[k,X]=s.useState(!1),[O,T]=s.useState(!1),[ee,L]=s.useState(!1),[U,D]=s.useState(null),[B,pe]=s.useState(""),[E,V]=s.useState(""),[H,R]=s.useState(""),[de,K]=s.useState(!1),q=s.useRef(null),re=s.useRef(0),ce=s.useMemo(()=>Gn(n,d,o),[n,d,o]),I=ce==null?void 0:ce.id,Q=s.useMemo(()=>Jn(r),[r]),le=s.useMemo(()=>I?`${I}
|
|
123
|
-
${Q}`:"",[I,Q]),ne=s.useCallback(async(h=0,_=!1)=>{const $=re.current+1,j=le;if(re.current=$,!I){S(null),y("");return}D(null),_||y(""),_?T(!0):X(!0);try{const z=await Ua(I,{path:Q,limit:20,offset:h,allowAbsolute:!0});if($!==re.current)return;y(j),S(te=>_&&te?{...z,branches:[...te.branches,...z.branches]}:z)}catch(z){if($!==re.current)return;D(z instanceof Error?z.message:"Failed to load branch info"),_||(S(null),y(""))}finally{$===re.current&&(X(!1),T(!1))}},[I,le,Q]);s.useEffect(()=>{if(!I){re.current+=1,S(null),y(""),D(null);return}ne()},[I,Q,ne]),s.useEffect(()=>{const h=t.trim(),_=w===le?N:null,$=_!=null&&_.available&&_.currentBranch?_.currentBranch:"";h!==$&&a($)},[N,le,w,a,t]),s.useEffect(()=>{if(!c)return;const h=$=>{q.current&&(q.current.contains($.target)||m(!1))},_=$=>{$.key==="Escape"&&m(!1)};return document.addEventListener("mousedown",h),document.addEventListener("keydown",_),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",_)}},[c]),s.useEffect(()=>{c&&(V(""),R(""),K(!1))},[c,I,Q]);const ie=s.useCallback(async()=>{if(!I)return;const h=B.trim(),_=de?H.trim():E.trim();if(!(!h||!_)){L(!0),D(null);try{const $=await Va(I,{path:Q,branchName:h,startPoint:_,limit:20,offset:0,allowAbsolute:!0}),j=await Qn($);y(le),S(j),a(j.currentBranch??j.createdBranch),pe(""),V(""),R(""),K(!1),m(!1)}catch($){D($ instanceof Error?$.message:"Failed to create branch")}finally{L(!1)}}},[I,le,Q,de,H,B,a,E]),x=w===le?N:null,Z=s.useCallback(()=>{x!=null&&x.hasMore&&ne(x.branches.length,!0)},[x,ne]),F=t.trim()||(x==null?void 0:x.currentBranch)||(x&&!x.available?"No git repo":"Branch"),be=de?H.trim():E.trim(),oe=!!(x!=null&&x.available&&B.trim()&&be&&!ee),je=u==="composer"?e.jsxs(A,{type:"button",variant:"ghost",onClick:()=>m(h=>!h),title:F,"aria-label":`Branch: ${F}`,className:P(f,l,"min-w-0 max-w-full",t.trim()?p:g),children:[k&&!x?e.jsx(ve,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(us,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:P("min-w-0 truncate",v),children:F})]}):e.jsxs(A,{type:"button",variant:"outline",onClick:()=>m(h=>!h),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:F,children:[e.jsx("span",{className:P("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:F}),e.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:ce?ce.name:"Manual"})]});return e.jsxs("div",{className:P("relative inline-block",u==="composer"?"min-w-0 shrink-0":"w-full"),ref:q,children:[u==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Se,{className:"text-sm font-medium",children:"Branch"}),je]}):je,c&&e.jsxs("div",{className:P("absolute z-50 mt-2 w-[240px] overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",u==="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(us,{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:x!=null&&x.repoRoot?`${x.currentBranch??F} · ${x.repoRoot}`:(x==null?void 0:x.currentBranch)??F,children:(x==null?void 0:x.currentBranch)??F}),k?e.jsx(ve,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}):null]}),ce?k&&!x?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(ve,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):x&&!x.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(Ie,{value:B,onChange:h=>pe(h.target.value),placeholder:"New branch name",className:"h-8 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx(A,{type:"button",size:"sm",onClick:()=>void ie(),disabled:!oe,title:oe?"Create branch":"Enter a name and pick a base","aria-label":"Create branch",className:"h-8 w-8 shrink-0 rounded-md p-0",children:ee?e.jsx(ve,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(vn,{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"}),!de&&e.jsxs("button",{type:"button",onClick:()=>K(!0),className:"flex items-center gap-1 rounded px-1 py-0.5 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:[e.jsx(at,{className:"h-2.5 w-2.5"}),"Manual"]})]}),de?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ie,{value:H,onChange:h=>R(h.target.value),placeholder:"upstream/release/1.0",className:"h-8 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>{K(!1),R("")},className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel manual input","aria-label":"Cancel manual input",children:e.jsx(Ve,{className:"h-3.5 w-3.5"})})]}):x!=null&&x.branches.length?e.jsxs("div",{className:"max-h-44 overflow-y-auto rounded-md border border-border/40 bg-background/40",children:[x.branches.map(h=>{const _=E===h.ref,$=h.branch==="main"||h.branch==="master";return e.jsxs("button",{type:"button",onClick:()=>V(h.ref),className:P("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",_&&"bg-background/70"),title:h.ref,children:[e.jsx("span",{className:P("shrink-0 text-[10px]",$?"text-amber-500 dark:text-amber-400":"text-muted-foreground/60"),"aria-hidden":!0,children:$?"★":"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:h.ref}),_?e.jsx(We,{className:"h-3 w-3 shrink-0 text-primary"}):null]},h.ref)}),x.hasMore&&e.jsxs("button",{type:"button",onClick:Z,disabled:O,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:[O?e.jsx(ve,{className:"h-3 w-3 animate-spin"}):e.jsx(Mt,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"rounded-md border border-dashed border-border/40 px-2.5 py-2 text-[11px] text-muted-foreground",children:"No remote branches found."})]})]})}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a specific node first."}),U&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-1.5 text-[11px] text-destructive",children:U})]})]})}const Zn=20,eo=3,Pt="meshy-working-dir-recents-by-node";function to(t){return t.startsWith("/")||t.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(t)}function so(t){const a=t.trim();return a||"."}function Rt(t){const a=[],r=new Set;for(const n of t){const d=n.trim();if(!(!d||r.has(d))&&(r.add(d),a.push(d),a.length===eo))break}return a}function ao(t,a){const r=a.trim();return Rt(r?[r,...t]:t)}function Ys(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const a={};for(const[r,n]of Object.entries(t)){if(!r||!Array.isArray(n))continue;const d=n.filter(u=>typeof u=="string"),o=Rt(d);o.length>0&&(a[r]=o)}return a}function ro(t,a,r){if(!a)return t;const n=t[a]??[],d=ao(n,r);if(d.length===0){if(!(a in t))return t;const{[a]:o,...u}=t;return u}return{...t,[a]:d}}function no(t,a){var r;return a?((r=t[a])==null?void 0:r[0])??"":""}function oo(t){if(!t||typeof window>"u")return"";try{const a=window.localStorage.getItem(Pt);return a?no(Ys(JSON.parse(a)),t):""}catch{return""}}function lo(t,a,r){return t!=="auto"?a.find(n=>n.id===t)??null:r.length===1?r[0]??null:null}function io(t,a){const r=a.trim();return r?to(r)||!t?r:`${t.replace(/[/\\]+$/,"")}/${r}`:""}function co(t,a){return t?t.isAbsolute?t.currentPath:t.currentPath==="."||t.currentPath===""?t.rootPath||(a==null?void 0:a.workDir)||"Node root":t.currentPath:(a==null?void 0:a.workDir)??"Node root"}function Ft({value:t,onChange:a,assignTo:r,nodes:n,assignableNodes:d,layout:o="default",chipClassName:u,chipActiveClassName:f,chipInactiveClassName:p,labelClassName:g,triggerClassName:v}){const[l,c]=s.useState(!1),[m,N]=s.useState(null),[S,w]=s.useState(!1),[y,k]=s.useState(!1),[X,O]=s.useState(null),[T,ee]=s.useState(""),[L,U]=s.useState(!1),[D,B]=s.useState({}),pe=s.useRef(null),E=s.useMemo(()=>lo(r,n,d),[r,n,d]),V=E==null?void 0:E.id,H=s.useMemo(()=>V?D[V]??[]:[],[D,V]),R=s.useMemo(()=>t.trim()?io(E==null?void 0:E.workDir,t):"Use node default",[t,E==null?void 0:E.workDir]);s.useEffect(()=>{if(!(typeof window>"u"))try{const x=window.localStorage.getItem(Pt);if(!x)return;const Z=JSON.parse(x);B(Ys(Z))}catch{}},[]);const de=s.useCallback(x=>{V&&B(Z=>{const F=ro(Z,V,x);if(F===Z)return Z;if(typeof window<"u")try{window.localStorage.setItem(Pt,JSON.stringify(F))}catch{}return F})},[V]),K=s.useCallback((x,Z=!0)=>{const F=x.trim();a(F),Z&&F&&de(F),c(!1)},[a,de]),q=s.useCallback(async(x,Z=0,F=!1)=>{if(V){O(null),F?k(!0):w(!0);try{const be=await qa(V,{path:x,limit:Zn,offset:Z,directoriesOnly:!0,allowAbsolute:!0});N(oe=>F&&oe?{...be,entries:[...oe.entries,...be.entries]}:be)}catch(be){O(be instanceof Error?be.message:"Failed to browse directories"),F||N(null)}finally{w(!1),k(!1)}}},[V]),re=s.useRef(t);re.current=t;const ce=s.useRef(q);ce.current=q,s.useEffect(()=>{if(!l)return;const x=re.current;ee(x),U(!1),N(null),O(null),V&&ce.current(so(x))},[l,V]),s.useEffect(()=>{if(!l)return;const x=F=>{pe.current&&(pe.current.contains(F.target)||c(!1))},Z=F=>{F.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",x),document.addEventListener("keydown",Z),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",Z)}},[l]);const I=s.useCallback(x=>{q(x)},[q]),Q=s.useCallback(()=>{m&&q(m.currentPath,m.entries.length,!0)},[m,q]),le=o==="composer"?e.jsxs(A,{type:"button",variant:"ghost",onClick:()=>c(x=>!x),title:R,"aria-label":`Working directory: ${R}`,className:P(u,v,"min-w-0 max-w-full",t.trim()?f:p),children:[e.jsx(Ha,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:P("min-w-0 truncate",g),children:R})]}):e.jsxs(A,{type:"button",variant:"outline",onClick:()=>c(x=>!x),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:R,children:[e.jsx("span",{className:P("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:R}),e.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:E?E.name:"Manual"})]}),ne=co(m,E),ie=!!(m!=null&&m.parentPath);return e.jsxs("div",{className:P("relative inline-block",o==="composer"?"min-w-0 max-w-[60%] shrink":"w-full"),ref:pe,children:[o==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Se,{className:"text-sm font-medium",children:"Working directory"}),le]}):le,l&&e.jsxs("div",{className:P("absolute z-50 mt-2 w-[240px] overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",o==="composer"?"left-0":"left-0 right-0 w-auto min-w-[240px]"),children:[H.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(Mt,{className:"h-2.5 w-2.5"}),"Recent"]}),e.jsx("div",{className:"flex flex-col",children:H.map(x=>e.jsx("button",{type:"button",onClick:()=>K(x),className:"truncate rounded px-1.5 py-0.5 text-left font-mono text-[11px] text-foreground hover:bg-background/60",title:x,children:x},x))})]}),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:()=>(m==null?void 0:m.parentPath)&&I(m.parentPath),disabled:!ie||S,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-border/60 text-muted-foreground transition-colors hover:bg-background/60 hover:text-foreground disabled:opacity-40",title:"Parent directory",children:e.jsx(Xr,{className:"h-3 w-3"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:ne,children:ne}),m&&e.jsx("button",{type:"button",onClick:()=>K(m.isAbsolute?m.currentPath:m.currentPath==="."?"":m.currentPath),className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium text-foreground hover:bg-background/60",title:"Use this folder",children:"Use"})]}),e.jsxs("div",{className:"max-h-56 overflow-y-auto",children:[E?S?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(ve,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):m&&m.entries.length>0?e.jsxs(e.Fragment,{children:[m.entries.map(x=>e.jsxs("div",{className:"group flex items-stretch border-b border-border/30 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>K(x.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 ${x.path}`,children:[e.jsx(Wr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[11px] text-foreground",children:x.name})]}),e.jsx("button",{type:"button",onClick:()=>I(x.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 ${x.name}`,children:e.jsx(tt,{className:"h-3.5 w-3.5"})})]},x.path)),m.hasMore&&e.jsxs("button",{type:"button",onClick:Q,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(ve,{className:"h-3 w-3 animate-spin"}):e.jsx(Mt,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:X??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a node to browse."}),X&&m&&m.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[11px] text-destructive",children:X})]}),e.jsx("div",{className:"flex items-center gap-1 border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:L?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{value:T,onChange:x=>ee(x.target.value),onKeyDown:x=>{x.key==="Enter"&&T.trim()?(x.preventDefault(),K(T)):x.key==="Escape"&&(x.preventDefault(),U(!1),ee(t))},autoFocus:!0,placeholder:"Path (relative or absolute)",className:"h-7 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>K(T),disabled:!T.trim(),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-foreground hover:bg-background/60 disabled:opacity-40",title:"Apply","aria-label":"Apply manual path",children:e.jsx(We,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{U(!1),ee(t)},className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel","aria-label":"Cancel manual path",children:e.jsx(Ve,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>{ee(t),U(!0)},className:"flex h-7 flex-1 items-center justify-between rounded-md px-1.5 text-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Enter a manual path",children:[e.jsx("span",{children:"Manual input"}),e.jsx(at,{className:"h-3 w-3"})]})})]})]})}function Xs(t,a={}){const r=t.filter(n=>n.status==="online");return a.currentNodeRole!=="follower"||!a.leaderNodeId?r:r.filter(n=>n.id!==a.leaderNodeId)}function Gt({isCurrent:t}){return t?e.jsx(dn,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):e.jsx(rn,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function It(t,a){return t.map(r=>{const n=!!a&&r.id===a;return e.jsx(me,{value:r.id,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(Gt,{isCurrent:n}),e.jsx("span",{className:"truncate",children:r.name}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:n?"current":"remote"})]})},r.id)})}function uo(t){var n;const a=t.sessionId.trim(),r=t.cwd.trim();return!a||!r||!t.assignTo?null:{title:t.title.trim()||((n=t.defaultTitle)==null?void 0:n.trim())||void 0,agent:t.agent,sessionId:a,cwd:r,assignTo:t.assignTo,priority:t.priority,mode:t.mode??et}}function xo(){return zt.map(t=>e.jsx(me,{value:t.value,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:t.label}),t.description&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:t.description})]})},t.value))}function ho(t){if(!t)return"unknown time";const a=Date.parse(t);return Number.isNaN(a)?t:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(a)}function mo({nodes:t,currentNodeRole:a,currentNodeId:r,leaderNodeId:n,onCreated:d,onCancel:o,className:u,footerClassName:f,submitLabel:p="Load session",cancelLabel:g="Cancel",autoFocus:v=!1}){const l=s.useMemo(()=>Xs(t,{currentNodeRole:a,leaderNodeId:n}),[t,a,n]),c=s.useMemo(()=>{var h;return r&&l.some(_=>_.id===r)?r:((h=l[0])==null?void 0:h.id)??""},[l,r]),[m,N]=s.useState(""),[S,w]=s.useState("codex"),[y,k]=s.useState(""),[X,O]=s.useState(""),[T,ee]=s.useState(""),[L,U]=s.useState(c),[D,B]=s.useState("normal"),[pe,E]=s.useState(et),[V,H]=s.useState(!1),[R,de]=s.useState([]),[K,q]=s.useState(!1),[re,ce]=s.useState(null),I=s.useMemo(()=>R.find(h=>h.sessionId===y)??null,[R,y]);s.useEffect(()=>{L&&l.some(h=>h.id===L)||U(c)},[L,l,c]),s.useEffect(()=>{k(""),O(""),ee("")},[S,L]),s.useEffect(()=>{let h=!1;return L?(q(!0),ce(null),Wa(L,{agent:S,limit:50}).then(_=>{h||de(_.sessions)}).catch(_=>{h||(de([]),ce(_ instanceof Error?_.message:"Failed to load native sessions"))}).finally(()=>{h||q(!1)}),()=>{h=!0}):(de([]),ce(null),q(!1),()=>{h=!0})},[S,L]),s.useEffect(()=>{I&&(O(I.sessionId),ee(I.cwd))},[I]);const Q=s.useCallback(async h=>{h.preventDefault();const _=uo({title:m,defaultTitle:I==null?void 0:I.summary,agent:S,sessionId:X,cwd:T,assignTo:L,priority:D,mode:pe});if(_){H(!0);try{const $=await Ga(_);d($)}catch($){xe.error($ instanceof Error?$.message:"Failed to load native session")}finally{H(!1)}}},[m,I,S,X,T,L,D,pe,d]),le=!!(X.trim()&&T.trim()&&L),[ne,ie]=s.useState(!1),[x,Z]=s.useState(""),F=l.find(h=>h.id===L)??null,be=!!(r&&(F==null?void 0:F.id)===r),oe=s.useMemo(()=>{const h=x.trim().toLowerCase();return h?R.filter(_=>_.summary.toLowerCase().includes(h)||_.sessionId.toLowerCase().includes(h)||_.cwd.toLowerCase().includes(h)):R},[R,x]),je="h-9 w-auto gap-1.5 rounded-full border-border/60 bg-background/60 px-3 text-xs shadow-none transition-colors hover:bg-background/80";return e.jsxs("form",{onSubmit:Q,className:P("space-y-4",u),children:[e.jsxs("div",{className:"rounded-[24px] border border-border/60 bg-background/45 shadow-[0_20px_80px_-40px_rgba(0,0,0,0.6)]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/50 px-4 py-3",children:[e.jsxs(ye,{value:L,onValueChange:U,children:[e.jsx(we,{className:P(je),"aria-label":"Node",children:F?e.jsxs(e.Fragment,{children:[e.jsx(Gt,{isCurrent:be}),e.jsx("span",{className:"max-w-[10rem] truncate",children:F.name})]}):e.jsx(Te,{placeholder:"Node"})}),e.jsx(Ce,{children:It(l,r)})]}),e.jsxs(ye,{value:S,onValueChange:h=>w(h),children:[e.jsxs(we,{className:P(je),"aria-label":"Agent",children:[e.jsx(Ot,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:S})]}),e.jsxs(Ce,{children:[e.jsx(me,{value:"codex",children:"codex"}),e.jsx(me,{value:"claudecode",children:"claudecode"})]})]}),e.jsxs("div",{className:"relative ml-auto min-w-0 flex-1 sm:max-w-56",children:[e.jsx(Lt,{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(Ie,{value:x,onChange:h=>Z(h.target.value),placeholder:"Filter sessions",className:"h-9 rounded-full 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(Se,{className:"text-[10px] font-medium uppercase tracking-[0.2em] text-muted-foreground",children:K?"Loading...":`${oe.length} session${oe.length===1?"":"s"}`})}),e.jsxs("div",{className:"relative h-88 overflow-hidden rounded-2xl",children:[K&&e.jsx("div",{className:"absolute inset-x-0 top-0 z-10 h-0.5 overflow-hidden bg-primary/10",children:e.jsx("div",{className:"h-full w-1/3 animate-indeterminate-bar bg-primary/70"})}),e.jsxs("div",{className:"h-full space-y-1.5 overflow-y-auto pr-1 pt-1",children:[!L&&e.jsx("div",{className:"rounded-2xl border border-dashed border-border/60 bg-background/35 px-4 py-6 text-center text-xs text-muted-foreground",children:"Pick a node to load its recent sessions."}),L&&!K&&oe.length===0&&e.jsx("div",{className:"rounded-2xl border border-dashed border-border/60 bg-background/35 px-4 py-6 text-center text-xs text-muted-foreground",children:R.length===0?"No recent sessions on this node. Use Manual session ID under More options.":"No sessions match your filter."}),oe.map(h=>{const _=h.sessionId===y;return e.jsxs("button",{type:"button",onClick:()=>k(h.sessionId),className:P("flex w-full flex-col gap-1 rounded-2xl border px-3 py-2.5 text-left transition-colors",_?"border-primary/45 bg-primary/9 shadow-[0_18px_60px_-44px_hsl(var(--primary)/0.95)]":"border-border/55 bg-background/40 hover:border-border hover:bg-background/65"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:P("h-2 w-2 shrink-0 rounded-full",_?"bg-primary":"bg-border")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:h.summary}),e.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:ho(h.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:h.sessionId.slice(0,12)}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),e.jsx("span",{className:"truncate font-mono",children:h.cwd})]})]},h.sessionId)})]})]}),re&&e.jsx("p",{className:"px-1 pt-2 text-[11px] text-destructive",children:re})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",onClick:()=>ie(h=>!h),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-[0.2em] text-muted-foreground transition-colors hover:text-foreground","aria-expanded":ne,children:[e.jsx("span",{className:"h-px flex-1 bg-border/60","aria-hidden":!0}),e.jsx("span",{className:"shrink-0",children:ne?"Less options":"More options"}),e.jsx(Ue,{className:P("h-3.5 w-3.5 shrink-0 transition-transform",ne&&"rotate-180")}),e.jsx("span",{className:"h-px flex-1 bg-border/60","aria-hidden":!0})]}),ne&&e.jsxs("div",{className:"space-y-4 rounded-[22px] border border-border/60 bg-background/35 p-4",children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Se,{htmlFor:"native-session-id",className:"text-xs font-medium text-muted-foreground",children:"Session ID"}),e.jsx(Ie,{id:"native-session-id",type:"text",value:X,onChange:h=>{k(""),O(h.target.value)},placeholder:"ses_... or thread_...",autoFocus:v,className:"h-10 rounded-full border-border/70 bg-background/70 font-mono text-xs"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Se,{htmlFor:"native-session-title",className:"text-xs font-medium text-muted-foreground",children:"Task title"}),e.jsx(Ie,{id:"native-session-title",type:"text",value:m,onChange:h=>N(h.target.value),placeholder:"Optional",className:"h-10 rounded-full border-border/70 bg-background/70 text-sm"})]})]}),e.jsx(Ft,{value:T,onChange:h=>{k(""),ee(h)},assignTo:L,nodes:t,assignableNodes:l}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Se,{className:"text-xs font-medium text-muted-foreground",children:"Mode"}),e.jsxs(ye,{value:pe,onValueChange:h=>E(h),children:[e.jsx(we,{className:"h-10 rounded-full border-border/70 bg-background/70 text-sm",children:e.jsx(Te,{placeholder:"Select mode"})}),e.jsx(Ce,{children:xo()})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Se,{className:"text-xs font-medium text-muted-foreground",children:"Priority"}),e.jsxs(ye,{value:D,onValueChange:B,children:[e.jsx(we,{className:"h-10 rounded-full border-border/70 bg-background/70 text-sm",children:e.jsx(Te,{placeholder:"Select priority"})}),e.jsxs(Ce,{children:[e.jsx(me,{value:"low",children:"Low"}),e.jsx(me,{value:"normal",children:"Normal"}),e.jsx(me,{value:"high",children:"High"}),e.jsx(me,{value:"critical",children:"Critical"})]})]})]})]})]})]}),e.jsxs("div",{className:P("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",f),children:[o&&e.jsx(A,{type:"button",variant:"ghost",onClick:o,className:"rounded-full",children:g}),e.jsx(A,{type:"submit",disabled:!le||V,className:"rounded-full px-5",children:V?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"h-4 w-4 animate-spin"})," Loading..."]}):p})]})]})}function ms(){return Cs.map(t=>e.jsx(me,{value:t.value,disabled:t.disabled,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:t.label}),t.description&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:t.description})]})},t.value))}function ps(){return zt.map(t=>e.jsx(me,{value:t.value,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:t.label}),t.description&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:t.description})]})},t.value))}function po(t){var a;return((a=Cs.find(r=>r.value===t))==null?void 0:a.label)??t}function fo(t){var a;return((a=zt.find(r=>r.value===t))==null?void 0:a.label)??t}function Qs(t,a,r=!1){const n=t.trim();if(n)return n;const d=a.trim().split(`
|
|
124
|
-
`).map(o=>o.trim()).find(Boolean);return d?d.length>72?`${d.slice(0,69).trimEnd()}...`:d:r?"Image task":""}function bo(t){var u;const a=t.title.trim(),r=Qs(t.title,t.description,t.images.length>0),n=t.description.trim()||r,d=t.mode??et,o=Is(t.description,t.images);return!r||!n||!t.agent?null:{title:r,description:n,agent:t.agent,project:t.project.trim()||null,branch:((u=t.branch)==null?void 0:u.trim())||null,payload:{initialMessage:o,mode:d,titleSource:a?"manual":"derived"},priority:t.priority,assignTo:t.assignTo==="auto"?void 0:t.assignTo}}function go({nodes:t,currentNodeRole:a,currentNodeId:r,leaderNodeId:n,onCreated:d,onCancel:o,className:u,footerClassName:f,submitLabel:p="Create chat",cancelLabel:g="Cancel",autoFocus:v=!1,layout:l="default"}){const[c,m]=s.useState(""),[N,S]=s.useState(""),[w,y]=s.useState("claudecode"),[k,X]=s.useState(et),[O,T]=s.useState(""),[ee,L]=s.useState(""),[U,D]=s.useState("normal"),B=s.useMemo(()=>Xs(t,{currentNodeRole:a,leaderNodeId:n}),[t,a,n]),pe=s.useMemo(()=>{var M;return r&&B.some(se=>se.id===r)?r:((M=B[0])==null?void 0:M.id)??""},[B,r]),[E,V]=s.useState(pe),[H,R]=s.useState(!1),[de,K]=s.useState(!1),{images:q,error:re,fileInputRef:ce,pickImages:I,handleFileChange:Q,handlePaste:le,removeImage:ne}=Js(),ie=s.useMemo(()=>B.find(M=>M.id===E)??null,[E,B]),x=!!(r&&(ie==null?void 0:ie.id)===r),Z=po(w),F=fo(k);s.useEffect(()=>{E&&B.some(M=>M.id===E)||V(pe)},[E,B,pe]),s.useEffect(()=>{T(oo(E)),L("")},[E]),s.useEffect(()=>{L("")},[O]);const be=s.useCallback(async M=>{M.preventDefault();const se=bo({title:c,description:N,agent:w,project:O,branch:ee,priority:U,assignTo:E,mode:k,images:q});if(se){R(!0);try{const G=await Ja(se);d(G)}catch(G){xe.error(G instanceof Error?G.message:"Failed to create task")}finally{R(!1)}}},[c,N,w,O,ee,U,E,k,q,d]),oe=Qs(c,N,q.length>0),je=!!(oe&&w&&E&&(N.trim()||q.length>0)),h=s.useCallback(M=>{var se;M.nativeEvent.isComposing||M.key==="Enter"&&(M.ctrlKey||M.metaKey)&&je&&!H&&(M.preventDefault(),(se=M.currentTarget.form)==null||se.requestSubmit())},[je,H]),_=q.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3",children:q.map((M,se)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:$s(M),alt:M.filename??`attachment ${se+1}`,className:"h-24 w-24 rounded-2xl border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>ne(se),className:"absolute -top-2 -right-2 flex h-6 w-6 items-center justify-center rounded-full border border-border/70 bg-background text-muted-foreground transition-colors hover:text-foreground","aria-label":`Remove ${M.filename??`image ${se+1}`}`,children:e.jsx(Ve,{className:"h-3.5 w-3.5"})})]},`${M.filename??"image"}-${se}`))}),$=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Se,{className:"text-sm font-medium",children:"Assign to"}),e.jsxs(ye,{value:E,onValueChange:V,children:[e.jsx(we,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:e.jsx(Te,{placeholder:"Select node"})}),e.jsx(Ce,{children:It(B,r)})]})]}),j=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Se,{className:"text-sm font-medium",children:"Agent"}),e.jsxs(ye,{value:w,onValueChange:y,children:[e.jsx(we,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:e.jsx(Te,{placeholder:"Select agent"})}),e.jsx(Ce,{children:ms()})]})]}),z=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Se,{className:"text-sm font-medium",children:"Mode"}),e.jsxs(ye,{value:k,onValueChange:M=>X(M),children:[e.jsx(we,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:e.jsx(Te,{placeholder:"Select mode"})}),e.jsx(Ce,{children:ps()})]})]}),te=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Se,{className:"text-sm font-medium",children:"Priority"}),e.jsxs(ye,{value:U,onValueChange:D,children:[e.jsx(we,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:e.jsx(Te,{placeholder:"Select priority"})}),e.jsxs(Ce,{children:[e.jsx(me,{value:"low",children:"Low"}),e.jsx(me,{value:"normal",children:"Normal"}),e.jsx(me,{value:"high",children:"High"}),e.jsx(me,{value:"critical",children:"Critical"})]})]})]}),fe=e.jsx(Ft,{value:O,onChange:T,assignTo:E,nodes:t,assignableNodes:B}),ke=e.jsx(hs,{value:ee,onChange:L,project:O,assignTo:E,nodes:t,assignableNodes:B});return l==="composer"?e.jsxs("form",{onSubmit:be,className:P("space-y-4",u),children:[e.jsx("input",{ref:ce,type:"file",accept:"image/*",multiple:!0,onChange:Q,className:"hidden"}),(()=>{const M="chat-composer__chip h-9 w-auto gap-1.5 rounded-full px-3.5 text-xs shadow-none transition-colors",se="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",G="border-border/70 bg-background/55 text-foreground",Re=w==="claudecode",Ke=k===et;return e.jsxs("div",{className:"chat-composer space-y-2",children:[e.jsxs("div",{className:"rounded-[24px] border border-border/60 bg-background/45 shadow-[0_20px_80px_-40px_rgba(0,0,0,0.6)]",children:[e.jsxs("div",{className:"chat-composer__header flex min-w-0 items-center justify-between gap-3 px-4 pt-3",children:[e.jsxs(ye,{value:E,onValueChange:V,children:[e.jsx(we,{className:P(M,G,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${(ie==null?void 0:ie.name)??"unassigned"}`,"aria-label":`Assigned node: ${(ie==null?void 0:ie.name)??"unassigned"}`,children:ie?e.jsxs(e.Fragment,{children:[e.jsx(Gt,{isCurrent:x}),e.jsx("span",{className:"min-w-0 truncate",children:ie.name}),e.jsx("span",{className:"chat-composer__header-meta shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:x?"current":"remote"})]}):e.jsx(Te,{placeholder:"Select node"})}),e.jsx(Ce,{children:It(B,r)})]}),de?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ie,{id:"task-title-composer",type:"text",value:c,onChange:Ne=>m(Ne.target.value),onKeyDown:Ne=>{(Ne.key==="Enter"||Ne.key==="Escape")&&(Ne.preventDefault(),K(!1))},autoFocus:!0,placeholder:"Chat title",className:"h-8 w-48 min-w-0 rounded-full border-border/70 bg-background/55 px-3 text-xs shadow-none"}),e.jsx(A,{type:"button",variant:"ghost",size:"icon",onClick:()=>K(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-full text-muted-foreground hover:text-foreground",children:e.jsx(We,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>K(!0),className:"chat-composer__title-button flex min-w-0 items-center gap-1.5 rounded-full px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-background/55 hover:text-foreground",title:oe||"Title","aria-label":oe?`Edit title: ${oe}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:oe||"Title"}),e.jsx(at,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",value:N,onChange:Ne=>S(Ne.target.value),onKeyDown:h,onPaste:le,placeholder:"Ask anything...",rows:4,autoFocus:v,"aria-label":"Opening prompt",className:"min-h-[140px] w-full resize-none rounded-[24px] bg-transparent px-5 pt-2 pb-2 text-[15px] leading-7 text-foreground ring-offset-background placeholder:text-muted-foreground/70 focus-visible:outline-none"}),e.jsxs("div",{className:"chat-composer__rail flex flex-nowrap items-center gap-2 px-3 pb-3",children:[e.jsx(A,{type:"button",variant:"ghost",size:"icon",onClick:I,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-full text-muted-foreground hover:text-foreground",children:e.jsx(At,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsxs(ye,{value:w,onValueChange:y,children:[e.jsxs(we,{className:P(M,"chat-composer__icon-trigger",Re?se:G),title:`Agent: ${Z}`,"aria-label":`Agent: ${Z}`,children:[e.jsx(Ot,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:Z})]}),e.jsx(Ce,{children:ms()})]}),e.jsxs(ye,{value:k,onValueChange:Ne=>X(Ne),children:[e.jsxs(we,{className:P(M,"chat-composer__icon-trigger",Ke?se:G),title:`Mode: ${F}`,"aria-label":`Mode: ${F}`,children:[e.jsx(_n,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:F})]}),e.jsx(Ce,{children:ps()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[e.jsxs(ye,{value:U,onValueChange:D,children:[e.jsx(we,{"aria-label":`Priority: ${U}`,title:`Priority: ${U}`,className:P("h-9 w-9 justify-center gap-0 rounded-full p-0 text-xs shadow-none [&>svg:last-child]:hidden",U==="normal"?"border-transparent bg-transparent text-muted-foreground hover:bg-background/40":"border-border/70 bg-background/55",U==="critical"&&"text-destructive",U==="high"&&"text-amber-600 dark:text-amber-400",U==="low"&&"text-muted-foreground"),children:e.jsx(Zr,{className:P("h-4 w-4",U==="critical"&&"fill-destructive/20")})}),e.jsxs(Ce,{children:[e.jsx(me,{value:"low",children:"Low"}),e.jsx(me,{value:"normal",children:"Normal"}),e.jsx(me,{value:"high",children:"High"}),e.jsx(me,{value:"critical",children:"Critical"})]})]}),o&&e.jsxs(A,{type:"button",variant:"ghost",size:"sm",onClick:o,"aria-label":g,className:"chat-composer__cancel h-9 rounded-full px-4 text-xs text-muted-foreground",children:[e.jsx(Ve,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:g})]}),e.jsxs(A,{type:"submit",size:"icon",disabled:!je||H,className:"h-10 w-10 rounded-full shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[H?e.jsx(ve,{className:"h-4 w-4 animate-spin"}):e.jsx(Ks,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:H?"Creating chat":p})]})]})]})]}),e.jsx("div",{className:"chat-composer__location flex flex-wrap items-center gap-2 px-1",children:(()=>{const Ne="border-border/40 bg-muted/40 text-foreground/80 hover:bg-muted/60 hover:text-foreground";return e.jsxs(e.Fragment,{children:[e.jsx(Ft,{value:O,onChange:T,assignTo:E,nodes:t,assignableNodes:B,layout:"composer",chipClassName:M,chipActiveClassName:Ne,chipInactiveClassName:Ne,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"}),e.jsx(hs,{value:ee,onChange:L,project:O,assignTo:E,nodes:t,assignableNodes:B,layout:"composer",chipClassName:M,chipActiveClassName:Ne,chipInactiveClassName:Ne,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"})]})})()})]})})(),(_||re)&&e.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/45 p-4",children:[_,re&&e.jsx("div",{className:"text-xs text-destructive",children:re}),!re&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Paste screenshots directly into the prompt box or use the Images button."})]})]}):e.jsxs("form",{onSubmit:be,className:P("space-y-5",u),children:[e.jsx("input",{ref:ce,type:"file",accept:"image/*",multiple:!0,onChange:Q,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Se,{htmlFor:"task-description",className:"text-sm font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",value:N,onChange:M=>S(M.target.value),onKeyDown:h,onPaste:le,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:v,className:"flex min-h-[144px] w-full resize-none rounded-[22px] border border-border/70 bg-background/70 px-4 py-3 text-sm leading-6 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(A,{type:"button",variant:"outline",onClick:I,className:"rounded-2xl",children:[e.jsx(At,{className:"h-4 w-4"}),"Add images"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Upload or paste screenshots and reference images with the opening prompt."})]}),_,re&&e.jsx("p",{className:"text-xs text-destructive",children:re})]}),e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1fr)_220px_220px]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Se,{htmlFor:"task-title",className:"text-sm font-medium",children:"Chat title"}),e.jsx(Ie,{id:"task-title",type:"text",value:c,onChange:M=>m(M.target.value),placeholder:"Optional. Leave blank to derive it from the prompt.",className:"h-11 rounded-2xl border-border/70 bg-background/70"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:oe?`Will appear as: ${oe}`:"A title will be generated from the first line of the prompt."})]}),j,z]}),fe,ke,e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[te,$]}),e.jsxs("div",{className:P("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",f),children:[o&&e.jsx(A,{type:"button",variant:"ghost",onClick:o,className:"rounded-2xl",children:g}),e.jsx(A,{type:"submit",disabled:!je||H,className:"rounded-2xl px-5",children:H?"Creating...":p})]})]})}function vo({nodes:t,currentNodeRole:a,currentNodeId:r,leaderNodeId:n,onCreated:d,onCancel:o,defaultMode:u="chat",mode:f,onModeChange:p,layout:g="default",className:v,footerClassName:l,autoFocus:c=!1}){const[m,N]=s.useState(u),S=f!==void 0,w=S?f:m,y=k=>{S||N(k),p==null||p(k)};return e.jsxs("div",{className:P("space-y-4",v),children:[!S&&e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border/60 bg-background/45 p-1",children:[e.jsxs(A,{type:"button",variant:w==="chat"?"default":"ghost",onClick:()=>y("chat"),className:"flex-1 rounded-full",children:[e.jsx(Tn,{className:"h-4 w-4"}),"New chat"]}),e.jsxs(A,{type:"button",variant:w==="native"?"default":"ghost",onClick:()=>y("native"),className:"flex-1 rounded-full",children:[e.jsx(Kt,{className:"h-4 w-4"}),"Load session"]})]}),w==="chat"?e.jsx(go,{nodes:t,currentNodeRole:a,currentNodeId:r,leaderNodeId:n,onCreated:d,onCancel:o,footerClassName:l,submitLabel:g==="composer"?"Start chat":"Create chat",cancelLabel:"Cancel",autoFocus:c,layout:g}):e.jsx(mo,{nodes:t,currentNodeRole:a,currentNodeId:r,leaderNodeId:n,onCreated:d,onCancel:o,footerClassName:l,autoFocus:c})]})}const Je="72f988bf-86f1-41af-91ab-2d7cd011db47",Zs=`${Je} (MSIT)`;function jo({open:t,onOpenChange:a,onShare:r,onStopShare:n,sharing:d,stopping:o=!1,shareResult:u}){return e.jsx(Ss,{open:t,onOpenChange:a,children:e.jsxs(ys,{className:"max-w-md rounded-lg p-5",children:[e.jsx(ws,{className:"sr-only",children:"Share conversation"}),e.jsx(ko,{onOpenChange:a,onShare:r,onStopShare:n,sharing:d,stopping:o,shareResult:u})]})})}function ko({onOpenChange:t,onShare:a,onStopShare:r,sharing:n,stopping:d=!1,shareResult:o}){const[u,f]=s.useState((o==null?void 0:o.tenant)??Je),[p,g]=s.useState((o==null?void 0:o.scope)??"chat"),v=(o==null?void 0:o.url)??null,l=n||d;return s.useEffect(()=>{f((o==null?void 0:o.tenant)??Je),g((o==null?void 0:o.scope)??"chat")},[o==null?void 0:o.shareId,o==null?void 0:o.tenant,o==null?void 0:o.scope]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h2",{className:"text-base font-semibold leading-none tracking-tight",children:"Share conversation"}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Create a tenant-gated link for this task."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(No,{value:u,onChange:f,disabled:l}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Access"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(fs,{active:p==="chat",title:"Chat only",description:"Conversation transcript and opening prompt.",onClick:()=>g("chat")}),e.jsx(fs,{active:p==="filesPreview",title:"Chat, files and preview",description:"Transcript plus task output files and HTML preview.",onClick:()=>g("filesPreview")})]})]}),v&&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-md border border-border/70 bg-muted/30 px-3 py-2",children:[e.jsx("input",{readOnly:!0,value:v,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none","aria-label":"Shared link"}),e.jsx(A,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-full text-muted-foreground",onClick:()=>void Ge(v,"Shared link copied"),"aria-label":"Copy shared link",title:"Copy shared link",children:e.jsx(_s,{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(A,{variant:"outline",onClick:()=>t(!1),disabled:l,className:"h-8 text-xs",children:o?"Done":"Cancel"}),o&&r&&e.jsxs(A,{variant:"outline",onClick:()=>void r(),disabled:l,className:"h-8 border-destructive/30 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive",children:[d&&e.jsx(ve,{className:"h-3.5 w-3.5 animate-spin"}),"Stop share"]}),e.jsxs(A,{onClick:()=>void a({tenant:u,scope:p}),disabled:l,className:"h-8 text-xs",children:[n&&e.jsx(ve,{className:"h-3.5 w-3.5 animate-spin"}),o?"Update link":"Share link"]})]})]})}function No({value:t,onChange:a,disabled:r}){const[n,d]=s.useState(!1),[o,u]=s.useState(!1),[f,p]=s.useState(t),g=s.useRef(null);s.useEffect(()=>{p(t)},[t]),s.useEffect(()=>{if(!n)return;const l=m=>{var S;const N=m.target;N instanceof Node&&((S=g.current)!=null&&S.contains(N)||(d(!1),u(!1)))},c=m=>{m.key==="Escape"&&(d(!1),u(!1))};return document.addEventListener("mousedown",l),document.addEventListener("keydown",c),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",c)}},[n]);const v=l=>{const c=l.trim();c&&(a(c),p(c),u(!1),d(!1))};return e.jsxs("div",{className:"space-y-2 text-xs",ref:g,children:[e.jsx("div",{className:"font-medium text-foreground",children:"Tenant"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>!r&&d(l=>!l),disabled:r,className:"flex h-9 w-full items-center justify-between gap-2 rounded-xl 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:yo(t)}),e.jsx(Ue,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),n&&e.jsxs("div",{className:"absolute left-0 right-0 z-50 mt-2 overflow-hidden rounded-2xl border border-border/60 bg-background/95 text-xs shadow-lg backdrop-blur",children:[e.jsxs("button",{type:"button",onClick:()=>v(Je),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:Zs}),t===Je&&e.jsx(We,{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:o?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{value:f,onChange:l=>p(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),v(f))},autoFocus:!0,placeholder:"Tenant ID",className:"h-7 min-w-0 flex-1 rounded-md 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:()=>v(f),className:"flex h-7 w-7 items-center justify-center rounded-md hover:bg-background/60",children:e.jsx(We,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{p(t),u(!1)},className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-background/60 hover:text-foreground",children:e.jsx(Ve,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>u(!0),className:"flex h-7 w-full items-center justify-between rounded-md 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(at,{className:"h-3 w-3"})]})})]})]})]})}function yo(t){return t===Je?Zs:t}function fs({active:t,title:a,description:r,onClick:n}){return e.jsxs("button",{type:"button",onClick:n,className:t?"rounded-md border border-primary/45 bg-primary/10 px-3 py-2 text-left":"rounded-md border border-border/70 bg-background px-3 py-2 text-left hover:bg-muted/50",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:a}),e.jsx("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:r})]})}const wo=s.lazy(async()=>({default:(await Ut(()=>import("./FilesTab-CLLyWXEv.js"),__vite__mapDeps([0,1,2,3,4]))).FilesTab})),Co=s.lazy(async()=>({default:(await Ut(()=>import("./PreviewTab-C1SWykXF.js"),__vite__mapDeps([5,1,2,6]))).PreviewTab})),So=s.lazy(async()=>({default:(await Ut(()=>import("./DiffTab-BPE2fUnK.js"),__vite__mapDeps([7,1,2,3,4,8,6]))).DiffTab}));function _o({onToggleTasks:t,desktopTasksOpen:a,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:d,cluster:o,sseConnected:u,activeTab:f,setActiveTab:p,creatingTask:g,createMode:v,activeTask:l,assignedNode:c,taskLoading:m,taskError:N,displayEvents:S,initialPromptAlreadyInLogs:w,initialPrompt:y,supportsFollowUp:k,taskUnavailable:X,chatDisabled:O,chatDisabledReason:T,questionBypassEnabled:ee,isRunning:L,isStarting:U,hasPendingFollowUp:D,canCancel:B,canRetry:pe,onRetry:E,onCancel:V,onShareTask:H,onStopShareTask:R,onStartCreateTask:de,onCancelCreateTask:K,onCreateTask:q,onSendMessage:re,onQuestionBypassChange:ce,onSubmitQuestionResponse:I,messagesEndRef:Q}){const[le,ne]=s.useState(!1),[ie,x]=s.useState(!1),[Z,F]=s.useState(!1),[be,oe]=s.useState(!1),[je,h]=s.useState(!1),[_,$]=s.useState({}),[j,z]=s.useState(new Set),[te,fe]=s.useState(new Set),ke=s.useRef(0),M=s.useRef(!1),se=s.useCallback(Ee=>{const J=Ee.currentTarget,De=ke.current;if(ke.current=J.scrollTop,M.current)return;if(J.scrollHeight-J.scrollTop-J.clientHeight<30){ne(!1),M.current=!0,setTimeout(()=>{M.current=!1},300);return}J.scrollTop<De&&De-J.scrollTop>10&&ne(!0),J.scrollTop<=0&&ne(!0)},[]),G=(l==null?void 0:l.effectiveProjectPath)??(l==null?void 0:l.project)??"default workspace",Re=l?(c==null?void 0:c.name)??Es(l.assignedTo,o==null?void 0:o.nodes,l.assignedNodeName):"unassigned",Ke=l!=null&&l.assignedTo?e.jsxs(e.Fragment,{children:["Connecting session on node ",e.jsx("span",{className:"font-medium text-foreground",children:Re}),"..."]}):"Connecting session to an available node...",Ne=l?[{label:"Working dir",value:G,mono:!0},...l.branch?[{label:"Branch",value:l.branch,mono:!0}]:[],{label:"Agent",value:l.agent,mono:!0},{label:"Node",value:Re}]:[],Xe=!!(y&&!w),rt=Xe||S.length>0,Qe=L&&rt,Ze=(U||D||L)&&!Qe,Fe=(l==null?void 0:l.conversationKind)==="nativeSession",Be=l&&!j.has(l.id)?_[l.id]??l.activeShare??null:null;return g?e.jsx(Eo,{onToggleTasks:t,desktopTasksOpen:a,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:d,cluster:o,sseConnected:u,defaultMode:v,onCancel:K,onCreated:q}):!l&&m?e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[e.jsx("div",{className:"shrink-0 border-b border-border/60 px-3 py-3 sm:px-5",children:e.jsx($t,{onToggleTasks:t,desktopTasksOpen:a,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:d,cluster:o,sseConnected:u})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-full border border-primary/20 bg-primary/10 text-primary",children:e.jsx(ve,{className:"h-7 w-7 animate-spin"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"Loading conversation"}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx(ve,{className:"h-4 w-4 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):l?e.jsxs(Ts,{value:f,onValueChange:p,className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-3 py-3 sm:px-5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ea,{desktopTasksOpen:a,mobileTasksPanelOpen:r,onToggleTasks:t}),e.jsx("h2",{className:"min-w-0 truncate text-sm font-semibold tracking-tight text-foreground sm:text-lg",title:l.title,children:l.title}),Fe&&e.jsx(Pe,{variant:"outline",className:"shrink-0 rounded-full border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",children:"Native session"}),e.jsx(Ds,{status:l.status}),e.jsx(Ya,{priority:l.priority}),e.jsx(A,{variant:"outline",size:"icon",onClick:d,title:n?"Hide cluster":"Show cluster","aria-label":n?"Hide cluster":"Show cluster",className:"ml-auto h-7 w-7 shrink-0 rounded-full border-border/70 bg-background/60",children:n?e.jsx(Ht,{className:"h-4 w-4"}):e.jsx(Vs,{className:"h-4 w-4"})})]}),N&&e.jsx("div",{className:"mt-2 w-fit rounded-full border border-destructive/25 bg-destructive/10 px-2 py-1 text-[11px] text-destructive",children:N}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsxs(Ms,{className:"h-auto max-w-full overflow-x-auto rounded-full bg-muted/70 p-0.5",children:[e.jsx(Oe,{value:"transcript",className:"rounded-full px-2 py-0.5 text-[11px] sm:px-2.5",children:"Transcript"}),e.jsx(Oe,{value:"files",className:"rounded-full px-2 py-0.5 text-[11px] sm:px-2.5",children:"Files"}),e.jsx(Oe,{value:"preview",className:"rounded-full px-2 py-0.5 text-[11px] sm:px-2.5",children:"Preview"}),e.jsx(Oe,{value:"diff",className:"rounded-full px-2 py-0.5 text-[11px] sm:px-2.5",children:"Diff"})]}),L&&e.jsx(Pe,{variant:"outline",className:"hidden rounded-full border-amber-500/30 bg-amber-500/10 text-amber-700 sm:inline-flex dark:text-amber-300",children:"Working"}),X&&e.jsx(Pe,{variant:"outline",className:"hidden rounded-full border-destructive/25 bg-destructive/10 text-destructive sm:inline-flex",children:"Unavailable"}),e.jsxs("div",{className:"ml-auto flex items-center gap-2 text-[10px] text-muted-foreground",children:[e.jsxs("span",{className:"hidden sm:inline",children:["updated ",Xa(l.updatedAt)]}),e.jsx("span",{className:"font-mono",children:l.id.slice(0,8)}),pe&&e.jsxs(A,{variant:"outline",size:"sm",onClick:E,className:"h-7 shrink-0 rounded-full px-2 text-[11px]",children:[e.jsx(kn,{className:"h-3.5 w-3.5"}),"Retry"]}),e.jsxs(A,{type:"button",variant:"outline",size:"sm",disabled:X,title:X?"Unavailable tasks cannot be shared.":"Share conversation",className:"h-7 shrink-0 rounded-full border-primary/30 bg-primary/10 px-2 text-[11px] text-primary hover:bg-primary/15 hover:text-primary disabled:border-border/60 disabled:bg-muted/40 disabled:text-muted-foreground",onClick:()=>F(!0),children:[e.jsx(Cn,{className:"h-3.5 w-3.5"}),"Share"]})]})]})]}),e.jsx(ze,{value:"transcript",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"min-h-0 flex-1 touch-pan-y overflow-x-hidden overflow-y-auto overscroll-x-none px-3 py-5 sm:px-5",onScroll:se,children:e.jsxs("div",{className:"mx-auto flex max-w-[72rem] flex-col gap-5",children:[Xe&&y&&e.jsx(ds,{event:y,questionBypassEnabled:ee,onQuestionBypassChange:ce,onSubmitQuestionResponse:I,questionResponseDisabled:!k||O}),S.map((Ee,J)=>e.jsx(ds,{event:Ee,questionBypassEnabled:ee,onQuestionBypassChange:ce,onSubmitQuestionResponse:I,questionResponseDisabled:!k||O},Or("transcript",Ee,J))),!rt&&!Ze&&e.jsxs("div",{className:"rounded-[28px] border border-dashed border-border/70 bg-background/35 px-5 py-8 text-center",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:"Transcript is warming up"}),e.jsx("div",{className:"mt-2 text-[11px] leading-6 text-muted-foreground",children:m?"Fetching task output...":Fe?"This native session is attached. Transcript starts after the next message you send from Meshy.":"The opening prompt has been stored, but the agent has not emitted conversation output yet."})]}),(!k&&l.result||l.error)&&e.jsxs("div",{className:"space-y-3",children:[!k&&l.result&&e.jsxs("div",{className:"rounded-[26px] border border-border/70 bg-card/80 px-3 py-3",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Stored result"}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5 text-muted-foreground",children:JSON.stringify(l.result,null,2)})]}),l.error&&!te.has(l.id)&&e.jsxs("div",{className:"rounded-[26px] 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:()=>fe(Ee=>new Set(Ee).add(l.id)),className:"rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(Ve,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5",children:l.error})]})]}),Ze&&e.jsx(bs,{children:Ke}),Qe&&e.jsx(bs,{children:"The agent is still working on this conversation."}),e.jsx("div",{ref:Q})]})}),k?le?e.jsx(A,{size:"icon",onClick:()=>ne(!1),className:"absolute bottom-4 right-4 z-10 h-12 w-12 rounded-full shadow-lg",children:e.jsx(at,{className:"h-4 w-4"})}):e.jsx("div",{className:"shrink-0",children:e.jsx("div",{className:"mx-auto w-full max-w-[72rem]",children:e.jsx(Wn,{onSend:re,disabled:O,disabledReason:T,contextItems:Ne,placeholder:O?T:"Continue the conversation...",running:L||D,onStop:B?()=>x(!0):void 0})})}):e.jsx("div",{className:"shrink-0 border-t border-border/60 px-3 py-3 text-[11px] text-muted-foreground sm:px-5",children:"This task does not expose follow-up chat messages. Use Files, Preview, or Diff to inspect the result."})]})}),e.jsx(ze,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(s.Suspense,{fallback:e.jsx(jt,{label:"Loading files..."}),children:e.jsx(wo,{taskId:l.id})})}),e.jsx(ze,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(s.Suspense,{fallback:e.jsx(jt,{label:"Loading preview..."}),children:e.jsx(Co,{taskId:l.id})})}),e.jsx(ze,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(s.Suspense,{fallback:e.jsx(jt,{label:"Loading diff..."}),children:e.jsx(So,{taskId:l.id})})}),e.jsx(Nt,{open:ie,onOpenChange:x,children:e.jsxs(yt,{children:[e.jsxs(wt,{children:[e.jsx(Ct,{children:"Stop this task?"}),e.jsx(St,{children:"The task will stop and move to a cancelled state."})]}),e.jsxs(_t,{children:[e.jsx(Et,{children:"Keep running"}),e.jsx(Tt,{onClick:V,children:"Stop task"})]})]})}),e.jsx(jo,{open:Z,onOpenChange:F,sharing:be,stopping:je,shareResult:Be,onShare:async Ee=>{if(!l)return null;oe(!0);try{const J=await H(Ee);return J!=null&&J.url&&($(De=>({...De,[l.id]:J})),z(De=>{const Me=new Set(De);return Me.delete(l.id),Me})),J}finally{oe(!1)}},onStopShare:async()=>{if(!l)return!1;h(!0);try{const Ee=await R();return Ee!==!1&&($(J=>{const De={...J};return delete De[l.id],De}),z(J=>new Set(J).add(l.id))),Ee}finally{h(!1)}}})]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[e.jsx("div",{className:"shrink-0 border-b border-border/60 px-3 py-3 sm:px-5",children:e.jsx($t,{onToggleTasks:t,desktopTasksOpen:a,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:d,cluster:o,sseConnected:u})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsxs("div",{className:"w-full max-w-2xl text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-full border border-primary/20 bg-primary/10 text-primary",children:e.jsx(Ot,{className:"h-7 w-7"})}),e.jsx("h2",{className:"mt-5 text-xl font-semibold tracking-tight text-foreground sm:text-3xl",children:"No chat selected"}),e.jsx("p",{className:"mx-auto mt-3 max-w-xl text-[11px] leading-6 text-muted-foreground",children:"Open a task from the left sidebar to continue the conversation, or start a new task or load a native session."}),e.jsxs(A,{onClick:de,className:"mt-6 rounded-full px-5",children:[e.jsx(qt,{className:"h-4 w-4"}),"Start or load chat"]}),N&&e.jsx("div",{className:"mx-auto mt-4 max-w-lg rounded-[20px] border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:N})]})})]})}function bs({children:t}){return e.jsxs("div",{className:"flex items-center gap-1.5 rounded-[24px] border border-border/60 bg-background/45 px-3 py-2 text-[11px] text-muted-foreground",children:[e.jsx(ve,{className:"h-4 w-4 shrink-0 animate-spin"}),e.jsx("div",{className:"min-w-0 leading-5",children:t})]})}function Eo({onToggleTasks:t,desktopTasksOpen:a,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:d,cluster:o,sseConnected:u,defaultMode:f,onCancel:p,onCreated:g}){var m,N,S;const[v,l]=s.useState(f??"chat");s.useEffect(()=>{f&&l(f)},[f]);const c=e.jsx("div",{className:"flex items-center gap-1 rounded-full border border-border/60 bg-background/55 p-0.5 text-[11px] font-medium",children:[{value:"chat",label:"New chat",icon:qt},{value:"native",label:"Load session",icon:Kt}].map(w=>{const y=w.icon,k=w.value===v;return e.jsxs("button",{type:"button",onClick:()=>l(w.value),"aria-pressed":k,className:P("flex items-center gap-1.5 rounded-full px-2 py-1 transition-colors",k?"bg-primary text-primary-foreground shadow-[0_8px_24px_-12px_hsl(var(--primary)/0.7)]":"text-muted-foreground hover:bg-background/80 hover:text-foreground"),children:[e.jsx(y,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:w.label})]},w.value)})});return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[e.jsx("div",{className:"shrink-0 border-b border-border/60 px-3 py-3 sm:px-5",children:e.jsx($t,{onToggleTasks:t,desktopTasksOpen:a,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:d,cluster:o,sseConnected:u,centerSlot:c})}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsx("div",{className:"w-full max-w-2xl",children:e.jsx(vo,{nodes:(o==null?void 0:o.nodes)??[],currentNodeRole:(m=o==null?void 0:o.self)==null?void 0:m.role,currentNodeId:((N=o==null?void 0:o.self)==null?void 0:N.id)??null,leaderNodeId:((S=o==null?void 0:o.leader)==null?void 0:S.id)??null,mode:v,onModeChange:l,onCreated:g,onCancel:p,autoFocus:!0,layout:"composer"})})})]})}function $t({onToggleTasks:t,desktopTasksOpen:a,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:d,centerSlot:o}){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(ea,{desktopTasksOpen:a,mobileTasksPanelOpen:r,onToggleTasks:t})}),o&&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:o})}),e.jsx(A,{variant:"outline",size:"icon",onClick:d,title:n?"Hide cluster":"Show cluster","aria-label":n?"Hide cluster":"Show cluster",className:"h-7 w-7 shrink-0 rounded-full border-border/70 bg-background/60",children:n?e.jsx(Ht,{className:"h-4 w-4"}):e.jsx(Vs,{className:"h-4 w-4"})})]})}function ea({desktopTasksOpen:t,mobileTasksPanelOpen:a,onToggleTasks:r}){var d,o;const n=(o=(d=globalThis.window)==null?void 0:d.matchMedia("(min-width: 1024px)"))!=null&&o.matches?t:a;return e.jsx(A,{variant:"outline",size:"icon",onClick:r,title:n?"Hide tasks":"Show tasks","aria-label":n?"Hide tasks":"Show tasks",className:"h-7 w-7 shrink-0 rounded-full border-border/70 bg-background/60",children:n?e.jsx(Us,{className:"h-4 w-4"}):e.jsx(mn,{className:"h-4 w-4"})})}function gs({cluster:t,systemInfo:a,nodeNameById:r,nodeBlockingTaskCounts:n,eventTypeFilter:d,onEventTypeFilterChange:o,eventTypeOptions:u,filteredEvents:f,sseConnected:p,clusterLoading:g,clusterError:v,promotePending:l,onPromote:c,onAddNode:m,leavePending:N,onLeaveCluster:S,onToggleNodeDevTunnel:w,devTunnelNodeId:y,onClose:k}){var E,V,H;const X=((E=t==null?void 0:t.self)==null?void 0:E.role)==="leader",O=((V=t==null?void 0:t.self)==null?void 0:V.role)==="follower"&&!(t!=null&&t.leader),T=(t==null?void 0:t.self)??null,L=Qa((t==null?void 0:t.nodes)??[],T==null?void 0:T.id).filter(R=>R.id!==(T==null?void 0:T.id)),U=t!=null&&t.leader?t.nodes.find(R=>{var de;return R.id===((de=t.leader)==null?void 0:de.id)})??null:null,D=t!=null&&t.leader?t.leader.dashboardOrigin??(U==null?void 0:U.dashboardOrigin)??(a&&t.leader.id===(a.nodeId??a.id)?a.dashboardOrigin:void 0)??t.leader.endpoint:null,B=(T==null?void 0:T.role)==="leader"&&L.length===0,pe=(T==null?void 0:T.role)==="follower";return e.jsx("aside",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-[32px] border border-border/60 bg-background/84 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:e.jsxs(Ts,{defaultValue:"overview",className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-3 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold tracking-tight",children:"Operations"}),e.jsx("p",{className:"mt-0.5 text-[10px] text-muted-foreground",children:"Node, cluster, and live events."})]}),e.jsx(A,{variant:"ghost",size:"icon",onClick:k,className:"h-7 w-7 rounded-full",children:e.jsx(Ht,{className:"h-4 w-4"})})]}),e.jsxs(Ms,{className:"mt-2 grid h-auto w-full grid-cols-3 rounded-full bg-muted/70 p-0.5",children:[e.jsx(Oe,{value:"overview",className:"rounded-full px-2 py-0.5 text-[11px]",children:"Overview"}),e.jsx(Oe,{value:"nodes",className:"rounded-full px-2 py-0.5 text-[11px]",children:"Nodes"}),e.jsx(Oe,{value:"events",className:"rounded-full px-2 py-0.5 text-[11px]",children:"Live events"})]})]}),e.jsx(ze,{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-3 py-3",children:e.jsxs("div",{className:"space-y-4",children:[T&&e.jsx(vs,{node:T,systemInfo:a,blockingTaskCount:n.get(T.id)??0,devTunnelNodeId:y,onToggleNodeDevTunnel:w,showActions:!1,defaultExpanded:!1}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:"Cluster snapshot"}),e.jsx(Pe,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:p?"Connected":"Reconnecting"})]}),g&&!t?e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx(ve,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):v&&!t?e.jsx("div",{className:"rounded-[18px] border border-destructive/20 bg-destructive/10 px-2.5 py-2 text-[11px] text-destructive",children:v}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(He,{label:"Term",value:String((t==null?void 0:t.term)??0)}),e.jsx(He,{label:"Nodes",value:String((t==null?void 0:t.nodes.length)??0)}),e.jsx(He,{label:"Pending",value:String((t==null?void 0:t.taskSummary.pending)??0)}),e.jsx(He,{label:"Running",value:String((t==null?void 0:t.taskSummary.running)??0)}),e.jsx(He,{label:"Completed",value:String((t==null?void 0:t.taskSummary.completed)??0)}),e.jsx(He,{label:"Failed",value:String((t==null?void 0:t.taskSummary.failed)??0)})]}),e.jsxs("div",{className:"space-y-2 rounded-[20px] border border-border/60 bg-background/45 px-2.5 py-2.5",children:[e.jsx(Le,{label:"Leader",value:((H=t==null?void 0:t.leader)==null?void 0:H.name)??"None"}),e.jsx(Le,{label:"Leader URL",value:D??"Unavailable",mono:!0,action:D?e.jsx(st,{label:"Copy leader URL",onClick:()=>void Ge(D,"Leader URL copied")}):void 0}),e.jsx(Le,{label:"Feed",value:p?"Receiving live updates":"Reconnecting to event stream"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:O&&e.jsxs(A,{variant:"outline",size:"sm",onClick:c,disabled:l,className:"h-7 rounded-full px-2.5 text-[11px]",children:[l&&e.jsx(ve,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})})]})]})]})})}),e.jsx(ze,{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-3 py-3",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:"This node"}),B?e.jsx(A,{variant:"outline",size:"sm",onClick:m,className:"h-7 rounded-full px-2.5 text-[11px]",children:"Join node"}):pe?e.jsxs(A,{variant:"outline",size:"sm",onClick:S,disabled:N,className:"h-7 rounded-full px-2.5 text-[11px]",children:[N&&e.jsx(ve,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),T&&e.jsx(vs,{node:T,systemInfo:a,blockingTaskCount:n.get(T.id)??0,devTunnelNodeId:y,onToggleNodeDevTunnel:w,showActions:!0,defaultExpanded:!0})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"text-[11px] font-medium text-foreground",children:["Peer nodes (",L.length,")"]}),L.length>0?e.jsx("div",{className:"space-y-2",children:L.map(R=>e.jsx(To,{node:R,isLeader:!!X,blockingTaskCount:n.get(R.id)??0,devTunnelNodeId:y,onToggleNodeDevTunnel:w},R.id))}):e.jsx("div",{className:"rounded-[20px] border border-dashed border-border/70 bg-background/35 px-3 py-3 text-[11px] text-muted-foreground",children:"No peer nodes are connected yet."})]})]})})}),e.jsx(ze,{value:"events",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col px-3 py-3",children:[e.jsxs("div",{className:"mb-3 space-y-2",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-foreground",children:[e.jsx(Za,{className:P("h-4 w-4",p?"text-emerald-500":"text-destructive")}),"Live events"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsxs(ye,{value:d,onValueChange:o,children:[e.jsx(we,{className:"h-7 min-w-[11rem] flex-1 rounded-full border-border/70 bg-background/55 text-[11px] sm:max-w-[15rem]",children:e.jsx(Te,{placeholder:"Event type"})}),e.jsx(Ce,{children:u.map(R=>e.jsx(me,{value:R,className:"text-[11px]",children:R==="all"?"All event types":R},R))})]}),e.jsx(Pe,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:p?"Connected":"Reconnecting"})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(er,{events:f,maxHeight:"100%",emptyTitle:d==="all"?"No live events yet":"No matching events",emptyDescription:d==="all"?"Cluster activity appears here as it happens.":`No "${d}" events are in the current stream.`,nodeNameById:r})})]})})]})})}function vs({node:t,systemInfo:a,blockingTaskCount:r,devTunnelNodeId:n,onToggleNodeDevTunnel:d,showActions:o=!0,defaultExpanded:u=!1}){const[f,p]=s.useState(u),g=(a==null?void 0:a.dashboardOrigin)??t.dashboardOrigin,v=t.devtunnelEndpoint??t.endpoint,l=g??t.endpoint,c=(a==null?void 0:a.workDir)??t.workDir,m=Hs(t,a==null?void 0:a.transportType),N=Wt(t,a==null?void 0:a.transportType),S=N&&Ye((a==null?void 0:a.transportType)??t.transportType)?!0:qs(t,a==null?void 0:a.transportType),w=r>0;return e.jsxs("section",{className:"rounded-[28px] border border-primary/20 bg-primary/8 shadow-[0_24px_80px_-60px_hsl(var(--primary)/0.9)]",children:[e.jsxs("button",{type:"button",onClick:()=>p(y=>!y),className:"w-full px-3 py-2 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[f?e.jsx(Ue,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):e.jsx(tt,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx(As,{status:t.status}),e.jsx("span",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Current node"}),e.jsx("a",{href:l,target:"_blank",rel:"noreferrer",onClick:y=>y.stopPropagation(),className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(Ls,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 pl-6",children:[e.jsx("span",{className:"text-[11px] font-semibold tracking-tight text-foreground",children:t.name}),e.jsx(Ps,{role:t.role}),e.jsx(Pe,{variant:"outline",className:"rounded-full border-primary/30 bg-background/60 text-[10px] capitalize",children:t.status})]})]}),f&&e.jsxs("div",{className:"space-y-3 border-t border-primary/15 px-3 pb-3 pt-2.5",children:[e.jsxs("div",{className:"space-y-2 rounded-[16px] border border-primary/20 bg-background/72 px-2 py-2",children:[e.jsx(Le,{label:"Node ID",value:t.id,mono:!0}),g&&e.jsx(Le,{label:"Dashboard",value:g,mono:!0,action:e.jsx(st,{label:"Copy dashboard URL",onClick:()=>void Ge(g,"Dashboard URL copied")})}),e.jsx(Le,{label:"Node URL",value:v,mono:!0,action:e.jsx(st,{label:"Copy node URL",onClick:()=>void Ge(v,"Node URL copied")})}),c&&e.jsx(Le,{label:"Workspace",value:c,mono:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[e.jsx(Dt,{label:"Transport",value:m}),a&&e.jsx(Dt,{label:"Uptime",value:tr(a.uptime),mono:!0})]}),e.jsx(Bs,{capabilities:t.capabilities,action:o&&S?e.jsxs(A,{variant:"outline",size:"sm",onClick:()=>d(t),disabled:n===t.id||w,className:"h-7 rounded-full px-2.5 text-[11px]",title:w?"Finish assigned or running tasks before changing remote access":void 0,children:[n===t.id&&e.jsx(ve,{className:"h-3.5 w-3.5 animate-spin"}),N?"Disable Remote Access":"Enable Remote Access"]}):void 0}),o&&S&&w&&e.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[r," active task",r===1?"":"s"," on this node."]})]})]})}function To({node:t,isLeader:a,blockingTaskCount:r,devTunnelNodeId:n,onToggleNodeDevTunnel:d}){const[o,u]=s.useState(!1),f=t.dashboardOrigin,p=t.devtunnelEndpoint??t.endpoint,g=f??t.endpoint,v=Hs(t),l=Wt(t),c=qs(t),m=r>0;return e.jsxs("div",{className:"rounded-[20px] border border-border/60 bg-background/45",children:[e.jsxs("button",{type:"button",onClick:()=>u(N=>!N),className:"w-full px-3 py-2 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[o?e.jsx(Ue,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(tt,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx(As,{status:t.status}),e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Peer node"}),e.jsx("a",{href:g,target:"_blank",rel:"noreferrer",onClick:N=>N.stopPropagation(),className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(Ls,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-1.5 pl-5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-foreground",children:t.name}),e.jsx(Ps,{role:t.role}),e.jsx(Pe,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px] capitalize",children:t.status})]})]}),o&&e.jsxs("div",{className:"space-y-3 border-t border-border/50 px-3 pb-3 pt-2.5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Le,{label:"Node ID",value:t.id,mono:!0}),f&&e.jsx(Le,{label:"Dashboard",value:f,mono:!0,action:e.jsx(st,{label:"Copy dashboard URL",onClick:()=>void Ge(f,"Dashboard URL copied")})}),e.jsx(Le,{label:"Node URL",value:p,mono:!0,action:e.jsx(st,{label:"Copy node URL",onClick:()=>void Ge(p,"Node URL copied")})}),t.workDir&&e.jsx(Le,{label:"Workspace",value:t.workDir,mono:!0}),e.jsx(Dt,{label:"Transport",value:v})]}),e.jsx(Bs,{capabilities:t.capabilities,action:a&&c?e.jsxs(A,{variant:"outline",size:"sm",onClick:()=>d(t),disabled:n===t.id||m,className:"h-7 rounded-full px-2.5 text-[11px]",title:m?"Finish assigned or running tasks before changing remote access":void 0,children:[n===t.id&&e.jsx(ve,{className:"h-3.5 w-3.5 animate-spin"}),l?"Disable Remote Access":"Enable Remote Access"]}):void 0}),a&&c&&m&&e.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[r," active task",r===1?"":"s"," on this node."]})]})]})}function st({label:t,onClick:a}){return e.jsx(A,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-full text-muted-foreground",onClick:a,"aria-label":t,title:t,children:e.jsx(_s,{className:"h-3.5 w-3.5"})})}function Do(t,a,r,n){var u;if(!t)return{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Select a task to continue the conversation."};const d=((u=a==null?void 0:a.self)==null?void 0:u.role)==="follower";return t.assignedTo!==null&&t.assignedNodeAvailable===!1?{taskUnavailable:!0,chatDisabled:!0,chatDisabledReason:`${t.assignedNodeName??"Assigned node"} is unavailable. Leave the cluster on that node or re-run the task elsewhere.`}:d?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Follower nodes are read-only. Use the leader dashboard to manage chat, or leave the cluster first."}:r||n?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Waiting for the current turn to finish..."}:ct.has(t.status)||t.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:ct.has(t.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}var ut="Checkbox",[Mo]=or(ut),[Ao,Jt]=Mo(ut);function Lo(t){const{__scopeCheckbox:a,checked:r,children:n,defaultChecked:d,disabled:o,form:u,name:f,onCheckedChange:p,required:g,value:v="on",internal_do_not_use_render:l}=t,[c,m]=ar({prop:r,defaultProp:d??!1,onChange:p,caller:ut}),[N,S]=s.useState(null),[w,y]=s.useState(null),k=s.useRef(!1),X=N?!!u||!!N.closest("form"):!0,O={checked:c,disabled:o,setChecked:m,control:N,setControl:S,name:f,form:u,value:v,hasConsumerStoppedPropagationRef:k,required:g,defaultChecked:$e(d)?!1:d,isFormControl:X,bubbleInput:w,setBubbleInput:y};return e.jsx(Ao,{scope:a,...O,children:Po(l)?l(O):n})}var ta="CheckboxTrigger",sa=s.forwardRef(({__scopeCheckbox:t,onKeyDown:a,onClick:r,...n},d)=>{const{control:o,value:u,disabled:f,checked:p,required:g,setControl:v,setChecked:l,hasConsumerStoppedPropagationRef:c,isFormControl:m,bubbleInput:N}=Jt(ta,t),S=Rs(d,v),w=s.useRef(p);return s.useEffect(()=>{const y=o==null?void 0:o.form;if(y){const k=()=>l(w.current);return y.addEventListener("reset",k),()=>y.removeEventListener("reset",k)}},[o,l]),e.jsx(Vt.button,{type:"button",role:"checkbox","aria-checked":$e(p)?"mixed":p,"aria-required":g,"data-state":la(p),"data-disabled":f?"":void 0,disabled:f,value:u,...n,ref:S,onKeyDown:os(a,y=>{y.key==="Enter"&&y.preventDefault()}),onClick:os(r,y=>{l(k=>$e(k)?!0:!k),N&&m&&(c.current=y.isPropagationStopped(),c.current||y.stopPropagation())})})});sa.displayName=ta;var Yt=s.forwardRef((t,a)=>{const{__scopeCheckbox:r,name:n,checked:d,defaultChecked:o,required:u,disabled:f,value:p,onCheckedChange:g,form:v,...l}=t;return e.jsx(Lo,{__scopeCheckbox:r,checked:d,defaultChecked:o,disabled:f,required:u,onCheckedChange:g,name:n,form:v,value:p,internal_do_not_use_render:({isFormControl:c})=>e.jsxs(e.Fragment,{children:[e.jsx(sa,{...l,ref:a,__scopeCheckbox:r}),c&&e.jsx(oa,{__scopeCheckbox:r})]})})});Yt.displayName=ut;var aa="CheckboxIndicator",ra=s.forwardRef((t,a)=>{const{__scopeCheckbox:r,forceMount:n,...d}=t,o=Jt(aa,r);return e.jsx(sr,{present:n||$e(o.checked)||o.checked===!0,children:e.jsx(Vt.span,{"data-state":la(o.checked),"data-disabled":o.disabled?"":void 0,...d,ref:a,style:{pointerEvents:"none",...t.style}})})});ra.displayName=aa;var na="CheckboxBubbleInput",oa=s.forwardRef(({__scopeCheckbox:t,...a},r)=>{const{control:n,hasConsumerStoppedPropagationRef:d,checked:o,defaultChecked:u,required:f,disabled:p,name:g,value:v,form:l,bubbleInput:c,setBubbleInput:m}=Jt(na,t),N=Rs(r,m),S=rr(o),w=nr(n);s.useEffect(()=>{const k=c;if(!k)return;const X=window.HTMLInputElement.prototype,T=Object.getOwnPropertyDescriptor(X,"checked").set,ee=!d.current;if(S!==o&&T){const L=new Event("click",{bubbles:ee});k.indeterminate=$e(o),T.call(k,$e(o)?!1:o),k.dispatchEvent(L)}},[c,S,o,d]);const y=s.useRef($e(o)?!1:o);return e.jsx(Vt.input,{type:"checkbox","aria-hidden":!0,defaultChecked:u??y.current,required:f,disabled:p,name:g,value:v,form:l,...a,tabIndex:-1,ref:N,style:{...a.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});oa.displayName=na;function Po(t){return typeof t=="function"}function $e(t){return t==="indeterminate"}function la(t){return $e(t)?"indeterminate":t?"checked":"unchecked"}const Bt=s.forwardRef(({className:t,...a},r)=>e.jsx(Yt,{ref:r,className:P("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...a,children:e.jsx(ra,{className:P("flex items-center justify-center text-current"),children:e.jsx(We,{className:"h-3.5 w-3.5"})})}));Bt.displayName=Yt.displayName;function js({toolbarTasks:t,activeTaskId:a,tasksLoading:r,tasksError:n,isLeader:d,scope:o,agentFilter:u,nodeFilter:f,taskKindFilter:p,agentOptions:g,nodeOptions:v,nodeNameById:l,searchQuery:c,selectedTaskIds:m,allVisibleTasksSelected:N,someVisibleTasksSelected:S,canBatchArchive:w,onSearchChange:y,onScopeChange:k,onAgentFilterChange:X,onNodeFilterChange:O,onTaskKindFilterChange:T,onToggleTaskSelected:ee,onToggleAllVisibleTasks:L,onBatchArchive:U,onBatchDelete:D,onCreateTask:B,onSelectTask:pe,onClose:E}){const[V,H]=s.useState(!!c),[R,de]=s.useState(!1),[K,q]=s.useState(!1),re=s.useRef(null),ce=s.useRef(null),I=s.useRef(null),Q=m.size,le=o!=="active"||f!=="all"||u!=="all"||p!=="all",ne=c.trim().length>0,[ie,x]=s.useState(new Set),[Z,F]=s.useState(new Set),be=s.useMemo(()=>lr(t,l),[t,l]),oe=be.length===1,je=!oe||le||ne,h=oe&&(le||ne),_=s.useCallback(j=>{x(z=>{const te=new Set(z);return te.has(j)?te.delete(j):te.add(j),te})},[]),$=s.useCallback(j=>{F(z=>{const te=new Set(z);return te.has(j)?te.delete(j):te.add(j),te})},[]);return s.useEffect(()=>{c&&H(!0)},[c]),s.useEffect(()=>{var j;V&&((j=re.current)==null||j.focus())},[V]),s.useEffect(()=>{if(!V)return;const j=te=>{var ke;const fe=te.target;fe instanceof Node&&((ke=ce.current)!=null&&ke.contains(fe)||H(!1))},z=te=>{te.key==="Escape"&&H(!1)};return document.addEventListener("mousedown",j),document.addEventListener("keydown",z),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("keydown",z)}},[V]),s.useEffect(()=>{if(!K)return;const j=te=>{var ke;const fe=te.target;fe instanceof Node&&((ke=I.current)!=null&&ke.contains(fe)||q(!1))},z=te=>{te.key==="Escape"&&q(!1)};return document.addEventListener("mousedown",j),document.addEventListener("keydown",z),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("keydown",z)}},[K]),e.jsxs("aside",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-[32px] border border-border/60 bg-background/80 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-3 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-lg font-semibold tracking-tight text-foreground",children:"Tasks"}),e.jsx(A,{variant:"ghost",size:"icon",onClick:E,className:"rounded-full",children:e.jsx(Us,{className:"h-4 w-4"})})]}),e.jsxs("div",{ref:ce,className:"mt-4 flex items-center gap-1.5",children:[e.jsxs("div",{ref:I,className:P("relative flex items-stretch transition-[flex] duration-200",V?"flex-[2]":"flex-1"),children:[e.jsxs(A,{onClick:()=>{q(!1),B("chat")},className:"flex-1 justify-start rounded-l-[22px] rounded-r-none px-3 py-6 text-left shadow-[0_24px_60px_-32px_hsl(var(--primary)/0.95)]",children:[e.jsx(qt,{className:"h-4 w-4"}),"New chat"]}),e.jsx(A,{onClick:()=>q(j=>!j),"aria-label":"More chat options","aria-haspopup":"menu","aria-expanded":K,className:"w-9 rounded-l-none rounded-r-[22px] border-l border-primary-foreground/20 px-0 py-6 shadow-[0_24px_60px_-32px_hsl(var(--primary)/0.95)]",children:e.jsx(Ue,{className:P("h-3.5 w-3.5 transition-transform",K&&"rotate-180")})}),K&&e.jsx("div",{role:"menu",className:"absolute left-0 right-0 top-full z-20 mt-2 overflow-hidden rounded-2xl border border-border/60 bg-popover p-1 shadow-[0_20px_60px_-30px_rgba(0,0,0,0.6)]",children:e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{q(!1),B("native")},className:"flex w-full items-center gap-1.5 rounded-xl px-2 py-2 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted",children:[e.jsx(Kt,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{className:"flex-1 truncate whitespace-nowrap",children:"Load session"}),e.jsx("span",{className:"shrink-0 text-[9px] uppercase tracking-[0.18em] text-muted-foreground",children:"native"})]})})]}),V?e.jsxs("div",{className:"flex min-w-0 flex-[3] items-center gap-1.5",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(Lt,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Ie,{ref:re,value:c,onChange:j=>y(j.target.value),placeholder:"Search tasks",className:"h-11 rounded-full border-border/70 bg-background/60 pl-11 text-[11px]"})]}),e.jsx(A,{variant:"outline",size:"icon",onClick:()=>H(!1),className:"rounded-full border-border/70 bg-background/60",children:e.jsx(ir,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(A,{variant:"outline",onClick:()=>H(!0),className:P("rounded-full border-border/70 bg-background/60 px-3 text-[11px]",c&&"border-primary/40 bg-primary/8 text-primary"),children:[e.jsx(Lt,{className:"h-4 w-4"}),"Search"]}),e.jsx(A,{variant:R||le?"secondary":"outline",size:"icon",onClick:()=>de(j=>!j),className:P("shrink-0 rounded-full border-border/70 bg-background/60",le&&"border-primary/40 bg-primary/8 text-primary"),title:"Filters",children:e.jsx(tn,{className:"h-4 w-4"})})]})]}),(R||le)&&e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[e.jsxs(ye,{value:o,onValueChange:j=>k(j),children:[e.jsx(we,{className:"h-7 rounded-full border-border/70 bg-background/55 text-[12px]",children:e.jsx(Te,{})}),e.jsx(Ce,{children:dr.map(j=>e.jsx(me,{value:j.value,className:"text-[12px]",children:j.label},j.value))})]}),e.jsxs(ye,{value:f,onValueChange:O,children:[e.jsx(we,{className:"h-7 rounded-full border-border/70 bg-background/55 text-[12px]",children:e.jsx(Te,{placeholder:"Node"})}),e.jsx(Ce,{children:v.map(j=>e.jsx(me,{value:j.value,className:"text-[12px]",children:j.label},j.value))})]}),e.jsxs(ye,{value:u,onValueChange:X,children:[e.jsx(we,{className:"h-7 rounded-full border-border/70 bg-background/55 text-[12px]",children:e.jsx(Te,{placeholder:"Agent"})}),e.jsx(Ce,{children:g.map(j=>e.jsx(me,{value:j,className:"text-[12px]",children:j==="all"?"All agents":j},j))})]}),e.jsxs(ye,{value:p,onValueChange:j=>T(j),children:[e.jsx(we,{className:"h-7 rounded-full border-border/70 bg-background/55 text-[12px]",children:e.jsx(Te,{placeholder:"Type"})}),e.jsx(Ce,{children:cr.map(j=>e.jsx(me,{value:j.value,className:"text-[12px]",children:j.label},j.value))})]})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2",children:be.length>0?e.jsxs("div",{className:"space-y-1",children:[d&&e.jsxs("div",{className:"mb-1 flex items-center justify-between px-1 py-1",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:[e.jsx(Bt,{checked:S&&!N?"indeterminate":N,onCheckedChange:j=>L(j===!0),"aria-label":"Select all visible tasks"}),e.jsx("span",{children:"Select all"})]}),Q>0&&e.jsx(A,{variant:"ghost",size:"sm",onClick:()=>L(!1),className:"h-7 rounded-full px-2 text-[11px]",children:"Clear"})]}),be.map(j=>{const z=j.nodeId??"__unassigned__",te=je&&!h&&ie.has(z);return e.jsxs("div",{className:"space-y-1",children:[je&&e.jsxs("button",{type:"button",onClick:()=>_(z),"aria-expanded":!te,className:"flex w-full items-center gap-1.5 rounded-xl px-2 py-1.5 text-left text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",children:[te?e.jsx(tt,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Ue,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:j.nodeName}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-muted-foreground/60",children:j.dirs.reduce((fe,ke)=>fe+ke.tasks.length,0)})]}),!te&&j.dirs.map(fe=>{const ke=`${z}::${fe.path}`,M=Z.has(ke),se=ur(fe.path);return e.jsxs("div",{className:P("space-y-1",je&&"pl-3"),children:[e.jsxs("button",{type:"button",onClick:()=>$(ke),"aria-expanded":!M,title:fe.path,className:"flex w-full items-center gap-1.5 rounded-xl px-2 py-1 text-left text-[11px] font-medium text-muted-foreground/80 transition-colors hover:bg-muted/40 hover:text-foreground",children:[M?e.jsx(tt,{className:"h-3 w-3 shrink-0"}):e.jsx(Ue,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate font-mono",children:se}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-muted-foreground/50",children:fe.tasks.length})]}),!M&&e.jsx("div",{className:P("space-y-2",je?"pl-2":"pl-0"),children:fe.tasks.map(G=>e.jsxs("div",{className:P("flex items-start gap-1.5 rounded-[24px] border px-2 py-2 transition-all",G.id===a?"border-primary/45 bg-primary/9 shadow-[0_24px_80px_-54px_hsl(var(--primary)/0.95)]":"border-border/60 bg-background/40 hover:border-border hover:bg-background/60"),children:[d&&e.jsx("div",{className:"flex shrink-0 pt-1",onClick:Re=>Re.stopPropagation(),children:e.jsx(Bt,{checked:m.has(G.id),onCheckedChange:Re=>ee(G.id,Re===!0),"aria-label":`Select ${G.title}`})}),e.jsx("button",{type:"button",onClick:()=>pe(G.id),className:"min-w-0 flex-1 text-left",children:e.jsxs("div",{className:"flex items-start gap-1.5",children:[e.jsx("span",{className:P("mt-1 h-2.5 w-2.5 shrink-0 rounded-full",xr(G.status))}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[11px] font-semibold text-foreground",children:G.title}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"font-mono",children:G.agent}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),e.jsx("span",{children:hr(G.updatedAt)})]}),e.jsxs("div",{className:"mt-3 flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx(Ds,{status:G.status}),G.conversationKind==="nativeSession"&&e.jsx(Pe,{variant:"outline",className:"border-sky-500/25 bg-sky-500/10 text-[10px] text-sky-700 dark:text-sky-300",children:"native"}),G.activeShare&&e.jsx(Pe,{variant:"outline",className:"border-primary/25 bg-primary/10 text-[10px] text-primary",children:"shared"}),G.assignedNodeAvailable===!1&&e.jsx(Pe,{variant:"outline",className:"border-destructive/25 bg-destructive/10 text-[10px] text-destructive",children:"unavailable"})]})]})]})})]},G.id))})]},ke)})]},z)})]}):e.jsx("div",{className:"rounded-[24px] border border-dashed border-border/70 bg-background/35 px-3 py-5 text-[11px] text-muted-foreground",children:r?"Loading tasks...":n||"No tasks match this view."})}),d&&Q>0?e.jsxs("div",{className:"shrink-0 border-t border-border/60 px-3 py-3",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Batch actions"}),e.jsxs("div",{className:"mt-2 text-[11px] font-semibold text-foreground",children:[Q," task",Q!==1?"s":""," selected"]}),!w&&e.jsx("div",{className:"mt-2 text-[11px] text-muted-foreground",children:"Only completed, failed, cancelled, or archived tasks can be archived."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsxs(Nt,{children:[e.jsx(ls,{asChild:!0,children:e.jsxs(A,{variant:"outline",size:"sm",disabled:!w,className:"rounded-full",children:[e.jsx(Jr,{className:"h-3.5 w-3.5"}),"Archive"]})}),e.jsxs(yt,{children:[e.jsxs(wt,{children:[e.jsxs(Ct,{children:["Archive ",Q," task",Q!==1?"s":"","?"]}),e.jsx(St,{children:"Archived tasks stay hidden from the default task view and can be reopened from the archived scope."})]}),e.jsxs(_t,{children:[e.jsx(Et,{children:"Cancel"}),e.jsx(Tt,{onClick:U,disabled:!w,children:"Archive"})]})]})]}),e.jsxs(Nt,{children:[e.jsx(ls,{asChild:!0,children:e.jsxs(A,{variant:"destructive",size:"sm",className:"rounded-full",children:[e.jsx(Mn,{className:"h-3.5 w-3.5"}),"Delete"]})}),e.jsxs(yt,{children:[e.jsxs(wt,{children:[e.jsxs(Ct,{children:["Delete ",Q," task",Q!==1?"s":"","?"]}),e.jsx(St,{children:"This removes the selected tasks and their saved logs."})]}),e.jsxs(_t,{children:[e.jsx(Et,{children:"Cancel"}),e.jsx(Tt,{onClick:D,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}):null]})}async function Ro(t,a){var r,n;try{const d=await mr(t,a);if((n=(r=globalThis.navigator)==null?void 0:r.clipboard)!=null&&n.writeText)try{await globalThis.navigator.clipboard.writeText(d.url),xe.success("Shared link copied")}catch{xe.success("Shared link created")}else xe.success("Shared link created");return d}catch(d){xe.error(d instanceof Error?d.message:"Failed to create shared link");return}}async function Fo(t){try{return await pr(t),xe.success("Shared link stopped"),!0}catch(a){return xe.error(a instanceof Error?a.message:"Failed to stop shared link"),!1}}function Io(t,a,r){const n=s.useCallback(()=>{a(),r()},[a,r]),d=s.useCallback(async u=>{if(!t)return;const f=await Ro(t.id,u);return f&&n(),f},[t,n]),o=s.useCallback(async()=>{if(!t)return!1;const u=await Fo(t.id);return u&&n(),u},[t,n]);return{handleShareTask:d,handleStopShareTask:o}}function ks(t,a,r){const n=s.useRef(a);n.current=a,s.useEffect(()=>{let u=0,f=0;const p=l=>{const c=l.touches[0];c&&(u=c.clientX,f=c.clientY)},g=l=>{var S,w,y,k;const c=l.changedTouches[0];if(!c)return;const m=c.clientX-u;Math.abs(c.clientY-f)>100||Math.abs(m)<50||(m>0?(w=(S=n.current).onSwipeRight)==null||w.call(S):(k=(y=n.current).onSwipeLeft)==null||k.call(y))},v=(t==null?void 0:t.current)??document;return v.addEventListener("touchstart",p,{passive:!0}),v.addEventListener("touchend",g,{passive:!0}),()=>{v.removeEventListener("touchstart",p),v.removeEventListener("touchend",g)}},[t,r==null?void 0:r.threshold,r==null?void 0:r.maxVertical])}const $o="(min-width: 1024px)",Bo="(min-width: 1280px)";function Ns(t){var a,r,n;return((n=(r=(a=globalThis.window)==null?void 0:a.matchMedia)==null?void 0:r.call(a,t))==null?void 0:n.matches)??!1}function Oo(){const[t,a]=s.useState(!0),[r,n]=s.useState(!1),[d,o]=s.useState(()=>Ns(Bo)),u=s.useRef(null),f=s.useRef(null);ks(u,{onSwipeLeft:()=>n(!1)}),ks(f,{onSwipeRight:()=>o(!1)});const p=s.useCallback(()=>{if(Ns($o)){a(g=>!g);return}n(g=>!g)},[]);return{desktopTasksOpen:t,mobileTasksPanelOpen:r,mobileTasksPanelRef:u,operationsOpen:d,operationsPanelRef:f,setMobileTasksPanelOpen:n,setOperationsOpen:o,toggleTasksPanel:p}}function zo({isLeader:t,selfId:a,subscribe:r}){const[n,d]=s.useState([]),[o,u]=s.useState(!0),[f,p]=s.useState(null),g=s.useCallback(async()=>{try{const v=await fr({assignedTo:!t&&a?a:void 0,limit:100});d(v),p(null)}catch(v){p(v instanceof Error?v.message:"Failed to load tasks")}finally{u(!1)}},[t,a]);return br(g,1e4),s.useEffect(()=>{g()},[g]),s.useEffect(()=>r("task",g),[r,g]),{fetchTasks:g,setTasks:d,tasks:n,tasksError:f,tasksLoading:o}}function Uo(t,a){return a.data.nodeId===t.self.id||a.data.name===t.self.name||a.data.endpoint===t.self.endpoint}function Vo({cluster:t,subscribe:a}){s.useEffect(()=>{var r;if(((r=t==null?void 0:t.self)==null?void 0:r.role)==="leader")return a("node",n=>{const d=String(n.data.name??n.data.nodeId??"node"),o=Uo(t,n);n.type==="node.joined"&&!o&&xe.success(`${d} joined the cluster`),n.type==="node.left"&&!o&&xe.message(`${d} left the cluster`)})},[t,a])}const Ko=[0,300,1e3,2e3];function qo({task:t,getActiveTaskId:a,setLogs:r,setPendingMessages:n}){t.conversationKind==="nativeSession"&&(async()=>{for(const d of Ko){if(d>0&&await new Promise(o=>setTimeout(o,d)),a()!==t.id)return;try{const o=await Fs(t.id);if(a()!==t.id||(r(u=>Os(u,o.logs)),n(u=>zs(u,o.logs)),o.total>0))return}catch{}}})()}function Ho(){var ts,ss,as;const{id:t}=gr(),a=vr(),r=jr(),{cluster:n,systemInfo:d,events:o,sseConnected:u,subscribe:f,refresh:p,loading:g,error:v}=kr(),l=s.useMemo(()=>Nr(a.state),[a.state]),[c,m]=s.useState(null),[N,S]=s.useState("active"),[w,y]=s.useState("all"),[k,X]=s.useState("all"),[O,T]=s.useState("all"),[ee,L]=s.useState(""),U=s.useDeferredValue(ee),{desktopTasksOpen:D,mobileTasksPanelOpen:B,mobileTasksPanelRef:pe,operationsOpen:E,operationsPanelRef:V,setMobileTasksPanelOpen:H,setOperationsOpen:R,toggleTasksPanel:de}=Oo(),[K,q]=s.useState(()=>!!(l!=null&&l.draftNewTask)),[re,ce]=s.useState(()=>(l==null?void 0:l.createMode)??"chat"),[I,Q]=s.useState(()=>l!=null&&l.draftNewTask?{route:l.returnRoute??"/",taskId:l.returnTaskId??null}:null),[le,ne]=s.useState(!1),[ie,x]=s.useState("transcript"),[Z,F]=s.useState("all"),[be,oe]=s.useState(!1),[je,h]=s.useState(null),[_,$]=s.useState([]),[j,z]=s.useState([]),[te,fe]=s.useState(!1),[ke,M]=s.useState(null),[se,G]=s.useState(new Set),[Re,Ke]=s.useState(!1),[Ne,Xe]=s.useState(!1),[rt,Qe]=s.useState(null),Ze=s.useRef(null),Fe=s.useRef(null),Be=((ts=n==null?void 0:n.self)==null?void 0:ts.role)==="leader",Ee=(ss=n==null?void 0:n.self)==null?void 0:ss.id;Vo({cluster:n,subscribe:f});const{fetchTasks:J,setTasks:De,tasks:Me,tasksError:ia,tasksLoading:xt}=zo({isLeader:Be,selfId:Ee,subscribe:f}),ge=s.useMemo(()=>[...Me].sort((i,b)=>b.updatedAt-i.updatedAt),[Me]),da=s.useMemo(()=>{const i=new Map;for(const b of(n==null?void 0:n.nodes)??[]){const C=Ln(ge,b.id);C>0&&i.set(b.id,C)}return i},[n==null?void 0:n.nodes,ge]),Ae=s.useMemo(()=>ge.filter(i=>!yr(i,N)||w!=="all"&&i.agent!==w||!wr(i,O)||k==="unassigned"&&i.assignedTo||k!=="all"&&k!=="unassigned"&&Cr(i.assignedTo,n==null?void 0:n.nodes,i.assignedNodeName)!==k?!1:U.trim()?Sr(i,U):!0),[ge,N,w,O,k,U]);s.useEffect(()=>{G(i=>{const b=Bn(i,Ae.map(C=>C.id));return b.size===i.size?i:b})},[Ae]),s.useEffect(()=>{Be||G(new Set)},[Be]);const ca=s.useMemo(()=>["all",...Array.from(new Set(ge.map(i=>i.agent))).sort()],[ge]),ua=s.useMemo(()=>{const b=Array.from(new Set(ge.map(C=>C.assignedTo).filter(C=>!!C))).map(C=>{const ue=ge.find(Y=>Y.assignedTo===C);return(n==null?void 0:n.nodes.find(Y=>Y.id===C))??{id:C,name:Es(C,n==null?void 0:n.nodes,ue==null?void 0:ue.assignedNodeName)}}).sort((C,ue)=>C.name.localeCompare(ue.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...b.map(C=>({value:C.name.toLowerCase(),label:C.name}))]},[ge,n==null?void 0:n.nodes]),Xt=s.useMemo(()=>{const i=new Map;for(const b of(n==null?void 0:n.nodes)??[])i.set(b.id,b.name);for(const b of ge)b.assignedTo&&b.assignedNodeName&&!i.has(b.assignedTo)&&i.set(b.assignedTo,b.assignedNodeName);return i},[n==null?void 0:n.nodes,ge]),ht=s.useMemo(()=>["all",...Array.from(new Set(o.map(i=>i.type))).sort()],[o]),xa=s.useMemo(()=>Z==="all"?o:o.filter(i=>i.type===Z),[o,Z]),ha=Ae.length>0&&Ae.every(i=>se.has(i.id)),ma=Ae.some(i=>se.has(i.id)),pa=On(Ae,se);s.useEffect(()=>{l!=null&&l.draftNewTask&&(q(!0),Q({route:l.returnRoute??"/",taskId:l.returnTaskId??null}))},[l]),s.useEffect(()=>{Z!=="all"&&!ht.includes(Z)&&F("all")},[Z,ht]),s.useEffect(()=>{xs(t,K)&&!c&&ge[0]&&m(ge[0].id)},[t,K,c,ge]),s.useEffect(()=>{var i;xs(t,K)&&(c&&Me.some(b=>b.id===c)||m(((i=ge[0])==null?void 0:i.id)??null))},[t,K,c,ge,Me]);const ae=Rn({routeTaskId:t,creatingTask:K,internalSelectedTaskId:c,sortedTaskIds:ge.map(i=>i.id)}),qe=s.useMemo(()=>Me.find(i=>i.id===ae)??null,[Me,ae]);s.useEffect(()=>{Fe.current=ae??null},[ae]);const nt=s.useCallback(()=>{h(null),$([]),z([]),M(null)},[]),_e=s.useCallback(async()=>{const i=ae;if(i)try{const b=await _r(i);if(Fe.current!==i)return;h(b),M(null)}catch(b){if(Fe.current!==i)return;h(null),$([]),z([]),M(b instanceof Error?b.message:"Failed to load task")}finally{Fe.current===i&&fe(!1)}},[ae]),ot=s.useCallback(async()=>{const i=ae;if(i)try{const b=await Fs(i);if(Fe.current!==i)return;$(C=>Os(C,b.logs)),z(C=>zs(C,b.logs))}catch{}},[ae]);s.useEffect(()=>{if(!ae){h(null),$([]),z([]),M(null),fe(!1);return}x("transcript"),h(qe),$([]),z([]),M(null),fe(!0),_e(),ot()},[ae,ot,_e]),s.useEffect(()=>{var b;if(!ae||K||xt||Me.some(C=>C.id===ae))return;const i=((b=ge[0])==null?void 0:b.id)??null;m(i),nt(),s.startTransition(()=>{r(i?`/tasks/${i}`:"/",{state:null})})},[ae,nt,K,r,ge,Me,xt]),s.useEffect(()=>{qe&&h(i=>!i||i.id!==qe.id?i:{...i,...qe})},[qe]),s.useEffect(()=>f("task.updated",i=>{De(b=>In(b,i.data))}),[f]),s.useEffect(()=>{if(ae)return f("task",i=>{const b=i.data.taskId;if(!(typeof b!="string"||b!==ae)){if(i.type==="task.output"){const C=i.data.event;if(C){$(Y=>zr(Y,C));const ue=cs(C);ue&&z(Y=>Ur(Y,ue))}}i.type==="task.updated"&&_e(),i.type==="task.status"&&(_e(),ot())}})},[f,ae,_e,ot]),s.useEffect(()=>{var i;ie==="transcript"&&((i=Ze.current)==null||i.scrollIntoView({behavior:"smooth"}))},[_,j,ie]);const W=je??qe,fa=W!=null&&W.assignedTo?(n==null?void 0:n.nodes.find(i=>i.id===W.assignedTo))??null:null,mt=j.length>0,ba=W?Er.has(W.agent):!1,pt=(W==null?void 0:W.status)==="running",ga=W?ct.has(W.status):!1,va=W?ct.has(W.status)||Tr.has(W.status):!1,ja=!!(W&&Be&&W.status==="failed"),ft=s.useMemo(()=>Do(W,n,mt,!!pt),[W,n,mt,pt]),bt=s.useMemo(()=>Vr([..._,...j.map(i=>kt(i.content,i.timestamp))]),[_,j]),lt=s.useMemo(()=>{if(!W||W.conversationKind==="nativeSession")return null;const i=Kr(W);if(i.length>0)return kt(i,new Date(W.createdAt).toISOString());if(bt.length>0)return null;const b=qr(W.description||W.title);return b.length>0?kt(b,new Date(W.createdAt).toISOString()):null},[W,bt]),gt=s.useMemo(()=>lt?cs(lt):null,[lt]),ka=s.useMemo(()=>gt?Hr(_,gt):!1,[_,gt]),vt=s.useCallback((i="chat")=>{const b={route:t?`/tasks/${t}`:"/",taskId:ae};Q(b),ce(i),q(!0),s.startTransition(()=>{r("/",{state:{draftNewTask:!0,returnRoute:b.route,returnTaskId:b.taskId,createMode:i}})})},[t,ae,r]),Na=s.useCallback(()=>{var b;const i=(I==null?void 0:I.taskId)??((b=ge[0])==null?void 0:b.id)??null;q(!1),Q(null),m(i),s.startTransition(()=>{r((I==null?void 0:I.route)??"/",{state:null})})},[I,ge,r]),Qt=s.useCallback(i=>{q(!1),Q(null),m(i),s.startTransition(()=>{r(`/tasks/${i}`,{state:null})})},[r]),ya=s.useCallback(i=>{Fe.current=i.id,q(!1),Q(null),De(b=>Fn(b,i)),h(i),$([]),z([]),M(null),fe(!1),x("transcript"),m(i.id),qo({task:i,getActiveTaskId:()=>Fe.current,setLogs:$,setPendingMessages:z}),J(),s.startTransition(()=>{r(`/tasks/${i.id}`,{state:null})})},[J,r]),it=s.useCallback(async i=>{if(!ae)return!1;const b=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`;z(C=>[...C,{id:b,content:i,timestamp:new Date().toISOString()}]);try{return await Dr(ae,i),_e(),!0}catch(C){return z(ue=>ue.filter(Y=>Y.id!==b)),xe.error(C instanceof Error?C.message:"Failed to send message"),!1}},[ae,_e]),wa=s.useCallback(i=>{it(i)},[it]),Ca=s.useCallback(i=>it(i),[it]),Sa=s.useCallback(async()=>{if(W)try{await Mr(W.id),_e(),J()}catch(i){xe.error(i instanceof Error?i.message:"Failed to cancel task")}},[W,_e,J]),{handleShareTask:_a,handleStopShareTask:Ea}=Io(W,_e,J),Ta=s.useCallback(async()=>{if(W)try{await Ar(W.id),_e(),J()}catch(i){xe.error(i instanceof Error?i.message:"Failed to retry task")}},[W,_e,J]),dt=s.useCallback((i,b=!1)=>{const C=zn(Ae,i);return m(C),(b||!C)&&nt(),s.startTransition(()=>{r(C?`/tasks/${C}`:"/",{state:null})}),C},[nt,Ae,r]),Da=s.useCallback((i,b)=>{G(C=>{const ue=new Set(C);return b?ue.add(i):ue.delete(i),ue})},[]),Ma=s.useCallback(i=>{if(!i){G(new Set);return}G(new Set(Ae.map(b=>b.id)))},[Ae]),Aa=s.useCallback(async()=>{const i=Array.from(se);if(i.length!==0)try{const{results:b}=await Lr(i),C=b.filter(Y=>!Y.ok),ue=b.filter(Y=>Y.ok).map(Y=>Y.id);ae&&ue.includes(ae)&&dt(ue),C.length>0?xe.error(`Failed to archive ${C.length} task(s): ${C.map(Y=>Y.error??Y.id).join(", ")}`):xe.success(`Archived ${ue.length} task(s)`),G(new Set(C.map(Y=>Y.id))),J()}catch(b){xe.error(b instanceof Error?b.message:"Failed to archive tasks")}},[ae,J,dt,se]),La=s.useCallback(async()=>{const i=Array.from(se);if(i.length!==0)try{const{results:b}=await Pr(i),C=b.filter(Y=>!Y.ok),ue=b.filter(Y=>Y.ok).map(Y=>Y.id);ae&&ue.includes(ae)&&dt(ue,!0),C.length>0?xe.error(`Failed to delete ${C.length} task(s): ${C.map(Y=>Y.error??Y.id).join(", ")}`):xe.success(`Deleted ${ue.length} task(s)`),G(new Set(C.map(Y=>Y.id))),J()}catch(b){xe.error(b instanceof Error?b.message:"Failed to delete tasks")}},[ae,J,dt,se]),Pa=s.useCallback(async()=>{Ke(!0);try{await Rr(),p()}catch(i){xe.error(i instanceof Error?i.message:"Failed to promote node")}finally{Ke(!1)}},[p]),Ra=s.useCallback(async()=>{Xe(!0);try{await Fr(),xe.success("This node left the remote cluster and is leading itself again."),J(),_e(),p()}catch(i){xe.error(i instanceof Error?i.message:"Failed to leave cluster")}finally{Xe(!1)}},[_e,J,p]),Fa=s.useCallback(async i=>{var rs;const b=!Wt(i),C=i.id===((rs=n==null?void 0:n.self)==null?void 0:rs.id),ue=C?(d==null?void 0:d.transportType)??i.transportType:i.transportType,Y=C&&!b&&Ye(ue);Qe(i.id);try{Y?await Ir("direct"):await $r(i.id,b),xe.success(b?`Enabled remote access on ${i.name}`:`Disabled remote access on ${i.name}`),p()}catch(ns){xe.error(ns instanceof Error?ns.message:"Failed to update remote access")}finally{Qe(null)}},[(as=n==null?void 0:n.self)==null?void 0:as.id,p,d==null?void 0:d.transportType]),Zt={toolbarTasks:Ae,activeTaskId:ae,tasksLoading:xt,tasksError:ia,isLeader:Be,scope:N,agentFilter:w,nodeFilter:k,taskKindFilter:O,agentOptions:ca,nodeOptions:ua,nodeNameById:Xt,searchQuery:ee,selectedTaskIds:se,allVisibleTasksSelected:ha,someVisibleTasksSelected:ma,canBatchArchive:pa,onSearchChange:L,onScopeChange:S,onAgentFilterChange:y,onNodeFilterChange:X,onTaskKindFilterChange:T,onToggleTaskSelected:Da,onToggleAllVisibleTasks:Ma,onBatchArchive:Aa,onBatchDelete:La,onCreateTask:vt,onSelectTask:Qt,onClose:de},es={cluster:n,systemInfo:d,nodeNameById:Xt,nodeBlockingTaskCounts:da,eventTypeFilter:Z,onEventTypeFilterChange:F,eventTypeOptions:ht,filteredEvents:xa,sseConnected:u,clusterLoading:g,clusterError:v,promotePending:Re,onPromote:Pa,onAddNode:()=>ne(!0),leavePending:Ne,onLeaveCluster:Ra,onToggleNodeDevTunnel:Fa,devTunnelNodeId:rt,onClose:()=>R(!1)};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden pb-2",children:[e.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[e.jsx("div",{className:P("hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",D?"lg:mr-3 lg:w-[24rem]":"lg:w-0 lg:overflow-hidden"),children:D&&e.jsx(js,{...Zt})}),e.jsx("section",{className:"min-h-0 min-w-0 flex-1",children:e.jsx(_o,{onToggleTasks:de,desktopTasksOpen:D,mobileTasksPanelOpen:B,operationsOpen:E,onToggleOperations:()=>R(i=>!i),cluster:n,sseConnected:u,activeTab:ie,setActiveTab:x,creatingTask:K,createMode:re,activeTask:W,assignedNode:fa,taskLoading:te,taskError:ke,displayEvents:bt,initialPromptAlreadyInLogs:ka,initialPrompt:lt,supportsFollowUp:ba,taskUnavailable:ft.taskUnavailable,chatDisabled:ft.chatDisabled,chatDisabledReason:ft.chatDisabledReason,questionBypassEnabled:be,isRunning:!!pt,isStarting:ga,hasPendingFollowUp:mt,canCancel:!!va,canRetry:!!ja,onRetry:Ta,onCancel:Sa,onShareTask:_a,onStopShareTask:Ea,onStartCreateTask:vt,onCancelCreateTask:Na,onCreateTask:ya,onSendMessage:wa,onQuestionBypassChange:oe,onSubmitQuestionResponse:Ca,messagesEndRef:Ze})}),e.jsx("div",{className:P("hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",E?"xl:ml-3 xl:w-[26rem]":"xl:w-0 xl:overflow-hidden"),children:E&&e.jsx(gs,{...es})})]}),E&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:()=>R(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),e.jsx("div",{ref:V,className:"fixed inset-y-0 right-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 xl:hidden",children:e.jsx(gs,{...es})})]}),B&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close task list",onClick:()=>H(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),e.jsx("div",{ref:pe,className:"fixed inset-y-0 left-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 lg:hidden",children:e.jsx(js,{...Zt,onCreateTask:i=>{H(!1),vt(i)},onSelectTask:i=>{H(!1),Qt(i)},onClose:()=>H(!1)})})]}),e.jsx(Ss,{open:le,onOpenChange:ne,children:e.jsx(Hn,{onAdded:()=>{ne(!1),p()}})})]})}const Xo=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:Ho},Symbol.toStringTag,{value:"Module"}));export{Xo as D,us as G};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import{c as h,r as g,j as n,i as P,C as T,b as E,X as ie,x as oe,G as Q,aU as ae,y as ce,B as le}from"./index-Cpz4J5-T.js";/**
|
|
2
|
-
* @license lucide-react v1.7.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const de=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],ue=h("brain",de);/**
|
|
7
|
-
* @license lucide-react v1.7.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const me=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],fe=h("circle-question-mark",me);/**
|
|
12
|
-
* @license lucide-react v1.7.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const pe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],xe=h("circle",pe);/**
|
|
17
|
-
* @license lucide-react v1.7.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const ge=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]],he=h("list-checks",ge);/**
|
|
22
|
-
* @license lucide-react v1.7.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const ye=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],be=h("loader-circle",ye);/**
|
|
27
|
-
* @license lucide-react v1.7.0 - ISC
|
|
28
|
-
*
|
|
29
|
-
* This source code is licensed under the ISC license.
|
|
30
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const je=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],Ne=h("shield-alert",je);/**
|
|
32
|
-
* @license lucide-react v1.7.0 - ISC
|
|
33
|
-
*
|
|
34
|
-
* This source code is licensed under the ISC license.
|
|
35
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const we=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ke=h("shield-check",we);/**
|
|
37
|
-
* @license lucide-react v1.7.0 - ISC
|
|
38
|
-
*
|
|
39
|
-
* This source code is licensed under the ISC license.
|
|
40
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const _e=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Se=h("user",_e);/**
|
|
42
|
-
* @license lucide-react v1.7.0 - ISC
|
|
43
|
-
*
|
|
44
|
-
* This source code is licensed under the ISC license.
|
|
45
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const $e=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],ee=h("wrench",$e);function I(e){return typeof e=="object"&&e!==null}function Ce(e){if(!I(e))return null;if(e.type==="text"&&typeof e.text=="string"){const t=e.text.trim();return t?{type:"text",text:t}:null}if(e.type==="image"&&typeof e.mediaType=="string"&&typeof e.data=="string"){const t=e.mediaType.trim(),r=e.data;return!t||!r?null:{type:"image",mediaType:t,data:r,...typeof e.filename=="string"&&e.filename.trim()?{filename:e.filename.trim()}:{}}}if(e.type==="tool_result"&&typeof e.toolUseId=="string"&&typeof e.content=="string"){const t=e.toolUseId.trim(),r=e.content.trim();return!t||!r?null:{type:"tool_result",toolUseId:t,content:r,...typeof e.isError=="boolean"?{isError:e.isError}:{}}}return null}function ve(e){if(!I(e))return null;if(e.type==="text"&&typeof e.text=="string"){const s=e.text.trim();return s?{type:"text",text:s}:null}if(e.type!=="image"||!I(e.source)){if(e.type==="tool_result"&&typeof e.tool_use_id=="string"&&typeof e.content=="string"){const s=e.tool_use_id.trim(),i=e.content.trim();return!s||!i?null:{type:"tool_result",toolUseId:s,content:i,...typeof e.is_error=="boolean"?{isError:e.is_error}:{}}}return null}const t=typeof e.source.media_type=="string"?e.source.media_type.trim():"",r=typeof e.source.data=="string"?e.source.data:"";return!t||!r?null:{type:"image",mediaType:t,data:r}}function M(e){if(typeof e=="string"){const t=e.trim();return t?[{type:"text",text:t}]:[]}return Array.isArray(e)?e.map(t=>Ce(t)??ve(t)).filter(t=>t!==null):[]}function mt(e,t){const r=e.trim();return[...r?[{type:"text",text:r}]:[],...t]}function Ae(e){return{role:"user",content:e.map(t=>t.type==="text"?{type:"text",text:t.text}:t.type==="tool_result"?{type:"tool_result",tool_use_id:t.toolUseId,content:t.content,...typeof t.isError=="boolean"?{is_error:t.isError}:{}}:{type:"image",source:{type:"base64",media_type:t.mediaType,data:t.data}})}}function ft(e,t=new Date().toISOString()){return{type:"user",message:Ae(e),timestamp:t}}function _(e){if(e.type!=="user"||e.isSynthetic===!0)return null;if(typeof e.message=="string"){const t=M(e.message);return t.length>0?t:null}if(I(e.message)&&Array.isArray(e.message.content)){const t=M(e.message.content);return t.length>0?t:null}if(Array.isArray(e.content)){const t=M(e.content);return t.length>0?t:null}return null}function pt(e){return M(e.payload.initialMessage)}function b(e){return e.map(t=>{if(t.type==="text")return`t:${t.text}`;if(t.type==="tool_result")return`r:${t.toolUseId}:${t.isError===!0?"1":"0"}:${t.content}`;const r=t.data.slice(0,32),s=t.data.slice(-32);return`i:${t.mediaType}:${t.data.length}:${r}:${s}`}).join("|")}function Te(e){return e.map(t=>t.type==="text"?t.text:t.type==="tool_result"?t.content:"").filter(Boolean).join(`
|
|
47
|
-
`)}function Ue(e){return`data:${e.mediaType};base64,${e.data}`}function xt(e){var i,o;if(!e)return[];const t=[],r=e.items;if(r)for(const a of Array.from(r)){if((a==null?void 0:a.kind)!=="file"||!((i=a.type)!=null&&i.startsWith("image/")))continue;const c=(o=a.getAsFile)==null?void 0:o.call(a);c&&c.type.startsWith("image/")&&t.push(c)}if(t.length>0)return t;const s=e.files;return s?Array.from(s).filter(a=>a.type.startsWith("image/")):[]}function Me(e){return new Promise((t,r)=>{const s=new FileReader;s.onload=()=>{if(typeof s.result!="string"){r(new Error(`Failed to read ${e.name}`));return}t(s.result)},s.onerror=()=>r(s.error??new Error(`Failed to read ${e.name}`)),s.readAsDataURL(e)})}async function gt(e){return Promise.all(Array.from(e).map(async t=>{if(!t.type.startsWith("image/"))throw new Error(`${t.name} is not an image`);const r=await Me(t),s=r.indexOf(",");if(s===-1)throw new Error(`Failed to parse ${t.name}`);return{type:"image",mediaType:t.type||"image/png",data:r.slice(s+1),filename:t.name}}))}function U(e){return typeof e=="object"&&e!==null}function Pe(e){return U(e)&&typeof e.name=="string"&&e.name.toLowerCase()==="askuserquestion"}function Ee(e){return!U(e)||typeof e.label!="string"||!e.label.trim()?null:{label:e.label.trim(),description:typeof e.description=="string"?e.description.trim():""}}function Ie(e){if(!U(e)||typeof e.question!="string"||!e.question.trim())return null;const t=Array.isArray(e.options)?e.options.map(Ee).filter(r=>r!==null):[];return t.length===0?null:{header:typeof e.header=="string"&&e.header.trim()?e.header.trim():void 0,question:e.question.trim(),multiSelect:e.multiSelect===!0,options:t}}function z(e){if(!U(e)||!Array.isArray(e.questions))return null;const t=e.questions.map(Ie).filter(r=>r!==null);return t.length===0?null:{questions:t}}function S(e){return JSON.stringify({questions:e.questions})}function O(e){const t=z(e);if(t)return t;if(Pe(e)){const r=U(e.input)?e.input:void 0,s=z(r);return s?{...s,...typeof e.id=="string"&&e.id.trim()?{toolUseId:e.id.trim()}:{}}:null}return null}function Oe(e){var i;const t=e.trim();if(!t)return[];const r=[t],s=t.matchAll(/```(?:json)?\s*([\s\S]*?)```/gi);for(const o of s){const a=(i=o[1])==null?void 0:i.trim();a&&r.push(a)}return r}function B(e){for(const t of Oe(e))try{const r=JSON.parse(t),s=z(r);if(s)return s}catch{}return null}function Be(e){return e.questions.map(t=>t.options.length>0?[0]:[])}function qe(e,t){return e.questions.every((r,s)=>(t[s]??[]).length>0)}function Fe(e,t){const s=e.questions.map((i,o)=>{const a=[...new Set(t[o]??[])].sort((c,u)=>c-u).filter(c=>i.options[c]!==void 0);return{header:i.header??null,question:i.question,multiSelect:i.multiSelect,selectedOptions:a.map(c=>i.options[c]).filter(c=>c!==void 0)}}).map(i=>{const o=i.header??i.question,a=i.selectedOptions.map(c=>c.label).join(i.multiSelect?", ":"");return`${o}: ${a}`}).join(`
|
|
48
|
-
`);return e.toolUseId?[{type:"tool_result",toolUseId:e.toolUseId,content:s,isError:!1}]:[{type:"text",text:s}]}function v(e){return typeof e=="object"&&e!==null}function ze(e){if(!e)return;const t=["file_path","path","command"].map(r=>e[r]).find(r=>typeof r=="string"&&r.trim().length>0);return t==null?void 0:t.trim()}function Je(e){const t=e.toLowerCase();return t.includes(" permission to write ")?"Write":t.includes(" permission to edit ")?"Edit":t.includes(" permission to run ")||t.includes(" permission to execute ")?"Bash":"Action"}function J(e){const t=e.trim();if(!t.startsWith("Awaiting your permission to "))return null;const r=t.match(/`([^`]+)`/);return{requests:[{toolName:Je(t),target:r==null?void 0:r[1],summary:t}]}}function Le(e){if(!Array.isArray(e.permission_denials))return null;const t=[];for(const r of e.permission_denials){if(!v(r)||typeof r.tool_name!="string")continue;const s=v(r.tool_input)?r.tool_input:void 0,i=ze(s),o=typeof e.result=="string"&&e.result.trim().length>0?e.result.trim():`Awaiting your permission to use ${r.tool_name}${i?` on \`${i}\``:""}.`;t.push({toolName:r.tool_name,...typeof r.tool_use_id=="string"?{toolUseId:r.tool_use_id}:{},...i?{target:i}:{},summary:o})}return t.length>0?{requests:t}:null}function H(e){if(!Array.isArray(e))return null;for(const t of e){if(!v(t)||t.type!=="text"||typeof t.text!="string")continue;const r=J(t.text);if(r)return r}return null}function V(e){if(!v(e))return null;const t=Le(e);if(t)return t;if(typeof e.result=="string"){const s=J(e.result);if(s)return s}if(typeof e.message=="string"){const s=J(e.message);if(s)return s}if(v(e.message)){const s=V(e.message);if(s)return s;const i=H(e.message.content);if(i)return i}const r=H(e.content);return r||null}function Re(e){return JSON.stringify(e.requests.map(t=>({toolName:t.toolName,target:t.target??null,summary:t.summary})))}function We(e,t){return e.requests.map(r=>{const s=r.target?` for \`${r.target}\``:"",i=t==="approve"?`Approved. Proceed with the requested ${r.toolName} action${s}.`:`Denied. Do not proceed with the requested ${r.toolName} action${s}. Ask for another approach if needed.`;return r.toolUseId?{type:"tool_result",toolUseId:r.toolUseId,content:i,isError:t==="deny"}:t==="approve"?{type:"text",text:i}:{type:"text",text:i}})}function Ve(e){return _(e)!==null}function L(e){return typeof e=="object"&&e!==null}function K(e){if(e.type==="user"){const t=_(e),r=typeof e.timestamp=="string"?e.timestamp:"";if(t)return`user:${r}:${b(t)}`}return JSON.stringify(e)}function $(e){return Array.isArray(e)?e.map(t=>$(t)):L(e)?Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[r])=>t.localeCompare(r)).map(([t,r])=>[t,$(r)])):e}function X(e){const t=_(e);if(t)return`user:${b(t)}`;if(e.type==="assistant"){if(typeof e.message=="string")return`assistant:${JSON.stringify(e.message)}`;if(L(e.message)&&"content"in e.message)return`assistant:${JSON.stringify($(e.message.content))}`;if(Array.isArray(e.content))return`assistant:${JSON.stringify($(e.content))}`;if(L(e.message))return`assistant:${JSON.stringify($(e.message))}`}return JSON.stringify(e)}function Y(e){if(typeof e.timestamp!="string")return null;const t=Date.parse(e.timestamp);return Number.isNaN(t)?null:t}function R(e){const t=O(e);return t?`question:${S(t)}`:null}function De(e){const t=V(e);return t?`permission:${Re(t)}`:null}function Z(e){if(!Array.isArray(e))return null;const t=new Set;for(const r of e){const s=R(r);if(s){t.add(s);continue}if(typeof r=="object"&&r!==null&&r.type==="text"&&typeof r.text=="string"){const i=B(r.text);i&&t.add(S(i))}}return t.size===0?null:Array.from(t).sort().join("|")}function Ge(e){const t=R(e);if(t)return t;if(typeof e.message=="string"){const r=B(e.message);return r?S(r):null}if(typeof e.message=="object"&&e.message!==null){const r=R(e.message);return r||Z(e.message.content)}return Z(e.content)}function He(e){return De(e)}function ht(e,t,r){const s=typeof t.timestamp=="string"?t.timestamp:"";return`${e}-${s}-${r}`}function yt(e,t){const r=new Map;for(const i of t){const o=X(i);r.set(o,(r.get(o)??0)+1)}const s=[];for(let i=e.length-1;i>=0;i-=1){const o=e[i];if(!o)continue;const a=X(o),c=r.get(a)??0;if(c>0){r.set(a,c-1);continue}s.push({...o})}return[...s.reverse(),...t.map(i=>({...i}))].map((i,o)=>({event:i,order:o})).sort((i,o)=>{const a=Y(i.event),c=Y(o.event);return a!==null&&c!==null&&a!==c?a-c:i.order-o.order}).map(i=>i.event)}function bt(e,t){const r=K(t);return e.some(s=>K(s)===r)?e:[...e,{...t}]}function jt(e,t){const r=new Map;for(const s of t){const i=_(s);if(!i)continue;const o=b(i);r.set(o,(r.get(o)??0)+1)}return e.filter(s=>{const i=b(s.content),o=r.get(i)??0;return o<=0?!0:(r.set(i,o-1),!1)})}function Nt(e,t){const r=b(t),s=e.findIndex(i=>b(i.content)===r);return s===-1?e:e.filter((i,o)=>o!==s)}function wt(e,t){const r=b(t);return e.some(s=>{const i=_(s);return i!==null&&b(i)===r})}function kt(e){const t=[];let r=null;for(const s of e){if(Ve(s)){r=null,t.push(s);continue}const i=He(s)??Ge(s);i&&i===r||(t.push(s),i&&(r=i))}return t}function A({payload:e,disabled:t=!1,bypassEnabled:r=!1,onBypassChange:s,onSubmit:i}){const[o,a]=g.useState(()=>r?Be(e):e.questions.map(()=>[])),[c,u]=g.useState(!1),[d,m]=g.useState(!1);g.useEffect(()=>{r&&a(l=>l.map((f,y)=>{var p;return f.length>0?f:(p=e.questions[y])!=null&&p.options.length?[0]:[]}))},[r,e]);const x=qe(e,o)&&!t&&!c&&!d&&!!i,j=(l,f)=>{t||d||c||a(y=>y.map((p,N)=>{if(N!==l)return p;const w=e.questions[N];return w?w.multiSelect?p.includes(f)?p.filter(q=>q!==f):[...p,f].sort((q,se)=>q-se):[f]:p}))},G=async()=>{if(!x||!i)return;u(!0);const l=await i(Fe(e,o));u(!1),l&&m(!0)};return n.jsxs("div",{className:"rounded-[24px] border border-primary/20 bg-primary/5 p-4 shadow-[0_24px_80px_-60px_hsl(var(--primary)/0.9)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-primary/20 bg-primary/10 text-primary",children:n.jsx(fe,{className:"h-4 w-4"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-primary/80",children:"Ask User Question"}),n.jsx("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:"Select the answer you want to send back to the agent."})]})]}),n.jsxs(P,{type:"button",variant:r?"secondary":"outline",size:"sm",onClick:()=>s==null?void 0:s(!r),className:"rounded-full",children:[n.jsx(ke,{className:"h-4 w-4"}),r?"Bypass on":"Bypass future questions"]})]}),n.jsx("div",{className:"mt-4 space-y-4",children:e.questions.map((l,f)=>{const y=o[f]??[];return n.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/75 p-4",children:[n.jsxs("div",{children:[l.header&&n.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground",children:l.header}),n.jsx("div",{className:"mt-1 text-sm font-medium leading-6 text-foreground",children:l.question}),n.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:l.multiSelect?"Select one or more options.":"Select one option."})]}),n.jsx("div",{className:"space-y-2",children:l.options.map((p,N)=>{const w=y.includes(N);return n.jsxs("button",{type:"button",onClick:()=>j(f,N),disabled:t||c||d,"aria-pressed":w,className:E("flex w-full items-start gap-3 rounded-[18px] border px-4 py-3 text-left transition-colors",w?"border-primary/50 bg-primary/10 text-foreground":"border-border/60 bg-background/80 text-foreground hover:border-primary/30 hover:bg-primary/5"),children:[n.jsx("span",{className:E("mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border",w?"border-primary bg-primary text-primary-foreground":"border-border/70 bg-background text-transparent"),children:n.jsx(T,{className:"h-3.5 w-3.5"})}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block text-sm font-medium leading-5",children:p.label}),p.description&&n.jsx("span",{className:"mt-1 block text-xs leading-5 text-muted-foreground",children:p.description})]})]},`${p.label}-${N}`)})})]},`${l.header??"question"}-${f}`)})}),n.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-3",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:r?"Bypass is enabled. New question cards will default to the first option.":"Enable bypass if you want future question cards to preselect the first option."}),n.jsx(P,{type:"button",onClick:()=>void G(),disabled:!x,className:"rounded-full px-5",children:d?"Sent":c?"Sending...":e.questions.length>1?"Send answers":"Send answer"})]})]})}function Ke({payload:e,disabled:t=!1,onSubmit:r}){const[s,i]=g.useState(null),[o,a]=g.useState(!1),c=!t&&!o&&!!r,u=async d=>{if(!c||!r)return;i(d);const m=await r(We(e,d));i(null),m&&a(!0)};return n.jsxs("div",{className:"rounded-[24px] border border-amber-500/25 bg-amber-500/5 p-4 shadow-[0_24px_80px_-60px_rgba(245,158,11,0.8)]",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-amber-500/25 bg-amber-500/10 text-amber-600 dark:text-amber-400",children:n.jsx(Ne,{className:"h-4 w-4"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-amber-700/80 dark:text-amber-300/80",children:"Permission Request"}),n.jsx("div",{className:"mt-1 space-y-3",children:e.requests.map((d,m)=>n.jsxs("div",{className:"rounded-[18px] border border-border/60 bg-background/75 px-4 py-3",children:[n.jsx("div",{className:"text-sm font-medium leading-6 text-foreground",children:d.summary}),(d.toolName||d.target)&&n.jsxs("div",{className:"mt-2 flex flex-wrap gap-2 text-[11px] uppercase tracking-[0.18em] text-muted-foreground",children:[n.jsx("span",{children:d.toolName}),d.target&&n.jsx("span",{className:"font-mono normal-case tracking-normal",children:d.target})]})]},`${d.toolUseId??d.toolName}-${m}`))})]})]}),n.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-end gap-2",children:[n.jsxs(P,{type:"button",variant:"outline",onClick:()=>void u("deny"),disabled:!c||s!==null,className:"rounded-full",children:[n.jsx(ie,{className:"h-4 w-4"}),o?"Sent":s==="deny"?"Sending...":"Deny"]}),n.jsxs(P,{type:"button",onClick:()=>void u("approve"),disabled:!c||s!==null,className:"rounded-full",children:[n.jsx(T,{className:"h-4 w-4"}),o?"Sent":s==="approve"?"Sending...":"Approve"]})]})]})}function _t({event:e,questionBypassEnabled:t=!1,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:i=!1}){const o=e.type,a=V(e),c=O(e);if(a)return n.jsx(C,{children:n.jsx(Ke,{payload:a,onSubmit:s,disabled:i})});if(c)return n.jsx(C,{children:n.jsx(A,{payload:c,bypassEnabled:t,onBypassChange:r,onSubmit:s,disabled:i})});if(o==="user"){const u=Xe(e),d=u.filter(x=>x.type==="tool_result");if(d.length>0&&u.every(x=>x.type==="tool_result"))return n.jsx(C,{children:d.map((x,j)=>n.jsx(ne,{block:x,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:i},j))});const m=_(e);return m?n.jsx(tt,{content:m}):null}return o==="assistant"?n.jsx(rt,{event:e,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:i}):null}function Xe(e){const t=e.message,r=t==null?void 0:t.content;if(Array.isArray(r))return r.filter(i=>typeof i=="object"&&i!==null);const s=e.content;return Array.isArray(s)?s.filter(i=>typeof i=="object"&&i!==null):[]}function F(e){var r;const t=e.replace(/\r\n/g,`
|
|
49
|
-
`).split(`
|
|
50
|
-
`);for(;t.length>0&&((r=t[0])==null?void 0:r.trim())==="";)t.shift();return t.join(`
|
|
51
|
-
`)}const Ye=/\b((?:https?:\/\/|www\.)[^\s<>()[\]{}'"`]+[^\s<>()[\]{}'"`.,;:!?])/gi;function te({text:e,className:t=""}){const r=[];let s=0;for(const i of e.matchAll(Ye)){const o=i.index??0;o>s&&r.push({kind:"text",value:e.slice(s,o)});const a=i[0],c=a.startsWith("www.")?`https://${a}`:a;r.push({kind:"link",value:a,href:c}),s=o+a.length}return s<e.length&&r.push({kind:"text",value:e.slice(s)}),r.length===0&&r.push({kind:"text",value:e}),n.jsx("div",{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere] ${t}`,children:r.map((i,o)=>i.kind==="link"?n.jsx("a",{href:i.href,target:"_blank",rel:"noreferrer noopener",className:"underline decoration-current/40 underline-offset-2 hover:decoration-current",onClick:a=>a.stopPropagation(),children:i.value},o):n.jsx("span",{children:i.value},o))})}function re({text:e,className:t=""}){const[r,s]=g.useState(!1);if(!e)return null;const i=async o=>{o.stopPropagation();try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),1500)}catch{}};return n.jsx("button",{type:"button",onClick:i,"aria-label":r?"Copied":"Copy message",className:`flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-background/80 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-opacity hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100 ${t}`,children:r?n.jsx(T,{className:"h-3 w-3 text-emerald-500"}):n.jsx(Q,{className:"h-3 w-3"})})}async function Ze(e){let r=await(await fetch(e)).blob();r.type!=="image/png"&&(r=await Qe(r)),await navigator.clipboard.write([new ClipboardItem({[r.type]:r})])}async function Qe(e){const t=await createImageBitmap(e),r=document.createElement("canvas");r.width=t.width,r.height=t.height;const s=r.getContext("2d");if(!s)throw new Error("canvas 2d context unavailable");return s.drawImage(t,0,0),await new Promise((i,o)=>{r.toBlob(a=>a?i(a):o(new Error("toBlob failed")),"image/png")})}function et({dataUrl:e,className:t=""}){const[r,s]=g.useState(!1),i=async o=>{o.stopPropagation();try{await Ze(e),s(!0),setTimeout(()=>s(!1),1500)}catch(a){console.error("copy image failed",a)}};return n.jsx("button",{type:"button",onClick:i,"aria-label":r?"Copied":"Copy image",className:`flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-background/80 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-opacity hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100 ${t}`,children:r?n.jsx(T,{className:"h-3 w-3 text-emerald-500"}):n.jsx(Q,{className:"h-3 w-3"})})}function tt({content:e}){const t=Te(e),r=e.filter(s=>s.type==="image");return n.jsx("div",{className:"animate-message-rise flex justify-end",children:n.jsxs("div",{className:"group relative flex max-w-[88%] items-start gap-3",children:[n.jsx(re,{text:t,className:"absolute -left-8 top-7"}),n.jsxs("div",{className:"flex min-w-0 flex-col items-end gap-1",children:[n.jsx("div",{className:"pr-1 text-[10px] font-semibold uppercase tracking-[0.28em] text-muted-foreground",children:"You"}),n.jsxs("div",{className:"space-y-1 rounded-[26px] rounded-tr-md border border-primary/25 bg-primary px-3.5 py-2.5 text-[12px] leading-[18px] text-primary-foreground shadow-[0_20px_70px_-42px_hsl(var(--primary)/0.95)]",children:[t&&n.jsx(te,{text:t}),r.length>0&&n.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:r.map((s,i)=>{const o=Ue(s);return n.jsxs("div",{className:"relative",children:[n.jsx("img",{src:o,alt:s.filename??`attachment ${i+1}`,className:"max-h-72 w-full rounded-2xl border border-primary-foreground/15 object-cover"}),n.jsx(et,{dataUrl:o,className:"absolute right-2 top-2"})]},`${s.filename??"image"}-${i}`)})})]})]}),n.jsx("div",{className:"mt-6 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-primary/20 bg-primary/10 text-primary",children:n.jsx(Se,{className:"h-4 w-4"})})]})})}function C({children:e}){return n.jsx("div",{className:"animate-message-rise flex justify-start",children:n.jsxs("div",{className:"flex max-w-[92%] items-start gap-3",children:[n.jsx("div",{className:"mt-6 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-border/70 bg-muted/70 text-muted-foreground",children:n.jsx(oe,{className:"h-4 w-4"})}),n.jsxs("div",{className:"min-w-0 space-y-2",children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.28em] text-muted-foreground",children:"Agent"}),e]})]})})}function rt({event:e,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:i}){const o=e.message;if(!o)return null;const a=O(o);if(a)return n.jsx(C,{children:n.jsx(A,{payload:a,bypassEnabled:t,onBypassChange:r,onSubmit:s,disabled:i})});const c=o.content;if(!c||!Array.isArray(c))return null;const u=new Set,d=c.filter(l=>l.type==="text").map(l=>({...l,text:F(String(l.text??"")),questionPayload:B(F(String(l.text??"")))})).filter(l=>l.text.length>0||l.questionPayload),m=c.filter(l=>l.type==="thinking").map(l=>F(String(l.thinking??""))).filter(Boolean).join(`
|
|
52
|
-
|
|
53
|
-
`),x=c.filter(l=>l.type==="tool_use"),j=c.filter(l=>l.type==="tool_result");return d.length>0||m.length>0||x.length>0||j.length>0?n.jsxs(C,{children:[m.length>0&&n.jsx(ot,{text:m}),d.map((l,f)=>{if(l.questionPayload){const y=S(l.questionPayload);return u.has(y)?null:(u.add(y),n.jsx(A,{payload:l.questionPayload,bypassEnabled:t,onBypassChange:r,onSubmit:s,disabled:i},f))}return n.jsxs("div",{className:"group relative rounded-[26px] rounded-tl-md border border-border/70 bg-card/80 px-3.5 py-2.5 text-[12px] leading-[18px] text-foreground shadow-[0_20px_70px_-58px_rgba(0,0,0,0.9)] backdrop-blur-sm",children:[n.jsx(re,{text:l.text,className:"absolute right-2 top-2"}),n.jsx(te,{text:l.text})]},f)}),x.map((l,f)=>n.jsx(at,{block:l,renderedQuestionSignatures:u,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:i},f)),j.map((l,f)=>n.jsx(ne,{block:l,renderedQuestionSignatures:u,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:i},f))]}):null}function nt(e){return e.replace(/\s+/g," ").trim()}function k(e,t=132){const r=nt(e);return r?r.length>t?`${r.slice(0,t-3)}...`:r:""}function W(e,t=84){if(typeof e=="string")return k(e,t);if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e)){const r=e.slice(0,3).map(s=>W(s,28)).filter(Boolean).join(", ");return k(r||JSON.stringify(e),t)}if(typeof e=="object"&&e!==null){const r=Object.entries(e).slice(0,3).map(([s,i])=>`${s}: ${W(i,32)}`).join(" · ");return k(r||JSON.stringify(e),t)}return""}function st(e){if(!e)return"No input";const t=Object.entries(e).slice(0,4).map(([r,s])=>`${r}: ${W(s,40)}`).filter(r=>r.trim().length>0).join(" · ");return k(t||JSON.stringify(e),156)||"No input"}function it({expanded:e}){return n.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-border/60 bg-background/70 px-2 py-1 text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:[e?"Less":"More",e?n.jsx(ae,{className:"h-3 w-3"}):n.jsx(ce,{className:"h-3 w-3"})]})}function D({title:e,preview:t,icon:r,children:s,accentClassName:i,previewClassName:o="font-mono text-[11px] text-muted-foreground/90"}){const[a,c]=g.useState(!1);return n.jsxs("div",{className:`overflow-hidden rounded-[22px] border border-border/60 ${i}`,children:[n.jsxs("button",{type:"button",onClick:()=>c(u=>!u),className:"flex w-full items-start gap-3 px-4 py-3 text-left transition-colors hover:bg-background/30",children:[n.jsx("div",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-border/60 bg-background/70 text-muted-foreground",children:r}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"flex flex-wrap items-center gap-2",children:n.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-muted-foreground",children:e})}),n.jsx("div",{className:`mt-1 whitespace-pre-wrap break-words text-[12px] leading-5 ${o}`,children:t})]}),n.jsx(it,{expanded:a})]}),a&&n.jsx("div",{className:"border-t border-border/60 px-4 py-3",children:s})]})}function ot({text:e}){const t=k(e,156);return n.jsx(D,{title:"Thinking",preview:t,icon:n.jsx(ue,{className:"h-3.5 w-3.5"}),accentClassName:"bg-muted/35",previewClassName:"text-[12px] leading-5 text-muted-foreground/90",children:n.jsx("div",{className:"whitespace-pre-wrap text-[13px] leading-5 text-muted-foreground/90",children:e})})}function at({block:e,renderedQuestionSignatures:t,questionBypassEnabled:r,onQuestionBypassChange:s,onSubmitQuestionResponse:i,questionResponseDisabled:o}){const a=String(e.name??"tool"),c=e.input,u=O(e);if(u){const m=S(u);return t!=null&&t.has(m)?null:(t==null||t.add(m),n.jsx(A,{payload:u,bypassEnabled:r,onBypassChange:s,onSubmit:i,disabled:o}))}const d=st(c);if(a==="TodoWrite"){const m=ct(c==null?void 0:c.todos);if(m.length>0)return n.jsx(lt,{todos:m})}return n.jsx(D,{title:`Tool: ${a}`,preview:d,icon:n.jsx(ee,{className:"h-3.5 w-3.5"}),accentClassName:"bg-muted/25",children:n.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:JSON.stringify(c??{},null,2)})})}function ne({block:e,renderedQuestionSignatures:t,questionBypassEnabled:r,onQuestionBypassChange:s,onSubmitQuestionResponse:i,questionResponseDisabled:o}){const a=e.content,c=typeof a=="string"?a:Array.isArray(a)?a.map(m=>String(m.text??"")).join(`
|
|
54
|
-
`):"";if(!c)return null;const u=B(c);if(u){const m=S(u);return t!=null&&t.has(m)?null:(t==null||t.add(m),n.jsx(A,{payload:u,bypassEnabled:r,onBypassChange:s,onSubmit:i,disabled:o}))}const d=k(c,156);return n.jsx(D,{title:"Result",preview:d,icon:n.jsx(ee,{className:"h-3.5 w-3.5"}),accentClassName:"bg-background/65",children:n.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:c})})}function ct(e){return Array.isArray(e)?e.map(t=>{if(typeof t!="object"||t===null)return null;const r=t,s=typeof r.content=="string"?r.content:"";if(!s)return null;const i=typeof r.activeForm=="string"?r.activeForm:s,o=typeof r.status=="string"?r.status:"pending";return{content:s,activeForm:i,status:o==="completed"||o==="in_progress"?o:"pending"}}).filter(t=>t!==null):[]}function lt({todos:e}){const t=e.filter(i=>i.status==="completed").length,r=e.length,s=e.find(i=>i.status==="in_progress");return n.jsxs("div",{className:"overflow-hidden rounded-[22px] border border-border/60 bg-muted/20",children:[n.jsxs("div",{className:"flex items-center gap-3 border-b border-border/50 px-4 py-3",children:[n.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-border/60 bg-background/70 text-muted-foreground",children:n.jsx(he,{className:"h-3.5 w-3.5"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-muted-foreground",children:"Todos"}),n.jsx("div",{className:"mt-0.5 truncate text-[12px] leading-5 text-muted-foreground/90",children:s?s.activeForm:r===0?"No items":t===r?"All complete":"Up next"})]}),n.jsxs("div",{className:"shrink-0 rounded-full border border-border/60 bg-background/70 px-2 py-0.5 font-mono text-[10px] tracking-wide text-muted-foreground",children:[t,"/",r]})]}),n.jsx("ul",{className:"divide-y divide-border/40",children:e.map((i,o)=>n.jsxs("li",{className:"flex items-start gap-3 px-4 py-2.5",children:[n.jsx(dt,{status:i.status}),n.jsx("span",{className:i.status==="completed"?"text-[13px] leading-5 text-muted-foreground line-through decoration-muted-foreground/60":i.status==="in_progress"?"text-[13px] font-medium leading-5 text-foreground":"text-[13px] leading-5 text-foreground/85",children:i.status==="in_progress"?i.activeForm:i.content})]},`${o}-${i.content}`))})]})}function dt({status:e}){return e==="completed"?n.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-emerald-500/15 text-emerald-500 dark:text-emerald-400",children:n.jsx(T,{className:"h-3 w-3"})}):e==="in_progress"?n.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center text-primary",children:n.jsx(be,{className:"h-3.5 w-3.5 animate-spin"})}):n.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground/60",children:n.jsx(xe,{className:"h-3 w-3"})})}function St({label:e,value:t}){return n.jsxs("div",{className:"min-w-[5.5rem] flex-1 rounded-[18px] border border-border/60 bg-background/45 px-2.5 py-2",children:[n.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:e}),n.jsx("div",{className:"mt-0.5 text-sm font-semibold tracking-tight text-foreground",children:t})]})}function $t({label:e}){return n.jsx("div",{className:"flex h-64 items-center justify-center text-sm text-muted-foreground",children:e})}function Ct({label:e,value:t,mono:r,action:s}){return n.jsxs("div",{className:"grid grid-cols-[4.25rem,minmax(0,1fr)] items-start gap-2",children:[n.jsx("span",{className:"pt-0.5 text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:e}),n.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[n.jsx("span",{className:E("min-w-0 flex-1 break-all text-[12px] text-foreground",r&&"font-mono text-[11px] leading-5"),children:t}),s]})]})}function vt({label:e,value:t,mono:r}){return n.jsxs("div",{className:"rounded-[16px] border border-border/60 bg-background/60 px-2.5 py-2",children:[n.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:e}),n.jsx("div",{className:E("mt-0.5 text-[12px] font-medium text-foreground",r&&"font-mono text-[11px]"),children:t})]})}function At({capabilities:e,action:t}){return n.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-3",children:[n.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[n.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Capabilities"}),n.jsx("div",{className:"flex flex-wrap items-center gap-1.5 text-[11px]",children:e.length>0?e.map(r=>n.jsx(le,{variant:"secondary",className:"rounded-full",children:r},r)):n.jsx("span",{className:"text-[12px] text-muted-foreground",children:"None declared"})})]}),t&&n.jsx("div",{className:"shrink-0 self-start",children:t})]})}export{_t as C,St as D,Ct as I,be as L,vt as M,$t as T,ht as a,mt as b,At as c,jt as d,xt as e,bt as f,_ as g,Nt as h,kt as i,ft as j,pt as k,wt as l,yt as m,M as n,gt as r,Ue as t};
|