meshy-node 0.2.6 → 0.2.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 +5 -3
- package/dashboard/assets/DashboardPage-ChA_y3oq.js +120 -0
- package/dashboard/assets/{DashboardShared-B08ZGEU3.js → DashboardShared-B4AJ8Ukj.js} +1 -1
- package/dashboard/assets/{DiffTab-D6XXV_vj.js → DiffTab-DgOYOCn1.js} +1 -1
- package/dashboard/assets/{FilesTab-DUebfVJo.js → FilesTab-Csi7UE5G.js} +1 -1
- package/dashboard/assets/{PreviewTab-CfNP0Ll3.js → PreviewTab-DT95fOD3.js} +1 -1
- package/dashboard/assets/{SharedConversationPage-D2ncPenP.js → SharedConversationPage-D5DMTSIy.js} +3 -3
- package/dashboard/assets/{file-C-p99c1E.js → file-BUN3RpOS.js} +1 -1
- package/dashboard/assets/{folder-C0oopt2q.js → folder-C28inzgP.js} +1 -1
- package/dashboard/assets/{index-B7PaE6U7.js → index-COwXI8L0.js} +2 -2
- package/dashboard/assets/{index-CxJE8HAC.css → index-tpSDJYRT.css} +1 -1
- package/dashboard/index.html +2 -2
- package/main.cjs +1896 -597
- package/package.json +1 -1
- package/runtime-metadata.json +5 -5
- package/dashboard/assets/DashboardPage-DeFE8aKR.js +0 -120
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# meshy-node
|
|
2
2
|
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.7
|
|
4
4
|
|
|
5
5
|
This package contains the built Meshy standalone node runtime only.
|
|
6
6
|
It intentionally excludes repository source files and TypeScript sources.
|
|
@@ -8,9 +8,11 @@ It intentionally excludes repository source files and TypeScript sources.
|
|
|
8
8
|
## Usage
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
|
-
npx meshy-node
|
|
11
|
+
npx -y meshy-node@latest start
|
|
12
12
|
# or after install
|
|
13
|
-
meshy
|
|
13
|
+
meshy start
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
Default transport is devtunnel. Common start parameters are --name, --port, --transport, --join, and --reset.
|
|
17
|
+
|
|
16
18
|
See the repository README for broader project documentation.
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-Csi7UE5G.js","assets/index-COwXI8L0.js","assets/index-tpSDJYRT.css","assets/folder-C28inzgP.js","assets/file-BUN3RpOS.js","assets/PreviewTab-DT95fOD3.js","assets/DiffTab-DgOYOCn1.js","assets/DashboardShared-B4AJ8Ukj.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as ue,r as a,j as e,a as _,b as tr,d as sr,e as ar,D as Ns,f as rr,g as ks,B as De,h as nr,i as T,X as ze,R as or,T as lr,k as ys,P as ir,u as jt,W as dr,C as cr,l as Pt,m as ur,n as mr,o as ws,O as xr,p as hr,q as Cs,s as Ss,t as pr,v as fr,w as Ke,x as gr,F as br,y as vr,z as ce,S as _e,A as Ee,E as Le,G as Te,H as _s,I as ye,J as Es,K as We,L as Ts,M as Ds,N as jr,Q as Nr,U as As,V as Ie,Y as Be,_ as zt,Z as kr,$ as Ps,a0 as Ms,a1 as Ls,a2 as yr,a3 as Ut,a4 as wr,a5 as Cr,a6 as Sr,a7 as _r,a8 as Er,a9 as Tr,aa as Dr,ab as Ar,ac as Pr,ad as Mr,ae as Lr,af as Rr,ag as $r,ah as Fr,ai as Or,aj as Ir,ak as Br,al as zr,am as Ur,an as Vr,ao as qr,ap as Hr,aq as Kr}from"./index-COwXI8L0.js";import{r as ss,e as Wr,b as Rs,t as $s,L as be,D as Mt,T as Fs,a as Os,C as Vt,c as Ue,d as Is,f as Gr,g as as,h as Jr,i as Tt,s as Yr,j as qe,I as Pe,M as Lt,k as Xr,l as Bs,W as mt,m as Qr,n as Zr,o as en,p as tn,q as sn,u as an,v as rn,w as nn,x as on,y as ln,z as dn,A as cn,B as rs,E as un,F as mn,R as xn,G as hn,H as Dt,J as pn,K as fn,N as gn}from"./DashboardShared-B4AJ8Ukj.js";import{F as bn,C as et}from"./folder-C28inzgP.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 vn=[["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"}]],jn=ue("archive",vn);/**
|
|
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 Nn=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],kn=ue("arrow-up",Nn);/**
|
|
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 yn=[["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"}]],wn=ue("flag",yn);/**
|
|
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 Cn=[["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"}]],Sn=ue("funnel",Cn);/**
|
|
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 _n=[["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"}]],ns=ue("git-branch",_n);/**
|
|
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 En=[["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"}]],Tn=ue("globe",En);/**
|
|
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 Dn=[["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"}]],Rt=ue("history",Dn);/**
|
|
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 An=[["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"}]],$t=ue("image-plus",An);/**
|
|
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 Pn=[["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"}]],Mn=ue("laptop",Pn);/**
|
|
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 Ln=[["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"}]],zs=ue("message-square-plus",Ln);/**
|
|
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 Rn=[["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=ue("panel-left-close",Rn);/**
|
|
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 $n=[["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"}]],Fn=ue("panel-left-open",$n);/**
|
|
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 On=[["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"}]],Vs=ue("panel-right-close",On);/**
|
|
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 In=[["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"}]],Bn=ue("panel-right-open",In);/**
|
|
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 zn=[["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"}]],st=ue("pencil",zn);/**
|
|
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 Un=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Vn=ue("plus",Un);/**
|
|
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 qn=[["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"}]],Hn=ue("rotate-ccw",qn);/**
|
|
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 Kn=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],os=ue("search",Kn);/**
|
|
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 Wn=[["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"}]],qs=ue("send",Wn);/**
|
|
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 Gn=[["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"}]],Jn=ue("share-2",Gn);/**
|
|
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 Yn=[["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"}]],Xn=ue("sliders-horizontal",Yn);/**
|
|
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 Qn=[["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"}]],Zn=ue("trash-2",Qn),eo=new Set(["assigned","running"]);function to(t,s){return t.reduce((r,n)=>n.assignedTo===s&&eo.has(n.status)?r+1:r,0)}function Je(t){return(t==null?void 0:t.toLowerCase())==="devtunnel"}function so(t){return t?Je(t)?"DevTunnel":t.charAt(0).toUpperCase()+t.slice(1):"Direct"}function qt(t,s){return Je(s??t.transportType)||!!t.devtunnelEndpoint}function Hs(t,s){return!Je(s??t.transportType)}function Ks(t,s){const r=s??t.transportType;return Je(r)?"DevTunnel":t.devtunnelEndpoint?"Direct + DevTunnel":so(r)}function ls(t,s){return!t&&!s}function ao({routeTaskId:t,creatingTask:s,internalSelectedTaskId:r,sortedTaskIds:n}){return t||(s?null:r??n[0]??null)}function ro(t,s){return[s,...t.filter(r=>r.id!==s.id)]}function no(t,s){const r=s.taskId,n=s.updates;return typeof r!="string"||!n||typeof n!="object"?t:t.map(i=>i.id===r?{...i,...n}:i)}const oo=new Set(["completed","failed","cancelled","archived"]);function lo(t,s){const r=new Set(s);return new Set(Array.from(t).filter(n=>r.has(n)))}function io(t,s){const r=new Set(s);if(r.size===0)return!1;const n=t.filter(i=>r.has(i.id));return n.length===r.size&&n.every(i=>oo.has(i.status))}function co(t,s){var n;const r=new Set(s);return((n=t.find(i=>!r.has(i.id)))==null?void 0:n.id)??null}const Fe=a.forwardRef(({className:t,type:s,...r},n)=>e.jsx("input",{type:s,className:_("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:n,...r}));Fe.displayName="Input";var uo=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],mo=uo.reduce((t,s)=>{const r=tr(`Primitive.${s}`),n=a.forwardRef((i,o)=>{const{asChild:c,...p}=i,f=c?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(f,{...p,ref:o})});return n.displayName=`Primitive.${s}`,{...t,[s]:n}},{}),xo="Label",Ws=a.forwardRef((t,s)=>e.jsx(mo.label,{...t,ref:s,onMouseDown:r=>{var i;r.target.closest("button, input, select, textarea")||((i=t.onMouseDown)==null||i.call(t,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));Ws.displayName=xo;var Gs=Ws;const ho=sr("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Me=a.forwardRef(({className:t,...s},r)=>e.jsx(Gs,{ref:r,className:_(ho(),t),...s}));Me.displayName=Gs.displayName;function po({onAdded:t}){const[s,r]=a.useState(""),[n,i]=a.useState(!1),[o,c]=a.useState(null),p=a.useCallback(async f=>{if(f.preventDefault(),!!s.trim()){i(!0),c(null);try{await ar({leaderEndpoint:s.trim(),transport:"devtunnel"}),t()}catch(b){c(b instanceof Error?b.message:"Failed to join node")}finally{i(!1)}}},[s,t]);return e.jsx(Ns,{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(rr,{className:"space-y-2 text-left",children:[e.jsx(ks,{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:p,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(Me,{htmlFor:"leader-endpoint",children:"Leader endpoint"}),e.jsx(De,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),e.jsx(Fe,{id:"leader-endpoint",type:"url",value:s,onChange:f=>r(f.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(nr,{className:"border-t border-border/60 pt-4",children:e.jsx(T,{type:"submit",disabled:!s.trim()||n,className:"rounded-2xl",children:n?"Joining...":"Join node"})})]})]})})}function Js(){const[t,s]=a.useState([]),[r,n]=a.useState(null),i=a.useRef(null),o=a.useCallback(()=>{var d;(d=i.current)==null||d.click()},[]),c=a.useCallback(async d=>{const u=Array.from(d.target.files??[]);if(u.length!==0)try{const x=await ss(u);s(h=>[...h,...x]),n(null)}catch(x){n(x instanceof Error?x.message:"Failed to attach image")}finally{d.target.value=""}},[]),p=a.useCallback(async d=>{const u=Wr(d.clipboardData);if(u.length!==0){d.preventDefault();try{const x=await ss(u);s(h=>[...h,...x]),n(null)}catch(x){n(x instanceof Error?x.message:"Failed to attach image")}}},[]),f=a.useCallback(d=>{s(u=>u.filter((x,h)=>h!==d))},[]),b=a.useCallback(()=>{s([]),n(null)},[]);return{images:t,error:r,fileInputRef:i,pickImages:o,handleFileChange:c,handlePaste:p,removeImage:f,clearImages:b}}function fo({onSend:t,disabled:s,disabledReason:r="Chat is waiting on the agent.",placeholder:n="Send a follow-up message...",contextItems:i=[],running:o=!1,onStop:c}){const[p,f]=a.useState(""),b=a.useRef(null),{images:d,error:u,fileInputRef:x,pickImages:h,handleFileChange:w,handlePaste:P,removeImage:D,clearImages:N}=Js(),C=a.useCallback(()=>{b.current&&(b.current.style.height="auto")},[]),O=a.useCallback(()=>{const M=Rs(p,d);M.length===0||s||(t(M),f(""),N(),C())},[p,d,s,t,N,C]),U=a.useCallback(M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),O())},[O]),S=a.useCallback(()=>{b.current&&(b.current.style.height="auto",b.current.style.height=`${Math.min(b.current.scrollHeight,220)}px`)},[]),H=!s&&!o&&(p.trim().length>0||d.length>0),ae=o&&!!c,F=o?c?"Task is running — click to stop":"Task is running...":s?r:"Enter sends, Shift+Enter adds a line";return e.jsxs("div",{className:"border-t border-border/60 bg-background/55 px-2 py-1.5 backdrop-blur-xl sm:px-4 sm:py-2",children:[i.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-2 px-3 pb-2.5",children:i.map(M=>e.jsxs("div",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-border/60 bg-muted/40 px-3 py-1 text-xs",children:[e.jsx("span",{className:"shrink-0 text-[9px] font-medium uppercase tracking-[0.12em] text-muted-foreground/80",children:M.label}),e.jsx("span",{className:`truncate text-foreground/90 ${M.mono?"font-mono text-[11px]":""}`,children:M.value})]},`${M.label}:${M.value}`))}),e.jsxs("div",{className:"overflow-hidden rounded-3xl border border-border/65 bg-card/85 shadow-[0_28px_90px_-62px_rgba(0,0,0,var(--panel-shadow-alpha))] sm:rounded-[40px]",children:[e.jsx("input",{ref:x,type:"file",accept:"image/*",multiple:!0,onChange:w,className:"hidden"}),d.length>0&&e.jsx("div",{className:"px-3 pt-3 sm:px-6 sm:pt-6",children:e.jsx("div",{className:"flex flex-wrap gap-3",children:d.map((M,R)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:$s(M),alt:M.filename??`attachment ${R+1}`,className:"h-24 w-24 rounded-[22px] border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>D(R),className:"absolute -top-2 -right-2 flex h-7 w-7 items-center justify-center rounded-full border border-border/70 bg-background text-muted-foreground transition-colors hover:text-foreground","aria-label":`Remove ${M.filename??`image ${R+1}`}`,children:e.jsx(ze,{className:"h-3.5 w-3.5"})})]},`${M.filename??"image"}-${R}`))})}),e.jsxs("div",{className:"flex items-end gap-2 px-3 pt-3 pb-3 sm:px-6 sm:pt-4 sm:pb-4",children:[e.jsx("textarea",{ref:b,value:p,onChange:M=>f(M.target.value),onKeyDown:U,onPaste:P,onInput:S,placeholder:n,disabled:s,rows:1,className:"min-h-[2.5rem] flex-1 resize-none bg-transparent px-0 py-1 text-sm leading-7 text-foreground placeholder:text-muted-foreground/70 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),e.jsxs(T,{type:"button",variant:"ghost",onClick:h,disabled:s,className:"mb-0.5 h-9 shrink-0 gap-1.5 rounded-full px-2 text-xs text-muted-foreground hover:text-foreground sm:px-3",title:"Attach images",children:[e.jsx($t,{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:F,children:e.jsx(T,{onClick:o?c:O,disabled:o?!ae:!H,size:"icon","aria-label":o?"Stop running task":"Send message",className:"mb-0.5 h-9 w-9 shrink-0 rounded-full bg-primary/85 text-primary-foreground shadow-sm hover:bg-primary",children:o?e.jsx(be,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"})})})]}),u&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive sm:px-6 sm:py-3",children:u})]})]})}var Ys="AlertDialog",[go]=Cs(Ys,[ys]),Re=ys(),Xs=t=>{const{__scopeAlertDialog:s,...r}=t,n=Re(s);return e.jsx(or,{...n,...r,modal:!0})};Xs.displayName=Ys;var bo="AlertDialogTrigger",Qs=a.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,i=Re(r);return e.jsx(lr,{...i,...n,ref:s})});Qs.displayName=bo;var vo="AlertDialogPortal",Zs=t=>{const{__scopeAlertDialog:s,...r}=t,n=Re(s);return e.jsx(ir,{...n,...r})};Zs.displayName=vo;var jo="AlertDialogOverlay",ea=a.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,i=Re(r);return e.jsx(xr,{...i,...n,ref:s})});ea.displayName=jo;var He="AlertDialogContent",[No,ko]=go(He),yo=hr("AlertDialogContent"),ta=a.forwardRef((t,s)=>{const{__scopeAlertDialog:r,children:n,...i}=t,o=Re(r),c=a.useRef(null),p=jt(s,c),f=a.useRef(null);return e.jsx(dr,{contentName:He,titleName:sa,docsSlug:"alert-dialog",children:e.jsx(No,{scope:r,cancelRef:f,children:e.jsxs(cr,{role:"alertdialog",...o,...i,ref:p,onOpenAutoFocus:Pt(i.onOpenAutoFocus,b=>{var d;b.preventDefault(),(d=f.current)==null||d.focus({preventScroll:!0})}),onPointerDownOutside:b=>b.preventDefault(),onInteractOutside:b=>b.preventDefault(),children:[e.jsx(yo,{children:n}),e.jsx(Co,{contentRef:c})]})})})});ta.displayName=He;var sa="AlertDialogTitle",aa=a.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,i=Re(r);return e.jsx(ur,{...i,...n,ref:s})});aa.displayName=sa;var ra="AlertDialogDescription",na=a.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,i=Re(r);return e.jsx(mr,{...i,...n,ref:s})});na.displayName=ra;var wo="AlertDialogAction",oa=a.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,i=Re(r);return e.jsx(ws,{...i,...n,ref:s})});oa.displayName=wo;var la="AlertDialogCancel",ia=a.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:i}=ko(la,r),o=Re(r),c=jt(s,i);return e.jsx(ws,{...o,...n,ref:c})});ia.displayName=la;var Co=({contentRef:t})=>{const s=`\`${He}\` requires a description for the component to be accessible for screen reader users.
|
|
113
|
+
|
|
114
|
+
You can add a description to the \`${He}\` by passing a \`${ra}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
|
|
115
|
+
|
|
116
|
+
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${He}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
117
|
+
|
|
118
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return a.useEffect(()=>{var n;document.getElementById((n=t.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},So=Xs,_o=Qs,Eo=Zs,da=ea,ca=ta,ua=oa,ma=ia,xa=aa,ha=na;const Ft=So,is=_o,To=Eo,pa=a.forwardRef(({className:t,...s},r)=>e.jsx(da,{className:_("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:r}));pa.displayName=da.displayName;const xt=a.forwardRef(({className:t,...s},r)=>e.jsxs(To,{children:[e.jsx(pa,{}),e.jsx(ca,{ref:r,className:_("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s})]}));xt.displayName=ca.displayName;const ht=({className:t,...s})=>e.jsx("div",{className:_("flex flex-col space-y-2 text-center sm:text-left",t),...s});ht.displayName="AlertDialogHeader";const pt=({className:t,...s})=>e.jsx("div",{className:_("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});pt.displayName="AlertDialogFooter";const ft=a.forwardRef(({className:t,...s},r)=>e.jsx(xa,{ref:r,className:_("text-lg font-semibold",t),...s}));ft.displayName=xa.displayName;const gt=a.forwardRef(({className:t,...s},r)=>e.jsx(ha,{ref:r,className:_("text-sm text-muted-foreground",t),...s}));gt.displayName=ha.displayName;const bt=a.forwardRef(({className:t,...s},r)=>e.jsx(ua,{ref:r,className:_(Ss(),t),...s}));bt.displayName=ua.displayName;const vt=a.forwardRef(({className:t,...s},r)=>e.jsx(ma,{ref:r,className:_(Ss({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));vt.displayName=ma.displayName;function Do(t,s,r){return t!=="auto"?s.find(n=>n.id===t)??null:r.length===1?r[0]??null:null}function Ao(t){return t.trim()||"."}function ds({value:t,onChange:s,project:r,assignTo:n,nodes:i,assignableNodes:o,layout:c="default",chipClassName:p,chipActiveClassName:f,chipInactiveClassName:b,labelClassName:d,triggerClassName:u}){const[x,h]=a.useState(!1),[w,P]=a.useState(null),[D,N]=a.useState(""),[C,O]=a.useState(!1),[U,S]=a.useState(!1),[H,ae]=a.useState(!1),[F,M]=a.useState(null),[R,re]=a.useState(""),[k,V]=a.useState(""),[Z,I]=a.useState(""),[he,J]=a.useState(!1),K=a.useRef(null),X=a.useRef(0),pe=a.useMemo(()=>Do(n,i,o),[n,i,o]),q=pe==null?void 0:pe.id,ne=a.useMemo(()=>Ao(r),[r]),ee=a.useMemo(()=>q?`${q}
|
|
119
|
+
${ne}`:"",[q,ne]),me=a.useCallback(async(y=0,L=!1)=>{const E=X.current+1,ke=ee;if(X.current=E,!q){P(null),N("");return}M(null),L||N(""),L?S(!0):O(!0);try{const fe=await pr(q,{path:ne,limit:20,offset:y,allowAbsolute:!0});if(E!==X.current)return;N(ke),P(Q=>L&&Q?{...fe,branches:[...Q.branches,...fe.branches]}:fe)}catch(fe){if(E!==X.current)return;M(fe instanceof Error?fe.message:"Failed to load branch info"),L||(P(null),N(""))}finally{E===X.current&&(O(!1),S(!1))}},[q,ee,ne]);a.useEffect(()=>{if(!q){X.current+=1,P(null),N(""),M(null);return}me()},[q,ne,me]),a.useEffect(()=>{const y=t.trim(),L=D===ee?w:null,E=L!=null&&L.available&&L.currentBranch?L.currentBranch:"";y!==E&&s(E)},[w,ee,D,s,t]),a.useEffect(()=>{if(!x)return;const y=E=>{K.current&&(K.current.contains(E.target)||h(!1))},L=E=>{E.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",y),document.addEventListener("keydown",L),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",L)}},[x]),a.useEffect(()=>{x&&(V(""),I(""),J(!1))},[x,q,ne]);const te=a.useCallback(async()=>{if(!q)return;const y=R.trim(),L=he?Z.trim():k.trim();if(!(!y||!L)){ae(!0),M(null);try{const E=await fr(q,{path:ne,branchName:y,startPoint:L,limit:20,offset:0,allowAbsolute:!0});N(ee),P(E),s(E.currentBranch??E.createdBranch),re(""),V(""),I(""),J(!1),h(!1)}catch(E){M(E instanceof Error?E.message:"Failed to create branch")}finally{ae(!1)}}},[q,ee,ne,he,Z,R,s,k]),m=D===ee?w:null,Y=a.useCallback(()=>{m!=null&&m.hasMore&&me(m.branches.length,!0)},[m,me]),$=t.trim()||(m==null?void 0:m.currentBranch)||(m&&!m.available?"No git repo":"Branch"),oe=he?Z.trim():k.trim(),v=!!(m!=null&&m.available&&R.trim()&&oe&&!H),le=c==="composer"?e.jsxs(T,{type:"button",variant:"ghost",onClick:()=>h(y=>!y),title:$,"aria-label":`Branch: ${$}`,className:_(p,u,"min-w-0 max-w-full",t.trim()?f:b),children:[C&&!m?e.jsx(be,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(ns,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:_("min-w-0 truncate",d),children:$})]}):e.jsxs(T,{type:"button",variant:"outline",onClick:()=>h(y=>!y),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:$,children:[e.jsx("span",{className:_("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:$}),e.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:pe?pe.name:"Manual"})]});return e.jsxs("div",{className:_("relative inline-block",c==="composer"?"min-w-0 shrink-0":"w-full"),ref:K,children:[c==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{className:"text-sm font-medium",children:"Branch"}),le]}):le,x&&e.jsxs("div",{className:_("absolute z-50 mt-2 w-[240px] overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",c==="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(ns,{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:m!=null&&m.repoRoot?`${m.currentBranch??$} · ${m.repoRoot}`:(m==null?void 0:m.currentBranch)??$,children:(m==null?void 0:m.currentBranch)??$}),C?e.jsx(be,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}):null]}),pe?C&&!m?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(be,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):m&&!m.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(Fe,{value:R,onChange:y=>re(y.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(T,{type:"button",size:"sm",onClick:()=>void te(),disabled:!v,title:v?"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:H?e.jsx(be,{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"}),!he&&e.jsxs("button",{type:"button",onClick:()=>J(!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(st,{className:"h-2.5 w-2.5"}),"Manual"]})]}),he?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Fe,{value:Z,onChange:y=>I(y.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:()=>{J(!1),I("")},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(ze,{className:"h-3.5 w-3.5"})})]}):m!=null&&m.branches.length?e.jsxs("div",{className:"max-h-44 overflow-y-auto rounded-md border border-border/40 bg-background/40",children:[m.branches.map(y=>{const L=k===y.ref,E=y.branch==="main"||y.branch==="master";return e.jsxs("button",{type:"button",onClick:()=>V(y.ref),className:_("flex w-full items-center gap-2 border-b border-border/20 px-2.5 py-1.5 text-left text-[11px] last:border-b-0 hover:bg-background/60",L&&"bg-background/70"),title:y.ref,children:[e.jsx("span",{className:_("shrink-0 text-[10px]",E?"text-amber-500 dark:text-amber-400":"text-muted-foreground/60"),"aria-hidden":!0,children:E?"★":"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:y.ref}),L?e.jsx(Ke,{className:"h-3 w-3 shrink-0 text-primary"}):null]},y.ref)}),m.hasMore&&e.jsxs("button",{type:"button",onClick:Y,disabled:U,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:[U?e.jsx(be,{className:"h-3 w-3 animate-spin"}):e.jsx(Rt,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"rounded-md border border-dashed border-border/40 px-2.5 py-2 text-[11px] text-muted-foreground",children:"No remote branches found."})]})]})}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a specific node first."}),F&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-1.5 text-[11px] text-destructive",children:F})]})]})}const Po=20,Mo=3,Ot="meshy-working-dir-recents-by-node";function Lo(t){return t.startsWith("/")||t.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(t)}function Ro(t){const s=t.trim();return s||"."}function It(t){const s=[],r=new Set;for(const n of t){const i=n.trim();if(!(!i||r.has(i))&&(r.add(i),s.push(i),s.length===Mo))break}return s}function $o(t,s){const r=s.trim();return It(r?[r,...t]:t)}function fa(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const s={};for(const[r,n]of Object.entries(t)){if(!r||!Array.isArray(n))continue;const i=n.filter(c=>typeof c=="string"),o=It(i);o.length>0&&(s[r]=o)}return s}function Fo(t,s,r){if(!s)return t;const n=t[s]??[],i=$o(n,r);if(i.length===0){if(!(s in t))return t;const{[s]:o,...c}=t;return c}return{...t,[s]:i}}function Oo(t,s){var r;return s?((r=t[s])==null?void 0:r[0])??"":""}function Io(t){if(!t||typeof window>"u")return"";try{const s=window.localStorage.getItem(Ot);return s?Oo(fa(JSON.parse(s)),t):""}catch{return""}}function Bo(t,s,r){return t!=="auto"?s.find(n=>n.id===t)??null:r.length===1?r[0]??null:null}function zo(t,s){const r=s.trim();return r?Lo(r)||!t?r:`${t.replace(/[/\\]+$/,"")}/${r}`:""}function Uo(t,s){return t?t.isAbsolute?t.currentPath:t.currentPath==="."||t.currentPath===""?t.rootPath||(s==null?void 0:s.workDir)||"Node root":t.currentPath:(s==null?void 0:s.workDir)??"Node root"}function cs({value:t,onChange:s,assignTo:r,nodes:n,assignableNodes:i,layout:o="default",chipClassName:c,chipActiveClassName:p,chipInactiveClassName:f,labelClassName:b,triggerClassName:d}){const[u,x]=a.useState(!1),[h,w]=a.useState(null),[P,D]=a.useState(!1),[N,C]=a.useState(!1),[O,U]=a.useState(null),[S,H]=a.useState(""),[ae,F]=a.useState(!1),[M,R]=a.useState({}),re=a.useRef(null),k=a.useMemo(()=>Bo(r,n,i),[r,n,i]),V=k==null?void 0:k.id,Z=a.useMemo(()=>V?M[V]??[]:[],[M,V]),I=a.useMemo(()=>t.trim()?zo(k==null?void 0:k.workDir,t):"Use node default",[t,k==null?void 0:k.workDir]);a.useEffect(()=>{if(!(typeof window>"u"))try{const m=window.localStorage.getItem(Ot);if(!m)return;const Y=JSON.parse(m);R(fa(Y))}catch{}},[]);const he=a.useCallback(m=>{V&&R(Y=>{const $=Fo(Y,V,m);if($===Y)return Y;if(typeof window<"u")try{window.localStorage.setItem(Ot,JSON.stringify($))}catch{}return $})},[V]),J=a.useCallback((m,Y=!0)=>{const $=m.trim();s($),Y&&$&&he($),x(!1)},[s,he]),K=a.useCallback(async(m,Y=0,$=!1)=>{if(V){U(null),$?C(!0):D(!0);try{const oe=await gr(V,{path:m,limit:Po,offset:Y,directoriesOnly:!0,allowAbsolute:!0});w(v=>$&&v?{...oe,entries:[...v.entries,...oe.entries]}:oe)}catch(oe){U(oe instanceof Error?oe.message:"Failed to browse directories"),$||w(null)}finally{D(!1),C(!1)}}},[V]),X=a.useRef(t);X.current=t;const pe=a.useRef(K);pe.current=K,a.useEffect(()=>{if(!u)return;const m=X.current;H(m),F(!1),w(null),U(null),V&&pe.current(Ro(m))},[u,V]),a.useEffect(()=>{if(!u)return;const m=$=>{re.current&&(re.current.contains($.target)||x(!1))},Y=$=>{$.key==="Escape"&&x(!1)};return document.addEventListener("mousedown",m),document.addEventListener("keydown",Y),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",Y)}},[u]);const q=a.useCallback(m=>{K(m)},[K]),ne=a.useCallback(()=>{h&&K(h.currentPath,h.entries.length,!0)},[h,K]),ee=o==="composer"?e.jsxs(T,{type:"button",variant:"ghost",onClick:()=>x(m=>!m),title:I,"aria-label":`Working directory: ${I}`,className:_(c,d,"min-w-0 max-w-full",t.trim()?p:f),children:[e.jsx(br,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:_("min-w-0 truncate",b),children:I})]}):e.jsxs(T,{type:"button",variant:"outline",onClick:()=>x(m=>!m),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:I,children:[e.jsx("span",{className:_("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:I}),e.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:k?k.name:"Manual"})]}),me=Uo(h,k),te=!!(h!=null&&h.parentPath);return e.jsxs("div",{className:_("relative inline-block",o==="composer"?"min-w-0 max-w-[60%] shrink":"w-full"),ref:re,children:[o==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{className:"text-sm font-medium",children:"Working directory"}),ee]}):ee,u&&e.jsxs("div",{className:_("absolute z-50 mt-2 w-[240px] overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",o==="composer"?"left-0":"left-0 right-0 w-auto min-w-[240px]"),children:[Z.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(Rt,{className:"h-2.5 w-2.5"}),"Recent"]}),e.jsx("div",{className:"flex flex-col",children:Z.map(m=>e.jsx("button",{type:"button",onClick:()=>J(m),className:"truncate rounded px-1.5 py-0.5 text-left font-mono text-[11px] text-foreground hover:bg-background/60",title:m,children:m},m))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/60 px-2.5 py-1.5",children:[e.jsx("button",{type:"button",onClick:()=>(h==null?void 0:h.parentPath)&&q(h.parentPath),disabled:!te||P,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(kn,{className:"h-3 w-3"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:me,children:me}),h&&e.jsx("button",{type:"button",onClick:()=>J(h.isAbsolute?h.currentPath:h.currentPath==="."?"":h.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:[k?P?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(be,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):h&&h.entries.length>0?e.jsxs(e.Fragment,{children:[h.entries.map(m=>e.jsxs("div",{className:"group flex items-stretch border-b border-border/30 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>J(m.path),className:"flex min-w-0 flex-1 items-center gap-2 px-2.5 py-1.5 text-left hover:bg-background/55",title:`Use ${m.path}`,children:[e.jsx(bn,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[11px] text-foreground",children:m.name})]}),e.jsx("button",{type:"button",onClick:()=>q(m.path),className:"flex w-9 shrink-0 items-center justify-center border-l border-border/30 text-muted-foreground hover:bg-background/70 hover:text-foreground",title:"Open subfolder","aria-label":`Open ${m.name}`,children:e.jsx(et,{className:"h-3.5 w-3.5"})})]},m.path)),h.hasMore&&e.jsxs("button",{type:"button",onClick:ne,disabled:N,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:[N?e.jsx(be,{className:"h-3 w-3 animate-spin"}):e.jsx(Rt,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:O??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a node to browse."}),O&&h&&h.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[11px] text-destructive",children:O})]}),e.jsx("div",{className:"flex items-center gap-1 border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:ae?e.jsxs(e.Fragment,{children:[e.jsx(Fe,{value:S,onChange:m=>H(m.target.value),onKeyDown:m=>{m.key==="Enter"&&S.trim()?(m.preventDefault(),J(S)):m.key==="Escape"&&(m.preventDefault(),F(!1),H(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:()=>J(S),disabled:!S.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(Ke,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{F(!1),H(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(ze,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>{H(t),F(!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(st,{className:"h-3 w-3"})]})})]})]})}function Vo(t,s={}){const r=t.filter(n=>n.status==="online");return s.currentNodeRole!=="follower"||!s.leaderNodeId?r:r.filter(n=>n.id!==s.leaderNodeId)}function us(){return Fs.map(t=>e.jsx(ye,{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 ms(){return Os.map(t=>e.jsx(ye,{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 ga({isCurrent:t}){return t?e.jsx(Mn,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):e.jsx(Tn,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function xs(t,s){return t.map(r=>{const n=!!s&&r.id===s;return e.jsx(ye,{value:r.id,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(ga,{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 qo(t){var s;return((s=Fs.find(r=>r.value===t))==null?void 0:s.label)??t}function Ho(t){var s;return((s=Os.find(r=>r.value===t))==null?void 0:s.label)??t}function ba(t,s,r=!1){const n=t.trim();if(n)return n;const i=s.trim().split(`
|
|
120
|
+
`).map(o=>o.trim()).find(Boolean);return i?i.length>72?`${i.slice(0,69).trimEnd()}...`:i:r?"Image task":""}function Ko(t){var c;const s=t.title.trim(),r=ba(t.title,t.description,t.images.length>0),n=t.description.trim()||r,i=t.mode??Mt,o=Rs(t.description,t.images);return!r||!n||!t.agent?null:{title:r,description:n,agent:t.agent,project:t.project.trim()||null,branch:((c=t.branch)==null?void 0:c.trim())||null,payload:{initialMessage:o,mode:i,titleSource:s?"manual":"derived"},priority:t.priority,assignTo:t.assignTo==="auto"?void 0:t.assignTo}}function Wo({nodes:t,currentNodeRole:s,currentNodeId:r,leaderNodeId:n,onCreated:i,onCancel:o,className:c,footerClassName:p,submitLabel:f="Create chat",cancelLabel:b="Cancel",autoFocus:d=!1,layout:u="default"}){const[x,h]=a.useState(""),[w,P]=a.useState(""),[D,N]=a.useState("claudecode"),[C,O]=a.useState(Mt),[U,S]=a.useState(""),[H,ae]=a.useState(""),[F,M]=a.useState("normal"),R=a.useMemo(()=>Vo(t,{currentNodeRole:s,leaderNodeId:n}),[t,s,n]),re=a.useMemo(()=>{var A;return r&&R.some(xe=>xe.id===r)?r:((A=R[0])==null?void 0:A.id)??""},[R,r]),[k,V]=a.useState(re),[Z,I]=a.useState(!1),[he,J]=a.useState(!1),{images:K,error:X,fileInputRef:pe,pickImages:q,handleFileChange:ne,handlePaste:ee,removeImage:me}=Js(),te=a.useMemo(()=>R.find(A=>A.id===k)??null,[k,R]),m=!!(r&&(te==null?void 0:te.id)===r),Y=qo(D),$=Ho(C);a.useEffect(()=>{k&&R.some(A=>A.id===k)||V(re)},[k,R,re]),a.useEffect(()=>{S(Io(k)),ae("")},[k]),a.useEffect(()=>{ae("")},[U]);const oe=a.useCallback(async A=>{A.preventDefault();const xe=Ko({title:x,description:w,agent:D,project:U,branch:H,priority:F,assignTo:k,mode:C,images:K});if(xe){I(!0);try{const Ne=await vr(xe);i(Ne)}catch(Ne){ce.error(Ne instanceof Error?Ne.message:"Failed to create task")}finally{I(!1)}}},[x,w,D,U,H,F,k,C,K,i]),v=ba(x,w,K.length>0),le=!!(v&&D&&k&&(w.trim()||K.length>0)),y=a.useCallback(A=>{var xe;A.nativeEvent.isComposing||A.key==="Enter"&&(A.ctrlKey||A.metaKey)&&le&&!Z&&(A.preventDefault(),(xe=A.currentTarget.form)==null||xe.requestSubmit())},[le,Z]),L=K.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3",children:K.map((A,xe)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:$s(A),alt:A.filename??`attachment ${xe+1}`,className:"h-24 w-24 rounded-2xl border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>me(xe),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 ${A.filename??`image ${xe+1}`}`,children:e.jsx(ze,{className:"h-3.5 w-3.5"})})]},`${A.filename??"image"}-${xe}`))}),E=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{className:"text-sm font-medium",children:"Assign to"}),e.jsxs(_e,{value:k,onValueChange:V,children:[e.jsx(Ee,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:e.jsx(Le,{placeholder:"Select node"})}),e.jsx(Te,{children:xs(R,r)})]})]}),ke=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{className:"text-sm font-medium",children:"Agent"}),e.jsxs(_e,{value:D,onValueChange:N,children:[e.jsx(Ee,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:e.jsx(Le,{placeholder:"Select agent"})}),e.jsx(Te,{children:us()})]})]}),fe=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{className:"text-sm font-medium",children:"Mode"}),e.jsxs(_e,{value:C,onValueChange:A=>O(A),children:[e.jsx(Ee,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:e.jsx(Le,{placeholder:"Select mode"})}),e.jsx(Te,{children:ms()})]})]}),Q=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{className:"text-sm font-medium",children:"Priority"}),e.jsxs(_e,{value:F,onValueChange:M,children:[e.jsx(Ee,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:e.jsx(Le,{placeholder:"Select priority"})}),e.jsxs(Te,{children:[e.jsx(ye,{value:"low",children:"Low"}),e.jsx(ye,{value:"normal",children:"Normal"}),e.jsx(ye,{value:"high",children:"High"}),e.jsx(ye,{value:"critical",children:"Critical"})]})]})]}),je=e.jsx(cs,{value:U,onChange:S,assignTo:k,nodes:t,assignableNodes:R}),Ye=e.jsx(ds,{value:H,onChange:ae,project:U,assignTo:k,nodes:t,assignableNodes:R});return u==="composer"?e.jsxs("form",{onSubmit:oe,className:_("space-y-4",c),children:[e.jsx("input",{ref:pe,type:"file",accept:"image/*",multiple:!0,onChange:ne,className:"hidden"}),(()=>{const A="chat-composer__chip h-9 w-auto gap-1.5 rounded-full px-3.5 text-xs shadow-none transition-colors",xe="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",Ne="border-border/70 bg-background/55 text-foreground",Ce=D==="claudecode",Se=C===Mt;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(_e,{value:k,onValueChange:V,children:[e.jsx(Ee,{className:_(A,Ne,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${(te==null?void 0:te.name)??"unassigned"}`,"aria-label":`Assigned node: ${(te==null?void 0:te.name)??"unassigned"}`,children:te?e.jsxs(e.Fragment,{children:[e.jsx(ga,{isCurrent:m}),e.jsx("span",{className:"min-w-0 truncate",children:te.name}),e.jsx("span",{className:"chat-composer__header-meta shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:m?"current":"remote"})]}):e.jsx(Le,{placeholder:"Select node"})}),e.jsx(Te,{children:xs(R,r)})]}),he?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Fe,{id:"task-title-composer",type:"text",value:x,onChange:ve=>h(ve.target.value),onKeyDown:ve=>{(ve.key==="Enter"||ve.key==="Escape")&&(ve.preventDefault(),J(!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(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>J(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-full text-muted-foreground hover:text-foreground",children:e.jsx(Ke,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>J(!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:v||"Title","aria-label":v?`Edit title: ${v}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:v||"Title"}),e.jsx(st,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",value:w,onChange:ve=>P(ve.target.value),onKeyDown:y,onPaste:ee,placeholder:"Ask anything...",rows:4,autoFocus:d,"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(T,{type:"button",variant:"ghost",size:"icon",onClick:q,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-full text-muted-foreground hover:text-foreground",children:e.jsx($t,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsxs(_e,{value:D,onValueChange:N,children:[e.jsxs(Ee,{className:_(A,"chat-composer__icon-trigger",Ce?xe:Ne),title:`Agent: ${Y}`,"aria-label":`Agent: ${Y}`,children:[e.jsx(_s,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:Y})]}),e.jsx(Te,{children:us()})]}),e.jsxs(_e,{value:C,onValueChange:ve=>O(ve),children:[e.jsxs(Ee,{className:_(A,"chat-composer__icon-trigger",Se?xe:Ne),title:`Mode: ${$}`,"aria-label":`Mode: ${$}`,children:[e.jsx(Xn,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:$})]}),e.jsx(Te,{children:ms()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[e.jsxs(_e,{value:F,onValueChange:M,children:[e.jsx(Ee,{"aria-label":`Priority: ${F}`,title:`Priority: ${F}`,className:_("h-9 w-9 justify-center gap-0 rounded-full p-0 text-xs shadow-none [&>svg:last-child]:hidden",F==="normal"?"border-transparent bg-transparent text-muted-foreground hover:bg-background/40":"border-border/70 bg-background/55",F==="critical"&&"text-destructive",F==="high"&&"text-amber-600 dark:text-amber-400",F==="low"&&"text-muted-foreground"),children:e.jsx(wn,{className:_("h-4 w-4",F==="critical"&&"fill-destructive/20")})}),e.jsxs(Te,{children:[e.jsx(ye,{value:"low",children:"Low"}),e.jsx(ye,{value:"normal",children:"Normal"}),e.jsx(ye,{value:"high",children:"High"}),e.jsx(ye,{value:"critical",children:"Critical"})]})]}),o&&e.jsxs(T,{type:"button",variant:"ghost",size:"sm",onClick:o,"aria-label":b,className:"chat-composer__cancel h-9 rounded-full px-4 text-xs text-muted-foreground",children:[e.jsx(ze,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:b})]}),e.jsxs(T,{type:"submit",size:"icon",disabled:!le||Z,className:"h-10 w-10 rounded-full shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[Z?e.jsx(be,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:Z?"Creating chat":f})]})]})]})]}),e.jsx("div",{className:"chat-composer__location flex flex-wrap items-center gap-2 px-1",children:(()=>{const ve="border-border/40 bg-muted/40 text-foreground/80 hover:bg-muted/60 hover:text-foreground";return e.jsxs(e.Fragment,{children:[e.jsx(cs,{value:U,onChange:S,assignTo:k,nodes:t,assignableNodes:R,layout:"composer",chipClassName:A,chipActiveClassName:ve,chipInactiveClassName:ve,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"}),e.jsx(ds,{value:H,onChange:ae,project:U,assignTo:k,nodes:t,assignableNodes:R,layout:"composer",chipClassName:A,chipActiveClassName:ve,chipInactiveClassName:ve,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"})]})})()})]})})(),(L||X)&&e.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/45 p-4",children:[L,X&&e.jsx("div",{className:"text-xs text-destructive",children:X}),!X&&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:oe,className:_("space-y-5",c),children:[e.jsx("input",{ref:pe,type:"file",accept:"image/*",multiple:!0,onChange:ne,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{htmlFor:"task-description",className:"text-sm font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",value:w,onChange:A=>P(A.target.value),onKeyDown:y,onPaste:ee,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:d,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(T,{type:"button",variant:"outline",onClick:q,className:"rounded-2xl",children:[e.jsx($t,{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."})]}),L,X&&e.jsx("p",{className:"text-xs text-destructive",children:X})]}),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(Me,{htmlFor:"task-title",className:"text-sm font-medium",children:"Chat title"}),e.jsx(Fe,{id:"task-title",type:"text",value:x,onChange:A=>h(A.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:v?`Will appear as: ${v}`:"A title will be generated from the first line of the prompt."})]}),ke,fe]}),je,Ye,e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[Q,E]}),e.jsxs("div",{className:_("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",p),children:[o&&e.jsx(T,{type:"button",variant:"ghost",onClick:o,className:"rounded-2xl",children:b}),e.jsx(T,{type:"submit",disabled:!le||Z,className:"rounded-2xl px-5",children:Z?"Creating...":f})]})]})}const Ge="72f988bf-86f1-41af-91ab-2d7cd011db47",va=`${Ge} (MSIT)`;function Go({open:t,onOpenChange:s,onShare:r,onStopShare:n,sharing:i,stopping:o=!1,shareResult:c}){return e.jsx(Es,{open:t,onOpenChange:s,children:e.jsxs(Ns,{className:"max-w-md rounded-lg p-5",children:[e.jsx(ks,{className:"sr-only",children:"Share conversation"}),e.jsx(Jo,{onOpenChange:s,onShare:r,onStopShare:n,sharing:i,stopping:o,shareResult:c})]})})}function Jo({onOpenChange:t,onShare:s,onStopShare:r,sharing:n,stopping:i=!1,shareResult:o}){const[c,p]=a.useState((o==null?void 0:o.tenant)??Ge),[f,b]=a.useState((o==null?void 0:o.scope)??"chat"),d=(o==null?void 0:o.url)??null,u=n||i;return a.useEffect(()=>{p((o==null?void 0:o.tenant)??Ge),b((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(Yo,{value:c,onChange:p,disabled:u}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Access"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(hs,{active:f==="chat",title:"Chat only",description:"Conversation transcript and opening prompt.",onClick:()=>b("chat")}),e.jsx(hs,{active:f==="filesPreview",title:"Chat, files and preview",description:"Transcript plus task output files and HTML preview.",onClick:()=>b("filesPreview")})]})]}),d&&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:d,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none","aria-label":"Shared link"}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-full text-muted-foreground",onClick:()=>void Ue(d,"Shared link copied"),"aria-label":"Copy shared link",title:"Copy shared link",children:e.jsx(Vt,{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(T,{variant:"outline",onClick:()=>t(!1),disabled:u,className:"h-8 text-xs",children:o?"Done":"Cancel"}),o&&r&&e.jsxs(T,{variant:"outline",onClick:()=>void r(),disabled:u,className:"h-8 border-destructive/30 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive",children:[i&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),"Stop share"]}),e.jsxs(T,{onClick:()=>void s({tenant:c,scope:f}),disabled:u,className:"h-8 text-xs",children:[n&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),o?"Update link":"Share link"]})]})]})}function Yo({value:t,onChange:s,disabled:r}){const[n,i]=a.useState(!1),[o,c]=a.useState(!1),[p,f]=a.useState(t),b=a.useRef(null);a.useEffect(()=>{f(t)},[t]),a.useEffect(()=>{if(!n)return;const u=h=>{var P;const w=h.target;w instanceof Node&&((P=b.current)!=null&&P.contains(w)||(i(!1),c(!1)))},x=h=>{h.key==="Escape"&&(i(!1),c(!1))};return document.addEventListener("mousedown",u),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",x)}},[n]);const d=u=>{const x=u.trim();x&&(s(x),f(x),c(!1),i(!1))};return e.jsxs("div",{className:"space-y-2 text-xs",ref:b,children:[e.jsx("div",{className:"font-medium text-foreground",children:"Tenant"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>!r&&i(u=>!u),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:Xo(t)}),e.jsx(We,{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:()=>d(Ge),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:va}),t===Ge&&e.jsx(Ke,{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:p,onChange:u=>f(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),d(p))},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:()=>d(p),className:"flex h-7 w-7 items-center justify-center rounded-md hover:bg-background/60",children:e.jsx(Ke,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{f(t),c(!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(ze,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>c(!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(st,{className:"h-3 w-3"})]})})]})]})]})}function Xo(t){return t===Ge?va:t}function hs({active:t,title:s,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:s}),e.jsx("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:r})]})}const Qo=a.lazy(async()=>({default:(await zt(()=>import("./FilesTab-Csi7UE5G.js"),__vite__mapDeps([0,1,2,3,4]))).FilesTab})),Zo=a.lazy(async()=>({default:(await zt(()=>import("./PreviewTab-DT95fOD3.js"),__vite__mapDeps([5,1,2]))).PreviewTab})),el=a.lazy(async()=>({default:(await zt(()=>import("./DiffTab-DgOYOCn1.js"),__vite__mapDeps([6,1,2,4,3,7]))).DiffTab}));function tl({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:i,cluster:o,sseConnected:c,activeTab:p,setActiveTab:f,creatingTask:b,activeTask:d,assignedNode:u,taskLoading:x,taskError:h,displayEvents:w,initialPromptAlreadyInLogs:P,initialPrompt:D,supportsFollowUp:N,taskUnavailable:C,chatDisabled:O,chatDisabledReason:U,questionBypassEnabled:S,isRunning:H,isStarting:ae,hasPendingFollowUp:F,canCancel:M,canRetry:R,onRetry:re,onCancel:k,onShareTask:V,onStopShareTask:Z,onStartCreateTask:I,onCancelCreateTask:he,onCreateTask:J,onSendMessage:K,onQuestionBypassChange:X,onSubmitQuestionResponse:pe,messagesEndRef:q}){const[ne,ee]=a.useState(!1),[me,te]=a.useState(!1),[m,Y]=a.useState(!1),[$,oe]=a.useState(!1),[v,le]=a.useState(!1),[y,L]=a.useState(!1),[E,ke]=a.useState({}),[fe,Q]=a.useState(new Set),[je,Ye]=a.useState(new Set),A=a.useRef(0),xe=a.useRef(!1),Ne=a.useCallback(ge=>{const de=ge.currentTarget,W=A.current;if(A.current=de.scrollTop,xe.current)return;if(de.scrollHeight-de.scrollTop-de.clientHeight<30){te(!1),xe.current=!0,setTimeout(()=>{xe.current=!1},300);return}de.scrollTop<W&&W-de.scrollTop>10&&te(!0),de.scrollTop<=0&&te(!0)},[]),Ce=(d==null?void 0:d.effectiveProjectPath)??(d==null?void 0:d.project)??"default workspace",Se=d?(u==null?void 0:u.name)??Is(d.assignedTo,o==null?void 0:o.nodes,d.assignedNodeName):"unassigned",ve=d!=null&&d.assignedTo?e.jsxs(e.Fragment,{children:["Connecting session on node ",e.jsx("span",{className:"font-medium text-foreground",children:Se}),"..."]}):"Connecting session to an available node...",at=d?[{label:"Working dir",value:Ce,mono:!0},...d.branch?[{label:"Branch",value:d.branch,mono:!0}]:[],{label:"Agent",value:d.agent,mono:!0},{label:"Node",value:Se}]:[],rt=d!=null&&d.description&&d.description!==d.title?d.description:null,Xe=!!(D&&!P),nt=Xe||w.length>0,Qe=H&&nt,Ze=(ae||F||H)&&!Qe,Oe=d&&!fe.has(d.id)?E[d.id]??d.activeShare??null:null;return b?e.jsx(sl,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:i,cluster:o,sseConnected:c,onCancel:he,onCreated:J}):!d&&x?e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[e.jsx("div",{className:"shrink-0 border-b border-border/60 px-4 py-4 sm:px-5",children:e.jsx(ut,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:i,cluster:o,sseConnected:c})}),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(be,{className:"h-7 w-7 animate-spin"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"Loading conversation"}),e.jsxs("div",{className:"flex items-center justify-center gap-3 text-sm text-muted-foreground",children:[e.jsx(be,{className:"h-4 w-4 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):d?e.jsxs(Ts,{value:p,onValueChange:f,className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-4 py-2.5 sm:px-5",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(ut,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:i,cluster:o,sseConnected:c})}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("h2",{className:"min-w-0 truncate text-base font-semibold tracking-tight text-foreground sm:text-lg",title:d.title,children:d.title}),e.jsx(Ds,{status:d.status}),e.jsx(jr,{priority:d.priority}),e.jsxs(T,{type:"button",variant:"outline",size:"sm",disabled:C,title:C?"Unavailable tasks cannot be shared.":"Share conversation",className:"ml-auto h-8 shrink-0 rounded-full border-primary/30 bg-primary/10 px-3 text-xs text-primary hover:bg-primary/15 hover:text-primary disabled:border-border/60 disabled:bg-muted/40 disabled:text-muted-foreground",onClick:()=>oe(!0),children:[e.jsx(Jn,{className:"h-3.5 w-3.5"}),"Share"]}),e.jsx(T,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 rounded-full text-muted-foreground",onClick:()=>ee(ge=>!ge),children:ne?e.jsx(Nr,{className:"h-3.5 w-3.5"}):e.jsx(We,{className:"h-3.5 w-3.5"})})]}),ne&&e.jsxs("div",{className:"mt-2 space-y-2",children:[rt&&e.jsx("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:rt}),h&&e.jsx("div",{className:"w-fit rounded-full border border-destructive/25 bg-destructive/10 px-3 py-1 text-xs text-destructive",children:h}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-col text-xs text-muted-foreground",children:[e.jsxs("span",{children:["updated ",Gr(d.updatedAt)]}),e.jsx("span",{className:"font-mono",children:d.id.slice(0,8)})]}),e.jsx("div",{className:"flex items-center gap-2",children:R&&e.jsxs(T,{variant:"outline",size:"sm",onClick:re,className:"shrink-0 rounded-full",children:[e.jsx(Hn,{className:"h-3.5 w-3.5"}),"Retry"]})})]})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[e.jsxs(As,{className:"h-auto max-w-full overflow-x-auto rounded-full bg-muted/70 p-1",children:[e.jsx(Ie,{value:"transcript",className:"rounded-full px-2.5 sm:px-4",children:"Transcript"}),e.jsx(Ie,{value:"files",className:"rounded-full px-2.5 sm:px-4",children:"Files"}),e.jsx(Ie,{value:"preview",className:"rounded-full px-2.5 sm:px-4",children:"Preview"}),e.jsx(Ie,{value:"diff",className:"rounded-full px-2.5 sm:px-4",children:"Diff"})]}),H&&e.jsx(De,{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"}),C&&e.jsx(De,{variant:"outline",className:"hidden rounded-full border-destructive/25 bg-destructive/10 text-destructive sm:inline-flex",children:"Unavailable"})]})]}),e.jsx(Be,{value:"transcript",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-5 sm:px-5",onScroll:Ne,children:e.jsxs("div",{className:"mx-auto flex max-w-[72rem] flex-col gap-5",children:[Xe&&D&&e.jsx(as,{event:D,questionBypassEnabled:S,onQuestionBypassChange:X,onSubmitQuestionResponse:pe,questionResponseDisabled:!N||O}),w.map((ge,de)=>e.jsx(as,{event:ge,questionBypassEnabled:S,onQuestionBypassChange:X,onSubmitQuestionResponse:pe,questionResponseDisabled:!N||O},Jr("transcript",ge,de))),!nt&&!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-sm font-medium text-foreground",children:"Transcript is warming up"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:x?"Fetching task output...":"The opening prompt has been stored, but the agent has not emitted conversation output yet."})]}),(!N&&d.result||d.error)&&e.jsxs("div",{className:"space-y-3",children:[!N&&d.result&&e.jsxs("div",{className:"rounded-[26px] border border-border/70 bg-card/80 px-4 py-4",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Stored result"}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:JSON.stringify(d.result,null,2)})]}),d.error&&!je.has(d.id)&&e.jsxs("div",{className:"rounded-[26px] border border-destructive/20 bg-destructive/10 px-4 py-4 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:()=>Ye(ge=>new Set(ge).add(d.id)),className:"rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(ze,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-xs leading-5",children:d.error})]})]}),Ze&&e.jsx(ps,{children:ve}),Qe&&e.jsx(ps,{children:"The agent is still working on this conversation."}),e.jsx("div",{ref:q})]})}),N?me?e.jsx(T,{size:"icon",onClick:()=>te(!1),className:"absolute bottom-4 right-4 z-10 h-12 w-12 rounded-full shadow-lg",children:e.jsx(st,{className:"h-5 w-5"})}):e.jsx("div",{className:"shrink-0",children:e.jsx("div",{className:"mx-auto w-full max-w-[72rem]",children:e.jsx(fo,{onSend:K,disabled:O,disabledReason:U,contextItems:at,placeholder:O?U:"Continue the conversation...",running:H||F,onStop:M?()=>Y(!0):void 0})})}):e.jsx("div",{className:"shrink-0 border-t border-border/60 px-4 py-4 text-sm text-muted-foreground sm:px-5",children:"This task does not expose follow-up chat messages. Use Files, Preview, or Diff to inspect the result."})]})}),e.jsx(Be,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:e.jsx(Tt,{label:"Loading files..."}),children:e.jsx(Qo,{taskId:d.id})})}),e.jsx(Be,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:e.jsx(Tt,{label:"Loading preview..."}),children:e.jsx(Zo,{taskId:d.id})})}),e.jsx(Be,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:e.jsx(Tt,{label:"Loading diff..."}),children:e.jsx(el,{taskId:d.id})})}),e.jsx(Ft,{open:m,onOpenChange:Y,children:e.jsxs(xt,{children:[e.jsxs(ht,{children:[e.jsx(ft,{children:"Stop this task?"}),e.jsx(gt,{children:"The task will stop and move to a cancelled state."})]}),e.jsxs(pt,{children:[e.jsx(vt,{children:"Keep running"}),e.jsx(bt,{onClick:k,children:"Stop task"})]})]})}),e.jsx(Go,{open:$,onOpenChange:oe,sharing:v,stopping:y,shareResult:Oe,onShare:async ge=>{if(!d)return null;le(!0);try{const de=await V(ge);return de!=null&&de.url&&(ke(W=>({...W,[d.id]:de})),Q(W=>{const se=new Set(W);return se.delete(d.id),se})),de}finally{le(!1)}},onStopShare:async()=>{if(!d)return!1;L(!0);try{const ge=await Z();return ge!==!1&&(ke(de=>{const W={...de};return delete W[d.id],W}),Q(de=>new Set(de).add(d.id))),ge}finally{L(!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-4 py-4 sm:px-5",children:e.jsx(ut,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:i,cluster:o,sseConnected:c})}),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(_s,{className:"h-7 w-7"})}),e.jsx("h2",{className:"mt-5 text-xl font-semibold tracking-tight text-foreground sm:text-3xl",children:"No chat selected"}),e.jsx("p",{className:"mx-auto mt-3 max-w-xl text-sm leading-6 text-muted-foreground",children:"Open a task from the left sidebar to continue the conversation, or start a new task to create a fresh chat thread."}),e.jsxs(T,{onClick:I,className:"mt-6 rounded-full px-5",children:[e.jsx(zs,{className:"h-4 w-4"}),"Start new chat"]}),h&&e.jsx("div",{className:"mx-auto mt-4 max-w-lg rounded-[20px] border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:h})]})})]})}function ps({children:t}){return e.jsxs("div",{className:"flex items-center gap-3 rounded-[24px] border border-border/60 bg-background/45 px-4 py-3 text-sm text-muted-foreground",children:[e.jsx(be,{className:"h-4 w-4 shrink-0 animate-spin"}),e.jsx("div",{className:"min-w-0 leading-5",children:t})]})}function sl({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:i,cluster:o,sseConnected:c,onCancel:p,onCreated:f}){var b,d,u;return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[e.jsx("div",{className:"shrink-0 border-b border-border/60 px-4 py-4 sm:px-5",children:e.jsx(ut,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:i,cluster:o,sseConnected: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(Wo,{nodes:(o==null?void 0:o.nodes)??[],currentNodeRole:(b=o==null?void 0:o.self)==null?void 0:b.role,currentNodeId:((d=o==null?void 0:o.self)==null?void 0:d.id)??null,leaderNodeId:((u=o==null?void 0:o.leader)==null?void 0:u.id)??null,onCreated:f,onCancel:p,submitLabel:"Start chat",autoFocus:!0,layout:"composer"})})})]})}function ut({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:r,operationsOpen:n,onToggleOperations:i,cluster:o,sseConnected:c}){var p;return e.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.jsx(al,{desktopTasksOpen:s,mobileTasksPanelOpen:r,onToggleTasks:t}),e.jsx(De,{variant:"outline",className:"hidden rounded-full border-border/70 bg-background/60 sm:inline-flex",children:c?"Live":"Retrying"}),((p=o==null?void 0:o.leader)==null?void 0:p.name)&&e.jsxs(De,{variant:"outline",className:"hidden rounded-full border-border/70 bg-background/60 sm:inline-flex",children:["leader ",o.leader.name]})]}),e.jsxs(T,{variant:"outline",onClick:i,className:"shrink-0 rounded-full border-border/70 bg-background/60 px-3 sm:px-4",children:[n?e.jsx(Vs,{className:"h-4 w-4"}):e.jsx(Bn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:n?"Hide cluster":"Show cluster"})]})]})}function al({desktopTasksOpen:t,mobileTasksPanelOpen:s,onToggleTasks:r}){var i,o;const n=(o=(i=globalThis.window)==null?void 0:i.matchMedia("(min-width: 1024px)"))!=null&&o.matches?t:s;return e.jsxs(T,{variant:"outline",onClick:r,className:"rounded-full border-border/70 bg-background/60 px-3 sm:px-4",children:[n?e.jsx(Us,{className:"h-4 w-4"}):e.jsx(Fn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:n?"Hide tasks":"Show tasks"})]})}const rl={node:"border-teal-500/30 bg-teal-500/10 text-teal-700 dark:text-teal-300",task:"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300",election:"border-indigo-500/30 bg-indigo-500/10 text-indigo-700 dark:text-indigo-300",cluster:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"};function nl(t){return t.split(".")[0]??"unknown"}function ol(t){return new Date(t).toLocaleTimeString("en-US",{hour12:!1})}function At(t,s){return(s==null?void 0:s.get(t))??t}function ll(t,s){const r=t.data;switch(t.type){case"node.joined":return`${r.name} joined the cluster`;case"node.left":return`${At(r.nodeId,s)} left (${r.reason})`;case"node.status":return`${At(r.nodeId,s)} is now ${r.status}`;case"task.created":return`"${r.title}" created`;case"task.assigned":return`task assigned to ${At(r.nodeId,s)}`;case"task.status":return`task ${r.taskId.slice(0,8)} -> ${r.status}`;case"election.started":return`candidate ${r.candidateId.slice(0,8)} term ${r.term}`;case"election.complete":return`leader elected, term ${r.term}`;case"cluster.state":return`${r.nodeCount} nodes, term ${r.term}`;default:return JSON.stringify(r)}}function il(t){return JSON.stringify(t,null,2)}function dl({events:t,maxHeight:s="400px",emptyTitle:r="No live events yet",emptyDescription:n="Cluster activity appears here as it happens.",nodeNameById:i}){return t.length===0?e.jsx("div",{className:"flex h-28 items-center justify-center rounded-[20px] border border-dashed border-border/70 bg-background/40 text-center",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:r}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground/70",children:n})]})}):e.jsx("div",{className:"overflow-y-auto pr-1",style:{maxHeight:s},children:e.jsx("div",{className:"space-y-2",children:t.map(o=>{const c=nl(o.type);return e.jsx("div",{className:"rounded-[20px] border border-border/60 bg-background/45 px-4 py-3 transition-colors hover:border-border hover:bg-background/65",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:ol(o.timestamp)}),e.jsx(De,{variant:"outline",className:_("w-fit text-[10px] font-medium uppercase tracking-[0.16em]",rl[c]),children:o.type})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-full text-muted-foreground",onClick:()=>void Ue(il(o),"Event copied"),"aria-label":`Copy ${o.type} event`,title:"Copy event",children:e.jsx(Vt,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"text-sm leading-6 text-foreground/85",children:ll(o,i)})]})},o.id)})})})}function fs({cluster:t,systemInfo:s,nodeNameById:r,nodeBlockingTaskCounts:n,eventTypeFilter:i,onEventTypeFilterChange:o,eventTypeOptions:c,filteredEvents:p,sseConnected:f,clusterLoading:b,clusterError:d,promotePending:u,onPromote:x,onAddNode:h,leavePending:w,onLeaveCluster:P,onToggleNodeDevTunnel:D,devTunnelNodeId:N,onClose:C}){var R,re,k,V,Z;const O=((R=t==null?void 0:t.self)==null?void 0:R.role)==="leader",U=((re=t==null?void 0:t.self)==null?void 0:re.role)==="follower"&&!(t!=null&&t.leader),S=(t==null?void 0:t.self)??null,ae=Yr((t==null?void 0:t.nodes)??[],S==null?void 0:S.id).filter(I=>I.id!==(S==null?void 0:S.id)),F=(S==null?void 0:S.role)==="leader"&&ae.length===0,M=(S==null?void 0:S.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-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-semibold tracking-tight",children:"Operations"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Node, cluster, and live events."})]}),e.jsx(T,{variant:"ghost",size:"icon",onClick:C,className:"rounded-full",children:e.jsx(Vs,{className:"h-4 w-4"})})]}),e.jsxs(As,{className:"mt-4 grid h-auto w-full grid-cols-3 rounded-full bg-muted/70 p-1",children:[e.jsx(Ie,{value:"overview",className:"rounded-full px-3 text-xs",children:"Overview"}),e.jsx(Ie,{value:"nodes",className:"rounded-full px-3 text-xs",children:"Nodes"}),e.jsx(Ie,{value:"events",className:"rounded-full px-3 text-xs",children:"Live events"})]})]}),e.jsx(Be,{value:"overview",className:"mt-0 min-h-0 flex-1",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto px-4 py-5",children:e.jsxs("div",{className:"space-y-7",children:[S&&e.jsx(gs,{node:S,systemInfo:s,blockingTaskCount:n.get(S.id)??0,devTunnelNodeId:N,onToggleNodeDevTunnel:D,showActions:!1,defaultExpanded:!1}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Cluster snapshot"}),e.jsx(De,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:f?"Connected":"Reconnecting"})]}),b&&!t?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(be,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):d&&!t?e.jsx("div",{className:"rounded-[22px] border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:d}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(qe,{label:"Term",value:String((t==null?void 0:t.term)??0)}),e.jsx(qe,{label:"Nodes",value:String((t==null?void 0:t.nodes.length)??0)}),e.jsx(qe,{label:"Pending",value:String((t==null?void 0:t.taskSummary.pending)??0)}),e.jsx(qe,{label:"Running",value:String((t==null?void 0:t.taskSummary.running)??0)}),e.jsx(qe,{label:"Completed",value:String((t==null?void 0:t.taskSummary.completed)??0)}),e.jsx(qe,{label:"Failed",value:String((t==null?void 0:t.taskSummary.failed)??0)})]}),e.jsxs("div",{className:"space-y-3 rounded-[24px] border border-border/60 bg-background/45 px-4 py-4",children:[e.jsx(Pe,{label:"Leader",value:((k=t==null?void 0:t.leader)==null?void 0:k.name)??"None"}),e.jsx(Pe,{label:"Leader URL",value:((V=t==null?void 0:t.leader)==null?void 0:V.endpoint)??"Unavailable",mono:!0,action:(Z=t==null?void 0:t.leader)!=null&&Z.endpoint?e.jsx(tt,{label:"Copy leader URL",onClick:()=>{var I;return void Ue(((I=t.leader)==null?void 0:I.endpoint)??"","Leader URL copied")}}):void 0}),e.jsx(Pe,{label:"Feed",value:f?"Receiving live updates":"Reconnecting to event stream"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:U&&e.jsxs(T,{variant:"outline",size:"sm",onClick:x,disabled:u,className:"rounded-full",children:[u&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})})]})]})]})})}),e.jsx(Be,{value:"nodes",className:"mt-0 min-h-0 flex-1",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto px-4 py-5",children:e.jsxs("div",{className:"space-y-7",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"This node"}),F?e.jsx(T,{variant:"outline",size:"sm",onClick:h,className:"rounded-full",children:"Join node"}):M?e.jsxs(T,{variant:"outline",size:"sm",onClick:P,disabled:w,className:"rounded-full",children:[w&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),S&&e.jsx(gs,{node:S,systemInfo:s,blockingTaskCount:n.get(S.id)??0,devTunnelNodeId:N,onToggleNodeDevTunnel:D,showActions:!0,defaultExpanded:!0})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm font-medium text-foreground",children:["Peer nodes (",ae.length,")"]}),ae.length>0?e.jsx("div",{className:"space-y-3",children:ae.map(I=>e.jsx(cl,{node:I,isLeader:!!O,blockingTaskCount:n.get(I.id)??0,devTunnelNodeId:N,onToggleNodeDevTunnel:D},I.id))}):e.jsx("div",{className:"rounded-[24px] border border-dashed border-border/70 bg-background/35 px-4 py-5 text-sm text-muted-foreground",children:"No peer nodes are connected yet."})]})]})})}),e.jsx(Be,{value:"events",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col px-4 py-5",children:[e.jsxs("div",{className:"mb-4 space-y-3",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[e.jsx(kr,{className:_("h-4 w-4",f?"text-emerald-500":"text-destructive")}),"Live events"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(_e,{value:i,onValueChange:o,children:[e.jsx(Ee,{className:"h-9 min-w-[11rem] flex-1 rounded-full border-border/70 bg-background/55 text-[12px] sm:max-w-[15rem]",children:e.jsx(Le,{placeholder:"Event type"})}),e.jsx(Te,{children:c.map(I=>e.jsx(ye,{value:I,className:"text-[12px]",children:I==="all"?"All event types":I},I))})]}),e.jsx(De,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:f?"Connected":"Reconnecting"})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(dl,{events:p,maxHeight:"100%",emptyTitle:i==="all"?"No live events yet":"No matching events",emptyDescription:i==="all"?"Cluster activity appears here as it happens.":`No "${i}" events are in the current stream.`,nodeNameById:r})})]})})]})})}function gs({node:t,systemInfo:s,blockingTaskCount:r,devTunnelNodeId:n,onToggleNodeDevTunnel:i,showActions:o=!0,defaultExpanded:c=!1}){const[p,f]=a.useState(c),b=(s==null?void 0:s.dashboardOrigin)??t.dashboardOrigin,d=t.devtunnelEndpoint??t.endpoint,u=b??t.endpoint,x=(s==null?void 0:s.workDir)??t.workDir,h=Ks(t,s==null?void 0:s.transportType),w=qt(t,s==null?void 0:s.transportType),P=w&&Je((s==null?void 0:s.transportType)??t.transportType)?!0:Hs(t,s==null?void 0:s.transportType),D=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:()=>f(N=>!N),className:"w-full px-4 py-3.5 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[p?e.jsx(We,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):e.jsx(et,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx(Ps,{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:u,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(Ms,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2 pl-6",children:[e.jsx("span",{className:"text-sm font-semibold tracking-tight text-foreground",children:t.name}),e.jsx(Ls,{role:t.role}),e.jsx(De,{variant:"outline",className:"rounded-full border-primary/30 bg-background/60 text-[10px] capitalize",children:t.status})]})]}),p&&e.jsxs("div",{className:"space-y-4 border-t border-primary/15 px-4 pb-4 pt-3",children:[e.jsxs("div",{className:"space-y-3 rounded-[20px] border border-primary/20 bg-background/72 px-3.5 py-3.5",children:[e.jsx(Pe,{label:"Node ID",value:t.id,mono:!0}),b&&e.jsx(Pe,{label:"Dashboard",value:b,mono:!0,action:e.jsx(tt,{label:"Copy dashboard URL",onClick:()=>void Ue(b,"Dashboard URL copied")})}),e.jsx(Pe,{label:"Node URL",value:d,mono:!0,action:e.jsx(tt,{label:"Copy node URL",onClick:()=>void Ue(d,"Node URL copied")})}),x&&e.jsx(Pe,{label:"Workspace",value:x,mono:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Lt,{label:"Transport",value:h}),s&&e.jsx(Lt,{label:"Uptime",value:Xr(s.uptime),mono:!0})]}),e.jsx(Bs,{capabilities:t.capabilities,action:o&&P?e.jsxs(T,{variant:"outline",size:"sm",onClick:()=>i(t),disabled:n===t.id||D,className:"rounded-full",title:D?"Finish assigned or running tasks before changing remote access":void 0,children:[n===t.id&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),w?"Disable Remote Access":"Enable Remote Access"]}):void 0}),o&&P&&D&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[r," active task",r===1?"":"s"," on this node."]})]})]})}function cl({node:t,isLeader:s,blockingTaskCount:r,devTunnelNodeId:n,onToggleNodeDevTunnel:i}){const[o,c]=a.useState(!1),p=t.dashboardOrigin,f=t.devtunnelEndpoint??t.endpoint,b=p??t.endpoint,d=Ks(t),u=qt(t),x=Hs(t),h=r>0;return e.jsxs("div",{className:"rounded-[24px] border border-border/60 bg-background/45",children:[e.jsxs("button",{type:"button",onClick:()=>c(w=>!w),className:"w-full px-4 py-3 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[o?e.jsx(We,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):e.jsx(et,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx(Ps,{status:t.status}),e.jsx("span",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Peer node"}),e.jsx("a",{href:b,target:"_blank",rel:"noreferrer",onClick:w=>w.stopPropagation(),className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(Ms,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2 pl-6",children:[e.jsx("span",{className:"text-sm font-semibold text-foreground",children:t.name}),e.jsx(Ls,{role:t.role}),e.jsx(De,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px] capitalize",children:t.status})]})]}),o&&e.jsxs("div",{className:"space-y-4 border-t border-border/50 px-4 pb-4 pt-3",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(Pe,{label:"Node ID",value:t.id,mono:!0}),p&&e.jsx(Pe,{label:"Dashboard",value:p,mono:!0,action:e.jsx(tt,{label:"Copy dashboard URL",onClick:()=>void Ue(p,"Dashboard URL copied")})}),e.jsx(Pe,{label:"Node URL",value:f,mono:!0,action:e.jsx(tt,{label:"Copy node URL",onClick:()=>void Ue(f,"Node URL copied")})}),t.workDir&&e.jsx(Pe,{label:"Workspace",value:t.workDir,mono:!0}),e.jsx(Lt,{label:"Transport",value:d})]}),e.jsx(Bs,{capabilities:t.capabilities,action:s&&x?e.jsxs(T,{variant:"outline",size:"sm",onClick:()=>i(t),disabled:n===t.id||h,className:"rounded-full",title:h?"Finish assigned or running tasks before changing remote access":void 0,children:[n===t.id&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),u?"Disable Remote Access":"Enable Remote Access"]}):void 0}),s&&x&&h&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[r," active task",r===1?"":"s"," on this node."]})]})]})}function tt({label:t,onClick:s}){return e.jsx(T,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-full text-muted-foreground",onClick:s,"aria-label":t,title:t,children:e.jsx(Vt,{className:"h-3.5 w-3.5"})})}function ul(t,s,r,n){var c;if(!t)return{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Select a task to continue the conversation."};const i=((c=s==null?void 0:s.self)==null?void 0:c.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.`}:i?{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..."}:mt.has(t.status)||t.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:mt.has(t.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}var Nt="Checkbox",[ml]=Cs(Nt),[xl,Ht]=ml(Nt);function hl(t){const{__scopeCheckbox:s,checked:r,children:n,defaultChecked:i,disabled:o,form:c,name:p,onCheckedChange:f,required:b,value:d="on",internal_do_not_use_render:u}=t,[x,h]=wr({prop:r,defaultProp:i??!1,onChange:f,caller:Nt}),[w,P]=a.useState(null),[D,N]=a.useState(null),C=a.useRef(!1),O=w?!!c||!!w.closest("form"):!0,U={checked:x,disabled:o,setChecked:h,control:w,setControl:P,name:p,form:c,value:d,hasConsumerStoppedPropagationRef:C,required:b,defaultChecked:$e(i)?!1:i,isFormControl:O,bubbleInput:D,setBubbleInput:N};return e.jsx(xl,{scope:s,...U,children:pl(u)?u(U):n})}var ja="CheckboxTrigger",Na=a.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:r,...n},i)=>{const{control:o,value:c,disabled:p,checked:f,required:b,setControl:d,setChecked:u,hasConsumerStoppedPropagationRef:x,isFormControl:h,bubbleInput:w}=Ht(ja,t),P=jt(i,d),D=a.useRef(f);return a.useEffect(()=>{const N=o==null?void 0:o.form;if(N){const C=()=>u(D.current);return N.addEventListener("reset",C),()=>N.removeEventListener("reset",C)}},[o,u]),e.jsx(Ut.button,{type:"button",role:"checkbox","aria-checked":$e(f)?"mixed":f,"aria-required":b,"data-state":Sa(f),"data-disabled":p?"":void 0,disabled:p,value:c,...n,ref:P,onKeyDown:Pt(s,N=>{N.key==="Enter"&&N.preventDefault()}),onClick:Pt(r,N=>{u(C=>$e(C)?!0:!C),w&&h&&(x.current=N.isPropagationStopped(),x.current||N.stopPropagation())})})});Na.displayName=ja;var Kt=a.forwardRef((t,s)=>{const{__scopeCheckbox:r,name:n,checked:i,defaultChecked:o,required:c,disabled:p,value:f,onCheckedChange:b,form:d,...u}=t;return e.jsx(hl,{__scopeCheckbox:r,checked:i,defaultChecked:o,disabled:p,required:c,onCheckedChange:b,name:n,form:d,value:f,internal_do_not_use_render:({isFormControl:x})=>e.jsxs(e.Fragment,{children:[e.jsx(Na,{...u,ref:s,__scopeCheckbox:r}),x&&e.jsx(Ca,{__scopeCheckbox:r})]})})});Kt.displayName=Nt;var ka="CheckboxIndicator",ya=a.forwardRef((t,s)=>{const{__scopeCheckbox:r,forceMount:n,...i}=t,o=Ht(ka,r);return e.jsx(yr,{present:n||$e(o.checked)||o.checked===!0,children:e.jsx(Ut.span,{"data-state":Sa(o.checked),"data-disabled":o.disabled?"":void 0,...i,ref:s,style:{pointerEvents:"none",...t.style}})})});ya.displayName=ka;var wa="CheckboxBubbleInput",Ca=a.forwardRef(({__scopeCheckbox:t,...s},r)=>{const{control:n,hasConsumerStoppedPropagationRef:i,checked:o,defaultChecked:c,required:p,disabled:f,name:b,value:d,form:u,bubbleInput:x,setBubbleInput:h}=Ht(wa,t),w=jt(r,h),P=Cr(o),D=Sr(n);a.useEffect(()=>{const C=x;if(!C)return;const O=window.HTMLInputElement.prototype,S=Object.getOwnPropertyDescriptor(O,"checked").set,H=!i.current;if(P!==o&&S){const ae=new Event("click",{bubbles:H});C.indeterminate=$e(o),S.call(C,$e(o)?!1:o),C.dispatchEvent(ae)}},[x,P,o,i]);const N=a.useRef($e(o)?!1:o);return e.jsx(Ut.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??N.current,required:p,disabled:f,name:b,value:d,form:u,...s,tabIndex:-1,ref:w,style:{...s.style,...D,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Ca.displayName=wa;function pl(t){return typeof t=="function"}function $e(t){return t==="indeterminate"}function Sa(t){return $e(t)?"indeterminate":t?"checked":"unchecked"}const Bt=a.forwardRef(({className:t,...s},r)=>e.jsx(Kt,{ref:r,className:_("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...s,children:e.jsx(ya,{className:_("flex items-center justify-center text-current"),children:e.jsx(Ke,{className:"h-3.5 w-3.5"})})}));Bt.displayName=Kt.displayName;function bs({toolbarTasks:t,activeTaskId:s,tasksLoading:r,tasksError:n,isLeader:i,scope:o,agentFilter:c,nodeFilter:p,agentOptions:f,nodeOptions:b,nodeNameById:d,searchQuery:u,selectedTaskIds:x,allVisibleTasksSelected:h,someVisibleTasksSelected:w,canBatchArchive:P,onSearchChange:D,onScopeChange:N,onAgentFilterChange:C,onNodeFilterChange:O,onToggleTaskSelected:U,onToggleAllVisibleTasks:S,onBatchArchive:H,onBatchDelete:ae,onCreateTask:F,onSelectTask:M,onClose:R}){const[re,k]=a.useState(!!u),[V,Z]=a.useState(!1),I=a.useRef(null),he=a.useRef(null),J=x.size,K=o!=="active"||p!=="all"||c!=="all",X=u.trim().length>0,[pe,q]=a.useState(new Set),[ne,ee]=a.useState(new Set),me=a.useMemo(()=>Qr(t,d),[t,d]),te=me.length===1,m=!te||K||X,Y=te&&(K||X),$=a.useCallback(v=>{q(le=>{const y=new Set(le);return y.has(v)?y.delete(v):y.add(v),y})},[]),oe=a.useCallback(v=>{ee(le=>{const y=new Set(le);return y.has(v)?y.delete(v):y.add(v),y})},[]);return a.useEffect(()=>{u&&k(!0)},[u]),a.useEffect(()=>{var v;re&&((v=I.current)==null||v.focus())},[re]),a.useEffect(()=>{if(!re)return;const v=y=>{var E;const L=y.target;L instanceof Node&&((E=he.current)!=null&&E.contains(L)||k(!1))},le=y=>{y.key==="Escape"&&k(!1)};return document.addEventListener("mousedown",v),document.addEventListener("keydown",le),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",le)}},[re]),e.jsxs("aside",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-[32px] border border-border/60 bg-background/80 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-lg font-semibold tracking-tight text-foreground",children:"Tasks"}),e.jsx(T,{variant:"ghost",size:"icon",onClick:R,className:"rounded-full",children:e.jsx(Us,{className:"h-4 w-4"})})]}),e.jsxs("div",{ref:he,className:"mt-4 flex items-center gap-2",children:[e.jsxs(T,{onClick:F,className:_("justify-start rounded-[22px] px-4 py-6 text-left shadow-[0_24px_60px_-32px_hsl(var(--primary)/0.95)] transition-[flex] duration-200",re?"flex-[2]":"flex-1"),children:[e.jsx(zs,{className:"h-4 w-4"}),"New chat"]}),re?e.jsxs("div",{className:"flex min-w-0 flex-[3] items-center gap-2",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(os,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Fe,{ref:I,value:u,onChange:v=>D(v.target.value),placeholder:"Search tasks",className:"h-11 rounded-full border-border/70 bg-background/60 pl-11 text-sm"})]}),e.jsx(T,{variant:"outline",size:"icon",onClick:()=>k(!1),className:"rounded-full border-border/70 bg-background/60",children:e.jsx(_r,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(T,{variant:"outline",onClick:()=>k(!0),className:_("rounded-full border-border/70 bg-background/60 px-4 text-sm",u&&"border-primary/40 bg-primary/8 text-primary"),children:[e.jsx(os,{className:"h-4 w-4"}),"Search"]}),e.jsx(T,{variant:V||K?"secondary":"outline",size:"icon",onClick:()=>Z(v=>!v),className:_("shrink-0 rounded-full border-border/70 bg-background/60",K&&"border-primary/40 bg-primary/8 text-primary"),title:"Filters",children:e.jsx(Sn,{className:"h-4 w-4"})})]})]}),(V||K)&&e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3",children:[e.jsxs(_e,{value:o,onValueChange:v=>N(v),children:[e.jsx(Ee,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:e.jsx(Le,{})}),e.jsx(Te,{children:Zr.map(v=>e.jsx(ye,{value:v.value,className:"text-[12px]",children:v.label},v.value))})]}),e.jsxs(_e,{value:p,onValueChange:O,children:[e.jsx(Ee,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:e.jsx(Le,{placeholder:"Node"})}),e.jsx(Te,{children:b.map(v=>e.jsx(ye,{value:v.value,className:"text-[12px]",children:v.label},v.value))})]}),e.jsxs(_e,{value:c,onValueChange:C,children:[e.jsx(Ee,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:e.jsx(Le,{placeholder:"Agent"})}),e.jsx(Te,{children:f.map(v=>e.jsx(ye,{value:v,className:"text-[12px]",children:v==="all"?"All agents":v},v))})]})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 py-3",children:me.length>0?e.jsxs("div",{className:"space-y-1",children:[i&&e.jsxs("div",{className:"mb-1 flex items-center justify-between px-1 py-1",children:[e.jsxs("label",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:[e.jsx(Bt,{checked:w&&!h?"indeterminate":h,onCheckedChange:v=>S(v===!0),"aria-label":"Select all visible tasks"}),e.jsx("span",{children:"Select all"})]}),J>0&&e.jsx(T,{variant:"ghost",size:"sm",onClick:()=>S(!1),className:"h-7 rounded-full px-3 text-xs",children:"Clear"})]}),me.map(v=>{const le=v.nodeId??"__unassigned__",y=m&&!Y&&pe.has(le);return e.jsxs("div",{className:"space-y-1",children:[m&&e.jsxs("button",{type:"button",onClick:()=>$(le),"aria-expanded":!y,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:[y?e.jsx(et,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(We,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:v.nodeName}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-muted-foreground/60",children:v.dirs.reduce((L,E)=>L+E.tasks.length,0)})]}),!y&&v.dirs.map(L=>{const E=`${le}::${L.path}`,ke=ne.has(E),fe=en(L.path);return e.jsxs("div",{className:_("space-y-1",m&&"pl-3"),children:[e.jsxs("button",{type:"button",onClick:()=>oe(E),"aria-expanded":!ke,title:L.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:[ke?e.jsx(et,{className:"h-3 w-3 shrink-0"}):e.jsx(We,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate font-mono",children:fe}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-muted-foreground/50",children:L.tasks.length})]}),!ke&&e.jsx("div",{className:_("space-y-2",m?"pl-2":"pl-0"),children:L.tasks.map(Q=>e.jsxs("div",{className:_("flex items-start gap-3 rounded-[24px] border px-3 py-3 transition-all",Q.id===s?"border-primary/45 bg-primary/9 shadow-[0_24px_80px_-54px_hsl(var(--primary)/0.95)]":"border-border/60 bg-background/40 hover:border-border hover:bg-background/60"),children:[i&&e.jsx("div",{className:"flex shrink-0 pt-1",onClick:je=>je.stopPropagation(),children:e.jsx(Bt,{checked:x.has(Q.id),onCheckedChange:je=>U(Q.id,je===!0),"aria-label":`Select ${Q.title}`})}),e.jsx("button",{type:"button",onClick:()=>M(Q.id),className:"min-w-0 flex-1 text-left",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:_("mt-1 h-2.5 w-2.5 shrink-0 rounded-full",tn(Q.status))}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:Q.title}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"font-mono",children:Q.agent}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),e.jsx("span",{children:sn(Q.updatedAt)})]}),e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx(Ds,{status:Q.status}),Q.activeShare&&e.jsx(De,{variant:"outline",className:"border-primary/25 bg-primary/10 text-[10px] text-primary",children:"shared"}),Q.assignedNodeAvailable===!1&&e.jsx(De,{variant:"outline",className:"border-destructive/25 bg-destructive/10 text-[10px] text-destructive",children:"unavailable"})]})]})]})})]},Q.id))})]},E)})]},le)})]}):e.jsx("div",{className:"rounded-[24px] border border-dashed border-border/70 bg-background/35 px-4 py-5 text-sm text-muted-foreground",children:r?"Loading tasks...":n||"No tasks match this view."})}),i&&J>0?e.jsxs("div",{className:"shrink-0 border-t border-border/60 px-4 py-4",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Batch actions"}),e.jsxs("div",{className:"mt-2 text-sm font-semibold text-foreground",children:[J," task",J!==1?"s":""," selected"]}),!P&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Only completed, failed, cancelled, or archived tasks can be archived."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(Ft,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(T,{variant:"outline",size:"sm",disabled:!P,className:"rounded-full",children:[e.jsx(jn,{className:"h-3.5 w-3.5"}),"Archive"]})}),e.jsxs(xt,{children:[e.jsxs(ht,{children:[e.jsxs(ft,{children:["Archive ",J," task",J!==1?"s":"","?"]}),e.jsx(gt,{children:"Archived tasks stay hidden from the default task view and can be reopened from the archived scope."})]}),e.jsxs(pt,{children:[e.jsx(vt,{children:"Cancel"}),e.jsx(bt,{onClick:H,disabled:!P,children:"Archive"})]})]})]}),e.jsxs(Ft,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(T,{variant:"destructive",size:"sm",className:"rounded-full",children:[e.jsx(Zn,{className:"h-3.5 w-3.5"}),"Delete"]})}),e.jsxs(xt,{children:[e.jsxs(ht,{children:[e.jsxs(ft,{children:["Delete ",J," task",J!==1?"s":"","?"]}),e.jsx(gt,{children:"This removes the selected tasks and their saved logs."})]}),e.jsxs(pt,{children:[e.jsx(vt,{children:"Cancel"}),e.jsx(bt,{onClick:ae,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}):null]})}async function fl(t,s){var r,n;try{const i=await Er(t,s);if((n=(r=globalThis.navigator)==null?void 0:r.clipboard)!=null&&n.writeText)try{await globalThis.navigator.clipboard.writeText(i.url),ce.success("Shared link copied")}catch{ce.success("Shared link created")}else ce.success("Shared link created");return i}catch(i){ce.error(i instanceof Error?i.message:"Failed to create shared link");return}}async function gl(t){try{return await Tr(t),ce.success("Shared link stopped"),!0}catch(s){return ce.error(s instanceof Error?s.message:"Failed to stop shared link"),!1}}function bl(t,s,r){const n=a.useCallback(()=>{s(),r()},[s,r]),i=a.useCallback(async c=>{if(!t)return;const p=await fl(t.id,c);return p&&n(),p},[t,n]),o=a.useCallback(async()=>{if(!t)return!1;const c=await gl(t.id);return c&&n(),c},[t,n]);return{handleShareTask:i,handleStopShareTask:o}}function vs(t,s,r){const n=a.useRef(s);n.current=s,a.useEffect(()=>{let c=0,p=0;const f=u=>{const x=u.touches[0];x&&(c=x.clientX,p=x.clientY)},b=u=>{var P,D,N,C;const x=u.changedTouches[0];if(!x)return;const h=x.clientX-c;Math.abs(x.clientY-p)>100||Math.abs(h)<50||(h>0?(D=(P=n.current).onSwipeRight)==null||D.call(P):(C=(N=n.current).onSwipeLeft)==null||C.call(N))},d=(t==null?void 0:t.current)??document;return d.addEventListener("touchstart",f,{passive:!0}),d.addEventListener("touchend",b,{passive:!0}),()=>{d.removeEventListener("touchstart",f),d.removeEventListener("touchend",b)}},[t,r==null?void 0:r.threshold,r==null?void 0:r.maxVertical])}const vl="(min-width: 1024px)",jl="(min-width: 1280px)";function js(t){var s,r,n;return((n=(r=(s=globalThis.window)==null?void 0:s.matchMedia)==null?void 0:r.call(s,t))==null?void 0:n.matches)??!1}function Nl(){const[t,s]=a.useState(!0),[r,n]=a.useState(!1),[i,o]=a.useState(()=>js(jl)),c=a.useRef(null),p=a.useRef(null);vs(c,{onSwipeLeft:()=>n(!1)}),vs(p,{onSwipeRight:()=>o(!1)});const f=a.useCallback(()=>{if(js(vl)){s(b=>!b);return}n(b=>!b)},[]);return{desktopTasksOpen:t,mobileTasksPanelOpen:r,mobileTasksPanelRef:c,operationsOpen:i,operationsPanelRef:p,setMobileTasksPanelOpen:n,setOperationsOpen:o,toggleTasksPanel:f}}function kl(t,s){return s.data.nodeId===t.self.id||s.data.name===t.self.name||s.data.endpoint===t.self.endpoint}function yl({cluster:t,subscribe:s}){a.useEffect(()=>{var r;if(((r=t==null?void 0:t.self)==null?void 0:r.role)==="leader")return s("node",n=>{const i=String(n.data.name??n.data.nodeId??"node"),o=kl(t,n);n.type==="node.joined"&&!o&&ce.success(`${i} joined the cluster`),n.type==="node.left"&&!o&&ce.message(`${i} left the cluster`)})},[t,s])}function wl(){var Xt,Qt,Zt;const{id:t}=Dr(),s=Ar(),r=Pr(),{cluster:n,systemInfo:i,events:o,sseConnected:c,subscribe:p,refresh:f,loading:b,error:d}=Mr(),u=a.useMemo(()=>an(s.state),[s.state]),[x,h]=a.useState([]),[w,P]=a.useState(!0),[D,N]=a.useState(null),[C,O]=a.useState(null),[U,S]=a.useState("active"),[H,ae]=a.useState("all"),[F,M]=a.useState("all"),[R,re]=a.useState(""),k=a.useDeferredValue(R),{desktopTasksOpen:V,mobileTasksPanelOpen:Z,mobileTasksPanelRef:I,operationsOpen:he,operationsPanelRef:J,setMobileTasksPanelOpen:K,setOperationsOpen:X,toggleTasksPanel:pe}=Nl(),[q,ne]=a.useState(()=>!!(u!=null&&u.draftNewTask)),[ee,me]=a.useState(()=>u!=null&&u.draftNewTask?{route:u.returnRoute??"/",taskId:u.returnTaskId??null}:null),[te,m]=a.useState(!1),[Y,$]=a.useState("transcript"),[oe,v]=a.useState("all"),[le,y]=a.useState(!1),[L,E]=a.useState(null),[ke,fe]=a.useState([]),[Q,je]=a.useState([]),[Ye,A]=a.useState(!1),[xe,Ne]=a.useState(null),[Ce,Se]=a.useState(new Set),[ve,at]=a.useState(!1),[rt,Xe]=a.useState(!1),[nt,Qe]=a.useState(null),Ze=a.useRef(null),Oe=a.useRef(null),ge=((Xt=n==null?void 0:n.self)==null?void 0:Xt.role)==="leader",de=(Qt=n==null?void 0:n.self)==null?void 0:Qt.id;yl({cluster:n,subscribe:p});const W=a.useCallback(async()=>{try{const l=await Lr({assignedTo:!ge&&de?de:void 0,limit:100});h(l),N(null)}catch(l){N(l instanceof Error?l.message:"Failed to load tasks")}finally{P(!1)}},[ge,de]);Rr(W,1e4),a.useEffect(()=>{W()},[W]),a.useEffect(()=>p("task",W),[p,W]);const se=a.useMemo(()=>[...x].sort((l,g)=>g.updatedAt-l.updatedAt),[x]),_a=a.useMemo(()=>{const l=new Map;for(const g of(n==null?void 0:n.nodes)??[]){const j=to(se,g.id);j>0&&l.set(g.id,j)}return l},[n==null?void 0:n.nodes,se]),Ae=a.useMemo(()=>se.filter(l=>!rn(l,U)||H!=="all"&&l.agent!==H||F==="unassigned"&&l.assignedTo||F!=="all"&&F!=="unassigned"&&nn(l.assignedTo,n==null?void 0:n.nodes,l.assignedNodeName)!==F?!1:k.trim()?on(l,k):!0),[se,U,H,F,k]);a.useEffect(()=>{Se(l=>{const g=lo(l,Ae.map(j=>j.id));return g.size===l.size?l:g})},[Ae]),a.useEffect(()=>{ge||Se(new Set)},[ge]);const Ea=a.useMemo(()=>["all",...Array.from(new Set(se.map(l=>l.agent))).sort()],[se]),Ta=a.useMemo(()=>{const g=Array.from(new Set(se.map(j=>j.assignedTo).filter(j=>!!j))).map(j=>{const ie=se.find(z=>z.assignedTo===j);return(n==null?void 0:n.nodes.find(z=>z.id===j))??{id:j,name:Is(j,n==null?void 0:n.nodes,ie==null?void 0:ie.assignedNodeName)}}).sort((j,ie)=>j.name.localeCompare(ie.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...g.map(j=>({value:j.name.toLowerCase(),label:j.name}))]},[se,n==null?void 0:n.nodes]),Wt=a.useMemo(()=>{const l=new Map;for(const g of(n==null?void 0:n.nodes)??[])l.set(g.id,g.name);for(const g of se)g.assignedTo&&g.assignedNodeName&&!l.has(g.assignedTo)&&l.set(g.assignedTo,g.assignedNodeName);return l},[n==null?void 0:n.nodes,se]),kt=a.useMemo(()=>["all",...Array.from(new Set(o.map(l=>l.type))).sort()],[o]),Da=a.useMemo(()=>oe==="all"?o:o.filter(l=>l.type===oe),[o,oe]),Aa=Ae.length>0&&Ae.every(l=>Ce.has(l.id)),Pa=Ae.some(l=>Ce.has(l.id)),Ma=io(Ae,Ce);a.useEffect(()=>{u!=null&&u.draftNewTask&&(ne(!0),me({route:u.returnRoute??"/",taskId:u.returnTaskId??null}))},[u]),a.useEffect(()=>{oe!=="all"&&!kt.includes(oe)&&v("all")},[oe,kt]),a.useEffect(()=>{ls(t,q)&&!C&&se[0]&&O(se[0].id)},[t,q,C,se]),a.useEffect(()=>{var l;ls(t,q)&&(C&&x.some(g=>g.id===C)||O(((l=se[0])==null?void 0:l.id)??null))},[t,q,C,se,x]);const G=ao({routeTaskId:t,creatingTask:q,internalSelectedTaskId:C,sortedTaskIds:se.map(l=>l.id)}),Ve=a.useMemo(()=>x.find(l=>l.id===G)??null,[x,G]);a.useEffect(()=>{Oe.current=G??null},[G]);const ot=a.useCallback(()=>{E(null),fe([]),je([]),Ne(null)},[]),we=a.useCallback(async()=>{const l=G;if(l)try{const g=await $r(l);if(Oe.current!==l)return;E(g),Ne(null)}catch(g){if(Oe.current!==l)return;E(null),fe([]),je([]),Ne(g instanceof Error?g.message:"Failed to load task")}finally{Oe.current===l&&A(!1)}},[G]),lt=a.useCallback(async()=>{const l=G;if(l)try{const g=await Fr(l);if(Oe.current!==l)return;fe(j=>ln(j,g.logs)),je(j=>dn(j,g.logs))}catch{}},[G]);a.useEffect(()=>{if(!G){E(null),fe([]),je([]),Ne(null),A(!1);return}$("transcript"),E(Ve),fe([]),je([]),Ne(null),A(!0),we(),lt()},[G,lt,we]),a.useEffect(()=>{var g;if(!G||q||w||x.some(j=>j.id===G))return;const l=((g=se[0])==null?void 0:g.id)??null;O(l),ot(),a.startTransition(()=>{r(l?`/tasks/${l}`:"/",{state:null})})},[G,ot,q,r,se,x,w]),a.useEffect(()=>{Ve&&E(l=>!l||l.id!==Ve.id?l:{...l,...Ve})},[Ve]),a.useEffect(()=>p("task.updated",l=>{h(g=>no(g,l.data))}),[p]),a.useEffect(()=>{if(G)return p("task",l=>{const g=l.data.taskId;if(!(typeof g!="string"||g!==G)){if(l.type==="task.output"){const j=l.data.event;if(j){fe(z=>cn(z,j));const ie=rs(j);ie&&je(z=>un(z,ie))}}l.type==="task.updated"&&we(),l.type==="task.status"&&(we(),lt())}})},[p,G,we,lt]),a.useEffect(()=>{var l;Y==="transcript"&&((l=Ze.current)==null||l.scrollIntoView({behavior:"smooth"}))},[ke,Q,Y]);const B=L??Ve,La=B!=null&&B.assignedTo?(n==null?void 0:n.nodes.find(l=>l.id===B.assignedTo))??null:null,yt=Q.length>0,Ra=B?mn.has(B.agent):!1,wt=(B==null?void 0:B.status)==="running",$a=B?mt.has(B.status):!1,Fa=B?mt.has(B.status)||xn.has(B.status):!1,Oa=!!(B&&ge&&B.status==="failed"),Ct=a.useMemo(()=>ul(B,n,yt,!!wt),[B,n,yt,wt]),St=a.useMemo(()=>hn([...ke,...Q.map(l=>Dt(l.content,l.timestamp))]),[ke,Q]),it=a.useMemo(()=>{if(!B)return null;const l=pn(B);if(l.length>0)return Dt(l,new Date(B.createdAt).toISOString());if(St.length>0)return null;const g=fn(B.description||B.title);return g.length>0?Dt(g,new Date(B.createdAt).toISOString()):null},[B,St]),_t=a.useMemo(()=>it?rs(it):null,[it]),Ia=a.useMemo(()=>_t?gn(ke,_t):!1,[ke,_t]),Et=a.useCallback(()=>{const l={route:t?`/tasks/${t}`:"/",taskId:G};me(l),ne(!0),a.startTransition(()=>{r("/",{state:{draftNewTask:!0,returnRoute:l.route,returnTaskId:l.taskId}})})},[t,G,r]),Ba=a.useCallback(()=>{var g;const l=(ee==null?void 0:ee.taskId)??((g=se[0])==null?void 0:g.id)??null;ne(!1),me(null),O(l),a.startTransition(()=>{r((ee==null?void 0:ee.route)??"/",{state:null})})},[ee,se,r]),Gt=a.useCallback(l=>{ne(!1),me(null),O(l),a.startTransition(()=>{r(`/tasks/${l}`,{state:null})})},[r]),za=a.useCallback(l=>{ne(!1),me(null),h(g=>ro(g,l)),E(l),fe([]),je([]),Ne(null),A(!1),$("transcript"),O(l.id),W(),a.startTransition(()=>{r(`/tasks/${l.id}`,{state:null})})},[W,r]),dt=a.useCallback(async l=>{if(!G)return!1;const g=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`;je(j=>[...j,{id:g,content:l,timestamp:new Date().toISOString()}]);try{return await Or(G,l),we(),!0}catch(j){return je(ie=>ie.filter(z=>z.id!==g)),ce.error(j instanceof Error?j.message:"Failed to send message"),!1}},[G,we]),Ua=a.useCallback(l=>{dt(l)},[dt]),Va=a.useCallback(l=>dt(l),[dt]),qa=a.useCallback(async()=>{if(B)try{await Ir(B.id),we(),W()}catch(l){ce.error(l instanceof Error?l.message:"Failed to cancel task")}},[B,we,W]),{handleShareTask:Ha,handleStopShareTask:Ka}=bl(B,we,W),Wa=a.useCallback(async()=>{if(B)try{await Br(B.id),we(),W()}catch(l){ce.error(l instanceof Error?l.message:"Failed to retry task")}},[B,we,W]),ct=a.useCallback((l,g=!1)=>{const j=co(Ae,l);return O(j),(g||!j)&&ot(),a.startTransition(()=>{r(j?`/tasks/${j}`:"/",{state:null})}),j},[ot,Ae,r]),Ga=a.useCallback((l,g)=>{Se(j=>{const ie=new Set(j);return g?ie.add(l):ie.delete(l),ie})},[]),Ja=a.useCallback(l=>{if(!l){Se(new Set);return}Se(new Set(Ae.map(g=>g.id)))},[Ae]),Ya=a.useCallback(async()=>{const l=Array.from(Ce);if(l.length!==0)try{const{results:g}=await zr(l),j=g.filter(z=>!z.ok),ie=g.filter(z=>z.ok).map(z=>z.id);G&&ie.includes(G)&&ct(ie),j.length>0?ce.error(`Failed to archive ${j.length} task(s): ${j.map(z=>z.error??z.id).join(", ")}`):ce.success(`Archived ${ie.length} task(s)`),Se(new Set(j.map(z=>z.id))),W()}catch(g){ce.error(g instanceof Error?g.message:"Failed to archive tasks")}},[G,W,ct,Ce]),Xa=a.useCallback(async()=>{const l=Array.from(Ce);if(l.length!==0)try{const{results:g}=await Ur(l),j=g.filter(z=>!z.ok),ie=g.filter(z=>z.ok).map(z=>z.id);G&&ie.includes(G)&&ct(ie,!0),j.length>0?ce.error(`Failed to delete ${j.length} task(s): ${j.map(z=>z.error??z.id).join(", ")}`):ce.success(`Deleted ${ie.length} task(s)`),Se(new Set(j.map(z=>z.id))),W()}catch(g){ce.error(g instanceof Error?g.message:"Failed to delete tasks")}},[G,W,ct,Ce]),Qa=a.useCallback(async()=>{at(!0);try{await Vr(),f()}catch(l){ce.error(l instanceof Error?l.message:"Failed to promote node")}finally{at(!1)}},[f]),Za=a.useCallback(async()=>{Xe(!0);try{await qr(),ce.success("This node left the remote cluster and is leading itself again."),W(),we(),f()}catch(l){ce.error(l instanceof Error?l.message:"Failed to leave cluster")}finally{Xe(!1)}},[we,W,f]),er=a.useCallback(async l=>{var es;const g=!qt(l),j=l.id===((es=n==null?void 0:n.self)==null?void 0:es.id),ie=j?(i==null?void 0:i.transportType)??l.transportType:l.transportType,z=j&&!g&&Je(ie);Qe(l.id);try{z?await Hr("direct"):await Kr(l.id,g),ce.success(g?`Enabled remote access on ${l.name}`:`Disabled remote access on ${l.name}`),f()}catch(ts){ce.error(ts instanceof Error?ts.message:"Failed to update remote access")}finally{Qe(null)}},[(Zt=n==null?void 0:n.self)==null?void 0:Zt.id,f,i==null?void 0:i.transportType]),Jt={toolbarTasks:Ae,activeTaskId:G,tasksLoading:w,tasksError:D,isLeader:ge,scope:U,agentFilter:H,nodeFilter:F,agentOptions:Ea,nodeOptions:Ta,nodeNameById:Wt,searchQuery:R,selectedTaskIds:Ce,allVisibleTasksSelected:Aa,someVisibleTasksSelected:Pa,canBatchArchive:Ma,onSearchChange:re,onScopeChange:S,onAgentFilterChange:ae,onNodeFilterChange:M,onToggleTaskSelected:Ga,onToggleAllVisibleTasks:Ja,onBatchArchive:Ya,onBatchDelete:Xa,onCreateTask:Et,onSelectTask:Gt,onClose:pe},Yt={cluster:n,systemInfo:i,nodeNameById:Wt,nodeBlockingTaskCounts:_a,eventTypeFilter:oe,onEventTypeFilterChange:v,eventTypeOptions:kt,filteredEvents:Da,sseConnected:c,clusterLoading:b,clusterError:d,promotePending:ve,onPromote:Qa,onAddNode:()=>m(!0),leavePending:rt,onLeaveCluster:Za,onToggleNodeDevTunnel:er,devTunnelNodeId:nt,onClose:()=>X(!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:_("hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",V?"lg:mr-3 lg:w-[24rem]":"lg:w-0 lg:overflow-hidden"),children:V&&e.jsx(bs,{...Jt})}),e.jsx("section",{className:"min-h-0 min-w-0 flex-1",children:e.jsx(tl,{onToggleTasks:pe,desktopTasksOpen:V,mobileTasksPanelOpen:Z,operationsOpen:he,onToggleOperations:()=>X(l=>!l),cluster:n,sseConnected:c,activeTab:Y,setActiveTab:$,creatingTask:q,activeTask:B,assignedNode:La,taskLoading:Ye,taskError:xe,displayEvents:St,initialPromptAlreadyInLogs:Ia,initialPrompt:it,supportsFollowUp:Ra,taskUnavailable:Ct.taskUnavailable,chatDisabled:Ct.chatDisabled,chatDisabledReason:Ct.chatDisabledReason,questionBypassEnabled:le,isRunning:!!wt,isStarting:$a,hasPendingFollowUp:yt,canCancel:!!Fa,canRetry:!!Oa,onRetry:Wa,onCancel:qa,onShareTask:Ha,onStopShareTask:Ka,onStartCreateTask:Et,onCancelCreateTask:Ba,onCreateTask:za,onSendMessage:Ua,onQuestionBypassChange:y,onSubmitQuestionResponse:Va,messagesEndRef:Ze})}),e.jsx("div",{className:_("hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",he?"xl:ml-3 xl:w-[26rem]":"xl:w-0 xl:overflow-hidden"),children:he&&e.jsx(fs,{...Yt})})]}),he&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:()=>X(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),e.jsx("div",{ref:J,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(fs,{...Yt})})]}),Z&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close task list",onClick:()=>K(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),e.jsx("div",{ref:I,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(bs,{...Jt,onCreateTask:()=>{K(!1),Et()},onSelectTask:l=>{K(!1),Gt(l)},onClose:()=>K(!1)})})]}),e.jsx(Es,{open:te,onOpenChange:m,children:e.jsx(po,{onAdded:()=>{m(!1),f()}})})]})}const El=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:wl},Symbol.toStringTag,{value:"Module"}));export{El as D,ns as G};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as g,r as h,j as s,i as U,w as T,a as E,X as te,H as re,Q as ne,K as se,z,B as oe}from"./index-
|
|
1
|
+
import{c as g,r as h,j as s,i as U,w as T,a as E,X as te,H as re,Q as ne,K as se,z,B as oe}from"./index-COwXI8L0.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as c,aD as L,ay as M,j as e,B as g,a as w,K as P}from"./index-
|
|
1
|
+
import{r as c,aD as L,ay as M,j as e,B as g,a as w,K as P}from"./index-COwXI8L0.js";import{G as O}from"./DashboardPage-ChA_y3oq.js";import{F as R}from"./file-BUN3RpOS.js";import{C as _,F as B}from"./folder-C28inzgP.js";import"./DashboardShared-B4AJ8Ukj.js";function C(r,t){if(!(r!=null&&r.trim()))return[];const s=r.split(`
|
|
2
2
|
`),n=[];let a=[];const d=()=>{if(a.length===0)return;const l=a.join(`
|
|
3
3
|
`).trim();if(!l){a=[];return}const i=J(a);if(!i){a=[];return}n.push({id:`${t}:${i}`,path:i,section:t,patch:l}),a=[]};for(const l of s)l.startsWith("diff --git ")&&a.length>0&&d(),a.push(l);return d(),n}function I(r){const t=[];for(const s of[...r].sort((n,a)=>n.path.localeCompare(a.path))){const n=s.path.split("/").filter(Boolean);let a=t,d="";n.forEach((l,i)=>{d=d?`${d}/${l}`:l;const p=i===n.length-1;let m=a.find(b=>b.name===l);m||(m=p?{type:"file",name:l,path:d,item:s}:{type:"folder",name:l,path:d,children:[]},a.push(m)),p||(m.children??(m.children=[]),a=m.children)})}return t}function G(r){const t=[];let s="";for(const n of r.split("/").filter(Boolean).slice(0,-1))s=s?`${s}/${n}`:n,t.push(s);return t}function A(r){return r.map(t=>({id:`untracked:${t}`,path:t,section:"untracked"}))}function J(r){var d,l;const t=(d=r.find(i=>i.startsWith("+++ ")))==null?void 0:d.slice(4).trim();if(t&&t!=="/dev/null")return k(t);const s=(l=r.find(i=>i.startsWith("--- ")))==null?void 0:l.slice(4).trim();if(s&&s!=="/dev/null")return k(s);const n=r.find(i=>i.startsWith("diff --git "));if(!n)return null;const a=n.match(/^diff --git a\/(.+?) b\/(.+)$/);return a?k(a[2]||a[1]||""):null}function k(r){return r.replace(/^[ab]\//,"")}const y={staged:"Staged",unstaged:"Unstaged",untracked:"Untracked"};function re({taskId:r}){const[t,s]=c.useState(null),[n,a]=c.useState(!0),[d,l]=c.useState(null),[i,p]=c.useState(null),[m,b]=c.useState(null),[T,v]=c.useState(!1),[U,N]=c.useState(null),S=c.useCallback(async()=>{a(!0),l(null),s(null);try{const o=await L(r);s(o)}catch(o){l(o instanceof Error?o.message:"Failed to load diff")}finally{a(!1)}},[r]);c.useEffect(()=>{S()},[S]);const F=c.useMemo(()=>C(t==null?void 0:t.staged,"staged"),[t==null?void 0:t.staged]),D=c.useMemo(()=>C(t==null?void 0:t.unstaged,"unstaged"),[t==null?void 0:t.unstaged]),E=c.useMemo(()=>A((t==null?void 0:t.untrackedFiles)??[]),[t==null?void 0:t.untrackedFiles]),j=c.useMemo(()=>[{section:"staged",items:F},{section:"unstaged",items:D},{section:"untracked",items:E}],[F,D,E]),h=c.useMemo(()=>j.flatMap(o=>o.items),[j]),u=c.useMemo(()=>h.find(o=>o.id===i)??h[0]??null,[h,i]);return c.useEffect(()=>{var o;(!i||!h.some(x=>x.id===i))&&p(((o=h[0])==null?void 0:o.id)??null)},[h,i]),c.useEffect(()=>{if(b(null),N(null),v(!1),!u||u.section!=="untracked")return;if(u.path.endsWith("/")){N("This untracked path is a directory. Open the Files tab to inspect its contents.");return}let o=!1;return v(!0),M(r,u.path).then(x=>{o||b(x)}).catch(x=>{o||N(x instanceof Error?x.message:"Failed to load file content")}).finally(()=>{o||v(!1)}),()=>{o=!0}},[u,r]),n?e.jsx(f,{tone:"muted",children:"Loading diff..."}):d?e.jsx(f,{tone:"destructive",children:d}):t!=null&&t.available?h.length>0?e.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 lg:grid-cols-[19rem_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-border/60 bg-background/30 lg:border-b-0 lg:border-r",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-4 py-4",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.24em] text-muted-foreground",children:"Repository diff"}),e.jsx("div",{className:"mt-3 flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[e.jsx(O,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:t.branch??"detached HEAD"})]}),t.repoRoot&&e.jsx("div",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",children:t.repoRoot})]})}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:j.map(o=>e.jsxs(g,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:[y[o.section]," ",o.items.length]},o.section))})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:e.jsx("div",{className:"space-y-3",children:j.map(({section:o,items:x})=>e.jsx(V,{section:o,items:x,selectedId:(u==null?void 0:u.id)??null,onSelect:p},o))})})]}),e.jsx("section",{className:"min-h-0 flex flex-col bg-card/10",children:u?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-4 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(g,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:y[u.section]}),u.section==="untracked"?e.jsx(g,{variant:"secondary",className:"rounded-full",children:"File content"}):e.jsx(g,{variant:"secondary",className:"rounded-full",children:"Diff patch"})]}),e.jsx("div",{className:"mt-3 break-all font-mono text-xs text-muted-foreground",children:u.path})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-4",children:u.section==="untracked"?e.jsx(K,{loading:T,error:U,content:m}):e.jsx(H,{patch:u.patch??""})})]}):e.jsx(f,{tone:"muted",children:"Select a file to inspect."})})]}):e.jsx(f,{tone:"muted",children:"Working tree is clean."}):e.jsx(f,{tone:"muted",children:"Task working directory is not inside a Git repository."})}function V({section:r,items:t,selectedId:s,onSelect:n}){const a=c.useMemo(()=>I(t),[t]),d=c.useMemo(()=>t.find(i=>i.id===s)??null,[t,s]),l=c.useMemo(()=>new Set(d?G(d.path):[]),[d]);return e.jsxs("section",{className:"rounded-[22px] border border-border/60 bg-background/35",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/60 px-3 py-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:y[r]}),e.jsx(g,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:t.length})]}),e.jsx("div",{className:"p-2",children:a.length>0?e.jsx("div",{className:"space-y-1",children:a.map(i=>e.jsx(W,{node:i,depth:0,selectedId:s,expandedAncestorPaths:l,onSelect:n},`${r}:${i.path}`))}):e.jsx("div",{className:"rounded-[16px] border border-dashed border-border/70 bg-background/30 px-3 py-3 text-sm text-muted-foreground",children:"No files."})})]})}function W({node:r,depth:t,selectedId:s,expandedAncestorPaths:n,onSelect:a}){var d;return r.type==="folder"?e.jsx(z,{node:r,depth:t,selectedId:s,expandedAncestorPaths:n,onSelect:a}):e.jsxs("button",{type:"button",onClick:()=>{r.item&&a(r.item.id)},className:w("flex w-full cursor-pointer items-center gap-2 rounded-[16px] px-2 py-2 text-left transition-colors",((d=r.item)==null?void 0:d.id)===s?"bg-primary/8 text-foreground":"text-foreground/90 hover:bg-background/55"),style:{paddingLeft:`${t*14+8}px`},children:[e.jsx(R,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-sm",children:r.name})]})}function z({node:r,depth:t,selectedId:s,expandedAncestorPaths:n,onSelect:a}){const[d,l]=c.useState(!0);return c.useEffect(()=>{n.has(r.path)&&l(!0)},[n,r.path]),e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>l(i=>!i),"aria-expanded":d,className:"flex w-full cursor-pointer select-none items-center gap-2 rounded-[14px] px-2 py-1.5 text-left text-sm text-muted-foreground transition-colors hover:bg-background/55 hover:text-foreground",style:{paddingLeft:`${t*14+8}px`},children:[d?e.jsx(P,{className:"h-4 w-4 shrink-0"}):e.jsx(_,{className:"h-4 w-4 shrink-0"}),e.jsx(B,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:r.name})]}),d&&e.jsx("div",{className:"space-y-1",children:(r.children??[]).map(i=>e.jsx(W,{node:i,depth:t+1,selectedId:s,expandedAncestorPaths:n,onSelect:a},i.path))})]})}function H({patch:r}){const t=r.split(`
|
|
4
4
|
`);return e.jsxs("div",{className:"rounded-[28px] border border-border/60 bg-background/55",children:[e.jsxs("div",{className:"border-b border-border/60 px-4 py-4",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"File diff"}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[t.length," lines"]})]}),e.jsx("div",{className:"font-mono text-xs leading-6",children:t.map((s,n)=>e.jsxs("div",{className:w("grid grid-cols-[56px_minmax(0,1fr)] gap-4 px-4 py-0.5",q(s)),children:[e.jsx("span",{className:"select-none text-right text-muted-foreground/55",children:n+1}),e.jsx("span",{className:"whitespace-pre-wrap break-all text-foreground",children:s||" "})]},`${n}-${s}`))})]})}function K({loading:r,error:t,content:s}){if(r)return e.jsx(f,{tone:"muted",children:"Loading file content..."});if(t)return e.jsx(f,{tone:"destructive",children:t});if(!s)return e.jsx(f,{tone:"muted",children:"Select an untracked file to preview its content."});if(s.kind==="image"){const n=s.content?`data:${s.mimeType};base64,${s.content}`:s.downloadUrl;return n?e.jsx("div",{className:"flex min-h-[20rem] items-center justify-center rounded-[28px] border border-border/60 bg-background/55 p-4",children:e.jsx("img",{src:n,alt:s.path,className:"max-h-full max-w-full rounded-[20px] object-contain shadow-[0_24px_90px_-52px_rgba(0,0,0,0.65)]"})}):e.jsx(f,{tone:"muted",children:"Image preview is not available."})}if(s.kind==="pdf"&&s.downloadUrl)return e.jsx("div",{className:"h-full min-h-[24rem] overflow-hidden rounded-[28px] border border-border/60 bg-background/55",children:e.jsx("iframe",{src:s.downloadUrl,title:s.path,className:"h-full w-full border-0"})});if(s.kind==="json"){let n=s.content;try{n=JSON.stringify(JSON.parse(s.content),null,2)}catch{}return e.jsx($,{content:n,truncated:s.truncated})}return s.kind==="markdown"||s.kind==="text"||s.kind==="html"?e.jsx($,{content:s.content,truncated:s.truncated}):e.jsx(f,{tone:"muted",children:"This file cannot be previewed inline."})}function $({content:r,truncated:t}){return e.jsxs("div",{className:"rounded-[28px] border border-border/60 bg-background/55",children:[e.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap px-5 py-5 font-mono text-xs leading-6 text-foreground",children:r}),t&&e.jsx("div",{className:"border-t border-border/60 px-5 py-3 text-xs text-muted-foreground",children:"Content truncated. Open the Files tab to inspect the full artifact."})]})}function f({children:r,tone:t}){return e.jsx("div",{className:w("flex h-full min-h-[16rem] items-center justify-center rounded-[24px] text-sm",t==="muted"?"text-muted-foreground":"text-destructive"),children:r})}function q(r){return r.startsWith("@@")?"bg-sky-500/10":r.startsWith("+")&&!r.startsWith("+++")?"bg-emerald-500/10":r.startsWith("-")&&!r.startsWith("---")?"bg-destructive/10":r.startsWith("diff ")||r.startsWith("index ")||r.startsWith("---")||r.startsWith("+++")?"bg-muted/45":""}export{re as DiffTab};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Ze,ax as Dt,j as y,r as re,ay as Nr,az as Ar,aA as Pr,B as rn,i as Me,a as Te}from"./index-
|
|
1
|
+
import{c as Ze,ax as Dt,j as y,r as re,ay as Nr,az as Ar,aA as Pr,B as rn,i as Me,a as Te}from"./index-COwXI8L0.js";import{F as zr,C as jr}from"./folder-C28inzgP.js";import{F as Lr}from"./file-BUN3RpOS.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as b,r as n,aB as O,aA as L,j as e,i as o,a0 as P,B as C,J as _,D,g as A,aC as F}from"./index-
|
|
1
|
+
import{c as b,r as n,aB as O,aA as L,j as e,i as o,a0 as P,B as C,J as _,D,g as A,aC as F}from"./index-COwXI8L0.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
package/dashboard/assets/{SharedConversationPage-D2ncPenP.js → SharedConversationPage-D5DMTSIy.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-
|
|
2
|
-
import{c as b,aa as j,r as s,ar as v,as as w,j as e,M as N,N as y,at as k,au as S,av as f,aw as T,_ as g}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-Csi7UE5G.js","assets/index-COwXI8L0.js","assets/index-tpSDJYRT.css","assets/folder-C28inzgP.js","assets/file-BUN3RpOS.js","assets/PreviewTab-DT95fOD3.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as b,aa as j,r as s,ar as v,as as w,j as e,M as N,N as y,at as k,au as S,av as f,aw as T,_ as g}from"./index-COwXI8L0.js";import{K as P,H as C,G as _,L as M,g as E,f as L,i as p}from"./DashboardShared-B4AJ8Ukj.js";/**
|
|
3
3
|
* @license lucide-react v1.7.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
6
6
|
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const O=[["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:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]],A=b("message-square-text",O),I=s.lazy(async()=>({default:(await g(()=>import("./FilesTab-
|
|
7
|
+
*/const O=[["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:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]],A=b("message-square-text",O),I=s.lazy(async()=>({default:(await g(()=>import("./FilesTab-Csi7UE5G.js"),__vite__mapDeps([0,1,2,3,4]))).FilesTab})),F=s.lazy(async()=>({default:(await g(()=>import("./PreviewTab-DT95fOD3.js"),__vite__mapDeps([5,1,2]))).PreviewTab})),R={getOutput:f,getOutputTree:S,getOutputContent:k},z={getOutput:f,createPreviewSession:T};function B(){const{shareId:t}=j(),[u,d]=s.useState(null),[o,r]=s.useState([]),[c,n]=s.useState(!0),[m,i]=s.useState(null),l=s.useRef(null);return s.useEffect(()=>{if(!t){d(null),r([]),i("Shared conversation not found"),n(!1);return}l.current=t,n(!0),i(null),Promise.all([v(t),w(t)]).then(([a,x])=>{l.current===t&&(d(a),r(x.logs),i(null))}).catch(a=>{l.current===t&&(d(null),r([]),i(a instanceof Error?a.message:"Failed to load shared conversation"))}).finally(()=>{l.current===t&&n(!1)})},[t]),e.jsx(D,{conversation:u,logs:o,loading:c,error:m})}function D({conversation:t,logs:u,loading:d,error:o}){const[r,c]=s.useState("transcript"),n=s.useMemo(()=>{if(!t)return null;const a=P(t.payload.initialMessage);return a.length>0?C(a,new Date(t.createdAt).toISOString()):null},[t]),m=s.useMemo(()=>_([...n?[n]:[],...u]),[n,u]),i=(t==null?void 0:t.scope)==="filesPreview",l=e.jsx("section",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain scroll-pb-16 px-4 py-5 sm:px-6",children:e.jsxs("div",{className:"mx-auto flex max-w-[72rem] flex-col gap-5 pb-16",children:[d&&e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border/60 bg-background/60 px-4 py-3 text-sm text-muted-foreground",children:[e.jsx(M,{className:"h-4 w-4 animate-spin"}),"Loading shared conversation..."]}),!d&&o&&e.jsxs("div",{className:"rounded-lg border border-destructive/20 bg-destructive/10 px-5 py-8 text-center text-destructive",children:[e.jsx("div",{className:"text-base font-semibold",children:"Shared conversation unavailable"}),e.jsx("div",{className:"mt-2 text-sm",children:o})]}),!d&&!o&&m.length===0&&e.jsxs("div",{className:"rounded-lg border border-dashed border-border/70 bg-background/35 px-5 py-8 text-center",children:[e.jsx(A,{className:"mx-auto h-6 w-6 text-muted-foreground"}),e.jsx("div",{className:"mt-3 text-sm font-medium text-foreground",children:"No transcript output yet"})]}),!d&&!o&&m.map((a,x)=>e.jsx(E,{event:a,questionResponseDisabled:!0},`shared-${x}`))]})});return e.jsxs("div",{className:"relative flex h-full min-h-0 overflow-hidden bg-background text-foreground",children:[e.jsxs("aside",{className:"hidden w-72 shrink-0 border-r border-border/60 bg-background/85 px-5 py-5 lg:block",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border border-border/70 bg-foreground text-xs font-semibold tracking-[0.24em] text-background",children:"M"}),e.jsx("div",{className:"mt-6 text-xs font-medium uppercase tracking-[0.28em] text-muted-foreground",children:"Shared conversation"}),t&&e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsx("h1",{className:"text-lg font-semibold leading-6 text-foreground",children:t.title}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(N,{status:t.status}),e.jsx(y,{priority:t.priority})]}),e.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[e.jsxs("div",{children:["updated ",L(t.updatedAt)]}),e.jsx("div",{className:"font-mono",children:t.id.slice(0,8)})]})]})]}),e.jsxs("main",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[e.jsxs("header",{className:"shrink-0 border-b border-border/60 bg-background/85 px-4 py-3 sm:px-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-md border border-border/70 bg-foreground text-xs font-semibold tracking-[0.24em] text-background lg:hidden",children:"M"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.28em] text-muted-foreground",children:"Shared conversation"}),e.jsx("div",{className:"truncate text-base font-semibold text-foreground",children:(t==null?void 0:t.title)??"Meshy"})]})]}),i&&e.jsxs("div",{className:"mt-3 inline-flex h-auto rounded-full bg-muted/70 p-1 text-muted-foreground",children:[e.jsx("button",{type:"button",onClick:()=>c("transcript"),className:h(r==="transcript"),children:"Transcript"}),e.jsx("button",{type:"button",onClick:()=>c("files"),className:h(r==="files"),children:"Files"}),e.jsx("button",{type:"button",onClick:()=>c("preview"),className:h(r==="preview"),children:"Preview"})]})]}),i&&t?e.jsxs(e.Fragment,{children:[r==="transcript"&&l,r==="files"&&e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(s.Suspense,{fallback:e.jsx(p,{label:"Loading files..."}),children:e.jsx(I,{taskId:t.shareId,api:R})})}),r==="preview"&&e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(s.Suspense,{fallback:e.jsx(p,{label:"Loading preview..."}),children:e.jsx(F,{taskId:t.shareId,api:z})})})]}):l]})]})}function h(t){return t?"inline-flex items-center justify-center whitespace-nowrap rounded-full bg-background px-3 py-1.5 text-sm font-medium text-foreground shadow-sm":"inline-flex items-center justify-center whitespace-nowrap rounded-full px-3 py-1.5 text-sm font-medium transition-colors hover:text-foreground"}export{B as SharedConversationPage,D as SharedConversationView};
|