meshy-node 0.6.8 → 0.6.10

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